]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/lldb/Target/QueueList.h
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / include / lldb / Target / QueueList.h
1 //===-- QueueList.h --------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_QueueList_h_
11 #define liblldb_QueueList_h_
12
13 #include <mutex>
14 #include <vector>
15
16 #include "lldb/Core/UserID.h"
17 #include "lldb/Utility/Iterable.h"
18 #include "lldb/lldb-private.h"
19
20 namespace lldb_private {
21
22 //------------------------------------------------------------------
23 // QueueList:
24 // This is the container for libdispatch aka Grand Central Dispatch
25 // Queue objects.
26 //
27 // Each Process will have a QueueList.  When the process execution is
28 // paused, the QueueList may be populated with Queues by the
29 // SystemRuntime.
30 //------------------------------------------------------------------
31
32 class QueueList {
33   friend class Process;
34
35 public:
36   QueueList(Process *process);
37
38   ~QueueList();
39
40   //------------------------------------------------------------------
41   /// Get the number of libdispatch queues that are available
42   ///
43   /// @return
44   ///     The number of queues that are stored in the QueueList.
45   //------------------------------------------------------------------
46   uint32_t GetSize();
47
48   //------------------------------------------------------------------
49   /// Get the Queue at a given index number
50   ///
51   /// @param [in] idx
52   ///     The index number (0-based) of the queue.
53   /// @return
54   ///     The Queue at that index number.
55   //------------------------------------------------------------------
56   lldb::QueueSP GetQueueAtIndex(uint32_t idx);
57
58   typedef std::vector<lldb::QueueSP> collection;
59   typedef LockingAdaptedIterable<collection, lldb::QueueSP, vector_adapter,
60                                  std::mutex>
61       QueueIterable;
62
63   //------------------------------------------------------------------
64   /// Iterate over the list of queues
65   ///
66   /// @return
67   ///     An Iterable object which can be used to loop over the queues
68   ///     that exist.
69   //------------------------------------------------------------------
70   QueueIterable Queues() { return QueueIterable(m_queues, m_mutex); }
71
72   //------------------------------------------------------------------
73   /// Clear out the list of queues from the QueueList
74   //------------------------------------------------------------------
75   void Clear();
76
77   //------------------------------------------------------------------
78   /// Add a Queue to the QueueList
79   ///
80   /// @param [in] queue
81   ///     Used by the SystemRuntime to populate the QueueList
82   //------------------------------------------------------------------
83   void AddQueue(lldb::QueueSP queue);
84
85   //------------------------------------------------------------------
86   /// Find a queue in the QueueList by QueueID
87   ///
88   /// @param [in] qid
89   ///     The QueueID (same as returned by Thread::GetQueueID()) to find.
90   ///
91   /// @return
92   ///     A QueueSP to the queue requested, if it is present in the QueueList.
93   ///     An empty QueueSP will be returned if this queue was not found.
94   //------------------------------------------------------------------
95   lldb::QueueSP FindQueueByID(lldb::queue_id_t qid);
96
97   //------------------------------------------------------------------
98   /// Find a queue in the QueueList by IndexID
99   ///
100   /// @param [in] index_id
101   ///     Find a queue by IndexID.  This is an integer associated with each
102   ///     unique queue seen during a debug session and will not be reused
103   ///     for a different queue.  Unlike the QueueID, a 64-bit value, this
104   ///     will tend to be an integral value like 1 or 7.
105   ///
106   /// @return
107   ///     A QueueSP to the queue requested, if it is present in the QueueList.
108   ///     An empty QueueSP will be returned if this queue was not found.
109   //------------------------------------------------------------------
110   lldb::QueueSP FindQueueByIndexID(uint32_t index_id);
111
112   std::mutex &GetMutex();
113
114 protected:
115   //------------------------------------------------------------------
116   // Classes that inherit from Process can see and modify these
117   //------------------------------------------------------------------
118   Process *m_process; ///< The process that manages this queue list.
119   uint32_t
120       m_stop_id; ///< The process stop ID that this queue list is valid for.
121   collection m_queues; ///< The queues for this process.
122   std::mutex m_mutex;
123
124 private:
125   QueueList();
126 };
127
128 } // namespace lldb_private
129
130 #endif // liblldb_QueueList_h_