Headless (and main): Improve crash reporting

This commit is contained in:
Henrik Rydgård committed 2026-08-11 22:36:47 +02:00
1 parent 22ac7ad119
commit 2d0e54f422
11 files changed
+79 -42

No files matched your search

+18 -6
View File
@@ -665,13 +665,25 @@ static std::string ModuleAddressSuffix(u32 address) {
void Core_MemoryException(u32 address, u32 accessSize, u32 pc, MemoryExceptionType type, std::string_view additionalInfo) {
// In jit, we only flush PC when bIgnoreBadMemAccess is off.
char pcDetails[128];
pcDetails[0] = 0;
if ((CPUCore)g_Config.iCpuCore == CPUCore::INTERPRETER) {
snprintf(pcDetails, sizeof(pcDetails), " PC %08x%s RA %08x%s",
pc, ModuleAddressSuffix(pc).c_str(),
switch ((CPUCore)g_Config.iCpuCore) {
case CPUCore::INTERPRETER:
snprintf(pcDetails, sizeof(pcDetails), "Interpreter: PC %08x%s RA %08x%s",
currentMIPS->pc, ModuleAddressSuffix(currentMIPS->pc).c_str(),
currentMIPS->r[MIPS_REG_RA], ModuleAddressSuffix(currentMIPS->r[MIPS_REG_RA]).c_str());
break;
case CPUCore::JIT:
snprintf(pcDetails, sizeof(pcDetails), "JIT: (PC approximate)=%08x%s", pc, ModuleAddressSuffix(pc).c_str());
break;
case CPUCore::JIT_IR:
snprintf(pcDetails, sizeof(pcDetails), "JIT_IR: (PC approximate)=%08x%s", pc, ModuleAddressSuffix(pc).c_str());
break;
case CPUCore::IR_INTERPRETER:
snprintf(pcDetails, sizeof(pcDetails), "IR_INTERPRETER: (PC approximate)=%08x%s", pc, ModuleAddressSuffix(pc).c_str());
break;
default:
break;
}
const std::string addressSuffix = ModuleAddressSuffix(address);
@@ -691,14 +703,14 @@ void Core_MemoryException(u32 address, u32 accessSize, u32 pc, MemoryExceptionTy
const char *desc = MemoryExceptionTypeAsString(type);
char msg[512];
snprintf(msg, sizeof(msg), "%s: SIGSEGV pc=%08x%s (size %08x) %sHost:%.*s", desc, address, addressSuffix.c_str(), accessSize, pcDetails, STR_VIEW(additionalInfo));
snprintf(msg, sizeof(msg), "%s: SIGSEGV at %08x%s (size: %d bytes) %s\nHost:%.*s", desc, address, addressSuffix.c_str(), accessSize, pcDetails, STR_VIEW(additionalInfo));
if (action == ExceptionAction::Ignore) {
Core_SendDebugOutput(LogLevel::LWARNING, msg);
return;
}
const std::string stackTrace = FormatStackTrace(WalkCurrentStack(-1));
// Do the most detailed logging we can.
Core_SendDebugOutput(LogLevel::LERROR, StringFromFormat("%sCall stack:\n%s", msg, stackTrace.c_str()));
Core_SendDebugOutput(LogLevel::LERROR, StringFromFormat("%sMIPS call stack:\n%s", msg, stackTrace.c_str()));
if (action == ExceptionAction::Break) {
MIPSExceptionInfo &e = g_exceptionInfo;
e = {};