[PATCH] Collect return addresses at tracepoints

Stan Shebs stanshebs@earthlink.net
Wed Sep 21 22:48:00 GMT 2011


This patch introduces a new tracepoint collection directive $_ret, which 
asks for the collection of the return address stored in the current 
stack frame.  It's not the complete solution for what users really want, 
which is to collect several frames of the stack, but that's hard to get 
right without adding a fancy unwinder to the tracepoint agent.  This is 
much simpler, needing only an architecture-specific method to generate 
appropriate bytecodes.

Not too much controversial here - the testsuite exercises the code, but 
it won't fail the test if the caller's name doesn't appear in the 
backtrace, since we can't guarantee that the method's heuristic will 
always work.

I'll commit this in a few days if there are no objections.

Stan
stan@codesourcery.com

2011-09-21  Stan Shebs <stan@codesourcery.com>

     Add return address collection for tracepoints.
     * tracepoint.c (encode_actions_1): Add case for $_ret.
     (validate_actionline): Check for $_ret.
     (trace_dump_actions): Ditto.
     * ax-gdb.h (gen_trace_for_return_address): Declare.
     * ax-gdb.c: Include arch-utils.h.
     (gen_trace_for_return_address): New function.
     (agent_command): Add return address special case.
     * amd64-tdep.c: Include ax.h and ax-gdb.h.
     (amd64_gen_return_address): New function.
     (amd64_init_abi): Call it.
     * i386-tdep.c: Include ax.h and ax-gdb.h.
     (i386_gen_return_address): New function.
     (i386_init_abi): Call it.
     * arch-utils.h (default_gen_return_address): Declare.
     * arch-utils.c (default_gen_return_address): New function.
     * gdbarch.sh (gen_return_address): New method.
     * gdbarch.h, gdbarch.c: Regenerate.

     * gdb.texinfo (Tracepoint Action Lists): Document $_ret.

     * gdb.trace/collection.exp: Test collection of $_ret.


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: tret-patch-1
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20110921/70a69180/attachment.ksh>


More information about the Gdb-patches mailing list