public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/4] make probes independent of the program space
@ 2013-12-03 19:47 Tom Tromey
  2013-12-03 19:47 ` [PATCH 1/4] comment fixes Tom Tromey
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Tom Tromey @ 2013-12-03 19:47 UTC (permalink / raw)
  To: gdb-patches

This patch series changes SystemTap probes to be independent of the
program space, and then to be stored in the per-BFD object.  That way,
they can be shared by all objfiles referring to a given BFD.  This
saves memory and perhaps a bit of time, in the multi-inferior case.

This is based on my similar patch series to make minimal symbols
independent of the program space:

    https://sourceware.org/ml/gdb-patches/2013-10/msg00521.html

This is part of the obj file splitting project:

    https://sourceware.org/gdb/wiki/ObjfileSplitting

I built and regtested the series on x86-64 Fedora 18.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 3/4] change probes to be program-space-independent
  2013-12-03 19:47 [PATCH 0/4] make probes independent of the program space Tom Tromey
  2013-12-03 19:47 ` [PATCH 1/4] comment fixes Tom Tromey
@ 2013-12-03 19:47 ` Tom Tromey
  2013-12-17 11:08   ` Gary Benson
  2013-12-03 19:47 ` [PATCH 2/4] remove some sym_probe_fns methods Tom Tromey
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Tom Tromey @ 2013-12-03 19:47 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes the probes to be independent of the program space.

After this, when a probe's address is needed, it is determined by
applying offsets at the point of use.

This introduces a bound_probe object, similar to bound minimal
symbols.  Objects of this type are used when it's necessary to pass a
probe and its corresponding objfile.

This removes the backlink from probe to objfile, which was primarily
used to fetch the architecture to use.

This adds a get_probe_address function which calls a probe method to
compute the probe's relocated address.  Similarly, it adds an objfile
parameter to the semaphore methods so they can do the relocation
properly as well.

2013-12-03  Tom Tromey  <tromey@redhat.com>

	* break-catch-throw.c (fetch_probe_arguments): Use bound probes.
	* breakpoint.c (create_longjmp_master_breakpoint): Use
	get_probe_address.
	(add_location_to_breakpoint, bkpt_probe_insert_location)
	(bkpt_probe_remove_location): Update.
	* breakpoint.h (struct bp_location) <probe>: Now a bound_probe.
	* elfread.c (elf_symfile_relocate_probe): Remove.
	(elf_probe_fns): Update.
	(insert_exception_resume_breakpoint): Change type of "probe"
	parameter to bound_probe.
	(check_exception_resume): Update.
	* objfiles.c (objfile_relocate1): Don't relocate probes.
	* probe.c (bound_probe_s): New typedef.
	(parse_probes): Use get_probe_address.  Set sal's objfile.
	(find_probe_by_pc): Return a bound_probe.
	(collect_probes): Return a VEC(bound_probe_s).
	(compare_probes): Update.
	(gen_ui_out_table_header_info): Change type of "probes"
	parameter.  Update.
	(info_probes_for_ops): Update.
	(get_probe_address): New function.
	(probe_safe_evaluate_at_pc): Update.
	* probe.h (struct probe_ops) <get_probe_address>: New field.
	<set_semaphore, clear_semaphore>: Add objfile parameter.
	(struct probe) <objfile>: Remove field.
	<arch>: New field.
	<address>: Update comment.
	(struct bound_probe): New.
	(find_probe_by_pc): Return a bound_probe.
	(get_probe_address): Declare.
	* solib-svr4.c (struct probe_and_action) <address>: New field.
	(hash_probe_and_action, equal_probe_and_action): Update.
	(register_solib_event_probe): Add address parameter.
	(solib_event_probe_at): Update.
	(svr4_create_probe_breakpoints): Add objfile parameter.  Use
	get_probe_address.
	* stap-probe.c (struct stap_probe) <sem_addr>: Update comment.
	(stap_parse_probe_arguments): Update.
	(stap_get_probe_address): New function.
	(stap_can_evaluate_probe_arguments, compute_probe_arg)
	(compile_probe_arg): Update.
	(stap_set_semaphore, stap_clear_semaphore): Compute semaphore's
	address.
	(handle_stap_probe): Don't relocate the probe.
	(stap_relocate): Remove.
	(stap_gen_info_probes_table_values): Update.
	(stap_probe_ops): Remove stap_relocate.
	* symfile-debug.c (debug_sym_relocate_probe): Remove.
	(debug_sym_probe_fns): Update.
	* symfile.h (struct sym_probe_fns) <sym_relocate_probe>: Remove.
	* symtab.c (init_sal): Use memset.
	* symtab.h (struct symtab_and_line) <objfile>: New field.
	* tracepoint.c (start_tracing, stop_tracing): Update.
---
 gdb/ChangeLog           |  56 ++++++++++++++++++++++++
 gdb/break-catch-throw.c |  18 ++++----
 gdb/breakpoint.c        |  19 +++++---
 gdb/breakpoint.h        |   3 +-
 gdb/elfread.c           |  16 -------
 gdb/infrun.c            |   8 ++--
 gdb/objfiles.c          |   5 ---
 gdb/probe.c             | 114 +++++++++++++++++++++++++++++-------------------
 gdb/probe.h             |  49 ++++++++++++++++-----
 gdb/solib-svr4.c        |  27 +++++++-----
 gdb/stap-probe.c        |  73 ++++++++++++++++---------------
 gdb/symfile-debug.c     |  19 --------
 gdb/symfile.h           |   5 ---
 gdb/symtab.c            |  10 +----
 gdb/symtab.h            |   3 ++
 gdb/tracepoint.c        |  12 +++--
 16 files changed, 258 insertions(+), 179 deletions(-)

diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index 76087d3..9de44d4 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -106,25 +106,25 @@ fetch_probe_arguments (struct value **arg0, struct value **arg1)
 {
   struct frame_info *frame = get_selected_frame (_("No frame selected"));
   CORE_ADDR pc = get_frame_pc (frame);
-  struct probe *pc_probe;
+  struct bound_probe pc_probe;
   const struct sym_probe_fns *pc_probe_fns;
   unsigned n_args;
 
   pc_probe = find_probe_by_pc (pc);
-  if (pc_probe == NULL
-      || strcmp (pc_probe->provider, "libstdcxx") != 0
-      || (strcmp (pc_probe->name, "catch") != 0
-	  && strcmp (pc_probe->name, "throw") != 0
-	  && strcmp (pc_probe->name, "rethrow") != 0))
+  if (pc_probe.probe == NULL
+      || strcmp (pc_probe.probe->provider, "libstdcxx") != 0
+      || (strcmp (pc_probe.probe->name, "catch") != 0
+	  && strcmp (pc_probe.probe->name, "throw") != 0
+	  && strcmp (pc_probe.probe->name, "rethrow") != 0))
     error (_("not stopped at a C++ exception catchpoint"));
 
-  n_args = get_probe_argument_count (pc_probe);
+  n_args = get_probe_argument_count (pc_probe.probe);
   if (n_args < 2)
     error (_("C++ exception catchpoint has too few arguments"));
 
   if (arg0 != NULL)
-    *arg0 = evaluate_probe_argument (pc_probe, 0);
-  *arg1 = evaluate_probe_argument (pc_probe, 1);
+    *arg0 = evaluate_probe_argument (pc_probe.probe, 0);
+  *arg1 = evaluate_probe_argument (pc_probe.probe, 1);
 
   if ((arg0 != NULL && *arg0 == NULL) || *arg1 == NULL)
     error (_("error computing probe argument at c++ exception catchpoint"));
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 57c64d8..3ead7cc 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -3271,7 +3271,9 @@ create_longjmp_master_breakpoint (void)
 	    {
 	      struct breakpoint *b;
 
-	      b = create_internal_breakpoint (gdbarch, probe->address,
+	      b = create_internal_breakpoint (gdbarch,
+					      get_probe_address (probe,
+								 objfile),
 					      bp_longjmp_master,
 					      &internal_breakpoint_ops);
 	      b->addr_string = xstrdup ("-probe-stap libc:longjmp");
@@ -3432,7 +3434,9 @@ create_exception_master_breakpoint (void)
 	    {
 	      struct breakpoint *b;
 
-	      b = create_internal_breakpoint (gdbarch, probe->address,
+	      b = create_internal_breakpoint (gdbarch,
+					      get_probe_address (probe,
+								 objfile),
 					      bp_exception_master,
 					      &internal_breakpoint_ops);
 	      b->addr_string = xstrdup ("-probe-stap libgcc:unwind");
@@ -8970,7 +8974,8 @@ add_location_to_breakpoint (struct breakpoint *b,
   loc->requested_address = sal->pc;
   loc->address = adjusted_address;
   loc->pspace = sal->pspace;
-  loc->probe = sal->probe;
+  loc->probe.probe = sal->probe;
+  loc->probe.objfile = sal->objfile;
   gdb_assert (loc->pspace != NULL);
   loc->section = sal->section;
   loc->gdbarch = loc_gdbarch;
@@ -13287,7 +13292,9 @@ bkpt_probe_insert_location (struct bp_location *bl)
     {
       /* The insertion was successful, now let's set the probe's semaphore
 	 if needed.  */
-      bl->probe->pops->set_semaphore (bl->probe, bl->gdbarch);
+      bl->probe.probe->pops->set_semaphore (bl->probe.probe,
+					    bl->probe.objfile,
+					    bl->gdbarch);
     }
 
   return v;
@@ -13297,7 +13304,9 @@ static int
 bkpt_probe_remove_location (struct bp_location *bl)
 {
   /* Let's clear the semaphore before removing the location.  */
-  bl->probe->pops->clear_semaphore (bl->probe, bl->gdbarch);
+  bl->probe.probe->pops->clear_semaphore (bl->probe.probe,
+					  bl->probe.objfile,
+					  bl->gdbarch);
 
   return bkpt_remove_location (bl);
 }
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index be0658f..76cac9c 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -25,6 +25,7 @@
 #include "ax.h"
 #include "command.h"
 #include "break-common.h"
+#include "probe.h"
 
 struct value;
 struct block;
@@ -436,7 +437,7 @@ struct bp_location
 
   /* If the location comes from a probe point, this is the probe associated
      with it.  */
-  struct probe *probe;
+  struct bound_probe probe;
 
   char *function_name;
 
diff --git a/gdb/elfread.c b/gdb/elfread.c
index c347230..dedecf2 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1516,21 +1516,6 @@ elf_get_probes (struct objfile *objfile)
   return probes_per_objfile;
 }
 
-/* Implementation of `sym_relocate_probe', as documented in symfile.h.  */
-
-static void
-elf_symfile_relocate_probe (struct objfile *objfile,
-			    const struct section_offsets *new_offsets,
-			    const struct section_offsets *delta)
-{
-  int ix;
-  VEC (probe_p) *probes = objfile_data (objfile, probe_key);
-  struct probe *probe;
-
-  for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++)
-    probe->pops->relocate (probe, ANOFFSET (delta, SECT_OFF_TEXT (objfile)));
-}
-
 /* Helper function used to free the space allocated for storing SystemTap
    probe information.  */
 
@@ -1554,7 +1539,6 @@ probe_key_free (struct objfile *objfile, void *d)
 static const struct sym_probe_fns elf_probe_fns =
 {
   elf_get_probes,		    /* sym_get_probes */
-  elf_symfile_relocate_probe,	    /* sym_relocate_probe */
 };
 
 /* Register that we are able to handle ELF object file formats.  */
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 3b55583..d79db0a 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -5620,7 +5620,7 @@ insert_exception_resume_breakpoint (struct thread_info *tp,
 
 static void
 insert_exception_resume_from_probe (struct thread_info *tp,
-				    const struct probe *probe,
+				    const struct bound_probe *probe,
 				    struct frame_info *frame)
 {
   struct value *arg_value;
@@ -5654,7 +5654,7 @@ check_exception_resume (struct execution_control_state *ecs,
 			struct frame_info *frame)
 {
   volatile struct gdb_exception e;
-  const struct probe *probe;
+  struct bound_probe probe;
   struct symbol *func;
 
   /* First see if this exception unwinding breakpoint was set via a
@@ -5662,9 +5662,9 @@ check_exception_resume (struct execution_control_state *ecs,
      CFA and the HANDLER.  We ignore the CFA, extract the handler, and
      set a breakpoint there.  */
   probe = find_probe_by_pc (get_frame_pc (frame));
-  if (probe)
+  if (probe.probe)
     {
-      insert_exception_resume_from_probe (ecs->event_thread, probe, frame);
+      insert_exception_resume_from_probe (ecs->event_thread, &probe, frame);
       return;
     }
 
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index ddc4d64..3c2cc77 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -853,11 +853,6 @@ objfile_relocate1 (struct objfile *objfile,
 				obj_section_addr (s));
     }
 
-  /* Relocating probes.  */
-  if (objfile->sf && objfile->sf->sym_probe_fns)
-    objfile->sf->sym_probe_fns->sym_relocate_probe (objfile,
-						    new_offsets, delta);
-
   /* Data changed.  */
   return 1;
 }
diff --git a/gdb/probe.c b/gdb/probe.c
index c1e0111..851b547 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -33,6 +33,9 @@
 #include "arch-utils.h"
 #include <ctype.h>
 
+typedef struct bound_probe bound_probe_s;
+DEF_VEC_O (bound_probe_s);
+
 \f
 
 /* See definition in probe.h.  */
@@ -144,11 +147,12 @@ parse_probes (char **argptr, struct linespec_result *canonical)
 
 	    init_sal (sal);
 
-	    sal->pc = probe->address;
+	    sal->pc = get_probe_address (probe, objfile);
 	    sal->explicit_pc = 1;
 	    sal->section = find_pc_overlay (sal->pc);
 	    sal->pspace = pspace;
 	    sal->probe = probe;
+	    sal->objfile = objfile;
 	  }
       }
 
@@ -204,10 +208,14 @@ find_probes_in_objfile (struct objfile *objfile, const char *provider,
 
 /* See definition in probe.h.  */
 
-struct probe *
+struct bound_probe
 find_probe_by_pc (CORE_ADDR pc)
 {
   struct objfile *objfile;
+  struct bound_probe result;
+
+  result.objfile = NULL;
+  result.probe = NULL;
 
   ALL_OBJFILES (objfile)
   {
@@ -215,17 +223,22 @@ find_probe_by_pc (CORE_ADDR pc)
     int ix;
     struct probe *probe;
 
-    if (!objfile->sf || !objfile->sf->sym_probe_fns)
+    if (!objfile->sf || !objfile->sf->sym_probe_fns
+	|| objfile->sect_index_text == -1)
       continue;
 
     /* If this proves too inefficient, we can replace with a hash.  */
     probes = objfile->sf->sym_probe_fns->sym_get_probes (objfile);
     for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++)
-      if (probe->address == pc)
-	return probe;
+      if (get_probe_address (probe, objfile) == pc)
+	{
+	  result.objfile = objfile;
+	  result.probe = probe;
+	  return result;
+	}
   }
 
-  return NULL;
+  return result;
 }
 
 \f
@@ -234,16 +247,16 @@ find_probe_by_pc (CORE_ADDR pc)
    If POPS is not NULL, only probes of this certain probe_ops will match.
    Each argument is a regexp, or NULL, which matches anything.  */
 
-static VEC (probe_p) *
+static VEC (bound_probe_s) *
 collect_probes (char *objname, char *provider, char *probe_name,
 		const struct probe_ops *pops)
 {
   struct objfile *objfile;
-  VEC (probe_p) *result = NULL;
+  VEC (bound_probe_s) *result = NULL;
   struct cleanup *cleanup, *cleanup_temps;
   regex_t obj_pat, prov_pat, probe_pat;
 
-  cleanup = make_cleanup (VEC_cleanup (probe_p), &result);
+  cleanup = make_cleanup (VEC_cleanup (bound_probe_s), &result);
 
   cleanup_temps = make_cleanup (null_cleanup, NULL);
   if (provider != NULL)
@@ -272,6 +285,8 @@ collect_probes (char *objname, char *provider, char *probe_name,
 
       for (ix = 0; VEC_iterate (probe_p, probes, ix, probe); ix++)
 	{
+	  struct bound_probe bound;
+
 	  if (pops != NULL && probe->pops != pops)
 	    continue;
 
@@ -283,7 +298,9 @@ collect_probes (char *objname, char *provider, char *probe_name,
 	      && regexec (&probe_pat, probe->name, 0, NULL, 0) != 0)
 	    continue;
 
-	  VEC_safe_push (probe_p, result, probe);
+	  bound.objfile = objfile;
+	  bound.probe = probe;
+	  VEC_safe_push (bound_probe_s, result, &bound);
 	}
     }
 
@@ -292,26 +309,26 @@ collect_probes (char *objname, char *provider, char *probe_name,
   return result;
 }
 
-/* A qsort comparison function for probe_p objects.  */
+/* A qsort comparison function for bound_probe_s objects.  */
 
 static int
 compare_probes (const void *a, const void *b)
 {
-  const struct probe *pa = *((const struct probe **) a);
-  const struct probe *pb = *((const struct probe **) b);
+  const struct bound_probe *pa = (const struct bound_probe *) a;
+  const struct bound_probe *pb = (const struct bound_probe *) b;
   int v;
 
-  v = strcmp (pa->provider, pb->provider);
+  v = strcmp (pa->probe->provider, pb->probe->provider);
   if (v)
     return v;
 
-  v = strcmp (pa->name, pb->name);
+  v = strcmp (pa->probe->name, pb->probe->name);
   if (v)
     return v;
 
-  if (pa->address < pb->address)
+  if (pa->probe->address < pb->probe->address)
     return -1;
-  if (pa->address > pb->address)
+  if (pa->probe->address > pb->probe->address)
     return 1;
 
   return strcmp (objfile_name (pa->objfile), objfile_name (pb->objfile));
@@ -321,7 +338,7 @@ compare_probes (const void *a, const void *b)
    crafted by `info_probes_for_ops'.  */
 
 static void
-gen_ui_out_table_header_info (VEC (probe_p) *probes,
+gen_ui_out_table_header_info (VEC (bound_probe_s) *probes,
 			      const struct probe_ops *p)
 {
   /* `headings' refers to the names of the columns when printing `info
@@ -350,11 +367,11 @@ gen_ui_out_table_header_info (VEC (probe_p) *probes,
        VEC_iterate (info_probe_column_s, headings, ix, column);
        ++ix)
     {
-      struct probe *probe;
+      struct bound_probe *probe;
       int jx;
       size_t size_max = strlen (column->print_name);
 
-      for (jx = 0; VEC_iterate (probe_p, probes, jx, probe); ++jx)
+      for (jx = 0; VEC_iterate (bound_probe_s, probes, jx, probe); ++jx)
 	{
 	  /* `probe_fields' refers to the values of each new field that this
 	     probe will display.  */
@@ -363,11 +380,11 @@ gen_ui_out_table_header_info (VEC (probe_p) *probes,
 	  const char *val;
 	  int kx;
 
-	  if (probe->pops != p)
+	  if (probe->probe->pops != p)
 	    continue;
 
 	  c2 = make_cleanup (VEC_cleanup (const_char_ptr), &probe_fields);
-	  p->gen_info_probes_table_values (probe, &probe_fields);
+	  p->gen_info_probes_table_values (probe->probe, &probe_fields);
 
 	  gdb_assert (VEC_length (const_char_ptr, probe_fields)
 		      == headings_size);
@@ -472,14 +489,14 @@ info_probes_for_ops (char *arg, int from_tty, const struct probe_ops *pops)
 {
   char *provider, *probe_name = NULL, *objname = NULL;
   struct cleanup *cleanup = make_cleanup (null_cleanup, NULL);
-  VEC (probe_p) *probes;
+  VEC (bound_probe_s) *probes;
   int i, any_found;
   int ui_out_extra_fields = 0;
   size_t size_addr;
   size_t size_name = strlen ("Name");
   size_t size_objname = strlen ("Object");
   size_t size_provider = strlen ("Provider");
-  struct probe *probe;
+  struct bound_probe *probe;
   struct gdbarch *gdbarch = get_current_arch ();
 
   /* Do we have a `provider:probe:objfile' style of linespec?  */
@@ -523,22 +540,23 @@ info_probes_for_ops (char *arg, int from_tty, const struct probe_ops *pops)
   make_cleanup (VEC_cleanup (probe_p), &probes);
   make_cleanup_ui_out_table_begin_end (current_uiout,
 				       4 + ui_out_extra_fields,
-				       VEC_length (probe_p, probes),
+				       VEC_length (bound_probe_s, probes),
 				       "StaticProbes");
 
-  if (!VEC_empty (probe_p, probes))
-    qsort (VEC_address (probe_p, probes), VEC_length (probe_p, probes),
-	   sizeof (probe_p), compare_probes);
+  if (!VEC_empty (bound_probe_s, probes))
+    qsort (VEC_address (bound_probe_s, probes),
+	   VEC_length (bound_probe_s, probes),
+	   sizeof (bound_probe_s), compare_probes);
 
   /* What's the size of an address in our architecture?  */
   size_addr = gdbarch_addr_bit (gdbarch) == 64 ? 18 : 10;
 
   /* Determining the maximum size of each field (`provider', `name' and
      `objname').  */
-  for (i = 0; VEC_iterate (probe_p, probes, i, probe); ++i)
+  for (i = 0; VEC_iterate (bound_probe_s, probes, i, probe); ++i)
     {
-      size_name = max (strlen (probe->name), size_name);
-      size_provider = max (strlen (probe->provider), size_provider);
+      size_name = max (strlen (probe->probe->name), size_name);
+      size_provider = max (strlen (probe->probe->provider), size_provider);
       size_objname = max (strlen (objfile_name (probe->objfile)), size_objname);
     }
 
@@ -564,17 +582,17 @@ info_probes_for_ops (char *arg, int from_tty, const struct probe_ops *pops)
 		       _("Object"));
   ui_out_table_body (current_uiout);
 
-  for (i = 0; VEC_iterate (probe_p, probes, i, probe); ++i)
+  for (i = 0; VEC_iterate (bound_probe_s, probes, i, probe); ++i)
     {
       struct cleanup *inner;
 
       inner = make_cleanup_ui_out_tuple_begin_end (current_uiout, "probe");
 
-      ui_out_field_string (current_uiout, "provider", probe->provider);
-      ui_out_field_string (current_uiout, "name", probe->name);
+      ui_out_field_string (current_uiout, "provider", probe->probe->provider);
+      ui_out_field_string (current_uiout, "name", probe->probe->name);
       ui_out_field_core_addr (current_uiout, "addr",
-			      get_objfile_arch (probe->objfile),
-			      probe->address);
+			      probe->probe->arch,
+			      get_probe_address (probe->probe, probe->objfile));
 
       if (pops == NULL)
 	{
@@ -583,11 +601,11 @@ info_probes_for_ops (char *arg, int from_tty, const struct probe_ops *pops)
 
 	  for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, po);
 	       ++ix)
-	    if (probe->pops == po)
-	      print_ui_out_info (probe);
+	    if (probe->probe->pops == po)
+	      print_ui_out_info (probe->probe);
 	}
       else
-	print_ui_out_info (probe);
+	print_ui_out_info (probe->probe);
 
       ui_out_field_string (current_uiout, "object",
 			   objfile_name (probe->objfile));
@@ -596,7 +614,7 @@ info_probes_for_ops (char *arg, int from_tty, const struct probe_ops *pops)
       do_cleanups (inner);
     }
 
-  any_found = !VEC_empty (probe_p, probes);
+  any_found = !VEC_empty (bound_probe_s, probes);
   do_cleanups (cleanup);
 
   if (!any_found)
@@ -613,6 +631,14 @@ info_probes_command (char *arg, int from_tty)
 
 /* See comments in probe.h.  */
 
+CORE_ADDR
+get_probe_address (struct probe *probe, struct objfile *objfile)
+{
+  return probe->pops->get_probe_address (probe, objfile);
+}
+
+/* See comments in probe.h.  */
+
 unsigned
 get_probe_argument_count (struct probe *probe)
 {
@@ -640,18 +666,18 @@ evaluate_probe_argument (struct probe *probe, unsigned n)
 struct value *
 probe_safe_evaluate_at_pc (struct frame_info *frame, unsigned n)
 {
-  struct probe *probe;
+  struct bound_probe probe;
   unsigned n_args;
 
   probe = find_probe_by_pc (get_frame_pc (frame));
-  if (!probe)
+  if (!probe.probe)
     return NULL;
 
-  n_args = get_probe_argument_count (probe);
+  n_args = get_probe_argument_count (probe.probe);
   if (n >= n_args)
     return NULL;
 
-  return evaluate_probe_argument (probe, n);
+  return evaluate_probe_argument (probe.probe, n);
 }
 
 /* See comment in probe.h.  */
diff --git a/gdb/probe.h b/gdb/probe.h
index d116274..9fb9aaf 100644
--- a/gdb/probe.h
+++ b/gdb/probe.h
@@ -64,10 +64,11 @@ struct probe_ops
 
     void (*get_probes) (VEC (probe_p) **probes, struct objfile *objfile);
 
-    /* Function used to relocate addresses from PROBE according to some DELTA
-       provided.  */
+    /* Compute the probe's relocated address.  OBJFILE is the objfile
+       in which the probe originated.  */
 
-    void (*relocate) (struct probe *probe, CORE_ADDR delta);
+    CORE_ADDR (*get_probe_address) (struct probe *probe,
+				    struct objfile *objfile);
 
     /* Return the number of arguments of PROBE.  */
 
@@ -95,13 +96,15 @@ struct probe_ops
        sense if the probe has a concept of semaphore associated to a
        probe.  */
 
-    void (*set_semaphore) (struct probe *probe, struct gdbarch *gdbarch);
+    void (*set_semaphore) (struct probe *probe, struct objfile *objfile,
+			   struct gdbarch *gdbarch);
 
     /* Clear the semaphore associated with the PROBE.  This function only
        makes sense if the probe has a concept of semaphore associated to
        a probe.  */
 
-    void (*clear_semaphore) (struct probe *probe, struct gdbarch *gdbarch);
+    void (*clear_semaphore) (struct probe *probe, struct objfile *objfile,
+			     struct gdbarch *gdbarch);
 
     /* Function called to destroy PROBE's specific data.  This function
        shall not free PROBE itself.  */
@@ -164,10 +167,8 @@ struct probe
     /* The operations associated with this probe.  */
     const struct probe_ops *pops;
 
-    /* The objfile which contains this probe.  Even if the probe is also
-       present in a separate debug objfile, this variable always points to
-       the non-separate debug objfile.  */
-    struct objfile *objfile;
+    /* The probe's architecture.  */
+    struct gdbarch *arch;
 
     /* The name of the probe.  */
     const char *name;
@@ -176,10 +177,27 @@ struct probe
        the objfile which contains the probe.  */
     const char *provider;
 
-    /* The address where the probe is inserted.  */
+    /* The address where the probe is inserted, relative to
+       SECT_OFF_TEXT.  */
     CORE_ADDR address;
   };
 
+/* A bound probe holds a pointer to a probe and a pointer to the
+   probe's defining objfile.  This is needed because probes are
+   independent of the program space and thus require relocation at
+   their point of use.  */
+
+struct bound_probe
+  {
+    /* The probe.  */
+
+    struct probe *probe;
+
+    /* The objfile in which the probe originated.  */
+
+    struct objfile *objfile;
+  };
+
 /* A helper for linespec that decodes a probe specification.  It returns a
    symtabs_and_lines object and updates *ARGPTR or throws an error.  */
 
@@ -192,9 +210,10 @@ extern struct symtabs_and_lines parse_probes (char **argptr,
 extern void register_probe_ops (struct probe *probe);
 
 /* Given a PC, find an associated probe.  If a probe is found, return
-   it.  If no probe is found, return NULL.  */
+   it.  If no probe is found, return a bound probe whose fields are
+   both NULL.  */
 
-extern struct probe *find_probe_by_pc (CORE_ADDR pc);
+extern struct bound_probe find_probe_by_pc (CORE_ADDR pc);
 
 /* Search OBJFILE for a probe with the given PROVIDER, NAME.  Return a
    VEC of all probes that were found.  If no matching probe is found,
@@ -219,6 +238,12 @@ extern void info_probes_for_ops (char *arg, int from_tty,
 
 extern struct cmd_list_element **info_probes_cmdlist_get (void);
 
+/* Compute the probe's relocated address.  OBJFILE is the objfile in
+   which the probe originated.  */
+
+extern CORE_ADDR get_probe_address (struct probe *probe,
+				    struct objfile *objfile);
+
 /* Return the argument count of the specified probe.  */
 
 extern unsigned get_probe_argument_count (struct probe *probe);
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index eac8793..fea2b24 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1569,6 +1569,9 @@ struct probe_and_action
   /* The probe.  */
   struct probe *probe;
 
+  /* The relocated address of the probe.  */
+  CORE_ADDR address;
+
   /* The action.  */
   enum probe_action action;
 };
@@ -1580,7 +1583,7 @@ hash_probe_and_action (const void *p)
 {
   const struct probe_and_action *pa = p;
 
-  return (hashval_t) pa->probe->address;
+  return (hashval_t) pa->address;
 }
 
 /* Returns non-zero if the probe_and_actions referenced by p1 and p2
@@ -1592,14 +1595,15 @@ equal_probe_and_action (const void *p1, const void *p2)
   const struct probe_and_action *pa1 = p1;
   const struct probe_and_action *pa2 = p2;
 
-  return pa1->probe->address == pa2->probe->address;
+  return pa1->address == pa2->address;
 }
 
 /* Register a solib event probe and its associated action in the
    probes table.  */
 
 static void
-register_solib_event_probe (struct probe *probe, enum probe_action action)
+register_solib_event_probe (struct probe *probe, CORE_ADDR address,
+			    enum probe_action action)
 {
   struct svr4_info *info = get_svr4_info ();
   struct probe_and_action lookup, *pa;
@@ -1612,11 +1616,13 @@ register_solib_event_probe (struct probe *probe, enum probe_action action)
 					    xfree, xcalloc, xfree);
 
   lookup.probe = probe;
+  lookup.address = address;
   slot = htab_find_slot (info->probes_table, &lookup, INSERT);
   gdb_assert (*slot == HTAB_EMPTY_ENTRY);
 
   pa = XCNEW (struct probe_and_action);
   pa->probe = probe;
+  pa->address = address;
   pa->action = action;
 
   *slot = pa;
@@ -1629,12 +1635,10 @@ register_solib_event_probe (struct probe *probe, enum probe_action action)
 static struct probe_and_action *
 solib_event_probe_at (struct svr4_info *info, CORE_ADDR address)
 {
-  struct probe lookup_probe;
   struct probe_and_action lookup;
   void **slot;
 
-  lookup_probe.address = address;
-  lookup.probe = &lookup_probe;
+  lookup.address = address;
   slot = htab_find_slot (info->probes_table, &lookup, NO_INSERT);
 
   if (slot == NULL)
@@ -1933,7 +1937,8 @@ svr4_update_solib_event_breakpoints (void)
 
 static void
 svr4_create_probe_breakpoints (struct gdbarch *gdbarch,
-			       VEC (probe_p) **probes)
+			       VEC (probe_p) **probes,
+			       struct objfile *objfile)
 {
   int i;
 
@@ -1947,8 +1952,10 @@ svr4_create_probe_breakpoints (struct gdbarch *gdbarch,
 	   VEC_iterate (probe_p, probes[i], ix, probe);
 	   ++ix)
 	{
-	  create_solib_event_breakpoint (gdbarch, probe->address);
-	  register_solib_event_probe (probe, action);
+	  CORE_ADDR address = get_probe_address (probe, objfile);
+
+	  create_solib_event_breakpoint (gdbarch, address);
+	  register_solib_event_probe (probe, address, action);
 	}
     }
 
@@ -2033,7 +2040,7 @@ svr4_create_solib_event_breakpoints (struct gdbarch *gdbarch,
 	    }
 
 	  if (all_probes_found)
-	    svr4_create_probe_breakpoints (gdbarch, probes);
+	    svr4_create_probe_breakpoints (gdbarch, probes, os->objfile);
 
 	  for (i = 0; i < NUM_PROBES; i++)
 	    VEC_free (probe_p, probes[i]);
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index e09d5d6..7f2d45d 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -99,7 +99,7 @@ struct stap_probe
   struct probe p;
 
   /* If the probe has a semaphore associated, then this is the value of
-     it.  */
+     it, relative to SECT_OFF_DATA.  */
   CORE_ADDR sem_addr;
 
   unsigned int args_parsed : 1;
@@ -917,7 +917,7 @@ static void
 stap_parse_probe_arguments (struct stap_probe *probe)
 {
   const char *cur;
-  struct gdbarch *gdbarch = get_objfile_arch (probe->p.objfile);
+  struct gdbarch *gdbarch = probe->p.arch;
 
   gdb_assert (!probe->args_parsed);
   cur = probe->args_u.text;
@@ -998,6 +998,15 @@ stap_parse_probe_arguments (struct stap_probe *probe)
     }
 }
 
+/* Implementation of the get_probe_address method.  */
+
+static CORE_ADDR
+stap_get_probe_address (struct probe *probe, struct objfile *objfile)
+{
+  return probe->address + ANOFFSET (objfile->section_offsets,
+				    SECT_OFF_DATA (objfile));
+}
+
 /* Given PROBE, returns the number of arguments present in that probe's
    argument string.  */
 
@@ -1086,7 +1095,7 @@ static int
 stap_can_evaluate_probe_arguments (struct probe *probe_generic)
 {
   struct stap_probe *stap_probe = (struct stap_probe *) probe_generic;
-  struct gdbarch *gdbarch = get_objfile_arch (stap_probe->p.objfile);
+  struct gdbarch *gdbarch = stap_probe->p.arch;
 
   /* For SystemTap probes, we have to guarantee that the method
      stap_is_single_operand is defined on gdbarch.  If it is not, then it
@@ -1166,7 +1175,7 @@ compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar,
   struct frame_info *frame = get_selected_frame (_("No frame selected"));
   CORE_ADDR pc = get_frame_pc (frame);
   int sel = (int) (uintptr_t) data;
-  struct probe *pc_probe;
+  struct bound_probe pc_probe;
   const struct sym_probe_fns *pc_probe_fns;
   unsigned n_args;
 
@@ -1174,10 +1183,10 @@ compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar,
   gdb_assert (sel >= -1);
 
   pc_probe = find_probe_by_pc (pc);
-  if (pc_probe == NULL)
+  if (pc_probe.probe == NULL)
     error (_("No SystemTap probe at PC %s"), core_addr_to_string (pc));
 
-  n_args = get_probe_argument_count (pc_probe);
+  n_args = get_probe_argument_count (pc_probe.probe);
   if (sel == -1)
     return value_from_longest (builtin_type (arch)->builtin_int, n_args);
 
@@ -1185,7 +1194,7 @@ compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar,
     error (_("Invalid probe argument %d -- probe has %u arguments available"),
 	   sel, n_args);
 
-  return evaluate_probe_argument (pc_probe, sel);
+  return evaluate_probe_argument (pc_probe.probe, sel);
 }
 
 /* This is called to compile one of the $_probe_arg* convenience
@@ -1197,7 +1206,7 @@ compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr,
 {
   CORE_ADDR pc = expr->scope;
   int sel = (int) (uintptr_t) data;
-  struct probe *pc_probe;
+  struct bound_probe pc_probe;
   const struct sym_probe_fns *pc_probe_fns;
   int n_args;
 
@@ -1205,10 +1214,10 @@ compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr,
   gdb_assert (sel >= -1);
 
   pc_probe = find_probe_by_pc (pc);
-  if (pc_probe == NULL)
+  if (pc_probe.probe == NULL)
     error (_("No SystemTap probe at PC %s"), core_addr_to_string (pc));
 
-  n_args = get_probe_argument_count (pc_probe);
+  n_args = get_probe_argument_count (pc_probe.probe);
 
   if (sel == -1)
     {
@@ -1223,7 +1232,7 @@ compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr,
     error (_("Invalid probe argument %d -- probe has %d arguments available"),
 	   sel, n_args);
 
-  pc_probe->pops->compile_to_ax (pc_probe, expr, value, sel);
+  pc_probe.probe->pops->compile_to_ax (pc_probe.probe, expr, value, sel);
 }
 
 \f
@@ -1275,25 +1284,33 @@ stap_modify_semaphore (CORE_ADDR address, int set, struct gdbarch *gdbarch)
    the probes, but that is too rare to care.  */
 
 static void
-stap_set_semaphore (struct probe *probe_generic, struct gdbarch *gdbarch)
+stap_set_semaphore (struct probe *probe_generic, struct objfile *objfile,
+		    struct gdbarch *gdbarch)
 {
   struct stap_probe *probe = (struct stap_probe *) probe_generic;
+  CORE_ADDR addr;
 
   gdb_assert (probe_generic->pops == &stap_probe_ops);
 
-  stap_modify_semaphore (probe->sem_addr, 1, gdbarch);
+  addr = (probe->sem_addr
+	  + ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)));
+  stap_modify_semaphore (addr, 1, gdbarch);
 }
 
 /* Clear a SystemTap semaphore.  SEM is the semaphore's address.  */
 
 static void
-stap_clear_semaphore (struct probe *probe_generic, struct gdbarch *gdbarch)
+stap_clear_semaphore (struct probe *probe_generic, struct objfile *objfile,
+		      struct gdbarch *gdbarch)
 {
   struct stap_probe *probe = (struct stap_probe *) probe_generic;
+  CORE_ADDR addr;
 
   gdb_assert (probe_generic->pops == &stap_probe_ops);
 
-  stap_modify_semaphore (probe->sem_addr, 0, gdbarch);
+  addr = (probe->sem_addr
+	  + ANOFFSET (objfile->section_offsets, SECT_OFF_DATA (objfile)));
+  stap_modify_semaphore (addr, 0, gdbarch);
 }
 
 /* Implementation of `$_probe_arg*' set of variables.  */
@@ -1333,7 +1350,7 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
 
   ret = obstack_alloc (&objfile->objfile_obstack, sizeof (*ret));
   ret->p.pops = &stap_probe_ops;
-  ret->p.objfile = objfile;
+  ret->p.arch = gdbarch;
 
   /* Provider and the name of the probe.  */
   ret->p.provider = (char *) &el->data[3 * size];
@@ -1362,13 +1379,9 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
   /* Semaphore address.  */
   ret->sem_addr = extract_typed_address (&el->data[2 * size], ptr_type);
 
-  ret->p.address += (ANOFFSET (objfile->section_offsets,
-			       SECT_OFF_TEXT (objfile))
-		     + base - base_ref);
+  ret->p.address += base - base_ref;
   if (ret->sem_addr)
-    ret->sem_addr += (ANOFFSET (objfile->section_offsets,
-				SECT_OFF_DATA (objfile))
-		      + base - base_ref);
+    ret->sem_addr += base - base_ref;
 
   /* Arguments.  We can only extract the argument format if there is a valid
      name for this probe.  */
@@ -1487,18 +1500,6 @@ stap_get_probes (VEC (probe_p) **probesp, struct objfile *objfile)
     }
 }
 
-static void
-stap_relocate (struct probe *probe_generic, CORE_ADDR delta)
-{
-  struct stap_probe *probe = (struct stap_probe *) probe_generic;
-
-  gdb_assert (probe_generic->pops == &stap_probe_ops);
-
-  probe->p.address += delta;
-  if (probe->sem_addr)
-    probe->sem_addr += delta;
-}
-
 static int
 stap_probe_is_linespec (const char **linespecp)
 {
@@ -1528,7 +1529,7 @@ stap_gen_info_probes_table_values (struct probe *probe_generic,
 
   gdb_assert (probe_generic->pops == &stap_probe_ops);
 
-  gdbarch = get_objfile_arch (probe->p.objfile);
+  gdbarch = probe->p.arch;
 
   if (probe->sem_addr)
     val = print_core_address (gdbarch, probe->sem_addr);
@@ -1542,7 +1543,7 @@ static const struct probe_ops stap_probe_ops =
 {
   stap_probe_is_linespec,
   stap_get_probes,
-  stap_relocate,
+  stap_get_probe_address,
   stap_get_probe_argument_count,
   stap_can_evaluate_probe_arguments,
   stap_evaluate_probe_argument,
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 4534a2a..ac10fa0 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -392,28 +392,9 @@ debug_sym_get_probes (struct objfile *objfile)
   return retval;
 }
 
-static void
-debug_sym_relocate_probe (struct objfile *objfile,
-			  const struct section_offsets *new_offsets,
-			  const struct section_offsets *delta)
-{
-  const struct debug_sym_fns_data *debug_data =
-    objfile_data (objfile, symfile_debug_objfile_data_key);
-
-  fprintf_filtered (gdb_stdlog,
-		    "probes->sym_relocate_probe (%s, %s, %s)\n",
-		    debug_objfile_name (objfile),
-		    host_address_to_string (new_offsets),
-		    host_address_to_string (delta));
-
-  debug_data->real_sf->sym_probe_fns->sym_relocate_probe
-    (objfile, new_offsets, delta);
-}
-
 static const struct sym_probe_fns debug_sym_probe_fns =
 {
   debug_sym_get_probes,
-  debug_sym_relocate_probe
 };
 \f
 /* Debugging version of struct sym_fns.  */
diff --git a/gdb/symfile.h b/gdb/symfile.h
index b800385..f8da08c 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -304,11 +304,6 @@ struct sym_probe_fns
      The returned value does not have to be freed and it has lifetime of the
      OBJFILE.  */
   VEC (probe_p) *(*sym_get_probes) (struct objfile *);
-
-  /* Relocate the probe section of OBJFILE.  */
-  void (*sym_relocate_probe) (struct objfile *objfile,
-			      const struct section_offsets *new_offsets,
-			      const struct section_offsets *delta);
 };
 
 /* Structure to keep track of symbol reading functions for various
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 991f56c..0aa77b9 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -941,15 +941,7 @@ symbol_search_name (const struct general_symbol_info *gsymbol)
 void
 init_sal (struct symtab_and_line *sal)
 {
-  sal->pspace = NULL;
-  sal->symtab = 0;
-  sal->section = 0;
-  sal->line = 0;
-  sal->pc = 0;
-  sal->end = 0;
-  sal->explicit_pc = 0;
-  sal->explicit_line = 0;
-  sal->probe = NULL;
+  memset (sal, 0, sizeof (*sal));
 }
 \f
 
diff --git a/gdb/symtab.h b/gdb/symtab.h
index d5daed3..6be2f2f 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1217,6 +1217,9 @@ struct symtab_and_line
 
   /* The probe associated with this symtab_and_line.  */
   struct probe *probe;
+  /* If PROBE is not NULL, then this is the objfile in which the probe
+     originated.  */
+  struct objfile *objfile;
 };
 
 extern void init_sal (struct symtab_and_line *sal);
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index 2ee70b2..e6d1c45 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -1867,8 +1867,10 @@ start_tracing (char *notes)
       t->number_on_target = b->number;
 
       for (loc = b->loc; loc; loc = loc->next)
-	if (loc->probe != NULL)
-	  loc->probe->pops->set_semaphore (loc->probe, loc->gdbarch);
+	if (loc->probe.probe != NULL)
+	  loc->probe.probe->pops->set_semaphore (loc->probe.probe,
+						 loc->probe.objfile,
+						 loc->gdbarch);
 
       if (bp_location_downloaded)
 	observer_notify_breakpoint_modified (b);
@@ -1964,8 +1966,10 @@ stop_tracing (char *note)
 	     but we don't really care if this semaphore goes out of sync.
 	     That's why we are decrementing it here, but not taking care
 	     in other places.  */
-	  if (loc->probe != NULL)
-	    loc->probe->pops->clear_semaphore (loc->probe, loc->gdbarch);
+	  if (loc->probe.probe != NULL)
+	    loc->probe.probe->pops->clear_semaphore (loc->probe.probe,
+						     loc->probe.objfile,
+						     loc->gdbarch);
 	}
     }
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/4] comment fixes
  2013-12-03 19:47 [PATCH 0/4] make probes independent of the program space Tom Tromey
@ 2013-12-03 19:47 ` Tom Tromey
  2013-12-03 19:47 ` [PATCH 3/4] change probes to be program-space-independent Tom Tromey
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 13+ messages in thread
From: Tom Tromey @ 2013-12-03 19:47 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This fixes up a few mildly erroneous comments in probe.h.

2013-12-03  Tom Tromey  <tromey@redhat.com>

	* probe.h (parse_probes, find_probe_by_pc)
	(find_probes_in_objfile): Fix comments.
---
 gdb/ChangeLog |  5 +++++
 gdb/probe.h   | 13 ++++++-------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/gdb/probe.h b/gdb/probe.h
index dd5387b..d116274 100644
--- a/gdb/probe.h
+++ b/gdb/probe.h
@@ -181,8 +181,7 @@ struct probe
   };
 
 /* A helper for linespec that decodes a probe specification.  It returns a
-   symtabs_and_lines object and updates *ARGPTR or throws an error.  The
-   argument PTYPE specifies the type of the probe(s) to be parsed.  */
+   symtabs_and_lines object and updates *ARGPTR or throws an error.  */
 
 extern struct symtabs_and_lines parse_probes (char **argptr,
 					      struct linespec_result *canon);
@@ -192,14 +191,14 @@ extern struct symtabs_and_lines parse_probes (char **argptr,
 
 extern void register_probe_ops (struct probe *probe);
 
-/* Given a PC, find an associated probe with type PTYPE.  If a probe is
-   found, return it.  If no probe is found, return NULL.  */
+/* Given a PC, find an associated probe.  If a probe is found, return
+   it.  If no probe is found, return NULL.  */
 
 extern struct probe *find_probe_by_pc (CORE_ADDR pc);
 
-/* Search OBJFILE for a probe with the given PROVIDER, NAME and PTYPE.
-   Return a VEC of all probes that were found.  If no matching probe
-   is found, return NULL.  The caller must free the VEC.  */
+/* Search OBJFILE for a probe with the given PROVIDER, NAME.  Return a
+   VEC of all probes that were found.  If no matching probe is found,
+   return NULL.  The caller must free the VEC.  */
 
 extern VEC (probe_p) *find_probes_in_objfile (struct objfile *objfile,
 					      const char *provider,
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 2/4] remove some sym_probe_fns methods
  2013-12-03 19:47 [PATCH 0/4] make probes independent of the program space Tom Tromey
  2013-12-03 19:47 ` [PATCH 1/4] comment fixes Tom Tromey
  2013-12-03 19:47 ` [PATCH 3/4] change probes to be program-space-independent Tom Tromey
@ 2013-12-03 19:47 ` Tom Tromey
  2013-12-05 23:06   ` Sergio Durigan Junior
  2013-12-03 20:37 ` [PATCH 4/4] move probes to be per-bfd Tom Tromey
  2013-12-05 17:10 ` [PATCH 0/4] make probes independent of the program space Pedro Alves
  4 siblings, 1 reply; 13+ messages in thread
From: Tom Tromey @ 2013-12-03 19:47 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

While looking into the probe API, it seemed to me that there were a
number of methods in sym_probe_fns that were not needed.  This patch
removes them.

Specifically, it seems to me that sym_probe_fns ought to be concerned
with the API for constructing the probes.  Any method relating to some
aspect of an individual probe can be handled via the probe's own
vtable.  That is, the double indirection here doesn't seem useful --
it certainly isn't in fact used, but also I couldn't think of a
potential use.

2013-12-03  Tom Tromey  <tromey@redhat.com>

	* break-catch-throw.c (fetch_probe_arguments): Use
	get_probe_argument_count and evaluate_probe_argument.
	* elfread.c (elf_get_probe_argument_count)
	(elf_can_evaluate_probe_arguments, elf_evaluate_probe_argument)
	(elf_compile_to_ax): Remove.
	(elf_probe_fns): Update.
	* probe.c (get_probe_argument_count, can_evaluate_probe_arguments)
	(evaluate_probe_argument): Call method on probe, not via sym
	functions.
	* stap-probe.c (compute_probe_arg): Use get_probe_argument_count,
	evaluate_probe_argument.
	(compile_probe_arg): Use get_probe_argument_count.  Call method on
	probe, not via sym functions.
	* symfile-debug.c (debug_sym_get_probe_argument_count)
	(debug_can_evaluate_probe_arguments)
	(debug_sym_evaluate_probe_argument, debug_sym_compile_to_ax):
	Remove.
	(debug_sym_probe_fns): Remove.
	* symfile.h (struct sym_probe_fns) <sym_get_probe_argument_count,
	can_evaluate_probe_arguments, sym_evaluate_probe_argument,
	sym_compile_to_ax>: Remove fields.
---
 gdb/ChangeLog           | 24 +++++++++++++++
 gdb/break-catch-throw.c | 11 ++-----
 gdb/elfread.c           | 42 --------------------------
 gdb/probe.c             | 33 ++------------------
 gdb/stap-probe.c        | 20 +++----------
 gdb/symfile-debug.c     | 80 -------------------------------------------------
 gdb/symfile.h           | 34 ---------------------
 7 files changed, 34 insertions(+), 210 deletions(-)

diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c
index fb24725..76087d3 100644
--- a/gdb/break-catch-throw.c
+++ b/gdb/break-catch-throw.c
@@ -118,18 +118,13 @@ fetch_probe_arguments (struct value **arg0, struct value **arg1)
 	  && strcmp (pc_probe->name, "rethrow") != 0))
     error (_("not stopped at a C++ exception catchpoint"));
 
-  gdb_assert (pc_probe->objfile != NULL);
-  gdb_assert (pc_probe->objfile->sf != NULL);
-  gdb_assert (pc_probe->objfile->sf->sym_probe_fns != NULL);
-
-  pc_probe_fns = pc_probe->objfile->sf->sym_probe_fns;
-  n_args = pc_probe_fns->sym_get_probe_argument_count (pc_probe);
+  n_args = get_probe_argument_count (pc_probe);
   if (n_args < 2)
     error (_("C++ exception catchpoint has too few arguments"));
 
   if (arg0 != NULL)
-    *arg0 = pc_probe_fns->sym_evaluate_probe_argument (pc_probe, 0);
-  *arg1 = pc_probe_fns->sym_evaluate_probe_argument (pc_probe, 1);
+    *arg0 = evaluate_probe_argument (pc_probe, 0);
+  *arg1 = evaluate_probe_argument (pc_probe, 1);
 
   if ((arg0 != NULL && *arg0 == NULL) || *arg1 == NULL)
     error (_("error computing probe argument at c++ exception catchpoint"));
diff --git a/gdb/elfread.c b/gdb/elfread.c
index 2863721..c347230 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -1516,44 +1516,6 @@ elf_get_probes (struct objfile *objfile)
   return probes_per_objfile;
 }
 
-/* Implementation of `sym_get_probe_argument_count', as documented in
-   symfile.h.  */
-
-static unsigned
-elf_get_probe_argument_count (struct probe *probe)
-{
-  return probe->pops->get_probe_argument_count (probe);
-}
-
-/* Implementation of `sym_can_evaluate_probe_arguments', as documented in
-   symfile.h.  */
-
-static int
-elf_can_evaluate_probe_arguments (struct probe *probe)
-{
-  return probe->pops->can_evaluate_probe_arguments (probe);
-}
-
-/* Implementation of `sym_evaluate_probe_argument', as documented in
-   symfile.h.  */
-
-static struct value *
-elf_evaluate_probe_argument (struct probe *probe, unsigned n)
-{
-  return probe->pops->evaluate_probe_argument (probe, n);
-}
-
-/* Implementation of `sym_compile_to_ax', as documented in symfile.h.  */
-
-static void
-elf_compile_to_ax (struct probe *probe,
-		   struct agent_expr *expr,
-		   struct axs_value *value,
-		   unsigned n)
-{
-  probe->pops->compile_to_ax (probe, expr, value, n);
-}
-
 /* Implementation of `sym_relocate_probe', as documented in symfile.h.  */
 
 static void
@@ -1592,10 +1554,6 @@ probe_key_free (struct objfile *objfile, void *d)
 static const struct sym_probe_fns elf_probe_fns =
 {
   elf_get_probes,		    /* sym_get_probes */
-  elf_get_probe_argument_count,	    /* sym_get_probe_argument_count */
-  elf_can_evaluate_probe_arguments, /* sym_can_evaluate_probe_arguments */
-  elf_evaluate_probe_argument,	    /* sym_evaluate_probe_argument */
-  elf_compile_to_ax,		    /* sym_compile_to_ax */
   elf_symfile_relocate_probe,	    /* sym_relocate_probe */
 };
 
diff --git a/gdb/probe.c b/gdb/probe.c
index 4046701..c1e0111 100644
--- a/gdb/probe.c
+++ b/gdb/probe.c
@@ -616,16 +616,7 @@ info_probes_command (char *arg, int from_tty)
 unsigned
 get_probe_argument_count (struct probe *probe)
 {
-  const struct sym_probe_fns *probe_fns;
-
-  gdb_assert (probe->objfile != NULL);
-  gdb_assert (probe->objfile->sf != NULL);
-
-  probe_fns = probe->objfile->sf->sym_probe_fns;
-
-  gdb_assert (probe_fns != NULL);
-
-  return probe_fns->sym_get_probe_argument_count (probe);
+  return probe->pops->get_probe_argument_count (probe);
 }
 
 /* See comments in probe.h.  */
@@ -633,16 +624,7 @@ get_probe_argument_count (struct probe *probe)
 int
 can_evaluate_probe_arguments (struct probe *probe)
 {
-  const struct sym_probe_fns *probe_fns;
-
-  gdb_assert (probe->objfile != NULL);
-  gdb_assert (probe->objfile->sf != NULL);
-
-  probe_fns = probe->objfile->sf->sym_probe_fns;
-
-  gdb_assert (probe_fns != NULL);
-
-  return probe_fns->can_evaluate_probe_arguments (probe);
+  return probe->pops->can_evaluate_probe_arguments (probe);
 }
 
 /* See comments in probe.h.  */
@@ -650,16 +632,7 @@ can_evaluate_probe_arguments (struct probe *probe)
 struct value *
 evaluate_probe_argument (struct probe *probe, unsigned n)
 {
-  const struct sym_probe_fns *probe_fns;
-
-  gdb_assert (probe->objfile != NULL);
-  gdb_assert (probe->objfile->sf != NULL);
-
-  probe_fns = probe->objfile->sf->sym_probe_fns;
-
-  gdb_assert (probe_fns != NULL);
-
-  return probe_fns->sym_evaluate_probe_argument (probe, n);
+  return probe->pops->evaluate_probe_argument (probe, n);
 }
 
 /* See comments in probe.h.  */
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index a734793..e09d5d6 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -1177,13 +1177,7 @@ compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar,
   if (pc_probe == NULL)
     error (_("No SystemTap probe at PC %s"), core_addr_to_string (pc));
 
-  gdb_assert (pc_probe->objfile != NULL);
-  gdb_assert (pc_probe->objfile->sf != NULL);
-  gdb_assert (pc_probe->objfile->sf->sym_probe_fns != NULL);
-
-  pc_probe_fns = pc_probe->objfile->sf->sym_probe_fns;
-
-  n_args = pc_probe_fns->sym_get_probe_argument_count (pc_probe);
+  n_args = get_probe_argument_count (pc_probe);
   if (sel == -1)
     return value_from_longest (builtin_type (arch)->builtin_int, n_args);
 
@@ -1191,7 +1185,7 @@ compute_probe_arg (struct gdbarch *arch, struct internalvar *ivar,
     error (_("Invalid probe argument %d -- probe has %u arguments available"),
 	   sel, n_args);
 
-  return pc_probe_fns->sym_evaluate_probe_argument (pc_probe, sel);
+  return evaluate_probe_argument (pc_probe, sel);
 }
 
 /* This is called to compile one of the $_probe_arg* convenience
@@ -1214,13 +1208,7 @@ compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr,
   if (pc_probe == NULL)
     error (_("No SystemTap probe at PC %s"), core_addr_to_string (pc));
 
-  gdb_assert (pc_probe->objfile != NULL);
-  gdb_assert (pc_probe->objfile->sf != NULL);
-  gdb_assert (pc_probe->objfile->sf->sym_probe_fns != NULL);
-
-  pc_probe_fns = pc_probe->objfile->sf->sym_probe_fns;
-
-  n_args = pc_probe_fns->sym_get_probe_argument_count (pc_probe);
+  n_args = get_probe_argument_count (pc_probe);
 
   if (sel == -1)
     {
@@ -1235,7 +1223,7 @@ compile_probe_arg (struct internalvar *ivar, struct agent_expr *expr,
     error (_("Invalid probe argument %d -- probe has %d arguments available"),
 	   sel, n_args);
 
-  pc_probe_fns->sym_compile_to_ax (pc_probe, expr, value, sel);
+  pc_probe->pops->compile_to_ax (pc_probe, expr, value, sel);
 }
 
 \f
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index c37c139..4534a2a 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -392,82 +392,6 @@ debug_sym_get_probes (struct objfile *objfile)
   return retval;
 }
 
-static unsigned
-debug_sym_get_probe_argument_count (struct probe *probe)
-{
-  struct objfile *objfile = probe->objfile;
-  const struct debug_sym_fns_data *debug_data =
-    objfile_data (objfile, symfile_debug_objfile_data_key);
-  unsigned retval;
-
-  retval = debug_data->real_sf->sym_probe_fns->sym_get_probe_argument_count
-    (probe);
-
-  fprintf_filtered (gdb_stdlog,
-		    "probes->sym_get_probe_argument_count (%s) = %u\n",
-		    host_address_to_string (probe), retval);
-
-  return retval;
-}
-
-static int
-debug_can_evaluate_probe_arguments (struct probe *probe)
-{
-  struct objfile *objfile = probe->objfile;
-  const struct debug_sym_fns_data *debug_data =
-    objfile_data (objfile, symfile_debug_objfile_data_key);
-  int retval;
-
-  retval = debug_data->real_sf->sym_probe_fns->can_evaluate_probe_arguments
-    (probe);
-
-  fprintf_filtered (gdb_stdlog,
-		    "probes->can_evaluate_probe_arguments (%s) = %d\n",
-		    host_address_to_string (probe), retval);
-
-  return retval;
-}
-
-static struct value *
-debug_sym_evaluate_probe_argument (struct probe *probe, unsigned n)
-{
-  struct objfile *objfile = probe->objfile;
-  const struct debug_sym_fns_data *debug_data =
-    objfile_data (objfile, symfile_debug_objfile_data_key);
-  struct value *retval;
-
-  fprintf_filtered (gdb_stdlog,
-		    "probes->sym_evaluate_probe_argument (%s, %u)\n",
-		    host_address_to_string (probe), n);
-
-  retval = debug_data->real_sf->sym_probe_fns->sym_evaluate_probe_argument
-    (probe, n);
-
-  fprintf_filtered (gdb_stdlog,
-		    "probes->sym_evaluate_probe_argument (...) = %s\n",
-		    host_address_to_string (retval));
-
-  return retval;
-}
-
-static void
-debug_sym_compile_to_ax (struct probe *probe, struct agent_expr *expr,
-			 struct axs_value *value, unsigned n)
-{
-  struct objfile *objfile = probe->objfile;
-  const struct debug_sym_fns_data *debug_data =
-    objfile_data (objfile, symfile_debug_objfile_data_key);
-
-  fprintf_filtered (gdb_stdlog,
-		    "probes->sym_compile_to_ax (%s, %s, %s, %u)\n",
-		    host_address_to_string (probe),
-		    host_address_to_string (expr),
-		    host_address_to_string (value), n);
-
-  debug_data->real_sf->sym_probe_fns->sym_compile_to_ax
-    (probe, expr, value, n);
-}
-
 static void
 debug_sym_relocate_probe (struct objfile *objfile,
 			  const struct section_offsets *new_offsets,
@@ -489,10 +413,6 @@ debug_sym_relocate_probe (struct objfile *objfile,
 static const struct sym_probe_fns debug_sym_probe_fns =
 {
   debug_sym_get_probes,
-  debug_sym_get_probe_argument_count,
-  debug_can_evaluate_probe_arguments,
-  debug_sym_evaluate_probe_argument,
-  debug_sym_compile_to_ax,
   debug_sym_relocate_probe
 };
 \f
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 6632a89..b800385 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -305,40 +305,6 @@ struct sym_probe_fns
      OBJFILE.  */
   VEC (probe_p) *(*sym_get_probes) (struct objfile *);
 
-  /* Return the number of arguments available to PROBE.  PROBE will
-     have come from a call to this objfile's sym_get_probes method.
-     If you provide an implementation of sym_get_probes, you must
-     implement this method as well.  */
-  unsigned (*sym_get_probe_argument_count) (struct probe *probe);
-
-  /* Return 1 if the probe interface can evaluate the arguments of probe
-     PROBE, zero otherwise.  This function can be probe-specific, informing
-     whether only the arguments of PROBE can be evaluated, of generic,
-     informing whether the probe interface is able to evaluate any kind of
-     argument.  If you provide an implementation of sym_get_probes, you must
-     implement this method as well.  */
-  int (*can_evaluate_probe_arguments) (struct probe *probe);
-
-  /* Evaluate the Nth argument available to PROBE.  PROBE will have
-     come from a call to this objfile's sym_get_probes method.  N will
-     be between 0 and the number of arguments available to this probe.
-     FRAME is the frame in which the evaluation is done; the frame's
-     PC will match the address of the probe.  If you provide an
-     implementation of sym_get_probes, you must implement this method
-     as well.  */
-  struct value *(*sym_evaluate_probe_argument) (struct probe *probe,
-						unsigned n);
-
-  /* Compile the Nth probe argument to an agent expression.  PROBE
-     will have come from a call to this objfile's sym_get_probes
-     method.  N will be between 0 and the number of arguments
-     available to this probe.  EXPR and VALUE are the agent expression
-     that is being updated.  */
-  void (*sym_compile_to_ax) (struct probe *probe,
-			     struct agent_expr *expr,
-			     struct axs_value *value,
-			     unsigned n);
-
   /* Relocate the probe section of OBJFILE.  */
   void (*sym_relocate_probe) (struct objfile *objfile,
 			      const struct section_offsets *new_offsets,
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 4/4] move probes to be per-bfd
  2013-12-03 19:47 [PATCH 0/4] make probes independent of the program space Tom Tromey
                   ` (2 preceding siblings ...)
  2013-12-03 19:47 ` [PATCH 2/4] remove some sym_probe_fns methods Tom Tromey
@ 2013-12-03 20:37 ` Tom Tromey
  2013-12-05 17:10 ` [PATCH 0/4] make probes independent of the program space Pedro Alves
  4 siblings, 0 replies; 13+ messages in thread
From: Tom Tromey @ 2013-12-03 20:37 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This patch moves the probe data from the objfile to the per-BFD
object.  This lets the probes be shared between different inferiors
(and different objfiles when dlmopen is in use, should gdb ever handle
that).

2013-12-03  Tom Tromey  <tromey@redhat.com>

	* elfread.c (probe_key): Change to bfd_data.
	(elf_get_probes, probe_key_free, _initialize_elfread): Probes are
	now per-BFD, not per-objfile.
	* stap-probe.c (stap_probe_destroy): Update comment.
	(handle_stap_probe): Allocate on the per-BFD obstack.
---
 gdb/ChangeLog    |  8 ++++++++
 gdb/elfread.c    | 26 +++++++++++++-------------
 gdb/stap-probe.c |  4 ++--
 3 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/gdb/elfread.c b/gdb/elfread.c
index dedecf2..1f28bc1 100644
--- a/gdb/elfread.c
+++ b/gdb/elfread.c
@@ -63,9 +63,9 @@ struct elfinfo
     asection *mdebugsect;	/* Section pointer for .mdebug section */
   };
 
-/* Per-objfile data for probe info.  */
+/* Per-BFD data for probe info.  */
 
-static const struct objfile_data *probe_key = NULL;
+static const struct bfd_data *probe_key = NULL;
 
 static void free_elfinfo (void *);
 
@@ -1488,12 +1488,12 @@ elfstab_offset_sections (struct objfile *objfile, struct partial_symtab *pst)
 static VEC (probe_p) *
 elf_get_probes (struct objfile *objfile)
 {
-  VEC (probe_p) *probes_per_objfile;
+  VEC (probe_p) *probes_per_bfd;
 
   /* Have we parsed this objfile's probes already?  */
-  probes_per_objfile = objfile_data (objfile, probe_key);
+  probes_per_bfd = bfd_data (objfile->obfd, probe_key);
 
-  if (!probes_per_objfile)
+  if (!probes_per_bfd)
     {
       int ix;
       const struct probe_ops *probe_ops;
@@ -1502,25 +1502,25 @@ elf_get_probes (struct objfile *objfile)
 	 objfile.  */
       for (ix = 0; VEC_iterate (probe_ops_cp, all_probe_ops, ix, probe_ops);
 	   ix++)
-	probe_ops->get_probes (&probes_per_objfile, objfile);
+	probe_ops->get_probes (&probes_per_bfd, objfile);
 
-      if (probes_per_objfile == NULL)
+      if (probes_per_bfd == NULL)
 	{
-	  VEC_reserve (probe_p, probes_per_objfile, 1);
-	  gdb_assert (probes_per_objfile != NULL);
+	  VEC_reserve (probe_p, probes_per_bfd, 1);
+	  gdb_assert (probes_per_bfd != NULL);
 	}
 
-      set_objfile_data (objfile, probe_key, probes_per_objfile);
+      set_bfd_data (objfile->obfd, probe_key, probes_per_bfd);
     }
 
-  return probes_per_objfile;
+  return probes_per_bfd;
 }
 
 /* Helper function used to free the space allocated for storing SystemTap
    probe information.  */
 
 static void
-probe_key_free (struct objfile *objfile, void *d)
+probe_key_free (bfd *abfd, void *d)
 {
   int ix;
   VEC (probe_p) *probes = d;
@@ -1606,7 +1606,7 @@ static const struct gnu_ifunc_fns elf_gnu_ifunc_fns =
 void
 _initialize_elfread (void)
 {
-  probe_key = register_objfile_data_with_cleanup (NULL, probe_key_free);
+  probe_key = register_bfd_data_with_cleanup (NULL, probe_key_free);
   add_symtab_fns (bfd_target_elf_flavour, &elf_sym_fns);
 
   elf_objfile_gnu_ifunc_cache_data = register_objfile_data ();
diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c
index 7f2d45d..fbc5724 100644
--- a/gdb/stap-probe.c
+++ b/gdb/stap-probe.c
@@ -1142,7 +1142,7 @@ stap_compile_to_ax (struct probe *probe_generic, struct agent_expr *expr,
 }
 
 /* Destroy (free) the data related to PROBE.  PROBE memory itself is not feed
-   as it is allocated from OBJFILE_OBSTACK.  */
+   as it is allocated on an obstack.  */
 
 static void
 stap_probe_destroy (struct probe *probe_generic)
@@ -1348,7 +1348,7 @@ handle_stap_probe (struct objfile *objfile, struct sdt_note *el,
   const char *probe_args = NULL;
   struct stap_probe *ret;
 
-  ret = obstack_alloc (&objfile->objfile_obstack, sizeof (*ret));
+  ret = obstack_alloc (&objfile->per_bfd->storage_obstack, sizeof (*ret));
   ret->p.pops = &stap_probe_ops;
   ret->p.arch = gdbarch;
 
-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/4] make probes independent of the program space
  2013-12-03 19:47 [PATCH 0/4] make probes independent of the program space Tom Tromey
                   ` (3 preceding siblings ...)
  2013-12-03 20:37 ` [PATCH 4/4] move probes to be per-bfd Tom Tromey
@ 2013-12-05 17:10 ` Pedro Alves
  2013-12-05 19:10   ` Tom Tromey
  4 siblings, 1 reply; 13+ messages in thread
From: Pedro Alves @ 2013-12-05 17:10 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On 12/03/2013 07:46 PM, Tom Tromey wrote:
> This patch series changes SystemTap probes to be independent of the
> program space, and then to be stored in the per-BFD object.  That way,
> they can be shared by all objfiles referring to a given BFD.  This
> saves memory and perhaps a bit of time, in the multi-inferior case.
> 
> This is based on my similar patch series to make minimal symbols
> independent of the program space:
> 
>     https://sourceware.org/ml/gdb-patches/2013-10/msg00521.html
> 
> This is part of the obj file splitting project:
> 
>     https://sourceware.org/gdb/wiki/ObjfileSplitting
> 
> I built and regtested the series on x86-64 Fedora 18.

I read this series, and it looked excellent to me.

I only wondered whether sal.objfile should be named
sal.probe_objfile to avoid confusion, but I realized that
down the road sal.objfile will probably end up set when
sal.symtab is too, so I understand that choice.  Or at
least, I think I do.  :-)

-- 
Pedro Alves

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 0/4] make probes independent of the program space
  2013-12-05 17:10 ` [PATCH 0/4] make probes independent of the program space Pedro Alves
@ 2013-12-05 19:10   ` Tom Tromey
  0 siblings, 0 replies; 13+ messages in thread
From: Tom Tromey @ 2013-12-05 19:10 UTC (permalink / raw)
  To: Pedro Alves; +Cc: gdb-patches

>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:

Pedro> I only wondered whether sal.objfile should be named
Pedro> sal.probe_objfile to avoid confusion, but I realized that
Pedro> down the road sal.objfile will probably end up set when
Pedro> sal.symtab is too, so I understand that choice.  Or at
Pedro> least, I think I do.  :-)

sal is ripe for refactoring.  It's just a grab bag now.

Tom

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/4] remove some sym_probe_fns methods
  2013-12-03 19:47 ` [PATCH 2/4] remove some sym_probe_fns methods Tom Tromey
@ 2013-12-05 23:06   ` Sergio Durigan Junior
  2013-12-06  2:25     ` Sergio Durigan Junior
  0 siblings, 1 reply; 13+ messages in thread
From: Sergio Durigan Junior @ 2013-12-05 23:06 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Tuesday, December 03 2013, Tom Tromey wrote:

> While looking into the probe API, it seemed to me that there were a
> number of methods in sym_probe_fns that were not needed.  This patch
> removes them.
>
> Specifically, it seems to me that sym_probe_fns ought to be concerned
> with the API for constructing the probes.  Any method relating to some
> aspect of an individual probe can be handled via the probe's own
> vtable.  That is, the double indirection here doesn't seem useful --
> it certainly isn't in fact used, but also I couldn't think of a
> potential use.

This patch is great and needed, thanks a lot.  The cleanup is more than
welcome.

I'll wait until you commit your patches so that I can rebase mine on top
of them.

Thanks,

-- 
Sergio

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/4] remove some sym_probe_fns methods
  2013-12-05 23:06   ` Sergio Durigan Junior
@ 2013-12-06  2:25     ` Sergio Durigan Junior
  2013-12-06 15:54       ` Tom Tromey
  0 siblings, 1 reply; 13+ messages in thread
From: Sergio Durigan Junior @ 2013-12-06  2:25 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Thursday, December 05 2013, I wrote:

> This patch is great and needed, thanks a lot.  The cleanup is more than
> welcome.

Tom, looking at this patch, I don't see a (strong) dependency on the
other patches of this series.  Can this single patch go in?  It would be
a nice cleanup, as I said above.

Thanks,

-- 
Sergio

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/4] remove some sym_probe_fns methods
  2013-12-06  2:25     ` Sergio Durigan Junior
@ 2013-12-06 15:54       ` Tom Tromey
  2013-12-06 17:26         ` Tom Tromey
  0 siblings, 1 reply; 13+ messages in thread
From: Tom Tromey @ 2013-12-06 15:54 UTC (permalink / raw)
  To: Sergio Durigan Junior; +Cc: gdb-patches

>>>>> "Sergio" == Sergio Durigan Junior <sergiodj@redhat.com> writes:

Sergio> On Thursday, December 05 2013, I wrote:
>> This patch is great and needed, thanks a lot.  The cleanup is more than
>> welcome.

Sergio> Tom, looking at this patch, I don't see a (strong) dependency on the
Sergio> other patches of this series.  Can this single patch go in?  It would be
Sergio> a nice cleanup, as I said above.

Sure.  I'll push it in a while.

Tom

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/4] remove some sym_probe_fns methods
  2013-12-06 15:54       ` Tom Tromey
@ 2013-12-06 17:26         ` Tom Tromey
  2013-12-06 18:23           ` Sergio Durigan Junior
  0 siblings, 1 reply; 13+ messages in thread
From: Tom Tromey @ 2013-12-06 17:26 UTC (permalink / raw)
  To: Sergio Durigan Junior; +Cc: gdb-patches

Sergio> Tom, looking at this patch, I don't see a (strong) dependency on the
Sergio> other patches of this series.  Can this single patch go in?  It would be
Sergio> a nice cleanup, as I said above.

Tom> Sure.  I'll push it in a while.

I regression tested it and pushed it in.

Tom

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 2/4] remove some sym_probe_fns methods
  2013-12-06 17:26         ` Tom Tromey
@ 2013-12-06 18:23           ` Sergio Durigan Junior
  0 siblings, 0 replies; 13+ messages in thread
From: Sergio Durigan Junior @ 2013-12-06 18:23 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Friday, December 06 2013, Tom Tromey wrote:

> I regression tested it and pushed it in.

Thanks a lot, Tom.

-- 
Sergio

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 3/4] change probes to be program-space-independent
  2013-12-03 19:47 ` [PATCH 3/4] change probes to be program-space-independent Tom Tromey
@ 2013-12-17 11:08   ` Gary Benson
  0 siblings, 0 replies; 13+ messages in thread
From: Gary Benson @ 2013-12-17 11:08 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

Tom Tromey wrote:
> This changes the probes to be independent of the program space.
> 
> After this, when a probe's address is needed, it is determined by
> applying offsets at the point of use.
> 
> This introduces a bound_probe object, similar to bound minimal
> symbols.  Objects of this type are used when it's necessary to pass a
> probe and its corresponding objfile.
> 
> This removes the backlink from probe to objfile, which was primarily
> used to fetch the architecture to use.
> 
> This adds a get_probe_address function which calls a probe method to
> compute the probe's relocated address.  Similarly, it adds an objfile
> parameter to the semaphore methods so they can do the relocation
> properly as well.

I haven't looked at the whole patch, but the solib-svr4.c bits look
good.  Thanks for doing this work Tom.

Cheers,
Gary

-- 
http://gbenson.net/

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-12-17 11:08 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-03 19:47 [PATCH 0/4] make probes independent of the program space Tom Tromey
2013-12-03 19:47 ` [PATCH 1/4] comment fixes Tom Tromey
2013-12-03 19:47 ` [PATCH 3/4] change probes to be program-space-independent Tom Tromey
2013-12-17 11:08   ` Gary Benson
2013-12-03 19:47 ` [PATCH 2/4] remove some sym_probe_fns methods Tom Tromey
2013-12-05 23:06   ` Sergio Durigan Junior
2013-12-06  2:25     ` Sergio Durigan Junior
2013-12-06 15:54       ` Tom Tromey
2013-12-06 17:26         ` Tom Tromey
2013-12-06 18:23           ` Sergio Durigan Junior
2013-12-03 20:37 ` [PATCH 4/4] move probes to be per-bfd Tom Tromey
2013-12-05 17:10 ` [PATCH 0/4] make probes independent of the program space Pedro Alves
2013-12-05 19:10   ` Tom Tromey

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).