LLDB  mainline
BreakpointLocationCollection.h
Go to the documentation of this file.
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 LLDB_BREAKPOINT_BREAKPOINTLOCATIONCOLLECTION_H
10 #define LLDB_BREAKPOINT_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 
21 public:
23 
25 
27 
28  /// Add the breakpoint \a bp_loc_sp to the list.
29  ///
30  /// \param[in] bp_loc_sp
31  /// Shared pointer to the breakpoint location that will get added
32  /// to the list.
33  void Add(const lldb::BreakpointLocationSP &bp_loc_sp);
34 
35  /// Removes the breakpoint location given by \b breakID from this
36  /// list.
37  ///
38  /// \param[in] break_id
39  /// The breakpoint index to remove.
40  ///
41  /// \param[in] break_loc_id
42  /// The breakpoint location index in break_id to remove.
43  ///
44  /// \result
45  /// \b true if the breakpoint was in the list.
46  bool Remove(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
47 
48  /// Returns a shared pointer to the breakpoint location with id \a
49  /// breakID.
50  ///
51  /// \param[in] break_id
52  /// The breakpoint ID to seek for.
53  ///
54  /// \param[in] break_loc_id
55  /// The breakpoint location ID in \a break_id to seek for.
56  ///
57  /// \result
58  /// A shared pointer to the breakpoint. May contain a NULL
59  /// pointer if the breakpoint doesn't exist.
60  lldb::BreakpointLocationSP FindByIDPair(lldb::break_id_t break_id,
61  lldb::break_id_t break_loc_id);
62 
63  /// Returns a shared pointer to the breakpoint location with id \a
64  /// breakID, const version.
65  ///
66  /// \param[in] break_id
67  /// The breakpoint location ID to seek for.
68  ///
69  /// \param[in] break_loc_id
70  /// The breakpoint location ID in \a break_id to seek for.
71  ///
72  /// \result
73  /// A shared pointer to the breakpoint. May contain a NULL
74  /// pointer if the breakpoint doesn't exist.
75  const lldb::BreakpointLocationSP
76  FindByIDPair(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;
77 
78  /// Returns a shared pointer to the breakpoint location with index
79  /// \a i.
80  ///
81  /// \param[in] i
82  /// The breakpoint location index to seek for.
83  ///
84  /// \result
85  /// A shared pointer to the breakpoint. May contain a NULL
86  /// pointer if the breakpoint doesn't exist.
87  lldb::BreakpointLocationSP GetByIndex(size_t i);
88 
89  /// Returns a shared pointer to the breakpoint location with index
90  /// \a i, const version.
91  ///
92  /// \param[in] i
93  /// The breakpoint location index to seek for.
94  ///
95  /// \result
96  /// A shared pointer to the breakpoint. May contain a NULL
97  /// pointer if the breakpoint doesn't exist.
98  const lldb::BreakpointLocationSP GetByIndex(size_t i) const;
99 
100  /// Returns the number of elements in this breakpoint location list.
101  ///
102  /// \result
103  /// The number of elements.
104  size_t GetSize() const { return m_break_loc_collection.size(); }
105 
106  /// Enquires of all the breakpoint locations in this list whether
107  /// we should stop at a hit at \a breakID.
108  ///
109  /// \param[in] context
110  /// This contains the information about this stop.
111  ///
112  /// \return
113  /// \b true if we should stop, \b false otherwise.
114  bool ShouldStop(StoppointCallbackContext *context);
115 
116  /// Print a description of the breakpoint locations in this list
117  /// to the stream \a s.
118  ///
119  /// \param[in] s
120  /// The stream to which to print the description.
121  ///
122  /// \param[in] level
123  /// The description level that indicates the detail level to
124  /// provide.
125  ///
126  /// \see lldb::DescriptionLevel
128 
129  /// Check whether this collection of breakpoint locations have any
130  /// thread specifiers, and if yes, is \a thread_id contained in any
131  /// of these specifiers.
132  ///
133  /// \param[in] thread
134  /// The thread against which to test.
135  ///
136  /// return
137  /// \b true if the collection contains at least one location that
138  /// would be valid for this thread, false otherwise.
139  bool ValidForThisThread(Thread &thread);
140 
141  /// Tell whether ALL the breakpoints in the location collection are internal.
142  ///
143  /// \result
144  /// \b true if all breakpoint locations are owned by internal breakpoints,
145  /// \b false otherwise.
146  bool IsInternal() const;
147 
148 protected:
149  // Classes that inherit from BreakpointLocationCollection can see and modify
150  // these
151 
152 private:
153  // For BreakpointLocationCollection only
154 
155  typedef std::vector<lldb::BreakpointLocationSP> collection;
156 
157  collection::iterator GetIDPairIterator(lldb::break_id_t break_id,
158  lldb::break_id_t break_loc_id);
159 
160  collection::const_iterator
162  lldb::break_id_t break_loc_id) const;
163 
165  mutable std::mutex m_collection_mutex;
166 
167 public:
168  typedef AdaptedIterable<collection, lldb::BreakpointLocationSP,
173  }
174 };
175 
176 } // namespace lldb_private
177 
178 #endif // LLDB_BREAKPOINT_BREAKPOINTLOCATIONCOLLECTION_H
lldb_private::BreakpointLocationCollection::GetByIndex
lldb::BreakpointLocationSP GetByIndex(size_t i)
Returns a shared pointer to the breakpoint location with index i.
Definition: BreakpointLocationCollection.cpp:101
lldb_private::BreakpointLocationCollection::FindByIDPair
lldb::BreakpointLocationSP FindByIDPair(lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
Returns a shared pointer to the breakpoint location with id breakID.
Definition: BreakpointLocationCollection.cpp:80
lldb_private::BreakpointLocationCollection::IsInternal
bool IsInternal() const
Tell whether ALL the breakpoints in the location collection are internal.
Definition: BreakpointLocationCollection.cpp:149
lldb_private::StoppointCallbackContext
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
Definition: StoppointCallbackContext.h:26
lldb_private::BreakpointLocationCollection::~BreakpointLocationCollection
~BreakpointLocationCollection()
lldb_private::vector_adapter
E vector_adapter(I &iter)
Definition: Iterable.h:21
lldb_private::BreakpointLocationCollection::BreakpointLocations
BreakpointLocationCollectionIterable BreakpointLocations()
Definition: BreakpointLocationCollection.h:171
lldb_private::AdaptedIterable
Definition: Iterable.h:153
lldb_private::BreakpointLocationCollection::ValidForThisThread
bool ValidForThisThread(Thread &thread)
Check whether this collection of breakpoint locations have any thread specifiers, and if yes,...
Definition: BreakpointLocationCollection.cpp:137
lldb_private::Stream
Definition: Stream.h:28
lldb_private::BreakpointLocationCollection::m_break_loc_collection
collection m_break_loc_collection
Definition: BreakpointLocationCollection.h:164
lldb_private::BreakpointLocationCollection::GetIDPairIterator
collection::iterator GetIDPairIterator(lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
Definition: BreakpointLocationCollection.cpp:62
lldb_private::BreakpointLocationCollection::m_collection_mutex
std::mutex m_collection_mutex
Definition: BreakpointLocationCollection.h:165
lldb_private::BreakpointLocationCollection::ShouldStop
bool ShouldStop(StoppointCallbackContext *context)
Enquires of all the breakpoint locations in this list whether we should stop at a hit at breakID.
Definition: BreakpointLocationCollection.cpp:120
lldb_private::Thread
Definition: Thread.h:62
lldb::break_id_t
int32_t break_id_t
Definition: lldb-types.h:88
lldb_private::BreakpointLocationCollection::GetDescription
void GetDescription(Stream *s, lldb::DescriptionLevel level)
Print a description of the breakpoint locations in this list to the stream s.
Definition: BreakpointLocationCollection.cpp:165
lldb_private::BreakpointLocationCollection::BreakpointLocationCollectionIterable
AdaptedIterable< collection, lldb::BreakpointLocationSP, vector_adapter > BreakpointLocationCollectionIterable
Definition: BreakpointLocationCollection.h:170
lldb_private::BreakpointLocationCollection::BreakpointLocationCollection
BreakpointLocationCollection()
Definition: BreakpointLocationCollection.cpp:20
lldb_private::BreakpointLocationCollection
Definition: BreakpointLocationCollection.h:20
lldb-private.h
Iterable.h
lldb_private::BreakpointLocationCollection::GetIDPairConstIterator
collection::const_iterator GetIDPairConstIterator(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const
Definition: BreakpointLocationCollection.cpp:71
lldb_private::BreakpointLocationCollection::Add
void Add(const lldb::BreakpointLocationSP &bp_loc_sp)
Add the breakpoint bp_loc_sp to the list.
Definition: BreakpointLocationCollection.cpp:26
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::BreakpointLocationCollection::GetSize
size_t GetSize() const
Returns the number of elements in this breakpoint location list.
Definition: BreakpointLocationCollection.h:104
lldb_private::BreakpointLocationCollection::collection
std::vector< lldb::BreakpointLocationSP > collection
Definition: BreakpointLocationCollection.h:155
lldb_private::BreakpointLocationCollection::Remove
bool Remove(lldb::break_id_t break_id, lldb::break_id_t break_loc_id)
Removes the breakpoint location given by breakID from this list.
Definition: BreakpointLocationCollection.cpp:34
lldb_private::BreakpointLocationCollection::operator=
BreakpointLocationCollection & operator=(const BreakpointLocationCollection &rhs)
Definition: BreakpointLocationCollection.cpp:178
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:207