From c5eb28a359e11c0dfc4fe50c6d9316eb11fda366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 4 Nov 2005 17:28:08 +0000 Subject: [PATCH] Now uses the new image_debug_lookup_user_symbol_address() call. The stack frame that got interrupted were missing from the stack output (and thus the call that got us into the kernel). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14706 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/arch/x86/arch_debug.c | 66 ++++++++++++++++--------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/src/system/kernel/arch/x86/arch_debug.c b/src/system/kernel/arch/x86/arch_debug.c index 5d8fc841e3..b9ed68ccfd 100644 --- a/src/system/kernel/arch/x86/arch_debug.c +++ b/src/system/kernel/arch/x86/arch_debug.c @@ -7,10 +7,11 @@ */ -#include #include -#include #include +#include +#include +#include #include #include @@ -68,6 +69,41 @@ error: } +static void +print_stack_frame(struct thread *thread, addr_t eip, addr_t ebp, addr_t nextEbp) +{ + const char *symbol, *image; + addr_t baseAddress; + bool exactMatch; + status_t status; + addr_t diff; + + diff = nextEbp - ebp; + + // kernel space/user space switch + if (diff & 0x80000000) + diff = 0; + + status = elf_debug_lookup_symbol_address(eip, &baseAddress, &symbol, + &image, &exactMatch); + if (status != B_OK) { + // try to locate the image in the images loaded into user space + status = image_debug_lookup_user_symbol_address(thread->team, eip, + &baseAddress, &symbol, &image, &exactMatch); + } + if (status == B_OK) { + if (symbol != NULL) { + kprintf("%08lx (+%4ld) %08lx <%s>:%s + 0x%04lx%s\n", ebp, diff, eip, + image, symbol, eip - baseAddress, exactMatch ? "" : " (nearest)"); + } else { + kprintf("%08lx (+%4ld) %08lx <%s@%p>:unknown + 0x%04lx\n", ebp, diff, + eip, image, (void *)baseAddress, eip - baseAddress); + } + } else + kprintf("%08lx (+%4ld) %08lx\n", ebp, diff, eip); +} + + static int stack_trace(int argc, char **argv) { @@ -154,12 +190,11 @@ stack_trace(int argc, char **argv) } kprintf("\n"); kprintf(" vector: 0x%lx, error code: 0x%lx\n", frame->vector, frame->error_code); + + print_stack_frame(thread, frame->eip, ebp, frame->ebp); ebp = frame->ebp; } else { - addr_t eip, nextEbp, diff; - const char *symbol, *image; - addr_t baseAddress; - bool exactMatch; + addr_t eip, nextEbp; if (get_next_frame(ebp, &nextEbp, &eip) != B_OK) { kprintf("%08lx -- read fault\n", ebp); @@ -169,24 +204,7 @@ stack_trace(int argc, char **argv) if (eip == 0 || ebp == 0) break; - diff = nextEbp - ebp; - - // kernel space/user space switch - if (diff & 0x80000000) - diff = 0; - - if (elf_debug_lookup_symbol_address(eip, &baseAddress, &symbol, - &image, &exactMatch) == B_OK) { - if (symbol != NULL) { - kprintf("%08lx (+%4ld) %08lx <%s>:%s + 0x%04lx%s\n", ebp, diff, eip, - image, symbol, eip - baseAddress, exactMatch ? "" : " (nearest)"); - } else { - kprintf("%08lx (+%4ld) %08lx <%s@%p>:unknown + 0x%04lx\n", ebp, diff, eip, - image, (void *)baseAddress, eip - baseAddress); - } - } else - kprintf("%08lx %08lx\n", ebp, eip); - + print_stack_frame(thread, eip, ebp, nextEbp); ebp = nextEbp; }