diff --git a/en/application-dev/tools/Readme-EN.md b/en/application-dev/tools/Readme-EN.md index 7be1e5159712ec14a7b6f433883a0ccbcda64938..586a7db31018d12b33acc54ac340d5dc3356afce 100644 --- a/en/application-dev/tools/Readme-EN.md +++ b/en/application-dev/tools/Readme-EN.md @@ -8,3 +8,4 @@ - [Common Event Manager](cem-tool.md) - [Advanced Notification Manager](anm-tool.md) - [restool](restool.md) +- [LLDB Usage Guide](lldb-tool.md) diff --git a/en/application-dev/tools/lldb-tool.md b/en/application-dev/tools/lldb-tool.md new file mode 100644 index 0000000000000000000000000000000000000000..d8cb8a1c52a7f71d66642a62793526f14bb26827 --- /dev/null +++ b/en/application-dev/tools/lldb-tool.md @@ -0,0 +1,109 @@ +# LLDB Usage Guide +## Overview +Low Lever Debugger (LLDB) is a next-generation high-performance debugger. + +LLDB is developed based on the [llvm15.0.4](https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.4) and supports debugging on the home screen and OpenHarmony devices or simulators. +## How to Obtain +Obtain the OpenHarmony SDK from http://ci.openharmony.cn/dailys/dailybuilds. + +LLDB is in the following path of the SDK: +``` +\ohos-sdk\[system]\native\llvm +``` +The value of **system** can be **windows**, **linux**, or **darwin**. + +For example, for Windows, **lldb.exe** is stored in the following path after the SDK is decompressed: +``` +\ohos-sdk\windows\native\llvm\bin +``` + +## Supported Platform and Architecture + +### Local Debugging +#### Example: Local Debugging on the Linux Platform +1. Obtain the name of the executable file with debugging information generated by the clang compiler of the same version as LLDB. + +2. Run the following command in the terminal window to specify the name of the file to debug: + + ``` + ./lldb filename + ``` + +3. Set a breakpoint at the **main** function in the code and run the following command on the LLDB interface: + + ``` + (lldb) b main + ``` + +4. Run the following command on the LLDB interface. The program will stop at the breakpoint: + + ``` + (lldb) run + ``` + +5. Perform subsequent debugging operations. + +### Remote Debugging + +> **Note: During remote debugging, the LLDB server and LLDB must be used together.** +- Debugging the OHOS device on the Windows platform (Arm architecture) +- Debugging the OHOS device on the Windows platform (AArch64 architecture) +- Debugging the simulator on the Windows platform +- Debugging the OHOS device on the macOS (M1) platform (Arm architecture) +- Debugging the OHOS device on the macOS (M1) platform (AArch64 architecture) +- Debugging the simulator on the macOS (M1) platform +- Debugging the OHOS device on the macOS (x86) platform (Arm architecture) +- Debugging the OHOS device on the macOS (x86) platform (AArch64 architecture) +- Debugging the simulator on the macOS (x86) platform +- Debugging the OHOS device on the Linux platform (Arm architecture) +- Debugging the OHOS device on the Linux platform (AArch64 architecture) + +#### Example: Remote Debugging the OHOS Device on the Linux Platform (Arm Architecture) + +1. Run the executable file with debugging information on the device. + + ``` + ./filename + ``` + +2. Push the LLDB server to the device and run the LLDB server. + + Command line window 1: + + ``` + hdc file send lldb-server /data/local/tmp + hdc shell ./data/local/tmp/lldb-server p --server --listen "*:8080" + ``` + + > **Note: /data/local/tmp is a directory on the device, and 8080 is a listening port. Both of them can be customized.** + +3. Start LLDB in another window, select the remote OHOS device, and connect to it. + + Command line window 2: + + ``` + ./lldb + (lldb) platform select remote-ohos + (lldb) platform connect connect://localhost:8080 + ``` + +4. Set breakpoints and perform debugging operations. + + Command line window 2: + + ``` + (lldb) breakpoint set --file --line + (lldb) process attach --name process-name + ``` + +## Functions Provided by LLDB +- Loading a program to LLDB +- Setting a breakpoint +- Setting an observation point +- Starting or attaching to a program +- Executing a control program +- Checking the thread status +- Checking the stack frame status + +## References +For details about other functions and commands, see [LLDB Usage Guide](https://gitee.com/openharmony/third_party_llvm-project/blob/master/lldb/README_zh.md)