From 7cecb28bdf6443362a6ab20e0042ddb3b407ebec Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 12 Feb 2023 11:07:11 +0100 Subject: 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. --- Source/Core/Common/Debug/CodeTrace.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'Source/Core/Common/Debug/CodeTrace.h') diff --git a/Source/Core/Common/Debug/CodeTrace.h b/Source/Core/Common/Debug/CodeTrace.h index 4f2cb701f2..15ba67036b 100644 --- a/Source/Core/Common/Debug/CodeTrace.h +++ b/Source/Core/Common/Debug/CodeTrace.h @@ -10,6 +10,11 @@ #include "Common/CommonTypes.h" +namespace Core +{ +class CPUThreadGuard; +} + struct InstructionAttributes { u32 address = 0; @@ -63,11 +68,12 @@ public: }; void SetRegTracked(const std::string& reg); - AutoStepResults AutoStepping(bool continue_previous = false, AutoStop stop_on = AutoStop::Always); + AutoStepResults AutoStepping(const Core::CPUThreadGuard& guard, bool continue_previous = false, + AutoStop stop_on = AutoStop::Always); private: InstructionAttributes GetInstructionAttributes(const TraceOutput& line) const; - TraceOutput SaveCurrentInstruction() const; + TraceOutput SaveCurrentInstruction(const Core::CPUThreadGuard* guard) const; HitType TraceLogic(const TraceOutput& current_instr, bool first_hit = false); bool m_recording = false; -- cgit v1.2.3