1cfca06d7SDimitry Andric //===-- SBThreadCollection.cpp --------------------------------------------===// 2205afe67SEd Maste // 35f29bb8aSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 45f29bb8aSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 55f29bb8aSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6205afe67SEd Maste // 7205afe67SEd Maste //===----------------------------------------------------------------------===// 8205afe67SEd Maste 9205afe67SEd Maste #include "lldb/API/SBThreadCollection.h" 10205afe67SEd Maste #include "lldb/API/SBThread.h" 11205afe67SEd Maste #include "lldb/Target/ThreadList.h" 126f8fc217SDimitry Andric #include "lldb/Utility/Instrumentation.h" 13205afe67SEd Maste 14205afe67SEd Maste using namespace lldb; 15205afe67SEd Maste using namespace lldb_private; 16205afe67SEd Maste SBThreadCollection()176f8fc217SDimitry AndricSBThreadCollection::SBThreadCollection() { LLDB_INSTRUMENT_VA(this); } 18205afe67SEd Maste SBThreadCollection(const SBThreadCollection & rhs)1914f1b3e8SDimitry AndricSBThreadCollection::SBThreadCollection(const SBThreadCollection &rhs) 205f29bb8aSDimitry Andric : m_opaque_sp(rhs.m_opaque_sp) { 216f8fc217SDimitry Andric LLDB_INSTRUMENT_VA(this, rhs); 225f29bb8aSDimitry Andric } 23205afe67SEd Maste 2414f1b3e8SDimitry Andric const SBThreadCollection &SBThreadCollection:: operator =(const SBThreadCollection & rhs)2514f1b3e8SDimitry Andricoperator=(const SBThreadCollection &rhs) { 266f8fc217SDimitry Andric LLDB_INSTRUMENT_VA(this, rhs); 275f29bb8aSDimitry Andric 28205afe67SEd Maste if (this != &rhs) 29205afe67SEd Maste m_opaque_sp = rhs.m_opaque_sp; 306f8fc217SDimitry Andric return *this; 31205afe67SEd Maste } 32205afe67SEd Maste SBThreadCollection(const ThreadCollectionSP & threads)3314f1b3e8SDimitry AndricSBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads) 3414f1b3e8SDimitry Andric : m_opaque_sp(threads) {} 35205afe67SEd Maste 36cfca06d7SDimitry Andric SBThreadCollection::~SBThreadCollection() = default; 37205afe67SEd Maste SetOpaque(const lldb::ThreadCollectionSP & threads)3814f1b3e8SDimitry Andricvoid SBThreadCollection::SetOpaque(const lldb::ThreadCollectionSP &threads) { 39205afe67SEd Maste m_opaque_sp = threads; 40205afe67SEd Maste } 41205afe67SEd Maste get() const4214f1b3e8SDimitry Andriclldb_private::ThreadCollection *SBThreadCollection::get() const { 43205afe67SEd Maste return m_opaque_sp.get(); 44205afe67SEd Maste } 45205afe67SEd Maste operator ->() const4614f1b3e8SDimitry Andriclldb_private::ThreadCollection *SBThreadCollection::operator->() const { 47205afe67SEd Maste return m_opaque_sp.operator->(); 48205afe67SEd Maste } 49205afe67SEd Maste operator *()5014f1b3e8SDimitry Andriclldb::ThreadCollectionSP &SBThreadCollection::operator*() { 51205afe67SEd Maste return m_opaque_sp; 52205afe67SEd Maste } 53205afe67SEd Maste operator *() const5414f1b3e8SDimitry Andricconst lldb::ThreadCollectionSP &SBThreadCollection::operator*() const { 55205afe67SEd Maste return m_opaque_sp; 56205afe67SEd Maste } 57205afe67SEd Maste IsValid() const585f29bb8aSDimitry Andricbool SBThreadCollection::IsValid() const { 596f8fc217SDimitry Andric LLDB_INSTRUMENT_VA(this); 605f29bb8aSDimitry Andric return this->operator bool(); 615f29bb8aSDimitry Andric } operator bool() const625f29bb8aSDimitry AndricSBThreadCollection::operator bool() const { 636f8fc217SDimitry Andric LLDB_INSTRUMENT_VA(this); 645f29bb8aSDimitry Andric 655f29bb8aSDimitry Andric return m_opaque_sp.get() != nullptr; 665f29bb8aSDimitry Andric } 67205afe67SEd Maste GetSize()6814f1b3e8SDimitry Andricsize_t SBThreadCollection::GetSize() { 696f8fc217SDimitry Andric LLDB_INSTRUMENT_VA(this); 705f29bb8aSDimitry Andric 71205afe67SEd Maste if (m_opaque_sp) 72205afe67SEd Maste return m_opaque_sp->GetSize(); 73205afe67SEd Maste return 0; 74205afe67SEd Maste } 75205afe67SEd Maste GetThreadAtIndex(size_t idx)7614f1b3e8SDimitry AndricSBThread SBThreadCollection::GetThreadAtIndex(size_t idx) { 776f8fc217SDimitry Andric LLDB_INSTRUMENT_VA(this, idx); 785f29bb8aSDimitry Andric 79205afe67SEd Maste SBThread thread; 80205afe67SEd Maste if (m_opaque_sp && idx < m_opaque_sp->GetSize()) 81205afe67SEd Maste thread = m_opaque_sp->GetThreadAtIndex(idx); 826f8fc217SDimitry Andric return thread; 83205afe67SEd Maste } 84