================ @@ -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:
I'm not completely clear what having WatchpointResource::Owners() returning a WatchpointIterable is going to do beyond allowing someone to write `for (WatchpointSP &wp_sp : wp_resource_sp->Owners())` - it's not exposing the underlying std::vector so I can't call `wp_resource_sp->Owners().size()` or `wp_resource_sp->Owners()[2]` is it? Right now the WatchpointResource has methods like `AddOwner`, `RemoveOwner`, `GetNumberOfOwners`, `GetOwnerAtIndex`, and some methods to check if the list of owners contains a watchpoint; should callers be able to lock the Resource's mutex and get a reference to the std::vector and query/manipulate it directly? 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