1a5ea1e2bSKuba Brecka //===-- SBThreadCollection.cpp ----------------------------------*- C++ -*-===// 2a5ea1e2bSKuba Brecka // 3*2946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*2946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 5*2946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6a5ea1e2bSKuba Brecka // 7a5ea1e2bSKuba Brecka //===----------------------------------------------------------------------===// 8a5ea1e2bSKuba Brecka 9a5ea1e2bSKuba Brecka #include "lldb/API/SBThreadCollection.h" 10a5ea1e2bSKuba Brecka #include "lldb/API/SBThread.h" 11a5ea1e2bSKuba Brecka #include "lldb/Target/ThreadList.h" 12a5ea1e2bSKuba Brecka 13a5ea1e2bSKuba Brecka using namespace lldb; 14a5ea1e2bSKuba Brecka using namespace lldb_private; 15a5ea1e2bSKuba Brecka 16b9c1b51eSKate Stone SBThreadCollection::SBThreadCollection() : m_opaque_sp() {} 17a5ea1e2bSKuba Brecka 18b9c1b51eSKate Stone SBThreadCollection::SBThreadCollection(const SBThreadCollection &rhs) 19b9c1b51eSKate Stone : m_opaque_sp(rhs.m_opaque_sp) {} 20a5ea1e2bSKuba Brecka 21b9c1b51eSKate Stone const SBThreadCollection &SBThreadCollection:: 22b9c1b51eSKate Stone operator=(const SBThreadCollection &rhs) { 23a5ea1e2bSKuba Brecka if (this != &rhs) 24a5ea1e2bSKuba Brecka m_opaque_sp = rhs.m_opaque_sp; 25a5ea1e2bSKuba Brecka return *this; 26a5ea1e2bSKuba Brecka } 27a5ea1e2bSKuba Brecka 28b9c1b51eSKate Stone SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads) 29b9c1b51eSKate Stone : m_opaque_sp(threads) {} 30a5ea1e2bSKuba Brecka 31b9c1b51eSKate Stone SBThreadCollection::~SBThreadCollection() {} 32a5ea1e2bSKuba Brecka 33b9c1b51eSKate Stone void SBThreadCollection::SetOpaque(const lldb::ThreadCollectionSP &threads) { 34a5ea1e2bSKuba Brecka m_opaque_sp = threads; 35a5ea1e2bSKuba Brecka } 36a5ea1e2bSKuba Brecka 37b9c1b51eSKate Stone lldb_private::ThreadCollection *SBThreadCollection::get() const { 38a5ea1e2bSKuba Brecka return m_opaque_sp.get(); 39a5ea1e2bSKuba Brecka } 40a5ea1e2bSKuba Brecka 41b9c1b51eSKate Stone lldb_private::ThreadCollection *SBThreadCollection::operator->() const { 42a5ea1e2bSKuba Brecka return m_opaque_sp.operator->(); 43a5ea1e2bSKuba Brecka } 44a5ea1e2bSKuba Brecka 45b9c1b51eSKate Stone lldb::ThreadCollectionSP &SBThreadCollection::operator*() { 46a5ea1e2bSKuba Brecka return m_opaque_sp; 47a5ea1e2bSKuba Brecka } 48a5ea1e2bSKuba Brecka 49b9c1b51eSKate Stone const lldb::ThreadCollectionSP &SBThreadCollection::operator*() const { 50a5ea1e2bSKuba Brecka return m_opaque_sp; 51a5ea1e2bSKuba Brecka } 52a5ea1e2bSKuba Brecka 53b9c1b51eSKate Stone bool SBThreadCollection::IsValid() const { return m_opaque_sp.get() != NULL; } 54a5ea1e2bSKuba Brecka 55b9c1b51eSKate Stone size_t SBThreadCollection::GetSize() { 56a5ea1e2bSKuba Brecka if (m_opaque_sp) 57a5ea1e2bSKuba Brecka return m_opaque_sp->GetSize(); 58a5ea1e2bSKuba Brecka return 0; 59a5ea1e2bSKuba Brecka } 60a5ea1e2bSKuba Brecka 61b9c1b51eSKate Stone SBThread SBThreadCollection::GetThreadAtIndex(size_t idx) { 62a5ea1e2bSKuba Brecka SBThread thread; 63a5ea1e2bSKuba Brecka if (m_opaque_sp && idx < m_opaque_sp->GetSize()) 64a5ea1e2bSKuba Brecka thread = m_opaque_sp->GetThreadAtIndex(idx); 65a5ea1e2bSKuba Brecka return thread; 66a5ea1e2bSKuba Brecka } 67