1 //===-- BreakpointLocationCollection.h --------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef liblldb_BreakpointLocationCollection_h_
10 #define liblldb_BreakpointLocationCollection_h_
15 #include "lldb/Utility/Iterable.h"
16 #include "lldb/lldb-private.h"
18 namespace lldb_private {
20 class BreakpointLocationCollection {
22 BreakpointLocationCollection();
24 ~BreakpointLocationCollection();
26 BreakpointLocationCollection &operator=(const BreakpointLocationCollection &rhs);
28 /// Add the breakpoint \a bp_loc_sp to the list.
31 /// Shared pointer to the breakpoint location that will get added
35 /// Returns breakpoint location id.
36 void Add(const lldb::BreakpointLocationSP &bp_loc_sp);
38 /// Removes the breakpoint location given by \b breakID from this
41 /// \param[in] break_id
42 /// The breakpoint index to remove.
44 /// \param[in] break_loc_id
45 /// The breakpoint location index in break_id to remove.
48 /// \b true if the breakpoint was in the list.
49 bool Remove(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
51 /// Returns a shared pointer to the breakpoint location with id \a
54 /// \param[in] break_id
55 /// The breakpoint ID to seek for.
57 /// \param[in] break_loc_id
58 /// The breakpoint location ID in \a break_id to seek for.
61 /// A shared pointer to the breakpoint. May contain a NULL
62 /// pointer if the breakpoint doesn't exist.
63 lldb::BreakpointLocationSP FindByIDPair(lldb::break_id_t break_id,
64 lldb::break_id_t break_loc_id);
66 /// Returns a shared pointer to the breakpoint location with id \a
67 /// breakID, const version.
69 /// \param[in] breakID
70 /// The breakpoint location ID to seek for.
72 /// \param[in] break_loc_id
73 /// The breakpoint location ID in \a break_id to seek for.
76 /// A shared pointer to the breakpoint. May contain a NULL
77 /// pointer if the breakpoint doesn't exist.
78 const lldb::BreakpointLocationSP
79 FindByIDPair(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;
81 /// Returns a shared pointer to the breakpoint location with index
85 /// The breakpoint location index to seek for.
88 /// A shared pointer to the breakpoint. May contain a NULL
89 /// pointer if the breakpoint doesn't exist.
90 lldb::BreakpointLocationSP GetByIndex(size_t i);
92 /// Returns a shared pointer to the breakpoint location with index
93 /// \a i, const version.
96 /// The breakpoint location index to seek for.
99 /// A shared pointer to the breakpoint. May contain a NULL
100 /// pointer if the breakpoint doesn't exist.
101 const lldb::BreakpointLocationSP GetByIndex(size_t i) const;
103 /// Returns the number of elements in this breakpoint location list.
106 /// The number of elements.
107 size_t GetSize() const { return m_break_loc_collection.size(); }
109 /// Enquires of all the breakpoint locations in this list whether
110 /// we should stop at a hit at \a breakID.
112 /// \param[in] context
113 /// This contains the information about this stop.
115 /// \param[in] breakID
116 /// This break ID that we hit.
119 /// \b true if we should stop, \b false otherwise.
120 bool ShouldStop(StoppointCallbackContext *context);
122 /// Print a description of the breakpoint locations in this list
123 /// to the stream \a s.
126 /// The stream to which to print the description.
129 /// The description level that indicates the detail level to
132 /// \see lldb::DescriptionLevel
133 void GetDescription(Stream *s, lldb::DescriptionLevel level);
135 /// Check whether this collection of breakpoint locations have any
136 /// thread specifiers, and if yes, is \a thread_id contained in any
137 /// of these specifiers.
139 /// \param[in] thread
140 /// The thread against which to test.
143 /// \b true if the collection contains at least one location that
144 /// would be valid for this thread, false otherwise.
145 bool ValidForThisThread(Thread *thread);
147 /// Tell whether ALL the breakpoints in the location collection are internal.
150 /// \b true if all breakpoint locations are owned by internal breakpoints,
151 /// \b false otherwise.
152 bool IsInternal() const;
155 // Classes that inherit from BreakpointLocationCollection can see and modify
159 // For BreakpointLocationCollection only
161 typedef std::vector<lldb::BreakpointLocationSP> collection;
163 collection::iterator GetIDPairIterator(lldb::break_id_t break_id,
164 lldb::break_id_t break_loc_id);
166 collection::const_iterator
167 GetIDPairConstIterator(lldb::break_id_t break_id,
168 lldb::break_id_t break_loc_id) const;
170 collection m_break_loc_collection;
171 mutable std::mutex m_collection_mutex;
174 typedef AdaptedIterable<collection, lldb::BreakpointLocationSP,
176 BreakpointLocationCollectionIterable;
177 BreakpointLocationCollectionIterable BreakpointLocations() {
178 return BreakpointLocationCollectionIterable(m_break_loc_collection);
182 } // namespace lldb_private
184 #endif // liblldb_BreakpointLocationCollection_h_