|
|
|||
File indexing completed on 2026-05-10 08:42:44
0001 //===-- WatchpointResource.h ------------------------------------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 0009 #ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H 0010 #define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H 0011 0012 #include "lldb/Utility/Iterable.h" 0013 #include "lldb/lldb-public.h" 0014 0015 #include <mutex> 0016 #include <vector> 0017 0018 namespace lldb_private { 0019 0020 class WatchpointResource 0021 : public std::enable_shared_from_this<WatchpointResource> { 0022 0023 public: 0024 WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write); 0025 0026 ~WatchpointResource(); 0027 0028 typedef lldb::wp_resource_id_t SiteID; 0029 typedef lldb::watch_id_t ConstituentID; 0030 0031 lldb::addr_t GetLoadAddress() const; 0032 0033 size_t GetByteSize() const; 0034 0035 bool WatchpointResourceRead() const; 0036 0037 bool WatchpointResourceWrite() const; 0038 0039 void SetType(bool read, bool write); 0040 0041 typedef std::vector<lldb::WatchpointSP> WatchpointCollection; 0042 typedef LockingAdaptedIterable<WatchpointCollection, lldb::WatchpointSP, 0043 vector_adapter, std::mutex> 0044 WatchpointIterable; 0045 0046 /// Iterate over the watchpoint constituents for this resource 0047 /// 0048 /// \return 0049 /// An Iterable object which can be used to loop over the watchpoints 0050 /// that are constituents of this resource. 0051 WatchpointIterable Constituents() { 0052 return WatchpointIterable(m_constituents, m_constituents_mutex); 0053 } 0054 0055 /// Enquires of the atchpoints that produced this watchpoint resource 0056 /// whether we should stop at this location. 0057 /// 0058 /// \param[in] context 0059 /// This contains the information about this stop. 0060 /// 0061 /// \return 0062 /// \b true if we should stop, \b false otherwise. 0063 bool ShouldStop(StoppointCallbackContext *context); 0064 0065 /// Standard Dump method 0066 void Dump(Stream *s) const; 0067 0068 /// The "Constituents" are the watchpoints that share this resource. 0069 /// The method adds the \a constituent to this resource's constituent list. 0070 /// 0071 /// \param[in] constituent 0072 /// \a constituent is the Wachpoint to add. 0073 void AddConstituent(const lldb::WatchpointSP &constituent); 0074 0075 /// The method removes the constituent at \a constituent from this watchpoint 0076 /// resource. 0077 void RemoveConstituent(lldb::WatchpointSP &constituent); 0078 0079 /// This method returns the number of Watchpoints currently using 0080 /// watchpoint resource. 0081 /// 0082 /// \return 0083 /// The number of constituents. 0084 size_t GetNumberOfConstituents(); 0085 0086 /// This method returns the Watchpoint at index \a index using this 0087 /// Resource. The constituents are listed ordinally from 0 to 0088 /// GetNumberOfConstituents() - 1 so you can use this method to iterate over 0089 /// the constituents. 0090 /// 0091 /// \param[in] idx 0092 /// The index in the list of constituents for which you wish the 0093 /// constituent location. 0094 /// 0095 /// \return 0096 /// The Watchpoint at that index. 0097 lldb::WatchpointSP GetConstituentAtIndex(size_t idx); 0098 0099 /// Check if the constituents includes a watchpoint. 0100 /// 0101 /// \param[in] wp_sp 0102 /// The WatchpointSP to search for. 0103 /// 0104 /// \result 0105 /// true if this resource's constituents includes the watchpoint. 0106 bool ConstituentsContains(const lldb::WatchpointSP &wp_sp); 0107 0108 /// Check if the constituents includes a watchpoint. 0109 /// 0110 /// \param[in] wp 0111 /// The Watchpoint to search for. 0112 /// 0113 /// \result 0114 /// true if this resource's constituents includes the watchpoint. 0115 bool ConstituentsContains(const lldb_private::Watchpoint *wp); 0116 0117 /// This method copies the watchpoint resource's constituents into a new 0118 /// collection. It does this while the constituents mutex is locked. 0119 /// 0120 /// \return 0121 /// A copy of the Watchpoints which own this resource. 0122 WatchpointCollection CopyConstituentsList(); 0123 0124 lldb::wp_resource_id_t GetID() const; 0125 0126 bool Contains(lldb::addr_t addr); 0127 0128 protected: 0129 // The StopInfoWatchpoint knows when it is processing a hit for a thread for 0130 // a site, so let it be the one to manage setting the location hit count once 0131 // and only once. 0132 friend class StopInfoWatchpoint; 0133 0134 void BumpHitCounts(); 0135 0136 private: 0137 static lldb::wp_resource_id_t GetNextID(); 0138 0139 lldb::wp_resource_id_t m_id; 0140 0141 // Start address & size aligned & expanded to be a valid watchpoint 0142 // memory granule on this target. 0143 lldb::addr_t m_addr; 0144 size_t m_size; 0145 0146 bool m_watch_read; 0147 bool m_watch_write; 0148 0149 /// The Watchpoints which own this resource. 0150 WatchpointCollection m_constituents; 0151 0152 /// This mutex protects the constituents collection. 0153 std::mutex m_constituents_mutex; 0154 0155 WatchpointResource(const WatchpointResource &) = delete; 0156 const WatchpointResource &operator=(const WatchpointResource &) = delete; 0157 }; 0158 0159 } // namespace lldb_private 0160 0161 #endif // LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|