OpenHarmony开发者论坛

标题: OpenHarmony超实用工具-Hidumper介绍 [打印本页]

作者: 深开鸿_王石    时间: 2023-12-21 10:18
标题: OpenHarmony超实用工具-Hidumper介绍
[md]### 简介

**HiDumper是OpenHarmony中为开发、测试人员,IDE工具提供统一的系统信息获取工具,帮助使用者分析,定位问题。**

**HiDumper主要包括以下几个主要模块:**

* **hidumper:可执行程序,工具入口,在板上可通过hidumper执行对应命令**
* **hidumperclient:动态库,提供framework层接口**
* **lib\_dump\_usage:动态库,提供framework层功能实现**
* **hidumperservice:动态库,sa服务,提供service层功能实现**

---

### 结构分析

```
.
├── BUILD.gn
├── bundle.json
├── client
│   └── native
│       ├── dump_client_main.cpp  
│       └── main.cpp                //可执行文件入口
├── figures
├── frameworks                      //框架实现
│   └── native
│       ├── BUILD.gn
│       ├── common.h
│       ├── dump_controller.h
│       ├── dump_utils.cpp
│       ├── dump_utils.h
│       ├── include
│       └── src
├── hidumper.gni
├── interfaces
│   ├── innerkits
│   │   ├── BUILD.gn
│   │   ├── dump_usage.cpp
│   │   └── include
│   └── native
│       └── innerkits
├── LICENSE
├── OAT.xml
├── README.md
├── README_zh.md
├── sa_profile
├── services                        //服务实现
│   ├── BUILD.gn
│   ├── hidumper.map
│   ├── native
│   │   ├── etc
│   │   ├── include
│   │   └── src
│   └── zidl
│       ├── include
│       └── src
├── test
└── utils
```

* **usage**

```
       "usage:\n"
       "  -h                          |help text for the tool\n"
       "  -lc                         |a list of system information clusters\n"
       "  -ls                         |a list of system abilities\n"
       "  -c                          |all system information clusters\n"
       "  -c [base system]            |system information clusters labeled \"base\" and \"system\"\n"
       "  -s                          |all system abilities\n"
       "  -s [SA0 SA1]                |system abilities labeled \"SA0\" and \"SA1\"\n"
       "  -s [SA] -a ['-h']           |system ability labeled \"SA\" with arguments \"-h\" specified\n"
       "  -e                          |faultlogs of crash history\n"
       "  --net                       |dump network information\n"
       "  --storage                   |dump storage information\n"
       "  -p                          |processes information, include list and infromation of processes"
       " and threads\n"
       "  -p [pid]                    |dump threads under pid, includes smap, block channel,"
       " execute time, mountinfo\n"
       "  --cpuusage [pid]            |dump cpu usage by processes and category; if PID is specified,"
       " dump category usage of specified pid\n"
       "  --cpufreq                   |dump real CPU frequency of each core\n"
       "  --mem [pid]                 |dump memory usage of total; dump memory usage of specified"
       " pid if pid was specified\n"
       "  --zip                       |compress output to /data/log/hidumper\n";
```

**如上,我们可以看出hidumper能查看几乎OpenHarmony里内的所有信息,比如:**

* **查看系统ability信息,其中也包括HiDumperService**

```
# hidumper -ls
System ability list:
RenderService                    AbilityManagerService            DataObserverMgr
UriPermissionMgr                 AccountMgr                       BundleMgr
FormMgr                          ApplicationManagerService        Installd
AccessibilityManagerService      UserIdmService                   UserAuthService
AuthExecutorMgrService           PinAuthService                   FaceAuthService
WifiDevice                       WifiHotspot                      WifiP2p
WifiScan                         BluetoothHost                    NetConnManager
NetPolicyManager                 NetStatsManager                  NetTetheringManager
EthernetManager                  NetsysNative                     HiviewService
HiviewFaultLogger                HiviewSysEventService            HiDumperService
DistributedKvData                DistributedSched                 EnterpriseDeviceManagerService
ResourceSched                    BackgroundTaskManager            WorkSchedule
SocPerfService                   DeviceUsageStatistics            MemoryManagerService
LocationGeoConvert               LocationLocator                  LocationGnss
LocationNetworkLocating          LocationNopowerLocating          DeviceStatusService
AudioDistributed                 PlayerDistributedService         CameraService
AudioPolicyService               AVSessionService                 MultimodalInput
DistributedNotificationService   CommonEventService               PowerManagerService
BatteryService                   ThermalService                   BatteryStatisticsService
DisplayPowerManagerService       AccessTokenManagerService        PrivacyManagerService
KeystoreService                  CertManagerService               SensorService
MiscDeviceService                PasteboardService                TimeService
InputMethodService               ScreenlockService                WallpaperManagerService
ParamWatcher                     SysParamDevice                   TelephonyCellularCall
TelephonyCellularData            TelephonySmsMms                  TelephonyStateRegistry
TelephonyCoreService             UsbService                       WindowManagerService
DisplayManagerService            DSoftbus                         DeviceAuthService
DeviceManagerService             StorageDaemon                    StorageManager
HdfDeviceServiceManager          DistributedFileDaemon            devattest_service
DistributedDeviceProfile         UiService
```

* **查看系统ability信息,其中也包括HiDumperService**
  ```

  -------------------------------[ability]-------------------------------


  ----------------------------------RenderService---------------------------------
  ------Graphic2D--RenderSerice ------
  Usage:
   h                             |help text for the tool
  screen                         |dump all screen infomation in the system
  surface                        |dump all surface information
  composer fps                   |dump the fps info of composer
  [surface name] fps             |dump the fps info of surface
  composer fpsClear                   |clear the fps info of composer
  [surface name] fpsClear             |clear the fps info of surface
  nodeNotOnTree                  |dump nodeNotOnTree info
  allSurfacesMem                 |dump surface mem info
  RSTree                         |dump RSTree info
  EventParamList                 |dump EventParamList info
  allInfo                        |dump all info
  ...后面有好多
  ```
* **查看系统网络信息**
  ```
  #hidumper --net

  -------------------------------[net]-------------------------------


  cmd is: netstat -nW

  Active Internet connections (w/o servers)
  Proto Recv-Q Send-Q Local Address                                       Foreign Address                                     State      
  udp        0      0 127.0.0.1:44451                                     127.0.0.1:9877                                      ESTABLISHED
  udp        0      0 127.0.0.1:37649                                     127.0.0.1:9877                                      ESTABLISHED
  Active UNIX domain sockets (w/o servers)
  Proto RefCnt Flags   Type       State       I-Node Path
  unix  2      [ ]         DGRAM                        1675 /dev/unix/socket/fd_holder
  unix  74     [ ]         DGRAM                         344 /dev/unix/socket/hilogInput
  unix  2      [ ]         DGRAM                        1719 /dev/unix/socket/hisysevent
  unix  2      [ ]         SEQPACKET                   24844 /dev/unix/socket/hdcd
  ...后面还有好多
  ```
* **查看系统进程信息**
  ```
  #hidumper -p

  -------------------------------[processes]-------------------------------


  cmd is: ps -efT

  UID            PID   TID  PPID TCNT STIME TTY          TIME CMD
  root             1     1     0    1 15:55:05 ?     00:00:03 init --second-stage
  root             2     2     0    1 15:55:05 ?     00:00:00 [kthreadd]
  root             3     3     2    1 15:55:05 ?     00:00:00 [rcu_gp]
  root             4     4     2    1 15:55:05 ?     00:00:00 [rcu_par_gp]
  root             8     8     2    1 15:55:05 ?     00:00:00 [mm_percpu_wq]
  root             9     9     2    1 15:55:05 ?     00:00:00 [rcu_tasks_rude_]
  ...后面还有好多
  ```
* **查看系统内存信息**
  ```
  #hidumper --mem

  -------------------------------[memory]-------------------------------

  Total Memory Usage by PID:
  PID  Name                Total Pss(xxx in SwapPss)   Total Vss   Total Rss   Total Uss          GL       Graph
  1       init               1217(0 in SwapPss) kB     4612 kB     3600 kB      828 kB        0 kB        0 kB
  241     watchdog_servic    260(0 in SwapPss) kB     3160 kB     2320 kB      232 kB        0 kB        0 kB
  253     hilogd             2414(0 in SwapPss) kB     5968 kB     4576 kB     2252 kB        0 kB        0 kB
  254     hdf_devmgr         600(0 in SwapPss) kB     6440 kB     3320 kB      496 kB        0 kB        0 kB
  255     hiview             4780(0 in SwapPss) kB    79168 kB    14752 kB     3148 kB        0 kB        0 kB
  256     storage_daemon     1539(0 in SwapPss) kB    11404 kB     7024 kB      932 kB        0 kB        0 kB
  ...后面有好多
  ```
* **查看系统错误**
  ```
  #hidumper -e

  -------------------------------[faultlog]-------------------------------


  /data/log/faultlog/faultlogger/jscrash-ohos.samples.videoplayer-20010040-20230328160126

  Generated by HiviewDFX@OpenHarmony
  ================================================================
  Device info:OpenHarmony 3.2
  Build info:OpenHarmony 3.2.11.2
  Module name:ohos.samples.videoplayer
  Version:1.0.0
  Pid:1763
  Uid:20010040
  Lifetime: 0.000000s
  Js-Engine: ark
  page: pages/Player.js
  Error message: assertion (false) failed: type mismatch
  Stacktrace:
      at clearVideoPlayer (/ets/pages/Player.ets:213:7)
      at onPageHide (/ets/pages/Player.ets:200:5)
  ...后面还有好多
  ```

---

**从上面列举的一些命令可以看出hidumper是个集成入口,有些用了Linux下的常规命令,如ps,netstat,有些用OH内特制的内容,如systemability,faultlog**

---

### 基本原理

* **hidumper同OHOS里的其他服务一样都提供framework和service架构,通过IPC方式通过hidumperservice服务执行具体命令。**
* **功能定义:**
  **在下面的问题提供三部分内容:**

  ```
  base/hiviewdfx/hidumper/frameworks/native/src/util/config_data.cpp
  1. 功能定义
  const std::string ConfigData::CONFIG_NAME_SPLIT = "_";
  const std::string ConfigData::CONFIG_GROUP = "group";
  ...
  const std::string ConfigData::CONFIG_DUMPER_LIST_SYSTEM_ABILITY = ConfigData::CONFIG_DUMPER_LIST_ + "system_ability";
  ...
  const std::string ConfigData::STR_ABILITY = "ability";
  const std::string ConfigData::STR_BASE = "base";
  const std::string ConfigData::STR_SERVICE = "service";
  const std::string ConfigData::STR_SYSTEM = "system";

  2. dumper方法
  const ConfigData::ItemCfg ConfigData::baseInfoDumper_[] = {
      {
          .name_ = "dumper_base_info",
          .desc_ = "Base Information",
          .target_ = "",
          .section_ = "",
          .class_ = DumperConstant::API_DUMPER,
          .level_ = DumperConstant::NONE,
          .loop_ = DumperConstant::NONE,
          .filterCfg_ = "",
      },
      {
          .name_ = "",
          .desc_ = "",
          .target_ = "",
          .section_ = "",
          .class_ = DumperConstant::FD_OUTPUT,
          .level_ = DumperConstant::NONE,
          .loop_ = DumperConstant::NONE,
          .filterCfg_ = "",
      },
  };

  3. 功能组定义
  ...
  const std::string ConfigData::testGroup_[] = {
      "dumper_test",
  };

  const ConfigData::GroupCfg ConfigData::groups_[] = {
      {
          .name_ = ConfigData::CONFIG_GROUP_CPU_FREQ,
          .desc_ = "group of cpu freq dumper",
          .list_ = cpuFreqGroup_,
          .size_ = ARRAY_SIZE(cpuFreqGroup_),
          .type_ = DumperConstant::GROUPTYPE_CPUID,
          .expand_ = true,
      },
  ...
  ```
* **简单调用流程:**

  <pre class="md-fences md-end-block md-diagram md-fences-advanced ty-contain-cm modeLoaded" spellcheck="false" lang="mermaid" cid="n63" mdtype="fences" mermaid-type="graph"><div class="md-diagram-panel md-fences-adv-panel"><div class="md-diagram-panel-header"></div><div class="md-diagram-panel-preview"><svg id="mermaidChart0" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="61.59375" viewBox="0 0 745.078125 61.59375" class="in-text-selection"><g><g class="output"><g class="clusters"></g><g class="edgePaths"><g class="edgePath LS-main LE-DumpManagerClient" id="L-main-DumpManagerClient"><path class="path" d="M65.953125,30.796875L90.953125,30.796875L115.953125,30.796875" marker-end="url(#arrowhead17)"></path><defs><marker id="arrowhead17" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath"></path></marker></defs></g><g class="edgePath LS-DumpManagerClient LE-DumpManagerService" id="L-DumpManagerClient-DumpManagerService"><path class="path" d="M295.9375,30.796875L320.9375,30.796875L345.9375,30.796875" marker-end="url(#arrowhead18)"></path><defs><marker id="arrowhead18" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath"></path></marker></defs></g><g class="edgePath LS-DumpManagerService LE-DumpImplement" id="L-DumpManagerService-DumpImplement"><path class="path" d="M536.671875,30.796875L561.671875,30.796875L586.671875,30.796875" marker-end="url(#arrowhead19)"></path><defs><marker id="arrowhead19" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform=""><g transform="translate(0,0)" class="label"><rect rx="0" ry="0" width="0" height="0"></rect><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml"><span id="L-L-main-DumpManagerClient" class="edgeLabel L-LS-main' L-LE-DumpManagerClient"></span></div></foreignObject></g></g><g class="edgeLabel" transform=""><g transform="translate(0,0)" class="label"><rect rx="0" ry="0" width="0" height="0"></rect><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml"><span id="L-L-DumpManagerClient-DumpManagerService" class="edgeLabel L-LS-DumpManagerClient' L-LE-DumpManagerService"></span></div></foreignObject></g></g><g class="edgeLabel" transform=""><g transform="translate(0,0)" class="label"><rect rx="0" ry="0" width="0" height="0"></rect><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml"><span id="L-L-DumpManagerService-DumpImplement" class="edgeLabel L-LS-DumpManagerService' L-LE-DumpImplement"></span></div></foreignObject></g></g></g><g class="nodes"><g class="node default" id="flowchart-main-4" transform="translate(36.9765625,30.796875)"><rect rx="0" ry="0" x="-28.9765625" y="-22.796875" width="57.953125" height="45.59375" class="label-container"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-18.9765625,-12.796875)"><foreignObject width="37.953125" height="25.59375"><div xmlns="http://www.w3.org/1999/xhtml">main</div></foreignObject></g></g></g><g class="node default" id="flowchart-DumpManagerClient-5" transform="translate(205.9453125,30.796875)"><rect rx="0" ry="0" x="-89.9921875" y="-22.796875" width="179.984375" height="45.59375" class="label-container"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-79.9921875,-12.796875)"><foreignObject width="159.984375" height="25.59375"><div xmlns="http://www.w3.org/1999/xhtml">DumpManagerClient</div></foreignObject></g></g></g><g class="node default" id="flowchart-DumpManagerService-6" transform="translate(441.3046875,30.796875)"><rect rx="0" ry="0" x="-95.3671875" y="-22.796875" width="190.734375" height="45.59375" class="label-container"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-85.3671875,-12.796875)"><foreignObject width="170.734375" height="25.59375"><div xmlns="http://www.w3.org/1999/xhtml">DumpManagerService</div></foreignObject></g></g></g><g class="node default" id="flowchart-DumpImplement-7" transform="translate(661.875,30.796875)"><rect rx="0" ry="0" x="-75.203125" y="-22.796875" width="150.40625" height="45.59375" class="label-container"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-65.203125,-12.796875)"><foreignObject width="130.40625" height="25.59375"><div xmlns="http://www.w3.org/1999/xhtml">DumpImplement</div></foreignObject></g></g></g></g></g></g></svg></div><div class="md-diagram-panel-error"></div></div></pre>
* **功能实现流程:**

  <pre class="md-fences md-end-block md-diagram md-fences-advanced ty-contain-cm modeLoaded" spellcheck="false" lang="mermaid" cid="n67" mdtype="fences" mermaid-type="graph"><div class="md-diagram-panel md-fences-adv-panel"><div class="md-diagram-panel-header"></div><div class="md-diagram-panel-preview"><svg id="mermaidChart1" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="61.59375" viewBox="0 0 1135.71875 61.59375" class="in-text-selection"><g><g class="output"><g class="clusters"></g><g class="edgePaths"><g class="edgePath LS-CmdParse LE-GetDumperConfigs" id="L-CmdParse-GetDumperConfigs"><path class="path" d="M104.71875,30.796875L129.71875,30.796875L154.71875,30.796875" marker-end="url(#arrowhead46)"></path><defs><marker id="arrowhead46" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath"></path></marker></defs></g><g class="edgePath LS-GetDumperConfigs LE-GetExecutorConfigList" id="L-GetDumperConfigs-GetExecutorConfigList"><path class="path" d="M322.28125,30.796875L347.28125,30.796875L372.28125,30.796875" marker-end="url(#arrowhead47)"></path><defs><marker id="arrowhead47" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath"></path></marker></defs></g><g class="edgePath LS-GetExecutorConfigList LE-setExecutorList" id="L-GetExecutorConfigList-setExecutorList"><path class="path" d="M561.671875,30.796875L586.671875,30.796875L611.671875,30.796875" marker-end="url(#arrowhead48)"></path><defs><marker id="arrowhead48" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath"></path></marker></defs></g><g class="edgePath LS-setExecutorList LE-SetProgressEnabled" id="L-setExecutorList-SetProgressEnabled"><path class="path" d="M745.796875,30.796875L770.796875,30.796875L795.796875,30.796875" marker-end="url(#arrowhead49)"></path><defs><marker id="arrowhead49" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath"></path></marker></defs></g><g class="edgePath LS-SetProgressEnabled LE-DumpDatas" id="L-SetProgressEnabled-DumpDatas"><path class="path" d="M967.21875,30.796875L992.21875,30.796875L1017.21875,30.796875" marker-end="url(#arrowhead50)"></path><defs><marker id="arrowhead50" viewBox="0 0 10 10" refX="9" refY="5" markerUnits="strokeWidth" markerWidth="8" markerHeight="6" orient="auto"><path d="M 0 0 L 10 5 L 0 10 z" class="arrowheadPath"></path></marker></defs></g></g><g class="edgeLabels"><g class="edgeLabel" transform=""><g transform="translate(0,0)" class="label"><rect rx="0" ry="0" width="0" height="0"></rect><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml"><span id="L-L-CmdParse-GetDumperConfigs" class="edgeLabel L-LS-CmdParse' L-LE-GetDumperConfigs"></span></div></foreignObject></g></g><g class="edgeLabel" transform=""><g transform="translate(0,0)" class="label"><rect rx="0" ry="0" width="0" height="0"></rect><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml"><span id="L-L-GetDumperConfigs-GetExecutorConfigList" class="edgeLabel L-LS-GetDumperConfigs' L-LE-GetExecutorConfigList"></span></div></foreignObject></g></g><g class="edgeLabel" transform=""><g transform="translate(0,0)" class="label"><rect rx="0" ry="0" width="0" height="0"></rect><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml"><span id="L-L-GetExecutorConfigList-setExecutorList" class="edgeLabel L-LS-GetExecutorConfigList' L-LE-setExecutorList"></span></div></foreignObject></g></g><g class="edgeLabel" transform=""><g transform="translate(0,0)" class="label"><rect rx="0" ry="0" width="0" height="0"></rect><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml"><span id="L-L-setExecutorList-SetProgressEnabled" class="edgeLabel L-LS-setExecutorList' L-LE-SetProgressEnabled"></span></div></foreignObject></g></g><g class="edgeLabel" transform=""><g transform="translate(0,0)" class="label"><rect rx="0" ry="0" width="0" height="0"></rect><foreignObject width="0" height="0"><div xmlns="http://www.w3.org/1999/xhtml"><span id="L-L-SetProgressEnabled-DumpDatas" class="edgeLabel L-LS-SetProgressEnabled' L-LE-DumpDatas"></span></div></foreignObject></g></g></g><g class="nodes"><g class="node default" id="flowchart-CmdParse-14" transform="translate(56.359375,30.796875)"><rect rx="0" ry="0" x="-48.359375" y="-22.796875" width="96.71875" height="45.59375" class="label-container"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-38.359375,-12.796875)"><foreignObject width="76.71875" height="25.59375"><div xmlns="http://www.w3.org/1999/xhtml">CmdParse</div></foreignObject></g></g></g><g class="node default" id="flowchart-GetDumperConfigs-15" transform="translate(238.5,30.796875)"><rect rx="0" ry="0" x="-83.78125" y="-22.796875" width="167.5625" height="45.59375" class="label-container"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-73.78125,-12.796875)"><foreignObject width="147.5625" height="25.59375"><div xmlns="http://www.w3.org/1999/xhtml">GetDumperConfigs</div></foreignObject></g></g></g><g class="node default" id="flowchart-GetExecutorConfigList-16" transform="translate(466.9765625,30.796875)"><rect rx="0" ry="0" x="-94.6953125" y="-22.796875" width="189.390625" height="45.59375" class="label-container"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-84.6953125,-12.796875)"><foreignObject width="169.390625" height="25.59375"><div xmlns="http://www.w3.org/1999/xhtml">GetExecutorConfigList</div></foreignObject></g></g></g><g class="node default" id="flowchart-setExecutorList-17" transform="translate(678.734375,30.796875)"><rect rx="0" ry="0" x="-67.0625" y="-22.796875" width="134.125" height="45.59375" class="label-container"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-57.0625,-12.796875)"><foreignObject width="114.125" height="25.59375"><div xmlns="http://www.w3.org/1999/xhtml">setExecutorList</div></foreignObject></g></g></g><g class="node default" id="flowchart-SetProgressEnabled-18" transform="translate(881.5078125,30.796875)"><rect rx="0" ry="0" x="-85.7109375" y="-22.796875" width="171.421875" height="45.59375" class="label-container"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-75.7109375,-12.796875)"><foreignObject width="151.421875" height="25.59375"><div xmlns="http://www.w3.org/1999/xhtml">SetProgressEnabled</div></foreignObject></g></g></g><g class="node default" id="flowchart-DumpDatas-19" transform="translate(1072.46875,30.796875)"><rect rx="0" ry="0" x="-55.25" y="-22.796875" width="110.5" height="45.59375" class="label-container"></rect><g class="label" transform="translate(0,0)"><g transform="translate(-45.25,-12.796875)"><foreignObject width="90.5" height="25.59375"><div xmlns="http://www.w3.org/1999/xhtml">DumpDatas</div></foreignObject></g></g></g></g></g></g></svg></div><div class="md-diagram-panel-error"></div></div></pre>

  * **CmdParse: 解析命令**
  * **GetDumperConfigs: 获取配置**
  * **GetExecutorConfigList: 根据配置获取执行命令**
  * **setExecutorList: 生成执行命令列表,通过ptrExecutorFactoryMap\_获得对应executor**
  * **SetProgressEnabled: 设置执行开关**
  * **DumpDatas: 执行命令,获取输出信息**
* **executor实现:**

  ```
  //命令调用
  popen 对应 dumper里.class_ = DumperConstant::CMD_DUMPER,

  //文件读取
  fdopen 对应 dumper里 .class_ = DumperConstant::FILE_DUMPER,

  //api接口读取
  提供对应的API调用,如GetDisplayVersion, 对应 dumper里 .class_ = DumperConstant::API_DUMPER,
  ```

### 小结

**本章我们讲了hidumper,作为开发者的查询工具,通过此工具可以查询系统信息,服务信息,进程栈等信息。通过此工具可以协助开发者发现一些系统运行信息,比如进程,线程,内存,CPU等信息;当然也可自己根据具体内容实现实现自己的对应查看工具:)**
[/md]




欢迎光临 OpenHarmony开发者论坛 (https://forums.openharmony.cn/) Powered by Discuz! X3.5