Issue
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.
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.
Solution
Probably you can try below: (This example steps are based on macOS)
run gdb server and attach process
//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.
attach gdb debugger
//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
Answered By - shizhen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.