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 6/6] Make longjmp handling use SystemTap probes


Hi,

This patch updates GDB to use SystemTap probes in the glibc longjmp
code, if available.  These probes have been submitted to glibc but
aren't on trunk and have not yet been shipped anywhere, to our
knowledge.

We are submitting this as an RFC.  We haven't yet had a chance to test
this, so we are not planning to check it in until we can.  It should fix
PR breakpoints/9270.

We did regtested this, though, so it at least does not cause problems.

Thanks,

Sergio.

---
 gdb/ChangeLog    |   10 ++++++++++
 gdb/breakpoint.c |   26 ++++++++++++++++++++++++++
 gdb/infrun.c     |   14 +++++++++++---
 3 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1b0b0d2..8b4b807 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,15 @@
 2011-04-04  Tom Tromey  <tromey@redhat.com>
 
+	PR breakpoints/9270
+	* breakpoint.c (struct breakpoint_objfile_data) <longjmp_probe>: New
+	field.
+	(create_longjmp_master_breakpoint): Prefer SystemTap probe over
+	`_Unwind_DebugHook'.
+	* infrun.c (handle_inferior_event): Handling longjmp breakpoint via
+	SystemTap probes.
+
+2011-04-04  Tom Tromey  <tromey@redhat.com>
+
 	* breakpoint.c (struct breakpoint_objfile_data) <exception_probe>: New
 	field.
 	(probe_not_found): New variable.
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 7e32276..6750400 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -2149,6 +2149,9 @@ struct breakpoint_objfile_data
   /* Minimal symbol(s) for "longjmp", "siglongjmp", etc. (if any).  */
   struct minimal_symbol *longjmp_msym[NUM_LONGJMP_NAMES];
 
+  /* SystemTap probe point for longjmp (if any).  */
+  const struct stap_probe *longjmp_probe;
+
   /* Minimal symbol for "std::terminate()" (if any).  */
   struct minimal_symbol *terminate_msym;
 
@@ -2271,6 +2274,29 @@ create_longjmp_master_breakpoint (void)
 
       bp_objfile_data = get_breakpoint_objfile_data (objfile);
 
+      if (bp_objfile_data->longjmp_probe != &probe_not_found)
+	{
+	  if (bp_objfile_data->longjmp_probe == NULL)
+	    bp_objfile_data->longjmp_probe
+	      = find_probe_in_objfile (objfile, "libc", "longjmp");
+
+	  if (bp_objfile_data->longjmp_probe)
+	    {
+	      struct breakpoint *b;
+	      struct gdbarch *gdbarch = get_objfile_arch (objfile);
+
+	      b = create_internal_breakpoint (gdbarch,
+					      bp_objfile_data->longjmp_probe->address,
+					      bp_longjmp_master);
+	      b->addr_string = xstrdup ("probe:libc:longjmp");
+	      b->enable_state = bp_disabled;
+
+	      continue;
+	    }
+	  else
+	    bp_objfile_data->longjmp_probe = &probe_not_found;
+	}
+
       for (i = 0; i < NUM_LONGJMP_NAMES; i++)
 	{
 	  struct breakpoint *b;
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 2c9cad8..b94c11a 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -4166,9 +4166,17 @@ process_event_stop_test:
 
 	if (what.is_longjmp)
 	  {
-	    if (!gdbarch_get_longjmp_target_p (gdbarch)
-		|| !gdbarch_get_longjmp_target (gdbarch,
-						frame, &jmp_buf_pc))
+	    struct value *arg_value;
+
+	    /* If we set the longjmp breakpoint via a SystemTap probe,
+	       then use it to extract the arguments.  The destination
+	       PC is the third argument to the probe.  */
+	    arg_value = stap_safe_evaluate_at_pc (frame, 2);
+	    if (arg_value)
+	      jmp_buf_pc = value_as_address (arg_value);
+	    else if (!gdbarch_get_longjmp_target_p (gdbarch)
+		     || !gdbarch_get_longjmp_target (gdbarch,
+						     frame, &jmp_buf_pc))
 	      {
 		if (debug_infrun)
 		  fprintf_unfiltered (gdb_stdlog,


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