feat: add crash stack snapshots and context menu annotations

This commit is contained in:
2026-08-12 18:30:08 +02:00
parent 3ef98a9fd5
commit 7f2d4b693f
8 changed files with 71 additions and 1 deletions
+1 -1
View File
@@ -12,4 +12,4 @@
#pragma once
#define MONTAUK_BUILD_NUMBER 106
#define MONTAUK_BUILD_NUMBER 108
+3
View File
@@ -34,6 +34,9 @@ namespace montauk::abi {
out->codeSegment = rep.codeSegment;
out->flags = rep.flags;
out->stackSegment = rep.stackSegment;
out->stackWordCount = rep.stackWordCount;
for (int i = 0; i < rep.stackWordCount && i < CrashReport::StackSnapshotWords; i++)
out->stackWords[i] = rep.stackWords[i];
out->pfPresent = rep.pfPresent;
out->pfWrite = rep.pfWrite;
out->pfUser = rep.pfUser;
+2
View File
@@ -780,6 +780,8 @@ namespace montauk::abi {
uint64_t codeSegment;
uint64_t flags;
uint64_t stackSegment;
uint64_t stackWords[8];
uint8_t stackWordCount;
uint8_t pfPresent : 1;
uint8_t pfWrite : 1;
uint8_t pfUser : 1;
+15
View File
@@ -127,6 +127,21 @@ namespace Hal {
rep.stackPointer = regs->SP;
rep.stackSegment = regs->SS;
// An indirect CALL pushes its real continuation address before a
// bad target faults on instruction fetch. Preserve a small stack
// snapshot while the dying process address space is still active;
// stackWords[0] will usually identify the caller even when RIP is
// corrupted data and cannot itself be symbolicated.
constexpr uint64_t snapshotBytes =
CrashReport::StackSnapshotWords * sizeof(uint64_t);
if (Memory::VMM::Paging::IsUserRangeAccessible(
proc->pml4Phys, regs->SP, snapshotBytes, false)) {
auto* userStack = (const volatile uint64_t*)regs->SP;
for (int word = 0; word < CrashReport::StackSnapshotWords; word++)
rep.stackWords[word] = userStack[word];
rep.stackWordCount = CrashReport::StackSnapshotWords;
}
if (i == 0x0E) {
// Page fault: read CR2 for faulting address
asm volatile("mov %%cr2, %0" : "=r"(rep.faultingAddress));
+3
View File
@@ -11,6 +11,7 @@
namespace CrashReport {
static constexpr int MaxReports = 8;
static constexpr int StackSnapshotWords = 8;
struct Report {
int pid;
@@ -24,6 +25,8 @@ struct Report {
uint64_t codeSegment;
uint64_t flags;
uint64_t stackSegment;
uint64_t stackWords[StackSnapshotWords];
uint8_t stackWordCount;
// Page fault error code bits (vector 0xE / page fault only)
uint8_t pfPresent : 1;