From 7d9539a461c989a744ab464c387d880570e18cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 10 May 2026 21:33:54 +0200 Subject: [PATCH] Fix multiple issues with temporary breakpoints. Prevents unnecessary jit clears on step-out. Thanks Nemoumbra. --- Core/Debugger/Breakpoints.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/Core/Debugger/Breakpoints.cpp b/Core/Debugger/Breakpoints.cpp index 5e6849ced9..eea01ba1fa 100644 --- a/Core/Debugger/Breakpoints.cpp +++ b/Core/Debugger/Breakpoints.cpp @@ -216,15 +216,30 @@ void BreakpointManager::ClearTemporaryBreakPoints() { if (!anyBreakPoints_) return; + std::unique_lock guard(breakPointsMutex_); - for (int i = (int)breakPoints_.size()-1; i >= 0; --i) - { - if (breakPoints_[i].temporary) - { - breakPoints_.erase(breakPoints_.begin() + i); - Update(); + + std::vector addrsToUpdate; + + for (auto it = breakPoints_.begin(); it != breakPoints_.end(); ) { + if (it->temporary) { + addrsToUpdate.push_back(it->addr); + it = breakPoints_.erase(it); + } else { + ++it; } } + + if (addrsToUpdate.size() == 1) { + // We can use the proper mechanism to update just one address. + // If there are any temp breakpoints, there's normally just one, so this is better + // than Update(). + Update(addrsToUpdate[0]); + } else if (!addrsToUpdate.empty()) { + Update(); + } + + anyBreakPoints_ = !breakPoints_.empty(); } void BreakpointManager::ChangeBreakPointAddCond(u32 addr, const BreakPointCond &cond)