From bddeef54cb66609ad0a32d840051713cd8487adb Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Wed, 24 Jan 2024 15:18:33 -0800 Subject: [PATCH] [lldb] [NFC] Remove unused WatchpointResourceList class (#79385) In `[lldb] [mostly NFC] Large WP foundation: WatchpointResources (#68845)` I added a new template StopPointSiteList to combine WatchpointResourceList and BreakpointSiteList. But I didn't remove the now-unused WatchpointResourceList class. This patch fixes that. --- .../lldb/Breakpoint/WatchpointResourceList.h | 145 ------------------ lldb/source/Breakpoint/CMakeLists.txt | 1 - .../Breakpoint/WatchpointResourceList.cpp | 114 -------------- 3 files changed, 260 deletions(-) delete mode 100644 lldb/include/lldb/Breakpoint/WatchpointResourceList.h delete mode 100644 lldb/source/Breakpoint/WatchpointResourceList.cpp diff --git a/lldb/include/lldb/Breakpoint/WatchpointResourceList.h b/lldb/include/lldb/Breakpoint/WatchpointResourceList.h deleted file mode 100644 index 0e6c5fab877895..00000000000000 --- a/lldb/include/lldb/Breakpoint/WatchpointResourceList.h +++ /dev/null @@ -1,145 +0,0 @@ -//===-- WatchpointResourceList.h --------------------------------*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCELIST_H -#define LLDB_BREAKPOINT_WATCHPOINTRESOURCELIST_H - -#include "lldb/Utility/Iterable.h" -#include "lldb/lldb-private.h" -#include "lldb/lldb-public.h" - -#include -#include - -namespace lldb_private { - -class WatchpointResourceList { - -public: - WatchpointResourceList(); - - ~WatchpointResourceList(); - - /// Add a WatchpointResource to the list. - /// - /// \param[in] wp_res_sp - /// A shared pointer to a breakpoint site being added to the list. - /// - /// \return - /// The ID of the BreakpointSite in the list. - lldb::wp_resource_id_t Add(const lldb::WatchpointResourceSP &wp_res_sp); - - /// Removes the watchpoint resource given by \a id from this list. - /// - /// \param[in] id - /// The watchpoint resource to remove. - /// - /// \result - /// \b true if the watchpoint resource \a id was in the list. - bool Remove(lldb::wp_resource_id_t id); - - /// Removes the watchpoint resource containing address \a addr from this list. - /// - /// \param[in] addr - /// The address from which to remove a watchpoint resource. - /// - /// \result - /// \b true if \a addr had a watchpoint resource to remove from the list. - bool RemoveByAddress(lldb::addr_t addr); - - /// Returns a shared pointer to the watchpoint resource which contains - /// \a addr. - /// - /// \param[in] addr - /// The address to look for. - /// - /// \result - /// A shared pointer to the watchpoint resource. May contain a nullptr - /// pointer if no watchpoint site exists with a matching address. - lldb::WatchpointResourceSP FindByAddress(lldb::addr_t addr); - - /// Returns a shared pointer to the watchpoint resource which is owned - /// by \a wp_sp. - /// - /// \param[in] wp_sp - /// The WatchpointSP to look for. - /// - /// \result - /// A shared pointer to the watchpoint resource. May contain a nullptr - /// pointer if no watchpoint site exists - lldb::WatchpointResourceSP FindByWatchpointSP(lldb::WatchpointSP &wp_sp); - - /// Returns a shared pointer to the watchpoint resource which is owned - /// by \a wp. - /// - /// \param[in] wp - /// The Watchpoint to look for. - /// - /// \result - /// A shared pointer to the watchpoint resource. May contain a nullptr - /// pointer if no watchpoint site exists - lldb::WatchpointResourceSP - FindByWatchpoint(const lldb_private::Watchpoint *wp); - - /// Returns a shared pointer to the watchpoint resource which has hardware - /// index \a id. Some Process plugins may not have access to the actual - /// hardware watchpoint register number used for a WatchpointResource, so - /// the wp_resource_id_t may not be correctly tracking the target's wp - /// register target. - /// - /// \param[in] id - /// The hardware resource index to search for. - /// - /// \result - /// A shared pointer to the watchpoint resource. May contain a nullptr - /// pointer if no watchpoint site exists with a matching id. - lldb::WatchpointResourceSP FindByID(lldb::wp_resource_id_t id); - - /// - /// Get the number of WatchpointResources that are available. - /// - /// \return - /// The number of WatchpointResources that are stored in the - /// WatchpointResourceList. - uint32_t GetSize(); - - /// Get the WatchpointResource at a given index. - /// - /// \param [in] idx - /// The index of the resource. - /// \return - /// The WatchpointResource at that index number. - lldb::WatchpointResourceSP GetResourceAtIndex(uint32_t idx); - - typedef std::vector collection; - typedef LockingAdaptedIterable - WatchpointResourceIterable; - - /// Iterate over the list of WatchpointResources. - /// - /// \return - /// An Iterable object which can be used to loop over the resources - /// that exist. - WatchpointResourceIterable Resources() { - return WatchpointResourceIterable(m_resources, m_mutex); - } - - /// Clear out the list of resources from the WatchpointResourceList - void Clear(); - - std::mutex &GetMutex(); - -private: - collection m_resources; - std::mutex m_mutex; -}; - -} // namespace lldb_private - -#endif // LLDB_BREAKPOINT_WATCHPOINTRESOURCELIST_H diff --git a/lldb/source/Breakpoint/CMakeLists.txt b/lldb/source/Breakpoint/CMakeLists.txt index 42ac338c315b4f..3b39189e525874 100644 --- a/lldb/source/Breakpoint/CMakeLists.txt +++ b/lldb/source/Breakpoint/CMakeLists.txt @@ -24,7 +24,6 @@ add_lldb_library(lldbBreakpoint NO_PLUGIN_DEPENDENCIES WatchpointList.cpp WatchpointOptions.cpp WatchpointResource.cpp - WatchpointResourceList.cpp LINK_LIBS lldbCore diff --git a/lldb/source/Breakpoint/WatchpointResourceList.cpp b/lldb/source/Breakpoint/WatchpointResourceList.cpp deleted file mode 100644 index d1d364832098f4..00000000000000 --- a/lldb/source/Breakpoint/WatchpointResourceList.cpp +++ /dev/null @@ -1,114 +0,0 @@ -//===-- WatchpointResourceList.cpp ----------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "lldb/Breakpoint/WatchpointResourceList.h" -#include "lldb/Breakpoint/WatchpointResource.h" -#include "lldb/Utility/LLDBLog.h" -#include "lldb/Utility/Log.h" - -using namespace lldb; -using namespace lldb_private; - -WatchpointResourceList::WatchpointResourceList() : m_resources(), m_mutex() {} - -WatchpointResourceList::~WatchpointResourceList() { Clear(); } - -wp_resource_id_t -WatchpointResourceList::Add(const WatchpointResourceSP &wp_res_sp) { - Log *log = GetLog(LLDBLog::Watchpoints); - std::lock_guard guard(m_mutex); - LLDB_LOGF(log, "WatchpointResourceList::Add(addr 0x%" PRIx64 " size %zu)", - wp_res_sp->GetLoadAddress(), wp_res_sp->GetByteSize()); - - m_resources.push_back(wp_res_sp); - return wp_res_sp->GetID(); -} - -bool WatchpointResourceList::Remove(wp_resource_id_t id) { - std::lock_guard guard(m_mutex); - Log *log = GetLog(LLDBLog::Watchpoints); - for (collection::iterator pos = m_resources.begin(); pos != m_resources.end(); - ++pos) { - if ((*pos)->GetID() == id) { - LLDB_LOGF(log, - "WatchpointResourceList::Remove(addr 0x%" PRIx64 " size %zu)", - (*pos)->GetLoadAddress(), (*pos)->GetByteSize()); - m_resources.erase(pos); - return true; - } - } - return false; -} - -bool WatchpointResourceList::RemoveByAddress(addr_t addr) { - std::lock_guard guard(m_mutex); - Log *log = GetLog(LLDBLog::Watchpoints); - for (collection::iterator pos = m_resources.begin(); pos != m_resources.end(); - ++pos) { - if ((*pos)->Contains(addr)) { - LLDB_LOGF(log, - "WatchpointResourceList::RemoveByAddress(addr 0x%" PRIx64 - " size %zu)", - (*pos)->GetLoadAddress(), (*pos)->GetByteSize()); - m_resources.erase(pos); - return true; - } - } - return false; -} - -WatchpointResourceSP WatchpointResourceList::FindByAddress(addr_t addr) { - std::lock_guard guard(m_mutex); - for (WatchpointResourceSP wp_res_sp : m_resources) - if (wp_res_sp->Contains(addr)) - return wp_res_sp; - return {}; -} - -WatchpointResourceSP -WatchpointResourceList::FindByWatchpointSP(WatchpointSP &wp_sp) { - return FindByWatchpoint(wp_sp.get()); -} - -WatchpointResourceSP -WatchpointResourceList::FindByWatchpoint(const Watchpoint *wp) { - std::lock_guard guard(m_mutex); - for (WatchpointResourceSP wp_res_sp : m_resources) - if (wp_res_sp->ConstituentsContains(wp)) - return wp_res_sp; - return {}; -} - -WatchpointResourceSP WatchpointResourceList::FindByID(wp_resource_id_t id) { - std::lock_guard guard(m_mutex); - for (WatchpointResourceSP wp_res_sp : m_resources) - if (wp_res_sp->GetID() == id) - return wp_res_sp; - return {}; -} - -uint32_t WatchpointResourceList::GetSize() { - std::lock_guard guard(m_mutex); - return m_resources.size(); -} - -lldb::WatchpointResourceSP -WatchpointResourceList::GetResourceAtIndex(uint32_t idx) { - std::lock_guard guard(m_mutex); - if (idx < m_resources.size()) - return m_resources[idx]; - - return {}; -} - -void WatchpointResourceList::Clear() { - std::lock_guard guard(m_mutex); - m_resources.clear(); -} - -std::mutex &WatchpointResourceList::GetMutex() { return m_mutex; }