• Home
Name Date Size #Lines LOC

..--

figures/12-May-2024-

interfaces/kits/12-May-2024-413267

script/12-May-2024-159129

.gitattributesD12-May-2024631 1615

LICENSED12-May-20249.9 KiB178150

OAT.xmlD12-May-20243.9 KiB6310

README.mdD12-May-20243.6 KiB9564

README_zh.mdD12-May-20243.3 KiB9865

bundle.jsonD12-May-2024732 3837

bytrace.gniD12-May-2024734 1915

README.md

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![](figures/architecture.png)
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

README_zh.md

1# bytrace组件<a name="ZH-CN_TOPIC_0000001102209942"></a>
2
3-   [简介](#section152771918494)
4-   [架构图](#section6808195518497)
5-   [目录](#section1610792125019)
6-   [说明](#section18684185975017)
7-   [相关仓](#section1849151125618)
8
9## 简介<a name="section152771918494"></a>
10
11bytrace是开发人员用于追踪进程轨迹、查看性能的一种工具,主要对内核ftrace进行了封装和扩展,来支持用户态的打点。该工具主要分为两部分,API和命令行:
12
131.  bytrace向应用开发人员暴露了打点的API,开发应用过程中可以在关键代码处调用对应API进行打点;
142.  命令行部分通过使能对应的label,来获取打点信息。通过该工具可以打开想要查看的用户态和内核label(通过命令行“bytrace -l”,查看支持的所有label),然后通过命令行进行抓取trace信息到指定文件中,下文有具体使用指导。
15
16## 架构图<a name="section6808195518497"></a>
17
18![](figures/architecture_zh.png)
19
20## 目录<a name="section1610792125019"></a>
21
22```
23/developtools/bytrace
24├── bin           # bytrace组件代码目录
25│   └── include   # 头文件目录
26│   └── src       # 源文件目录
27│   └── test      # 测试用例目录
28├── interfaces    # 对外接口存放目录
29│   └── innerkits # 对内部子系统暴露的头文件存放目录
30│   └── kits      # 对外部暴露的头文件存放目录
31├── script        # 脚本目录
32```
33
34## 说明<a name="section18684185975017"></a>
35
36使用说明
37
38bytrace当前支持如下命令:
39
40**表 1**  命令行列表
41
42| Option | Description |
43|--------|------------|
44| -h,--help | 查看option帮助 |
45| -b n,--buffer_size n | 指定n(KB)内存大小用于存取trace日志,默认2048KB |
46| -t n,--time n | 用来指定trace运行的时间(单位:s),取决于需要分析过程的时间 |
47| --trace_clock clock | trace输出的时钟类型,一般设备支持boot、global、mono、uptime、perf等,默认为boot |
48| --trace_begin | 启动抓trace |
49| --trace_dump | 将数据输出到指定位置(默认控制台) |
50| --trace_finish | 停止抓trace,并将数据输出到指定位置(默认控制台) |
51| -l,--list_categories | 输出手机能支持的trace模块 |
52| --overwrite | 当缓冲区满的时候,将丢弃最新的信息。(默认丢弃最老的日志) |
53| -o filename,--output filename | 指定输出的目标文件名称 |
54| -z | 抓取trace后进行压缩 |
55
56以下是常用bytrace命令示例,供开发者参考:
57
58-   查询支持的label。
59
60    ```
61    bytrace -l
62    ```
63
64    或者
65
66    ```
67    bytrace --list_categories
68    ```
69
70
71-   设置4M缓存,抓取10秒,抓取label为ability的trace信息。
72
73    ```
74    bytrace -b 4096 -t 10 --overwrite ability > /data/mytrace.ftrace
75    ```
76
77
78-   设置trace的输出时钟为mono。
79
80    ```
81    bytrace --trace_clock mono  -b 4096 -t 10 --overwrite ability > /data/mytrace.ftrace
82    ```
83
84
85-   抓取trace后进行压缩。
86
87    ```
88    bytrace -z  -b 4096 -t 10 --overwrite ability > /data/mytrace.ftrace
89    ```
90
91
92## 相关仓<a name="section1849151125618"></a>
93
94[研发工具链子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E7%A0%94%E5%8F%91%E5%B7%A5%E5%85%B7%E9%93%BE%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
95
96**developtools\_bytrace\_standard**
97
98