Add bound related fields to the siginfo structure
authorWalfred Tedeschi <walfred.tedeschi@intel.com>
Tue, 2 Feb 2016 10:58:36 +0000 (11:58 +0100)
committerWalfred Tedeschi <walfred.tedeschi@intel.com>
Tue, 2 Feb 2016 10:58:36 +0000 (11:58 +0100)
Both Linux and glibc have introduced bound related fields in the
segmentation fault fields of the siginfo_t type. Add the new fields
to our x86's siginfo_t type too.

Kernel patch:
http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=ee1b58d36aa1b5a79eaba11f5c3633c88231da83

Glibc patch:
http://repo.or.cz/w/glibc.git/commit/d4358b51c26a634eb885955aea06cad26af6f696

2016-02-02  Walfred Tedeschi  <walfred.tedeschi@intel.com>

gdb/ChangeLog:

* linux-tdep.c (linux_get_siginfo_type): Add the _addr_bnd
structure to the siginfo if extra_fields contains
LINUX_SIGINFO_FIELD_ADDR_BND.

gdb/ChangeLog
gdb/linux-tdep.c

index 25f7f169b8d158affd42dd06077607ea7f8da268..56bdc79ac13e87b60b687a7a4c46e9c1f6523bca 100644 (file)
@@ -1,3 +1,9 @@
+2016-02-02  Walfred Tedeschi  <walfred.tedeschi@intel.com>
+
+       * linux-tdep.c (linux_get_siginfo_type): Add the _addr_bnd
+       structure to the siginfo if extra_fields contains
+       LINUX_SIGINFO_FIELD_ADDR_BND.
+
 2016-02-02  Walfred Tedeschi  <walfred.tedeschi@intel.com>
 
        * linux-tdep.h (linux_get_siginfo_type_with_fields): Make extern.
@@ -11,7 +17,6 @@
        (i386_linux_init_abi): Add new function at the i386 ABI
        initialization.
 
-
 2016-02-02  Walfred Tedeschi  <walfred.tedeschi@intel.com>
 
        * linux-tdep.h (linux_siginfo_extra_field_values): New enum values.
index cfbec40b0e1c9fe7fae99b2f3bd291603e2aee95..555c302bc889d41e153150c88c80fcfd92ade242 100644 (file)
@@ -250,7 +250,7 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
                                    linux_siginfo_extra_fields extra_fields)
 {
   struct linux_gdbarch_data *linux_gdbarch_data;
-  struct type *int_type, *uint_type, *long_type, *void_ptr_type;
+  struct type *int_type, *uint_type, *long_type, *void_ptr_type, *short_type;
   struct type *uid_type, *pid_type;
   struct type *sigval_type, *clock_type;
   struct type *siginfo_type, *sifields_type;
@@ -266,6 +266,8 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
                                 1, "unsigned int");
   long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
                                 0, "long");
+  short_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
+                                0, "short");
   void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
 
   /* sival_t */
@@ -341,6 +343,18 @@ linux_get_siginfo_type_with_fields (struct gdbarch *gdbarch,
   /* _sigfault */
   type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
   append_composite_type_field (type, "si_addr", void_ptr_type);
+
+  /* Additional bound fields for _sigfault in case they were requested.  */
+  if ((extra_fields & LINUX_SIGINFO_FIELD_ADDR_BND) != 0)
+    {
+      struct type *sigfault_bnd_fields;
+
+      append_composite_type_field (type, "_addr_lsb", short_type);
+      sigfault_bnd_fields = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+      append_composite_type_field (sigfault_bnd_fields, "_lower", void_ptr_type);
+      append_composite_type_field (sigfault_bnd_fields, "_upper", void_ptr_type);
+      append_composite_type_field (type, "_addr_bnd", sigfault_bnd_fields);
+    }
   append_composite_type_field (sifields_type, "_sigfault", type);
 
   /* _sigpoll */