Path: blob/main/contrib/llvm-project/lldb/source/API/SBFileSpecList.cpp
39587 views
//===-- SBFileSpecList.cpp ------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/API/SBFileSpecList.h"9#include "Utils.h"10#include "lldb/API/SBFileSpec.h"11#include "lldb/API/SBStream.h"12#include "lldb/Host/PosixApi.h"13#include "lldb/Utility/FileSpec.h"14#include "lldb/Utility/FileSpecList.h"15#include "lldb/Utility/Instrumentation.h"16#include "lldb/Utility/Stream.h"1718#include <climits>1920using namespace lldb;21using namespace lldb_private;2223SBFileSpecList::SBFileSpecList() : m_opaque_up(new FileSpecList()) {24LLDB_INSTRUMENT_VA(this);25}2627SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) {28LLDB_INSTRUMENT_VA(this, rhs);2930m_opaque_up = clone(rhs.m_opaque_up);31}3233SBFileSpecList::~SBFileSpecList() = default;3435const SBFileSpecList &SBFileSpecList::operator=(const SBFileSpecList &rhs) {36LLDB_INSTRUMENT_VA(this, rhs);3738if (this != &rhs)39m_opaque_up = clone(rhs.m_opaque_up);40return *this;41}4243uint32_t SBFileSpecList::GetSize() const {44LLDB_INSTRUMENT_VA(this);4546return m_opaque_up->GetSize();47}4849void SBFileSpecList::Append(const SBFileSpec &sb_file) {50LLDB_INSTRUMENT_VA(this, sb_file);5152m_opaque_up->Append(sb_file.ref());53}5455bool SBFileSpecList::AppendIfUnique(const SBFileSpec &sb_file) {56LLDB_INSTRUMENT_VA(this, sb_file);5758return m_opaque_up->AppendIfUnique(sb_file.ref());59}6061void SBFileSpecList::Clear() {62LLDB_INSTRUMENT_VA(this);6364m_opaque_up->Clear();65}6667uint32_t SBFileSpecList::FindFileIndex(uint32_t idx, const SBFileSpec &sb_file,68bool full) {69LLDB_INSTRUMENT_VA(this, idx, sb_file, full);7071return m_opaque_up->FindFileIndex(idx, sb_file.ref(), full);72}7374const SBFileSpec SBFileSpecList::GetFileSpecAtIndex(uint32_t idx) const {75LLDB_INSTRUMENT_VA(this, idx);7677SBFileSpec new_spec;78new_spec.SetFileSpec(m_opaque_up->GetFileSpecAtIndex(idx));79return new_spec;80}8182const lldb_private::FileSpecList *SBFileSpecList::operator->() const {83return m_opaque_up.get();84}8586const lldb_private::FileSpecList *SBFileSpecList::get() const {87return m_opaque_up.get();88}8990const lldb_private::FileSpecList &SBFileSpecList::operator*() const {91return *m_opaque_up;92}9394const lldb_private::FileSpecList &SBFileSpecList::ref() const {95return *m_opaque_up;96}9798bool SBFileSpecList::GetDescription(SBStream &description) const {99LLDB_INSTRUMENT_VA(this, description);100101Stream &strm = description.ref();102103if (m_opaque_up) {104uint32_t num_files = m_opaque_up->GetSize();105strm.Printf("%d files: ", num_files);106for (uint32_t i = 0; i < num_files; i++) {107char path[PATH_MAX];108if (m_opaque_up->GetFileSpecAtIndex(i).GetPath(path, sizeof(path)))109strm.Printf("\n %s", path);110}111} else112strm.PutCString("No value");113114return true;115}116117118