LLDB mainline
SBQueueItem.cpp
Go to the documentation of this file.
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//===----------------------------------------------------------------------===//
8
9#include "lldb/lldb-forward.h"
10
11#include "lldb/API/SBAddress.h"
13#include "lldb/API/SBThread.h"
14#include "lldb/Core/Address.h"
15#include "lldb/Target/Process.h"
17#include "lldb/Target/Thread.h"
19
20using namespace lldb;
21using namespace lldb_private;
22
23// Constructors
25
27 : m_queue_item_sp(queue_item_sp) {
28 LLDB_INSTRUMENT_VA(this, queue_item_sp);
29}
30
31// Destructor
33
36 return this->operator bool();
37}
38SBQueueItem::operator bool() const {
40
41 return m_queue_item_sp.get() != nullptr;
42}
43
46
47 m_queue_item_sp.reset();
48}
49
50void SBQueueItem::SetQueueItem(const QueueItemSP &queue_item_sp) {
51 LLDB_INSTRUMENT_VA(this, queue_item_sp);
52
53 m_queue_item_sp = queue_item_sp;
54}
55
58
60 if (m_queue_item_sp) {
61 result = m_queue_item_sp->GetKind();
62 }
63 return result;
64}
65
67 LLDB_INSTRUMENT_VA(this, kind);
68
69 if (m_queue_item_sp) {
70 m_queue_item_sp->SetKind(kind);
71 }
72}
73
76
77 SBAddress result;
78 if (m_queue_item_sp) {
79 result.SetAddress(m_queue_item_sp->GetAddress());
80 }
81 return result;
82}
83
85 LLDB_INSTRUMENT_VA(this, addr);
86
87 if (m_queue_item_sp) {
88 m_queue_item_sp->SetAddress(addr.ref());
89 }
90}
91
93 LLDB_INSTRUMENT_VA(this, type);
94
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);
108 }
109 }
110 }
111 return result;
112}
#define LLDB_INSTRUMENT_VA(...)
lldb_private::Address & ref()
Definition: SBAddress.cpp:173
void SetAddress(lldb::SBSection section, lldb::addr_t offset)
Definition: SBAddress.cpp:88
lldb::QueueItemSP m_queue_item_sp
Definition: SBQueueItem.h:51
SBThread GetExtendedBacktraceThread(const char *type)
Definition: SBQueueItem.cpp:92
lldb::SBAddress GetAddress() const
Definition: SBQueueItem.cpp:74
bool IsValid() const
Definition: SBQueueItem.cpp:34
void SetQueueItem(const lldb::QueueItemSP &queue_item_sp)
Definition: SBQueueItem.cpp:50
void SetKind(lldb::QueueItemKind kind)
Definition: SBQueueItem.cpp:66
void SetAddress(lldb::SBAddress addr)
Definition: SBQueueItem.cpp:84
lldb::QueueItemKind GetKind() const
Definition: SBQueueItem.cpp:56
void SetThread(const lldb::ThreadSP &lldb_object_sp)
Definition: SBThread.cpp:372
A uniqued constant string class.
Definition: ConstString.h:40
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:444
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:385
QueueItemKind
Queue work item types.
@ eQueueItemKindUnknown
std::shared_ptr< lldb_private::QueueItem > QueueItemSP
Definition: lldb-forward.h:396