Code: Select all
void kstrace(int depth) {
unsigned int *ebp = &depth - 2;
printf("Stack trace:\n");
for (unsigned int frame = 0; frame < depth; ++frame) {
unsigned int eip = ebp[1];
if (eip == 0)
break;
ebp = (unsigned int *)(ebp[0]);
unsigned int *arguments = &ebp[2];
printf(" %02X\n", eip);
}
}
If I use GDB, I can see what's going on:
Code: Select all
Remote debugging using :1234
k_main (mboot=0x10000) at src/kernel/kernel.c:104
104 kstrace(10);
(gdb) continue
Continuing.
Program received signal SIGSEGV, Segmentation fault.
0x0010472e in kstrace (depth=10) at src/libk/stdlib.c:126
126 unsigned int eip = ebp[1];
(gdb) stop
(gdb) backtrace
#0 0x0010373e in kstrace (depth=10) at src/libk/stdlib.c:126
#1 0x0010310d in k_main (mboot=0x10000) at src/kernel/kernel.c:104
#2 0x00104d14 in start ()
(gdb)
Code: Select all
Stack trace:
0x0010310D
0x00104D14
0xF000FF53
(Page Fault)
If you need a register dump, let me know.
I don't know what I need to do here, so that's why I'm asking for help. Thanks in advance!