X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gdb%2Fi386-linux-tdep.c;h=eeaf6211ef2f64f38c730dd66ba55bb30b68866d;hb=38334d6de448272c3bd831e3410dbc337fc2739d;hp=d02c527f35b3fbada820018805311dc45199a69e;hpb=9a3c826307ae6ad4dd6fbd72431e7d9d4947f1dd;p=external%2Fbinutils.git diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index d02c527..eeaf621 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -1,6 +1,6 @@ /* Target-dependent code for GNU/Linux i386. - Copyright (C) 2000-2015 Free Software Foundation, Inc. + Copyright (C) 2000-2016 Free Software Foundation, Inc. This file is part of GDB. @@ -30,6 +30,7 @@ #include "i386-tdep.h" #include "i386-linux-tdep.h" #include "linux-tdep.h" +#include "utils.h" #include "glibc-tdep.h" #include "solib-svr4.h" #include "symtab.h" @@ -47,6 +48,7 @@ #include "features/i386/i386-linux.c" #include "features/i386/i386-mmx-linux.c" #include "features/i386/i386-mpx-linux.c" +#include "features/i386/i386-avx-mpx-linux.c" #include "features/i386/i386-avx-linux.c" #include "features/i386/i386-avx512-linux.c" @@ -384,6 +386,72 @@ i386_canonicalize_syscall (int syscall) return gdb_sys_no_syscall; } +/* Value of the sigcode in case of a boundary fault. */ + +#define SIG_CODE_BONDARY_FAULT 3 + +/* i386 GNU/Linux implementation of the handle_segmentation_fault + gdbarch hook. Displays information related to MPX bound + violations. */ +void +i386_linux_handle_segmentation_fault (struct gdbarch *gdbarch, + struct ui_out *uiout) +{ + /* -Wmaybe-uninitialized */ + CORE_ADDR lower_bound = 0, upper_bound = 0, access = 0; + int is_upper; + long sig_code = 0; + + if (!i386_mpx_enabled ()) + return; + + TRY + { + /* Sigcode evaluates if the actual segfault is a boundary violation. */ + sig_code = parse_and_eval_long ("$_siginfo.si_code\n"); + + lower_bound + = parse_and_eval_long ("$_siginfo._sifields._sigfault._addr_bnd._lower"); + upper_bound + = parse_and_eval_long ("$_siginfo._sifields._sigfault._addr_bnd._upper"); + access + = parse_and_eval_long ("$_siginfo._sifields._sigfault.si_addr"); + } + CATCH (exception, RETURN_MASK_ALL) + { + return; + } + END_CATCH + + /* If this is not a boundary violation just return. */ + if (sig_code != SIG_CODE_BONDARY_FAULT) + return; + + is_upper = (access > upper_bound ? 1 : 0); + + ui_out_text (uiout, "\n"); + if (is_upper) + ui_out_field_string (uiout, "sigcode-meaning", + _("Upper bound violation")); + else + ui_out_field_string (uiout, "sigcode-meaning", + _("Lower bound violation")); + + ui_out_text (uiout, _(" while accessing address ")); + ui_out_field_fmt (uiout, "bound-access", "%s", + paddress (gdbarch, access)); + + ui_out_text (uiout, _("\nBounds: [lower = ")); + ui_out_field_fmt (uiout, "lower-bound", "%s", + paddress (gdbarch, lower_bound)); + + ui_out_text (uiout, _(", upper = ")); + ui_out_field_fmt (uiout, "upper-bound", "%s", + paddress (gdbarch, upper_bound)); + + ui_out_text (uiout, _("]")); +} + /* Parse the arguments of current system call instruction and record the values of the registers and memory that will be changed into "record_arch_list". This instruction is "int 0x80" (Linux @@ -630,6 +698,8 @@ i386_linux_core_read_description (struct gdbarch *gdbarch, return tdesc_i386_avx512_linux; case X86_XSTATE_MPX_MASK: return tdesc_i386_mpx_linux; + case X86_XSTATE_AVX_MPX_MASK: + return tdesc_i386_avx_mpx_linux; case X86_XSTATE_AVX_MASK: return tdesc_i386_avx_linux; case X86_XSTATE_SSE_MASK: @@ -656,6 +726,12 @@ i386_linux_supply_xstateregset (const struct regset *regset, i387_supply_xsave (regcache, regnum, xstateregs); } +struct type * +x86_linux_get_siginfo_type (struct gdbarch *gdbarch) +{ + return linux_get_siginfo_type_with_fields (gdbarch, LINUX_SIGINFO_FIELD_ADDR_BND); +} + /* Similar to i386_collect_fpregset, but use XSAVE extended state. */ static void @@ -806,8 +882,8 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) i386_linux_record_tdep.size_flock = 16; i386_linux_record_tdep.size_oldold_utsname = 45; i386_linux_record_tdep.size_ustat = 20; - i386_linux_record_tdep.size_old_sigaction = 140; - i386_linux_record_tdep.size_old_sigset_t = 128; + i386_linux_record_tdep.size_old_sigaction = 16; + i386_linux_record_tdep.size_old_sigset_t = 4; i386_linux_record_tdep.size_rlimit = 8; i386_linux_record_tdep.size_rusage = 72; i386_linux_record_tdep.size_timeval = 8; @@ -815,8 +891,7 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) i386_linux_record_tdep.size_old_gid_t = 2; i386_linux_record_tdep.size_old_uid_t = 2; i386_linux_record_tdep.size_fd_set = 128; - i386_linux_record_tdep.size_dirent = 268; - i386_linux_record_tdep.size_dirent64 = 276; + i386_linux_record_tdep.size_old_dirent = 268; i386_linux_record_tdep.size_statfs = 64; i386_linux_record_tdep.size_statfs64 = 84; i386_linux_record_tdep.size_sockaddr = 16; @@ -843,15 +918,15 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) i386_linux_record_tdep.size_NFS_FHSIZE = 32; i386_linux_record_tdep.size_knfsd_fh = 132; i386_linux_record_tdep.size_TASK_COMM_LEN = 16; - i386_linux_record_tdep.size_sigaction = 140; + i386_linux_record_tdep.size_sigaction = 20; i386_linux_record_tdep.size_sigset_t = 8; i386_linux_record_tdep.size_siginfo_t = 128; i386_linux_record_tdep.size_cap_user_data_t = 12; i386_linux_record_tdep.size_stack_t = 12; i386_linux_record_tdep.size_off_t = i386_linux_record_tdep.size_long; i386_linux_record_tdep.size_stat64 = 96; - i386_linux_record_tdep.size_gid_t = 2; - i386_linux_record_tdep.size_uid_t = 2; + i386_linux_record_tdep.size_gid_t = 4; + i386_linux_record_tdep.size_uid_t = 4; i386_linux_record_tdep.size_PAGE_SIZE = 4096; i386_linux_record_tdep.size_flock64 = 24; i386_linux_record_tdep.size_user_desc = 16; @@ -861,7 +936,6 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) i386_linux_record_tdep.size_itimerspec = i386_linux_record_tdep.size_timespec * 2; i386_linux_record_tdep.size_mq_attr = 32; - i386_linux_record_tdep.size_siginfo = 128; i386_linux_record_tdep.size_termios = 36; i386_linux_record_tdep.size_termios2 = 44; i386_linux_record_tdep.size_pid_t = 4; @@ -871,6 +945,7 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) i386_linux_record_tdep.size_hayes_esp_config = 12; i386_linux_record_tdep.size_size_t = 4; i386_linux_record_tdep.size_iovec = 8; + i386_linux_record_tdep.size_time_t = 4; /* These values are the second argument of system call "sys_ioctl". They are obtained from Linux Kernel source. */ @@ -995,6 +1070,10 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_I386); set_gdbarch_get_syscall_number (gdbarch, i386_linux_get_syscall_number); + + set_gdbarch_get_siginfo_type (gdbarch, x86_linux_get_siginfo_type); + set_gdbarch_handle_segmentation_fault (gdbarch, + i386_linux_handle_segmentation_fault); } /* Provide a prototype to silence -Wmissing-prototypes. */ @@ -1011,5 +1090,6 @@ _initialize_i386_linux_tdep (void) initialize_tdesc_i386_mmx_linux (); initialize_tdesc_i386_avx_linux (); initialize_tdesc_i386_mpx_linux (); + initialize_tdesc_i386_avx_mpx_linux (); initialize_tdesc_i386_avx512_linux (); }