[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / lldb / source / API / SBModuleSpec.cpp
bloba5e9ad26fac12865346e89232eeb3bac0666454d
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 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBModuleSpec.h"
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"
19 using namespace lldb;
20 using namespace lldb_private;
22 SBModuleSpec::SBModuleSpec() : m_opaque_up(new lldb_private::ModuleSpec()) {
23 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBModuleSpec);
26 SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs) : m_opaque_up() {
27 LLDB_RECORD_CONSTRUCTOR(SBModuleSpec, (const lldb::SBModuleSpec &), rhs);
29 m_opaque_up = clone(rhs.m_opaque_up);
32 const SBModuleSpec &SBModuleSpec::operator=(const SBModuleSpec &rhs) {
33 LLDB_RECORD_METHOD(const lldb::SBModuleSpec &,
34 SBModuleSpec, operator=,(const lldb::SBModuleSpec &), rhs);
36 if (this != &rhs)
37 m_opaque_up = clone(rhs.m_opaque_up);
38 return LLDB_RECORD_RESULT(*this);
41 SBModuleSpec::~SBModuleSpec() {}
43 bool SBModuleSpec::IsValid() const {
44 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModuleSpec, IsValid);
45 return this->operator bool();
47 SBModuleSpec::operator bool() const {
48 LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModuleSpec, operator bool);
50 return m_opaque_up->operator bool();
53 void SBModuleSpec::Clear() {
54 LLDB_RECORD_METHOD_NO_ARGS(void, SBModuleSpec, Clear);
56 m_opaque_up->Clear();
59 SBFileSpec SBModuleSpec::GetFileSpec() {
60 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModuleSpec, GetFileSpec);
62 SBFileSpec sb_spec(m_opaque_up->GetFileSpec());
63 return LLDB_RECORD_RESULT(sb_spec);
66 void SBModuleSpec::SetFileSpec(const lldb::SBFileSpec &sb_spec) {
67 LLDB_RECORD_METHOD(void, SBModuleSpec, SetFileSpec,
68 (const lldb::SBFileSpec &), sb_spec);
70 m_opaque_up->GetFileSpec() = *sb_spec;
73 lldb::SBFileSpec SBModuleSpec::GetPlatformFileSpec() {
74 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModuleSpec,
75 GetPlatformFileSpec);
77 return LLDB_RECORD_RESULT(SBFileSpec(m_opaque_up->GetPlatformFileSpec()));
80 void SBModuleSpec::SetPlatformFileSpec(const lldb::SBFileSpec &sb_spec) {
81 LLDB_RECORD_METHOD(void, SBModuleSpec, SetPlatformFileSpec,
82 (const lldb::SBFileSpec &), sb_spec);
84 m_opaque_up->GetPlatformFileSpec() = *sb_spec;
87 lldb::SBFileSpec SBModuleSpec::GetSymbolFileSpec() {
88 LLDB_RECORD_METHOD_NO_ARGS(lldb::SBFileSpec, SBModuleSpec, GetSymbolFileSpec);
90 return LLDB_RECORD_RESULT(SBFileSpec(m_opaque_up->GetSymbolFileSpec()));
93 void SBModuleSpec::SetSymbolFileSpec(const lldb::SBFileSpec &sb_spec) {
94 LLDB_RECORD_METHOD(void, SBModuleSpec, SetSymbolFileSpec,
95 (const lldb::SBFileSpec &), sb_spec);
97 m_opaque_up->GetSymbolFileSpec() = *sb_spec;
100 const char *SBModuleSpec::GetObjectName() {
101 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBModuleSpec, GetObjectName);
103 return m_opaque_up->GetObjectName().GetCString();
106 void SBModuleSpec::SetObjectName(const char *name) {
107 LLDB_RECORD_METHOD(void, SBModuleSpec, SetObjectName, (const char *), name);
109 m_opaque_up->GetObjectName().SetCString(name);
112 const char *SBModuleSpec::GetTriple() {
113 LLDB_RECORD_METHOD_NO_ARGS(const char *, SBModuleSpec, GetTriple);
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();
123 void SBModuleSpec::SetTriple(const char *triple) {
124 LLDB_RECORD_METHOD(void, SBModuleSpec, SetTriple, (const char *), triple);
126 m_opaque_up->GetArchitecture().SetTriple(triple);
129 const uint8_t *SBModuleSpec::GetUUIDBytes() {
130 return m_opaque_up->GetUUID().GetBytes().data();
133 size_t SBModuleSpec::GetUUIDLength() {
134 LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModuleSpec, GetUUIDLength);
136 return m_opaque_up->GetUUID().GetBytes().size();
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();
144 bool SBModuleSpec::GetDescription(lldb::SBStream &description) {
145 LLDB_RECORD_METHOD(bool, SBModuleSpec, GetDescription, (lldb::SBStream &),
146 description);
148 m_opaque_up->Dump(description.ref());
149 return true;
152 SBModuleSpecList::SBModuleSpecList() : m_opaque_up(new ModuleSpecList()) {
153 LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBModuleSpecList);
156 SBModuleSpecList::SBModuleSpecList(const SBModuleSpecList &rhs)
157 : m_opaque_up(new ModuleSpecList(*rhs.m_opaque_up)) {
158 LLDB_RECORD_CONSTRUCTOR(SBModuleSpecList, (const lldb::SBModuleSpecList &),
159 rhs);
162 SBModuleSpecList &SBModuleSpecList::operator=(const SBModuleSpecList &rhs) {
163 LLDB_RECORD_METHOD(
164 lldb::SBModuleSpecList &,
165 SBModuleSpecList, operator=,(const lldb::SBModuleSpecList &), rhs);
167 if (this != &rhs)
168 *m_opaque_up = *rhs.m_opaque_up;
169 return LLDB_RECORD_RESULT(*this);
172 SBModuleSpecList::~SBModuleSpecList() {}
174 SBModuleSpecList SBModuleSpecList::GetModuleSpecifications(const char *path) {
175 LLDB_RECORD_STATIC_METHOD(lldb::SBModuleSpecList, SBModuleSpecList,
176 GetModuleSpecifications, (const char *), path);
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);
186 void SBModuleSpecList::Append(const SBModuleSpec &spec) {
187 LLDB_RECORD_METHOD(void, SBModuleSpecList, Append,
188 (const lldb::SBModuleSpec &), spec);
190 m_opaque_up->Append(*spec.m_opaque_up);
193 void SBModuleSpecList::Append(const SBModuleSpecList &spec_list) {
194 LLDB_RECORD_METHOD(void, SBModuleSpecList, Append,
195 (const lldb::SBModuleSpecList &), spec_list);
197 m_opaque_up->Append(*spec_list.m_opaque_up);
200 size_t SBModuleSpecList::GetSize() {
201 LLDB_RECORD_METHOD_NO_ARGS(size_t, SBModuleSpecList, GetSize);
203 return m_opaque_up->GetSize();
206 SBModuleSpec SBModuleSpecList::GetSpecAtIndex(size_t i) {
207 LLDB_RECORD_METHOD(lldb::SBModuleSpec, SBModuleSpecList, GetSpecAtIndex,
208 (size_t), i);
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);
215 SBModuleSpec
216 SBModuleSpecList::FindFirstMatchingSpec(const SBModuleSpec &match_spec) {
217 LLDB_RECORD_METHOD(lldb::SBModuleSpec, SBModuleSpecList,
218 FindFirstMatchingSpec, (const lldb::SBModuleSpec &),
219 match_spec);
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);
227 SBModuleSpecList
228 SBModuleSpecList::FindMatchingSpecs(const SBModuleSpec &match_spec) {
229 LLDB_RECORD_METHOD(lldb::SBModuleSpecList, SBModuleSpecList,
230 FindMatchingSpecs, (const lldb::SBModuleSpec &),
231 match_spec);
233 SBModuleSpecList specs;
234 m_opaque_up->FindMatchingModuleSpecs(*match_spec.m_opaque_up,
235 *specs.m_opaque_up);
236 return LLDB_RECORD_RESULT(specs);
239 bool SBModuleSpecList::GetDescription(lldb::SBStream &description) {
240 LLDB_RECORD_METHOD(bool, SBModuleSpecList, GetDescription, (lldb::SBStream &),
241 description);
243 m_opaque_up->Dump(description.ref());
244 return true;
247 namespace lldb_private {
248 namespace repro {
250 template <>
251 void RegisterMethods<SBModuleSpec>(Registry &R) {
252 LLDB_REGISTER_CONSTRUCTOR(SBModuleSpec, ());
253 LLDB_REGISTER_CONSTRUCTOR(SBModuleSpec, (const lldb::SBModuleSpec &));
254 LLDB_REGISTER_METHOD(const lldb::SBModuleSpec &,
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, ());
259 LLDB_REGISTER_METHOD(lldb::SBFileSpec, SBModuleSpec, GetFileSpec, ());
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, ());
274 LLDB_REGISTER_METHOD(bool, SBModuleSpec, GetDescription,
275 (lldb::SBStream &));
276 LLDB_REGISTER_CONSTRUCTOR(SBModuleSpecList, ());
277 LLDB_REGISTER_CONSTRUCTOR(SBModuleSpecList,
278 (const lldb::SBModuleSpecList &));
279 LLDB_REGISTER_METHOD(
280 lldb::SBModuleSpecList &,
281 SBModuleSpecList, operator=,(const lldb::SBModuleSpecList &));
282 LLDB_REGISTER_STATIC_METHOD(lldb::SBModuleSpecList, SBModuleSpecList,
283 GetModuleSpecifications, (const char *));
284 LLDB_REGISTER_METHOD(void, SBModuleSpecList, Append,
285 (const lldb::SBModuleSpec &));
286 LLDB_REGISTER_METHOD(void, SBModuleSpecList, Append,
287 (const lldb::SBModuleSpecList &));
288 LLDB_REGISTER_METHOD(size_t, SBModuleSpecList, GetSize, ());
289 LLDB_REGISTER_METHOD(lldb::SBModuleSpec, SBModuleSpecList, GetSpecAtIndex,
290 (size_t));
291 LLDB_REGISTER_METHOD(lldb::SBModuleSpec, SBModuleSpecList,
292 FindFirstMatchingSpec, (const lldb::SBModuleSpec &));
293 LLDB_REGISTER_METHOD(lldb::SBModuleSpecList, SBModuleSpecList,
294 FindMatchingSpecs, (const lldb::SBModuleSpec &));
295 LLDB_REGISTER_METHOD(bool, SBModuleSpecList, GetDescription,
296 (lldb::SBStream &));