aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2017-06-02 22:12:12 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-06-02 22:12:12 +0000
commit734a59577edd7862465dafd24e86e20bf833b031 (patch)
tree91ff7f0a68496207723328905a5b2cd1b0d16fa4
parent0c12408773cd8de02ff37716b8cb94a4300d36b3 (diff)
parent0b65dc85acb1d62176c5584a7243e68aebf648f0 (diff)
downloadbionic-734a59577edd7862465dafd24e86e20bf833b031.tar.gz
Merge "Use libdemangle for function names." am: 5c76fec282
am: 0b65dc85ac Change-Id: I78957fcc07495269d5d6ac924c7cde64f5edb8c8
-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,