LLDB mainline
WatchpointResource.h
Go to the documentation of this file.
1//===-- WatchpointResource.h ------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
10#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
11
13#include "lldb/lldb-public.h"
14
15#include <mutex>
16#include <vector>
17
18namespace lldb_private {
19
21 : public std::enable_shared_from_this<WatchpointResource> {
22
23public:
24 WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write);
25
27
30
32
33 size_t GetByteSize() const;
34
35 bool WatchpointResourceRead() const;
36
37 bool WatchpointResourceWrite() const;
38
39 void SetType(bool read, bool write);
40
41 typedef std::vector<lldb::WatchpointSP> WatchpointCollection;
44
45 /// Iterate over the watchpoint constituents for this resource
46 ///
47 /// \return
48 /// An Iterable object which can be used to loop over the watchpoints
49 /// that are constituents of this resource.
53
54 /// Enquires of the atchpoints that produced this watchpoint resource
55 /// whether we should stop at this location.
56 ///
57 /// \param[in] context
58 /// This contains the information about this stop.
59 ///
60 /// \return
61 /// \b true if we should stop, \b false otherwise.
63
64 /// Standard Dump method
65 void Dump(Stream *s) const;
66
67 /// The "Constituents" are the watchpoints that share this resource.
68 /// The method adds the \a constituent to this resource's constituent list.
69 ///
70 /// \param[in] constituent
71 /// \a constituent is the Wachpoint to add.
72 void AddConstituent(const lldb::WatchpointSP &constituent);
73
74 /// The method removes the constituent at \a constituent from this watchpoint
75 /// resource.
76 void RemoveConstituent(lldb::WatchpointSP &constituent);
77
78 /// This method returns the number of Watchpoints currently using
79 /// watchpoint resource.
80 ///
81 /// \return
82 /// The number of constituents.
84
85 /// This method returns the Watchpoint at index \a index using this
86 /// Resource. The constituents are listed ordinally from 0 to
87 /// GetNumberOfConstituents() - 1 so you can use this method to iterate over
88 /// the constituents.
89 ///
90 /// \param[in] idx
91 /// The index in the list of constituents for which you wish the
92 /// constituent location.
93 ///
94 /// \return
95 /// The Watchpoint at that index.
97
98 /// Check if the constituents includes a watchpoint.
99 ///
100 /// \param[in] wp_sp
101 /// The WatchpointSP to search for.
102 ///
103 /// \result
104 /// true if this resource's constituents includes the watchpoint.
105 bool ConstituentsContains(const lldb::WatchpointSP &wp_sp);
106
107 /// Check if the constituents includes a watchpoint.
108 ///
109 /// \param[in] wp
110 /// The Watchpoint to search for.
111 ///
112 /// \result
113 /// true if this resource's constituents includes the watchpoint.
115
116 /// This method copies the watchpoint resource's constituents into a new
117 /// collection. It does this while the constituents mutex is locked.
118 ///
119 /// \return
120 /// A copy of the Watchpoints which own this resource.
122
124
125 bool Contains(lldb::addr_t addr);
126
127protected:
128 // The StopInfoWatchpoint knows when it is processing a hit for a thread for
129 // a site, so let it be the one to manage setting the location hit count once
130 // and only once.
131 friend class StopInfoWatchpoint;
132
134
135private:
137
139
140 // Start address & size aligned & expanded to be a valid watchpoint
141 // memory granule on this target.
143 size_t m_size;
144
147
148 /// The Watchpoints which own this resource.
150
151 /// This mutex protects the constituents collection.
153
156};
157
158} // namespace lldb_private
159
160#endif // LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
A stream class that can stream formatted output to a file.
Definition Stream.h:28
bool ShouldStop(StoppointCallbackContext *context)
Enquires of the atchpoints that produced this watchpoint resource whether we should stop at this loca...
size_t GetNumberOfConstituents()
This method returns the number of Watchpoints currently using watchpoint resource.
WatchpointCollection CopyConstituentsList()
This method copies the watchpoint resource's constituents into a new collection.
const WatchpointResource & operator=(const WatchpointResource &)=delete
void AddConstituent(const lldb::WatchpointSP &constituent)
The "Constituents" are the watchpoints that share this resource.
WatchpointCollection m_constituents
The Watchpoints which own this resource.
bool ConstituentsContains(const lldb::WatchpointSP &wp_sp)
Check if the constituents includes a watchpoint.
lldb::WatchpointSP GetConstituentAtIndex(size_t idx)
This method returns the Watchpoint at index index using this Resource.
lldb::wp_resource_id_t GetID() const
static lldb::wp_resource_id_t GetNextID()
LockingAdaptedIterable< std::mutex, WatchpointCollection > WatchpointIterable
void SetType(bool read, bool write)
void Dump(Stream *s) const
Standard Dump method.
std::mutex m_constituents_mutex
This mutex protects the constituents collection.
WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write)
WatchpointResource(const WatchpointResource &)=delete
void RemoveConstituent(lldb::WatchpointSP &constituent)
The method removes the constituent at constituent from this watchpoint resource.
std::vector< lldb::WatchpointSP > WatchpointCollection
WatchpointIterable Constituents()
Iterate over the watchpoint constituents for this resource.
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Watchpoint > WatchpointSP
int32_t watch_id_t
Definition lldb-types.h:87
uint64_t addr_t
Definition lldb-types.h:80
uint32_t wp_resource_id_t
Definition lldb-types.h:88