LLDB mainline
Queue.cpp
Go to the documentation of this file.
1//===-- Queue.cpp ---------------------------------------------------------===//
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#include "lldb/Target/Queue.h"
10#include "lldb/Target/Process.h"
13#include "lldb/Target/Thread.h"
14
15using namespace lldb;
16using namespace lldb_private;
17
19 const char *queue_name)
20 : m_process_wp(), m_queue_id(queue_id), m_queue_name(),
21 m_running_work_items_count(0), m_pending_work_items_count(0),
22 m_pending_items(), m_dispatch_queue_t_addr(LLDB_INVALID_ADDRESS),
23 m_kind(eQueueKindUnknown) {
24 if (queue_name)
25 m_queue_name = queue_name;
26
27 m_process_wp = process_sp;
28}
29
30Queue::~Queue() = default;
31
33
34const char *Queue::GetName() {
35 return (m_queue_name.empty() ? nullptr : m_queue_name.c_str());
36}
37
38uint32_t Queue::GetIndexID() { return m_queue_id; }
39
40std::vector<lldb::ThreadSP> Queue::GetThreads() {
41 std::vector<ThreadSP> result;
42 ProcessSP process_sp = m_process_wp.lock();
43 if (process_sp) {
44 for (ThreadSP thread_sp : process_sp->Threads()) {
45 if (thread_sp->GetQueueID() == m_queue_id) {
46 result.push_back(thread_sp);
47 }
48 }
49 }
50 return result;
51}
52
53void Queue::SetNumRunningWorkItems(uint32_t count) {
55}
56
59}
60
61void Queue::SetNumPendingWorkItems(uint32_t count) {
63}
64
67}
68
69void Queue::SetLibdispatchQueueAddress(addr_t dispatch_queue_t_addr) {
70 m_dispatch_queue_t_addr = dispatch_queue_t_addr;
71}
72
75}
76
77const std::vector<lldb::QueueItemSP> &Queue::GetPendingItems() {
78 if (m_pending_items.empty()) {
79 ProcessSP process_sp = m_process_wp.lock();
80 if (process_sp && process_sp->GetSystemRuntime()) {
81 process_sp->GetSystemRuntime()->PopulatePendingItemsForQueue(this);
82 }
83 }
84 return m_pending_items;
85}
86
88
lldb::queue_id_t GetID()
Get the QueueID for this Queue.
Definition: Queue.cpp:32
void SetNumPendingWorkItems(uint32_t count)
Definition: Queue.cpp:61
uint32_t GetIndexID()
Get the IndexID for this Queue.
Definition: Queue.cpp:38
void SetNumRunningWorkItems(uint32_t count)
Definition: Queue.cpp:53
uint32_t m_running_work_items_count
Definition: Queue.h:140
lldb::QueueKind GetKind()
Return the kind (serial, concurrent) of this queue.
Definition: Queue.cpp:87
lldb::addr_t m_dispatch_queue_t_addr
Definition: Queue.h:143
Queue(lldb::ProcessSP process_sp, lldb::queue_id_t queue_id, const char *queue_name)
Definition: Queue.cpp:18
std::vector< lldb::QueueItemSP > m_pending_items
Definition: Queue.h:142
lldb::ProcessWP m_process_wp
Definition: Queue.h:137
uint32_t m_pending_work_items_count
Definition: Queue.h:141
const std::vector< lldb::QueueItemSP > & GetPendingItems()
Return the items that are currently enqueued.
Definition: Queue.cpp:77
lldb::QueueKind m_kind
Definition: Queue.h:145
void SetKind(lldb::QueueKind kind)
Definition: Queue.cpp:89
uint32_t GetNumRunningWorkItems() const
Get the number of work items that this queue is currently running.
Definition: Queue.cpp:57
lldb::addr_t GetLibdispatchQueueAddress() const
Get the dispatch_queue_t structure address for this Queue.
Definition: Queue.cpp:73
uint32_t GetNumPendingWorkItems() const
Get the number of work items enqueued on this queue.
Definition: Queue.cpp:65
std::string m_queue_name
Definition: Queue.h:139
const char * GetName()
Get the name of this Queue.
Definition: Queue.cpp:34
std::vector< lldb::ThreadSP > GetThreads()
Return the threads currently associated with this queue.
Definition: Queue.cpp:40
lldb::queue_id_t m_queue_id
Definition: Queue.h:138
void SetLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t_addr)
Definition: Queue.cpp:69
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:82
A class that represents a running process on the host machine.
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:450
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:389
QueueKind
Queue type.
uint64_t addr_t
Definition: lldb-types.h:80
uint64_t queue_id_t
Definition: lldb-types.h:90