LLDB mainline
SBModuleSpec.cpp
Go to the documentation of this file.
1//===-- SBModuleSpec.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/SBStream.h"
12#include "lldb/API/SBTarget.h"
13#include "lldb/Core/Module.h"
15#include "lldb/Host/Host.h"
18#include "lldb/Utility/Stream.h"
19
20using namespace lldb;
21using namespace lldb_private;
22
26
32
34 : m_opaque_up(new lldb_private::ModuleSpec(module_spec)) {
35 LLDB_INSTRUMENT_VA(this, module_spec);
36}
37
39 LLDB_INSTRUMENT_VA(this, rhs);
40
41 if (this != &rhs)
43 return *this;
44}
45
47
50 return this->operator bool();
51}
52SBModuleSpec::operator bool() const {
54
55 return m_opaque_up->operator bool();
56}
57
60
61 m_opaque_up->Clear();
62}
63
66
67 SBFileSpec sb_spec(m_opaque_up->GetFileSpec());
68 return sb_spec;
69}
70
72 LLDB_INSTRUMENT_VA(this, sb_spec);
73
74 m_opaque_up->GetFileSpec() = *sb_spec;
75}
76
79
80 return SBFileSpec(m_opaque_up->GetPlatformFileSpec());
81}
82
84 LLDB_INSTRUMENT_VA(this, sb_spec);
85
86 m_opaque_up->GetPlatformFileSpec() = *sb_spec;
87}
88
94
96 LLDB_INSTRUMENT_VA(this, sb_spec);
97
98 m_opaque_up->GetSymbolFileSpec() = *sb_spec;
99}
100
102 LLDB_INSTRUMENT_VA(this);
103
104 return ConstString(m_opaque_up->GetObjectName()).GetCString();
105}
106
107void SBModuleSpec::SetObjectName(const char *name) {
108 LLDB_INSTRUMENT_VA(this, name);
109
110 if (!name)
111 m_opaque_up->SetObjectName(std::string());
112 else
113 m_opaque_up->SetObjectName(name);
114}
115
117 LLDB_INSTRUMENT_VA(this);
118
119 std::string triple(m_opaque_up->GetArchitecture().GetTriple().str());
120 // Unique the string so we don't run into ownership issues since the const
121 // strings put the string into the string pool once and the strings never
122 // comes out
123 ConstString const_triple(triple);
124 return const_triple.GetCString();
125}
126
127void SBModuleSpec::SetTriple(const char *triple) {
128 LLDB_INSTRUMENT_VA(this, triple);
129
130 m_opaque_up->GetArchitecture().SetTriple(triple);
131}
132
135 return m_opaque_up->GetUUID().GetBytes().data();
136}
137
139 LLDB_INSTRUMENT_VA(this);
140
141 return m_opaque_up->GetUUID().GetBytes().size();
142}
143
144bool SBModuleSpec::SetUUIDBytes(const uint8_t *uuid, size_t uuid_len) {
145 LLDB_INSTRUMENT_VA(this, uuid, uuid_len)
146 m_opaque_up->GetUUID() = UUID(uuid, uuid_len);
147 return m_opaque_up->GetUUID().IsValid();
148}
149
151 LLDB_INSTRUMENT_VA(this, description);
152
153 m_opaque_up->Dump(description.ref());
154 return true;
155}
156
158 LLDB_INSTRUMENT_VA(this);
159
160 return m_opaque_up->GetObjectOffset();
161}
162
163void SBModuleSpec::SetObjectOffset(uint64_t object_offset) {
164 LLDB_INSTRUMENT_VA(this, object_offset);
165
166 m_opaque_up->SetObjectOffset(object_offset);
167}
168
170 LLDB_INSTRUMENT_VA(this);
171
172 return m_opaque_up->GetObjectSize();
173}
174
175void SBModuleSpec::SetObjectSize(uint64_t object_size) {
176 LLDB_INSTRUMENT_VA(this, object_size);
177
178 m_opaque_up->SetObjectSize(object_size);
179}
180
182 LLDB_INSTRUMENT_VA(this);
183
184 return SBTarget(m_opaque_up->GetTargetSP());
185}
186
188 LLDB_INSTRUMENT_VA(this, target);
189
190 m_opaque_up->SetTarget(target.GetSP());
191}
192
196
201
203 : m_opaque_up(new ModuleSpecList(std::move(module_spec))) {
204 LLDB_INSTRUMENT_VA(this);
205}
206
208 LLDB_INSTRUMENT_VA(this, rhs);
209
210 if (this != &rhs)
211 *m_opaque_up = *rhs.m_opaque_up;
212 return *this;
213}
214
216
218 LLDB_INSTRUMENT_VA(path);
219
220 SBModuleSpecList specs;
221 FileSpec file_spec(path);
222 FileSystem::Instance().Resolve(file_spec);
224 *specs.m_opaque_up = ObjectFile::GetModuleSpecifications(file_spec, 0, 0);
225 return specs;
226}
227
229 LLDB_INSTRUMENT_VA(this, spec);
230
231 m_opaque_up->Append(*spec.m_opaque_up);
232}
233
235 LLDB_INSTRUMENT_VA(this, spec_list);
236
237 m_opaque_up->Append(*spec_list.m_opaque_up);
238}
239
241 LLDB_INSTRUMENT_VA(this);
242
243 return m_opaque_up->GetSize();
244}
245
247 LLDB_INSTRUMENT_VA(this, i);
248
249 SBModuleSpec sb_module_spec;
250 m_opaque_up->GetModuleSpecAtIndex(i, *sb_module_spec.m_opaque_up);
251 return sb_module_spec;
252}
253
256 LLDB_INSTRUMENT_VA(this, match_spec);
257
258 SBModuleSpec sb_module_spec;
259 m_opaque_up->FindMatchingModuleSpec(*match_spec.m_opaque_up,
260 *sb_module_spec.m_opaque_up);
261 return sb_module_spec;
262}
263
266 LLDB_INSTRUMENT_VA(this, match_spec);
267
268 SBModuleSpecList specs;
269 m_opaque_up->FindMatchingModuleSpecs(*match_spec.m_opaque_up,
270 *specs.m_opaque_up);
271 return specs;
272}
273
275 LLDB_INSTRUMENT_VA(this, description);
276
277 m_opaque_up->Dump(description.ref());
278 return true;
279}
#define LLDB_INSTRUMENT_VA(...)
SBModuleSpec GetSpecAtIndex(size_t i)
SBModuleSpecList FindMatchingSpecs(const SBModuleSpec &match_spec)
SBModuleSpec FindFirstMatchingSpec(const SBModuleSpec &match_spec)
void Append(const SBModuleSpec &spec)
bool GetDescription(lldb::SBStream &description)
static SBModuleSpecList GetModuleSpecifications(const char *path)
std::unique_ptr< lldb_private::ModuleSpecList > m_opaque_up
SBModuleSpecList & operator=(const SBModuleSpecList &rhs)
void SetObjectSize(uint64_t object_size)
void SetFileSpec(const lldb::SBFileSpec &fspec)
const uint8_t * GetUUIDBytes()
lldb::SBFileSpec GetFileSpec()
Get const accessor for the module file.
void SetSymbolFileSpec(const lldb::SBFileSpec &fspec)
void SetTarget(lldb::SBTarget target)
Set the target to be used when resolving a module.
bool GetDescription(lldb::SBStream &description)
friend class SBTarget
void SetObjectOffset(uint64_t object_offset)
void SetPlatformFileSpec(const lldb::SBFileSpec &fspec)
void SetTriple(const char *triple)
lldb::SBTarget GetTarget() const
lldb::SBFileSpec GetPlatformFileSpec()
Get accessor for the module platform file.
void SetObjectName(const char *name)
lldb::SBFileSpec GetSymbolFileSpec()
uint64_t GetObjectOffset()
const SBModuleSpec & operator=(const SBModuleSpec &rhs)
const char * GetObjectName()
bool IsValid() const
std::unique_ptr< lldb_private::ModuleSpec > m_opaque_up
bool SetUUIDBytes(const uint8_t *uuid, size_t uuid_len)
const char * GetTriple()
lldb_private::Stream & ref()
Definition SBStream.cpp:179
lldb::TargetSP GetSP() const
Definition SBTarget.cpp:600
A uniqued constant string class.
Definition ConstString.h:40
const char * GetCString() const
Get the string value as a C string.
A file utility class.
Definition FileSpec.h:56
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
static bool ResolveExecutableInBundle(FileSpec &file)
When executable files may live within a directory, where the directory represents an executable bundl...
static ModuleSpecList GetModuleSpecifications(const FileSpec &file, lldb::offset_t file_offset, lldb::offset_t file_size, lldb::DataExtractorSP=lldb::DataExtractorSP())
Represents UUID's of various sizes.
Definition UUID.h:27
A class that represents a running process on the host machine.
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition Utils.h:17
class LLDB_API SBFileSpec
Definition SBDefines.h:76