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 true if this type is an aggregate type. 359 360 Language-specific behaviour: 361 362 * C: Returns true for struct values, arrays, and vectors. 363 * C++: Same a C. Also includes class instances. 364 * Objective-C: Same as C. Also includes class instances. 365 ") IsAggregateType; 366 bool 367 IsAggregateType (); 368 369 %feature("docstring", 370 "Returns a type that represents a pointer to this type. 371 372 If the type system of the current language can't represent a pointer to this 373 type or this type is invalid, an invalid `SBType` is returned. 374 375 Language-specific behaviour: 376 377 * C: Returns the pointer type of this type. 378 * C++: Same as in C. 379 * Objective-C: Same as in C. 380 ") GetPointerType; 381 lldb::SBType 382 GetPointerType(); 383 384 %feature("docstring", 385 "Returns the underlying pointee type. 386 387 If this type is a pointer type as specified by `IsPointerType` then this 388 returns the underlying type. If this is not a pointer type or an invalid 389 `SBType` then this returns an invalid `SBType`. 390 391 Language-specific behaviour: 392 393 * C: Returns the underlying type for for C pointer types or typedefs of 394 these types). For example, ``int *`` will return ``int``. 395 * C++: Same as in C. Returns an `SBType` representation for data members/ 396 member functions in case the `SBType` is a pointer to data member or 397 pointer to member function. 398 * Objective-C: Same as in C. The pointee type of ``id`` and ``Class`` is 399 an invalid `SBType`. The pointee type of pointers Objective-C types is an 400 `SBType` for the non-pointer type of the respective type. For example, 401 ``NSString *`` will return ``NSString`` as a pointee type. 402 ") GetPointeeType; 403 lldb::SBType 404 GetPointeeType(); 405 406 %feature("docstring", 407 "Returns a type that represents a reference to this type. 408 409 If the type system of the current language can't represent a reference to 410 this type, an invalid `SBType` is returned. 411 412 Language-specific behaviour: 413 414 * C: Currently assumes the type system is C++ and returns an l-value 415 reference type. For example, ``int`` will return ``int&``. This behavior 416 is likely to change in the future and shouldn't be relied on. 417 * C++: Same as in C. 418 * Objective-C: Same as in C. 419 ") GetReferenceType; 420 lldb::SBType 421 GetReferenceType(); 422 423 %feature("docstring", 424 "Returns the underlying type of a typedef. 425 426 If this type is a typedef as designated by `IsTypedefType`, then the 427 underlying type is being returned. Otherwise an invalid `SBType` is 428 returned. 429 430 Language-specific behaviour: 431 432 * C: Returns the underlying type of a typedef type. 433 * C++: Same as in C. For type aliases, the underlying type is returned. 434 * Objective-C: Same as in C. 435 ") GetTypedefedType; 436 lldb::SBType 437 SBType::GetTypedefedType(); 438 439 %feature("docstring", 440 "Returns the underlying type of a reference type. 441 442 If this type is a reference as designated by `IsReferenceType`, then the 443 underlying type is being returned. Otherwise an invalid `SBType` is 444 returned. 445 446 Language-specific behaviour: 447 448 * C: Always returns an invalid type. 449 * C++: For l-value and r-value references the underlying type is returned. 450 For example, ``int &`` will return ``int``. 451 * Objective-C: Same as in C. 452 ") GetDereferencedType; 453 lldb::SBType 454 GetDereferencedType(); 455 456 %feature("docstring", 457 "Returns the unqualified version of this type. 458 459 Language-specific behaviour: 460 461 * C: If this type with any const or volatile specifier removed. 462 * C++: Same as in C. 463 * Objective-C: Same as in C. 464 ") GetUnqualifiedType; 465 lldb::SBType 466 GetUnqualifiedType(); 467 468 lldb::SBType 469 GetCanonicalType(); 470 471 %feature("docstring", 472 "Returns the underlying integer type if this is an enumeration type. 473 474 If this type is an invalid `SBType` or not an enumeration type an invalid 475 `SBType` is returned. 476 477 Language-specific behaviour: 478 479 * C: Returns the underlying type for enums. 480 * C++: Same as in C but also returns the underlying type for scoped enums. 481 * Objective-C: Same as in C. 482 ") GetEnumerationIntegerType; 483 lldb::SBType 484 GetEnumerationIntegerType(); 485 486 %feature("docstring", 487 "Returns the array element type if this type is an array type. 488 489 Otherwise returns an invalid `SBType` if this type is invalid or not an 490 array type. 491 492 Language-specific behaviour: 493 494 * C: If this is an array type (see `IsArrayType`) such as ``T[]``, returns 495 the element type. 496 * C++: Same as in C. 497 * Objective-C: Same as in C. 498 499 See also `IsArrayType`. 500 ") GetArrayElementType; 501 lldb::SBType 502 GetArrayElementType (); 503 504 %feature("docstring", 505 "Returns the array type with the given constant size. 506 507 Language-specific behaviour: 508 509 * C: Returns a constant-size array ``T[size]`` for any non-void type. 510 * C++: Same as in C. 511 * Objective-C: Same as in C. 512 513 See also `IsArrayType` and `GetArrayElementType`. 514 ") GetArrayType; 515 lldb::SBType 516 GetArrayType (uint64_t size); 517 518 %feature("docstring", 519 "Returns the vector element type if this type is a vector type. 520 521 Otherwise returns an invalid `SBType` if this type is invalid or not a 522 vector type. 523 524 Language-specific behaviour: 525 526 * C: If this is a vector type (see `IsVectorType`), returns the element 527 type. 528 * C++: Same as in C. 529 * Objective-C: Same as in C. 530 531 See also `IsVectorType`. 532 ") GetVectorElementType; 533 lldb::SBType 534 GetVectorElementType (); 535 536 %feature("docstring", 537 "Returns the `BasicType` value that is most appropriate to this type. 538 539 Returns `eBasicTypeInvalid` if no appropriate `BasicType` was found or this 540 type is invalid. See the `BasicType` documentation for the language-specific 541 meaning of each `BasicType` value. 542 543 **Overload behaviour:** When called with a `BasicType` parameter, the 544 following behaviour applies: 545 546 Returns the `SBType` that represents the passed `BasicType` value. Returns 547 an invalid `SBType` if no fitting `SBType` could be created. 548 549 Language-specific behaviour: 550 551 * C: Returns the respective builtin type. Note that some types 552 (e.g. ``__uint128_t``) might even be successfully created even if they are 553 not available on the target platform. C++ and Objective-C specific types 554 might also be created even if the target program is not written in C++ or 555 Objective-C. 556 * C++: Same as in C. 557 * Objective-C: Same as in C. 558 "); 559 lldb::BasicType 560 GetBasicType(); 561 562 lldb::SBType 563 GetBasicType (lldb::BasicType type); 564 565 %feature("docstring", 566 "Returns the number of fields of this type. 567 568 Returns ``0`` if this type does not have fields. 569 570 Language-specific behaviour: 571 572 * C: Returns the number of fields if the type is a struct. If the type 573 contains an anonymous struct/union it only counts as a single field (even 574 if the struct/union contains several fields). 575 * C++: Returns the number of non-static fields if the type is a 576 struct/class. If the type contains an anonymous struct/union it only 577 counts as a single field (even if the struct/union contains several 578 fields). The fields of any base classes are not included in the count. 579 * Objective-C: Same as in C for structs. For Objective-C classes the number 580 of ivars is returned. 581 582 See also `GetFieldAtIndex`. 583 ") GetNumberOfFields; 584 uint32_t 585 GetNumberOfFields (); 586 587 %feature("docstring", 588 "Returns the number of base/parent classes of this type. 589 590 Returns ``0`` if this type doesn't have any base classes. 591 592 Language-specific behaviour: 593 594 * C: Returns always ``0``. 595 * C++: The number of direct non-virtual base classes if this type is 596 a class. 597 * Objective-C: The number of super classes for Objective-C classes. 598 As Objective-C doesn't have multiple inheritance this is usually returns 1 599 except for NSObject. 600 ") GetNumberOfDirectBaseClasses; 601 uint32_t 602 GetNumberOfDirectBaseClasses (); 603 604 %feature("docstring", 605 "Returns the number of virtual base/parent classes of this type 606 607 Returns ``0`` if this type doesn't have any base classes. 608 609 Language-specific behaviour: 610 611 * C: Returns always ``0``. 612 * C++: The number of direct virtual base classes if this type is a 613 class. 614 * Objective-C: Returns always ``0``. 615 ") GetNumberOfVirtualBaseClasses; 616 uint32_t 617 GetNumberOfVirtualBaseClasses (); 618 619 %feature("docstring", 620 "Returns the field at the given index. 621 622 Returns an invalid `SBType` if the index is out of range or the current 623 type doesn't have any fields. 624 625 Language-specific behaviour: 626 627 * C: Returns the field with the given index for struct types. Fields are 628 ordered/indexed starting from ``0`` for the first field in a struct (as 629 declared in the definition). 630 * C++: Returns the non-static field with the given index for struct types. 631 Fields are ordered/indexed starting from ``0`` for the first field in a 632 struct (as declared in the definition). 633 * Objective-C: Same as in C for structs. For Objective-C classes the ivar 634 with the given index is returned. ivars are indexed starting from ``0``. 635 ") GetFieldAtIndex; 636 lldb::SBTypeMember 637 GetFieldAtIndex (uint32_t idx); 638 639 %feature("docstring", 640 "Returns the direct base class as indexed by `GetNumberOfDirectBaseClasses`. 641 642 Returns an invalid SBTypeMember if the index is invalid or this SBType is 643 invalid. 644 ") GetDirectBaseClassAtIndex; 645 lldb::SBTypeMember 646 GetDirectBaseClassAtIndex (uint32_t idx); 647 648 %feature("docstring", 649 "Returns the virtual base class as indexed by 650 `GetNumberOfVirtualBaseClasses`. 651 652 Returns an invalid SBTypeMember if the index is invalid or this SBType is 653 invalid. 654 ") GetVirtualBaseClassAtIndex; 655 lldb::SBTypeMember 656 GetVirtualBaseClassAtIndex (uint32_t idx); 657 658 lldb::SBTypeEnumMemberList 659 GetEnumMembers(); 660 %feature("docstring", 661 "Returns the `SBModule` this `SBType` belongs to. 662 663 Returns no `SBModule` if this type does not belong to any specific 664 `SBModule` or this `SBType` is invalid. An invalid `SBModule` might also 665 indicate that once came from an `SBModule` but LLDB could no longer 666 determine the original module. 667 ") GetModule; 668 lldb::SBModule 669 GetModule(); 670 671 %feature("autodoc", "GetName() -> string") GetName; 672 %feature("docstring", 673 "Returns the name of this type. 674 675 Returns an empty string if an error occurred or this type is invalid. 676 677 Use this function when trying to match a specific type by name in a script. 678 The names returned by this function try to uniquely identify a name but 679 conflicts can occur (for example, if a C++ program contains two different 680 classes with the same name in different translation units. `GetName` can 681 return the same name for both class types.) 682 683 684 Language-specific behaviour: 685 686 * C: The name of the type. For structs the ``struct`` prefix is omitted. 687 * C++: Returns the qualified name of the type (including anonymous/inline 688 namespaces and all template arguments). 689 * Objective-C: Same as in C. 690 ") GetName; 691 const char* 692 GetName(); 693 694 %feature("autodoc", "GetDisplayTypeName() -> string") GetDisplayTypeName; 695 %feature("docstring", 696 "Returns the name of this type in a user-friendly format. 697 698 Returns an empty string if an error occurred or this type is invalid. 699 700 Use this function when displaying a type name to the user. 701 702 Language-specific behaviour: 703 704 * C: Returns the type name. For structs the ``struct`` prefix is omitted. 705 * C++: Returns the qualified name. Anonymous/inline namespaces are omitted. 706 Template arguments that match their default value might also be hidden 707 (this functionality depends on whether LLDB can determine the template's 708 default arguments). 709 * Objective-C: Same as in C. 710 ") GetDisplayTypeName; 711 const char * 712 GetDisplayTypeName (); 713 714 %feature("autodoc", "GetTypeClass() -> TypeClass") GetTypeClass; 715 %feature("docstring", 716 "Returns the `TypeClass` for this type. 717 718 Returns an `eTypeClassInvalid` if this `SBType` is invalid. 719 720 See `TypeClass` for the language-specific meaning of each `TypeClass` value. 721 ") GetTypeClass; 722 lldb::TypeClass 723 GetTypeClass (); 724 725 %feature("docstring", 726 "Returns the number of template arguments of this type. 727 728 Returns ``0`` if this type is not a template. 729 730 Language-specific behaviour: 731 732 * C: Always returns ``0``. 733 * C++: If this type is a class template instantiation then this returns the 734 number of template parameters that were used in this instantiation. This 735 includes both explicit and implicit template parameters. 736 * Objective-C: Always returns ``0``. 737 ") GetNumberOfTemplateArguments; 738 uint32_t 739 GetNumberOfTemplateArguments (); 740 741 %feature("docstring", 742 "Returns the type of the template argument with the given index. 743 744 Returns an invalid `SBType` if there is no template argument with the given 745 index or this type is not a template. The first template argument has the 746 index ``0``. 747 748 Language-specific behaviour: 749 750 * C: Always returns an invalid SBType. 751 * C++: If this type is a class template instantiation and the template 752 parameter with the given index is a type template parameter, then this 753 returns the type of that parameter. Otherwise returns an invalid `SBType`. 754 * Objective-C: Always returns an invalid SBType. 755 ") GetTemplateArgumentType; 756 lldb::SBType 757 GetTemplateArgumentType (uint32_t idx); 758 759 %feature("docstring", 760 "Returns the kind of the template argument with the given index. 761 762 Returns `eTemplateArgumentKindNull` if there is no template argument 763 with the given index or this type is not a template. The first template 764 argument has the index ``0``. 765 766 Language-specific behaviour: 767 768 * C: Always returns `eTemplateArgumentKindNull`. 769 * C++: If this type is a class template instantiation then this returns 770 the appropriate `TemplateArgument` value for the parameter with the given 771 index. See the documentation of `TemplateArgument` for how certain C++ 772 template parameter kinds are mapped to `TemplateArgument` values. 773 * Objective-C: Always returns `eTemplateArgumentKindNull`. 774 ") GetTemplateArgumentKind; 775 lldb::TemplateArgumentKind 776 GetTemplateArgumentKind (uint32_t idx); 777 778 %feature("docstring", 779 "Returns the return type if this type represents a function. 780 781 Returns an invalid `SBType` if this type is not a function type or invalid. 782 783 Language-specific behaviour: 784 785 * C: For functions return the return type. Returns an invalid `SBType` if 786 this type is a function pointer type. 787 * C++: Same as in C for functions and instantiated template functions. 788 Member functions are also considered functions. For functions that have 789 their return type specified by a placeholder type specifier (``auto``) 790 this returns the deduced return type. 791 * Objective-C: Same as in C for functions. For Objective-C methods this 792 returns the return type of the method. 793 ") GetFunctionReturnType; 794 lldb::SBType 795 GetFunctionReturnType (); 796 797 %feature("docstring", 798 "Returns the list of argument types if this type represents a function. 799 800 Returns an invalid `SBType` if this type is not a function type or invalid. 801 802 Language-specific behaviour: 803 804 * C: For functions return the types of each parameter. Returns an invalid 805 `SBType` if this type is a function pointer. For variadic functions this 806 just returns the list of parameters before the variadic arguments. 807 * C++: Same as in C for functions and instantiated template functions. 808 Member functions are also considered functions. 809 * Objective-C: Always returns an invalid SBType for Objective-C methods. 810 ") GetFunctionArgumentTypes; 811 lldb::SBTypeList 812 GetFunctionArgumentTypes (); 813 814 %feature("docstring", 815 "Returns the number of member functions of this type. 816 817 Returns ``0`` if an error occurred or this type is invalid. 818 819 Language-specific behaviour: 820 821 * C: Always returns ``0``. 822 * C++: If this type represents a struct/class, then the number of 823 member functions (static and non-static) is returned. The count includes 824 constructors and destructors (both explicit and implicit). Member 825 functions of base classes are not included in the count. 826 * Objective-C: If this type represents a struct/class, then the 827 number of methods is returned. Methods in categories or super classes 828 are not counted. 829 ") GetNumberOfMemberFunctions; 830 uint32_t 831 GetNumberOfMemberFunctions (); 832 833 %feature("docstring", 834 "Returns the member function of this type with the given index. 835 836 Returns an invalid `SBTypeMemberFunction` if the index is invalid or this 837 type is invalid. 838 839 Language-specific behaviour: 840 841 * C: Always returns an invalid `SBTypeMemberFunction`. 842 * C++: Returns the member function or constructor/destructor with the given 843 index. 844 * Objective-C: Returns the method with the given index. 845 846 See `GetNumberOfMemberFunctions` for what functions can be queried by this 847 function. 848 ") GetMemberFunctionAtIndex; 849 lldb::SBTypeMemberFunction 850 GetMemberFunctionAtIndex (uint32_t idx); 851 852 %feature("docstring", 853 "Returns true if the type is completely defined. 854 855 Language-specific behaviour: 856 857 * C: Returns false for struct types that were only forward declared in the 858 type's `SBTarget`/`SBModule`. Otherwise returns true. 859 * C++: Returns false for template/non-template struct/class types and 860 scoped enums that were only forward declared inside the type's 861 `SBTarget`/`SBModule`. Otherwise returns true. 862 * Objective-C: Follows the same behavior as C for struct types. Objective-C 863 classes are considered complete unless they were only forward declared via 864 ``@class ClassName`` in the type's `SBTarget`/`SBModule`. Otherwise 865 returns true. 866 ") IsTypeComplete; 867 bool 868 IsTypeComplete (); 869 870 %feature("docstring", 871 "Returns the `TypeFlags` values for this type. 872 873 See the respective `TypeFlags` values for what values can be set. Returns an 874 integer in which each `TypeFlags` value is represented by a bit. Specific 875 flags can be checked via Python's bitwise operators. For example, the 876 `eTypeIsInteger` flag can be checked like this: 877 878 ``(an_sb_type.GetTypeFlags() & lldb.eTypeIsInteger) != 0`` 879 880 If this type is invalid this returns ``0``. 881 882 See the different values for `TypeFlags` for the language-specific meanings 883 of each `TypeFlags` value. 884 ") GetTypeFlags; 885 uint32_t 886 GetTypeFlags (); 887 888 bool operator==(lldb::SBType &rhs); 889 890 bool operator!=(lldb::SBType &rhs); 891 892 STRING_EXTENSION_LEVEL(SBType, lldb::eDescriptionLevelBrief) 893 894 #ifdef SWIGPYTHON 895 %pythoncode %{ 896 def template_arg_array(self): 897 num_args = self.num_template_args 898 if num_args: 899 template_args = [] 900 for i in range(num_args): 901 template_args.append(self.GetTemplateArgumentType(i)) 902 return template_args 903 return None 904 905 module = property(GetModule, None, doc='''A read only property that returns the module in which type is defined.''') 906 name = property(GetName, None, doc='''A read only property that returns the name for this type as a string.''') 907 size = property(GetByteSize, None, doc='''A read only property that returns size in bytes for this type as an integer.''') 908 is_pointer = property(IsPointerType, None, doc='''A read only property that returns a boolean value that indicates if this type is a pointer type.''') 909 is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a reference type.''') 910 is_reference = property(IsReferenceType, None, doc='''A read only property that returns a boolean value that indicates if this type is a function type.''') 911 num_fields = property(GetNumberOfFields, None, doc='''A read only property that returns number of fields in this type as an integer.''') 912 num_bases = property(GetNumberOfDirectBaseClasses, None, doc='''A read only property that returns number of direct base classes in this type as an integer.''') 913 num_vbases = property(GetNumberOfVirtualBaseClasses, None, doc='''A read only property that returns number of virtual base classes in this type as an integer.''') 914 num_template_args = property(GetNumberOfTemplateArguments, None, doc='''A read only property that returns number of template arguments in this type as an integer.''') 915 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.''') 916 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.''') 917 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).''') 918 919 def get_bases_array(self): 920 '''An accessor function that returns a list() that contains all direct base classes in a lldb.SBType object.''' 921 bases = [] 922 for idx in range(self.GetNumberOfDirectBaseClasses()): 923 bases.append(self.GetDirectBaseClassAtIndex(idx)) 924 return bases 925 926 def get_vbases_array(self): 927 '''An accessor function that returns a list() that contains all fields in a lldb.SBType object.''' 928 vbases = [] 929 for idx in range(self.GetNumberOfVirtualBaseClasses()): 930 vbases.append(self.GetVirtualBaseClassAtIndex(idx)) 931 return vbases 932 933 def get_fields_array(self): 934 '''An accessor function that returns a list() that contains all fields in a lldb.SBType object.''' 935 fields = [] 936 for idx in range(self.GetNumberOfFields()): 937 fields.append(self.GetFieldAtIndex(idx)) 938 return fields 939 940 def get_members_array(self): 941 '''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.''' 942 members = [] 943 bases = self.get_bases_array() 944 fields = self.get_fields_array() 945 vbases = self.get_vbases_array() 946 for base in bases: 947 bit_offset = base.bit_offset 948 added = False 949 for idx, member in enumerate(members): 950 if member.bit_offset > bit_offset: 951 members.insert(idx, base) 952 added = True 953 break 954 if not added: 955 members.append(base) 956 for vbase in vbases: 957 bit_offset = vbase.bit_offset 958 added = False 959 for idx, member in enumerate(members): 960 if member.bit_offset > bit_offset: 961 members.insert(idx, vbase) 962 added = True 963 break 964 if not added: 965 members.append(vbase) 966 for field in fields: 967 bit_offset = field.bit_offset 968 added = False 969 for idx, member in enumerate(members): 970 if member.bit_offset > bit_offset: 971 members.insert(idx, field) 972 added = True 973 break 974 if not added: 975 members.append(field) 976 return members 977 978 def get_enum_members_array(self): 979 '''An accessor function that returns a list() that contains all enum members in an lldb.SBType object.''' 980 enum_members_list = [] 981 sb_enum_members = self.GetEnumMembers() 982 for idx in range(sb_enum_members.GetSize()): 983 enum_members_list.append(sb_enum_members.GetTypeEnumMemberAtIndex(idx)) 984 return enum_members_list 985 986 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.''') 987 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.''') 988 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.''') 989 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.''') 990 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.''') 991 %} 992 #endif 993 994 }; 995 996 %feature("docstring", 997 "Represents a list of :py:class:`SBType` s. 998 999 The FindTypes() method of :py:class:`SBTarget`/:py:class:`SBModule` returns a SBTypeList. 1000 1001 SBTypeList supports :py:class:`SBType` iteration. For example, 1002 1003 .. code-block:: cpp 1004 1005 // main.cpp: 1006 1007 class Task { 1008 public: 1009 int id; 1010 Task *next; 1011 Task(int i, Task *n): 1012 id(i), 1013 next(n) 1014 {} 1015 }; 1016 1017 .. code-block:: python 1018 1019 # find_type.py: 1020 1021 # Get the type 'Task'. 1022 type_list = target.FindTypes('Task') 1023 self.assertTrue(len(type_list) == 1) 1024 # To illustrate the SBType iteration. 1025 for type in type_list: 1026 # do something with type 1027 1028 ") SBTypeList; 1029 class SBTypeList 1030 { 1031 public: 1032 SBTypeList(); 1033 1034 bool 1035 IsValid(); 1036 1037 explicit operator bool() const; 1038 1039 void 1040 Append (lldb::SBType type); 1041 1042 lldb::SBType 1043 GetTypeAtIndex (uint32_t index); 1044 1045 uint32_t 1046 GetSize(); 1047 1048 ~SBTypeList(); 1049 1050 #ifdef SWIGPYTHON 1051 %pythoncode%{ 1052 def __iter__(self): 1053 '''Iterate over all types in a lldb.SBTypeList object.''' 1054 return lldb_iter(self, 'GetSize', 'GetTypeAtIndex') 1055 1056 def __len__(self): 1057 '''Return the number of types in a lldb.SBTypeList object.''' 1058 return self.GetSize() 1059 %} 1060 #endif 1061 }; 1062 1063 } // namespace lldb 1064