diff --git a/sortix/interrupt.cpp b/sortix/interrupt.cpp index 27e29c2d..e009a745 100644 --- a/sortix/interrupt.cpp +++ b/sortix/interrupt.cpp @@ -27,8 +27,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -64,6 +66,7 @@ const bool DEBUG_IRQ = false; const bool DEBUG_ISR = false; const bool CALLTRACE_KERNEL = false; const bool CALLTRACE_USER = false; +const bool RUN_DEBUGGER_ON_CRASH = false; bool initialized; const size_t NUM_KNOWN_EXCEPTIONS = 20; @@ -220,6 +223,8 @@ void RegisterRawHandler(unsigned index, RawHandler handler, bool userspace) void CrashHandler(CPU::InterruptRegisters* regs) { + CurrentThread()->SaveRegisters(regs); + const char* message = ( regs->int_no < NUM_KNOWN_EXCEPTIONS ) ? exceptions[regs->int_no] : "Unknown"; @@ -245,6 +250,9 @@ void CrashHandler(CPU::InterruptRegisters* regs) #error Please provide a calltrace implementation for your CPU. #endif + if ( RUN_DEBUGGER_ON_CRASH ) + Debugger::Run(); + if ( is_in_kernel ) { PanicF("Unhandled CPU Exception id %zu '%s' at ip=0x%zx "