LLDB  mainline
SBQueueItem.cpp
Go to the documentation of this file.
1 //===-- SBQueueItem.cpp -----------------------------------------*- C++ -*-===//
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 "SBReproducerPrivate.h"
12 #include "lldb/API/SBAddress.h"
13 #include "lldb/API/SBQueueItem.h"
14 #include "lldb/API/SBThread.h"
15 #include "lldb/Core/Address.h"
16 #include "lldb/Target/Process.h"
17 #include "lldb/Target/QueueItem.h"
18 #include "lldb/Target/Thread.h"
19 
20 using namespace lldb;
21 using namespace lldb_private;
22 
23 // Constructors
24 SBQueueItem::SBQueueItem() : m_queue_item_sp() {
26 }
27 
28 SBQueueItem::SBQueueItem(const QueueItemSP &queue_item_sp)
29  : m_queue_item_sp(queue_item_sp) {
30  LLDB_RECORD_CONSTRUCTOR(SBQueueItem, (const lldb::QueueItemSP &),
31  queue_item_sp);
32 }
33 
34 // Destructor
35 SBQueueItem::~SBQueueItem() { m_queue_item_sp.reset(); }
36 
37 bool SBQueueItem::IsValid() const {
39  return this->operator bool();
40 }
41 SBQueueItem::operator bool() const {
42  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueueItem, operator bool);
43 
44  return m_queue_item_sp.get() != NULL;
45 }
46 
49 
50  m_queue_item_sp.reset();
51 }
52 
53 void SBQueueItem::SetQueueItem(const QueueItemSP &queue_item_sp) {
55  (const lldb::QueueItemSP &), queue_item_sp);
56 
57  m_queue_item_sp = queue_item_sp;
58 }
59 
62 
64  if (m_queue_item_sp) {
65  result = m_queue_item_sp->GetKind();
66  }
67  return result;
68 }
69 
72 
73  if (m_queue_item_sp) {
74  m_queue_item_sp->SetKind(kind);
75  }
76 }
77 
80 
81  SBAddress result;
82  if (m_queue_item_sp) {
83  result.SetAddress(&m_queue_item_sp->GetAddress());
84  }
85  return LLDB_RECORD_RESULT(result);
86 }
87 
90 
91  if (m_queue_item_sp) {
92  m_queue_item_sp->SetAddress(addr.ref());
93  }
94 }
95 
98  (const char *), type);
99 
100  SBThread result;
101  if (m_queue_item_sp) {
102  ProcessSP process_sp = m_queue_item_sp->GetProcessSP();
103  Process::StopLocker stop_locker;
104  if (process_sp && stop_locker.TryLock(&process_sp->GetRunLock())) {
105  ThreadSP thread_sp;
106  ConstString type_const(type);
107  thread_sp = m_queue_item_sp->GetExtendedBacktraceThread(type_const);
108  if (thread_sp) {
109  // Save this in the Process' ExtendedThreadList so a strong pointer
110  // retains the object
111  process_sp->GetExtendedThreadList().AddThread(thread_sp);
112  result.SetThread(thread_sp);
113  }
114  }
115  }
116  return LLDB_RECORD_RESULT(result);
117 }
118 
119 namespace lldb_private {
120 namespace repro {
121 
122 template <>
125  LLDB_REGISTER_CONSTRUCTOR(SBQueueItem, (const lldb::QueueItemSP &));
127  LLDB_REGISTER_METHOD_CONST(bool, SBQueueItem, operator bool, ());
130  (const lldb::QueueItemSP &));
136  GetExtendedBacktraceThread, (const char *));
137 }
138 
139 }
140 }
lldb::SBAddress GetAddress() const
Definition: SBQueueItem.cpp:78
The registry contains a unique mapping between functions and their ID.
void SetKind(lldb::QueueItemKind kind)
Definition: SBQueueItem.cpp:70
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
SBThread GetExtendedBacktraceThread(const char *type)
Definition: SBQueueItem.cpp:96
void SetAddress(lldb::SBSection section, lldb::addr_t offset)
Definition: SBAddress.cpp:95
void RegisterMethods< SBQueueItem >(Registry &R)
void SetQueueItem(const lldb::QueueItemSP &queue_item_sp)
Definition: SBQueueItem.cpp:53
lldb::QueueItemKind GetKind() const
Definition: SBQueueItem.cpp:60
bool IsValid() const
Definition: SBQueueItem.cpp:37
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
lldb_private::Address & ref()
Definition: SBAddress.cpp:188
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
void SetAddress(lldb::SBAddress addr)
Definition: SBQueueItem.cpp:88
A uniqued constant string class.
Definition: ConstString.h:38
Definition: SBAddress.h:15
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
#define LLDB_RECORD_RESULT(Result)
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)