2 /* Internal type definitions for GDB.
4 Copyright (C) 1992-2022 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"
50 #include "gdbsupport/gdb_optional.h"
51 #include "gdbsupport/offset-type.h"
52 #include "gdbsupport/enum-flags.h"
53 #include "gdbsupport/underlying.h"
54 #include "gdbsupport/print-utils.h"
56 #include "gdbsupport/gdb_obstack.h"
57 #include "gmp-utils.h"
59 /* Forward declarations for prototypes. */
62 struct value_print_options
;
64 struct dwarf2_per_cu_data
;
65 struct dwarf2_per_objfile
;
67 /* These declarations are DWARF-specific as some of the gdbtypes.h data types
68 are already DWARF-specific. */
70 /* * Offset relative to the start of its containing CU (compilation
72 DEFINE_OFFSET_TYPE (cu_offset
, unsigned int);
74 /* * Offset relative to the start of its .debug_info or .debug_types
76 DEFINE_OFFSET_TYPE (sect_offset
, uint64_t);
79 sect_offset_str (sect_offset offset
)
81 return hex_string (to_underlying (offset
));
84 /* Some macros for char-based bitfields. */
86 #define B_SET(a,x) ((a)[(x)>>3] |= (1 << ((x)&7)))
87 #define B_CLR(a,x) ((a)[(x)>>3] &= ~(1 << ((x)&7)))
88 #define B_TST(a,x) ((a)[(x)>>3] & (1 << ((x)&7)))
89 #define B_TYPE unsigned char
90 #define B_BYTES(x) ( 1 + ((x)>>3) )
91 #define B_CLRALL(a,x) memset ((a), 0, B_BYTES(x))
93 /* * Different kinds of data types are distinguished by the `code'
98 TYPE_CODE_BITSTRING
= -1, /**< Deprecated */
99 TYPE_CODE_UNDEF
= 0, /**< Not used; catches errors */
100 TYPE_CODE_PTR
, /**< Pointer type */
102 /* * Array type with lower & upper bounds.
104 Regardless of the language, GDB represents multidimensional
105 array types the way C does: as arrays of arrays. So an
106 instance of a GDB array type T can always be seen as a series
107 of instances of TYPE_TARGET_TYPE (T) laid out sequentially in
110 Row-major languages like C lay out multi-dimensional arrays so
111 that incrementing the rightmost index in a subscripting
112 expression results in the smallest change in the address of the
113 element referred to. Column-major languages like Fortran lay
114 them out so that incrementing the leftmost index results in the
117 This means that, in column-major languages, working our way
118 from type to target type corresponds to working through indices
119 from right to left, not left to right. */
122 TYPE_CODE_STRUCT
, /**< C struct or Pascal record */
123 TYPE_CODE_UNION
, /**< C union or Pascal variant part */
124 TYPE_CODE_ENUM
, /**< Enumeration type */
125 TYPE_CODE_FLAGS
, /**< Bit flags type */
126 TYPE_CODE_FUNC
, /**< Function type */
127 TYPE_CODE_INT
, /**< Integer type */
129 /* * Floating type. This is *NOT* a complex type. */
132 /* * Void type. The length field specifies the length (probably
133 always one) which is used in pointer arithmetic involving
134 pointers to this type, but actually dereferencing such a
135 pointer is invalid; a void type has no length and no actual
136 representation in memory or registers. A pointer to a void
137 type is a generic pointer. */
140 TYPE_CODE_SET
, /**< Pascal sets */
141 TYPE_CODE_RANGE
, /**< Range (integers within spec'd bounds). */
143 /* * A string type which is like an array of character but prints
144 differently. It does not contain a length field as Pascal
145 strings (for many Pascals, anyway) do; if we want to deal with
146 such strings, we should use a new type code. */
149 /* * Unknown type. The length field is valid if we were able to
150 deduce that much about the type, or 0 if we don't even know
155 TYPE_CODE_METHOD
, /**< Method type */
157 /* * Pointer-to-member-function type. This describes how to access a
158 particular member function of a class (possibly a virtual
159 member function). The representation may vary between different
163 /* * Pointer-to-member type. This is the offset within a class to
164 some particular data member. The only currently supported
165 representation uses an unbiased offset, with -1 representing
166 NULL; this is used by the Itanium C++ ABI (used by GCC on all
170 TYPE_CODE_REF
, /**< C++ Reference types */
172 TYPE_CODE_RVALUE_REF
, /**< C++ rvalue reference types */
174 TYPE_CODE_CHAR
, /**< *real* character type */
176 /* * Boolean type. 0 is false, 1 is true, and other values are
177 non-boolean (e.g. FORTRAN "logical" used as unsigned int). */
181 TYPE_CODE_COMPLEX
, /**< Complex float */
185 TYPE_CODE_NAMESPACE
, /**< C++ namespace. */
187 TYPE_CODE_DECFLOAT
, /**< Decimal floating point. */
189 TYPE_CODE_MODULE
, /**< Fortran module. */
191 /* * Internal function type. */
192 TYPE_CODE_INTERNAL_FUNCTION
,
194 /* * Methods implemented in extension languages. */
197 /* * Fixed Point type. */
198 TYPE_CODE_FIXED_POINT
,
201 /* * Some bits for the type's instance_flags word. See the macros
202 below for documentation on each bit. */
204 enum type_instance_flag_value
: unsigned
206 TYPE_INSTANCE_FLAG_CONST
= (1 << 0),
207 TYPE_INSTANCE_FLAG_VOLATILE
= (1 << 1),
208 TYPE_INSTANCE_FLAG_CODE_SPACE
= (1 << 2),
209 TYPE_INSTANCE_FLAG_DATA_SPACE
= (1 << 3),
210 TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1
= (1 << 4),
211 TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2
= (1 << 5),
212 TYPE_INSTANCE_FLAG_NOTTEXT
= (1 << 6),
213 TYPE_INSTANCE_FLAG_RESTRICT
= (1 << 7),
214 TYPE_INSTANCE_FLAG_ATOMIC
= (1 << 8)
217 DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value
, type_instance_flags
);
219 /* * Not textual. By default, GDB treats all single byte integers as
220 characters (or elements of strings) unless this flag is set. */
222 #define TYPE_NOTTEXT(t) (((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_NOTTEXT)
224 /* * Constant type. If this is set, the corresponding type has a
227 #define TYPE_CONST(t) ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_CONST) != 0)
229 /* * Volatile type. If this is set, the corresponding type has a
230 volatile modifier. */
232 #define TYPE_VOLATILE(t) \
233 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_VOLATILE) != 0)
235 /* * Restrict type. If this is set, the corresponding type has a
236 restrict modifier. */
238 #define TYPE_RESTRICT(t) \
239 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_RESTRICT) != 0)
241 /* * Atomic type. If this is set, the corresponding type has an
244 #define TYPE_ATOMIC(t) \
245 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_ATOMIC) != 0)
247 /* * True if this type represents either an lvalue or lvalue reference type. */
249 #define TYPE_IS_REFERENCE(t) \
250 ((t)->code () == TYPE_CODE_REF || (t)->code () == TYPE_CODE_RVALUE_REF)
252 /* * True if this type is allocatable. */
253 #define TYPE_IS_ALLOCATABLE(t) \
254 ((t)->dyn_prop (DYN_PROP_ALLOCATED) != NULL)
256 /* * True if this type has variant parts. */
257 #define TYPE_HAS_VARIANT_PARTS(t) \
258 ((t)->dyn_prop (DYN_PROP_VARIANT_PARTS) != nullptr)
260 /* * True if this type has a dynamic length. */
261 #define TYPE_HAS_DYNAMIC_LENGTH(t) \
262 ((t)->dyn_prop (DYN_PROP_BYTE_SIZE) != nullptr)
264 /* * Instruction-space delimited type. This is for Harvard architectures
265 which have separate instruction and data address spaces (and perhaps
268 GDB usually defines a flat address space that is a superset of the
269 architecture's two (or more) address spaces, but this is an extension
270 of the architecture's model.
272 If TYPE_INSTANCE_FLAG_CODE_SPACE is set, an object of the corresponding type
273 resides in instruction memory, even if its address (in the extended
274 flat address space) does not reflect this.
276 Similarly, if TYPE_INSTANCE_FLAG_DATA_SPACE is set, then an object of the
277 corresponding type resides in the data memory space, even if
278 this is not indicated by its (flat address space) address.
280 If neither flag is set, the default space for functions / methods
281 is instruction space, and for data objects is data memory. */
283 #define TYPE_CODE_SPACE(t) \
284 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_CODE_SPACE) != 0)
286 #define TYPE_DATA_SPACE(t) \
287 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_DATA_SPACE) != 0)
289 /* * Address class flags. Some environments provide for pointers
290 whose size is different from that of a normal pointer or address
291 types where the bits are interpreted differently than normal
292 addresses. The TYPE_INSTANCE_FLAG_ADDRESS_CLASS_n flags may be used in
293 target specific ways to represent these different types of address
296 #define TYPE_ADDRESS_CLASS_1(t) (((t)->instance_flags ()) \
297 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
298 #define TYPE_ADDRESS_CLASS_2(t) (((t)->instance_flags ()) \
299 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2)
300 #define TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL \
301 (TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 | TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2)
302 #define TYPE_ADDRESS_CLASS_ALL(t) (((t)->instance_flags ()) \
303 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL)
305 /* * Information about a single discriminant. */
307 struct discriminant_range
309 /* * The range of values for the variant. This is an inclusive
313 /* * Return true if VALUE is contained in this range. IS_UNSIGNED
314 is true if this should be an unsigned comparison; false for
316 bool contains (ULONGEST value
, bool is_unsigned
) const
319 return value
>= low
&& value
<= high
;
320 LONGEST valuel
= (LONGEST
) value
;
321 return valuel
>= (LONGEST
) low
&& valuel
<= (LONGEST
) high
;
327 /* * A single variant. A variant has a list of discriminant values.
328 When the discriminator matches one of these, the variant is
329 enabled. Each variant controls zero or more fields; and may also
330 control other variant parts as well. This struct corresponds to
331 DW_TAG_variant in DWARF. */
333 struct variant
: allocate_on_obstack
335 /* * The discriminant ranges for this variant. */
336 gdb::array_view
<discriminant_range
> discriminants
;
338 /* * The fields controlled by this variant. This is inclusive on
339 the low end and exclusive on the high end. A variant may not
340 control any fields, in which case the two values will be equal.
341 These are indexes into the type's array of fields. */
345 /* * Variant parts controlled by this variant. */
346 gdb::array_view
<variant_part
> parts
;
348 /* * Return true if this is the default variant. The default
349 variant can be recognized because it has no associated
351 bool is_default () const
353 return discriminants
.empty ();
356 /* * Return true if this variant matches VALUE. IS_UNSIGNED is true
357 if this should be an unsigned comparison; false for signed. */
358 bool matches (ULONGEST value
, bool is_unsigned
) const;
361 /* * A variant part. Each variant part has an optional discriminant
362 and holds an array of variants. This struct corresponds to
363 DW_TAG_variant_part in DWARF. */
365 struct variant_part
: allocate_on_obstack
367 /* * The index of the discriminant field in the outer type. This is
368 an index into the type's array of fields. If this is -1, there
369 is no discriminant, and only the default variant can be
370 considered to be selected. */
371 int discriminant_index
;
373 /* * True if this discriminant is unsigned; false if signed. This
374 comes from the type of the discriminant. */
377 /* * The variants that are controlled by this variant part. Note
378 that these will always be sorted by field number. */
379 gdb::array_view
<variant
> variants
;
383 enum dynamic_prop_kind
385 PROP_UNDEFINED
, /* Not defined. */
386 PROP_CONST
, /* Constant. */
387 PROP_ADDR_OFFSET
, /* Address offset. */
388 PROP_LOCEXPR
, /* Location expression. */
389 PROP_LOCLIST
, /* Location list. */
390 PROP_VARIANT_PARTS
, /* Variant parts. */
391 PROP_TYPE
, /* Type. */
392 PROP_VARIABLE_NAME
, /* Variable name. */
395 union dynamic_prop_data
397 /* Storage for constant property. */
401 /* Storage for dynamic property. */
405 /* Storage of variant parts for a type. A type with variant parts
406 has all its fields "linearized" -- stored in a single field
407 array, just as if they had all been declared that way. The
408 variant parts are attached via a dynamic property, and then are
409 used to control which fields end up in the final type during
410 dynamic type resolution. */
412 const gdb::array_view
<variant_part
> *variant_parts
;
414 /* Once a variant type is resolved, we may want to be able to go
415 from the resolved type to the original type. In this case we
416 rewrite the property's kind and set this field. */
418 struct type
*original_type
;
420 /* Name of a variable to look up; the variable holds the value of
423 const char *variable_name
;
426 /* * Used to store a dynamic property. */
430 dynamic_prop_kind
kind () const
435 void set_undefined ()
437 m_kind
= PROP_UNDEFINED
;
440 LONGEST
const_val () const
442 gdb_assert (m_kind
== PROP_CONST
);
444 return m_data
.const_val
;
447 void set_const_val (LONGEST const_val
)
450 m_data
.const_val
= const_val
;
455 gdb_assert (m_kind
== PROP_LOCEXPR
456 || m_kind
== PROP_LOCLIST
457 || m_kind
== PROP_ADDR_OFFSET
);
462 void set_locexpr (void *baton
)
464 m_kind
= PROP_LOCEXPR
;
465 m_data
.baton
= baton
;
468 void set_loclist (void *baton
)
470 m_kind
= PROP_LOCLIST
;
471 m_data
.baton
= baton
;
474 void set_addr_offset (void *baton
)
476 m_kind
= PROP_ADDR_OFFSET
;
477 m_data
.baton
= baton
;
480 const gdb::array_view
<variant_part
> *variant_parts () const
482 gdb_assert (m_kind
== PROP_VARIANT_PARTS
);
484 return m_data
.variant_parts
;
487 void set_variant_parts (gdb::array_view
<variant_part
> *variant_parts
)
489 m_kind
= PROP_VARIANT_PARTS
;
490 m_data
.variant_parts
= variant_parts
;
493 struct type
*original_type () const
495 gdb_assert (m_kind
== PROP_TYPE
);
497 return m_data
.original_type
;
500 void set_original_type (struct type
*original_type
)
503 m_data
.original_type
= original_type
;
506 /* Return the name of the variable that holds this property's value.
507 Only valid for PROP_VARIABLE_NAME. */
508 const char *variable_name () const
510 gdb_assert (m_kind
== PROP_VARIABLE_NAME
);
511 return m_data
.variable_name
;
514 /* Set the name of the variable that holds this property's value,
515 and set this property to be of kind PROP_VARIABLE_NAME. */
516 void set_variable_name (const char *name
)
518 m_kind
= PROP_VARIABLE_NAME
;
519 m_data
.variable_name
= name
;
522 /* Determine which field of the union dynamic_prop.data is used. */
523 enum dynamic_prop_kind m_kind
;
525 /* Storage for dynamic or static value. */
526 union dynamic_prop_data m_data
;
529 /* Compare two dynamic_prop objects for equality. dynamic_prop
530 instances are equal iff they have the same type and storage. */
531 extern bool operator== (const dynamic_prop
&l
, const dynamic_prop
&r
);
533 /* Compare two dynamic_prop objects for inequality. */
534 static inline bool operator!= (const dynamic_prop
&l
, const dynamic_prop
&r
)
539 /* * Define a type's dynamic property node kind. */
540 enum dynamic_prop_node_kind
542 /* A property providing a type's data location.
543 Evaluating this field yields to the location of an object's data. */
544 DYN_PROP_DATA_LOCATION
,
546 /* A property representing DW_AT_allocated. The presence of this attribute
547 indicates that the object of the type can be allocated/deallocated. */
550 /* A property representing DW_AT_associated. The presence of this attribute
551 indicated that the object of the type can be associated. */
554 /* A property providing an array's byte stride. */
555 DYN_PROP_BYTE_STRIDE
,
557 /* A property holding variant parts. */
558 DYN_PROP_VARIANT_PARTS
,
560 /* A property holding the size of the type. */
564 /* * List for dynamic type attributes. */
565 struct dynamic_prop_list
567 /* The kind of dynamic prop in this node. */
568 enum dynamic_prop_node_kind prop_kind
;
570 /* The dynamic property itself. */
571 struct dynamic_prop prop
;
573 /* A pointer to the next dynamic property. */
574 struct dynamic_prop_list
*next
;
577 /* * Determine which field of the union main_type.fields[x].loc is
582 FIELD_LOC_KIND_BITPOS
, /**< bitpos */
583 FIELD_LOC_KIND_ENUMVAL
, /**< enumval */
584 FIELD_LOC_KIND_PHYSADDR
, /**< physaddr */
585 FIELD_LOC_KIND_PHYSNAME
, /**< physname */
586 FIELD_LOC_KIND_DWARF_BLOCK
/**< dwarf_block */
589 /* * A discriminant to determine which field in the
590 main_type.type_specific union is being used, if any.
592 For types such as TYPE_CODE_FLT, the use of this
593 discriminant is really redundant, as we know from the type code
594 which field is going to be used. As such, it would be possible to
595 reduce the size of this enum in order to save a bit or two for
596 other fields of struct main_type. But, since we still have extra
597 room , and for the sake of clarity and consistency, we treat all fields
598 of the union the same way. */
600 enum type_specific_kind
603 TYPE_SPECIFIC_CPLUS_STUFF
,
604 TYPE_SPECIFIC_GNAT_STUFF
,
605 TYPE_SPECIFIC_FLOATFORMAT
,
606 /* Note: This is used by TYPE_CODE_FUNC and TYPE_CODE_METHOD. */
608 TYPE_SPECIFIC_SELF_TYPE
,
610 TYPE_SPECIFIC_FIXED_POINT
,
615 struct objfile
*objfile
;
616 struct gdbarch
*gdbarch
;
621 /* * Position of this field, counting in bits from start of
622 containing structure. For big-endian targets, it is the bit
623 offset to the MSB. For little-endian targets, it is the bit
624 offset to the LSB. */
631 /* * For a static field, if TYPE_FIELD_STATIC_HAS_ADDR then
632 physaddr is the location (in the target) of the static
633 field. Otherwise, physname is the mangled label of the
637 const char *physname
;
639 /* * The field location can be computed by evaluating the
640 following DWARF block. Its DATA is allocated on
641 objfile_obstack - no CU load is needed to access it. */
643 struct dwarf2_locexpr_baton
*dwarf_block
;
648 struct type
*type () const
653 void set_type (struct type
*type
)
658 const char *name () const
663 void set_name (const char *name
)
668 /* Location getters / setters. */
670 field_loc_kind
loc_kind () const
675 LONGEST
loc_bitpos () const
677 gdb_assert (m_loc_kind
== FIELD_LOC_KIND_BITPOS
);
681 void set_loc_bitpos (LONGEST bitpos
)
683 m_loc_kind
= FIELD_LOC_KIND_BITPOS
;
684 m_loc
.bitpos
= bitpos
;
687 LONGEST
loc_enumval () const
689 gdb_assert (m_loc_kind
== FIELD_LOC_KIND_ENUMVAL
);
690 return m_loc
.enumval
;
693 void set_loc_enumval (LONGEST enumval
)
695 m_loc_kind
= FIELD_LOC_KIND_ENUMVAL
;
696 m_loc
.enumval
= enumval
;
699 CORE_ADDR
loc_physaddr () const
701 gdb_assert (m_loc_kind
== FIELD_LOC_KIND_PHYSADDR
);
702 return m_loc
.physaddr
;
705 void set_loc_physaddr (CORE_ADDR physaddr
)
707 m_loc_kind
= FIELD_LOC_KIND_PHYSADDR
;
708 m_loc
.physaddr
= physaddr
;
711 const char *loc_physname () const
713 gdb_assert (m_loc_kind
== FIELD_LOC_KIND_PHYSNAME
);
714 return m_loc
.physname
;
717 void set_loc_physname (const char *physname
)
719 m_loc_kind
= FIELD_LOC_KIND_PHYSNAME
;
720 m_loc
.physname
= physname
;
723 dwarf2_locexpr_baton
*loc_dwarf_block () const
725 gdb_assert (m_loc_kind
== FIELD_LOC_KIND_DWARF_BLOCK
);
726 return m_loc
.dwarf_block
;
729 void set_loc_dwarf_block (dwarf2_locexpr_baton
*dwarf_block
)
731 m_loc_kind
= FIELD_LOC_KIND_DWARF_BLOCK
;
732 m_loc
.dwarf_block
= dwarf_block
;
735 union field_location m_loc
;
737 /* * For a function or member type, this is 1 if the argument is
738 marked artificial. Artificial arguments should not be shown
739 to the user. For TYPE_CODE_RANGE it is set if the specific
740 bound is not defined. */
742 unsigned int artificial
: 1;
744 /* * Discriminant for union field_location. */
746 ENUM_BITFIELD(field_loc_kind
) m_loc_kind
: 3;
748 /* * Size of this field, in bits, or zero if not packed.
749 If non-zero in an array type, indicates the element size in
750 bits (used only in Ada at the moment).
751 For an unpacked field, the field's type's length
752 says how many bytes the field occupies. */
754 unsigned int bitsize
: 28;
756 /* * In a struct or union type, type of this field.
757 - In a function or member type, type of this argument.
758 - In an array type, the domain-type of the array. */
762 /* * Name of field, value or argument.
763 NULL for range bounds, array domains, and member function
771 ULONGEST
bit_stride () const
773 if (this->flag_is_byte_stride
)
774 return this->stride
.const_val () * 8;
776 return this->stride
.const_val ();
779 /* * Low bound of range. */
781 struct dynamic_prop low
;
783 /* * High bound of range. */
785 struct dynamic_prop high
;
787 /* The stride value for this range. This can be stored in bits or bytes
788 based on the value of BYTE_STRIDE_P. It is optional to have a stride
789 value, if this range has no stride value defined then this will be set
790 to the constant zero. */
792 struct dynamic_prop stride
;
794 /* * The bias. Sometimes a range value is biased before storage.
795 The bias is added to the stored bits to form the true value. */
799 /* True if HIGH range bound contains the number of elements in the
800 subrange. This affects how the final high bound is computed. */
802 unsigned int flag_upper_bound_is_count
: 1;
804 /* True if LOW or/and HIGH are resolved into a static bound from
807 unsigned int flag_bound_evaluated
: 1;
809 /* If this is true this STRIDE is in bytes, otherwise STRIDE is in bits. */
811 unsigned int flag_is_byte_stride
: 1;
814 /* Compare two range_bounds objects for equality. Simply does
815 memberwise comparison. */
816 extern bool operator== (const range_bounds
&l
, const range_bounds
&r
);
818 /* Compare two range_bounds objects for inequality. */
819 static inline bool operator!= (const range_bounds
&l
, const range_bounds
&r
)
826 /* * CPLUS_STUFF is for TYPE_CODE_STRUCT. It is initialized to
827 point to cplus_struct_default, a default static instance of a
828 struct cplus_struct_type. */
830 struct cplus_struct_type
*cplus_stuff
;
832 /* * GNAT_STUFF is for types for which the GNAT Ada compiler
833 provides additional information. */
835 struct gnat_aux_type
*gnat_stuff
;
837 /* * FLOATFORMAT is for TYPE_CODE_FLT. It is a pointer to a
838 floatformat object that describes the floating-point value
839 that resides within the type. */
841 const struct floatformat
*floatformat
;
843 /* * For TYPE_CODE_FUNC and TYPE_CODE_METHOD types. */
845 struct func_type
*func_stuff
;
847 /* * For types that are pointer to member types (TYPE_CODE_METHODPTR,
848 TYPE_CODE_MEMBERPTR), SELF_TYPE is the type that this pointer
851 struct type
*self_type
;
853 /* * For TYPE_CODE_FIXED_POINT types, the info necessary to decode
854 values of that type. */
855 struct fixed_point_type_info
*fixed_point_info
;
857 /* * An integer-like scalar type may be stored in just part of its
858 enclosing storage bytes. This structure describes this
862 /* * The bit size of the integer. This can be 0. For integers
863 that fill their storage (the ordinary case), this field holds
864 the byte size times 8. */
865 unsigned short bit_size
;
866 /* * The bit offset of the integer. This is ordinarily 0, and can
867 only be non-zero if the bit size is less than the storage
869 unsigned short bit_offset
;
873 /* * Main structure representing a type in GDB.
875 This structure is space-critical. Its layout has been tweaked to
876 reduce the space used. */
880 /* * Code for kind of type. */
882 ENUM_BITFIELD(type_code
) code
: 8;
884 /* * Flags about this type. These fields appear at this location
885 because they packs nicely here. See the TYPE_* macros for
886 documentation about these fields. */
888 unsigned int m_flag_unsigned
: 1;
889 unsigned int m_flag_nosign
: 1;
890 unsigned int m_flag_stub
: 1;
891 unsigned int m_flag_target_stub
: 1;
892 unsigned int m_flag_prototyped
: 1;
893 unsigned int m_flag_varargs
: 1;
894 unsigned int m_flag_vector
: 1;
895 unsigned int m_flag_stub_supported
: 1;
896 unsigned int m_flag_gnu_ifunc
: 1;
897 unsigned int m_flag_fixed_instance
: 1;
898 unsigned int m_flag_objfile_owned
: 1;
899 unsigned int m_flag_endianity_not_default
: 1;
901 /* * True if this type was declared with "class" rather than
904 unsigned int m_flag_declared_class
: 1;
906 /* * True if this is an enum type with disjoint values. This
907 affects how the enum is printed. */
909 unsigned int m_flag_flag_enum
: 1;
911 /* * A discriminant telling us which field of the type_specific
912 union is being used for this type, if any. */
914 ENUM_BITFIELD(type_specific_kind
) type_specific_field
: 3;
916 /* * Number of fields described for this type. This field appears
917 at this location because it packs nicely here. */
921 /* * Name of this type, or NULL if none.
923 This is used for printing only. For looking up a name, look for
924 a symbol in the VAR_DOMAIN. This is generally allocated in the
925 objfile's obstack. However coffread.c uses malloc. */
929 /* * Every type is now associated with a particular objfile, and the
930 type is allocated on the objfile_obstack for that objfile. One
931 problem however, is that there are times when gdb allocates new
932 types while it is not in the process of reading symbols from a
933 particular objfile. Fortunately, these happen when the type
934 being created is a derived type of an existing type, such as in
935 lookup_pointer_type(). So we can just allocate the new type
936 using the same objfile as the existing type, but to do this we
937 need a backpointer to the objfile from the existing type. Yes
938 this is somewhat ugly, but without major overhaul of the internal
939 type system, it can't be avoided for now. */
941 union type_owner m_owner
;
943 /* * For a pointer type, describes the type of object pointed to.
944 - For an array type, describes the type of the elements.
945 - For a function or method type, describes the type of the return value.
946 - For a range type, describes the type of the full range.
947 - For a complex type, describes the type of each coordinate.
948 - For a special record or union type encoding a dynamic-sized type
949 in GNAT, a memoized pointer to a corresponding static version of
951 - Unused otherwise. */
953 struct type
*target_type
;
955 /* * For structure and union types, a description of each field.
956 For set and pascal array types, there is one "field",
957 whose type is the domain type of the set or array.
958 For range types, there are two "fields",
959 the minimum and maximum values (both inclusive).
960 For enum types, each possible value is described by one "field".
961 For a function or method type, a "field" for each parameter.
962 For C++ classes, there is one field for each base class (if it is
963 a derived class) plus one field for each class data member. Member
964 functions are recorded elsewhere.
966 Using a pointer to a separate array of fields
967 allows all types to have the same size, which is useful
968 because we can allocate the space for a type before
969 we know what to put in it. */
973 struct field
*fields
;
975 /* * Union member used for range types. */
977 struct range_bounds
*bounds
;
979 /* If this is a scalar type, then this is its corresponding
981 struct type
*complex_type
;
985 /* * Slot to point to additional language-specific fields of this
988 union type_specific type_specific
;
990 /* * Contains all dynamic type properties. */
991 struct dynamic_prop_list
*dyn_prop_list
;
994 /* * Number of bits allocated for alignment. */
996 #define TYPE_ALIGN_BITS 8
998 /* * A ``struct type'' describes a particular instance of a type, with
999 some particular qualification. */
1003 /* Get the type code of this type.
1005 Note that the code can be TYPE_CODE_TYPEDEF, so if you want the real
1006 type, you need to do `check_typedef (type)->code ()`. */
1007 type_code
code () const
1009 return this->main_type
->code
;
1012 /* Set the type code of this type. */
1013 void set_code (type_code code
)
1015 this->main_type
->code
= code
;
1018 /* Get the name of this type. */
1019 const char *name () const
1021 return this->main_type
->name
;
1024 /* Set the name of this type. */
1025 void set_name (const char *name
)
1027 this->main_type
->name
= name
;
1030 /* Get the number of fields of this type. */
1031 int num_fields () const
1033 return this->main_type
->nfields
;
1036 /* Set the number of fields of this type. */
1037 void set_num_fields (int num_fields
)
1039 this->main_type
->nfields
= num_fields
;
1042 /* Get the fields array of this type. */
1043 struct field
*fields () const
1045 return this->main_type
->flds_bnds
.fields
;
1048 /* Get the field at index IDX. */
1049 struct field
&field (int idx
) const
1051 gdb_assert (idx
>= 0 && idx
< num_fields ());
1052 return this->fields ()[idx
];
1055 /* Set the fields array of this type. */
1056 void set_fields (struct field
*fields
)
1058 this->main_type
->flds_bnds
.fields
= fields
;
1061 type
*index_type () const
1063 return this->field (0).type ();
1066 void set_index_type (type
*index_type
)
1068 this->field (0).set_type (index_type
);
1071 /* Return the instance flags converted to the correct type. */
1072 const type_instance_flags
instance_flags () const
1074 return (enum type_instance_flag_value
) this->m_instance_flags
;
1077 /* Set the instance flags. */
1078 void set_instance_flags (type_instance_flags flags
)
1080 this->m_instance_flags
= flags
;
1083 /* Get the bounds bounds of this type. The type must be a range type. */
1084 range_bounds
*bounds () const
1086 switch (this->code ())
1088 case TYPE_CODE_RANGE
:
1089 return this->main_type
->flds_bnds
.bounds
;
1091 case TYPE_CODE_ARRAY
:
1092 case TYPE_CODE_STRING
:
1093 return this->index_type ()->bounds ();
1096 gdb_assert_not_reached
1097 ("type::bounds called on type with invalid code");
1101 /* Set the bounds of this type. The type must be a range type. */
1102 void set_bounds (range_bounds
*bounds
)
1104 gdb_assert (this->code () == TYPE_CODE_RANGE
);
1106 this->main_type
->flds_bnds
.bounds
= bounds
;
1109 ULONGEST
bit_stride () const
1111 if (this->code () == TYPE_CODE_ARRAY
&& this->field (0).bitsize
!= 0)
1112 return this->field (0).bitsize
;
1113 return this->bounds ()->bit_stride ();
1116 /* Unsigned integer type. If this is not set for a TYPE_CODE_INT,
1117 the type is signed (unless TYPE_NOSIGN is set). */
1119 bool is_unsigned () const
1121 return this->main_type
->m_flag_unsigned
;
1124 void set_is_unsigned (bool is_unsigned
)
1126 this->main_type
->m_flag_unsigned
= is_unsigned
;
1129 /* No sign for this type. In C++, "char", "signed char", and
1130 "unsigned char" are distinct types; so we need an extra flag to
1131 indicate the absence of a sign! */
1133 bool has_no_signedness () const
1135 return this->main_type
->m_flag_nosign
;
1138 void set_has_no_signedness (bool has_no_signedness
)
1140 this->main_type
->m_flag_nosign
= has_no_signedness
;
1143 /* This appears in a type's flags word if it is a stub type (e.g.,
1144 if someone referenced a type that wasn't defined in a source file
1145 via (struct sir_not_appearing_in_this_film *)). */
1147 bool is_stub () const
1149 return this->main_type
->m_flag_stub
;
1152 void set_is_stub (bool is_stub
)
1154 this->main_type
->m_flag_stub
= is_stub
;
1157 /* The target type of this type is a stub type, and this type needs
1158 to be updated if it gets un-stubbed in check_typedef. Used for
1159 arrays and ranges, in which TYPE_LENGTH of the array/range gets set
1160 based on the TYPE_LENGTH of the target type. Also, set for
1161 TYPE_CODE_TYPEDEF. */
1163 bool target_is_stub () const
1165 return this->main_type
->m_flag_target_stub
;
1168 void set_target_is_stub (bool target_is_stub
)
1170 this->main_type
->m_flag_target_stub
= target_is_stub
;
1173 /* This is a function type which appears to have a prototype. We
1174 need this for function calls in order to tell us if it's necessary
1175 to coerce the args, or to just do the standard conversions. This
1176 is used with a short field. */
1178 bool is_prototyped () const
1180 return this->main_type
->m_flag_prototyped
;
1183 void set_is_prototyped (bool is_prototyped
)
1185 this->main_type
->m_flag_prototyped
= is_prototyped
;
1188 /* FIXME drow/2002-06-03: Only used for methods, but applies as well
1191 bool has_varargs () const
1193 return this->main_type
->m_flag_varargs
;
1196 void set_has_varargs (bool has_varargs
)
1198 this->main_type
->m_flag_varargs
= has_varargs
;
1201 /* Identify a vector type. Gcc is handling this by adding an extra
1202 attribute to the array type. We slurp that in as a new flag of a
1203 type. This is used only in dwarf2read.c. */
1205 bool is_vector () const
1207 return this->main_type
->m_flag_vector
;
1210 void set_is_vector (bool is_vector
)
1212 this->main_type
->m_flag_vector
= is_vector
;
1215 /* This debug target supports TYPE_STUB(t). In the unsupported case
1216 we have to rely on NFIELDS to be zero etc., see TYPE_IS_OPAQUE().
1217 TYPE_STUB(t) with !TYPE_STUB_SUPPORTED(t) may exist if we only
1218 guessed the TYPE_STUB(t) value (see dwarfread.c). */
1220 bool stub_is_supported () const
1222 return this->main_type
->m_flag_stub_supported
;
1225 void set_stub_is_supported (bool stub_is_supported
)
1227 this->main_type
->m_flag_stub_supported
= stub_is_supported
;
1230 /* Used only for TYPE_CODE_FUNC where it specifies the real function
1231 address is returned by this function call. TYPE_TARGET_TYPE
1232 determines the final returned function type to be presented to
1235 bool is_gnu_ifunc () const
1237 return this->main_type
->m_flag_gnu_ifunc
;
1240 void set_is_gnu_ifunc (bool is_gnu_ifunc
)
1242 this->main_type
->m_flag_gnu_ifunc
= is_gnu_ifunc
;
1245 /* The debugging formats (especially STABS) do not contain enough
1246 information to represent all Ada types---especially those whose
1247 size depends on dynamic quantities. Therefore, the GNAT Ada
1248 compiler includes extra information in the form of additional type
1249 definitions connected by naming conventions. This flag indicates
1250 that the type is an ordinary (unencoded) GDB type that has been
1251 created from the necessary run-time information, and does not need
1252 further interpretation. Optionally marks ordinary, fixed-size GDB
1255 bool is_fixed_instance () const
1257 return this->main_type
->m_flag_fixed_instance
;
1260 void set_is_fixed_instance (bool is_fixed_instance
)
1262 this->main_type
->m_flag_fixed_instance
= is_fixed_instance
;
1265 /* A compiler may supply dwarf instrumentation that indicates the desired
1266 endian interpretation of the variable differs from the native endian
1269 bool endianity_is_not_default () const
1271 return this->main_type
->m_flag_endianity_not_default
;
1274 void set_endianity_is_not_default (bool endianity_is_not_default
)
1276 this->main_type
->m_flag_endianity_not_default
= endianity_is_not_default
;
1280 /* True if this type was declared using the "class" keyword. This is
1281 only valid for C++ structure and enum types. If false, a structure
1282 was declared as a "struct"; if true it was declared "class". For
1283 enum types, this is true when "enum class" or "enum struct" was
1284 used to declare the type. */
1286 bool is_declared_class () const
1288 return this->main_type
->m_flag_declared_class
;
1291 void set_is_declared_class (bool is_declared_class
) const
1293 this->main_type
->m_flag_declared_class
= is_declared_class
;
1296 /* True if this type is a "flag" enum. A flag enum is one where all
1297 the values are pairwise disjoint when "and"ed together. This
1298 affects how enum values are printed. */
1300 bool is_flag_enum () const
1302 return this->main_type
->m_flag_flag_enum
;
1305 void set_is_flag_enum (bool is_flag_enum
)
1307 this->main_type
->m_flag_flag_enum
= is_flag_enum
;
1310 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return a reference
1311 to this type's fixed_point_info. */
1313 struct fixed_point_type_info
&fixed_point_info () const
1315 gdb_assert (this->code () == TYPE_CODE_FIXED_POINT
);
1316 gdb_assert (this->main_type
->type_specific
.fixed_point_info
!= nullptr);
1318 return *this->main_type
->type_specific
.fixed_point_info
;
1321 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, set this type's
1322 fixed_point_info to INFO. */
1324 void set_fixed_point_info (struct fixed_point_type_info
*info
) const
1326 gdb_assert (this->code () == TYPE_CODE_FIXED_POINT
);
1328 this->main_type
->type_specific
.fixed_point_info
= info
;
1331 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return its base type.
1333 In other words, this returns the type after having peeled all
1334 intermediate type layers (such as TYPE_CODE_RANGE, for instance).
1335 The TYPE_CODE of the type returned is guaranteed to be
1336 a TYPE_CODE_FIXED_POINT. */
1338 struct type
*fixed_point_type_base_type ();
1340 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return its scaling
1343 const gdb_mpq
&fixed_point_scaling_factor ();
1345 /* * Return the dynamic property of the requested KIND from this type's
1346 list of dynamic properties. */
1347 dynamic_prop
*dyn_prop (dynamic_prop_node_kind kind
) const;
1349 /* * Given a dynamic property PROP of a given KIND, add this dynamic
1350 property to this type.
1352 This function assumes that this type is objfile-owned. */
1353 void add_dyn_prop (dynamic_prop_node_kind kind
, dynamic_prop prop
);
1355 /* * Remove dynamic property of kind KIND from this type, if it exists. */
1356 void remove_dyn_prop (dynamic_prop_node_kind kind
);
1358 /* Return true if this type is owned by an objfile. Return false if it is
1359 owned by an architecture. */
1360 bool is_objfile_owned () const
1362 return this->main_type
->m_flag_objfile_owned
;
1365 /* Set the owner of the type to be OBJFILE. */
1366 void set_owner (objfile
*objfile
)
1368 gdb_assert (objfile
!= nullptr);
1370 this->main_type
->m_owner
.objfile
= objfile
;
1371 this->main_type
->m_flag_objfile_owned
= true;
1374 /* Set the owner of the type to be ARCH. */
1375 void set_owner (gdbarch
*arch
)
1377 gdb_assert (arch
!= nullptr);
1379 this->main_type
->m_owner
.gdbarch
= arch
;
1380 this->main_type
->m_flag_objfile_owned
= false;
1383 /* Return the objfile owner of this type.
1385 Return nullptr if this type is not objfile-owned. */
1386 struct objfile
*objfile_owner () const
1388 if (!this->is_objfile_owned ())
1391 return this->main_type
->m_owner
.objfile
;
1394 /* Return the gdbarch owner of this type.
1396 Return nullptr if this type is not gdbarch-owned. */
1397 gdbarch
*arch_owner () const
1399 if (this->is_objfile_owned ())
1402 return this->main_type
->m_owner
.gdbarch
;
1405 /* Return the type's architecture. For types owned by an
1406 architecture, that architecture is returned. For types owned by an
1407 objfile, that objfile's architecture is returned.
1409 The return value is always non-nullptr. */
1410 gdbarch
*arch () const;
1412 /* * Return true if this is an integer type whose logical (bit) size
1413 differs from its storage size; false otherwise. Always return
1414 false for non-integer (i.e., non-TYPE_SPECIFIC_INT) types. */
1415 bool bit_size_differs_p () const
1417 return (main_type
->type_specific_field
== TYPE_SPECIFIC_INT
1418 && main_type
->type_specific
.int_stuff
.bit_size
!= 8 * length
);
1421 /* * Return the logical (bit) size for this integer type. Only
1422 valid for integer (TYPE_SPECIFIC_INT) types. */
1423 unsigned short bit_size () const
1425 gdb_assert (main_type
->type_specific_field
== TYPE_SPECIFIC_INT
);
1426 return main_type
->type_specific
.int_stuff
.bit_size
;
1429 /* * Return the bit offset for this integer type. Only valid for
1430 integer (TYPE_SPECIFIC_INT) types. */
1431 unsigned short bit_offset () const
1433 gdb_assert (main_type
->type_specific_field
== TYPE_SPECIFIC_INT
);
1434 return main_type
->type_specific
.int_stuff
.bit_offset
;
1437 /* Return true if this is a pointer or reference type. */
1438 bool is_pointer_or_reference () const
1440 return this->code () == TYPE_CODE_PTR
|| TYPE_IS_REFERENCE (this);
1443 /* * Type that is a pointer to this type.
1444 NULL if no such pointer-to type is known yet.
1445 The debugger may add the address of such a type
1446 if it has to construct one later. */
1448 struct type
*pointer_type
;
1450 /* * C++: also need a reference type. */
1452 struct type
*reference_type
;
1454 /* * A C++ rvalue reference type added in C++11. */
1456 struct type
*rvalue_reference_type
;
1458 /* * Variant chain. This points to a type that differs from this
1459 one only in qualifiers and length. Currently, the possible
1460 qualifiers are const, volatile, code-space, data-space, and
1461 address class. The length may differ only when one of the
1462 address class flags are set. The variants are linked in a
1463 circular ring and share MAIN_TYPE. */
1467 /* * The alignment for this type. Zero means that the alignment was
1468 not specified in the debug info. Note that this is stored in a
1469 funny way: as the log base 2 (plus 1) of the alignment; so a
1470 value of 1 means the alignment is 1, and a value of 9 means the
1471 alignment is 256. */
1473 unsigned align_log2
: TYPE_ALIGN_BITS
;
1475 /* * Flags specific to this instance of the type, indicating where
1478 For TYPE_CODE_TYPEDEF the flags of the typedef type should be
1479 binary or-ed with the target type, with a special case for
1480 address class and space class. For example if this typedef does
1481 not specify any new qualifiers, TYPE_INSTANCE_FLAGS is 0 and the
1482 instance flags are completely inherited from the target type. No
1483 qualifiers can be cleared by the typedef. See also
1485 unsigned m_instance_flags
: 9;
1487 /* * Length of storage for a value of this type. The value is the
1488 expression in host bytes of what sizeof(type) would return. This
1489 size includes padding. For example, an i386 extended-precision
1490 floating point value really only occupies ten bytes, but most
1491 ABI's declare its size to be 12 bytes, to preserve alignment.
1492 A `struct type' representing such a floating-point type would
1493 have a `length' value of 12, even though the last two bytes are
1496 Since this field is expressed in host bytes, its value is appropriate
1497 to pass to memcpy and such (it is assumed that GDB itself always runs
1498 on an 8-bits addressable architecture). However, when using it for
1499 target address arithmetic (e.g. adding it to a target address), the
1500 type_length_units function should be used in order to get the length
1501 expressed in target addressable memory units. */
1505 /* * Core type, shared by a group of qualified types. */
1507 struct main_type
*main_type
;
1513 /* * The overloaded name.
1514 This is generally allocated in the objfile's obstack.
1515 However stabsread.c sometimes uses malloc. */
1519 /* * The number of methods with this name. */
1523 /* * The list of methods. */
1525 struct fn_field
*fn_fields
;
1532 /* * If is_stub is clear, this is the mangled name which we can look
1533 up to find the address of the method (FIXME: it would be cleaner
1534 to have a pointer to the struct symbol here instead).
1536 If is_stub is set, this is the portion of the mangled name which
1537 specifies the arguments. For example, "ii", if there are two int
1538 arguments, or "" if there are no arguments. See gdb_mangle_name
1539 for the conversion from this format to the one used if is_stub is
1542 const char *physname
;
1544 /* * The function type for the method.
1546 (This comment used to say "The return value of the method", but
1547 that's wrong. The function type is expected here, i.e. something
1548 with TYPE_CODE_METHOD, and *not* the return-value type). */
1552 /* * For virtual functions. First baseclass that defines this
1553 virtual function. */
1555 struct type
*fcontext
;
1559 unsigned int is_const
:1;
1560 unsigned int is_volatile
:1;
1561 unsigned int is_private
:1;
1562 unsigned int is_protected
:1;
1563 unsigned int is_artificial
:1;
1565 /* * A stub method only has some fields valid (but they are enough
1566 to reconstruct the rest of the fields). */
1568 unsigned int is_stub
:1;
1570 /* * True if this function is a constructor, false otherwise. */
1572 unsigned int is_constructor
: 1;
1574 /* * True if this function is deleted, false otherwise. */
1576 unsigned int is_deleted
: 1;
1578 /* * DW_AT_defaulted attribute for this function. The value is one
1579 of the DW_DEFAULTED constants. */
1581 ENUM_BITFIELD (dwarf_defaulted_attribute
) defaulted
: 2;
1585 unsigned int dummy
:6;
1587 /* * Index into that baseclass's virtual function table, minus 2;
1588 else if static: VOFFSET_STATIC; else: 0. */
1590 unsigned int voffset
:16;
1592 #define VOFFSET_STATIC 1
1598 /* * Unqualified name to be prefixed by owning class qualified
1603 /* * Type this typedef named NAME represents. */
1607 /* * True if this field was declared protected, false otherwise. */
1608 unsigned int is_protected
: 1;
1610 /* * True if this field was declared private, false otherwise. */
1611 unsigned int is_private
: 1;
1614 /* * C++ language-specific information for TYPE_CODE_STRUCT and
1615 TYPE_CODE_UNION nodes. */
1617 struct cplus_struct_type
1619 /* * Number of base classes this type derives from. The
1620 baseclasses are stored in the first N_BASECLASSES fields
1621 (i.e. the `fields' field of the struct type). The only fields
1622 of struct field that are used are: type, name, loc.bitpos. */
1624 short n_baseclasses
;
1626 /* * Field number of the virtual function table pointer in VPTR_BASETYPE.
1627 All access to this field must be through TYPE_VPTR_FIELDNO as one
1628 thing it does is check whether the field has been initialized.
1629 Initially TYPE_RAW_CPLUS_SPECIFIC has the value of cplus_struct_default,
1630 which for portability reasons doesn't initialize this field.
1631 TYPE_VPTR_FIELDNO returns -1 for this case.
1633 If -1, we were unable to find the virtual function table pointer in
1634 initial symbol reading, and get_vptr_fieldno should be called to find
1635 it if possible. get_vptr_fieldno will update this field if possible.
1636 Otherwise the value is left at -1.
1638 Unused if this type does not have virtual functions. */
1642 /* * Number of methods with unique names. All overloaded methods
1643 with the same name count only once. */
1647 /* * Number of template arguments. */
1649 unsigned short n_template_arguments
;
1651 /* * One if this struct is a dynamic class, as defined by the
1652 Itanium C++ ABI: if it requires a virtual table pointer,
1653 because it or any of its base classes have one or more virtual
1654 member functions or virtual base classes. Minus one if not
1655 dynamic. Zero if not yet computed. */
1659 /* * The calling convention for this type, fetched from the
1660 DW_AT_calling_convention attribute. The value is one of the
1663 ENUM_BITFIELD (dwarf_calling_convention
) calling_convention
: 8;
1665 /* * The base class which defined the virtual function table pointer. */
1667 struct type
*vptr_basetype
;
1669 /* * For derived classes, the number of base classes is given by
1670 n_baseclasses and virtual_field_bits is a bit vector containing
1671 one bit per base class. If the base class is virtual, the
1672 corresponding bit will be set.
1677 class C : public B, public virtual A {};
1679 B is a baseclass of C; A is a virtual baseclass for C.
1680 This is a C++ 2.0 language feature. */
1682 B_TYPE
*virtual_field_bits
;
1684 /* * For classes with private fields, the number of fields is
1685 given by nfields and private_field_bits is a bit vector
1686 containing one bit per field.
1688 If the field is private, the corresponding bit will be set. */
1690 B_TYPE
*private_field_bits
;
1692 /* * For classes with protected fields, the number of fields is
1693 given by nfields and protected_field_bits is a bit vector
1694 containing one bit per field.
1696 If the field is private, the corresponding bit will be set. */
1698 B_TYPE
*protected_field_bits
;
1700 /* * For classes with fields to be ignored, either this is
1701 optimized out or this field has length 0. */
1703 B_TYPE
*ignore_field_bits
;
1705 /* * For classes, structures, and unions, a description of each
1706 field, which consists of an overloaded name, followed by the
1707 types of arguments that the method expects, and then the name
1708 after it has been renamed to make it distinct.
1710 fn_fieldlists points to an array of nfn_fields of these. */
1712 struct fn_fieldlist
*fn_fieldlists
;
1714 /* * typedefs defined inside this class. typedef_field points to
1715 an array of typedef_field_count elements. */
1717 struct decl_field
*typedef_field
;
1719 unsigned typedef_field_count
;
1721 /* * The nested types defined by this type. nested_types points to
1722 an array of nested_types_count elements. */
1724 struct decl_field
*nested_types
;
1726 unsigned nested_types_count
;
1728 /* * The template arguments. This is an array with
1729 N_TEMPLATE_ARGUMENTS elements. This is NULL for non-template
1732 struct symbol
**template_arguments
;
1735 /* * Struct used to store conversion rankings. */
1741 /* * When two conversions are of the same type and therefore have
1742 the same rank, subrank is used to differentiate the two.
1744 Eg: Two derived-class-pointer to base-class-pointer conversions
1745 would both have base pointer conversion rank, but the
1746 conversion with the shorter distance to the ancestor is
1747 preferable. 'subrank' would be used to reflect that. */
1752 /* * Used for ranking a function for overload resolution. */
1754 typedef std::vector
<rank
> badness_vector
;
1756 /* * GNAT Ada-specific information for various Ada types. */
1758 struct gnat_aux_type
1760 /* * Parallel type used to encode information about dynamic types
1761 used in Ada (such as variant records, variable-size array,
1763 struct type
* descriptive_type
;
1766 /* * For TYPE_CODE_FUNC and TYPE_CODE_METHOD types. */
1770 /* * The calling convention for targets supporting multiple ABIs.
1771 Right now this is only fetched from the Dwarf-2
1772 DW_AT_calling_convention attribute. The value is one of the
1775 ENUM_BITFIELD (dwarf_calling_convention
) calling_convention
: 8;
1777 /* * Whether this function normally returns to its caller. It is
1778 set from the DW_AT_noreturn attribute if set on the
1779 DW_TAG_subprogram. */
1781 unsigned int is_noreturn
: 1;
1783 /* * Only those DW_TAG_call_site's in this function that have
1784 DW_AT_call_tail_call set are linked in this list. Function
1785 without its tail call list complete
1786 (DW_AT_call_all_tail_calls or its superset
1787 DW_AT_call_all_calls) has TAIL_CALL_LIST NULL, even if some
1788 DW_TAG_call_site's exist in such function. */
1790 struct call_site
*tail_call_list
;
1792 /* * For method types (TYPE_CODE_METHOD), the aggregate type that
1793 contains the method. */
1795 struct type
*self_type
;
1798 /* struct call_site_parameter can be referenced in callees by several ways. */
1800 enum call_site_parameter_kind
1802 /* * Use field call_site_parameter.u.dwarf_reg. */
1803 CALL_SITE_PARAMETER_DWARF_REG
,
1805 /* * Use field call_site_parameter.u.fb_offset. */
1806 CALL_SITE_PARAMETER_FB_OFFSET
,
1808 /* * Use field call_site_parameter.u.param_offset. */
1809 CALL_SITE_PARAMETER_PARAM_OFFSET
1812 struct call_site_target
1814 field_loc_kind
loc_kind () const
1819 CORE_ADDR
loc_physaddr () const
1821 gdb_assert (m_loc_kind
== FIELD_LOC_KIND_PHYSADDR
);
1822 return m_loc
.physaddr
;
1825 void set_loc_physaddr (CORE_ADDR physaddr
)
1827 m_loc_kind
= FIELD_LOC_KIND_PHYSADDR
;
1828 m_loc
.physaddr
= physaddr
;
1831 const char *loc_physname () const
1833 gdb_assert (m_loc_kind
== FIELD_LOC_KIND_PHYSNAME
);
1834 return m_loc
.physname
;
1837 void set_loc_physname (const char *physname
)
1839 m_loc_kind
= FIELD_LOC_KIND_PHYSNAME
;
1840 m_loc
.physname
= physname
;
1843 dwarf2_locexpr_baton
*loc_dwarf_block () const
1845 gdb_assert (m_loc_kind
== FIELD_LOC_KIND_DWARF_BLOCK
);
1846 return m_loc
.dwarf_block
;
1849 void set_loc_dwarf_block (dwarf2_locexpr_baton
*dwarf_block
)
1851 m_loc_kind
= FIELD_LOC_KIND_DWARF_BLOCK
;
1852 m_loc
.dwarf_block
= dwarf_block
;
1855 union field_location m_loc
;
1857 /* * Discriminant for union field_location. */
1859 ENUM_BITFIELD(field_loc_kind
) m_loc_kind
: 3;
1862 union call_site_parameter_u
1864 /* * DW_TAG_formal_parameter's DW_AT_location's DW_OP_regX
1865 as DWARF register number, for register passed
1870 /* * Offset from the callee's frame base, for stack passed
1871 parameters. This equals offset from the caller's stack
1874 CORE_ADDR fb_offset
;
1876 /* * Offset relative to the start of this PER_CU to
1877 DW_TAG_formal_parameter which is referenced by both
1878 caller and the callee. */
1880 cu_offset param_cu_off
;
1883 struct call_site_parameter
1885 ENUM_BITFIELD (call_site_parameter_kind
) kind
: 2;
1887 union call_site_parameter_u u
;
1889 /* * DW_TAG_formal_parameter's DW_AT_call_value. It is never NULL. */
1891 const gdb_byte
*value
;
1894 /* * DW_TAG_formal_parameter's DW_AT_call_data_value.
1895 It may be NULL if not provided by DWARF. */
1897 const gdb_byte
*data_value
;
1898 size_t data_value_size
;
1901 /* * A place where a function gets called from, represented by
1902 DW_TAG_call_site. It can be looked up from symtab->call_site_htab. */
1906 call_site (CORE_ADDR pc
, dwarf2_per_cu_data
*per_cu
,
1907 dwarf2_per_objfile
*per_objfile
)
1908 : per_cu (per_cu
), per_objfile (per_objfile
), m_unrelocated_pc (pc
)
1912 eq (const call_site
*a
, const call_site
*b
)
1914 return a
->m_unrelocated_pc
== b
->m_unrelocated_pc
;
1918 hash (const call_site
*a
)
1920 return a
->m_unrelocated_pc
;
1924 eq (const void *a
, const void *b
)
1926 return eq ((const call_site
*)a
, (const call_site
*)b
);
1930 hash (const void *a
)
1932 return hash ((const call_site
*)a
);
1935 /* Return the address of the first instruction after this call. */
1937 CORE_ADDR
pc () const;
1939 /* * List successor with head in FUNC_TYPE.TAIL_CALL_LIST. */
1941 struct call_site
*tail_call_next
= nullptr;
1943 /* * Describe DW_AT_call_target. Missing attribute uses
1944 FIELD_LOC_KIND_DWARF_BLOCK with FIELD_DWARF_BLOCK == NULL. */
1946 struct call_site_target target
{};
1948 /* * Size of the PARAMETER array. */
1950 unsigned parameter_count
= 0;
1952 /* * CU of the function where the call is located. It gets used
1953 for DWARF blocks execution in the parameter array below. */
1955 dwarf2_per_cu_data
*const per_cu
= nullptr;
1957 /* objfile of the function where the call is located. */
1959 dwarf2_per_objfile
*const per_objfile
= nullptr;
1962 /* Unrelocated address of the first instruction after this call. */
1963 const CORE_ADDR m_unrelocated_pc
;
1966 /* * Describe DW_TAG_call_site's DW_TAG_formal_parameter. */
1968 struct call_site_parameter parameter
[];
1971 /* The type-specific info for TYPE_CODE_FIXED_POINT types. */
1973 struct fixed_point_type_info
1975 /* The fixed point type's scaling factor. */
1976 gdb_mpq scaling_factor
;
1979 /* * The default value of TYPE_CPLUS_SPECIFIC(T) points to this shared
1980 static structure. */
1982 extern const struct cplus_struct_type cplus_struct_default
;
1984 extern void allocate_cplus_struct_type (struct type
*);
1986 #define INIT_CPLUS_SPECIFIC(type) \
1987 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_CPLUS_STUFF, \
1988 TYPE_RAW_CPLUS_SPECIFIC (type) = (struct cplus_struct_type*) \
1989 &cplus_struct_default)
1991 #define ALLOCATE_CPLUS_STRUCT_TYPE(type) allocate_cplus_struct_type (type)
1993 #define HAVE_CPLUS_STRUCT(type) \
1994 (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_CPLUS_STUFF \
1995 && TYPE_RAW_CPLUS_SPECIFIC (type) != &cplus_struct_default)
1997 #define INIT_NONE_SPECIFIC(type) \
1998 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_NONE, \
1999 TYPE_MAIN_TYPE (type)->type_specific = {})
2001 extern const struct gnat_aux_type gnat_aux_default
;
2003 extern void allocate_gnat_aux_type (struct type
*);
2005 #define INIT_GNAT_SPECIFIC(type) \
2006 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_GNAT_STUFF, \
2007 TYPE_GNAT_SPECIFIC (type) = (struct gnat_aux_type *) &gnat_aux_default)
2008 #define ALLOCATE_GNAT_AUX_TYPE(type) allocate_gnat_aux_type (type)
2009 /* * A macro that returns non-zero if the type-specific data should be
2010 read as "gnat-stuff". */
2011 #define HAVE_GNAT_AUX_INFO(type) \
2012 (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_GNAT_STUFF)
2014 /* * True if TYPE is known to be an Ada type of some kind. */
2015 #define ADA_TYPE_P(type) \
2016 (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_GNAT_STUFF \
2017 || (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE \
2018 && (type)->is_fixed_instance ()))
2020 #define INIT_FUNC_SPECIFIC(type) \
2021 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FUNC, \
2022 TYPE_MAIN_TYPE (type)->type_specific.func_stuff = (struct func_type *) \
2023 TYPE_ZALLOC (type, \
2024 sizeof (*TYPE_MAIN_TYPE (type)->type_specific.func_stuff)))
2026 /* "struct fixed_point_type_info" has a field that has a destructor.
2027 See allocate_fixed_point_type_info to understand how this is
2029 #define INIT_FIXED_POINT_SPECIFIC(type) \
2030 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FIXED_POINT, \
2031 allocate_fixed_point_type_info (type))
2033 #define TYPE_MAIN_TYPE(thistype) (thistype)->main_type
2034 #define TYPE_TARGET_TYPE(thistype) TYPE_MAIN_TYPE(thistype)->target_type
2035 #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
2036 #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
2037 #define TYPE_RVALUE_REFERENCE_TYPE(thistype) (thistype)->rvalue_reference_type
2038 #define TYPE_CHAIN(thistype) (thistype)->chain
2039 /* * Note that if thistype is a TYPEDEF type, you have to call check_typedef.
2040 But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
2041 so you only have to call check_typedef once. Since allocate_value
2042 calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe. */
2043 #define TYPE_LENGTH(thistype) (thistype)->length
2045 /* * Return the alignment of the type in target addressable memory
2046 units, or 0 if no alignment was specified. */
2047 #define TYPE_RAW_ALIGN(thistype) type_raw_align (thistype)
2049 /* * Return the alignment of the type in target addressable memory
2050 units, or 0 if no alignment was specified. */
2051 extern unsigned type_raw_align (struct type
*);
2053 /* * Return the alignment of the type in target addressable memory
2054 units. Return 0 if the alignment cannot be determined; but note
2055 that this makes an effort to compute the alignment even it it was
2056 not specified in the debug info. */
2057 extern unsigned type_align (struct type
*);
2059 /* * Set the alignment of the type. The alignment must be a power of
2060 2. Returns false if the given value does not fit in the available
2061 space in struct type. */
2062 extern bool set_type_align (struct type
*, ULONGEST
);
2064 /* Property accessors for the type data location. */
2065 #define TYPE_DATA_LOCATION(thistype) \
2066 ((thistype)->dyn_prop (DYN_PROP_DATA_LOCATION))
2067 #define TYPE_DATA_LOCATION_BATON(thistype) \
2068 TYPE_DATA_LOCATION (thistype)->data.baton
2069 #define TYPE_DATA_LOCATION_ADDR(thistype) \
2070 (TYPE_DATA_LOCATION (thistype)->const_val ())
2071 #define TYPE_DATA_LOCATION_KIND(thistype) \
2072 (TYPE_DATA_LOCATION (thistype)->kind ())
2073 #define TYPE_DYNAMIC_LENGTH(thistype) \
2074 ((thistype)->dyn_prop (DYN_PROP_BYTE_SIZE))
2076 /* Property accessors for the type allocated/associated. */
2077 #define TYPE_ALLOCATED_PROP(thistype) \
2078 ((thistype)->dyn_prop (DYN_PROP_ALLOCATED))
2079 #define TYPE_ASSOCIATED_PROP(thistype) \
2080 ((thistype)->dyn_prop (DYN_PROP_ASSOCIATED))
2084 #define TYPE_SELF_TYPE(thistype) internal_type_self_type (thistype)
2085 /* Do not call this, use TYPE_SELF_TYPE. */
2086 extern struct type
*internal_type_self_type (struct type
*);
2087 extern void set_type_self_type (struct type
*, struct type
*);
2089 extern int internal_type_vptr_fieldno (struct type
*);
2090 extern void set_type_vptr_fieldno (struct type
*, int);
2091 extern struct type
*internal_type_vptr_basetype (struct type
*);
2092 extern void set_type_vptr_basetype (struct type
*, struct type
*);
2093 #define TYPE_VPTR_FIELDNO(thistype) internal_type_vptr_fieldno (thistype)
2094 #define TYPE_VPTR_BASETYPE(thistype) internal_type_vptr_basetype (thistype)
2096 #define TYPE_NFN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields
2097 #define TYPE_SPECIFIC_FIELD(thistype) \
2098 TYPE_MAIN_TYPE(thistype)->type_specific_field
2099 /* We need this tap-dance with the TYPE_RAW_SPECIFIC because of the case
2100 where we're trying to print an Ada array using the C language.
2101 In that case, there is no "cplus_stuff", but the C language assumes
2102 that there is. What we do, in that case, is pretend that there is
2103 an implicit one which is the default cplus stuff. */
2104 #define TYPE_CPLUS_SPECIFIC(thistype) \
2105 (!HAVE_CPLUS_STRUCT(thistype) \
2106 ? (struct cplus_struct_type*)&cplus_struct_default \
2107 : TYPE_RAW_CPLUS_SPECIFIC(thistype))
2108 #define TYPE_RAW_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff
2109 #define TYPE_CPLUS_CALLING_CONVENTION(thistype) \
2110 TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff->calling_convention
2111 #define TYPE_FLOATFORMAT(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.floatformat
2112 #define TYPE_GNAT_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.gnat_stuff
2113 #define TYPE_DESCRIPTIVE_TYPE(thistype) TYPE_GNAT_SPECIFIC(thistype)->descriptive_type
2114 #define TYPE_CALLING_CONVENTION(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->calling_convention
2115 #define TYPE_NO_RETURN(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->is_noreturn
2116 #define TYPE_TAIL_CALL_LIST(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->tail_call_list
2117 #define TYPE_BASECLASS(thistype,index) ((thistype)->field (index).type ())
2118 #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
2119 #define TYPE_BASECLASS_NAME(thistype,index) (thistype->field (index).name ())
2120 #define TYPE_BASECLASS_BITPOS(thistype,index) (thistype->field (index).loc_bitpos ())
2121 #define BASETYPE_VIA_PUBLIC(thistype, index) \
2122 ((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index)))
2123 #define TYPE_CPLUS_DYNAMIC(thistype) TYPE_CPLUS_SPECIFIC (thistype)->is_dynamic
2125 #define BASETYPE_VIA_VIRTUAL(thistype, index) \
2126 (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
2127 : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
2129 #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
2130 #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
2132 #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL((thistype)->field (n))
2133 #define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE((thistype)->field (n))
2134 #define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE((thistype)->field (n))!=0)
2136 #define TYPE_FIELD_PRIVATE_BITS(thistype) \
2137 TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits
2138 #define TYPE_FIELD_PROTECTED_BITS(thistype) \
2139 TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits
2140 #define TYPE_FIELD_IGNORE_BITS(thistype) \
2141 TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits
2142 #define TYPE_FIELD_VIRTUAL_BITS(thistype) \
2143 TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits
2144 #define SET_TYPE_FIELD_PRIVATE(thistype, n) \
2145 B_SET (TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n))
2146 #define SET_TYPE_FIELD_PROTECTED(thistype, n) \
2147 B_SET (TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n))
2148 #define SET_TYPE_FIELD_IGNORE(thistype, n) \
2149 B_SET (TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits, (n))
2150 #define SET_TYPE_FIELD_VIRTUAL(thistype, n) \
2151 B_SET (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n))
2152 #define TYPE_FIELD_PRIVATE(thistype, n) \
2153 (TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits == NULL ? 0 \
2154 : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n)))
2155 #define TYPE_FIELD_PROTECTED(thistype, n) \
2156 (TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits == NULL ? 0 \
2157 : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n)))
2158 #define TYPE_FIELD_IGNORE(thistype, n) \
2159 (TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits == NULL ? 0 \
2160 : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits, (n)))
2161 #define TYPE_FIELD_VIRTUAL(thistype, n) \
2162 (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
2163 : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n)))
2165 #define TYPE_FN_FIELDLISTS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists
2166 #define TYPE_FN_FIELDLIST(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n]
2167 #define TYPE_FN_FIELDLIST1(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].fn_fields
2168 #define TYPE_FN_FIELDLIST_NAME(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].name
2169 #define TYPE_FN_FIELDLIST_LENGTH(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].length
2171 #define TYPE_N_TEMPLATE_ARGUMENTS(thistype) \
2172 TYPE_CPLUS_SPECIFIC (thistype)->n_template_arguments
2173 #define TYPE_TEMPLATE_ARGUMENTS(thistype) \
2174 TYPE_CPLUS_SPECIFIC (thistype)->template_arguments
2175 #define TYPE_TEMPLATE_ARGUMENT(thistype, n) \
2176 TYPE_CPLUS_SPECIFIC (thistype)->template_arguments[n]
2178 #define TYPE_FN_FIELD(thisfn, n) (thisfn)[n]
2179 #define TYPE_FN_FIELD_PHYSNAME(thisfn, n) (thisfn)[n].physname
2180 #define TYPE_FN_FIELD_TYPE(thisfn, n) (thisfn)[n].type
2181 #define TYPE_FN_FIELD_ARGS(thisfn, n) (((thisfn)[n].type)->fields ())
2182 #define TYPE_FN_FIELD_CONST(thisfn, n) ((thisfn)[n].is_const)
2183 #define TYPE_FN_FIELD_VOLATILE(thisfn, n) ((thisfn)[n].is_volatile)
2184 #define TYPE_FN_FIELD_PRIVATE(thisfn, n) ((thisfn)[n].is_private)
2185 #define TYPE_FN_FIELD_PROTECTED(thisfn, n) ((thisfn)[n].is_protected)
2186 #define TYPE_FN_FIELD_ARTIFICIAL(thisfn, n) ((thisfn)[n].is_artificial)
2187 #define TYPE_FN_FIELD_STUB(thisfn, n) ((thisfn)[n].is_stub)
2188 #define TYPE_FN_FIELD_CONSTRUCTOR(thisfn, n) ((thisfn)[n].is_constructor)
2189 #define TYPE_FN_FIELD_FCONTEXT(thisfn, n) ((thisfn)[n].fcontext)
2190 #define TYPE_FN_FIELD_VOFFSET(thisfn, n) ((thisfn)[n].voffset-2)
2191 #define TYPE_FN_FIELD_VIRTUAL_P(thisfn, n) ((thisfn)[n].voffset > 1)
2192 #define TYPE_FN_FIELD_STATIC_P(thisfn, n) ((thisfn)[n].voffset == VOFFSET_STATIC)
2193 #define TYPE_FN_FIELD_DEFAULTED(thisfn, n) ((thisfn)[n].defaulted)
2194 #define TYPE_FN_FIELD_DELETED(thisfn, n) ((thisfn)[n].is_deleted)
2196 /* Accessors for typedefs defined by a class. */
2197 #define TYPE_TYPEDEF_FIELD_ARRAY(thistype) \
2198 TYPE_CPLUS_SPECIFIC (thistype)->typedef_field
2199 #define TYPE_TYPEDEF_FIELD(thistype, n) \
2200 TYPE_CPLUS_SPECIFIC (thistype)->typedef_field[n]
2201 #define TYPE_TYPEDEF_FIELD_NAME(thistype, n) \
2202 TYPE_TYPEDEF_FIELD (thistype, n).name
2203 #define TYPE_TYPEDEF_FIELD_TYPE(thistype, n) \
2204 TYPE_TYPEDEF_FIELD (thistype, n).type
2205 #define TYPE_TYPEDEF_FIELD_COUNT(thistype) \
2206 TYPE_CPLUS_SPECIFIC (thistype)->typedef_field_count
2207 #define TYPE_TYPEDEF_FIELD_PROTECTED(thistype, n) \
2208 TYPE_TYPEDEF_FIELD (thistype, n).is_protected
2209 #define TYPE_TYPEDEF_FIELD_PRIVATE(thistype, n) \
2210 TYPE_TYPEDEF_FIELD (thistype, n).is_private
2212 #define TYPE_NESTED_TYPES_ARRAY(thistype) \
2213 TYPE_CPLUS_SPECIFIC (thistype)->nested_types
2214 #define TYPE_NESTED_TYPES_FIELD(thistype, n) \
2215 TYPE_CPLUS_SPECIFIC (thistype)->nested_types[n]
2216 #define TYPE_NESTED_TYPES_FIELD_NAME(thistype, n) \
2217 TYPE_NESTED_TYPES_FIELD (thistype, n).name
2218 #define TYPE_NESTED_TYPES_FIELD_TYPE(thistype, n) \
2219 TYPE_NESTED_TYPES_FIELD (thistype, n).type
2220 #define TYPE_NESTED_TYPES_COUNT(thistype) \
2221 TYPE_CPLUS_SPECIFIC (thistype)->nested_types_count
2222 #define TYPE_NESTED_TYPES_FIELD_PROTECTED(thistype, n) \
2223 TYPE_NESTED_TYPES_FIELD (thistype, n).is_protected
2224 #define TYPE_NESTED_TYPES_FIELD_PRIVATE(thistype, n) \
2225 TYPE_NESTED_TYPES_FIELD (thistype, n).is_private
2227 #define TYPE_IS_OPAQUE(thistype) \
2228 ((((thistype)->code () == TYPE_CODE_STRUCT) \
2229 || ((thistype)->code () == TYPE_CODE_UNION)) \
2230 && ((thistype)->num_fields () == 0) \
2231 && (!HAVE_CPLUS_STRUCT (thistype) \
2232 || TYPE_NFN_FIELDS (thistype) == 0) \
2233 && ((thistype)->is_stub () || !(thistype)->stub_is_supported ()))
2235 /* * A helper macro that returns the name of a type or "unnamed type"
2236 if the type has no name. */
2238 #define TYPE_SAFE_NAME(type) \
2239 (type->name () != nullptr ? type->name () : _("<unnamed type>"))
2241 /* * A helper macro that returns the name of an error type. If the
2242 type has a name, it is used; otherwise, a default is used. */
2244 #define TYPE_ERROR_NAME(type) \
2245 (type->name () ? type->name () : _("<error type>"))
2247 /* Given TYPE, return its floatformat. */
2248 const struct floatformat
*floatformat_from_type (const struct type
*type
);
2252 /* Integral types. */
2254 /* Implicit size/sign (based on the architecture's ABI). */
2255 struct type
*builtin_void
;
2256 struct type
*builtin_char
;
2257 struct type
*builtin_short
;
2258 struct type
*builtin_int
;
2259 struct type
*builtin_long
;
2260 struct type
*builtin_signed_char
;
2261 struct type
*builtin_unsigned_char
;
2262 struct type
*builtin_unsigned_short
;
2263 struct type
*builtin_unsigned_int
;
2264 struct type
*builtin_unsigned_long
;
2265 struct type
*builtin_bfloat16
;
2266 struct type
*builtin_half
;
2267 struct type
*builtin_float
;
2268 struct type
*builtin_double
;
2269 struct type
*builtin_long_double
;
2270 struct type
*builtin_complex
;
2271 struct type
*builtin_double_complex
;
2272 struct type
*builtin_string
;
2273 struct type
*builtin_bool
;
2274 struct type
*builtin_long_long
;
2275 struct type
*builtin_unsigned_long_long
;
2276 struct type
*builtin_decfloat
;
2277 struct type
*builtin_decdouble
;
2278 struct type
*builtin_declong
;
2280 /* "True" character types.
2281 We use these for the '/c' print format, because c_char is just a
2282 one-byte integral type, which languages less laid back than C
2283 will print as ... well, a one-byte integral type. */
2284 struct type
*builtin_true_char
;
2285 struct type
*builtin_true_unsigned_char
;
2287 /* Explicit sizes - see C9X <intypes.h> for naming scheme. The "int0"
2288 is for when an architecture needs to describe a register that has
2290 struct type
*builtin_int0
;
2291 struct type
*builtin_int8
;
2292 struct type
*builtin_uint8
;
2293 struct type
*builtin_int16
;
2294 struct type
*builtin_uint16
;
2295 struct type
*builtin_int24
;
2296 struct type
*builtin_uint24
;
2297 struct type
*builtin_int32
;
2298 struct type
*builtin_uint32
;
2299 struct type
*builtin_int64
;
2300 struct type
*builtin_uint64
;
2301 struct type
*builtin_int128
;
2302 struct type
*builtin_uint128
;
2304 /* Wide character types. */
2305 struct type
*builtin_char16
;
2306 struct type
*builtin_char32
;
2307 struct type
*builtin_wchar
;
2309 /* Pointer types. */
2311 /* * `pointer to data' type. Some target platforms use an implicitly
2312 {sign,zero} -extended 32-bit ABI pointer on a 64-bit ISA. */
2313 struct type
*builtin_data_ptr
;
2315 /* * `pointer to function (returning void)' type. Harvard
2316 architectures mean that ABI function and code pointers are not
2317 interconvertible. Similarly, since ANSI, C standards have
2318 explicitly said that pointers to functions and pointers to data
2319 are not interconvertible --- that is, you can't cast a function
2320 pointer to void * and back, and expect to get the same value.
2321 However, all function pointer types are interconvertible, so void
2322 (*) () can server as a generic function pointer. */
2324 struct type
*builtin_func_ptr
;
2326 /* * `function returning pointer to function (returning void)' type.
2327 The final void return type is not significant for it. */
2329 struct type
*builtin_func_func
;
2331 /* Special-purpose types. */
2333 /* * This type is used to represent a GDB internal function. */
2335 struct type
*internal_fn
;
2337 /* * This type is used to represent an xmethod. */
2338 struct type
*xmethod
;
2341 /* * Return the type table for the specified architecture. */
2343 extern const struct builtin_type
*builtin_type (struct gdbarch
*gdbarch
);
2345 /* * Per-objfile types used by symbol readers. */
2349 /* Basic types based on the objfile architecture. */
2350 struct type
*builtin_void
;
2351 struct type
*builtin_char
;
2352 struct type
*builtin_short
;
2353 struct type
*builtin_int
;
2354 struct type
*builtin_long
;
2355 struct type
*builtin_long_long
;
2356 struct type
*builtin_signed_char
;
2357 struct type
*builtin_unsigned_char
;
2358 struct type
*builtin_unsigned_short
;
2359 struct type
*builtin_unsigned_int
;
2360 struct type
*builtin_unsigned_long
;
2361 struct type
*builtin_unsigned_long_long
;
2362 struct type
*builtin_half
;
2363 struct type
*builtin_float
;
2364 struct type
*builtin_double
;
2365 struct type
*builtin_long_double
;
2367 /* * This type is used to represent symbol addresses. */
2368 struct type
*builtin_core_addr
;
2370 /* * This type represents a type that was unrecognized in symbol
2372 struct type
*builtin_error
;
2374 /* * Types used for symbols with no debug information. */
2375 struct type
*nodebug_text_symbol
;
2376 struct type
*nodebug_text_gnu_ifunc_symbol
;
2377 struct type
*nodebug_got_plt_symbol
;
2378 struct type
*nodebug_data_symbol
;
2379 struct type
*nodebug_unknown_symbol
;
2380 struct type
*nodebug_tls_symbol
;
2383 /* * Return the type table for the specified objfile. */
2385 extern const struct objfile_type
*objfile_type (struct objfile
*objfile
);
2387 /* Explicit floating-point formats. See "floatformat.h". */
2388 extern const struct floatformat
*floatformats_ieee_half
[BFD_ENDIAN_UNKNOWN
];
2389 extern const struct floatformat
*floatformats_ieee_single
[BFD_ENDIAN_UNKNOWN
];
2390 extern const struct floatformat
*floatformats_ieee_double
[BFD_ENDIAN_UNKNOWN
];
2391 extern const struct floatformat
*floatformats_ieee_double_littlebyte_bigword
[BFD_ENDIAN_UNKNOWN
];
2392 extern const struct floatformat
*floatformats_i387_ext
[BFD_ENDIAN_UNKNOWN
];
2393 extern const struct floatformat
*floatformats_m68881_ext
[BFD_ENDIAN_UNKNOWN
];
2394 extern const struct floatformat
*floatformats_arm_ext
[BFD_ENDIAN_UNKNOWN
];
2395 extern const struct floatformat
*floatformats_ia64_spill
[BFD_ENDIAN_UNKNOWN
];
2396 extern const struct floatformat
*floatformats_ia64_quad
[BFD_ENDIAN_UNKNOWN
];
2397 extern const struct floatformat
*floatformats_vax_f
[BFD_ENDIAN_UNKNOWN
];
2398 extern const struct floatformat
*floatformats_vax_d
[BFD_ENDIAN_UNKNOWN
];
2399 extern const struct floatformat
*floatformats_ibm_long_double
[BFD_ENDIAN_UNKNOWN
];
2400 extern const struct floatformat
*floatformats_bfloat16
[BFD_ENDIAN_UNKNOWN
];
2402 /* Allocate space for storing data associated with a particular
2403 type. We ensure that the space is allocated using the same
2404 mechanism that was used to allocate the space for the type
2405 structure itself. I.e. if the type is on an objfile's
2406 objfile_obstack, then the space for data associated with that type
2407 will also be allocated on the objfile_obstack. If the type is
2408 associated with a gdbarch, then the space for data associated with that
2409 type will also be allocated on the gdbarch_obstack.
2411 If a type is not associated with neither an objfile or a gdbarch then
2412 you should not use this macro to allocate space for data, instead you
2413 should call xmalloc directly, and ensure the memory is correctly freed
2414 when it is no longer needed. */
2416 #define TYPE_ALLOC(t,size) \
2417 (obstack_alloc (((t)->is_objfile_owned () \
2418 ? &((t)->objfile_owner ()->objfile_obstack) \
2419 : gdbarch_obstack ((t)->arch_owner ())), \
2423 /* See comment on TYPE_ALLOC. */
2425 #define TYPE_ZALLOC(t,size) (memset (TYPE_ALLOC (t, size), 0, size))
2427 /* Use alloc_type to allocate a type owned by an objfile. Use
2428 alloc_type_arch to allocate a type owned by an architecture. Use
2429 alloc_type_copy to allocate a type with the same owner as a
2430 pre-existing template type, no matter whether objfile or
2432 extern struct type
*alloc_type (struct objfile
*);
2433 extern struct type
*alloc_type_arch (struct gdbarch
*);
2434 extern struct type
*alloc_type_copy (const struct type
*);
2436 /* * This returns the target type (or NULL) of TYPE, also skipping
2439 extern struct type
*get_target_type (struct type
*type
);
2441 /* Return the equivalent of TYPE_LENGTH, but in number of target
2442 addressable memory units of the associated gdbarch instead of bytes. */
2444 extern unsigned int type_length_units (struct type
*type
);
2446 /* * Helper function to construct objfile-owned types. */
2448 extern struct type
*init_type (struct objfile
*, enum type_code
, int,
2450 extern struct type
*init_integer_type (struct objfile
*, int, int,
2452 extern struct type
*init_character_type (struct objfile
*, int, int,
2454 extern struct type
*init_boolean_type (struct objfile
*, int, int,
2456 extern struct type
*init_float_type (struct objfile
*, int, const char *,
2457 const struct floatformat
**,
2458 enum bfd_endian
= BFD_ENDIAN_UNKNOWN
);
2459 extern struct type
*init_decfloat_type (struct objfile
*, int, const char *);
2460 extern bool can_create_complex_type (struct type
*);
2461 extern struct type
*init_complex_type (const char *, struct type
*);
2462 extern struct type
*init_pointer_type (struct objfile
*, int, const char *,
2464 extern struct type
*init_fixed_point_type (struct objfile
*, int, int,
2467 /* Helper functions to construct architecture-owned types. */
2468 extern struct type
*arch_type (struct gdbarch
*, enum type_code
, int,
2470 extern struct type
*arch_integer_type (struct gdbarch
*, int, int,
2472 extern struct type
*arch_character_type (struct gdbarch
*, int, int,
2474 extern struct type
*arch_boolean_type (struct gdbarch
*, int, int,
2476 extern struct type
*arch_float_type (struct gdbarch
*, int, const char *,
2477 const struct floatformat
**);
2478 extern struct type
*arch_decfloat_type (struct gdbarch
*, int, const char *);
2479 extern struct type
*arch_pointer_type (struct gdbarch
*, int, const char *,
2482 /* Helper functions to construct a struct or record type. An
2483 initially empty type is created using arch_composite_type().
2484 Fields are then added using append_composite_type_field*(). A union
2485 type has its size set to the largest field. A struct type has each
2486 field packed against the previous. */
2488 extern struct type
*arch_composite_type (struct gdbarch
*gdbarch
,
2489 const char *name
, enum type_code code
);
2490 extern void append_composite_type_field (struct type
*t
, const char *name
,
2491 struct type
*field
);
2492 extern void append_composite_type_field_aligned (struct type
*t
,
2496 struct field
*append_composite_type_field_raw (struct type
*t
, const char *name
,
2497 struct type
*field
);
2499 /* Helper functions to construct a bit flags type. An initially empty
2500 type is created using arch_flag_type(). Flags are then added using
2501 append_flag_type_field() and append_flag_type_flag(). */
2502 extern struct type
*arch_flags_type (struct gdbarch
*gdbarch
,
2503 const char *name
, int bit
);
2504 extern void append_flags_type_field (struct type
*type
,
2505 int start_bitpos
, int nr_bits
,
2506 struct type
*field_type
, const char *name
);
2507 extern void append_flags_type_flag (struct type
*type
, int bitpos
,
2510 extern void make_vector_type (struct type
*array_type
);
2511 extern struct type
*init_vector_type (struct type
*elt_type
, int n
);
2513 extern struct type
*lookup_reference_type (struct type
*, enum type_code
);
2514 extern struct type
*lookup_lvalue_reference_type (struct type
*);
2515 extern struct type
*lookup_rvalue_reference_type (struct type
*);
2518 extern struct type
*make_reference_type (struct type
*, struct type
**,
2521 extern struct type
*make_cv_type (int, int, struct type
*, struct type
**);
2523 extern struct type
*make_restrict_type (struct type
*);
2525 extern struct type
*make_unqualified_type (struct type
*);
2527 extern struct type
*make_atomic_type (struct type
*);
2529 extern void replace_type (struct type
*, struct type
*);
2531 extern type_instance_flags address_space_name_to_type_instance_flags
2532 (struct gdbarch
*, const char *);
2534 extern const char *address_space_type_instance_flags_to_name
2535 (struct gdbarch
*, type_instance_flags
);
2537 extern struct type
*make_type_with_address_space
2538 (struct type
*type
, type_instance_flags space_identifier
);
2540 extern struct type
*lookup_memberptr_type (struct type
*, struct type
*);
2542 extern struct type
*lookup_methodptr_type (struct type
*);
2544 extern void smash_to_method_type (struct type
*type
, struct type
*self_type
,
2545 struct type
*to_type
, struct field
*args
,
2546 int nargs
, int varargs
);
2548 extern void smash_to_memberptr_type (struct type
*, struct type
*,
2551 extern void smash_to_methodptr_type (struct type
*, struct type
*);
2553 extern struct type
*allocate_stub_method (struct type
*);
2555 extern const char *type_name_or_error (struct type
*type
);
2559 /* The field of the element, or NULL if no element was found. */
2560 struct field
*field
;
2562 /* The bit offset of the element in the parent structure. */
2566 /* Given a type TYPE, lookup the field and offset of the component named
2569 TYPE can be either a struct or union, or a pointer or reference to
2570 a struct or union. If it is a pointer or reference, its target
2571 type is automatically used. Thus '.' and '->' are interchangable,
2572 as specified for the definitions of the expression element types
2573 STRUCTOP_STRUCT and STRUCTOP_PTR.
2575 If NOERR is nonzero, the returned structure will have field set to
2576 NULL if there is no component named NAME.
2578 If the component NAME is a field in an anonymous substructure of
2579 TYPE, the returned offset is a "global" offset relative to TYPE
2580 rather than an offset within the substructure. */
2582 extern struct_elt
lookup_struct_elt (struct type
*, const char *, int);
2584 /* Given a type TYPE, lookup the type of the component named NAME.
2586 TYPE can be either a struct or union, or a pointer or reference to
2587 a struct or union. If it is a pointer or reference, its target
2588 type is automatically used. Thus '.' and '->' are interchangable,
2589 as specified for the definitions of the expression element types
2590 STRUCTOP_STRUCT and STRUCTOP_PTR.
2592 If NOERR is nonzero, return NULL if there is no component named
2595 extern struct type
*lookup_struct_elt_type (struct type
*, const char *, int);
2597 extern struct type
*make_pointer_type (struct type
*, struct type
**);
2599 extern struct type
*lookup_pointer_type (struct type
*);
2601 extern struct type
*make_function_type (struct type
*, struct type
**);
2603 extern struct type
*lookup_function_type (struct type
*);
2605 extern struct type
*lookup_function_type_with_arguments (struct type
*,
2609 extern struct type
*create_static_range_type (struct type
*, struct type
*,
2613 extern struct type
*create_array_type_with_stride
2614 (struct type
*, struct type
*, struct type
*,
2615 struct dynamic_prop
*, unsigned int);
2617 extern struct type
*create_range_type (struct type
*, struct type
*,
2618 const struct dynamic_prop
*,
2619 const struct dynamic_prop
*,
2622 /* Like CREATE_RANGE_TYPE but also sets up a stride. When BYTE_STRIDE_P
2623 is true the value in STRIDE is a byte stride, otherwise STRIDE is a bit
2626 extern struct type
* create_range_type_with_stride
2627 (struct type
*result_type
, struct type
*index_type
,
2628 const struct dynamic_prop
*low_bound
,
2629 const struct dynamic_prop
*high_bound
, LONGEST bias
,
2630 const struct dynamic_prop
*stride
, bool byte_stride_p
);
2632 extern struct type
*create_array_type (struct type
*, struct type
*,
2635 extern struct type
*lookup_array_range_type (struct type
*, LONGEST
, LONGEST
);
2637 extern struct type
*create_string_type (struct type
*, struct type
*,
2639 extern struct type
*lookup_string_range_type (struct type
*, LONGEST
, LONGEST
);
2641 extern struct type
*create_set_type (struct type
*, struct type
*);
2643 extern struct type
*lookup_unsigned_typename (const struct language_defn
*,
2646 extern struct type
*lookup_signed_typename (const struct language_defn
*,
2649 extern ULONGEST
get_unsigned_type_max (struct type
*);
2651 extern void get_signed_type_minmax (struct type
*, LONGEST
*, LONGEST
*);
2653 extern CORE_ADDR
get_pointer_type_max (struct type
*);
2655 /* * Resolve all dynamic values of a type e.g. array bounds to static values.
2656 ADDR specifies the location of the variable the type is bound to.
2657 If TYPE has no dynamic properties return TYPE; otherwise a new type with
2658 static properties is returned.
2660 For an array type, if the element type is dynamic, then that will
2661 not be resolved. This is done because each individual element may
2662 have a different type when resolved (depending on the contents of
2663 memory). In this situation, 'is_dynamic_type' will still return
2664 true for the return value of this function. */
2665 extern struct type
*resolve_dynamic_type
2666 (struct type
*type
, gdb::array_view
<const gdb_byte
> valaddr
,
2669 /* * Predicate if the type has dynamic values, which are not resolved yet.
2670 See the caveat in 'resolve_dynamic_type' to understand a scenario
2671 where an apparently-resolved type may still be considered
2673 extern int is_dynamic_type (struct type
*type
);
2675 extern struct type
*check_typedef (struct type
*);
2677 extern void check_stub_method_group (struct type
*, int);
2679 extern char *gdb_mangle_name (struct type
*, int, int);
2681 extern struct type
*lookup_typename (const struct language_defn
*,
2682 const char *, const struct block
*, int);
2684 extern struct type
*lookup_template_type (const char *, struct type
*,
2685 const struct block
*);
2687 extern int get_vptr_fieldno (struct type
*, struct type
**);
2689 /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type
2692 Return true if the two bounds are available, false otherwise. */
2694 extern bool get_discrete_bounds (struct type
*type
, LONGEST
*lowp
,
2697 /* If TYPE's low bound is a known constant, return it, else return nullopt. */
2699 extern gdb::optional
<LONGEST
> get_discrete_low_bound (struct type
*type
);
2701 /* If TYPE's high bound is a known constant, return it, else return nullopt. */
2703 extern gdb::optional
<LONGEST
> get_discrete_high_bound (struct type
*type
);
2705 /* Assuming TYPE is a simple, non-empty array type, compute its upper
2706 and lower bound. Save the low bound into LOW_BOUND if not NULL.
2707 Save the high bound into HIGH_BOUND if not NULL.
2709 Return true if the operation was successful. Return false otherwise,
2710 in which case the values of LOW_BOUND and HIGH_BOUNDS are unmodified. */
2712 extern bool get_array_bounds (struct type
*type
, LONGEST
*low_bound
,
2713 LONGEST
*high_bound
);
2715 extern gdb::optional
<LONGEST
> discrete_position (struct type
*type
,
2718 extern int class_types_same_p (const struct type
*, const struct type
*);
2720 extern int is_ancestor (struct type
*, struct type
*);
2722 extern int is_public_ancestor (struct type
*, struct type
*);
2724 extern int is_unique_ancestor (struct type
*, struct value
*);
2726 /* Overload resolution */
2728 /* * Badness if parameter list length doesn't match arg list length. */
2729 extern const struct rank LENGTH_MISMATCH_BADNESS
;
2731 /* * Dummy badness value for nonexistent parameter positions. */
2732 extern const struct rank TOO_FEW_PARAMS_BADNESS
;
2733 /* * Badness if no conversion among types. */
2734 extern const struct rank INCOMPATIBLE_TYPE_BADNESS
;
2736 /* * Badness of an exact match. */
2737 extern const struct rank EXACT_MATCH_BADNESS
;
2739 /* * Badness of integral promotion. */
2740 extern const struct rank INTEGER_PROMOTION_BADNESS
;
2741 /* * Badness of floating promotion. */
2742 extern const struct rank FLOAT_PROMOTION_BADNESS
;
2743 /* * Badness of converting a derived class pointer
2744 to a base class pointer. */
2745 extern const struct rank BASE_PTR_CONVERSION_BADNESS
;
2746 /* * Badness of integral conversion. */
2747 extern const struct rank INTEGER_CONVERSION_BADNESS
;
2748 /* * Badness of floating conversion. */
2749 extern const struct rank FLOAT_CONVERSION_BADNESS
;
2750 /* * Badness of integer<->floating conversions. */
2751 extern const struct rank INT_FLOAT_CONVERSION_BADNESS
;
2752 /* * Badness of conversion of pointer to void pointer. */
2753 extern const struct rank VOID_PTR_CONVERSION_BADNESS
;
2754 /* * Badness of conversion to boolean. */
2755 extern const struct rank BOOL_CONVERSION_BADNESS
;
2756 /* * Badness of converting derived to base class. */
2757 extern const struct rank BASE_CONVERSION_BADNESS
;
2758 /* * Badness of converting from non-reference to reference. Subrank
2759 is the type of reference conversion being done. */
2760 extern const struct rank REFERENCE_CONVERSION_BADNESS
;
2761 extern const struct rank REFERENCE_SEE_THROUGH_BADNESS
;
2762 /* * Conversion to rvalue reference. */
2763 #define REFERENCE_CONVERSION_RVALUE 1
2764 /* * Conversion to const lvalue reference. */
2765 #define REFERENCE_CONVERSION_CONST_LVALUE 2
2767 /* * Badness of converting integer 0 to NULL pointer. */
2768 extern const struct rank NULL_POINTER_CONVERSION
;
2769 /* * Badness of cv-conversion. Subrank is a flag describing the conversions
2771 extern const struct rank CV_CONVERSION_BADNESS
;
2772 #define CV_CONVERSION_CONST 1
2773 #define CV_CONVERSION_VOLATILE 2
2775 /* Non-standard conversions allowed by the debugger */
2777 /* * Converting a pointer to an int is usually OK. */
2778 extern const struct rank NS_POINTER_CONVERSION_BADNESS
;
2780 /* * Badness of converting a (non-zero) integer constant
2782 extern const struct rank NS_INTEGER_POINTER_CONVERSION_BADNESS
;
2784 extern struct rank
sum_ranks (struct rank a
, struct rank b
);
2785 extern int compare_ranks (struct rank a
, struct rank b
);
2787 extern int compare_badness (const badness_vector
&,
2788 const badness_vector
&);
2790 extern badness_vector
rank_function (gdb::array_view
<type
*> parms
,
2791 gdb::array_view
<value
*> args
);
2793 extern struct rank
rank_one_type (struct type
*, struct type
*,
2796 extern void recursive_dump_type (struct type
*, int);
2798 extern int field_is_static (struct field
*);
2802 extern void print_scalar_formatted (const gdb_byte
*, struct type
*,
2803 const struct value_print_options
*,
2804 int, struct ui_file
*);
2806 extern int can_dereference (struct type
*);
2808 extern int is_integral_type (struct type
*);
2810 extern int is_floating_type (struct type
*);
2812 extern int is_scalar_type (struct type
*type
);
2814 extern int is_scalar_type_recursive (struct type
*);
2816 extern int class_or_union_p (const struct type
*);
2818 extern void maintenance_print_type (const char *, int);
2820 extern htab_up
create_copied_types_hash (struct objfile
*objfile
);
2822 extern struct type
*copy_type_recursive (struct objfile
*objfile
,
2824 htab_t copied_types
);
2826 extern struct type
*copy_type (const struct type
*type
);
2828 extern bool types_equal (struct type
*, struct type
*);
2830 extern bool types_deeply_equal (struct type
*, struct type
*);
2832 extern int type_not_allocated (const struct type
*type
);
2834 extern int type_not_associated (const struct type
*type
);
2836 /* Return True if TYPE is a TYPE_CODE_FIXED_POINT or if TYPE is
2837 a range type whose base type is a TYPE_CODE_FIXED_POINT. */
2838 extern bool is_fixed_point_type (struct type
*type
);
2840 /* Allocate a fixed-point type info for TYPE. This should only be
2841 called by INIT_FIXED_POINT_SPECIFIC. */
2842 extern void allocate_fixed_point_type_info (struct type
*type
);
2844 /* * When the type includes explicit byte ordering, return that.
2845 Otherwise, the byte ordering from gdbarch_byte_order for
2846 the type's arch is returned. */
2848 extern enum bfd_endian
type_byte_order (const struct type
*type
);
2850 /* A flag to enable printing of debugging information of C++
2853 extern unsigned int overload_debug
;
2855 #endif /* GDBTYPES_H */