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_
16 // Other libraries and framework includes
18 #include "lldb/Breakpoint/Breakpoint.h"
19 #include "lldb/Host/Mutex.h"
21 namespace lldb_private {
23 //----------------------------------------------------------------------
24 /// @class BreakpointList BreakpointList.h "lldb/Breakpoint/BreakpointList.h"
25 /// @brief This class manages a list of breakpoints.
26 //----------------------------------------------------------------------
28 //----------------------------------------------------------------------
30 /// Allows adding and removing breakpoints and find by ID and index.
31 //----------------------------------------------------------------------
36 BreakpointList (bool is_internal);
40 //------------------------------------------------------------------
41 /// Add the breakpoint \a bp_sp to the list.
44 /// Shared pointer to the breakpoint that will get added to the list.
47 /// Returns breakpoint id.
48 //------------------------------------------------------------------
50 Add (lldb::BreakpointSP& bp_sp, bool notify);
52 //------------------------------------------------------------------
53 /// Standard "Dump" method. At present it does nothing.
54 //------------------------------------------------------------------
56 Dump (Stream *s) const;
58 //------------------------------------------------------------------
59 /// Returns a shared pointer to the breakpoint with id \a breakID.
61 /// @param[in] breakID
62 /// The breakpoint ID to seek for.
65 /// A shared pointer to the breakpoint. May contain a NULL pointer if the
66 /// breakpoint doesn't exist.
67 //------------------------------------------------------------------
69 FindBreakpointByID (lldb::break_id_t breakID);
71 //------------------------------------------------------------------
72 /// Returns a shared pointer to the breakpoint with id \a breakID. Const version.
74 /// @param[in] breakID
75 /// The breakpoint ID to seek for.
78 /// A shared pointer to the breakpoint. May contain a NULL pointer if the
79 /// breakpoint doesn't exist.
80 //------------------------------------------------------------------
81 const lldb::BreakpointSP
82 FindBreakpointByID (lldb::break_id_t breakID) const;
84 //------------------------------------------------------------------
85 /// Returns a shared pointer to the breakpoint with index \a i.
88 /// The breakpoint index to seek for.
91 /// A shared pointer to the breakpoint. May contain a NULL pointer if the
92 /// breakpoint doesn't exist.
93 //------------------------------------------------------------------
95 GetBreakpointAtIndex (size_t i);
97 //------------------------------------------------------------------
98 /// Returns a shared pointer to the breakpoint with index \a i, const version
101 /// The breakpoint index to seek for.
104 /// A shared pointer to the breakpoint. May contain a NULL pointer if the
105 /// breakpoint doesn't exist.
106 //------------------------------------------------------------------
107 const lldb::BreakpointSP
108 GetBreakpointAtIndex (size_t i) const;
110 //------------------------------------------------------------------
111 /// Returns the number of elements in this breakpoint list.
114 /// The number of elements.
115 //------------------------------------------------------------------
119 Mutex::Locker locker(m_mutex);
120 return m_breakpoints.size();
123 //------------------------------------------------------------------
124 /// Removes the breakpoint given by \b breakID from this list.
126 /// @param[in] breakID
127 /// The breakpoint index to remove.
130 /// \b true if the breakpoint \a breakID was in the list.
131 //------------------------------------------------------------------
133 Remove (lldb::break_id_t breakID, bool notify);
136 //------------------------------------------------------------------
137 /// Removes all invalid breakpoint locations.
139 /// Removes all breakpoint locations in the list with architectures
140 /// that aren't compatible with \a arch. Also remove any breakpoint
141 /// locations with whose locations have address where the section
142 /// has been deleted (module and object files no longer exist).
144 /// This is typically used after the process calls exec, or anytime
145 /// the architecture of the target changes.
148 /// If valid, check the module in each breakpoint to make sure
149 /// they are compatible, otherwise, ignore architecture.
150 //------------------------------------------------------------------
152 RemoveInvalidLocations (const ArchSpec &arch);
155 SetEnabledAll (bool enabled);
157 //------------------------------------------------------------------
158 /// Removes all the breakpoints from this list.
159 //------------------------------------------------------------------
161 RemoveAll (bool notify);
163 //------------------------------------------------------------------
164 /// Tell all the breakpoints to update themselves due to a change in the
165 /// modules in \a module_list. \a added says whether the module was loaded
168 /// @param[in] module_list
169 /// The module list that has changed.
172 /// \b true if the modules are loaded, \b false if unloaded.
174 /// @param[in] delete_locations
175 /// If \a load is \b false, then delete breakpoint locations when
176 /// when updating breakpoints.
177 //------------------------------------------------------------------
179 UpdateBreakpoints (ModuleList &module_list,
181 bool delete_locations);
184 UpdateBreakpointsWhenModuleIsReplaced (lldb::ModuleSP old_module_sp, lldb::ModuleSP new_module_sp);
187 ClearAllBreakpointSites ();
189 //------------------------------------------------------------------
190 /// Sets the passed in Locker to hold the Breakpoint List mutex.
192 /// @param[in] locker
193 /// The locker object that is set.
194 //------------------------------------------------------------------
196 GetListMutex (lldb_private::Mutex::Locker &locker);
199 typedef std::list<lldb::BreakpointSP> bp_collection;
201 bp_collection::iterator
202 GetBreakpointIDIterator(lldb::break_id_t breakID);
204 bp_collection::const_iterator
205 GetBreakpointIDConstIterator(lldb::break_id_t breakID) const;
207 mutable Mutex m_mutex;
208 bp_collection m_breakpoints; // The breakpoint list, currently a list.
209 lldb::break_id_t m_next_break_id;
213 DISALLOW_COPY_AND_ASSIGN (BreakpointList);
216 } // namespace lldb_private
218 #endif // liblldb_BreakpointList_h_