From 504f982fd3bbbf14645c2ae8b2ab37ce2081f8e1 Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Mon, 21 Nov 2011 21:04:55 -0800 Subject: [PATCH] Use libcorkscrew to format the stack trace. Change-Id: I3a5439ada76bc77c2dd491eaed2272e16a811cc7 --- libs/utils/CallStack.cpp | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/libs/utils/CallStack.cpp b/libs/utils/CallStack.cpp index b4c581b03..c2a5e5534 100644 --- a/libs/utils/CallStack.cpp +++ b/libs/utils/CallStack.cpp @@ -101,17 +101,10 @@ void CallStack::dump(const char* prefix) const { get_backtrace_symbols(mStack, mCount, symbols); for (size_t i = 0; i < mCount; i++) { - const backtrace_frame_t& frame = mStack[i]; - const backtrace_symbol_t& symbol = symbols[i]; - const char* mapName = symbol.map_name ? symbol.map_name : ""; - const char* symbolName = symbol.demangled_name ? symbol.demangled_name : symbol.name; - if (symbolName) { - LOGD("%s#%02d pc %08x %s (%s)\n", prefix, - int(i), uint32_t(symbol.relative_pc), mapName, symbolName); - } else { - LOGD("%s#%02d pc %08x %s\n", prefix, - int(i), uint32_t(symbol.relative_pc), mapName); - } + char line[MAX_BACKTRACE_LINE_LENGTH]; + format_backtrace_line(i, &mStack[i], &symbols[i], + line, MAX_BACKTRACE_LINE_LENGTH); + LOGD("%s%s", prefix, line); } free_backtrace_symbols(symbols, mCount); } @@ -122,17 +115,12 @@ String8 CallStack::toString(const char* prefix) const { get_backtrace_symbols(mStack, mCount, symbols); for (size_t i = 0; i < mCount; i++) { - const backtrace_frame_t& frame = mStack[i]; - const backtrace_symbol_t& symbol = symbols[i]; - const char* mapName = symbol.map_name ? symbol.map_name : ""; - const char* symbolName = symbol.demangled_name ? symbol.demangled_name : symbol.name; - if (symbolName) { - str.appendFormat("%s#%02d pc %08x %s (%s)\n", prefix, - int(i), uint32_t(symbol.relative_pc), mapName, symbolName); - } else { - str.appendFormat("%s#%02d pc %08x %s\n", prefix, - int(i), uint32_t(symbol.relative_pc), mapName); - } + char line[MAX_BACKTRACE_LINE_LENGTH]; + format_backtrace_line(i, &mStack[i], &symbols[i], + line, MAX_BACKTRACE_LINE_LENGTH); + str.append(prefix); + str.append(line); + str.append("\n"); } free_backtrace_symbols(symbols, mCount); return str;