public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* proposed instruction trace support in SystemTap
@ 2007-07-02 23:01 Dave Nomura
  2007-07-05 19:37 ` Frank Ch. Eigler
  2007-07-06 21:39 ` Maynard Johnson
  0 siblings, 2 replies; 27+ messages in thread
From: Dave Nomura @ 2007-07-02 23:01 UTC (permalink / raw)
  To: systemtap

PROPOSED INSTRUCTION TRACING INTEGRATION INTO SYSTEMTAP
A user would write a stap script that identified where to turn on 
instruction tracing and where to turn it off.  The stap script could be 
invoked via: stap <user_script>.stp -b -M -c "<some program>" -o 
<trace_data>
to allow the stap script to access the pid to trace, although other 
usage modes are also possible.  Some enhancements to the stap translator 
are suggested below to support instruction tracing.

SINGLE_STEP/BRANCH TRAP HANDLER
The user's stap script would also need to define an instruction trace 
handler and insert their own body for the handler.  This might look like:
probe single_step label("single_step handler 1")
{
        <do whatever you want for each single stepped instruction>
        itrace_output();        // write itrace binary output
}

probe branch_step label("branch handler 1")
{
        <do whatever you want for each branch instruction>
        itrace_output();        // write itrace binary output
}

where "label" is an language extension to attach a name to a instruction 
trace probe that would allow you to have different instruction trace 
handlers for different instruction trace probes.  There would only be 
one single_step trap handler but it would use the label to decide which 
code to execute from the user's stap script.

The itrace_output() is a function that produces the raw trace data that 
could then be post processed for consumption by various performance 
analysis tools but the user could do something as simple as printing out 
the PC value.  It might be nice if there was some way to name the relay 
streams so that they aren't intermingled.  Maybe something analogous to 
the stream parameter to fprintf.

The SystemTap translator would generate calls to target dependent code 
to implement single instruction or branch trapping.  This is done a 
variety of ways on different architectures, but generally involves 
setting a bit in a system register to enable single instruction/branch 
trapping.


TURNING ON/OFF TRACING
The user's stap script would turn on/off instruction tracing by creating 
a uprobe containing a call to a SystemTap itrace tapset function for 
turning on/off instruction tracing.  I don't know what SystemTap's 
uprobe interface will look like but it might be something like:
probe process(target()).function(
"function_to_trace")
{
        itrace_on_pid("single step handler 1", pid())
}

probe process(target()).function("function_to_trace").return
{
        itrace_off(pid())
}

Note:
- instruction tracing enabled for a parent process id will enable 
tracing for all of its children (threads). Since uprobes are on a 
per-process basis rather than per-thread, instruction tracing would be 
constrained to the same semantics, although it would be possible for a 
user to write their single step handler to treat some threads individually.
- The "single step handler 1" parameter is the label attached to the 
instruction trace handler above to allow one to have different handlers 
for different instruction trace probes.

INITIALIZATION/CLEANUP
Initialization/cleanup of the instruction tracing feature could be done 
by insertion of a call to an itrace initialilzation/cleanup routine in 
the user's begin/end probes.

probe begin
{
        itrace_init(<some params>)
}

probe end
{
        itrace_cleanup()
}

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

end of thread, other threads:[~2007-09-06 14:05 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-02 23:01 proposed instruction trace support in SystemTap Dave Nomura
2007-07-05 19:37 ` Frank Ch. Eigler
2007-07-06 12:46   ` grundy
2007-07-06 14:59     ` Frank Ch. Eigler
2007-07-06 21:43   ` Maynard Johnson
2007-07-07  1:58     ` Frank Ch. Eigler
2007-07-10 15:47       ` Maynard Johnson
2007-07-10 14:12   ` Dave Nomura
2007-07-10 14:39     ` Frank Ch. Eigler
2007-07-10 20:57       ` Maynard Johnson
2007-07-10 22:45         ` Jim Keniston
2007-07-11  4:31         ` Ananth N Mavinakayanahalli
2007-08-20  0:34       ` Dave Nomura
2007-08-20  0:37         ` Roland McGrath
2007-08-25 11:34           ` Dave Nomura
2007-08-29 14:57             ` Frank Ch. Eigler
2007-08-30  5:43               ` kernel API for in-kernel single stepping Dave Nomura
2007-08-30 13:05                 ` Paul Mackerras
2007-09-04  3:05                   ` Frank Ch. Eigler
2007-09-05  5:02                     ` Dave Nomura
2007-08-29 15:40           ` proposed instruction trace support in SystemTap Dave Nomura
2007-08-29 16:25             ` Frank Ch. Eigler
2007-09-06  2:57           ` using utrace for instruction tracing Dave Nomura
2007-09-06 14:05             ` Jim Keniston
2007-09-06 18:28               ` Dave Nomura
2007-08-23 22:10         ` proposed instruction trace support in SystemTap Dave Nomura
2007-07-06 21:39 ` Maynard Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).