1 //===-- BreakpointList.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_BreakpointList_h_
11 #define liblldb_BreakpointList_h_
18 // Other libraries and framework includes
20 #include "lldb/Breakpoint/Breakpoint.h"
22 namespace lldb_private {
24 //----------------------------------------------------------------------
25 /// @class BreakpointList BreakpointList.h "lldb/Breakpoint/BreakpointList.h"
26 /// @brief This class manages a list of breakpoints.
27 //----------------------------------------------------------------------
29 //----------------------------------------------------------------------
31 /// Allows adding and removing breakpoints and find by ID and index.
32 //----------------------------------------------------------------------
37 BreakpointList (bool is_internal);
41 //------------------------------------------------------------------
42 /// Add the breakpoint \a bp_sp to the list.
45 /// Shared pointer to the breakpoint that will get added to the list.
48 /// Returns breakpoint id.
49 //------------------------------------------------------------------
51 Add (lldb::BreakpointSP& bp_sp, bool notify);
53 //------------------------------------------------------------------
54 /// Standard "Dump" method. At present it does nothing.
55 //------------------------------------------------------------------
57 Dump (Stream *s) const;
59 //------------------------------------------------------------------
60 /// Returns a shared pointer to the breakpoint with id \a breakID.
62 /// @param[in] breakID
63 /// The breakpoint ID to seek for.
66 /// A shared pointer to the breakpoint. May contain a NULL pointer if the
67 /// breakpoint doesn't exist.
68 //------------------------------------------------------------------
70 FindBreakpointByID (lldb::break_id_t breakID);
72 //------------------------------------------------------------------
73 /// Returns a shared pointer to the breakpoint with id \a breakID. Const version.
75 /// @param[in] breakID
76 /// The breakpoint ID to seek for.
79 /// A shared pointer to the breakpoint. May contain a NULL pointer if the
80 /// breakpoint doesn't exist.
81 //------------------------------------------------------------------
82 const lldb::BreakpointSP
83 FindBreakpointByID (lldb::break_id_t breakID) const;
85 //------------------------------------------------------------------
86 /// Returns a shared pointer to the breakpoint with index \a i.
89 /// The breakpoint index to seek for.
92 /// A shared pointer to the breakpoint. May contain a NULL pointer if the
93 /// breakpoint doesn't exist.
94 //------------------------------------------------------------------
96 GetBreakpointAtIndex (size_t i);
98 //------------------------------------------------------------------
99 /// Returns a shared pointer to the breakpoint with index \a i, const version
102 /// The breakpoint index to seek for.
105 /// A shared pointer to the breakpoint. May contain a NULL pointer if the
106 /// breakpoint doesn't exist.
107 //------------------------------------------------------------------
108 const lldb::BreakpointSP
109 GetBreakpointAtIndex (size_t i) const;
111 //------------------------------------------------------------------
112 /// Returns the number of elements in this breakpoint list.
115 /// The number of elements.
116 //------------------------------------------------------------------
120 std::lock_guard<std::recursive_mutex> guard(m_mutex);
121 return m_breakpoints.size();
124 //------------------------------------------------------------------
125 /// Removes the breakpoint given by \b breakID from this list.
127 /// @param[in] breakID
128 /// The breakpoint index to remove.
131 /// \b true if the breakpoint \a breakID was in the list.
132 //------------------------------------------------------------------
134 Remove (lldb::break_id_t breakID, bool notify);
137 //------------------------------------------------------------------
138 /// Removes all invalid breakpoint locations.
140 /// Removes all breakpoint locations in the list with architectures
141 /// that aren't compatible with \a arch. Also remove any breakpoint
142 /// locations with whose locations have address where the section
143 /// has been deleted (module and object files no longer exist).
145 /// This is typically used after the process calls exec, or anytime
146 /// the architecture of the target changes.
149 /// If valid, check the module in each breakpoint to make sure
150 /// they are compatible, otherwise, ignore architecture.
151 //------------------------------------------------------------------
153 RemoveInvalidLocations (const ArchSpec &arch);
156 SetEnabledAll (bool enabled);
158 //------------------------------------------------------------------
159 /// Removes all the breakpoints from this list.
160 //------------------------------------------------------------------
162 RemoveAll (bool notify);
164 //------------------------------------------------------------------
165 /// Tell all the breakpoints to update themselves due to a change in the
166 /// modules in \a module_list. \a added says whether the module was loaded
169 /// @param[in] module_list
170 /// The module list that has changed.
173 /// \b true if the modules are loaded, \b false if unloaded.
175 /// @param[in] delete_locations
176 /// If \a load is \b false, then delete breakpoint locations when
177 /// when updating breakpoints.
178 //------------------------------------------------------------------
180 UpdateBreakpoints (ModuleList &module_list,
182 bool delete_locations);
185 UpdateBreakpointsWhenModuleIsReplaced (lldb::ModuleSP old_module_sp, lldb::ModuleSP new_module_sp);
188 ClearAllBreakpointSites ();
190 //------------------------------------------------------------------
191 /// Sets the passed in Locker to hold the Breakpoint List mutex.
193 /// @param[in] locker
194 /// The locker object that is set.
195 //------------------------------------------------------------------
197 GetListMutex(std::unique_lock<std::recursive_mutex> &lock);
200 typedef std::list<lldb::BreakpointSP> bp_collection;
202 bp_collection::iterator
203 GetBreakpointIDIterator(lldb::break_id_t breakID);
205 bp_collection::const_iterator
206 GetBreakpointIDConstIterator(lldb::break_id_t breakID) const;
208 std::recursive_mutex &
214 mutable std::recursive_mutex m_mutex;
215 bp_collection m_breakpoints; // The breakpoint list, currently a list.
216 lldb::break_id_t m_next_break_id;
220 typedef LockingAdaptedIterable<bp_collection, lldb::BreakpointSP, list_adapter, std::recursive_mutex>
225 return BreakpointIterable(m_breakpoints, GetMutex());
229 DISALLOW_COPY_AND_ASSIGN (BreakpointList);
232 } // namespace lldb_private
234 #endif // liblldb_BreakpointList_h_