2 /* Internal type definitions for GDB.
4 Copyright (C) 1992-2024 Free Software Foundation, Inc.
6 Contributed by Cygnus Support, using pieces from other GDB modules.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #if !defined (GDBTYPES_H)
26 /* * \page gdbtypes GDB Types
28 GDB represents all the different kinds of types in programming
29 languages using a common representation defined in gdbtypes.h.
31 The main data structure is main_type; it consists of a code (such
32 as #TYPE_CODE_ENUM for enumeration types), a number of
33 generally-useful fields such as the printable name, and finally a
34 field main_type::type_specific that is a union of info specific to
35 particular languages or other special cases (such as calling
38 The available type codes are defined in enum #type_code. The enum
39 includes codes both for types that are common across a variety
40 of languages, and for types that are language-specific.
42 Most accesses to type fields go through macros such as
43 #TYPE_CODE(thistype) and #TYPE_FN_FIELD_CONST(thisfn, n). These are
44 written such that they can be used as both rvalues and lvalues.
48 #include "gdbsupport/array-view.h"
49 #include "gdbsupport/gdb-hashtab.h"
51 #include "gdbsupport/offset-type.h"
52 #include "gdbsupport/enum-flags.h"
53 #include "gdbsupport/underlying.h"
54 #include "gdbsupport/print-utils.h"
55 #include "gdbsupport/function-view.h"
57 #include "gdbsupport/gdb_obstack.h"
58 #include "gmp-utils.h"
60 /* Forward declarations for prototypes. */
63 struct value_print_options
;
65 struct dwarf2_per_cu_data
;
66 struct dwarf2_per_objfile
;
67 struct dwarf2_property_baton
;
69 /* * Different kinds of data types are distinguished by the `code'
74 TYPE_CODE_UNDEF
= 0, /**< Not used; catches errors */
77 #include "type-codes.def"
82 /* * Some bits for the type's instance_flags word. See the macros
83 below for documentation on each bit. */
85 enum type_instance_flag_value
: unsigned
87 TYPE_INSTANCE_FLAG_CONST
= (1 << 0),
88 TYPE_INSTANCE_FLAG_VOLATILE
= (1 << 1),
89 TYPE_INSTANCE_FLAG_CODE_SPACE
= (1 << 2),
90 TYPE_INSTANCE_FLAG_DATA_SPACE
= (1 << 3),
91 TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1
= (1 << 4),
92 TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2
= (1 << 5),
93 TYPE_INSTANCE_FLAG_NOTTEXT
= (1 << 6),
94 TYPE_INSTANCE_FLAG_RESTRICT
= (1 << 7),
95 TYPE_INSTANCE_FLAG_ATOMIC
= (1 << 8)
98 DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value
, type_instance_flags
);
100 /* * Not textual. By default, GDB treats all single byte integers as
101 characters (or elements of strings) unless this flag is set. */
103 #define TYPE_NOTTEXT(t) (((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_NOTTEXT)
105 /* * Constant type. If this is set, the corresponding type has a
108 #define TYPE_CONST(t) ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_CONST) != 0)
110 /* * Volatile type. If this is set, the corresponding type has a
111 volatile modifier. */
113 #define TYPE_VOLATILE(t) \
114 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_VOLATILE) != 0)
116 /* * Restrict type. If this is set, the corresponding type has a
117 restrict modifier. */
119 #define TYPE_RESTRICT(t) \
120 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_RESTRICT) != 0)
122 /* * Atomic type. If this is set, the corresponding type has an
125 #define TYPE_ATOMIC(t) \
126 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_ATOMIC) != 0)
128 /* * True if this type represents either an lvalue or lvalue reference type. */
130 #define TYPE_IS_REFERENCE(t) \
131 ((t)->code () == TYPE_CODE_REF || (t)->code () == TYPE_CODE_RVALUE_REF)
133 /* * True if this type is allocatable. */
134 #define TYPE_IS_ALLOCATABLE(t) \
135 ((t)->dyn_prop (DYN_PROP_ALLOCATED) != NULL)
137 /* * True if this type has variant parts. */
138 #define TYPE_HAS_VARIANT_PARTS(t) \
139 ((t)->dyn_prop (DYN_PROP_VARIANT_PARTS) != nullptr)
141 /* * True if this type has a dynamic length. */
142 #define TYPE_HAS_DYNAMIC_LENGTH(t) \
143 ((t)->dyn_prop (DYN_PROP_BYTE_SIZE) != nullptr)
145 /* * Instruction-space delimited type. This is for Harvard architectures
146 which have separate instruction and data address spaces (and perhaps
149 GDB usually defines a flat address space that is a superset of the
150 architecture's two (or more) address spaces, but this is an extension
151 of the architecture's model.
153 If TYPE_INSTANCE_FLAG_CODE_SPACE is set, an object of the corresponding type
154 resides in instruction memory, even if its address (in the extended
155 flat address space) does not reflect this.
157 Similarly, if TYPE_INSTANCE_FLAG_DATA_SPACE is set, then an object of the
158 corresponding type resides in the data memory space, even if
159 this is not indicated by its (flat address space) address.
161 If neither flag is set, the default space for functions / methods
162 is instruction space, and for data objects is data memory. */
164 #define TYPE_CODE_SPACE(t) \
165 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_CODE_SPACE) != 0)
167 #define TYPE_DATA_SPACE(t) \
168 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_DATA_SPACE) != 0)
170 /* * Address class flags. Some environments provide for pointers
171 whose size is different from that of a normal pointer or address
172 types where the bits are interpreted differently than normal
173 addresses. The TYPE_INSTANCE_FLAG_ADDRESS_CLASS_n flags may be used in
174 target specific ways to represent these different types of address
177 #define TYPE_ADDRESS_CLASS_1(t) (((t)->instance_flags ()) \
178 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
179 #define TYPE_ADDRESS_CLASS_2(t) (((t)->instance_flags ()) \
180 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2)
181 #define TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL \
182 (TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 | TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2)
183 #define TYPE_ADDRESS_CLASS_ALL(t) (((t)->instance_flags ()) \
184 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL)
186 /* * Information about a single discriminant. */
188 struct discriminant_range
190 /* * The range of values for the variant. This is an inclusive
194 /* * Return true if VALUE is contained in this range. IS_UNSIGNED
195 is true if this should be an unsigned comparison; false for
197 bool contains (ULONGEST value
, bool is_unsigned
) const
200 return value
>= low
&& value
<= high
;
201 LONGEST valuel
= (LONGEST
) value
;
202 return valuel
>= (LONGEST
) low
&& valuel
<= (LONGEST
) high
;
208 /* * A single variant. A variant has a list of discriminant values.
209 When the discriminator matches one of these, the variant is
210 enabled. Each variant controls zero or more fields; and may also
211 control other variant parts as well. This struct corresponds to
212 DW_TAG_variant in DWARF. */
214 struct variant
: allocate_on_obstack
<variant
>
216 /* * The discriminant ranges for this variant. */
217 gdb::array_view
<discriminant_range
> discriminants
;
219 /* * The fields controlled by this variant. This is inclusive on
220 the low end and exclusive on the high end. A variant may not
221 control any fields, in which case the two values will be equal.
222 These are indexes into the type's array of fields. */
226 /* * Variant parts controlled by this variant. */
227 gdb::array_view
<variant_part
> parts
;
229 /* * Return true if this is the default variant. The default
230 variant can be recognized because it has no associated
232 bool is_default () const
234 return discriminants
.empty ();
237 /* * Return true if this variant matches VALUE. IS_UNSIGNED is true
238 if this should be an unsigned comparison; false for signed. */
239 bool matches (ULONGEST value
, bool is_unsigned
) const;
242 /* * A variant part. Each variant part has an optional discriminant
243 and holds an array of variants. This struct corresponds to
244 DW_TAG_variant_part in DWARF. */
246 struct variant_part
: allocate_on_obstack
<variant_part
>
248 /* * The index of the discriminant field in the outer type. This is
249 an index into the type's array of fields. If this is -1, there
250 is no discriminant, and only the default variant can be
251 considered to be selected. */
252 int discriminant_index
;
254 /* * True if this discriminant is unsigned; false if signed. This
255 comes from the type of the discriminant. */
258 /* * The variants that are controlled by this variant part. Note
259 that these will always be sorted by field number. */
260 gdb::array_view
<variant
> variants
;
264 enum dynamic_prop_kind
266 PROP_UNDEFINED
, /* Not defined. */
267 PROP_CONST
, /* Constant. */
268 PROP_ADDR_OFFSET
, /* Address offset. */
269 PROP_LOCEXPR
, /* Location expression. */
270 PROP_LOCLIST
, /* Location list. */
271 PROP_VARIANT_PARTS
, /* Variant parts. */
272 PROP_TYPE
, /* Type. */
273 PROP_VARIABLE_NAME
, /* Variable name. */
274 PROP_OPTIMIZED_OUT
, /* Optimized out. */
277 union dynamic_prop_data
279 /* Storage for constant property. */
283 /* Storage for dynamic property. */
285 const dwarf2_property_baton
*baton
;
287 /* Storage of variant parts for a type. A type with variant parts
288 has all its fields "linearized" -- stored in a single field
289 array, just as if they had all been declared that way. The
290 variant parts are attached via a dynamic property, and then are
291 used to control which fields end up in the final type during
292 dynamic type resolution. */
294 const gdb::array_view
<variant_part
> *variant_parts
;
296 /* Once a variant type is resolved, we may want to be able to go
297 from the resolved type to the original type. In this case we
298 rewrite the property's kind and set this field. */
300 struct type
*original_type
;
302 /* Name of a variable to look up; the variable holds the value of
305 const char *variable_name
;
308 /* * Used to store a dynamic property. */
312 dynamic_prop_kind
kind () const
317 void set_undefined ()
319 m_kind
= PROP_UNDEFINED
;
322 void set_optimized_out ()
324 m_kind
= PROP_OPTIMIZED_OUT
;
327 /* Return true if this property is "available", at least in theory
328 -- meaning it is neither undefined nor optimized out. */
329 bool is_available () const
331 return m_kind
!= PROP_UNDEFINED
&& m_kind
!= PROP_OPTIMIZED_OUT
;
334 LONGEST
const_val () const
336 gdb_assert (m_kind
== PROP_CONST
);
338 return m_data
.const_val
;
341 void set_const_val (LONGEST const_val
)
344 m_data
.const_val
= const_val
;
347 /* Return true if this property has a constant value, false
349 bool is_constant () const
350 { return m_kind
== PROP_CONST
; }
352 const dwarf2_property_baton
*baton () const
354 gdb_assert (m_kind
== PROP_LOCEXPR
355 || m_kind
== PROP_LOCLIST
356 || m_kind
== PROP_ADDR_OFFSET
);
361 void set_locexpr (const dwarf2_property_baton
*baton
)
363 m_kind
= PROP_LOCEXPR
;
364 m_data
.baton
= baton
;
367 void set_loclist (const dwarf2_property_baton
*baton
)
369 m_kind
= PROP_LOCLIST
;
370 m_data
.baton
= baton
;
373 void set_addr_offset (const dwarf2_property_baton
*baton
)
375 m_kind
= PROP_ADDR_OFFSET
;
376 m_data
.baton
= baton
;
379 const gdb::array_view
<variant_part
> *variant_parts () const
381 gdb_assert (m_kind
== PROP_VARIANT_PARTS
);
383 return m_data
.variant_parts
;
386 void set_variant_parts (gdb::array_view
<variant_part
> *variant_parts
)
388 m_kind
= PROP_VARIANT_PARTS
;
389 m_data
.variant_parts
= variant_parts
;
392 struct type
*original_type () const
394 gdb_assert (m_kind
== PROP_TYPE
);
396 return m_data
.original_type
;
399 void set_original_type (struct type
*original_type
)
402 m_data
.original_type
= original_type
;
405 /* Return the name of the variable that holds this property's value.
406 Only valid for PROP_VARIABLE_NAME. */
407 const char *variable_name () const
409 gdb_assert (m_kind
== PROP_VARIABLE_NAME
);
410 return m_data
.variable_name
;
413 /* Set the name of the variable that holds this property's value,
414 and set this property to be of kind PROP_VARIABLE_NAME. */
415 void set_variable_name (const char *name
)
417 m_kind
= PROP_VARIABLE_NAME
;
418 m_data
.variable_name
= name
;
421 /* Determine which field of the union dynamic_prop.data is used. */
422 enum dynamic_prop_kind m_kind
;
424 /* Storage for dynamic or static value. */
425 union dynamic_prop_data m_data
;
428 /* Compare two dynamic_prop objects for equality. dynamic_prop
429 instances are equal iff they have the same type and storage. */
430 extern bool operator== (const dynamic_prop
&l
, const dynamic_prop
&r
);
432 /* Compare two dynamic_prop objects for inequality. */
433 static inline bool operator!= (const dynamic_prop
&l
, const dynamic_prop
&r
)
438 /* * Define a type's dynamic property node kind. */
439 enum dynamic_prop_node_kind
441 /* A property providing a type's data location.
442 Evaluating this field yields to the location of an object's data. */
443 DYN_PROP_DATA_LOCATION
,
445 /* A property representing DW_AT_allocated. The presence of this attribute
446 indicates that the object of the type can be allocated/deallocated. */
449 /* A property representing DW_AT_associated. The presence of this attribute
450 indicated that the object of the type can be associated. */
453 /* A property providing an array's byte stride. */
454 DYN_PROP_BYTE_STRIDE
,
456 /* A property holding variant parts. */
457 DYN_PROP_VARIANT_PARTS
,
459 /* A property representing DW_AT_rank. The presence of this attribute
460 indicates that the object is of assumed rank array type. */
463 /* A property holding the size of the type. */
467 /* * List for dynamic type attributes. */
468 struct dynamic_prop_list
470 /* The kind of dynamic prop in this node. */
471 enum dynamic_prop_node_kind prop_kind
;
473 /* The dynamic property itself. */
474 struct dynamic_prop prop
;
476 /* A pointer to the next dynamic property. */
477 struct dynamic_prop_list
*next
;
480 /* * Determine which field of the union main_type.fields[x].loc is
485 FIELD_LOC_KIND_BITPOS
, /**< bitpos */
486 FIELD_LOC_KIND_ENUMVAL
, /**< enumval */
487 FIELD_LOC_KIND_PHYSADDR
, /**< physaddr */
488 FIELD_LOC_KIND_PHYSNAME
, /**< physname */
489 FIELD_LOC_KIND_DWARF_BLOCK
/**< dwarf_block */
492 /* * A discriminant to determine which field in the
493 main_type.type_specific union is being used, if any.
495 For types such as TYPE_CODE_FLT, the use of this
496 discriminant is really redundant, as we know from the type code
497 which field is going to be used. As such, it would be possible to
498 reduce the size of this enum in order to save a bit or two for
499 other fields of struct main_type. But, since we still have extra
500 room , and for the sake of clarity and consistency, we treat all fields
501 of the union the same way. */
503 enum type_specific_kind
506 TYPE_SPECIFIC_CPLUS_STUFF
,
507 TYPE_SPECIFIC_GNAT_STUFF
,
508 TYPE_SPECIFIC_FLOATFORMAT
,
509 /* Note: This is used by TYPE_CODE_FUNC and TYPE_CODE_METHOD. */
511 TYPE_SPECIFIC_SELF_TYPE
,
513 TYPE_SPECIFIC_FIXED_POINT
,
518 struct objfile
*objfile
;
519 struct gdbarch
*gdbarch
;
524 /* * Position of this field, counting in bits from start of
525 containing structure. For big-endian targets, it is the bit
526 offset to the MSB. For little-endian targets, it is the bit
527 offset to the LSB. */
534 /* * For a static field, if TYPE_FIELD_STATIC_HAS_ADDR then
535 physaddr is the location (in the target) of the static
536 field. Otherwise, physname is the mangled label of the
540 const char *physname
;
542 /* * The field location can be computed by evaluating the
543 following DWARF block. Its DATA is allocated on
544 objfile_obstack - no CU load is needed to access it. */
546 struct dwarf2_locexpr_baton
*dwarf_block
;
549 /* Accessibility of a member. */
550 enum class accessibility
: unsigned char
552 /* It's important that this be 0 so that fields default to
561 struct type
*type () const
566 void set_type (struct type
*type
)
571 const char *name () const
576 void set_name (const char *name
)
581 bool is_artificial () const
586 void set_is_artificial (bool is_artificial
)
588 m_artificial
= is_artificial
;
591 unsigned int bitsize () const
596 void set_bitsize (unsigned int bitsize
)
601 bool is_packed () const
603 return m_bitsize
!= 0;
606 /* Return true if this field is static; false if not. */
607 bool is_static () const
609 /* "static" fields are the fields whose location is not relative
610 to the address of the enclosing struct. It would be nice to
611 have a dedicated flag that would be set for static fields when
612 the type is being created. But in practice, checking the field
613 loc_kind should give us an accurate answer. */
614 return (m_loc_kind
== FIELD_LOC_KIND_PHYSNAME
615 || m_loc_kind
== FIELD_LOC_KIND_PHYSADDR
);
618 /* Location getters / setters. */
620 field_loc_kind
loc_kind () const
625 LONGEST
loc_bitpos () const
627 gdb_assert (m_loc_kind
== FIELD_LOC_KIND_BITPOS
);
631 void set_loc_bitpos (LONGEST bitpos
)
633 m_loc_kind
= FIELD_LOC_KIND_BITPOS
;
634 m_loc
.bitpos
= bitpos
;
637 LONGEST
loc_enumval () const
639 gdb_assert (m_loc_kind
== FIELD_LOC_KIND_ENUMVAL
);
640 return m_loc
.enumval
;
643 void set_loc_enumval (LONGEST enumval
)
645 m_loc_kind
= FIELD_LOC_KIND_ENUMVAL
;
646 m_loc
.enumval
= enumval
;
649 CORE_ADDR
loc_physaddr () const
651 gdb_assert (m_loc_kind
== FIELD_LOC_KIND_PHYSADDR
);
652 return m_loc
.physaddr
;
655 void set_loc_physaddr (CORE_ADDR physaddr
)
657 m_loc_kind
= FIELD_LOC_KIND_PHYSADDR
;
658 m_loc
.physaddr
= physaddr
;
661 const char *loc_physname () const
663 gdb_assert (m_loc_kind
== FIELD_LOC_KIND_PHYSNAME
);
664 return m_loc
.physname
;
667 void set_loc_physname (const char *physname
)
669 m_loc_kind
= FIELD_LOC_KIND_PHYSNAME
;
670 m_loc
.physname
= physname
;
673 dwarf2_locexpr_baton
*loc_dwarf_block () const
675 gdb_assert (m_loc_kind
== FIELD_LOC_KIND_DWARF_BLOCK
);
676 return m_loc
.dwarf_block
;
679 void set_loc_dwarf_block (dwarf2_locexpr_baton
*dwarf_block
)
681 m_loc_kind
= FIELD_LOC_KIND_DWARF_BLOCK
;
682 m_loc
.dwarf_block
= dwarf_block
;
685 /* Set the field's accessibility. */
686 void set_accessibility (accessibility acc
)
687 { m_accessibility
= acc
; }
689 /* Fetch the field's accessibility. */
690 enum accessibility
accessibility () const
691 { return m_accessibility
; }
693 /* True if this field is 'public'. */
694 bool is_public () const
695 { return m_accessibility
== accessibility::PUBLIC
; }
697 /* True if this field is 'private'. */
698 bool is_private () const
699 { return m_accessibility
== accessibility::PRIVATE
; }
701 /* True if this field is 'protected'. */
702 bool is_protected () const
703 { return m_accessibility
== accessibility::PROTECTED
; }
705 /* True if this field is 'virtual'. */
706 bool is_virtual () const
707 { return m_virtual
; }
709 /* Set the field's "virtual" flag. */
711 { m_virtual
= true; }
713 /* True if this field is 'ignored'. */
714 bool is_ignored () const
715 { return m_ignored
; }
717 /* Set the field's "ignored" flag. Note that the 'ignored' bit is
718 deprecated. It was used by some unknown stabs generator, and has
719 been replaced by the optimized-out approach -- however, it
720 remains because the stabs reader was never updated. */
722 { m_ignored
= true; }
724 union field_location m_loc
;
726 /* * For a function or member type, this is 1 if the argument is
727 marked artificial. Artificial arguments should not be shown
728 to the user. For TYPE_CODE_RANGE it is set if the specific
729 bound is not defined. */
731 unsigned int m_artificial
: 1;
733 /* Whether the field is 'virtual'. */
735 /* Whether the field is 'ignored'. */
738 /* * Discriminant for union field_location. */
740 ENUM_BITFIELD(field_loc_kind
) m_loc_kind
: 3;
742 /* Accessibility of the field. */
743 enum accessibility m_accessibility
;
745 /* * Size of this field, in bits, or zero if not packed.
746 If non-zero in an array type, indicates the element size in
747 bits (used only in Ada at the moment).
748 For an unpacked field, the field's type's length
749 says how many bytes the field occupies. */
751 unsigned int m_bitsize
;
753 /* * In a struct or union type, type of this field.
754 - In a function or member type, type of this argument.
755 - In an array type, the domain-type of the array. */
759 /* * Name of field, value or argument.
760 NULL for range bounds, array domains, and member function
768 ULONGEST
bit_stride () const
770 if (this->flag_is_byte_stride
)
771 return this->stride
.const_val () * 8;
773 return this->stride
.const_val ();
776 /* Return true if either bounds is optimized out. */
777 bool optimized_out () const
779 return (low
.kind () == PROP_OPTIMIZED_OUT
780 || high
.kind () == PROP_OPTIMIZED_OUT
);
783 /* * Low bound of range. */
785 struct dynamic_prop low
;
787 /* * High bound of range. */
789 struct dynamic_prop high
;
791 /* The stride value for this range. This can be stored in bits or bytes
792 based on the value of BYTE_STRIDE_P. It is optional to have a stride
793 value, if this range has no stride value defined then this will be set
794 to the constant zero. */
796 struct dynamic_prop stride
;
798 /* * The bias. Sometimes a range value is biased before storage.
799 The bias is added to the stored bits to form the true value. */
803 /* True if HIGH range bound contains the number of elements in the
804 subrange. This affects how the final high bound is computed. */
806 unsigned int flag_upper_bound_is_count
: 1;
808 /* True if LOW or/and HIGH are resolved into a static bound from
811 unsigned int flag_bound_evaluated
: 1;
813 /* If this is true this STRIDE is in bytes, otherwise STRIDE is in bits. */
815 unsigned int flag_is_byte_stride
: 1;
818 /* Compare two range_bounds objects for equality. Simply does
819 memberwise comparison. */
820 extern bool operator== (const range_bounds
&l
, const range_bounds
&r
);
822 /* Compare two range_bounds objects for inequality. */
823 static inline bool operator!= (const range_bounds
&l
, const range_bounds
&r
)
830 /* * CPLUS_STUFF is for TYPE_CODE_STRUCT. It is initialized to
831 point to cplus_struct_default, a default static instance of a
832 struct cplus_struct_type. */
834 struct cplus_struct_type
*cplus_stuff
;
836 /* * GNAT_STUFF is for types for which the GNAT Ada compiler
837 provides additional information. */
839 struct gnat_aux_type
*gnat_stuff
;
841 /* * FLOATFORMAT is for TYPE_CODE_FLT. It is a pointer to a
842 floatformat object that describes the floating-point value
843 that resides within the type. */
845 const struct floatformat
*floatformat
;
847 /* * For TYPE_CODE_FUNC and TYPE_CODE_METHOD types. */
849 struct func_type
*func_stuff
;
851 /* * For types that are pointer to member types (TYPE_CODE_METHODPTR,
852 TYPE_CODE_MEMBERPTR), SELF_TYPE is the type that this pointer
855 struct type
*self_type
;
857 /* * For TYPE_CODE_FIXED_POINT types, the info necessary to decode
858 values of that type. */
859 struct fixed_point_type_info
*fixed_point_info
;
861 /* * An integer-like scalar type may be stored in just part of its
862 enclosing storage bytes. This structure describes this
866 /* * The bit size of the integer. This can be 0. For integers
867 that fill their storage (the ordinary case), this field holds
868 the byte size times 8. */
869 unsigned short bit_size
;
870 /* * The bit offset of the integer. This is ordinarily 0, and can
871 only be non-zero if the bit size is less than the storage
873 unsigned short bit_offset
;
877 /* * Main structure representing a type in GDB.
879 This structure is space-critical. Its layout has been tweaked to
880 reduce the space used. */
884 /* * Code for kind of type. */
886 ENUM_BITFIELD(type_code
) code
: 8;
888 /* * Flags about this type. These fields appear at this location
889 because they packs nicely here. See the TYPE_* macros for
890 documentation about these fields. */
892 unsigned int m_flag_unsigned
: 1;
893 unsigned int m_flag_nosign
: 1;
894 unsigned int m_flag_stub
: 1;
895 unsigned int m_flag_target_stub
: 1;
896 unsigned int m_flag_prototyped
: 1;
897 unsigned int m_flag_varargs
: 1;
898 unsigned int m_flag_vector
: 1;
899 unsigned int m_flag_stub_supported
: 1;
900 unsigned int m_flag_gnu_ifunc
: 1;
901 unsigned int m_flag_fixed_instance
: 1;
902 unsigned int m_flag_objfile_owned
: 1;
903 unsigned int m_flag_endianity_not_default
: 1;
905 /* * True if this type was declared with "class" rather than
908 unsigned int m_flag_declared_class
: 1;
910 /* * True if this is an enum type with disjoint values. This
911 affects how the enum is printed. */
913 unsigned int m_flag_flag_enum
: 1;
915 /* * For TYPE_CODE_ARRAY, this is true if this type is part of a
916 multi-dimensional array. Multi-dimensional arrays are
917 represented internally as arrays of arrays, and this flag lets
918 gdb distinguish between multiple dimensions and an ordinary array
919 of arrays. The flag is set on each inner dimension, but not the
920 outermost dimension. */
922 unsigned int m_multi_dimensional
: 1;
924 /* * A discriminant telling us which field of the type_specific
925 union is being used for this type, if any. */
927 ENUM_BITFIELD(type_specific_kind
) type_specific_field
: 3;
929 /* The language for this type. */
931 ENUM_BITFIELD(language
) m_lang
: LANGUAGE_BITS
;
933 /* * Number of fields described for this type. This field appears
934 at this location because it packs nicely here. */
936 unsigned int m_nfields
;
938 /* * Name of this type, or NULL if none.
940 This is used for printing only. For looking up a name, look for
941 a symbol in the VAR_DOMAIN. This is generally allocated in the
942 objfile's obstack. However coffread.c uses malloc. */
946 /* * Every type is now associated with a particular objfile, and the
947 type is allocated on the objfile_obstack for that objfile. One
948 problem however, is that there are times when gdb allocates new
949 types while it is not in the process of reading symbols from a
950 particular objfile. Fortunately, these happen when the type
951 being created is a derived type of an existing type, such as in
952 lookup_pointer_type(). So we can just allocate the new type
953 using the same objfile as the existing type, but to do this we
954 need a backpointer to the objfile from the existing type. Yes
955 this is somewhat ugly, but without major overhaul of the internal
956 type system, it can't be avoided for now. */
958 union type_owner m_owner
;
960 /* * For a pointer type, describes the type of object pointed to.
961 - For an array type, describes the type of the elements.
962 - For a function or method type, describes the type of the return value.
963 - For a range type, describes the type of the full range.
964 - For a complex type, describes the type of each coordinate.
965 - For a special record or union type encoding a dynamic-sized type
966 in GNAT, a memoized pointer to a corresponding static version of
968 - Unused otherwise. */
970 struct type
*m_target_type
;
972 /* * For structure and union types, a description of each field.
973 For set and pascal array types, there is one "field",
974 whose type is the domain type of the set or array.
975 For range types, there are two "fields",
976 the minimum and maximum values (both inclusive).
977 For enum types, each possible value is described by one "field".
978 For a function or method type, a "field" for each parameter.
979 For C++ classes, there is one field for each base class (if it is
980 a derived class) plus one field for each class data member. Member
981 functions are recorded elsewhere.
983 Using a pointer to a separate array of fields
984 allows all types to have the same size, which is useful
985 because we can allocate the space for a type before
986 we know what to put in it. */
990 struct field
*fields
;
992 /* * Union member used for range types. */
994 struct range_bounds
*bounds
;
996 /* If this is a scalar type, then this is its corresponding
998 struct type
*complex_type
;
1002 /* * Slot to point to additional language-specific fields of this
1005 union type_specific type_specific
;
1007 /* * Contains all dynamic type properties. */
1008 struct dynamic_prop_list
*dyn_prop_list
;
1011 /* * Number of bits allocated for alignment. */
1013 #define TYPE_ALIGN_BITS 8
1015 /* * A ``struct type'' describes a particular instance of a type, with
1016 some particular qualification. */
1020 /* Get the type code of this type.
1022 Note that the code can be TYPE_CODE_TYPEDEF, so if you want the real
1023 type, you need to do `check_typedef (type)->code ()`. */
1024 type_code
code () const
1026 return this->main_type
->code
;
1029 /* Set the type code of this type. */
1030 void set_code (type_code code
)
1032 this->main_type
->code
= code
;
1035 /* Get the name of this type. */
1036 const char *name () const
1038 return this->main_type
->name
;
1041 /* Set the name of this type. */
1042 void set_name (const char *name
)
1044 this->main_type
->name
= name
;
1047 /* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
1048 But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
1049 so you only have to call check_typedef once. Since value::allocate
1050 calls check_typedef, X->type ()->length () is safe. */
1051 ULONGEST
length () const
1053 return this->m_length
;
1056 void set_length (ULONGEST length
)
1058 this->m_length
= length
;
1061 /* Get the number of fields of this type. */
1062 unsigned int num_fields () const
1064 return this->main_type
->m_nfields
;
1067 /* Set the number of fields of this type. */
1068 void set_num_fields (unsigned int num_fields
)
1070 this->main_type
->m_nfields
= num_fields
;
1073 /* Get the fields array of this type. */
1074 struct field
*fields () const
1076 return this->main_type
->flds_bnds
.fields
;
1079 /* Get the field at index IDX. */
1080 struct field
&field (int idx
) const
1082 gdb_assert (idx
>= 0 && idx
< num_fields ());
1083 return this->fields ()[idx
];
1086 /* Set the fields array of this type. */
1087 void set_fields (struct field
*fields
)
1089 this->main_type
->flds_bnds
.fields
= fields
;
1092 /* Allocate the fields array of this type, with NFIELDS elements. If INIT,
1093 zero-initialize the allocated memory. */
1094 void alloc_fields (unsigned int nfields
, bool init
= true);
1096 /* Allocate the fields array of this type, and copy the fields from SRC. */
1097 void copy_fields (struct type
*src
);
1098 void copy_fields (std::vector
<struct field
> &src
);
1100 type
*index_type () const
1102 return this->field (0).type ();
1105 struct type
*target_type () const
1107 return this->main_type
->m_target_type
;
1110 void set_target_type (struct type
*target_type
)
1112 this->main_type
->m_target_type
= target_type
;
1115 void set_index_type (type
*index_type
)
1117 this->field (0).set_type (index_type
);
1120 /* Return the instance flags converted to the correct type. */
1121 const type_instance_flags
instance_flags () const
1123 return (enum type_instance_flag_value
) this->m_instance_flags
;
1126 /* Set the instance flags. */
1127 void set_instance_flags (type_instance_flags flags
)
1129 this->m_instance_flags
= flags
;
1132 /* Get the bounds bounds of this type. The type must be a range type. */
1133 range_bounds
*bounds () const
1135 switch (this->code ())
1137 case TYPE_CODE_RANGE
:
1138 return this->main_type
->flds_bnds
.bounds
;
1140 case TYPE_CODE_ARRAY
:
1141 case TYPE_CODE_STRING
:
1142 return this->index_type ()->bounds ();
1145 gdb_assert_not_reached
1146 ("type::bounds called on type with invalid code");
1150 /* Set the bounds of this type. The type must be a range type. */
1151 void set_bounds (range_bounds
*bounds
)
1153 gdb_assert (this->code () == TYPE_CODE_RANGE
);
1155 this->main_type
->flds_bnds
.bounds
= bounds
;
1158 /* Return true if this type's bounds were optimized out. */
1159 bool bound_optimized_out () const
1161 return bounds ()->optimized_out ();
1164 ULONGEST
bit_stride () const
1166 if (this->code () == TYPE_CODE_ARRAY
&& this->field (0).bitsize () != 0)
1167 return this->field (0).bitsize ();
1168 return this->bounds ()->bit_stride ();
1171 /* Unsigned integer type. If this is not set for a TYPE_CODE_INT,
1172 the type is signed (unless TYPE_NOSIGN is set). */
1174 bool is_unsigned () const
1176 return this->main_type
->m_flag_unsigned
;
1179 void set_is_unsigned (bool is_unsigned
)
1181 this->main_type
->m_flag_unsigned
= is_unsigned
;
1184 /* No sign for this type. In C++, "char", "signed char", and
1185 "unsigned char" are distinct types; so we need an extra flag to
1186 indicate the absence of a sign! */
1188 bool has_no_signedness () const
1190 return this->main_type
->m_flag_nosign
;
1193 void set_has_no_signedness (bool has_no_signedness
)
1195 this->main_type
->m_flag_nosign
= has_no_signedness
;
1198 /* This appears in a type's flags word if it is a stub type (e.g.,
1199 if someone referenced a type that wasn't defined in a source file
1200 via (struct sir_not_appearing_in_this_film *)). */
1202 bool is_stub () const
1204 return this->main_type
->m_flag_stub
;
1207 void set_is_stub (bool is_stub
)
1209 this->main_type
->m_flag_stub
= is_stub
;
1212 /* The target type of this type is a stub type, and this type needs
1213 to be updated if it gets un-stubbed in check_typedef. Used for
1214 arrays and ranges, in which TYPE_LENGTH of the array/range gets set
1215 based on the TYPE_LENGTH of the target type. Also, set for
1216 TYPE_CODE_TYPEDEF. */
1218 bool target_is_stub () const
1220 return this->main_type
->m_flag_target_stub
;
1223 void set_target_is_stub (bool target_is_stub
)
1225 this->main_type
->m_flag_target_stub
= target_is_stub
;
1228 /* This is a function type which appears to have a prototype. We
1229 need this for function calls in order to tell us if it's necessary
1230 to coerce the args, or to just do the standard conversions. This
1231 is used with a short field. */
1233 bool is_prototyped () const
1235 return this->main_type
->m_flag_prototyped
;
1238 void set_is_prototyped (bool is_prototyped
)
1240 this->main_type
->m_flag_prototyped
= is_prototyped
;
1243 /* FIXME drow/2002-06-03: Only used for methods, but applies as well
1246 bool has_varargs () const
1248 return this->main_type
->m_flag_varargs
;
1251 void set_has_varargs (bool has_varargs
)
1253 this->main_type
->m_flag_varargs
= has_varargs
;
1256 /* Identify a vector type. Gcc is handling this by adding an extra
1257 attribute to the array type. We slurp that in as a new flag of a
1258 type. This is used only in dwarf2read.c. */
1260 bool is_vector () const
1262 return this->main_type
->m_flag_vector
;
1265 void set_is_vector (bool is_vector
)
1267 this->main_type
->m_flag_vector
= is_vector
;
1270 /* This debug target supports TYPE_STUB(t). In the unsupported case
1271 we have to rely on NFIELDS to be zero etc., see TYPE_IS_OPAQUE().
1272 TYPE_STUB(t) with !TYPE_STUB_SUPPORTED(t) may exist if we only
1273 guessed the TYPE_STUB(t) value (see dwarfread.c). */
1275 bool stub_is_supported () const
1277 return this->main_type
->m_flag_stub_supported
;
1280 void set_stub_is_supported (bool stub_is_supported
)
1282 this->main_type
->m_flag_stub_supported
= stub_is_supported
;
1285 /* Used only for TYPE_CODE_FUNC where it specifies the real function
1286 address is returned by this function call. The target_type method
1287 determines the final returned function type to be presented to
1290 bool is_gnu_ifunc () const
1292 return this->main_type
->m_flag_gnu_ifunc
;
1295 void set_is_gnu_ifunc (bool is_gnu_ifunc
)
1297 this->main_type
->m_flag_gnu_ifunc
= is_gnu_ifunc
;
1300 /* The debugging formats (especially STABS) do not contain enough
1301 information to represent all Ada types---especially those whose
1302 size depends on dynamic quantities. Therefore, the GNAT Ada
1303 compiler includes extra information in the form of additional type
1304 definitions connected by naming conventions. This flag indicates
1305 that the type is an ordinary (unencoded) GDB type that has been
1306 created from the necessary run-time information, and does not need
1307 further interpretation. Optionally marks ordinary, fixed-size GDB
1310 bool is_fixed_instance () const
1312 return this->main_type
->m_flag_fixed_instance
;
1315 void set_is_fixed_instance (bool is_fixed_instance
)
1317 this->main_type
->m_flag_fixed_instance
= is_fixed_instance
;
1320 /* A compiler may supply dwarf instrumentation that indicates the desired
1321 endian interpretation of the variable differs from the native endian
1324 bool endianity_is_not_default () const
1326 return this->main_type
->m_flag_endianity_not_default
;
1329 void set_endianity_is_not_default (bool endianity_is_not_default
)
1331 this->main_type
->m_flag_endianity_not_default
= endianity_is_not_default
;
1335 /* True if this type was declared using the "class" keyword. This is
1336 only valid for C++ structure and enum types. If false, a structure
1337 was declared as a "struct"; if true it was declared "class". For
1338 enum types, this is true when "enum class" or "enum struct" was
1339 used to declare the type. */
1341 bool is_declared_class () const
1343 return this->main_type
->m_flag_declared_class
;
1346 void set_is_declared_class (bool is_declared_class
) const
1348 this->main_type
->m_flag_declared_class
= is_declared_class
;
1351 /* True if this type is a "flag" enum. A flag enum is one where all
1352 the values are pairwise disjoint when "and"ed together. This
1353 affects how enum values are printed. */
1355 bool is_flag_enum () const
1357 return this->main_type
->m_flag_flag_enum
;
1360 void set_is_flag_enum (bool is_flag_enum
)
1362 this->main_type
->m_flag_flag_enum
= is_flag_enum
;
1365 /* True if this array type is part of a multi-dimensional array. */
1367 bool is_multi_dimensional () const
1369 return this->main_type
->m_multi_dimensional
;
1372 void set_is_multi_dimensional (bool value
)
1374 this->main_type
->m_multi_dimensional
= value
;
1377 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return a reference
1378 to this type's fixed_point_info. */
1380 struct fixed_point_type_info
&fixed_point_info () const
1382 gdb_assert (this->code () == TYPE_CODE_FIXED_POINT
);
1383 gdb_assert (this->main_type
->type_specific
.fixed_point_info
!= nullptr);
1385 return *this->main_type
->type_specific
.fixed_point_info
;
1388 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, set this type's
1389 fixed_point_info to INFO. */
1391 void set_fixed_point_info (struct fixed_point_type_info
*info
) const
1393 gdb_assert (this->code () == TYPE_CODE_FIXED_POINT
);
1395 this->main_type
->type_specific
.fixed_point_info
= info
;
1398 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return its base type.
1400 In other words, this returns the type after having peeled all
1401 intermediate type layers (such as TYPE_CODE_RANGE, for instance).
1402 The TYPE_CODE of the type returned is guaranteed to be
1403 a TYPE_CODE_FIXED_POINT. */
1405 struct type
*fixed_point_type_base_type ();
1407 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return its scaling
1410 const gdb_mpq
&fixed_point_scaling_factor ();
1412 /* * Return the dynamic property of the requested KIND from this type's
1413 list of dynamic properties. */
1414 dynamic_prop
*dyn_prop (dynamic_prop_node_kind kind
) const;
1416 /* * Given a dynamic property PROP of a given KIND, add this dynamic
1417 property to this type.
1419 This function assumes that this type is objfile-owned. */
1420 void add_dyn_prop (dynamic_prop_node_kind kind
, dynamic_prop prop
);
1422 /* * Remove dynamic property of kind KIND from this type, if it exists. */
1423 void remove_dyn_prop (dynamic_prop_node_kind kind
);
1425 /* Return true if this type is owned by an objfile. Return false if it is
1426 owned by an architecture. */
1427 bool is_objfile_owned () const
1429 return this->main_type
->m_flag_objfile_owned
;
1432 /* Set the owner of the type to be OBJFILE. */
1433 void set_owner (objfile
*objfile
)
1435 gdb_assert (objfile
!= nullptr);
1437 this->main_type
->m_owner
.objfile
= objfile
;
1438 this->main_type
->m_flag_objfile_owned
= true;
1441 /* Set the owner of the type to be ARCH. */
1442 void set_owner (gdbarch
*arch
)
1444 gdb_assert (arch
!= nullptr);
1446 this->main_type
->m_owner
.gdbarch
= arch
;
1447 this->main_type
->m_flag_objfile_owned
= false;
1450 /* Return the objfile owner of this type.
1452 Return nullptr if this type is not objfile-owned. */
1453 struct objfile
*objfile_owner () const
1455 if (!this->is_objfile_owned ())
1458 return this->main_type
->m_owner
.objfile
;
1461 /* Return the gdbarch owner of this type.
1463 Return nullptr if this type is not gdbarch-owned. */
1464 gdbarch
*arch_owner () const
1466 if (this->is_objfile_owned ())
1469 return this->main_type
->m_owner
.gdbarch
;
1472 /* Return the type's architecture. For types owned by an
1473 architecture, that architecture is returned. For types owned by an
1474 objfile, that objfile's architecture is returned.
1476 The return value is always non-nullptr. */
1477 gdbarch
*arch () const;
1479 /* * Return true if this is an integer type whose logical (bit) size
1480 differs from its storage size; false otherwise. Always return
1481 false for non-integer (i.e., non-TYPE_SPECIFIC_INT) types. */
1482 bool bit_size_differs_p () const
1484 return (main_type
->type_specific_field
== TYPE_SPECIFIC_INT
1485 && main_type
->type_specific
.int_stuff
.bit_size
!= 8 * length ());
1488 /* * Return the logical (bit) size for this integer type. Only
1489 valid for integer (TYPE_SPECIFIC_INT) types. */
1490 unsigned short bit_size () const
1492 gdb_assert (main_type
->type_specific_field
== TYPE_SPECIFIC_INT
);
1493 return main_type
->type_specific
.int_stuff
.bit_size
;
1496 /* * Return the bit offset for this integer type. Only valid for
1497 integer (TYPE_SPECIFIC_INT) types. */
1498 unsigned short bit_offset () const
1500 gdb_assert (main_type
->type_specific_field
== TYPE_SPECIFIC_INT
);
1501 return main_type
->type_specific
.int_stuff
.bit_offset
;
1504 /* Return true if this is a pointer or reference type. */
1505 bool is_pointer_or_reference () const
1507 return this->code () == TYPE_CODE_PTR
|| TYPE_IS_REFERENCE (this);
1510 /* Return true if this type is "string-like", according to its
1511 defining language. */
1512 bool is_string_like ();
1514 /* Return true if this type is "array-like". This includes arrays,
1515 but also some forms of structure type that are recognized as
1516 representations of arrays by the type's language. */
1517 bool is_array_like ();
1519 /* Return the language that this type came from. */
1520 enum language
language () const
1521 { return main_type
->m_lang
; }
1523 /* * Type that is a pointer to this type.
1524 NULL if no such pointer-to type is known yet.
1525 The debugger may add the address of such a type
1526 if it has to construct one later. */
1528 struct type
*pointer_type
;
1530 /* * C++: also need a reference type. */
1532 struct type
*reference_type
;
1534 /* * A C++ rvalue reference type added in C++11. */
1536 struct type
*rvalue_reference_type
;
1538 /* * Variant chain. This points to a type that differs from this
1539 one only in qualifiers and length. Currently, the possible
1540 qualifiers are const, volatile, code-space, data-space, and
1541 address class. The length may differ only when one of the
1542 address class flags are set. The variants are linked in a
1543 circular ring and share MAIN_TYPE. */
1547 /* * The alignment for this type. Zero means that the alignment was
1548 not specified in the debug info. Note that this is stored in a
1549 funny way: as the log base 2 (plus 1) of the alignment; so a
1550 value of 1 means the alignment is 1, and a value of 9 means the
1551 alignment is 256. */
1553 unsigned align_log2
: TYPE_ALIGN_BITS
;
1555 /* * Flags specific to this instance of the type, indicating where
1558 For TYPE_CODE_TYPEDEF the flags of the typedef type should be
1559 binary or-ed with the target type, with a special case for
1560 address class and space class. For example if this typedef does
1561 not specify any new qualifiers, TYPE_INSTANCE_FLAGS is 0 and the
1562 instance flags are completely inherited from the target type. No
1563 qualifiers can be cleared by the typedef. See also
1565 unsigned m_instance_flags
: 9;
1567 /* * Length of storage for a value of this type. The value is the
1568 expression in host bytes of what sizeof(type) would return. This
1569 size includes padding. For example, an i386 extended-precision
1570 floating point value really only occupies ten bytes, but most
1571 ABI's declare its size to be 12 bytes, to preserve alignment.
1572 A `struct type' representing such a floating-point type would
1573 have a `length' value of 12, even though the last two bytes are
1576 Since this field is expressed in host bytes, its value is appropriate
1577 to pass to memcpy and such (it is assumed that GDB itself always runs
1578 on an 8-bits addressable architecture). However, when using it for
1579 target address arithmetic (e.g. adding it to a target address), the
1580 type_length_units function should be used in order to get the length
1581 expressed in target addressable memory units. */
1585 /* * Core type, shared by a group of qualified types. */
1587 struct main_type
*main_type
;
1593 /* * The overloaded name.
1594 This is generally allocated in the objfile's obstack.
1595 However stabsread.c sometimes uses malloc. */
1599 /* * The number of methods with this name. */
1603 /* * The list of methods. */
1605 struct fn_field
*fn_fields
;
1612 /* * If is_stub is clear, this is the mangled name which we can look
1613 up to find the address of the method (FIXME: it would be cleaner
1614 to have a pointer to the struct symbol here instead).
1616 If is_stub is set, this is the portion of the mangled name which
1617 specifies the arguments. For example, "ii", if there are two int
1618 arguments, or "" if there are no arguments. See gdb_mangle_name
1619 for the conversion from this format to the one used if is_stub is
1622 const char *physname
;
1624 /* * The function type for the method.
1626 (This comment used to say "The return value of the method", but
1627 that's wrong. The function type is expected here, i.e. something
1628 with TYPE_CODE_METHOD, and *not* the return-value type). */
1632 /* * For virtual functions. First baseclass that defines this
1633 virtual function. */
1635 struct type
*fcontext
;
1639 unsigned int is_const
:1;
1640 unsigned int is_volatile
:1;
1641 unsigned int is_artificial
:1;
1643 /* * A stub method only has some fields valid (but they are enough
1644 to reconstruct the rest of the fields). */
1646 unsigned int is_stub
:1;
1648 /* * True if this function is a constructor, false otherwise. */
1650 unsigned int is_constructor
: 1;
1652 /* * True if this function is deleted, false otherwise. */
1654 unsigned int is_deleted
: 1;
1656 /* * DW_AT_defaulted attribute for this function. The value is one
1657 of the DW_DEFAULTED constants. */
1659 ENUM_BITFIELD (dwarf_defaulted_attribute
) defaulted
: 2;
1661 /* Accessibility of the field. */
1662 enum accessibility accessibility
;
1664 /* * Index into that baseclass's virtual function table, minus 2;
1665 else if static: VOFFSET_STATIC; else: 0. */
1667 unsigned int voffset
:16;
1669 #define VOFFSET_STATIC 1
1675 /* * Unqualified name to be prefixed by owning class qualified
1680 /* * Type this typedef named NAME represents. */
1684 /* Accessibility of the field. */
1685 enum accessibility accessibility
;
1688 /* * C++ language-specific information for TYPE_CODE_STRUCT and
1689 TYPE_CODE_UNION nodes. */
1691 struct cplus_struct_type
1693 /* * Number of base classes this type derives from. The
1694 baseclasses are stored in the first N_BASECLASSES fields
1695 (i.e. the `fields' field of the struct type). The only fields
1696 of struct field that are used are: type, name, loc.bitpos. */
1698 short n_baseclasses
;
1700 /* * Field number of the virtual function table pointer in VPTR_BASETYPE.
1701 All access to this field must be through TYPE_VPTR_FIELDNO as one
1702 thing it does is check whether the field has been initialized.
1703 Initially TYPE_RAW_CPLUS_SPECIFIC has the value of cplus_struct_default,
1704 which for portability reasons doesn't initialize this field.
1705 TYPE_VPTR_FIELDNO returns -1 for this case.
1707 If -1, we were unable to find the virtual function table pointer in
1708 initial symbol reading, and get_vptr_fieldno should be called to find
1709 it if possible. get_vptr_fieldno will update this field if possible.
1710 Otherwise the value is left at -1.
1712 Unused if this type does not have virtual functions. */
1716 /* * Number of methods with unique names. All overloaded methods
1717 with the same name count only once. */
1721 /* * Number of template arguments. */
1723 unsigned short n_template_arguments
;
1725 /* * One if this struct is a dynamic class, as defined by the
1726 Itanium C++ ABI: if it requires a virtual table pointer,
1727 because it or any of its base classes have one or more virtual
1728 member functions or virtual base classes. Minus one if not
1729 dynamic. Zero if not yet computed. */
1733 /* * The calling convention for this type, fetched from the
1734 DW_AT_calling_convention attribute. The value is one of the
1737 ENUM_BITFIELD (dwarf_calling_convention
) calling_convention
: 8;
1739 /* * The base class which defined the virtual function table pointer. */
1741 struct type
*vptr_basetype
;
1743 /* * For classes, structures, and unions, a description of each
1744 field, which consists of an overloaded name, followed by the
1745 types of arguments that the method expects, and then the name
1746 after it has been renamed to make it distinct.
1748 fn_fieldlists points to an array of nfn_fields of these. */
1750 struct fn_fieldlist
*fn_fieldlists
;
1752 /* * typedefs defined inside this class. typedef_field points to
1753 an array of typedef_field_count elements. */
1755 struct decl_field
*typedef_field
;
1757 unsigned typedef_field_count
;
1759 /* * The nested types defined by this type. nested_types points to
1760 an array of nested_types_count elements. */
1762 struct decl_field
*nested_types
;
1764 unsigned nested_types_count
;
1766 /* * The template arguments. This is an array with
1767 N_TEMPLATE_ARGUMENTS elements. This is NULL for non-template
1770 struct symbol
**template_arguments
;
1773 /* * Struct used to store conversion rankings. */
1779 /* * When two conversions are of the same type and therefore have
1780 the same rank, subrank is used to differentiate the two.
1782 Eg: Two derived-class-pointer to base-class-pointer conversions
1783 would both have base pointer conversion rank, but the
1784 conversion with the shorter distance to the ancestor is
1785 preferable. 'subrank' would be used to reflect that. */
1790 /* * Used for ranking a function for overload resolution. */
1792 typedef std::vector
<rank
> badness_vector
;
1794 /* * GNAT Ada-specific information for various Ada types. */
1796 struct gnat_aux_type
1798 /* * Parallel type used to encode information about dynamic types
1799 used in Ada (such as variant records, variable-size array,
1801 struct type
* descriptive_type
;
1804 /* * For TYPE_CODE_FUNC and TYPE_CODE_METHOD types. */
1808 /* * The calling convention for targets supporting multiple ABIs.
1809 Right now this is only fetched from the Dwarf-2
1810 DW_AT_calling_convention attribute. The value is one of the
1813 ENUM_BITFIELD (dwarf_calling_convention
) calling_convention
: 8;
1815 /* * Whether this function normally returns to its caller. It is
1816 set from the DW_AT_noreturn attribute if set on the
1817 DW_TAG_subprogram. */
1819 unsigned int is_noreturn
: 1;
1821 /* * Only those DW_TAG_call_site's in this function that have
1822 DW_AT_call_tail_call set are linked in this list. Function
1823 without its tail call list complete
1824 (DW_AT_call_all_tail_calls or its superset
1825 DW_AT_call_all_calls) has TAIL_CALL_LIST NULL, even if some
1826 DW_TAG_call_site's exist in such function. */
1828 struct call_site
*tail_call_list
;
1830 /* * For method types (TYPE_CODE_METHOD), the aggregate type that
1831 contains the method. */
1833 struct type
*self_type
;
1836 /* The type-specific info for TYPE_CODE_FIXED_POINT types. */
1838 struct fixed_point_type_info
1840 /* The fixed point type's scaling factor. */
1841 gdb_mpq scaling_factor
;
1844 /* * The default value of TYPE_CPLUS_SPECIFIC(T) points to this shared
1845 static structure. */
1847 extern const struct cplus_struct_type cplus_struct_default
;
1849 extern void allocate_cplus_struct_type (struct type
*);
1851 #define INIT_CPLUS_SPECIFIC(type) \
1852 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_CPLUS_STUFF, \
1853 TYPE_RAW_CPLUS_SPECIFIC (type) = (struct cplus_struct_type*) \
1854 &cplus_struct_default)
1856 #define ALLOCATE_CPLUS_STRUCT_TYPE(type) allocate_cplus_struct_type (type)
1858 #define HAVE_CPLUS_STRUCT(type) \
1859 (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_CPLUS_STUFF \
1860 && TYPE_RAW_CPLUS_SPECIFIC (type) != &cplus_struct_default)
1862 #define INIT_NONE_SPECIFIC(type) \
1863 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_NONE, \
1864 TYPE_MAIN_TYPE (type)->type_specific = {})
1866 extern const struct gnat_aux_type gnat_aux_default
;
1868 extern void allocate_gnat_aux_type (struct type
*);
1870 #define INIT_GNAT_SPECIFIC(type) \
1871 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_GNAT_STUFF, \
1872 TYPE_GNAT_SPECIFIC (type) = (struct gnat_aux_type *) &gnat_aux_default)
1873 #define ALLOCATE_GNAT_AUX_TYPE(type) allocate_gnat_aux_type (type)
1874 /* * A macro that returns non-zero if the type-specific data should be
1875 read as "gnat-stuff". */
1876 #define HAVE_GNAT_AUX_INFO(type) \
1877 (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_GNAT_STUFF)
1879 /* * True if TYPE is known to be an Ada type of some kind. */
1880 #define ADA_TYPE_P(type) \
1881 (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_GNAT_STUFF \
1882 || (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE \
1883 && (type)->is_fixed_instance ()))
1885 #define INIT_FUNC_SPECIFIC(type) \
1886 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FUNC, \
1887 TYPE_MAIN_TYPE (type)->type_specific.func_stuff = (struct func_type *) \
1888 TYPE_ZALLOC (type, \
1889 sizeof (*TYPE_MAIN_TYPE (type)->type_specific.func_stuff)))
1891 /* "struct fixed_point_type_info" has a field that has a destructor.
1892 See allocate_fixed_point_type_info to understand how this is
1894 #define INIT_FIXED_POINT_SPECIFIC(type) \
1895 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FIXED_POINT, \
1896 allocate_fixed_point_type_info (type))
1898 #define TYPE_MAIN_TYPE(thistype) (thistype)->main_type
1899 #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
1900 #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
1901 #define TYPE_RVALUE_REFERENCE_TYPE(thistype) (thistype)->rvalue_reference_type
1902 #define TYPE_CHAIN(thistype) (thistype)->chain
1904 /* * Return the alignment of the type in target addressable memory
1905 units, or 0 if no alignment was specified. */
1906 #define TYPE_RAW_ALIGN(thistype) type_raw_align (thistype)
1908 /* * Return the alignment of the type in target addressable memory
1909 units, or 0 if no alignment was specified. */
1910 extern unsigned type_raw_align (struct type
*);
1912 /* * Return the alignment of the type in target addressable memory
1913 units. Return 0 if the alignment cannot be determined; but note
1914 that this makes an effort to compute the alignment even it it was
1915 not specified in the debug info. */
1916 extern unsigned type_align (struct type
*);
1918 /* * Set the alignment of the type. The alignment must be a power of
1919 2. Returns false if the given value does not fit in the available
1920 space in struct type. */
1921 extern bool set_type_align (struct type
*, ULONGEST
);
1923 /* Property accessors for the type data location. */
1924 #define TYPE_DATA_LOCATION(thistype) \
1925 ((thistype)->dyn_prop (DYN_PROP_DATA_LOCATION))
1926 #define TYPE_DATA_LOCATION_BATON(thistype) \
1927 TYPE_DATA_LOCATION (thistype)->data.baton
1928 #define TYPE_DATA_LOCATION_ADDR(thistype) \
1929 (TYPE_DATA_LOCATION (thistype)->const_val ())
1930 #define TYPE_DATA_LOCATION_KIND(thistype) \
1931 (TYPE_DATA_LOCATION (thistype)->kind ())
1932 #define TYPE_DYNAMIC_LENGTH(thistype) \
1933 ((thistype)->dyn_prop (DYN_PROP_BYTE_SIZE))
1935 /* Property accessors for the type allocated/associated. */
1936 #define TYPE_ALLOCATED_PROP(thistype) \
1937 ((thistype)->dyn_prop (DYN_PROP_ALLOCATED))
1938 #define TYPE_ASSOCIATED_PROP(thistype) \
1939 ((thistype)->dyn_prop (DYN_PROP_ASSOCIATED))
1940 #define TYPE_RANK_PROP(thistype) \
1941 ((thistype)->dyn_prop (DYN_PROP_RANK))
1945 #define TYPE_SELF_TYPE(thistype) internal_type_self_type (thistype)
1946 /* Do not call this, use TYPE_SELF_TYPE. */
1947 extern struct type
*internal_type_self_type (struct type
*);
1948 extern void set_type_self_type (struct type
*, struct type
*);
1950 extern int internal_type_vptr_fieldno (struct type
*);
1951 extern void set_type_vptr_fieldno (struct type
*, int);
1952 extern struct type
*internal_type_vptr_basetype (struct type
*);
1953 extern void set_type_vptr_basetype (struct type
*, struct type
*);
1954 #define TYPE_VPTR_FIELDNO(thistype) internal_type_vptr_fieldno (thistype)
1955 #define TYPE_VPTR_BASETYPE(thistype) internal_type_vptr_basetype (thistype)
1957 #define TYPE_NFN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields
1958 #define TYPE_SPECIFIC_FIELD(thistype) \
1959 TYPE_MAIN_TYPE(thistype)->type_specific_field
1960 /* We need this tap-dance with the TYPE_RAW_SPECIFIC because of the case
1961 where we're trying to print an Ada array using the C language.
1962 In that case, there is no "cplus_stuff", but the C language assumes
1963 that there is. What we do, in that case, is pretend that there is
1964 an implicit one which is the default cplus stuff. */
1965 #define TYPE_CPLUS_SPECIFIC(thistype) \
1966 (!HAVE_CPLUS_STRUCT(thistype) \
1967 ? (struct cplus_struct_type*)&cplus_struct_default \
1968 : TYPE_RAW_CPLUS_SPECIFIC(thistype))
1969 #define TYPE_RAW_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff
1970 #define TYPE_CPLUS_CALLING_CONVENTION(thistype) \
1971 TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff->calling_convention
1972 #define TYPE_FLOATFORMAT(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.floatformat
1973 #define TYPE_GNAT_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.gnat_stuff
1974 #define TYPE_DESCRIPTIVE_TYPE(thistype) TYPE_GNAT_SPECIFIC(thistype)->descriptive_type
1975 #define TYPE_CALLING_CONVENTION(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->calling_convention
1976 #define TYPE_NO_RETURN(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->is_noreturn
1977 #define TYPE_TAIL_CALL_LIST(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->tail_call_list
1978 #define TYPE_BASECLASS(thistype,index) ((thistype)->field (index).type ())
1979 #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
1980 #define TYPE_BASECLASS_NAME(thistype,index) (thistype->field (index).name ())
1981 #define TYPE_BASECLASS_BITPOS(thistype,index) (thistype->field (index).loc_bitpos ())
1982 #define BASETYPE_VIA_PUBLIC(thistype, index) \
1983 ((thistype)->field (index).is_public ())
1984 #define TYPE_CPLUS_DYNAMIC(thistype) TYPE_CPLUS_SPECIFIC (thistype)->is_dynamic
1986 #define BASETYPE_VIA_VIRTUAL(thistype, index) \
1987 ((thistype)->field (index).is_virtual ())
1989 #define TYPE_FN_FIELDLISTS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists
1990 #define TYPE_FN_FIELDLIST(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n]
1991 #define TYPE_FN_FIELDLIST1(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].fn_fields
1992 #define TYPE_FN_FIELDLIST_NAME(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].name
1993 #define TYPE_FN_FIELDLIST_LENGTH(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].length
1995 #define TYPE_N_TEMPLATE_ARGUMENTS(thistype) \
1996 TYPE_CPLUS_SPECIFIC (thistype)->n_template_arguments
1997 #define TYPE_TEMPLATE_ARGUMENTS(thistype) \
1998 TYPE_CPLUS_SPECIFIC (thistype)->template_arguments
1999 #define TYPE_TEMPLATE_ARGUMENT(thistype, n) \
2000 TYPE_CPLUS_SPECIFIC (thistype)->template_arguments[n]
2002 #define TYPE_FN_FIELD(thisfn, n) (thisfn)[n]
2003 #define TYPE_FN_FIELD_PHYSNAME(thisfn, n) (thisfn)[n].physname
2004 #define TYPE_FN_FIELD_TYPE(thisfn, n) (thisfn)[n].type
2005 #define TYPE_FN_FIELD_ARGS(thisfn, n) (((thisfn)[n].type)->fields ())
2006 #define TYPE_FN_FIELD_CONST(thisfn, n) ((thisfn)[n].is_const)
2007 #define TYPE_FN_FIELD_VOLATILE(thisfn, n) ((thisfn)[n].is_volatile)
2008 #define TYPE_FN_FIELD_PRIVATE(thisfn, n) \
2009 ((thisfn)[n].accessibility == accessibility::PRIVATE)
2010 #define TYPE_FN_FIELD_PROTECTED(thisfn, n) \
2011 ((thisfn)[n].accessibility == accessibility::PROTECTED)
2012 #define TYPE_FN_FIELD_ARTIFICIAL(thisfn, n) ((thisfn)[n].is_artificial)
2013 #define TYPE_FN_FIELD_STUB(thisfn, n) ((thisfn)[n].is_stub)
2014 #define TYPE_FN_FIELD_CONSTRUCTOR(thisfn, n) ((thisfn)[n].is_constructor)
2015 #define TYPE_FN_FIELD_FCONTEXT(thisfn, n) ((thisfn)[n].fcontext)
2016 #define TYPE_FN_FIELD_VOFFSET(thisfn, n) ((thisfn)[n].voffset-2)
2017 #define TYPE_FN_FIELD_VIRTUAL_P(thisfn, n) ((thisfn)[n].voffset > 1)
2018 #define TYPE_FN_FIELD_STATIC_P(thisfn, n) ((thisfn)[n].voffset == VOFFSET_STATIC)
2019 #define TYPE_FN_FIELD_DEFAULTED(thisfn, n) ((thisfn)[n].defaulted)
2020 #define TYPE_FN_FIELD_DELETED(thisfn, n) ((thisfn)[n].is_deleted)
2022 /* Accessors for typedefs defined by a class. */
2023 #define TYPE_TYPEDEF_FIELD_ARRAY(thistype) \
2024 TYPE_CPLUS_SPECIFIC (thistype)->typedef_field
2025 #define TYPE_TYPEDEF_FIELD(thistype, n) \
2026 TYPE_CPLUS_SPECIFIC (thistype)->typedef_field[n]
2027 #define TYPE_TYPEDEF_FIELD_NAME(thistype, n) \
2028 TYPE_TYPEDEF_FIELD (thistype, n).name
2029 #define TYPE_TYPEDEF_FIELD_TYPE(thistype, n) \
2030 TYPE_TYPEDEF_FIELD (thistype, n).type
2031 #define TYPE_TYPEDEF_FIELD_COUNT(thistype) \
2032 TYPE_CPLUS_SPECIFIC (thistype)->typedef_field_count
2033 #define TYPE_TYPEDEF_FIELD_PROTECTED(thistype, n) \
2034 (TYPE_TYPEDEF_FIELD (thistype, n).accessibility == accessibility::PROTECTED)
2035 #define TYPE_TYPEDEF_FIELD_PRIVATE(thistype, n) \
2036 (TYPE_TYPEDEF_FIELD (thistype, n).accessibility == accessibility::PRIVATE)
2038 #define TYPE_NESTED_TYPES_ARRAY(thistype) \
2039 TYPE_CPLUS_SPECIFIC (thistype)->nested_types
2040 #define TYPE_NESTED_TYPES_FIELD(thistype, n) \
2041 TYPE_CPLUS_SPECIFIC (thistype)->nested_types[n]
2042 #define TYPE_NESTED_TYPES_FIELD_NAME(thistype, n) \
2043 TYPE_NESTED_TYPES_FIELD (thistype, n).name
2044 #define TYPE_NESTED_TYPES_FIELD_TYPE(thistype, n) \
2045 TYPE_NESTED_TYPES_FIELD (thistype, n).type
2046 #define TYPE_NESTED_TYPES_COUNT(thistype) \
2047 TYPE_CPLUS_SPECIFIC (thistype)->nested_types_count
2048 #define TYPE_NESTED_TYPES_FIELD_PROTECTED(thistype, n) \
2049 (TYPE_NESTED_TYPES_FIELD (thistype, n).accessibility \
2050 == accessibility::PROTECTED)
2051 #define TYPE_NESTED_TYPES_FIELD_PRIVATE(thistype, n) \
2052 (TYPE_NESTED_TYPES_FIELD (thistype, n).accessibility \
2053 == accessibility::PRIVATE)
2055 #define TYPE_IS_OPAQUE(thistype) \
2056 ((((thistype)->code () == TYPE_CODE_STRUCT) \
2057 || ((thistype)->code () == TYPE_CODE_UNION)) \
2058 && ((thistype)->num_fields () == 0) \
2059 && (!HAVE_CPLUS_STRUCT (thistype) \
2060 || TYPE_NFN_FIELDS (thistype) == 0) \
2061 && ((thistype)->is_stub () || !(thistype)->stub_is_supported ()))
2063 /* * A helper macro that returns the name of a type or "unnamed type"
2064 if the type has no name. */
2066 #define TYPE_SAFE_NAME(type) \
2067 (type->name () != nullptr ? type->name () : _("<unnamed type>"))
2069 /* * A helper macro that returns the name of an error type. If the
2070 type has a name, it is used; otherwise, a default is used. */
2072 #define TYPE_ERROR_NAME(type) \
2073 (type->name () ? type->name () : _("<error type>"))
2075 /* Given TYPE, return its floatformat. */
2076 const struct floatformat
*floatformat_from_type (const struct type
*type
);
2080 /* Integral types. */
2082 /* Implicit size/sign (based on the architecture's ABI). */
2083 struct type
*builtin_void
= nullptr;
2084 struct type
*builtin_char
= nullptr;
2085 struct type
*builtin_short
= nullptr;
2086 struct type
*builtin_int
= nullptr;
2087 struct type
*builtin_long
= nullptr;
2088 struct type
*builtin_signed_char
= nullptr;
2089 struct type
*builtin_unsigned_char
= nullptr;
2090 struct type
*builtin_unsigned_short
= nullptr;
2091 struct type
*builtin_unsigned_int
= nullptr;
2092 struct type
*builtin_unsigned_long
= nullptr;
2093 struct type
*builtin_bfloat16
= nullptr;
2094 struct type
*builtin_half
= nullptr;
2095 struct type
*builtin_float
= nullptr;
2096 struct type
*builtin_double
= nullptr;
2097 struct type
*builtin_long_double
= nullptr;
2098 struct type
*builtin_complex
= nullptr;
2099 struct type
*builtin_double_complex
= nullptr;
2100 struct type
*builtin_string
= nullptr;
2101 struct type
*builtin_bool
= nullptr;
2102 struct type
*builtin_long_long
= nullptr;
2103 struct type
*builtin_unsigned_long_long
= nullptr;
2104 struct type
*builtin_decfloat
= nullptr;
2105 struct type
*builtin_decdouble
= nullptr;
2106 struct type
*builtin_declong
= nullptr;
2108 /* "True" character types.
2109 We use these for the '/c' print format, because c_char is just a
2110 one-byte integral type, which languages less laid back than C
2111 will print as ... well, a one-byte integral type. */
2112 struct type
*builtin_true_char
= nullptr;
2113 struct type
*builtin_true_unsigned_char
= nullptr;
2115 /* Explicit sizes - see C9X <intypes.h> for naming scheme. The "int0"
2116 is for when an architecture needs to describe a register that has
2118 struct type
*builtin_int0
= nullptr;
2119 struct type
*builtin_int8
= nullptr;
2120 struct type
*builtin_uint8
= nullptr;
2121 struct type
*builtin_int16
= nullptr;
2122 struct type
*builtin_uint16
= nullptr;
2123 struct type
*builtin_int24
= nullptr;
2124 struct type
*builtin_uint24
= nullptr;
2125 struct type
*builtin_int32
= nullptr;
2126 struct type
*builtin_uint32
= nullptr;
2127 struct type
*builtin_int64
= nullptr;
2128 struct type
*builtin_uint64
= nullptr;
2129 struct type
*builtin_int128
= nullptr;
2130 struct type
*builtin_uint128
= nullptr;
2132 /* Wide character types. */
2133 struct type
*builtin_char16
= nullptr;
2134 struct type
*builtin_char32
= nullptr;
2135 struct type
*builtin_wchar
= nullptr;
2137 /* Pointer types. */
2139 /* * `pointer to data' type. Some target platforms use an implicitly
2140 {sign,zero} -extended 32-bit ABI pointer on a 64-bit ISA. */
2141 struct type
*builtin_data_ptr
= nullptr;
2143 /* * `pointer to function (returning void)' type. Harvard
2144 architectures mean that ABI function and code pointers are not
2145 interconvertible. Similarly, since ANSI, C standards have
2146 explicitly said that pointers to functions and pointers to data
2147 are not interconvertible --- that is, you can't cast a function
2148 pointer to void * and back, and expect to get the same value.
2149 However, all function pointer types are interconvertible, so void
2150 (*) () can server as a generic function pointer. */
2152 struct type
*builtin_func_ptr
= nullptr;
2154 /* * `function returning pointer to function (returning void)' type.
2155 The final void return type is not significant for it. */
2157 struct type
*builtin_func_func
= nullptr;
2159 /* Special-purpose types. */
2161 /* * This type is used to represent a GDB internal function. */
2163 struct type
*internal_fn
= nullptr;
2165 /* * This type is used to represent an xmethod. */
2166 struct type
*xmethod
= nullptr;
2168 /* * This type is used to represent symbol addresses. */
2169 struct type
*builtin_core_addr
= nullptr;
2171 /* * This type represents a type that was unrecognized in symbol
2173 struct type
*builtin_error
= nullptr;
2175 /* * Types used for symbols with no debug information. */
2176 struct type
*nodebug_text_symbol
= nullptr;
2177 struct type
*nodebug_text_gnu_ifunc_symbol
= nullptr;
2178 struct type
*nodebug_got_plt_symbol
= nullptr;
2179 struct type
*nodebug_data_symbol
= nullptr;
2180 struct type
*nodebug_unknown_symbol
= nullptr;
2181 struct type
*nodebug_tls_symbol
= nullptr;
2184 /* * Return the type table for the specified architecture. */
2186 extern const struct builtin_type
*builtin_type (struct gdbarch
*gdbarch
);
2188 /* * Return the type table for the specified objfile. */
2190 extern const struct builtin_type
*builtin_type (struct objfile
*objfile
);
2192 /* Explicit floating-point formats. See "floatformat.h". */
2193 extern const struct floatformat
*floatformats_ieee_half
[BFD_ENDIAN_UNKNOWN
];
2194 extern const struct floatformat
*floatformats_ieee_single
[BFD_ENDIAN_UNKNOWN
];
2195 extern const struct floatformat
*floatformats_ieee_double
[BFD_ENDIAN_UNKNOWN
];
2196 extern const struct floatformat
*floatformats_ieee_quad
[BFD_ENDIAN_UNKNOWN
];
2197 extern const struct floatformat
*floatformats_ieee_double_littlebyte_bigword
[BFD_ENDIAN_UNKNOWN
];
2198 extern const struct floatformat
*floatformats_i387_ext
[BFD_ENDIAN_UNKNOWN
];
2199 extern const struct floatformat
*floatformats_m68881_ext
[BFD_ENDIAN_UNKNOWN
];
2200 extern const struct floatformat
*floatformats_arm_ext
[BFD_ENDIAN_UNKNOWN
];
2201 extern const struct floatformat
*floatformats_ia64_spill
[BFD_ENDIAN_UNKNOWN
];
2202 extern const struct floatformat
*floatformats_vax_f
[BFD_ENDIAN_UNKNOWN
];
2203 extern const struct floatformat
*floatformats_vax_d
[BFD_ENDIAN_UNKNOWN
];
2204 extern const struct floatformat
*floatformats_ibm_long_double
[BFD_ENDIAN_UNKNOWN
];
2205 extern const struct floatformat
*floatformats_bfloat16
[BFD_ENDIAN_UNKNOWN
];
2207 /* Allocate space for storing data associated with a particular
2208 type. We ensure that the space is allocated using the same
2209 mechanism that was used to allocate the space for the type
2210 structure itself. I.e. if the type is on an objfile's
2211 objfile_obstack, then the space for data associated with that type
2212 will also be allocated on the objfile_obstack. If the type is
2213 associated with a gdbarch, then the space for data associated with that
2214 type will also be allocated on the gdbarch_obstack.
2216 If a type is not associated with neither an objfile or a gdbarch then
2217 you should not use this macro to allocate space for data, instead you
2218 should call xmalloc directly, and ensure the memory is correctly freed
2219 when it is no longer needed. */
2221 #define TYPE_ALLOC(t,size) \
2222 (obstack_alloc (((t)->is_objfile_owned () \
2223 ? &((t)->objfile_owner ()->objfile_obstack) \
2224 : gdbarch_obstack ((t)->arch_owner ())), \
2228 /* See comment on TYPE_ALLOC. */
2230 #define TYPE_ZALLOC(t,size) (memset (TYPE_ALLOC (t, size), 0, size))
2232 /* * This returns the target type (or NULL) of TYPE, also skipping
2235 extern struct type
*get_target_type (struct type
*type
);
2237 /* Return the equivalent of TYPE_LENGTH, but in number of target
2238 addressable memory units of the associated gdbarch instead of bytes. */
2240 extern unsigned int type_length_units (struct type
*type
);
2242 /* An object of this type is passed when allocating certain types. It
2243 determines where the new type is allocated. Ultimately a type is
2244 either allocated on a on an objfile obstack or on a gdbarch
2245 obstack. However, it's also possible to request that a new type be
2246 allocated on the same obstack as some existing type, or that a
2247 "new" type instead overwrite a supplied type object. */
2249 class type_allocator
2253 /* Create new types on OBJFILE. */
2254 type_allocator (objfile
*objfile
, enum language lang
)
2255 : m_is_objfile (true),
2258 m_data
.objfile
= objfile
;
2261 /* Create new types on GDBARCH. */
2262 explicit type_allocator (gdbarch
*gdbarch
)
2263 : m_lang (language_minimal
)
2265 m_data
.gdbarch
= gdbarch
;
2268 /* This determines whether a passed-in type should be rewritten in
2269 place, or whether it should simply determine where the new type
2271 enum type_allocator_kind
2273 /* Allocate on same obstack as existing type. */
2275 /* Smash the existing type. */
2279 /* Create new types either on the same obstack as TYPE; or if SMASH
2280 is passed, overwrite TYPE. */
2281 explicit type_allocator (struct type
*type
,
2282 type_allocator_kind kind
= SAME
)
2283 : m_lang (type
->language ())
2287 if (type
->is_objfile_owned ())
2289 m_data
.objfile
= type
->objfile_owner ();
2290 m_is_objfile
= true;
2293 m_data
.gdbarch
= type
->arch_owner ();
2302 /* Create new types on the same obstack as TYPE. */
2303 explicit type_allocator (const struct type
*type
)
2304 : m_is_objfile (type
->is_objfile_owned ()),
2305 m_lang (type
->language ())
2307 if (type
->is_objfile_owned ())
2308 m_data
.objfile
= type
->objfile_owner ();
2310 m_data
.gdbarch
= type
->arch_owner ();
2313 /* Create a new type on the desired obstack. Note that a "new" type
2314 is not created if type-smashing was selected at construction. */
2317 /* Create a new type on the desired obstack, and fill in its code,
2318 length, and name. If NAME is non-null, it is copied to the
2319 destination obstack first. Note that a "new" type is not created
2320 if type-smashing was selected at construction. */
2321 type
*new_type (enum type_code code
, int bit
, const char *name
);
2323 /* Return the architecture associated with this allocator. This
2324 comes from whatever object was supplied to the constructor. */
2329 /* Where the type should wind up. */
2332 struct objfile
*objfile
;
2333 struct gdbarch
*gdbarch
;
2337 /* True if this allocator uses the objfile field above. */
2338 bool m_is_objfile
= false;
2339 /* True if this allocator uses the type field above, indicating that
2340 the "allocation" should be done in-place. */
2341 bool m_smash
= false;
2342 /* The language for types created by this allocator. */
2343 enum language m_lang
;
2346 /* Allocate a TYPE_CODE_INT type structure using ALLOC. BIT is the
2347 type size in bits. If UNSIGNED_P is non-zero, set the type's
2348 TYPE_UNSIGNED flag. NAME is the type name. */
2350 extern struct type
*init_integer_type (type_allocator
&alloc
, int bit
,
2351 int unsigned_p
, const char *name
);
2353 /* Allocate a TYPE_CODE_CHAR type structure using ALLOC. BIT is the
2354 type size in bits. If UNSIGNED_P is non-zero, set the type's
2355 TYPE_UNSIGNED flag. NAME is the type name. */
2357 extern struct type
*init_character_type (type_allocator
&alloc
, int bit
,
2358 int unsigned_p
, const char *name
);
2360 /* Allocate a TYPE_CODE_BOOL type structure using ALLOC. BIT is the
2361 type size in bits. If UNSIGNED_P is non-zero, set the type's
2362 TYPE_UNSIGNED flag. NAME is the type name. */
2364 extern struct type
*init_boolean_type (type_allocator
&alloc
, int bit
,
2365 int unsigned_p
, const char *name
);
2367 /* Allocate a TYPE_CODE_FLT type structure using ALLOC.
2368 BIT is the type size in bits; if BIT equals -1, the size is
2369 determined by the floatformat. NAME is the type name. Set the
2370 TYPE_FLOATFORMAT from FLOATFORMATS. BYTE_ORDER is the byte order
2371 to use. If it is BFD_ENDIAN_UNKNOWN (the default), then the byte
2372 order of the objfile's architecture is used. */
2374 extern struct type
*init_float_type
2375 (type_allocator
&alloc
, int bit
, const char *name
,
2376 const struct floatformat
**floatformats
,
2377 enum bfd_endian byte_order
= BFD_ENDIAN_UNKNOWN
);
2379 /* Allocate a TYPE_CODE_DECFLOAT type structure using ALLOC.
2380 BIT is the type size in bits. NAME is the type name. */
2382 extern struct type
*init_decfloat_type (type_allocator
&alloc
, int bit
,
2385 extern bool can_create_complex_type (struct type
*);
2386 extern struct type
*init_complex_type (const char *, struct type
*);
2388 /* Allocate a TYPE_CODE_PTR type structure using ALLOC.
2389 BIT is the pointer type size in bits. NAME is the type name.
2390 TARGET_TYPE is the pointer target type. Always sets the pointer type's
2391 TYPE_UNSIGNED flag. */
2393 extern struct type
*init_pointer_type (type_allocator
&alloc
, int bit
,
2395 struct type
*target_type
);
2397 extern struct type
*init_fixed_point_type (type_allocator
&, int, int,
2400 /* Helper functions to construct a struct or record type. An
2401 initially empty type is created using arch_composite_type().
2402 Fields are then added using append_composite_type_field*(). A union
2403 type has its size set to the largest field. A struct type has each
2404 field packed against the previous. */
2406 extern struct type
*arch_composite_type (struct gdbarch
*gdbarch
,
2407 const char *name
, enum type_code code
);
2408 extern void append_composite_type_field (struct type
*t
, const char *name
,
2409 struct type
*field
);
2410 extern void append_composite_type_field_aligned (struct type
*t
,
2414 struct field
*append_composite_type_field_raw (struct type
*t
, const char *name
,
2415 struct type
*field
);
2417 /* Helper functions to construct a bit flags type. An initially empty
2418 type is created using arch_flag_type(). Flags are then added using
2419 append_flag_type_field() and append_flag_type_flag(). */
2420 extern struct type
*arch_flags_type (struct gdbarch
*gdbarch
,
2421 const char *name
, int bit
);
2422 extern void append_flags_type_field (struct type
*type
,
2423 int start_bitpos
, int nr_bits
,
2424 struct type
*field_type
, const char *name
);
2425 extern void append_flags_type_flag (struct type
*type
, int bitpos
,
2428 extern void make_vector_type (struct type
*array_type
);
2429 extern struct type
*init_vector_type (struct type
*elt_type
, int n
);
2431 extern struct type
*lookup_reference_type (struct type
*, enum type_code
);
2432 extern struct type
*lookup_lvalue_reference_type (struct type
*);
2433 extern struct type
*lookup_rvalue_reference_type (struct type
*);
2436 extern struct type
*make_reference_type (struct type
*, struct type
**,
2439 extern struct type
*make_cv_type (int, int, struct type
*, struct type
**);
2441 extern struct type
*make_restrict_type (struct type
*);
2443 extern struct type
*make_unqualified_type (struct type
*);
2445 extern struct type
*make_atomic_type (struct type
*);
2447 extern void replace_type (struct type
*, struct type
*);
2449 extern type_instance_flags address_space_name_to_type_instance_flags
2450 (struct gdbarch
*, const char *);
2452 extern const char *address_space_type_instance_flags_to_name
2453 (struct gdbarch
*, type_instance_flags
);
2455 extern struct type
*make_type_with_address_space
2456 (struct type
*type
, type_instance_flags space_identifier
);
2458 extern struct type
*lookup_memberptr_type (struct type
*, struct type
*);
2460 extern struct type
*lookup_methodptr_type (struct type
*);
2462 extern void smash_to_method_type (struct type
*type
, struct type
*self_type
,
2463 struct type
*to_type
, struct field
*args
,
2464 int nargs
, int varargs
);
2466 extern void smash_to_memberptr_type (struct type
*, struct type
*,
2469 extern void smash_to_methodptr_type (struct type
*, struct type
*);
2471 extern const char *type_name_or_error (struct type
*type
);
2475 /* The field of the element, or NULL if no element was found. */
2476 struct field
*field
;
2478 /* The bit offset of the element in the parent structure. */
2482 /* Given a type TYPE, lookup the field and offset of the component named
2485 TYPE can be either a struct or union, or a pointer or reference to
2486 a struct or union. If it is a pointer or reference, its target
2487 type is automatically used. Thus '.' and '->' are interchangeable,
2488 as specified for the definitions of the expression element types
2489 STRUCTOP_STRUCT and STRUCTOP_PTR.
2491 If NOERR is nonzero, the returned structure will have field set to
2492 NULL if there is no component named NAME.
2494 If the component NAME is a field in an anonymous substructure of
2495 TYPE, the returned offset is a "global" offset relative to TYPE
2496 rather than an offset within the substructure. */
2498 extern struct_elt
lookup_struct_elt (struct type
*, const char *, int);
2500 /* Given a type TYPE, lookup the type of the component named NAME.
2502 TYPE can be either a struct or union, or a pointer or reference to
2503 a struct or union. If it is a pointer or reference, its target
2504 type is automatically used. Thus '.' and '->' are interchangeable,
2505 as specified for the definitions of the expression element types
2506 STRUCTOP_STRUCT and STRUCTOP_PTR.
2508 If NOERR is nonzero, return NULL if there is no component named
2511 extern struct type
*lookup_struct_elt_type (struct type
*, const char *, int);
2513 extern struct type
*make_pointer_type (struct type
*, struct type
**);
2515 extern struct type
*lookup_pointer_type (struct type
*);
2517 extern struct type
*make_function_type (struct type
*, struct type
**);
2519 extern struct type
*lookup_function_type (struct type
*);
2521 extern struct type
*lookup_function_type_with_arguments (struct type
*,
2525 /* Create a range type using ALLOC.
2527 Indices will be of type INDEX_TYPE, and will range from LOW_BOUND
2528 to HIGH_BOUND, inclusive. */
2530 extern struct type
*create_static_range_type (type_allocator
&alloc
,
2531 struct type
*index_type
,
2533 LONGEST high_bound
);
2535 /* Create an array type using ALLOC.
2537 Elements will be of type ELEMENT_TYPE, the indices will be of type
2540 BYTE_STRIDE_PROP, when not NULL, provides the array's byte stride.
2541 This byte stride property is added to the resulting array type
2542 as a DYN_PROP_BYTE_STRIDE. As a consequence, the BYTE_STRIDE_PROP
2543 argument can only be used to create types that are objfile-owned
2544 (see add_dyn_prop), meaning that either this function must be called
2545 with an objfile-owned RESULT_TYPE, or an objfile-owned RANGE_TYPE.
2547 BIT_STRIDE is taken into account only when BYTE_STRIDE_PROP is NULL.
2548 If BIT_STRIDE is not zero, build a packed array type whose element
2549 size is BIT_STRIDE. Otherwise, ignore this parameter. */
2551 extern struct type
*create_array_type_with_stride
2552 (type_allocator
&alloc
, struct type
*element_type
,
2553 struct type
*range_type
, struct dynamic_prop
*byte_stride_prop
,
2554 unsigned int bit_stride
);
2556 /* Create a range type using ALLOC with a dynamic range from LOW_BOUND
2557 to HIGH_BOUND, inclusive. INDEX_TYPE is the underlying type. BIAS
2558 is the bias to be applied when storing or retrieving values of this
2561 extern struct type
*create_range_type (type_allocator
&alloc
,
2562 struct type
*index_type
,
2563 const struct dynamic_prop
*low_bound
,
2564 const struct dynamic_prop
*high_bound
,
2567 /* Like CREATE_RANGE_TYPE but also sets up a stride. When BYTE_STRIDE_P
2568 is true the value in STRIDE is a byte stride, otherwise STRIDE is a bit
2571 extern struct type
*create_range_type_with_stride
2572 (type_allocator
&alloc
, struct type
*index_type
,
2573 const struct dynamic_prop
*low_bound
,
2574 const struct dynamic_prop
*high_bound
, LONGEST bias
,
2575 const struct dynamic_prop
*stride
, bool byte_stride_p
);
2577 /* Same as create_array_type_with_stride but with no bit_stride
2578 (BIT_STRIDE = 0), thus building an unpacked array. */
2580 extern struct type
*create_array_type (type_allocator
&alloc
,
2581 struct type
*element_type
,
2582 struct type
*range_type
);
2584 extern struct type
*lookup_array_range_type (struct type
*, LONGEST
, LONGEST
);
2586 /* Create a string type using ALLOC. String types are similar enough
2587 to array of char types that we can use create_array_type to build
2588 the basic type and then bash it into a string type.
2590 For fixed length strings, the range type contains 0 as the lower
2591 bound and the length of the string minus one as the upper bound. */
2593 extern struct type
*create_string_type (type_allocator
&alloc
,
2594 struct type
*string_char_type
,
2595 struct type
*range_type
);
2597 extern struct type
*lookup_string_range_type (struct type
*, LONGEST
, LONGEST
);
2599 extern struct type
*create_set_type (type_allocator
&alloc
,
2600 struct type
*domain_type
);
2602 extern struct type
*lookup_unsigned_typename (const struct language_defn
*,
2605 extern struct type
*lookup_signed_typename (const struct language_defn
*,
2608 extern ULONGEST
get_unsigned_type_max (struct type
*);
2610 extern void get_signed_type_minmax (struct type
*, LONGEST
*, LONGEST
*);
2612 extern CORE_ADDR
get_pointer_type_max (struct type
*);
2614 /* * Resolve all dynamic values of a type e.g. array bounds to static values.
2615 ADDR specifies the location of the variable the type is bound to.
2616 If TYPE has no dynamic properties return TYPE; otherwise a new type with
2617 static properties is returned.
2619 If FRAME is given, it is used when evaluating dynamic properties.
2620 This can be important when a static link is seen. If not given,
2621 the selected frame is used.
2623 For an array type, if the element type is dynamic, then that will
2624 not be resolved. This is done because each individual element may
2625 have a different type when resolved (depending on the contents of
2626 memory). In this situation, 'is_dynamic_type' will still return
2627 true for the return value of this function. */
2628 extern struct type
*resolve_dynamic_type
2629 (struct type
*type
, gdb::array_view
<const gdb_byte
> valaddr
,
2630 CORE_ADDR addr
, const frame_info_ptr
*frame
= nullptr);
2632 /* * Predicate if the type has dynamic values, which are not resolved yet.
2633 See the caveat in 'resolve_dynamic_type' to understand a scenario
2634 where an apparently-resolved type may still be considered
2636 extern bool is_dynamic_type (struct type
*type
);
2638 extern struct type
*check_typedef (struct type
*);
2640 extern void check_stub_method_group (struct type
*, int);
2642 extern char *gdb_mangle_name (struct type
*, int, int);
2644 /* Lookup a typedef or primitive type named NAME, visible in lexical block
2645 BLOCK. If NOERR is nonzero, return zero if NAME is not suitably
2648 If this function finds a suitable type then check_typedef is called on
2649 the type, this ensures that if the type being returned is a typedef
2650 then the length of the type will be correct. The original typedef will
2651 still be returned, not the result of calling check_typedef. */
2653 extern struct type
*lookup_typename (const struct language_defn
*language
,
2655 const struct block
*block
, int noerr
);
2657 extern struct type
*lookup_template_type (const char *, struct type
*,
2658 const struct block
*);
2660 extern int get_vptr_fieldno (struct type
*, struct type
**);
2662 /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type
2665 Return true if the two bounds are available, false otherwise. */
2667 extern bool get_discrete_bounds (struct type
*type
, LONGEST
*lowp
,
2670 /* If TYPE's low bound is a known constant, return it, else return nullopt. */
2672 extern std::optional
<LONGEST
> get_discrete_low_bound (struct type
*type
);
2674 /* If TYPE's high bound is a known constant, return it, else return nullopt. */
2676 extern std::optional
<LONGEST
> get_discrete_high_bound (struct type
*type
);
2678 /* Assuming TYPE is a simple, non-empty array type, compute its upper
2679 and lower bound. Save the low bound into LOW_BOUND if not NULL.
2680 Save the high bound into HIGH_BOUND if not NULL.
2682 Return true if the operation was successful. Return false otherwise,
2683 in which case the values of LOW_BOUND and HIGH_BOUNDS are unmodified. */
2685 extern bool get_array_bounds (struct type
*type
, LONGEST
*low_bound
,
2686 LONGEST
*high_bound
);
2688 extern std::optional
<LONGEST
> discrete_position (struct type
*type
,
2691 extern int class_types_same_p (const struct type
*, const struct type
*);
2693 extern int is_ancestor (struct type
*, struct type
*);
2695 extern int is_public_ancestor (struct type
*, struct type
*);
2697 extern int is_unique_ancestor (struct type
*, struct value
*);
2699 /* Overload resolution */
2701 /* * Badness if parameter list length doesn't match arg list length. */
2702 extern const struct rank LENGTH_MISMATCH_BADNESS
;
2704 /* * Dummy badness value for nonexistent parameter positions. */
2705 extern const struct rank TOO_FEW_PARAMS_BADNESS
;
2706 /* * Badness if no conversion among types. */
2707 extern const struct rank INCOMPATIBLE_TYPE_BADNESS
;
2709 /* * Badness of an exact match. */
2710 extern const struct rank EXACT_MATCH_BADNESS
;
2712 /* * Badness of integral promotion. */
2713 extern const struct rank INTEGER_PROMOTION_BADNESS
;
2714 /* * Badness of floating promotion. */
2715 extern const struct rank FLOAT_PROMOTION_BADNESS
;
2716 /* * Badness of converting a derived class pointer
2717 to a base class pointer. */
2718 extern const struct rank BASE_PTR_CONVERSION_BADNESS
;
2719 /* * Badness of integral conversion. */
2720 extern const struct rank INTEGER_CONVERSION_BADNESS
;
2721 /* * Badness of floating conversion. */
2722 extern const struct rank FLOAT_CONVERSION_BADNESS
;
2723 /* * Badness of integer<->floating conversions. */
2724 extern const struct rank INT_FLOAT_CONVERSION_BADNESS
;
2725 /* * Badness of conversion of pointer to void pointer. */
2726 extern const struct rank VOID_PTR_CONVERSION_BADNESS
;
2727 /* * Badness of conversion to boolean. */
2728 extern const struct rank BOOL_CONVERSION_BADNESS
;
2729 /* * Badness of converting derived to base class. */
2730 extern const struct rank BASE_CONVERSION_BADNESS
;
2731 /* * Badness of converting from non-reference to reference. Subrank
2732 is the type of reference conversion being done. */
2733 extern const struct rank REFERENCE_CONVERSION_BADNESS
;
2734 extern const struct rank REFERENCE_SEE_THROUGH_BADNESS
;
2735 /* * Conversion to rvalue reference. */
2736 #define REFERENCE_CONVERSION_RVALUE 1
2737 /* * Conversion to const lvalue reference. */
2738 #define REFERENCE_CONVERSION_CONST_LVALUE 2
2740 /* * Badness of converting integer 0 to NULL pointer. */
2741 extern const struct rank NULL_POINTER_CONVERSION
;
2742 /* * Badness of cv-conversion. Subrank is a flag describing the conversions
2744 extern const struct rank CV_CONVERSION_BADNESS
;
2745 #define CV_CONVERSION_CONST 1
2746 #define CV_CONVERSION_VOLATILE 2
2748 /* Non-standard conversions allowed by the debugger */
2750 /* * Converting a pointer to an int is usually OK. */
2751 extern const struct rank NS_POINTER_CONVERSION_BADNESS
;
2753 /* * Badness of converting a (non-zero) integer constant
2755 extern const struct rank NS_INTEGER_POINTER_CONVERSION_BADNESS
;
2757 extern struct rank
sum_ranks (struct rank a
, struct rank b
);
2758 extern int compare_ranks (struct rank a
, struct rank b
);
2760 extern int compare_badness (const badness_vector
&,
2761 const badness_vector
&);
2763 extern badness_vector
rank_function (gdb::array_view
<type
*> parms
,
2764 gdb::array_view
<value
*> args
,
2765 bool varargs
= false);
2767 extern struct rank
rank_one_type (struct type
*, struct type
*,
2770 extern void recursive_dump_type (struct type
*, int);
2774 extern void print_scalar_formatted (const gdb_byte
*, struct type
*,
2775 const struct value_print_options
*,
2776 int, struct ui_file
*);
2778 extern int can_dereference (struct type
*);
2780 extern int is_integral_type (struct type
*);
2782 extern int is_floating_type (struct type
*);
2784 extern int is_scalar_type (struct type
*type
);
2786 extern int is_scalar_type_recursive (struct type
*);
2788 extern int class_or_union_p (const struct type
*);
2790 extern void maintenance_print_type (const char *, int);
2792 extern htab_up
create_copied_types_hash ();
2794 extern struct type
*copy_type_recursive (struct type
*type
,
2795 htab_t copied_types
);
2797 extern struct type
*copy_type (const struct type
*type
);
2799 extern bool types_equal (struct type
*, struct type
*);
2801 extern bool types_deeply_equal (struct type
*, struct type
*);
2803 extern int type_not_allocated (const struct type
*type
);
2805 extern int type_not_associated (const struct type
*type
);
2807 /* Return True if TYPE is a TYPE_CODE_FIXED_POINT or if TYPE is
2808 a range type whose base type is a TYPE_CODE_FIXED_POINT. */
2809 extern bool is_fixed_point_type (struct type
*type
);
2811 /* Allocate a fixed-point type info for TYPE. This should only be
2812 called by INIT_FIXED_POINT_SPECIFIC. */
2813 extern void allocate_fixed_point_type_info (struct type
*type
);
2815 /* * When the type includes explicit byte ordering, return that.
2816 Otherwise, the byte ordering from gdbarch_byte_order for
2817 the type's arch is returned. */
2819 extern enum bfd_endian
type_byte_order (const struct type
*type
);
2821 /* A flag to enable printing of debugging information of C++
2824 extern unsigned int overload_debug
;
2826 /* Return whether the function type represented by TYPE is marked as unsafe
2827 to call by the debugger.
2829 This usually indicates that the function does not follow the target's
2830 standard calling convention. */
2832 extern bool is_nocall_function (const struct type
*type
);
2834 #endif /* GDBTYPES_H */