mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Added a friendly message on panic, and SIGSEGV no longer panics.
This commit is contained in:
parent
8a085f6fa0
commit
1a2446fca6
2 changed files with 32 additions and 3 deletions
|
@ -10,6 +10,11 @@
|
|||
#include "isr.h"
|
||||
#include "panic.h"
|
||||
|
||||
#include "process.h" // Hack for SIGSEGV
|
||||
#include "sound.h" // Hack for SIGSEGV
|
||||
|
||||
using namespace Sortix;
|
||||
|
||||
size_t numknownexceptions = 19;
|
||||
const char* exceptions[] = { "Divide by zero", "Debug", "Non maskable interrupt", "Breakpoint",
|
||||
"Into detected overflow", "Out of bounds", "Invalid opcode",
|
||||
|
@ -31,10 +36,26 @@ const char* exceptions[] = { "Divide by zero", "Debug", "Non maskable interrupt"
|
|||
#ifdef PLATFORM_X86
|
||||
if ( Regs->int_no < 32 )
|
||||
{
|
||||
const char* message = ( Regs->int_no < numknownexceptions ) ? exceptions[Regs->int_no] : "Unknown";
|
||||
//Sortix::Log::PrintF("eax=0x%x\tebx=0x%x\tecx=0x%x\tedx=0x%x\tesi=0x%x\tedi=0x%x\tesp=0x%x\tuseresp=0x%x\tebp=0x%x\teip=0x%x\n", Regs->eax, Regs->ebx, Regs->ecx, Regs->edx, Regs->esi, Regs->edi, Regs->esp, Regs->useresp, Regs->ebp, Regs->eip);
|
||||
const char* message = ( Regs->int_no < numknownexceptions )
|
||||
? exceptions[Regs->int_no] : "Unknown";
|
||||
|
||||
Sortix::PanicF("Unhandled CPU Exception id %zu '%s' at eip=0x%zx (cr2=0x%p, err_code=0x%p)", Regs->int_no, message, Regs->eip, Regs->cr2, Regs->err_code);
|
||||
// Halt and catch fire if we are the kernel.
|
||||
if ( (Regs->cs & (0x4-1)) == 0 )
|
||||
{
|
||||
PanicF("Unhandled CPU Exception id %zu '%s' at eip=0x%zx "
|
||||
"(cr2=0x%p, err_code=0x%p)", Regs->int_no, message,
|
||||
Regs->eip, Regs->cr2, Regs->err_code);
|
||||
}
|
||||
|
||||
Log::Print("The current program has crashed and was terminated:\n");
|
||||
Log::PrintF("%s exception at eip=0x%zx (cr2=0x%p, err_code=0x%p)\n",
|
||||
message, Regs->eip, Regs->cr2, Regs->err_code);
|
||||
|
||||
Sound::Mute();
|
||||
const char* programname = "sh";
|
||||
Regs->ebx = (uint32_t) programname;
|
||||
SysExecute(Regs);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( interrupt_handlers[Regs->int_no] != NULL )
|
||||
|
|
|
@ -32,7 +32,11 @@ using namespace Maxsi;
|
|||
|
||||
namespace Sortix
|
||||
{
|
||||
#if defined(DEBUG) || defined(PANIC_LONG)
|
||||
bool longpanic = false;
|
||||
#else
|
||||
bool longpanic = true;
|
||||
#endif
|
||||
|
||||
void PanicInit()
|
||||
{
|
||||
|
@ -57,6 +61,10 @@ namespace Sortix
|
|||
Log::Print(" \n");
|
||||
Log::Print(" RED MAXSI OF DEATH \n");
|
||||
Log::Print(" \n");
|
||||
Log::Print("A critical error occured within the kernel of the operating system and it has\n");
|
||||
Log::Print("forcefully shut down as a last resort.\n");
|
||||
Log::Print("\n");
|
||||
Log::Print("Technical information:\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue