1 //===-- QueueItem.cpp -----------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Target/Queue.h"
10 #include "lldb/Target/Process.h"
11 #include "lldb/Target/QueueItem.h"
12 #include "lldb/Target/SystemRuntime.h"
15 using namespace lldb_private
;
17 QueueItem::QueueItem(QueueSP queue_sp
, ProcessSP process_sp
,
18 lldb::addr_t item_ref
, lldb_private::Address address
)
19 : m_queue_wp(), m_process_wp(), m_item_ref(item_ref
), m_address(address
),
20 m_have_fetched_entire_item(false), m_kind(eQueueItemKindUnknown
),
21 m_item_that_enqueued_this_ref(LLDB_INVALID_ADDRESS
),
22 m_enqueueing_thread_id(LLDB_INVALID_THREAD_ID
),
23 m_enqueueing_queue_id(LLDB_INVALID_QUEUE_ID
),
24 m_target_queue_id(LLDB_INVALID_QUEUE_ID
), m_stop_id(0), m_backtrace(),
25 m_thread_label(), m_queue_label(), m_target_queue_label() {
26 m_queue_wp
= queue_sp
;
27 m_process_wp
= process_sp
;
30 QueueItem::~QueueItem() = default;
32 QueueItemKind
QueueItem::GetKind() {
37 void QueueItem::SetKind(QueueItemKind item_kind
) { m_kind
= item_kind
; }
39 Address
&QueueItem::GetAddress() { return m_address
; }
41 void QueueItem::SetAddress(Address addr
) { m_address
= addr
; }
43 ThreadSP
QueueItem::GetExtendedBacktraceThread(ConstString type
) {
45 ThreadSP return_thread
;
46 QueueSP queue_sp
= m_queue_wp
.lock();
48 ProcessSP process_sp
= queue_sp
->GetProcess();
49 if (process_sp
&& process_sp
->GetSystemRuntime()) {
51 process_sp
->GetSystemRuntime()->GetExtendedBacktraceForQueueItem(
52 this->shared_from_this(), type
);
58 lldb::addr_t
QueueItem::GetItemThatEnqueuedThis() {
60 return m_item_that_enqueued_this_ref
;
63 lldb::tid_t
QueueItem::GetEnqueueingThreadID() {
65 return m_enqueueing_thread_id
;
68 lldb::queue_id_t
QueueItem::GetEnqueueingQueueID() {
70 return m_enqueueing_queue_id
;
73 uint32_t QueueItem::GetStopID() {
78 std::vector
<lldb::addr_t
> &QueueItem::GetEnqueueingBacktrace() {
83 std::string
QueueItem::GetThreadLabel() {
85 return m_thread_label
;
88 std::string
QueueItem::GetQueueLabel() {
93 ProcessSP
QueueItem::GetProcessSP() { return m_process_wp
.lock(); }
95 void QueueItem::FetchEntireItem() {
96 if (m_have_fetched_entire_item
)
98 ProcessSP process_sp
= m_process_wp
.lock();
100 SystemRuntime
*runtime
= process_sp
->GetSystemRuntime();
102 runtime
->CompleteQueueItem(this, m_item_ref
);
103 m_have_fetched_entire_item
= true;