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
This commit is contained in:
Axel Dörfler 2005-08-19 12:53:58 +00:00
parent c987e126de
commit d6c32d2bf3

View File

@ -15,6 +15,8 @@
#include <arch/debug.h> #include <arch/debug.h>
#include <arch_cpu.h> #include <arch_cpu.h>
#include <stdlib.h>
struct stack_frame { struct stack_frame {
struct stack_frame *previous; struct stack_frame *previous;
@ -77,21 +79,30 @@ stack_trace(int argc, char **argv)
if (argc < 2) { if (argc < 2) {
thread = thread_get_current_thread(); thread = thread_get_current_thread();
if (thread != NULL) read_ebp(ebp);
frameStack = &thread->arch_info.iframes;
else
frameStack = &gBootFrameStack;
} else { } else {
kprintf("not supported\n"); thread_id id = strtoul(argv[1], NULL, 0);
return 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++) { for (i = 0; i < frameStack->index; i++) {
kprintf("iframe %p (end = %p)\n", kprintf("iframe %p (end = %p)\n",
frameStack->frames[i], frameStack->frames[i] + 1); frameStack->frames[i], frameStack->frames[i] + 1);
} }
// We don't have a thread pointer early in the boot process
if (thread != NULL) { if (thread != NULL) {
kprintf("stack trace for thread 0x%lx \"%s\"\n", thread->id, thread->name); 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 <image>:function + offset\n"); kprintf("frame caller <image>:function + offset\n");
read_ebp(ebp);
for (;;) { for (;;) {
bool isIFrame = false; bool isIFrame = false;
// see if the ebp matches the iframe // see if the ebp matches the iframe