aboutsummaryrefslogtreecommitdiffstats
path: root/debuggerd
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2011-11-21 21:10:00 -0800
committerJeff Brown <jeffbrown@google.com>2011-11-22 12:13:46 -0800
commit19b39f371be5250e7b9e88016be1e5e665367b3f (patch)
tree95ab25975d40d4833921a7bcb87970f3dfce2234 /debuggerd
parentde8b136d5a1bcb5decf0dd00edcd6c9e70b4f882 (diff)
downloadsystem_core-19b39f371be5250e7b9e88016be1e5e665367b3f.tar.gz
system_core-19b39f371be5250e7b9e88016be1e5e665367b3f.tar.bz2
system_core-19b39f371be5250e7b9e88016be1e5e665367b3f.zip
Improve backtrace formatting.
Show the symbol offset, when available. Centralized formatting of native stack traces in libcorkscrew. It's handy for automated tools if all stacks look the same. Since we already made them all look them same, we might as well do the formatting in just one place. Do not strip the Thumb bit on ARM. This fixes an off-by-one issue that could happen when resolving a PC that was at the very beginning of a Thumb function, since the symbol table would have the Thumb bit set but since we stripped the bit from our PC, we would be looking for an address one byte before the one listed in the symbol table. It's also quite useful to see whether a given function is executing in Thumb mode just by glancing at the PC. Change-Id: Icaa29add85ce0bcafe24d5ce2098e138d809e2ab
Diffstat (limited to 'debuggerd')
-rw-r--r--debuggerd/utility.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/debuggerd/utility.c b/debuggerd/utility.c
index 64e59809..2ccf947e 100644
--- a/debuggerd/utility.c
+++ b/debuggerd/utility.c
@@ -65,16 +65,10 @@ static void dump_backtrace(const ptrace_context_t* context __attribute((unused))
backtrace_symbol_t backtrace_symbols[STACK_DEPTH];
get_backtrace_symbols_ptrace(context, backtrace, frames, backtrace_symbols);
for (size_t i = 0; i < frames; i++) {
- const backtrace_symbol_t* symbol = &backtrace_symbols[i];
- const char* map_name = symbol->map_name ? symbol->map_name : "<unknown>";
- const char* symbol_name = symbol->demangled_name ? symbol->demangled_name : symbol->name;
- if (symbol_name) {
- _LOG(tfd, !at_fault, " #%02d pc %08x %s (%s)\n",
- (int)i, symbol->relative_pc, map_name, symbol_name);
- } else {
- _LOG(tfd, !at_fault, " #%02d pc %08x %s\n",
- (int)i, symbol->relative_pc, map_name);
- }
+ char line[MAX_BACKTRACE_LINE_LENGTH];
+ format_backtrace_line(i, &backtrace[i], &backtrace_symbols[i],
+ line, MAX_BACKTRACE_LINE_LENGTH);
+ _LOG(tfd, !at_fault, " %s\n", line);
}
free_backtrace_symbols(backtrace_symbols, frames);
}
@@ -94,12 +88,23 @@ static void dump_stack_segment(const ptrace_context_t* context, int tfd, pid_t t
if (symbol) {
char* demangled_name = demangle_symbol_name(symbol->name);
const char* symbol_name = demangled_name ? demangled_name : symbol->name;
+ uint32_t offset = stack_content - (mi->start + symbol->start);
if (!i && label >= 0) {
- _LOG(tfd, only_in_tombstone, " #%02d %08x %08x %s (%s)\n",
- label, *sp, stack_content, mi ? mi->name : "", symbol_name);
+ if (offset) {
+ _LOG(tfd, only_in_tombstone, " #%02d %08x %08x %s (%s+%u)\n",
+ label, *sp, stack_content, mi ? mi->name : "", symbol_name, offset);
+ } else {
+ _LOG(tfd, only_in_tombstone, " #%02d %08x %08x %s (%s)\n",
+ label, *sp, stack_content, mi ? mi->name : "", symbol_name);
+ }
} else {
- _LOG(tfd, only_in_tombstone, " %08x %08x %s (%s)\n",
- *sp, stack_content, mi ? mi->name : "", symbol_name);
+ if (offset) {
+ _LOG(tfd, only_in_tombstone, " %08x %08x %s (%s+%u)\n",
+ *sp, stack_content, mi ? mi->name : "", symbol_name, offset);
+ } else {
+ _LOG(tfd, only_in_tombstone, " %08x %08x %s (%s)\n",
+ *sp, stack_content, mi ? mi->name : "", symbol_name);
+ }
}
free(demangled_name);
} else {