ITrace (Instruction Trace) is a software tracing mechanism that runs
on Windows and Linux. ITRACE is part of the performance
tools packages. It uses the software trace facility (swtrace) to
allocate a buffer, capture MTE information and write branch trace
records. It then uses post to format the swtrace output
into callflow reports. ITRACE traces through application and kernel
code, and it can also trace IBM's Java jitted code.
How ITRACE worksITRACE tracing gives you the ability to single step trace your application in Ring 3 and kernel code.You can enable tracing of:
ITRACE, in association with swtrace, A2N, and post can give you "arc" reports for your application. post can also dump the single step flow if needed (post -ss). ITRACE branch tracing works in concert with the software trace facility to trace ring 3 and ring 0 instructions. ITRACE uses the normal swtrace buffer and trace formats to record the last branch that executed. It uses the IA32/64 single step trap and branch flags to stop the application flow and write out a callflow hook. This hook includes time stamp, To and From addresses. ITRACE can also step through system calls, page faults and device drivers. When branch tracing through an application or system calls the machine is slowed down tremendously writing the instruction information to the buffer. This will change the characteristics of the system while tracing, to try and counter balance some of this we have added the ability to reduce the amount of timer ticks processed using a skip_count when tracing is turned on (currently not supported on Linux).
ITRACE tracing is turned on using two steps: It is advisable to "warm-up" the code to be traced. This will reduce the amount of page fault processing that is traced. This is true in both C and Java code where the code path to be examined can be contained in a loop. Also note that with Java, the JIT code path will be traced the first "X" times that a method is jitted. It is advisable to try and keep the trace scenario as simple as possible and limit the amount of pids to trace. |
ITRACE writes two types of hooks to the swtrace buffer, one that
contains branch information for every traced branch and the other
when a traced pid changes.
It also uses the swtrace MTE hooks for post-processing name
resolution.
For ITRACE support, install the platform appropriate package. See the Installing Performance Inspector page for available packages.
The following section assumes swtrace or swtrace.exe resides either in a directory listed in the PATH environment variable, or it resides in the current directory.
swtrace
must be initialized using the
To initialize swtrace and initialize ITrace:
swtrace init -s 30
swtrace it_install
swtrace disable
At this point swtrace has created the trace buffer(s) and
initialized everything needed to start instruction tracing. The next
step is to start the trace, by calling perfutil ITRACE APIs.
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> #include "perfutil.h" int main(int argc, char* argv[])> { ITraceDisable(); ITraceEnableCurrent(); ITraceOn(); // code to be traced ... ITraceOff(); }
Java execution can also be traced, JPROF is used to gather Java naming and code information on jitted methods. post uses this information to "reconstruct" code execution of the jitted methods. To enable JPROF, start Java in one of the following ways:
You can enable/disable pids and turn on/off ITRACE directly from your Java application, using Java ITRACE APIs.
After tracing has completed and swtrace has been turned off,
use the
To capture the contents of the trace buffer to file swtrace.nrm2 and post-process it, enter:
swtrace get
post -arc
ITRACE swtrace Command Examples
1. Initialize swtrace swtrace init -s 10 setting the buffer size to 10 MB per CPU. 2. Install ITRACE support. swtrace it_install 3. Disable all of the performance trace hooks. swtrace disable 4. Turn swtrace on. swtrace on 5. Run the desired program with ITRACE enable/disable, on/off. execute the program to trace 6. When ITRACE completes, or at the swtrace off appropriate time, turn off swtrace. 7. Get a copy of the trace information swtrace get from all processors. 8. If all tracing is complete, you could swtrace free now free the trace buffers. 9. Generate readable trace data. post -arc -ss 10. Remove ITRACE support. swtrace it_remove
post
is used to format the swtrace buffer output, swtrace.nrm2 into
codeflow reports. It can produce post.show, arc and ptree files. The
ITRACE
options are -arc which creates an "arc" file. This is a generic2
file, which is a function call report. The -arc option along with
the -ss option will produce the
function call report along with disassembled instructions. The "ptree"
option will produce the prunned tree report which is a reduced callflow
report.
See post documentation for more detail (also post -?).