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 m_opaque_up->GetObjectName().GetCString();
105}
106
107void SBModuleSpec::SetObjectName(const char *name) {
108 LLDB_INSTRUMENT_VA(this, name);
109
110 m_opaque_up->GetObjectName().SetCString(name);
111}
112
114 LLDB_INSTRUMENT_VA(this);
115
116 std::string triple(m_opaque_up->GetArchitecture().GetTriple().str());
117 // Unique the string so we don't run into ownership issues since the const
118 // strings put the string into the string pool once and the strings never
119 // comes out
120 ConstString const_triple(triple.c_str());
121 return const_triple.GetCString();
122}
123
124void SBModuleSpec::SetTriple(const char *triple) {
125 LLDB_INSTRUMENT_VA(this, triple);
126
127 m_opaque_up->GetArchitecture().SetTriple(triple);
128}
129
132 return m_opaque_up->GetUUID().GetBytes().data();
133}
134
136 LLDB_INSTRUMENT_VA(this);
137
138 return m_opaque_up->GetUUID().GetBytes().size();
139}
140
141bool SBModuleSpec::SetUUIDBytes(const uint8_t *uuid, size_t uuid_len) {
142 LLDB_INSTRUMENT_VA(this, uuid, uuid_len)
143 m_opaque_up->GetUUID() = UUID(uuid, uuid_len);
144 return m_opaque_up->GetUUID().IsValid();
145}
146
148 LLDB_INSTRUMENT_VA(this, description);
149
150 m_opaque_up->Dump(description.ref());
151 return true;
152}
153
155 LLDB_INSTRUMENT_VA(this);
156
157 return m_opaque_up->GetObjectOffset();
158}
159
160void SBModuleSpec::SetObjectOffset(uint64_t object_offset) {
161 LLDB_INSTRUMENT_VA(this, object_offset);
162
163 m_opaque_up->SetObjectOffset(object_offset);
164}
165
167 LLDB_INSTRUMENT_VA(this);
168
169 return m_opaque_up->GetObjectSize();
170}
171
172void SBModuleSpec::SetObjectSize(uint64_t object_size) {
173 LLDB_INSTRUMENT_VA(this, object_size);
174
175 m_opaque_up->SetObjectSize(object_size);
176}
177
179 LLDB_INSTRUMENT_VA(this);
180
181 return SBTarget(m_opaque_up->GetTargetSP());
182}
183
185 LLDB_INSTRUMENT_VA(this, target);
186
187 m_opaque_up->SetTarget(target.GetSP());
188}
189
193
198
200 LLDB_INSTRUMENT_VA(this, rhs);
201
202 if (this != &rhs)
203 *m_opaque_up = *rhs.m_opaque_up;
204 return *this;
205}
206
208
210 LLDB_INSTRUMENT_VA(path);
211
212 SBModuleSpecList specs;
213 FileSpec file_spec(path);
214 FileSystem::Instance().Resolve(file_spec);
216 ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_up);
217 return specs;
218}
219
221 LLDB_INSTRUMENT_VA(this, spec);
222
223 m_opaque_up->Append(*spec.m_opaque_up);
224}
225
227 LLDB_INSTRUMENT_VA(this, spec_list);
228
229 m_opaque_up->Append(*spec_list.m_opaque_up);
230}
231
233 LLDB_INSTRUMENT_VA(this);
234
235 return m_opaque_up->GetSize();
236}
237
239 LLDB_INSTRUMENT_VA(this, i);
240
241 SBModuleSpec sb_module_spec;
242 m_opaque_up->GetModuleSpecAtIndex(i, *sb_module_spec.m_opaque_up);
243 return sb_module_spec;
244}
245
248 LLDB_INSTRUMENT_VA(this, match_spec);
249
250 SBModuleSpec sb_module_spec;
251 m_opaque_up->FindMatchingModuleSpec(*match_spec.m_opaque_up,
252 *sb_module_spec.m_opaque_up);
253 return sb_module_spec;
254}
255
258 LLDB_INSTRUMENT_VA(this, match_spec);
259
260 SBModuleSpecList specs;
261 m_opaque_up->FindMatchingModuleSpecs(*match_spec.m_opaque_up,
262 *specs.m_opaque_up);
263 return specs;
264}
265
267 LLDB_INSTRUMENT_VA(this, description);
268
269 m_opaque_up->Dump(description.ref());
270 return true;
271}
#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::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)
lldb::SBTarget GetTarget()
const char * GetTriple()
lldb_private::Stream & ref()
Definition SBStream.cpp:178
lldb::TargetSP GetSP() const
Definition SBTarget.cpp:579
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:57
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
static FileSystem & Instance()
static bool ResolveExecutableInBundle(FileSpec &file)
When executable files may live within a directory, where the directory represents an executable bundl...
static size_t GetModuleSpecifications(const FileSpec &file, lldb::offset_t file_offset, lldb::offset_t file_size, ModuleSpecList &specs, lldb::DataBufferSP data_sp=lldb::DataBufferSP())
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:75