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 2/4] remove some sym_probe_fns methods


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);
 }
 
 
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
 };
 
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


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