This is an archive of the discontinued LLVM Phabricator instance.

Reorder debug symbol search path on linux
AbandonedPublic

Authored by labath on Feb 12 2015, 9:01 AM.

Details

Reviewers
vharron
Summary

lldb was failing to locate the split debug symbols for libc. The previous search order was:

  • the directory containing the original library
  • the current directory
  • /usr/lib/debug

This was failing to locate the debug symbols for libc (at least on my machine), because the
.gnu_debuglink for libc (libc.so.6) was "libc-2.19.so". However, libc.so.6 itself is a symlink to
libc-2.19.so, located in the same directory. This meant that under the default search path lldb
would locate the same file, which obviously provides no new information. Moving the module
directory to the last place in the search path allows lldb to correctly locate the debug version
of libc under /usr/lib/debug and indeed makes additional information visible in lldb output.

If the user has a newer version of debug symbols in the library directory than those in
/usr/lib/debug (perhaps because he is working on the library), then those should get picked up
anyway, because the newer library should have a different UUID.

Diff Detail

Event Timeline

labath updated this revision to Diff 19838.Feb 12 2015, 9:01 AM
labath retitled this revision from to Reorder debug symbol search path on linux.
labath updated this object.
labath edited the test plan for this revision. (Show Details)
labath added a reviewer: vharron.
labath added a subscriber: Unknown Object (MLST).
emaste added a subscriber: emaste.EditedFeb 12 2015, 11:08 AM

because the .gnu_debuglink for libc (libc.so.6) was "libc-2.19.so".

That seems rather odd, the debuglink is typically to <filename>.debug. What distro uses the same name without an extension?

If the user has a newer version of debug symbols in the library directory than those in /usr/lib/debug (perhaps because he is working on the library), then those should get picked up anyway, because the newer library should have a different UUID.

Note that on FreeBSD we use .gnu_debuglink but do not (yet) have build-ID in binaries/libraries.

Also this change doesn't match GDB's ordering, which is:

  • /usr/lib/debug/.build-id/ab/cdef1234.debug
  • /usr/bin/ls.debug
  • /usr/bin/.debug/ls.debug
  • /usr/lib/debug/usr/bin/ls.debug.

(from https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html)

Moving up the files.push_back (dirname + "/.build-id/" + uuid_str); at line 81 may be what you want instead.

test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
47–49

This is needed because you now have debug data for libc?

labath planned changes to this revision.Feb 13 2015, 1:38 AM

This is google's custom version of ubuntu, but I don't think they've changed anything in this respect.
$ dpkg -l libc6:amd64
ii libc6:amd64 2.19-0ubuntu6.5 amd64 Embedded GNU C Library: Shared libraries

$ objdump -j .gnu_debuglink -s /lib/x86_64-linux-gnu/libc.so.6

/lib/x86_64-linux-gnu/libc.so.6: file format elf64-x86-64

Contents of section .gnu_debuglink:
0000 6c696263 2d322e31 392e736f 00000000 libc-2.19.so....
0010 ae65f08d .e..

Funnily enough, GDB seems to manage to find the debug information just fine. Maybe it just detects it's the same file underneath and skips it. I'll hold off from committing and try to investigate more...

thanks.

test/functionalities/unwind/noreturn/TestNoreturnUnwind.py
47–49

Yes.

I have a note that it would be nice to keep resolving the symbol to "abort" and not some internal libc mess. However, this is a separate issue (ps, gdb also resolves this do __GI_abort).

labath abandoned this revision.Feb 23 2015, 10:55 AM