This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Support for the $_siginfo convenience var in sparc64


Hi.

The following patch adds support for the $_siginfo convenience variable
to sparc64-*-linux-gnu targets.

It also makes the tests gdb.base/siginfo-thread.exp and
gdb.base/siginfo-obj.exp to run (and pass) on these targets.

Tested on sparc64-unknown-linux-gnu.  No visible regressions after
running the testsuite.

2013-10-22  Jose E. Marchesi  <jose.marchesi@oracle.com>
 
	* sparc64-linux-tdep.c (sparc64_linux_get_siginfo_type): New function.
        (sparc64_linux_init_abi): Hook sparc_linux_get_siginfo_type to provide
        gdbarch_get_siginfo_type.

2013-10-22  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* gdb.base/siginfo-obj.exp: Extended signal info is now supported
	in sparc64, so run the test in these targets.
	* gdb.base/siginfo-thread.exp: Likewise.

diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c
index 3f53f6c..1c4f647 100644
--- a/gdb/sparc64-linux-tdep.c
+++ b/gdb/sparc64-linux-tdep.c
@@ -232,6 +232,121 @@ sparc64_linux_get_syscall_number (struct gdbarch *gdbarch,
   return ret;
 }
 
+/* Implementation of gdbarch_get_siginfo_type as documented in
+   gdbarch.h  */
+
+static struct type *
+sparc64_linux_get_siginfo_type (struct gdbarch *gdbarch)
+{
+  struct type *int_type, *uint_type, *long_type, *void_ptr_type;
+  struct type *uid_type, *pid_type;
+  struct type *sigval_type, *clock_type;
+  struct type *siginfo_type, *sifields_type;
+  struct type *type;
+
+  int_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
+			 	0, "int");
+  uint_type = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch),
+				 1, "unsigned int");
+  long_type = arch_integer_type (gdbarch, gdbarch_long_bit (gdbarch),
+				 0, "long");
+  void_ptr_type = lookup_pointer_type (builtin_type (gdbarch)->builtin_void);
+
+  /* sival_t */
+  sigval_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
+  TYPE_NAME (sigval_type) = xstrdup ("sigval_t");
+  append_composite_type_field (sigval_type, "sival_int", int_type);
+  append_composite_type_field (sigval_type, "sival_ptr", void_ptr_type);
+
+  /* __pid_t */
+  pid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
+			TYPE_LENGTH (int_type), "__pid_t");
+  TYPE_TARGET_TYPE (pid_type) = int_type;
+  TYPE_TARGET_STUB (pid_type) = 1;
+
+  /* __uid_t */
+  uid_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
+			TYPE_LENGTH (uint_type), "__uid_t");
+  TYPE_TARGET_TYPE (uid_type) = uint_type;
+  TYPE_TARGET_STUB (uid_type) = 1;
+
+  /* __clock_t */
+  clock_type = arch_type (gdbarch, TYPE_CODE_TYPEDEF,
+			  TYPE_LENGTH (long_type), "__clock_t");
+  TYPE_TARGET_TYPE (clock_type) = long_type;
+  TYPE_TARGET_STUB (clock_type) = 1;
+
+  /* _sifields */
+  sifields_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_UNION);
+
+  {
+    const int si_max_size = 128;
+    int si_pad_size;
+    int size_of_int = gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT;
+
+    /* _pad */
+    if (gdbarch_ptr_bit (gdbarch) == 64)
+      si_pad_size = (si_max_size / size_of_int) - 4;
+    else
+      si_pad_size = (si_max_size / size_of_int) - 3;
+    append_composite_type_field (sifields_type, "_pad",
+				 init_vector_type (int_type, si_pad_size));
+  }
+
+  /* _kill */
+  type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+  append_composite_type_field (type, "si_pid", pid_type);
+  append_composite_type_field (type, "si_uid", uid_type);
+  append_composite_type_field (sifields_type, "_kill", type);
+
+  /* _timer */
+  type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+  append_composite_type_field (type, "si_tid", int_type);
+  append_composite_type_field (type, "si_overrun", int_type);
+  append_composite_type_field (type, "si_sigval", sigval_type);
+  append_composite_type_field (sifields_type, "_timer", type);
+
+  /* _rt */
+  type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+  append_composite_type_field (type, "si_pid", pid_type);
+  append_composite_type_field (type, "si_uid", uid_type);
+  append_composite_type_field (type, "si_sigval", sigval_type);
+  append_composite_type_field (sifields_type, "_rt", type);
+
+  /* _sigchld */
+  type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+  append_composite_type_field (type, "si_pid", pid_type);
+  append_composite_type_field (type, "si_uid", uid_type);
+  append_composite_type_field (type, "si_status", int_type);
+  append_composite_type_field (type, "si_utime", clock_type);
+  append_composite_type_field (type, "si_stime", clock_type);
+  append_composite_type_field (sifields_type, "_sigchld", type);
+
+  /* _sigfault */
+  type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+  append_composite_type_field (type, "si_addr", void_ptr_type);
+  append_composite_type_field (type, "si_trapno", int_type);
+  append_composite_type_field (sifields_type, "_sigfault", type);
+
+  /* _sigpoll */
+  type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+  append_composite_type_field (type, "si_band", int_type);
+  append_composite_type_field (type, "si_fd", int_type);
+  append_composite_type_field (sifields_type, "_sigpoll", type);
+
+  /* struct siginfo */
+  siginfo_type = arch_composite_type (gdbarch, NULL, TYPE_CODE_STRUCT);
+  TYPE_NAME (siginfo_type) = xstrdup ("siginfo");
+  append_composite_type_field (siginfo_type, "si_signo", int_type);
+  append_composite_type_field (siginfo_type, "si_errno", int_type);
+  append_composite_type_field (siginfo_type, "si_code", int_type);
+  append_composite_type_field_aligned (siginfo_type,
+				       "_sifields", sifields_type,
+				       TYPE_LENGTH (long_type));
+
+  return siginfo_type;
+}
+
 
 
 static void
@@ -278,6 +393,9 @@ sparc64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   set_xml_syscall_file_name (XML_SYSCALL_FILENAME_SPARC64);
   set_gdbarch_get_syscall_number (gdbarch,
                                   sparc64_linux_get_syscall_number);
+
+  set_gdbarch_get_siginfo_type (gdbarch,
+				sparc64_linux_get_siginfo_type);
 }
 
 
diff --git a/gdb/testsuite/gdb.base/siginfo-obj.exp b/gdb/testsuite/gdb.base/siginfo-obj.exp
index 6cee02e..5046892 100644
--- a/gdb/testsuite/gdb.base/siginfo-obj.exp
+++ b/gdb/testsuite/gdb.base/siginfo-obj.exp
@@ -28,7 +28,8 @@ if [target_info exists gdb,nosignals] {
 
 if { ! [istarget "i?86-*-linux*"]
      && ! [istarget "x86_64-*-linux*"]
-     && ! [istarget "arm*-*-linux*"] } {
+     && ! [istarget "arm*-*-linux*"]
+     && ! [istarget "sparc64-*-linux*"] } {
     verbose "Skipping siginfo-obj.exp because of lack of support."
     return
 }
diff --git a/gdb/testsuite/gdb.base/siginfo-thread.exp b/gdb/testsuite/gdb.base/siginfo-thread.exp
index a351802..541594b 100644
--- a/gdb/testsuite/gdb.base/siginfo-thread.exp
+++ b/gdb/testsuite/gdb.base/siginfo-thread.exp
@@ -23,7 +23,8 @@ if [target_info exists gdb,nosignals] {
 
 if { ! [istarget "i?86-*-linux*"]
      && ! [istarget "x86_64-*-linux*"]
-     && ! [istarget "arm*-*-linux*"] } {
+     && ! [istarget "arm*-*-linux*"]
+     && ! [istarget "sparc64-*-linux*"] } {
     verbose "Skipping siginfo-thread.exp because of lack of support."
     return
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]