1 //===-- SBThreadCollection.cpp --------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBThreadCollection.h"
10 #include "lldb/API/SBThread.h"
11 #include "lldb/Target/ThreadList.h"
12 #include "lldb/Utility/Instrumentation.h"
15 using namespace lldb_private
;
17 SBThreadCollection::SBThreadCollection() { LLDB_INSTRUMENT_VA(this); }
19 SBThreadCollection::SBThreadCollection(const SBThreadCollection
&rhs
)
20 : m_opaque_sp(rhs
.m_opaque_sp
) {
21 LLDB_INSTRUMENT_VA(this, rhs
);
24 const SBThreadCollection
&SBThreadCollection::
25 operator=(const SBThreadCollection
&rhs
) {
26 LLDB_INSTRUMENT_VA(this, rhs
);
29 m_opaque_sp
= rhs
.m_opaque_sp
;
33 SBThreadCollection::SBThreadCollection(const ThreadCollectionSP
&threads
)
34 : m_opaque_sp(threads
) {}
36 SBThreadCollection::~SBThreadCollection() = default;
38 void SBThreadCollection::SetOpaque(const lldb::ThreadCollectionSP
&threads
) {
39 m_opaque_sp
= threads
;
42 lldb_private::ThreadCollection
*SBThreadCollection::get() const {
43 return m_opaque_sp
.get();
46 lldb_private::ThreadCollection
*SBThreadCollection::operator->() const {
47 return m_opaque_sp
.operator->();
50 lldb::ThreadCollectionSP
&SBThreadCollection::operator*() {
54 const lldb::ThreadCollectionSP
&SBThreadCollection::operator*() const {
58 bool SBThreadCollection::IsValid() const {
59 LLDB_INSTRUMENT_VA(this);
60 return this->operator bool();
62 SBThreadCollection::operator bool() const {
63 LLDB_INSTRUMENT_VA(this);
65 return m_opaque_sp
.get() != nullptr;
68 size_t SBThreadCollection::GetSize() {
69 LLDB_INSTRUMENT_VA(this);
72 return m_opaque_sp
->GetSize();
76 SBThread
SBThreadCollection::GetThreadAtIndex(size_t idx
) {
77 LLDB_INSTRUMENT_VA(this, idx
);
80 if (m_opaque_sp
&& idx
< m_opaque_sp
->GetSize())
81 thread
= m_opaque_sp
->GetThreadAtIndex(idx
);