================
@@ -53,44 +49,52 @@ bool WatchpointResource::Contains(addr_t addr) {
 
 void WatchpointResource::AddOwner(const WatchpointSP &wp_sp) {
   std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
-  m_owners.Add(wp_sp);
+  m_owners.push_back(wp_sp);
 }
 
 void WatchpointResource::RemoveOwner(WatchpointSP &wp_sp) {
   std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
-  m_owners.Remove(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+    m_owners.erase(it);
 }
 
 size_t WatchpointResource::GetNumberOfOwners() {
   std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
-  return m_owners.GetSize();
+  return m_owners.size();
 }
 
 bool WatchpointResource::OwnersContains(WatchpointSP &wp_sp) {
   std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
-  return m_owners.Contains(wp_sp);
+  const auto &it = std::find(m_owners.begin(), m_owners.end(), wp_sp);
+  if (it != m_owners.end())
+    return true;
+  return false;
 }
 
 bool WatchpointResource::OwnersContains(const Watchpoint *wp) {
   std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
-  return m_owners.Contains(wp);
+  for (WatchpointCollection::const_iterator it = m_owners.begin();
+       it != m_owners.end(); ++it)
+    if ((*it).get() == wp)
+      return true;
+  return false;
 }
 
 WatchpointSP WatchpointResource::GetOwnerAtIndex(size_t idx) {
   std::lock_guard<std::recursive_mutex> guard(m_owners_mutex);
-  assert(idx < m_owners.GetSize());
-  if (idx >= m_owners.GetSize())
+  lldbassert(idx < m_owners.size());
+  if (idx >= m_owners.size())
     return {};
 
-  return m_owners.GetByIndex(idx);
+  return m_owners[idx];
----------------
jasonmolenda wrote:

This is a good point.  I am mostly trying to copy the API of BreakpointSite 
which has methods like this, and that's how its Owners are accessed today in 
different parts of lldb.  I haven't gotten to the point where I use the Owners 
anywhere yet, so I'm not locked in to the same API that BreakpointSite exposes. 
 We have things like `SBThread::GetStopReasonDataAtIndex()` which for 
Breakpoints exposes all of the Breakpoints that were owning the BreakpointSite 
that was hit.  We have other places like 
`StackFrameList::ResetCurrentInlinedDepth` which is iterating over a 
BreakpointSite's owners to see if any of them are internal; the 
IterableWatchpoint returned by `WatchpointResources::Owners` would be a cleaner 
approach in this case.  We have some places in the code that need to know the 
address of the breakpoint that was hit and are grabbing the first 
BreakpointLocation associated with the BreakpointSite, e.g. 
`PlatformDarwin::GetSoftwareBreakpointTrapOpcode` (for some arm/thumb reason).  
In `ThreadPlanCallFunction::DoPlanExplainsStop` we're iterating over the Owners 
to log about them and detect if any are Internal breakpoint locations, which 
could be done with an Iterable.  

https://github.com/llvm/llvm-project/pull/68845
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to