aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2017-06-01 14:16:32 -0700
committerChristopher Ferris <cferris@google.com>2017-06-02 10:10:24 -0700
commita625ee2063dec60996f01e0274e4c352ab75c46b (patch)
tree5654e79f8e65ba2372ff038d1e4285ea3ecf6629
parent498b4de964b5d38952acfe2d1823c13f20a641d3 (diff)
downloadbionic-a625ee2063dec60996f01e0274e4c352ab75c46b.tar.gz
Use libdemangle for function names.
Bug: 62141808 Test: Ran unit tests, ran malloc debug with leaks and verified functions Test: are demangled. Change-Id: I1900632e9a55bb818b1aabc798224ff3eebc1fca
-rw-r--r--libc/malloc_debug/Android.bp2
-rw-r--r--libc/malloc_debug/backtrace.cpp8
2 files changed, 4 insertions, 6 deletions
diff --git a/libc/malloc_debug/Android.bp b/libc/malloc_debug/Android.bp
index b071b90ae..06fc426d6 100644
--- a/libc/malloc_debug/Android.bp
+++ b/libc/malloc_debug/Android.bp
@@ -13,7 +13,7 @@ cc_library_static {
stl: "libc++_static",
- whole_static_libs: ["libasync_safe"],
+ whole_static_libs: ["libasync_safe", "libdemangle"],
include_dirs: ["bionic/libc"],
diff --git a/libc/malloc_debug/backtrace.cpp b/libc/malloc_debug/backtrace.cpp
index 907944f12..2443ba103 100644
--- a/libc/malloc_debug/backtrace.cpp
+++ b/libc/malloc_debug/backtrace.cpp
@@ -36,6 +36,8 @@
#include <unistd.h>
#include <unwind.h>
+#include <demangle.h>
+
#include "backtrace.h"
#include "debug_log.h"
#include "MapData.h"
@@ -163,13 +165,9 @@ std::string backtrace_string(const uintptr_t* frames, size_t frame_count) {
char buf[1024];
if (symbol != nullptr) {
- char* demangled_symbol = __cxa_demangle(symbol, nullptr, nullptr, nullptr);
- const char* best_name = (demangled_symbol != nullptr) ? demangled_symbol : symbol;
-
async_safe_format_buffer(
buf, sizeof(buf), " #%02zd pc %" PAD_PTR " %s%s (%s+%" PRIuPTR ")\n", frame_num,
- rel_pc, soname, offset_buf, best_name, frames[frame_num] - offset);
- free(demangled_symbol);
+ rel_pc, soname, offset_buf, demangle(symbol).c_str(), frames[frame_num] - offset);
} else {
async_safe_format_buffer(
buf, sizeof(buf), " #%02zd pc %" PAD_PTR " %s%s\n", frame_num, rel_pc, soname,