Systrace

by groleo

Now, a bit on the systrace tool.
systrace

It’s based on the trace_marker mechanism. This means that a program can write to $DEBUGFS/tracing/trace_marker, and whatever text it wrote to that,
it will appear in $DEBUGFS/tracing/trace.
So, in Trace.h, a helper macro is defined, ATRACE_CALL() which allocates a Tracer object on stack.
In its constructor, traceBegin is called, while in its destructor, traceEnd.
After a check to see what tracing tag is enabled, each of the two functions (traceBegin and traceEnd)
will write a string to $DEBUGFS/tracing/trace_marker.
The string looks like “B|getpid()|__func__” for traceBegin
and “E|getpid()|__func__” for traceEnd.

At a later stage, systrace.py reads the trace buffer(the green path in the diagram) using the atrace tool found on device, and puts it in an HTML file.
The generated HTML parses the trace content and provide a nice view of the trace.

SystraceScreenshot__cropped__large_verge_medium_landscape

Advertisements