From b6c20b715ac2703389ff03c7205565adf975f5b7 Mon Sep 17 00:00:00 2001 From: mitaclaw <140017135+mitaclaw@users.noreply.github.com> Date: Tue, 6 Aug 2024 03:29:50 -0700 Subject: [PATCH] BranchWatch: Don't Save Irrelevant Hits In Reduction Phase --- Source/Core/Core/Debugger/BranchWatch.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/Debugger/BranchWatch.cpp b/Source/Core/Core/Debugger/BranchWatch.cpp index b7cb76ff27..73e6892258 100644 --- a/Source/Core/Core/Debugger/BranchWatch.cpp +++ b/Source/Core/Core/Debugger/BranchWatch.cpp @@ -69,18 +69,22 @@ void BranchWatch::Save(const CPUThreadGuard& guard, std::FILE* file) const if (file == nullptr) return; + const bool is_reduction_phase = GetRecordingPhase() == Phase::Reduction; + const auto routine = [&](const Collection& collection, bool is_virtual, bool condition) { for (const Collection::value_type& kv : collection) { - const auto iter = std::find_if( - m_selection.begin(), m_selection.end(), - [&](const Selection::value_type& value) { return value.collection_ptr == &kv; }); + const auto iter = std::ranges::find_if(m_selection, [&](const Selection::value_type& value) { + return value.collection_ptr == &kv; + }); + const bool selected = iter != m_selection.end(); + if (is_reduction_phase && !selected) + continue; // Unselected hits are irrelevant to the reduction phase. + const auto inspection = selected ? iter->inspection : SelectionInspection{}; fmt::println(file, "{:08x} {:08x} {:08x} {} {} {:x}", kv.first.origin_addr, kv.first.destin_addr, kv.first.original_inst.hex, kv.second.total_hits, kv.second.hits_snapshot, - iter == m_selection.end() ? - USnapshotMetadata(is_virtual, condition, false, {}).hex : - USnapshotMetadata(is_virtual, condition, true, iter->inspection).hex); + USnapshotMetadata(is_virtual, condition, selected, inspection).hex); } }; routine(m_collection_vt, true, true);