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/Core/Module.h"
14#include "lldb/Host/Host.h"
17#include "lldb/Utility/Stream.h"
18
19using namespace lldb;
20using namespace lldb_private;
21
24}
25
27 LLDB_INSTRUMENT_VA(this, rhs);
28
30}
31
33 : m_opaque_up(new lldb_private::ModuleSpec(module_spec)) {
34 LLDB_INSTRUMENT_VA(this, module_spec);
35}
36
38 LLDB_INSTRUMENT_VA(this, rhs);
39
40 if (this != &rhs)
42 return *this;
43}
44
46
49 return this->operator bool();
50}
51SBModuleSpec::operator bool() const {
53
54 return m_opaque_up->operator bool();
55}
56
59
60 m_opaque_up->Clear();
61}
62
65
66 SBFileSpec sb_spec(m_opaque_up->GetFileSpec());
67 return sb_spec;
68}
69
71 LLDB_INSTRUMENT_VA(this, sb_spec);
72
73 m_opaque_up->GetFileSpec() = *sb_spec;
74}
75
78
79 return SBFileSpec(m_opaque_up->GetPlatformFileSpec());
80}
81
83 LLDB_INSTRUMENT_VA(this, sb_spec);
84
85 m_opaque_up->GetPlatformFileSpec() = *sb_spec;
86}
87
90
91 return SBFileSpec(m_opaque_up->GetSymbolFileSpec());
92}
93
95 LLDB_INSTRUMENT_VA(this, sb_spec);
96
97 m_opaque_up->GetSymbolFileSpec() = *sb_spec;
98}
99
101 LLDB_INSTRUMENT_VA(this);
102
103 return m_opaque_up->GetObjectName().GetCString();
104}
105
106void SBModuleSpec::SetObjectName(const char *name) {
107 LLDB_INSTRUMENT_VA(this, name);
108
109 m_opaque_up->GetObjectName().SetCString(name);
110}
111
113 LLDB_INSTRUMENT_VA(this);
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
123void SBModuleSpec::SetTriple(const char *triple) {
124 LLDB_INSTRUMENT_VA(this, triple);
125
126 m_opaque_up->GetArchitecture().SetTriple(triple);
127}
128
131 return m_opaque_up->GetUUID().GetBytes().data();
132}
133
135 LLDB_INSTRUMENT_VA(this);
136
137 return m_opaque_up->GetUUID().GetBytes().size();
138}
139
140bool SBModuleSpec::SetUUIDBytes(const uint8_t *uuid, size_t uuid_len) {
141 LLDB_INSTRUMENT_VA(this, uuid, uuid_len)
142 m_opaque_up->GetUUID() = UUID(uuid, uuid_len);
143 return m_opaque_up->GetUUID().IsValid();
144}
145
147 LLDB_INSTRUMENT_VA(this, description);
148
149 m_opaque_up->Dump(description.ref());
150 return true;
151}
152
154 LLDB_INSTRUMENT_VA(this);
155
156 return m_opaque_up->GetObjectOffset();
157}
158
159void SBModuleSpec::SetObjectOffset(uint64_t object_offset) {
160 LLDB_INSTRUMENT_VA(this, object_offset);
161
162 m_opaque_up->SetObjectOffset(object_offset);
163}
164
166 LLDB_INSTRUMENT_VA(this);
167
168 return m_opaque_up->GetObjectSize();
169}
170
171void SBModuleSpec::SetObjectSize(uint64_t object_size) {
172 LLDB_INSTRUMENT_VA(this, object_size);
173
174 m_opaque_up->SetObjectSize(object_size);
175}
176
178 LLDB_INSTRUMENT_VA(this);
179}
180
182 : m_opaque_up(new ModuleSpecList(*rhs.m_opaque_up)) {
183 LLDB_INSTRUMENT_VA(this, rhs);
184}
185
187 LLDB_INSTRUMENT_VA(this, rhs);
188
189 if (this != &rhs)
190 *m_opaque_up = *rhs.m_opaque_up;
191 return *this;
192}
193
195
197 LLDB_INSTRUMENT_VA(path);
198
199 SBModuleSpecList specs;
200 FileSpec file_spec(path);
201 FileSystem::Instance().Resolve(file_spec);
203 ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_up);
204 return specs;
205}
206
208 LLDB_INSTRUMENT_VA(this, spec);
209
210 m_opaque_up->Append(*spec.m_opaque_up);
211}
212
214 LLDB_INSTRUMENT_VA(this, spec_list);
215
216 m_opaque_up->Append(*spec_list.m_opaque_up);
217}
218
220 LLDB_INSTRUMENT_VA(this);
221
222 return m_opaque_up->GetSize();
223}
224
226 LLDB_INSTRUMENT_VA(this, i);
227
228 SBModuleSpec sb_module_spec;
229 m_opaque_up->GetModuleSpecAtIndex(i, *sb_module_spec.m_opaque_up);
230 return sb_module_spec;
231}
232
235 LLDB_INSTRUMENT_VA(this, match_spec);
236
237 SBModuleSpec sb_module_spec;
238 m_opaque_up->FindMatchingModuleSpec(*match_spec.m_opaque_up,
239 *sb_module_spec.m_opaque_up);
240 return sb_module_spec;
241}
242
245 LLDB_INSTRUMENT_VA(this, match_spec);
246
247 SBModuleSpecList specs;
248 m_opaque_up->FindMatchingModuleSpecs(*match_spec.m_opaque_up,
249 *specs.m_opaque_up);
250 return specs;
251}
252
254 LLDB_INSTRUMENT_VA(this, description);
255
256 m_opaque_up->Dump(description.ref());
257 return true;
258}
#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
Definition: SBModuleSpec.h:128
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)
bool GetDescription(lldb::SBStream &description)
void SetObjectOffset(uint64_t object_offset)
uint64_t GetObjectSize()
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
Definition: SBModuleSpec.h:98
bool SetUUIDBytes(const uint8_t *uuid, size_t uuid_len)
const char * GetTriple()
lldb_private::Stream & ref()
Definition: SBStream.cpp:177
A uniqued constant string class.
Definition: ConstString.h:40
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:214
A file utility class.
Definition: FileSpec.h:56
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())
Definition: ObjectFile.cpp:187
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
Definition: SBAddress.h:15