feat: add process crash popups
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
#include <CppLib/Stream.hpp>
|
||||
#include <Memory/PageFrameAllocator.hpp>
|
||||
#include <Sched/Scheduler.hpp>
|
||||
#include "CrashReport.hpp"
|
||||
#include <Timekeeping/ApicTimer.hpp>
|
||||
|
||||
namespace Hal {
|
||||
constexpr auto InterruptGate = 0x8E;
|
||||
@@ -87,6 +89,50 @@ namespace Hal {
|
||||
<< ExceptionStrings[i] << " in process \""
|
||||
<< proc->name << "\" (pid " << proc->pid
|
||||
<< ") - process terminated";
|
||||
|
||||
// Capture crash report
|
||||
CrashReport::Report rep;
|
||||
rep.valid = true;
|
||||
rep.pid = proc->pid;
|
||||
for (int j = 0; j < 64 && proc->name[j]; j++) rep.processName[j] = proc->name[j];
|
||||
rep.processName[63] = '\0';
|
||||
rep.exceptionVector = i;
|
||||
for (int j = 0; j < 32 && ExceptionStrings[i][j]; j++) rep.exceptionName[j] = ExceptionStrings[i][j];
|
||||
rep.exceptionName[31] = '\0';
|
||||
rep.instructionPointer = frame->IP;
|
||||
rep.codeSegment = frame->CS;
|
||||
rep.flags = frame->Flags;
|
||||
rep.stackPointer = frame->SP;
|
||||
rep.stackSegment = frame->SS;
|
||||
|
||||
if (i == 0x0E) {
|
||||
// Page fault: read CR2 for faulting address
|
||||
asm volatile("mov %%cr2, %0" : "=r"(rep.faultingAddress));
|
||||
auto* pf = (System::PageFaultPanicFrame*)frame;
|
||||
rep.pfPresent = pf->PageFaultError.Present;
|
||||
rep.pfWrite = pf->PageFaultError.Write;
|
||||
rep.pfUser = pf->PageFaultError.User;
|
||||
rep.pfReservedWrite = pf->PageFaultError.ReservedWrite;
|
||||
rep.pfInstructionFetch = pf->PageFaultError.InstructionFetch;
|
||||
rep.pfProtectionKey = pf->PageFaultError.ProtectionKey;
|
||||
rep.pfShadowStack = pf->PageFaultError.ShadowStack;
|
||||
rep.pfSGX = pf->PageFaultError.SGX;
|
||||
} else {
|
||||
rep.faultingAddress = 0;
|
||||
rep.pfPresent = 0;
|
||||
rep.pfWrite = 0;
|
||||
rep.pfUser = 0;
|
||||
rep.pfReservedWrite = 0;
|
||||
rep.pfInstructionFetch = 0;
|
||||
rep.pfProtectionKey = 0;
|
||||
rep.pfShadowStack = 0;
|
||||
rep.pfSGX = 0;
|
||||
}
|
||||
rep.timestampTick = Timekeeping::GetTicks();
|
||||
|
||||
CrashReport::AddReport(rep);
|
||||
Sched::SpawnCrashPad();
|
||||
|
||||
Sched::ExitProcess();
|
||||
__builtin_unreachable();
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user