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 | |
parent | bfda022dd6fbbcea60e9f52496d90ece514b32da (diff) | |
parent | f77cc9b224c35fa7d1d71e7c374ef19e47b5f6a5 (diff) |
Merge RP1A.190822.001
Change-Id: Iaf90835a99d87f6246798efd2cea6fe9f750ea18
Diffstat (limited to 'libc/malloc_debug')
-rw-r--r-- | libc/malloc_debug/Android.bp | 3 | ||||
-rw-r--r-- | libc/malloc_debug/PointerData.cpp | 14 | ||||
-rw-r--r-- | libc/malloc_debug/UnwindBacktrace.cpp | 12 | ||||
-rw-r--r-- | libc/malloc_debug/backtrace.cpp | 12 |
4 files changed, 31 insertions, 10 deletions
diff --git a/libc/malloc_debug/Android.bp b/libc/malloc_debug/Android.bp index aae16f14d..d6b85319e 100644 --- a/libc/malloc_debug/Android.bp +++ b/libc/malloc_debug/Android.bp @@ -16,7 +16,6 @@ cc_library_static { whole_static_libs: [ "libbase", "libasync_safe", - "libdemangle", ], include_dirs: ["bionic/libc"], @@ -66,7 +65,6 @@ cc_library { static_libs: [ "libasync_safe", "libbase", - "libdemangle", "libc_malloc_debug_backtrace", ], @@ -122,7 +120,6 @@ cc_test { static_libs: [ "libc_malloc_debug", - "libdemangle", "libtinyxml2", ], diff --git a/libc/malloc_debug/PointerData.cpp b/libc/malloc_debug/PointerData.cpp index 8cc1a2891..b5219a172 100644 --- a/libc/malloc_debug/PointerData.cpp +++ b/libc/malloc_debug/PointerData.cpp @@ -43,7 +43,6 @@ #include <android-base/stringprintf.h> #include <android-base/thread_annotations.h> -#include <demangle.h> #include <private/bionic_macros.h> #include "Config.h" @@ -54,6 +53,8 @@ #include "malloc_debug.h" #include "UnwindBacktrace.h" +extern "C" char* __cxa_demangle(const char*, char*, size_t*, int*); + std::atomic_uint8_t PointerData::backtrace_enabled_; std::atomic_bool PointerData::backtrace_dump_; @@ -599,7 +600,16 @@ void PointerData::DumpLiveToFile(FILE* fp) { if (frame.function_name.empty()) { fprintf(fp, " \"\" 0}"); } else { - fprintf(fp, " \"%s\" %" PRIx64 "}", demangle(frame.function_name.c_str()).c_str(), frame.function_offset); + char* demangled_name = __cxa_demangle(frame.function_name.c_str(), nullptr, nullptr, + nullptr); + const char* name; + if (demangled_name != nullptr) { + name = demangled_name; + } else { + name = frame.function_name.c_str(); + } + fprintf(fp, " \"%s\" %" PRIx64 "}", name, frame.function_offset); + free(demangled_name); } } fprintf(fp, "\n"); diff --git a/libc/malloc_debug/UnwindBacktrace.cpp b/libc/malloc_debug/UnwindBacktrace.cpp index ddafc731f..92fb3fa96 100644 --- a/libc/malloc_debug/UnwindBacktrace.cpp +++ b/libc/malloc_debug/UnwindBacktrace.cpp @@ -36,7 +36,6 @@ #include <vector> #include <android-base/stringprintf.h> -#include <demangle.h> #include <unwindstack/LocalUnwinder.h> #include <unwindstack/MapInfo.h> @@ -49,6 +48,8 @@ #define PAD_PTR "08" PRIx64 #endif +extern "C" char* __cxa_demangle(const char*, char*, size_t*, int*); + static pthread_once_t g_setup_once = PTHREAD_ONCE_INIT; static unwindstack::LocalUnwinder* g_unwinder; @@ -100,7 +101,14 @@ void UnwindLog(const std::vector<unwindstack::LocalFrameData>& frame_info) { } if (!info->function_name.empty()) { - line += " (" + demangle(info->function_name.c_str()); + line += " ("; + char* demangled_name = __cxa_demangle(info->function_name.c_str(), nullptr, nullptr, nullptr); + if (demangled_name != nullptr) { + line += demangled_name; + free(demangled_name); + } else { + line += info->function_name; + } if (info->function_offset != 0) { line += "+" + std::to_string(info->function_offset); } 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); |