Search code examples
linuxgdbshared-librariesarmremote-debugging

Debugging shared libraries remotely with gdb/gdbserver


My question is about remote debugging an application on an embedded arm processor using gdb/gdbserver.

I can debug the application itself, but the application dynamically links to a shared library which implements an in house communications protocol. I want to be able to set breakpoints within the shared library functions so try to figure out some device discovery problems.

I have made sure that the library is compiled with debug symbols and is loaded by gdb on the host side, I can list functions within the library and even set the breakpoints but as soon as I try to run the application I get an error message to the effect of:

Cannot insert breakpoint X. Error accessing memory address [Hex address]: Input/output error.

where X is the breakpoint number in gdb and [Hex address] is an address far to small to be valid.
I am using the new library on both the target and the host machine, but via mount -o bind newlib oldlib on the target from an nfs mount.
Does anyone have an idea about what could be wrong? Thanks in advance.


Solution

  • Wild guess: you loaded the shared library into host GDB at incorrect address.

    Instead of explicitly loading it into GDB, use "set stop-on-solib-event on", wait for the library to get loaded (info shared will tell you current list of loaded libraries), and then set the breakpoints.