LLDB  mainline
QueueItem.cpp
Go to the documentation of this file.
1 //===-- QueueItem.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"
11 #include "lldb/Target/QueueItem.h"
13 
14 using namespace lldb;
15 using namespace lldb_private;
16 
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;
28 }
29 
30 QueueItem::~QueueItem() = default;
31 
34  return m_kind;
35 }
36 
37 void QueueItem::SetKind(QueueItemKind item_kind) { m_kind = item_kind; }
38 
40 
41 void QueueItem::SetAddress(Address addr) { m_address = addr; }
42 
45  ThreadSP return_thread;
46  QueueSP queue_sp = m_queue_wp.lock();
47  if (queue_sp) {
48  ProcessSP process_sp = queue_sp->GetProcess();
49  if (process_sp && process_sp->GetSystemRuntime()) {
50  return_thread =
51  process_sp->GetSystemRuntime()->GetExtendedBacktraceForQueueItem(
52  this->shared_from_this(), type);
53  }
54  }
55  return return_thread;
56 }
57 
61 }
62 
66 }
67 
70  return m_enqueueing_queue_id;
71 }
72 
75  return m_stop_id;
76 }
77 
78 std::vector<lldb::addr_t> &QueueItem::GetEnqueueingBacktrace() {
80  return m_backtrace;
81 }
82 
85  return m_thread_label;
86 }
87 
90  return m_queue_label;
91 }
92 
93 ProcessSP QueueItem::GetProcessSP() { return m_process_wp.lock(); }
94 
97  return;
98  ProcessSP process_sp = m_process_wp.lock();
99  if (process_sp) {
100  SystemRuntime *runtime = process_sp->GetSystemRuntime();
101  if (runtime) {
102  runtime->CompleteQueueItem(this, m_item_ref);
104  }
105  }
106 }
lldb_private::QueueItem::GetItemThatEnqueuedThis
lldb::addr_t GetItemThatEnqueuedThis()
Definition: QueueItem.cpp:58
lldb_private::QueueItem::m_enqueueing_queue_id
lldb::queue_id_t m_enqueueing_queue_id
Definition: QueueItem.h:153
lldb_private::SystemRuntime
Definition: SystemRuntime.h:43
lldb_private::QueueItem::GetEnqueueingBacktrace
std::vector< lldb::addr_t > & GetEnqueueingBacktrace()
Definition: QueueItem.cpp:78
lldb_private::QueueItem::~QueueItem
~QueueItem()
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::QueueItem::m_item_ref
lldb::addr_t m_item_ref
Definition: QueueItem.h:142
Process.h
lldb_private::QueueItem::GetKind
lldb::QueueItemKind GetKind()
Get the kind of work item this is.
Definition: QueueItem.cpp:32
lldb::queue_id_t
uint64_t queue_id_t
Definition: lldb-types.h:91
lldb_private::QueueItem::m_item_that_enqueued_this_ref
lldb::addr_t m_item_that_enqueued_this_ref
Definition: QueueItem.h:148
lldb_private::QueueItem::GetProcessSP
lldb::ProcessSP GetProcessSP()
Definition: QueueItem.cpp:93
lldb_private::QueueItem::GetEnqueueingQueueID
lldb::queue_id_t GetEnqueueingQueueID()
Definition: QueueItem.cpp:68
lldb_private::SystemRuntime::CompleteQueueItem
virtual void CompleteQueueItem(lldb_private::QueueItem *queue_item, lldb::addr_t item_ref)
Complete the fields in a QueueItem.
Definition: SystemRuntime.h:266
lldb_private::QueueItem::m_stop_id
uint32_t m_stop_id
Definition: QueueItem.h:155
lldb_private::QueueItem::m_kind
lldb::QueueItemKind m_kind
Definition: QueueItem.h:147
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::QueueItem::GetExtendedBacktraceThread
lldb::ThreadSP GetExtendedBacktraceThread(ConstString type)
Get an extended backtrace thread for this queue item, if available.
Definition: QueueItem.cpp:43
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::QueueItem::m_address
lldb_private::Address m_address
Definition: QueueItem.h:144
lldb_private::QueueItem::GetQueueLabel
std::string GetQueueLabel()
Definition: QueueItem.cpp:88
LLDB_INVALID_QUEUE_ID
#define LLDB_INVALID_QUEUE_ID
Definition: lldb-defines.h:100
lldb_private::QueueItem::m_process_wp
lldb::ProcessWP m_process_wp
Definition: QueueItem.h:140
lldb_private::QueueItem::GetAddress
lldb_private::Address & GetAddress()
Get the code address that will be executed when this work item is executed.
Definition: QueueItem.cpp:39
Queue.h
lldb_private::Queue::m_process_wp
lldb::ProcessWP m_process_wp
Definition: Queue.h:137
lldb_private::QueueItem::SetAddress
void SetAddress(lldb_private::Address addr)
Set the work item address for this object.
Definition: QueueItem.cpp:41
lldb_private::QueueItem::m_queue_wp
lldb::QueueWP m_queue_wp
Definition: QueueItem.h:139
lldb_private::QueueItem::GetStopID
uint32_t GetStopID()
Definition: QueueItem.cpp:73
lldb_private::QueueItem::SetKind
void SetKind(lldb::QueueItemKind item_kind)
Set the type of work item this is.
Definition: QueueItem.cpp:37
lldb_private::QueueItem::m_backtrace
std::vector< lldb::addr_t > m_backtrace
Definition: QueueItem.h:156
uint32_t
lldb_private::QueueItem::FetchEntireItem
void FetchEntireItem()
Definition: QueueItem.cpp:95
lldb_private::QueueItem::m_thread_label
std::string m_thread_label
Definition: QueueItem.h:157
lldb_private::Address
Definition: Address.h:59
lldb_private::QueueItem::GetEnqueueingThreadID
lldb::tid_t GetEnqueueingThreadID()
Definition: QueueItem.cpp:63
lldb_private::QueueItem::m_enqueueing_thread_id
lldb::tid_t m_enqueueing_thread_id
Definition: QueueItem.h:151
SystemRuntime.h
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
lldb_private::QueueItem::m_queue_label
std::string m_queue_label
Definition: QueueItem.h:158
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
QueueItem.h
lldb::QueueItemKind
QueueItemKind
Queue work item types.
Definition: lldb-enumerations.h:933
lldb_private::QueueItem::m_have_fetched_entire_item
bool m_have_fetched_entire_item
Definition: QueueItem.h:145
lldb::eQueueItemKindUnknown
@ eQueueItemKindUnknown
Definition: lldb-enumerations.h:934
LLDB_INVALID_THREAD_ID
#define LLDB_INVALID_THREAD_ID
Definition: lldb-defines.h:94
lldb_private::QueueItem::GetThreadLabel
std::string GetThreadLabel()
Definition: QueueItem.cpp:83
lldb
Definition: SBAddress.h:15
lldb::tid_t
uint64_t tid_t
Definition: lldb-types.h:86