diff options
author | Milian Wolff <milian.wolff@kdab.com> | 2018-01-19 16:04:40 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-05-03 12:40:50 +0000 |
commit | 9ba708cca62ca704b4048fb49de1431aa19fdcd7 (patch) | |
tree | 6f361afa77765a739d8093c0cc3c4a1be320a00f | |
parent | 7cd91875557ee6c6f75c9ee37aab81b3ad839106 (diff) |
Add fallback search in /usr/lib/debug for debug info file
This is required to find e.g. the debug file for ld-2.26.so
on Ubuntu 17.10. That one can only be found in the /usr/lib/debug
folder. It itself resides in /lib/x86_64-linux-gnu/ld-2.26.so.
The debuglink is ld-2.26.so. The debug info file is found in
/usr/lib/debug/lib/x86_64-linux-gnu/ld-2.26.so.
Change-Id: I7c4c67873761a70a7b4f72f5adafea3023b08c12
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
-rw-r--r-- | app/perfsymboltable.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/app/perfsymboltable.cpp b/app/perfsymboltable.cpp index a71cc8c..4c3a037 100644 --- a/app/perfsymboltable.cpp +++ b/app/perfsymboltable.cpp @@ -531,6 +531,26 @@ Dwfl_Module *PerfSymbolTable::module(quint64 addr, const PerfElfMap::ElfInfo &el return reportElf(elf); } +static QFileInfo findDebugInfoFile(const QString &root, const QString &file, + const QString &debugLinkString) +{ + auto dir = QFileInfo(root).dir(); + QFileInfo debugLinkFile; + debugLinkFile.setFile(dir, file + QDir::separator() + debugLinkString); + if (debugLinkFile.isFile()) + return debugLinkFile; + // try again in .debug folder + debugLinkFile.setFile(dir, file + QDir::separator() + QLatin1String(".debug") + + QDir::separator() + debugLinkString); + if (debugLinkFile.isFile()) + return debugLinkFile; + // try again in /usr/lib/debug folder + debugLinkFile.setFile(dir, QLatin1String("usr") + QDir::separator() + QLatin1String("lib") + + QDir::separator() + QLatin1String("debug") + QDir::separator() + QFileInfo(file).path() + + QDir::separator() + debugLinkString); + return debugLinkFile; +} + int PerfSymbolTable::findDebugInfo(Dwfl_Module *module, const char *moduleName, Dwarf_Addr base, const char *file, const char *debugLink, GElf_Word crc, char **debugInfoFilename) @@ -547,13 +567,8 @@ int PerfSymbolTable::findDebugInfo(Dwfl_Module *module, const char *moduleName, if (!debugLinkFile.isFile()) { // fall-back to original file path with debug link file name const auto &elf = m_elfs.findElf(base); - const auto &dir = QFileInfo(m_unwind->systemRoot() + - QString::fromUtf8(elf.originalPath)).absoluteDir(); - debugLinkFile.setFile(dir, debugLinkString); - if (!debugLinkFile.isFile()) { // try again in .debug folder - debugLinkFile.setFile(dir, QLatin1String(".debug") + - QDir::separator() + debugLinkString); - } + const auto &path = QString::fromUtf8(elf.originalPath); + debugLinkFile = findDebugInfoFile(m_unwind->systemRoot(), path, debugLinkString); } if (!debugLinkFile.isFile()) |