mirror of
https://github.com/openharmony/ark_runtime_core.git
synced 2026-07-18 10:18:07 -04:00
14c9021696
Signed-off-by: wanyanglan <wanyanglan1@huawei.com> Change-Id: I2564094cef9c6c41263e37faf9ffbbec14223dc7
1.3 KiB
1.3 KiB
Panda Tracing
This document describes the Panda trace subsystem. The subsystem provides an API for creating tracepoints to track key points in the runtime. The subsystem uses the ftrace ring buffer to record the trace.
API
The Trace API is described in the libpandabase/trace/trace.h file. It supports tracing a scope execution time and tracking a parameter value.
Usage examples:
...
#include "trace/trace.h"
...
void FunctionA() {
trace::ScopedTrace scoped_trace("Loading file");
...
}
void FunctionB() {
trace::ScopedTrace scoped_trace(__func__);
...
}
void FunctionC() {
SCOPED_TRACE_STREAM << "Trace: " << __func__;
...
}
void FunctionD() {
trace::BeginTracePoint(__func__);
...
trace::EndTracePoint();
}
void FunctionE(int allocated_bytes) {
trace::IntTracePoint("Heap Size", allocated_bytes);
...
}
Recording a trace
To record and view a trace, perform the following steps:
- Enable tracing by running the following command:
sudo scripts/trace_enable.sh <output_file> <trace_time_in_seconds>
- Launch the runtime with an extra environment variable:
PANDA_TRACE=1 panda <args>
- Stop tracing by ^C if the trace time is still running out.
- Load <output_file> in Chrome at the
chrome://tracingaddress.