Remote debugging: setting breakpoints in shared libraries

Klaus Zeitler
Tue Jan 31 16:17:00 GMT 2012

I'm trying to figure out how to debug shared libraries remotely with
gdbserver. My first try was on the same host:

[]$ gdbserver localhost:7777 test
and then in gdb:
(gdb) target remote localhost:7777
(gdb) b function_in_shared_lib
Function "function_in_shared_lib" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
(gdb) c
this works beautifully, i.e. the test program stops at the breakpoint.

Now when I try running the same sequence with gdbserver on a remote host
(and localhost replaced accordingly), gdb doesn't stop at the
breakpoint. My test program doesn't stop.

I found some cumbersome workaround. Put a breakpoint in test program
right after the shared library (dlopen) is loaded, then I manually do:
(gdb) add-symbol-file <address>

Am I missing something or is this behavior to be expected?

I'm using:
GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-37.el5_7.1)



|  Klaus Zeitler              Alcatel-Lucent                        |
|  Lorenzstrasse 10           70435 Stuttgart, Germany              |
|  Department:                Building: 005  Office: 3/171          |
|  Telefon:                   +49 711821 43898                      |
|  Email:                 |
|                                                                   |
| Alcatel-Lucent Deutschland AG                                     |
| Sitz der Gesellschaft: Stuttgart · Amtsgericht Stuttgart HRB 4026 |
| Vorsitzender des Aufsichtsrates: Michael Oppenhoff                |
| Vorstand:                                                         |
|   Alf Henryk Wulf (Vorsitzender) · Dr. Rainer Fechner             |
Those who can, do.  Those who can't, simulate.

More information about the Gdb mailing list