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 SetEnabledAll (bool enabled);
138 //------------------------------------------------------------------
139 /// Removes all the breakpoints from this list.
140 //------------------------------------------------------------------
142 RemoveAll (bool notify);
144 //------------------------------------------------------------------
145 /// Tell all the breakpoints to update themselves due to a change in the
146 /// modules in \a module_list. \a added says whether the module was loaded
149 /// @param[in] module_list
150 /// The module list that has changed.
153 /// \b true if the modules are loaded, \b false if unloaded.
154 //------------------------------------------------------------------
156 UpdateBreakpoints (ModuleList &module_list, bool added);
159 UpdateBreakpointsWhenModuleIsReplaced (lldb::ModuleSP old_module_sp, lldb::ModuleSP new_module_sp);
162 ClearAllBreakpointSites ();
164 //------------------------------------------------------------------
165 /// Sets the passed in Locker to hold the Breakpoint List mutex.
167 /// @param[in] locker
168 /// The locker object that is set.
169 //------------------------------------------------------------------
171 GetListMutex (lldb_private::Mutex::Locker &locker);
174 typedef std::list<lldb::BreakpointSP> bp_collection;
176 bp_collection::iterator
177 GetBreakpointIDIterator(lldb::break_id_t breakID);
179 bp_collection::const_iterator
180 GetBreakpointIDConstIterator(lldb::break_id_t breakID) const;
182 mutable Mutex m_mutex;
183 bp_collection m_breakpoints; // The breakpoint list, currently a list.
184 lldb::break_id_t m_next_break_id;
188 DISALLOW_COPY_AND_ASSIGN (BreakpointList);
191 } // namespace lldb_private
193 #endif // liblldb_BreakpointList_h_