1 //===-- BreakpointSiteList.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_BreakpointSiteList_h_
11 #define liblldb_BreakpointSiteList_h_
17 // Other libraries and framework includes
19 #include "lldb/Breakpoint/BreakpointSite.h"
20 #include "lldb/Host/Mutex.h"
22 namespace lldb_private {
24 //----------------------------------------------------------------------
25 /// @class BreakpointSiteList BreakpointSiteList.h "lldb/Breakpoint/BreakpointSiteList.h"
26 /// @brief Class that manages lists of BreakpointSite shared pointers.
27 //----------------------------------------------------------------------
28 class BreakpointSiteList
30 // At present Process directly accesses the map of BreakpointSites so it can
31 // do quick lookups into the map (using GetMap).
32 // FIXME: Find a better interface for this.
36 //------------------------------------------------------------------
37 /// Default constructor makes an empty list.
38 //------------------------------------------------------------------
41 //------------------------------------------------------------------
42 /// Destructor, currently does nothing.
43 //------------------------------------------------------------------
44 ~BreakpointSiteList();
46 //------------------------------------------------------------------
47 /// Add a BreakpointSite to the list.
49 /// @param[in] bp_site_sp
50 /// A shared pointer to a breakpoint site being added to the list.
53 /// The ID of the BreakpointSite in the list.
54 //------------------------------------------------------------------
56 Add (const lldb::BreakpointSiteSP& bp_site_sp);
58 //------------------------------------------------------------------
59 /// Standard Dump routine, doesn't do anything at present.
61 /// Stream into which to dump the description.
62 //------------------------------------------------------------------
64 Dump (Stream *s) const;
66 //------------------------------------------------------------------
67 /// Returns a shared pointer to the breakpoint site at address
71 /// The address to look for.
74 /// A shared pointer to the breakpoint site. May contain a NULL
75 /// pointer if no breakpoint site exists with a matching address.
76 //------------------------------------------------------------------
77 lldb::BreakpointSiteSP
78 FindByAddress (lldb::addr_t addr);
80 //------------------------------------------------------------------
81 /// Returns a shared pointer to the breakpoint site with id \a breakID.
83 /// @param[in] breakID
84 /// The breakpoint site ID to seek for.
87 /// A shared pointer to the breakpoint site. May contain a NULL pointer if the
88 /// breakpoint doesn't exist.
89 //------------------------------------------------------------------
90 lldb::BreakpointSiteSP
91 FindByID (lldb::break_id_t breakID);
93 //------------------------------------------------------------------
94 /// Returns a shared pointer to the breakpoint site with id \a breakID - const version.
96 /// @param[in] breakID
97 /// The breakpoint site ID to seek for.
100 /// A shared pointer to the breakpoint site. May contain a NULL pointer if the
101 /// breakpoint doesn't exist.
102 //------------------------------------------------------------------
103 const lldb::BreakpointSiteSP
104 FindByID (lldb::break_id_t breakID) const;
106 //------------------------------------------------------------------
107 /// Returns the breakpoint site id to the breakpoint site at address \a addr.
110 /// The address to match.
113 /// The ID of the breakpoint site, or LLDB_INVALID_BREAK_ID.
114 //------------------------------------------------------------------
116 FindIDByAddress (lldb::addr_t addr);
118 //------------------------------------------------------------------
119 /// Returns whether the breakpoint site \a bp_site_id has \a bp_id
120 // as one of its owners.
122 /// @param[in] bp_site_id
123 /// The breakpoint site id to query.
126 /// The breakpoint id to look for in \a bp_site_id.
129 /// True if \a bp_site_id exists in the site list AND \a bp_id is one of the
130 /// owners of that site.
131 //------------------------------------------------------------------
133 BreakpointSiteContainsBreakpoint (lldb::break_id_t bp_site_id, lldb::break_id_t bp_id);
136 ForEach (std::function <void(BreakpointSite *)> const &callback);
138 //------------------------------------------------------------------
139 /// Removes the breakpoint site given by \b breakID from this list.
141 /// @param[in] breakID
142 /// The breakpoint site index to remove.
145 /// \b true if the breakpoint site \a breakID was in the list.
146 //------------------------------------------------------------------
148 Remove (lldb::break_id_t breakID);
150 //------------------------------------------------------------------
151 /// Removes the breakpoint site at address \a addr from this list.
154 /// The address from which to remove a breakpoint site.
157 /// \b true if \a addr had a breakpoint site to remove from the list.
158 //------------------------------------------------------------------
160 RemoveByAddress (lldb::addr_t addr);
163 FindInRange (lldb::addr_t lower_bound, lldb::addr_t upper_bound, BreakpointSiteList &bp_site_list) const;
165 typedef void (*BreakpointSiteSPMapFunc) (lldb::BreakpointSiteSP &bp, void *baton);
167 //------------------------------------------------------------------
168 /// Enquires of the breakpoint site on in this list with ID \a breakID whether
169 /// we should stop for the breakpoint or not.
171 /// @param[in] context
172 /// This contains the information about this stop.
174 /// @param[in] breakID
175 /// This break ID that we hit.
178 /// \b true if we should stop, \b false otherwise.
179 //------------------------------------------------------------------
181 ShouldStop (StoppointCallbackContext *context, lldb::break_id_t breakID);
183 //------------------------------------------------------------------
184 /// Returns the number of elements in the list.
187 /// The number of elements.
188 //------------------------------------------------------------------
192 Mutex::Locker locker(m_mutex);
193 return m_bp_site_list.size();
199 Mutex::Locker locker(m_mutex);
200 return m_bp_site_list.empty();
203 typedef std::map<lldb::addr_t, lldb::BreakpointSiteSP> collection;
206 GetIDIterator(lldb::break_id_t breakID);
208 collection::const_iterator
209 GetIDConstIterator(lldb::break_id_t breakID) const;
211 mutable Mutex m_mutex;
212 collection m_bp_site_list; // The breakpoint site list.
215 } // namespace lldb_private
217 #endif // liblldb_BreakpointSiteList_h_