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"
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"
19 
20 using namespace lldb;
21 using namespace lldb_private;
22 
23 // Constructors
25 
26 SBQueueItem::SBQueueItem(const QueueItemSP &queue_item_sp)
27  : m_queue_item_sp(queue_item_sp) {
28  LLDB_INSTRUMENT_VA(this, queue_item_sp);
29 }
30 
31 // Destructor
33 
34 bool SBQueueItem::IsValid() const {
35  LLDB_INSTRUMENT_VA(this);
36  return this->operator bool();
37 }
38 SBQueueItem::operator bool() const {
39  LLDB_INSTRUMENT_VA(this);
40 
41  return m_queue_item_sp.get() != nullptr;
42 }
43 
45  LLDB_INSTRUMENT_VA(this);
46 
47  m_queue_item_sp.reset();
48 }
49 
50 void 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 
57  LLDB_INSTRUMENT_VA(this);
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 
75  LLDB_INSTRUMENT_VA(this);
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 }
Instrumentation.h
lldb::SBThread
Definition: SBThread.h:20
lldb::SBThread::SetThread
void SetThread(const lldb::ThreadSP &lldb_object_sp)
Definition: SBThread.cpp:372
lldb::SBQueueItem::SBQueueItem
SBQueueItem()
Definition: SBQueueItem.cpp:24
lldb_private::ProcessRunLock::ProcessRunLocker
Definition: ProcessRunLock.h:36
lldb::SBAddress::SetAddress
void SetAddress(lldb::SBSection section, lldb::addr_t offset)
Definition: SBAddress.cpp:88
Process.h
lldb::SBQueueItem::SetKind
void SetKind(lldb::QueueItemKind kind)
Definition: SBQueueItem.cpp:66
SBThread.h
lldb_private::ProcessRunLock::ProcessRunLocker::TryLock
bool TryLock(ProcessRunLock *lock)
Definition: ProcessRunLock.h:43
lldb::SBQueueItem::~SBQueueItem
~SBQueueItem()
Definition: SBQueueItem.cpp:32
lldb_private::ConstString
Definition: ConstString.h:40
lldb::SBQueueItem::GetAddress
lldb::SBAddress GetAddress() const
Definition: SBQueueItem.cpp:74
lldb::SBQueueItem::GetExtendedBacktraceThread
SBThread GetExtendedBacktraceThread(const char *type)
Definition: SBQueueItem.cpp:92
lldb::SBQueueItem::SetQueueItem
void SetQueueItem(const lldb::QueueItemSP &queue_item_sp)
Definition: SBQueueItem.cpp:50
Thread.h
Address.h
SBAddress.h
lldb::SBQueueItem::IsValid
bool IsValid() const
Definition: SBQueueItem.cpp:34
lldb-forward.h
lldb::SBAddress
Definition: SBAddress.h:17
lldb::SBAddress::ref
lldb_private::Address & ref()
Definition: SBAddress.cpp:173
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
QueueItem.h
lldb::SBQueueItem::SetAddress
void SetAddress(lldb::SBAddress addr)
Definition: SBQueueItem.cpp:84
LLDB_INSTRUMENT_VA
#define LLDB_INSTRUMENT_VA(...)
Definition: Instrumentation.h:98
lldb::QueueItemKind
QueueItemKind
Queue work item types.
Definition: lldb-enumerations.h:942
lldb::eQueueItemKindUnknown
@ eQueueItemKindUnknown
Definition: lldb-enumerations.h:943
SBQueueItem.h
lldb::SBQueueItem::GetKind
lldb::QueueItemKind GetKind() const
Definition: SBQueueItem.cpp:56
lldb::SBQueueItem::Clear
void Clear()
Definition: SBQueueItem.cpp:44
lldb::SBQueueItem::m_queue_item_sp
lldb::QueueItemSP m_queue_item_sp
Definition: SBQueueItem.h:44
lldb
Definition: SBAddress.h:15