aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe de Azevedo Piovezan <fpiovezan@apple.com>2026-04-29 13:16:53 +0100
committerFelipe de Azevedo Piovezan <fpiovezan@apple.com>2026-04-29 15:15:56 +0100
commitc2aaec93a5b097a12f98ec26f8cde94274f1e1ca (patch)
tree3ead4485f5155c13cb16943c3b0de78a33839b57
parenteb4568c3e56927ee5d57d85525b83b09750fefbe (diff)
downloadllvm-users/felipepiovezan/delayed_bps_p3.tar.gz
llvm-users/felipepiovezan/delayed_bps_p3.tar.bz2
llvm-users/felipepiovezan/delayed_bps_p3.zip
fixup! protect bp cache with a lockusers/felipepiovezan/delayed_bps_p3
-rw-r--r--lldb/include/lldb/Target/Process.h1
-rw-r--r--lldb/source/Target/Process.cpp7
2 files changed, 8 insertions, 0 deletions
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index f9887e985a00..045fa9ee2a05 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -3575,6 +3575,7 @@ protected:
};
DelayedBreakpointCache m_delayed_breakpoints;
+ std::recursive_mutex m_delayed_breakpoints_mutex;
llvm::Error FlushDelayedBreakpoints();
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 4d61527a79ff..85f587166ce4 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -1596,6 +1596,7 @@ Status Process::DisableBreakpointSiteByID(lldb::user_id_t break_id) {
llvm::Error Process::ExecuteBreakpointSiteAction(BreakpointSite &site,
BreakpointAction action) {
auto site_sp = site.shared_from_this();
+ std::unique_lock<std::recursive_mutex> guard(m_delayed_breakpoints_mutex);
// Ignore requests that won't change the Site status.
if (IsBreakpointSiteEnabled(*site_sp) == (action == BreakpointAction::Enable))
@@ -1607,6 +1608,7 @@ llvm::Error Process::ExecuteBreakpointSiteAction(BreakpointSite &site,
}
m_delayed_breakpoints.RemoveSite(site_sp);
+ guard.unlock();
switch (action) {
case BreakpointAction::Enable:
@@ -1633,6 +1635,8 @@ Status Process::EnableBreakpointSiteByID(lldb::user_id_t break_id) {
}
bool Process::IsBreakpointSiteEnabled(const BreakpointSite &site) {
+ std::lock_guard<std::recursive_mutex> guard(m_delayed_breakpoints_mutex);
+
// `site` won't be mutated, but the cache stores mutable pointers.
auto it = m_delayed_breakpoints.m_site_to_action.find(
const_cast<BreakpointSite &>(site).shared_from_this());
@@ -1707,6 +1711,8 @@ static addr_t ComputeConstituentLoadAddress(BreakpointLocation &constituent,
}
llvm::Error Process::FlushDelayedBreakpoints() {
+ std::unique_lock<std::recursive_mutex> guard(m_delayed_breakpoints_mutex);
+
// Clear the cache in m_delayed_breakpoints so it can't affect the actual
// enabling of breakpoints. For example, if `EnableSoftwareBreakpoint` is
// called outside of FlushDelayedBreakpoints, it needs to check the delayed
@@ -1716,6 +1722,7 @@ llvm::Error Process::FlushDelayedBreakpoints() {
auto site_to_action = std::move(m_delayed_breakpoints.m_site_to_action);
m_delayed_breakpoints.m_site_to_action.clear();
+ guard.unlock();
return UpdateBreakpointSites(site_to_action);
}