LLDB  mainline
SBModuleSpec.cpp
Go to the documentation of this file.
1 //===-- SBModuleSpec.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/SBStream.h"
13 #include "lldb/Core/Module.h"
14 #include "lldb/Core/ModuleSpec.h"
15 #include "lldb/Host/Host.h"
16 #include "lldb/Symbol/ObjectFile.h"
17 #include "lldb/Utility/Stream.h"
18 
19 using namespace lldb;
20 using namespace lldb_private;
21 
24 }
25 
26 SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs) : m_opaque_up() {
28 
29  m_opaque_up = clone(rhs.m_opaque_up);
30 }
31 
34  SBModuleSpec, operator=,(const lldb::SBModuleSpec &), rhs);
35 
36  if (this != &rhs)
37  m_opaque_up = clone(rhs.m_opaque_up);
38  return LLDB_RECORD_RESULT(*this);
39 }
40 
42 
43 bool SBModuleSpec::IsValid() const {
45  return this->operator bool();
46 }
47 SBModuleSpec::operator bool() const {
48  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModuleSpec, operator bool);
49 
50  return m_opaque_up->operator bool();
51 }
52 
55 
56  m_opaque_up->Clear();
57 }
58 
61 
62  SBFileSpec sb_spec(m_opaque_up->GetFileSpec());
63  return LLDB_RECORD_RESULT(sb_spec);
64 }
65 
68  (const lldb::SBFileSpec &), sb_spec);
69 
70  m_opaque_up->GetFileSpec() = *sb_spec;
71 }
72 
76 
77  return LLDB_RECORD_RESULT(SBFileSpec(m_opaque_up->GetPlatformFileSpec()));
78 }
79 
82  (const lldb::SBFileSpec &), sb_spec);
83 
84  m_opaque_up->GetPlatformFileSpec() = *sb_spec;
85 }
86 
89 
90  return LLDB_RECORD_RESULT(SBFileSpec(m_opaque_up->GetSymbolFileSpec()));
91 }
92 
95  (const lldb::SBFileSpec &), sb_spec);
96 
97  m_opaque_up->GetSymbolFileSpec() = *sb_spec;
98 }
99 
102 
103  return m_opaque_up->GetObjectName().GetCString();
104 }
105 
106 void SBModuleSpec::SetObjectName(const char *name) {
107  LLDB_RECORD_METHOD(void, SBModuleSpec, SetObjectName, (const char *), name);
108 
109  m_opaque_up->GetObjectName().SetCString(name);
110 }
111 
112 const char *SBModuleSpec::GetTriple() {
114 
115  std::string triple(m_opaque_up->GetArchitecture().GetTriple().str());
116  // Unique the string so we don't run into ownership issues since the const
117  // strings put the string into the string pool once and the strings never
118  // comes out
119  ConstString const_triple(triple.c_str());
120  return const_triple.GetCString();
121 }
122 
123 void SBModuleSpec::SetTriple(const char *triple) {
124  LLDB_RECORD_METHOD(void, SBModuleSpec, SetTriple, (const char *), triple);
125 
126  m_opaque_up->GetArchitecture().SetTriple(triple);
127 }
128 
129 const uint8_t *SBModuleSpec::GetUUIDBytes() {
130  return m_opaque_up->GetUUID().GetBytes().data();
131 }
132 
135 
136  return m_opaque_up->GetUUID().GetBytes().size();
137 }
138 
139 bool SBModuleSpec::SetUUIDBytes(const uint8_t *uuid, size_t uuid_len) {
140  m_opaque_up->GetUUID() = UUID::fromOptionalData(uuid, uuid_len);
141  return m_opaque_up->GetUUID().IsValid();
142 }
143 
146  description);
147 
148  m_opaque_up->Dump(description.ref());
149  return true;
150 }
151 
154 }
155 
157  : m_opaque_up(new ModuleSpecList(*rhs.m_opaque_up)) {
159  rhs);
160 }
161 
165  SBModuleSpecList, operator=,(const lldb::SBModuleSpecList &), rhs);
166 
167  if (this != &rhs)
168  *m_opaque_up = *rhs.m_opaque_up;
169  return LLDB_RECORD_RESULT(*this);
170 }
171 
173 
176  GetModuleSpecifications, (const char *), path);
177 
178  SBModuleSpecList specs;
179  FileSpec file_spec(path);
180  FileSystem::Instance().Resolve(file_spec);
181  Host::ResolveExecutableInBundle(file_spec);
182  ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_up);
183  return LLDB_RECORD_RESULT(specs);
184 }
185 
188  (const lldb::SBModuleSpec &), spec);
189 
190  m_opaque_up->Append(*spec.m_opaque_up);
191 }
192 
195  (const lldb::SBModuleSpecList &), spec_list);
196 
197  m_opaque_up->Append(*spec_list.m_opaque_up);
198 }
199 
202 
203  return m_opaque_up->GetSize();
204 }
205 
208  (size_t), i);
209 
210  SBModuleSpec sb_module_spec;
211  m_opaque_up->GetModuleSpecAtIndex(i, *sb_module_spec.m_opaque_up);
212  return LLDB_RECORD_RESULT(sb_module_spec);
213 }
214 
219  match_spec);
220 
221  SBModuleSpec sb_module_spec;
222  m_opaque_up->FindMatchingModuleSpec(*match_spec.m_opaque_up,
223  *sb_module_spec.m_opaque_up);
224  return LLDB_RECORD_RESULT(sb_module_spec);
225 }
226 
231  match_spec);
232 
233  SBModuleSpecList specs;
234  m_opaque_up->FindMatchingModuleSpecs(*match_spec.m_opaque_up,
235  *specs.m_opaque_up);
236  return LLDB_RECORD_RESULT(specs);
237 }
238 
241  description);
242 
243  m_opaque_up->Dump(description.ref());
244  return true;
245 }
246 
247 namespace lldb_private {
248 namespace repro {
249 
250 template <>
255  SBModuleSpec, operator=,(const lldb::SBModuleSpec &));
256  LLDB_REGISTER_METHOD_CONST(bool, SBModuleSpec, IsValid, ());
257  LLDB_REGISTER_METHOD_CONST(bool, SBModuleSpec, operator bool, ());
258  LLDB_REGISTER_METHOD(void, SBModuleSpec, Clear, ());
260  LLDB_REGISTER_METHOD(void, SBModuleSpec, SetFileSpec,
261  (const lldb::SBFileSpec &));
262  LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModuleSpec, GetPlatformFileSpec,
263  ());
264  LLDB_REGISTER_METHOD(void, SBModuleSpec, SetPlatformFileSpec,
265  (const lldb::SBFileSpec &));
266  LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModuleSpec, GetSymbolFileSpec, ());
267  LLDB_REGISTER_METHOD(void, SBModuleSpec, SetSymbolFileSpec,
268  (const lldb::SBFileSpec &));
269  LLDB_REGISTER_METHOD(const char *, SBModuleSpec, GetObjectName, ());
270  LLDB_REGISTER_METHOD(void, SBModuleSpec, SetObjectName, (const char *));
271  LLDB_REGISTER_METHOD(const char *, SBModuleSpec, GetTriple, ());
272  LLDB_REGISTER_METHOD(void, SBModuleSpec, SetTriple, (const char *));
273  LLDB_REGISTER_METHOD(size_t, SBModuleSpec, GetUUIDLength, ());
275  (lldb::SBStream &));
278  (const lldb::SBModuleSpecList &));
281  SBModuleSpecList, operator=,(const lldb::SBModuleSpecList &));
283  GetModuleSpecifications, (const char *));
285  (const lldb::SBModuleSpec &));
287  (const lldb::SBModuleSpecList &));
290  (size_t));
296  (lldb::SBStream &));
297 }
298 
299 }
300 }
bool GetDescription(lldb::SBStream &description)
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)
lldb::SBFileSpec GetPlatformFileSpec()
Get accessor for the module platform file.
#define LLDB_RECORD_STATIC_METHOD(Result, Class, Method, Signature,...)
void SetSymbolFileSpec(const lldb::SBFileSpec &fspec)
A file utility class.
Definition: FileSpec.h:55
const char * GetObjectName()
void SetTriple(const char *triple)
void SetFileSpec(const lldb::SBFileSpec &fspec)
bool GetDescription(lldb::SBStream &description)
void RegisterMethods< SBModuleSpec >(Registry &R)
bool SetUUIDBytes(const uint8_t *uuid, size_t uuid_len)
lldb::SBFileSpec GetSymbolFileSpec()
SBModuleSpecList & operator=(const SBModuleSpecList &rhs)
#define LLDB_REGISTER_STATIC_METHOD(Result, Class, Method, Signature)
class LLDB_API SBFileSpec
Definition: SBDefines.h:44
void SetPlatformFileSpec(const lldb::SBFileSpec &fspec)
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
SBModuleSpec GetSpecAtIndex(size_t i)
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
const uint8_t * GetUUIDBytes()
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
const char * GetTriple()
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
void SetObjectName(const char *name)
lldb::SBFileSpec GetFileSpec()
Get const accessor for the module file.
lldb_private::Stream & ref()
Definition: SBStream.cpp:162
A uniqued constant string class.
Definition: ConstString.h:38
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:247
SBModuleSpecList FindMatchingSpecs(const SBModuleSpec &match_spec)
Definition: SBAddress.h:15
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
void Append(const SBModuleSpec &spec)
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
SBModuleSpec FindFirstMatchingSpec(const SBModuleSpec &match_spec)
#define LLDB_RECORD_RESULT(Result)
static SBModuleSpecList GetModuleSpecifications(const char *path)
bool IsValid() const
const SBModuleSpec & operator=(const SBModuleSpec &rhs)
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)