diff options
author | Christopher Ferris <cferris@google.com> | 2018-05-24 18:06:02 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-05-24 18:06:02 +0000 |
commit | 7bfc149b4365b32f16eae9bc072c3df3d11383a2 (patch) | |
tree | 2fdfebb60f1ac55713f9bb117253cadf508f61f5 /libc/malloc_debug/malloc_debug.cpp | |
parent | 6b4f8094766c47ffafb7d169fbf032034090064b (diff) | |
parent | 93bdd6ae3ad8322b7be2be0201c8db7227631d14 (diff) |
Merge "Add support for using the new unwinder."
Diffstat (limited to 'libc/malloc_debug/malloc_debug.cpp')
-rw-r--r-- | libc/malloc_debug/malloc_debug.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp index 6f841cab5..836c33b86 100644 --- a/libc/malloc_debug/malloc_debug.cpp +++ b/libc/malloc_debug/malloc_debug.cpp @@ -47,6 +47,7 @@ #include "debug_disable.h" #include "debug_log.h" #include "malloc_debug.h" +#include "UnwindBacktrace.h" // ------------------------------------------------------------------------ // Global Data @@ -118,6 +119,26 @@ static void InitAtfork() { }); } +void BacktraceAndLog() { + if (g_debug->config().options() & BACKTRACE_FULL) { + std::vector<uintptr_t> frames; + std::vector<unwindstack::LocalFrameData> frames_info; + if (!Unwind(&frames, &frames_info, 256)) { + error_log(" Backtrace failed to get any frames."); + } else { + UnwindLog(frames_info); + } + } else { + std::vector<uintptr_t> frames(256); + size_t num_frames = backtrace_get(frames.data(), frames.size()); + if (num_frames == 0) { + error_log(" Backtrace failed to get any frames."); + } else { + backtrace_log(frames.data(), num_frames); + } + } +} + static void LogError(const void* pointer, const char* error_str) { error_log(LOG_DIVIDER); error_log("+++ ALLOCATION %p %s", pointer, error_str); @@ -128,14 +149,8 @@ static void LogError(const void* pointer, const char* error_str) { PointerData::LogFreeBacktrace(pointer); } - std::vector<uintptr_t> frames(128); - size_t num_frames = backtrace_get(frames.data(), frames.size()); - if (num_frames == 0) { - error_log("Backtrace failed to get any frames."); - } else { - error_log("Backtrace at time of failure:"); - backtrace_log(frames.data(), num_frames); - } + error_log("Backtrace at time of failure:"); + BacktraceAndLog(); error_log(LOG_DIVIDER); } @@ -819,7 +834,7 @@ bool debug_dump_heap(const char* file_name) { return false; } - fprintf(fp, "Android Native Heap Dump v1.0\n\n"); + fprintf(fp, "Android Native Heap Dump v1.1\n\n"); PointerData::DumpLiveToFile(fp); |