feat: move CrashReport.cpp/hpp

This commit is contained in:
2026-04-08 07:45:51 +02:00
parent 9e04e51daa
commit 09d855aea7
4 changed files with 2 additions and 2 deletions
+21
View File
@@ -0,0 +1,21 @@
/*
* CrashReport.cpp
* Structured crash report implementation
* Copyright (c) 2026 Daniel Hammer
*/
#include "CrashReport.hpp"
namespace CrashReport {
Report g_reports[MaxReports];
int g_reportHead = 0;
int g_reportCount = 0;
void AddReport(const Report& report) {
g_reports[g_reportHead] = report;
g_reportHead = (g_reportHead + 1) % MaxReports;
if (g_reportCount < MaxReports) g_reportCount++;
}
} // namespace CrashReport
+50
View File
@@ -0,0 +1,50 @@
/*
* CrashReport.hpp
* Structured crash report for userspace process faults
* Copyright (c) 2026 Daniel Hammer
*/
#pragma once
#include <cstdint>
#include <cstddef>
namespace CrashReport {
static constexpr int MaxReports = 8;
struct Report {
int pid;
char processName[64];
uint8_t exceptionVector;
char exceptionName[32];
uint64_t faultingAddress;
uint64_t instructionPointer;
uint64_t stackPointer;
uint64_t codeSegment;
uint64_t flags;
uint64_t stackSegment;
// Page fault error code bits (vector 0xE / page fault only)
uint8_t pfPresent : 1;
uint8_t pfWrite : 1;
uint8_t pfUser : 1;
uint8_t pfReservedWrite : 1;
uint8_t pfInstructionFetch : 1;
uint8_t pfProtectionKey : 1;
uint8_t pfShadowStack : 1;
uint8_t pfSGX : 1;
uint64_t timestampTick;
bool valid;
};
// Kernel-side ring buffer (written by exception handlers, read by SYS_CRASH_REPORT)
extern Report g_reports[MaxReports];
extern int g_reportHead;
extern int g_reportCount;
// Add a report to the kernel ring buffer
void AddReport(const Report& report);
} // namespace CrashReport