gpt4 book ai didi

android - 如何在命令行上使用 lldb 调试 Android 上的 C++ 代码

转载 作者:行者123 更新时间:2023-12-03 22:12:02 27 4
gpt4 key购买 nike

我正在尝试使用 lldb 调试器在 C++ 中调试我的 Android ndk 项目。

我试图通过仅使用命令行来实现这一点。

我似乎找不到任何关于如何使用 lldb 和 adb 从命令行调试应用程序的文章或文档。

最佳答案

也许您可以尝试以下方法:(此示例步骤基于 macOS )

运行 gdb 服务器并附加进程

//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.

附加 gdb 调试器
//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

关于android - 如何在命令行上使用 lldb 调试 Android 上的 C++ 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53733781/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com