Hook crash handler up against kernel debugger.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-06-01 22:58:38 +02:00
parent 5d1fe2620b
commit 7c3740a85d
1 changed files with 8 additions and 0 deletions

View File

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