Skip to content

Android GDB remote debugging

This article introduces the remote debugging through GDB on Android system.

Copy gdbserver to the device

Prebulit gdbserver can be found in the NDK toolchain folder. In my case, In my case it was located in “~/opt/android-ndk-r21e/prebuilt/android-arm64/gdbserver/gdbserver”.

adb push ~/opt/android-ndk-r21e/prebuilt/android-arm64/gdbserver/gdbserver /system/bin

Start gdbserver

adb shell gdbserver :5039 your_program_path

Forward TCP port

Forward the TCP traffic on port 5039 of the device to port 5039 on the PC, so that the GDB client can communicate with the GDB server.

adb forward tcp:5039 tcp:5039

Start debugging

Start GDB client on PC.

gdb

GDB client connects to GDB server.

target remote 127.0.0.1:5039

Then, use GDB as you normally would.

r
Leave a Reply