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));
@@ -152,10 +156,11 @@ Class& LLDBParser::enumerateClass(lldb::SBType& type) {
152
156
kind = Class::Kind::Union;
153
157
break ;
154
158
default :
155
- throw LLDBParserError{" Invalid type class for compound type: " + std::to_string (typeClass)};
159
+ throw LLDBParserError{" Invalid type class for compound type: " +
160
+ std::to_string (typeClass)};
156
161
}
157
162
158
- auto & c = makeType<Class>(type, kind, displayName, name, size, virtuality);
163
+ auto & c = makeType<Class>(type, kind, displayName, name, size, virtuality);
159
164
160
165
enumerateClassTemplateParams (type, c.templateParams );
161
166
enumerateClassParents (type, c.parents );
@@ -165,7 +170,8 @@ Class& LLDBParser::enumerateClass(lldb::SBType& type) {
165
170
return c;
166
171
}
167
172
168
- void LLDBParser::enumerateClassTemplateParams (lldb::SBType &type, std::vector<TemplateParam>& params) {
173
+ void LLDBParser::enumerateClassTemplateParams (
174
+ lldb::SBType& type, std::vector<TemplateParam>& params) {
169
175
assert (params.empty ());
170
176
params.reserve (type.GetNumberOfTemplateArguments ());
171
177
@@ -180,13 +186,15 @@ void LLDBParser::enumerateTemplateParam(lldb::SBType& /*type*/,
180
186
uint32_t /* i*/ ,
181
187
std::vector<TemplateParam>& params) {
182
188
QualifierSet qualifiers;
183
- qualifiers[Qualifier::Const] = param.GetName () != param.GetUnqualifiedType ().GetName (); // TODO: Wonky as hell :/
189
+ qualifiers[Qualifier::Const] = // TODO: Wonky as hell :/
190
+ param.GetName () != param.GetUnqualifiedType ().GetName ();
184
191
auto & paramType = enumerateType (param);
185
192
186
193
params.emplace_back (paramType, qualifiers);
187
194
}
188
195
189
- void LLDBParser::enumerateClassParents (lldb::SBType& type, std::vector<Parent>& parents) {
196
+ void LLDBParser::enumerateClassParents (lldb::SBType& type,
197
+ std::vector<Parent>& parents) {
190
198
assert (parents.empty ());
191
199
parents.reserve (type.GetNumberOfDirectBaseClasses ());
192
200
@@ -198,15 +206,16 @@ void LLDBParser::enumerateClassParents(lldb::SBType& type, std::vector<Parent>&
198
206
}
199
207
}
200
208
201
- void LLDBParser::enumerateClassMembers (lldb::SBType& type, std::vector<Member>& members) {
209
+ void LLDBParser::enumerateClassMembers (lldb::SBType& type,
210
+ std::vector<Member>& members) {
202
211
assert (members.empty ());
203
212
members.reserve (type.GetNumberOfFields ());
204
213
205
214
/* TODO: We are missing the _vptr */
206
215
for (uint32_t i = 0 ; i < type.GetNumberOfFields (); i++) {
207
216
auto field = type.GetFieldAtIndex (i);
208
217
if (field.GetName () == nullptr )
209
- continue ; // Skip anonymous fields (TODO: Why?)
218
+ continue ; // Skip anonymous fields (TODO: Why?)
210
219
auto fieldName = field.GetName ();
211
220
auto fieldType = field.GetType ();
212
221
auto bitFieldSize = field.GetBitfieldSizeInBits ();
@@ -221,7 +230,8 @@ void LLDBParser::enumerateClassMembers(lldb::SBType& type, std::vector<Member>&
221
230
});
222
231
}
223
232
224
- void LLDBParser::enumerateClassFunctions (lldb::SBType &type, std::vector<Function>& functions) {
233
+ void LLDBParser::enumerateClassFunctions (lldb::SBType& type,
234
+ std::vector<Function>& functions) {
225
235
assert (functions.empty ());
226
236
functions.reserve (type.GetNumberOfMemberFunctions ());
227
237
@@ -235,7 +245,7 @@ void LLDBParser::enumerateClassFunctions(lldb::SBType &type, std::vector<Functio
235
245
}
236
246
237
247
Enum& LLDBParser::enumerateEnum (lldb::SBType& type) {
238
- const char * typeName = type.GetName ();
248
+ const char * typeName = type.GetName ();
239
249
std::string name = typeName ? typeName : " " ;
240
250
uint64_t size = type.GetByteSize ();
241
251
@@ -260,9 +270,9 @@ Typedef& LLDBParser::enumerateTypedef(lldb::SBType& type) {
260
270
}
261
271
262
272
Type& LLDBParser::enumeratePointer (lldb::SBType& type) {
263
- if (!chasePointer ()) {
264
- return makeType<Primitive>(type, Primitive::Kind::StubbedPointer);
265
- }
273
+ if (!chasePointer ()) {
274
+ return makeType<Primitive>(type, Primitive::Kind::StubbedPointer);
275
+ }
266
276
267
277
lldb::SBType pointeeType;
268
278
switch (auto kind = type.GetTypeClass ()) {
@@ -273,11 +283,12 @@ Type& LLDBParser::enumeratePointer(lldb::SBType& type) {
273
283
pointeeType = type.GetDereferencedType ();
274
284
break ;
275
285
default :
276
- throw LLDBParserError{" Invalid type class for pointer type: " + std::to_string (kind)};
286
+ throw LLDBParserError{" Invalid type class for pointer type: " +
287
+ std::to_string (kind)};
277
288
}
278
289
279
290
if (pointeeType.IsFunctionType ()) {
280
- return makeType<Primitive>(type, Primitive::Kind::StubbedPointer);
291
+ return makeType<Primitive>(type, Primitive::Kind::StubbedPointer);
281
292
}
282
293
283
294
Type& t = enumerateType (pointeeType);
@@ -291,7 +302,8 @@ bool LLDBParser::chasePointer() const {
291
302
return options_.chaseRawPointers ;
292
303
}
293
304
294
- Primitive::Kind LLDBParser::primitiveIntKind (lldb::SBType& type, bool is_signed) {
305
+ Primitive::Kind LLDBParser::primitiveIntKind (lldb::SBType& type,
306
+ bool is_signed) {
295
307
switch (auto size = type.GetByteSize ()) {
296
308
case 1 :
297
309
return is_signed ? Primitive::Kind::Int8 : Primitive::Kind::UInt8;
@@ -376,7 +388,8 @@ Primitive& LLDBParser::enumeratePrimitive(lldb::SBType& type) {
376
388
case lldb::eBasicTypeObjCSel:
377
389
case lldb::eBasicTypeOther:
378
390
default :
379
- throw LLDBParserError{" Unhandled primitive type: " + std::to_string (kind)};
391
+ throw LLDBParserError{" Unhandled primitive type: " +
392
+ std::to_string (kind)};
380
393
}
381
394
382
395
return makeType<Primitive>(type, primitiveKind);
0 commit comments