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 #include "lldb/Breakpoint/BreakpointSite.h"
19 namespace lldb_private {
21 //----------------------------------------------------------------------
22 /// @class BreakpointSiteList BreakpointSiteList.h
23 /// "lldb/Breakpoint/BreakpointSiteList.h" Class that manages lists of
24 /// BreakpointSite shared pointers.
25 //----------------------------------------------------------------------
26 class BreakpointSiteList {
27 // At present Process directly accesses the map of BreakpointSites so it can
28 // do quick lookups into the map (using GetMap).
29 // FIXME: Find a better interface for this.
33 //------------------------------------------------------------------
34 /// Default constructor makes an empty list.
35 //------------------------------------------------------------------
38 //------------------------------------------------------------------
39 /// Destructor, currently does nothing.
40 //------------------------------------------------------------------
41 ~BreakpointSiteList();
43 //------------------------------------------------------------------
44 /// Add a BreakpointSite to the list.
46 /// @param[in] bp_site_sp
47 /// A shared pointer to a breakpoint site being added to the list.
50 /// The ID of the BreakpointSite in the list.
51 //------------------------------------------------------------------
52 lldb::break_id_t Add(const lldb::BreakpointSiteSP &bp_site_sp);
54 //------------------------------------------------------------------
55 /// Standard Dump routine, doesn't do anything at present. @param[in] s
56 /// Stream into which to dump the description.
57 //------------------------------------------------------------------
58 void Dump(Stream *s) const;
60 //------------------------------------------------------------------
61 /// Returns a shared pointer to the breakpoint site at address \a addr.
64 /// The address to look for.
67 /// A shared pointer to the breakpoint site. May contain a NULL
68 /// pointer if no breakpoint site exists with a matching address.
69 //------------------------------------------------------------------
70 lldb::BreakpointSiteSP FindByAddress(lldb::addr_t addr);
72 //------------------------------------------------------------------
73 /// Returns a shared pointer to the breakpoint site with id \a breakID.
75 /// @param[in] breakID
76 /// The breakpoint site ID to seek for.
79 /// A shared pointer to the breakpoint site. May contain a NULL pointer if
81 /// breakpoint doesn't exist.
82 //------------------------------------------------------------------
83 lldb::BreakpointSiteSP FindByID(lldb::break_id_t breakID);
85 //------------------------------------------------------------------
86 /// Returns a shared pointer to the breakpoint site with id \a breakID -
89 /// @param[in] breakID
90 /// The breakpoint site ID to seek for.
93 /// A shared pointer to the breakpoint site. May contain a NULL pointer if
95 /// breakpoint doesn't exist.
96 //------------------------------------------------------------------
97 const lldb::BreakpointSiteSP FindByID(lldb::break_id_t breakID) const;
99 //------------------------------------------------------------------
100 /// Returns the breakpoint site id to the breakpoint site at address \a
104 /// The address to match.
107 /// The ID of the breakpoint site, or LLDB_INVALID_BREAK_ID.
108 //------------------------------------------------------------------
109 lldb::break_id_t FindIDByAddress(lldb::addr_t addr);
111 //------------------------------------------------------------------
112 /// Returns whether the breakpoint site \a bp_site_id has \a bp_id
113 // as one of its owners.
115 /// @param[in] bp_site_id
116 /// The breakpoint site id to query.
119 /// The breakpoint id to look for in \a bp_site_id.
122 /// True if \a bp_site_id exists in the site list AND \a bp_id is one of the
123 /// owners of that site.
124 //------------------------------------------------------------------
125 bool BreakpointSiteContainsBreakpoint(lldb::break_id_t bp_site_id,
126 lldb::break_id_t bp_id);
128 void ForEach(std::function<void(BreakpointSite *)> const &callback);
130 //------------------------------------------------------------------
131 /// Removes the breakpoint site given by \b breakID from this list.
133 /// @param[in] breakID
134 /// The breakpoint site index to remove.
137 /// \b true if the breakpoint site \a breakID was in the list.
138 //------------------------------------------------------------------
139 bool Remove(lldb::break_id_t breakID);
141 //------------------------------------------------------------------
142 /// Removes the breakpoint site at address \a addr from this list.
145 /// The address from which to remove a breakpoint site.
148 /// \b true if \a addr had a breakpoint site to remove from the list.
149 //------------------------------------------------------------------
150 bool RemoveByAddress(lldb::addr_t addr);
152 bool FindInRange(lldb::addr_t lower_bound, lldb::addr_t upper_bound,
153 BreakpointSiteList &bp_site_list) const;
155 typedef void (*BreakpointSiteSPMapFunc)(lldb::BreakpointSiteSP &bp,
158 //------------------------------------------------------------------
159 /// Enquires of the breakpoint site on in this list with ID \a breakID
160 /// whether we should stop for the breakpoint or not.
162 /// @param[in] context
163 /// This contains the information about this stop.
165 /// @param[in] breakID
166 /// This break ID that we hit.
169 /// \b true if we should stop, \b false otherwise.
170 //------------------------------------------------------------------
171 bool ShouldStop(StoppointCallbackContext *context, lldb::break_id_t breakID);
173 //------------------------------------------------------------------
174 /// Returns the number of elements in the list.
177 /// The number of elements.
178 //------------------------------------------------------------------
179 size_t GetSize() const {
180 std::lock_guard<std::recursive_mutex> guard(m_mutex);
181 return m_bp_site_list.size();
184 bool IsEmpty() const {
185 std::lock_guard<std::recursive_mutex> guard(m_mutex);
186 return m_bp_site_list.empty();
190 typedef std::map<lldb::addr_t, lldb::BreakpointSiteSP> collection;
192 collection::iterator GetIDIterator(lldb::break_id_t breakID);
194 collection::const_iterator GetIDConstIterator(lldb::break_id_t breakID) const;
196 mutable std::recursive_mutex m_mutex;
197 collection m_bp_site_list; // The breakpoint site list.
200 } // namespace lldb_private
202 #endif // liblldb_BreakpointSiteList_h_