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]

RFC: tracepoints: Add function for collecting variables


The tracepoint code supports things like 'trace $args' and 'trace
$locals', which walk over blocks' symbols and collect everything
relevant they find using the tracepoint protocol's special cases for
memory ranges and plain registers.

This code has never supported LOC_COMPUTED and LOC_COMPUTED_ARG
symbols, which postdate the original tracepoint implementation and
can't, in general, be squeezed into any of the special cases.

However, LOC_COMPUTED* symbols do provide a 'tracepoint_var_ref'
function, to emit bytecode to collect their values.  This patch adds a
function the tracepoint code can use to take advantage of that.  The
actual code to use it will come later.

Okay to commit?

gdb/ChangeLog:
2007-10-25  Jim Blandy  <jimb@codesourcery.com>

	* ax-gdb.c (gen_trace_for_symbol): New function.
	* ax-gdb.h (gen_trace_for_symbol): New declaration.

diff -r 84b7570f26f4 -r c9d900af6ded gdb/ax-gdb.c
--- a/gdb/ax-gdb.c	Thu Oct 25 12:47:24 2007 -0700
+++ b/gdb/ax-gdb.c	Thu Oct 25 12:48:34 2007 -0700
@@ -1827,6 +1827,29 @@ gen_trace_for_expr (CORE_ADDR scope, str
   return ax;
 }
 
+struct agent_expr *
+gen_trace_for_symbol (CORE_ADDR scope, struct symbol *sym)
+{
+  struct agent_expr *ax = new_agent_expr (scope);
+  struct cleanup *old_chain = make_cleanup_free_agent_expr (ax);
+  struct axs_value value;
+
+  trace_kludge = 1;
+  gen_var_ref (ax, &value, sym);
+
+  /* Make sure we record the final object, and get rid of it.  */
+  gen_traced_pop (ax, &value);
+
+  /* Oh, and terminate.  */
+  ax_simple (ax, aop_end);
+
+  /* We have successfully built the agent expr, so cancel the cleanup
+     request.  If we add more cleanups that we always want done, this
+     will have to get more complicated.  */
+  discard_cleanups (old_chain);
+  return ax;
+}
+
 static void
 agent_command (char *exp, int from_tty)
 {
diff -r 84b7570f26f4 -r c9d900af6ded gdb/ax-gdb.h
--- a/gdb/ax-gdb.h	Thu Oct 25 12:47:24 2007 -0700
+++ b/gdb/ax-gdb.h	Thu Oct 25 12:48:34 2007 -0700
@@ -108,4 +108,11 @@ extern struct agent_expr *expr_to_addres
    function to discover which registers the expression uses.  */
 extern struct agent_expr *gen_trace_for_expr (CORE_ADDR, struct expression *);
 
+/* Given a GDB symbol SYM, return bytecode to trace its value.
+   The result will use the `trace' and `trace_quick' bytecodes to
+   record the value of all memory touched by the expression, and leave
+   no values on the stack.  The caller can then use the ax_reqs
+   function to discover which registers the expression uses.  */
+extern struct agent_expr *gen_trace_for_symbol (CORE_ADDR, struct symbol *);
+
 #endif /* AX_GDB_H */


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