aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Breakpoint/BreakpointLocationCollection.h
blob: 1a016544fa4ca9d86965d64c7054e1480b61a65a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
//===-- BreakpointLocationCollection.h --------------------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef liblldb_BreakpointLocationCollection_h_
#define liblldb_BreakpointLocationCollection_h_

// C Includes
// C++ Includes
#include <vector>
#include <mutex>

// Other libraries and framework includes
// Project includes
#include "lldb/lldb-private.h"
#include "lldb/Utility/Iterable.h"

namespace lldb_private {

class BreakpointLocationCollection
{
public:
    BreakpointLocationCollection();

    ~BreakpointLocationCollection();

    //------------------------------------------------------------------
    /// Add the breakpoint \a bp_loc_sp to the list.
    ///
    /// @param[in] bp_sp
    ///     Shared pointer to the breakpoint location that will get added
    ///     to the list.
    ///
    /// @result
    ///     Returns breakpoint location id.
    //------------------------------------------------------------------
    void
    Add (const lldb::BreakpointLocationSP& bp_loc_sp);

    //------------------------------------------------------------------
    /// Removes the breakpoint location given by \b breakID from this
    /// list.
    ///
    /// @param[in] break_id
    ///     The breakpoint index to remove.
    ///
    /// @param[in] break_loc_id
    ///     The breakpoint location index in break_id to remove.
    ///
    /// @result
    ///     \b true if the breakpoint was in the list.
    //------------------------------------------------------------------
    bool
    Remove (lldb::break_id_t break_id, lldb::break_id_t break_loc_id);

    //------------------------------------------------------------------
    /// Returns a shared pointer to the breakpoint location with id \a
    /// breakID.
    ///
    /// @param[in] break_id
    ///     The breakpoint  ID to seek for.
    ///
    /// @param[in] break_loc_id
    ///     The breakpoint location ID in \a break_id to seek for.
    ///
    /// @result
    ///     A shared pointer to the breakpoint.  May contain a NULL
    ///     pointer if the breakpoint doesn't exist.
    //------------------------------------------------------------------
    lldb::BreakpointLocationSP
    FindByIDPair (lldb::break_id_t break_id, lldb::break_id_t break_loc_id);

    //------------------------------------------------------------------
    /// Returns a shared pointer to the breakpoint location with id \a
    /// breakID, const version.
    ///
    /// @param[in] breakID
    ///     The breakpoint location ID to seek for.
    ///
    /// @param[in] break_loc_id
    ///     The breakpoint location ID in \a break_id to seek for.
    ///
    /// @result
    ///     A shared pointer to the breakpoint.  May contain a NULL
    ///     pointer if the breakpoint doesn't exist.
    //------------------------------------------------------------------
    const lldb::BreakpointLocationSP
    FindByIDPair (lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;

    //------------------------------------------------------------------
    /// Returns a shared pointer to the breakpoint location with index
    /// \a i.
    ///
    /// @param[in] i
    ///     The breakpoint location index to seek for.
    ///
    /// @result
    ///     A shared pointer to the breakpoint.  May contain a NULL
    ///     pointer if the breakpoint doesn't exist.
    //------------------------------------------------------------------
    lldb::BreakpointLocationSP
    GetByIndex (size_t i);

    //------------------------------------------------------------------
    /// Returns a shared pointer to the breakpoint location with index
    /// \a i, const version.
    ///
    /// @param[in] i
    ///     The breakpoint location index to seek for.
    ///
    /// @result
    ///     A shared pointer to the breakpoint.  May contain a NULL
    ///     pointer if the breakpoint doesn't exist.
    //------------------------------------------------------------------
    const lldb::BreakpointLocationSP
    GetByIndex (size_t i) const;

    //------------------------------------------------------------------
    /// Returns the number of elements in this breakpoint location list.
    ///
    /// @result
    ///     The number of elements.
    //------------------------------------------------------------------
    size_t
    GetSize() const { return m_break_loc_collection.size(); }

    //------------------------------------------------------------------
    /// Enquires of all the breakpoint locations in this list whether
    /// we should stop at a hit at \a breakID.
    ///
    /// @param[in] context
    ///    This contains the information about this stop.
    ///
    /// @param[in] breakID
    ///    This break ID that we hit.
    ///
    /// @return
    ///    \b true if we should stop, \b false otherwise.
    //------------------------------------------------------------------
    bool
    ShouldStop (StoppointCallbackContext *context);

    //------------------------------------------------------------------
    /// Print a description of the breakpoint locations in this list
    /// to the stream \a s.
    ///
    /// @param[in] s
    ///     The stream to which to print the description.
    ///
    /// @param[in] level
    ///     The description level that indicates the detail level to
    ///     provide.
    ///
    /// @see lldb::DescriptionLevel
    //------------------------------------------------------------------
    void GetDescription (Stream *s, lldb::DescriptionLevel level);
    
    //------------------------------------------------------------------
    /// Check whether this collection of breakpoint locations have any
    /// thread specifiers, and if yes, is \a thread_id contained in any
    /// of these specifiers.
    ///
    /// @param[in] thread
    ///     The thread against which to test.
    ///
    /// return
    ///     \b true if the collection contains at least one location that
    ///     would be valid for this thread, false otherwise.
    //------------------------------------------------------------------
    bool ValidForThisThread (Thread *thread);

    //------------------------------------------------------------------
    /// Tell whether ALL the breakpoints in the location collection are internal.
    ///
    /// @result
    ///     \b true if all breakpoint locations are owned by internal breakpoints,
    ///     \b false otherwise.
    //------------------------------------------------------------------
    bool IsInternal() const;


protected:
    //------------------------------------------------------------------
    // Classes that inherit from BreakpointLocationCollection can see
    // and modify these
    //------------------------------------------------------------------

private:
    //------------------------------------------------------------------
    // For BreakpointLocationCollection only
    //------------------------------------------------------------------

    typedef std::vector<lldb::BreakpointLocationSP> collection;

    collection::iterator
    GetIDPairIterator(lldb::break_id_t break_id, lldb::break_id_t break_loc_id);

    collection::const_iterator
    GetIDPairConstIterator(lldb::break_id_t break_id, lldb::break_id_t break_loc_id) const;

    collection     m_break_loc_collection;
    mutable std::mutex  m_collection_mutex;

public:
    typedef AdaptedIterable<collection, lldb::BreakpointLocationSP, vector_adapter> BreakpointLocationCollectionIterable;
    BreakpointLocationCollectionIterable
    BreakpointLocations()
    {
        return BreakpointLocationCollectionIterable(m_break_loc_collection);
    }

};

} // namespace lldb_private

#endif  // liblldb_BreakpointLocationCollection_h_