]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / 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 <mutex>
16 #include <vector>
17
18 // Other libraries and framework includes
19 // Project includes
20 #include "lldb/Utility/Iterable.h"
21 #include "lldb/lldb-private.h"
22
23 namespace lldb_private {
24
25 class BreakpointLocationCollection {
26 public:
27   BreakpointLocationCollection();
28
29   ~BreakpointLocationCollection();
30
31   //------------------------------------------------------------------
32   /// Add the breakpoint \a bp_loc_sp to the list.
33   ///
34   /// @param[in] bp_sp
35   ///     Shared pointer to the breakpoint location that will get added
36   ///     to the list.
37   ///
38   /// @result
39   ///     Returns breakpoint location id.
40   //------------------------------------------------------------------
41   void Add(const lldb::BreakpointLocationSP &bp_loc_sp);
42
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   //------------------------------------------------------------------
56   bool Remove(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
57
58   //------------------------------------------------------------------
59   /// Returns a shared pointer to the breakpoint location with id \a
60   /// breakID.
61   ///
62   /// @param[in] break_id
63   ///     The breakpoint  ID to seek for.
64   ///
65   /// @param[in] break_loc_id
66   ///     The breakpoint location ID in \a break_id to seek for.
67   ///
68   /// @result
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);
74
75   //------------------------------------------------------------------
76   /// Returns a shared pointer to the breakpoint location with id \a
77   /// breakID, const version.
78   ///
79   /// @param[in] breakID
80   ///     The breakpoint location ID to seek for.
81   ///
82   /// @param[in] break_loc_id
83   ///     The breakpoint location ID in \a break_id to seek for.
84   ///
85   /// @result
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;
91
92   //------------------------------------------------------------------
93   /// Returns a shared pointer to the breakpoint location with index
94   /// \a i.
95   ///
96   /// @param[in] i
97   ///     The breakpoint location index to seek for.
98   ///
99   /// @result
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);
104
105   //------------------------------------------------------------------
106   /// Returns a shared pointer to the breakpoint location with index
107   /// \a i, const version.
108   ///
109   /// @param[in] i
110   ///     The breakpoint location index to seek for.
111   ///
112   /// @result
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;
117
118   //------------------------------------------------------------------
119   /// Returns the number of elements in this breakpoint location list.
120   ///
121   /// @result
122   ///     The number of elements.
123   //------------------------------------------------------------------
124   size_t GetSize() const { return m_break_loc_collection.size(); }
125
126   //------------------------------------------------------------------
127   /// Enquires of all the breakpoint locations in this list whether
128   /// we should stop at a hit at \a breakID.
129   ///
130   /// @param[in] context
131   ///    This contains the information about this stop.
132   ///
133   /// @param[in] breakID
134   ///    This break ID that we hit.
135   ///
136   /// @return
137   ///    \b true if we should stop, \b false otherwise.
138   //------------------------------------------------------------------
139   bool ShouldStop(StoppointCallbackContext *context);
140
141   //------------------------------------------------------------------
142   /// Print a description of the breakpoint locations in this list
143   /// to the stream \a s.
144   ///
145   /// @param[in] s
146   ///     The stream to which to print the description.
147   ///
148   /// @param[in] level
149   ///     The description level that indicates the detail level to
150   ///     provide.
151   ///
152   /// @see lldb::DescriptionLevel
153   //------------------------------------------------------------------
154   void GetDescription(Stream *s, lldb::DescriptionLevel level);
155
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.
160   ///
161   /// @param[in] thread
162   ///     The thread against which to test.
163   ///
164   /// return
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);
169
170   //------------------------------------------------------------------
171   /// Tell whether ALL the breakpoints in the location collection are internal.
172   ///
173   /// @result
174   ///     \b true if all breakpoint locations are owned by internal breakpoints,
175   ///     \b false otherwise.
176   //------------------------------------------------------------------
177   bool IsInternal() const;
178
179 protected:
180   //------------------------------------------------------------------
181   // Classes that inherit from BreakpointLocationCollection can see and modify
182   // these
183   //------------------------------------------------------------------
184
185 private:
186   //------------------------------------------------------------------
187   // For BreakpointLocationCollection only
188   //------------------------------------------------------------------
189
190   typedef std::vector<lldb::BreakpointLocationSP> collection;
191
192   collection::iterator GetIDPairIterator(lldb::break_id_t break_id,
193                                          lldb::break_id_t break_loc_id);
194
195   collection::const_iterator
196   GetIDPairConstIterator(lldb::break_id_t break_id,
197                          lldb::break_id_t break_loc_id) const;
198
199   collection m_break_loc_collection;
200   mutable std::mutex m_collection_mutex;
201
202 public:
203   typedef AdaptedIterable<collection, lldb::BreakpointLocationSP,
204                           vector_adapter>
205       BreakpointLocationCollectionIterable;
206   BreakpointLocationCollectionIterable BreakpointLocations() {
207     return BreakpointLocationCollectionIterable(m_break_loc_collection);
208   }
209 };
210
211 } // namespace lldb_private
212
213 #endif // liblldb_BreakpointLocationCollection_h_