Add a new gdbarch hook to report additional signal information.
authorJohn Baldwin <jhb@FreeBSD.org>
Wed, 22 Jul 2020 00:28:16 +0000 (17:28 -0700)
committerJohn Baldwin <jhb@FreeBSD.org>
Wed, 22 Jul 2020 00:28:16 +0000 (17:28 -0700)
This is a more general version of the existing handle_segmentation_fault
hook that is able to report information for an arbitrary signal, not
just SIGSEGV.

gdb/ChangeLog:

* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* gdbarch.sh (report_signal_info): New method.
* infrun.c (print_signal_received_reason): Invoke gdbarch
report_signal_info hook if present.

gdb/ChangeLog
gdb/gdbarch.c
gdb/gdbarch.h
gdb/gdbarch.sh
gdb/infrun.c

index 31307e6ff2b6cadffc74e5bac9d9dacd9e107c0b..afdaa749f1ef26c930a6845d199554c74485314c 100644 (file)
@@ -1,3 +1,11 @@
+2020-07-21  John Baldwin  <jhb@FreeBSD.org>
+
+       * gdbarch.c: Regenerate.
+       * gdbarch.h: Regenerate.
+       * gdbarch.sh (report_signal_info): New method.
+       * infrun.c (print_signal_received_reason): Invoke gdbarch
+       report_signal_info hook if present.
+
 2020-07-21  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * python/py-registers.c : Add 'unordered_map' include.
index 21ee840e88f83210d19b3cfedaeaa0a73e587a4c..d393e7a73450cf1de2d3426aff93dbab411193d2 100644 (file)
@@ -192,6 +192,7 @@ struct gdbarch
   gdbarch_ax_pseudo_register_collect_ftype *ax_pseudo_register_collect;
   gdbarch_ax_pseudo_register_push_stack_ftype *ax_pseudo_register_push_stack;
   gdbarch_handle_segmentation_fault_ftype *handle_segmentation_fault;
+  gdbarch_report_signal_info_ftype *report_signal_info;
   int sp_regnum;
   int pc_regnum;
   int ps_regnum;
@@ -556,6 +557,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of ax_pseudo_register_collect, has predicate.  */
   /* Skip verify of ax_pseudo_register_push_stack, has predicate.  */
   /* Skip verify of handle_segmentation_fault, has predicate.  */
+  /* Skip verify of report_signal_info, has predicate.  */
   /* Skip verify of sp_regnum, invalid_p == 0 */
   /* Skip verify of pc_regnum, invalid_p == 0 */
   /* Skip verify of ps_regnum, invalid_p == 0 */
@@ -1320,6 +1322,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
   fprintf_unfiltered (file,
                       "gdbarch_dump: remote_register_number = <%s>\n",
                       host_address_to_string (gdbarch->remote_register_number));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: gdbarch_report_signal_info_p() = %d\n",
+                      gdbarch_report_signal_info_p (gdbarch));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: report_signal_info = <%s>\n",
+                      host_address_to_string (gdbarch->report_signal_info));
   fprintf_unfiltered (file,
                       "gdbarch_dump: return_in_first_hidden_param_p = <%s>\n",
                       host_address_to_string (gdbarch->return_in_first_hidden_param_p));
@@ -2113,6 +2121,30 @@ set_gdbarch_handle_segmentation_fault (struct gdbarch *gdbarch,
   gdbarch->handle_segmentation_fault = handle_segmentation_fault;
 }
 
+int
+gdbarch_report_signal_info_p (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  return gdbarch->report_signal_info != NULL;
+}
+
+void
+gdbarch_report_signal_info (struct gdbarch *gdbarch, struct ui_out *uiout, enum gdb_signal siggnal)
+{
+  gdb_assert (gdbarch != NULL);
+  gdb_assert (gdbarch->report_signal_info != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_report_signal_info called\n");
+  gdbarch->report_signal_info (gdbarch, uiout, siggnal);
+}
+
+void
+set_gdbarch_report_signal_info (struct gdbarch *gdbarch,
+                                gdbarch_report_signal_info_ftype report_signal_info)
+{
+  gdbarch->report_signal_info = report_signal_info;
+}
+
 int
 gdbarch_sp_regnum (struct gdbarch *gdbarch)
 {
index 0940156aeb8f558fea72b231365cc84357782550..9414407b04db502923ace19c54c8c7d52e48c73f 100644 (file)
@@ -332,6 +332,16 @@ typedef void (gdbarch_handle_segmentation_fault_ftype) (struct gdbarch *gdbarch,
 extern void gdbarch_handle_segmentation_fault (struct gdbarch *gdbarch, struct ui_out *uiout);
 extern void set_gdbarch_handle_segmentation_fault (struct gdbarch *gdbarch, gdbarch_handle_segmentation_fault_ftype *handle_segmentation_fault);
 
+/* Some architectures can display additional information for specific
+   signals.
+   UIOUT is the output stream where the handler will place information. */
+
+extern int gdbarch_report_signal_info_p (struct gdbarch *gdbarch);
+
+typedef void (gdbarch_report_signal_info_ftype) (struct gdbarch *gdbarch, struct ui_out *uiout, enum gdb_signal siggnal);
+extern void gdbarch_report_signal_info (struct gdbarch *gdbarch, struct ui_out *uiout, enum gdb_signal siggnal);
+extern void set_gdbarch_report_signal_info (struct gdbarch *gdbarch, gdbarch_report_signal_info_ftype *report_signal_info);
+
 /* GDB's standard (or well known) register numbers.  These can map onto
    a real register or a pseudo (computed) register or not be defined at
    all (-1).
index 41e7b8d5cc3b0ad6302a04560d30bfb14add2eaf..1601879532fcb849909b56f431eb0a6b84859e06 100755 (executable)
@@ -420,6 +420,11 @@ M;int;ax_pseudo_register_push_stack;struct agent_expr *ax, int reg;ax, reg
 # UIOUT is the output stream where the handler will place information.
 M;void;handle_segmentation_fault;struct ui_out *uiout;uiout
 
+# Some architectures can display additional information for specific
+# signals.
+# UIOUT is the output stream where the handler will place information.
+M;void;report_signal_info;struct ui_out *uiout, enum gdb_signal siggnal;uiout, siggnal
+
 # GDB's standard (or well known) register numbers.  These can map onto
 # a real register or a pseudo (computed) register or not be defined at
 # all (-1).
index 31266109a6d33dbbb004c7582bb57752d11fd240..e58b623954d1609991524a4f61aeffead179de69 100644 (file)
@@ -8299,6 +8299,11 @@ print_signal_received_reason (struct ui_out *uiout, enum gdb_signal siggnal)
       annotate_signal_string ();
       uiout->field_string ("signal-meaning", gdb_signal_to_string (siggnal));
 
+      struct regcache *regcache = get_current_regcache ();
+      struct gdbarch *gdbarch = regcache->arch ();
+      if (gdbarch_report_signal_info_p (gdbarch))
+       gdbarch_report_signal_info (gdbarch, uiout, siggnal);
+
       if (siggnal == GDB_SIGNAL_SEGV)
        handle_segmentation_fault (uiout);