| 1 | //===-- SBProcessInfoList.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/SBProcessInfoList.h" |
| 10 | #include "lldb/API/SBProcessInfo.h" |
| 11 | #include "lldb/Utility/Instrumentation.h" |
| 12 | #include "lldb/Utility/ProcessInfo.h" |
| 13 | |
| 14 | #include "Utils.h" |
| 15 | |
| 16 | using namespace lldb; |
| 17 | using namespace lldb_private; |
| 18 | |
| 19 | SBProcessInfoList::SBProcessInfoList() = default; |
| 20 | |
| 21 | SBProcessInfoList::~SBProcessInfoList() = default; |
| 22 | |
| 23 | SBProcessInfoList::SBProcessInfoList(const ProcessInfoList &impl) |
| 24 | : m_opaque_up(std::make_unique<ProcessInfoList>(args: impl)) { |
| 25 | LLDB_INSTRUMENT_VA(this, impl); |
| 26 | } |
| 27 | |
| 28 | SBProcessInfoList::SBProcessInfoList(const lldb::SBProcessInfoList &rhs) { |
| 29 | |
| 30 | LLDB_INSTRUMENT_VA(this, rhs); |
| 31 | |
| 32 | m_opaque_up = clone(src: rhs.m_opaque_up); |
| 33 | } |
| 34 | |
| 35 | const lldb::SBProcessInfoList & |
| 36 | SBProcessInfoList::operator=(const lldb::SBProcessInfoList &rhs) { |
| 37 | |
| 38 | LLDB_INSTRUMENT_VA(this, rhs); |
| 39 | |
| 40 | if (this != &rhs) |
| 41 | m_opaque_up = clone(src: rhs.m_opaque_up); |
| 42 | return *this; |
| 43 | } |
| 44 | |
| 45 | uint32_t SBProcessInfoList::GetSize() const { |
| 46 | LLDB_INSTRUMENT_VA(this); |
| 47 | |
| 48 | if (m_opaque_up) |
| 49 | return m_opaque_up->GetSize(); |
| 50 | |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | void SBProcessInfoList::Clear() { |
| 55 | LLDB_INSTRUMENT_VA(this); |
| 56 | |
| 57 | if (m_opaque_up) |
| 58 | m_opaque_up->Clear(); |
| 59 | } |
| 60 | |
| 61 | bool SBProcessInfoList::GetProcessInfoAtIndex(uint32_t idx, |
| 62 | SBProcessInfo &info) { |
| 63 | LLDB_INSTRUMENT_VA(this, idx, info); |
| 64 | |
| 65 | if (m_opaque_up) { |
| 66 | lldb_private::ProcessInstanceInfo process_instance_info; |
| 67 | if (m_opaque_up->GetProcessInfoAtIndex(idx, info&: process_instance_info)) { |
| 68 | info.SetProcessInfo(process_instance_info); |
| 69 | return true; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | return false; |
| 74 | } |
| 75 |
