[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Thu Oct 26 17:19:32 PDT 2023
================
@@ -0,0 +1,155 @@
+//===-- WatchpointResource.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_WATCHPOINTRESOURCE_H
+#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+
+#include "lldb/Utility/Iterable.h"
+#include "lldb/lldb-public.h"
+
+#include <mutex>
+#include <set>
+
+namespace lldb_private {
+
+class WatchpointResource
+ : public std::enable_shared_from_this<WatchpointResource> {
+
+public:
+ // Constructors and Destructors
+ WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write);
+
+ ~WatchpointResource();
+
+ lldb::addr_t GetAddress() const;
+
+ size_t GetByteSize() const;
+
+ bool WatchpointResourceRead() const;
+
+ bool WatchpointResourceWrite() const;
+
+ void SetType(bool read, bool write);
+
+ typedef std::vector<lldb::WatchpointSP> WatchpointCollection;
+ typedef LockingAdaptedIterable<WatchpointCollection, lldb::WatchpointSP,
+ vector_adapter, std::recursive_mutex>
+ WatchpointIterable;
+
+ /// Iterate over the watchpoint owners for this resource
+ ///
+ /// \return
+ /// An Iterable object which can be used to loop over the watchpoints
+ /// that are owners of this resource.
+ WatchpointIterable Owners() {
+ return WatchpointIterable(m_owners, m_owners_mutex);
+ }
+
+ /// The "Owners" are the watchpoints that share this resource.
+ /// The method adds the \a owner to this resource's owner list.
+ ///
+ /// \param[in] owner
+ /// \a owner is the Wachpoint to add.
+ void AddOwner(const lldb::WatchpointSP &owner);
+
+ /// The method removes the owner at \a owner from this watchpoint
+ /// resource.
+ void RemoveOwner(lldb::WatchpointSP &owner);
+
+ /// This method returns the number of Watchpoints currently using
+ /// watchpoint resource.
+ ///
+ /// \return
+ /// The number of owners.
+ size_t GetNumberOfOwners();
+
+ /// This method returns the Watchpoint at index \a index using this
+ /// Resource. The owners are listed ordinally from 0 to
+ /// GetNumberOfOwners() - 1 so you can use this method to iterate over the
+ /// owners.
+ ///
+ /// \param[in] idx
+ /// The index in the list of owners for which you wish the owner location.
+ ///
+ /// \return
+ /// The Watchpoint at that index.
+ lldb::WatchpointSP GetOwnerAtIndex(size_t idx);
+
+ /// Check if the owners includes a watchpoint.
+ ///
+ /// \param[in] wp_sp
+ /// The WatchpointSP to search for.
+ ///
+ /// \result
+ /// true if this resource's owners includes the watchpoint.
+ bool OwnersContains(lldb::WatchpointSP &wp_sp);
+
+ /// Check if the owners includes a watchpoint.
+ ///
+ /// \param[in] wp
+ /// The Watchpoint to search for.
+ ///
+ /// \result
+ /// true if this resource's owners includes the watchpoint.
+ bool OwnersContains(const lldb_private::Watchpoint *wp);
----------------
JDevlieghere wrote:
Can this be a const reference?
https://github.com/llvm/llvm-project/pull/68845
More information about the lldb-commits
mailing list