5

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

What I did was: Copied from the target the following files: /system/lib, /vendor/lib, /system/bin/app_process, and /system/bin/linker.

Target:

  • Copied gdbserver from NDK to the target device
  • Sent the exe that I want to debug
  • runned gdb server on target using ./gdbserver :5039 exec
    • this basically executes the process, and gets a pid

Host:

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

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

Am I missing something here?

Thank you.

jww
  • 97,681
  • 90
  • 411
  • 885
Paschalis
  • 11,929
  • 9
  • 52
  • 82
  • 1
    Related: [Debug native Android application](http://stackoverflow.com/q/18143331), [How to Debug native code using ndk-gdb](http://stackoverflow.com/q/17593284), [Gdbserver strange error while debugging native app](http://stackoverflow.com/q/26317509), [Debugging Android NDK native apps](http://stackoverflow.com/q/8934575), [Debug native code in Android Library](http://stackoverflow.com/q/12638849), etc. – jww May 26 '15 at 06:13

1 Answers1

0

So, at host, in gdb shell, before specifying the remote's target port, I should type shared. This command loads the shared symbols.

Also, for compiling, I used -ggdb.

Paschalis
  • 11,929
  • 9
  • 52
  • 82
  • I don't believe `-ggdb` has an effect. That's what the GDB folks told me a few years ago on their mailing list. That may have changed. – jww May 26 '15 at 06:19
  • emm, so gdb can load the symbols of the debugging program! – Paschalis May 26 '15 at 09:24