How to use debug version of libc
I think that the version of libc with debug symbols is in /usr/lib/debug/lib. I tried setting my LD_LIBRARY_PATH variable to have this at the front of the path but that did not seem to make a difference.
These are not the droids you are looking for.
The libraries in /usr/lib/debug
are not real libraries. Rather, they contain only debug info, but do not contain .text
nor .data
sections of the real libc.so.6
. You can read about the separate debuginfo files here.
The files in /usr/lib/debug
come from libc6-dbg
package, and GDB will load them automatically, so long as they match your installed libc6
version. If your libc6
and libc6-dbg
do not match, you should get a warning from GDB.
You can observe the files GDB is attempting to read by setting set verbose on
. Here is what you should see when libc6
and libc6-dbg
do match:
(gdb) set verbose on
(gdb) run
thread_db_load_search returning 0
Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug/lib/ld-2.11.1.so...done.
thread_db_load_search returning 0
done.
thread_db_load_search returning 0
Loaded symbols for /lib64/ld-linux-x86-64.so.2
Reading symbols from system-supplied DSO at 0x7ffff7ffb000...done.
WARNING: no debugging symbols found in system-supplied DSO at 0x7ffff7ffb000.
thread_db_load_search returning 0
Reading in symbols for dl-debug.c...done.
Reading in symbols for rtld.c...done.
Reading symbols from /lib/librt.so.1...Reading symbols from /usr/lib/debug/lib/librt-2.11.1.so...done.
thread_db_load_search returning 0
... etc ...
Update:
For instance I see
Reading symbols from /lib/libc.so.6...(no debugging symbols found)...done
That implies that your GDB is not searching /usr/lib/debug
. One way that could happen is if you set debug-file-directory
in your .gdbinit
incorrectly.
Here is the default setting:
(gdb) show debug-file-directory
The directory where separate debug symbols are searched for is "/usr/lib/debug".
Make sure you've installed the debug symbols for libc:
sudo apt-get install libc6-dbg
And if you're on an x64 system debugging x86 code:
sudo apt-get install libc6:i386
sudo apt-get install libc6-dbg:i386