[lldb][dwarf] Compute fully qualified names on simplified template names with DWARFT...
[llvm-project.git] / lldb / source / API / SBQueueItem.cpp
blobb2204452c0fac5f7102c2db5347f0efb0fefc235
1 //===-- SBQueueItem.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 //===----------------------------------------------------------------------===//
9 #include "lldb/lldb-forward.h"
11 #include "lldb/API/SBAddress.h"
12 #include "lldb/API/SBQueueItem.h"
13 #include "lldb/API/SBThread.h"
14 #include "lldb/Core/Address.h"
15 #include "lldb/Target/Process.h"
16 #include "lldb/Target/QueueItem.h"
17 #include "lldb/Target/Thread.h"
18 #include "lldb/Utility/Instrumentation.h"
20 using namespace lldb;
21 using namespace lldb_private;
23 // Constructors
24 SBQueueItem::SBQueueItem() { LLDB_INSTRUMENT_VA(this); }
26 SBQueueItem::SBQueueItem(const QueueItemSP &queue_item_sp)
27 : m_queue_item_sp(queue_item_sp) {
28 LLDB_INSTRUMENT_VA(this, queue_item_sp);
31 // Destructor
32 SBQueueItem::~SBQueueItem() { m_queue_item_sp.reset(); }
34 bool SBQueueItem::IsValid() const {
35 LLDB_INSTRUMENT_VA(this);
36 return this->operator bool();
38 SBQueueItem::operator bool() const {
39 LLDB_INSTRUMENT_VA(this);
41 return m_queue_item_sp.get() != nullptr;
44 void SBQueueItem::Clear() {
45 LLDB_INSTRUMENT_VA(this);
47 m_queue_item_sp.reset();
50 void SBQueueItem::SetQueueItem(const QueueItemSP &queue_item_sp) {
51 LLDB_INSTRUMENT_VA(this, queue_item_sp);
53 m_queue_item_sp = queue_item_sp;
56 lldb::QueueItemKind SBQueueItem::GetKind() const {
57 LLDB_INSTRUMENT_VA(this);
59 QueueItemKind result = eQueueItemKindUnknown;
60 if (m_queue_item_sp) {
61 result = m_queue_item_sp->GetKind();
63 return result;
66 void SBQueueItem::SetKind(lldb::QueueItemKind kind) {
67 LLDB_INSTRUMENT_VA(this, kind);
69 if (m_queue_item_sp) {
70 m_queue_item_sp->SetKind(kind);
74 SBAddress SBQueueItem::GetAddress() const {
75 LLDB_INSTRUMENT_VA(this);
77 SBAddress result;
78 if (m_queue_item_sp) {
79 result.SetAddress(m_queue_item_sp->GetAddress());
81 return result;
84 void SBQueueItem::SetAddress(SBAddress addr) {
85 LLDB_INSTRUMENT_VA(this, addr);
87 if (m_queue_item_sp) {
88 m_queue_item_sp->SetAddress(addr.ref());
92 SBThread SBQueueItem::GetExtendedBacktraceThread(const char *type) {
93 LLDB_INSTRUMENT_VA(this, type);
95 SBThread result;
96 if (m_queue_item_sp) {
97 ProcessSP process_sp = m_queue_item_sp->GetProcessSP();
98 Process::StopLocker stop_locker;
99 if (process_sp && stop_locker.TryLock(&process_sp->GetRunLock())) {
100 ThreadSP thread_sp;
101 ConstString type_const(type);
102 thread_sp = m_queue_item_sp->GetExtendedBacktraceThread(type_const);
103 if (thread_sp) {
104 // Save this in the Process' ExtendedThreadList so a strong pointer
105 // retains the object
106 process_sp->GetExtendedThreadList().AddThread(thread_sp);
107 result.SetThread(thread_sp);
111 return result;