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
35
37 LLDB_INSTRUMENT_VA(this, rhs);
38
39 if (this != &rhs)
41 return *this;
42}
43
44// Destructor
46
49 return this->operator bool();
50}
51SBQueueItem::operator bool() const {
53
54 return m_queue_item_sp.get() != nullptr;
55}
56
59
60 m_queue_item_sp.reset();
61}
62
63void SBQueueItem::SetQueueItem(const QueueItemSP &queue_item_sp) {
64 LLDB_INSTRUMENT_VA(this, queue_item_sp);
65
66 m_queue_item_sp = queue_item_sp;
67}
68
71
73 if (m_queue_item_sp) {
74 result = m_queue_item_sp->GetKind();
75 }
76 return result;
77}
78
80 LLDB_INSTRUMENT_VA(this, kind);
81
82 if (m_queue_item_sp) {
83 m_queue_item_sp->SetKind(kind);
84 }
85}
86
89
90 SBAddress result;
91 if (m_queue_item_sp) {
92 result.SetAddress(m_queue_item_sp->GetAddress());
93 }
94 return result;
95}
96
98 LLDB_INSTRUMENT_VA(this, addr);
99
100 if (m_queue_item_sp) {
101 m_queue_item_sp->SetAddress(addr.ref());
102 }
103}
104
106 LLDB_INSTRUMENT_VA(this, type);
107
108 SBThread result;
109 if (m_queue_item_sp) {
110 ProcessSP process_sp = m_queue_item_sp->GetProcessSP();
111 Process::StopLocker stop_locker;
112 if (process_sp && stop_locker.TryLock(&process_sp->GetRunLock())) {
113 ThreadSP thread_sp;
114 ConstString type_const(type);
115 thread_sp = m_queue_item_sp->GetExtendedBacktraceThread(type_const);
116 if (thread_sp) {
117 // Save this in the Process' ExtendedThreadList so a strong pointer
118 // retains the object
119 process_sp->GetExtendedThreadList().AddThread(thread_sp);
120 result.SetThread(thread_sp);
121 }
122 }
123 }
124 return result;
125}
#define LLDB_INSTRUMENT_VA(...)
lldb_private::Address & ref()
void SetAddress(lldb::SBSection section, lldb::addr_t offset)
Definition SBAddress.cpp:90
lldb::QueueItemSP m_queue_item_sp
Definition SBQueueItem.h:55
SBThread GetExtendedBacktraceThread(const char *type)
lldb::SBQueueItem & operator=(const lldb::SBQueueItem &rhs)
lldb::SBAddress GetAddress() const
bool IsValid() const
void SetQueueItem(const lldb::QueueItemSP &queue_item_sp)
void SetKind(lldb::QueueItemKind kind)
void SetAddress(lldb::SBAddress addr)
lldb::QueueItemKind GetKind() const
void SetThread(const lldb::ThreadSP &lldb_object_sp)
Definition SBThread.cpp:332
A uniqued constant string class.
Definition ConstString.h:40
bool TryLock(ProcessRunLock *lock)
Try to acquire the read lock.
ProcessRunLock::ProcessRunLocker StopLocker
Definition Process.h:411
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::Process > ProcessSP
QueueItemKind
Queue work item types.
@ eQueueItemKindUnknown
std::shared_ptr< lldb_private::QueueItem > QueueItemSP