17
17
18
18
#include < glog/logging.h>
19
19
#include < lldb/API/LLDB.h>
20
+
20
21
#include < cassert>
21
22
22
23
namespace std {
@@ -29,25 +30,28 @@ namespace std {
29
30
* Is there a better way to do this?
30
31
*/
31
32
size_t hash<lldb::SBType>::operator ()(const lldb::SBType& key) const {
32
- auto * name = const_cast <lldb::SBType&>(key).GetName ();
33
+ auto * name = const_cast <lldb::SBType&>(key).GetName ();
33
34
auto Hasher = std::hash<const char *>();
34
35
{ /* Debugging
35
- auto & keyAsSP = reinterpret_cast<const lldb::TypeImplSP&>(key);
36
+ auto& keyAsSP = reinterpret_cast<const lldb::TypeImplSP&>(key);
36
37
fprintf(stderr, "LLDBType::hash(key@0x%08zx = (0x%08zx, %s)) = 0x%08zx\n",
37
38
(uintptr_t)keyAsSP.get(), (uintptr_t)name, name, Hasher(name));
38
39
// Debugging */
39
40
}
40
41
return Hasher (name);
41
42
}
42
43
43
- bool equal_to<lldb::SBType>::operator ()(const lldb::SBType& lhs, const lldb::SBType& rhs) const {
44
+ bool equal_to<lldb::SBType>::operator ()(const lldb::SBType& lhs,
45
+ const lldb::SBType& rhs) const {
44
46
auto * lhsName = const_cast <lldb::SBType&>(lhs).GetName ();
45
47
auto * rhsName = const_cast <lldb::SBType&>(rhs).GetName ();
46
48
auto EqualTo = std::equal_to<const char *>();
47
49
{ /* Debugging
48
- auto &lhsAsSP = reinterpret_cast<const lldb::TypeImplSP&>(lhs);
49
- auto &rhsAsSP = reinterpret_cast<const lldb::TypeImplSP&>(rhs);
50
- fprintf(stderr, "LLDBType::equal_to(lhs@0x%08zx = (0x%08zx, %s), rhs@0x%08zx = (0x%08zx, %s)) = %d\n",
50
+ auto& lhsAsSP = reinterpret_cast<const lldb::TypeImplSP&>(lhs);
51
+ auto& rhsAsSP = reinterpret_cast<const lldb::TypeImplSP&>(rhs);
52
+ fprintf(stderr, "LLDBType::equal_to("
53
+ "lhs@0x%08zx = (0x%08zx, %s), "
54
+ "rhs@0x%08zx = (0x%08zx, %s)) = %d\n",
51
55
(uintptr_t)lhsAsSP.get(), (uintptr_t)lhsName, lhsName,
52
56
(uintptr_t)rhsAsSP.get(), (uintptr_t)rhsName, rhsName,
53
57
EqualTo(lhsName, rhsName));
@@ -71,6 +75,7 @@ struct DepthGuard {
71
75
~DepthGuard () {
72
76
--depth_;
73
77
}
78
+
74
79
private:
75
80
int & depth_;
76
81
};
@@ -152,10 +157,11 @@ Class& LLDBParser::enumerateClass(lldb::SBType& type) {
152
157
kind = Class::Kind::Union;
153
158
break ;
154
159
default :
155
- throw LLDBParserError{" Invalid type class for compound type: " + std::to_string (typeClass)};
160
+ throw LLDBParserError{" Invalid type class for compound type: " +
161
+ std::to_string (typeClass)};
156
162
}
157
163
158
- auto & c = makeType<Class>(type, kind, displayName, name, size, virtuality);
164
+ auto & c = makeType<Class>(type, kind, displayName, name, size, virtuality);
159
165
160
166
enumerateClassTemplateParams (type, c.templateParams );
161
167
enumerateClassParents (type, c.parents );
@@ -165,7 +171,8 @@ Class& LLDBParser::enumerateClass(lldb::SBType& type) {
165
171
return c;
166
172
}
167
173
168
- void LLDBParser::enumerateClassTemplateParams (lldb::SBType &type, std::vector<TemplateParam>& params) {
174
+ void LLDBParser::enumerateClassTemplateParams (
175
+ lldb::SBType& type, std::vector<TemplateParam>& params) {
169
176
assert (params.empty ());
170
177
params.reserve (type.GetNumberOfTemplateArguments ());
171
178
@@ -180,13 +187,15 @@ void LLDBParser::enumerateTemplateParam(lldb::SBType& /*type*/,
180
187
uint32_t /* i*/ ,
181
188
std::vector<TemplateParam>& params) {
182
189
QualifierSet qualifiers;
183
- qualifiers[Qualifier::Const] = param.GetName () != param.GetUnqualifiedType ().GetName (); // TODO: Wonky as hell :/
190
+ qualifiers[Qualifier::Const] = // TODO: Wonky as hell :/
191
+ param.GetName () != param.GetUnqualifiedType ().GetName ();
184
192
auto & paramType = enumerateType (param);
185
193
186
194
params.emplace_back (paramType, qualifiers);
187
195
}
188
196
189
- void LLDBParser::enumerateClassParents (lldb::SBType& type, std::vector<Parent>& parents) {
197
+ void LLDBParser::enumerateClassParents (lldb::SBType& type,
198
+ std::vector<Parent>& parents) {
190
199
assert (parents.empty ());
191
200
parents.reserve (type.GetNumberOfDirectBaseClasses ());
192
201
@@ -198,15 +207,16 @@ void LLDBParser::enumerateClassParents(lldb::SBType& type, std::vector<Parent>&
198
207
}
199
208
}
200
209
201
- void LLDBParser::enumerateClassMembers (lldb::SBType& type, std::vector<Member>& members) {
210
+ void LLDBParser::enumerateClassMembers (lldb::SBType& type,
211
+ std::vector<Member>& members) {
202
212
assert (members.empty ());
203
213
members.reserve (type.GetNumberOfFields ());
204
214
205
215
/* TODO: We are missing the _vptr */
206
216
for (uint32_t i = 0 ; i < type.GetNumberOfFields (); i++) {
207
217
auto field = type.GetFieldAtIndex (i);
208
218
if (field.GetName () == nullptr )
209
- continue ; // Skip anonymous fields (TODO: Why?)
219
+ continue ; // Skip anonymous fields (TODO: Why?)
210
220
auto fieldName = field.GetName ();
211
221
auto fieldType = field.GetType ();
212
222
auto bitFieldSize = field.GetBitfieldSizeInBits ();
@@ -221,7 +231,8 @@ void LLDBParser::enumerateClassMembers(lldb::SBType& type, std::vector<Member>&
221
231
});
222
232
}
223
233
224
- void LLDBParser::enumerateClassFunctions (lldb::SBType &type, std::vector<Function>& functions) {
234
+ void LLDBParser::enumerateClassFunctions (lldb::SBType& type,
235
+ std::vector<Function>& functions) {
225
236
assert (functions.empty ());
226
237
functions.reserve (type.GetNumberOfMemberFunctions ());
227
238
@@ -235,7 +246,7 @@ void LLDBParser::enumerateClassFunctions(lldb::SBType &type, std::vector<Functio
235
246
}
236
247
237
248
Enum& LLDBParser::enumerateEnum (lldb::SBType& type) {
238
- const char * typeName = type.GetName ();
249
+ const char * typeName = type.GetName ();
239
250
std::string name = typeName ? typeName : " " ;
240
251
uint64_t size = type.GetByteSize ();
241
252
@@ -260,9 +271,9 @@ Typedef& LLDBParser::enumerateTypedef(lldb::SBType& type) {
260
271
}
261
272
262
273
Type& LLDBParser::enumeratePointer (lldb::SBType& type) {
263
- if (!chasePointer ()) {
264
- return makeType<Primitive>(type, Primitive::Kind::StubbedPointer);
265
- }
274
+ if (!chasePointer ()) {
275
+ return makeType<Primitive>(type, Primitive::Kind::StubbedPointer);
276
+ }
266
277
267
278
lldb::SBType pointeeType;
268
279
switch (auto kind = type.GetTypeClass ()) {
@@ -273,11 +284,12 @@ Type& LLDBParser::enumeratePointer(lldb::SBType& type) {
273
284
pointeeType = type.GetDereferencedType ();
274
285
break ;
275
286
default :
276
- throw LLDBParserError{" Invalid type class for pointer type: " + std::to_string (kind)};
287
+ throw LLDBParserError{" Invalid type class for pointer type: " +
288
+ std::to_string (kind)};
277
289
}
278
290
279
291
if (pointeeType.IsFunctionType ()) {
280
- return makeType<Primitive>(type, Primitive::Kind::StubbedPointer);
292
+ return makeType<Primitive>(type, Primitive::Kind::StubbedPointer);
281
293
}
282
294
283
295
Type& t = enumerateType (pointeeType);
@@ -291,7 +303,8 @@ bool LLDBParser::chasePointer() const {
291
303
return options_.chaseRawPointers ;
292
304
}
293
305
294
- Primitive::Kind LLDBParser::primitiveIntKind (lldb::SBType& type, bool is_signed) {
306
+ Primitive::Kind LLDBParser::primitiveIntKind (lldb::SBType& type,
307
+ bool is_signed) {
295
308
switch (auto size = type.GetByteSize ()) {
296
309
case 1 :
297
310
return is_signed ? Primitive::Kind::Int8 : Primitive::Kind::UInt8;
@@ -376,7 +389,8 @@ Primitive& LLDBParser::enumeratePrimitive(lldb::SBType& type) {
376
389
case lldb::eBasicTypeObjCSel:
377
390
case lldb::eBasicTypeOther:
378
391
default :
379
- throw LLDBParserError{" Unhandled primitive type: " + std::to_string (kind)};
392
+ throw LLDBParserError{" Unhandled primitive type: " +
393
+ std::to_string (kind)};
380
394
}
381
395
382
396
return makeType<Primitive>(type, primitiveKind);
0 commit comments