From 9782b8707484addc0c90b641422e583e95ab7b35 Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Thu, 18 Jul 2019 13:36:50 -0700 Subject: Move to the libc++ demangler. Bug: 136138882 Test: Ran malloc debug tests. Test: Ran an app with backtrace_full and verified demangling working in Test: log file. Test: Enabled leak checking and verified that the logs include properly Test: demangled. Change-Id: Ic4fd9f1522451e867048ac1bea59d8c5ed0d3577 --- libc/malloc_debug/PointerData.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'libc/malloc_debug/PointerData.cpp') diff --git a/libc/malloc_debug/PointerData.cpp b/libc/malloc_debug/PointerData.cpp index 617d128c7..ec7e42dda 100644 --- a/libc/malloc_debug/PointerData.cpp +++ b/libc/malloc_debug/PointerData.cpp @@ -43,7 +43,6 @@ #include #include -#include #include #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_; @@ -596,7 +597,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"); -- cgit v1.2.3