751 lines · plain
1%feature("docstring",2"Represents a member of a type."3) lldb::SBTypeMember;4 5%feature("docstring",6"Represents a member function of a type."7) lldb::SBTypeMemberFunction;8 9%feature("docstring",10"Represents a data type in lldb.11 12The actual characteristics of each type are defined by the semantics of the13programming language and the specific language implementation that was used14to compile the target program. See the language-specific notes in the15documentation of each method.16 17SBType instances can be obtained by a variety of methods.18`SBTarget.FindFirstType` and `SBModule.FindFirstType` can be used to create19`SBType` representations of types in executables/libraries with debug20information. For some languages such as C, C++ and Objective-C it is possible21to create new types by evaluating expressions that define a new type.22 23Note that most `SBType` properties are computed independently of any runtime24information so for dynamic languages the functionality can be very limited.25`SBValue` can be used to represent runtime values which then can be more26accurately queried for certain information such as byte size.27 28 29SBType supports the eq/ne operator. For example,::30 31 //main.cpp:32 33 class Task {34 public:35 int id;36 Task *next;37 Task(int i, Task *n):38 id(i),39 next(n)40 {}41 };42 43 int main (int argc, char const *argv[])44 {45 Task *task_head = new Task(-1, NULL);46 Task *task1 = new Task(1, NULL);47 Task *task2 = new Task(2, NULL);48 Task *task3 = new Task(3, NULL); // Orphaned.49 Task *task4 = new Task(4, NULL);50 Task *task5 = new Task(5, NULL);51 52 task_head->next = task1;53 task1->next = task2;54 task2->next = task4;55 task4->next = task5;56 57 int total = 0;58 Task *t = task_head;59 while (t != NULL) {60 if (t->id >= 0)61 ++total;62 t = t->next;63 }64 printf('We have a total number of %d tasks\\n', total);65 66 // This corresponds to an empty task list.67 Task *empty_task_head = new Task(-1, NULL);68 69 return 0; // Break at this line70 }71 72 # find_type.py:73 74 # Get the type 'Task'.75 task_type = target.FindFirstType('Task')76 self.assertTrue(task_type)77 78 # Get the variable 'task_head'.79 frame0.FindVariable('task_head')80 task_head_type = task_head.GetType()81 self.assertTrue(task_head_type.IsPointerType())82 83 # task_head_type is 'Task *'.84 task_pointer_type = task_type.GetPointerType()85 self.assertTrue(task_head_type == task_pointer_type)86 87 # Get the child mmember 'id' from 'task_head'.88 id = task_head.GetChildMemberWithName('id')89 id_type = id.GetType()90 91 # SBType.GetBasicType() takes an enum 'BasicType' (lldb-enumerations.h).92 int_type = id_type.GetBasicType(lldb.eBasicTypeInt)93 # id_type and int_type should be the same type!94 self.assertTrue(id_type == int_type)95 96") lldb::SBType;97 98%feature("docstring",99 "Returns the number of bytes a variable with the given types occupies in memory.100 101 Returns ``0`` if the size can't be determined.102 103 If a type occupies ``N`` bytes + ``M`` bits in memory, this function returns104 the rounded up amount of bytes (i.e., if ``M`` is ``0``,105 this function returns ``N`` and otherwise ``N + 1``).106 107 Language-specific behaviour:108 109 * C: The output is expected to match the value of ``sizeof(Type)``. If110 ``sizeof(Type)`` is not a valid expression for the given type, the111 function returns ``0``.112 * C++: Same as in C.113 * Objective-C: Same as in C. For Objective-C classes this always returns114 ``0`` as the actual size depends on runtime information.115 "116) lldb::SBType::GetByteSize;117 118%feature("docstring",119 "Returns true if this type is a pointer type.120 121 Language-specific behaviour:122 123 * C: Returns true for C pointer types (or typedefs of these types).124 * C++: Pointer types include the C pointer types as well as pointers to data125 mebers or member functions.126 * Objective-C: Pointer types include the C pointer types. ``id``, ``Class``127 and pointers to blocks are also considered pointer types.128 "129) lldb::SBType::IsPointerType;130 131%feature("docstring",132 "Returns true if this type is a reference type.133 134 Language-specific behaviour:135 136 * C: Returns false for all types.137 * C++: Both l-value and r-value references are considered reference types.138 * Objective-C: Returns false for all types.139 "140) lldb::SBType::IsReferenceType;141 142%feature("docstring",143 "Returns true if this type is a polymorphic type.144 145 Language-specific behaviour:146 147 * C: Returns false for all types.148 * C++: Returns true if the type is a class type that contains at least one149 virtual member function or if at least one of its base classes is150 considered a polymorphic type.151 * Objective-C: Returns false for all types.152 "153) lldb::SBType::IsPolymorphicClass;154 155%feature("docstring",156 "Returns true if this type is an array type.157 158 Language-specific behaviour:159 160 * C: Returns true if the types is an array type. This includes incomplete161 array types ``T[]`` and array types with integer (``T[1]``) or variable162 length (``T[some_variable]``). Pointer types are not considered arrays.163 * C++: Includes C's array types and dependent array types (i.e., array types164 in templates which size depends on template arguments).165 * Objective-C: Same as in C.166 "167) lldb::SBType::IsArrayType;168 169%feature("docstring",170 "Returns true if this type is a vector type.171 172 Language-specific behaviour:173 174 * C: Returns true if the types is a vector type created with175 GCC's ``vector_size`` or Clang's ``ext_vector_type`` feature.176 * C++: Same as in C.177 * Objective-C: Same as in C.178 "179) lldb::SBType::IsVectorType;180 181%feature("docstring",182 "Returns true if this type is a typedef.183 184 Language-specific behaviour:185 186 * C: Returns true if the type is a C typedef.187 * C++: Same as in C. Also treats type aliases as typedefs.188 * Objective-C: Same as in C.189 "190) lldb::SBType::IsTypedefType;191 192%feature("docstring",193 "Returns true if this type is an anonymous type.194 195 Language-specific behaviour:196 197 * C: Returns true for anonymous unions. Also returns true for198 anonymous structs (which are a GNU language extension).199 * C++: Same as in C.200 * Objective-C: Same as in C.201 "202) lldb::SBType::IsAnonymousType;203 204%feature("docstring",205 "Returns true if this type is a scoped enum.206 207 Language-specific behaviour:208 209 * C: Returns false for all types.210 * C++: Return true only for C++11 scoped enums.211 * Objective-C: Returns false for all types.212 "213) lldb::SBType::IsScopedEnumerationType;214 215%feature("docstring",216 "Returns true if this type is an aggregate type.217 218 Language-specific behaviour:219 220 * C: Returns true for struct values, arrays, and vectors.221 * C++: Same a C. Also includes class instances.222 * Objective-C: Same as C. Also includes class instances.223 "224) lldb::SBType::IsAggregateType;225 226%feature("docstring",227 "Returns a type that represents a pointer to this type.228 229 If the type system of the current language can't represent a pointer to this230 type or this type is invalid, an invalid `SBType` is returned.231 232 Language-specific behaviour:233 234 * C: Returns the pointer type of this type.235 * C++: Same as in C.236 * Objective-C: Same as in C.237 "238) lldb::SBType::GetPointerType;239 240%feature("docstring",241 "Returns the underlying pointee type.242 243 If this type is a pointer type as specified by `IsPointerType` then this244 returns the underlying type. If this is not a pointer type or an invalid245 `SBType` then this returns an invalid `SBType`.246 247 Language-specific behaviour:248 249 * C: Returns the underlying type for for C pointer types or typedefs of250 these types). For example, ``int *`` will return ``int``.251 * C++: Same as in C. Returns an `SBType` representation for data members/252 member functions in case the `SBType` is a pointer to data member or253 pointer to member function.254 * Objective-C: Same as in C. The pointee type of ``id`` and ``Class`` is255 an invalid `SBType`. The pointee type of pointers Objective-C types is an256 `SBType` for the non-pointer type of the respective type. For example,257 ``NSString *`` will return ``NSString`` as a pointee type.258 "259) lldb::SBType::GetPointeeType;260 261%feature("docstring",262 "Returns a type that represents a reference to this type.263 264 If the type system of the current language can't represent a reference to265 this type, an invalid `SBType` is returned.266 267 Language-specific behaviour:268 269 * C: Currently assumes the type system is C++ and returns an l-value270 reference type. For example, ``int`` will return ``int&``. This behavior271 is likely to change in the future and shouldn't be relied on.272 * C++: Same as in C.273 * Objective-C: Same as in C.274 "275) lldb::SBType::GetReferenceType;276 277%feature("docstring",278 "Returns the underlying type of a typedef.279 280 If this type is a typedef as designated by `IsTypedefType`, then the281 underlying type is being returned. Otherwise an invalid `SBType` is282 returned.283 284 Language-specific behaviour:285 286 * C: Returns the underlying type of a typedef type.287 * C++: Same as in C. For type aliases, the underlying type is returned.288 * Objective-C: Same as in C.289 "290) lldb::SBType::GetTypedefedType;291 292%feature("docstring",293 "Returns the underlying type of a reference type.294 295 If this type is a reference as designated by `IsReferenceType`, then the296 underlying type is being returned. Otherwise an invalid `SBType` is297 returned.298 299 Language-specific behaviour:300 301 * C: Always returns an invalid type.302 * C++: For l-value and r-value references the underlying type is returned.303 For example, ``int &`` will return ``int``.304 * Objective-C: Same as in C.305 "306) lldb::SBType::GetDereferencedType;307 308%feature("docstring",309 "Returns the unqualified version of this type.310 311 Language-specific behaviour:312 313 * C: If this type with any const or volatile specifier removed.314 * C++: Same as in C.315 * Objective-C: Same as in C.316 "317) lldb::SBType::GetUnqualifiedType;318 319%feature("docstring",320 "Returns the underlying integer type if this is an enumeration type.321 322 If this type is an invalid `SBType` or not an enumeration type an invalid323 `SBType` is returned.324 325 Language-specific behaviour:326 327 * C: Returns the underlying type for enums.328 * C++: Same as in C but also returns the underlying type for scoped enums.329 * Objective-C: Same as in C.330 "331) lldb::SBType::GetEnumerationIntegerType;332 333%feature("docstring",334 "Returns the array element type if this type is an array type.335 336 Otherwise returns an invalid `SBType` if this type is invalid or not an337 array type.338 339 Language-specific behaviour:340 341 * C: If this is an array type (see `IsArrayType`) such as ``T[]``, returns342 the element type.343 * C++: Same as in C.344 * Objective-C: Same as in C.345 346 See also `IsArrayType`.347 "348) lldb::SBType::GetArrayElementType;349 350%feature("docstring",351 "Returns the array type with the given constant size.352 353 Language-specific behaviour:354 355 * C: Returns a constant-size array ``T[size]`` for any non-void type.356 * C++: Same as in C.357 * Objective-C: Same as in C.358 359 See also `IsArrayType` and `GetArrayElementType`.360 "361) lldb::SBType::GetArrayType;362 363%feature("docstring",364 "Returns the vector element type if this type is a vector type.365 366 Otherwise returns an invalid `SBType` if this type is invalid or not a367 vector type.368 369 Language-specific behaviour:370 371 * C: If this is a vector type (see `IsVectorType`), returns the element372 type.373 * C++: Same as in C.374 * Objective-C: Same as in C.375 376 See also `IsVectorType`.377 "378) lldb::SBType::GetVectorElementType;379 380%feature("docstring",381 "Returns the `BasicType` value that is most appropriate to this type.382 383 Returns `eBasicTypeInvalid` if no appropriate `BasicType` was found or this384 type is invalid. See the `BasicType` documentation for the language-specific385 meaning of each `BasicType` value.386 387 **Overload behaviour:** When called with a `BasicType` parameter, the388 following behaviour applies:389 390 Returns the `SBType` that represents the passed `BasicType` value. Returns391 an invalid `SBType` if no fitting `SBType` could be created.392 393 Language-specific behaviour:394 395 * C: Returns the respective builtin type. Note that some types396 (e.g. ``__uint128_t``) might even be successfully created even if they are397 not available on the target platform. C++ and Objective-C specific types398 might also be created even if the target program is not written in C++ or399 Objective-C.400 * C++: Same as in C.401 * Objective-C: Same as in C.402 "403) lldb::SBType::GetBasicType;404 405%feature("docstring",406 "Returns the number of fields of this type.407 408 Returns ``0`` if this type does not have fields.409 410 Language-specific behaviour:411 412 * C: Returns the number of fields if the type is a struct. If the type413 contains an anonymous struct/union it only counts as a single field (even414 if the struct/union contains several fields).415 * C++: Returns the number of non-static fields if the type is a416 struct/class. If the type contains an anonymous struct/union it only417 counts as a single field (even if the struct/union contains several418 fields). The fields of any base classes are not included in the count.419 * Objective-C: Same as in C for structs. For Objective-C classes the number420 of ivars is returned.421 422 See also `GetFieldAtIndex`.423 "424) lldb::SBType::GetNumberOfFields;425 426%feature("docstring",427 "Returns the number of base/parent classes of this type.428 429 Returns ``0`` if this type doesn't have any base classes.430 431 Language-specific behaviour:432 433 * C: Returns always ``0``.434 * C++: The number of direct non-virtual base classes if this type is435 a class.436 * Objective-C: The number of super classes for Objective-C classes.437 As Objective-C doesn't have multiple inheritance this is usually returns 1438 except for NSObject.439 "440) lldb::SBType::GetNumberOfDirectBaseClasses;441 442%feature("docstring",443 "Returns the number of virtual base/parent classes of this type444 445 Returns ``0`` if this type doesn't have any base classes.446 447 Language-specific behaviour:448 449 * C: Returns always ``0``.450 * C++: The number of direct virtual base classes if this type is a451 class.452 * Objective-C: Returns always ``0``.453 "454) lldb::SBType::GetNumberOfVirtualBaseClasses;455 456%feature("docstring",457 "Returns the field at the given index.458 459 Returns an invalid `SBType` if the index is out of range or the current460 type doesn't have any fields.461 462 Language-specific behaviour:463 464 * C: Returns the field with the given index for struct types. Fields are465 ordered/indexed starting from ``0`` for the first field in a struct (as466 declared in the definition).467 * C++: Returns the non-static field with the given index for struct types.468 Fields are ordered/indexed starting from ``0`` for the first field in a469 struct (as declared in the definition).470 * Objective-C: Same as in C for structs. For Objective-C classes the ivar471 with the given index is returned. ivars are indexed starting from ``0``.472 "473) lldb::SBType::GetFieldAtIndex;474 475%feature("docstring",476 "Returns the direct base class as indexed by `GetNumberOfDirectBaseClasses`.477 478 Returns an invalid SBTypeMember if the index is invalid or this SBType is479 invalid.480 "481) lldb::SBType::GetDirectBaseClassAtIndex;482 483%feature("docstring",484 "Returns the virtual base class as indexed by485 `GetNumberOfVirtualBaseClasses`.486 487 Returns an invalid SBTypeMember if the index is invalid or this SBType is488 invalid.489 "490) lldb::SBType::GetVirtualBaseClassAtIndex;491 492%feature("docstring",493 "Returns the `SBModule` this `SBType` belongs to.494 495 Returns no `SBModule` if this type does not belong to any specific496 `SBModule` or this `SBType` is invalid. An invalid `SBModule` might also497 indicate that once came from an `SBModule` but LLDB could no longer498 determine the original module.499 "500) lldb::SBType::GetModule;501 502%feature("autodoc", "GetName() -> string") lldb::SBType::GetName;503 504%feature("docstring",505 "Returns the name of this type.506 507 Returns an empty string if an error occurred or this type is invalid.508 509 Use this function when trying to match a specific type by name in a script.510 The names returned by this function try to uniquely identify a name but511 conflicts can occur (for example, if a C++ program contains two different512 classes with the same name in different translation units. `GetName` can513 return the same name for both class types.)514 515 516 Language-specific behaviour:517 518 * C: The name of the type. For structs the ``struct`` prefix is omitted.519 * C++: Returns the qualified name of the type (including anonymous/inline520 namespaces and all template arguments).521 * Objective-C: Same as in C.522 "523) lldb::SBType::GetName;524 525%feature("autodoc", "GetDisplayTypeName() -> string") lldb::SBType::GetDisplayTypeName;526 527%feature("docstring",528 "Returns the name of this type in a user-friendly format.529 530 Returns an empty string if an error occurred or this type is invalid.531 532 Use this function when displaying a type name to the user.533 534 Language-specific behaviour:535 536 * C: Returns the type name. For structs the ``struct`` prefix is omitted.537 * C++: Returns the qualified name. Anonymous/inline namespaces are omitted.538 Template arguments that match their default value might also be hidden539 (this functionality depends on whether LLDB can determine the template's540 default arguments).541 * Objective-C: Same as in C.542 "543) lldb::SBType::GetDisplayTypeName;544 545%feature("autodoc", "GetTypeClass() -> TypeClass") lldb::SBType::GetTypeClass;546 547%feature("docstring",548 "Returns the `TypeClass` for this type.549 550 Returns an `eTypeClassInvalid` if this `SBType` is invalid.551 552 See `TypeClass` for the language-specific meaning of each `TypeClass` value.553 "554) lldb::SBType::GetTypeClass;555 556%feature("docstring",557 "Returns the number of template arguments of this type.558 559 Returns ``0`` if this type is not a template.560 561 Language-specific behaviour:562 563 * C: Always returns ``0``.564 * C++: If this type is a class template instantiation then this returns the565 number of template parameters that were used in this instantiation. This566 includes both explicit and implicit template parameters.567 * Objective-C: Always returns ``0``.568 "569) lldb::SBType::GetNumberOfTemplateArguments;570 571%feature("docstring",572 "Returns the type of the template argument with the given index.573 574 Returns an invalid `SBType` if there is no template argument with the given575 index or this type is not a template. The first template argument has the576 index ``0``.577 578 Language-specific behaviour:579 580 * C: Always returns an invalid SBType.581 * C++: If this type is a class template instantiation and the template582 parameter with the given index is a type template parameter, then this583 returns the type of that parameter. Otherwise returns an invalid `SBType`.584 * Objective-C: Always returns an invalid SBType.585 "586) lldb::SBType::GetTemplateArgumentType;587 588%feature("docstring",589 "Returns the kind of the template argument with the given index.590 591 Returns `eTemplateArgumentKindNull` if there is no template argument592 with the given index or this type is not a template. The first template593 argument has the index ``0``.594 595 Language-specific behaviour:596 597 * C: Always returns `eTemplateArgumentKindNull`.598 * C++: If this type is a class template instantiation then this returns599 the appropriate `TemplateArgument` value for the parameter with the given600 index. See the documentation of `TemplateArgument` for how certain C++601 template parameter kinds are mapped to `TemplateArgument` values.602 * Objective-C: Always returns `eTemplateArgumentKindNull`.603 "604) lldb::SBType::GetTemplateArgumentKind;605 606%feature("docstring",607 "Returns the return type if this type represents a function.608 609 Returns an invalid `SBType` if this type is not a function type or invalid.610 611 Language-specific behaviour:612 613 * C: For functions return the return type. Returns an invalid `SBType` if614 this type is a function pointer type.615 * C++: Same as in C for functions and instantiated template functions.616 Member functions are also considered functions. For functions that have617 their return type specified by a placeholder type specifier (``auto``)618 this returns the deduced return type.619 * Objective-C: Same as in C for functions. For Objective-C methods this620 returns the return type of the method.621 "622) lldb::SBType::GetFunctionReturnType;623 624%feature("docstring",625 "Returns the list of argument types if this type represents a function.626 627 Returns an invalid `SBType` if this type is not a function type or invalid.628 629 Language-specific behaviour:630 631 * C: For functions return the types of each parameter. Returns an invalid632 `SBType` if this type is a function pointer. For variadic functions this633 just returns the list of parameters before the variadic arguments.634 * C++: Same as in C for functions and instantiated template functions.635 Member functions are also considered functions.636 * Objective-C: Always returns an invalid SBType for Objective-C methods.637 "638) lldb::SBType::GetFunctionArgumentTypes;639 640%feature("docstring",641 "Returns the number of member functions of this type.642 643 Returns ``0`` if an error occurred or this type is invalid.644 645 Language-specific behaviour:646 647 * C: Always returns ``0``.648 * C++: If this type represents a struct/class, then the number of649 member functions (static and non-static) is returned. The count includes650 constructors and destructors (both explicit and implicit). Member651 functions of base classes are not included in the count.652 * Objective-C: If this type represents a struct/class, then the653 number of methods is returned. Methods in categories or super classes654 are not counted.655 "656) lldb::SBType::GetNumberOfMemberFunctions;657 658%feature("docstring",659 "Returns the member function of this type with the given index.660 661 Returns an invalid `SBTypeMemberFunction` if the index is invalid or this662 type is invalid.663 664 Language-specific behaviour:665 666 * C: Always returns an invalid `SBTypeMemberFunction`.667 * C++: Returns the member function or constructor/destructor with the given668 index.669 * Objective-C: Returns the method with the given index.670 671 See `GetNumberOfMemberFunctions` for what functions can be queried by this672 function.673 "674) lldb::SBType::GetMemberFunctionAtIndex;675 676%feature("docstring",677 "Returns true if the type is completely defined.678 679 Language-specific behaviour:680 681 * C: Returns false for struct types that were only forward declared in the682 type's `SBTarget`/`SBModule`. Otherwise returns true.683 * C++: Returns false for template/non-template struct/class types and684 scoped enums that were only forward declared inside the type's685 `SBTarget`/`SBModule`. Otherwise returns true.686 * Objective-C: Follows the same behavior as C for struct types. Objective-C687 classes are considered complete unless they were only forward declared via688 ``@class ClassName`` in the type's `SBTarget`/`SBModule`. Otherwise689 returns true.690 "691) lldb::SBType::IsTypeComplete;692 693%feature("docstring",694 "Returns the `TypeFlags` values for this type.695 696 See the respective `TypeFlags` values for what values can be set. Returns an697 integer in which each `TypeFlags` value is represented by a bit. Specific698 flags can be checked via Python's bitwise operators. For example, the699 `eTypeIsInteger` flag can be checked like this:700 701 ``(an_sb_type.GetTypeFlags() & lldb.eTypeIsInteger) != 0``702 703 If this type is invalid this returns ``0``.704 705 See the different values for `TypeFlags` for the language-specific meanings706 of each `TypeFlags` value.707 "708) lldb::SBType::GetTypeFlags;709 710%feature("docstring",711 "Searches for a directly nested type that has the provided name.712 713 Returns the type if it was found.714 Returns invalid type if nothing was found.715 "716) lldb::SBType::FindDirectNestedType;717 718%feature("docstring",719"Represents a list of :py:class:`SBType` s.720 721The FindTypes() method of :py:class:`SBTarget`/:py:class:`SBModule` returns a SBTypeList.722 723SBTypeList supports :py:class:`SBType` iteration. For example,724 725.. code-block:: cpp726 727 // main.cpp:728 729 class Task {730 public:731 int id;732 Task *next;733 Task(int i, Task *n):734 id(i),735 next(n)736 {}737 };738 739.. code-block:: python740 741 # find_type.py:742 743 # Get the type 'Task'.744 type_list = target.FindTypes('Task')745 self.assertTrue(len(type_list) == 1)746 # To illustrate the SBType iteration.747 for type in type_list:748 # do something with type749 750") lldb::SBTypeList;751