]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h
Merge ^/vendor/lldb/dist up to its last change, and resolve conflicts.
[FreeBSD/FreeBSD.git] / contrib / llvm-project / lldb / include / lldb / Breakpoint / BreakpointLocationCollection.h
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 liblldb_BreakpointLocationCollection_h_
10 #define liblldb_BreakpointLocationCollection_h_
11
12 #include <mutex>
13 #include <vector>
14
15 #include "lldb/Utility/Iterable.h"
16 #include "lldb/lldb-private.h"
17
18 namespace lldb_private {
19
20 class BreakpointLocationCollection {
21 public:
22   BreakpointLocationCollection();
23
24   ~BreakpointLocationCollection();
25   
26   BreakpointLocationCollection &operator=(const BreakpointLocationCollection &rhs);
27
28   /// Add the breakpoint \a bp_loc_sp to the list.
29   ///
30   /// \param[in] bp_sp
31   ///     Shared pointer to the breakpoint location that will get added
32   ///     to the list.
33   ///
34   /// \result
35   ///     Returns breakpoint location id.
36   void Add(const lldb::BreakpointLocationSP &bp_loc_sp);
37
38   /// Removes the breakpoint location given by \b breakID from this
39   /// list.
40   ///
41   /// \param[in] break_id
42   ///     The breakpoint index to remove.
43   ///
44   /// \param[in] break_loc_id
45   ///     The breakpoint location index in break_id to remove.
46   ///
47   /// \result
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);
50
51   /// Returns a shared pointer to the breakpoint location with id \a
52   /// breakID.
53   ///
54   /// \param[in] break_id
55   ///     The breakpoint  ID to seek for.
56   ///
57   /// \param[in] break_loc_id
58   ///     The breakpoint location ID in \a break_id to seek for.
59   ///
60   /// \result
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);
65
66   /// Returns a shared pointer to the breakpoint location with id \a
67   /// breakID, const version.
68   ///
69   /// \param[in] breakID
70   ///     The breakpoint location ID to seek for.
71   ///
72   /// \param[in] break_loc_id
73   ///     The breakpoint location ID in \a break_id to seek for.
74   ///
75   /// \result
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;
80
81   /// Returns a shared pointer to the breakpoint location with index
82   /// \a i.
83   ///
84   /// \param[in] i
85   ///     The breakpoint location index to seek for.
86   ///
87   /// \result
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);
91
92   /// Returns a shared pointer to the breakpoint location with index
93   /// \a i, const version.
94   ///
95   /// \param[in] i
96   ///     The breakpoint location index to seek for.
97   ///
98   /// \result
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;
102
103   /// Returns the number of elements in this breakpoint location list.
104   ///
105   /// \result
106   ///     The number of elements.
107   size_t GetSize() const { return m_break_loc_collection.size(); }
108
109   /// Enquires of all the breakpoint locations in this list whether
110   /// we should stop at a hit at \a breakID.
111   ///
112   /// \param[in] context
113   ///    This contains the information about this stop.
114   ///
115   /// \param[in] breakID
116   ///    This break ID that we hit.
117   ///
118   /// \return
119   ///    \b true if we should stop, \b false otherwise.
120   bool ShouldStop(StoppointCallbackContext *context);
121
122   /// Print a description of the breakpoint locations in this list
123   /// to the stream \a s.
124   ///
125   /// \param[in] s
126   ///     The stream to which to print the description.
127   ///
128   /// \param[in] level
129   ///     The description level that indicates the detail level to
130   ///     provide.
131   ///
132   /// \see lldb::DescriptionLevel
133   void GetDescription(Stream *s, lldb::DescriptionLevel level);
134
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.
138   ///
139   /// \param[in] thread
140   ///     The thread against which to test.
141   ///
142   /// return
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);
146
147   /// Tell whether ALL the breakpoints in the location collection are internal.
148   ///
149   /// \result
150   ///     \b true if all breakpoint locations are owned by internal breakpoints,
151   ///     \b false otherwise.
152   bool IsInternal() const;
153
154 protected:
155   // Classes that inherit from BreakpointLocationCollection can see and modify
156   // these
157
158 private:
159   // For BreakpointLocationCollection only
160
161   typedef std::vector<lldb::BreakpointLocationSP> collection;
162
163   collection::iterator GetIDPairIterator(lldb::break_id_t break_id,
164                                          lldb::break_id_t break_loc_id);
165
166   collection::const_iterator
167   GetIDPairConstIterator(lldb::break_id_t break_id,
168                          lldb::break_id_t break_loc_id) const;
169
170   collection m_break_loc_collection;
171   mutable std::mutex m_collection_mutex;
172
173 public:
174   typedef AdaptedIterable<collection, lldb::BreakpointLocationSP,
175                           vector_adapter>
176       BreakpointLocationCollectionIterable;
177   BreakpointLocationCollectionIterable BreakpointLocations() {
178     return BreakpointLocationCollectionIterable(m_break_loc_collection);
179   }
180 };
181
182 } // namespace lldb_private
183
184 #endif // liblldb_BreakpointLocationCollection_h_