From 8bdfdc88b241e5f32177f434fc42f19dd9dd3c26 Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Wed, 7 Aug 2024 02:39:17 -0700 Subject: [PATCH] Branch Watch Tool: Ignore Apploader Branch Hits Concurrency Fix Also removed worthless `Start` and `Pause` helpers from `Core::BranchWatch`. --- Source/Core/Core/Boot/Boot_BS2Emu.cpp | 4 ++-- Source/Core/Core/Debugger/BranchWatch.h | 4 +--- Source/Core/DolphinQt/Debugger/BranchWatchDialog.cpp | 12 +++--------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/Source/Core/Core/Boot/Boot_BS2Emu.cpp b/Source/Core/Core/Boot/Boot_BS2Emu.cpp index 891e7fc324..1f331fbe54 100644 --- a/Source/Core/Core/Boot/Boot_BS2Emu.cpp +++ b/Source/Core/Core/Boot/Boot_BS2Emu.cpp @@ -163,7 +163,7 @@ bool CBoot::RunApploader(Core::System& system, const Core::CPUThreadGuard& guard const bool resume_branch_watch = branch_watch.GetRecordingActive(); if (system.IsBranchWatchIgnoreApploader()) - branch_watch.Pause(); + branch_watch.SetRecordingActive(guard, false); // Call iAppLoaderEntry. DEBUG_LOG_FMT(BOOT, "Call iAppLoaderEntry"); @@ -226,7 +226,7 @@ bool CBoot::RunApploader(Core::System& system, const Core::CPUThreadGuard& guard // return ppc_state.pc = ppc_state.gpr[3]; - branch_watch.SetRecordingActive(resume_branch_watch); + branch_watch.SetRecordingActive(guard, resume_branch_watch); return true; } diff --git a/Source/Core/Core/Debugger/BranchWatch.h b/Source/Core/Core/Debugger/BranchWatch.h index fd4cd158ea..32dc28853d 100644 --- a/Source/Core/Core/Debugger/BranchWatch.h +++ b/Source/Core/Core/Debugger/BranchWatch.h @@ -117,9 +117,7 @@ public: using SelectionInspection = BranchWatchSelectionInspection; bool GetRecordingActive() const { return m_recording_active; } - void SetRecordingActive(bool active) { m_recording_active = active; } - void Start() { SetRecordingActive(true); } - void Pause() { SetRecordingActive(false); } + void SetRecordingActive(const CPUThreadGuard& guard, bool active) { m_recording_active = active; } void Clear(const CPUThreadGuard& guard); void Save(const CPUThreadGuard& guard, std::FILE* file) const; diff --git a/Source/Core/DolphinQt/Debugger/BranchWatchDialog.cpp b/Source/Core/DolphinQt/Debugger/BranchWatchDialog.cpp index 39e7748df4..aef6f18cc3 100644 --- a/Source/Core/DolphinQt/Debugger/BranchWatchDialog.cpp +++ b/Source/Core/DolphinQt/Debugger/BranchWatchDialog.cpp @@ -516,7 +516,6 @@ BranchWatchDialog::~BranchWatchDialog() } static constexpr int BRANCH_WATCH_TOOL_TIMER_DELAY_MS = 100; -static constexpr int BRANCH_WATCH_TOOL_TIMER_PAUSE_ONESHOT_MS = 200; static bool TimerCondition(const Core::BranchWatch& branch_watch, Core::State state) { @@ -537,23 +536,18 @@ void BranchWatchDialog::showEvent(QShowEvent* event) void BranchWatchDialog::OnStartPause(bool checked) const { + m_branch_watch.SetRecordingActive(Core::CPUThreadGuard{m_system}, checked); if (checked) { - m_branch_watch.Start(); m_btn_start_pause->setText(tr("Pause Branch Watch")); - // Restart the timer if the situation calls for it, but always turn off single-shot. - m_timer->setSingleShot(false); if (Core::GetState(m_system) > Core::State::Paused) m_timer->start(BRANCH_WATCH_TOOL_TIMER_DELAY_MS); } else { - m_branch_watch.Pause(); m_btn_start_pause->setText(tr("Start Branch Watch")); - // Schedule one last update in the future in case Branch Watch is in the middle of a hit. - if (Core::GetState(m_system) > Core::State::Paused) - m_timer->setInterval(BRANCH_WATCH_TOOL_TIMER_PAUSE_ONESHOT_MS); - m_timer->setSingleShot(true); + if (m_timer->isActive()) + m_timer->stop(); } Update(); }