From c29e0323020e0f96932d0f9b09747d5b2e28e5a6 Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Tue, 24 Nov 2020 16:41:49 -0700 Subject: Changes to painic. It now prints the stack at the time of failure (if logging is initialized). --- src/kern/panic.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/kern/panic.c') diff --git a/src/kern/panic.c b/src/kern/panic.c index 8708456..3e67b90 100644 --- a/src/kern/panic.c +++ b/src/kern/panic.c @@ -12,6 +12,8 @@ #ifdef ARCH_STM32L4 _Noreturn void panic(const char* fmt, ...) { + uint32_t base[0]; + disable_all_interrupts(); if (get_system_init_level() > INIT_LEVEL_2) { va_list l; @@ -19,6 +21,13 @@ _Noreturn void panic(const char* fmt, ...) kerr_logf("** Kernel Panic! **\n"); kerr_vlogf(fmt, l); + kerr_logf("** Stack:\n"); + + int i = 0; + for (; i < 20 && &base[i] != (void*)STACK_TOP; ++ i) { + kerr_logf(" (%p) %p\n", &base[i], base[i]); + } + set_system_clock_MHz(4); /* reduce power usage while we do nothing. */ for(;;); -- cgit