1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
|
//===-- SWIG Interface for SBType -------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
namespace lldb {
%feature("docstring",
"Represents a member of a type in lldb.
") SBTypeMember;
class SBTypeMember
{
public:
SBTypeMember ();
SBTypeMember (const lldb::SBTypeMember& rhs);
~SBTypeMember();
bool
IsValid() const;
const char *
GetName ();
lldb::SBType
GetType ();
uint64_t
GetOffsetInBytes();
uint64_t
GetOffsetInBits();
bool
IsBitfield();
uint32_t
GetBitfieldSizeInBits();
%pythoncode %{
__swig_getmethods__["name"] = GetName
if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this member as a string.''')
__swig_getmethods__["type"] = GetType
if _newclass: type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the type (lldb.SBType) for this member.''')
__swig_getmethods__["byte_offset"] = GetOffsetInBytes
if _newclass: byte_offset = property(GetOffsetInBytes, None, doc='''A read only property that returns offset in bytes for this member as an integer.''')
__swig_getmethods__["bit_offset"] = GetOffsetInBits
if _newclass: bit_offset = property(GetOffsetInBits, None, doc='''A read only property that returns offset in bits for this member as an integer.''')
__swig_getmethods__["is_bitfield"] = IsBitfield
if _newclass: is_bitfield = property(IsBitfield, None, doc='''A read only property that returns true if this member is a bitfield.''')
__swig_getmethods__["bitfield_bit_size"] = GetBitfieldSizeInBits
if _newclass: bitfield_bit_size = property(GetBitfieldSizeInBits, None, doc='''A read only property that returns the bitfield size in bits for this member as an integer, or zero if this member is not a bitfield.''')
%}
protected:
std::unique_ptr<lldb_private::TypeMemberImpl> m_opaque_ap;
};
class SBTypeMemberFunction
{
public:
SBTypeMemberFunction ();
SBTypeMemberFunction (const lldb::SBTypeMemberFunction& rhs);
~SBTypeMemberFunction();
bool
IsValid() const;
const char *
GetName ();
const char *
GetDemangledName ();
const char *
GetMangledName ();
lldb::SBType
GetType ();
lldb::SBType
GetReturnType ();
uint32_t
GetNumberOfArguments ();
lldb::SBType
GetArgumentTypeAtIndex (uint32_t);
lldb::MemberFunctionKind
GetKind();
bool
GetDescription (lldb::SBStream &description,
lldb::DescriptionLevel description_level);
protected:
lldb::TypeMemberFunctionImplSP m_opaque_sp;
};
%feature("docstring",
"Represents a data type in lldb. The FindFirstType() method of SBTarget/SBModule
returns a SBType.
SBType supports the eq/ne operator. For example,
main.cpp:
class Task {
public:
int id;
Task *next;
Task(int i, Task *n):
id(i),
next(n)
{}
};
int main (int argc, char const *argv[])
{
Task *task_head = new Task(-1, NULL);
Task *task1 = new Task(1, NULL);
Task *task2 = new Task(2, NULL);
Task *task3 = new Task(3, NULL); // Orphaned.
Task *task4 = new Task(4, NULL);
Task *task5 = new Task(5, NULL);
task_head->next = task1;
task1->next = task2;
task2->next = task4;
task4->next = task5;
int total = 0;
Task *t = task_head;
while (t != NULL) {
if (t->id >= 0)
++total;
t = t->next;
}
printf('We have a total number of %d tasks\\n', total);
// This corresponds to an empty task list.
Task *empty_task_head = new Task(-1, NULL);
return 0; // Break at this line
}
find_type.py:
# Get the type 'Task'.
task_type = target.FindFirstType('Task')
self.assertTrue(task_type)
# Get the variable 'task_head'.
frame0.FindVariable('task_head')
task_head_type = task_head.GetType()
self.assertTrue(task_head_type.IsPointerType())
# task_head_type is 'Task *'.
task_pointer_type = task_type.GetPointerType()
self.assertTrue(task_head_type == task_pointer_type)
# Get the child mmember 'id' from 'task_head'.
id = task_head.GetChildMemberWithName('id')
id_type = id.GetType()
# SBType.GetBasicType() takes an enum 'BasicType' (lldb-enumerations.h).
int_type = id_type.GetBasicType(lldb.eBasicTypeInt)
# id_type and int_type should be the same type!
self.assertTrue(id_type == int_type)
...
") SBType;
class SBType
{
public:
SBType ();
SBType (const lldb::SBType &rhs);
~SBType ();
bool
IsValid();
uint64_t
GetByteSize();
bool
IsPointerType();
bool
IsReferenceType();
bool
IsFunctionType ();
bool
IsPolymorphicClass ();
bool
IsArrayType ();
bool
IsVectorType ();
bool
IsTypedefType ();
bool
IsAnonymousType ();
lldb::SBType
GetPointerType();
lldb::SBType
GetPointeeType();
lldb::SBType
GetReferenceType();
lldb::SBType
SBType::GetTypedefedType();
lldb::SBType
GetDereferencedType();
lldb::SBType
GetUnqualifiedType();
lldb::SBType
GetCanonicalType();
lldb::SBType
GetArrayElementType ();
lldb::SBType
GetArrayType (uint64_t size);
lldb::SBType
GetVectorElementType ();
lldb::BasicType
GetBasicType();
lldb::SBType
GetBasicType (lldb::BasicType type);
uint32_t
GetNumberOfFields ();
uint32_t
GetNumberOfDirectBaseClasses ();
uint32_t
GetNumberOfVirtualBaseClasses ();
lldb::SBTypeMember
GetFieldAtIndex (uint32_t idx);
lldb::SBTypeMember
GetDirectBaseClassAtIndex (uint32_t idx);
lldb::SBTypeMember
GetVirtualBaseClassAtIndex (uint32_t idx);
lldb::SBTypeEnumMemberList
GetEnumMembers();
const char*
GetName();
const char *
GetDisplayTypeName ();
lldb::TypeClass
GetTypeClass ();
uint32_t
GetNumberOfTemplateArguments ();
lldb::SBType
GetTemplateArgumentType (uint32_t idx);
lldb::TemplateArgumentKind
GetTemplateArgumentKind (uint32_t idx);
lldb::SBType
GetFunctionReturnType ();
lldb::SBTypeList
GetFunctionArgumentTypes ();
uint32_t
GetNumberOfMemberFunctions ();
lldb::SBTypeMemberFunction
GetMemberFunctionAtIndex (uint32_t idx);
bool
IsTypeComplete ();
uint32_t
GetTypeFlags ();
%pythoncode %{
def template_arg_array(self):
num_args = self.num_template_args
if num_args:
template_args = []
for i in range(num_args):
template_args.append(self.GetTemplateArgumentType(i))
return template_args
return None
__swig_getmethods__["name"] = GetName
if _newclass: name = property(GetName, None, doc='''A read only property that returns the name for this type as a string.''')
__swig_getmethods__["size"] = GetByteSize
if _newclass: size = property(GetByteSize, None, doc='''A read only property that returns size in bytes for this type as an integer.''')
__swig_getmethods__["is_pointer"] = IsPointerType
if _newclass: is_pointer = property(IsPointerType, None, doc='''A read only property that returns a boolean value that indicates if this type is a pointer type.''')
__swig_getmethods__["is_reference"] = IsReferenceType
if _newclass: is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a reference type.''')
__swig_getmethods__["is_function"] = IsFunctionType
if _newclass: is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a function type.''')
__swig_getmethods__["num_fields"] = GetNumberOfFields
if _newclass: num_fields = property(GetNumberOfFields, None, doc='''A read only property that returns number of fields in this type as an integer.''')
__swig_getmethods__["num_bases"] = GetNumberOfDirectBaseClasses
if _newclass: num_bases = property(GetNumberOfDirectBaseClasses, None, doc='''A read only property that returns number of direct base classes in this type as an integer.''')
__swig_getmethods__["num_vbases"] = GetNumberOfVirtualBaseClasses
if _newclass: num_vbases = property(GetNumberOfVirtualBaseClasses, None, doc='''A read only property that returns number of virtual base classes in this type as an integer.''')
__swig_getmethods__["num_template_args"] = GetNumberOfTemplateArguments
if _newclass: num_template_args = property(GetNumberOfTemplateArguments, None, doc='''A read only property that returns number of template arguments in this type as an integer.''')
__swig_getmethods__["template_args"] = template_arg_array
if _newclass: template_args = property(template_arg_array, None, doc='''A read only property that returns a list() of lldb.SBType objects that represent all template arguments in this type.''')
__swig_getmethods__["type"] = GetTypeClass
if _newclass: type = property(GetTypeClass, None, doc='''A read only property that returns an lldb enumeration value (see enumerations that start with "lldb.eTypeClass") that represents a classification for this type.''')
__swig_getmethods__["is_complete"] = IsTypeComplete
if _newclass: is_complete = property(IsTypeComplete, None, doc='''A read only property that returns a boolean value that indicates if this type is a complete type (True) or a forward declaration (False).''')
def get_bases_array(self):
'''An accessor function that returns a list() that contains all direct base classes in a lldb.SBType object.'''
bases = []
for idx in range(self.GetNumberOfDirectBaseClasses()):
bases.append(self.GetDirectBaseClassAtIndex(idx))
return bases
def get_vbases_array(self):
'''An accessor function that returns a list() that contains all fields in a lldb.SBType object.'''
vbases = []
for idx in range(self.GetNumberOfVirtualBaseClasses()):
vbases.append(self.GetVirtualBaseClassAtIndex(idx))
return vbases
def get_fields_array(self):
'''An accessor function that returns a list() that contains all fields in a lldb.SBType object.'''
fields = []
for idx in range(self.GetNumberOfFields()):
fields.append(self.GetFieldAtIndex(idx))
return fields
def get_members_array(self):
'''An accessor function that returns a list() that contains all members (base classes and fields) in a lldb.SBType object in ascending bit offset order.'''
members = []
bases = self.get_bases_array()
fields = self.get_fields_array()
vbases = self.get_vbases_array()
for base in bases:
bit_offset = base.bit_offset
added = False
for idx, member in enumerate(members):
if member.bit_offset > bit_offset:
members.insert(idx, base)
added = True
break
if not added:
members.append(base)
for vbase in vbases:
bit_offset = vbase.bit_offset
added = False
for idx, member in enumerate(members):
if member.bit_offset > bit_offset:
members.insert(idx, vbase)
added = True
break
if not added:
members.append(vbase)
for field in fields:
bit_offset = field.bit_offset
added = False
for idx, member in enumerate(members):
if member.bit_offset > bit_offset:
members.insert(idx, field)
added = True
break
if not added:
members.append(field)
return members
def get_enum_members_array(self):
'''An accessor function that returns a list() that contains all enum members in an lldb.SBType object.'''
enum_members_list = []
sb_enum_members = self.GetEnumMembers()
for idx in range(sb_enum_members.GetSize()):
enum_members_list.append(sb_enum_members.GetTypeEnumMemberAtIndex(idx))
return enum_members_list
__swig_getmethods__["bases"] = get_bases_array
if _newclass: bases = property(get_bases_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the direct base classes for this type.''')
__swig_getmethods__["vbases"] = get_vbases_array
if _newclass: vbases = property(get_vbases_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the virtual base classes for this type.''')
__swig_getmethods__["fields"] = get_fields_array
if _newclass: fields = property(get_fields_array, None, doc='''A read only property that returns a list() of lldb.SBTypeMember objects that represent all of the fields for this type.''')
__swig_getmethods__["members"] = get_members_array
if _newclass: members = property(get_members_array, None, doc='''A read only property that returns a list() of all lldb.SBTypeMember objects that represent all of the base classes, virtual base classes and fields for this type in ascending bit offset order.''')
__swig_getmethods__["enum_members"] = get_enum_members_array
if _newclass: enum_members = property(get_enum_members_array, None, doc='''A read only property that returns a list() of all lldb.SBTypeEnumMember objects that represent the enum members for this type.''')
%}
};
%feature("docstring",
"Represents a list of SBTypes. The FindTypes() method of SBTarget/SBModule
returns a SBTypeList.
SBTypeList supports SBType iteration. For example,
main.cpp:
class Task {
public:
int id;
Task *next;
Task(int i, Task *n):
id(i),
next(n)
{}
};
...
find_type.py:
# Get the type 'Task'.
type_list = target.FindTypes('Task')
self.assertTrue(len(type_list) == 1)
# To illustrate the SBType iteration.
for type in type_list:
# do something with type
...
") SBTypeList;
class SBTypeList
{
public:
SBTypeList();
bool
IsValid();
void
Append (lldb::SBType type);
lldb::SBType
GetTypeAtIndex (uint32_t index);
uint32_t
GetSize();
~SBTypeList();
};
} // namespace lldb
|