1 //===-- BreakpointLocationList.h --------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_BreakpointLocationList_h_
11 #define liblldb_BreakpointLocationList_h_
17 // Other libraries and framework includes
19 #include "lldb/lldb-private.h"
20 #include "lldb/Core/Address.h"
21 #include "lldb/Host/Mutex.h"
23 namespace lldb_private {
25 //----------------------------------------------------------------------
26 /// @class BreakpointLocationList BreakpointLocationList.h "lldb/Breakpoint/BreakpointLocationList.h"
27 /// @brief This class is used by Breakpoint to manage a list of breakpoint locations,
28 // each breakpoint location in the list
29 /// has a unique ID, and is unique by Address as well.
30 //----------------------------------------------------------------------
32 class BreakpointLocationList
34 // Only Breakpoints can make the location list, or add elements to it.
35 // This is not just some random collection of locations. Rather, the act of adding the location
36 // to this list sets its ID, and implicitly all the locations have the same breakpoint ID as
37 // well. If you need a generic container for breakpoint locations, use BreakpointLocationCollection.
38 friend class Breakpoint;
42 ~BreakpointLocationList();
44 //------------------------------------------------------------------
45 /// Standard "Dump" method. At present it does nothing.
46 //------------------------------------------------------------------
48 Dump (Stream *s) const;
50 //------------------------------------------------------------------
51 /// Returns a shared pointer to the breakpoint location at address
52 /// \a addr - const version.
55 /// The address to look for.
58 /// A shared pointer to the breakpoint. May contain a NULL
59 /// pointer if the breakpoint doesn't exist.
60 //------------------------------------------------------------------
61 const lldb::BreakpointLocationSP
62 FindByAddress (const Address &addr) const;
64 //------------------------------------------------------------------
65 /// Returns a shared pointer to the breakpoint location with id
66 /// \a breakID, const version.
68 /// @param[in] breakID
69 /// The breakpoint location ID to seek for.
72 /// A shared pointer to the breakpoint. May contain a NULL
73 /// pointer if the breakpoint doesn't exist.
74 //------------------------------------------------------------------
75 lldb::BreakpointLocationSP
76 FindByID (lldb::break_id_t breakID) const;
78 //------------------------------------------------------------------
79 /// Returns the breakpoint location id to the breakpoint location
80 /// at address \a addr.
83 /// The address to match.
86 /// The ID of the breakpoint location, or LLDB_INVALID_BREAK_ID.
87 //------------------------------------------------------------------
89 FindIDByAddress (const Address &addr);
91 //------------------------------------------------------------------
92 /// Returns a breakpoint location list of the breakpoint locations
93 /// in the module \a module. This list is allocated, and owned by
97 /// The module to seek in.
100 /// A breakpoint collection that gets any breakpoint locations
101 /// that match \a module appended to.
104 /// The number of matches
105 //------------------------------------------------------------------
107 FindInModule (Module *module,
108 BreakpointLocationCollection& bp_loc_list);
110 //------------------------------------------------------------------
111 /// Returns a shared pointer to the breakpoint location with
115 /// The breakpoint location index to seek for.
118 /// A shared pointer to the breakpoint. May contain a NULL
119 /// pointer if the breakpoint doesn't exist.
120 //------------------------------------------------------------------
121 lldb::BreakpointLocationSP
122 GetByIndex (size_t i);
124 //------------------------------------------------------------------
125 /// Returns a shared pointer to the breakpoint location with index
126 /// \a i, const version.
129 /// The breakpoint location index to seek for.
132 /// A shared pointer to the breakpoint. May contain a NULL
133 /// pointer if the breakpoint doesn't exist.
134 //------------------------------------------------------------------
135 const lldb::BreakpointLocationSP
136 GetByIndex (size_t i) const;
138 //------------------------------------------------------------------
139 /// Removes all the locations in this list from their breakpoint site
141 //------------------------------------------------------------------
143 ClearAllBreakpointSites ();
145 //------------------------------------------------------------------
146 /// Tells all the breakopint locations in this list to attempt to
147 /// resolve any possible breakpoint sites.
148 //------------------------------------------------------------------
150 ResolveAllBreakpointSites ();
152 //------------------------------------------------------------------
153 /// Returns the number of breakpoint locations in this list with
154 /// resolved breakpoints.
157 /// Number of qualifying breakpoint locations.
158 //------------------------------------------------------------------
160 GetNumResolvedLocations() const;
162 //------------------------------------------------------------------
163 /// Returns the number hit count of all locations in this list.
166 /// Hit count of all locations in this list.
167 //------------------------------------------------------------------
169 GetHitCount () const;
171 //------------------------------------------------------------------
172 /// Enquires of the breakpoint location in this list with ID \a
173 /// breakID whether we should stop.
175 /// @param[in] context
176 /// This contains the information about this stop.
178 /// @param[in] breakID
179 /// This break ID that we hit.
182 /// \b true if we should stop, \b false otherwise.
183 //------------------------------------------------------------------
185 ShouldStop (StoppointCallbackContext *context,
186 lldb::break_id_t breakID);
188 //------------------------------------------------------------------
189 /// Returns the number of elements in this breakpoint location list.
192 /// The number of elements.
193 //------------------------------------------------------------------
197 return m_locations.size();
200 //------------------------------------------------------------------
201 /// Print a description of the breakpoint locations in this list to
205 /// The stream to which to print the description.
208 /// The description level that indicates the detail level to
211 /// @see lldb::DescriptionLevel
212 //------------------------------------------------------------------
214 GetDescription (Stream *s,
215 lldb::DescriptionLevel level);
219 //------------------------------------------------------------------
220 /// This is the standard constructor.
222 /// It creates an empty breakpoint location list. It is protected
223 /// here because only Breakpoints are allowed to create the
224 /// breakpoint location list.
225 //------------------------------------------------------------------
226 BreakpointLocationList(Breakpoint &owner);
228 //------------------------------------------------------------------
229 /// Add the breakpoint \a bp_loc_sp to the list.
232 /// Shared pointer to the breakpoint location that will get
233 /// added to the list.
236 /// Returns breakpoint location id.
237 //------------------------------------------------------------------
238 lldb::BreakpointLocationSP
239 Create (const Address &addr);
242 StartRecordingNewLocations(BreakpointLocationCollection &new_locations);
245 StopRecordingNewLocations();
247 lldb::BreakpointLocationSP
248 AddLocation (const Address &addr,
249 bool *new_location = NULL);
252 RemoveLocation (const lldb::BreakpointLocationSP &bp_loc_sp);
254 typedef std::vector<lldb::BreakpointLocationSP> collection;
255 typedef std::map<lldb_private::Address,
256 lldb::BreakpointLocationSP,
257 Address::ModulePointerAndOffsetLessThanFunctionObject> addr_map;
260 collection m_locations;
261 addr_map m_address_to_location;
262 mutable Mutex m_mutex;
263 lldb::break_id_t m_next_id;
264 BreakpointLocationCollection *m_new_location_recorder;
267 } // namespace lldb_private
269 #endif // liblldb_BreakpointLocationList_h_