mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
DolphinQt: Properly lock CPU before accessing emulated memory
This fixes a problem I was having where using frame advance with the debugger open would frequently cause panic alerts about invalid addresses due to the CPU thread changing MSR.DR while the host thread was trying to access memory. To aid in tracking down all the places where we weren't properly locking the CPU, I've created a new type (in Core.h) that you have to pass as a reference or pointer to functions that require running as the CPU thread.
This commit is contained in:
@ -9,6 +9,11 @@
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class CPUThreadGuard;
|
||||
}
|
||||
|
||||
namespace Common::Debug
|
||||
{
|
||||
struct MemoryPatch
|
||||
@ -40,21 +45,21 @@ public:
|
||||
MemoryPatches();
|
||||
virtual ~MemoryPatches();
|
||||
|
||||
void SetPatch(u32 address, u32 value);
|
||||
void SetPatch(u32 address, std::vector<u8> value);
|
||||
void SetFramePatch(u32 address, u32 value);
|
||||
void SetFramePatch(u32 address, std::vector<u8> value);
|
||||
void SetPatch(const Core::CPUThreadGuard& guard, u32 address, u32 value);
|
||||
void SetPatch(const Core::CPUThreadGuard& guard, u32 address, std::vector<u8> value);
|
||||
void SetFramePatch(const Core::CPUThreadGuard& guard, u32 address, u32 value);
|
||||
void SetFramePatch(const Core::CPUThreadGuard& guard, u32 address, std::vector<u8> value);
|
||||
const std::vector<MemoryPatch>& GetPatches() const;
|
||||
void UnsetPatch(u32 address);
|
||||
void EnablePatch(std::size_t index);
|
||||
void DisablePatch(std::size_t index);
|
||||
void UnsetPatch(const Core::CPUThreadGuard& guard, u32 address);
|
||||
void EnablePatch(const Core::CPUThreadGuard& guard, std::size_t index);
|
||||
void DisablePatch(const Core::CPUThreadGuard& guard, std::size_t index);
|
||||
bool HasEnabledPatch(u32 address) const;
|
||||
void RemovePatch(std::size_t index);
|
||||
void ClearPatches();
|
||||
virtual void ApplyExistingPatch(std::size_t index) = 0;
|
||||
void RemovePatch(const Core::CPUThreadGuard& guard, std::size_t index);
|
||||
void ClearPatches(const Core::CPUThreadGuard& guard);
|
||||
virtual void ApplyExistingPatch(const Core::CPUThreadGuard& guard, std::size_t index) = 0;
|
||||
|
||||
protected:
|
||||
virtual void Patch(std::size_t index) = 0;
|
||||
virtual void Patch(const Core::CPUThreadGuard& guard, std::size_t index) = 0;
|
||||
virtual void UnPatch(std::size_t index) = 0;
|
||||
|
||||
std::vector<MemoryPatch> m_patches;
|
||||
|
Reference in New Issue
Block a user