1# hitrace 2 3<!--Kit: Performance Analysis Kit--> 4<!--Subsystem: HiviewDFX--> 5<!--Owner: @qq_437963121--> 6<!--Designer: @kutcherzhou1; @MontSaintMichel--> 7<!--Tester: @gcw_KuLfPSbe--> 8<!--Adviser: @foryourself--> 9 10hitrace命令行工具提供trace信息采集能力,支持采集系统提供的打点和开发者使用[HitraceMeter接口](hitracemeter-intro.md)在应用中设置的打点。该工具支持多种方式采集文本格式或二进制格式的trace信息,帮助开发者观测程序运行情况和定位故障问题。 11 12 13## 环境要求 14 15- 根据hdc命令行工具指导,完成[hdc环境准备](hdc.md#环境准备)。 16 17- 确保设备已正常连接,并执行hdc shell。 18 19 20## 命令行说明 21 22| 命令 | 含义说明 | 23| -------- | -------- | 24| -h/--help | 查看帮助。 | 25| -l/--list_categories | 查看tag列表。 | 26| --trace_begin | 开始捕获trace。 | 27| --trace_finish | 结束捕获trace。 | 28| --trace_finish_nodump | 结束捕获trace,与--trace_finish的区别是不输出trace信息。 | 29| --trace_dump | 导出trace信息。 | 30| --record | 使能录制模式,允许长时间采集并落盘trace数据,必须和--trace_begin或--trace_finish一起使用。 | 31| --overwrite | 设置内核缓冲区满之后的行为,未设置此选项时默认丢弃最老数据,设置此选项后丢弃最新数据。 | 32| --file_size | 设置文件大小(单位为KB),仅在采集二进制格式trace数据时有效。 | 33| -b N/--buffer_size N | 设置用于存储和读取trace的缓冲区大小(单位为KB)。最小值为512,最大值与设备当前可用内存有关。 | 34| -t N/--time N | 设置hitrace采集时长,单位为s。 | 35| -o/--output filename | 指定目标文件的名称(导出trace格式为文本时默认为stdout,如需保存到文件,建议使用/data/local/tmp路径。导出trace格式为二进制时不支持此选项)。 | 36| -z | 压缩捕获的trace数据。 | 37| --text | 导出trace数据为文本格式(默认为文本格式)。 | 38| --raw | 导出trace数据为二进制格式(默认为文本格式)。 | 39| --trace_clock | 设置向trace添加时间戳的时钟类型,可以是boot(默认)、global、mono、uptime或perf。不同设备支持的时钟类型不同,建议使用默认的boot进行采集,其时间为从本次开机起的时间戳,单位为s。每种时间类型的说明如下:<br/>- boot:系统启动后的时间戳,休眠或系统挂起时也会计时。<br/>- global:全局同步的时钟,可能有性能开销。<br/>- mono:系统启动后的时间戳,休眠或系统挂起时不会计时。<br/>- uptime:系统启动后的时间戳,类似于mono。<br/>- perf:高性能计数器,适合性能分析。 | 40| --start_bgsrv | 开启快照模式trace捕获。 | 41| --dump_bgsrv | 触发快照模式trace输出到文件。 | 42| --stop_bgsrv | 关闭快照模式trace捕获。 | 43| --trace_level | 设置trace输出级别阈值,输出级别可以是Debug、Info、Critical、Commercial或其对应缩写D、I、C、M。<br/>**说明**:从API version 19开始,支持该命令。 | 44| --get_level | 查询trace输出级别阈值。<br/>**说明**:从API version 20开始,支持该命令。 | 45 46> **说明:** 47> 48> trace信息可以用两种不同的格式保存,分别为文本格式和二进制格式。文本格式的trace可以直接用文本编辑器查看,二进制格式的trace可以使用[Smartperf_Host](https://gitee.com/openharmony/developtools_smartperf_host)工具进行可视化trace分析。工具下载链接:[developtools_smartperf_host官方发行版](https://gitee.com/openharmony/developtools_smartperf_host/releases)。 49 50 51## 常用命令 52 53 54### 查看帮助信息 55 56 57```shell 58hitrace -h 59``` 60 61 62**使用样例**: 63 64 65```shell 66$ hitrace -h 672025/05/28 15:19:52 hitrace enter, running_state is SHOW_HELP 68usage: hitrace [options] [categories...] 69options include: 70 -b N Set the size of the buffer (KB) for storing and reading traces. 71 The default buffer size is 18432 KB. 72 --buffer_size N Like "-b N". 73 -l List available hitrace categories. 74 --list_categories Like "-l". 75 -t N Set the hitrace running duration in seconds (5s by default), which depends on 76 the time required for analysis. 77 --time N Like "-t N". 78 --trace_clock clock Sets the type of the clock for adding a timestamp to a trace, which can be 79 boot (default), global, mono, uptime, or perf. 80 --trace_begin Start capturing traces. 81 --trace_dump Dump traces to a specified path (stdout by default). 82 --trace_finish Stop capturing traces and dumps traces to a specified path (stdout by default). 83 --trace_finish_nodump Stop capturing traces and not dumps traces. 84 --record Enable or disable long-term trace collection tasks in conjunction with 85 "--trace_begin" and "--trace_finish". 86 --overwrite Set the action to take when the buffer is full. If this option is used, 87 the latest traces are discarded; if this option is not used (default setting), 88 the earliest traces are discarded. 89 -o filename Specifies the name of the target file (stdout by default). 90 --output filename Like "-o filename". 91 -z Compresses a captured trace. 92 --text Specify the output format of trace as text. 93 --raw Specify the output format of trace as raw trace, the default format is text. 94 --start_bgsrv Enable trace_service in snapshot mode. 95 --dump_bgsrv Trigger the dump trace task of the trace_service. 96 --stop_bgsrv Disable trace_service in snapshot mode. 97 --file_size Sets the size of the raw trace (KB). The default file size is 102400 KB. 98 Only effective in raw trace mode 99 --trace_level level Set the system parameter "persist.hitrace.level.threshold", which can control 100 the level threshold of tracing. Valid values for "level" include 101 D or Debug, I or Info, C or Critical, M or Commercial. 102 --get_level Query the system parameter "persist.hitrace.level.threshold", 103 which can control the level threshold of tracing. 104``` 105 106 107### 查看hitrace包含的tag 108 109```shell 110hitrace -l 111``` 112 113**使用样例**: 114 115```shell 116$ hitrace -l 1172025/05/27 16:24:38 hitrace enter, running_state is SHOW_LIST_CATEGORY 118 tagName: description: 119 ability - Ability Manager 120 accesscontrol - Access Control Module 121 accessibility - Accessibility Manager 122 account - Account Manager 123 ace - ACE development framework 124 animation - Animation 125 app - APP Module 126 ark - ARK Module 127 binder - Binder kernel Info 128 bluetooth - communication bluetooth 129 cloud - Cloud subsystem tag 130 commercial - Commercial version tag 131 commonlibrary - commonlibrary subsystem 132 daudio - Distributed Audio 133 dcamera - Distributed Camera 134 deviceauth - Device Auth 135 devicemanager - Device Manager 136 deviceprofile - Device Profile 137 dhfwk - Distributed Hardware FWK 138 dinput - Distributed Input 139 disk - Disk I/O 140 distributeddatamgr - Distributed Data Manager 141 dlpcre - Dlp Credential Service 142 drm - Digital Rights Management 143 dsched - Distributed Schedule 144 dscreen - Distributed Screen 145 dslm - device security level 146 dsoftbus - Distributed Softbus 147 ffrt - ffrt tasks 148 filemanagement - filemanagement 149 freq - CPU Frequency 150 graphic - Graphic Module 151 gresource - Global Resource Manager 152 hdcd - hdcd 153 hdf - hdf subsystem 154 hmfs - HMFS commands 155 huks - Universal KeyStore 156 i2c - I2C Events 157 idle - CPU Idle 158 interconn - Interconnection subsystem 159 ipa - thermal power allocator 160 irq - IRQ Events 161 irqoff - IRQ-disabled code section tracing 162 load - CPU Load 163 mdfs - Mobile Distributed File System 164 membus - Memory Bus Utilization 165 memory - Memory 166 memreclaim - Kernel Memory Reclaim 167 misc - Misc Module 168 mmc - eMMC commands 169 msdp - Multimodal Sensor Data Platform 170 multimodalinput - HITRACE_TAG_MULTIMODALINPUT 171 musl - musl module 172 net - net 173 notification - Notification Module 174 nweb - NWEB Module 175 ohos - OpenHarmony 176 pagecache - Page cache 177 power - Power Manager 178 preemptoff - Preempt-disabled code section tracing 179 push - Push subsystem 180 regulators - Voltage and Current Regulators 181 rpc - RPC and IPC 182 samgr - samgr 183 sched - CPU Scheduling 184 security - Security subsystem 185 sensors - Sensors Module 186 sync - Synchronization 187 ufs - UFS commands 188 usb - usb subsystem 189 useriam - useriam 190 virse - Virtualization Service 191 window - Window Manager 192 workq - Kernel Workqueues 193 zaudio - OpenHarmony Audio Module 194 zbinder - OpenHarmony binder communication 195 zcamera - OpenHarmony Camera Module 196 zimage - OpenHarmony Image Module 197 zmedia - OpenHarmony Media Module 198``` 199 200 201### 捕获指定时长文本格式trace 202 203不指定-o参数时,默认将捕获到的trace内容显示在命令行窗口。下面参数是指定采集10秒的数据,缓冲区大小为204800KB,采集的tag为app。 204 205```shell 206hitrace -t 10 -b 204800 app 207``` 208 209 210**使用样例**: 211 212 213```shell 214$ hitrace -t 10 -b 204800 app 2152025/06/04 10:14:52 start capture, please wait 10s ... 216# tracer: nop 217# _-----=> irqs-off 218# / _----=> need-resched 219# | / _---=> hardirq/softirq 220# || / _--=> preempt-depth 221# ||| / delay 222# TASK-PID TGID CPU# |||| TIMESTAMP FUNCTION 223# | | | | |||| | | 224 KstateRecvThrea-1132 ( 952) [003] .... 589942.951387: tracing_mark_write: B|952|H:CheckMsgFromNetlink|I62 225 KstateRecvThrea-1132 ( 952) [003] .... 589942.951554: tracing_mark_write: B|952|H:OnKstateCallback, mask: 8, data: [PID 15461 KILLED][SIG 9]|I62 226 KstateRecvThrea-1132 ( 952) [003] .... 589942.951693: tracing_mark_write: E|952|I62 227 KstateRecvThrea-1132 ( 952) [003] .... 589942.951737: tracing_mark_write: E|952|I62 228 state_change_ha-1139 ( 952) [001] .... 589942.951909: tracing_mark_write: B|952|H:ProcessEvent, eventId: 6|I62 229 state_change_ha-1139 ( 952) [001] .... 589942.952510: tracing_mark_write: E|952|I62 2302025/06/04 10:15:02 TraceFinish done. 231``` 232 233 234指定-o参数时,可以将trace信息保存到指定目录,建议保存在/data/local/tmp路径下。 235 236 237```shell 238hitrace -t 10 -b 204800 app -o /data/local/tmp/test.ftrace 239``` 240 241 242**使用样例**: 243 244 245```shell 246$ hitrace -t 10 -b 204800 app -o /data/local/tmp/test.ftrace 2472025/06/04 10:19:47 start capture, please wait 10s ... 2482025/06/04 10:19:57 capture done, start to read trace. 2492025/06/04 10:19:57 trace read done, output: /data/local/tmp/test.ftrace 2502025/06/04 10:19:57 TraceFinish done. 251``` 252 253 254### 捕获指定时长二进制格式trace 255 256命令带--raw参数时可捕获二进制格式trace,捕获二进制格式trace时不支持指定路径,固定保存在路径/data/log/hitrace下。采集结束后,采集结束后生成文件的绝对路径会显示在命令行窗口。 257 258```shell 259hitrace -t 10 -b 204800 app --raw 260``` 261 262 263**使用样例**: 264 265 266```shell 267$ hitrace -t 10 -b 204800 app --raw 2682025/06/04 10:21:16 hitrace enter, running_state is RECORDING_SHORT_RAW 2692025/06/04 10:21:16 args: tags:app bufferSize:204800 overwrite:1 2702025/06/04 10:21:16 start capture, please wait 10s ... 2712025/06/04 10:21:27 capture done, output files: 272 /data/log/hitrace/record_trace_20250604102116@590322-695861087.sys 273``` 274 275 276### 快照模式捕获文本格式trace 277 278快照模式下,trace信息保存在内核缓冲区。当数据量超出缓冲区大小时,默认丢弃最早的数据。 279 280使用以下命令开启快照模式,指定缓冲区大小为204800KB,采集的tag为app和graphic。 281 282```shell 283hitrace --trace_begin -b 204800 app graphic 284``` 285 286**使用样例**: 287 288```shell 289$ hitrace --trace_begin -b 204800 app graphic 2902025/06/04 16:03:39 hitrace enter, running_state is RECORDING_LONG_BEGIN 2912025/06/04 16:03:39 args: tags:app,graphic bufferSize:204800 overwrite:1 2922025/06/04 16:03:39 OpenRecording done. 293``` 294 295在开启快照模式后,可以使用下面的命令将当前缓冲区内的数据导出。默认将trace信息显示到命令行窗口。 296 297```shell 298hitrace --trace_dump 299``` 300 301**使用样例**: 302 303```shell 304$ hitrace --trace_dump 3052025/06/04 16:07:57 start to read trace. 306# tracer: nop 307# _-----=> irqs-off 308# / _----=> need-resched 309# | / _---=> hardirq/softirq 310# || / _--=> preempt-depth 311# ||| / delay 312# TASK-PID TGID CPU# |||| TIMESTAMP FUNCTION 313# | | | | |||| | | 314 KstateRecvThrea-1132 ( 952) [002] .... 610865.463378: tracing_mark_write: B|952|H:CheckMsgFromNetlink|I62 315 KstateRecvThrea-1132 ( 952) [002] .... 610865.463503: tracing_mark_write: B|952|H:OnKstateCallback, mask: 8, data: [PID 14446 KILLED][SIG 9]|I62 316 KstateRecvThrea-1132 ( 952) [002] .... 610865.463626: tracing_mark_write: E|952|I62 317 KstateRecvThrea-1132 ( 952) [002] .... 610865.463654: tracing_mark_write: E|952|I62 318 state_change_ha-1139 ( 952) [001] .... 610865.463767: tracing_mark_write: B|952|H:ProcessEvent, eventId: 6|I62 319 state_change_ha-1139 ( 952) [001] .... 610865.463879: tracing_mark_write: E|952|I62 320 state_change_ha-1139 ( 952) [001] .... 610866.506055: tracing_mark_write: B|952|H:ProcessEvent, eventId: 0|I62 321 state_change_ha-1139 ( 952) [001] .... 610866.506297: tracing_mark_write: B|952|H:HandleStateTransition, 20020111_com.ohos.medialibrary.medialibrarydata_[6255]|I62 322 state_change_ha-1139 ( 952) [001] .... 610866.506782: tracing_mark_write: E|952|I62 323 state_change_ha-1139 ( 952) [001] .... 610866.506824: tracing_mark_write: E|952|I62 324 state_change_ha-1139 ( 952) [001] .... 610866.557458: tracing_mark_write: B|952|H:ProcessEvent, eventId: 0|I62 325 state_change_ha-1139 ( 952) [001] .... 610866.558060: tracing_mark_write: E|952|I62 326 state_change_ha-1139 ( 952) [001] .... 610866.558101: tracing_mark_write: E|952|I62 327``` 328 329导出时也可以使用-o命令保存到指定文件,建议保存到/data/local/tmp路径下。 330 331```shell 332hitrace --trace_dump -o /data/local/tmp/test.ftrace 333``` 334 335**使用样例**: 336 337```shell 338$ hitrace --trace_dump -o /data/local/tmp/test.ftrace 3392025/06/04 16:09:10 start to read trace. 3402025/06/04 16:09:10 trace read done, output: /data/local/tmp/test.ftrace 341``` 342 343需要停止采集时,有如下三种命令: 344 3451. 停止采集,并将当前缓冲区内的trace信息显示到命令行窗口。 346 347 ```shell 348 hitrace --trace_finish 349 ``` 350 351 **使用样例**: 352 353 ```shell 354 $ hitrace --trace_finish 355 2025/06/04 16:22:02 start to read trace. 356 # tracer: nop 357 # _-----=> irqs-off 358 # / _----=> need-resched 359 # | / _---=> hardirq/softirq 360 # || / _--=> preempt-depth 361 # ||| / delay 362 # TASK-PID TGID CPU# |||| TIMESTAMP FUNCTION 363 # | | | | |||| | | 364 KstateRecvThrea-1132 ( 952) [002] .... 610865.463378: tracing_mark_write: B|952|H:CheckMsgFromNetlink|I62 365 KstateRecvThrea-1132 ( 952) [002] .... 610865.463503: tracing_mark_write: B|952|H:OnKstateCallback, mask: 8, data: [PID 14446 KILLED][SIG 9]|I62 366 KstateRecvThrea-1132 ( 952) [002] .... 610865.463626: tracing_mark_write: E|952|I62 367 KstateRecvThrea-1132 ( 952) [002] .... 610865.463654: tracing_mark_write: E|952|I62 368 ``` 369 3702. 停止采集,并将当前缓冲区内的trace信息保存到指定文件。建议保存路径为/data/local/tmp。 371 372 ```shell 373 hitrace --trace_finish -o /data/local/tmp/test.ftrace 374 ``` 375 376 **使用样例**: 377 378 ```shell 379 $ hitrace --trace_finish -o /data/local/tmp/test.ftrace 380 2025/06/04 16:24:52 start to read trace. 381 2025/06/04 16:24:52 trace read done, output: /data/local/tmp/test.ftrace 382 2025/06/04 16:24:52 Trace Closed. 383 ``` 384 3853. 停止采集,不输出trace信息。 386 387 ```shell 388 hitrace --trace_finish_nodump 389 ``` 390 391 **使用样例**: 392 393 ```shell 394 $ hitrace --trace_finish_nodump 395 2025/06/04 16:26:11 hitrace enter, running_state is RECORDING_LONG_FINISH_NODUMP 396 2025/06/04 16:26:11 end capture trace. 397 ``` 398 399 400### 快照模式捕获二进制格式trace 401 402 403快照模式下捕获二进制格式trace时不支持指定tag,默认采集以下tag。 404 405 406```shell 407"net", "dsched", "graphic", "multimodalinput", "dinput", "ark", "ace", "window","zaudio", "daudio", "zmedia", "dcamera", "zcamera", "dhfwk", "app", "gresource", "ability", "power", "samgr", "ffrt", "nweb", "hdf", "virse", "workq", "ipa", "sched", "freq", "disk", "sync", "binder", "mmc", "membus", "load" 408``` 409 410 411使用下面的命令开启捕获二进制trace。 412 413 414```shell 415hitrace --start_bgsrv 416``` 417 418 419**使用样例**: 420 421 422```shell 423$ hitrace --start_bgsrv 4242025/06/04 16:44:54 hitrace enter, running_state is SNAPSHOT_START 4252025/06/04 16:44:54 OpenSnapshot done. 426``` 427 428 429使用以下命令将当前缓冲区的trace信息导出到文件。二进制格式trace不支持指定路径导出或显示到命令行窗口,导出的文件路径会显示在命令行窗口。 430 431 432```shell 433hitrace --dump_bgsrv 434``` 435 436 437**使用样例**: 438 439 440```shell 441$ hitrace --dump_bgsrv 4422025/06/04 16:50:34 hitrace enter, running_state is SNAPSHOT_DUMP 4432025/06/04 16:50:35 DumpSnapshot done, output: 444 /data/log/hitrace/trace_20250604164454@613340-339960.sys 445``` 446 447 448在结束捕获时,可以使用下面的命令停止采集。 449 450 451```shell 452hitrace --stop_bgsrv 453``` 454 455 456**使用样例**: 457 458 459```shell 460$ hitrace --stop_bgsrv 4612025/06/04 16:52:51 hitrace enter, running_state is SNAPSHOT_STOP 4622025/06/04 16:52:52 CloseSnapshot done. 463``` 464 465 466### 录制模式捕获trace 467 468录制模式下,系统会持续保存运行时生成的二进制格式trace,文件大小超过设定的值时会生成新文件。不支持指定保存路径。 469 470使用以下命令开启录制模式。缓冲区大小设定为204800KB,文件大小设为102400KB,采集的tag为app和graphic。 471 472```shell 473hitrace --trace_begin --record -b 204800 --file_size 102400 app graphic 474``` 475 476**使用样例**: 477 478```shell 479$ hitrace --trace_begin --record -b 204800 --file_size 102400 app graphic 4802025/06/04 17:03:37 hitrace enter, running_state is RECORDING_LONG_BEGIN_RECORD 4812025/06/04 17:03:37 args: tags:app,graphic bufferSize:204800 overwrite:1 fileSize:102400 4822025/06/04 17:03:37 trace capturing. 483``` 484 485 486采集结束时,使用以下命令停止采集,命令行窗口会显示生成的文件的绝对路径。 487 488 489```shell 490hitrace --trace_finish --record 491``` 492 493 494**使用样例**: 495 496 497```shell 498$ hitrace --trace_finish --record 4992025/06/04 17:06:14 hitrace enter, running_state is RECORDING_LONG_FINISH_RECORD 5002025/06/04 17:06:15 capture done, output files: 501 /data/log/hitrace/record_trace_20250604170337@614463-183970330.sys 502 /data/log/hitrace/record_trace_20250604170423@614508-554071886.sys 503 /data/log/hitrace/record_trace_20250604170552@614597-598551039.sys 504``` 505 506 507### 捕获trace后进行压缩 508 509```shell 510hitrace -z -b 102400 -t 10 sched freq idle disk -o /data/local/tmp/test.ftrace 511``` 512 513**使用样例**: 514 515```shell 516$ hitrace -z -b 102400 -t 10 sched freq idle disk -o /data/local/tmp/test.ftrace 5172024/11/14 12:00:18 start capture, please wait 10s ... 5182024/11/14 12:00:28 capture done, start to read trace. 5192024/11/14 12:00:29 trace read done, output: /data/local/tmp/test.ftrace 5202024/11/14 12:00:29 TraceFinish done. 521``` 522 523 524### 设置和查询trace输出级别阈值 525 526打点级别优先级从高到低分别为 M(Commercial)、C(Critical)、I(Info)、D(Debug),低于trace输出级别阈值的打点将不会生效。 527 528开发者可使用带trace级别的打点接口(参考[js-apis-hitracemeter](../reference/apis-performance-analysis-kit/js-apis-hitracemeter.md)和[_hitrace](../reference/apis-performance-analysis-kit/capi-trace-h.md)中的API version 19的trace打点接口),测试不同阈值下的trace输出是否符合预期。 529 530```shell 531// 设置trace输出级别阈值 532hitrace --trace_level D/I/C/M 533hitrace --trace_level Debug/Info/Critical/Commercial 534// 查询trace输出级别阈值 535hitrace --get_level 536``` 537 538**使用样例**: 539 540```shell 541$ hitrace --trace_level Info 5422025/08/16 10:34:23 hitrace enter, running_state is SET_TRACE_LEVEL 5432025/08/16 10:34:23 success to set trace level. 544$ hitrace --get_level 5452025/08/16 10:34:29 hitrace enter, running_state is GET_TRACE_LEVEL 5462025/08/16 10:34:29 the current trace level threshold is Info 547``` 548 549 550## trace文件名说明 551 552使用hitrace命令行工具采集二进制格式trace信息时,不支持指定文件路径。默认保存在/data/log/hitrace路径下,hitrace自动生成文件名并将绝对路径显示在命令行窗口。 553 554快照模式下生成的trace文件名以trace开头,录制模式下生成的trace文件名以record开头,后面为本地时间和boot time(从开机时间开始的时间戳)。 555 556以下面这个文件名为例:20250701215441说明这个文件生成的时间为2025年7月1日21时54分41秒,此时对应的boot time为6016.653165227。 557 558```shell 559$ hitrace --dump_bgsrv 5602025/07/01 21:54:41 hitrace enter, running_state is SNAPSHOT_DUMP 5612025/07/01 21:54:42 DumpSnapshot done, output: 562 /data/log/hitrace/trace_20250701215441@6016-653165227.sys 563``` 564 565 566## 常见问题 567 568 569### 执行hitrace命令后显示错误码1 570 571**现象描述** 572 573执行hitrace命令后报错,错误码为1。 574 575```shell 576$ hitrace --dump_bgsrv 5772025/07/04 17:20:38 hitrace enter, running_state is SNAPSHOT_DUMP 5782025/07/04 17:20:38 error: DumpSnapshot failed, errorCode(1) 579``` 580 581**可能原因&解决方法** 582 583错误码1表示hiview进程状态异常,可以尝试重启手机后重新采集。 584 585 586### 执行hitrace命令后报错“not support category on this device” 587 588**现象描述** 589 590执行hitrace命令后报错,命令行窗口显示“not support category on this device”。 591 592```shell 593$ hitrace -t 10 aaa 5942025/07/04 17:24:21 error: aaa is not support category on this device. 5952025/07/04 17:24:21 error: parsing args failed, exit. 596``` 597 598**可能原因&解决方法** 599 600命令中指定的tag不存在,建议使用“hitrace -l”命令查看支持的tag范围。 601 602 603### 执行hitrace命令后显示错误码1004 604 605**现象描述** 606 607执行hitrace命令后报错,错误码为1004。 608 609```shell 610$ hitrace --dump_bgsrv 6112025/07/04 17:25:58 hitrace enter, running_state is SNAPSHOT_DUMP 6122025/07/04 17:25:58 error: DumpSnapshot failed, errorCode(1004) 613``` 614 615**可能原因&解决方法** 616 6171004表示写入文件错误,可能的原因包括: 618 6191. 采集文本格式trace时,使用-o参数指定输出的文件路径不存在或无权限。建议将trace保存到/data/local/tmp路径下。 620 6212. 磁盘空间已满时,不会生成新的trace文件,建议释放磁盘空间,确保空闲空间大于500MB,然后重新采集。 622