如何在命令行上使用lldb在Android上调试C ++代码 [英] How do I use lldb to debug C++ code on Android on command line

查看:820
本文介绍了如何在命令行上使用lldb在Android上调试C ++代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出使用lldb调试器在c ++中调试我的Android ndk项目的方法.

I am trying to figure out to debug my Android ndk project in c++, using the lldb debugger.

我正在尝试仅通过命令行来实现这一目标.

I am trying achieve this by using the command line only.

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

I can not seem to find any articles or documentation on how to use lldb along with adb to debug an app from the command line.

推荐答案

可能您可以尝试以下操作:(此示例步骤基于 macOS )

Probably you can try below: (This example steps are based on 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.

附加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

这篇关于如何在命令行上使用lldb在Android上调试C ++代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆