Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 : 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.

like image 471
asm Avatar asked Nov 06 '09 19:11

asm


1 Answers

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.

like image 200
Ryan V. Bissell Avatar answered Sep 18 '22 00:09

Ryan V. Bissell