]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/lldb/Breakpoint/BreakpointLocationCollection.h
Vendor import of lldb release_39 branch r276489:
[FreeBSD/FreeBSD.git] / include / lldb / Breakpoint / BreakpointLocationCollection.h
1 //===-- BreakpointLocationCollection.h --------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_BreakpointLocationCollection_h_
11 #define liblldb_BreakpointLocationCollection_h_
12
13 // C Includes
14 // C++ Includes
15 #include <vector>
16 #include <mutex>
17
18 // Other libraries and framework includes
19 // Project includes
20 #include "lldb/lldb-private.h"
21 #include "lldb/Utility/Iterable.h"
22
23 namespace lldb_private {
24
25 class BreakpointLocationCollection
26 {
27 public:
28     BreakpointLocationCollection();
29
30     ~BreakpointLocationCollection();
31
32     //------------------------------------------------------------------
33     /// Add the breakpoint \a bp_loc_sp to the list.
34     ///
35     /// @param[in] bp_sp
36     ///     Shared pointer to the breakpoint location that will get added
37     ///     to the list.
38     ///
39     /// @result
40     ///     Returns breakpoint location id.
41     //------------------------------------------------------------------
42     void
43     Add (const lldb::BreakpointLocationSP& bp_loc_sp);
44
45     //------------------------------------------------------------------
46     /// Removes the breakpoint location given by \b breakID from this
47     /// list.
48     ///
49     /// @param[in] break_id
50     ///     The breakpoint index to remove.
51     ///
52     /// @param[in] break_loc_id
53     ///     The breakpoint location index in break_id to remove.
54     ///
55     /// @result
56     ///     \b true if the breakpoint was in the list.
57     //------------------------------------------------------------------
58     bool
59     Remove (lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
60
61     //------------------------------------------------------------------
62     /// Returns a shared pointer to the breakpoint location with id \a
63     /// breakID.
64     ///
65     /// @param[in] break_id
66     ///     The breakpoint  ID to seek for.
67     ///
68     /// @param[in] break_loc_id
69     ///     The breakpoint location ID in \a break_id to seek for.
70     ///
71     /// @result
72     ///     A shared pointer to the breakpoint.  May contain a NULL
73     ///     pointer if the breakpoint doesn't exist.
74     //------------------------------------------------------------------
75     lldb::BreakpointLocationSP
76     FindByIDPair (lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
77
78     //------------------------------------------------------------------
79     /// Returns a shared pointer to the breakpoint location with id \a
80     /// breakID, const version.
81     ///
82     /// @param[in] breakID
83     ///     The breakpoint location ID to seek for.
84     ///
85     /// @param[in] break_loc_id
86     ///     The breakpoint location ID in \a break_id to seek for.
87     ///
88     /// @result
89     ///     A shared pointer to the breakpoint.  May contain a NULL
90     ///     pointer if the breakpoint doesn't exist.
91     //------------------------------------------------------------------
92     const lldb::BreakpointLocationSP
93     FindByIDPair (lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;
94
95     //------------------------------------------------------------------
96     /// Returns a shared pointer to the breakpoint location with index
97     /// \a i.
98     ///
99     /// @param[in] i
100     ///     The breakpoint location index to seek for.
101     ///
102     /// @result
103     ///     A shared pointer to the breakpoint.  May contain a NULL
104     ///     pointer if the breakpoint doesn't exist.
105     //------------------------------------------------------------------
106     lldb::BreakpointLocationSP
107     GetByIndex (size_t i);
108
109     //------------------------------------------------------------------
110     /// Returns a shared pointer to the breakpoint location with index
111     /// \a i, const version.
112     ///
113     /// @param[in] i
114     ///     The breakpoint location index to seek for.
115     ///
116     /// @result
117     ///     A shared pointer to the breakpoint.  May contain a NULL
118     ///     pointer if the breakpoint doesn't exist.
119     //------------------------------------------------------------------
120     const lldb::BreakpointLocationSP
121     GetByIndex (size_t i) const;
122
123     //------------------------------------------------------------------
124     /// Returns the number of elements in this breakpoint location list.
125     ///
126     /// @result
127     ///     The number of elements.
128     //------------------------------------------------------------------
129     size_t
130     GetSize() const { return m_break_loc_collection.size(); }
131
132     //------------------------------------------------------------------
133     /// Enquires of all the breakpoint locations in this list whether
134     /// we should stop at a hit at \a breakID.
135     ///
136     /// @param[in] context
137     ///    This contains the information about this stop.
138     ///
139     /// @param[in] breakID
140     ///    This break ID that we hit.
141     ///
142     /// @return
143     ///    \b true if we should stop, \b false otherwise.
144     //------------------------------------------------------------------
145     bool
146     ShouldStop (StoppointCallbackContext *context);
147
148     //------------------------------------------------------------------
149     /// Print a description of the breakpoint locations in this list
150     /// to the stream \a s.
151     ///
152     /// @param[in] s
153     ///     The stream to which to print the description.
154     ///
155     /// @param[in] level
156     ///     The description level that indicates the detail level to
157     ///     provide.
158     ///
159     /// @see lldb::DescriptionLevel
160     //------------------------------------------------------------------
161     void GetDescription (Stream *s, lldb::DescriptionLevel level);
162     
163     //------------------------------------------------------------------
164     /// Check whether this collection of breakpoint locations have any
165     /// thread specifiers, and if yes, is \a thread_id contained in any
166     /// of these specifiers.
167     ///
168     /// @param[in] thread
169     ///     The thread against which to test.
170     ///
171     /// return
172     ///     \b true if the collection contains at least one location that
173     ///     would be valid for this thread, false otherwise.
174     //------------------------------------------------------------------
175     bool ValidForThisThread (Thread *thread);
176
177     //------------------------------------------------------------------
178     /// Tell whether ALL the breakpoints in the location collection are internal.
179     ///
180     /// @result
181     ///     \b true if all breakpoint locations are owned by internal breakpoints,
182     ///     \b false otherwise.
183     //------------------------------------------------------------------
184     bool IsInternal() const;
185
186
187 protected:
188     //------------------------------------------------------------------
189     // Classes that inherit from BreakpointLocationCollection can see
190     // and modify these
191     //------------------------------------------------------------------
192
193 private:
194     //------------------------------------------------------------------
195     // For BreakpointLocationCollection only
196     //------------------------------------------------------------------
197
198     typedef std::vector<lldb::BreakpointLocationSP> collection;
199
200     collection::iterator
201     GetIDPairIterator(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
202
203     collection::const_iterator
204     GetIDPairConstIterator(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;
205
206     collection     m_break_loc_collection;
207     mutable std::mutex  m_collection_mutex;
208
209 public:
210     typedef AdaptedIterable<collection, lldb::BreakpointLocationSP, vector_adapter> BreakpointLocationCollectionIterable;
211     BreakpointLocationCollectionIterable
212     BreakpointLocations()
213     {
214         return BreakpointLocationCollectionIterable(m_break_loc_collection);
215     }
216
217 };
218
219 } // namespace lldb_private
220
221 #endif  // liblldb_BreakpointLocationCollection_h_