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_
16 // Other libraries and framework includes
18 #include "lldb/Breakpoint/BreakpointSite.h"
19 #include "lldb/Host/Mutex.h"
21 namespace lldb_private {
23 //----------------------------------------------------------------------
24 /// @class BreakpointSiteList BreakpointSiteList.h "lldb/Breakpoint/BreakpointSiteList.h"
25 /// @brief Class that manages lists of BreakpointSite shared pointers.
26 //----------------------------------------------------------------------
27 class BreakpointSiteList
29 // At present Process directly accesses the map of BreakpointSites so it can
30 // do quick lookups into the map (using GetMap).
31 // FIXME: Find a better interface for this.
35 //------------------------------------------------------------------
36 /// Default constructor makes an empty list.
37 //------------------------------------------------------------------
40 //------------------------------------------------------------------
41 /// Destructor, currently does nothing.
42 //------------------------------------------------------------------
43 ~BreakpointSiteList();
45 //------------------------------------------------------------------
46 /// Add a BreakpointSite to the list.
48 /// @param[in] bp_site_sp
49 /// A shared pointer to a breakpoint site being added to the list.
52 /// The ID of the BreakpointSite in the list.
53 //------------------------------------------------------------------
55 Add (const lldb::BreakpointSiteSP& bp_site_sp);
57 //------------------------------------------------------------------
58 /// Standard Dump routine, doesn't do anything at present.
60 /// Stream into which to dump the description.
61 //------------------------------------------------------------------
63 Dump (Stream *s) const;
65 //------------------------------------------------------------------
66 /// Returns a shared pointer to the breakpoint site at address
70 /// The address to look for.
73 /// A shared pointer to the breakpoint site. May contain a NULL
74 /// pointer if no breakpoint site exists with a matching address.
75 //------------------------------------------------------------------
76 lldb::BreakpointSiteSP
77 FindByAddress (lldb::addr_t addr);
79 //------------------------------------------------------------------
80 /// Returns a shared pointer to the breakpoint site with id \a breakID.
82 /// @param[in] breakID
83 /// The breakpoint site ID to seek for.
86 /// A shared pointer to the breakpoint site. May contain a NULL pointer if the
87 /// breakpoint doesn't exist.
88 //------------------------------------------------------------------
89 lldb::BreakpointSiteSP
90 FindByID (lldb::break_id_t breakID);
92 //------------------------------------------------------------------
93 /// Returns a shared pointer to the breakpoint site with id \a breakID - const version.
95 /// @param[in] breakID
96 /// The breakpoint site ID to seek for.
99 /// A shared pointer to the breakpoint site. May contain a NULL pointer if the
100 /// breakpoint doesn't exist.
101 //------------------------------------------------------------------
102 const lldb::BreakpointSiteSP
103 FindByID (lldb::break_id_t breakID) const;
105 //------------------------------------------------------------------
106 /// Returns the breakpoint site id to the breakpoint site at address \a addr.
109 /// The address to match.
112 /// The ID of the breakpoint site, or LLDB_INVALID_BREAK_ID.
113 //------------------------------------------------------------------
115 FindIDByAddress (lldb::addr_t addr);
117 //------------------------------------------------------------------
118 /// Returns whether the breakpoint site \a bp_site_id has \a bp_id
119 // as one of its owners.
121 /// @param[in] bp_site_id
122 /// The breakpoint site id to query.
125 /// The breakpoint id to look for in \a bp_site_id.
128 /// True if \a bp_site_id exists in the site list AND \a bp_id is one of the
129 /// owners of that site.
130 //------------------------------------------------------------------
132 BreakpointSiteContainsBreakpoint (lldb::break_id_t bp_site_id, lldb::break_id_t bp_id);
135 ForEach (std::function <void(BreakpointSite *)> const &callback);
137 //------------------------------------------------------------------
138 /// Removes the breakpoint site given by \b breakID from this list.
140 /// @param[in] breakID
141 /// The breakpoint site index to remove.
144 /// \b true if the breakpoint site \a breakID was in the list.
145 //------------------------------------------------------------------
147 Remove (lldb::break_id_t breakID);
149 //------------------------------------------------------------------
150 /// Removes the breakpoint site at address \a addr from this list.
153 /// The address from which to remove a breakpoint site.
156 /// \b true if \a addr had a breakpoint site to remove from the list.
157 //------------------------------------------------------------------
159 RemoveByAddress (lldb::addr_t addr);
162 FindInRange (lldb::addr_t lower_bound, lldb::addr_t upper_bound, BreakpointSiteList &bp_site_list) const;
164 typedef void (*BreakpointSiteSPMapFunc) (lldb::BreakpointSiteSP &bp, void *baton);
166 //------------------------------------------------------------------
167 /// Enquires of the breakpoint site on in this list with ID \a breakID whether
168 /// we should stop for the breakpoint or not.
170 /// @param[in] context
171 /// This contains the information about this stop.
173 /// @param[in] breakID
174 /// This break ID that we hit.
177 /// \b true if we should stop, \b false otherwise.
178 //------------------------------------------------------------------
180 ShouldStop (StoppointCallbackContext *context, lldb::break_id_t breakID);
182 //------------------------------------------------------------------
183 /// Returns the number of elements in the list.
186 /// The number of elements.
187 //------------------------------------------------------------------
191 Mutex::Locker locker(m_mutex);
192 return m_bp_site_list.size();
198 Mutex::Locker locker(m_mutex);
199 return m_bp_site_list.empty();
202 typedef std::map<lldb::addr_t, lldb::BreakpointSiteSP> collection;
205 GetIDIterator(lldb::break_id_t breakID);
207 collection::const_iterator
208 GetIDConstIterator(lldb::break_id_t breakID) const;
210 mutable Mutex m_mutex;
211 collection m_bp_site_list; // The breakpoint site list.
214 } // namespace lldb_private
216 #endif // liblldb_BreakpointSiteList_h_