Hi Pavel,
I stepped through SymbolVendorELF::CreateInstance(), and it seems that the problem lies within Symbols::LocateExecutableSymbolFile (Host/common/Symbols.cpp). This method looks at the correct locations:
(gdb) print debug_file_search_paths
$35 = {m_files = std::vector of length 3, capacity 4 = {
{m_directory = {m_string = 0x7994f8 "/usr/lib"},
m_filename = {m_string = 0x7fffe400ba88 "x86_64-linux-gnu"},
m_is_resolved = true,
m_syntax = lldb_private::FileSpec::ePathSyntaxPosix},
{m_directory = {m_string = 0x7fffe400bae0 "/home/stefan/git/dsu-ld/libdsu-project"},
m_filename = {m_string = 0x7fffe400bac8 "."},
m_is_resolved = true,
m_syntax = lldb_private::FileSpec::ePathSyntaxPosix},
{m_directory = {m_string = 0x7994f8 "/usr/lib"},
m_filename = {m_string = 0x7fffe400bb18 "debug"},
m_is_resolved = true,
m_syntax = lldb_private::FileSpec::ePathSyntaxPosix}}}
But it looks for the wrong file names. Under Ubuntu, the contents of a *-dbg packge are stored under /usr/lib/debug, using the exact same file names as their regular executable counterparts. In the case of apache2-dbg, the files under /usr/lib/debug are (for example):
/usr/lib/debug/usr/bin/rotatelogs
/usr/lib/debug/usr/sbin/apache2
/usr/lib/debug/usr/lib/apache2/modules/mod_ssl.so
and so on.
If i now look at the file names lldb looks for, I find for /usr/lib/x86_64-linux-gnu:
(gdb) print files
$36 = std::vector of length 4, capacity 4 = {
"/usr/lib/x86_64-linux-gnu/9d72ee0b01e9b2947c7f95e7b4ebbbf05a8aa5.debug",
"/usr/lib/x86_64-linux-gnu/.debug/9d72ee0b01e9b2947c7f95e7b4ebbbf05a8aa5.debug",
"/usr/lib/x86_64-linux-gnu/.build-id/B5/9D72EE0B01E9B2947C7F95E7B4EBBBF05A8AA5.debug",
"/usr/lib/x86_64-linux-gnu/usr/lib/x86_64-linux-gnu/9d72ee0b01e9b2947c7f95e7b4ebbbf05a8aa5.debug"}
For my /home/stefan/git/dsu-ld/libdsu-project/:
(gdb) print files
$38 = std::vector of length 4, capacity 4 = {
"/home/stefan/git/dsu-ld/libdsu-project/./9d72ee0b01e9b2947c7f95e7b4ebbbf05a8aa5.debug",
"/home/stefan/git/dsu-ld/libdsu-project/./.debug/9d72ee0b01e9b2947c7f95e7b4ebbbf05a8aa5.debug",
"/home/stefan/git/dsu-ld/libdsu-project/./.build-id/B5/9D72EE0B01E9B2947C7F95E7B4EBBBF05A8AA5.debug",
"/home/stefan/git/dsu-ld/libdsu-project/./usr/lib/x86_64-linux-gnu/9d72ee0b01e9b2947c7f95e7b4ebbbf05a8aa5.debug"}
And finally for the /usr/lib/debug directory:
(gdb) print files
$39 = std::vector of length 4, capacity 4 = {
"/usr/lib/debug/9d72ee0b01e9b2947c7f95e7b4ebbbf05a8aa5.debug",
"/usr/lib/debug/.debug/9d72ee0b01e9b2947c7f95e7b4ebbbf05a8aa5.debug",
"/usr/lib/debug/.build-id/B5/9D72EE0B01E9B2947C7F95E7B4EBBBF05A8AA5.debug",
"/usr/lib/debug/usr/lib/x86_64-linux-gnu/9d72ee0b01e9b2947c7f95e7b4ebbbf05a8aa5.debug"}
So, lldb expects that the uuid/build of the Module it is about to load is also contained in the symbol file name.
Imho, we also have to take the FileSpec contents of the ModuleSpec we are currently looking at, and add its path to the files vector. But I am not that familiar with the whole lldb backend to tell for sure what would happen then.
I also checked the current HEAD of the lldb source tree to see if there are any changes, compared with my older revision. There is only a slight difference in how Symbols::LoadExecutableSymbolFile uses the /usr/lib/debug directory:
// Some debug files may stored in the module directory like this:
// /usr/lib/debug/usr/lib/library.so.debug
if (!file_dir.IsEmpty())
files.push_back (dirname + file_dir.AsCString() + "/" ++ symbol_filename);
This would be in fact the solution to my problem, if it wouldn't use the symbol_filename (which contains a uuid, something the *-dbg packages don't have).
Well, what do you think?
Cheers,
Stefan