[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / lldb / source / API / SBThreadCollection.cpp
blob3c1cf98650620ea95707eff145d3d347fd775c56
1 //===-- SBThreadCollection.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 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBThreadCollection.h"
10 #include "SBReproducerPrivate.h"
11 #include "lldb/API/SBThread.h"
12 #include "lldb/Target/ThreadList.h"
14 using namespace lldb;
15 using namespace lldb_private;
17 SBThreadCollection::SBThreadCollection() : m_opaque_sp() {
18 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBThreadCollection);
21 SBThreadCollection::SBThreadCollection(const SBThreadCollection &rhs)
22 : m_opaque_sp(rhs.m_opaque_sp) {
23 LLDB_RECORD_CONSTRUCTOR(SBThreadCollection,
24 (const lldb::SBThreadCollection &), rhs);
27 const SBThreadCollection &SBThreadCollection::
28 operator=(const SBThreadCollection &rhs) {
29 LLDB_RECORD_METHOD(
30 const lldb::SBThreadCollection &,
31 SBThreadCollection, operator=,(const lldb::SBThreadCollection &), rhs);
33 if (this != &rhs)
34 m_opaque_sp = rhs.m_opaque_sp;
35 return LLDB_RECORD_RESULT(*this);
38 SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads)
39 : m_opaque_sp(threads) {}
41 SBThreadCollection::~SBThreadCollection() {}
43 void SBThreadCollection::SetOpaque(const lldb::ThreadCollectionSP &threads) {
44 m_opaque_sp = threads;
47 lldb_private::ThreadCollection *SBThreadCollection::get() const {
48 return m_opaque_sp.get();
51 lldb_private::ThreadCollection *SBThreadCollection::operator->() const {
52 return m_opaque_sp.operator->();
55 lldb::ThreadCollectionSP &SBThreadCollection::operator*() {
56 return m_opaque_sp;
59 const lldb::ThreadCollectionSP &SBThreadCollection::operator*() const {
60 return m_opaque_sp;
63 bool SBThreadCollection::IsValid() const {
64 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadCollection, IsValid);
65 return this->operator bool();
67 SBThreadCollection::operator bool() const {
68 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBThreadCollection, operator bool);
70 return m_opaque_sp.get() != nullptr;
73 size_t SBThreadCollection::GetSize() {
74 LLDB_RECORD_METHOD_NO_ARGS(size_t, SBThreadCollection, GetSize);
76 if (m_opaque_sp)
77 return m_opaque_sp->GetSize();
78 return 0;
81 SBThread SBThreadCollection::GetThreadAtIndex(size_t idx) {
82 LLDB_RECORD_METHOD(lldb::SBThread, SBThreadCollection, GetThreadAtIndex,
83 (size_t), idx);
85 SBThread thread;
86 if (m_opaque_sp && idx < m_opaque_sp->GetSize())
87 thread = m_opaque_sp->GetThreadAtIndex(idx);
88 return LLDB_RECORD_RESULT(thread);
91 namespace lldb_private {
92 namespace repro {
94 template <>
95 void RegisterMethods<SBThreadCollection>(Registry &R) {
96 LLDB_REGISTER_CONSTRUCTOR(SBThreadCollection, ());
97 LLDB_REGISTER_CONSTRUCTOR(SBThreadCollection,
98 (const lldb::SBThreadCollection &));
99 LLDB_REGISTER_METHOD(
100 const lldb::SBThreadCollection &,
101 SBThreadCollection, operator=,(const lldb::SBThreadCollection &));
102 LLDB_REGISTER_METHOD_CONST(bool, SBThreadCollection, IsValid, ());
103 LLDB_REGISTER_METHOD_CONST(bool, SBThreadCollection, operator bool, ());
104 LLDB_REGISTER_METHOD(size_t, SBThreadCollection, GetSize, ());
105 LLDB_REGISTER_METHOD(lldb::SBThread, SBThreadCollection, GetThreadAtIndex,
106 (size_t));