Question

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 : Input/output error.

where X is the breakpoint number in gdb and 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.

Was it helpful?

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.

OTHER TIPS

I see this question is from 2009, but the current answers are out-of-date, so here's an update:

@Employed Russian suggested that you must use stop-on-solib-event. This is no longer true; NDK r8d supports pending breakpoints in yet-to-be-loaded solibs.

@Brent Piddy says that stop-on-solib-event doesn't work with gdbserver. This is also no longer true since at least r8c. My company has a product that relies on this NDK behavior from GDB, we would be in big trouble without it.

Use the following command to set pending breakpoints that will get resolved after the shared object library is loaded

set breakpoint pending on

Sadly you can not use "set stop-on-solib-event on" for gdbserver remote debugging since gdbserver does not recognize/send solib events. I have had to just issue a set solib-search-path or set sysroot command to get gdb to load all of the shared library symbols after hitting a breakpoint on main.

Run up to main and then set solib-search-path .

Otherwise, gdbserver stops at the dynamic loader, before the libraries are loaded. At main, they should be ready for GDB.

More details: Debugging shared libraries with gdbserver

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top