1 //===-- BreakpointLocationCollection.h --------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_BreakpointLocationCollection_h_
11 #define liblldb_BreakpointLocationCollection_h_
18 // Other libraries and framework includes
20 #include "lldb/Utility/Iterable.h"
21 #include "lldb/lldb-private.h"
23 namespace lldb_private {
25 class BreakpointLocationCollection {
27 BreakpointLocationCollection();
29 ~BreakpointLocationCollection();
31 //------------------------------------------------------------------
32 /// Add the breakpoint \a bp_loc_sp to the list.
35 /// Shared pointer to the breakpoint location that will get added
39 /// Returns breakpoint location id.
40 //------------------------------------------------------------------
41 void Add(const lldb::BreakpointLocationSP &bp_loc_sp);
43 //------------------------------------------------------------------
44 /// Removes the breakpoint location given by \b breakID from this
47 /// @param[in] break_id
48 /// The breakpoint index to remove.
50 /// @param[in] break_loc_id
51 /// The breakpoint location index in break_id to remove.
54 /// \b true if the breakpoint was in the list.
55 //------------------------------------------------------------------
56 bool Remove(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
58 //------------------------------------------------------------------
59 /// Returns a shared pointer to the breakpoint location with id \a
62 /// @param[in] break_id
63 /// The breakpoint ID to seek for.
65 /// @param[in] break_loc_id
66 /// The breakpoint location ID in \a break_id to seek for.
69 /// A shared pointer to the breakpoint. May contain a NULL
70 /// pointer if the breakpoint doesn't exist.
71 //------------------------------------------------------------------
72 lldb::BreakpointLocationSP FindByIDPair(lldb::break_id_t break_id,
73 lldb::break_id_t break_loc_id);
75 //------------------------------------------------------------------
76 /// Returns a shared pointer to the breakpoint location with id \a
77 /// breakID, const version.
79 /// @param[in] breakID
80 /// The breakpoint location ID to seek for.
82 /// @param[in] break_loc_id
83 /// The breakpoint location ID in \a break_id to seek for.
86 /// A shared pointer to the breakpoint. May contain a NULL
87 /// pointer if the breakpoint doesn't exist.
88 //------------------------------------------------------------------
89 const lldb::BreakpointLocationSP
90 FindByIDPair(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;
92 //------------------------------------------------------------------
93 /// Returns a shared pointer to the breakpoint location with index
97 /// The breakpoint location index to seek for.
100 /// A shared pointer to the breakpoint. May contain a NULL
101 /// pointer if the breakpoint doesn't exist.
102 //------------------------------------------------------------------
103 lldb::BreakpointLocationSP GetByIndex(size_t i);
105 //------------------------------------------------------------------
106 /// Returns a shared pointer to the breakpoint location with index
107 /// \a i, const version.
110 /// The breakpoint location index to seek for.
113 /// A shared pointer to the breakpoint. May contain a NULL
114 /// pointer if the breakpoint doesn't exist.
115 //------------------------------------------------------------------
116 const lldb::BreakpointLocationSP GetByIndex(size_t i) const;
118 //------------------------------------------------------------------
119 /// Returns the number of elements in this breakpoint location list.
122 /// The number of elements.
123 //------------------------------------------------------------------
124 size_t GetSize() const { return m_break_loc_collection.size(); }
126 //------------------------------------------------------------------
127 /// Enquires of all the breakpoint locations in this list whether
128 /// we should stop at a hit at \a breakID.
130 /// @param[in] context
131 /// This contains the information about this stop.
133 /// @param[in] breakID
134 /// This break ID that we hit.
137 /// \b true if we should stop, \b false otherwise.
138 //------------------------------------------------------------------
139 bool ShouldStop(StoppointCallbackContext *context);
141 //------------------------------------------------------------------
142 /// Print a description of the breakpoint locations in this list
143 /// to the stream \a s.
146 /// The stream to which to print the description.
149 /// The description level that indicates the detail level to
152 /// @see lldb::DescriptionLevel
153 //------------------------------------------------------------------
154 void GetDescription(Stream *s, lldb::DescriptionLevel level);
156 //------------------------------------------------------------------
157 /// Check whether this collection of breakpoint locations have any
158 /// thread specifiers, and if yes, is \a thread_id contained in any
159 /// of these specifiers.
161 /// @param[in] thread
162 /// The thread against which to test.
165 /// \b true if the collection contains at least one location that
166 /// would be valid for this thread, false otherwise.
167 //------------------------------------------------------------------
168 bool ValidForThisThread(Thread *thread);
170 //------------------------------------------------------------------
171 /// Tell whether ALL the breakpoints in the location collection are internal.
174 /// \b true if all breakpoint locations are owned by internal breakpoints,
175 /// \b false otherwise.
176 //------------------------------------------------------------------
177 bool IsInternal() const;
180 //------------------------------------------------------------------
181 // Classes that inherit from BreakpointLocationCollection can see
183 //------------------------------------------------------------------
186 //------------------------------------------------------------------
187 // For BreakpointLocationCollection only
188 //------------------------------------------------------------------
190 typedef std::vector<lldb::BreakpointLocationSP> collection;
192 collection::iterator GetIDPairIterator(lldb::break_id_t break_id,
193 lldb::break_id_t break_loc_id);
195 collection::const_iterator
196 GetIDPairConstIterator(lldb::break_id_t break_id,
197 lldb::break_id_t break_loc_id) const;
199 collection m_break_loc_collection;
200 mutable std::mutex m_collection_mutex;
203 typedef AdaptedIterable<collection, lldb::BreakpointLocationSP,
205 BreakpointLocationCollectionIterable;
206 BreakpointLocationCollectionIterable BreakpointLocations() {
207 return BreakpointLocationCollectionIterable(m_break_loc_collection);
211 } // namespace lldb_private
213 #endif // liblldb_BreakpointLocationCollection_h_