summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--kernel/panic.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/kernel/panic.c b/kernel/panic.c
index e7eb330..65279f0 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -5,8 +5,22 @@
static int panicked = 0;
+void walk_stack(uintptr_t *addrs, size_t n);
+
+void stack_trace(void) {
+ kprintf("PRINTING STACK TRACE\n");
+ uintptr_t strace[32];
+ walk_stack(strace, 32);
+ for (int i = 0; i < 32; i++) {
+ if (strace[i] == 0)
+ break;
+ kprintf("#%d: %x\n", i, strace[i]);
+ }
+}
+
void panic(const char *str) {
- kprintf("KERNEL PANIC: %s\n", str);
panicked = 1;
+ kprintf("KERNEL PANIC: %s\n", str);
+ stack_trace();
while (1);
}