This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch]: Trace pointer targets
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: gdb-patches at sources dot redhat dot com
- Cc: Paul Brook <paul at codesourcery dot com>
- Date: Thu, 10 Feb 2005 11:01:45 +0000
- Subject: [patch]: Trace pointer targets
- Organization: Codesourcery LLC
Hi,
this patch modifies the tracepoint expression mechanism so that the
target of a pointer expression is also gathered. It's uesful to gather
this information automatically, and the gdb.trace/collection.exp test
has a case where the contents of an array parameter are expected to
be gathered automatically.
The patch gathers gathers the first 2^N objects at the pointer target,
where N is the smallest value such that at least 16 bytes are gathered.
built & tested on i686-pc-linux-gnu, and an unreleased architecture, ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery LLC
nathan@codesourcery.com :: http://www.planetfall.pwp.blueyonder.co.uk
2005-02-10 Nathan Sidwell <nathan@codesourcery.com>
* ax-gdb (gen_traced_pop): Read some bytes at destination of a
pointer.
Index: ax-gdb.c
===================================================================
RCS file: /home/icera/Repository/gnu/gdb/ax-gdb.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -c -3 -p -r1.1 -r1.2
*** ax-gdb.c 15 Jul 2004 10:04:59 -0000 1.1
--- ax-gdb.c 6 Feb 2005 11:53:20 -0000 1.2
*************** static void
*** 311,348 ****
gen_traced_pop (struct agent_expr *ax, struct axs_value *value)
{
if (trace_kludge)
! switch (value->kind)
! {
! case axs_rvalue:
! /* We don't trace rvalues, just the lvalues necessary to
! produce them. So just dispose of this value. */
! ax_simple (ax, aop_pop);
! break;
! case axs_lvalue_memory:
{
int length = TYPE_LENGTH (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);
}
! break;
!
! case axs_lvalue_register:
! /* We need to mention the register somewhere in the bytecode,
! so ax_reqs will pick it up and add it to the mask of
! registers used. */
! ax_reg (ax, value->u.reg);
ax_simple (ax, aop_pop);
! break;
! }
else
- /* If we're not tracing, just pop the value. */
ax_simple (ax, aop_pop);
}
--- 311,354 ----
gen_traced_pop (struct agent_expr *ax, struct axs_value *value)
{
if (trace_kludge)
! {
! int length = 0;
!
! if (value->kind == axs_lvalue_register)
! /* We need to mention the register somewhere in the bytecode,
! so ax_reqs will pick it up and add it to the mask of
! registers used. */
! ax_reg (ax, value->u.reg);
! /* If the thing is a pointer, fetch something of what it points
! to. */
! if (TYPE_CODE (value->type) == TYPE_CODE_PTR
! || TYPE_CODE (value->type) == TYPE_CODE_REF)
! length = TYPE_LENGTH (TYPE_TARGET_TYPE (value->type));
!
! if (length)
! {
! if (value->kind == axs_lvalue_memory)
! /* This will generate a trace of the pointer value. */
! gen_fetch (ax, value->type);
!
! /* Get somethin, but not too much. */
! while (length < 16)
! length *= 2;
! ax_const_l (ax, length);
! ax_simple (ax, aop_trace);
! }
! else if (value->kind == axs_lvalue_memory)
{
int length = TYPE_LENGTH (value->type);
ax_const_l (ax, length);
ax_simple (ax, aop_trace);
}
! else
ax_simple (ax, aop_pop);
! }
else
ax_simple (ax, aop_pop);
}