Sco*_*ttF 6 debugging android adb android-ndk lldb
如何使用lldb命令行调试器在 C++ 中调试我的 Android NDK 项目?
Hax*_*raZ 11
/data/local/tmp目录)。PATH环境变量中。-g标志)编译完成后,将它们复制到您设备的/data/local/tmp目录中。
lldb-server到设备将提供的 NDK 复制lldb-server到您的 Android 手机(最好是 64 位手机),
adb push ./toolchains/llvm/prebuilt/windows-x86_64/lib64/clang/9.0.9/lib/linux/aarch64/lldb-server /data/local/tmp
Run Code Online (Sandbox Code Playgroud)
并通过以下方式启动:
./lldb-server platform --listen "*:10086" --server
Run Code Online (Sandbox Code Playgroud)
10086是端口号,你可以更改它。
通过运行转发端口:
./lldb-server platform --listen "*:10086" --server
Run Code Online (Sandbox Code Playgroud)
adb forward tcp:10086 tcp:10086
Run Code Online (Sandbox Code Playgroud)
安装 LLDB,将其二进制文件添加到PATH,输入以下命令:
adb devices #For me, it's 39688bd9
Run Code Online (Sandbox Code Playgroud)
其中,39688bd9是我的设备ID,10086是我在前面步骤中选择的端口。
现在,您已连接到 lldb-server,因此只需像在本地一样使用 lldb 即可:
platform select remote-android
platform connect connect://39688bd9:10086
Run Code Online (Sandbox Code Playgroud)
也许你可以尝试以下:(此示例步骤基于macOS)
//Below commands will suspend the execution on the running app, and waits for a debugger to connect to it on port 5045.
adb shell
// to get pid
root@generic_x86:/ # ps | grep <your-app-name>
u0_a54 6510 1196 800157 47442 ffffffff b662df1b S
<your-app-name>
root@generic_x86:/ # gdbserver :5045 --attach 6510 (PID)
Attached; pid = 6510
Listening on port 5045
//The process is now suspended, and gdbserver is listening for debugging clients on port 5045.
Run Code Online (Sandbox Code Playgroud)
//open a new terminal, e.g. terminal2, send below commands from this new terminal
//forward the above port to a local port on the host with the abd forward command
adb forward tcp:5045 tcp:5045
//launch gdb client from your android ndk folder
<your-ndk-home>/android-ndk-r16b/prebuilt/darwin-x86_64/bin/gdb
//Target the gdb to the remote sever
(gdb) target remote :5045
//now the process is successfully attached with the application for debugging, you can see below info from terminal 1.
Remote debugging from host 127.0.0.1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8973 次 |
| 最近记录: |