1 //===-- SBThreadCollection.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/API/SBThreadCollection.h" 10 #include "lldb/API/SBThread.h" 11 #include "lldb/Target/ThreadList.h" 12 #include "lldb/Utility/Instrumentation.h" 13 14 using namespace lldb; 15 using namespace lldb_private; 16 SBThreadCollection()17SBThreadCollection::SBThreadCollection() { LLDB_INSTRUMENT_VA(this); } 18 SBThreadCollection(const SBThreadCollection & rhs)19SBThreadCollection::SBThreadCollection(const SBThreadCollection &rhs) 20 : m_opaque_sp(rhs.m_opaque_sp) { 21 LLDB_INSTRUMENT_VA(this, rhs); 22 } 23 24 const SBThreadCollection &SBThreadCollection:: operator =(const SBThreadCollection & rhs)25operator=(const SBThreadCollection &rhs) { 26 LLDB_INSTRUMENT_VA(this, rhs); 27 28 if (this != &rhs) 29 m_opaque_sp = rhs.m_opaque_sp; 30 return *this; 31 } 32 SBThreadCollection(const ThreadCollectionSP & threads)33SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads) 34 : m_opaque_sp(threads) {} 35 36 SBThreadCollection::~SBThreadCollection() = default; 37 SetOpaque(const lldb::ThreadCollectionSP & threads)38void SBThreadCollection::SetOpaque(const lldb::ThreadCollectionSP &threads) { 39 m_opaque_sp = threads; 40 } 41 get() const42lldb_private::ThreadCollection *SBThreadCollection::get() const { 43 return m_opaque_sp.get(); 44 } 45 operator ->() const46lldb_private::ThreadCollection *SBThreadCollection::operator->() const { 47 return m_opaque_sp.operator->(); 48 } 49 operator *()50lldb::ThreadCollectionSP &SBThreadCollection::operator*() { 51 return m_opaque_sp; 52 } 53 operator *() const54const lldb::ThreadCollectionSP &SBThreadCollection::operator*() const { 55 return m_opaque_sp; 56 } 57 IsValid() const58bool SBThreadCollection::IsValid() const { 59 LLDB_INSTRUMENT_VA(this); 60 return this->operator bool(); 61 } operator bool() const62SBThreadCollection::operator bool() const { 63 LLDB_INSTRUMENT_VA(this); 64 65 return m_opaque_sp.get() != nullptr; 66 } 67 GetSize()68size_t SBThreadCollection::GetSize() { 69 LLDB_INSTRUMENT_VA(this); 70 71 if (m_opaque_sp) 72 return m_opaque_sp->GetSize(); 73 return 0; 74 } 75 GetThreadAtIndex(size_t idx)76SBThread SBThreadCollection::GetThreadAtIndex(size_t idx) { 77 LLDB_INSTRUMENT_VA(this, idx); 78 79 SBThread thread; 80 if (m_opaque_sp && idx < m_opaque_sp->GetSize()) 81 thread = m_opaque_sp->GetThreadAtIndex(idx); 82 return thread; 83 } 84