LLDB mainline
QueueList.h
Go to the documentation of this file.
1//===-- QueueList.h --------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_TARGET_QUEUELIST_H
10#define LLDB_TARGET_QUEUELIST_H
11
12#include <mutex>
13#include <vector>
14
16#include "lldb/Utility/UserID.h"
17#include "lldb/lldb-private.h"
18
19namespace lldb_private {
20
21// QueueList:
22// This is the container for libdispatch aka Grand Central Dispatch Queue
23// objects.
24//
25// Each Process will have a QueueList. When the process execution is paused,
26// the QueueList may be populated with Queues by the SystemRuntime.
27
28class QueueList {
29 friend class Process;
30
31public:
32 QueueList(Process *process);
33
34 ~QueueList();
35
36 /// Get the number of libdispatch queues that are available
37 ///
38 /// \return
39 /// The number of queues that are stored in the QueueList.
40 uint32_t GetSize();
41
42 /// Get the Queue at a given index number
43 ///
44 /// \param [in] idx
45 /// The index number (0-based) of the queue.
46 /// \return
47 /// The Queue at that index number.
48 lldb::QueueSP GetQueueAtIndex(uint32_t idx);
49
50 typedef std::vector<lldb::QueueSP> collection;
52
53 /// Iterate over the list of queues
54 ///
55 /// \return
56 /// An Iterable object which can be used to loop over the queues
57 /// that exist.
59
60 /// Clear out the list of queues from the QueueList
61 void Clear();
62
63 /// Add a Queue to the QueueList
64 ///
65 /// \param [in] queue
66 /// Used by the SystemRuntime to populate the QueueList
67 void AddQueue(lldb::QueueSP queue);
68
69 /// Find a queue in the QueueList by QueueID
70 ///
71 /// \param [in] qid
72 /// The QueueID (same as returned by Thread::GetQueueID()) to find.
73 ///
74 /// \return
75 /// A QueueSP to the queue requested, if it is present in the QueueList.
76 /// An empty QueueSP will be returned if this queue was not found.
78
79 /// Find a queue in the QueueList by IndexID
80 ///
81 /// \param [in] index_id
82 /// Find a queue by IndexID. This is an integer associated with each
83 /// unique queue seen during a debug session and will not be reused
84 /// for a different queue. Unlike the QueueID, a 64-bit value, this
85 /// will tend to be an integral value like 1 or 7.
86 ///
87 /// \return
88 /// A QueueSP to the queue requested, if it is present in the QueueList.
89 /// An empty QueueSP will be returned if this queue was not found.
90 lldb::QueueSP FindQueueByIndexID(uint32_t index_id);
91
92 std::mutex &GetMutex();
93
94protected:
95 // Classes that inherit from Process can see and modify these
96 Process *m_process; ///< The process that manages this queue list.
97 uint32_t
98 m_stop_id; ///< The process stop ID that this queue list is valid for.
99 collection m_queues; ///< The queues for this process.
100 std::mutex m_mutex;
101
102private:
103 QueueList() = delete;
104};
105
106} // namespace lldb_private
107
108#endif // LLDB_TARGET_QUEUELIST_H
LockingAdaptedIterable< std::mutex, collection > QueueIterable
Definition QueueList.h:51
std::vector< lldb::QueueSP > collection
Definition QueueList.h:50
Process * m_process
The process that manages this queue list.
Definition QueueList.h:96
QueueIterable Queues()
Iterate over the list of queues.
Definition QueueList.h:58
uint32_t GetSize()
Get the number of libdispatch queues that are available.
Definition QueueList.cpp:21
lldb::QueueSP GetQueueAtIndex(uint32_t idx)
Get the Queue at a given index number.
Definition QueueList.cpp:26
lldb::QueueSP FindQueueByID(lldb::queue_id_t qid)
Find a queue in the QueueList by QueueID.
Definition QueueList.cpp:47
friend class Process
Definition QueueList.h:29
void AddQueue(lldb::QueueSP queue)
Add a Queue to the QueueList.
Definition QueueList.cpp:40
QueueList(Process *process)
Definition QueueList.cpp:16
lldb::QueueSP FindQueueByIndexID(uint32_t index_id)
Find a queue in the QueueList by IndexID.
Definition QueueList.cpp:58
uint32_t m_stop_id
The process stop ID that this queue list is valid for.
Definition QueueList.h:98
std::mutex & GetMutex()
Definition QueueList.cpp:69
void Clear()
Clear out the list of queues from the QueueList.
Definition QueueList.cpp:35
collection m_queues
The queues for this process.
Definition QueueList.h:99
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Queue > QueueSP
uint64_t queue_id_t
Definition lldb-types.h:90