]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/tools/lldb/include/lldb/Breakpoint/BreakpointList.h
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / tools / lldb / include / lldb / Breakpoint / BreakpointList.h
1 //===-- BreakpointList.h ----------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_BreakpointList_h_
11 #define liblldb_BreakpointList_h_
12
13 // C Includes
14 // C++ Includes
15 #include <list>
16 // Other libraries and framework includes
17 // Project includes
18 #include "lldb/Breakpoint/Breakpoint.h"
19 #include "lldb/Host/Mutex.h"
20
21 namespace lldb_private {
22
23 //----------------------------------------------------------------------
24 /// @class BreakpointList BreakpointList.h "lldb/Breakpoint/BreakpointList.h"
25 /// @brief This class manages a list of breakpoints.
26 //----------------------------------------------------------------------
27
28 //----------------------------------------------------------------------
29 /// General Outline:
30 /// Allows adding and removing breakpoints and find by ID and index.
31 //----------------------------------------------------------------------
32
33 class BreakpointList
34 {
35 public:
36     BreakpointList (bool is_internal);
37
38     ~BreakpointList();
39
40     //------------------------------------------------------------------
41     /// Add the breakpoint \a bp_sp to the list.
42     ///
43     /// @param[in] bp_sp
44     ///   Shared pointer to the breakpoint that will get added to the list.
45     ///
46     /// @result
47     ///   Returns breakpoint id.
48     //------------------------------------------------------------------
49     lldb::break_id_t
50     Add (lldb::BreakpointSP& bp_sp, bool notify);
51
52     //------------------------------------------------------------------
53     /// Standard "Dump" method.  At present it does nothing.
54     //------------------------------------------------------------------
55     void
56     Dump (Stream *s) const;
57
58     //------------------------------------------------------------------
59     /// Returns a shared pointer to the breakpoint with id \a breakID.
60     ///
61     /// @param[in] breakID
62     ///   The breakpoint ID to seek for.
63     ///
64     /// @result
65     ///   A shared pointer to the breakpoint.  May contain a NULL pointer if the
66     ///   breakpoint doesn't exist.
67     //------------------------------------------------------------------
68     lldb::BreakpointSP
69     FindBreakpointByID (lldb::break_id_t breakID);
70
71     //------------------------------------------------------------------
72     /// Returns a shared pointer to the breakpoint with id \a breakID.  Const version.
73     ///
74     /// @param[in] breakID
75     ///   The breakpoint ID to seek for.
76     ///
77     /// @result
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;
83
84     //------------------------------------------------------------------
85     /// Returns a shared pointer to the breakpoint with index \a i.
86     ///
87     /// @param[in] i
88     ///   The breakpoint index to seek for.
89     ///
90     /// @result
91     ///   A shared pointer to the breakpoint.  May contain a NULL pointer if the
92     ///   breakpoint doesn't exist.
93     //------------------------------------------------------------------
94     lldb::BreakpointSP
95     GetBreakpointAtIndex (size_t i);
96
97     //------------------------------------------------------------------
98     /// Returns a shared pointer to the breakpoint with index \a i, const version
99     ///
100     /// @param[in] i
101     ///   The breakpoint index to seek for.
102     ///
103     /// @result
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;
109
110     //------------------------------------------------------------------
111     /// Returns the number of elements in this breakpoint list.
112     ///
113     /// @result
114     ///   The number of elements.
115     //------------------------------------------------------------------
116     size_t
117     GetSize() const 
118     {
119         Mutex::Locker locker(m_mutex);
120         return m_breakpoints.size(); 
121     }
122
123     //------------------------------------------------------------------
124     /// Removes the breakpoint given by \b breakID from this list.
125     ///
126     /// @param[in] breakID
127     ///   The breakpoint index to remove.
128     ///
129     /// @result
130     ///   \b true if the breakpoint \a breakID was in the list.
131     //------------------------------------------------------------------
132     bool
133     Remove (lldb::break_id_t breakID, bool notify);
134
135     
136     //------------------------------------------------------------------
137     /// Removes all invalid breakpoint locations.
138     ///
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).
143     ///
144     /// This is typically used after the process calls exec, or anytime
145     /// the architecture of the target changes.
146     ///
147     /// @param[in] arch
148     ///     If valid, check the module in each breakpoint to make sure
149     ///     they are compatible, otherwise, ignore architecture.
150     //------------------------------------------------------------------
151     void
152     RemoveInvalidLocations (const ArchSpec &arch);
153
154     void
155     SetEnabledAll (bool enabled);
156
157     //------------------------------------------------------------------
158     /// Removes all the breakpoints from this list.
159     //------------------------------------------------------------------
160     void
161     RemoveAll (bool notify);
162
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
166     /// or unloaded.
167     ///
168     /// @param[in] module_list
169     ///   The module list that has changed.
170     ///
171     /// @param[in] load
172     ///   \b true if the modules are loaded, \b false if unloaded.
173     ///
174     /// @param[in] delete_locations
175     ///   If \a load is \b false, then delete breakpoint locations when
176     ///   when updating breakpoints.
177     //------------------------------------------------------------------
178     void
179     UpdateBreakpoints (ModuleList &module_list,
180                        bool load,
181                        bool delete_locations);
182     
183     void
184     UpdateBreakpointsWhenModuleIsReplaced (lldb::ModuleSP old_module_sp, lldb::ModuleSP new_module_sp);
185
186     void
187     ClearAllBreakpointSites ();
188     
189     //------------------------------------------------------------------
190     /// Sets the passed in Locker to hold the Breakpoint List mutex.
191     ///
192     /// @param[in] locker
193     ///   The locker object that is set.
194     //------------------------------------------------------------------
195     void
196     GetListMutex (lldb_private::Mutex::Locker &locker);
197
198 protected:
199     typedef std::list<lldb::BreakpointSP> bp_collection;
200
201     bp_collection::iterator
202     GetBreakpointIDIterator(lldb::break_id_t breakID);
203
204     bp_collection::const_iterator
205     GetBreakpointIDConstIterator(lldb::break_id_t breakID) const;
206
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;
210     bool m_is_internal;
211
212 private:
213     DISALLOW_COPY_AND_ASSIGN (BreakpointList);
214 };
215
216 } // namespace lldb_private
217
218 #endif  // liblldb_BreakpointList_h_