UI: Show return address for exec crashes.

This commit is contained in:
Unknown W. Brackets 2022-08-21 14:09:52 -07:00
parent 80e481bbdc
commit 8e7847f6d9
5 changed files with 22 additions and 9 deletions

View File

@ -487,16 +487,19 @@ void Core_ExecException(u32 address, u32 pc, ExecExceptionType type) {
e.exec_type = type;
e.address = address;
e.pc = pc;
Core_EnableStepping(true, "cpu.exception", pc);
// This just records the closest value that could be useful as reference.
e.ra = currentMIPS->r[MIPS_REG_RA];
Core_EnableStepping(true, "cpu.exception", address);
}
void Core_Break() {
void Core_Break(u32 pc) {
ERROR_LOG(CPU, "BREAK!");
ExceptionInfo &e = g_exceptionInfo;
e = {};
e.type = ExceptionType::BREAK;
e.info = "";
e.pc = pc;
if (!g_Config.bIgnoreBadMemAccess) {
Core_EnableStepping(true, "cpu.breakInstruction", currentMIPS->pc);

View File

@ -106,7 +106,7 @@ void Core_MemoryException(u32 address, u32 pc, MemoryExceptionType type);
void Core_MemoryExceptionInfo(u32 address, u32 pc, MemoryExceptionType type, std::string additionalInfo);
void Core_ExecException(u32 address, u32 pc, ExecExceptionType type);
void Core_Break();
void Core_Break(u32 pc);
// Call when loading save states, etc.
void Core_ResetException();
@ -125,6 +125,7 @@ struct ExceptionInfo {
MemoryExceptionType memory_type;
uint32_t pc;
uint32_t address;
uint32_t ra = 0;
// Reuses pc and address from memory type, where address is the failed destination.
ExecExceptionType exec_type;

View File

@ -998,7 +998,7 @@ u32 IRInterpret(MIPSState *mips, const IRInst *inst, int count) {
}
case IROp::Break:
Core_Break();
Core_Break(mips->pc);
return mips->pc + 4;
case IROp::SetCtrlVFPU:

View File

@ -157,7 +157,7 @@ namespace MIPSInt
void Int_Break(MIPSOpcode op)
{
Reporting::ReportMessage("BREAK instruction hit");
Core_Break();
Core_Break(PC);
PC += 4;
}

View File

@ -1209,16 +1209,25 @@ PC: %08x
} else if (info.type == ExceptionType::BAD_EXEC_ADDR) {
snprintf(statbuf, sizeof(statbuf), R"(
Destination: %s to %08x
PC: %08x)",
PC: %08x
RA: %08x)",
ExecExceptionTypeAsString(info.exec_type),
info.address,
info.pc);
info.pc,
info.ra);
ctx->Draw()->DrawTextShadow(ubuntu24, statbuf, x, y, 0xFFFFFFFF);
y += 180;
} else if (info.type == ExceptionType::BREAK) {
snprintf(statbuf, sizeof(statbuf), R"(
BREAK
PC: %08x
)", info.pc);
ctx->Draw()->DrawTextShadow(ubuntu24, statbuf, x, y, 0xFFFFFFFF);
y += 180;
} else {
snprintf(statbuf, sizeof(statbuf), R"(
BREAK
)");
Invalid / Unknown (%d)
)", (int)info.type);
ctx->Draw()->DrawTextShadow(ubuntu24, statbuf, x, y, 0xFFFFFFFF);
y += 180;
}