Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:43

0001 //===-- BreakpointLocationCollection.h --------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_BREAKPOINT_BREAKPOINTLOCATIONCOLLECTION_H
0010 #define LLDB_BREAKPOINT_BREAKPOINTLOCATIONCOLLECTION_H
0011 
0012 #include <mutex>
0013 #include <vector>
0014 
0015 #include "lldb/Utility/Iterable.h"
0016 #include "lldb/lldb-private.h"
0017 
0018 namespace lldb_private {
0019 
0020 class BreakpointLocationCollection {
0021 public:
0022   BreakpointLocationCollection();
0023 
0024   ~BreakpointLocationCollection();
0025 
0026   BreakpointLocationCollection &operator=(const BreakpointLocationCollection &rhs);
0027 
0028   /// Add the breakpoint \a bp_loc_sp to the list.
0029   ///
0030   /// \param[in] bp_loc_sp
0031   ///     Shared pointer to the breakpoint location that will get added
0032   ///     to the list.
0033   void Add(const lldb::BreakpointLocationSP &bp_loc_sp);
0034 
0035   /// Removes the breakpoint location given by \b breakID from this
0036   /// list.
0037   ///
0038   /// \param[in] break_id
0039   ///     The breakpoint index to remove.
0040   ///
0041   /// \param[in] break_loc_id
0042   ///     The breakpoint location index in break_id to remove.
0043   ///
0044   /// \result
0045   ///     \b true if the breakpoint was in the list.
0046   bool Remove(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);
0047 
0048   /// Returns a shared pointer to the breakpoint location with id \a
0049   /// breakID.
0050   ///
0051   /// \param[in] break_id
0052   ///     The breakpoint  ID to seek for.
0053   ///
0054   /// \param[in] break_loc_id
0055   ///     The breakpoint location ID in \a break_id to seek for.
0056   ///
0057   /// \result
0058   ///     A shared pointer to the breakpoint.  May contain a NULL
0059   ///     pointer if the breakpoint doesn't exist.
0060   lldb::BreakpointLocationSP FindByIDPair(lldb::break_id_t break_id,
0061                                           lldb::break_id_t break_loc_id);
0062 
0063   /// Returns a shared pointer to the breakpoint location with id \a
0064   /// breakID, const version.
0065   ///
0066   /// \param[in] break_id
0067   ///     The breakpoint location ID to seek for.
0068   ///
0069   /// \param[in] break_loc_id
0070   ///     The breakpoint location ID in \a break_id to seek for.
0071   ///
0072   /// \result
0073   ///     A shared pointer to the breakpoint.  May contain a NULL
0074   ///     pointer if the breakpoint doesn't exist.
0075   const lldb::BreakpointLocationSP
0076   FindByIDPair(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;
0077 
0078   /// Returns a shared pointer to the breakpoint location with index
0079   /// \a i.
0080   ///
0081   /// \param[in] i
0082   ///     The breakpoint location index to seek for.
0083   ///
0084   /// \result
0085   ///     A shared pointer to the breakpoint.  May contain a NULL
0086   ///     pointer if the breakpoint doesn't exist.
0087   lldb::BreakpointLocationSP GetByIndex(size_t i);
0088 
0089   /// Returns a shared pointer to the breakpoint location with index
0090   /// \a i, const version.
0091   ///
0092   /// \param[in] i
0093   ///     The breakpoint location index to seek for.
0094   ///
0095   /// \result
0096   ///     A shared pointer to the breakpoint.  May contain a NULL
0097   ///     pointer if the breakpoint doesn't exist.
0098   const lldb::BreakpointLocationSP GetByIndex(size_t i) const;
0099 
0100   /// Returns the number of elements in this breakpoint location list.
0101   ///
0102   /// \result
0103   ///     The number of elements.
0104   size_t GetSize() const { return m_break_loc_collection.size(); }
0105 
0106   /// Enquires of all the breakpoint locations in this list whether
0107   /// we should stop at a hit at \a breakID.
0108   ///
0109   /// \param[in] context
0110   ///    This contains the information about this stop.
0111   ///
0112   /// \return
0113   ///    \b true if we should stop, \b false otherwise.
0114   bool ShouldStop(StoppointCallbackContext *context);
0115 
0116   /// Print a description of the breakpoint locations in this list
0117   /// to the stream \a s.
0118   ///
0119   /// \param[in] s
0120   ///     The stream to which to print the description.
0121   ///
0122   /// \param[in] level
0123   ///     The description level that indicates the detail level to
0124   ///     provide.
0125   ///
0126   /// \see lldb::DescriptionLevel
0127   void GetDescription(Stream *s, lldb::DescriptionLevel level);
0128 
0129   /// Check whether this collection of breakpoint locations have any
0130   /// thread specifiers, and if yes, is \a thread_id contained in any
0131   /// of these specifiers.
0132   ///
0133   /// \param[in] thread
0134   ///     The thread against which to test.
0135   ///
0136   /// return
0137   ///     \b true if the collection contains at least one location that
0138   ///     would be valid for this thread, false otherwise.
0139   bool ValidForThisThread(Thread &thread);
0140 
0141   /// Tell whether ALL the breakpoints in the location collection are internal.
0142   ///
0143   /// \result
0144   ///     \b true if all breakpoint locations are owned by internal breakpoints,
0145   ///     \b false otherwise.
0146   bool IsInternal() const;
0147 
0148 protected:
0149   // Classes that inherit from BreakpointLocationCollection can see and modify
0150   // these
0151 
0152 private:
0153   // For BreakpointLocationCollection only
0154 
0155   typedef std::vector<lldb::BreakpointLocationSP> collection;
0156 
0157   collection::iterator GetIDPairIterator(lldb::break_id_t break_id,
0158                                          lldb::break_id_t break_loc_id);
0159 
0160   collection::const_iterator
0161   GetIDPairConstIterator(lldb::break_id_t break_id,
0162                          lldb::break_id_t break_loc_id) const;
0163 
0164   collection m_break_loc_collection;
0165   mutable std::mutex m_collection_mutex;
0166 
0167 public:
0168   typedef AdaptedIterable<collection, lldb::BreakpointLocationSP,
0169                           vector_adapter>
0170       BreakpointLocationCollectionIterable;
0171   BreakpointLocationCollectionIterable BreakpointLocations() {
0172     return BreakpointLocationCollectionIterable(m_break_loc_collection);
0173   }
0174 };
0175 
0176 } // namespace lldb_private
0177 
0178 #endif // LLDB_BREAKPOINT_BREAKPOINTLOCATIONCOLLECTION_H