LLDB mainline
BreakpointLocationCollection.h
Go to the documentation of this file.
1//===-- BreakpointLocationCollection.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_BREAKPOINTLOCATIONCOLLECTION_H
10#define LLDB_BREAKPOINT_BREAKPOINTLOCATIONCOLLECTION_H
11
12#include <map>
13#include <mutex>
14#include <vector>
15
17#include "lldb/lldb-private.h"
18
19namespace lldb_private {
20
22public:
23 /// Breakpoint locations don't keep their breakpoint owners alive, so neither
24 /// will a collection of breakpoint locations. However, if you need to
25 /// use this collection in a context where some of the breakpoints whose
26 /// locations are in the collection might get deleted during its lifespan,
27 /// then you need to make sure the breakpoints don't get deleted out from
28 /// under you. To do that, pass true for preserving, and so long as there is
29 /// a location for a given breakpoint in the collection, the breakpoint will
30 /// not get destroyed.
31 BreakpointLocationCollection(bool preserving = false);
32
34
37
38 /// Add the breakpoint \a bp_loc_sp to the list.
39 ///
40 /// \param[in] bp_loc_sp
41 /// Shared pointer to the breakpoint location that will get added
42 /// to the list.
43 void Add(const lldb::BreakpointLocationSP &bp_loc_sp);
44
45 /// Removes the breakpoint location given by \b breakID from this
46 /// list.
47 ///
48 /// \param[in] break_id
49 /// The breakpoint index to remove.
50 ///
51 /// \param[in] break_loc_id
52 /// The breakpoint location index in break_id to remove.
53 ///
54 /// \result
55 /// \b true if the breakpoint was in the list.
56 bool Remove(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
57
58 /// Returns a shared pointer to the breakpoint location with id \a
59 /// breakID.
60 ///
61 /// \param[in] break_id
62 /// The breakpoint ID to seek for.
63 ///
64 /// \param[in] break_loc_id
65 /// The breakpoint location ID in \a break_id to seek for.
66 ///
67 /// \result
68 /// A shared pointer to the breakpoint. May contain a NULL
69 /// pointer if the breakpoint doesn't exist.
71 lldb::break_id_t break_loc_id);
72
73 /// Returns a shared pointer to the breakpoint location with id \a
74 /// breakID, const version.
75 ///
76 /// \param[in] break_id
77 /// The breakpoint location ID to seek for.
78 ///
79 /// \param[in] break_loc_id
80 /// The breakpoint location ID in \a break_id to seek for.
81 ///
82 /// \result
83 /// A shared pointer to the breakpoint. May contain a NULL
84 /// pointer if the breakpoint doesn't exist.
86 FindByIDPair(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;
87
88 /// Returns a shared pointer to the breakpoint location with index
89 /// \a i.
90 ///
91 /// \param[in] i
92 /// The breakpoint location index to seek for.
93 ///
94 /// \result
95 /// A shared pointer to the breakpoint. May contain a NULL
96 /// pointer if the breakpoint doesn't exist.
98
99 /// Returns a shared pointer to the breakpoint location with index
100 /// \a i, const version.
101 ///
102 /// \param[in] i
103 /// The breakpoint location index to seek for.
104 ///
105 /// \result
106 /// A shared pointer to the breakpoint. May contain a NULL
107 /// pointer if the breakpoint doesn't exist.
108 const lldb::BreakpointLocationSP GetByIndex(size_t i) const;
109
110 /// Returns the number of elements in this breakpoint location list.
111 ///
112 /// \result
113 /// The number of elements.
114 size_t GetSize() const { return m_break_loc_collection.size(); }
115
116 /// Enquires of all the breakpoint locations in this list whether
117 /// we should stop at a hit at \a breakID.
118 ///
119 /// \param[in] context
120 /// This contains the information about this stop.
121 ///
122 /// \return
123 /// \b true if we should stop, \b false otherwise.
125 BreakpointLocationCollection &stopped_bp_locs);
126
127 /// Print a description of the breakpoint locations in this list
128 /// to the stream \a s.
129 ///
130 /// \param[in] s
131 /// The stream to which to print the description.
132 ///
133 /// \param[in] level
134 /// The description level that indicates the detail level to
135 /// provide.
136 ///
137 /// \see lldb::DescriptionLevel
139
140 /// Check whether this collection of breakpoint locations have any
141 /// thread specifiers, and if yes, is \a thread_id contained in any
142 /// of these specifiers.
143 ///
144 /// \param[in] thread
145 /// The thread against which to test.
146 ///
147 /// return
148 /// \b true if the collection contains at least one location that
149 /// would be valid for this thread, false otherwise.
150 bool ValidForThisThread(Thread &thread);
151
152 /// Tell whether ALL the breakpoints in the location collection are internal.
153 ///
154 /// \result
155 /// \b true if all breakpoint locations are owned by internal breakpoints,
156 /// \b false otherwise.
157 bool IsInternal() const;
158
159protected:
160 // Classes that inherit from BreakpointLocationCollection can see and modify
161 // these
162
163private:
164 // For BreakpointLocationCollection only
165
166 typedef std::vector<lldb::BreakpointLocationSP> collection;
167
168 collection::iterator GetIDPairIterator(lldb::break_id_t break_id,
169 lldb::break_id_t break_loc_id);
170
171 collection::const_iterator
173 lldb::break_id_t break_loc_id) const;
174
176 mutable std::recursive_mutex m_collection_mutex;
177 /// These are used if we're preserving breakpoints in this list:
178 const bool m_preserving_bkpts = false;
179 std::map<std::pair<lldb::break_id_t, lldb::break_id_t>, lldb::BreakpointSP>
181
182public:
189};
190} // namespace lldb_private
191
192#endif // LLDB_BREAKPOINT_BREAKPOINTLOCATIONCOLLECTION_H
lldb::BreakpointLocationSP FindByIDPair(lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
Returns a shared pointer to the breakpoint location with id breakID.
BreakpointLocationCollection(bool preserving=false)
Breakpoint locations don't keep their breakpoint owners alive, so neither will a collection of breakp...
void GetDescription(Stream *s, lldb::DescriptionLevel level)
Print a description of the breakpoint locations in this list to the stream s.
std::map< std::pair< lldb::break_id_t, lldb::break_id_t >, lldb::BreakpointSP > m_preserved_bps
bool IsInternal() const
Tell whether ALL the breakpoints in the location collection are internal.
bool ValidForThisThread(Thread &thread)
Check whether this collection of breakpoint locations have any thread specifiers, and if yes,...
collection::const_iterator GetIDPairConstIterator(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const
BreakpointLocationCollection & operator=(const BreakpointLocationCollection &rhs)
collection::iterator GetIDPairIterator(lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
std::vector< lldb::BreakpointLocationSP > collection
BreakpointLocationCollectionIterable BreakpointLocations()
lldb::BreakpointLocationSP GetByIndex(size_t i)
Returns a shared pointer to the breakpoint location with index i.
bool ShouldStop(StoppointCallbackContext *context, BreakpointLocationCollection &stopped_bp_locs)
Enquires of all the breakpoint locations in this list whether we should stop at a hit at breakID.
void Add(const lldb::BreakpointLocationSP &bp_loc_sp)
Add the breakpoint bp_loc_sp to the list.
bool Remove(lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
Removes the breakpoint location given by breakID from this list.
LockingAdaptedIterable< std::recursive_mutex, collection > BreakpointLocationCollectionIterable
size_t GetSize() const
Returns the number of elements in this breakpoint location list.
const bool m_preserving_bkpts
These are used if we're preserving breakpoints in this list:
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
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
int32_t break_id_t
Definition lldb-types.h:86