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
This commit is contained in:
Axel Dörfler
2004-05-31 21:40:43 +00:00
parent 6fccd3b788
commit 4a88dcb2cd
+20 -9
View File
@@ -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("stack trace for thread 0x%lx '%s'\n", t->id, t->name);
dprintf("frame \tcaller:<base function+offset>\n"); dprintf("frame caller <image>:function + offset\n");
dprintf("-------------------------------\n");
read_ebp(ebp); read_ebp(ebp);
for (;;) { for (;;) {
bool is_iframe = false; bool is_iframe = false;
// see if the ebp matches the iframe // see if the ebp matches the iframe
for (i = 0; i < t->arch_info.iframe_ptr; i++) { 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 // it's an iframe
is_iframe = true; is_iframe = true;
} }
@@ -66,20 +65,32 @@ dbg_stack_trace(int argc, char **argv)
ebp = frame->ebp; ebp = frame->ebp;
} else { } else {
uint32 eip = *((uint32 *)ebp + 1); uint32 eip = *((uint32 *)ebp + 1);
char symname[256]; const char *symbol, *image;
addr base_address; addr baseAddress;
bool exactMatch;
if (eip == 0 || ebp == 0) if (eip == 0 || ebp == 0)
break; break;
if (elf_lookup_symbol_address(eip, &base_address, symname, sizeof(symname)) >= 0) if (elf_lookup_symbol_address(eip, &baseAddress, &symbol,
dprintf("%p\t%p:<%p+%p>\t'%s'\n", (void *)ebp, (void *)eip, (void *)base_address, (void *)(eip - base_address), symname); &image, &exactMatch) == B_OK) {
else if (symbol != NULL) {
dprintf("%p\t%p\n", (void *)ebp, (void *)eip); 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; ebp = *(uint32 *)ebp;
} }
if (ebp == 0)
break;
} }
return 0; return 0;
} }