Move to the libc++ demangler.
Bug: 136138882 Test: Unit tests pass. Test: Did a kill -3 on a zygote process to verify art demangles properly. Change-Id: Iaf4fab191e84871be906b39cc32dd7c97c5d385a
This commit is contained in:
parent
45a1c998d1
commit
4ec93a7ee5
3 changed files with 19 additions and 6 deletions
|
@ -97,7 +97,6 @@ cc_library {
|
|||
cflags: ["-DNO_LIBDEXFILE_SUPPORT"],
|
||||
},
|
||||
},
|
||||
whole_static_libs: ["libdemangle"],
|
||||
}
|
||||
|
||||
cc_test_library {
|
||||
|
|
|
@ -28,13 +28,13 @@
|
|||
#include <backtrace/Backtrace.h>
|
||||
#include <backtrace/BacktraceMap.h>
|
||||
|
||||
#include <demangle.h>
|
||||
|
||||
#include "BacktraceLog.h"
|
||||
#include "UnwindStack.h"
|
||||
|
||||
using android::base::StringPrintf;
|
||||
|
||||
extern "C" char* __cxa_demangle(const char*, char*, size_t*, int*);
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Backtrace functions.
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -63,7 +63,14 @@ std::string Backtrace::GetFunctionName(uint64_t pc, uint64_t* offset, const back
|
|||
if (map->start == 0 || (map->flags & PROT_DEVICE_MAP)) {
|
||||
return "";
|
||||
}
|
||||
return demangle(GetFunctionNameRaw(pc, offset).c_str());
|
||||
std::string name(GetFunctionNameRaw(pc, offset));
|
||||
char* demangled_name = __cxa_demangle(name.c_str(), nullptr, nullptr, nullptr);
|
||||
if (demangled_name != nullptr) {
|
||||
name = demangled_name;
|
||||
free(demangled_name);
|
||||
return name;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
bool Backtrace::VerifyReadWordArgs(uint64_t ptr, word_t* out_value) {
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <string>
|
||||
|
||||
#include <backtrace/Backtrace.h>
|
||||
#include <demangle.h>
|
||||
#include <unwindstack/Elf.h>
|
||||
#include <unwindstack/MapInfo.h>
|
||||
#include <unwindstack/Maps.h>
|
||||
|
@ -41,6 +40,8 @@
|
|||
#include "UnwindStack.h"
|
||||
#include "UnwindStackMap.h"
|
||||
|
||||
extern "C" char* __cxa_demangle(const char*, char*, size_t*, int*);
|
||||
|
||||
bool Backtrace::Unwind(unwindstack::Regs* regs, BacktraceMap* back_map,
|
||||
std::vector<backtrace_frame_data_t>* frames, size_t num_ignore_frames,
|
||||
std::vector<std::string>* skip_names, BacktraceUnwindError* error) {
|
||||
|
@ -115,7 +116,13 @@ bool Backtrace::Unwind(unwindstack::Regs* regs, BacktraceMap* back_map,
|
|||
back_frame->pc = frame->pc;
|
||||
back_frame->sp = frame->sp;
|
||||
|
||||
back_frame->func_name = demangle(frame->function_name.c_str());
|
||||
char* demangled_name = __cxa_demangle(frame->function_name.c_str(), nullptr, nullptr, nullptr);
|
||||
if (demangled_name != nullptr) {
|
||||
back_frame->func_name = demangled_name;
|
||||
free(demangled_name);
|
||||
} else {
|
||||
back_frame->func_name = frame->function_name;
|
||||
}
|
||||
back_frame->func_offset = frame->function_offset;
|
||||
|
||||
back_frame->map.name = frame->map_name;
|
||||
|
|
Loading…
Reference in a new issue