mirror of
https://gitee.com/openharmony/developtools_bytrace
synced 2024-11-22 22:51:24 +00:00
a4e91f5056
Merge pull request !150 from Federer-JC/master |
||
---|---|---|
figures | ||
script | ||
.gitattributes | ||
bundle.json | ||
bytrace.gni | ||
LICENSE | ||
OAT.xml | ||
README_zh.md | ||
README.md |
ByTrace
Introduction
ByTrace is a tool for you to trace processes and monitor performance. It encapsulates and extends the ftrace in the kernel and supports tracing in the user space. This tool provides APIs and commands:
- APIs: When developing an application, you can call ByTrace APIs in the application key code to perform tracing.
- Commands: You can enable the desired label to obtain the tracing information. With ByTrace, you can enable a user-space or kernel-space label you want to view (run the bytrace -l command to query all the supported labels) and run the corresponding commands to capture traces and dump them to a specified file.
Architecture
Directory Structure
/developtools/bytrace
├── bin # ByTrace code
│ └── include # Header files
│ └── src # Source files
│ └── test # Test cases
├── interfaces # APIs
│ └── innerkits # Header files of internal subsystems
│ └── kits # Header files exposed externally
├── script # Scripts
Usage
The following table lists the commands supported by ByTrace.
** Table 1** Commands supported by ByTrace
Option | Description |
---|---|
-h, --help | Views the help Information. |
-b n, --buffer_size n | Sets the size of the buffer (KB) for storing and reading traces. The default buffer size is 2048 KB. |
-t n, --time n | Sets the ByTrace uptime in seconds, which depends on the time required for analysis. |
--trace_clock clock | Sets the type of the clock for adding a timestamp to a trace, which can be boot (default), global, mono, uptime, or perf. |
--trace_begin | Starts trace. |
--trace_dump | Dumps traced data to a specified position (the default position is the console). |
--trace_finish | Stops capturing traces and dumps traced data to a specified position (the default position is the console). |
-l, --list_categories | Lists the ByTrace categories supported by the device. |
--overwrite | Sets the action to take when the buffer is full. If this option is used, the latest traced data is discarded. |
-o filename, --output filename | Outputs traced data to a specified file. |
-z | Compresses traced data. |
The following are some example ByTrace commands:
-
Run the following command to query supported labels:
bytrace -l
or
bytrace --list_categories
-
Run the following command to capture traces whose label is ability, with the buffer size set to 4096 KB and ByTrace uptime set to 10s:
bytrace -b 4096 -t 10 --overwrite ability > /data/mytrace.ftrace
-
Run the following command to set the clock type for traces to mono:
bytrace --trace_clock mono -b 4096 -t 10 --overwrite ability > /data/mytrace.ftrace
-
Run the following command to compress the traced data:
bytrace -z -b 4096 -t 10 --overwrite ability > /data/mytrace.ftrace
Repositories Involved
developtools_bytrace_standard