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
36
37 /// Add the breakpoint \a bp_loc_sp to the list.
38 ///
39 /// \param[in] bp_loc_sp
40 /// Shared pointer to the breakpoint location that will get added
41 /// to the list.
42 void Add(const lldb::BreakpointLocationSP &bp_loc_sp);
43
44 /// Removes the breakpoint location given by \b breakID from this
45 /// list.
46 ///
47 /// \param[in] break_id
48 /// The breakpoint index to remove.
49 ///
50 /// \param[in] break_loc_id
51 /// The breakpoint location index in break_id to remove.
52 ///
53 /// \result
54 /// \b true if the breakpoint was in the list.
55 bool Remove(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
56
57 /// Returns a shared pointer to the breakpoint location with id \a
58 /// breakID.
59 ///
60 /// \param[in] break_id
61 /// The breakpoint ID to seek for.
62 ///
63 /// \param[in] break_loc_id
64 /// The breakpoint location ID in \a break_id to seek for.
65 ///
66 /// \result
67 /// A shared pointer to the breakpoint. May contain a NULL
68 /// pointer if the breakpoint doesn't exist.
70 lldb::break_id_t break_loc_id);
71
72 /// Returns a shared pointer to the breakpoint location with id \a
73 /// breakID, const version.
74 ///
75 /// \param[in] break_id
76 /// The breakpoint location ID to seek for.
77 ///
78 /// \param[in] break_loc_id
79 /// The breakpoint location ID in \a break_id to seek for.
80 ///
81 /// \result
82 /// A shared pointer to the breakpoint. May contain a NULL
83 /// pointer if the breakpoint doesn't exist.
85 FindByIDPair(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;
86
87 /// Returns a shared pointer to the breakpoint location with index
88 /// \a i.
89 ///
90 /// \param[in] i
91 /// The breakpoint location index to seek for.
92 ///
93 /// \result
94 /// A shared pointer to the breakpoint. May contain a NULL
95 /// pointer if the breakpoint doesn't exist.
97
98 /// Returns a shared pointer to the breakpoint location with index
99 /// \a i, const version.
100 ///
101 /// \param[in] i
102 /// The breakpoint location index to seek for.
103 ///
104 /// \result
105 /// A shared pointer to the breakpoint. May contain a NULL
106 /// pointer if the breakpoint doesn't exist.
107 const lldb::BreakpointLocationSP GetByIndex(size_t i) const;
108
109 /// Returns the number of elements in this breakpoint location list.
110 ///
111 /// \result
112 /// The number of elements.
113 size_t GetSize() const { return m_break_loc_collection.size(); }
114
115 /// Enquires of all the breakpoint locations in this list whether
116 /// we should stop at a hit at \a breakID.
117 ///
118 /// \param[in] context
119 /// This contains the information about this stop.
120 ///
121 /// \return
122 /// \b true if we should stop, \b false otherwise.
124 BreakpointLocationCollection &stopped_bp_locs);
125
126 /// Print a description of the breakpoint locations in this list
127 /// to the stream \a s.
128 ///
129 /// \param[in] s
130 /// The stream to which to print the description.
131 ///
132 /// \param[in] level
133 /// The description level that indicates the detail level to
134 /// provide.
135 ///
136 /// \see lldb::DescriptionLevel
138
139 /// Check whether this collection of breakpoint locations have any
140 /// thread specifiers, and if yes, is \a thread_id contained in any
141 /// of these specifiers.
142 ///
143 /// \param[in] thread
144 /// The thread against which to test.
145 ///
146 /// return
147 /// \b true if the collection contains at least one location that
148 /// would be valid for this thread, false otherwise.
149 bool ValidForThisThread(Thread &thread);
150
151 /// Tell whether ALL the breakpoints in the location collection are internal.
152 ///
153 /// \result
154 /// \b true if all breakpoint locations are owned by internal breakpoints,
155 /// \b false otherwise.
156 bool IsInternal() const;
157
158protected:
159 // Classes that inherit from BreakpointLocationCollection can see and modify
160 // these
161
162private:
163 // For BreakpointLocationCollection only
164
165 typedef std::vector<lldb::BreakpointLocationSP> collection;
166
167 collection::iterator GetIDPairIterator(lldb::break_id_t break_id,
168 lldb::break_id_t break_loc_id);
169
170 collection::const_iterator
172 lldb::break_id_t break_loc_id) const;
173
175 mutable std::mutex m_collection_mutex;
176 /// These are used if we're preserving breakpoints in this list:
177 const bool m_preserving_bkpts = false;
178 std::map<std::pair<lldb::break_id_t, lldb::break_id_t>, lldb::BreakpointSP>
180
181public:
182 typedef llvm::iterator_range<collection::const_iterator>
187};
188} // namespace lldb_private
189
190#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
llvm::iterator_range< collection::const_iterator > BreakpointLocationCollectionIterable
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.
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