diff options
author | Scott Lobdell <slobdell@google.com> | 2019-08-25 12:20:54 -0700 |
---|---|---|
committer | Scott Lobdell <slobdell@google.com> | 2019-08-25 12:20:54 -0700 |
commit | 4f9bfdcaca2414c8959986f0a4d73f16cb15e1c4 (patch) | |
tree | 540bab5498d276cbbfad24c48a7ff989ee8b920a /libc/malloc_debug/backtrace.cpp | |
parent | bfda022dd6fbbcea60e9f52496d90ece514b32da (diff) | |
parent | f77cc9b224c35fa7d1d71e7c374ef19e47b5f6a5 (diff) |
Merge RP1A.190822.001
Change-Id: Iaf90835a99d87f6246798efd2cea6fe9f750ea18
Diffstat (limited to 'libc/malloc_debug/backtrace.cpp')
-rw-r--r-- | libc/malloc_debug/backtrace.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libc/malloc_debug/backtrace.cpp b/libc/malloc_debug/backtrace.cpp index 0e3a53f92..ab5c50523 100644 --- a/libc/malloc_debug/backtrace.cpp +++ b/libc/malloc_debug/backtrace.cpp @@ -36,8 +36,6 @@ #include <unistd.h> #include <unwind.h> -#include <demangle.h> - #include "MapData.h" #include "backtrace.h" #include "debug_log.h" @@ -164,10 +162,18 @@ std::string backtrace_string(const uintptr_t* frames, size_t frame_count) { char buf[1024]; if (symbol != nullptr) { + char* demangled_name = __cxa_demangle(symbol, nullptr, nullptr, nullptr); + const char* name; + if (demangled_name != nullptr) { + name = demangled_name; + } else { + name = symbol; + } async_safe_format_buffer(buf, sizeof(buf), " #%02zd pc %" PAD_PTR " %s%s (%s+%" PRIuPTR ")\n", - frame_num, rel_pc, soname, offset_buf, demangle(symbol).c_str(), + frame_num, rel_pc, soname, offset_buf, name, frames[frame_num] - offset); + free(demangled_name); } else { async_safe_format_buffer(buf, sizeof(buf), " #%02zd pc %" PAD_PTR " %s%s\n", frame_num, rel_pc, soname, offset_buf); |