diff --git a/en/application-dev/Readme-EN.md b/en/application-dev/Readme-EN.md index 4c9056682a6a479fb5b907813205f5788f720ae6..6be76dd106c3f964779dd68b7034131f7b6fb174 100644 --- a/en/application-dev/Readme-EN.md +++ b/en/application-dev/Readme-EN.md @@ -35,6 +35,7 @@ - [Device Usage Statistics](device-usage-statistics/Readme-EN.md) - [DFX](dfx/Readme-EN.md) - [Internationalization](internationalization/Readme-EN.md) + - [Native APIs](napi/Readme-EN.md) - Tools - [DevEco Studio (OpenHarmony) User Guide](quick-start/deveco-studio-user-guide-for-openharmony.md) - Hands-On Tutorials @@ -43,6 +44,11 @@ - API References - [Component Reference (JavaScript-based Web-like Development Paradigm)](reference/arkui-js/Readme-EN.md) - [Component Reference (TypeScript-based Declarative Development Paradigm)](reference/arkui-ts/Readme-EN.md) - - [APIs](reference/apis/Readme-EN.md) + - APIs + - [JS (eTS Incldued) APIs](reference/apis/Readme-EN.md) + - Native APIs + - [Standard Library](reference/native-lib/third_party_libc/musl.md) + - [Node_API](reference/native-lib/third_party_napi/napi.md) - Contribution - [How to Contribute](../contribute/documentation-contribution.md) + diff --git a/en/application-dev/media/Readme-EN.md b/en/application-dev/media/Readme-EN.md index e1997f5069c591019217fc68858c866318daecbe..b47160b577b755c84faa9627e63c28456bbc9a39 100755 --- a/en/application-dev/media/Readme-EN.md +++ b/en/application-dev/media/Readme-EN.md @@ -4,11 +4,9 @@ - [Audio Overview](audio-overview.md) - [Audio Playback Development](audio-playback.md) - - [Audio Recording Development](audio-recorder.md) - [Audio Rendering Development](audio-renderer.md) - - - [Audio Capture Development](audio-capturer) + - [Audio Capture Development](audio-capturer.md) - Video - [Video Playback Development](video-playback.md) diff --git a/en/application-dev/napi/Readme-EN.md b/en/application-dev/napi/Readme-EN.md new file mode 100644 index 0000000000000000000000000000000000000000..33670e46af96c2bb35b120bd4be23958bce8f84b --- /dev/null +++ b/en/application-dev/napi/Readme-EN.md @@ -0,0 +1,3 @@ +# Native APIs + +- [Using Native APIs in Application Projects](napi-guidelines.md) diff --git a/en/application-dev/reference/Readme-EN.md b/en/application-dev/reference/Readme-EN.md index 0730fd77fd56fef492927c964e97ff47bc733610..7100b4253c003a9c4514642c4973ce1469d994b0 100644 --- a/en/application-dev/reference/Readme-EN.md +++ b/en/application-dev/reference/Readme-EN.md @@ -1,7 +1,15 @@ # Development References -- [JavaScript-based Web-like Development Paradigm](arkui-js/Readme-EN.md) -- [TypeScript-based Declarative Development Paradigm](arkui-ts/Readme-EN.md) -- [APIs](apis/Readme-EN.md) +- [JavaScript-based Web-like Development Paradigm](arkui-js/Readme-EN.md) + +- [TypeScript-based Declarative Development Paradigm](arkui-ts/Readme-EN.md) + +- APIs + + - [JS (eTS Included) APIs](apis/Readme-EN.md) + - Native APIs + - [Standard Library](native-lib/third_party_libc/musl.md) + - [Node_API](native-lib/third_party_napi/napi.md) - \ No newline at end of file + + diff --git a/en/application-dev/reference/native-lib/third_party_libuv/libuv.md b/en/application-dev/reference/native-lib/third_party_libuv/libuv.md new file mode 100644 index 0000000000000000000000000000000000000000..5fbe6060835a391832904bd396635bdf00e2585d --- /dev/null +++ b/en/application-dev/reference/native-lib/third_party_libuv/libuv.md @@ -0,0 +1,18 @@ +# libuv + + + +## Introduction + + + +libuv is a cross-platform library that implements asynchronous I/O based on event loops. It is mainly used in Node.js. + +## Supported Capabilities + + + +libuv implements cross-platform asynchronous I/O based on event loops. + +It supports standard lib interfaces. + diff --git a/en/application-dev/reference/native-lib/third_party_napi/napi.md b/en/application-dev/reference/native-lib/third_party_napi/napi.md new file mode 100644 index 0000000000000000000000000000000000000000..c3167109f246ab1d4a47e8b466a5a7cd14ef87cc --- /dev/null +++ b/en/application-dev/reference/native-lib/third_party_napi/napi.md @@ -0,0 +1,130 @@ +# Node_API + + + +## Introduction + + + +Node-API is an API used to encapsulate JavaScript capabilities as native plug-ins. It is independent of the underlying JavaScript and is maintained as part of Node.js. + +## Supported Capabilities + + + +Node-API eliminates the differences between underlying JavaScript engines and provides a set of stable interfaces. + +The NAPI component re-implements the Node-API and connects to underlying engines such as ArkJs. Currently, some interfaces in the Node-API standard library are supported. + +**List of Extended Symbols of NAPI** + +|Type|Symbol|Description| +| --- | --- | --- | +|FUNC|napi_run_script_path|Runs a JavaScript file.| + +**List of Symbols Exported from the Standard Library** + +|Type|Symbol|Description| +| --- | --- | --- | +|FUNC|napi_module_register| +|FUNC|napi_get_last_error_info| +|FUNC|napi_throw| +|FUNC|napi_throw_error| +|FUNC|napi_throw_type_error| +|FUNC|napi_throw_range_error| +|FUNC|napi_is_error| +|FUNC|napi_create_error| +|FUNC|napi_create_type_error| +|FUNC|napi_create_range_error| +|FUNC|napi_get_and_clear_last_exception| +|FUNC|napi_is_exception_pending| +|FUNC|napi_fatal_error| +|FUNC|napi_open_handle_scope| +|FUNC|napi_close_handle_scope| +|FUNC|napi_open_escapable_handle_scope| +|FUNC|napi_close_escapable_handle_scope| +|FUNC|napi_escape_handle| +|FUNC|napi_create_reference| +|FUNC|napi_delete_reference| +|FUNC|napi_reference_ref| +|FUNC|napi_reference_unref| +|FUNC|napi_get_reference_value| +|FUNC|napi_create_array| +|FUNC|napi_create_array_with_length| +|FUNC|napi_create_arraybuffer| +|FUNC|napi_create_external| +|FUNC|napi_create_external_arraybuffer| +|FUNC|napi_create_object| +|FUNC|napi_create_symbol| +|FUNC|napi_create_typedarray| +|FUNC|napi_create_dataview| +|FUNC|napi_create_int32| +|FUNC|napi_create_uint32| +|FUNC|napi_create_int64| +|FUNC|napi_create_double| +|FUNC|napi_create_string_latin1| +|FUNC|napi_create_string_utf8| +|FUNC|napi_get_array_length| +|FUNC|napi_get_arraybuffer_info| +|FUNC|napi_get_prototype| +|FUNC|napi_get_typedarray_info| +|FUNC|napi_get_dataview_info| +|FUNC|napi_get_value_bool| +|FUNC|napi_get_value_double| +|FUNC|napi_get_value_external| +|FUNC|napi_get_value_int32| +|FUNC|napi_get_value_int64| +|FUNC|napi_get_value_string_latin1| +|FUNC|napi_get_value_string_utf8| +|FUNC|napi_get_value_uint32| +|FUNC|napi_get_boolean| +|FUNC|napi_get_global| +|FUNC|napi_get_null| +|FUNC|napi_get_undefined| +|FUNC|napi_coerce_to_bool| +|FUNC|napi_coerce_to_number| +|FUNC|napi_coerce_to_object| +|FUNC|napi_coerce_to_string| +|FUNC|napi_typeof| +|FUNC|napi_instanceof| +|FUNC|napi_is_array| +|FUNC|napi_is_arraybuffer| +|FUNC|napi_is_typedarray| +|FUNC|napi_is_dataview| +|FUNC|napi_is_date| +|FUNC|napi_strict_equals| +|FUNC|napi_get_property_names| +|FUNC|napi_set_property| +|FUNC|napi_get_property| +|FUNC|napi_has_property| +|FUNC|napi_delete_property| +|FUNC|napi_has_own_property| +|FUNC|napi_set_named_property| +|FUNC|napi_get_named_property| +|FUNC|napi_has_named_property| +|FUNC|napi_set_element| +|FUNC|napi_get_element| +|FUNC|napi_has_element| +|FUNC|napi_delete_element| +|FUNC|napi_define_properties| +|FUNC|napi_call_function| +|FUNC|napi_create_function| +|FUNC|napi_get_cb_info| +|FUNC|napi_get_new_target| +|FUNC|napi_new_instance| +|FUNC|napi_define_class| +|FUNC|napi_wrap| +|FUNC|napi_unwrap| +|FUNC|napi_remove_wrap| +|FUNC|napi_create_async_work| +|FUNC|napi_delete_async_work| +|FUNC|napi_queue_async_work| +|FUNC|napi_cancel_async_work| +|FUNC|napi_get_node_version| +|FUNC|napi_get_version| +|FUNC|napi_create_promise| +|FUNC|napi_resolve_deferred| +|FUNC|napi_reject_deferred| +|FUNC|napi_is_promise| +|FUNC|napi_run_script| +|FUNC|napi_get_uv_event_loop| diff --git a/en/contribute/code-contribution.md b/en/contribute/code-contribution.md index 745343f109f954238b11df0c1eafa20594550176..4c340a50ad319bdb122658d6f6bfea7c034de72d 100644 --- a/en/contribute/code-contribution.md +++ b/en/contribute/code-contribution.md @@ -29,7 +29,6 @@ For details, see [Contribution Process](contribution-process.md). ## Security Issue Disclosure - [Security Issue Handling and Release Processes](https://gitee.com/openharmony/security/blob/master/en/security-process/README.md) - - [OpenHarmony Security Vulnerability Notice](https://gitee.com/openharmony/security/blob/master/en/security-process/security-disclosure.md) diff --git a/en/device-dev/Readme-EN.md b/en/device-dev/Readme-EN.md index ff023f452e4d125e3519d13278168176d15f60e6..b400c789ec2e0705546aa2f1513fcac9665d38a4 100644 --- a/en/device-dev/Readme-EN.md +++ b/en/device-dev/Readme-EN.md @@ -32,8 +32,8 @@ - [Sensor](subsystems/subsys-sensor.md) - [USB](subsystems/subsys-usbservice.md) - [Application Framework](subsystems/subsys-application-framework.md) - - [OTA Upgrade](subsystems/subsys-ota-guide.md) - - [Telephony Service](subsystems/subsys-tel.md) + - [OTA Update](subsystems/subsys-ota-guide.md) + - [Telephony](subsystems/subsys-tel.md) - [Security](subsystems/subsys-security.md) - [Startup](subsystems/subsys-boot.md) - [DFX](subsystems/subsys-dfx.md) @@ -43,16 +43,15 @@ - [Mini- and Small-System Devices](guide/device-lite.md) - [Standard-System Devices](guide/device-standard.md) - Debugging - - [Test](subsystems/subsys-testguide-test.md) + - [Test Case Development](subsystems/subsys-testguide-test.md) - [R&D Tools](subsystems/subsys-toolchain.md) - XTS Certification - - [XTS](subsystems/subsys-xts-guide.md) + - [XTS Test Case Development](subsystems/subsys-xts-guide.md) - Tools - [Docker Environment](get-code/gettools-acquire.md) - [IDE](get-code/gettools-ide.md) - Hands-On Tutorials - - [Samples](https://gitee.com/openharmony/app_samples/blob/master/README.md) - [Codelabs](https://gitee.com/openharmony/codelabs) - References - [FAQs](faqs/Readme-EN.md) diff --git a/en/device-dev/porting/Readme-EN.md b/en/device-dev/porting/Readme-EN.md index 238773053ceba4a917225ceaa56b61272fe503d6..14788b0cf14223159d60e38a746255fc16bb1eb5 100644 --- a/en/device-dev/porting/Readme-EN.md +++ b/en/device-dev/porting/Readme-EN.md @@ -62,5 +62,4 @@ The download steps for other resources are the same as those in the mainline ver - [Mini System SoC Porting Cases](porting-minichip-cases.md) - [Mini-System Devices with Screens — Bestechnic SoC Porting Case](porting-bes2600w-on-minisystem-display-demo.md) - - [Combo Solution – ASR Chip Porting Case](porting-asr582x-combo-demo.md) diff --git a/en/device-dev/porting/porting-smallchip-driver-overview.md b/en/device-dev/porting/porting-smallchip-driver-overview.md index 117cd129bfdf88cd855693439c6542aef427212e..9147e903f6ced8a672af0a2613a761e6ab3ee42b 100644 --- a/en/device-dev/porting/porting-smallchip-driver-overview.md +++ b/en/device-dev/porting/porting-smallchip-driver-overview.md @@ -1,4 +1,4 @@ -# Overview +# Porting Overview Drivers can be classified as platform drivers or device drivers. The platform drivers are generally in the SoC, such as the GPIO, I2C, and SPI drivers. The device drivers are typically outside of the SoC, such as the LCD, TP, and WLAN drivers. diff --git a/en/device-dev/quick-start/Readme-EN.md b/en/device-dev/quick-start/Readme-EN.md index b49cc0253248c313bc339b1e86ee6e1a8b28dba7..c7450bd439d6e6480711948ec8d28034c451cc1d 100644 --- a/en/device-dev/quick-start/Readme-EN.md +++ b/en/device-dev/quick-start/Readme-EN.md @@ -32,7 +32,7 @@ - [Burning](quickstart-lite-steps-hi3861-burn.md) - [Networking](quickstart-lite-steps-hi3861-netconfig.md) - [Debugging and Verification](quickstart-lite-steps-hi3861-debug.md) - - [Running](quickstart-lite-steps-hi3816-running.md) + - [Running](quickstart-lite-steps-hi3861-running.md) - Hi3516 Development Board - [Setting Up the Hi3516 Development Board Environment](quickstart-lite-steps-hi3516-setting.md) - [Writing a Hello World Program](quickstart-lite-steps-hi3516-application-framework.md) diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3816-running.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md similarity index 100% rename from en/device-dev/quick-start/quickstart-lite-steps-hi3816-running.md rename to en/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md diff --git a/en/device-dev/quick-start/quickstart-lite-steps-hi3861.md b/en/device-dev/quick-start/quickstart-lite-steps-hi3861.md index d91f35a59f47a33ca413733901908cbd221964f6..0f637821f518c0edcced32f369eb09eb594990c7 100644 --- a/en/device-dev/quick-start/quickstart-lite-steps-hi3861.md +++ b/en/device-dev/quick-start/quickstart-lite-steps-hi3861.md @@ -14,4 +14,5 @@ - **[Debugging and Verification](quickstart-lite-steps-hi3861-debug.md)** -- **[Running](quickstart-lite-steps-hi3816-running.md)** +- **[Running](quickstart-lite-steps-hi3861-running.md)** + diff --git a/en/device-dev/subsystems/Readme-EN.md b/en/device-dev/subsystems/Readme-EN.md index dab9c6eb3f87693652caf1e043036fa36f947d52..02491a37a69ad53538be221e92bd519fe98fc17f 100644 --- a/en/device-dev/subsystems/Readme-EN.md +++ b/en/device-dev/subsystems/Readme-EN.md @@ -80,7 +80,7 @@ - [syspara Module](subsys-boot-syspara.md) - [FAQs](subsys-boot-faqs.md) - [Reference](subsys-boot-ref.md) -- [Test](subsys-testguide-test.md) +- [Test Case Development](subsys-testguide-test.md) - DFX - [DFX Overview](subsys-dfx-overview.md) - [HiLog Development](subsys-dfx-hilog-rich.md) @@ -95,8 +95,9 @@ - [HiSysEvent Tool Usage](subsys-dfx-hisysevent-tool.md) - [HiDumper Development](subsys-dfx-hidumper.md) - [HiChecker Development](subsys-dfx-hichecker.md) + - [FaultLogger Development](subsys-dfx-faultlogger.md) - R&D Tools - [bytrace](subsys-toolchain-bytrace-guide.md) - [hdc\_std](subsys-toolchain-hdc-guide.md) - [hiperf](subsys-toolchain-hiperf.md) -- [XTS](subsys-xts-guide.md) \ No newline at end of file +- [XTS Test Case Development](subsys-xts-guide.md) \ No newline at end of file diff --git a/en/device-dev/subsystems/figure/process_crash_handling.png b/en/device-dev/subsystems/figure/process_crash_handling.png new file mode 100644 index 0000000000000000000000000000000000000000..786a6a535d8ccafb9819fe21f7225c875c975144 Binary files /dev/null and b/en/device-dev/subsystems/figure/process_crash_handling.png differ diff --git a/en/device-dev/subsystems/subsys-dfx-faultlogger.md b/en/device-dev/subsystems/subsys-dfx-faultlogger.md new file mode 100644 index 0000000000000000000000000000000000000000..8693b997de9caa12e3d1b294f50ed7600896d737 --- /dev/null +++ b/en/device-dev/subsystems/subsys-dfx-faultlogger.md @@ -0,0 +1,268 @@ +# FaultLogger Development + + +## Overview + + +### Function + +FaultLogger is a maintenance and debugging log framework provided by OpenHarmony. It enables unified detection, log collection, log storage, and log reporting for application, ability, and system service process crashes. + +FaultLogger is responsible for fault recording of OpenHarmony. It runs on the following two components based on the service object: + +- HiView: serves functional modules at the application layer and native layer. It manages various fault information in the system and provides APIs for modules to query faults. + +- FaultLoggerd: serves the crash process. It collects information about abnormal daemon processes in C/C++ and obtains the process call stack. + +The following figure shows the process of handling a process crash based on the FaultLogger service. + + **Figure 1** Process crash handling flowchart + +![process_crash_handling](figure/process_crash_handling.png) + +1. After the signal processor is installed, the **DFX_SignalHandler** function detects and responds to the process crash exception signal. + +2. **SignalHandler** forks a child process after detecting the exception signal and runs **ProcessDump** to dump the stack information of the crashed process and thread. + +3. **ProcessDump** then writes a log to the temporary storage directory in FaultLoggerd, generating a full crash log. + +4. FaultLoggerd reports the fault through the **AddFaultLog()** API provided by HiView. HiView handles the fault, generates a simple crash log, and reports a HiSysEvent. + +With this design, a small-system with limited resources can obtain logs for locating crash faults as long as FaultLoggerd is deployed. + + +### Use Cases + +FaultLoggerd provides a lightweight approach for you to locate crash or suspension problems during development and testing. + +It is applicable to the following scenarios: + + **Table 1** Application scenarios of the Faultloggerd module + +| Scenario| Tool| Usage| +| -------- | -------- | -------- | +| To understand the function call sequence| DumpCatcher API | See [Using DumpCatcher to Obtain the Call Stack](#using-dumpcatcher-to-obtain-the-call-stack).| +| Application suspension or high CPU usage| ProcessDump | See [Using ProcessDump to Obtain the Call Stack](#using-processdump-to-obtain-the-call-stack).| +| Signal crash not handled by the process| Crash log and addr2line tool| See [Locating Faults Based on Crash Logs](#locating-faults-based-on-crash-logs).| + + +## Using DumpCatcher to Obtain the Call Stack + + +### Available APIs + +DumpCatcher can capture the call stack of a specified process (thread) on OpenHarmony. + + Table 2 DumpCatcher APIs + +| Class| API| Description| +| -------- | -------- | -------- | +| DfxDumpCatcher | bool DumpCatch(const int pid, const int tid, std::string& msg) | Return value:
**true**: Back trace is successful. Related information is stored in the **msg** string object.
**false**: Back trace failed.
Input arguments:
**pid**: target process ID.
**tid**: target thread ID. If all threads in the process need to be back traced, set **tid** to **0**.
Output argument:
**msg**: return message. If back trace is successful, the call stack information is returned through **msg**.| + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> If the PID that calls this API is different from the target PID, the caller must be the **system** or **root** user. To capture the call stack of a process that does not belong to the current user group, ensure that you have permissions to read **/proc/pid/maps** and implement **ptrace** on the peer process. + + +### Development Example + + +You can use DumpCatcher to obtain the call stack of a specified process (thread) in your applications. The following uses the **dumpcatcherdemo** module as an example to describe how to use the DumpCatcher API to obtain the call stack. + + +1. Add the DumpCatcher dependency to the build file. Take /base/hiviewdfx/faultloggerd/example/BUILD.gn as an example. Add the **dfx_dump_catcher.h** file path to **include_dirs** and add the required **//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:lib_dfx_dump_catcher** module to **deps**. + + ``` + import("//base/hiviewdfx/faultloggerd/faultloggerd.gni") + import("//build/ohos.gni") + + config("dumpcatcherdemo_config") { + visibility = [ ":*" ] + + include_dirs = [ + ".", + "//utils/native/base/include", + "//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher/include/", # Add the path of the dump_catcher header file. + ] + } + + ohos_executable("dumpcatcherdemo") { sources = [ "dump_catcher_demo.cpp" ] configs = [ ":dumpcatcherdemo_config" ] deps = [ "//base/hiviewdfx/faultloggerd/interfaces/innerkits/dump_catcher:lib_dfx_dump_catcher", # Add the DumpCatcher module dependency. "//utils/native/base:utils", ] external_deps = [ "hilog_native:libhilog" ] install_enable = true part_name = "faultloggerd" subsystem_name = "hiviewdfx" + } + ``` + +2. Define the header file. Take **/base/hiviewdfx/faultloggerd/example/dump_catcher_demo.h** as an example. In the sample code, the function of the stack depth test is called to construct a call stack with a specified depth. + + ``` + #ifndef DUMP_CATCHER_DEMO_H + #define DUMP_CATCHER_DEMO_H + + #include + + #define NOINLINE __attribute__((noinline)) + + // Define the macro function to automatically generate a function call chain. + #define GEN_TEST_FUNCTION(FuncNumA, FuncNumB) \ + __attribute__((noinline)) int TestFunc##FuncNumA() \ + { \ + return TestFunc##FuncNumB(); \ + } + + // Call the function of the stack depth test. + int TestFunc0(void); + int TestFunc1(void); + int TestFunc2(void); + int TestFunc3(void); + int TestFunc4(void); + int TestFunc5(void); + int TestFunc6(void); + int TestFunc7(void); + int TestFunc8(void); + int TestFunc9(void); + int TestFunc10(void); + + #endif // DUMP_CATCHER_DEMO_H + ``` + +3. Call the **DumpCatch** API in the source file. Take **/base/hiviewdfx/faultloggerd/example/dump_catcher_demo.cpp** as an example. Include the **dfx_dump_catcher.h** file, declare the **DfxDumpCatcher** object, use the macro function to construct a function call chain, call the **DumpCatch** method, and pass the required process ID and thread ID of the call stack into this method. + + ``` + #include "dump_catcher_demo.h" + + #include + #include + #include + // Include the dfx_dump_catcher.h file. + #include "dfx_dump_catcher.h" + using namespace std; + + NOINLINE int TestFunc10(void) + { + OHOS::HiviewDFX::DfxDumpCatcher dumplog; + string msg = ""; + bool ret = dumplog.DumpCatch(getpid(), gettid(), msg); // Call the DumpCatch API to obtain the call stack. + if (ret) { + cout << msg << endl; + } + return 0; + } + + // Use the macro function to automatically generate a function call chain. + GEN_TEST_FUNCTION(0, 1) + GEN_TEST_FUNCTION(1, 2) + GEN_TEST_FUNCTION(2, 3) + GEN_TEST_FUNCTION(3, 4) + GEN_TEST_FUNCTION(4, 5) + GEN_TEST_FUNCTION(5, 6) + GEN_TEST_FUNCTION(6, 7) + GEN_TEST_FUNCTION(7, 8) + GEN_TEST_FUNCTION(8, 9) + GEN_TEST_FUNCTION(9, 10) + + int main(int argc, char *argv[]) + { + TestFunc0(); + return 0; + } + ``` + + +## Using ProcessDump to Obtain the Call Stack + + +### Tool Description + +ProcessDump is a command line interface (CLI) based tool for capturing call stacks on OpenHarmony. It uses the **-p** and **-t** parameters to specify the process and thread. After the command is executed, the thread stack information of the specified process is displayed in the CLI window. + + **Table 3** Usage of the CLI-based ProcessDump + +| Tool| Path| Command| Description| +| -------- | -------- | -------- | -------- | +| processdump | /system/bin | - processdump -p [pid]
- processdump -p [pid] -t [tid] | **Arguments:**
**- -p [pid]**: prints stack information for all threads of the specified process.
**- -p [pid] -t [tid]**: prints information for the specified thread of the specified process.
**Return value:**
If the stack information is parsed successfully, the information is displayed in the standard output. If the stack information fails to be parsed, error information is displayed.| + + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
+> This tool must be used by the **root** user, or the caller must have the permission to ptrace the target process and read the smaps of the target process. + + +### Example + +Use ProcessDump to print the call stack of the **hiview** process. + + +``` +# ps -A | grep hiview + 114 ? 00:00:00 hiview +# processdump -p 114 -t 114 +Tid:114, Name:hiview +#00 pc 0000000000089824(00000000b6f44824) /system/lib/ld-musl-arm.so.1(ioctl+68) +#01 pc 000000000002a709(00000000b6c56709) /system/lib/libipc_core.z.so(_ZN4OHOS15BinderConnector11WriteBinderEmPv+16) +#02 pc 000000000002ba75(00000000b6c57a75) /system/lib/libipc_core.z.so(_ZN4OHOS13BinderInvoker18TransactWithDriverEb+224) +#03 pc 000000000002bb37(00000000b6c57b37) /system/lib/libipc_core.z.so(_ZN4OHOS13BinderInvoker13StartWorkLoopEv+22) +#04 pc 000000000002c211(00000000b6c58211) /system/lib/libipc_core.z.so(_ZN4OHOS13BinderInvoker10JoinThreadEb+36) +#05 pc 0000000000038d07(00000000004bcd07) /system/bin/hiview(_ZNSt3__h6vectorINS_9sub_matchINS_11__wrap_iterIPKcEEEENS_9allocatorIS6_EEE8__appendEj+596) +#06 pc 0000000000028655(00000000004ac655) /system/bin/hiview +#07 pc 00000000000c2b08(00000000b6f7db08) /system/lib/ld-musl-arm.so.1(__libc_start_main+116) +#08 pc 00000000000285f4(00000000004ac5f4) /system/bin/hiview +#09 pc 0000000000028580(00000000004ac580) /system/bin/hiview +``` + + +## Locating Faults Based on Crash Logs + +You can locate faults based on the crash stack logs generated by FaultLoggerd. This section describes how to use the addr2line tool to locate a crash fault. + +1. Find a program crash or construct a crash. + For example, insert the following code into your code to trigger an invalid memory access fault (SIGSEGV). + + + ``` + NOINLINE int TriggerSegmentFaultException() + { + printf("test TriggerSegmentFaultException \n"); + // Forcibly convert the type to construct a crash. + int *a = (int *)(&RaiseAbort); + *a = SIGSEGV; + return 0; + } + ``` + +2. Obtain the crash function call stack log. + The process generates a temporary log file in the** /data/log/faultlog/temp** directory due to an exception that is not handled. The naming rule of the temporary log file is as follows: + + + ``` + cppcrash-pid-time + ``` + + The generated call stack is as follows: + + + ``` + Pid:816 + Uid:0 + Process name:./crasher + Reason:Signal:SIGSEGV(SEGV_ACCERR)@0x0042d33d + Fault thread Info: + Tid:816, Name:crasher + r0:0042d33d r1:0000000b r2:1725d4c4 r3:b6f9fa84 + r4:bec97e69 r5:b6fc0268 r6:0042d661 r7:bec97d60 + r8:00000000 r9:00000000 r10:00000000 + fp:bec97d20 ip:00000020 sp:bec97cd0 lr:b6f9fae4 pc:0042d32c + + #00 pc 000000000000332c(000000000042d32c) /data/crasher(TriggerSegmentFaultException+15) + #01 pc 00000000000035c7(000000000042d5c7) /data/crasher(ParseAndDoCrash+277) + #02 pc 0000000000003689(000000000042d689) /data/crasher(main+39) + #03 pc 00000000000c3b08(00000000b6fbbb08) /system/lib/ld-musl-arm.so.1(__libc_start_main+116) + #04 pc 00000000000032f8(000000000042d2f8) /data/crasher(_start_c+112) + #05 pc 0000000000003284(000000000042d284) /data/crasher(_start+32) + ``` + +3. Use the addr2line tool to analyze the call stack. + Then, parse the line number based on the offset address. + + + ``` + root:~/OpenHarmony/out/hi3516dv300/exe.unstripped/hiviewdfx/faultloggerd$ addr2line -e crasher 000332c + base/hiviewdfx/faultloggerd/tools/crasher/dfx_crasher.c:57 + ``` + + The crash is caused by assigning a value to an unwritable area. It is in code line 57 in the **dfx_crasher.c** file. You can modify it to avoid the crash. diff --git a/en/device-dev/subsystems/subsys-testguide-test.md b/en/device-dev/subsystems/subsys-testguide-test.md index e4d444038311193b50204599a1ce41088e332f01..b3def7ee3f6035aacff7843e400f08e778ec6737 100644 --- a/en/device-dev/subsystems/subsys-testguide-test.md +++ b/en/device-dev/subsystems/subsys-testguide-test.md @@ -1,4 +1,4 @@ -# Test +# Test Case Development OpenHarmony provides a comprehensive auto-test framework for designing test cases. Detecting defects in the development process can improve code quality. This document describes how to use the OpenHarmony test framework. diff --git a/en/device-dev/subsystems/subsys-xts-guide.md b/en/device-dev/subsystems/subsys-xts-guide.md index 8edb14f97ee25a560587fbe9b875e5b9aaf5d50e..4fe43850bc82b8919612f856c222c7a66050c99a 100644 --- a/en/device-dev/subsystems/subsys-xts-guide.md +++ b/en/device-dev/subsystems/subsys-xts-guide.md @@ -1,4 +1,4 @@ -# XTS +# XTS Test Case Development ## Introduction @@ -332,7 +332,7 @@ The HCTest framework is used to support test cases developed with the C language Test suites are built along with version build. The ACTS is built together with the debug version. - >![](../public_sys-resources/icon-note.gif) **NOTE:** + >![](../public_sys-resources/icon-note.gif) **NOTE** >The ACTS build middleware is a static library, which will be linked to the image. @@ -506,6 +506,7 @@ The test cases are developed with the JavaScript language and must meet the prog **Table 5** +

Syntax

Description

diff --git a/en/device-dev/subsystems/subsys.md b/en/device-dev/subsystems/subsys.md index b70f2033ffdf00ea57edb3a44c92733557f01f73..27949f654c00c71b0cc49946d21e39deea7b66b7 100644 --- a/en/device-dev/subsystems/subsys.md +++ b/en/device-dev/subsystems/subsys.md @@ -13,9 +13,9 @@ - **[Telephony](subsys-tel.md)** - **[Security](subsys-security.md)** - **[Startup](subsys-boot.md)** -- **[Test](subsys-testguide-test.md)** +- **[Test Case Development](subsys-testguide-test.md)** - **[DFX](subsys-dfx.md)** - **[R&D Tools](subsys-toolchain.md)** -- **[XTS](subsys-xts-guide.md)** +- **[XTS Test Case Development](subsys-xts-guide.md)** diff --git a/en/device-dev/website.md b/en/device-dev/website.md index f227baec8b1070ac993797e6ec55560c7758a1f7..a7191eb01da868e164af9669c37613c1c77c3f6f 100644 --- a/en/device-dev/website.md +++ b/en/device-dev/website.md @@ -35,7 +35,7 @@ - [Burning](quick-start/quickstart-lite-steps-hi3861-burn.md) - [Networking](quick-start/quickstart-lite-steps-hi3861-netconfig.md) - [Debugging and Verification](quick-start/quickstart-lite-steps-hi3861-debug.md) - - [Running](quick-start/quickstart-lite-steps-hi3816-running.md) + - [Running](quick-start/quickstart-lite-steps-hi3861-running.md) - Hi3516 Development Board - [Setting Up the Hi3516 Development Board Environment](quick-start/quickstart-lite-steps-hi3516-setting.md) - [Writing a Hello World Program](quick-start/quickstart-lite-steps-hi3516-application-framework.md) @@ -131,7 +131,7 @@ - [LiteOS Cortex-A](porting/porting-smallchip-kernel-a.md) - [Linux Kernel](porting/porting-smallchip-kernel-linux.md) - Driver Porting - - [Overview](porting/porting-smallchip-driver-overview.md) + - [Porting Overview](porting/porting-smallchip-driver-overview.md) - [Platform Driver Porting](porting/porting-smallchip-driver-plat.md) - [Device Driver Porting](porting/porting-smallchip-driver-oom.md) @@ -357,22 +357,22 @@ - [UART](driver/driver-platform-uart-develop.md) - [WatchDog](driver/driver-platform-watchdog-develop.md) - Platform Driver Usage - - [ADC](driver-platform-adc-des.md) - - [DAC](driver-platform-dac-des.md) - - [GPIO](driver-platform-gpio-des.md) - - [HDMI](driver-platform-hdmi-des.md) - - [I2C](driver-platform-i2c-des.md) - - [I3C](driver-platform-i3c-des.md) - - [MIPI CSI](driver-platform-mipicsi-des.md) - - [MIPI DSI](driver-platform-mipidsi-des.md) - - [PIN](driver-platform-pin-des.md) - - [PWM](driver-platform-pwm-des.md) - - [Regulator](driver-platform-regulator-des.md) - - [RTC](driver-platform-rtc-des.md) - - [SDIO](driver-platform-sdio-des.md) - - [SPI](driver-platform-spi-des.md) - - [UART](driver-platform-uart-des.md) - - [WatchDog](driver-platform-watchdog-des.md) + - [ADC](driver/driver-platform-adc-des.md) + - [DAC](driver/driver-platform-dac-des.md) + - [GPIO](driver/driver-platform-gpio-des.md) + - [HDMI](driver/driver-platform-hdmi-des.md) + - [I2C](driver/driver-platform-i2c-des.md) + - [I3C](driver/driver-platform-i3c-des.md) + - [MIPI CSI](driver/driver-platform-mipicsi-des.md) + - [MIPI DSI](driver/driver-platform-mipidsi-des.md) + - [PIN](driver/driver-platform-pin-des.md) + - [PWM](driver/driver-platform-pwm-des.md) + - [Regulator](driver/driver-platform-regulator-des.md) + - [RTC](driver/driver-platform-rtc-des.md) + - [SDIO](driver/driver-platform-sdio-des.md) + - [SPI](driver/driver-platform-spi-des.md) + - [UART](driver/driver-platform-uart-des.md) + - [WatchDog](driver/driver-platform-watchdog-des.md) - Peripheral Driver Usage - [LCD](driver/driver-peripherals-lcd-des.md) - [Touchscreen](driver/driver-peripherals-touch-des.md) @@ -477,6 +477,7 @@ - [HiSysEvent Tool Usage](subsystems/subsys-dfx-hisysevent-tool.md) - [HiDumper Development](subsystems/subsys-dfx-hidumper.md) - [HiChecker Development](subsystems/subsys-dfx-hichecker.md) + - [FaultLogger Development](subsystems/subsys-dfx-faultlogger.md) - Featured Topics - HPM Part - [HPM Part Overview](hpm-part/hpm-part-about.md) @@ -517,7 +518,7 @@ - [Development Example for Peripheral Drivers](guide/device-outerdriver-demo.md) - Debugging - - [Test](subsystems/subsys-testguide-test.md) + - [Test Case Development](subsystems/subsys-testguide-test.md) - Debugging Tools - [bytrace](subsystems/subsys-toolchain-bytrace-guide.md) - [hdc\_std](subsystems/subsys-toolchain-hdc-guide.md) diff --git a/en/website.md b/en/website.md index aba19ae3c2a4eb227ee06b7704e7ed829044b775..9cf5b09520641a3fe3d6b0ce7003d4d3c9b3cf64 100644 --- a/en/website.md +++ b/en/website.md @@ -7,12 +7,11 @@ - [OpenHarmony v3.1 Release (2022-03-30)](release-notes/OpenHarmony-v3.1-release.md) - [OpenHarmony v3.1 Beta (2021-12-31)](release-notes/OpenHarmony-v3.1-beta.md) - [OpenHarmony v3.0.1 LTS (2022-01-12)](release-notes/OpenHarmony-v3.0.1-LTS.md) -- [OpenHarmony v3.0 LTS (2021-09-30)](release-notes/OpenHarmony-v3.0-LTS.md) - + - [OpenHarmony v3.0 LTS (2021-09-30)](release-notes/OpenHarmony-v3.0-LTS.md) + - OpenHarmony 2.x Releases - [OpenHarmony v2.2 beta2 (2021-08-04)](release-notes/OpenHarmony-v2.2-beta2.md) - - [OpenHarmony 2.0 Canary (2021-06-01)](release-notes/OpenHarmony-2-0-Canary.md) - + - [OpenHarmony 2.0 Canary (2021-06-01)](release-notes/OpenHarmony-2-0-Canary.md) - OpenHarmony 1.x Releases - [OpenHarmony v1.1.4 LTS (2022-02-11)](release-notes/OpenHarmony-v1-1-4-LTS.md) - [OpenHarmony v1.1.3 LTS (2021-09-30)](release-notes/OpenHarmony-v1-1-3-LTS.md) diff --git a/zh-cn/device-dev/quick-start/Readme-CN.md b/zh-cn/device-dev/quick-start/Readme-CN.md index 3ba43059da59b693aa0dfb06a2fdf18feb4bcfa5..201084420a5ab4831ffed05caeeedeb6e068645d 100644 --- a/zh-cn/device-dev/quick-start/Readme-CN.md +++ b/zh-cn/device-dev/quick-start/Readme-CN.md @@ -12,7 +12,7 @@ - [烧录](quickstart-ide-lite-steps-hi3861-burn.md) - [联网](quickstart-ide-lite-steps-hi3861-netconfig.md) - [调试验证](quickstart-ide-lite-steps-hi3861-debug.md) - - [运行](quickstart-ide-lite-steps-hi3816-running.md) + - [运行](quickstart-ide-lite-steps-hi3861-running.md) - Hi3516开发板 - [编写“Hello World”程序](quickstart-ide-lite-steps-hi3516-application-framework.md) - [编译](quickstart-ide-lite-steps-hi3516-building.md) @@ -32,7 +32,7 @@ - [烧录](quickstart-lite-steps-hi3861-burn.md) - [联网](quickstart-lite-steps-hi3861-netconfig.md) - [调试验证](quickstart-lite-steps-hi3861-debug.md) - - [运行](quickstart-lite-steps-hi3816-running.md) + - [运行](quickstart-lite-steps-hi3861-running.md) - Hi3516开发板 - [安装Hi3516开发板环境](quickstart-lite-steps-hi3516-setting.md) - [编写“Hello World”程序](quickstart-lite-steps-hi3516-application-framework.md) diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3816-running.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md similarity index 100% rename from zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3816-running.md rename to zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861-running.md diff --git a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861.md b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861.md index 4266d6e5ea673b59b90ac19c571c1c6be397ab4d..c5cbefed3f3b42ed3ec22874493bd4e643dbe027 100644 --- a/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861.md +++ b/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3861.md @@ -14,4 +14,4 @@ - **[调试验证](quickstart-lite-steps-hi3861-debug.md)** -- **[运行](quickstart-lite-steps-hi3816-running.md)** \ No newline at end of file +- **[运行](quickstart-lite-steps-hi3861-running.md)** \ No newline at end of file diff --git a/zh-cn/device-dev/website.md b/zh-cn/device-dev/website.md index 891bdd451ad3734f8c9658d61073b8ce56c0a0e5..38e960f2ad8bfeb0e6d5fe15e4cbd51df0d8d290 100644 --- a/zh-cn/device-dev/website.md +++ b/zh-cn/device-dev/website.md @@ -15,7 +15,7 @@ - [烧录](quick-start/quickstart-ide-lite-steps-hi3861-burn.md) - [联网](quick-start/quickstart-ide-lite-steps-hi3861-netconfig.md) - [调试验证](quick-start/quickstart-ide-lite-steps-hi3861-debug.md) - - [运行](quick-start/quickstart-ide-lite-steps-hi3816-running.md) + - [运行](quick-start/quickstart-ide-lite-steps-hi3861-running.md) - Hi3516开发板 - [编写“Hello World”程序](quick-start/quickstart-ide-lite-steps-hi3516-application-framework.md) - [编译](quick-start/quickstart-ide-lite-steps-hi3516-building.md) @@ -35,7 +35,7 @@ - [烧录](quick-start/quickstart-lite-steps-hi3861-burn.md) - [联网](quick-start/quickstart-lite-steps-hi3861-netconfig.md) - [调试验证](quick-start/quickstart-lite-steps-hi3861-debug.md) - - [运行](quick-start/quickstart-lite-steps-hi3816-running.md) + - [运行](quick-start/quickstart-lite-steps-hi3861-running.md) - Hi3516开发板 - [安装Hi3516开发板环境](quick-start/quickstart-lite-steps-hi3516-setting.md) - [编写“Hello World”程序](quick-start/quickstart-lite-steps-hi3516-application-framework.md)