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_
19 // Other libraries and framework includes
21 #include "lldb/Breakpoint/BreakpointSite.h"
23 namespace lldb_private {
25 //----------------------------------------------------------------------
26 /// @class BreakpointSiteList BreakpointSiteList.h
27 /// "lldb/Breakpoint/BreakpointSiteList.h" Class that manages lists of
28 /// BreakpointSite shared pointers.
29 //----------------------------------------------------------------------
30 class BreakpointSiteList {
31 // At present Process directly accesses the map of BreakpointSites so it can
32 // do quick lookups into the map (using GetMap).
33 // FIXME: Find a better interface for this.
37 //------------------------------------------------------------------
38 /// Default constructor makes an empty list.
39 //------------------------------------------------------------------
42 //------------------------------------------------------------------
43 /// Destructor, currently does nothing.
44 //------------------------------------------------------------------
45 ~BreakpointSiteList();
47 //------------------------------------------------------------------
48 /// Add a BreakpointSite to the list.
50 /// @param[in] bp_site_sp
51 /// A shared pointer to a breakpoint site being added to the list.
54 /// The ID of the BreakpointSite in the list.
55 //------------------------------------------------------------------
56 lldb::break_id_t Add(const lldb::BreakpointSiteSP &bp_site_sp);
58 //------------------------------------------------------------------
59 /// Standard Dump routine, doesn't do anything at present. @param[in] s
60 /// Stream into which to dump the description.
61 //------------------------------------------------------------------
62 void Dump(Stream *s) const;
64 //------------------------------------------------------------------
65 /// Returns a shared pointer to the breakpoint site at address \a addr.
68 /// The address to look for.
71 /// A shared pointer to the breakpoint site. May contain a NULL
72 /// pointer if no breakpoint site exists with a matching address.
73 //------------------------------------------------------------------
74 lldb::BreakpointSiteSP FindByAddress(lldb::addr_t addr);
76 //------------------------------------------------------------------
77 /// Returns a shared pointer to the breakpoint site with id \a breakID.
79 /// @param[in] breakID
80 /// The breakpoint site ID to seek for.
83 /// A shared pointer to the breakpoint site. May contain a NULL pointer if
85 /// breakpoint doesn't exist.
86 //------------------------------------------------------------------
87 lldb::BreakpointSiteSP FindByID(lldb::break_id_t breakID);
89 //------------------------------------------------------------------
90 /// Returns a shared pointer to the breakpoint site with id \a breakID -
93 /// @param[in] breakID
94 /// The breakpoint site ID to seek for.
97 /// A shared pointer to the breakpoint site. May contain a NULL pointer if
99 /// breakpoint doesn't exist.
100 //------------------------------------------------------------------
101 const lldb::BreakpointSiteSP FindByID(lldb::break_id_t breakID) const;
103 //------------------------------------------------------------------
104 /// Returns the breakpoint site id to the breakpoint site at address \a
108 /// The address to match.
111 /// The ID of the breakpoint site, or LLDB_INVALID_BREAK_ID.
112 //------------------------------------------------------------------
113 lldb::break_id_t FindIDByAddress(lldb::addr_t addr);
115 //------------------------------------------------------------------
116 /// Returns whether the breakpoint site \a bp_site_id has \a bp_id
117 // as one of its owners.
119 /// @param[in] bp_site_id
120 /// The breakpoint site id to query.
123 /// The breakpoint id to look for in \a bp_site_id.
126 /// True if \a bp_site_id exists in the site list AND \a bp_id is one of the
127 /// owners of that site.
128 //------------------------------------------------------------------
129 bool BreakpointSiteContainsBreakpoint(lldb::break_id_t bp_site_id,
130 lldb::break_id_t bp_id);
132 void ForEach(std::function<void(BreakpointSite *)> const &callback);
134 //------------------------------------------------------------------
135 /// Removes the breakpoint site given by \b breakID from this list.
137 /// @param[in] breakID
138 /// The breakpoint site index to remove.
141 /// \b true if the breakpoint site \a breakID was in the list.
142 //------------------------------------------------------------------
143 bool Remove(lldb::break_id_t breakID);
145 //------------------------------------------------------------------
146 /// Removes the breakpoint site at address \a addr from this list.
149 /// The address from which to remove a breakpoint site.
152 /// \b true if \a addr had a breakpoint site to remove from the list.
153 //------------------------------------------------------------------
154 bool RemoveByAddress(lldb::addr_t addr);
156 bool FindInRange(lldb::addr_t lower_bound, lldb::addr_t upper_bound,
157 BreakpointSiteList &bp_site_list) const;
159 typedef void (*BreakpointSiteSPMapFunc)(lldb::BreakpointSiteSP &bp,
162 //------------------------------------------------------------------
163 /// Enquires of the breakpoint site on in this list with ID \a breakID
164 /// whether we should stop for the breakpoint or not.
166 /// @param[in] context
167 /// This contains the information about this stop.
169 /// @param[in] breakID
170 /// This break ID that we hit.
173 /// \b true if we should stop, \b false otherwise.
174 //------------------------------------------------------------------
175 bool ShouldStop(StoppointCallbackContext *context, lldb::break_id_t breakID);
177 //------------------------------------------------------------------
178 /// Returns the number of elements in the list.
181 /// The number of elements.
182 //------------------------------------------------------------------
183 size_t GetSize() const {
184 std::lock_guard<std::recursive_mutex> guard(m_mutex);
185 return m_bp_site_list.size();
188 bool IsEmpty() const {
189 std::lock_guard<std::recursive_mutex> guard(m_mutex);
190 return m_bp_site_list.empty();
194 typedef std::map<lldb::addr_t, lldb::BreakpointSiteSP> collection;
196 collection::iterator GetIDIterator(lldb::break_id_t breakID);
198 collection::const_iterator GetIDConstIterator(lldb::break_id_t breakID) const;
200 mutable std::recursive_mutex m_mutex;
201 collection m_bp_site_list; // The breakpoint site list.
204 } // namespace lldb_private
206 #endif // liblldb_BreakpointSiteList_h_