Coverage Report

Created: 2023-09-30 09:22

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h
Line
Count
Source
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
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_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
232k
  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
127
  void GetDescription(Stream *s, lldb::DescriptionLevel level);
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
161
  GetIDPairConstIterator(lldb::break_id_t break_id,
162
                         lldb::break_id_t break_loc_id) const;
163
164
  collection m_break_loc_collection;
165
  mutable std::mutex m_collection_mutex;
166
167
public:
168
  typedef AdaptedIterable<collection, lldb::BreakpointLocationSP,
169
                          vector_adapter>
170
      BreakpointLocationCollectionIterable;
171
11.9k
  BreakpointLocationCollectionIterable BreakpointLocations() {
172
11.9k
    return BreakpointLocationCollectionIterable(m_break_loc_collection);
173
11.9k
  }
174
};
175
176
} // namespace lldb_private
177
178
#endif // LLDB_BREAKPOINT_BREAKPOINTLOCATIONCOLLECTION_H