1b1c73532SDimitry Andric //===-- SBProcessInfoList.cpp ---------------------------------------------===// 2b1c73532SDimitry Andric // 3b1c73532SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4b1c73532SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5b1c73532SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6b1c73532SDimitry Andric // 7b1c73532SDimitry Andric //===----------------------------------------------------------------------===// 8b1c73532SDimitry Andric 9b1c73532SDimitry Andric #include "lldb/API/SBProcessInfoList.h" 10b1c73532SDimitry Andric #include "lldb/API/SBProcessInfo.h" 11b1c73532SDimitry Andric #include "lldb/Utility/Instrumentation.h" 12b1c73532SDimitry Andric #include "lldb/Utility/ProcessInfo.h" 13b1c73532SDimitry Andric 14b1c73532SDimitry Andric #include "Utils.h" 15b1c73532SDimitry Andric 16b1c73532SDimitry Andric using namespace lldb; 17b1c73532SDimitry Andric using namespace lldb_private; 18b1c73532SDimitry Andric 19b1c73532SDimitry Andric SBProcessInfoList::SBProcessInfoList() = default; 20b1c73532SDimitry Andric 21b1c73532SDimitry Andric SBProcessInfoList::~SBProcessInfoList() = default; 22b1c73532SDimitry Andric SBProcessInfoList(const ProcessInfoList & impl)23b1c73532SDimitry AndricSBProcessInfoList::SBProcessInfoList(const ProcessInfoList &impl) 24b1c73532SDimitry Andric : m_opaque_up(std::make_unique<ProcessInfoList>(impl)) { 25b1c73532SDimitry Andric LLDB_INSTRUMENT_VA(this, impl); 26b1c73532SDimitry Andric } 27b1c73532SDimitry Andric SBProcessInfoList(const lldb::SBProcessInfoList & rhs)28b1c73532SDimitry AndricSBProcessInfoList::SBProcessInfoList(const lldb::SBProcessInfoList &rhs) { 29b1c73532SDimitry Andric 30b1c73532SDimitry Andric LLDB_INSTRUMENT_VA(this, rhs); 31b1c73532SDimitry Andric 32b1c73532SDimitry Andric m_opaque_up = clone(rhs.m_opaque_up); 33b1c73532SDimitry Andric } 34b1c73532SDimitry Andric 35b1c73532SDimitry Andric const lldb::SBProcessInfoList & operator =(const lldb::SBProcessInfoList & rhs)36b1c73532SDimitry AndricSBProcessInfoList::operator=(const lldb::SBProcessInfoList &rhs) { 37b1c73532SDimitry Andric 38b1c73532SDimitry Andric LLDB_INSTRUMENT_VA(this, rhs); 39b1c73532SDimitry Andric 40b1c73532SDimitry Andric if (this != &rhs) 41b1c73532SDimitry Andric m_opaque_up = clone(rhs.m_opaque_up); 42b1c73532SDimitry Andric return *this; 43b1c73532SDimitry Andric } 44b1c73532SDimitry Andric GetSize() const45b1c73532SDimitry Andricuint32_t SBProcessInfoList::GetSize() const { 46b1c73532SDimitry Andric LLDB_INSTRUMENT_VA(this); 47b1c73532SDimitry Andric 48b1c73532SDimitry Andric if (m_opaque_up) 49b1c73532SDimitry Andric return m_opaque_up->GetSize(); 50b1c73532SDimitry Andric 51b1c73532SDimitry Andric return 0; 52b1c73532SDimitry Andric } 53b1c73532SDimitry Andric Clear()54b1c73532SDimitry Andricvoid SBProcessInfoList::Clear() { 55b1c73532SDimitry Andric LLDB_INSTRUMENT_VA(this); 56b1c73532SDimitry Andric 57b1c73532SDimitry Andric if (m_opaque_up) 58b1c73532SDimitry Andric m_opaque_up->Clear(); 59b1c73532SDimitry Andric } 60b1c73532SDimitry Andric GetProcessInfoAtIndex(uint32_t idx,SBProcessInfo & info)61b1c73532SDimitry Andricbool SBProcessInfoList::GetProcessInfoAtIndex(uint32_t idx, 62b1c73532SDimitry Andric SBProcessInfo &info) { 63b1c73532SDimitry Andric LLDB_INSTRUMENT_VA(this, idx, info); 64b1c73532SDimitry Andric 65b1c73532SDimitry Andric if (m_opaque_up) { 66b1c73532SDimitry Andric lldb_private::ProcessInstanceInfo process_instance_info; 67b1c73532SDimitry Andric if (m_opaque_up->GetProcessInfoAtIndex(idx, process_instance_info)) { 68b1c73532SDimitry Andric info.SetProcessInfo(process_instance_info); 69b1c73532SDimitry Andric return true; 70b1c73532SDimitry Andric } 71b1c73532SDimitry Andric } 72b1c73532SDimitry Andric 73b1c73532SDimitry Andric return false; 74b1c73532SDimitry Andric } 75