README.md
1# HiDumper<a name="EN-US_TOPIC_0000001116225437"></a>
2
3 - [Introduction](#section11660541593)
4 - [Directory Structure](#section161941989596)
5 - [Usage](#section1312121216216)
6 - [How to Use](#section129654513264)
7 - [Repositories Involved](#section1371113476307)
8
9## Introduction<a name="section11660541593"></a>
10
11HiDumper is a unified system information collection tool provided by OpenHarmony for development and test personnel to analyze and locate faults.
12
13HiDumper consists of the following modules:
14
15- hidumper: Serves as the executable program of HiDumper, which receives user input and communicates with the server.
16- DumpManager: Serves as the manager of HiDumper, which provides functions such as information classification, command request distribution, and information collection.
17- Dumpers: Exports various information, including file information, command information, CPU usage, and memory usage.
18- Output: Outputs various contents. This module consists of two parts: FdOutput for standard output or file output and ZipOutput for compressed output.
19
20**Figure 1** HiDumper architecture
21
22![](figures/en-us_image_0000001116226343.png)
23
24## Directory Structure<a name="section161941989596"></a>
25
26```
27/base/hiviewdfx/hidumper
28├── client # Client code
29│ ├── native # Native code
30├── frameworks # Framework code
31│ ├── native # Core function code
32| | |── include # Header files
33| | |── src # Source files
34| | |── common # Common function code
35| | |── executor # Process executor code
36| | |── factory # Factory code
37| | |── manager # Core manager code
38| | |── util # Utility code
39|── sa_profile # HiDumper SA profile
40|── services # HiDumper service code
41| |── native # C++ service code
42| |── zidl # Communication function
43| | |── include # Header files of the communication function
44| | |── src # Source code of the communication function
45├── test # Test cases
46│ ├── unittest # Unit test code
47│ ├── moduletest # Module-level test code
48```
49
50## Usage<a name="section1312121216216"></a>
51
52During OpenHarmony application development, you can use HiDumper to query system information, service information, and process stack information, and then use the information to analyze and locate faults.
53
54
55### How to Use<a name="section129654513264"></a>
56
57HiDumper helps you export basic system information to locate and analyze faults. When passing complex parameters to sub-services and abilities, enclose parameters in double quotation marks.
58
59The procedure is as follows:
60
611. Access the device CLI, and run the **hidumper -h** command to obtain the help information, which includes basic information and function syntax.
62
63 ```
64 hidumper -h
65 ```
66
672. Run the **hidumper -lc** command to obtain the system information cluster list.
68
69 ```
70 hidumper -lc
71 ```
72
733. Run the **hidumper -c** command to obtain all information that is classified by **base** and **system**.
74
75 ```
76 hidumper -c
77 ```
78
794. Run the **hidumper -c [base | system]** to obtain the system cluster information that is classified by **base** or **system**.
80
81 ```
82 hidumper -c base
83 hidumper -c system
84 ```
85
865. Run the **hidumper -ls** command to obtain the system ability list.
87
88 ```
89 hidumper -ls
90 ```
91
926. Run the **hidumper -s** command to obtain all system ability information.
93
94 ```
95 hidumper -s
96 ```
97
987. Run the **hidumper -s 3301 -a "-h"** command to obtain the help information about the ability whose ID is **3301**.
99
100 ```
101 hidumper -s 3301 -a "-h"
102 ```
103
1048. Run the **hidumper -s 3008** command to obtain all information about the ability whose ID is **3008**.
105
106 ```
107 hidumper -s 3008
108 ```
109
1109. Run the **hidumper -e** command to obtain the crash information generated by the Faultlog module.
111
112 ```
113 hidumper -e
114 ```
115
11610. Run the **hidumper --net** command to obtain network information of the process whose PID has been specified.
117
118 ```
119 hidumper --net
120 hidumper --net 1024
121 ```
122
12311. Run the **hidumper --storage** command to obtain storage information of the process whose PID has been specified.
124
125 ```
126 hidumper --storage
127 hidumper --storage 1024
128 ```
12912. Run the **hidumper -p** command to obtain process information, including the list and information of processes and threads.
130
131 ```
132 hidumper -p
133 ```
134
13513. Run the **hidumper -p 1024** command to obtain information about the process whose PID is **1024**.
136
137 ```
138 hidumper -p 1024
139 ```
140
14114. Run the **hidumper --cpuusage [pid]** command to obtain the CPU usage information of the process whose PID has been specified.
142
143 ```
144 hidumper --cpuusage
145 hidumper --cpuusage 1024
146 ```
147
14815. Run the **hidumper --cpufreq** command to obtain the actual operating frequency of each CPU core.
149
150 ```
151 hidumper --cpufreq
152 ```
153
15416. Run the **hidumper --mem [pid]** command to obtain all memory usage information of the process whose PID has been specified.
155
156 ```
157 hidumper --mem
158 hidumper --mem 1024
159 ```
160
16117. Run the **hidumper --zip** command to compress data to the **/data/log/hidumper** directory.
162
163 ```
164 hidumper --zip
165 ```
166
16718. Run the **hidumper --mem-smaps pid [-v]** The pid parameter is mandatory.Run the following command to query the detailed memory usage of a specified process.
168
169 ```
170 hidumper --zip
171 ```
172
17319. run the **hidumper --mem-jsheap pid [-T tid] [--gc]** The pid parameter is mandatory.Run the following command to trigger all threads gc and export snapshot.If -T is specified, only the thread's GC and snapshot export will be triggered; If --gc is specified, only trigger GC without doing snapshot export.
174
175 ```
176 hidumper --mem-jsheap pid [-T tid] [--gc]
177 ```
178
179## Repositories Involved<a name="section1371113476307"></a>
180
181[DFX Subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/dfx.md)
182
183[hiviewdfx_hilog](https://gitee.com/openharmony/hiviewdfx_hilog/blob/master/README.md)
184
185[hiviewdfx_faultloggerd](https://gitee.com/openharmony/hiviewdfx_faultloggerd/blob/master/README.md)
186
187[hiviewdfx_hidumper](https://gitee.com/openharmony/hiviewdfx_hidumper/blob/master/README.md)
README_zh.md
1# HiDumper组件<a name="ZH-CN_TOPIC_0000001116225437"></a>
2
3
4- [HiDumper组件<a name="ZH-CN_TOPIC_0000001116225437"></a>](#hidumper组件)
5 - [简介<a name="section11660541593"></a>](#简介)
6 - [目录<a name="section161941989596"></a>](#目录)
7 - [说明<a name="section1312121216216"></a>](#说明)
8 - [接口说明<a name="section1551164914237"></a>](#接口说明)
9 - [使用说明<a name="section129654513264"></a>](#使用说明)
10 - [相关仓<a name="section1371113476307"></a>](#相关仓)
11
12
13## 简介<a name="section11660541593"></a>
14
15HiDumper是OpenHarmony中为开发、测试人员,IDE工具提供统一的系统信息获取工具,帮助使用者分析,定位问题。
16
17HiDumper主要包括以下几个主要模块:
18
19- hidumper,hidumper工具的可执行程序,接收用户输入,与服务端通讯。
20- DumpManager,系统信息导出工具管理者,提供信息分类,命令请求分发和信息获取方法的管理。
21- Dumpers,各类信息的导出器。主要包括文件导出、命令导出、CPU使用导出、内存使用导出等。
22- Output,内容输出,主要包括向标准输出或文件输出的FdOutput,压缩输出的ZipOutput。
23
24**图1** HiDumper架构图
25
26![](figures/zh-cn_image_0000001116226343.png)
27
28## 目录<a name="section161941989596"></a>
29
30```
31/base/hiviewdfx/hidumper
32├── client # 客户端代码
33│ ├── native # 客户端native代码
34├── frameworks # 框架代码
35│ ├── native # 导出功能核心代码
36| | |── include # 头文件目录
37| | |── src # 源文件目录
38| | |── common # 通用功能代码
39| | |── executor # 导出过程执行器代码
40| | |── factory # 跟进导出项生成导出执行器
41| | |── manager # 导出管理核心代码
42| | |── util # 工具类源代码
43|── sa_profile # Hidumper sa 属性文件
44|── services # Hidumper服务源码
45| |── native # 服务C++源码
46| |── zidl # 通讯功能源码目录
47| | |── include # 通讯功能头文件
48| | |── src # 通讯功能源代码
49├── test # 测试用例目录
50│ ├── unittest # 单元测试代码
51│ ├── moduletest # 模块级别测试代码
52```
53
54## 说明<a name="section1312121216216"></a>
55
56开发者在OpenHarmony应用开发过程中需要查询系统信息,服务信息,进程栈等信息时可以通过HiDumper获取到对应信息,然后利用这些信息分析定位问题。
57
58
59### 使用说明<a name="section129654513264"></a>
60
61hidumper可以为开发者导出系统当前基本信息,通过这些基本信息可以定位分析问题。给子服务和元能力传递复杂参数时,参数需要在双引号中。
62
63具体步骤如下:
64
651. 进入设备命令行,输入hidumper -h获取基本信息介绍,功能语法介绍。
66
67 ```
68 hidumper -h
69 ```
70
712. 输入hidumper -lc获取系统信息分类列表。
72
73 ```
74 hidumper -lc
75 ```
76
773. 输入hidumper -c 获取系统base、system等所有分类信息。
78
79 ```
80 hidumper -c
81 ```
82
834. 输入 **hidumper -c [base system]** 按 **base** 或 **system** 分类获取系统簇信息。
84
85 ```
86 hidumper -c base
87 hidumper -c system
88 ```
89
905. 输入 **hidumper -ls** 命令获取系统中元能力列表。
91
92 ```
93 hidumper -ls
94 ```
95
966. 输入 **hidumper -s** 命令获取系统全部元能力信息。
97
98 ```
99 hidumper -s
100 ```
101
1027. 运行 **hidumper -s 3301 -a "-h"** 命令获取id为3301的元能力的帮助。
103
104 ```
105 hidumper -s 3301 -a "-h"
106 ```
107
1088. 运行 **hidumper -s 3008** 命令获取id为3008的元能力的全部信息。
109
110 ```
111 hidumper -s 3008
112 ```
113
1149. 运行 **hidumper -e** 命令获取Faultlog模块生成的崩溃历史信息。
115
116 ```
117 hidumper -e
118 ```
119
12010. 运行 **hidumper --net [pid]** 命令获取网络信息;如果指定了进程的pid,则只获取该进程的网络流量使用信息。
121
122 ```
123 hidumper --net
124 hidumper --net 1024
125 ```
126
12711. 运行 **hidumper --storage [pid]** 命令获取存储相关信息;如果指定了进程的pid,则只获取该进程的io信息。
128
129 ```
130 hidumper --storage
131 hidumper --storage 1024
132 ```
13312. 运行 **hidumper -p** 命令获取进程信息,包括进程、线程的列表和信息。
134
135 ```
136 hidumper -p
137 ```
138
13913. 运行 **hidumper -p 1024** 命令获取pid为1024的进程信息。
140
141 ```
142 hidumper -p 1024
143 ```
144
14514. 运行 **hidumper --cpuusage [pid]** 命令获取CPU的使用信息;如果指定了进程的pid,则只获取该进程的CPU使用信息。
146
147 ```
148 hidumper --cpuusage
149 hidumper --cpuusage 1024
150 ```
151
15215. 运行 **hidumper --cpufreq** 命令获取每一个CPU核实际运行的频率。
153
154 ```
155 hidumper --cpufreq
156 ```
157
15816. 运行 **hidumper --mem [pid]** 命令获取全部的内存使用信息;如果指定进程的pid,只获取该进程的内存使用情况。
159
160 ```
161 hidumper --mem
162 hidumper --mem 1024
163 ```
164
16517. 运行 **hidumper --zip** 命令压缩信息数据到/data/log/hidumper目录下。
166
167 ```
168 hidumper --zip
169 ```
170
17118. 运行 **hidumper --mem-smaps pid [-v]** pid 必选参数。命令获取指定进程内存信息的详细使用情况。
172
173 ```
174 hidumper --mem-smaps pid [-v]
175 ```
176
17719. 运行 **hidumper --mem-jsheap pid [-T tid] [--gc]** pid 必选参数。命令触发所有线程gc和快照导出。如果指定线程的tid,只触发该线程gc和快照导出;如果指定--gc,只触发gc不做快照导出。
178
179 ```
180 hidumper --mem-jsheap pid [-T tid] [--gc]
181 ```
182
183## 相关仓<a name="section1371113476307"></a>
184
185
186[DFX子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/DFX子系统.md)
187
188[hiviewdfx_hilog](https://gitee.com/openharmony/hiviewdfx_hilog/blob/master/README_zh.md)
189
190[hiviewdfx_faultloggerd](https://gitee.com/openharmony/hiviewdfx_faultloggerd/blob/master/README_zh.md)
191
192[hiviewdfx_hidumper](https://gitee.com/openharmony/hiviewdfx_hidumper/blob/master/README_zh.md)
193