Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RFC: tracepoints: Use constant-size trace opcodes where possible
@ 2007-10-26 23:18 Jim Blandy
  2007-10-27  8:17 ` Michael Snyder
  0 siblings, 1 reply; 2+ messages in thread
From: Jim Blandy @ 2007-10-26 23:18 UTC (permalink / raw)
  To: gdb-patches


The comments should explain what's going on here.  The Linux
tracepoint agent was much simplified by restricting it to expressions
whose data size could be estimated in advance.  This should have no
effect on other agents.

Okay to commit?

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

	* ax-gdb.c (gen_traced_pop): Generate trace_quick or trace16
	bytecodes whenever possible.

diff -r cdc626576c72 -r 84b7570f26f4 gdb/ax-gdb.c
--- a/gdb/ax-gdb.c	Thu Oct 25 12:43:14 2007 -0700
+++ b/gdb/ax-gdb.c	Thu Oct 25 12:47:24 2007 -0700
@@ -321,13 +321,22 @@ gen_traced_pop (struct agent_expr *ax, s
 	{
 	  int length = TYPE_LENGTH (check_typedef (value->type));
 
-	  /* There's no point in trying to use a trace_quick bytecode
-	     here, since "trace_quick SIZE pop" is three bytes, whereas
-	     "const8 SIZE trace" is also three bytes, does the same
-	     thing, and the simplest code which generates that will also
-	     work correctly for objects with large sizes.  */
-	  ax_const_l (ax, length);
-	  ax_simple (ax, aop_trace);
+          /* Try to generate a trace_quick here if we can.  The
+             bytecode stream generated isn't any shorter ('quick <len>
+             pop' and 'const8 <len> trace' are both three bytes long),
+             but this simplifies agent expression evaluators that want
+             to be able to easily put an upper bound on the memory
+             that will be collected by an expression.  */
+          if (length < 1 << 16)
+            {
+              ax_trace_quick (ax, length);
+              ax_simple (ax, aop_pop);
+            }
+          else
+            {
+              ax_const_l (ax, length);
+              ax_simple (ax, aop_trace);
+            }
 	}
 	break;
 


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

end of thread, other threads:[~2007-10-27  8:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-26 23:18 RFC: tracepoints: Use constant-size trace opcodes where possible Jim Blandy
2007-10-27  8:17 ` Michael Snyder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox