LLDB  mainline
SBFileSpecList.cpp
Go to the documentation of this file.
1 //===-- SBFileSpecList.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 
10 #include "Utils.h"
11 #include "lldb/API/SBFileSpec.h"
12 #include "lldb/API/SBStream.h"
13 #include "lldb/Core/FileSpecList.h"
14 #include "lldb/Host/PosixApi.h"
15 #include "lldb/Utility/FileSpec.h"
17 #include "lldb/Utility/Stream.h"
18 
19 #include <climits>
20 
21 using namespace lldb;
22 using namespace lldb_private;
23 
24 SBFileSpecList::SBFileSpecList() : m_opaque_up(new FileSpecList()) {
25  LLDB_INSTRUMENT_VA(this);
26 }
27 
29  LLDB_INSTRUMENT_VA(this, rhs);
30 
32 }
33 
35 
37  LLDB_INSTRUMENT_VA(this, rhs);
38 
39  if (this != &rhs)
41  return *this;
42 }
43 
45  LLDB_INSTRUMENT_VA(this);
46 
47  return m_opaque_up->GetSize();
48 }
49 
50 void SBFileSpecList::Append(const SBFileSpec &sb_file) {
51  LLDB_INSTRUMENT_VA(this, sb_file);
52 
53  m_opaque_up->Append(sb_file.ref());
54 }
55 
57  LLDB_INSTRUMENT_VA(this, sb_file);
58 
59  return m_opaque_up->AppendIfUnique(sb_file.ref());
60 }
61 
63  LLDB_INSTRUMENT_VA(this);
64 
65  m_opaque_up->Clear();
66 }
67 
69  bool full) {
70  LLDB_INSTRUMENT_VA(this, idx, sb_file, full);
71 
72  return m_opaque_up->FindFileIndex(idx, sb_file.ref(), full);
73 }
74 
76  LLDB_INSTRUMENT_VA(this, idx);
77 
78  SBFileSpec new_spec;
79  new_spec.SetFileSpec(m_opaque_up->GetFileSpecAtIndex(idx));
80  return new_spec;
81 }
82 
83 const lldb_private::FileSpecList *SBFileSpecList::operator->() const {
84  return m_opaque_up.get();
85 }
86 
87 const lldb_private::FileSpecList *SBFileSpecList::get() const {
88  return m_opaque_up.get();
89 }
90 
91 const lldb_private::FileSpecList &SBFileSpecList::operator*() const {
92  return *m_opaque_up;
93 }
94 
95 const lldb_private::FileSpecList &SBFileSpecList::ref() const {
96  return *m_opaque_up;
97 }
98 
99 bool SBFileSpecList::GetDescription(SBStream &description) const {
100  LLDB_INSTRUMENT_VA(this, description);
101 
102  Stream &strm = description.ref();
103 
104  if (m_opaque_up) {
105  uint32_t num_files = m_opaque_up->GetSize();
106  strm.Printf("%d files: ", num_files);
107  for (uint32_t i = 0; i < num_files; i++) {
108  char path[PATH_MAX];
109  if (m_opaque_up->GetFileSpecAtIndex(i).GetPath(path, sizeof(path)))
110  strm.Printf("\n %s", path);
111  }
112  } else
113  strm.PutCString("No value");
114 
115  return true;
116 }
Instrumentation.h
lldb::SBFileSpecList::operator*
const lldb_private::FileSpecList & operator*() const
Definition: SBFileSpecList.cpp:91
lldb::SBStream::ref
lldb_private::Stream & ref()
Definition: SBStream.cpp:175
lldb::SBFileSpecList::operator->
const lldb_private::FileSpecList * operator->() const
Definition: SBFileSpecList.cpp:83
lldb::SBFileSpecList::Clear
void Clear()
Definition: SBFileSpecList.cpp:62
lldb::SBFileSpecList::AppendIfUnique
bool AppendIfUnique(const SBFileSpec &sb_file)
Definition: SBFileSpecList.cpp:56
SBFileSpecList.h
lldb::SBFileSpecList::GetFileSpecAtIndex
const SBFileSpec GetFileSpecAtIndex(uint32_t idx) const
Definition: SBFileSpecList.cpp:75
lldb_private::Stream
Definition: Stream.h:28
lldb::SBFileSpec::SetFileSpec
void SetFileSpec(const lldb_private::FileSpec &fspec)
Definition: SBFileSpec.cpp:164
SBStream.h
lldb_private::clone
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
Utils.h
SBFileSpec.h
FileSpecList.h
lldb::SBFileSpec::ref
const lldb_private::FileSpec & ref() const
Definition: SBFileSpec.cpp:162
lldb::SBFileSpecList::FindFileIndex
uint32_t FindFileIndex(uint32_t idx, const SBFileSpec &sb_file, bool full)
Definition: SBFileSpecList.cpp:68
lldb::SBFileSpecList::ref
const lldb_private::FileSpecList & ref() const
Definition: SBFileSpecList.cpp:95
lldb::SBFileSpecList::get
const lldb_private::FileSpecList * get() const
Definition: SBFileSpecList.cpp:87
lldb::SBFileSpecList::GetSize
uint32_t GetSize() const
Definition: SBFileSpecList.cpp:44
lldb::SBFileSpecList::SBFileSpecList
SBFileSpecList()
Definition: SBFileSpecList.cpp:24
uint32_t
lldb::SBFileSpec
Definition: SBFileSpec.h:16
lldb_private::Stream::Printf
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:107
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
PosixApi.h
FileSpec.h
lldb::SBFileSpecList::~SBFileSpecList
~SBFileSpecList()
LLDB_INSTRUMENT_VA
#define LLDB_INSTRUMENT_VA(...)
Definition: Instrumentation.h:100
lldb::SBFileSpecList::operator=
const SBFileSpecList & operator=(const lldb::SBFileSpecList &rhs)
Definition: SBFileSpecList.cpp:36
Stream.h
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb::SBFileSpecList::m_opaque_up
std::unique_ptr< lldb_private::FileSpecList > m_opaque_up
Definition: SBFileSpecList.h:52
lldb::SBStream
Definition: SBStream.h:18
PATH_MAX
#define PATH_MAX
Definition: windows/PosixApi.h:25
lldb::SBFileSpecList::GetDescription
bool GetDescription(SBStream &description) const
Definition: SBFileSpecList.cpp:99
lldb::SBFileSpecList::Append
void Append(const SBFileSpec &sb_file)
Definition: SBFileSpecList.cpp:50
lldb
Definition: SBAddress.h:15
lldb::SBFileSpecList
Definition: SBFileSpecList.h:17