LLDB  mainline
SBFileSpecList.cpp
Go to the documentation of this file.
1 //===-- SBFileSpecList.cpp --------------------------------------*- C++ -*-===//
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 "SBReproducerPrivate.h"
11 #include "Utils.h"
12 #include "lldb/API/SBFileSpec.h"
13 #include "lldb/API/SBStream.h"
14 #include "lldb/Core/FileSpecList.h"
15 #include "lldb/Host/PosixApi.h"
16 #include "lldb/Utility/FileSpec.h"
17 #include "lldb/Utility/Stream.h"
18 
19 #include <limits.h>
20 
21 using namespace lldb;
22 using namespace lldb_private;
23 
24 SBFileSpecList::SBFileSpecList() : m_opaque_up(new FileSpecList()) {
26 }
27 
28 SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) : m_opaque_up() {
30 
31 
32  m_opaque_up = clone(rhs.m_opaque_up);
33 }
34 
36 
39  SBFileSpecList, operator=,(const lldb::SBFileSpecList &),
40  rhs);
41 
42  if (this != &rhs)
43  m_opaque_up = clone(rhs.m_opaque_up);
44  return LLDB_RECORD_RESULT(*this);
45 }
46 
49 
50  return m_opaque_up->GetSize();
51 }
52 
53 void SBFileSpecList::Append(const SBFileSpec &sb_file) {
55  sb_file);
56 
57  m_opaque_up->Append(sb_file.ref());
58 }
59 
62  (const lldb::SBFileSpec &), sb_file);
63 
64  return m_opaque_up->AppendIfUnique(sb_file.ref());
65 }
66 
69 
70  m_opaque_up->Clear();
71 }
72 
74  bool full) {
76  (uint32_t, const lldb::SBFileSpec &, bool), idx, sb_file,
77  full);
78 
79  return m_opaque_up->FindFileIndex(idx, sb_file.ref(), full);
80 }
81 
85 
86  SBFileSpec new_spec;
87  new_spec.SetFileSpec(m_opaque_up->GetFileSpecAtIndex(idx));
88  return LLDB_RECORD_RESULT(new_spec);
89 }
90 
91 const lldb_private::FileSpecList *SBFileSpecList::operator->() const {
92  return m_opaque_up.get();
93 }
94 
95 const lldb_private::FileSpecList *SBFileSpecList::get() const {
96  return m_opaque_up.get();
97 }
98 
99 const lldb_private::FileSpecList &SBFileSpecList::operator*() const {
100  return *m_opaque_up;
101 }
102 
103 const lldb_private::FileSpecList &SBFileSpecList::ref() const {
104  return *m_opaque_up;
105 }
106 
107 bool SBFileSpecList::GetDescription(SBStream &description) const {
109  (lldb::SBStream &), description);
110 
111  Stream &strm = description.ref();
112 
113  if (m_opaque_up) {
114  uint32_t num_files = m_opaque_up->GetSize();
115  strm.Printf("%d files: ", num_files);
116  for (uint32_t i = 0; i < num_files; i++) {
117  char path[PATH_MAX];
118  if (m_opaque_up->GetFileSpecAtIndex(i).GetPath(path, sizeof(path)))
119  strm.Printf("\n %s", path);
120  }
121  } else
122  strm.PutCString("No value");
123 
124  return true;
125 }
126 
127 namespace lldb_private {
128 namespace repro {
129 
130 template <>
135  const lldb::SBFileSpecList &,
136  SBFileSpecList, operator=,(const lldb::SBFileSpecList &));
139  (const lldb::SBFileSpec &));
141  (const lldb::SBFileSpec &));
144  (uint32_t, const lldb::SBFileSpec &, bool));
148  (lldb::SBStream &));
149 }
150 
151 }
152 }
uint32_t GetSize() const
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:61
The registry contains a unique mapping between functions and their ID.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
uint32_t FindFileIndex(uint32_t idx, const SBFileSpec &sb_file, bool full)
bool GetDescription(SBStream &description) const
const Scalar operator*(const Scalar &lhs, const Scalar &rhs)
Definition: Scalar.cpp:2161
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
const SBFileSpecList & operator=(const lldb::SBFileSpecList &rhs)
const SBFileSpec GetFileSpecAtIndex(uint32_t idx) const
void Append(const SBFileSpec &sb_file)
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:106
lldb_private::Stream & ref()
Definition: SBStream.cpp:162
bool AppendIfUnique(const SBFileSpec &sb_file)
#define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature,...)
Definition: SBAddress.h:15
#define PATH_MAX
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
void RegisterMethods< SBFileSpecList >(Registry &R)
#define LLDB_RECORD_RESULT(Result)
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)