public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-gbenson-stap-rtld: Only disable bp_shlib_event breakpoints
@ 2011-08-10 13:24 gary
  0 siblings, 0 replies; only message in thread
From: gary @ 2011-08-10 13:24 UTC (permalink / raw)
  To: archer-commits

The branch, archer-gbenson-stap-rtld has been updated
       via  abfd244dd7722275c858313bb41ad6716da0a588 (commit)
       via  066c7ef450d63324b7d9f22e20472fa61c964a74 (commit)
       via  e11a39444f368fca5007f808f0dfbcee50a8b23a (commit)
       via  c4fcd28d19a7bf5b01a76dee4182d00c5812aec8 (commit)
       via  25b339c623875904f5b13a23a4422ee6dd782a05 (commit)
      from  0cddb89a989ccc3fd7adff52ba83bb68b334377c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit abfd244dd7722275c858313bb41ad6716da0a588
Author: Gary Benson <gbenson@redhat.com>
Date:   Wed Aug 10 11:30:59 2011 +0100

    Only disable bp_shlib_event breakpoints

commit 066c7ef450d63324b7d9f22e20472fa61c964a74
Author: Gary Benson <gbenson@redhat.com>
Date:   Wed Aug 10 11:15:36 2011 +0100

    Use probes

commit e11a39444f368fca5007f808f0dfbcee50a8b23a
Author: Gary Benson <gbenson@redhat.com>
Date:   Wed Aug 10 10:40:30 2011 +0100

    Locate the probes

commit c4fcd28d19a7bf5b01a76dee4182d00c5812aec8
Author: Gary Benson <gbenson@redhat.com>
Date:   Mon Aug 8 15:47:14 2011 +0100

    Clear the probes list before we continue

commit 25b339c623875904f5b13a23a4422ee6dd782a05
Author: Gary Benson <gbenson@redhat.com>
Date:   Mon Aug 8 15:43:15 2011 +0100

    Define the probes we're looking for

-----------------------------------------------------------------------

Summary of changes:
 gdb/solib-svr4.c |  147 +++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 102 insertions(+), 45 deletions(-)

First 500 lines of diff:
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 8b5fe11..73cbe1c 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -94,6 +94,32 @@ static const char * const solib_break_names[] =
   NULL
 };
 
+/* A list of SystemTap probes which, if present in the dynamic linker,
+   allow more fine-grained breakpoints to be placed on shared library
+   events.  */
+
+struct probe_info
+  {
+    /* The name of the probe.  */
+    const char *name;
+
+    /* Nonzero if this probe must be stopped at even when
+       stop-on-solib-events is off.  */
+    int mandatory;
+  };
+
+static const struct probe_info probe_info[] =
+{
+  {"rtld_init_start", 0},
+  {"rtld_init_complete", 1},
+  {"rtld_map_start", 0},
+  {"rtld_reloc_complete", 1},
+  {"rtld_unmap_start", 0},
+  {"rtld_unmap_complete", 1},
+};
+
+#define NUM_PROBES (sizeof(probe_info) / sizeof(probe_info[0]))
+
 static const char * const bkpt_names[] =
 {
   "_start",
@@ -339,7 +365,10 @@ struct svr4_info
   CORE_ADDR interp_plt_sect_high;
 
   /* SystemTap probes.  */
-  VEC (stap_probe_p) *pre_mod_probes, *post_mod_probes;
+  VEC (stap_probe_p) *probes[NUM_PROBES];
+
+  /* Nonzero if we are using the SystemTap interface.  */
+  int using_probes;
 };
 
 /* Per-program-space data key.  */
@@ -349,13 +378,15 @@ static void
 svr4_pspace_data_cleanup (struct program_space *pspace, void *arg)
 {
   struct svr4_info *info;
+  int i;
 
   info = program_space_data (pspace, solib_svr4_pspace_data);
   if (info == NULL)
     return;
 
-  VEC_free (stap_probe_p, info->pre_mod_probes);
-  VEC_free (stap_probe_p, info->post_mod_probes);
+  for (i = 0; i < NUM_PROBES; i++)
+    VEC_free (stap_probe_p, info->probes[i]);
+
   xfree (info);
 }
 
@@ -1339,19 +1370,34 @@ svr4_update_solib_event_breakpoint (struct breakpoint *b, void *arg)
   struct svr4_info *info = get_svr4_info ();
   struct bp_location *loc;
 
+  if (b->type != bp_shlib_event)
+    return 0;
+
   for (loc = b->loc; loc; loc = loc->next)
     {
-      const struct stap_probe *probe;
-      int ix;
+      int i;
 
-      for (ix = 0; VEC_iterate (stap_probe_p, info->pre_mod_probes, ix, probe);
-	   ++ix)
-	if (loc->pspace == current_program_space
-	    && loc->address == probe->address)
-	  {
-	    b->enable_state = stop_on_solib_events ? bp_enabled : bp_disabled;
-	    return 1;
-	  }
+      for (i = 0; i < NUM_PROBES; i++)
+	{
+	  if (!probe_info[i].mandatory)
+	    {
+	      const struct stap_probe *probe;
+	      int ix;
+
+	      for (ix = 0;
+		   VEC_iterate (stap_probe_p, info->probes[i], ix, probe);
+		   ++ix)
+		{
+		  if (loc->pspace == current_program_space
+		      && loc->address == probe->address)
+		    {
+		      b->enable_state =
+			stop_on_solib_events ? bp_enabled : bp_disabled;
+		      return 0;
+		    }
+		}
+	    }
+	}
     }
 
   return 0;
@@ -1365,7 +1411,7 @@ svr4_update_solib_event_breakpoints (void)
 {
   struct svr4_info *info = get_svr4_info ();
 
-  if (info->pre_mod_probes)
+  if (info->using_probes)
     iterate_over_breakpoints (svr4_update_solib_event_breakpoint, NULL);
 }
 
@@ -1384,42 +1430,49 @@ svr4_update_solib_event_breakpoints (void)
 static void
 svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch, CORE_ADDR address)
 {
+  struct svr4_info *info = get_svr4_info ();
   struct obj_section *os;
 
   os = find_pc_section (address);
   if (os != NULL)
     {
-      struct svr4_info *info = get_svr4_info ();
+      int all_probes_found = 1;
+      int i;
 
-      VEC_free (stap_probe_p, info->pre_mod_probes);
-      info->pre_mod_probes = find_probes_in_objfile (os->objfile, "rtld",
-						     "r_debug_mod_starting");
+      for (i = 0; i < NUM_PROBES; i++)
+	{
+	  info->probes[i] = find_probes_in_objfile (os->objfile, "rtld",
+						    probe_info[i].name);
+
+	  if (!VEC_length(stap_probe_p, info->probes[i]))
+	    {
+	      int j;
 
-      VEC_free (stap_probe_p, info->post_mod_probes);
-      info->post_mod_probes = find_probes_in_objfile (os->objfile, "rtld",
-						      "r_debug_mod_complete");
+	      for (j = i - 1; j >= 0; j--)
+		{
+		  VEC_free (stap_probe_p, info->probes[j]);
+		  info->probes[j] = NULL;
+		}
 
-      if (info->pre_mod_probes && info->post_mod_probes)
+	      all_probes_found = 0;
+	      break;
+	    }
+	}
+
+      if (all_probes_found)
 	{
-	  const struct stap_probe *probe;
-	  int ix;
-
-	  /* The pre-modification probe is triggered before a link map
-	     is changed.  This probe isn't used internally, so we only
-	     break on it when stop-on-solib-events is on.  */
-	  for (ix = 0;
-	       VEC_iterate (stap_probe_p, info->pre_mod_probes, ix, probe);
-	       ++ix)
-	    create_solib_event_breakpoint (gdbarch, probe->address);
-
-	  /* The post-modification probe is triggered whenever a link
-	     map has been changed.  We always need to break on this
-	     one so we can track libraries being loaded and
-	     unloaded.  */
-	  for (ix = 0;
-	       VEC_iterate (stap_probe_p, info->post_mod_probes, ix, probe);
-	       ++ix)
-	    create_solib_event_breakpoint (gdbarch, probe->address);
+	  info->using_probes = 1;
+
+	  for (i = 0; i < NUM_PROBES; i++)
+	    {
+	      const struct stap_probe *probe;
+	      int ix;
+
+	      for (ix = 0;
+		   VEC_iterate (stap_probe_p, info->probes[i], ix, probe);
+		   ++ix)
+		create_solib_event_breakpoint (gdbarch, probe->address);
+	    }
 
 	  svr4_update_solib_event_breakpoints ();
 	  return;
@@ -1480,13 +1533,17 @@ enable_break (struct svr4_info *info, int from_tty)
   asection *interp_sect;
   gdb_byte *interp_name;
   CORE_ADDR sym_addr;
+  int i;
 
   info->interp_text_sect_low = info->interp_text_sect_high = 0;
   info->interp_plt_sect_low = info->interp_plt_sect_high = 0;
 
-  VEC_free (stap_probe_p, info->pre_mod_probes);
-  VEC_free (stap_probe_p, info->post_mod_probes);
-  info->pre_mod_probes = info->post_mod_probes = NULL;
+  for (i = 0; i < NUM_PROBES; i++)
+    {
+      VEC_free (stap_probe_p, info->probes[i]);
+      info->probes[i] = NULL;
+    }
+  info->using_probes = 0;
 
   /* If we already have a shared library list in the target, and
      r_debug contains r_brk, set the breakpoint there - this should


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-08-10 13:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-10 13:24 [SCM] archer-gbenson-stap-rtld: Only disable bp_shlib_event breakpoints gary

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).