mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-22 10:49:05 +02:00
Only the CPU thread runs IRInterpret, so it doesn't need to be thread-local. Volatile keeps the compiler from dropping or sinking the stores, which nothing but the fault handler reads. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
51 lines
1.7 KiB
C++
51 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
|
|
#include "Core/MIPS/MIPSStackWalk.h"
|
|
|
|
namespace Memory {
|
|
|
|
void MemFault_Init();
|
|
|
|
// Used by the hacky "Resume" button.
|
|
//
|
|
// TODO: Add a way to actually resume to the next instruction,
|
|
// rather than just jumping into the dispatcher again and hoping for the best. That will be
|
|
// a little tricky though, with per-backend work.
|
|
bool MemFault_MayBeResumable();
|
|
void MemFault_IgnoreLastCrash();
|
|
|
|
// Called by exception handlers. We simply filter out accesses to PSP RAM and otherwise
|
|
// just leave it as-is.
|
|
bool HandleFault(uintptr_t hostAddress, void *context);
|
|
|
|
// Set while IRInterpret runs its own loads and stores. A fault in those can be stepped over, which the
|
|
// IR interpreter does to halt cleanly instead of crashing. Only the CPU thread runs it.
|
|
extern volatile bool g_inIRInterpreter;
|
|
|
|
class IRInterpreterFaultScope {
|
|
public:
|
|
explicit IRInterpreterFaultScope(bool inInterpreter) : prev_(g_inIRInterpreter) {
|
|
g_inIRInterpreter = inInterpreter;
|
|
}
|
|
~IRInterpreterFaultScope() {
|
|
g_inIRInterpreter = prev_;
|
|
}
|
|
|
|
private:
|
|
bool prev_;
|
|
};
|
|
|
|
}
|
|
|
|
// Stack walk utility function, walks from the current state. Useful in the debugger and crash report screens etc.
|
|
// Doesn't exactly belong here maybe, but can think of worse locations.
|
|
// threadID can be -1 for current.
|
|
// startPC of 0 means "wherever the CPU is now". Pass one explicitly when the current pc is the
|
|
// problem - a jump to a bad address leaves it pointing at nothing walkable, and starting from ra
|
|
// instead still recovers the callers.
|
|
std::vector<MIPSStackWalk::StackFrame> WalkCurrentStack(int threadID, uint32_t startPC = 0);
|
|
|
|
std::string FormatStackTrace(const std::vector<MIPSStackWalk::StackFrame> &frames);
|