mirror of
https://github.com/openharmony/developtools_bytrace.git
synced 2026-07-16 06:55:39 -04:00
Merge branch 'master' of gitee.com:openharmony/developtools_bytrace into master
This commit is contained in:
@@ -20,7 +20,7 @@ ByTrace is a tool for you to trace processes and monitor performance. It encapsu
|
||||
## Directory Structure<a name="section1610792125019"></a>
|
||||
|
||||
```
|
||||
/developtools/bytrace_standard
|
||||
/developtools/bytrace
|
||||
├── bin # ByTrace code
|
||||
│ └── include # Header files
|
||||
│ └── src # Source files
|
||||
@@ -37,70 +37,19 @@ The following table lists the commands supported by ByTrace.
|
||||
|
||||
** Table 1** Commands supported by ByTrace
|
||||
|
||||
<a name="table16802195914247"></a>
|
||||
<table><thead align="left"><tr id="row14804759142412"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1280465972411"><a name="p1280465972411"></a><a name="p1280465972411"></a>Option</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p380414595249"><a name="p380414595249"></a><a name="p380414595249"></a>Description</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="row1714512123414"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1915412133419"><a name="p1915412133419"></a><a name="p1915412133419"></a>-h, --help</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p6156126341"><a name="p6156126341"></a><a name="p6156126341"></a>Views the help Information.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row13804135982416"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p18051959152410"><a name="p18051959152410"></a><a name="p18051959152410"></a>-b <em id="i35979186184"><a name="i35979186184"></a><a name="i35979186184"></a>n</em>, --buffer_size <em id="i144491624181811"><a name="i144491624181811"></a><a name="i144491624181811"></a>n</em></p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p0805165932419"><a name="p0805165932419"></a><a name="p0805165932419"></a>Sets the size of the buffer (KB) for storing and reading traces. The default buffer size is 2048 KB.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row580519592245"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p880510591241"><a name="p880510591241"></a><a name="p880510591241"></a>-t <em id="i8668143912203"><a name="i8668143912203"></a><a name="i8668143912203"></a>n</em>, --time <em id="i841433614202"><a name="i841433614202"></a><a name="i841433614202"></a>n</em></p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1480517591245"><a name="p1480517591245"></a><a name="p1480517591245"></a>Sets the ByTrace uptime in seconds, which depends on the time required for analysis.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row4806175913247"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p980655912242"><a name="p980655912242"></a><a name="p980655912242"></a>--trace_clock <em id="i19464452217"><a name="i19464452217"></a><a name="i19464452217"></a>clock</em></p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p11806959142416"><a name="p11806959142416"></a><a name="p11806959142416"></a>Sets the type of the clock for adding a timestamp to a trace, which can be <strong>boot</strong> (default), <strong>global</strong>, <strong>mono</strong>, <strong>uptime</strong>, or <strong>perf</strong>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1280635917242"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p180715591244"><a name="p180715591244"></a><a name="p180715591244"></a>--trace_begin</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p480795916243"><a name="p480795916243"></a><a name="p480795916243"></a>Starts trace.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1580717599245"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p38073598242"><a name="p38073598242"></a><a name="p38073598242"></a>--trace_dump</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p148077595245"><a name="p148077595245"></a><a name="p148077595245"></a>Dumps traced data to a specified position (the default position is the console).</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row180811592242"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p11808165922419"><a name="p11808165922419"></a><a name="p11808165922419"></a>--trace_finish</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18809559182420"><a name="p18809559182420"></a><a name="p18809559182420"></a>Stops capturing traces and dumps traced data to a specified position (the default position is the console).</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row2809185972420"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p2080925922418"><a name="p2080925922418"></a><a name="p2080925922418"></a>-l, --list_categories</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p38091159142414"><a name="p38091159142414"></a><a name="p38091159142414"></a>Lists the ByTrace categories supported by the device.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1880912598248"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1681014595244"><a name="p1681014595244"></a><a name="p1681014595244"></a>--overwrite</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p12810165914248"><a name="p12810165914248"></a><a name="p12810165914248"></a>Sets the action to take when the buffer is full. If this option is used, the latest traced data is discarded.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1181015992414"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p168101859152415"><a name="p168101859152415"></a><a name="p168101859152415"></a>-o <em id="i1367232742113"><a name="i1367232742113"></a><a name="i1367232742113"></a>filename</em>, --output <em id="i4305133012219"><a name="i4305133012219"></a><a name="i4305133012219"></a>filename</em></p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p9810559132410"><a name="p9810559132410"></a><a name="p9810559132410"></a>Outputs traced data to a specified file.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row8810155982415"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p381145912410"><a name="p381145912410"></a><a name="p381145912410"></a>-z</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1281117592249"><a name="p1281117592249"></a><a name="p1281117592249"></a>Compresses traced data.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
| 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:
|
||||
|
||||
@@ -140,6 +89,6 @@ The following are some example ByTrace commands:
|
||||
|
||||
## Repositories Involved<a name="section1849151125618"></a>
|
||||
|
||||
Development Tools Subsystem
|
||||
[Development Tools Subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/development-toolchain.md)
|
||||
|
||||
**developtools\_bytrace\_standard**
|
||||
|
||||
+15
-66
@@ -20,7 +20,7 @@ bytrace是开发人员用于追踪进程轨迹、查看性能的一种工具,
|
||||
## 目录<a name="section1610792125019"></a>
|
||||
|
||||
```
|
||||
/developtools/bytrace_standard
|
||||
/developtools/bytrace
|
||||
├── bin # bytrace组件代码目录
|
||||
│ └── include # 头文件目录
|
||||
│ └── src # 源文件目录
|
||||
@@ -39,70 +39,19 @@ bytrace当前支持如下命令:
|
||||
|
||||
**表 1** 命令行列表
|
||||
|
||||
<a name="table16802195914247"></a>
|
||||
<table><thead align="left"><tr id="row14804759142412"><th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.1"><p id="p1280465972411"><a name="p1280465972411"></a><a name="p1280465972411"></a>Option</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="50%" id="mcps1.2.3.1.2"><p id="p380414595249"><a name="p380414595249"></a><a name="p380414595249"></a>Description</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="row1714512123414"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1915412133419"><a name="p1915412133419"></a><a name="p1915412133419"></a>-h,--help</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p6156126341"><a name="p6156126341"></a><a name="p6156126341"></a>查看option帮助</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row13804135982416"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p18051959152410"><a name="p18051959152410"></a><a name="p18051959152410"></a>-b <em id="i35979186184"><a name="i35979186184"></a><a name="i35979186184"></a>n</em>,--buffer_size <em id="i144491624181811"><a name="i144491624181811"></a><a name="i144491624181811"></a>n</em></p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p0805165932419"><a name="p0805165932419"></a><a name="p0805165932419"></a>指定<em id="i134241333181817"><a name="i134241333181817"></a><a name="i134241333181817"></a>n</em>(KB)内存大小用于存取trace日志,默认2048KB</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row580519592245"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p880510591241"><a name="p880510591241"></a><a name="p880510591241"></a>-t <em id="i8668143912203"><a name="i8668143912203"></a><a name="i8668143912203"></a>n</em>,--time <em id="i841433614202"><a name="i841433614202"></a><a name="i841433614202"></a>n</em></p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1480517591245"><a name="p1480517591245"></a><a name="p1480517591245"></a>用来指定trace运行的时间(单位:s),取决于需要分析过程的时间</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row4806175913247"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p980655912242"><a name="p980655912242"></a><a name="p980655912242"></a>--trace_clock <em id="i19464452217"><a name="i19464452217"></a><a name="i19464452217"></a>clock</em></p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p11806959142416"><a name="p11806959142416"></a><a name="p11806959142416"></a>trace输出的时钟类型,一般设备支持boot、global、mono、uptime、perf等,默认为boot</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1280635917242"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p180715591244"><a name="p180715591244"></a><a name="p180715591244"></a>--trace_begin</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p480795916243"><a name="p480795916243"></a><a name="p480795916243"></a>启动抓trace</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1580717599245"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p38073598242"><a name="p38073598242"></a><a name="p38073598242"></a>--trace_dump</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p148077595245"><a name="p148077595245"></a><a name="p148077595245"></a>将数据输出到指定位置(默认控制台)</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row180811592242"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p11808165922419"><a name="p11808165922419"></a><a name="p11808165922419"></a>--trace_finish</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p18809559182420"><a name="p18809559182420"></a><a name="p18809559182420"></a>停止抓trace,并将数据输出到指定位置(默认控制台)</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row2809185972420"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p2080925922418"><a name="p2080925922418"></a><a name="p2080925922418"></a>-l,--list_categories</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p38091159142414"><a name="p38091159142414"></a><a name="p38091159142414"></a>输出手机能支持的trace模块</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1880912598248"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p1681014595244"><a name="p1681014595244"></a><a name="p1681014595244"></a>--overwrite</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p12810165914248"><a name="p12810165914248"></a><a name="p12810165914248"></a>当缓冲区满的时候,将丢弃最新的信息。(默认丢弃最老的日志)</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row1181015992414"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p168101859152415"><a name="p168101859152415"></a><a name="p168101859152415"></a>-o <em id="i1367232742113"><a name="i1367232742113"></a><a name="i1367232742113"></a>filename</em>,--output <em id="i4305133012219"><a name="i4305133012219"></a><a name="i4305133012219"></a>filename</em></p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p9810559132410"><a name="p9810559132410"></a><a name="p9810559132410"></a>指定输出的目标文件名称</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row8810155982415"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.1 "><p id="p381145912410"><a name="p381145912410"></a><a name="p381145912410"></a>-z</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.2.3.1.2 "><p id="p1281117592249"><a name="p1281117592249"></a><a name="p1281117592249"></a>抓取trace后进行压缩</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
| Option | Description |
|
||||
|--------|------------|
|
||||
| -h,--help | 查看option帮助 |
|
||||
| -b n,--buffer_size n | 指定n(KB)内存大小用于存取trace日志,默认2048KB |
|
||||
| -t n,--time n | 用来指定trace运行的时间(单位:s),取决于需要分析过程的时间 |
|
||||
| --trace_clock clock | trace输出的时钟类型,一般设备支持boot、global、mono、uptime、perf等,默认为boot |
|
||||
| --trace_begin | 启动抓trace |
|
||||
| --trace_dump | 将数据输出到指定位置(默认控制台) |
|
||||
| --trace_finish | 停止抓trace,并将数据输出到指定位置(默认控制台) |
|
||||
| -l,--list_categories | 输出手机能支持的trace模块 |
|
||||
| --overwrite | 当缓冲区满的时候,将丢弃最新的信息。(默认丢弃最老的日志) |
|
||||
| -o filename,--output filename | 指定输出的目标文件名称 |
|
||||
| -z | 抓取trace后进行压缩 |
|
||||
|
||||
以下是常用bytrace命令示例,供开发者参考:
|
||||
|
||||
@@ -142,7 +91,7 @@ bytrace当前支持如下命令:
|
||||
|
||||
## 相关仓<a name="section1849151125618"></a>
|
||||
|
||||
研发工具链子系统
|
||||
[研发工具链子系统](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)
|
||||
|
||||
**developtools\_bytrace\_standard**
|
||||
|
||||
|
||||
+15
-32
@@ -12,34 +12,13 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//developtools/bytrace_standard/bytrace.gni")
|
||||
|
||||
config("bytrace_lib_inner_config") {
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [ "${innerkits_path}/native/include" ]
|
||||
}
|
||||
|
||||
ohos_static_library("bytrace_inner") {
|
||||
sources = [ "./src/bytrace_impl.cpp" ]
|
||||
public_configs = [ ":bytrace_lib_inner_config" ]
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara",
|
||||
"startup_l2:syspara_watchagent",
|
||||
|
||||
#"distributedschedule:samgr_standard"
|
||||
]
|
||||
|
||||
subsystem_name = "developtools"
|
||||
part_name = "bytrace_standard"
|
||||
}
|
||||
import("//developtools/bytrace/bytrace.gni")
|
||||
|
||||
config("bytrace_osal_inner_config") {
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [
|
||||
"./include",
|
||||
"${innerkits_path}/native/include",
|
||||
"//base/hiviewdfx/hitrace/interfaces/native/innerkits/include/hitrace_meter",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -47,12 +26,12 @@ ohos_static_library("bytrace_osal_inner") {
|
||||
sources = [ "./src/bytrace_osal.cpp" ]
|
||||
public_configs = [ ":bytrace_osal_inner_config" ]
|
||||
external_deps = [
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"startup_l2:syspara",
|
||||
]
|
||||
|
||||
subsystem_name = "developtools"
|
||||
part_name = "bytrace_standard"
|
||||
part_name = "bytrace"
|
||||
}
|
||||
|
||||
ohos_executable("bytrace") {
|
||||
@@ -61,33 +40,37 @@ ohos_executable("bytrace") {
|
||||
|
||||
deps = [
|
||||
":bytrace_osal_inner",
|
||||
"${innerkits_path}/native:bytrace_core",
|
||||
"//third_party/zlib:libz",
|
||||
"//utils/native/base:utils",
|
||||
]
|
||||
|
||||
external_deps = [ "hitrace_native:hitrace_meter" ]
|
||||
|
||||
include_dirs = [
|
||||
"${bytrace_path}/bin/include",
|
||||
"${innerkits_path}/include",
|
||||
"//base/hiviewdfx/hitrace/interfaces/native/innerkits/include/hitrace_meter",
|
||||
"//utils/native/base/include",
|
||||
"//third_party/zlib",
|
||||
]
|
||||
subsystem_name = "developtools"
|
||||
part_name = "bytrace_standard"
|
||||
part_name = "bytrace"
|
||||
}
|
||||
|
||||
ohos_prebuilt_etc("bytrace.cfg") {
|
||||
source = "./config/bytrace.cfg"
|
||||
relative_install_dir = "init"
|
||||
subsystem_name = "developtools"
|
||||
part_name = "bytrace_standard"
|
||||
part_name = "bytrace"
|
||||
}
|
||||
|
||||
ohos_executable("bytrace_example") {
|
||||
sources = [ "example/bytrace_example.cpp" ]
|
||||
deps = [ "${innerkits_path}/native:bytrace_core" ]
|
||||
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||
external_deps = [
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
subsystem_name = "developtools"
|
||||
part_name = "bytrace_standard"
|
||||
part_name = "bytrace"
|
||||
}
|
||||
|
||||
group("bytrace_target") {
|
||||
|
||||
@@ -183,7 +183,7 @@
|
||||
"chmod 0666 /sys/kernel/tracing/per_cpu/cpu13/trace",
|
||||
"chmod 0666 /sys/kernel/tracing/per_cpu/cpu14/trace",
|
||||
"chmod 0666 /sys/kernel/tracing/per_cpu/cpu15/trace",
|
||||
"setparam debug.bytrace.tags.enableflags 0"
|
||||
"setparam debug.hitrace.tags.enableflags 0"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
#include "bytrace.h"
|
||||
#include "hitrace_meter.h"
|
||||
|
||||
using namespace std;
|
||||
namespace {
|
||||
@@ -26,7 +26,7 @@ constexpr int SLEEP_ONE_SECOND = 1;
|
||||
constexpr int SLEEP_TWO_SECOND = 2;
|
||||
constexpr int CYCLE_TIMES = 5;
|
||||
constexpr int32_t TASK_ID = 111;
|
||||
constexpr uint64_t LABEL = BYTRACE_TAG_OHOS;
|
||||
constexpr uint64_t LABEL = HITRACE_TAG_OHOS;
|
||||
|
||||
void FuncA()
|
||||
{
|
||||
@@ -45,7 +45,7 @@ void FuncC()
|
||||
cout << "funcC" << endl;
|
||||
int num = 0;
|
||||
for (int i = 0; i < CYCLE_TIMES; i++) {
|
||||
CountTrace(BYTRACE_TAG_OHOS, "count number", ++num);
|
||||
CountTrace(HITRACE_TAG_OHOS, "count number", ++num);
|
||||
sleep(SLEEP_ONE_SECOND);
|
||||
}
|
||||
}
|
||||
|
||||
+54
-28
@@ -30,7 +30,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <zlib.h>
|
||||
#include "bytrace.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "bytrace_osal.h"
|
||||
#include "securec.h"
|
||||
|
||||
@@ -49,11 +49,12 @@ struct option g_longOptions[] = {
|
||||
{ "trace_dump", no_argument, nullptr, 0 },
|
||||
{ "list_categories", no_argument, nullptr, 0 },
|
||||
{ "overwrite", no_argument, nullptr, 0 },
|
||||
{ nullptr, 0, nullptr, 0 },
|
||||
};
|
||||
const unsigned int CHUNK_SIZE = 65536;
|
||||
const int BLOCK_SIZE = 4096;
|
||||
|
||||
const string TRACE_TAG_PROPERTY = "debug.bytrace.tags.enableflags";
|
||||
const string TRACE_TAG_PROPERTY = "debug.hitrace.tags.enableflags";
|
||||
|
||||
// various operating paths of ftrace
|
||||
const string TRACING_ON_PATH = "tracing_on";
|
||||
@@ -80,7 +81,10 @@ bool g_compress = false;
|
||||
|
||||
string g_traceRootPath;
|
||||
|
||||
bool g_traceStart = true;
|
||||
const unsigned int START_NONE = 0;
|
||||
const unsigned int START_NORMAL = 1;
|
||||
const unsigned int START_ASYNC = 2;
|
||||
unsigned int g_traceStart = START_NORMAL;
|
||||
bool g_traceStop = true;
|
||||
bool g_traceDump = true;
|
||||
|
||||
@@ -436,15 +440,15 @@ static void ParseLongOpt(const string& cmd, int optionIndex, bool& isTrue)
|
||||
} else if (!strcmp(g_longOptions[optionIndex].name, "overwrite")) {
|
||||
g_overwrite = false;
|
||||
} else if (!strcmp(g_longOptions[optionIndex].name, "trace_begin")) {
|
||||
g_traceStart = true;
|
||||
g_traceStart = START_ASYNC;
|
||||
g_traceStop = false;
|
||||
g_traceDump = false;
|
||||
} else if (!strcmp(g_longOptions[optionIndex].name, "trace_finish")) {
|
||||
g_traceStart = false;
|
||||
g_traceStart = START_NONE;
|
||||
g_traceStop = true;
|
||||
g_traceDump = true;
|
||||
} else if (!strcmp(g_longOptions[optionIndex].name, "trace_dump")) {
|
||||
g_traceStart = false;
|
||||
g_traceStart = START_NONE;
|
||||
g_traceStop = false;
|
||||
g_traceDump = true;
|
||||
}
|
||||
@@ -561,11 +565,15 @@ static bool StartTrace()
|
||||
ClearTrace();
|
||||
printf("capturing trace...\n");
|
||||
fflush(stdout);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void WaitForTraceDone(void)
|
||||
{
|
||||
struct timespec ts = {0, 0};
|
||||
ts.tv_sec = g_traceDuration;
|
||||
ts.tv_nsec = 0;
|
||||
while ((nanosleep(&ts, &ts) == -1) && (errno == EINTR)) {}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool StopTrace()
|
||||
@@ -833,31 +841,45 @@ static void InitKernelSupportTags()
|
||||
static void InitAllSupportTags()
|
||||
{
|
||||
// OHOS
|
||||
g_tagMap["ohos"] = { "ohos", "OpenHarmony", BYTRACE_TAG_OHOS, USER, {}};
|
||||
g_tagMap["ability"] = { "ability", "Ability Manager", BYTRACE_TAG_ABILITY_MANAGER, USER, {}};
|
||||
g_tagMap["zcamera"] = { "zcamera", "OpenHarmony Camera Module", BYTRACE_TAG_ZCAMERA, USER, {}};
|
||||
g_tagMap["zmedia"] = { "zmedia", "OpenHarmony Media Module", BYTRACE_TAG_ZMEDIA, USER, {}};
|
||||
g_tagMap["zimage"] = { "zimage", "OpenHarmony Image Module", BYTRACE_TAG_ZIMAGE, USER, {}};
|
||||
g_tagMap["zaudio"] = { "zaudio", "OpenHarmony Audio Module", BYTRACE_TAG_ZAUDIO, USER, {}};
|
||||
g_tagMap["ohos"] = { "ohos", "OpenHarmony", HITRACE_TAG_OHOS, USER, {}};
|
||||
g_tagMap["ability"] = { "ability", "Ability Manager", HITRACE_TAG_ABILITY_MANAGER, USER, {}};
|
||||
g_tagMap["zcamera"] = { "zcamera", "OpenHarmony Camera Module", HITRACE_TAG_ZCAMERA, USER, {}};
|
||||
g_tagMap["zmedia"] = { "zmedia", "OpenHarmony Media Module", HITRACE_TAG_ZMEDIA, USER, {}};
|
||||
g_tagMap["zimage"] = { "zimage", "OpenHarmony Image Module", HITRACE_TAG_ZIMAGE, USER, {}};
|
||||
g_tagMap["zaudio"] = { "zaudio", "OpenHarmony Audio Module", HITRACE_TAG_ZAUDIO, USER, {}};
|
||||
g_tagMap["distributeddatamgr"] = { "distributeddatamgr", "Distributed Data Manager",
|
||||
BYTRACE_TAG_DISTRIBUTEDDATA, USER, {}};
|
||||
g_tagMap["mdfs"] = { "mdfs", "Mobile Distributed File System", BYTRACE_TAG_MDFS, USER, {}};
|
||||
g_tagMap["graphic"] = { "graphic", "Graphic Module", BYTRACE_TAG_GRAPHIC_AGP, USER, {}};
|
||||
g_tagMap["ace"] = { "ace", "ACE development framework", BYTRACE_TAG_ACE, USER, {}};
|
||||
g_tagMap["notification"] = { "notification", "Notification Module", BYTRACE_TAG_NOTIFICATION, USER, {}};
|
||||
g_tagMap["misc"] = { "misc", "Misc Module", BYTRACE_TAG_MISC, USER, {}};
|
||||
HITRACE_TAG_DISTRIBUTEDDATA, USER, {}};
|
||||
g_tagMap["mdfs"] = { "mdfs", "Mobile Distributed File System", HITRACE_TAG_MDFS, USER, {}};
|
||||
g_tagMap["graphic"] = { "graphic", "Graphic Module", HITRACE_TAG_GRAPHIC_AGP, USER, {}};
|
||||
g_tagMap["ace"] = { "ace", "ACE development framework", HITRACE_TAG_ACE, USER, {}};
|
||||
g_tagMap["notification"] = { "notification", "Notification Module", HITRACE_TAG_NOTIFICATION, USER, {}};
|
||||
g_tagMap["misc"] = { "misc", "Misc Module", HITRACE_TAG_MISC, USER, {}};
|
||||
g_tagMap["multimodalinput"] = { "multimodalinput", "Multimodal Input Module",
|
||||
BYTRACE_TAG_MULTIMODALINPUT, USER, {}};
|
||||
g_tagMap["sensors"] = { "sensors", "Sensors Module", BYTRACE_TAG_SENSORS, USER, {}};
|
||||
g_tagMap["msdp"] = { "msdp", "Multimodal Sensor Data Platform", BYTRACE_TAG_MSDP, USER, {}};
|
||||
g_tagMap["dsoftbus"] = { "dsoftbus", "Distributed Softbus", BYTRACE_TAG_DSOFTBUS, USER, {}};
|
||||
g_tagMap["rpc"] = { "rpc", "RPC and IPC", BYTRACE_TAG_RPC, USER, {}};
|
||||
g_tagMap["ark"] = { "ark", "ARK Module", BYTRACE_TAG_ARK, USER, {}};
|
||||
g_tagMap["window"] = { "window", "Window Manager", BYTRACE_TAG_WINDOW_MANAGER, USER, {}};
|
||||
g_tagMap["app"] = { "app", "APP Module", BYTRACE_TAG_APP, USER, {}};
|
||||
HITRACE_TAG_MULTIMODALINPUT, USER, {}};
|
||||
g_tagMap["sensors"] = { "sensors", "Sensors Module", HITRACE_TAG_SENSORS, USER, {}};
|
||||
g_tagMap["msdp"] = { "msdp", "Multimodal Sensor Data Platform", HITRACE_TAG_MSDP, USER, {}};
|
||||
g_tagMap["dsoftbus"] = { "dsoftbus", "Distributed Softbus", HITRACE_TAG_DSOFTBUS, USER, {}};
|
||||
g_tagMap["rpc"] = { "rpc", "RPC and IPC", HITRACE_TAG_RPC, USER, {}};
|
||||
g_tagMap["ark"] = { "ark", "ARK Module", HITRACE_TAG_ARK, USER, {}};
|
||||
g_tagMap["window"] = { "window", "Window Manager", HITRACE_TAG_WINDOW_MANAGER, USER, {}};
|
||||
g_tagMap["accessibility"] = { "accessibility", "Accessibility Manager",
|
||||
HITRACE_TAG_ACCESSIBILITY_MANAGER, USER, {}};
|
||||
g_tagMap["account"] = { "account", "Account Manager", HITRACE_TAG_ACCOUNT_MANAGER, USER, {}};
|
||||
g_tagMap["dhfwk"] = { "dhfwk", "Distributed Hardware FWK", HITRACE_TAG_DISTRIBUTED_HARDWARE_FWK, USER, {}};
|
||||
g_tagMap["dscreen"] = { "dscreen", "Distributed Screen", HITRACE_TAG_DISTRIBUTED_SCREEN, USER, {}};
|
||||
g_tagMap["dcamera"] = { "dcamera", "Distributed Camera", HITRACE_TAG_DISTRIBUTED_CAMERA, USER, {}};
|
||||
g_tagMap["dinput"] = { "dinput", "Distributed Input", HITRACE_TAG_DISTRIBUTED_INPUT, USER, {}};
|
||||
g_tagMap["devicemanager"] = { "devicemanager", "Device Manager", HITRACE_TAG_DEVICE_MANAGER, USER, {}};
|
||||
g_tagMap["deviceprofile"] = { "deviceprofile", "Device Profile", HITRACE_TAG_DEVICE_PROFILE, USER, {}};
|
||||
g_tagMap["dsched"] = { "dsched", "Distributed Schedule", HITRACE_TAG_DISTRIBUTED_SCHEDULE, USER, {}};
|
||||
g_tagMap["samgr"] = { "samgr", "samgr", HITRACE_TAG_SAMGR, USER, {}};
|
||||
g_tagMap["app"] = { "app", "APP Module", HITRACE_TAG_APP, USER, {}};
|
||||
g_tagMap["zbinder"] = { "zbinder", "OpenHarmony binder communication", 0, KERNEL, {
|
||||
{ "events/zbinder/enable" },
|
||||
}};
|
||||
g_tagMap["gresource"] = { "gresource", "Global Resource Manager", HITRACE_TAG_GLOBAL_RESMGR, USER, {}};
|
||||
g_tagMap["power"] = { "power", "Power Manager", HITRACE_TAG_POWER, USER, {}};
|
||||
g_tagMap["filemanagement"] = { "filemanagement", "filemanagement", HITRACE_TAG_FILEMANAGEMENT, USER, {}};
|
||||
|
||||
// Kernel os
|
||||
InitKernelSupportTags();
|
||||
@@ -895,9 +917,13 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
bool isTrue = true;
|
||||
if (g_traceStart) {
|
||||
if (g_traceStart != START_NONE) {
|
||||
SetViewStyle();
|
||||
isTrue = isTrue && StartTrace();
|
||||
if (g_traceStart == START_ASYNC) {
|
||||
return isTrue ? 0 : -1;
|
||||
}
|
||||
WaitForTraceDone();
|
||||
}
|
||||
|
||||
isTrue = isTrue && MarkOthersClockSync();
|
||||
|
||||
@@ -1,239 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <atomic>
|
||||
#include <cinttypes>
|
||||
#include <climits>
|
||||
#include <fcntl.h>
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
#include "bytrace.h"
|
||||
#include "hilog/log.h"
|
||||
#include "parameter.h"
|
||||
#include "parameters.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace OHOS::HiviewDFX;
|
||||
|
||||
#define EXPECTANTLY(exp) (__builtin_expect(!!(exp), true))
|
||||
#define UNEXPECTANTLY(exp) (__builtin_expect(!!(exp), false))
|
||||
|
||||
namespace {
|
||||
int g_markerFd = -1;
|
||||
std::once_flag g_onceFlag;
|
||||
|
||||
std::atomic<bool> g_isBytraceInit(false);
|
||||
std::atomic<uint64_t> g_tagsProperty(BYTRACE_TAG_NOT_READY);
|
||||
|
||||
const std::string KEY_TRACE_TAG = "debug.bytrace.tags.enableflags";
|
||||
const std::string KEY_APP_NUMBER = "debug.bytrace.app_number";
|
||||
const std::string KEY_RO_DEBUGGABLE = "ro.debuggable";
|
||||
|
||||
constexpr int NAME_MAX_SIZE = 1000;
|
||||
static std::vector<std::string> g_markTypes = {"B", "E", "S", "F", "C"};
|
||||
enum MarkerType { MARKER_BEGIN, MARKER_END, MARKER_ASYNC_BEGIN, MARKER_ASYNC_END, MARKER_INT, MARKER_MAX };
|
||||
|
||||
constexpr uint64_t BYTRACE_TAG = 0xd03301;
|
||||
constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, BYTRACE_TAG, "BytraceCore"};
|
||||
|
||||
static void ParameterChange(const char* key, const char* value, void* context)
|
||||
{
|
||||
HiLog::Info(LABEL, "Trace param %{public}s change notified", key);
|
||||
UpdateTraceLabel();
|
||||
}
|
||||
|
||||
bool IsAppValid()
|
||||
{
|
||||
// Judge if application-level tracing is enabled.
|
||||
if (OHOS::system::GetBoolParameter(KEY_RO_DEBUGGABLE, 0)) {
|
||||
std::ifstream fs;
|
||||
fs.open("/proc/self/cmdline");
|
||||
if (!fs.is_open()) {
|
||||
fprintf(stderr, "IsAppValid, open /proc/self/cmdline failed.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string lineStr;
|
||||
std::getline(fs, lineStr);
|
||||
std::string keyPrefix = "debug.bytrace.app_";
|
||||
int nums = OHOS::system::GetIntParameter<int>(KEY_APP_NUMBER, 0);
|
||||
for (int i = 0; i < nums; i++) {
|
||||
std::string keyStr = keyPrefix + std::to_string(i);
|
||||
std::string val = OHOS::system::GetParameter(keyStr, "");
|
||||
if (val == "*" || val == lineStr) {
|
||||
fs.close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t GetSysParamTags()
|
||||
{
|
||||
// Get the system parameters of KEY_TRACE_TAG.
|
||||
uint64_t tags = OHOS::system::GetUintParameter<uint64_t>(KEY_TRACE_TAG, 0);
|
||||
if (tags == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
IsAppValid();
|
||||
return (tags | BYTRACE_TAG_ALWAYS) & BYTRACE_TAG_VALID_MASK;
|
||||
}
|
||||
|
||||
// open file "trace_marker".
|
||||
void OpenTraceMarkerFile()
|
||||
{
|
||||
const std::string debugFile = "/sys/kernel/debug/tracing/trace_marker";
|
||||
const std::string traceFile = "/sys/kernel/tracing/trace_marker";
|
||||
g_markerFd = open(debugFile.c_str(), O_WRONLY | O_CLOEXEC);
|
||||
if (g_markerFd == -1) {
|
||||
g_markerFd = open(traceFile.c_str(), O_WRONLY | O_CLOEXEC);
|
||||
if (g_markerFd == -1) {
|
||||
HiLog::Error(LABEL, "open trace file %{public}s failed: %{public}d", traceFile.c_str(), errno);
|
||||
g_tagsProperty = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
g_tagsProperty = GetSysParamTags();
|
||||
if (g_tagsProperty == 0 || (g_tagsProperty & BYTRACE_TAG_VALID_MASK) == BYTRACE_TAG_ALWAYS) {
|
||||
HiLog::Info(LABEL, "Get trace param value zero firstly");
|
||||
}
|
||||
|
||||
if (WatchParameter(KEY_TRACE_TAG.c_str(), ParameterChange, nullptr) != 0) {
|
||||
HiLog::Error(LABEL, "WatchParameter %{public}s failed", KEY_TRACE_TAG.c_str());
|
||||
return;
|
||||
}
|
||||
g_isBytraceInit = true;
|
||||
}
|
||||
}; // namespace
|
||||
|
||||
void AddBytraceMarker(MarkerType type, uint64_t tag, const std::string& name, const std::string& value)
|
||||
{
|
||||
if (UNEXPECTANTLY(!g_isBytraceInit)) {
|
||||
std::call_once(g_onceFlag, OpenTraceMarkerFile);
|
||||
}
|
||||
if (UNEXPECTANTLY(g_tagsProperty & tag)) {
|
||||
// record fomart: "type|pid|name value".
|
||||
std::string record = g_markTypes[type] + "|";
|
||||
record += std::to_string(getpid()) + "|";
|
||||
record += (name.size() < NAME_MAX_SIZE) ? name : name.substr(0, NAME_MAX_SIZE);
|
||||
record += " " + value;
|
||||
if (write(g_markerFd, record.c_str(), record.size()) < 0) {
|
||||
HiLog::Error(LABEL, "write trace_marker failed, %{public}d", errno);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateTraceLabel()
|
||||
{
|
||||
if (!g_isBytraceInit) {
|
||||
HiLog::Info(LABEL, "trace param notified value delay to acquire");
|
||||
return;
|
||||
}
|
||||
g_tagsProperty = GetSysParamTags();
|
||||
uint64_t val = g_tagsProperty;
|
||||
if (val == 0 || (val & BYTRACE_TAG_VALID_MASK) == BYTRACE_TAG_ALWAYS) {
|
||||
HiLog::Info(LABEL, "Get trace param notified value zero");
|
||||
} else {
|
||||
HiLog::Info(LABEL, "Get trace param notified value 0x%{public}" PRIx64, val);
|
||||
}
|
||||
}
|
||||
|
||||
void StartTrace(uint64_t label, const string& value, float limit)
|
||||
{
|
||||
string traceName = "H:" + value;
|
||||
AddBytraceMarker(MARKER_BEGIN, label, traceName, "");
|
||||
}
|
||||
|
||||
void StartTraceDebug(uint64_t label, const string& value, float limit)
|
||||
{
|
||||
#if (TRACE_LEVEL >= DEBUG_LEVEL)
|
||||
string traceName = "H:" + value + GetHiTraceInfo();
|
||||
AddBytraceMarker(MARKER_BEGIN, label, traceName, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
void FinishTrace(uint64_t label)
|
||||
{
|
||||
AddBytraceMarker(MARKER_END, label, "", "");
|
||||
}
|
||||
|
||||
void FinishTraceDebug(uint64_t label)
|
||||
{
|
||||
#if (TRACE_LEVEL >= DEBUG_LEVEL)
|
||||
AddBytraceMarker(MARKER_END, label, "", "");
|
||||
#endif
|
||||
}
|
||||
|
||||
void StartAsyncTrace(uint64_t label, const string& value, int32_t taskId, float limit)
|
||||
{
|
||||
string traceName = "H:" + value;
|
||||
AddBytraceMarker(MARKER_ASYNC_BEGIN, label, traceName, std::to_string(taskId));
|
||||
}
|
||||
|
||||
void StartAsyncTraceDebug(uint64_t label, const string& value, int32_t taskId, float limit)
|
||||
{
|
||||
#if (TRACE_LEVEL >= DEBUG_LEVEL)
|
||||
string traceName = "H:" + value;
|
||||
AddBytraceMarker(MARKER_ASYNC_BEGIN, label, traceName, std::to_string(taskId));
|
||||
#endif
|
||||
}
|
||||
|
||||
void FinishAsyncTrace(uint64_t label, const string& value, int32_t taskId)
|
||||
{
|
||||
string traceName = "H:" + value;
|
||||
AddBytraceMarker(MARKER_ASYNC_END, label, traceName, std::to_string(taskId));
|
||||
}
|
||||
|
||||
void FinishAsyncTraceDebug(uint64_t label, const string& value, int32_t taskId)
|
||||
{
|
||||
#if (TRACE_LEVEL >= DEBUG_LEVEL)
|
||||
string traceName = "H:" + value;
|
||||
AddBytraceMarker(MARKER_ASYNC_END, label, traceName, std::to_string(taskId));
|
||||
#endif
|
||||
}
|
||||
|
||||
void MiddleTrace(uint64_t label, const string& beforeValue, const std::string& afterValue)
|
||||
{
|
||||
string traceName = "H:" + afterValue;
|
||||
AddBytraceMarker(MARKER_END, label, "", "");
|
||||
AddBytraceMarker(MARKER_BEGIN, label, traceName, "");
|
||||
}
|
||||
|
||||
void MiddleTraceDebug(uint64_t label, const string& beforeValue, const std::string& afterValue)
|
||||
{
|
||||
#if (TRACE_LEVEL >= DEBUG_LEVEL)
|
||||
string traceName = "H:" + afterValue + GetTraceInfo();
|
||||
AddBytraceMarker(MARKER_END, label, "", "");
|
||||
AddBytraceMarker(MARKER_BEGIN, label, traceName, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
void CountTrace(uint64_t label, const string& name, int64_t count)
|
||||
{
|
||||
string traceName = "H:" + name;
|
||||
AddBytraceMarker(MARKER_INT, label, traceName, std::to_string(count));
|
||||
}
|
||||
|
||||
void CountTraceDebug(uint64_t label, const string& name, int64_t count)
|
||||
{
|
||||
#if (TRACE_LEVEL >= DEBUG_LEVEL)
|
||||
string traceName = "H:" + name;
|
||||
AddBytraceMarker(MARKER_INT, label, traceName, std::to_string(count));
|
||||
#endif
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "bytrace_osal.h"
|
||||
#include "bytrace.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "parameters.h"
|
||||
|
||||
namespace OHOS {
|
||||
@@ -24,7 +24,7 @@ bool SetPropertyInner(const std::string& property, const std::string& value)
|
||||
{
|
||||
bool result = OHOS::system::SetParameter(property, value);
|
||||
if (!result) {
|
||||
fprintf(stderr, "Error: Failed to set %s property.\n", property.c_str());
|
||||
fprintf(stderr, "Error: Failed to set %s property.\n", value.c_str());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
# Copyright (C) 2021 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/test.gni")
|
||||
import("//developtools/bytrace_standard/bytrace.gni")
|
||||
|
||||
module_output_path = "bytrace_standard/bytrace"
|
||||
|
||||
config("module_private_config") {
|
||||
visibility = [ ":*" ]
|
||||
}
|
||||
|
||||
ohos_unittest("BytraceNDKTest") {
|
||||
module_out_path = module_output_path
|
||||
sources = [ "unittest/common/native/bytrace_ndk_test.cpp" ]
|
||||
deps = [
|
||||
"${bytrace_path}/bin:bytrace_osal_inner",
|
||||
"${innerkits_path}/native:bytrace_core",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"startup_l2:syspara",
|
||||
]
|
||||
include_dirs = [ "${innerkits_path}/bytrace/bytrace_native/include" ]
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
testonly = true
|
||||
deps = [ ":BytraceNDKTest" ]
|
||||
}
|
||||
@@ -1,684 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <fstream>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
#include <fcntl.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hilog/log.h>
|
||||
#include "bytrace.h"
|
||||
#include "bytrace_osal.h"
|
||||
#include "parameters.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace std;
|
||||
using namespace OHOS::HiviewDFX;
|
||||
using namespace OHOS::Developtools::BytraceOsal;
|
||||
|
||||
namespace OHOS {
|
||||
namespace Developtools {
|
||||
namespace BytraceTest {
|
||||
const string TRACE_MARKER_PATH = "trace_marker";
|
||||
const string TRACING_ON_PATH = "tracing_on";
|
||||
const string TRACING_ON = "tracing_on";
|
||||
const string TRACE_PATH = "trace";
|
||||
const string TRACE_MARK_WRITE = "tracing_mark_write";
|
||||
const string TRACE_PATTERN = "\\s*(.*?)-(.*?)\\s+(.*?)\\[(\\d+?)\\]\\s+(.*?)\\s+((\\d+).(\\d+)?):\\s+"
|
||||
+ TRACE_MARK_WRITE + ": ";
|
||||
const string TRACE_START = TRACE_PATTERN + "B\\|(.*?)\\|H:";
|
||||
const string TRACE_FINISH = TRACE_PATTERN + "E\\|";
|
||||
const string TRACE_ASYNC_START = TRACE_PATTERN + "S\\|(.*?)\\|H:";
|
||||
const string TRACE_ASYNC_FINISH = TRACE_PATTERN + "F\\|(.*?)\\|H:";
|
||||
const string TRACE_COUNT = TRACE_PATTERN + "C\\|(.*?)\\|H:";
|
||||
const string TRACE_PROPERTY = "debug.bytrace.tags.enableflags";
|
||||
constexpr uint32_t TASK = 1;
|
||||
constexpr uint32_t TID = 2;
|
||||
constexpr uint32_t TGID = 3;
|
||||
constexpr uint32_t CPU = 4;
|
||||
constexpr uint32_t DNH2 = 5;
|
||||
constexpr uint32_t TIMESTAMP = 6;
|
||||
constexpr uint32_t PID = 9;
|
||||
constexpr uint32_t TRACE_NAME = 10;
|
||||
constexpr uint32_t NUM = 11;
|
||||
|
||||
constexpr uint32_t TRACE_FMA11 = 11;
|
||||
constexpr uint32_t TRACE_FMA12 = 12;
|
||||
|
||||
constexpr uint64_t TRACE_INVALIDATE_TAG = 0x1000000;
|
||||
constexpr uint64_t BYTRACE_TAG = 0xd03301;
|
||||
const constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, BYTRACE_TAG, "BYTRACE_TEST"};
|
||||
const uint64_t TAG = BYTRACE_TAG_OHOS;
|
||||
static string g_traceRootPath;
|
||||
|
||||
bool SetProperty(const string& property, const string& value);
|
||||
string GetProperty(const string& property, const string& value);
|
||||
bool CleanTrace();
|
||||
bool CleanFtrace();
|
||||
bool SetFtrace(const string& filename, bool enabled);
|
||||
|
||||
class BytraceNDKTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void);
|
||||
static void TearDownTestCase(void);
|
||||
void SetUp();
|
||||
void TearDown() {}
|
||||
};
|
||||
|
||||
void BytraceNDKTest::SetUpTestCase()
|
||||
{
|
||||
const string debugfsDir = "/sys/kernel/debug/tracing/";
|
||||
const string tracefsDir = "/sys/kernel/tracing/";
|
||||
if (access((debugfsDir + TRACE_MARKER_PATH).c_str(), F_OK) != -1) {
|
||||
g_traceRootPath = debugfsDir;
|
||||
} else if (access((tracefsDir + TRACE_MARKER_PATH).c_str(), F_OK) != -1) {
|
||||
g_traceRootPath = tracefsDir;
|
||||
} else {
|
||||
HiLog::Error(LABEL, "Error: Finding trace folder failed");
|
||||
}
|
||||
CleanFtrace();
|
||||
}
|
||||
|
||||
void BytraceNDKTest::TearDownTestCase()
|
||||
{
|
||||
SetProperty(TRACE_PROPERTY, "0");
|
||||
SetFtrace(TRACING_ON, false);
|
||||
CleanTrace();
|
||||
}
|
||||
|
||||
void BytraceNDKTest::SetUp()
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
string value = to_string(TAG);
|
||||
SetProperty(TRACE_PROPERTY, value);
|
||||
HiLog::Info(LABEL, "current tag is %{public}s", GetProperty(TRACE_PROPERTY, "0").c_str());
|
||||
ASSERT_TRUE(GetProperty(TRACE_PROPERTY, "-123") == value);
|
||||
UpdateTraceLabel();
|
||||
}
|
||||
|
||||
struct Param {
|
||||
string m_task;
|
||||
string m_tid;
|
||||
string m_tgid;
|
||||
string m_cpu;
|
||||
string m_dnh2;
|
||||
string m_timestamp;
|
||||
string m_pid;
|
||||
string m_traceName;
|
||||
string m_num;
|
||||
};
|
||||
|
||||
class MyTrace {
|
||||
Param m_param;
|
||||
bool m_loaded = false;
|
||||
public:
|
||||
MyTrace() : m_loaded(false)
|
||||
{
|
||||
m_param.m_task = "";
|
||||
m_param.m_tid = "";
|
||||
m_param.m_tgid = "";
|
||||
m_param.m_cpu = "";
|
||||
m_param.m_dnh2 = "";
|
||||
m_param.m_timestamp = "";
|
||||
m_param.m_pid = "";
|
||||
m_param.m_traceName = "";
|
||||
m_param.m_num = "";
|
||||
}
|
||||
|
||||
~MyTrace()
|
||||
{
|
||||
}
|
||||
|
||||
// task-pid ( tig) [cpu] ...1 timestamp: tracing_mark_write: B|pid|traceName
|
||||
// task-pid ( tig) [cpu] ...1 timestamp: tracing_mark_write: E|pid
|
||||
void Load(const Param& param)
|
||||
{
|
||||
m_param.m_task = param.m_task;
|
||||
m_param.m_pid = param.m_pid;
|
||||
m_param.m_tid = param.m_tid;
|
||||
m_param.m_tgid = param.m_tgid;
|
||||
m_param.m_cpu = param.m_cpu;
|
||||
m_param.m_dnh2 = param.m_dnh2;
|
||||
m_param.m_timestamp = param.m_timestamp;
|
||||
m_param.m_traceName = param.m_traceName;
|
||||
m_param.m_num = param.m_num;
|
||||
m_loaded = true;
|
||||
}
|
||||
|
||||
string GetTask()
|
||||
{
|
||||
return m_param.m_task;
|
||||
}
|
||||
|
||||
string GetPid()
|
||||
{
|
||||
if (m_loaded) {
|
||||
return m_param.m_pid;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
string GetTgid()
|
||||
{
|
||||
if (m_loaded) {
|
||||
return m_param.m_tgid;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
string GetCpu()
|
||||
{
|
||||
if (m_loaded) {
|
||||
return m_param.m_cpu;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
string GetDnh2()
|
||||
{
|
||||
if (m_loaded) {
|
||||
return m_param.m_dnh2;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
string GetTimestamp()
|
||||
{
|
||||
if (m_loaded) {
|
||||
return m_param.m_timestamp;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
string GetTraceName()
|
||||
{
|
||||
if (m_loaded) {
|
||||
return m_param.m_traceName;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
string GetNum()
|
||||
{
|
||||
if (m_loaded) {
|
||||
return m_param.m_num;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
string GetTid()
|
||||
{
|
||||
if (m_loaded) {
|
||||
return m_param.m_tid;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
bool IsLoaded() const
|
||||
{
|
||||
return m_loaded;
|
||||
}
|
||||
};
|
||||
|
||||
bool SetProperty(const string& property, const string& value)
|
||||
{
|
||||
bool result = false;
|
||||
result = OHOS::system::SetParameter(property, value);
|
||||
if (!result) {
|
||||
HiLog::Error(LABEL, "Error: setting %s failed", property.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
string GetProperty(const string& property, const string& value)
|
||||
{
|
||||
return OHOS::system::GetParameter(property, value);
|
||||
}
|
||||
|
||||
bool GetTimeDuration(int64_t time1, int64_t time2, int64_t diffRange)
|
||||
{
|
||||
int64_t duration = time2 - time1;
|
||||
return (duration > 0) && (duration <= diffRange ? true : false);
|
||||
}
|
||||
|
||||
string& Trim(string& s)
|
||||
{
|
||||
if (s.empty()) {
|
||||
return s;
|
||||
}
|
||||
s.erase(0, s.find_first_not_of(" "));
|
||||
s.erase(s.find_last_not_of(" ") + 1);
|
||||
return s;
|
||||
}
|
||||
|
||||
int64_t GetTimeStamp(string str)
|
||||
{
|
||||
if (str == "") {
|
||||
return 0;
|
||||
}
|
||||
int64_t time;
|
||||
Trim(str);
|
||||
time = atol(str.erase(str.find("."), 1).c_str());
|
||||
return time;
|
||||
}
|
||||
|
||||
MyTrace GetTraceResult(const string& checkContent, const vector<string>& list)
|
||||
{
|
||||
MyTrace trace;
|
||||
if (list.empty() || checkContent == "") {
|
||||
return trace;
|
||||
}
|
||||
regex pattern(checkContent);
|
||||
smatch match;
|
||||
Param param {""};
|
||||
for (int i = list.size() - 1; i >= 0; i--) {
|
||||
if (regex_match(list[i], match, pattern)) {
|
||||
param.m_task = match[TASK];
|
||||
param.m_tid = match[TID];
|
||||
param.m_tgid = match[TGID];
|
||||
param.m_cpu = match[CPU];
|
||||
param.m_dnh2 = match[DNH2];
|
||||
param.m_timestamp = match[TIMESTAMP];
|
||||
param.m_pid = match[PID];
|
||||
if (match.size() == TRACE_FMA11) {
|
||||
param.m_traceName = match[TRACE_NAME],
|
||||
param.m_num = "";
|
||||
} else if (match.size() == TRACE_FMA12) {
|
||||
param.m_traceName = match[TRACE_NAME],
|
||||
param.m_num = match[NUM];
|
||||
} else {
|
||||
param.m_traceName = "";
|
||||
param.m_num = "";
|
||||
}
|
||||
trace.Load(param);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return trace;
|
||||
}
|
||||
|
||||
static bool WriteStringToFile(const string& fileName, const string& str)
|
||||
{
|
||||
if (g_traceRootPath.empty()) {
|
||||
HiLog::Error(LABEL, "Error: trace path not found.");
|
||||
return false;
|
||||
}
|
||||
ofstream out;
|
||||
out.open(g_traceRootPath + fileName, ios::out);
|
||||
out << str;
|
||||
out.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CleanTrace()
|
||||
{
|
||||
if (g_traceRootPath.empty()) {
|
||||
HiLog::Error(LABEL, "Error: trace path not found.");
|
||||
return false;
|
||||
}
|
||||
ofstream ofs;
|
||||
ofs.open(g_traceRootPath + TRACE_PATH, ofstream::out);
|
||||
if (!ofs.is_open()) {
|
||||
HiLog::Error(LABEL, "Error: opening trace path failed.");
|
||||
return false;
|
||||
}
|
||||
ofs << "";
|
||||
ofs.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
static stringstream ReadFile(const string& filename)
|
||||
{
|
||||
stringstream ss;
|
||||
char resolvedPath[PATH_MAX] = { 0 };
|
||||
if (realpath(filename.c_str(), resolvedPath) == nullptr) {
|
||||
fprintf(stderr, "Error: _fullpath %s failed", filename.c_str());
|
||||
return ss;
|
||||
}
|
||||
ifstream fin(resolvedPath);
|
||||
if (!fin.is_open()) {
|
||||
fprintf(stderr, "opening file: %s failed!", filename.c_str());
|
||||
return ss;
|
||||
}
|
||||
ss << fin.rdbuf();
|
||||
fin.close();
|
||||
return ss;
|
||||
}
|
||||
|
||||
static bool IsFileExisting(const string& filename)
|
||||
{
|
||||
return access(filename.c_str(), F_OK) != -1;
|
||||
}
|
||||
|
||||
bool SetFtrace(const string& filename, bool enabled)
|
||||
{
|
||||
return WriteStringToFile(filename, enabled ? "1" : "0");
|
||||
}
|
||||
|
||||
bool CleanFtrace()
|
||||
{
|
||||
return WriteStringToFile("set_event", "");
|
||||
}
|
||||
|
||||
string GetFinishTraceRegex(MyTrace& trace)
|
||||
{
|
||||
if (!trace.IsLoaded()) {
|
||||
return "";
|
||||
} else {
|
||||
return "\\s*(.*?)-(" + trace.GetTid() + "?)\\s+(.*?)\\[(\\d+?)\\]\\s+(.*?)\\s+" + "((\\d+).(\\d+)?):\\s+" +
|
||||
TRACE_MARK_WRITE + ": E\\|(" + trace.GetPid() + ")|(.*)";
|
||||
}
|
||||
}
|
||||
|
||||
vector<string> ReadFile2string(const string& filename)
|
||||
{
|
||||
vector<string> list;
|
||||
if (IsFileExisting(filename)) {
|
||||
stringstream ss = ReadFile(filename);
|
||||
string line;
|
||||
while (getline(ss, line)) {
|
||||
list.emplace_back(move(line));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
vector<string> ReadTrace()
|
||||
{
|
||||
return ReadFile2string(g_traceRootPath + TRACE_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: tracing_mark_write file node normal output start tracing and end tracing.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_001, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
StartTrace(TAG, "StartTraceTest001");
|
||||
FinishTrace(TAG);
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed.";
|
||||
vector<string> list = ReadTrace();
|
||||
MyTrace startTrace = GetTraceResult(TRACE_START + "(StartTraceTest001) ", list);
|
||||
ASSERT_TRUE(startTrace.IsLoaded()) << "Can't find \"B|pid|StartTraceTest001\" from trace.";
|
||||
MyTrace finishTrace = GetTraceResult(GetFinishTraceRegex(startTrace), list);
|
||||
ASSERT_TRUE(finishTrace.IsLoaded()) << "Can't find \"E|\" from trace.";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: tracing_mark_write file node has no output.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_002, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
StartTrace(TAG, "StartTraceTest002");
|
||||
FinishTrace(TAG);
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed.";
|
||||
vector<string> list = ReadTrace();
|
||||
MyTrace startTrace = GetTraceResult(TRACE_START + "(StartTraceTest002) ", list);
|
||||
ASSERT_TRUE(startTrace.IsLoaded()) << "Can't find \"B|pid|StartTraceTest002\" from trace.";
|
||||
MyTrace finishTrace = GetTraceResult(GetFinishTraceRegex(startTrace), list);
|
||||
ASSERT_TRUE(finishTrace.IsLoaded()) << "Can't find \"E|\" from trace.";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: tracing_mark_write file node normal output start trace and end trace.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_003, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
StartTrace(TAG, "StartTraceTest003 %s");
|
||||
FinishTrace(TAG);
|
||||
vector<string> list = ReadTrace();
|
||||
MyTrace startTrace = GetTraceResult(TRACE_START + "(StartTraceTest003 %s) ", list);
|
||||
ASSERT_TRUE(startTrace.IsLoaded()) << "Can't find \"B|pid|StartTraceTest003 %s\" from trace.";
|
||||
MyTrace finishTrace = GetTraceResult(GetFinishTraceRegex(startTrace), list);
|
||||
ASSERT_TRUE(finishTrace.IsLoaded()) << "Can't find \"E|\" from trace.";
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
list.clear();
|
||||
StartTrace(TAG, "StartTraceTest003 %p");
|
||||
FinishTrace(TAG);
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed.";
|
||||
list = ReadTrace();
|
||||
MyTrace startTrace2 = GetTraceResult(TRACE_START + "(StartTraceTest003 %p) ", list);
|
||||
MyTrace finishTrace2 = GetTraceResult(GetFinishTraceRegex(startTrace), list);
|
||||
ASSERT_TRUE(finishTrace2.IsLoaded()) << "Can't find \"E|\" from trace.";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: test Input and output interval 1ms execution, time fluctuation 1ms
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_004, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
StartTrace(TAG, "StartTraceTest004");
|
||||
usleep(1000);
|
||||
FinishTrace(TAG);
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed.";
|
||||
vector<string> list = ReadTrace();
|
||||
MyTrace startTrace = GetTraceResult(TRACE_START + "(StartTraceTest004) ", list);
|
||||
ASSERT_TRUE(startTrace.IsLoaded()) << "Can't find \"B|pid|StartTraceTest004\" from trace.";
|
||||
MyTrace finishTrace = GetTraceResult(GetFinishTraceRegex(startTrace), list);
|
||||
ASSERT_TRUE(finishTrace.IsLoaded()) << "Can't find \"E|\" from trace.";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: tracing_mark_write file node normal output start trace and end trace
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_005, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
StartAsyncTrace(TAG, "asyncTraceTest005", 123);
|
||||
FinishAsyncTrace(TAG, "asyncTraceTest005", 123);
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed.";
|
||||
vector<string> list = ReadTrace();
|
||||
MyTrace startTrace = GetTraceResult(TRACE_ASYNC_START + "(asyncTraceTest005) (.*)", list);
|
||||
ASSERT_TRUE(startTrace.IsLoaded()) << "Can't find \"S|pid|asyncTraceTest005\" from trace.";
|
||||
MyTrace finishTrace =
|
||||
GetTraceResult(TRACE_ASYNC_FINISH + startTrace.GetTraceName() + " " + startTrace.GetNum(), list);
|
||||
ASSERT_TRUE(finishTrace.IsLoaded()) << "Can't find \"F|\" from trace.";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: tracing_mark_write file node normal output start trace and end trace
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_006, TestSize.Level0)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
CountTrace(TAG, "countTraceTest006", 1);
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed.";
|
||||
vector<string> list = ReadTrace();
|
||||
MyTrace countTrace = GetTraceResult(TRACE_COUNT + "(countTraceTest006) (.*)", list);
|
||||
ASSERT_TRUE(countTrace.IsLoaded()) << "Can't find \"C|\" from trace.";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: tracing_mark_write file node normal output start trace and end trace.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_007, TestSize.Level1)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
StartTrace(TRACE_INVALIDATE_TAG, "StartTraceTest007");
|
||||
FinishTrace(TRACE_INVALIDATE_TAG);
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed.";
|
||||
vector<string> list = ReadTrace();
|
||||
MyTrace startTrace = GetTraceResult(TRACE_START + "(StartTraceTest007)", list);
|
||||
EXPECT_FALSE(startTrace.IsLoaded()) << "Can't find \"B|pid|StartTraceTest007\" from trace.";
|
||||
MyTrace finishTrace = GetTraceResult(GetFinishTraceRegex(startTrace), list);
|
||||
EXPECT_FALSE(finishTrace.IsLoaded()) << "Can't find \"E|\" from trace.";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: tracing_mark_write file node normal output start trace and end trace.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_008, TestSize.Level1)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
StartTrace(TRACE_INVALIDATE_TAG, "StartTraceTest008 %s");
|
||||
FinishTrace(TRACE_INVALIDATE_TAG);
|
||||
vector<string> list = ReadTrace();
|
||||
MyTrace startTrace = GetTraceResult(TRACE_START + "(StartTraceTest008 %s)", list);
|
||||
EXPECT_FALSE(startTrace.IsLoaded()) << "Can't find \"B|pid|StartTraceTest008 %s\" from trace.";
|
||||
MyTrace finishTrace = GetTraceResult(GetFinishTraceRegex(startTrace), list);
|
||||
EXPECT_FALSE(finishTrace.IsLoaded()) << "Can't find \"E|\" from trace.";
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
list.clear();
|
||||
StartTrace(TRACE_INVALIDATE_TAG, "StartTraceTest008 %p");
|
||||
FinishTrace(TRACE_INVALIDATE_TAG);
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed.";
|
||||
list = ReadTrace();
|
||||
MyTrace startTrace2 = GetTraceResult(TRACE_START + "(StartTraceTest008 %p)", list);
|
||||
MyTrace finishTrace2 = GetTraceResult(GetFinishTraceRegex(startTrace), list);
|
||||
EXPECT_FALSE(finishTrace2.IsLoaded()) << "Can't find \"E|\" from trace.";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: tracing_mark_write file node normal output start trace and end trace
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_009, TestSize.Level1)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
StartAsyncTrace(TRACE_INVALIDATE_TAG, "asyncTraceTest009", 123);
|
||||
FinishAsyncTrace(TRACE_INVALIDATE_TAG, "asyncTraceTest009", 123);
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed.";
|
||||
vector<string> list = ReadTrace();
|
||||
MyTrace startTrace = GetTraceResult(TRACE_ASYNC_START + "(asyncTraceTest009)\\|(.*)", list);
|
||||
EXPECT_FALSE(startTrace.IsLoaded()) << "Can't find \"S|pid|asyncTraceTest009\" from trace.";
|
||||
MyTrace finishTrace = GetTraceResult(TRACE_ASYNC_FINISH + startTrace.GetTraceName() + "\\|"
|
||||
+ startTrace.GetNum(), list);
|
||||
EXPECT_FALSE(finishTrace.IsLoaded()) << "Can't find \"F|\" from trace.";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: tracing_mark_write file node normal output start trace and end trace
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_010, TestSize.Level1)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
CountTrace(TRACE_INVALIDATE_TAG, "countTraceTest010", 1);
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, false)) << "Setting tracing_on failed.";
|
||||
vector<string> list = ReadTrace();
|
||||
MyTrace countTrace = GetTraceResult(TRACE_COUNT + "(countTraceTest010)\\|(.*)", list);
|
||||
EXPECT_FALSE(countTrace.IsLoaded()) << "Can't find \"C|\" from trace.";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: tracing_mark_write file node general output start and end tracing for debugging.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_011, TestSize.Level1)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
StartTraceDebug(TAG, "StartTraceTest011");
|
||||
FinishTraceDebug(TAG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: tracing_mark_write file node general output start and end tracing for debugging.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_012, TestSize.Level1)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
StartTraceDebug(TAG, "StartTraceTest012 %s");
|
||||
FinishTraceDebug(TAG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: Testing StartAsyncTraceDebug and FinishAsyncTraceDebug functions
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_013, TestSize.Level1)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
StartAsyncTraceDebug(TAG, "asyncTraceTest013", 123);
|
||||
FinishAsyncTraceDebug(TAG, "asyncTraceTest013", 123);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: Testing CountTraceDebug function
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_014, TestSize.Level1)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
CountTraceDebug(TAG, "countTraceTest014", 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: Testing MiddleTrace function
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_015, TestSize.Level1)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
MiddleTrace(TAG, "MiddleTraceTest015", "050tseTecarTelddiM");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: bytrace
|
||||
* @tc.desc: Testing MiddleTraceDebug function
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(BytraceNDKTest, StartTrace_016, TestSize.Level1)
|
||||
{
|
||||
ASSERT_TRUE(CleanTrace());
|
||||
ASSERT_TRUE(SetFtrace(TRACING_ON, true)) << "Setting tracing_on failed.";
|
||||
MiddleTraceDebug(TAG, "MiddleTraceTest016", "061tseTecarTelddiM");
|
||||
}
|
||||
} // namespace BytraceTest
|
||||
} // namespace Developtools
|
||||
} // namespace OHOS
|
||||
+10
-24
@@ -1,16 +1,16 @@
|
||||
{
|
||||
"name": "@ohos/bytrace_standard",
|
||||
"name": "@ohos/bytrace",
|
||||
"description": "A tool to trace processes and monitor performance",
|
||||
"version": "3.1",
|
||||
"license": "Apache License 2.0",
|
||||
"publishAs": "code-segment",
|
||||
"segment": {
|
||||
"destPath": "developtools/bytrace_standard"
|
||||
"destPath": "developtools/bytrace"
|
||||
},
|
||||
"dirs": {},
|
||||
"scripts": {},
|
||||
"component": {
|
||||
"name": "bytrace_standard",
|
||||
"name": "bytrace",
|
||||
"subsystem": "developtools",
|
||||
"adapted_system_type": [
|
||||
"standard"
|
||||
@@ -19,11 +19,11 @@
|
||||
"ram": "720KB",
|
||||
"deps": {
|
||||
"components": [
|
||||
"hilog",
|
||||
"syspara",
|
||||
"syspara_watchagent",
|
||||
"hitrace_native",
|
||||
"hiviewdfx_hilog_native",
|
||||
"init",
|
||||
"ipc",
|
||||
"utils_base"
|
||||
"napi"
|
||||
],
|
||||
"third_party": [
|
||||
"zlib"
|
||||
@@ -31,25 +31,11 @@
|
||||
},
|
||||
"build": {
|
||||
"sub_component": [
|
||||
"//developtools/bytrace_standard/interfaces/innerkits/native:bytrace_core",
|
||||
"//developtools/bytrace_standard/bin:bytrace_target",
|
||||
"//developtools/bytrace_standard/bin:bytrace.cfg",
|
||||
"//developtools/bytrace_standard/interfaces/kits:jsapi_kits_target"
|
||||
"//developtools/bytrace/bin:bytrace_target",
|
||||
"//developtools/bytrace/bin:bytrace.cfg",
|
||||
"//developtools/bytrace/interfaces/kits:jsapi_kits_target"
|
||||
],
|
||||
"inner_kits": [
|
||||
{
|
||||
"type": "so",
|
||||
"name": "//developtools/bytrace_standard/interfaces/innerkits/native:bytrace_core",
|
||||
"header": {
|
||||
"header_files": [
|
||||
"bytrace.h"
|
||||
],
|
||||
"header_base": "//developtools/bytrace_standard/interfaces/innerkits/native/include"
|
||||
}
|
||||
}
|
||||
],
|
||||
"test": [
|
||||
"//developtools/bytrace_standard/bin/test:unittest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
bytrace_path = "//developtools/bytrace_standard"
|
||||
bytrace_path = "//developtools/bytrace"
|
||||
|
||||
innerkits_path = "${bytrace_path}/interfaces/innerkits"
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# Copyright (C) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
|
||||
group("innerkits_target") {
|
||||
deps = [ "native:bytrace_core" ]
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
# Copyright (C) 2021-2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//developtools/bytrace_standard/bytrace.gni")
|
||||
|
||||
config("bytrace_config") {
|
||||
visibility = [ ":*" ]
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
|
||||
ohos_shared_library("bytrace_core") {
|
||||
public_configs = [ ":bytrace_config" ]
|
||||
deps = [ "${bytrace_path}/bin:bytrace_inner" ]
|
||||
subsystem_name = "developtools"
|
||||
part_name = "bytrace_standard"
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef INTERFACES_INNERKITS_NATIVE_INCLUDE_BYTRACE_H
|
||||
#define INTERFACES_INNERKITS_NATIVE_INCLUDE_BYTRACE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
constexpr uint64_t BYTRACE_TAG_NEVER = 0; // This tag is never enabled.
|
||||
constexpr uint64_t BYTRACE_TAG_ALWAYS = (1ULL << 0); // This tag is always enabled.
|
||||
constexpr uint64_t BYTRACE_TAG_OHOS = (1ULL << 30); // OHOS generic tag.
|
||||
constexpr uint64_t BYTRACE_TAG_ABILITY_MANAGER = (1ULL << 31); // Ability Manager tag.
|
||||
constexpr uint64_t BYTRACE_TAG_ZCAMERA = (1ULL << 32); // Camera module tag.
|
||||
constexpr uint64_t BYTRACE_TAG_ZMEDIA = (1ULL << 33); // Media module tag.
|
||||
constexpr uint64_t BYTRACE_TAG_ZIMAGE = (1ULL << 34); // Image module tag.
|
||||
constexpr uint64_t BYTRACE_TAG_ZAUDIO = (1ULL << 35); // Audio module tag.
|
||||
constexpr uint64_t BYTRACE_TAG_DISTRIBUTEDDATA = (1ULL << 36); // Distributeddata manager module tag.
|
||||
constexpr uint64_t BYTRACE_TAG_MDFS = (1ULL << 37); // Mobile distributed file system tag.
|
||||
constexpr uint64_t BYTRACE_TAG_GRAPHIC_AGP = (1ULL << 38); // Graphic module tag.
|
||||
constexpr uint64_t BYTRACE_TAG_ACE = (1ULL << 39); // ACE development framework tag.
|
||||
constexpr uint64_t BYTRACE_TAG_NOTIFICATION = (1ULL << 40); // Notification module tag.
|
||||
constexpr uint64_t BYTRACE_TAG_MISC = (1ULL << 41); // Notification module tag.
|
||||
constexpr uint64_t BYTRACE_TAG_MULTIMODALINPUT = (1ULL << 42); // Multi modal module tag.
|
||||
constexpr uint64_t BYTRACE_TAG_SENSORS = (1ULL << 43); // Sensors mudule tag.
|
||||
constexpr uint64_t BYTRACE_TAG_MSDP = (1ULL << 44); // Multimodal Sensor Data Platform module tag.
|
||||
constexpr uint64_t BYTRACE_TAG_DSOFTBUS = (1ULL << 45); // Distributed Softbus tag.
|
||||
constexpr uint64_t BYTRACE_TAG_RPC = (1ULL << 46); // RPC and IPC tag.
|
||||
constexpr uint64_t BYTRACE_TAG_ARK = (1ULL << 47); // ARK tag.
|
||||
constexpr uint64_t BYTRACE_TAG_WINDOW_MANAGER = (1ULL << 48); // window manager tag.
|
||||
constexpr uint64_t BYTRACE_TAG_APP = (1ULL << 62); // App tag.
|
||||
|
||||
constexpr uint64_t BYTRACE_TAG_LAST = BYTRACE_TAG_APP;
|
||||
constexpr uint64_t BYTRACE_TAG_NOT_READY = (1ULL << 63); // Reserved for initialization.
|
||||
constexpr uint64_t BYTRACE_TAG_VALID_MASK = ((BYTRACE_TAG_LAST - 1) | BYTRACE_TAG_LAST);
|
||||
|
||||
#ifndef BYTRACE_TAG
|
||||
#define BYTRACE_TAG BYTRACE_TAG_NEVER
|
||||
#elif BYTRACE_TAG > BYTRACE_TAG_VALID_MASK
|
||||
#error BYTRACE_TAG must be defined to be one of the tags defined in bytrace.h
|
||||
#elif BYTRACE_TAG < BYTRACE_TAG_OHOS
|
||||
#error BYTRACE_TAG must be defined to be one of the tags defined in bytrace.h
|
||||
#endif
|
||||
|
||||
#define RELEASE_LEVEL 0X01
|
||||
#define DEBUG_LEVEL 0X02
|
||||
|
||||
#ifndef TRACE_LEVEL
|
||||
#define TRACE_LEVEL RELEASE
|
||||
#endif
|
||||
|
||||
#define TOKENPASTE(x, y) x ## y
|
||||
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
|
||||
#define BYTRACE_NAME(TAG, fmt, ...) ByTraceScoped TOKENPASTE2(tracer, __LINE__)(TAG, fmt, ##__VA_ARGS__)
|
||||
#define BYTRACE(TAG) BYTRACE_NAME(TAG, __func__)
|
||||
|
||||
/**
|
||||
* Update trace label when your process has started.
|
||||
*/
|
||||
void UpdateTraceLabel();
|
||||
|
||||
/**
|
||||
* Track the beginning of a context.
|
||||
*/
|
||||
void StartTrace(uint64_t label, const std::string& value, float limit = -1);
|
||||
void StartTraceDebug(uint64_t label, const std::string& value, float limit = -1);
|
||||
/**
|
||||
* Track the end of a context.
|
||||
*/
|
||||
void FinishTrace(uint64_t label);
|
||||
void FinishTraceDebug(uint64_t label);
|
||||
/**
|
||||
* Track the beginning of an asynchronous event.
|
||||
*/
|
||||
void StartAsyncTrace(uint64_t label, const std::string& value, int32_t taskId, float limit = -1);
|
||||
void StartAsyncTraceDebug(uint64_t label, const std::string& value, int32_t taskId, float limit = -1);
|
||||
|
||||
/**
|
||||
* Track the end of an asynchronous event.
|
||||
*/
|
||||
void FinishAsyncTrace(uint64_t label, const std::string& value, int32_t taskId);
|
||||
void FinishAsyncTraceDebug(uint64_t label, const std::string& value, int32_t taskId);
|
||||
|
||||
/**
|
||||
* Track the middle of a context. Match the previous function of StartTrace before it.
|
||||
*/
|
||||
void MiddleTrace(uint64_t label, const std::string& beforeValue, const std::string& afterValue);
|
||||
void MiddleTraceDebug(uint64_t label, const std::string& beforeValue, const std::string& afterValue);
|
||||
|
||||
/**
|
||||
* Track the 64-bit integer counter value.
|
||||
*/
|
||||
void CountTrace(uint64_t label, const std::string& name, int64_t count);
|
||||
void CountTraceDebug(uint64_t label, const std::string& name, int64_t count);
|
||||
|
||||
class ByTraceScoped {
|
||||
public:
|
||||
inline ByTraceScoped(uint64_t tag, const std::string &value) : mTag(tag)
|
||||
{
|
||||
StartTrace(mTag, value);
|
||||
}
|
||||
|
||||
inline ~ByTraceScoped()
|
||||
{
|
||||
FinishTrace(mTag);
|
||||
}
|
||||
private:
|
||||
uint64_t mTag;
|
||||
};
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // INTERFACES_INNERKITS_NATIVE_INCLUDE_BYTRACE_H
|
||||
@@ -16,8 +16,8 @@ import("//build/ohos.gni")
|
||||
group("jsapi_kits_target") {
|
||||
if (support_jsapi) {
|
||||
deps = [
|
||||
"//developtools/bytrace_standard/interfaces/kits/js/napi:bytrace",
|
||||
"//developtools/bytrace_standard/interfaces/kits/js/napi:hitracemeter_napi",
|
||||
"//developtools/bytrace/interfaces/kits/js/napi:bytrace",
|
||||
"//developtools/bytrace/interfaces/kits/js/napi:hitracemeter_napi",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,23 +12,23 @@
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("//developtools/bytrace_standard/bytrace.gni")
|
||||
import("//developtools/bytrace/bytrace.gni")
|
||||
|
||||
ohos_shared_library("bytrace") {
|
||||
sources = [
|
||||
"bytrace.cpp",
|
||||
"bytrace_napi_common.cpp",
|
||||
]
|
||||
deps = [
|
||||
"${innerkits_path}/native:bytrace_core",
|
||||
"//foundation/ace/napi:ace_napi",
|
||||
deps = [ "//foundation/arkui/napi:ace_napi" ]
|
||||
external_deps = [
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||
|
||||
relative_install_dir = "module"
|
||||
|
||||
subsystem_name = "developtools"
|
||||
part_name = "bytrace_standard"
|
||||
part_name = "bytrace"
|
||||
}
|
||||
|
||||
ohos_shared_library("hitracemeter_napi") {
|
||||
@@ -36,14 +36,14 @@ ohos_shared_library("hitracemeter_napi") {
|
||||
"bytrace_napi_common.cpp",
|
||||
"hitracemeter.cpp",
|
||||
]
|
||||
deps = [
|
||||
"${innerkits_path}/native:bytrace_core",
|
||||
"//foundation/ace/napi:ace_napi",
|
||||
deps = [ "//foundation/arkui/napi:ace_napi" ]
|
||||
external_deps = [
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
external_deps = [ "hiviewdfx_hilog_native:libhilog" ]
|
||||
|
||||
relative_install_dir = "module"
|
||||
|
||||
subsystem_name = "developtools"
|
||||
part_name = "bytrace_standard"
|
||||
part_name = "bytrace"
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
@rem limitations under the License.
|
||||
|
||||
@echo off
|
||||
hdc shell "echo > /sys/kernel/debug/tracing/trace"
|
||||
hdc shell "echo 4096 > /d/tracing/saved_cmdlines_size"
|
||||
hdc shell "bytrace -t 10 -b 4096 --overwrite ohos zimage zmedia zcamera zaudio ability distributeddatamgr sched freq irq workq rs idle load disk pagecache memreclaim > /data/mynewtrace.ftrace"
|
||||
hdc shell "echo > /sys/kernel/debug/tracing/trace"
|
||||
hdc shell "sed -i '1,2d' /data/mynewtrace.ftrace"
|
||||
hdc pull /data/mynewtrace.ftrace .
|
||||
hdc_std shell "echo > /sys/kernel/debug/tracing/trace"
|
||||
hdc_std shell "echo 4096 > /sys/kernel/debug/tracing/saved_cmdlines_size"
|
||||
hdc_std shell "bytrace -t 10 -b 204800 --overwrite filemanagement gresource devicemanager deviceprofile dscreen dinput dhfwk accessibility dsched samgr ohos ace workq idle app ark ability binder disk distributeddatamgr dsoftbus freq graphic irq mdfs memory memreclaim misc mmc msdp multimodalinput notification pagecache regulators rpc sched sync window zaudio zcamera zimage zmedia > /data/local/tmp/data.ftrace"
|
||||
hdc_std shell "echo > /sys/kernel/debug/tracing/trace"
|
||||
hdc_std shell "sed -i '1,2d' /data/mynewtrace.ftrace"
|
||||
hdc_std file recv /data/mynewtrace.ftrace .
|
||||
pause
|
||||
|
||||
Reference in New Issue
Block a user