1 //===-- SWIG Interface for SBType -------------------------------*- C++ -*-===// 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 namespace lldb { 10 11 %feature("docstring", 12 "Represents a member of a type.") SBTypeMember; 13 14 class SBTypeMember 15 { 16 public: 17 SBTypeMember (); 18 19 SBTypeMember (const lldb::SBTypeMember& rhs); 20 21 ~SBTypeMember(); 22 23 bool 24 IsValid() const; 25 26 explicit operator bool() const; 27 28 const char * 29 GetName (); 30 31 lldb::SBType 32 GetType (); 33 34 uint64_t 35 GetOffsetInBytes(); 36 37 uint64_t 38 GetOffsetInBits(); 39 40 bool 41 IsBitfield(); 42 43 uint32_t 44 GetBitfieldSizeInBits(); 45 46 STRING_EXTENSION_LEVEL(SBTypeMember, lldb::eDescriptionLevelBrief) 47 48 #ifdef SWIGPYTHON 49 %pythoncode %{ 50 name = property(GetName, None, doc='''A read only property that returns the name for this member as a string.''') 51 type = property(GetType, None, doc='''A read only property that returns an lldb object that represents the type (lldb.SBType) for this member.''') 52 byte_offset = property(GetOffsetInBytes, None, doc='''A read only property that returns offset in bytes for this member as an integer.''') 53 bit_offset = property(GetOffsetInBits, None, doc='''A read only property that returns offset in bits for this member as an integer.''') 54 is_bitfield = property(IsBitfield, None, doc='''A read only property that returns true if this member is a bitfield.''') 55 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.''') 56 %} 57 #endif 58 59 protected: 60 std::unique_ptr<lldb_private::TypeMemberImpl> m_opaque_ap; 61 }; 62 63 %feature("docstring", 64 "Represents a member function of a type." 65 ) SBTypeMemberFunction; 66 class SBTypeMemberFunction 67 { 68 public: 69 SBTypeMemberFunction (); 70 71 SBTypeMemberFunction (const lldb::SBTypeMemberFunction& rhs); 72 73 ~SBTypeMemberFunction(); 74 75 bool 76 IsValid() const; 77 78 explicit operator bool() const; 79 80 const char * 81 GetName (); 82 83 const char * 84 GetDemangledName (); 85 86 const char * 87 GetMangledName (); 88 89 lldb::SBType 90 GetType (); 91 92 lldb::SBType 93 GetReturnType (); 94 95 uint32_t 96 GetNumberOfArguments (); 97 98 lldb::SBType 99 GetArgumentTypeAtIndex (uint32_t); 100 101 lldb::MemberFunctionKind 102 GetKind(); 103 104 bool 105 GetDescription (lldb::SBStream &description, 106 lldb::DescriptionLevel description_level); 107 108 STRING_EXTENSION_LEVEL(SBTypeMemberFunction, lldb::eDescriptionLevelBrief) 109 protected: 110 lldb::TypeMemberFunctionImplSP m_opaque_sp; 111 }; 112 113 %feature("docstring", 114 "Represents a data type in lldb. 115 116 The actual characteristics of each type are defined by the semantics of the 117 programming language and the specific language implementation that was used 118 to compile the target program. See the language-specific notes in the 119 documentation of each method. 120 121 SBType instances can be obtained by a variety of methods. 122 `SBTarget.FindFirstType` and `SBModule.FindFirstType` can be used to create 123 `SBType` representations of types in executables/libraries with debug 124 information. For some languages such as C, C++ and Objective-C it is possible 125 to create new types by evaluating expressions that define a new type. 126 127 Note that most `SBType` properties are computed independently of any runtime 128 information so for dynamic languages the functionality can be very limited. 129 `SBValue` can be used to represent runtime values which then can be more 130 accurately queried for certain information such as byte size. 131 132 133 SBType supports the eq/ne operator. For example,:: 134 135 //main.cpp: 136 137 class Task { 138 public: 139 int id; 140 Task *next; 141 Task(int i, Task *n): 142 id(i), 143 next(n) 144 {} 145 }; 146 147 int main (int argc, char const *argv[]) 148 { 149 Task *task_head = new Task(-1, NULL); 150 Task *task1 = new Task(1, NULL); 151 Task *task2 = new Task(2, NULL); 152 Task *task3 = new Task(3, NULL); // Orphaned. 153 Task *task4 = new Task(4, NULL); 154 Task *task5 = new Task(5, NULL); 155 156 task_head->next = task1; 157 task1->next = task2; 158 task2->next = task4; 159 task4->next = task5; 160 161 int total = 0; 162 Task *t = task_head; 163 while (t != NULL) { 164 if (t->id >= 0) 165 ++total; 166 t = t->next; 167 } 168 printf('We have a total number of %d tasks\\n', total); 169 170 // This corresponds to an empty task list. 171 Task *empty_task_head = new Task(-1, NULL); 172 173 return 0; // Break at this line 174 } 175 176 # find_type.py: 177 178 # Get the type 'Task'. 179 task_type = target.FindFirstType('Task') 180 self.assertTrue(task_type) 181 182 # Get the variable 'task_head'. 183 frame0.FindVariable('task_head') 184 task_head_type = task_head.GetType() 185 self.assertTrue(task_head_type.IsPointerType()) 186 187 # task_head_type is 'Task *'. 188 task_pointer_type = task_type.GetPointerType() 189 self.assertTrue(task_head_type == task_pointer_type) 190 191 # Get the child mmember 'id' from 'task_head'. 192 id = task_head.GetChildMemberWithName('id') 193 id_type = id.GetType() 194 195 # SBType.GetBasicType() takes an enum 'BasicType' (lldb-enumerations.h). 196 int_type = id_type.GetBasicType(lldb.eBasicTypeInt) 197 # id_type and int_type should be the same type! 198 self.assertTrue(id_type == int_type) 199 200 ") SBType; 201 class SBType 202 { 203 public: 204 SBType (); 205 206 SBType (const lldb::SBType &rhs); 207 208 ~SBType (); 209 210 bool 211 IsValid(); 212 213 explicit operator bool() const; 214 215 216 %feature("docstring", 217 "Returns the number of bytes a variable with the given types occupies in memory. 218 219 Returns ``0`` if the size can't be determined. 220 221 If a type occupies ``N`` bytes + ``M`` bits in memory, this function returns 222 the rounded up amount of bytes (i.e., if ``M`` is ``0``, 223 this function returns ``N`` and otherwise ``N + 1``). 224 225 Language-specific behaviour: 226 227 * C: The output is expected to match the value of ``sizeof(Type)``. If 228 ``sizeof(Type)`` is not a valid expression for the given type, the 229 function returns ``0``. 230 * C++: Same as in C. 231 * Objective-C: Same as in C. For Objective-C classes this always returns 232 `0`` as the actual size depends on runtime information. 233 ") GetByteSize; 234 uint64_t 235 GetByteSize(); 236 237 238 %feature("docstring", 239 "Returns true if this type is a pointer type. 240 241 Language-specific behaviour: 242 243 * C: Returns true for C pointer types (or typedefs of these types). 244 * C++: Pointer types include the C pointer types as well as pointers to data 245 mebers or member functions. 246 * Objective-C: Pointer types include the C pointer types. ``id``, ``Class`` 247 and pointers to blocks are also considered pointer types. 248 ") IsPointerType; 249 bool 250 IsPointerType(); 251 252 %feature("docstring", 253 "Returns true if this type is a reference type. 254 255 Language-specific behaviour: 256 257 * C: Returns false for all types. 258 * C++: Both l-value and r-value references are considered reference types. 259 * Objective-C: Returns false for all types. 260 ") IsReferenceType; 261 bool 262 IsReferenceType(); 263 264 %feature("docstring", 265 "Returns true if this type is a function type. 266 267 Language-specific behaviour: 268 269 * C: Returns true for types that represent functions. Note that function 270 pointers are not function types (but their `GetPointeeType()` are function 271 types). 272 * C++: Same as in C. 273 * Objective-C: Returns false for all types. 274 ") IsPolymorphicClass; 275 bool 276 IsFunctionType (); 277 278 %feature("docstring", 279 "Returns true if this type is a polymorphic type. 280 281 Language-specific behaviour: 282 283 * C: Returns false for all types. 284 * C++: Returns true if the type is a class type that contains at least one 285 virtual member function or if at least one of its base classes is 286 considered a polymorphic type. 287 * Objective-C: Returns false for all types. 288 ") IsPolymorphicClass; 289 bool 290 IsPolymorphicClass (); 291 292 %feature("docstring", 293 "Returns true if this type is an array type. 294 295 Language-specific behaviour: 296 297 * C: Returns true if the types is an array type. This includes incomplete 298 array types ``T[]`` and array types with integer (``T[1]``) or variable 299 length (``T[some_variable]``). Pointer types are not considered arrays. 300 * C++: Includes C's array types and dependent array types (i.e., array types 301 in templates which size depends on template arguments). 302 * Objective-C: Same as in C. 303 ") IsArrayType; 304 bool 305 IsArrayType (); 306 307 %feature("docstring", 308 "Returns true if this type is a vector type. 309 310 Language-specific behaviour: 311 312 * C: Returns true if the types is a vector type created with 313 GCC's ``vector_size`` or Clang's ``ext_vector_type`` feature. 314 * C++: Same as in C. 315 * Objective-C: Same as in C. 316 ") IsVectorType; 317 bool 318 IsVectorType (); 319 320 %feature("docstring", 321 "Returns true if this type is a typedef. 322 323 Language-specific behaviour: 324 325 * C: Returns true if the type is a C typedef. 326 * C++: Same as in C. Also treats type aliases as typedefs. 327 * Objective-C: Same as in C. 328 ") IsTypedefType; 329 bool 330 IsTypedefType (); 331 332 %feature("docstring", 333 "Returns true if this type is an anonymous type. 334 335 Language-specific behaviour: 336 337 * C: Returns true for anonymous unions. Also returns true for 338 anonymous structs (which are a GNU language extension). 339 * C++: Same as in C. 340 * Objective-C: Same as in C. 341 ") IsAnonymousType; 342 bool 343 IsAnonymousType (); 344 345 %feature("docstring", 346 "Returns true if this type is a scoped enum. 347 348 Language-specific behaviour: 349 350 * C: Returns false for all types. 351 * C++: Return true only for C++11 scoped enums. 352 * Objective-C: Returns false for all types. 353 ") IsScopedEnumerationType; 354 bool 355 IsScopedEnumerationType (); 356 357 %feature("docstring", 358 "Returns a type that represents a pointer to this type. 359 360 If the type system of the current language can't represent a pointer to this 361 type or this type is invalid, an invalid `SBType` is returned. 362 363 Language-specific behaviour: 364 365 * C: Returns the pointer type of this type. 366 * C++: Same as in C. 367 * Objective-C: Same as in C. 368 ") GetPointerType; 369 lldb::SBType 370 GetPointerType(); 371 372 %feature("docstring", 373 "Returns the underlying pointee type. 374 375 If this type is a pointer type as specified by `IsPointerType` then this 376 returns the underlying type. If this is not a pointer type or an invalid 377 `SBType` then this returns an invalid `SBType`. 378 379 Language-specific behaviour: 380 381 * C: Returns the underlying type for for C pointer types or typedefs of 382 these types). For example, ``int *`` will return ``int``. 383 * C++: Same as in C. Returns an `SBType` representation for data members/ 384 member functions in case the `SBType` is a pointer to data member or 385 pointer to member function. 386 * Objective-C: Same as in C. The pointee type of ``id`` and ``Class`` is 387 an invalid `SBType`. The pointee type of pointers Objective-C types is an 388 `SBType` for the non-pointer type of the respective type. For example, 389 ``NSString *`` will return ``NSString`` as a pointee type. 390 ") GetPointeeType; 391 lldb::SBType 392 GetPointeeType(); 393 394 %feature("docstring", 395 "Returns a type that represents a reference to this type. 396 397 If the type system of the current language can't represent a reference to 398 this type, an invalid `SBType` is returned. 399 400 Language-specific behaviour: 401 402 * C: Currently assumes the type system is C++ and returns an l-value 403 reference type. For example, ``int`` will return ``int&``. This behavior 404 is likely to change in the future and shouldn't be relied on. 405 * C++: Same as in C. 406 * Objective-C: Same as in C. 407 ") GetReferenceType; 408 lldb::SBType 409 GetReferenceType(); 410 411 %feature("docstring", 412 "Returns the underlying type of a typedef. 413 414 If this type is a typedef as designated by `IsTypedefType`, then the 415 underlying type is being returned. Otherwise an invalid `SBType` is 416 returned. 417 418 Language-specific behaviour: 419 420 * C: Returns the underlying type of a typedef type. 421 * C++: Same as in C. For type aliases, the underlying type is returned. 422 * Objective-C: Same as in C. 423 ") GetTypedefedType; 424 lldb::SBType 425 SBType::GetTypedefedType(); 426 427 %feature("docstring", 428 "Returns the underlying type of a reference type. 429 430 If this type is a reference as designated by `IsReferenceType`, then the 431 underlying type is being returned. Otherwise an invalid `SBType` is 432 returned. 433 434 Language-specific behaviour: 435 436 * C: Always returns an invalid type. 437 * C++: For l-value and r-value references the underlying type is returned. 438 For example, ``int &`` will return ``int``. 439 * Objective-C: Same as in C. 440 ") GetDereferencedType; 441 lldb::SBType 442 GetDereferencedType(); 443 444 %feature("docstring", 445 "Returns the unqualified version of this type. 446 447 Language-specific behaviour: 448 449 * C: If this type with any const or volatile specifier removed. 450 * C++: Same as in C. 451 * Objective-C: Same as in C. 452 ") GetUnqualifiedType; 453 lldb::SBType 454 GetUnqualifiedType(); 455 456 lldb::SBType 457 GetCanonicalType(); 458 459 %feature("docstring", 460 "Returns the underlying integer type if this is an enumeration type. 461 462 If this type is an invalid `SBType` or not an enumeration type an invalid 463 `SBType` is returned. 464 465 Language-specific behaviour: 466 467 * C: Returns the underlying type for enums. 468 * C++: Same as in C but also returns the underlying type for scoped enums. 469 * Objective-C: Same as in C. 470 ") GetEnumerationIntegerType; 471 lldb::SBType 472 GetEnumerationIntegerType(); 473 474 %feature("docstring", 475 "Returns the array element type if this type is an array type. 476 477 Otherwise returns an invalid `SBType` if this type is invalid or not an 478 array type. 479 480 Language-specific behaviour: 481 482 * C: If this is an array type (see `IsArrayType`) such as ``T[]``, returns 483 the element type. 484 * C++: Same as in C. 485 * Objective-C: Same as in C. 486 487 See also `IsArrayType`. 488 ") GetArrayElementType; 489 lldb::SBType 490 GetArrayElementType (); 491 492 %feature("docstring", 493 "Returns the array type with the given constant size. 494 495 Language-specific behaviour: 496 497 * C: Returns a constant-size array `T[size]` for any non-void type. 498 * C++: Same as in C. 499 * Objective-C: Same as in C. 500 501 See also `IsArrayType` and `GetArrayElementType`. 502 ") GetArrayType; 503 lldb::SBType 504 GetArrayType (uint64_t size); 505 506 %feature("docstring", 507 "Returns the vector element type if this type is a vector type. 508 509 Otherwise returns an invalid `SBType` if this type is invalid or not a 510 vector type. 511 512 Language-specific behaviour: 513 514 * C: If this is a vector type (see `IsVectorType`), returns the element 515 type. 516 * C++: Same as in C. 517 * Objective-C: Same as in C. 518 519 See also `IsVectorType`. 520 ") GetVectorElementType; 521 lldb::SBType 522 GetVectorElementType (); 523 524 %feature("docstring", 525 "Returns the `BasicType` value that is most appropriate to this type. 526 527 Returns `eBasicTypeInvalid` if no appropriate `BasicType` was found or this 528 type is invalid. See the `BasicType` documentation for the language-specific m 529 aning of each `BasicType` value. 530 531 **Overload behaviour:** When called with a `BasicType` parameter, the 532 following behaviour applies: 533 534 Returns the `SBType` that represents the passed `BasicType` value. Returns 535 an invalid `SBType` if no fitting `SBType` could be created. 536 537 Language-specific behaviour: 538 539 * C: Returns the respective builtin type. Note that some types 540 (e.g. ``__uint128_t``) might even be successfully created even if they are 541 not available on the target platform. C++ and Objective-C specific types 542 might also be created even if the target program is not written in C++ or 543 Objective-C. 544 * C++: Same as in C. 545 * Objective-C: Same as in C. 546 "); 547 lldb::BasicType 548 GetBasicType(); 549 550 lldb::SBType 551 GetBasicType (lldb::BasicType type); 552 553 %feature("docstring", 554 "Returns the number of fields of this type. 555 556 Returns ``0`` if this type does not have fields. 557 558 Language-specific behaviour: 559 560 * C: Returns the number of fields if the type is a struct. If the type 561 contains an anonymous struct/union it only counts as a single field (even 562 if the struct/union contains several fields). 563 * C++: Returns the number of non-static fields if the type is a 564 struct/class. If the type contains an anonymous struct/union it only 565 counts as a single field (even if the struct/union contains several 566 fields). The fields of any base classes are not included in the count. 567 * Objective-C: Same as in C for structs. For Objective-C classes the number 568 of ivars is returned. 569 570 See also `GetFieldAtIndex`. 571 ") GetNumberOfFields; 572 uint32_t 573 GetNumberOfFields (); 574 575 %feature("docstring", 576 "Returns the number of base/parent classes of this type. 577 578 Returns ``0`` if this type doesn't have any base classes. 579 580 Language-specific behaviour: 581 582 * C: Returns always ``0``. 583 * C++: The number of direct non-virtual base classes if this type is 584 a class. 585 * Objective-C: The number of super classes for Objective-C classes. 586 As Objective-C doesn't have multiple inheritance this is usually returns 1 587 except for NSObject. 588 ") GetNumberOfDirectBaseClasses; 589 uint32_t 590 GetNumberOfDirectBaseClasses (); 591 592 %feature("docstring", 593 "Returns the number of virtual base/parent classes of this type 594 595 Returns ``0`` if this type doesn't have any base classes. 596 597 Language-specific behaviour: 598 599 * C: Returns always ``0``. 600 * C++: The number of direct virtual base classes if this type is a 601 class. 602 * Objective-C: Returns always ``0``. 603 ") GetNumberOfVirtualBaseClasses; 604 uint32_t 605 GetNumberOfVirtualBaseClasses (); 606 607 %feature("docstring", 608 "Returns the field at the given index. 609 610 Returns an invalid `SBType` if the index is out of range or the current 611 type doesn't have any fields. 612 613 Language-specific behaviour: 614 615 * C: Returns the field with the given index for struct types. Fields are 616 ordered/indexed starting from ``0`` for the first field in a struct (as 617 declared in the definition). 618 * C++: Returns the non-static field with the given index for struct types. 619 Fields are ordered/indexed starting from ``0`` for the first field in a 620 struct (as declared in the definition). 621 * Objective-C: Same as in C for structs. For Objective-C classes the ivar 622 with the given index is returned. ivars are indexed starting from ``0``. 623 ") GetFieldAtIndex; 624 lldb::SBTypeMember 625 GetFieldAtIndex (uint32_t idx); 626 627 %feature("docstring", 628 "Returns the direct base class as indexed by `GetNumberOfDirectBaseClasses`. 629 630 Returns an invalid SBTypeMember if the index is invalid or this SBType is 631 invalid. 632 ") GetDirectBaseClassAtIndex; 633 lldb::SBTypeMember 634 GetDirectBaseClassAtIndex (uint32_t idx); 635 636 %feature("docstring", 637 "Returns the virtual base class as indexed by 638 `GetNumberOfVirtualBaseClasses`. 639 640 Returns an invalid SBTypeMember if the index is invalid or this SBType is 641 invalid. 642 ") GetVirtualBaseClassAtIndex; 643 lldb::SBTypeMember 644 GetVirtualBaseClassAtIndex (uint32_t idx); 645 646 lldb::SBTypeEnumMemberList 647 GetEnumMembers(); 648 %feature("docstring", 649 "Returns the `SBModule` this `SBType` belongs to. 650 651 Returns no `SBModule` if this type does not belong to any specific 652 `SBModule` or this `SBType` is invalid. An invalid `SBModule` might also 653 indicate that once came from an `SBModule` but LLDB could no longer 654 determine the original module. 655 ") GetModule; 656 lldb::SBModule 657 GetModule(); 658 659 %feature("autodoc", "GetName() -> string") GetName; 660 %feature("docstring", 661 "Returns the name of this type. 662 663 Returns an empty string if an error occurred or this type is invalid. 664 665 Use this function when trying to match a specific type by name in a script. 666 The names returned by this function try to uniquely identify a name but 667 conflicts can occur (for example, if a C++ program contains two different 668 classes with the same name in different translation units. `GetName` can 669 return the same name for both class types.) 670 671 672 Language-specific behaviour: 673 674 * C: The name of the type. For structs the ``struct`` prefix is omitted. 675 * C++: Returns the qualified name of the type (including anonymous/inline 676 namespaces and all template arguments). 677 * Objective-C: Same as in C. 678 ") GetName; 679 const char* 680 GetName(); 681 682 %feature("autodoc", "GetDisplayTypeName() -> string") GetDisplayTypeName; 683 %feature("docstring", 684 "Returns the name of this type in a user-friendly format. 685 686 Returns an empty string if an error occurred or this type is invalid. 687 688 Use this function when displaying a type name to the user. 689 690 Language-specific behaviour: 691 692 * C: Returns the type name. For structs the ``struct`` prefix is omitted. 693 * C++: Returns the qualified name. Anonymous/inline namespaces are omitted. 694 Template arguments that match their default value might also be hidden 695 (this functionality depends on whether LLDB can determine the template's 696 default arguments). 697 * Objective-C: Same as in C. 698 ") GetDisplayTypeName; 699 const char * 700 GetDisplayTypeName (); 701 702 %feature("autodoc", "GetTypeClass() -> TypeClass") GetTypeClass; 703 %feature("docstring", 704 "Returns the `TypeClass` for this type. 705 706 Returns an `eTypeClassInvalid` if this `SBType` is invalid. 707 708 See `TypeClass` for the language-specific meaning of each `TypeClass` value. 709 ") GetTypeClass; 710 lldb::TypeClass 711 GetTypeClass (); 712 713 %feature("docstring", 714 "Returns the number of template arguments of this type. 715 716 Returns ``0`` if this type is not a template. 717 718 Language-specific behaviour: 719 720 * C: Always returns ``0``. 721 * C++: If this type is a class template instantiation then this returns the 722 number of template parameters that were used in this instantiation. This i 723 cludes both explicit and implicit template parameters. 724 * Objective-C: Always returns ``0``. 725 ") GetNumberOfTemplateArguments; 726 uint32_t 727 GetNumberOfTemplateArguments (); 728 729 %feature("docstring", 730 "Returns the type of the template argument with the given index. 731 732 Returns an invalid `SBType` if there is no template argument with the given 733 index or this type is not a template. The first template argument has the 734 index ``0``. 735 736 Language-specific behaviour: 737 738 * C: Always returns an invalid SBType. 739 * C++: If this type is a class template instantiation and the template 740 parameter with the given index is a type template parameter, then this 741 returns the type of that parameter. Otherwise returns an invalid `SBType`. 742 * Objective-C: Always returns an invalid SBType. 743 ") GetTemplateArgumentType; 744 lldb::SBType 745 GetTemplateArgumentType (uint32_t idx); 746 747 %feature("docstring", 748 "Returns the kind of the template argument with the given index. 749 750 Returns `eTemplateArgumentKindNull` if there is no template argument 751 with the given index or this type is not a template. The first template 752 argument has the index ``0``. 753 754 Language-specific behaviour: 755 756 * C: Always returns `eTemplateArgumentKindNull`. 757 * C++: If this type is a class template instantiation then this returns 758 the appropriate `TemplateArgument` value for the parameter with the given 759 index. See the documentation of `TemplateArgument` for how certain C++ 760 template parameter kinds are mapped to `TemplateArgument` values. 761 * Objective-C: Always returns `eTemplateArgumentKindNull`. 762 ") GetTemplateArgumentKind; 763 lldb::TemplateArgumentKind 764 GetTemplateArgumentKind (uint32_t idx); 765 766 %feature("docstring", 767 "Returns the return type if this type represents a function. 768 769 Returns an invalid `SBType` if this type is not a function type or invalid. 770 771 Language-specific behaviour: 772 773 * C: For functions return the return type. Returns an invalid `SBType` if 774 this type is a function pointer type. 775 * C++: Same as in C for functions and instantiated template functions. 776 Member functions are also considered functions. For functions that have 777 their return type specified by a placeholder type specifier (``auto``) 778 this returns the deduced return type. 779 * Objective-C: Same as in C for functions. For Objective-C methods this 780 returns the return type of the method. 781 ") GetFunctionReturnType; 782 lldb::SBType 783 GetFunctionReturnType (); 784 785 %feature("docstring", 786 "Returns the list of argument types if this type represents a function. 787 788 Returns an invalid `SBType` if this type is not a function type or invalid. 789 790 Language-specific behaviour: 791 792 * C: For functions return the types of each parameter. Returns an invalid 793 `SBType` if this type is a function pointer. For variadic functions this 794 just returns the list of parameters before the variadic arguments. 795 * C++: Same as in C for functions and instantiated template functions. 796 Member functions are also considered functions. 797 * Objective-C: Always returns an invalid SBType for Objective-C methods. 798 ") GetFunctionArgumentTypes; 799 lldb::SBTypeList 800 GetFunctionArgumentTypes (); 801 802 %feature("docstring", 803 "Returns the number of member functions of this type. 804 805 Returns ``0`` if an error occurred or this type is invalid. 806 807 Language-specific behaviour: 808 809 * C: Always returns ``0``. 810 * C++: If this type represents a struct/class, then the number of 811 member functions (static and non-static) is returned. The count includes 812 constructors and destructors (both explicit and implicit). Member 813 functions of base classes are not included in the count. 814 * Objective-C: If this type represents a struct/class, then the 815 number of methods is returned. Methods in categories or super classes 816 are not counted. 817 ") GetNumberOfMemberFunctions; 818 uint32_t 819 GetNumberOfMemberFunctions (); 820 821 %feature("docstring", 822 "Returns the member function of this type with the given index. 823 824 Returns an invalid `SBTypeMemberFunction` if the index is invalid or this 825 type is invalid. 826 827 Language-specific behaviour: 828 829 * C: Always returns an invalid `SBTypeMemberFunction`. 830 * C++: Returns the member function or constructor/destructor with the given 831 index. 832 * Objective-C: Returns the method with the given index. 833 834 See `GetNumberOfMemberFunctions` for what functions can be queried by this 835 function. 836 ") GetMemberFunctionAtIndex; 837 lldb::SBTypeMemberFunction 838 GetMemberFunctionAtIndex (uint32_t idx); 839 840 %feature("docstring", 841 "Returns true if the type is completely defined. 842 843 Language-specific behaviour: 844 845 * C: Returns false for struct types that were only forward declared in the 846 type's `SBTarget`/`SBModule`. Otherwise returns true. 847 * C++: Returns false for template/non-template struct/class types and 848 scoped enums that were only forward declared inside the type's 849 `SBTarget`/`SBModule`. Otherwise returns true. 850 * Objective-C: Follows the same behavior as C for struct types. Objective-C 851 classes are considered complete unless they were only forward declared via 852 ``@class ClassName`` in the type's `SBTarget`/`SBModule`. Otherwise 853 returns true. 854 ") IsTypeComplete; 855 bool 856 IsTypeComplete (); 857 858 %feature("docstring", 859 "Returns the `TypeFlags` values for this type. 860 861 See the respective `TypeFlags` values for what values can be set. Returns an 862 integer in which each `TypeFlags` value is represented by a bit. Specific 863 flags can be checked via Python's bitwise operators. For example, the 864 `eTypeIsInteger` flag can be checked like this: 865 866 ``(an_sb_type.GetTypeFlags() & lldb.eTypeIsInteger) != 0`` 867 868 If this type is invalid this returns ``0``. 869 870 See the different values for `TypeFlags` for the language-specific meanings 871 of each `TypeFlags` value. 872 ") GetTypeFlags; 873 uint32_t 874 GetTypeFlags (); 875 876 bool operator==(lldb::SBType &rhs); 877 878 bool operator!=(lldb::SBType &rhs); 879 880 STRING_EXTENSION_LEVEL(SBType, lldb::eDescriptionLevelBrief) 881 882 #ifdef SWIGPYTHON 883 %pythoncode %{ 884 def template_arg_array(self): 885 num_args = self.num_template_args 886 if num_args: 887 template_args = [] 888 for i in range(num_args): 889 template_args.append(self.GetTemplateArgumentType(i)) 890 return template_args 891 return None 892 893 module = property(GetModule, None, doc='''A read only property that returns the module in which type is defined.''') 894 name = property(GetName, None, doc='''A read only property that returns the name for this type as a string.''') 895 size = property(GetByteSize, None, doc='''A read only property that returns size in bytes for this type as an integer.''') 896 is_pointer = property(IsPointerType, None, doc='''A read only property that returns a boolean value that indicates if this type is a pointer type.''') 897 is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a reference type.''') 898 is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a function type.''') 899 num_fields = property(GetNumberOfFields, None, doc='''A read only property that returns number of fields in this type as an integer.''') 900 num_bases = property(GetNumberOfDirectBaseClasses, None, doc='''A read only property that returns number of direct base classes in this type as an integer.''') 901 num_vbases = property(GetNumberOfVirtualBaseClasses, None, doc='''A read only property that returns number of virtual base classes in this type as an integer.''') 902 num_template_args = property(GetNumberOfTemplateArguments, None, doc='''A read only property that returns number of template arguments in this type as an integer.''') 903 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.''') 904 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.''') 905 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).''') 906 907 def get_bases_array(self): 908 '''An accessor function that returns a list() that contains all direct base classes in a lldb.SBType object.''' 909 bases = [] 910 for idx in range(self.GetNumberOfDirectBaseClasses()): 911 bases.append(self.GetDirectBaseClassAtIndex(idx)) 912 return bases 913 914 def get_vbases_array(self): 915 '''An accessor function that returns a list() that contains all fields in a lldb.SBType object.''' 916 vbases = [] 917 for idx in range(self.GetNumberOfVirtualBaseClasses()): 918 vbases.append(self.GetVirtualBaseClassAtIndex(idx)) 919 return vbases 920 921 def get_fields_array(self): 922 '''An accessor function that returns a list() that contains all fields in a lldb.SBType object.''' 923 fields = [] 924 for idx in range(self.GetNumberOfFields()): 925 fields.append(self.GetFieldAtIndex(idx)) 926 return fields 927 928 def get_members_array(self): 929 '''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.''' 930 members = [] 931 bases = self.get_bases_array() 932 fields = self.get_fields_array() 933 vbases = self.get_vbases_array() 934 for base in bases: 935 bit_offset = base.bit_offset 936 added = False 937 for idx, member in enumerate(members): 938 if member.bit_offset > bit_offset: 939 members.insert(idx, base) 940 added = True 941 break 942 if not added: 943 members.append(base) 944 for vbase in vbases: 945 bit_offset = vbase.bit_offset 946 added = False 947 for idx, member in enumerate(members): 948 if member.bit_offset > bit_offset: 949 members.insert(idx, vbase) 950 added = True 951 break 952 if not added: 953 members.append(vbase) 954 for field in fields: 955 bit_offset = field.bit_offset 956 added = False 957 for idx, member in enumerate(members): 958 if member.bit_offset > bit_offset: 959 members.insert(idx, field) 960 added = True 961 break 962 if not added: 963 members.append(field) 964 return members 965 966 def get_enum_members_array(self): 967 '''An accessor function that returns a list() that contains all enum members in an lldb.SBType object.''' 968 enum_members_list = [] 969 sb_enum_members = self.GetEnumMembers() 970 for idx in range(sb_enum_members.GetSize()): 971 enum_members_list.append(sb_enum_members.GetTypeEnumMemberAtIndex(idx)) 972 return enum_members_list 973 974 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.''') 975 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.''') 976 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.''') 977 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.''') 978 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.''') 979 %} 980 #endif 981 982 }; 983 984 %feature("docstring", 985 "Represents a list of :py:class:`SBType` s. 986 987 The FindTypes() method of :py:class:`SBTarget`/:py:class:`SBModule` returns a SBTypeList. 988 989 SBTypeList supports :py:class:`SBType` iteration. For example, 990 991 .. code-block:: cpp 992 993 // main.cpp: 994 995 class Task { 996 public: 997 int id; 998 Task *next; 999 Task(int i, Task *n): 1000 id(i), 1001 next(n) 1002 {} 1003 }; 1004 1005 .. code-block:: python 1006 1007 # find_type.py: 1008 1009 # Get the type 'Task'. 1010 type_list = target.FindTypes('Task') 1011 self.assertTrue(len(type_list) == 1) 1012 # To illustrate the SBType iteration. 1013 for type in type_list: 1014 # do something with type 1015 1016 ") SBTypeList; 1017 class SBTypeList 1018 { 1019 public: 1020 SBTypeList(); 1021 1022 bool 1023 IsValid(); 1024 1025 explicit operator bool() const; 1026 1027 void 1028 Append (lldb::SBType type); 1029 1030 lldb::SBType 1031 GetTypeAtIndex (uint32_t index); 1032 1033 uint32_t 1034 GetSize(); 1035 1036 ~SBTypeList(); 1037 1038 #ifdef SWIGPYTHON 1039 %pythoncode%{ 1040 def __iter__(self): 1041 '''Iterate over all types in a lldb.SBTypeList object.''' 1042 return lldb_iter(self, 'GetSize', 'GetTypeAtIndex') 1043 1044 def __len__(self): 1045 '''Return the number of types in a lldb.SBTypeList object.''' 1046 return self.GetSize() 1047 %} 1048 #endif 1049 }; 1050 1051 } // namespace lldb 1052