1# ByTrace<a name="EN-US_TOPIC_0000001102209942"></a> 2 3- [Introduction](#section152771918494) 4- [Architecture](#section6808195518497) 5- [Directory Structure](#section1610792125019) 6- [Usage](#section18684185975017) 7- [Repositories Involved](#section1849151125618) 8 9## Introduction<a name="section152771918494"></a> 10 11ByTrace 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: 12 131. APIs: When developing an application, you can call ByTrace APIs in the application key code to perform tracing. 142. 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. 15 16## Architecture<a name="section6808195518497"></a> 17 18 19 20## Directory Structure<a name="section1610792125019"></a> 21 22``` 23/developtools/bytrace 24├── bin # ByTrace code 25│ └── include # Header files 26│ └── src # Source files 27│ └── test # Test cases 28├── interfaces # APIs 29│ └── innerkits # Header files of internal subsystems 30│ └── kits # Header files exposed externally 31├── script # Scripts 32``` 33 34## Usage<a name="section18684185975017"></a> 35 36The following table lists the commands supported by ByTrace. 37 38** Table 1** Commands supported by ByTrace 39 40| Option | Description | 41|---------|------------| 42| -h, --help | Views the help Information. | 43| -b n, --buffer_size n | Sets the size of the buffer (KB) for storing and reading traces. The default buffer size is 2048 KB. | 44| -t n, --time n | Sets the ByTrace uptime in seconds, which depends on the time required for analysis. | 45| --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. | 46| --trace_begin | Starts trace. | 47| --trace_dump | Dumps traced data to a specified position (the default position is the console). | 48| --trace_finish | Stops capturing traces and dumps traced data to a specified position (the default position is the console). | 49| -l, --list_categories | Lists the ByTrace categories supported by the device. | 50| --overwrite | Sets the action to take when the buffer is full. If this option is used, the latest traced data is discarded. | 51| -o filename, --output filename | Outputs traced data to a specified file. | 52| -z | Compresses traced data. | 53 54The following are some example ByTrace commands: 55 56- Run the following command to query supported labels: 57 58 ``` 59 bytrace -l 60 ``` 61 62 or 63 64 ``` 65 bytrace --list_categories 66 ``` 67 68 69- Run the following command to capture traces whose label is <strong>ability</strong>, with the buffer size set to 4096 KB and ByTrace uptime set to 10s: 70 71 ``` 72 bytrace -b 4096 -t 10 --overwrite ability > /data/mytrace.ftrace 73 ``` 74 75 76- Run the following command to set the clock type for traces to <strong>mono</strong>: 77 78 ``` 79 bytrace --trace_clock mono -b 4096 -t 10 --overwrite ability > /data/mytrace.ftrace 80 ``` 81 82 83- Run the following command to compress the traced data: 84 85 ``` 86 bytrace -z -b 4096 -t 10 --overwrite ability > /data/mytrace.ftrace 87 ``` 88 89 90## Repositories Involved<a name="section1849151125618"></a> 91 92[Development Tools Subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/development-toolchain.md) 93 94**developtools\_bytrace\_standard** 95