]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/Target/Queue.cpp
Update libc++ to release_39 branch r279689.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / Target / Queue.cpp
1 //===-- Queue.cpp -----------------------------------------------*- 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 // C Includes
11 // C++ Includes
12 // Other libraries and framework includes
13 // Project includes
14 #include "lldb/Target/Process.h"
15 #include "lldb/Target/Queue.h"
16 #include "lldb/Target/QueueList.h"
17 #include "lldb/Target/Thread.h"
18 #include "lldb/Target/SystemRuntime.h"
19
20 using namespace lldb;
21 using namespace lldb_private;
22
23 Queue::Queue (ProcessSP process_sp, lldb::queue_id_t queue_id, const char *queue_name) :
24     m_process_wp (),
25     m_queue_id (queue_id),
26     m_queue_name (),
27     m_running_work_items_count(0),
28     m_pending_work_items_count(0),
29     m_pending_items(),
30     m_dispatch_queue_t_addr(LLDB_INVALID_ADDRESS),
31     m_kind (eQueueKindUnknown)
32 {
33     if (queue_name)
34         m_queue_name = queue_name;
35
36     m_process_wp = process_sp;
37 }
38
39 Queue::~Queue() = default;
40
41 queue_id_t
42 Queue::GetID ()
43 {
44     return m_queue_id;
45 }
46
47 const char *
48 Queue::GetName ()
49 {
50     return (m_queue_name.empty() ? nullptr : m_queue_name.c_str());
51 }
52
53 uint32_t
54 Queue::GetIndexID ()
55 {
56     return m_queue_id;
57 }
58
59 std::vector<lldb::ThreadSP>
60 Queue::GetThreads ()
61 {
62     std::vector<ThreadSP> result;
63     ProcessSP process_sp = m_process_wp.lock();
64     if (process_sp)
65     {
66         for (ThreadSP thread_sp : process_sp->Threads())
67         {
68             if (thread_sp->GetQueueID() == m_queue_id)
69             {
70                 result.push_back (thread_sp);
71             }
72         }
73     }
74     return result;
75 }
76
77 void
78 Queue::SetNumRunningWorkItems (uint32_t count)
79 {
80     m_running_work_items_count = count;
81 }
82
83 uint32_t
84 Queue::GetNumRunningWorkItems () const
85 {
86     return m_running_work_items_count;
87 }
88
89 void
90 Queue::SetNumPendingWorkItems (uint32_t count)
91 {
92     m_pending_work_items_count = count;
93 }
94
95 uint32_t
96 Queue::GetNumPendingWorkItems () const
97 {
98     return m_pending_work_items_count;
99 }
100
101 void
102 Queue::SetLibdispatchQueueAddress (addr_t dispatch_queue_t_addr)
103 {
104     m_dispatch_queue_t_addr = dispatch_queue_t_addr;
105 }
106
107 addr_t
108 Queue::GetLibdispatchQueueAddress () const
109 {
110     return m_dispatch_queue_t_addr;
111 }
112
113 const std::vector<lldb::QueueItemSP> &
114 Queue::GetPendingItems ()
115 {
116     if (m_pending_items.empty())
117     {
118         ProcessSP process_sp = m_process_wp.lock();
119         if (process_sp && process_sp->GetSystemRuntime())
120         {
121             process_sp->GetSystemRuntime()->PopulatePendingItemsForQueue (this);
122         }
123     }
124     return m_pending_items;
125 }
126
127 lldb::QueueKind
128 Queue::GetKind ()
129 {
130     return m_kind;
131 }
132
133 void
134 Queue::SetKind (lldb::QueueKind kind)
135 {
136     m_kind = kind;
137 }