When debugging my application, if I break in GDB and try to print errno, even from inside a function that checks errno, I get the following error from GDB:

(gdb) print errno
Cannot find shared library `/usr/lib/debug/lib/libc-2.11.1.so' in dynamic linker's load module list

Things I've tried:

  1. Check if the file exists, it does and is about 7.3MB.
  2. Adding /usr/lib/debug/lib/ to the front of my LD_LIBRARY_PATH. No effect.
  3. Setting LD_PRELOAD=/usr/lib/debug/lib/libc-2.11.1.so causes my app to segfault on startup.
  4. If I run ldd on the binary it says it's using '/lib/libc.so.6', and aptitude (I'm running Ubuntu) tells me libc6-dbg is installed.
  5. Checked that I don't have a custom lib path set in .gdbinit, I don't.

The application seems to otherwise run fine, so I can't imagine libc itself is screwed up. Any ideas?

有帮助吗?

解决方案

The file /usr/lib/debug/lib/libc-2.11.1.so does not contain a debug version of glibc. It contains only debug parts of libc, but no actual executable code. Putting it into LD_PRELOAD or LD_LIBRARY_PATH is the wrong thing to do. Do not do that.

You can read about separate debug files here.

(gdb) print errno
Cannot find shared library `/usr/lib/debug/lib/libc-2.11.1.so' in dynamic linker's load module list

This is a buglet in GDB.

You should know that GDB will look for a variable errno, but your application does not use any such variable. Rather, errno is a #defined macro, that expands to *(__errno_location()), and GDB doesn't know about this.

Try this instead:

(gdb) p __errno_location()
$1 = (int *) 0x7ffff78396a8

(gdb) x/x $1
0x7ffff78396a8: 0x00000000
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top