1254721Semaste//===-- BreakpointLocationCollection.h --------------------------*- C++ -*-===// 2254721Semaste// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6254721Semaste// 7254721Semaste//===----------------------------------------------------------------------===// 8254721Semaste 9254721Semaste#ifndef liblldb_BreakpointLocationCollection_h_ 10254721Semaste#define liblldb_BreakpointLocationCollection_h_ 11254721Semaste 12314564Sdim#include <mutex> 13254721Semaste#include <vector> 14309124Sdim 15314564Sdim#include "lldb/Utility/Iterable.h" 16254721Semaste#include "lldb/lldb-private.h" 17254721Semaste 18254721Semastenamespace lldb_private { 19254721Semaste 20314564Sdimclass BreakpointLocationCollection { 21254721Semastepublic: 22314564Sdim BreakpointLocationCollection(); 23254721Semaste 24314564Sdim ~BreakpointLocationCollection(); 25360784Sdim 26353358Sdim BreakpointLocationCollection &operator=(const BreakpointLocationCollection &rhs); 27254721Semaste 28314564Sdim /// Add the breakpoint \a bp_loc_sp to the list. 29314564Sdim /// 30360784Sdim /// \param[in] bp_loc_sp 31314564Sdim /// Shared pointer to the breakpoint location that will get added 32314564Sdim /// to the list. 33314564Sdim void Add(const lldb::BreakpointLocationSP &bp_loc_sp); 34254721Semaste 35314564Sdim /// Removes the breakpoint location given by \b breakID from this 36314564Sdim /// list. 37314564Sdim /// 38353358Sdim /// \param[in] break_id 39314564Sdim /// The breakpoint index to remove. 40314564Sdim /// 41353358Sdim /// \param[in] break_loc_id 42314564Sdim /// The breakpoint location index in break_id to remove. 43314564Sdim /// 44353358Sdim /// \result 45314564Sdim /// \b true if the breakpoint was in the list. 46314564Sdim bool Remove(lldb::break_id_t break_id, lldb::break_id_t break_loc_id); 47254721Semaste 48314564Sdim /// Returns a shared pointer to the breakpoint location with id \a 49314564Sdim /// breakID. 50314564Sdim /// 51353358Sdim /// \param[in] break_id 52314564Sdim /// The breakpoint ID to seek for. 53314564Sdim /// 54353358Sdim /// \param[in] break_loc_id 55314564Sdim /// The breakpoint location ID in \a break_id to seek for. 56314564Sdim /// 57353358Sdim /// \result 58314564Sdim /// A shared pointer to the breakpoint. May contain a NULL 59314564Sdim /// pointer if the breakpoint doesn't exist. 60314564Sdim lldb::BreakpointLocationSP FindByIDPair(lldb::break_id_t break_id, 61314564Sdim lldb::break_id_t break_loc_id); 62254721Semaste 63314564Sdim /// Returns a shared pointer to the breakpoint location with id \a 64314564Sdim /// breakID, const version. 65314564Sdim /// 66360784Sdim /// \param[in] break_id 67314564Sdim /// The breakpoint location ID to seek for. 68314564Sdim /// 69353358Sdim /// \param[in] break_loc_id 70314564Sdim /// The breakpoint location ID in \a break_id to seek for. 71314564Sdim /// 72353358Sdim /// \result 73314564Sdim /// A shared pointer to the breakpoint. May contain a NULL 74314564Sdim /// pointer if the breakpoint doesn't exist. 75314564Sdim const lldb::BreakpointLocationSP 76314564Sdim FindByIDPair(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const; 77254721Semaste 78314564Sdim /// Returns a shared pointer to the breakpoint location with index 79314564Sdim /// \a i. 80314564Sdim /// 81353358Sdim /// \param[in] i 82314564Sdim /// The breakpoint location index to seek for. 83314564Sdim /// 84353358Sdim /// \result 85314564Sdim /// A shared pointer to the breakpoint. May contain a NULL 86314564Sdim /// pointer if the breakpoint doesn't exist. 87314564Sdim lldb::BreakpointLocationSP GetByIndex(size_t i); 88254721Semaste 89314564Sdim /// Returns a shared pointer to the breakpoint location with index 90314564Sdim /// \a i, const version. 91314564Sdim /// 92353358Sdim /// \param[in] i 93314564Sdim /// The breakpoint location index to seek for. 94314564Sdim /// 95353358Sdim /// \result 96314564Sdim /// A shared pointer to the breakpoint. May contain a NULL 97314564Sdim /// pointer if the breakpoint doesn't exist. 98314564Sdim const lldb::BreakpointLocationSP GetByIndex(size_t i) const; 99254721Semaste 100314564Sdim /// Returns the number of elements in this breakpoint location list. 101314564Sdim /// 102353358Sdim /// \result 103314564Sdim /// The number of elements. 104314564Sdim size_t GetSize() const { return m_break_loc_collection.size(); } 105254721Semaste 106314564Sdim /// Enquires of all the breakpoint locations in this list whether 107314564Sdim /// we should stop at a hit at \a breakID. 108314564Sdim /// 109353358Sdim /// \param[in] context 110314564Sdim /// This contains the information about this stop. 111314564Sdim /// 112353358Sdim /// \return 113314564Sdim /// \b true if we should stop, \b false otherwise. 114314564Sdim bool ShouldStop(StoppointCallbackContext *context); 115254721Semaste 116314564Sdim /// Print a description of the breakpoint locations in this list 117314564Sdim /// to the stream \a s. 118314564Sdim /// 119353358Sdim /// \param[in] s 120314564Sdim /// The stream to which to print the description. 121314564Sdim /// 122353358Sdim /// \param[in] level 123314564Sdim /// The description level that indicates the detail level to 124314564Sdim /// provide. 125314564Sdim /// 126353358Sdim /// \see lldb::DescriptionLevel 127314564Sdim void GetDescription(Stream *s, lldb::DescriptionLevel level); 128254721Semaste 129314564Sdim /// Check whether this collection of breakpoint locations have any 130314564Sdim /// thread specifiers, and if yes, is \a thread_id contained in any 131314564Sdim /// of these specifiers. 132314564Sdim /// 133353358Sdim /// \param[in] thread 134314564Sdim /// The thread against which to test. 135314564Sdim /// 136314564Sdim /// return 137314564Sdim /// \b true if the collection contains at least one location that 138314564Sdim /// would be valid for this thread, false otherwise. 139314564Sdim bool ValidForThisThread(Thread *thread); 140254721Semaste 141314564Sdim /// Tell whether ALL the breakpoints in the location collection are internal. 142314564Sdim /// 143353358Sdim /// \result 144314564Sdim /// \b true if all breakpoint locations are owned by internal breakpoints, 145314564Sdim /// \b false otherwise. 146314564Sdim bool IsInternal() const; 147254721Semaste 148254721Semasteprotected: 149341825Sdim // Classes that inherit from BreakpointLocationCollection can see and modify 150341825Sdim // these 151254721Semaste 152254721Semasteprivate: 153314564Sdim // For BreakpointLocationCollection only 154254721Semaste 155314564Sdim typedef std::vector<lldb::BreakpointLocationSP> collection; 156254721Semaste 157314564Sdim collection::iterator GetIDPairIterator(lldb::break_id_t break_id, 158314564Sdim lldb::break_id_t break_loc_id); 159254721Semaste 160314564Sdim collection::const_iterator 161314564Sdim GetIDPairConstIterator(lldb::break_id_t break_id, 162314564Sdim lldb::break_id_t break_loc_id) const; 163254721Semaste 164314564Sdim collection m_break_loc_collection; 165314564Sdim mutable std::mutex m_collection_mutex; 166254721Semaste 167280031Sdimpublic: 168314564Sdim typedef AdaptedIterable<collection, lldb::BreakpointLocationSP, 169314564Sdim vector_adapter> 170314564Sdim BreakpointLocationCollectionIterable; 171314564Sdim BreakpointLocationCollectionIterable BreakpointLocations() { 172314564Sdim return BreakpointLocationCollectionIterable(m_break_loc_collection); 173314564Sdim } 174254721Semaste}; 175254721Semaste 176254721Semaste} // namespace lldb_private 177254721Semaste 178314564Sdim#endif // liblldb_BreakpointLocationCollection_h_ 179