[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)
Jason Molenda via lldb-commits
lldb-commits at lists.llvm.org
Tue Oct 24 16:04:47 PDT 2023
================
@@ -0,0 +1,140 @@
+//===-- 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/Breakpoint/WatchpointCollection.h"
+#include "lldb/lldb-public.h"
+
+#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();
+
+ void GetMemoryRange(lldb::addr_t &addr, size_t &size) const;
+
+ lldb::addr_t GetAddress() const;
+
+ size_t GetByteSize() const;
+
+ void GetType(bool &read, bool &write) const;
+
+ void SetType(bool read, bool write);
+
+ /// 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();
----------------
jasonmolenda wrote:
tbh there could be an argument for locking the whole object because a WatchpointResource may be expanded to service multiple watchpoints (one watchpoint watches bytes 0-1, a second watchpoint watches bytes 2-3) and then reduced again when one of those watchpoints is deleted/disabled.
https://github.com/llvm/llvm-project/pull/68845
More information about the lldb-commits
mailing list