• Home
Name Date Size #Lines LOC

..--

figures/12-May-2024-

frameworks/native/12-May-2024-268205

interfaces/12-May-2024-539428

test/12-May-2024-274175

BUILD.gnD12-May-2024617 1513

LICENSED12-May-20249.9 KiB177150

OAT.xmlD12-May-20243.8 KiB6310

README.mdD12-May-20244.7 KiB7656

README_zh.mdD12-May-20244.2 KiB7656

bundle.jsonD12-May-20241.5 KiB5151

README.md

1# HiChecker
2
3-   [Introduction](#section11660541593)
4-   [Architecture](#section161941989596)
5-   [Directory Structure](#section14197309111)
6-   [Usage](#section1371113476307)
7-   [Repositories Involved](#section1371113476310)
8
9## Introduction<a name="section11660541593"></a>
10
11HiChecker is provided for you to check issues that may be easily ignored during development of OpenHarmony applications (including system-built and third-party applications). Such issues include calling of time-consuming functions by key application threads, event distribution and execution timeout in application processes, and ability resource leakage in application processes. The issues are recorded in logs or lead to process crashes explicitly so that you can find and rectify them.
12
13## Architecture<a name="section161941989596"></a>
14
15 <img src="./figures/HiChecker_architecture.png" style="zoom:100%;" />
16
17| Dependent Component                                                   | Dependency Description                                                    |
18| ----------------------------------------------------------- | ------------------------------------------------------------ |
19| Multimedia subsystem: ImagePacker           | Invokes the HiChecker API in time-consuming functions to display a notification with the preset prompt message.|
20| Ability subsystem: FeatureAbility| Provides registration for resource leakage detection and notification of the detection results.                  |
21
22Supported features:
23
24- Time-consuming function call detection
25- Ability leakage detection
26- Addition and removal of check rules
27- Addition and removal of caution rules for logs (default) and app crashes
28- When related detection conditions are met, unwinding of Native stacks to the key trigger point is supported. JS stack unwinding is not supported currently.
29
30## Directory Structure<a name="section14197309111"></a>
31
32```
33/base/hiviewdfx/hichecker
34├── frameworks          # Framework code
35│   └── native          # HiChecker Native implementation code
36├── interfaces          # APIs
37│   └── native          # C++ APIs
38│       └── innerkits   # APIs provided for internal subsystems
39|   └── js              # JS APIs
40│       └── kits        # APIs provided for applications
41├── test                # Test cases
42│   └── unittest
43```
44
45
46
47## Usage<a name="section1371113476307"></a>
48### Available APIs
49
50The following table lists the APIs provided by HiChecker.
51
52| Class       | API                                               | Description                      |
53| --------- | :-------------------------------------------------- | -------------------------- |
54| HiChecker | BigInt RULE_CAUTION_PRINT_LOG = 1<<63;              | Defines a caution rule, which is programmed to print a log when an alarm is generated.      |
55|           | BigInt RULE_CAUTION_TRIGGER_CRASH = 1<<62;          | Defines a caution rule, which is programmed to force an application to exit when an alarm is generated.      |
56|           | BigInt RULE_THREAD_CHECK_SLOW_PROCESS = 1;          | Defines a check rule, which is programmed to check whether any time-consuming function is called.|
57|           | BigInt RULE_CHECK_ABILITY_CONNECTION_LEAK = 1<<33;  | Defines a check rule, which is programmed to check ability leakage. |
58|           | addRule(BigInt rule) : void                         | Adds one or more rules.      |
59|           | removeRule(BigInt rule) : void                      | Removes one or more rules.      |
60|           | getRule() : BigInt                                  | Obtains all rules.            |
61|           | contains(BigInt rule) : boolean                     | Checks whether a rule exists.    |
62|           | NotifySlowProcess(std::string) : void               | Sends a notification of a time-consuming function call.            |
63|           | NotifySlowEvent(std::string) : void                 | Sends a notification of a time-consuming function call event.            |
64|           | NotifyAbilityConnectionLeak(Caution caution) : void | Sends a notification of ability leakage.         |
65| Caution   | GetTriggerRule() : BigInt                           | Obtains the rule that triggers the current alarm.|
66|           | GetCustomMessage() : String                         | Obtains the alarm message.          |
67|           | GetStackTrace() : String                           | Obtains stack information.              |
68
69## Repositories Involved<a name="section1371113476310"></a>
70
71[DFX Subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/dfx.md)
72
73[hiviewdfx_hilog](https://gitee.com/openharmony/hiviewdfx_hilog/blob/master/README.md)
74
75[hiviewdfx_faultloggerd](https://gitee.com/openharmony/hiviewdfx_faultloggerd/blob/master/README.md)
76

README_zh.md

1# HiChecker组件
2
3-   [简介](#section11660541593)
4-   [架构](#section161941989596)
5-   [目录](#section14197309111)
6-   [说明](#section1371113476307)
7-   [涉及仓](#section1371113476310)
8
9## 简介<a name="section11660541593"></a>
10
11HiChecker,可以作为应用开发阶段使用的检测工具,用于检测代码运行过程中部分易忽略的问题,如应用线程出现耗时调用、应用进程中元能力资源泄露等问题。开发者可以通过日志记录或进程crash等形式查看具体问题并进行修改,提升应用的使用体验。
12
13## 架构<a name="section161941989596"></a>
14
15 <img src="./figures/HiChecker架构图.png" style="zoom:100%;" />
16
17| 依赖部件                                                    | 依赖描述                                                     |
18| ----------------------------------------------------------- | ------------------------------------------------------------ |
19| 媒体子系统/【image部件】图片基础框架 ImagePacker            | 在比较耗时的函数中调用HiChecker接口,通知有耗时调用,同时传入对应的告警提示字符串 |
20| 元能力子系统/ability_runtime/运行管理支持DFX FeatureAbility | 提供注册泄露检测逻辑,通知检测模式相关结果                   |
21
22支持特性:
23
24- 提供耗时调用检测功能
25- 提供注册(ability) 泄露检测功能
26- 支持应用增加、删除不同的检测规则
27- 支持应用增加、删除不同的告警通知规则,目前支持记录流水日志(默认),应用崩溃两种规则
28- 相关检测条件满足时,支持Native回栈到关键触发点,暂不支持JS回栈
29
30## 目录<a name="section14197309111"></a>
31
32```
33/base/hiviewdfx/hichecker
34├── frameworks          # 框架代码
35│   └── native          # HiChecker native实现代码
36├── interfaces          # 接口
37│   └── native          # C++接口
38│       └── innerkits   # 对内部子系统提供的接口
39|   └── js              # JS接口
40│       └── kits        # 对应用提供的接口
41├── test                # 测试用例
42│   └── unittest
43```
44
45
46
47## 说明<a name="section1371113476307"></a>
48### 接口说明
49
50主要接口说明
51
52| 类        | 方法                                                | 描述                       |
53| --------- | :-------------------------------------------------- | -------------------------- |
54| HiChecker | BigInt RULE_CAUTION_PRINT_LOG = 1<<63;              | 告警规则,仅记录日志       |
55|           | BigInt RULE_CAUTION_TRIGGER_CRASH = 1<<62;          | 告警规则,让应用退出       |
56|           | BigInt RULE_THREAD_CHECK_SLOW_PROCESS = 1;          | 检测规则,检测耗时函数调用 |
57|           | BigInt RULE_CHECK_ABILITY_CONNECTION_LEAK = 1<<33;  | 检测规则,检测ability泄露  |
58|           | addRule(BigInt rule) : void                         | 增加一个或多个检测项       |
59|           | removeRule(BigInt rule) : void                      | 删除一个或多个检测项       |
60|           | getRule() : BigInt                                  | 获取所有检测项             |
61|           | contains(BigInt rule) : boolean                     | 当前是否有某一个检测项     |
62|           | NotifySlowProcess(std::string) : void               | 通知有耗时调用             |
63|           | NotifySlowEvent(std::string) : void                 | 通知有耗时事件             |
64|           | NotifyAbilityConnectionLeak(Caution caution) : void | 通知有ability泄露          |
65| Caution   | GetTriggerRule() : BigInt                           | 获取触发当前告警的检测规则 |
66|           | GetCustomMessage() : String                         | 获取更多辅助信息           |
67|           | GetStackTrace() :String                            | 获取堆栈信息               |
68
69## 涉及仓<a name="section1371113476310"></a>
70
71[DFX子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/DFX子系统.md)
72
73[hiviewdfx_hilog](https://gitee.com/openharmony/hiviewdfx_hilog/blob/master/README_zh.md)
74
75[hiviewdfx_faultloggerd](https://gitee.com/openharmony/hiviewdfx_faultloggerd/blob/master/README_zh.md)
76