Skip to content

Commit e2b4c5b

Browse files
committed
Make ElfReader::open_debug_file() support searching for debuginfo files by build ID
This is the only thing that works in Debian 12. Should be generally useful though.
1 parent d05d6fe commit e2b4c5b

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/ElfReader.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,16 @@ ElfFileReader::~ElfFileReader() {
599599
}
600600

601601
ScopedFd ElfFileReader::open_debug_file(const std::string& elf_file_name) {
602+
string build_id = read_buildid();
603+
if (build_id.size() > 2) {
604+
string debug_path = "/usr/lib/debug/.build-id/" + build_id.substr(0, 2) +
605+
"/" + build_id.substr(2) + ".debug";
606+
ScopedFd debug_fd(debug_path.c_str(), O_RDONLY);
607+
if (debug_fd.is_open()) {
608+
return debug_fd;
609+
}
610+
}
611+
602612
if (elf_file_name.empty() || elf_file_name[0] != '/') {
603613
return ScopedFd();
604614
}

0 commit comments

Comments
 (0)