Add a function to make a mutex-protected copy of a breakpoint site's
owners list, so the StopInfo machinery can get the list of owners without
some other thread being able to mess up the list by deleting/disabline one of its
locations in the process of doing so.
<rdar://problem/18685197>
llvm-svn: 243541
diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp
index 4f6ef7a..64bbe80 100644
--- a/lldb/source/Target/StopInfo.cpp
+++ b/lldb/source/Target/StopInfo.cpp
@@ -350,7 +350,10 @@
if (bp_site_sp)
{
- size_t num_owners = bp_site_sp->GetNumberOfOwners();
+ // Let's copy the owners list out of the site and store them in a local list. That way if
+ // one of the breakpoint actions changes the site, then we won't be operating on a bad list.
+ BreakpointLocationCollection site_locations;
+ size_t num_owners = bp_site_sp->CopyOwnersList(site_locations);
if (num_owners == 0)
{
@@ -416,20 +419,16 @@
StoppointCallbackContext context (event_ptr, exe_ctx, false);
- // Let's copy the breakpoint locations out of the site and store them in a local list. That way if
- // one of the breakpoint actions changes the site, then we won't be operating on a bad list.
// For safety's sake let's also grab an extra reference to the breakpoint owners of the locations we're
// going to examine, since the locations are going to have to get back to their breakpoints, and the
// locations don't keep their owners alive. I'm just sticking the BreakpointSP's in a vector since
- // I'm only really using it to locally increment their retain counts.
+ // I'm only using it to locally increment their retain counts.
- BreakpointLocationCollection site_locations;
std::vector<lldb::BreakpointSP> location_owners;
for (size_t j = 0; j < num_owners; j++)
{
- BreakpointLocationSP loc(bp_site_sp->GetOwnerAtIndex(j));
- site_locations.Add(loc);
+ BreakpointLocationSP loc(site_locations.GetByIndex(j));
location_owners.push_back(loc->GetBreakpoint().shared_from_this());
}