From 4a88dcb2cdc3f099768247b7805577c7fe59990b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 31 May 2004 21:40:43 +0000 Subject: [PATCH] Changed the "sc" output to be more useful. Now uses the extended possibilities of the elf_lookup_symbol_address() call. Fixed a bug in dbg_stack_trace(); it could crash at the top most stack frame. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7698 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/arch/x86/arch_debug.c | 29 ++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/kernel/core/arch/x86/arch_debug.c b/src/kernel/core/arch/x86/arch_debug.c index 850b66dd90..f51f96c3cf 100755 --- a/src/kernel/core/arch/x86/arch_debug.c +++ b/src/kernel/core/arch/x86/arch_debug.c @@ -36,15 +36,14 @@ dbg_stack_trace(int argc, char **argv) } dprintf("stack trace for thread 0x%lx '%s'\n", t->id, t->name); - dprintf("frame \tcaller:\n"); - dprintf("-------------------------------\n"); + dprintf("frame caller :function + offset\n"); read_ebp(ebp); for (;;) { bool is_iframe = false; // see if the ebp matches the iframe for (i = 0; i < t->arch_info.iframe_ptr; i++) { - if (ebp == ((uint32) t->arch_info.iframes[i] - 8)) { + if (ebp == ((uint32)t->arch_info.iframes[i] - 8)) { // it's an iframe is_iframe = true; } @@ -66,20 +65,32 @@ dbg_stack_trace(int argc, char **argv) ebp = frame->ebp; } else { uint32 eip = *((uint32 *)ebp + 1); - char symname[256]; - addr base_address; + const char *symbol, *image; + addr baseAddress; + bool exactMatch; if (eip == 0 || ebp == 0) break; - if (elf_lookup_symbol_address(eip, &base_address, symname, sizeof(symname)) >= 0) - dprintf("%p\t%p:<%p+%p>\t'%s'\n", (void *)ebp, (void *)eip, (void *)base_address, (void *)(eip - base_address), symname); - else - dprintf("%p\t%p\n", (void *)ebp, (void *)eip); + if (elf_lookup_symbol_address(eip, &baseAddress, &symbol, + &image, &exactMatch) == B_OK) { + if (symbol != NULL) { + dprintf("%08lx %08lx <%s>:%s + 0x%04lx%s\n", ebp, eip, + image, symbol, eip - baseAddress, exactMatch ? "" : " (nearest)"); + } else { + dprintf("%08lx %08lx <%s@%p>:unknown + 0x%04lx\n", ebp, eip, + image, (void *)baseAddress, eip - baseAddress); + } + } else + dprintf("%08lx %08lx\n", ebp, eip); ebp = *(uint32 *)ebp; } + + if (ebp == 0) + break; } + return 0; }