Skip to content

[lldb] [NFC] Remove unused WatchpointResourceList class #79385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

jasonmolenda
Copy link
Collaborator

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.

In `[lldb] [mostly NFC] Large WP foundation: WatchpointResources
(llvm#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.
@llvmbot
Copy link
Member

llvmbot commented Jan 24, 2024

@llvm/pr-subscribers-lldb

Author: Jason Molenda (jasonmolenda)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/79385.diff

2 Files Affected:

  • (removed) lldb/include/lldb/Breakpoint/WatchpointResourceList.h (-145)
  • (removed) lldb/source/Breakpoint/WatchpointResourceList.cpp (-114)
diff --git a/lldb/include/lldb/Breakpoint/WatchpointResourceList.h b/lldb/include/lldb/Breakpoint/WatchpointResourceList.h
deleted file mode 100644
index 0e6c5fab877895c..000000000000000
--- 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 <mutex>
-#include <vector>
-
-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<lldb::WatchpointResourceSP> collection;
-  typedef LockingAdaptedIterable<collection, lldb::WatchpointResourceSP,
-                                 vector_adapter, std::mutex>
-      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/WatchpointResourceList.cpp b/lldb/source/Breakpoint/WatchpointResourceList.cpp
deleted file mode 100644
index d1d364832098f4e..000000000000000
--- 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> 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<std::mutex> guard(m_mutex);
-  return m_resources.size();
-}
-
-lldb::WatchpointResourceSP
-WatchpointResourceList::GetResourceAtIndex(uint32_t idx) {
-  std::lock_guard<std::mutex> guard(m_mutex);
-  if (idx < m_resources.size())
-    return m_resources[idx];
-
-  return {};
-}
-
-void WatchpointResourceList::Clear() {
-  std::lock_guard<std::mutex> guard(m_mutex);
-  m_resources.clear();
-}
-
-std::mutex &WatchpointResourceList::GetMutex() { return m_mutex; }

Copy link
Member

@bulbazord bulbazord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of that!

@jasonmolenda jasonmolenda merged commit bddeef5 into llvm:main Jan 24, 2024
@jasonmolenda jasonmolenda deleted the remove-unused-watchpoint-resource-list-class branch January 24, 2024 23:18
tstellar pushed a commit to tstellar/llvm-project that referenced this pull request Jan 25, 2024
In `[lldb] [mostly NFC] Large WP foundation: WatchpointResources
(llvm#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.

(cherry picked from commit bddeef5)
jasonmolenda added a commit to jasonmolenda/llvm-project that referenced this pull request Feb 1, 2024
In `[lldb] [mostly NFC] Large WP foundation: WatchpointResources
(llvm#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.

(cherry picked from commit bddeef5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants