diff options
| author | JosJuice <josjuice@gmail.com> | 2023-02-12 11:07:11 +0100 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2023-02-12 11:27:50 +0100 |
| commit | 7cecb28bdf6443362a6ab20e0042ddb3b407ebec (patch) | |
| tree | 710c9afcd7296dbc9591ac42ec6da81ba2daa2b6 /Source/Core/Common/Debug/CodeTrace.cpp | |
| parent | efed037c4af882171237b70f47e50359bc5260da (diff) | |
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.
Diffstat (limited to 'Source/Core/Common/Debug/CodeTrace.cpp')
| -rw-r--r-- | Source/Core/Common/Debug/CodeTrace.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Source/Core/Common/Debug/CodeTrace.cpp b/Source/Core/Common/Debug/CodeTrace.cpp index 65b7826770..3023923fbb 100644 --- a/Source/Core/Common/Debug/CodeTrace.cpp +++ b/Source/Core/Common/Debug/CodeTrace.cpp @@ -122,14 +122,14 @@ InstructionAttributes CodeTrace::GetInstructionAttributes(const TraceOutput& ins return tmp_attributes; } -TraceOutput CodeTrace::SaveCurrentInstruction() const +TraceOutput CodeTrace::SaveCurrentInstruction(const Core::CPUThreadGuard* guard) const { auto& system = Core::System::GetInstance(); auto& ppc_state = system.GetPPCState(); // Quickly save instruction and memory target for fast logging. TraceOutput output; - const std::string instr = PowerPC::debug_interface.Disassemble(ppc_state.pc); + const std::string instr = PowerPC::debug_interface.Disassemble(guard, ppc_state.pc); output.instruction = instr; output.address = ppc_state.pc; @@ -139,14 +139,15 @@ TraceOutput CodeTrace::SaveCurrentInstruction() const return output; } -AutoStepResults CodeTrace::AutoStepping(bool continue_previous, AutoStop stop_on) +AutoStepResults CodeTrace::AutoStepping(const Core::CPUThreadGuard& guard, bool continue_previous, + AutoStop stop_on) { AutoStepResults results; - if (!CPU::IsStepping() || m_recording) + if (m_recording) return results; - TraceOutput pc_instr = SaveCurrentInstruction(); + TraceOutput pc_instr = SaveCurrentInstruction(&guard); const InstructionAttributes instr = GetInstructionAttributes(pc_instr); // Not an instruction we should start autostepping from (ie branches). @@ -187,7 +188,6 @@ AutoStepResults CodeTrace::AutoStepping(bool continue_previous, AutoStop stop_on else if (stop_on == AutoStop::Changed) stop_condition = HitType::ACTIVE; - CPU::PauseAndLock(true, false); PowerPC::breakpoints.ClearAllTemporary(); using clock = std::chrono::steady_clock; clock::time_point timeout = clock::now() + std::chrono::seconds(4); @@ -199,7 +199,7 @@ AutoStepResults CodeTrace::AutoStepping(bool continue_previous, AutoStop stop_on { PowerPC::SingleStep(); - pc_instr = SaveCurrentInstruction(); + pc_instr = SaveCurrentInstruction(&guard); hit = TraceLogic(pc_instr); results.count += 1; } while (clock::now() < timeout && hit < stop_condition && @@ -210,7 +210,6 @@ AutoStepResults CodeTrace::AutoStepping(bool continue_previous, AutoStop stop_on results.timed_out = true; PowerPC::SetMode(old_mode); - CPU::PauseAndLock(false, false); m_recording = false; results.reg_tracked = m_reg_autotrack; |
