summaryrefslogtreecommitdiff
path: root/debuggerd/libdebuggerd/utility.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'debuggerd/libdebuggerd/utility.cpp')
-rw-r--r--debuggerd/libdebuggerd/utility.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/debuggerd/libdebuggerd/utility.cpp b/debuggerd/libdebuggerd/utility.cpp
index 7aebea8fe..9b2779a9e 100644
--- a/debuggerd/libdebuggerd/utility.cpp
+++ b/debuggerd/libdebuggerd/utility.cpp
@@ -38,6 +38,7 @@
#include <debuggerd/handler.h>
#include <log/log.h>
#include <unwindstack/Memory.h>
+#include <unwindstack/Unwinder.h>
using android::base::unique_fd;
@@ -422,3 +423,22 @@ const char* get_sigcode(const siginfo_t* si) {
// Then give up...
return "?";
}
+
+void log_backtrace(log_t* log, unwindstack::Unwinder* unwinder, const char* prefix) {
+ if (unwinder->elf_from_memory_not_file()) {
+ _LOG(log, logtype::BACKTRACE,
+ "%sNOTE: Function names and BuildId information is missing for some frames due\n", prefix);
+ _LOG(log, logtype::BACKTRACE,
+ "%sNOTE: to unreadable libraries. For unwinds of apps, only shared libraries\n", prefix);
+ _LOG(log, logtype::BACKTRACE, "%sNOTE: found under the lib/ directory are readable.\n", prefix);
+#if defined(ROOT_POSSIBLE)
+ _LOG(log, logtype::BACKTRACE,
+ "%sNOTE: On this device, run setenforce 0 to make the libraries readable.\n", prefix);
+#endif
+ }
+
+ 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());
+ }
+}