[Lldb-commits] [lldb] Remove watchpointresource setid method (PR #79388)

via lldb-commits lldb-commits at lists.llvm.org
Wed Jan 24 15:04:35 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Jason Molenda (jasonmolenda)

<details>
<summary>Changes</summary>



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


4 Files Affected:

- (modified) lldb/include/lldb/Breakpoint/WatchpointResource.h (-8) 
- (removed) lldb/include/lldb/Breakpoint/WatchpointResourceList.h (-145) 
- (modified) lldb/source/Breakpoint/WatchpointResource.cpp (-2) 
- (removed) lldb/source/Breakpoint/WatchpointResourceList.cpp (-114) 


``````````diff
diff --git a/lldb/include/lldb/Breakpoint/WatchpointResource.h b/lldb/include/lldb/Breakpoint/WatchpointResource.h
index 4b1d733850f1bbf..070d84cff8f26fe 100644
--- a/lldb/include/lldb/Breakpoint/WatchpointResource.h
+++ b/lldb/include/lldb/Breakpoint/WatchpointResource.h
@@ -121,14 +121,6 @@ class WatchpointResource
   ///    A copy of the Watchpoints which own this resource.
   WatchpointCollection CopyConstituentsList();
 
-  // The ID of the WatchpointResource is set by the WatchpointResourceList
-  // when the Resource has been set in the inferior and is being added
-  // to the List, in an attempt to match the hardware watchpoint register
-  // ordering.  If a Process can correctly identify the hardware watchpoint
-  // register index when it has created the Resource, it may initialize it
-  // before it is inserted in the WatchpointResourceList.
-  void SetID(lldb::wp_resource_id_t);
-
   lldb::wp_resource_id_t GetID() const;
 
   bool Contains(lldb::addr_t addr);
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/WatchpointResource.cpp b/lldb/source/Breakpoint/WatchpointResource.cpp
index d0f8dc346f3c024..c1eb50c0358b30e 100644
--- a/lldb/source/Breakpoint/WatchpointResource.cpp
+++ b/lldb/source/Breakpoint/WatchpointResource.cpp
@@ -42,8 +42,6 @@ void WatchpointResource::SetType(bool read, bool write) {
 
 wp_resource_id_t WatchpointResource::GetID() const { return m_id; }
 
-void WatchpointResource::SetID(wp_resource_id_t id) { m_id = id; }
-
 bool WatchpointResource::Contains(addr_t addr) {
   if (addr >= m_addr && addr < m_addr + m_size)
     return true;
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; }

``````````

</details>


https://github.com/llvm/llvm-project/pull/79388


More information about the lldb-commits mailing list