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 LLDB_INSTRUMENT_VA(this, rhs);
34
35 if (this != &rhs)
37 return *this;
38}
39
41
44 return this->operator bool();
45}
46SBModuleSpec::operator bool() const {
48
49 return m_opaque_up->operator bool();
50}
51
54
55 m_opaque_up->Clear();
56}
57
60
61 SBFileSpec sb_spec(m_opaque_up->GetFileSpec());
62 return sb_spec;
63}
64
66 LLDB_INSTRUMENT_VA(this, sb_spec);
67
68 m_opaque_up->GetFileSpec() = *sb_spec;
69}
70
73
74 return SBFileSpec(m_opaque_up->GetPlatformFileSpec());
75}
76
78 LLDB_INSTRUMENT_VA(this, sb_spec);
79
80 m_opaque_up->GetPlatformFileSpec() = *sb_spec;
81}
82
85
86 return SBFileSpec(m_opaque_up->GetSymbolFileSpec());
87}
88
90 LLDB_INSTRUMENT_VA(this, sb_spec);
91
92 m_opaque_up->GetSymbolFileSpec() = *sb_spec;
93}
94
97
98 return m_opaque_up->GetObjectName().GetCString();
99}
100
101void SBModuleSpec::SetObjectName(const char *name) {
102 LLDB_INSTRUMENT_VA(this, name);
103
104 m_opaque_up->GetObjectName().SetCString(name);
105}
106
108 LLDB_INSTRUMENT_VA(this);
109
110 std::string triple(m_opaque_up->GetArchitecture().GetTriple().str());
111 // Unique the string so we don't run into ownership issues since the const
112 // strings put the string into the string pool once and the strings never
113 // comes out
114 ConstString const_triple(triple.c_str());
115 return const_triple.GetCString();
116}
117
118void SBModuleSpec::SetTriple(const char *triple) {
119 LLDB_INSTRUMENT_VA(this, triple);
120
121 m_opaque_up->GetArchitecture().SetTriple(triple);
122}
123
126 return m_opaque_up->GetUUID().GetBytes().data();
127}
128
130 LLDB_INSTRUMENT_VA(this);
131
132 return m_opaque_up->GetUUID().GetBytes().size();
133}
134
135bool SBModuleSpec::SetUUIDBytes(const uint8_t *uuid, size_t uuid_len) {
136 LLDB_INSTRUMENT_VA(this, uuid, uuid_len)
137 m_opaque_up->GetUUID() = UUID(uuid, uuid_len);
138 return m_opaque_up->GetUUID().IsValid();
139}
140
142 LLDB_INSTRUMENT_VA(this, description);
143
144 m_opaque_up->Dump(description.ref());
145 return true;
146}
147
149 LLDB_INSTRUMENT_VA(this);
150}
151
153 : m_opaque_up(new ModuleSpecList(*rhs.m_opaque_up)) {
154 LLDB_INSTRUMENT_VA(this, rhs);
155}
156
158 LLDB_INSTRUMENT_VA(this, rhs);
159
160 if (this != &rhs)
161 *m_opaque_up = *rhs.m_opaque_up;
162 return *this;
163}
164
166
168 LLDB_INSTRUMENT_VA(path);
169
170 SBModuleSpecList specs;
171 FileSpec file_spec(path);
172 FileSystem::Instance().Resolve(file_spec);
174 ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_up);
175 return specs;
176}
177
179 LLDB_INSTRUMENT_VA(this, spec);
180
181 m_opaque_up->Append(*spec.m_opaque_up);
182}
183
185 LLDB_INSTRUMENT_VA(this, spec_list);
186
187 m_opaque_up->Append(*spec_list.m_opaque_up);
188}
189
191 LLDB_INSTRUMENT_VA(this);
192
193 return m_opaque_up->GetSize();
194}
195
197 LLDB_INSTRUMENT_VA(this, i);
198
199 SBModuleSpec sb_module_spec;
200 m_opaque_up->GetModuleSpecAtIndex(i, *sb_module_spec.m_opaque_up);
201 return sb_module_spec;
202}
203
206 LLDB_INSTRUMENT_VA(this, match_spec);
207
208 SBModuleSpec sb_module_spec;
209 m_opaque_up->FindMatchingModuleSpec(*match_spec.m_opaque_up,
210 *sb_module_spec.m_opaque_up);
211 return sb_module_spec;
212}
213
216 LLDB_INSTRUMENT_VA(this, match_spec);
217
218 SBModuleSpecList specs;
219 m_opaque_up->FindMatchingModuleSpecs(*match_spec.m_opaque_up,
220 *specs.m_opaque_up);
221 return specs;
222}
223
225 LLDB_INSTRUMENT_VA(this, description);
226
227 m_opaque_up->Dump(description.ref());
228 return true;
229}
#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:117
SBModuleSpecList & operator=(const SBModuleSpecList &rhs)
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 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()
const SBModuleSpec & operator=(const SBModuleSpec &rhs)
const char * GetObjectName()
bool IsValid() const
std::unique_ptr< lldb_private::ModuleSpec > m_opaque_up
Definition: SBModuleSpec.h:87
bool SetUUIDBytes(const uint8_t *uuid, size_t uuid_len)
const char * GetTriple()
lldb_private::Stream & ref()
Definition: SBStream.cpp:176
A uniqued constant string class.
Definition: ConstString.h:39
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:215
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())
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