Remote debugging of pure C program with GDB

I am trying to remotely debug a clean C program on an Android device. The Android device (target) is connected via USB to the host machine.

What I did: The following files were copied from target : /system/lib , /vendor/lib , /system/bin/app_process and /system/bin/linker .

Goal:

  • Copied gdbserver from the NDK to the target device.
  • Submitted by exe I want to debug
  • running gdb server in target mode using ./gdbserver :5039 exec
    • it basically executes this process and gets a pid

Leading:

  • enabled adb forward tcp:5039 tcp:5039
  • runned: arm-eabi-gcc exec .
  • Then in gdb:
    • set solib-search-path ... , with libraries that I pulled earlier from target
    • target remote :5039

arm-eabi-gcc can connect to a remote process and even continue ( C ) execution. However, I cannot set breakpoints. If so, then I get the following error: Cannot access memory at address xxx .

Did I miss something?

Thanks.

+5
source share
1 answer

So, in the host , in the gdb shell, before specifying the remote target port, I have to enter shared . This command loads common characters.

In addition, I used -ggdb to compile.

0
source

All Articles