Compare commits

...

1 Commits

Author SHA1 Message Date
patchzyy 35673dda7e dump kamek overlay on crash 2026-10-22 20:09:28 +02:00
2 changed files with 19 additions and 11 deletions
+2 -1
View File
@@ -84,7 +84,8 @@ public:
// Crash-path helpers shared by the centralized reporter in main.cpp.
// DumpCrashHeuristics prints plain-language "likely cause" hints derived
// from the register state; WriteGuestMemorySnapshot writes MEM1 to
// `mem1Path` and MEM2 to `mem1Path + ".mem2"`, logging outcomes to `os`.
// `mem1Path`, MEM2 to `mem1Path + ".mem2"` and the Kamek overlay to
// `mem1Path + ".kamek"`, logging outcomes to `os`.
static void DumpCrashHeuristics(std::ostream& os, const struct CpuContext* cpu,
const uint32_t* missingGuestTarget);
static void WriteGuestMemorySnapshot(std::ostream& os, const std::filesystem::path& mem1Path);
+17 -10
View File
@@ -413,14 +413,18 @@ void SystemBridge::Initialize() {
}
void SystemBridge::WriteGuestMemorySnapshot(std::ostream& os, const std::filesystem::path& mem1Path) {
auto writeRegion = [&](const char* label, uint32_t base, uint32_t size,
const std::filesystem::path& path) {
std::ofstream dump(path, std::ios::binary | std::ios::trunc);
dump.write(reinterpret_cast<const char*>(Memory::GetPointer(base, size)), size);
os << "[runtime] " << label << " snapshot written to " << RuntimeConfigFile::PathToUtf8(path)
<< (dump.good() ? "" : " (write failed)") << std::endl;
};
constexpr uint32_t kMem1Base = 0x80000000u;
constexpr uint32_t kMem1Size = 0x01800000u;
if (Memory::Contains(kMem1Base, kMem1Size)) {
std::ofstream dump(mem1Path, std::ios::binary | std::ios::trunc);
dump.write(reinterpret_cast<const char*>(Memory::GetPointer(kMem1Base, kMem1Size)),
kMem1Size);
os << "[runtime] MEM1 snapshot written to " << RuntimeConfigFile::PathToUtf8(mem1Path)
<< (dump.good() ? "" : " (write failed)") << std::endl;
writeRegion("MEM1", kMem1Base, kMem1Size, mem1Path);
}
constexpr uint32_t kMem2Base = 0x90000000u;
for (uint32_t mem2Size : {0x08000000u, 0x04000000u}) {
@@ -429,13 +433,16 @@ void SystemBridge::WriteGuestMemorySnapshot(std::ostream& os, const std::filesys
}
std::filesystem::path mem2Path = mem1Path;
mem2Path += ".mem2";
std::ofstream dump(mem2Path, std::ios::binary | std::ios::trunc);
dump.write(reinterpret_cast<const char*>(Memory::GetPointer(kMem2Base, mem2Size)),
mem2Size);
os << "[runtime] MEM2 snapshot written to " << RuntimeConfigFile::PathToUtf8(mem2Path)
<< (dump.good() ? "" : " (write failed)") << std::endl;
writeRegion("MEM2", kMem2Base, mem2Size, mem2Path);
break;
}
constexpr uint32_t kKamekBase = 0x81800000u;
constexpr uint32_t kKamekSize = 0x00200000u;
if (Memory::Contains(kKamekBase, kKamekSize)) {
std::filesystem::path kamekPath = mem1Path;
kamekPath += ".kamek";
writeRegion("Kamek overlay", kKamekBase, kKamekSize, kamekPath);
}
}
void SystemBridge::DumpCrashHeuristics(std::ostream& os, const CpuContext* cpu,