diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index a5af1d2867..31f781c803 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -170,7 +170,7 @@ void OnFrameEnd() if (s_memory_watcher) { ASSERT(IsCPUThread()); - CPUThreadGuard guard; + CPUThreadGuard guard(Core::System::GetInstance()); s_memory_watcher->Step(guard); } @@ -533,7 +533,7 @@ static void EmuThread(std::unique_ptr boot, WindowSystemInfo wsi HW::Init(NetPlay::IsNetPlayRunning() ? &(boot_session_data.GetNetplaySettings()->sram) : nullptr); - Common::ScopeGuard hw_guard{[] { + Common::ScopeGuard hw_guard{[&system] { // We must set up this flag before executing HW::Shutdown() s_hardware_initialized = false; INFO_LOG_FMT(CONSOLE, "{}", StopMessage(false, "Shutting down HW")); @@ -550,7 +550,7 @@ static void EmuThread(std::unique_ptr boot, WindowSystemInfo wsi PatchEngine::Shutdown(); HLE::Clear(); - CPUThreadGuard guard; + CPUThreadGuard guard(system); PowerPC::debug_interface.Clear(guard); }}; @@ -603,7 +603,7 @@ static void EmuThread(std::unique_ptr boot, WindowSystemInfo wsi { ASSERT(IsCPUThread()); - CPUThreadGuard guard; + CPUThreadGuard guard(system); if (!CBoot::BootUp(system, guard, std::move(boot))) return; } @@ -1058,16 +1058,17 @@ void UpdateInputGate(bool require_focus, bool require_full_focus) ControlReference::SetInputGate(focus_passes && full_focus_passes); } -CPUThreadGuard::CPUThreadGuard() : m_was_cpu_thread(IsCPUThread()) +CPUThreadGuard::CPUThreadGuard(Core::System& system) + : m_system(system), m_was_cpu_thread(IsCPUThread()) { if (!m_was_cpu_thread) - m_was_unpaused = PauseAndLock(Core::System::GetInstance(), true, true); + m_was_unpaused = PauseAndLock(system, true, true); } CPUThreadGuard::~CPUThreadGuard() { if (!m_was_cpu_thread) - PauseAndLock(Core::System::GetInstance(), false, m_was_unpaused); + PauseAndLock(m_system, false, m_was_unpaused); } } // namespace Core diff --git a/Source/Core/Core/Core.h b/Source/Core/Core/Core.h index 2308848750..4dd0f7e32e 100644 --- a/Source/Core/Core/Core.h +++ b/Source/Core/Core/Core.h @@ -108,7 +108,7 @@ enum class ConsoleType : u32 class CPUThreadGuard final { public: - CPUThreadGuard(); + explicit CPUThreadGuard(Core::System& system); ~CPUThreadGuard(); CPUThreadGuard(const CPUThreadGuard&) = delete; @@ -117,6 +117,7 @@ public: CPUThreadGuard& operator=(CPUThreadGuard&&) = delete; private: + Core::System& m_system; const bool m_was_cpu_thread; bool m_was_unpaused = false; }; diff --git a/Source/Core/Core/HLE/HLE.cpp b/Source/Core/Core/HLE/HLE.cpp index 956535571c..6728160ae7 100644 --- a/Source/Core/Core/HLE/HLE.cpp +++ b/Source/Core/Core/HLE/HLE.cpp @@ -169,7 +169,7 @@ void Execute(const Core::CPUThreadGuard& guard, u32 current_pc, u32 hook_index) void ExecuteFromJIT(u32 current_pc, u32 hook_index) { ASSERT(Core::IsCPUThread()); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); Execute(guard, current_pc, hook_index); } diff --git a/Source/Core/Core/IOS/IOS.cpp b/Source/Core/Core/IOS/IOS.cpp index 83851ed4f3..3f17ababf7 100644 --- a/Source/Core/Core/IOS/IOS.cpp +++ b/Source/Core/Core/IOS/IOS.cpp @@ -914,7 +914,7 @@ static void FinishPPCBootstrap(Core::System& system, u64 userdata, s64 cycles_la ReleasePPC(); ASSERT(Core::IsCPUThread()); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(system); SConfig::OnNewTitleLoad(guard); INFO_LOG_FMT(IOS, "Bootstrapping done."); diff --git a/Source/Core/Core/IOS/MIOS.cpp b/Source/Core/Core/IOS/MIOS.cpp index d4820e2c43..037e871f08 100644 --- a/Source/Core/Core/IOS/MIOS.cpp +++ b/Source/Core/Core/IOS/MIOS.cpp @@ -61,7 +61,7 @@ bool Load() auto& memory = system.GetMemory(); ASSERT(Core::IsCPUThread()); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(system); memory.Write_U32(0x00000000, ADDRESS_INIT_SEMAPHORE); memory.Write_U32(0x09142001, 0x3180); diff --git a/Source/Core/Core/PatchEngine.cpp b/Source/Core/Core/PatchEngine.cpp index 0d736503a3..4f4f9b9090 100644 --- a/Source/Core/Core/PatchEngine.cpp +++ b/Source/Core/Core/PatchEngine.cpp @@ -322,7 +322,7 @@ bool ApplyFramePatches() auto& ppc_state = system.GetPPCState(); ASSERT(Core::IsCPUThread()); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(system); // Because we're using the VI Interrupt to time this instead of patching the game with a // callback hook we can end up catching the game in an exception vector. diff --git a/Source/Core/Core/PowerPC/Expression.cpp b/Source/Core/Core/PowerPC/Expression.cpp index 6da5188e86..597c77c985 100644 --- a/Source/Core/Core/PowerPC/Expression.cpp +++ b/Source/Core/Core/PowerPC/Expression.cpp @@ -83,7 +83,7 @@ static double HostReadFunc(expr_func* f, vec_expr_t* args, void* c) return 0; const u32 address = static_cast(expr_eval(&vec_nth(args, 0))); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); return Common::BitCast(HostRead(guard, address)); } @@ -95,7 +95,7 @@ static double HostWriteFunc(expr_func* f, vec_expr_t* args, void* c) const T var = static_cast(expr_eval(&vec_nth(args, 0))); const u32 address = static_cast(expr_eval(&vec_nth(args, 1))); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); HostWrite(guard, Common::BitCast(var), address); return var; } @@ -115,8 +115,9 @@ static double CallstackFunc(expr_func* f, vec_expr_t* args, void* c) std::vector stack; { - Core::CPUThreadGuard guard; - bool success = Dolphin_Debugger::GetCallstack(Core::System::GetInstance(), guard, stack); + auto& system = Core::System::GetInstance(); + Core::CPUThreadGuard guard(system); + bool success = Dolphin_Debugger::GetCallstack(system, guard, stack); if (!success) return 0; } @@ -163,7 +164,7 @@ static double StreqFunc(expr_func* f, vec_expr_t* args, void* c) return 0; std::array strs; - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); for (int i = 0; i < 2; i++) { std::optional arg = ReadStringArg(guard, &vec_nth(args, i)); diff --git a/Source/Core/Core/PowerPC/GDBStub.cpp b/Source/Core/Core/PowerPC/GDBStub.cpp index b07c1aaf71..94d3e2e060 100644 --- a/Source/Core/Core/PowerPC/GDBStub.cpp +++ b/Source/Core/Core/PowerPC/GDBStub.cpp @@ -997,7 +997,7 @@ void ProcessCommands(bool loop_until_continue) case 'm': { ASSERT(Core::IsCPUThread()); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(system); ReadMemory(guard); break; @@ -1005,7 +1005,7 @@ void ProcessCommands(bool loop_until_continue) case 'M': { ASSERT(Core::IsCPUThread()); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(system); WriteMemory(guard); auto& ppc_state = system.GetPPCState(); diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp index aba7c31ab5..7f91883bb1 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp @@ -343,7 +343,7 @@ void Interpreter::unknown_instruction(UGeckoInstruction inst) { ASSERT(Core::IsCPUThread()); auto& system = Core::System::GetInstance(); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(system); const u32 opcode = PowerPC::HostRead_U32(guard, last_pc); const std::string disasm = Common::GekkoDisassembler::Disassemble(opcode, last_pc); diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp index 2a881301e0..39c1165a5c 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_Branch.cpp @@ -10,6 +10,7 @@ #include "Core/HLE/HLE.h" #include "Core/PowerPC/Interpreter/ExceptionUtils.h" #include "Core/PowerPC/PowerPC.h" +#include "Core/System.h" void Interpreter::bx(UGeckoInstruction inst) { @@ -98,7 +99,7 @@ void Interpreter::HLEFunction(UGeckoInstruction inst) m_end_block = true; ASSERT(Core::IsCPUThread()); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); HLE::Execute(guard, PowerPC::ppcState.pc, inst.hex); } diff --git a/Source/Core/Core/PowerPC/JitInterface.cpp b/Source/Core/Core/PowerPC/JitInterface.cpp index 5b1d7a1f9c..d19e3fd442 100644 --- a/Source/Core/Core/PowerPC/JitInterface.cpp +++ b/Source/Core/Core/PowerPC/JitInterface.cpp @@ -30,6 +30,7 @@ #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/Profiler.h" +#include "Core/System.h" #if _M_X86 #include "Core/PowerPC/Jit64/Jit.h" @@ -273,7 +274,7 @@ void CompileExceptionCheck(ExceptionType type) if (type == ExceptionType::FIFOWrite) { ASSERT(Core::IsCPUThread()); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); // Check in case the code has been replaced since: do we need to do this? const OpType optype = diff --git a/Source/Core/DolphinQt/CheatSearchWidget.cpp b/Source/Core/DolphinQt/CheatSearchWidget.cpp index 3ff88f3c08..1f9d226601 100644 --- a/Source/Core/DolphinQt/CheatSearchWidget.cpp +++ b/Source/Core/DolphinQt/CheatSearchWidget.cpp @@ -37,6 +37,7 @@ #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/PowerPC/PowerPC.h" +#include "Core/System.h" #include "DolphinQt/Config/CheatCodeEditor.h" #include "DolphinQt/Config/CheatWarningWidget.h" @@ -288,7 +289,7 @@ void CheatSearchWidget::OnNextScanClicked() } const Cheats::SearchErrorCode error_code = [this] { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); return m_session->RunSearch(guard); }(); @@ -397,7 +398,7 @@ bool CheatSearchWidget::RefreshValues() tmp->SetFilterType(Cheats::FilterType::DoNotFilter); const Cheats::SearchErrorCode error_code = [&tmp] { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); return tmp->RunSearch(guard); }(); diff --git a/Source/Core/DolphinQt/Debugger/CodeDiffDialog.cpp b/Source/Core/DolphinQt/Debugger/CodeDiffDialog.cpp index a3d1ddec26..1be7d8c785 100644 --- a/Source/Core/DolphinQt/Debugger/CodeDiffDialog.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeDiffDialog.cpp @@ -23,6 +23,7 @@ #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" #include "Core/PowerPC/Profiler.h" +#include "Core/System.h" #include "DolphinQt/Debugger/CodeWidget.h" #include "DolphinQt/Host.h" @@ -485,7 +486,7 @@ void CodeDiffDialog::OnSetBLR() return; { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); PowerPC::debug_interface.SetPatch(guard, symbol->address, 0x4E800020); } diff --git a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp index 218350e568..e4073fb16a 100644 --- a/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp @@ -33,6 +33,7 @@ #include "Core/PowerPC/PPCAnalyst.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" +#include "Core/System.h" #include "DolphinQt/Debugger/PatchInstructionDialog.h" #include "DolphinQt/Host.h" #include "DolphinQt/Resources.h" @@ -258,7 +259,7 @@ void CodeViewWidget::Update() if (Core::GetState() == Core::State::Paused) { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); Update(&guard); } else @@ -532,7 +533,7 @@ void CodeViewWidget::SetAddress(u32 address, SetAddressUpdate update) void CodeViewWidget::ReplaceAddress(u32 address, ReplaceWith replace) { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); PowerPC::debug_interface.SetPatch(guard, address, replace == ReplaceWith::BLR ? 0x4e800020 : 0x60000000); @@ -594,7 +595,7 @@ void CodeViewWidget::OnContextMenu() bool follow_branch_enabled = false; if (paused) { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); const std::string disasm = PowerPC::debug_interface.Disassemble(&guard, PowerPC::ppcState.pc); if (addr == PowerPC::ppcState.pc) @@ -650,7 +651,7 @@ void CodeViewWidget::AutoStep(CodeTrace::AutoStop option) // Autosteps and follows value in the target (left-most) register. The Used and Changed options // silently follows target through reshuffles in memory and registers and stops on use or update. - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); CodeTrace code_trace; bool repeat = false; @@ -741,7 +742,7 @@ void CodeViewWidget::OnCopyTargetAddress() const u32 addr = GetContextAddress(); const std::string code_line = [addr] { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); return PowerPC::debug_interface.Disassemble(&guard, addr); }(); @@ -771,7 +772,7 @@ void CodeViewWidget::OnShowTargetInMemory() const u32 addr = GetContextAddress(); const std::string code_line = [addr] { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); return PowerPC::debug_interface.Disassemble(&guard, addr); }(); @@ -790,7 +791,7 @@ void CodeViewWidget::OnCopyCode() const u32 addr = GetContextAddress(); const std::string text = [addr] { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); return PowerPC::debug_interface.Disassemble(&guard, addr); }(); @@ -808,7 +809,7 @@ void CodeViewWidget::OnCopyFunction() std::string text = symbol->name + "\r\n"; { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); // we got a function const u32 start = symbol->address; @@ -828,7 +829,7 @@ void CodeViewWidget::OnCopyHex() const u32 addr = GetContextAddress(); const u32 instruction = [addr] { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); return PowerPC::debug_interface.ReadInstruction(guard, addr); }(); @@ -856,7 +857,7 @@ void CodeViewWidget::OnAddFunction() { const u32 addr = GetContextAddress(); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); g_symbolDB.AddFunction(guard, addr); emit SymbolsChanged(); @@ -882,7 +883,7 @@ void CodeViewWidget::OnFollowBranch() const u32 addr = GetContextAddress(); const u32 branch_addr = [addr] { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); return GetBranchFromAddress(guard, addr); }(); @@ -945,7 +946,7 @@ void CodeViewWidget::OnSetSymbolSize() if (!good) return; - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); PPCAnalyst::ReanalyzeFunction(guard, symbol->address, *symbol, size); emit SymbolsChanged(); @@ -973,7 +974,7 @@ void CodeViewWidget::OnSetSymbolEndAddress() if (!good) return; - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); PPCAnalyst::ReanalyzeFunction(guard, symbol->address, *symbol, address - symbol->address); emit SymbolsChanged(); @@ -982,7 +983,7 @@ void CodeViewWidget::OnSetSymbolEndAddress() void CodeViewWidget::OnReplaceInstruction() { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); const u32 addr = GetContextAddress(); @@ -1004,7 +1005,7 @@ void CodeViewWidget::OnReplaceInstruction() void CodeViewWidget::OnRestoreInstruction() { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); const u32 addr = GetContextAddress(); diff --git a/Source/Core/DolphinQt/Debugger/CodeWidget.cpp b/Source/Core/DolphinQt/Debugger/CodeWidget.cpp index f5fa095166..d232fede85 100644 --- a/Source/Core/DolphinQt/Debugger/CodeWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/CodeWidget.cpp @@ -330,7 +330,7 @@ void CodeWidget::UpdateCallstack() std::vector stack; const bool success = [&stack] { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); return Dolphin_Debugger::GetCallstack(Core::System::GetInstance(), guard, stack); }(); @@ -461,8 +461,8 @@ void CodeWidget::StepOver() if (!cpu.IsStepping()) return; - const UGeckoInstruction inst = [] { - Core::CPUThreadGuard guard; + const UGeckoInstruction inst = [&] { + Core::CPUThreadGuard guard(system); return PowerPC::HostRead_Instruction(guard, PowerPC::ppcState.pc); }(); @@ -506,7 +506,7 @@ void CodeWidget::StepOut() clock::time_point timeout = clock::now() + std::chrono::seconds(5); { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(system); PowerPC::breakpoints.ClearAllTemporary(); diff --git a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp index 6f057aed4f..46db6477d4 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp @@ -25,6 +25,7 @@ #include "Core/HW/AddressSpace.h" #include "Core/PowerPC/BreakPoints.h" #include "Core/PowerPC/PowerPC.h" +#include "Core/System.h" #include "DolphinQt/Host.h" #include "DolphinQt/Resources.h" #include "DolphinQt/Settings.h" @@ -153,7 +154,7 @@ public: u32 end_address = address + static_cast(bytes.size()) - 1; AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_view->GetAddressSpace()); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); if (!bytes.empty() && accessors->IsValidAddress(guard, address) && accessors->IsValidAddress(guard, end_address)) @@ -442,7 +443,7 @@ void MemoryViewWidget::UpdateColumns() if (Core::GetState() == Core::State::Paused) { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); UpdateColumns(&guard); } else @@ -850,7 +851,7 @@ void MemoryViewWidget::OnCopyHex(u32 addr) const AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_address_space); const u64 value = [addr, accessors] { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); return accessors->ReadU64(guard, addr); }(); @@ -873,7 +874,7 @@ void MemoryViewWidget::OnContextMenu(const QPoint& pos) [this, addr] { const AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_address_space); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); return accessors->IsValidAddress(guard, addr); }(); diff --git a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp index ab3e269470..0c3646ec7a 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp @@ -32,6 +32,7 @@ #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/HW/AddressSpace.h" +#include "Core/System.h" #include "DolphinQt/Debugger/MemoryViewWidget.h" #include "DolphinQt/Host.h" #include "DolphinQt/QtUtils/ModalMessageBox.h" @@ -496,7 +497,7 @@ void MemoryWidget::SetAddress(u32 address) AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_memory_view->GetAddressSpace()); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); good = accessors->IsValidAddress(guard, current_addr); } @@ -653,7 +654,7 @@ void MemoryWidget::OnSetValue() return; } - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_memory_view->GetAddressSpace()); u32 end_address = target_addr.address + static_cast(bytes.size()) - 1; @@ -715,7 +716,7 @@ void MemoryWidget::OnSetValueFromFile() AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_memory_view->GetAddressSpace()); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); for (u8 b : file_contents) accessors->WriteU8(guard, target_addr.address++, b); @@ -833,7 +834,7 @@ void MemoryWidget::FindValue(bool next) AddressSpace::Accessors* accessors = AddressSpace::GetAccessors(m_memory_view->GetAddressSpace()); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); return accessors->Search(guard, target_addr.address, reinterpret_cast(search_for.data()), static_cast(search_for.size()), next); diff --git a/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp b/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp index f7dd891855..9d7079e04a 100644 --- a/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/RegisterWidget.cpp @@ -296,7 +296,7 @@ void RegisterWidget::AutoStep(const std::string& reg) const while (true) { const AutoStepResults results = [&trace] { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); return trace.AutoStepping(guard, true); }(); diff --git a/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp b/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp index c9d0df2930..147efa3779 100644 --- a/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/ThreadWidget.cpp @@ -15,6 +15,7 @@ #include "Core/Core.h" #include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" +#include "Core/System.h" #include "DolphinQt/Host.h" #include "DolphinQt/Settings.h" @@ -257,7 +258,7 @@ void ThreadWidget::Update() m_thread_table->setRowCount(0); UpdateThreadContext({}); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); UpdateThreadCallstack(guard, {}); } if (emu_state != Core::State::Paused) @@ -301,7 +302,7 @@ void ThreadWidget::Update() }; { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); // YAGCD - Section 4.2.1.4 Dolphin OS Globals m_current_context->setText(format_hex_from(guard, 0x800000D4)); @@ -471,7 +472,7 @@ void ThreadWidget::UpdateThreadCallstack(const Core::CPUThreadGuard& guard, void ThreadWidget::OnSelectionChanged(int row) { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); Common::Debug::PartialContext context; if (row >= 0 && size_t(row) < m_threads.size()) diff --git a/Source/Core/DolphinQt/Debugger/WatchWidget.cpp b/Source/Core/DolphinQt/Debugger/WatchWidget.cpp index 70bbcd57d6..8bab9ed1fb 100644 --- a/Source/Core/DolphinQt/Debugger/WatchWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/WatchWidget.cpp @@ -16,6 +16,7 @@ #include "Core/Core.h" #include "Core/PowerPC/MMU.h" #include "Core/PowerPC/PowerPC.h" +#include "Core/System.h" #include "DolphinQt/Host.h" #include "DolphinQt/QtUtils/ModalMessageBox.h" @@ -166,7 +167,7 @@ void WatchWidget::Update() m_table->setDisabled(false); m_table->clearContents(); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); int size = static_cast(PowerPC::debug_interface.GetWatches().size()); @@ -295,7 +296,7 @@ void WatchWidget::OnLoad() return; } - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); if (ini.GetLines("Watches", &watches, false)) { @@ -405,7 +406,7 @@ void WatchWidget::OnItemChanged(QTableWidgetItem* item) if (good) { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); if (column == COLUMN_INDEX_ADDRESS) { @@ -430,7 +431,7 @@ void WatchWidget::OnItemChanged(QTableWidgetItem* item) { PowerPC::debug_interface.UpdateWatchLockedState(row, item->checkState() == Qt::Checked); const auto& watch = PowerPC::debug_interface.GetWatch(row); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); if (watch.locked) LockWatchAddress(guard, watch.address); else @@ -459,7 +460,7 @@ void WatchWidget::LockWatchAddress(const Core::CPUThreadGuard& guard, u32 addres void WatchWidget::DeleteSelectedWatches() { { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); std::vector row_indices; for (const auto& index : m_table->selectionModel()->selectedRows()) { @@ -491,7 +492,7 @@ void WatchWidget::DeleteWatch(const Core::CPUThreadGuard& guard, int row) void WatchWidget::DeleteWatchAndUpdate(int row) { { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); DeleteWatch(guard, row); } @@ -517,7 +518,7 @@ void WatchWidget::AddWatch(QString name, u32 addr) void WatchWidget::LockSelectedWatches() { { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); for (const auto& index : m_table->selectionModel()->selectedRows()) { const auto* item = m_table->item(index.row(), index.column()); @@ -539,7 +540,7 @@ void WatchWidget::LockSelectedWatches() void WatchWidget::UnlockSelectedWatches() { { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); for (const auto& index : m_table->selectionModel()->selectedRows()) { const auto* item = m_table->item(index.row(), index.column()); diff --git a/Source/Core/DolphinQt/MenuBar.cpp b/Source/Core/DolphinQt/MenuBar.cpp index 443d848740..1a15d9c100 100644 --- a/Source/Core/DolphinQt/MenuBar.cpp +++ b/Source/Core/DolphinQt/MenuBar.cpp @@ -1186,7 +1186,7 @@ void MenuBar::ClearSymbols() void MenuBar::GenerateSymbolsFromAddress() { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); auto& system = Core::System::GetInstance(); auto& memory = system.GetMemory(); @@ -1198,7 +1198,7 @@ void MenuBar::GenerateSymbolsFromAddress() void MenuBar::GenerateSymbolsFromSignatureDB() { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); auto& system = Core::System::GetInstance(); auto& memory = system.GetMemory(); @@ -1244,7 +1244,7 @@ void MenuBar::GenerateSymbolsFromRSO() return; } - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); RSOChainView rso_chain; if (rso_chain.Load(guard, static_cast(address))) @@ -1300,7 +1300,7 @@ void MenuBar::GenerateSymbolsFromRSOAuto() RSOChainView rso_chain; const u32 address = item.mid(0, item.indexOf(QLatin1Char(' '))).toUInt(nullptr, 16); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); if (rso_chain.Load(guard, address)) { @@ -1315,7 +1315,7 @@ void MenuBar::GenerateSymbolsFromRSOAuto() RSOVector MenuBar::DetectRSOModules(ParallelProgressDialog& progress) { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); constexpr std::array search_for = {".elf", ".plf"}; @@ -1429,7 +1429,7 @@ void MenuBar::LoadSymbolMap() g_symbolDB.Clear(); { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); PPCAnalyst::FindFunctions(guard, Memory::MEM1_BASE_ADDR + 0x1300000, Memory::MEM1_BASE_ADDR + memory.GetRamSizeReal(), &g_symbolDB); @@ -1523,7 +1523,7 @@ void MenuBar::SaveCode() bool success; { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); success = g_symbolDB.SaveCodeMap(guard, path); } @@ -1537,7 +1537,7 @@ void MenuBar::SaveCode() bool MenuBar::TryLoadMapFile(const QString& path, const bool bad) { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); if (!g_symbolDB.LoadMap(guard, path.toStdString(), bad)) { @@ -1621,7 +1621,7 @@ void MenuBar::ApplySignatureFile() SignatureDB db(load_path); db.Load(load_path); { - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(Core::System::GetInstance()); db.Apply(guard, &g_symbolDB); } db.List(); @@ -1692,7 +1692,7 @@ void MenuBar::SearchInstruction() auto& system = Core::System::GetInstance(); auto& memory = system.GetMemory(); - Core::CPUThreadGuard guard; + Core::CPUThreadGuard guard(system); bool found = false; for (u32 addr = Memory::MEM1_BASE_ADDR; addr < Memory::MEM1_BASE_ADDR + memory.GetRamSizeReal();