[Bug 17903] New: Standalone debug file search path does not match GDB

Bug ID 17903
Summary Standalone debug file search path does not match GDB
Product lldb
Version unspecified
Hardware PC
OS FreeBSD
Status NEW
Severity normal
Priority P
Component All Bugs
Assignee lldb-dev@cs.uiuc.edu
Reporter emaste@freebsd.org
Classification Unclassified

See e.g. [https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html](https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html)

For an example file /usr/bin/ls with a debuglink file of ls.debug, the search
paths should be, in order:

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

On FreeBSD, we use by default the 4th case from the GDB example above - /bin/ls
has debug info in /usr/lib/debug/bin/ls.debug.

Adding some debug logging to Symbols::LocateExecutableSymbolFile shows the
following paths being tried:
Directory /bin
Trying file /bin/ls.debug
Trying file /bin/.debug/ls.debug
Trying file /bin/.build-id/F4/DD1447000000000000000000000000.debug
Trying file /bin/bin/ls
Directory /data/emaste/src/llvm/build
Trying file /data/emaste/src/llvm/build/ls.debug
Trying file /data/emaste/src/llvm/build/.debug/ls.debug
Trying file
/data/emaste/src/llvm/build/.build-id/F4/DD1447000000000000000000000000.debug
Trying file /data/emaste/src/llvm/build/bin/ls
Directory /usr/lib/debug
Trying file /usr/lib/debug/ls.debug
Trying file /usr/lib/debug/.debug/ls.debug
Trying file /usr/lib/debug/.build-id/F4/DD1447000000000000000000000000.debug
Trying file /usr/lib/debug/bin/ls

The current set of LLDB search paths is, for each of dirname in <module_dir>,
<current dir>, and /usr/lib/debug:

        files.push_back (dirname + "/" + symbol_filename);                      
        files.push_back (dirname + "/.debug/" + symbol_filename);               
        files.push_back (dirname + "/.build-id/" + uuid_str);                   
        files.push_back (dirname + module_filename);                            

This ends up including extra paths not in GDB (e.g.
/usr/bin/.build-id/<uuid_str>), and excluding paths that are (e.g.
/usr/lib/debug/usr/bin/ls.debug).  The paths are also in a different order,
compared to GDB.

emaste@freebsd.org changed bug 17903