diff options
| author | Christopher Ferris <cferris@google.com> | 2022-03-14 15:02:11 -0700 |
|---|---|---|
| committer | Christopher Ferris <cferris@google.com> | 2022-03-15 09:50:48 -0700 |
| commit | bb4e3ef26b64c7e902f7108fe6ba67fe7f412705 (patch) | |
| tree | debe5fd01e72fef06b39c9f64f60270953da073f /debuggerd/libdebuggerd/utility.cpp | |
| parent | dc03a8ee14daebcdcce0e8cdbb6ae3ce76d36679 (diff) | |
Update for accurate unreadable elf files.
The functionality moved from the Unwinder object to the MapInfo
object and means that the individual unreadable files can be
displayed now.
Included adding the unreadable elfs per thread in the protobuf.
Updated the unwinder test.
Test: All unit tests pass.
Change-Id: I7140bde16938736da005f926e10bbdb3dbc0f6f5
Diffstat (limited to 'debuggerd/libdebuggerd/utility.cpp')
| -rw-r--r-- | debuggerd/libdebuggerd/utility.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/debuggerd/libdebuggerd/utility.cpp b/debuggerd/libdebuggerd/utility.cpp index 543a67c94f..ecd98a4c56 100644 --- a/debuggerd/libdebuggerd/utility.cpp +++ b/debuggerd/libdebuggerd/utility.cpp @@ -28,6 +28,7 @@ #include <sys/wait.h> #include <unistd.h> +#include <set> #include <string> #include <android-base/properties.h> @@ -483,7 +484,16 @@ std::string describe_pac_enabled_keys(long value) { } void log_backtrace(log_t* log, unwindstack::Unwinder* unwinder, const char* prefix) { - if (unwinder->elf_from_memory_not_file()) { + std::set<std::string> unreadable_elf_files; + unwinder->SetDisplayBuildID(true); + for (const auto& frame : unwinder->frames()) { + if (frame.map_info != nullptr && frame.map_info->ElfFileNotReadable()) { + unreadable_elf_files.emplace(frame.map_info->name()); + } + } + + // Put the preamble ahead of the backtrace. + if (!unreadable_elf_files.empty()) { _LOG(log, logtype::BACKTRACE, "%sNOTE: Function names and BuildId information is missing for some frames due\n", prefix); _LOG(log, logtype::BACKTRACE, @@ -493,10 +503,13 @@ void log_backtrace(log_t* log, unwindstack::Unwinder* unwinder, const char* pref _LOG(log, logtype::BACKTRACE, "%sNOTE: On this device, run setenforce 0 to make the libraries readable.\n", prefix); #endif + _LOG(log, logtype::BACKTRACE, "%sNOTE: Unreadable libraries:\n", prefix); + for (auto& name : unreadable_elf_files) { + _LOG(log, logtype::BACKTRACE, "%sNOTE: %s\n", prefix, name.c_str()); + } } - unwinder->SetDisplayBuildID(true); - for (size_t i = 0; i < unwinder->NumFrames(); i++) { - _LOG(log, logtype::BACKTRACE, "%s%s\n", prefix, unwinder->FormatFrame(i).c_str()); + for (const auto& frame : unwinder->frames()) { + _LOG(log, logtype::BACKTRACE, "%s%s\n", prefix, unwinder->FormatFrame(frame).c_str()); } } |
