Support new .debug location

This commit is contained in:
Amos Bird 2021-01-24 03:03:54 +08:00
parent d2366b5c6c
commit 554663a533
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4

View File

@ -324,6 +324,27 @@ void collectSymbolsFromELF(dl_phdr_info * info,
object_name = local_debug_info_path;
else if (std::filesystem::exists(debug_info_path))
object_name = debug_info_path;
else if (!build_id.empty())
{
// Check if there is a .debug file in .build-id folder. For example:
// /usr/lib/debug/.build-id/e4/0526a12e9a8f3819a18694f6b798f10c624d5c.debug
String build_id_hex;
build_id_hex.resize(build_id.size() * 2);
char * pos = build_id_hex.data();
for (auto c : build_id)
{
writeHexByteLowercase(c, pos);
pos += 2;
}
std::filesystem::path build_id_debug_info_path(
fmt::format("/usr/lib/debug/.build-id/{}/{}.debug", build_id_hex.substr(0, 2), build_id_hex.substr(2)));
if (std::filesystem::exists(build_id_debug_info_path))
object_name = build_id_debug_info_path;
else
object_name = canonical_path;
}
else
object_name = canonical_path;