From d6c32d2bf34e0bc35526f2b5732e4a20599c55b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 19 Aug 2005 12:53:58 +0000 Subject: [PATCH] The debugger's "sc"/"where" command now accepts a thread ID as parameter (and then shows the stack crawl of that stack instead of the current one). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13984 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/arch/x86/arch_debug.c | 27 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/system/kernel/arch/x86/arch_debug.c b/src/system/kernel/arch/x86/arch_debug.c index f9526c04f7..45fd0023fa 100644 --- a/src/system/kernel/arch/x86/arch_debug.c +++ b/src/system/kernel/arch/x86/arch_debug.c @@ -15,6 +15,8 @@ #include #include +#include + struct stack_frame { struct stack_frame *previous; @@ -77,21 +79,30 @@ stack_trace(int argc, char **argv) if (argc < 2) { thread = thread_get_current_thread(); - if (thread != NULL) - frameStack = &thread->arch_info.iframes; - else - frameStack = &gBootFrameStack; + read_ebp(ebp); } else { - kprintf("not supported\n"); - return 0; + thread_id id = strtoul(argv[1], NULL, 0); + thread = thread_get_thread_struct_locked(id); + if (thread == NULL) { + kprintf("could not find thread %ld\n", id); + return 0; + } + + // read %ebp from the thread's stack stored by a pushad + ebp = thread->arch_info.current_stack.esp[2]; } + // We don't have a thread pointer early in the boot process + if (thread != NULL) + frameStack = &thread->arch_info.iframes; + else + frameStack = &gBootFrameStack; + for (i = 0; i < frameStack->index; i++) { kprintf("iframe %p (end = %p)\n", frameStack->frames[i], frameStack->frames[i] + 1); } - // We don't have a thread pointer early in the boot process if (thread != NULL) { kprintf("stack trace for thread 0x%lx \"%s\"\n", thread->id, thread->name); @@ -105,8 +116,6 @@ stack_trace(int argc, char **argv) kprintf("frame caller :function + offset\n"); - read_ebp(ebp); - for (;;) { bool isIFrame = false; // see if the ebp matches the iframe