/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/API/SBModuleSpec.cpp
Line | Count | Source (jump to first uncovered line) |
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 | | |
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" |
18 | | |
19 | | using namespace lldb; |
20 | | using namespace lldb_private; |
21 | | |
22 | 16 | SBModuleSpec::SBModuleSpec() : m_opaque_up(new lldb_private::ModuleSpec()) { |
23 | 16 | LLDB_INSTRUMENT_VA(this); |
24 | 16 | } |
25 | | |
26 | 21 | SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs) { |
27 | 21 | LLDB_INSTRUMENT_VA(this, rhs); |
28 | | |
29 | 21 | m_opaque_up = clone(rhs.m_opaque_up); |
30 | 21 | } |
31 | | |
32 | | SBModuleSpec::SBModuleSpec(const lldb_private::ModuleSpec &module_spec) |
33 | 164 | : m_opaque_up(new lldb_private::ModuleSpec(module_spec)) { |
34 | 164 | LLDB_INSTRUMENT_VA(this, module_spec); |
35 | 164 | } |
36 | | |
37 | 5 | const SBModuleSpec &SBModuleSpec::operator=(const SBModuleSpec &rhs) { |
38 | 5 | LLDB_INSTRUMENT_VA(this, rhs); |
39 | | |
40 | 5 | if (this != &rhs) |
41 | 5 | m_opaque_up = clone(rhs.m_opaque_up); |
42 | 5 | return *this; |
43 | 5 | } |
44 | | |
45 | 201 | SBModuleSpec::~SBModuleSpec() = default; |
46 | | |
47 | 0 | bool SBModuleSpec::IsValid() const { |
48 | 0 | LLDB_INSTRUMENT_VA(this); |
49 | 0 | return this->operator bool(); |
50 | 0 | } |
51 | 0 | SBModuleSpec::operator bool() const { |
52 | 0 | LLDB_INSTRUMENT_VA(this); |
53 | |
|
54 | 0 | return m_opaque_up->operator bool(); |
55 | 0 | } |
56 | | |
57 | 2 | void SBModuleSpec::Clear() { |
58 | 2 | LLDB_INSTRUMENT_VA(this); |
59 | | |
60 | 2 | m_opaque_up->Clear(); |
61 | 2 | } |
62 | | |
63 | 16 | SBFileSpec SBModuleSpec::GetFileSpec() { |
64 | 16 | LLDB_INSTRUMENT_VA(this); |
65 | | |
66 | 16 | SBFileSpec sb_spec(m_opaque_up->GetFileSpec()); |
67 | 16 | return sb_spec; |
68 | 16 | } |
69 | | |
70 | 4 | void SBModuleSpec::SetFileSpec(const lldb::SBFileSpec &sb_spec) { |
71 | 4 | LLDB_INSTRUMENT_VA(this, sb_spec); |
72 | | |
73 | 4 | m_opaque_up->GetFileSpec() = *sb_spec; |
74 | 4 | } |
75 | | |
76 | 0 | lldb::SBFileSpec SBModuleSpec::GetPlatformFileSpec() { |
77 | 0 | LLDB_INSTRUMENT_VA(this); |
78 | |
|
79 | 0 | return SBFileSpec(m_opaque_up->GetPlatformFileSpec()); |
80 | 0 | } |
81 | | |
82 | 0 | void SBModuleSpec::SetPlatformFileSpec(const lldb::SBFileSpec &sb_spec) { |
83 | 0 | LLDB_INSTRUMENT_VA(this, sb_spec); |
84 | |
|
85 | 0 | m_opaque_up->GetPlatformFileSpec() = *sb_spec; |
86 | 0 | } |
87 | | |
88 | 0 | lldb::SBFileSpec SBModuleSpec::GetSymbolFileSpec() { |
89 | 0 | LLDB_INSTRUMENT_VA(this); |
90 | |
|
91 | 0 | return SBFileSpec(m_opaque_up->GetSymbolFileSpec()); |
92 | 0 | } |
93 | | |
94 | 0 | void SBModuleSpec::SetSymbolFileSpec(const lldb::SBFileSpec &sb_spec) { |
95 | 0 | LLDB_INSTRUMENT_VA(this, sb_spec); |
96 | |
|
97 | 0 | m_opaque_up->GetSymbolFileSpec() = *sb_spec; |
98 | 0 | } |
99 | | |
100 | 5 | const char *SBModuleSpec::GetObjectName() { |
101 | 5 | LLDB_INSTRUMENT_VA(this); |
102 | | |
103 | 5 | return m_opaque_up->GetObjectName().GetCString(); |
104 | 5 | } |
105 | | |
106 | 0 | void SBModuleSpec::SetObjectName(const char *name) { |
107 | 0 | LLDB_INSTRUMENT_VA(this, name); |
108 | |
|
109 | 0 | m_opaque_up->GetObjectName().SetCString(name); |
110 | 0 | } |
111 | | |
112 | 16 | const char *SBModuleSpec::GetTriple() { |
113 | 16 | LLDB_INSTRUMENT_VA(this); |
114 | | |
115 | 16 | 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 | 16 | ConstString const_triple(triple.c_str()); |
120 | 16 | return const_triple.GetCString(); |
121 | 16 | } |
122 | | |
123 | 0 | void SBModuleSpec::SetTriple(const char *triple) { |
124 | 0 | LLDB_INSTRUMENT_VA(this, triple); |
125 | |
|
126 | 0 | m_opaque_up->GetArchitecture().SetTriple(triple); |
127 | 0 | } |
128 | | |
129 | 16 | const uint8_t *SBModuleSpec::GetUUIDBytes() { |
130 | 16 | LLDB_INSTRUMENT_VA(this) |
131 | 16 | return m_opaque_up->GetUUID().GetBytes().data(); |
132 | 16 | } |
133 | | |
134 | 16 | size_t SBModuleSpec::GetUUIDLength() { |
135 | 16 | LLDB_INSTRUMENT_VA(this); |
136 | | |
137 | 16 | return m_opaque_up->GetUUID().GetBytes().size(); |
138 | 16 | } |
139 | | |
140 | 0 | bool SBModuleSpec::SetUUIDBytes(const uint8_t *uuid, size_t uuid_len) { |
141 | 0 | LLDB_INSTRUMENT_VA(this, uuid, uuid_len) |
142 | 0 | m_opaque_up->GetUUID() = UUID(uuid, uuid_len); |
143 | 0 | return m_opaque_up->GetUUID().IsValid(); |
144 | 0 | } |
145 | | |
146 | 0 | bool SBModuleSpec::GetDescription(lldb::SBStream &description) { |
147 | 0 | LLDB_INSTRUMENT_VA(this, description); |
148 | |
|
149 | 0 | m_opaque_up->Dump(description.ref()); |
150 | 0 | return true; |
151 | 0 | } |
152 | | |
153 | 6 | uint64_t SBModuleSpec::GetObjectOffset() { |
154 | 6 | LLDB_INSTRUMENT_VA(this); |
155 | | |
156 | 6 | return m_opaque_up->GetObjectOffset(); |
157 | 6 | } |
158 | | |
159 | 2 | void SBModuleSpec::SetObjectOffset(uint64_t object_offset) { |
160 | 2 | LLDB_INSTRUMENT_VA(this, object_offset); |
161 | | |
162 | 2 | m_opaque_up->SetObjectOffset(object_offset); |
163 | 2 | } |
164 | | |
165 | 11 | uint64_t SBModuleSpec::GetObjectSize() { |
166 | 11 | LLDB_INSTRUMENT_VA(this); |
167 | | |
168 | 11 | return m_opaque_up->GetObjectSize(); |
169 | 11 | } |
170 | | |
171 | 2 | void SBModuleSpec::SetObjectSize(uint64_t object_size) { |
172 | 2 | LLDB_INSTRUMENT_VA(this, object_size); |
173 | | |
174 | 2 | m_opaque_up->SetObjectSize(object_size); |
175 | 2 | } |
176 | | |
177 | 6 | SBModuleSpecList::SBModuleSpecList() : m_opaque_up(new ModuleSpecList()) { |
178 | 6 | LLDB_INSTRUMENT_VA(this); |
179 | 6 | } |
180 | | |
181 | | SBModuleSpecList::SBModuleSpecList(const SBModuleSpecList &rhs) |
182 | 3 | : m_opaque_up(new ModuleSpecList(*rhs.m_opaque_up)) { |
183 | 3 | LLDB_INSTRUMENT_VA(this, rhs); |
184 | 3 | } |
185 | | |
186 | 3 | SBModuleSpecList &SBModuleSpecList::operator=(const SBModuleSpecList &rhs) { |
187 | 3 | LLDB_INSTRUMENT_VA(this, rhs); |
188 | | |
189 | 3 | if (this != &rhs) |
190 | 3 | *m_opaque_up = *rhs.m_opaque_up; |
191 | 3 | return *this; |
192 | 3 | } |
193 | | |
194 | 9 | SBModuleSpecList::~SBModuleSpecList() = default; |
195 | | |
196 | 3 | SBModuleSpecList SBModuleSpecList::GetModuleSpecifications(const char *path) { |
197 | 3 | LLDB_INSTRUMENT_VA(path); |
198 | | |
199 | 3 | SBModuleSpecList specs; |
200 | 3 | FileSpec file_spec(path); |
201 | 3 | FileSystem::Instance().Resolve(file_spec); |
202 | 3 | Host::ResolveExecutableInBundle(file_spec); |
203 | 3 | ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_up); |
204 | 3 | return specs; |
205 | 3 | } |
206 | | |
207 | 0 | void SBModuleSpecList::Append(const SBModuleSpec &spec) { |
208 | 0 | LLDB_INSTRUMENT_VA(this, spec); |
209 | |
|
210 | 0 | m_opaque_up->Append(*spec.m_opaque_up); |
211 | 0 | } |
212 | | |
213 | 0 | void SBModuleSpecList::Append(const SBModuleSpecList &spec_list) { |
214 | 0 | LLDB_INSTRUMENT_VA(this, spec_list); |
215 | |
|
216 | 0 | m_opaque_up->Append(*spec_list.m_opaque_up); |
217 | 0 | } |
218 | | |
219 | 3 | size_t SBModuleSpecList::GetSize() { |
220 | 3 | LLDB_INSTRUMENT_VA(this); |
221 | | |
222 | 3 | return m_opaque_up->GetSize(); |
223 | 3 | } |
224 | | |
225 | 5 | SBModuleSpec SBModuleSpecList::GetSpecAtIndex(size_t i) { |
226 | 5 | LLDB_INSTRUMENT_VA(this, i); |
227 | | |
228 | 5 | SBModuleSpec sb_module_spec; |
229 | 5 | m_opaque_up->GetModuleSpecAtIndex(i, *sb_module_spec.m_opaque_up); |
230 | 5 | return sb_module_spec; |
231 | 5 | } |
232 | | |
233 | | SBModuleSpec |
234 | 0 | SBModuleSpecList::FindFirstMatchingSpec(const SBModuleSpec &match_spec) { |
235 | 0 | LLDB_INSTRUMENT_VA(this, match_spec); |
236 | |
|
237 | 0 | SBModuleSpec sb_module_spec; |
238 | 0 | m_opaque_up->FindMatchingModuleSpec(*match_spec.m_opaque_up, |
239 | 0 | *sb_module_spec.m_opaque_up); |
240 | 0 | return sb_module_spec; |
241 | 0 | } |
242 | | |
243 | | SBModuleSpecList |
244 | 0 | SBModuleSpecList::FindMatchingSpecs(const SBModuleSpec &match_spec) { |
245 | 0 | LLDB_INSTRUMENT_VA(this, match_spec); |
246 | |
|
247 | 0 | SBModuleSpecList specs; |
248 | 0 | m_opaque_up->FindMatchingModuleSpecs(*match_spec.m_opaque_up, |
249 | 0 | *specs.m_opaque_up); |
250 | 0 | return specs; |
251 | 0 | } |
252 | | |
253 | 0 | bool SBModuleSpecList::GetDescription(lldb::SBStream &description) { |
254 | 0 | LLDB_INSTRUMENT_VA(this, description); |
255 | |
|
256 | 0 | m_opaque_up->Dump(description.ref()); |
257 | 0 | return true; |
258 | 0 | } |