Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory exception handler: Don't disassemble if ignoring the exception #18823

Merged
merged 1 commit into from
Feb 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions Core/MemFault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,6 @@ bool HandleFault(uintptr_t hostAddress, void *ctx) {

MemoryExceptionType type = MemoryExceptionType::NONE;

std::string infoString = "";

bool isAtDispatch = false;
if (MIPSComp::jit) {
std::string desc;
if (MIPSComp::jit->DescribeCodePtr(codePtr, desc)) {
infoString += desc + "\n";
}
if (MIPSComp::jit->IsAtDispatchFetch(codePtr)) {
isAtDispatch = true;
}
}

int instructionSize = 4;
#if PPSSPP_ARCH(AMD64) || PPSSPP_ARCH(X86)
// X86, X86-64. Variable instruction size so need to analyze the mov instruction in detail.
Expand Down Expand Up @@ -251,12 +238,7 @@ bool HandleFault(uintptr_t hostAddress, void *ctx) {
}
#endif

std::string disassembly;
if (DisassembleNativeAt(codePtr, instructionSize, &disassembly)) {
infoString += disassembly + "\n";
}

if (isAtDispatch) {
if (MIPSComp::jit && MIPSComp::jit->IsAtDispatchFetch(codePtr)) {
u32 targetAddr = currentMIPS->pc; // bad approximation
// TODO: Do the other archs and platforms.
#if PPSSPP_ARCH(AMD64) && PPSSPP_PLATFORM(WINDOWS)
Expand Down Expand Up @@ -299,6 +281,16 @@ bool HandleFault(uintptr_t hostAddress, void *ctx) {
ERROR_LOG(MEMMAP, "Bad memory access detected and ignored: %08x (%p)", guestAddress, (void *)hostAddress);
}
} else {
std::string infoString = "";
std::string temp;
if (MIPSComp::jit && MIPSComp::jit->DescribeCodePtr(codePtr, temp)) {
infoString += temp + "\n";
}
temp.clear();
if (DisassembleNativeAt(codePtr, instructionSize, &temp)) {
infoString += temp + "\n";
}

// Either bIgnoreBadMemAccess is off, or we failed recovery analysis.
// We can't ignore this memory access.
uint32_t approximatePC = currentMIPS->pc;
Expand Down
Loading