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;
43 vector_adapter, std::mutex>
45
46 /// Iterate over the watchpoint constituents for this resource
47 ///
48 /// \return
49 /// An Iterable object which can be used to loop over the watchpoints
50 /// that are constituents of this resource.
53 }
54
55 /// Enquires of the atchpoints that produced this watchpoint resource
56 /// whether we should stop at this location.
57 ///
58 /// \param[in] context
59 /// This contains the information about this stop.
60 ///
61 /// \return
62 /// \b true if we should stop, \b false otherwise.
64
65 /// Standard Dump method
66 void Dump(Stream *s) const;
67
68 /// The "Constituents" are the watchpoints that share this resource.
69 /// The method adds the \a constituent to this resource's constituent list.
70 ///
71 /// \param[in] constituent
72 /// \a constituent is the Wachpoint to add.
73 void AddConstituent(const lldb::WatchpointSP &constituent);
74
75 /// The method removes the constituent at \a constituent from this watchpoint
76 /// resource.
77 void RemoveConstituent(lldb::WatchpointSP &constituent);
78
79 /// This method returns the number of Watchpoints currently using
80 /// watchpoint resource.
81 ///
82 /// \return
83 /// The number of constituents.
85
86 /// This method returns the Watchpoint at index \a index using this
87 /// Resource. The constituents are listed ordinally from 0 to
88 /// GetNumberOfConstituents() - 1 so you can use this method to iterate over
89 /// the constituents.
90 ///
91 /// \param[in] idx
92 /// The index in the list of constituents for which you wish the
93 /// constituent location.
94 ///
95 /// \return
96 /// The Watchpoint at that index.
98
99 /// Check if the constituents includes a watchpoint.
100 ///
101 /// \param[in] wp_sp
102 /// The WatchpointSP to search for.
103 ///
104 /// \result
105 /// true if this resource's constituents includes the watchpoint.
106 bool ConstituentsContains(const lldb::WatchpointSP &wp_sp);
107
108 /// Check if the constituents includes a watchpoint.
109 ///
110 /// \param[in] wp
111 /// The Watchpoint to search for.
112 ///
113 /// \result
114 /// true if this resource's constituents includes the watchpoint.
116
117 /// This method copies the watchpoint resource's constituents into a new
118 /// collection. It does this while the constituents mutex is locked.
119 ///
120 /// \return
121 /// A copy of the Watchpoints which own this resource.
123
125
126 bool Contains(lldb::addr_t addr);
127
128protected:
129 // The StopInfoWatchpoint knows when it is processing a hit for a thread for
130 // a site, so let it be the one to manage setting the location hit count once
131 // and only once.
132 friend class StopInfoWatchpoint;
133
135
136private:
138
140
141 // Start address & size aligned & expanded to be a valid watchpoint
142 // memory granule on this target.
144 size_t m_size;
145
148
149 /// The Watchpoints which own this resource.
151
152 /// This mutex protects the constituents collection.
154
157};
158
159} // namespace lldb_private
160
161#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.
LockingAdaptedIterable< WatchpointCollection, lldb::WatchpointSP, vector_adapter, std::mutex > WatchpointIterable
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()
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(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.
E vector_adapter(I &iter)
Definition: Iterable.h:21
std::shared_ptr< lldb_private::Watchpoint > WatchpointSP
Definition: lldb-forward.h:489
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