2 "Represents a member of a type."
6 "Represents a member function of a type."
7 ) lldb
::SBTypeMemberFunction
;
10 "Represents a data type in lldb.
12 The actual characteristics of each type are defined by the semantics of the
13 programming language and the specific language implementation that was used
14 to compile the target program. See the language-specific notes in the
15 documentation of each method.
17 SBType instances can be obtained by a variety of methods.
18 `SBTarget.FindFirstType` and `SBModule.FindFirstType` can be used to create
19 `SBType` representations of types in executables/libraries with debug
20 information. For some languages such as C, C++ and Objective-C it is possible
21 to create new types by evaluating expressions that define a new type.
23 Note that most `SBType` properties are computed independently of any runtime
24 information so for dynamic languages the functionality can be very limited.
25 `SBValue` can be used to represent runtime values which then can be more
26 accurately queried for certain information such as byte size.
29 SBType supports the eq/ne operator. For example,::
43 int main (int argc, char const *argv[])
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);
52 task_head->next = task1;
64 printf('We have a total number of %d tasks\\n', total);
66 // This corresponds to an empty task list.
67 Task *empty_task_head = new Task(-1, NULL);
69 return 0; // Break at this line
74 # Get the type 'Task'.
75 task_type = target.FindFirstType('Task')
76 self.assertTrue(task_type)
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())
83 # task_head_type is 'Task *'.
84 task_pointer_type = task_type.GetPointerType()
85 self.assertTrue(task_head_type == task_pointer_type)
87 # Get the child mmember 'id' from 'task_head'.
88 id = task_head.GetChildMemberWithName('id')
89 id_type = id.GetType()
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)
99 "Returns the number of bytes a variable with the given types occupies in memory.
101 Returns ``0`` if the size can't be determined.
103 If a type occupies ``N`` bytes + ``M`` bits in memory, this function returns
104 the rounded up amount of bytes (i.e., if ``M`` is ``0``,
105 this function returns ``N`` and otherwise ``N + 1``).
107 Language-specific behaviour:
109 * C: The output is expected to match the value of ``sizeof(Type)``. If
110 ``sizeof(Type)`` is not a valid expression for the given type, the
111 function returns ``0``.
113 * Objective-C: Same as in C. For Objective-C classes this always returns
114 ``0`` as the actual size depends on runtime information.
116 ) lldb
::SBType
::GetByteSize
;
118 %feature
("docstring",
119 "Returns true if this type is a pointer type.
121 Language-specific behaviour:
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 data
125 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.
129 ) lldb
::SBType
::IsPointerType
;
131 %feature
("docstring",
132 "Returns true if this type is a reference type.
134 Language-specific behaviour:
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.
140 ) lldb
::SBType
::IsReferenceType
;
142 %feature
("docstring",
143 "Returns true if this type is a polymorphic type.
145 Language-specific behaviour:
147 * C: Returns false for all types.
148 * C++: Returns true if the type is a class type that contains at least one
149 virtual member function or if at least one of its base classes is
150 considered a polymorphic type.
151 * Objective-C: Returns false for all types.
153 ) lldb
::SBType
::IsPolymorphicClass
;
155 %feature
("docstring",
156 "Returns true if this type is an array type.
158 Language-specific behaviour:
160 * C: Returns true if the types is an array type. This includes incomplete
161 array types ``T[]`` and array types with integer (``T[1]``) or variable
162 length (``T[some_variable]``). Pointer types are not considered arrays.
163 * C++: Includes C's array types and dependent array types (i.e., array types
164 in templates which size depends on template arguments).
165 * Objective-C: Same as in C.
167 ) lldb
::SBType
::IsArrayType
;
169 %feature
("docstring",
170 "Returns true if this type is a vector type.
172 Language-specific behaviour:
174 * C: Returns true if the types is a vector type created with
175 GCC's ``vector_size`` or Clang's ``ext_vector_type`` feature.
177 * Objective-C: Same as in C.
179 ) lldb
::SBType
::IsVectorType
;
181 %feature
("docstring",
182 "Returns true if this type is a typedef.
184 Language-specific behaviour:
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.
190 ) lldb
::SBType
::IsTypedefType
;
192 %feature
("docstring",
193 "Returns true if this type is an anonymous type.
195 Language-specific behaviour:
197 * C: Returns true for anonymous unions. Also returns true for
198 anonymous structs (which are a GNU language extension).
200 * Objective-C: Same as in C.
202 ) lldb
::SBType
::IsAnonymousType
;
204 %feature
("docstring",
205 "Returns true if this type is a scoped enum.
207 Language-specific behaviour:
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.
213 ) lldb
::SBType
::IsScopedEnumerationType
;
215 %feature
("docstring",
216 "Returns true if this type is an aggregate type.
218 Language-specific behaviour:
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.
224 ) lldb
::SBType
::IsAggregateType
;
226 %feature
("docstring",
227 "Returns a type that represents a pointer to this type.
229 If the type system of the current language can't represent a pointer to this
230 type or this type is invalid, an invalid `SBType` is returned.
232 Language-specific behaviour:
234 * C: Returns the pointer type of this type.
236 * Objective-C: Same as in C.
238 ) lldb
::SBType
::GetPointerType
;
240 %feature
("docstring",
241 "Returns the underlying pointee type.
243 If this type is a pointer type as specified by `IsPointerType` then this
244 returns the underlying type. If this is not a pointer type or an invalid
245 `SBType` then this returns an invalid `SBType`.
247 Language-specific behaviour:
249 * C: Returns the underlying type for for C pointer types or typedefs of
250 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 or
253 pointer to member function.
254 * Objective-C: Same as in C. The pointee type of ``id`` and ``Class`` is
255 an invalid `SBType`. The pointee type of pointers Objective-C types is an
256 `SBType` for the non-pointer type of the respective type. For example,
257 ``NSString *`` will return ``NSString`` as a pointee type.
259 ) lldb
::SBType
::GetPointeeType
;
261 %feature
("docstring",
262 "Returns a type that represents a reference to this type.
264 If the type system of the current language can't represent a reference to
265 this type, an invalid `SBType` is returned.
267 Language-specific behaviour:
269 * C: Currently assumes the type system is C++ and returns an l-value
270 reference type. For example, ``int`` will return ``int&``. This behavior
271 is likely to change in the future and shouldn't be relied on.
273 * Objective-C: Same as in C.
275 ) lldb
::SBType
::GetReferenceType
;
277 %feature
("docstring",
278 "Returns the underlying type of a typedef.
280 If this type is a typedef as designated by `IsTypedefType`, then the
281 underlying type is being returned. Otherwise an invalid `SBType` is
284 Language-specific behaviour:
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.
290 ) lldb
::SBType
::GetTypedefedType
;
292 %feature
("docstring",
293 "Returns the underlying type of a reference type.
295 If this type is a reference as designated by `IsReferenceType`, then the
296 underlying type is being returned. Otherwise an invalid `SBType` is
299 Language-specific behaviour:
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.
306 ) lldb
::SBType
::GetDereferencedType
;
308 %feature
("docstring",
309 "Returns the unqualified version of this type.
311 Language-specific behaviour:
313 * C: If this type with any const or volatile specifier removed.
315 * Objective-C: Same as in C.
317 ) lldb
::SBType
::GetUnqualifiedType
;
319 %feature
("docstring",
320 "Returns the underlying integer type if this is an enumeration type.
322 If this type is an invalid `SBType` or not an enumeration type an invalid
323 `SBType` is returned.
325 Language-specific behaviour:
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.
331 ) lldb
::SBType
::GetEnumerationIntegerType
;
333 %feature
("docstring",
334 "Returns the array element type if this type is an array type.
336 Otherwise returns an invalid `SBType` if this type is invalid or not an
339 Language-specific behaviour:
341 * C: If this is an array type (see `IsArrayType`) such as ``T[]``, returns
344 * Objective-C: Same as in C.
346 See also `IsArrayType`.
348 ) lldb
::SBType
::GetArrayElementType
;
350 %feature
("docstring",
351 "Returns the array type with the given constant size.
353 Language-specific behaviour:
355 * C: Returns a constant-size array ``T[size]`` for any non-void type.
357 * Objective-C: Same as in C.
359 See also `IsArrayType` and `GetArrayElementType`.
361 ) lldb
::SBType
::GetArrayType
;
363 %feature
("docstring",
364 "Returns the vector element type if this type is a vector type.
366 Otherwise returns an invalid `SBType` if this type is invalid or not a
369 Language-specific behaviour:
371 * C: If this is a vector type (see `IsVectorType`), returns the element
374 * Objective-C: Same as in C.
376 See also `IsVectorType`.
378 ) lldb
::SBType
::GetVectorElementType
;
380 %feature
("docstring",
381 "Returns the `BasicType` value that is most appropriate to this type.
383 Returns `eBasicTypeInvalid` if no appropriate `BasicType` was found or this
384 type is invalid. See the `BasicType` documentation for the language-specific
385 meaning of each `BasicType` value.
387 **Overload behaviour:** When called with a `BasicType` parameter, the
388 following behaviour applies:
390 Returns the `SBType` that represents the passed `BasicType` value. Returns
391 an invalid `SBType` if no fitting `SBType` could be created.
393 Language-specific behaviour:
395 * C: Returns the respective builtin type. Note that some types
396 (e.g. ``__uint128_t``) might even be successfully created even if they are
397 not available on the target platform. C++ and Objective-C specific types
398 might also be created even if the target program is not written in C++ or
401 * Objective-C: Same as in C.
403 ) lldb
::SBType
::GetBasicType
;
405 %feature
("docstring",
406 "Returns the number of fields of this type.
408 Returns ``0`` if this type does not have fields.
410 Language-specific behaviour:
412 * C: Returns the number of fields if the type is a struct. If the type
413 contains an anonymous struct/union it only counts as a single field (even
414 if the struct/union contains several fields).
415 * C++: Returns the number of non-static fields if the type is a
416 struct/class. If the type contains an anonymous struct/union it only
417 counts as a single field (even if the struct/union contains several
418 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 number
420 of ivars is returned.
422 See also `GetFieldAtIndex`.
424 ) lldb
::SBType
::GetNumberOfFields
;
426 %feature
("docstring",
427 "Returns the number of base/parent classes of this type.
429 Returns ``0`` if this type doesn't have any base classes.
431 Language-specific behaviour:
433 * C: Returns always ``0``.
434 * C++: The number of direct non-virtual base classes if this type is
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 1
440 ) lldb
::SBType
::GetNumberOfDirectBaseClasses
;
442 %feature
("docstring",
443 "Returns the number of virtual base/parent classes of this type
445 Returns ``0`` if this type doesn't have any base classes.
447 Language-specific behaviour:
449 * C: Returns always ``0``.
450 * C++: The number of direct virtual base classes if this type is a
452 * Objective-C: Returns always ``0``.
454 ) lldb
::SBType
::GetNumberOfVirtualBaseClasses
;
456 %feature
("docstring",
457 "Returns the field at the given index.
459 Returns an invalid `SBType` if the index is out of range or the current
460 type doesn't have any fields.
462 Language-specific behaviour:
464 * C: Returns the field with the given index for struct types. Fields are
465 ordered/indexed starting from ``0`` for the first field in a struct (as
466 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 a
469 struct (as declared in the definition).
470 * Objective-C: Same as in C for structs. For Objective-C classes the ivar
471 with the given index is returned. ivars are indexed starting from ``0``.
473 ) lldb
::SBType
::GetFieldAtIndex
;
475 %feature
("docstring",
476 "Returns the direct base class as indexed by `GetNumberOfDirectBaseClasses`.
478 Returns an invalid SBTypeMember if the index is invalid or this SBType is
481 ) lldb
::SBType
::GetDirectBaseClassAtIndex
;
483 %feature
("docstring",
484 "Returns the virtual base class as indexed by
485 `GetNumberOfVirtualBaseClasses`.
487 Returns an invalid SBTypeMember if the index is invalid or this SBType is
490 ) lldb
::SBType
::GetVirtualBaseClassAtIndex
;
492 %feature
("docstring",
493 "Returns the `SBModule` this `SBType` belongs to.
495 Returns no `SBModule` if this type does not belong to any specific
496 `SBModule` or this `SBType` is invalid. An invalid `SBModule` might also
497 indicate that once came from an `SBModule` but LLDB could no longer
498 determine the original module.
500 ) lldb
::SBType
::GetModule
;
502 %feature
("autodoc", "GetName() -> string") lldb
::SBType
::GetName
;
504 %feature
("docstring",
505 "Returns the name of this type.
507 Returns an empty string if an error occurred or this type is invalid.
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 but
511 conflicts can occur (for example, if a C++ program contains two different
512 classes with the same name in different translation units. `GetName` can
513 return the same name for both class types.)
516 Language-specific behaviour:
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/inline
520 namespaces and all template arguments).
521 * Objective-C: Same as in C.
523 ) lldb
::SBType
::GetName
;
525 %feature
("autodoc", "GetDisplayTypeName() -> string") lldb
::SBType
::GetDisplayTypeName
;
527 %feature
("docstring",
528 "Returns the name of this type in a user-friendly format.
530 Returns an empty string if an error occurred or this type is invalid.
532 Use this function when displaying a type name to the user.
534 Language-specific behaviour:
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 hidden
539 (this functionality depends on whether LLDB can determine the template's
541 * Objective-C: Same as in C.
543 ) lldb
::SBType
::GetDisplayTypeName
;
545 %feature
("autodoc", "GetTypeClass() -> TypeClass") lldb
::SBType
::GetTypeClass
;
547 %feature
("docstring",
548 "Returns the `TypeClass` for this type.
550 Returns an `eTypeClassInvalid` if this `SBType` is invalid.
552 See `TypeClass` for the language-specific meaning of each `TypeClass` value.
554 ) lldb
::SBType
::GetTypeClass
;
556 %feature
("docstring",
557 "Returns the number of template arguments of this type.
559 Returns ``0`` if this type is not a template.
561 Language-specific behaviour:
563 * C: Always returns ``0``.
564 * C++: If this type is a class template instantiation then this returns the
565 number of template parameters that were used in this instantiation. This
566 includes both explicit and implicit template parameters.
567 * Objective-C: Always returns ``0``.
569 ) lldb
::SBType
::GetNumberOfTemplateArguments
;
571 %feature
("docstring",
572 "Returns the type of the template argument with the given index.
574 Returns an invalid `SBType` if there is no template argument with the given
575 index or this type is not a template. The first template argument has the
578 Language-specific behaviour:
580 * C: Always returns an invalid SBType.
581 * C++: If this type is a class template instantiation and the template
582 parameter with the given index is a type template parameter, then this
583 returns the type of that parameter. Otherwise returns an invalid `SBType`.
584 * Objective-C: Always returns an invalid SBType.
586 ) lldb
::SBType
::GetTemplateArgumentType
;
588 %feature
("docstring",
589 "Returns the kind of the template argument with the given index.
591 Returns `eTemplateArgumentKindNull` if there is no template argument
592 with the given index or this type is not a template. The first template
593 argument has the index ``0``.
595 Language-specific behaviour:
597 * C: Always returns `eTemplateArgumentKindNull`.
598 * C++: If this type is a class template instantiation then this returns
599 the appropriate `TemplateArgument` value for the parameter with the given
600 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`.
604 ) lldb
::SBType
::GetTemplateArgumentKind
;
606 %feature
("docstring",
607 "Returns the return type if this type represents a function.
609 Returns an invalid `SBType` if this type is not a function type or invalid.
611 Language-specific behaviour:
613 * C: For functions return the return type. Returns an invalid `SBType` if
614 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 have
617 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 this
620 returns the return type of the method.
622 ) lldb
::SBType
::GetFunctionReturnType
;
624 %feature
("docstring",
625 "Returns the list of argument types if this type represents a function.
627 Returns an invalid `SBType` if this type is not a function type or invalid.
629 Language-specific behaviour:
631 * C: For functions return the types of each parameter. Returns an invalid
632 `SBType` if this type is a function pointer. For variadic functions this
633 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.
638 ) lldb
::SBType
::GetFunctionArgumentTypes
;
640 %feature
("docstring",
641 "Returns the number of member functions of this type.
643 Returns ``0`` if an error occurred or this type is invalid.
645 Language-specific behaviour:
647 * C: Always returns ``0``.
648 * C++: If this type represents a struct/class, then the number of
649 member functions (static and non-static) is returned. The count includes
650 constructors and destructors (both explicit and implicit). Member
651 functions of base classes are not included in the count.
652 * Objective-C: If this type represents a struct/class, then the
653 number of methods is returned. Methods in categories or super classes
656 ) lldb
::SBType
::GetNumberOfMemberFunctions
;
658 %feature
("docstring",
659 "Returns the member function of this type with the given index.
661 Returns an invalid `SBTypeMemberFunction` if the index is invalid or this
664 Language-specific behaviour:
666 * C: Always returns an invalid `SBTypeMemberFunction`.
667 * C++: Returns the member function or constructor/destructor with the given
669 * Objective-C: Returns the method with the given index.
671 See `GetNumberOfMemberFunctions` for what functions can be queried by this
674 ) lldb
::SBType
::GetMemberFunctionAtIndex
;
676 %feature
("docstring",
677 "Returns true if the type is completely defined.
679 Language-specific behaviour:
681 * C: Returns false for struct types that were only forward declared in the
682 type's `SBTarget`/`SBModule`. Otherwise returns true.
683 * C++: Returns false for template/non-template struct/class types and
684 scoped enums that were only forward declared inside the type's
685 `SBTarget`/`SBModule`. Otherwise returns true.
686 * Objective-C: Follows the same behavior as C for struct types. Objective-C
687 classes are considered complete unless they were only forward declared via
688 ``@class ClassName`` in the type's `SBTarget`/`SBModule`. Otherwise
691 ) lldb
::SBType
::IsTypeComplete
;
693 %feature
("docstring",
694 "Returns the `TypeFlags` values for this type.
696 See the respective `TypeFlags` values for what values can be set. Returns an
697 integer in which each `TypeFlags` value is represented by a bit. Specific
698 flags can be checked via Python's bitwise operators. For example, the
699 `eTypeIsInteger` flag can be checked like this:
701 ``(an_sb_type.GetTypeFlags() & lldb.eTypeIsInteger) != 0``
703 If this type is invalid this returns ``0``.
705 See the different values for `TypeFlags` for the language-specific meanings
706 of each `TypeFlags` value.
708 ) lldb
::SBType
::GetTypeFlags
;
710 %feature
("docstring",
711 "Searches for a directly nested type that has the provided name.
713 Returns the type if it was found.
714 Returns invalid type if nothing was found.
716 ) lldb
::SBType
::FindDirectNestedType
;
718 %feature
("docstring",
719 "Represents a list of :py:class:`SBType` s.
721 The FindTypes() method of :py:class:`SBTarget`/:py:class:`SBModule` returns a SBTypeList.
723 SBTypeList supports :py:class:`SBType` iteration. For example,
733 Task(int i, Task *n):
739 .. code-block:: python
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 type