[lldb][dwarf] Compute fully qualified names on simplified template names with DWARFT...
[llvm-project.git] / lldb / source / API / SBModuleSpec.cpp
blobfbbcfeac20178316cacdcab8027b9f1d59d81561
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 //===----------------------------------------------------------------------===//
9 #include "lldb/API/SBModuleSpec.h"
10 #include "Utils.h"
11 #include "lldb/API/SBStream.h"
12 #include "lldb/Core/Module.h"
13 #include "lldb/Core/ModuleSpec.h"
14 #include "lldb/Host/Host.h"
15 #include "lldb/Symbol/ObjectFile.h"
16 #include "lldb/Utility/Instrumentation.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_INSTRUMENT_VA(this);
26 SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs) {
27 LLDB_INSTRUMENT_VA(this, rhs);
29 m_opaque_up = clone(rhs.m_opaque_up);
32 SBModuleSpec::SBModuleSpec(const lldb_private::ModuleSpec &module_spec)
33 : m_opaque_up(new lldb_private::ModuleSpec(module_spec)) {
34 LLDB_INSTRUMENT_VA(this, module_spec);
37 const SBModuleSpec &SBModuleSpec::operator=(const SBModuleSpec &rhs) {
38 LLDB_INSTRUMENT_VA(this, rhs);
40 if (this != &rhs)
41 m_opaque_up = clone(rhs.m_opaque_up);
42 return *this;
45 SBModuleSpec::~SBModuleSpec() = default;
47 bool SBModuleSpec::IsValid() const {
48 LLDB_INSTRUMENT_VA(this);
49 return this->operator bool();
51 SBModuleSpec::operator bool() const {
52 LLDB_INSTRUMENT_VA(this);
54 return m_opaque_up->operator bool();
57 void SBModuleSpec::Clear() {
58 LLDB_INSTRUMENT_VA(this);
60 m_opaque_up->Clear();
63 SBFileSpec SBModuleSpec::GetFileSpec() {
64 LLDB_INSTRUMENT_VA(this);
66 SBFileSpec sb_spec(m_opaque_up->GetFileSpec());
67 return sb_spec;
70 void SBModuleSpec::SetFileSpec(const lldb::SBFileSpec &sb_spec) {
71 LLDB_INSTRUMENT_VA(this, sb_spec);
73 m_opaque_up->GetFileSpec() = *sb_spec;
76 lldb::SBFileSpec SBModuleSpec::GetPlatformFileSpec() {
77 LLDB_INSTRUMENT_VA(this);
79 return SBFileSpec(m_opaque_up->GetPlatformFileSpec());
82 void SBModuleSpec::SetPlatformFileSpec(const lldb::SBFileSpec &sb_spec) {
83 LLDB_INSTRUMENT_VA(this, sb_spec);
85 m_opaque_up->GetPlatformFileSpec() = *sb_spec;
88 lldb::SBFileSpec SBModuleSpec::GetSymbolFileSpec() {
89 LLDB_INSTRUMENT_VA(this);
91 return SBFileSpec(m_opaque_up->GetSymbolFileSpec());
94 void SBModuleSpec::SetSymbolFileSpec(const lldb::SBFileSpec &sb_spec) {
95 LLDB_INSTRUMENT_VA(this, sb_spec);
97 m_opaque_up->GetSymbolFileSpec() = *sb_spec;
100 const char *SBModuleSpec::GetObjectName() {
101 LLDB_INSTRUMENT_VA(this);
103 return m_opaque_up->GetObjectName().GetCString();
106 void SBModuleSpec::SetObjectName(const char *name) {
107 LLDB_INSTRUMENT_VA(this, name);
109 m_opaque_up->GetObjectName().SetCString(name);
112 const char *SBModuleSpec::GetTriple() {
113 LLDB_INSTRUMENT_VA(this);
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_INSTRUMENT_VA(this, triple);
126 m_opaque_up->GetArchitecture().SetTriple(triple);
129 const uint8_t *SBModuleSpec::GetUUIDBytes() {
130 LLDB_INSTRUMENT_VA(this)
131 return m_opaque_up->GetUUID().GetBytes().data();
134 size_t SBModuleSpec::GetUUIDLength() {
135 LLDB_INSTRUMENT_VA(this);
137 return m_opaque_up->GetUUID().GetBytes().size();
140 bool 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();
146 bool SBModuleSpec::GetDescription(lldb::SBStream &description) {
147 LLDB_INSTRUMENT_VA(this, description);
149 m_opaque_up->Dump(description.ref());
150 return true;
153 uint64_t SBModuleSpec::GetObjectOffset() {
154 LLDB_INSTRUMENT_VA(this);
156 return m_opaque_up->GetObjectOffset();
159 void SBModuleSpec::SetObjectOffset(uint64_t object_offset) {
160 LLDB_INSTRUMENT_VA(this, object_offset);
162 m_opaque_up->SetObjectOffset(object_offset);
165 uint64_t SBModuleSpec::GetObjectSize() {
166 LLDB_INSTRUMENT_VA(this);
168 return m_opaque_up->GetObjectSize();
171 void SBModuleSpec::SetObjectSize(uint64_t object_size) {
172 LLDB_INSTRUMENT_VA(this, object_size);
174 m_opaque_up->SetObjectSize(object_size);
177 SBModuleSpecList::SBModuleSpecList() : m_opaque_up(new ModuleSpecList()) {
178 LLDB_INSTRUMENT_VA(this);
181 SBModuleSpecList::SBModuleSpecList(const SBModuleSpecList &rhs)
182 : m_opaque_up(new ModuleSpecList(*rhs.m_opaque_up)) {
183 LLDB_INSTRUMENT_VA(this, rhs);
186 SBModuleSpecList &SBModuleSpecList::operator=(const SBModuleSpecList &rhs) {
187 LLDB_INSTRUMENT_VA(this, rhs);
189 if (this != &rhs)
190 *m_opaque_up = *rhs.m_opaque_up;
191 return *this;
194 SBModuleSpecList::~SBModuleSpecList() = default;
196 SBModuleSpecList SBModuleSpecList::GetModuleSpecifications(const char *path) {
197 LLDB_INSTRUMENT_VA(path);
199 SBModuleSpecList specs;
200 FileSpec file_spec(path);
201 FileSystem::Instance().Resolve(file_spec);
202 Host::ResolveExecutableInBundle(file_spec);
203 ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_up);
204 return specs;
207 void SBModuleSpecList::Append(const SBModuleSpec &spec) {
208 LLDB_INSTRUMENT_VA(this, spec);
210 m_opaque_up->Append(*spec.m_opaque_up);
213 void SBModuleSpecList::Append(const SBModuleSpecList &spec_list) {
214 LLDB_INSTRUMENT_VA(this, spec_list);
216 m_opaque_up->Append(*spec_list.m_opaque_up);
219 size_t SBModuleSpecList::GetSize() {
220 LLDB_INSTRUMENT_VA(this);
222 return m_opaque_up->GetSize();
225 SBModuleSpec SBModuleSpecList::GetSpecAtIndex(size_t i) {
226 LLDB_INSTRUMENT_VA(this, i);
228 SBModuleSpec sb_module_spec;
229 m_opaque_up->GetModuleSpecAtIndex(i, *sb_module_spec.m_opaque_up);
230 return sb_module_spec;
233 SBModuleSpec
234 SBModuleSpecList::FindFirstMatchingSpec(const SBModuleSpec &match_spec) {
235 LLDB_INSTRUMENT_VA(this, match_spec);
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;
243 SBModuleSpecList
244 SBModuleSpecList::FindMatchingSpecs(const SBModuleSpec &match_spec) {
245 LLDB_INSTRUMENT_VA(this, match_spec);
247 SBModuleSpecList specs;
248 m_opaque_up->FindMatchingModuleSpecs(*match_spec.m_opaque_up,
249 *specs.m_opaque_up);
250 return specs;
253 bool SBModuleSpecList::GetDescription(lldb::SBStream &description) {
254 LLDB_INSTRUMENT_VA(this, description);
256 m_opaque_up->Dump(description.ref());
257 return true;