LLDB mainline
BreakpointLocationList.h
Go to the documentation of this file.
1//===-- BreakpointLocationList.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_BREAKPOINTLOCATIONLIST_H
10#define LLDB_BREAKPOINT_BREAKPOINTLOCATIONLIST_H
11
12#include <map>
13#include <mutex>
14#include <vector>
15
16#include "lldb/Core/Address.h"
18#include "lldb/lldb-private.h"
19
20namespace lldb_private {
21
22/// \class BreakpointLocationList BreakpointLocationList.h
23/// "lldb/Breakpoint/BreakpointLocationList.h" This class is used by
24/// Breakpoint to manage a list of breakpoint locations, each breakpoint
25/// location in the list has a unique ID, and is unique by Address as well.
27 // Only Breakpoints can make the location list, or add elements to it. This
28 // is not just some random collection of locations. Rather, the act of
29 // adding the location to this list sets its ID, and implicitly all the
30 // locations have the same breakpoint ID as well. If you need a generic
31 // container for breakpoint locations, use BreakpointLocationCollection.
32 friend class Breakpoint;
33
34public:
36
37 /// Standard "Dump" method. At present it does nothing.
38 void Dump(Stream *s) const;
39
40 /// Returns a shared pointer to the breakpoint location at address \a addr -
41 /// const version.
42 ///
43 /// \param[in] addr
44 /// The address to look for.
45 ///
46 /// \result
47 /// A shared pointer to the breakpoint. May contain a nullptr
48 /// pointer if the breakpoint doesn't exist.
49 const lldb::BreakpointLocationSP FindByAddress(const Address &addr) const;
50
51 /// Returns a shared pointer to the breakpoint location with id \a breakID,
52 /// const version.
53 ///
54 /// \param[in] breakID
55 /// The breakpoint location ID to seek for.
56 ///
57 /// \result
58 /// A shared pointer to the breakpoint. May contain a nullptr
59 /// pointer if the breakpoint doesn't exist.
61
62 /// Returns the breakpoint location id to the breakpoint location at address
63 /// \a addr.
64 ///
65 /// \param[in] addr
66 /// The address to match.
67 ///
68 /// \result
69 /// The ID of the breakpoint location, or LLDB_INVALID_BREAK_ID.
71
72 /// Returns a breakpoint location list of the breakpoint locations in the
73 /// module \a module. This list is allocated, and owned by the caller.
74 ///
75 /// \param[in] module
76 /// The module to seek in.
77 ///
78 /// \param[in] bp_loc_list
79 /// A breakpoint collection that gets any breakpoint locations
80 /// that match \a module appended to.
81 ///
82 /// \result
83 /// The number of matches
84 size_t FindInModule(Module *module,
85 BreakpointLocationCollection &bp_loc_list);
86
87 /// Returns a shared pointer to the breakpoint location with index \a i.
88 ///
89 /// \param[in] i
90 /// The breakpoint location index to seek for.
91 ///
92 /// \result
93 /// A shared pointer to the breakpoint. May contain a nullptr
94 /// pointer if the breakpoint doesn't exist.
96
97 /// Returns a shared pointer to the breakpoint location with index \a i,
98 /// const version.
99 ///
100 /// \param[in] i
101 /// The breakpoint location index to seek for.
102 ///
103 /// \result
104 /// A shared pointer to the breakpoint. May contain a nullptr
105 /// pointer if the breakpoint doesn't exist.
106 const lldb::BreakpointLocationSP GetByIndex(size_t i) const;
107
108 /// Removes all the locations in this list from their breakpoint site owners
109 /// list.
111
112 /// Tells all the breakpoint locations in this list to attempt to resolve
113 /// any possible breakpoint sites.
115
116 /// Returns the number of breakpoint locations in this list with resolved
117 /// breakpoints.
118 ///
119 /// \result
120 /// Number of qualifying breakpoint locations.
121 size_t GetNumResolvedLocations() const;
122
123 /// Returns the number hit count of all locations in this list.
124 ///
125 /// \result
126 /// Hit count of all locations in this list.
127 uint32_t GetHitCount() const;
128
129 /// Resets the hit count of all locations in this list.
130 void ResetHitCount();
131
132 /// Enquires of the breakpoint location in this list with ID \a breakID
133 /// whether we should stop.
134 ///
135 /// \param[in] context
136 /// This contains the information about this stop.
137 ///
138 /// \param[in] breakID
139 /// This break ID that we hit.
140 ///
141 /// \return
142 /// \b true if we should stop, \b false otherwise.
144
145 /// Returns the number of elements in this breakpoint location list.
146 ///
147 /// \result
148 /// The number of elements.
149 size_t GetSize() const { return m_locations.size(); }
150
151 /// Print a description of the breakpoint locations in this list to the
152 /// stream \a s.
153 ///
154 /// \param[in] s
155 /// The stream to which to print the description.
156 ///
157 /// \param[in] level
158 /// The description level that indicates the detail level to
159 /// provide.
160 ///
161 /// \see lldb::DescriptionLevel
163
164protected:
165 /// This is the standard constructor.
166 ///
167 /// It creates an empty breakpoint location list. It is protected here
168 /// because only Breakpoints are allowed to create the breakpoint location
169 /// list.
171
173 bool resolve_indirect_symbols);
174
176
178
180 bool resolve_indirect_symbols,
181 bool *new_location = nullptr);
182
183 void SwapLocation(lldb::BreakpointLocationSP to_location_sp,
184 lldb::BreakpointLocationSP from_location_sp);
185
186 bool RemoveLocation(const lldb::BreakpointLocationSP &bp_loc_sp);
187
188 void RemoveLocationByIndex(size_t idx);
189
190 void RemoveInvalidLocations(const ArchSpec &arch);
191
192 void Compact();
193
194 typedef std::vector<lldb::BreakpointLocationSP> collection;
198
200 collection m_locations; // Vector of locations, sorted by ID
202 mutable std::recursive_mutex m_mutex;
205
206public:
210
213 }
214};
215
216} // namespace lldb_private
217
218#endif // LLDB_BREAKPOINT_BREAKPOINTLOCATIONLIST_H
A section + offset based address class.
Definition: Address.h:62
An architecture specification class.
Definition: ArchSpec.h:31
"lldb/Breakpoint/BreakpointLocationList.h" This class is used by Breakpoint to manage a list of break...
void ResetHitCount()
Resets the hit count of all locations in this list.
void GetDescription(Stream *s, lldb::DescriptionLevel level)
Print a description of the breakpoint locations in this list to the stream s.
void RemoveInvalidLocations(const ArchSpec &arch)
lldb::BreakpointLocationSP GetByIndex(size_t i)
Returns a shared pointer to the breakpoint location with index i.
bool RemoveLocation(const lldb::BreakpointLocationSP &bp_loc_sp)
void Dump(Stream *s) const
Standard "Dump" method. At present it does nothing.
void ClearAllBreakpointSites()
Removes all the locations in this list from their breakpoint site owners list.
uint32_t GetHitCount() const
Returns the number hit count of all locations in this list.
const lldb::BreakpointLocationSP FindByAddress(const Address &addr) const
Returns a shared pointer to the breakpoint location at address addr - const version.
std::vector< lldb::BreakpointLocationSP > collection
void ResolveAllBreakpointSites()
Tells all the breakpoint locations in this list to attempt to resolve any possible breakpoint sites.
size_t FindInModule(Module *module, BreakpointLocationCollection &bp_loc_list)
Returns a breakpoint location list of the breakpoint locations in the module module.
AdaptedIterable< collection, lldb::BreakpointLocationSP, vector_adapter > BreakpointLocationIterable
bool ShouldStop(StoppointCallbackContext *context, lldb::break_id_t breakID)
Enquires of the breakpoint location in this list with ID breakID whether we should stop.
BreakpointLocationCollection * m_new_location_recorder
size_t GetSize() const
Returns the number of elements in this breakpoint location list.
lldb::BreakpointLocationSP FindByID(lldb::break_id_t breakID) const
Returns a shared pointer to the breakpoint location with id breakID, const version.
lldb::BreakpointLocationSP Create(const Address &addr, bool resolve_indirect_symbols)
lldb::BreakpointLocationSP AddLocation(const Address &addr, bool resolve_indirect_symbols, bool *new_location=nullptr)
void StartRecordingNewLocations(BreakpointLocationCollection &new_locations)
lldb::break_id_t FindIDByAddress(const Address &addr)
Returns the breakpoint location id to the breakpoint location at address addr.
size_t GetNumResolvedLocations() const
Returns the number of breakpoint locations in this list with resolved breakpoints.
BreakpointLocationIterable BreakpointLocations()
std::map< lldb_private::Address, lldb::BreakpointLocationSP, Address::ModulePointerAndOffsetLessThanFunctionObject > addr_map
void SwapLocation(lldb::BreakpointLocationSP to_location_sp, lldb::BreakpointLocationSP from_location_sp)
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition: Breakpoint.h:81
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:88
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
A class that represents a running process on the host machine.
E vector_adapter(I &iter)
Definition: Iterable.h:21
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
Definition: lldb-forward.h:322
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
int32_t break_id_t
Definition: lldb-types.h:86