MIPS: Use 64-bit a ABI by default for `mipsisa64*-*-linux*' targets
[binutils-gdb.git] / gdb / gdbtypes.h
blobaedaf53cd5d58a11ca3090fdde387a7657e8ae74
2 /* Internal type definitions for GDB.
4 Copyright (C) 1992-2023 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)
24 #define GDBTYPES_H 1
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
36 convention).
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.
47 #include "hashtab.h"
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"
55 #include "gdbsupport/function-view.h"
56 #include "dwarf2.h"
57 #include "gdbsupport/gdb_obstack.h"
58 #include "gmp-utils.h"
60 /* Forward declarations for prototypes. */
61 struct field;
62 struct block;
63 struct value_print_options;
64 struct language_defn;
65 struct dwarf2_per_cu_data;
66 struct dwarf2_per_objfile;
67 struct dwarf2_property_baton;
69 /* Some macros for char-based bitfields. */
71 #define B_SET(a,x) ((a)[(x)>>3] |= (1 << ((x)&7)))
72 #define B_CLR(a,x) ((a)[(x)>>3] &= ~(1 << ((x)&7)))
73 #define B_TST(a,x) ((a)[(x)>>3] & (1 << ((x)&7)))
74 #define B_TYPE unsigned char
75 #define B_BYTES(x) ( 1 + ((x)>>3) )
76 #define B_CLRALL(a,x) memset ((a), 0, B_BYTES(x))
78 /* * Different kinds of data types are distinguished by the `code'
79 field. */
81 enum type_code
83 TYPE_CODE_UNDEF = 0, /**< Not used; catches errors */
85 #define OP(X) X,
86 #include "type-codes.def"
87 #undef OP
91 /* * Some bits for the type's instance_flags word. See the macros
92 below for documentation on each bit. */
94 enum type_instance_flag_value : unsigned
96 TYPE_INSTANCE_FLAG_CONST = (1 << 0),
97 TYPE_INSTANCE_FLAG_VOLATILE = (1 << 1),
98 TYPE_INSTANCE_FLAG_CODE_SPACE = (1 << 2),
99 TYPE_INSTANCE_FLAG_DATA_SPACE = (1 << 3),
100 TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 = (1 << 4),
101 TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2 = (1 << 5),
102 TYPE_INSTANCE_FLAG_NOTTEXT = (1 << 6),
103 TYPE_INSTANCE_FLAG_RESTRICT = (1 << 7),
104 TYPE_INSTANCE_FLAG_ATOMIC = (1 << 8)
107 DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags);
109 /* * Not textual. By default, GDB treats all single byte integers as
110 characters (or elements of strings) unless this flag is set. */
112 #define TYPE_NOTTEXT(t) (((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_NOTTEXT)
114 /* * Constant type. If this is set, the corresponding type has a
115 const modifier. */
117 #define TYPE_CONST(t) ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_CONST) != 0)
119 /* * Volatile type. If this is set, the corresponding type has a
120 volatile modifier. */
122 #define TYPE_VOLATILE(t) \
123 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_VOLATILE) != 0)
125 /* * Restrict type. If this is set, the corresponding type has a
126 restrict modifier. */
128 #define TYPE_RESTRICT(t) \
129 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_RESTRICT) != 0)
131 /* * Atomic type. If this is set, the corresponding type has an
132 _Atomic modifier. */
134 #define TYPE_ATOMIC(t) \
135 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_ATOMIC) != 0)
137 /* * True if this type represents either an lvalue or lvalue reference type. */
139 #define TYPE_IS_REFERENCE(t) \
140 ((t)->code () == TYPE_CODE_REF || (t)->code () == TYPE_CODE_RVALUE_REF)
142 /* * True if this type is allocatable. */
143 #define TYPE_IS_ALLOCATABLE(t) \
144 ((t)->dyn_prop (DYN_PROP_ALLOCATED) != NULL)
146 /* * True if this type has variant parts. */
147 #define TYPE_HAS_VARIANT_PARTS(t) \
148 ((t)->dyn_prop (DYN_PROP_VARIANT_PARTS) != nullptr)
150 /* * True if this type has a dynamic length. */
151 #define TYPE_HAS_DYNAMIC_LENGTH(t) \
152 ((t)->dyn_prop (DYN_PROP_BYTE_SIZE) != nullptr)
154 /* * Instruction-space delimited type. This is for Harvard architectures
155 which have separate instruction and data address spaces (and perhaps
156 others).
158 GDB usually defines a flat address space that is a superset of the
159 architecture's two (or more) address spaces, but this is an extension
160 of the architecture's model.
162 If TYPE_INSTANCE_FLAG_CODE_SPACE is set, an object of the corresponding type
163 resides in instruction memory, even if its address (in the extended
164 flat address space) does not reflect this.
166 Similarly, if TYPE_INSTANCE_FLAG_DATA_SPACE is set, then an object of the
167 corresponding type resides in the data memory space, even if
168 this is not indicated by its (flat address space) address.
170 If neither flag is set, the default space for functions / methods
171 is instruction space, and for data objects is data memory. */
173 #define TYPE_CODE_SPACE(t) \
174 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_CODE_SPACE) != 0)
176 #define TYPE_DATA_SPACE(t) \
177 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_DATA_SPACE) != 0)
179 /* * Address class flags. Some environments provide for pointers
180 whose size is different from that of a normal pointer or address
181 types where the bits are interpreted differently than normal
182 addresses. The TYPE_INSTANCE_FLAG_ADDRESS_CLASS_n flags may be used in
183 target specific ways to represent these different types of address
184 classes. */
186 #define TYPE_ADDRESS_CLASS_1(t) (((t)->instance_flags ()) \
187 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
188 #define TYPE_ADDRESS_CLASS_2(t) (((t)->instance_flags ()) \
189 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2)
190 #define TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL \
191 (TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 | TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2)
192 #define TYPE_ADDRESS_CLASS_ALL(t) (((t)->instance_flags ()) \
193 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL)
195 /* * Information about a single discriminant. */
197 struct discriminant_range
199 /* * The range of values for the variant. This is an inclusive
200 range. */
201 ULONGEST low, high;
203 /* * Return true if VALUE is contained in this range. IS_UNSIGNED
204 is true if this should be an unsigned comparison; false for
205 signed. */
206 bool contains (ULONGEST value, bool is_unsigned) const
208 if (is_unsigned)
209 return value >= low && value <= high;
210 LONGEST valuel = (LONGEST) value;
211 return valuel >= (LONGEST) low && valuel <= (LONGEST) high;
215 struct variant_part;
217 /* * A single variant. A variant has a list of discriminant values.
218 When the discriminator matches one of these, the variant is
219 enabled. Each variant controls zero or more fields; and may also
220 control other variant parts as well. This struct corresponds to
221 DW_TAG_variant in DWARF. */
223 struct variant : allocate_on_obstack
225 /* * The discriminant ranges for this variant. */
226 gdb::array_view<discriminant_range> discriminants;
228 /* * The fields controlled by this variant. This is inclusive on
229 the low end and exclusive on the high end. A variant may not
230 control any fields, in which case the two values will be equal.
231 These are indexes into the type's array of fields. */
232 int first_field;
233 int last_field;
235 /* * Variant parts controlled by this variant. */
236 gdb::array_view<variant_part> parts;
238 /* * Return true if this is the default variant. The default
239 variant can be recognized because it has no associated
240 discriminants. */
241 bool is_default () const
243 return discriminants.empty ();
246 /* * Return true if this variant matches VALUE. IS_UNSIGNED is true
247 if this should be an unsigned comparison; false for signed. */
248 bool matches (ULONGEST value, bool is_unsigned) const;
251 /* * A variant part. Each variant part has an optional discriminant
252 and holds an array of variants. This struct corresponds to
253 DW_TAG_variant_part in DWARF. */
255 struct variant_part : allocate_on_obstack
257 /* * The index of the discriminant field in the outer type. This is
258 an index into the type's array of fields. If this is -1, there
259 is no discriminant, and only the default variant can be
260 considered to be selected. */
261 int discriminant_index;
263 /* * True if this discriminant is unsigned; false if signed. This
264 comes from the type of the discriminant. */
265 bool is_unsigned;
267 /* * The variants that are controlled by this variant part. Note
268 that these will always be sorted by field number. */
269 gdb::array_view<variant> variants;
273 enum dynamic_prop_kind
275 PROP_UNDEFINED, /* Not defined. */
276 PROP_CONST, /* Constant. */
277 PROP_ADDR_OFFSET, /* Address offset. */
278 PROP_LOCEXPR, /* Location expression. */
279 PROP_LOCLIST, /* Location list. */
280 PROP_VARIANT_PARTS, /* Variant parts. */
281 PROP_TYPE, /* Type. */
282 PROP_VARIABLE_NAME, /* Variable name. */
285 union dynamic_prop_data
287 /* Storage for constant property. */
289 LONGEST const_val;
291 /* Storage for dynamic property. */
293 const dwarf2_property_baton *baton;
295 /* Storage of variant parts for a type. A type with variant parts
296 has all its fields "linearized" -- stored in a single field
297 array, just as if they had all been declared that way. The
298 variant parts are attached via a dynamic property, and then are
299 used to control which fields end up in the final type during
300 dynamic type resolution. */
302 const gdb::array_view<variant_part> *variant_parts;
304 /* Once a variant type is resolved, we may want to be able to go
305 from the resolved type to the original type. In this case we
306 rewrite the property's kind and set this field. */
308 struct type *original_type;
310 /* Name of a variable to look up; the variable holds the value of
311 this property. */
313 const char *variable_name;
316 /* * Used to store a dynamic property. */
318 struct dynamic_prop
320 dynamic_prop_kind kind () const
322 return m_kind;
325 void set_undefined ()
327 m_kind = PROP_UNDEFINED;
330 LONGEST const_val () const
332 gdb_assert (m_kind == PROP_CONST);
334 return m_data.const_val;
337 void set_const_val (LONGEST const_val)
339 m_kind = PROP_CONST;
340 m_data.const_val = const_val;
343 /* Return true if this property has a constant value, false
344 otherwise. */
345 bool is_constant () const
346 { return m_kind == PROP_CONST; }
348 const dwarf2_property_baton *baton () const
350 gdb_assert (m_kind == PROP_LOCEXPR
351 || m_kind == PROP_LOCLIST
352 || m_kind == PROP_ADDR_OFFSET);
354 return m_data.baton;
357 void set_locexpr (const dwarf2_property_baton *baton)
359 m_kind = PROP_LOCEXPR;
360 m_data.baton = baton;
363 void set_loclist (const dwarf2_property_baton *baton)
365 m_kind = PROP_LOCLIST;
366 m_data.baton = baton;
369 void set_addr_offset (const dwarf2_property_baton *baton)
371 m_kind = PROP_ADDR_OFFSET;
372 m_data.baton = baton;
375 const gdb::array_view<variant_part> *variant_parts () const
377 gdb_assert (m_kind == PROP_VARIANT_PARTS);
379 return m_data.variant_parts;
382 void set_variant_parts (gdb::array_view<variant_part> *variant_parts)
384 m_kind = PROP_VARIANT_PARTS;
385 m_data.variant_parts = variant_parts;
388 struct type *original_type () const
390 gdb_assert (m_kind == PROP_TYPE);
392 return m_data.original_type;
395 void set_original_type (struct type *original_type)
397 m_kind = PROP_TYPE;
398 m_data.original_type = original_type;
401 /* Return the name of the variable that holds this property's value.
402 Only valid for PROP_VARIABLE_NAME. */
403 const char *variable_name () const
405 gdb_assert (m_kind == PROP_VARIABLE_NAME);
406 return m_data.variable_name;
409 /* Set the name of the variable that holds this property's value,
410 and set this property to be of kind PROP_VARIABLE_NAME. */
411 void set_variable_name (const char *name)
413 m_kind = PROP_VARIABLE_NAME;
414 m_data.variable_name = name;
417 /* Determine which field of the union dynamic_prop.data is used. */
418 enum dynamic_prop_kind m_kind;
420 /* Storage for dynamic or static value. */
421 union dynamic_prop_data m_data;
424 /* Compare two dynamic_prop objects for equality. dynamic_prop
425 instances are equal iff they have the same type and storage. */
426 extern bool operator== (const dynamic_prop &l, const dynamic_prop &r);
428 /* Compare two dynamic_prop objects for inequality. */
429 static inline bool operator!= (const dynamic_prop &l, const dynamic_prop &r)
431 return !(l == r);
434 /* * Define a type's dynamic property node kind. */
435 enum dynamic_prop_node_kind
437 /* A property providing a type's data location.
438 Evaluating this field yields to the location of an object's data. */
439 DYN_PROP_DATA_LOCATION,
441 /* A property representing DW_AT_allocated. The presence of this attribute
442 indicates that the object of the type can be allocated/deallocated. */
443 DYN_PROP_ALLOCATED,
445 /* A property representing DW_AT_associated. The presence of this attribute
446 indicated that the object of the type can be associated. */
447 DYN_PROP_ASSOCIATED,
449 /* A property providing an array's byte stride. */
450 DYN_PROP_BYTE_STRIDE,
452 /* A property holding variant parts. */
453 DYN_PROP_VARIANT_PARTS,
455 /* A property representing DW_AT_rank. The presence of this attribute
456 indicates that the object is of assumed rank array type. */
457 DYN_PROP_RANK,
459 /* A property holding the size of the type. */
460 DYN_PROP_BYTE_SIZE,
463 /* * List for dynamic type attributes. */
464 struct dynamic_prop_list
466 /* The kind of dynamic prop in this node. */
467 enum dynamic_prop_node_kind prop_kind;
469 /* The dynamic property itself. */
470 struct dynamic_prop prop;
472 /* A pointer to the next dynamic property. */
473 struct dynamic_prop_list *next;
476 /* * Determine which field of the union main_type.fields[x].loc is
477 used. */
479 enum field_loc_kind
481 FIELD_LOC_KIND_BITPOS, /**< bitpos */
482 FIELD_LOC_KIND_ENUMVAL, /**< enumval */
483 FIELD_LOC_KIND_PHYSADDR, /**< physaddr */
484 FIELD_LOC_KIND_PHYSNAME, /**< physname */
485 FIELD_LOC_KIND_DWARF_BLOCK /**< dwarf_block */
488 /* * A discriminant to determine which field in the
489 main_type.type_specific union is being used, if any.
491 For types such as TYPE_CODE_FLT, the use of this
492 discriminant is really redundant, as we know from the type code
493 which field is going to be used. As such, it would be possible to
494 reduce the size of this enum in order to save a bit or two for
495 other fields of struct main_type. But, since we still have extra
496 room , and for the sake of clarity and consistency, we treat all fields
497 of the union the same way. */
499 enum type_specific_kind
501 TYPE_SPECIFIC_NONE,
502 TYPE_SPECIFIC_CPLUS_STUFF,
503 TYPE_SPECIFIC_GNAT_STUFF,
504 TYPE_SPECIFIC_FLOATFORMAT,
505 /* Note: This is used by TYPE_CODE_FUNC and TYPE_CODE_METHOD. */
506 TYPE_SPECIFIC_FUNC,
507 TYPE_SPECIFIC_SELF_TYPE,
508 TYPE_SPECIFIC_INT,
509 TYPE_SPECIFIC_FIXED_POINT,
512 union type_owner
514 struct objfile *objfile;
515 struct gdbarch *gdbarch;
518 union field_location
520 /* * Position of this field, counting in bits from start of
521 containing structure. For big-endian targets, it is the bit
522 offset to the MSB. For little-endian targets, it is the bit
523 offset to the LSB. */
525 LONGEST bitpos;
527 /* * Enum value. */
528 LONGEST enumval;
530 /* * For a static field, if TYPE_FIELD_STATIC_HAS_ADDR then
531 physaddr is the location (in the target) of the static
532 field. Otherwise, physname is the mangled label of the
533 static field. */
535 CORE_ADDR physaddr;
536 const char *physname;
538 /* * The field location can be computed by evaluating the
539 following DWARF block. Its DATA is allocated on
540 objfile_obstack - no CU load is needed to access it. */
542 struct dwarf2_locexpr_baton *dwarf_block;
545 struct field
547 struct type *type () const
549 return this->m_type;
552 void set_type (struct type *type)
554 this->m_type = type;
557 const char *name () const
559 return m_name;
562 void set_name (const char *name)
564 m_name = name;
567 /* Return true if this field is static; false if not. */
568 bool is_static () const
570 /* "static" fields are the fields whose location is not relative
571 to the address of the enclosing struct. It would be nice to
572 have a dedicated flag that would be set for static fields when
573 the type is being created. But in practice, checking the field
574 loc_kind should give us an accurate answer. */
575 return (m_loc_kind == FIELD_LOC_KIND_PHYSNAME
576 || m_loc_kind == FIELD_LOC_KIND_PHYSADDR);
579 /* Location getters / setters. */
581 field_loc_kind loc_kind () const
583 return m_loc_kind;
586 LONGEST loc_bitpos () const
588 gdb_assert (m_loc_kind == FIELD_LOC_KIND_BITPOS);
589 return m_loc.bitpos;
592 void set_loc_bitpos (LONGEST bitpos)
594 m_loc_kind = FIELD_LOC_KIND_BITPOS;
595 m_loc.bitpos = bitpos;
598 LONGEST loc_enumval () const
600 gdb_assert (m_loc_kind == FIELD_LOC_KIND_ENUMVAL);
601 return m_loc.enumval;
604 void set_loc_enumval (LONGEST enumval)
606 m_loc_kind = FIELD_LOC_KIND_ENUMVAL;
607 m_loc.enumval = enumval;
610 CORE_ADDR loc_physaddr () const
612 gdb_assert (m_loc_kind == FIELD_LOC_KIND_PHYSADDR);
613 return m_loc.physaddr;
616 void set_loc_physaddr (CORE_ADDR physaddr)
618 m_loc_kind = FIELD_LOC_KIND_PHYSADDR;
619 m_loc.physaddr = physaddr;
622 const char *loc_physname () const
624 gdb_assert (m_loc_kind == FIELD_LOC_KIND_PHYSNAME);
625 return m_loc.physname;
628 void set_loc_physname (const char *physname)
630 m_loc_kind = FIELD_LOC_KIND_PHYSNAME;
631 m_loc.physname = physname;
634 dwarf2_locexpr_baton *loc_dwarf_block () const
636 gdb_assert (m_loc_kind == FIELD_LOC_KIND_DWARF_BLOCK);
637 return m_loc.dwarf_block;
640 void set_loc_dwarf_block (dwarf2_locexpr_baton *dwarf_block)
642 m_loc_kind = FIELD_LOC_KIND_DWARF_BLOCK;
643 m_loc.dwarf_block = dwarf_block;
646 union field_location m_loc;
648 /* * For a function or member type, this is 1 if the argument is
649 marked artificial. Artificial arguments should not be shown
650 to the user. For TYPE_CODE_RANGE it is set if the specific
651 bound is not defined. */
653 unsigned int artificial : 1;
655 /* * Discriminant for union field_location. */
657 ENUM_BITFIELD(field_loc_kind) m_loc_kind : 3;
659 /* * Size of this field, in bits, or zero if not packed.
660 If non-zero in an array type, indicates the element size in
661 bits (used only in Ada at the moment).
662 For an unpacked field, the field's type's length
663 says how many bytes the field occupies. */
665 unsigned int bitsize : 28;
667 /* * In a struct or union type, type of this field.
668 - In a function or member type, type of this argument.
669 - In an array type, the domain-type of the array. */
671 struct type *m_type;
673 /* * Name of field, value or argument.
674 NULL for range bounds, array domains, and member function
675 arguments. */
677 const char *m_name;
680 struct range_bounds
682 ULONGEST bit_stride () const
684 if (this->flag_is_byte_stride)
685 return this->stride.const_val () * 8;
686 else
687 return this->stride.const_val ();
690 /* * Low bound of range. */
692 struct dynamic_prop low;
694 /* * High bound of range. */
696 struct dynamic_prop high;
698 /* The stride value for this range. This can be stored in bits or bytes
699 based on the value of BYTE_STRIDE_P. It is optional to have a stride
700 value, if this range has no stride value defined then this will be set
701 to the constant zero. */
703 struct dynamic_prop stride;
705 /* * The bias. Sometimes a range value is biased before storage.
706 The bias is added to the stored bits to form the true value. */
708 LONGEST bias;
710 /* True if HIGH range bound contains the number of elements in the
711 subrange. This affects how the final high bound is computed. */
713 unsigned int flag_upper_bound_is_count : 1;
715 /* True if LOW or/and HIGH are resolved into a static bound from
716 a dynamic one. */
718 unsigned int flag_bound_evaluated : 1;
720 /* If this is true this STRIDE is in bytes, otherwise STRIDE is in bits. */
722 unsigned int flag_is_byte_stride : 1;
725 /* Compare two range_bounds objects for equality. Simply does
726 memberwise comparison. */
727 extern bool operator== (const range_bounds &l, const range_bounds &r);
729 /* Compare two range_bounds objects for inequality. */
730 static inline bool operator!= (const range_bounds &l, const range_bounds &r)
732 return !(l == r);
735 union type_specific
737 /* * CPLUS_STUFF is for TYPE_CODE_STRUCT. It is initialized to
738 point to cplus_struct_default, a default static instance of a
739 struct cplus_struct_type. */
741 struct cplus_struct_type *cplus_stuff;
743 /* * GNAT_STUFF is for types for which the GNAT Ada compiler
744 provides additional information. */
746 struct gnat_aux_type *gnat_stuff;
748 /* * FLOATFORMAT is for TYPE_CODE_FLT. It is a pointer to a
749 floatformat object that describes the floating-point value
750 that resides within the type. */
752 const struct floatformat *floatformat;
754 /* * For TYPE_CODE_FUNC and TYPE_CODE_METHOD types. */
756 struct func_type *func_stuff;
758 /* * For types that are pointer to member types (TYPE_CODE_METHODPTR,
759 TYPE_CODE_MEMBERPTR), SELF_TYPE is the type that this pointer
760 is a member of. */
762 struct type *self_type;
764 /* * For TYPE_CODE_FIXED_POINT types, the info necessary to decode
765 values of that type. */
766 struct fixed_point_type_info *fixed_point_info;
768 /* * An integer-like scalar type may be stored in just part of its
769 enclosing storage bytes. This structure describes this
770 situation. */
771 struct
773 /* * The bit size of the integer. This can be 0. For integers
774 that fill their storage (the ordinary case), this field holds
775 the byte size times 8. */
776 unsigned short bit_size;
777 /* * The bit offset of the integer. This is ordinarily 0, and can
778 only be non-zero if the bit size is less than the storage
779 size. */
780 unsigned short bit_offset;
781 } int_stuff;
784 /* * Main structure representing a type in GDB.
786 This structure is space-critical. Its layout has been tweaked to
787 reduce the space used. */
789 struct main_type
791 /* * Code for kind of type. */
793 ENUM_BITFIELD(type_code) code : 8;
795 /* * Flags about this type. These fields appear at this location
796 because they packs nicely here. See the TYPE_* macros for
797 documentation about these fields. */
799 unsigned int m_flag_unsigned : 1;
800 unsigned int m_flag_nosign : 1;
801 unsigned int m_flag_stub : 1;
802 unsigned int m_flag_target_stub : 1;
803 unsigned int m_flag_prototyped : 1;
804 unsigned int m_flag_varargs : 1;
805 unsigned int m_flag_vector : 1;
806 unsigned int m_flag_stub_supported : 1;
807 unsigned int m_flag_gnu_ifunc : 1;
808 unsigned int m_flag_fixed_instance : 1;
809 unsigned int m_flag_objfile_owned : 1;
810 unsigned int m_flag_endianity_not_default : 1;
812 /* * True if this type was declared with "class" rather than
813 "struct". */
815 unsigned int m_flag_declared_class : 1;
817 /* * True if this is an enum type with disjoint values. This
818 affects how the enum is printed. */
820 unsigned int m_flag_flag_enum : 1;
822 /* * For TYPE_CODE_ARRAY, this is true if this type is part of a
823 multi-dimensional array. Multi-dimensional arrays are
824 represented internally as arrays of arrays, and this flag lets
825 gdb distinguish between multiple dimensions and an ordinary array
826 of arrays. The flag is set on each inner dimension, but not the
827 outermost dimension. */
829 unsigned int m_multi_dimensional : 1;
831 /* * A discriminant telling us which field of the type_specific
832 union is being used for this type, if any. */
834 ENUM_BITFIELD(type_specific_kind) type_specific_field : 3;
836 /* * Number of fields described for this type. This field appears
837 at this location because it packs nicely here. */
839 unsigned int m_nfields;
841 /* * Name of this type, or NULL if none.
843 This is used for printing only. For looking up a name, look for
844 a symbol in the VAR_DOMAIN. This is generally allocated in the
845 objfile's obstack. However coffread.c uses malloc. */
847 const char *name;
849 /* * Every type is now associated with a particular objfile, and the
850 type is allocated on the objfile_obstack for that objfile. One
851 problem however, is that there are times when gdb allocates new
852 types while it is not in the process of reading symbols from a
853 particular objfile. Fortunately, these happen when the type
854 being created is a derived type of an existing type, such as in
855 lookup_pointer_type(). So we can just allocate the new type
856 using the same objfile as the existing type, but to do this we
857 need a backpointer to the objfile from the existing type. Yes
858 this is somewhat ugly, but without major overhaul of the internal
859 type system, it can't be avoided for now. */
861 union type_owner m_owner;
863 /* * For a pointer type, describes the type of object pointed to.
864 - For an array type, describes the type of the elements.
865 - For a function or method type, describes the type of the return value.
866 - For a range type, describes the type of the full range.
867 - For a complex type, describes the type of each coordinate.
868 - For a special record or union type encoding a dynamic-sized type
869 in GNAT, a memoized pointer to a corresponding static version of
870 the type.
871 - Unused otherwise. */
873 struct type *m_target_type;
875 /* * For structure and union types, a description of each field.
876 For set and pascal array types, there is one "field",
877 whose type is the domain type of the set or array.
878 For range types, there are two "fields",
879 the minimum and maximum values (both inclusive).
880 For enum types, each possible value is described by one "field".
881 For a function or method type, a "field" for each parameter.
882 For C++ classes, there is one field for each base class (if it is
883 a derived class) plus one field for each class data member. Member
884 functions are recorded elsewhere.
886 Using a pointer to a separate array of fields
887 allows all types to have the same size, which is useful
888 because we can allocate the space for a type before
889 we know what to put in it. */
891 union
893 struct field *fields;
895 /* * Union member used for range types. */
897 struct range_bounds *bounds;
899 /* If this is a scalar type, then this is its corresponding
900 complex type. */
901 struct type *complex_type;
903 } flds_bnds;
905 /* * Slot to point to additional language-specific fields of this
906 type. */
908 union type_specific type_specific;
910 /* * Contains all dynamic type properties. */
911 struct dynamic_prop_list *dyn_prop_list;
914 /* * Number of bits allocated for alignment. */
916 #define TYPE_ALIGN_BITS 8
918 /* * A ``struct type'' describes a particular instance of a type, with
919 some particular qualification. */
921 struct type
923 /* Get the type code of this type.
925 Note that the code can be TYPE_CODE_TYPEDEF, so if you want the real
926 type, you need to do `check_typedef (type)->code ()`. */
927 type_code code () const
929 return this->main_type->code;
932 /* Set the type code of this type. */
933 void set_code (type_code code)
935 this->main_type->code = code;
938 /* Get the name of this type. */
939 const char *name () const
941 return this->main_type->name;
944 /* Set the name of this type. */
945 void set_name (const char *name)
947 this->main_type->name = name;
950 /* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
951 But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
952 so you only have to call check_typedef once. Since value::allocate
953 calls check_typedef, X->type ()->length () is safe. */
954 ULONGEST length () const
956 return this->m_length;
959 void set_length (ULONGEST length)
961 this->m_length = length;
964 /* Get the number of fields of this type. */
965 unsigned int num_fields () const
967 return this->main_type->m_nfields;
970 /* Set the number of fields of this type. */
971 void set_num_fields (unsigned int num_fields)
973 this->main_type->m_nfields = num_fields;
976 /* Get the fields array of this type. */
977 struct field *fields () const
979 return this->main_type->flds_bnds.fields;
982 /* Get the field at index IDX. */
983 struct field &field (int idx) const
985 gdb_assert (idx >= 0 && idx < num_fields ());
986 return this->fields ()[idx];
989 /* Set the fields array of this type. */
990 void set_fields (struct field *fields)
992 this->main_type->flds_bnds.fields = fields;
995 type *index_type () const
997 return this->field (0).type ();
1000 struct type *target_type () const
1002 return this->main_type->m_target_type;
1005 void set_target_type (struct type *target_type)
1007 this->main_type->m_target_type = target_type;
1010 void set_index_type (type *index_type)
1012 this->field (0).set_type (index_type);
1015 /* Return the instance flags converted to the correct type. */
1016 const type_instance_flags instance_flags () const
1018 return (enum type_instance_flag_value) this->m_instance_flags;
1021 /* Set the instance flags. */
1022 void set_instance_flags (type_instance_flags flags)
1024 this->m_instance_flags = flags;
1027 /* Get the bounds bounds of this type. The type must be a range type. */
1028 range_bounds *bounds () const
1030 switch (this->code ())
1032 case TYPE_CODE_RANGE:
1033 return this->main_type->flds_bnds.bounds;
1035 case TYPE_CODE_ARRAY:
1036 case TYPE_CODE_STRING:
1037 return this->index_type ()->bounds ();
1039 default:
1040 gdb_assert_not_reached
1041 ("type::bounds called on type with invalid code");
1045 /* Set the bounds of this type. The type must be a range type. */
1046 void set_bounds (range_bounds *bounds)
1048 gdb_assert (this->code () == TYPE_CODE_RANGE);
1050 this->main_type->flds_bnds.bounds = bounds;
1053 ULONGEST bit_stride () const
1055 if (this->code () == TYPE_CODE_ARRAY && this->field (0).bitsize != 0)
1056 return this->field (0).bitsize;
1057 return this->bounds ()->bit_stride ();
1060 /* Unsigned integer type. If this is not set for a TYPE_CODE_INT,
1061 the type is signed (unless TYPE_NOSIGN is set). */
1063 bool is_unsigned () const
1065 return this->main_type->m_flag_unsigned;
1068 void set_is_unsigned (bool is_unsigned)
1070 this->main_type->m_flag_unsigned = is_unsigned;
1073 /* No sign for this type. In C++, "char", "signed char", and
1074 "unsigned char" are distinct types; so we need an extra flag to
1075 indicate the absence of a sign! */
1077 bool has_no_signedness () const
1079 return this->main_type->m_flag_nosign;
1082 void set_has_no_signedness (bool has_no_signedness)
1084 this->main_type->m_flag_nosign = has_no_signedness;
1087 /* This appears in a type's flags word if it is a stub type (e.g.,
1088 if someone referenced a type that wasn't defined in a source file
1089 via (struct sir_not_appearing_in_this_film *)). */
1091 bool is_stub () const
1093 return this->main_type->m_flag_stub;
1096 void set_is_stub (bool is_stub)
1098 this->main_type->m_flag_stub = is_stub;
1101 /* The target type of this type is a stub type, and this type needs
1102 to be updated if it gets un-stubbed in check_typedef. Used for
1103 arrays and ranges, in which TYPE_LENGTH of the array/range gets set
1104 based on the TYPE_LENGTH of the target type. Also, set for
1105 TYPE_CODE_TYPEDEF. */
1107 bool target_is_stub () const
1109 return this->main_type->m_flag_target_stub;
1112 void set_target_is_stub (bool target_is_stub)
1114 this->main_type->m_flag_target_stub = target_is_stub;
1117 /* This is a function type which appears to have a prototype. We
1118 need this for function calls in order to tell us if it's necessary
1119 to coerce the args, or to just do the standard conversions. This
1120 is used with a short field. */
1122 bool is_prototyped () const
1124 return this->main_type->m_flag_prototyped;
1127 void set_is_prototyped (bool is_prototyped)
1129 this->main_type->m_flag_prototyped = is_prototyped;
1132 /* FIXME drow/2002-06-03: Only used for methods, but applies as well
1133 to functions. */
1135 bool has_varargs () const
1137 return this->main_type->m_flag_varargs;
1140 void set_has_varargs (bool has_varargs)
1142 this->main_type->m_flag_varargs = has_varargs;
1145 /* Identify a vector type. Gcc is handling this by adding an extra
1146 attribute to the array type. We slurp that in as a new flag of a
1147 type. This is used only in dwarf2read.c. */
1149 bool is_vector () const
1151 return this->main_type->m_flag_vector;
1154 void set_is_vector (bool is_vector)
1156 this->main_type->m_flag_vector = is_vector;
1159 /* This debug target supports TYPE_STUB(t). In the unsupported case
1160 we have to rely on NFIELDS to be zero etc., see TYPE_IS_OPAQUE().
1161 TYPE_STUB(t) with !TYPE_STUB_SUPPORTED(t) may exist if we only
1162 guessed the TYPE_STUB(t) value (see dwarfread.c). */
1164 bool stub_is_supported () const
1166 return this->main_type->m_flag_stub_supported;
1169 void set_stub_is_supported (bool stub_is_supported)
1171 this->main_type->m_flag_stub_supported = stub_is_supported;
1174 /* Used only for TYPE_CODE_FUNC where it specifies the real function
1175 address is returned by this function call. The target_type method
1176 determines the final returned function type to be presented to
1177 user. */
1179 bool is_gnu_ifunc () const
1181 return this->main_type->m_flag_gnu_ifunc;
1184 void set_is_gnu_ifunc (bool is_gnu_ifunc)
1186 this->main_type->m_flag_gnu_ifunc = is_gnu_ifunc;
1189 /* The debugging formats (especially STABS) do not contain enough
1190 information to represent all Ada types---especially those whose
1191 size depends on dynamic quantities. Therefore, the GNAT Ada
1192 compiler includes extra information in the form of additional type
1193 definitions connected by naming conventions. This flag indicates
1194 that the type is an ordinary (unencoded) GDB type that has been
1195 created from the necessary run-time information, and does not need
1196 further interpretation. Optionally marks ordinary, fixed-size GDB
1197 type. */
1199 bool is_fixed_instance () const
1201 return this->main_type->m_flag_fixed_instance;
1204 void set_is_fixed_instance (bool is_fixed_instance)
1206 this->main_type->m_flag_fixed_instance = is_fixed_instance;
1209 /* A compiler may supply dwarf instrumentation that indicates the desired
1210 endian interpretation of the variable differs from the native endian
1211 representation. */
1213 bool endianity_is_not_default () const
1215 return this->main_type->m_flag_endianity_not_default;
1218 void set_endianity_is_not_default (bool endianity_is_not_default)
1220 this->main_type->m_flag_endianity_not_default = endianity_is_not_default;
1224 /* True if this type was declared using the "class" keyword. This is
1225 only valid for C++ structure and enum types. If false, a structure
1226 was declared as a "struct"; if true it was declared "class". For
1227 enum types, this is true when "enum class" or "enum struct" was
1228 used to declare the type. */
1230 bool is_declared_class () const
1232 return this->main_type->m_flag_declared_class;
1235 void set_is_declared_class (bool is_declared_class) const
1237 this->main_type->m_flag_declared_class = is_declared_class;
1240 /* True if this type is a "flag" enum. A flag enum is one where all
1241 the values are pairwise disjoint when "and"ed together. This
1242 affects how enum values are printed. */
1244 bool is_flag_enum () const
1246 return this->main_type->m_flag_flag_enum;
1249 void set_is_flag_enum (bool is_flag_enum)
1251 this->main_type->m_flag_flag_enum = is_flag_enum;
1254 /* True if this array type is part of a multi-dimensional array. */
1256 bool is_multi_dimensional () const
1258 return this->main_type->m_multi_dimensional;
1261 void set_is_multi_dimensional (bool value)
1263 this->main_type->m_multi_dimensional = value;
1266 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return a reference
1267 to this type's fixed_point_info. */
1269 struct fixed_point_type_info &fixed_point_info () const
1271 gdb_assert (this->code () == TYPE_CODE_FIXED_POINT);
1272 gdb_assert (this->main_type->type_specific.fixed_point_info != nullptr);
1274 return *this->main_type->type_specific.fixed_point_info;
1277 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, set this type's
1278 fixed_point_info to INFO. */
1280 void set_fixed_point_info (struct fixed_point_type_info *info) const
1282 gdb_assert (this->code () == TYPE_CODE_FIXED_POINT);
1284 this->main_type->type_specific.fixed_point_info = info;
1287 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return its base type.
1289 In other words, this returns the type after having peeled all
1290 intermediate type layers (such as TYPE_CODE_RANGE, for instance).
1291 The TYPE_CODE of the type returned is guaranteed to be
1292 a TYPE_CODE_FIXED_POINT. */
1294 struct type *fixed_point_type_base_type ();
1296 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return its scaling
1297 factor. */
1299 const gdb_mpq &fixed_point_scaling_factor ();
1301 /* * Return the dynamic property of the requested KIND from this type's
1302 list of dynamic properties. */
1303 dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;
1305 /* * Given a dynamic property PROP of a given KIND, add this dynamic
1306 property to this type.
1308 This function assumes that this type is objfile-owned. */
1309 void add_dyn_prop (dynamic_prop_node_kind kind, dynamic_prop prop);
1311 /* * Remove dynamic property of kind KIND from this type, if it exists. */
1312 void remove_dyn_prop (dynamic_prop_node_kind kind);
1314 /* Return true if this type is owned by an objfile. Return false if it is
1315 owned by an architecture. */
1316 bool is_objfile_owned () const
1318 return this->main_type->m_flag_objfile_owned;
1321 /* Set the owner of the type to be OBJFILE. */
1322 void set_owner (objfile *objfile)
1324 gdb_assert (objfile != nullptr);
1326 this->main_type->m_owner.objfile = objfile;
1327 this->main_type->m_flag_objfile_owned = true;
1330 /* Set the owner of the type to be ARCH. */
1331 void set_owner (gdbarch *arch)
1333 gdb_assert (arch != nullptr);
1335 this->main_type->m_owner.gdbarch = arch;
1336 this->main_type->m_flag_objfile_owned = false;
1339 /* Return the objfile owner of this type.
1341 Return nullptr if this type is not objfile-owned. */
1342 struct objfile *objfile_owner () const
1344 if (!this->is_objfile_owned ())
1345 return nullptr;
1347 return this->main_type->m_owner.objfile;
1350 /* Return the gdbarch owner of this type.
1352 Return nullptr if this type is not gdbarch-owned. */
1353 gdbarch *arch_owner () const
1355 if (this->is_objfile_owned ())
1356 return nullptr;
1358 return this->main_type->m_owner.gdbarch;
1361 /* Return the type's architecture. For types owned by an
1362 architecture, that architecture is returned. For types owned by an
1363 objfile, that objfile's architecture is returned.
1365 The return value is always non-nullptr. */
1366 gdbarch *arch () const;
1368 /* * Return true if this is an integer type whose logical (bit) size
1369 differs from its storage size; false otherwise. Always return
1370 false for non-integer (i.e., non-TYPE_SPECIFIC_INT) types. */
1371 bool bit_size_differs_p () const
1373 return (main_type->type_specific_field == TYPE_SPECIFIC_INT
1374 && main_type->type_specific.int_stuff.bit_size != 8 * length ());
1377 /* * Return the logical (bit) size for this integer type. Only
1378 valid for integer (TYPE_SPECIFIC_INT) types. */
1379 unsigned short bit_size () const
1381 gdb_assert (main_type->type_specific_field == TYPE_SPECIFIC_INT);
1382 return main_type->type_specific.int_stuff.bit_size;
1385 /* * Return the bit offset for this integer type. Only valid for
1386 integer (TYPE_SPECIFIC_INT) types. */
1387 unsigned short bit_offset () const
1389 gdb_assert (main_type->type_specific_field == TYPE_SPECIFIC_INT);
1390 return main_type->type_specific.int_stuff.bit_offset;
1393 /* Return true if this is a pointer or reference type. */
1394 bool is_pointer_or_reference () const
1396 return this->code () == TYPE_CODE_PTR || TYPE_IS_REFERENCE (this);
1399 /* * Type that is a pointer to this type.
1400 NULL if no such pointer-to type is known yet.
1401 The debugger may add the address of such a type
1402 if it has to construct one later. */
1404 struct type *pointer_type;
1406 /* * C++: also need a reference type. */
1408 struct type *reference_type;
1410 /* * A C++ rvalue reference type added in C++11. */
1412 struct type *rvalue_reference_type;
1414 /* * Variant chain. This points to a type that differs from this
1415 one only in qualifiers and length. Currently, the possible
1416 qualifiers are const, volatile, code-space, data-space, and
1417 address class. The length may differ only when one of the
1418 address class flags are set. The variants are linked in a
1419 circular ring and share MAIN_TYPE. */
1421 struct type *chain;
1423 /* * The alignment for this type. Zero means that the alignment was
1424 not specified in the debug info. Note that this is stored in a
1425 funny way: as the log base 2 (plus 1) of the alignment; so a
1426 value of 1 means the alignment is 1, and a value of 9 means the
1427 alignment is 256. */
1429 unsigned align_log2 : TYPE_ALIGN_BITS;
1431 /* * Flags specific to this instance of the type, indicating where
1432 on the ring we are.
1434 For TYPE_CODE_TYPEDEF the flags of the typedef type should be
1435 binary or-ed with the target type, with a special case for
1436 address class and space class. For example if this typedef does
1437 not specify any new qualifiers, TYPE_INSTANCE_FLAGS is 0 and the
1438 instance flags are completely inherited from the target type. No
1439 qualifiers can be cleared by the typedef. See also
1440 check_typedef. */
1441 unsigned m_instance_flags : 9;
1443 /* * Length of storage for a value of this type. The value is the
1444 expression in host bytes of what sizeof(type) would return. This
1445 size includes padding. For example, an i386 extended-precision
1446 floating point value really only occupies ten bytes, but most
1447 ABI's declare its size to be 12 bytes, to preserve alignment.
1448 A `struct type' representing such a floating-point type would
1449 have a `length' value of 12, even though the last two bytes are
1450 unused.
1452 Since this field is expressed in host bytes, its value is appropriate
1453 to pass to memcpy and such (it is assumed that GDB itself always runs
1454 on an 8-bits addressable architecture). However, when using it for
1455 target address arithmetic (e.g. adding it to a target address), the
1456 type_length_units function should be used in order to get the length
1457 expressed in target addressable memory units. */
1459 ULONGEST m_length;
1461 /* * Core type, shared by a group of qualified types. */
1463 struct main_type *main_type;
1466 struct fn_fieldlist
1469 /* * The overloaded name.
1470 This is generally allocated in the objfile's obstack.
1471 However stabsread.c sometimes uses malloc. */
1473 const char *name;
1475 /* * The number of methods with this name. */
1477 int length;
1479 /* * The list of methods. */
1481 struct fn_field *fn_fields;
1486 struct fn_field
1488 /* * If is_stub is clear, this is the mangled name which we can look
1489 up to find the address of the method (FIXME: it would be cleaner
1490 to have a pointer to the struct symbol here instead).
1492 If is_stub is set, this is the portion of the mangled name which
1493 specifies the arguments. For example, "ii", if there are two int
1494 arguments, or "" if there are no arguments. See gdb_mangle_name
1495 for the conversion from this format to the one used if is_stub is
1496 clear. */
1498 const char *physname;
1500 /* * The function type for the method.
1502 (This comment used to say "The return value of the method", but
1503 that's wrong. The function type is expected here, i.e. something
1504 with TYPE_CODE_METHOD, and *not* the return-value type). */
1506 struct type *type;
1508 /* * For virtual functions. First baseclass that defines this
1509 virtual function. */
1511 struct type *fcontext;
1513 /* Attributes. */
1515 unsigned int is_const:1;
1516 unsigned int is_volatile:1;
1517 unsigned int is_private:1;
1518 unsigned int is_protected:1;
1519 unsigned int is_artificial:1;
1521 /* * A stub method only has some fields valid (but they are enough
1522 to reconstruct the rest of the fields). */
1524 unsigned int is_stub:1;
1526 /* * True if this function is a constructor, false otherwise. */
1528 unsigned int is_constructor : 1;
1530 /* * True if this function is deleted, false otherwise. */
1532 unsigned int is_deleted : 1;
1534 /* * DW_AT_defaulted attribute for this function. The value is one
1535 of the DW_DEFAULTED constants. */
1537 ENUM_BITFIELD (dwarf_defaulted_attribute) defaulted : 2;
1539 /* * Unused. */
1541 unsigned int dummy:6;
1543 /* * Index into that baseclass's virtual function table, minus 2;
1544 else if static: VOFFSET_STATIC; else: 0. */
1546 unsigned int voffset:16;
1548 #define VOFFSET_STATIC 1
1552 struct decl_field
1554 /* * Unqualified name to be prefixed by owning class qualified
1555 name. */
1557 const char *name;
1559 /* * Type this typedef named NAME represents. */
1561 struct type *type;
1563 /* * True if this field was declared protected, false otherwise. */
1564 unsigned int is_protected : 1;
1566 /* * True if this field was declared private, false otherwise. */
1567 unsigned int is_private : 1;
1570 /* * C++ language-specific information for TYPE_CODE_STRUCT and
1571 TYPE_CODE_UNION nodes. */
1573 struct cplus_struct_type
1575 /* * Number of base classes this type derives from. The
1576 baseclasses are stored in the first N_BASECLASSES fields
1577 (i.e. the `fields' field of the struct type). The only fields
1578 of struct field that are used are: type, name, loc.bitpos. */
1580 short n_baseclasses;
1582 /* * Field number of the virtual function table pointer in VPTR_BASETYPE.
1583 All access to this field must be through TYPE_VPTR_FIELDNO as one
1584 thing it does is check whether the field has been initialized.
1585 Initially TYPE_RAW_CPLUS_SPECIFIC has the value of cplus_struct_default,
1586 which for portability reasons doesn't initialize this field.
1587 TYPE_VPTR_FIELDNO returns -1 for this case.
1589 If -1, we were unable to find the virtual function table pointer in
1590 initial symbol reading, and get_vptr_fieldno should be called to find
1591 it if possible. get_vptr_fieldno will update this field if possible.
1592 Otherwise the value is left at -1.
1594 Unused if this type does not have virtual functions. */
1596 short vptr_fieldno;
1598 /* * Number of methods with unique names. All overloaded methods
1599 with the same name count only once. */
1601 short nfn_fields;
1603 /* * Number of template arguments. */
1605 unsigned short n_template_arguments;
1607 /* * One if this struct is a dynamic class, as defined by the
1608 Itanium C++ ABI: if it requires a virtual table pointer,
1609 because it or any of its base classes have one or more virtual
1610 member functions or virtual base classes. Minus one if not
1611 dynamic. Zero if not yet computed. */
1613 int is_dynamic : 2;
1615 /* * The calling convention for this type, fetched from the
1616 DW_AT_calling_convention attribute. The value is one of the
1617 DW_CC constants. */
1619 ENUM_BITFIELD (dwarf_calling_convention) calling_convention : 8;
1621 /* * The base class which defined the virtual function table pointer. */
1623 struct type *vptr_basetype;
1625 /* * For derived classes, the number of base classes is given by
1626 n_baseclasses and virtual_field_bits is a bit vector containing
1627 one bit per base class. If the base class is virtual, the
1628 corresponding bit will be set.
1629 I.E, given:
1631 class A{};
1632 class B{};
1633 class C : public B, public virtual A {};
1635 B is a baseclass of C; A is a virtual baseclass for C.
1636 This is a C++ 2.0 language feature. */
1638 B_TYPE *virtual_field_bits;
1640 /* * For classes with private fields, the number of fields is
1641 given by nfields and private_field_bits is a bit vector
1642 containing one bit per field.
1644 If the field is private, the corresponding bit will be set. */
1646 B_TYPE *private_field_bits;
1648 /* * For classes with protected fields, the number of fields is
1649 given by nfields and protected_field_bits is a bit vector
1650 containing one bit per field.
1652 If the field is private, the corresponding bit will be set. */
1654 B_TYPE *protected_field_bits;
1656 /* * For classes with fields to be ignored, either this is
1657 optimized out or this field has length 0. */
1659 B_TYPE *ignore_field_bits;
1661 /* * For classes, structures, and unions, a description of each
1662 field, which consists of an overloaded name, followed by the
1663 types of arguments that the method expects, and then the name
1664 after it has been renamed to make it distinct.
1666 fn_fieldlists points to an array of nfn_fields of these. */
1668 struct fn_fieldlist *fn_fieldlists;
1670 /* * typedefs defined inside this class. typedef_field points to
1671 an array of typedef_field_count elements. */
1673 struct decl_field *typedef_field;
1675 unsigned typedef_field_count;
1677 /* * The nested types defined by this type. nested_types points to
1678 an array of nested_types_count elements. */
1680 struct decl_field *nested_types;
1682 unsigned nested_types_count;
1684 /* * The template arguments. This is an array with
1685 N_TEMPLATE_ARGUMENTS elements. This is NULL for non-template
1686 classes. */
1688 struct symbol **template_arguments;
1691 /* * Struct used to store conversion rankings. */
1693 struct rank
1695 short rank;
1697 /* * When two conversions are of the same type and therefore have
1698 the same rank, subrank is used to differentiate the two.
1700 Eg: Two derived-class-pointer to base-class-pointer conversions
1701 would both have base pointer conversion rank, but the
1702 conversion with the shorter distance to the ancestor is
1703 preferable. 'subrank' would be used to reflect that. */
1705 short subrank;
1708 /* * Used for ranking a function for overload resolution. */
1710 typedef std::vector<rank> badness_vector;
1712 /* * GNAT Ada-specific information for various Ada types. */
1714 struct gnat_aux_type
1716 /* * Parallel type used to encode information about dynamic types
1717 used in Ada (such as variant records, variable-size array,
1718 etc). */
1719 struct type* descriptive_type;
1722 /* * For TYPE_CODE_FUNC and TYPE_CODE_METHOD types. */
1724 struct func_type
1726 /* * The calling convention for targets supporting multiple ABIs.
1727 Right now this is only fetched from the Dwarf-2
1728 DW_AT_calling_convention attribute. The value is one of the
1729 DW_CC constants. */
1731 ENUM_BITFIELD (dwarf_calling_convention) calling_convention : 8;
1733 /* * Whether this function normally returns to its caller. It is
1734 set from the DW_AT_noreturn attribute if set on the
1735 DW_TAG_subprogram. */
1737 unsigned int is_noreturn : 1;
1739 /* * Only those DW_TAG_call_site's in this function that have
1740 DW_AT_call_tail_call set are linked in this list. Function
1741 without its tail call list complete
1742 (DW_AT_call_all_tail_calls or its superset
1743 DW_AT_call_all_calls) has TAIL_CALL_LIST NULL, even if some
1744 DW_TAG_call_site's exist in such function. */
1746 struct call_site *tail_call_list;
1748 /* * For method types (TYPE_CODE_METHOD), the aggregate type that
1749 contains the method. */
1751 struct type *self_type;
1754 /* The type-specific info for TYPE_CODE_FIXED_POINT types. */
1756 struct fixed_point_type_info
1758 /* The fixed point type's scaling factor. */
1759 gdb_mpq scaling_factor;
1762 /* * The default value of TYPE_CPLUS_SPECIFIC(T) points to this shared
1763 static structure. */
1765 extern const struct cplus_struct_type cplus_struct_default;
1767 extern void allocate_cplus_struct_type (struct type *);
1769 #define INIT_CPLUS_SPECIFIC(type) \
1770 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_CPLUS_STUFF, \
1771 TYPE_RAW_CPLUS_SPECIFIC (type) = (struct cplus_struct_type*) \
1772 &cplus_struct_default)
1774 #define ALLOCATE_CPLUS_STRUCT_TYPE(type) allocate_cplus_struct_type (type)
1776 #define HAVE_CPLUS_STRUCT(type) \
1777 (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_CPLUS_STUFF \
1778 && TYPE_RAW_CPLUS_SPECIFIC (type) != &cplus_struct_default)
1780 #define INIT_NONE_SPECIFIC(type) \
1781 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_NONE, \
1782 TYPE_MAIN_TYPE (type)->type_specific = {})
1784 extern const struct gnat_aux_type gnat_aux_default;
1786 extern void allocate_gnat_aux_type (struct type *);
1788 #define INIT_GNAT_SPECIFIC(type) \
1789 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_GNAT_STUFF, \
1790 TYPE_GNAT_SPECIFIC (type) = (struct gnat_aux_type *) &gnat_aux_default)
1791 #define ALLOCATE_GNAT_AUX_TYPE(type) allocate_gnat_aux_type (type)
1792 /* * A macro that returns non-zero if the type-specific data should be
1793 read as "gnat-stuff". */
1794 #define HAVE_GNAT_AUX_INFO(type) \
1795 (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_GNAT_STUFF)
1797 /* * True if TYPE is known to be an Ada type of some kind. */
1798 #define ADA_TYPE_P(type) \
1799 (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_GNAT_STUFF \
1800 || (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE \
1801 && (type)->is_fixed_instance ()))
1803 #define INIT_FUNC_SPECIFIC(type) \
1804 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FUNC, \
1805 TYPE_MAIN_TYPE (type)->type_specific.func_stuff = (struct func_type *) \
1806 TYPE_ZALLOC (type, \
1807 sizeof (*TYPE_MAIN_TYPE (type)->type_specific.func_stuff)))
1809 /* "struct fixed_point_type_info" has a field that has a destructor.
1810 See allocate_fixed_point_type_info to understand how this is
1811 handled. */
1812 #define INIT_FIXED_POINT_SPECIFIC(type) \
1813 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FIXED_POINT, \
1814 allocate_fixed_point_type_info (type))
1816 #define TYPE_MAIN_TYPE(thistype) (thistype)->main_type
1817 #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
1818 #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
1819 #define TYPE_RVALUE_REFERENCE_TYPE(thistype) (thistype)->rvalue_reference_type
1820 #define TYPE_CHAIN(thistype) (thistype)->chain
1822 /* * Return the alignment of the type in target addressable memory
1823 units, or 0 if no alignment was specified. */
1824 #define TYPE_RAW_ALIGN(thistype) type_raw_align (thistype)
1826 /* * Return the alignment of the type in target addressable memory
1827 units, or 0 if no alignment was specified. */
1828 extern unsigned type_raw_align (struct type *);
1830 /* * Return the alignment of the type in target addressable memory
1831 units. Return 0 if the alignment cannot be determined; but note
1832 that this makes an effort to compute the alignment even it it was
1833 not specified in the debug info. */
1834 extern unsigned type_align (struct type *);
1836 /* * Set the alignment of the type. The alignment must be a power of
1837 2. Returns false if the given value does not fit in the available
1838 space in struct type. */
1839 extern bool set_type_align (struct type *, ULONGEST);
1841 /* Property accessors for the type data location. */
1842 #define TYPE_DATA_LOCATION(thistype) \
1843 ((thistype)->dyn_prop (DYN_PROP_DATA_LOCATION))
1844 #define TYPE_DATA_LOCATION_BATON(thistype) \
1845 TYPE_DATA_LOCATION (thistype)->data.baton
1846 #define TYPE_DATA_LOCATION_ADDR(thistype) \
1847 (TYPE_DATA_LOCATION (thistype)->const_val ())
1848 #define TYPE_DATA_LOCATION_KIND(thistype) \
1849 (TYPE_DATA_LOCATION (thistype)->kind ())
1850 #define TYPE_DYNAMIC_LENGTH(thistype) \
1851 ((thistype)->dyn_prop (DYN_PROP_BYTE_SIZE))
1853 /* Property accessors for the type allocated/associated. */
1854 #define TYPE_ALLOCATED_PROP(thistype) \
1855 ((thistype)->dyn_prop (DYN_PROP_ALLOCATED))
1856 #define TYPE_ASSOCIATED_PROP(thistype) \
1857 ((thistype)->dyn_prop (DYN_PROP_ASSOCIATED))
1858 #define TYPE_RANK_PROP(thistype) \
1859 ((thistype)->dyn_prop (DYN_PROP_RANK))
1861 /* C++ */
1863 #define TYPE_SELF_TYPE(thistype) internal_type_self_type (thistype)
1864 /* Do not call this, use TYPE_SELF_TYPE. */
1865 extern struct type *internal_type_self_type (struct type *);
1866 extern void set_type_self_type (struct type *, struct type *);
1868 extern int internal_type_vptr_fieldno (struct type *);
1869 extern void set_type_vptr_fieldno (struct type *, int);
1870 extern struct type *internal_type_vptr_basetype (struct type *);
1871 extern void set_type_vptr_basetype (struct type *, struct type *);
1872 #define TYPE_VPTR_FIELDNO(thistype) internal_type_vptr_fieldno (thistype)
1873 #define TYPE_VPTR_BASETYPE(thistype) internal_type_vptr_basetype (thistype)
1875 #define TYPE_NFN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields
1876 #define TYPE_SPECIFIC_FIELD(thistype) \
1877 TYPE_MAIN_TYPE(thistype)->type_specific_field
1878 /* We need this tap-dance with the TYPE_RAW_SPECIFIC because of the case
1879 where we're trying to print an Ada array using the C language.
1880 In that case, there is no "cplus_stuff", but the C language assumes
1881 that there is. What we do, in that case, is pretend that there is
1882 an implicit one which is the default cplus stuff. */
1883 #define TYPE_CPLUS_SPECIFIC(thistype) \
1884 (!HAVE_CPLUS_STRUCT(thistype) \
1885 ? (struct cplus_struct_type*)&cplus_struct_default \
1886 : TYPE_RAW_CPLUS_SPECIFIC(thistype))
1887 #define TYPE_RAW_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff
1888 #define TYPE_CPLUS_CALLING_CONVENTION(thistype) \
1889 TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff->calling_convention
1890 #define TYPE_FLOATFORMAT(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.floatformat
1891 #define TYPE_GNAT_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.gnat_stuff
1892 #define TYPE_DESCRIPTIVE_TYPE(thistype) TYPE_GNAT_SPECIFIC(thistype)->descriptive_type
1893 #define TYPE_CALLING_CONVENTION(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->calling_convention
1894 #define TYPE_NO_RETURN(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->is_noreturn
1895 #define TYPE_TAIL_CALL_LIST(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->tail_call_list
1896 #define TYPE_BASECLASS(thistype,index) ((thistype)->field (index).type ())
1897 #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
1898 #define TYPE_BASECLASS_NAME(thistype,index) (thistype->field (index).name ())
1899 #define TYPE_BASECLASS_BITPOS(thistype,index) (thistype->field (index).loc_bitpos ())
1900 #define BASETYPE_VIA_PUBLIC(thistype, index) \
1901 ((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index)))
1902 #define TYPE_CPLUS_DYNAMIC(thistype) TYPE_CPLUS_SPECIFIC (thistype)->is_dynamic
1904 #define BASETYPE_VIA_VIRTUAL(thistype, index) \
1905 (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
1906 : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
1908 #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
1909 #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
1911 #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL((thistype)->field (n))
1912 #define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE((thistype)->field (n))
1913 #define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE((thistype)->field (n))!=0)
1915 #define TYPE_FIELD_PRIVATE_BITS(thistype) \
1916 TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits
1917 #define TYPE_FIELD_PROTECTED_BITS(thistype) \
1918 TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits
1919 #define TYPE_FIELD_IGNORE_BITS(thistype) \
1920 TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits
1921 #define TYPE_FIELD_VIRTUAL_BITS(thistype) \
1922 TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits
1923 #define SET_TYPE_FIELD_PRIVATE(thistype, n) \
1924 B_SET (TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n))
1925 #define SET_TYPE_FIELD_PROTECTED(thistype, n) \
1926 B_SET (TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n))
1927 #define SET_TYPE_FIELD_IGNORE(thistype, n) \
1928 B_SET (TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits, (n))
1929 #define SET_TYPE_FIELD_VIRTUAL(thistype, n) \
1930 B_SET (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n))
1931 #define TYPE_FIELD_PRIVATE(thistype, n) \
1932 (TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits == NULL ? 0 \
1933 : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n)))
1934 #define TYPE_FIELD_PROTECTED(thistype, n) \
1935 (TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits == NULL ? 0 \
1936 : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n)))
1937 #define TYPE_FIELD_IGNORE(thistype, n) \
1938 (TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits == NULL ? 0 \
1939 : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits, (n)))
1940 #define TYPE_FIELD_VIRTUAL(thistype, n) \
1941 (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
1942 : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n)))
1944 #define TYPE_FN_FIELDLISTS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists
1945 #define TYPE_FN_FIELDLIST(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n]
1946 #define TYPE_FN_FIELDLIST1(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].fn_fields
1947 #define TYPE_FN_FIELDLIST_NAME(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].name
1948 #define TYPE_FN_FIELDLIST_LENGTH(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].length
1950 #define TYPE_N_TEMPLATE_ARGUMENTS(thistype) \
1951 TYPE_CPLUS_SPECIFIC (thistype)->n_template_arguments
1952 #define TYPE_TEMPLATE_ARGUMENTS(thistype) \
1953 TYPE_CPLUS_SPECIFIC (thistype)->template_arguments
1954 #define TYPE_TEMPLATE_ARGUMENT(thistype, n) \
1955 TYPE_CPLUS_SPECIFIC (thistype)->template_arguments[n]
1957 #define TYPE_FN_FIELD(thisfn, n) (thisfn)[n]
1958 #define TYPE_FN_FIELD_PHYSNAME(thisfn, n) (thisfn)[n].physname
1959 #define TYPE_FN_FIELD_TYPE(thisfn, n) (thisfn)[n].type
1960 #define TYPE_FN_FIELD_ARGS(thisfn, n) (((thisfn)[n].type)->fields ())
1961 #define TYPE_FN_FIELD_CONST(thisfn, n) ((thisfn)[n].is_const)
1962 #define TYPE_FN_FIELD_VOLATILE(thisfn, n) ((thisfn)[n].is_volatile)
1963 #define TYPE_FN_FIELD_PRIVATE(thisfn, n) ((thisfn)[n].is_private)
1964 #define TYPE_FN_FIELD_PROTECTED(thisfn, n) ((thisfn)[n].is_protected)
1965 #define TYPE_FN_FIELD_ARTIFICIAL(thisfn, n) ((thisfn)[n].is_artificial)
1966 #define TYPE_FN_FIELD_STUB(thisfn, n) ((thisfn)[n].is_stub)
1967 #define TYPE_FN_FIELD_CONSTRUCTOR(thisfn, n) ((thisfn)[n].is_constructor)
1968 #define TYPE_FN_FIELD_FCONTEXT(thisfn, n) ((thisfn)[n].fcontext)
1969 #define TYPE_FN_FIELD_VOFFSET(thisfn, n) ((thisfn)[n].voffset-2)
1970 #define TYPE_FN_FIELD_VIRTUAL_P(thisfn, n) ((thisfn)[n].voffset > 1)
1971 #define TYPE_FN_FIELD_STATIC_P(thisfn, n) ((thisfn)[n].voffset == VOFFSET_STATIC)
1972 #define TYPE_FN_FIELD_DEFAULTED(thisfn, n) ((thisfn)[n].defaulted)
1973 #define TYPE_FN_FIELD_DELETED(thisfn, n) ((thisfn)[n].is_deleted)
1975 /* Accessors for typedefs defined by a class. */
1976 #define TYPE_TYPEDEF_FIELD_ARRAY(thistype) \
1977 TYPE_CPLUS_SPECIFIC (thistype)->typedef_field
1978 #define TYPE_TYPEDEF_FIELD(thistype, n) \
1979 TYPE_CPLUS_SPECIFIC (thistype)->typedef_field[n]
1980 #define TYPE_TYPEDEF_FIELD_NAME(thistype, n) \
1981 TYPE_TYPEDEF_FIELD (thistype, n).name
1982 #define TYPE_TYPEDEF_FIELD_TYPE(thistype, n) \
1983 TYPE_TYPEDEF_FIELD (thistype, n).type
1984 #define TYPE_TYPEDEF_FIELD_COUNT(thistype) \
1985 TYPE_CPLUS_SPECIFIC (thistype)->typedef_field_count
1986 #define TYPE_TYPEDEF_FIELD_PROTECTED(thistype, n) \
1987 TYPE_TYPEDEF_FIELD (thistype, n).is_protected
1988 #define TYPE_TYPEDEF_FIELD_PRIVATE(thistype, n) \
1989 TYPE_TYPEDEF_FIELD (thistype, n).is_private
1991 #define TYPE_NESTED_TYPES_ARRAY(thistype) \
1992 TYPE_CPLUS_SPECIFIC (thistype)->nested_types
1993 #define TYPE_NESTED_TYPES_FIELD(thistype, n) \
1994 TYPE_CPLUS_SPECIFIC (thistype)->nested_types[n]
1995 #define TYPE_NESTED_TYPES_FIELD_NAME(thistype, n) \
1996 TYPE_NESTED_TYPES_FIELD (thistype, n).name
1997 #define TYPE_NESTED_TYPES_FIELD_TYPE(thistype, n) \
1998 TYPE_NESTED_TYPES_FIELD (thistype, n).type
1999 #define TYPE_NESTED_TYPES_COUNT(thistype) \
2000 TYPE_CPLUS_SPECIFIC (thistype)->nested_types_count
2001 #define TYPE_NESTED_TYPES_FIELD_PROTECTED(thistype, n) \
2002 TYPE_NESTED_TYPES_FIELD (thistype, n).is_protected
2003 #define TYPE_NESTED_TYPES_FIELD_PRIVATE(thistype, n) \
2004 TYPE_NESTED_TYPES_FIELD (thistype, n).is_private
2006 #define TYPE_IS_OPAQUE(thistype) \
2007 ((((thistype)->code () == TYPE_CODE_STRUCT) \
2008 || ((thistype)->code () == TYPE_CODE_UNION)) \
2009 && ((thistype)->num_fields () == 0) \
2010 && (!HAVE_CPLUS_STRUCT (thistype) \
2011 || TYPE_NFN_FIELDS (thistype) == 0) \
2012 && ((thistype)->is_stub () || !(thistype)->stub_is_supported ()))
2014 /* * A helper macro that returns the name of a type or "unnamed type"
2015 if the type has no name. */
2017 #define TYPE_SAFE_NAME(type) \
2018 (type->name () != nullptr ? type->name () : _("<unnamed type>"))
2020 /* * A helper macro that returns the name of an error type. If the
2021 type has a name, it is used; otherwise, a default is used. */
2023 #define TYPE_ERROR_NAME(type) \
2024 (type->name () ? type->name () : _("<error type>"))
2026 /* Given TYPE, return its floatformat. */
2027 const struct floatformat *floatformat_from_type (const struct type *type);
2029 struct builtin_type
2031 /* Integral types. */
2033 /* Implicit size/sign (based on the architecture's ABI). */
2034 struct type *builtin_void = nullptr;
2035 struct type *builtin_char = nullptr;
2036 struct type *builtin_short = nullptr;
2037 struct type *builtin_int = nullptr;
2038 struct type *builtin_long = nullptr;
2039 struct type *builtin_signed_char = nullptr;
2040 struct type *builtin_unsigned_char = nullptr;
2041 struct type *builtin_unsigned_short = nullptr;
2042 struct type *builtin_unsigned_int = nullptr;
2043 struct type *builtin_unsigned_long = nullptr;
2044 struct type *builtin_bfloat16 = nullptr;
2045 struct type *builtin_half = nullptr;
2046 struct type *builtin_float = nullptr;
2047 struct type *builtin_double = nullptr;
2048 struct type *builtin_long_double = nullptr;
2049 struct type *builtin_complex = nullptr;
2050 struct type *builtin_double_complex = nullptr;
2051 struct type *builtin_string = nullptr;
2052 struct type *builtin_bool = nullptr;
2053 struct type *builtin_long_long = nullptr;
2054 struct type *builtin_unsigned_long_long = nullptr;
2055 struct type *builtin_decfloat = nullptr;
2056 struct type *builtin_decdouble = nullptr;
2057 struct type *builtin_declong = nullptr;
2059 /* "True" character types.
2060 We use these for the '/c' print format, because c_char is just a
2061 one-byte integral type, which languages less laid back than C
2062 will print as ... well, a one-byte integral type. */
2063 struct type *builtin_true_char = nullptr;
2064 struct type *builtin_true_unsigned_char = nullptr;
2066 /* Explicit sizes - see C9X <intypes.h> for naming scheme. The "int0"
2067 is for when an architecture needs to describe a register that has
2068 no size. */
2069 struct type *builtin_int0 = nullptr;
2070 struct type *builtin_int8 = nullptr;
2071 struct type *builtin_uint8 = nullptr;
2072 struct type *builtin_int16 = nullptr;
2073 struct type *builtin_uint16 = nullptr;
2074 struct type *builtin_int24 = nullptr;
2075 struct type *builtin_uint24 = nullptr;
2076 struct type *builtin_int32 = nullptr;
2077 struct type *builtin_uint32 = nullptr;
2078 struct type *builtin_int64 = nullptr;
2079 struct type *builtin_uint64 = nullptr;
2080 struct type *builtin_int128 = nullptr;
2081 struct type *builtin_uint128 = nullptr;
2083 /* Wide character types. */
2084 struct type *builtin_char16 = nullptr;
2085 struct type *builtin_char32 = nullptr;
2086 struct type *builtin_wchar = nullptr;
2088 /* Pointer types. */
2090 /* * `pointer to data' type. Some target platforms use an implicitly
2091 {sign,zero} -extended 32-bit ABI pointer on a 64-bit ISA. */
2092 struct type *builtin_data_ptr = nullptr;
2094 /* * `pointer to function (returning void)' type. Harvard
2095 architectures mean that ABI function and code pointers are not
2096 interconvertible. Similarly, since ANSI, C standards have
2097 explicitly said that pointers to functions and pointers to data
2098 are not interconvertible --- that is, you can't cast a function
2099 pointer to void * and back, and expect to get the same value.
2100 However, all function pointer types are interconvertible, so void
2101 (*) () can server as a generic function pointer. */
2103 struct type *builtin_func_ptr = nullptr;
2105 /* * `function returning pointer to function (returning void)' type.
2106 The final void return type is not significant for it. */
2108 struct type *builtin_func_func = nullptr;
2110 /* Special-purpose types. */
2112 /* * This type is used to represent a GDB internal function. */
2114 struct type *internal_fn = nullptr;
2116 /* * This type is used to represent an xmethod. */
2117 struct type *xmethod = nullptr;
2119 /* * This type is used to represent symbol addresses. */
2120 struct type *builtin_core_addr = nullptr;
2122 /* * This type represents a type that was unrecognized in symbol
2123 read-in. */
2124 struct type *builtin_error = nullptr;
2126 /* * Types used for symbols with no debug information. */
2127 struct type *nodebug_text_symbol = nullptr;
2128 struct type *nodebug_text_gnu_ifunc_symbol = nullptr;
2129 struct type *nodebug_got_plt_symbol = nullptr;
2130 struct type *nodebug_data_symbol = nullptr;
2131 struct type *nodebug_unknown_symbol = nullptr;
2132 struct type *nodebug_tls_symbol = nullptr;
2135 /* * Return the type table for the specified architecture. */
2137 extern const struct builtin_type *builtin_type (struct gdbarch *gdbarch);
2139 /* * Return the type table for the specified objfile. */
2141 extern const struct builtin_type *builtin_type (struct objfile *objfile);
2143 /* Explicit floating-point formats. See "floatformat.h". */
2144 extern const struct floatformat *floatformats_ieee_half[BFD_ENDIAN_UNKNOWN];
2145 extern const struct floatformat *floatformats_ieee_single[BFD_ENDIAN_UNKNOWN];
2146 extern const struct floatformat *floatformats_ieee_double[BFD_ENDIAN_UNKNOWN];
2147 extern const struct floatformat *floatformats_ieee_quad[BFD_ENDIAN_UNKNOWN];
2148 extern const struct floatformat *floatformats_ieee_double_littlebyte_bigword[BFD_ENDIAN_UNKNOWN];
2149 extern const struct floatformat *floatformats_i387_ext[BFD_ENDIAN_UNKNOWN];
2150 extern const struct floatformat *floatformats_m68881_ext[BFD_ENDIAN_UNKNOWN];
2151 extern const struct floatformat *floatformats_arm_ext[BFD_ENDIAN_UNKNOWN];
2152 extern const struct floatformat *floatformats_ia64_spill[BFD_ENDIAN_UNKNOWN];
2153 extern const struct floatformat *floatformats_vax_f[BFD_ENDIAN_UNKNOWN];
2154 extern const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN];
2155 extern const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN];
2156 extern const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN];
2158 /* Allocate space for storing data associated with a particular
2159 type. We ensure that the space is allocated using the same
2160 mechanism that was used to allocate the space for the type
2161 structure itself. I.e. if the type is on an objfile's
2162 objfile_obstack, then the space for data associated with that type
2163 will also be allocated on the objfile_obstack. If the type is
2164 associated with a gdbarch, then the space for data associated with that
2165 type will also be allocated on the gdbarch_obstack.
2167 If a type is not associated with neither an objfile or a gdbarch then
2168 you should not use this macro to allocate space for data, instead you
2169 should call xmalloc directly, and ensure the memory is correctly freed
2170 when it is no longer needed. */
2172 #define TYPE_ALLOC(t,size) \
2173 (obstack_alloc (((t)->is_objfile_owned () \
2174 ? &((t)->objfile_owner ()->objfile_obstack) \
2175 : gdbarch_obstack ((t)->arch_owner ())), \
2176 size))
2179 /* See comment on TYPE_ALLOC. */
2181 #define TYPE_ZALLOC(t,size) (memset (TYPE_ALLOC (t, size), 0, size))
2183 /* * This returns the target type (or NULL) of TYPE, also skipping
2184 past typedefs. */
2186 extern struct type *get_target_type (struct type *type);
2188 /* Return the equivalent of TYPE_LENGTH, but in number of target
2189 addressable memory units of the associated gdbarch instead of bytes. */
2191 extern unsigned int type_length_units (struct type *type);
2193 /* An object of this type is passed when allocating certain types. It
2194 determines where the new type is allocated. Ultimately a type is
2195 either allocated on a on an objfile obstack or on a gdbarch
2196 obstack. However, it's also possible to request that a new type be
2197 allocated on the same obstack as some existing type, or that a
2198 "new" type instead overwrite a supplied type object. */
2200 class type_allocator
2202 public:
2204 /* Create new types on OBJFILE. */
2205 explicit type_allocator (objfile *objfile)
2206 : m_is_objfile (true)
2208 m_data.objfile = objfile;
2211 /* Create new types on GDBARCH. */
2212 explicit type_allocator (gdbarch *gdbarch)
2214 m_data.gdbarch = gdbarch;
2217 /* This determines whether a passed-in type should be rewritten in
2218 place, or whether it should simply determine where the new type
2219 is created. */
2220 enum type_allocator_kind
2222 /* Allocate on same obstack as existing type. */
2223 SAME = 0,
2224 /* Smash the existing type. */
2225 SMASH = 1,
2228 /* Create new types either on the same obstack as TYPE; or if SMASH
2229 is passed, overwrite TYPE. */
2230 explicit type_allocator (struct type *type,
2231 type_allocator_kind kind = SAME)
2233 if (kind == SAME)
2235 if (type->is_objfile_owned ())
2237 m_data.objfile = type->objfile_owner ();
2238 m_is_objfile = true;
2240 else
2241 m_data.gdbarch = type->arch_owner ();
2243 else
2245 m_smash = true;
2246 m_data.type = type;
2250 /* Create new types on the same obstack as TYPE. */
2251 explicit type_allocator (const struct type *type)
2252 : m_is_objfile (type->is_objfile_owned ())
2254 if (type->is_objfile_owned ())
2255 m_data.objfile = type->objfile_owner ();
2256 else
2257 m_data.gdbarch = type->arch_owner ();
2260 /* Create a new type on the desired obstack. Note that a "new" type
2261 is not created if type-smashing was selected at construction. */
2262 type *new_type ();
2264 /* Create a new type on the desired obstack, and fill in its code,
2265 length, and name. If NAME is non-null, it is copied to the
2266 destination obstack first. Note that a "new" type is not created
2267 if type-smashing was selected at construction. */
2268 type *new_type (enum type_code code, int bit, const char *name);
2270 /* Return the architecture associated with this allocator. This
2271 comes from whatever object was supplied to the constructor. */
2272 gdbarch *arch ();
2274 private:
2276 /* Where the type should wind up. */
2277 union
2279 struct objfile *objfile;
2280 struct gdbarch *gdbarch;
2281 struct type *type;
2282 } m_data {};
2284 /* True if this allocator uses the objfile field above. */
2285 bool m_is_objfile = false;
2286 /* True if this allocator uses the type field above, indicating that
2287 the "allocation" should be done in-place. */
2288 bool m_smash = false;
2291 /* Allocate a TYPE_CODE_INT type structure using ALLOC. BIT is the
2292 type size in bits. If UNSIGNED_P is non-zero, set the type's
2293 TYPE_UNSIGNED flag. NAME is the type name. */
2295 extern struct type *init_integer_type (type_allocator &alloc, int bit,
2296 int unsigned_p, const char *name);
2298 /* Allocate a TYPE_CODE_CHAR type structure using ALLOC. BIT is the
2299 type size in bits. If UNSIGNED_P is non-zero, set the type's
2300 TYPE_UNSIGNED flag. NAME is the type name. */
2302 extern struct type *init_character_type (type_allocator &alloc, int bit,
2303 int unsigned_p, const char *name);
2305 /* Allocate a TYPE_CODE_BOOL type structure using ALLOC. BIT is the
2306 type size in bits. If UNSIGNED_P is non-zero, set the type's
2307 TYPE_UNSIGNED flag. NAME is the type name. */
2309 extern struct type *init_boolean_type (type_allocator &alloc, int bit,
2310 int unsigned_p, const char *name);
2312 /* Allocate a TYPE_CODE_FLT type structure using ALLOC.
2313 BIT is the type size in bits; if BIT equals -1, the size is
2314 determined by the floatformat. NAME is the type name. Set the
2315 TYPE_FLOATFORMAT from FLOATFORMATS. BYTE_ORDER is the byte order
2316 to use. If it is BFD_ENDIAN_UNKNOWN (the default), then the byte
2317 order of the objfile's architecture is used. */
2319 extern struct type *init_float_type
2320 (type_allocator &alloc, int bit, const char *name,
2321 const struct floatformat **floatformats,
2322 enum bfd_endian byte_order = BFD_ENDIAN_UNKNOWN);
2324 /* Allocate a TYPE_CODE_DECFLOAT type structure using ALLOC.
2325 BIT is the type size in bits. NAME is the type name. */
2327 extern struct type *init_decfloat_type (type_allocator &alloc, int bit,
2328 const char *name);
2330 extern bool can_create_complex_type (struct type *);
2331 extern struct type *init_complex_type (const char *, struct type *);
2333 /* Allocate a TYPE_CODE_PTR type structure using ALLOC.
2334 BIT is the pointer type size in bits. NAME is the type name.
2335 TARGET_TYPE is the pointer target type. Always sets the pointer type's
2336 TYPE_UNSIGNED flag. */
2338 extern struct type *init_pointer_type (type_allocator &alloc, int bit,
2339 const char *name,
2340 struct type *target_type);
2342 extern struct type *init_fixed_point_type (struct objfile *, int, int,
2343 const char *);
2345 /* Helper functions to construct a struct or record type. An
2346 initially empty type is created using arch_composite_type().
2347 Fields are then added using append_composite_type_field*(). A union
2348 type has its size set to the largest field. A struct type has each
2349 field packed against the previous. */
2351 extern struct type *arch_composite_type (struct gdbarch *gdbarch,
2352 const char *name, enum type_code code);
2353 extern void append_composite_type_field (struct type *t, const char *name,
2354 struct type *field);
2355 extern void append_composite_type_field_aligned (struct type *t,
2356 const char *name,
2357 struct type *field,
2358 int alignment);
2359 struct field *append_composite_type_field_raw (struct type *t, const char *name,
2360 struct type *field);
2362 /* Helper functions to construct a bit flags type. An initially empty
2363 type is created using arch_flag_type(). Flags are then added using
2364 append_flag_type_field() and append_flag_type_flag(). */
2365 extern struct type *arch_flags_type (struct gdbarch *gdbarch,
2366 const char *name, int bit);
2367 extern void append_flags_type_field (struct type *type,
2368 int start_bitpos, int nr_bits,
2369 struct type *field_type, const char *name);
2370 extern void append_flags_type_flag (struct type *type, int bitpos,
2371 const char *name);
2373 extern void make_vector_type (struct type *array_type);
2374 extern struct type *init_vector_type (struct type *elt_type, int n);
2376 extern struct type *lookup_reference_type (struct type *, enum type_code);
2377 extern struct type *lookup_lvalue_reference_type (struct type *);
2378 extern struct type *lookup_rvalue_reference_type (struct type *);
2381 extern struct type *make_reference_type (struct type *, struct type **,
2382 enum type_code);
2384 extern struct type *make_cv_type (int, int, struct type *, struct type **);
2386 extern struct type *make_restrict_type (struct type *);
2388 extern struct type *make_unqualified_type (struct type *);
2390 extern struct type *make_atomic_type (struct type *);
2392 extern void replace_type (struct type *, struct type *);
2394 extern type_instance_flags address_space_name_to_type_instance_flags
2395 (struct gdbarch *, const char *);
2397 extern const char *address_space_type_instance_flags_to_name
2398 (struct gdbarch *, type_instance_flags);
2400 extern struct type *make_type_with_address_space
2401 (struct type *type, type_instance_flags space_identifier);
2403 extern struct type *lookup_memberptr_type (struct type *, struct type *);
2405 extern struct type *lookup_methodptr_type (struct type *);
2407 extern void smash_to_method_type (struct type *type, struct type *self_type,
2408 struct type *to_type, struct field *args,
2409 int nargs, int varargs);
2411 extern void smash_to_memberptr_type (struct type *, struct type *,
2412 struct type *);
2414 extern void smash_to_methodptr_type (struct type *, struct type *);
2416 extern const char *type_name_or_error (struct type *type);
2418 struct struct_elt
2420 /* The field of the element, or NULL if no element was found. */
2421 struct field *field;
2423 /* The bit offset of the element in the parent structure. */
2424 LONGEST offset;
2427 /* Given a type TYPE, lookup the field and offset of the component named
2428 NAME.
2430 TYPE can be either a struct or union, or a pointer or reference to
2431 a struct or union. If it is a pointer or reference, its target
2432 type is automatically used. Thus '.' and '->' are interchangeable,
2433 as specified for the definitions of the expression element types
2434 STRUCTOP_STRUCT and STRUCTOP_PTR.
2436 If NOERR is nonzero, the returned structure will have field set to
2437 NULL if there is no component named NAME.
2439 If the component NAME is a field in an anonymous substructure of
2440 TYPE, the returned offset is a "global" offset relative to TYPE
2441 rather than an offset within the substructure. */
2443 extern struct_elt lookup_struct_elt (struct type *, const char *, int);
2445 /* Given a type TYPE, lookup the type of the component named NAME.
2447 TYPE can be either a struct or union, or a pointer or reference to
2448 a struct or union. If it is a pointer or reference, its target
2449 type is automatically used. Thus '.' and '->' are interchangeable,
2450 as specified for the definitions of the expression element types
2451 STRUCTOP_STRUCT and STRUCTOP_PTR.
2453 If NOERR is nonzero, return NULL if there is no component named
2454 NAME. */
2456 extern struct type *lookup_struct_elt_type (struct type *, const char *, int);
2458 extern struct type *make_pointer_type (struct type *, struct type **);
2460 extern struct type *lookup_pointer_type (struct type *);
2462 extern struct type *make_function_type (struct type *, struct type **);
2464 extern struct type *lookup_function_type (struct type *);
2466 extern struct type *lookup_function_type_with_arguments (struct type *,
2467 int,
2468 struct type **);
2470 /* Create a range type using ALLOC.
2472 Indices will be of type INDEX_TYPE, and will range from LOW_BOUND
2473 to HIGH_BOUND, inclusive. */
2475 extern struct type *create_static_range_type (type_allocator &alloc,
2476 struct type *index_type,
2477 LONGEST low_bound,
2478 LONGEST high_bound);
2480 /* Create an array type using ALLOC.
2482 Elements will be of type ELEMENT_TYPE, the indices will be of type
2483 RANGE_TYPE.
2485 BYTE_STRIDE_PROP, when not NULL, provides the array's byte stride.
2486 This byte stride property is added to the resulting array type
2487 as a DYN_PROP_BYTE_STRIDE. As a consequence, the BYTE_STRIDE_PROP
2488 argument can only be used to create types that are objfile-owned
2489 (see add_dyn_prop), meaning that either this function must be called
2490 with an objfile-owned RESULT_TYPE, or an objfile-owned RANGE_TYPE.
2492 BIT_STRIDE is taken into account only when BYTE_STRIDE_PROP is NULL.
2493 If BIT_STRIDE is not zero, build a packed array type whose element
2494 size is BIT_STRIDE. Otherwise, ignore this parameter. */
2496 extern struct type *create_array_type_with_stride
2497 (type_allocator &alloc, struct type *element_type,
2498 struct type *range_type, struct dynamic_prop *byte_stride_prop,
2499 unsigned int bit_stride);
2501 /* Create a range type using ALLOC with a dynamic range from LOW_BOUND
2502 to HIGH_BOUND, inclusive. INDEX_TYPE is the underlying type. BIAS
2503 is the bias to be applied when storing or retrieving values of this
2504 type. */
2506 extern struct type *create_range_type (type_allocator &alloc,
2507 struct type *index_type,
2508 const struct dynamic_prop *low_bound,
2509 const struct dynamic_prop *high_bound,
2510 LONGEST bias);
2512 /* Like CREATE_RANGE_TYPE but also sets up a stride. When BYTE_STRIDE_P
2513 is true the value in STRIDE is a byte stride, otherwise STRIDE is a bit
2514 stride. */
2516 extern struct type *create_range_type_with_stride
2517 (type_allocator &alloc, struct type *index_type,
2518 const struct dynamic_prop *low_bound,
2519 const struct dynamic_prop *high_bound, LONGEST bias,
2520 const struct dynamic_prop *stride, bool byte_stride_p);
2522 /* Same as create_array_type_with_stride but with no bit_stride
2523 (BIT_STRIDE = 0), thus building an unpacked array. */
2525 extern struct type *create_array_type (type_allocator &alloc,
2526 struct type *element_type,
2527 struct type *range_type);
2529 extern struct type *lookup_array_range_type (struct type *, LONGEST, LONGEST);
2531 /* Create a string type using ALLOC. String types are similar enough
2532 to array of char types that we can use create_array_type to build
2533 the basic type and then bash it into a string type.
2535 For fixed length strings, the range type contains 0 as the lower
2536 bound and the length of the string minus one as the upper bound. */
2538 extern struct type *create_string_type (type_allocator &alloc,
2539 struct type *string_char_type,
2540 struct type *range_type);
2542 extern struct type *lookup_string_range_type (struct type *, LONGEST, LONGEST);
2544 extern struct type *create_set_type (type_allocator &alloc,
2545 struct type *domain_type);
2547 extern struct type *lookup_unsigned_typename (const struct language_defn *,
2548 const char *);
2550 extern struct type *lookup_signed_typename (const struct language_defn *,
2551 const char *);
2553 extern ULONGEST get_unsigned_type_max (struct type *);
2555 extern void get_signed_type_minmax (struct type *, LONGEST *, LONGEST *);
2557 extern CORE_ADDR get_pointer_type_max (struct type *);
2559 /* * Resolve all dynamic values of a type e.g. array bounds to static values.
2560 ADDR specifies the location of the variable the type is bound to.
2561 If TYPE has no dynamic properties return TYPE; otherwise a new type with
2562 static properties is returned.
2564 If FRAME is given, it is used when evaluating dynamic properties.
2565 This can be important when a static link is seen. If not given,
2566 the selected frame is used.
2568 For an array type, if the element type is dynamic, then that will
2569 not be resolved. This is done because each individual element may
2570 have a different type when resolved (depending on the contents of
2571 memory). In this situation, 'is_dynamic_type' will still return
2572 true for the return value of this function. */
2573 extern struct type *resolve_dynamic_type
2574 (struct type *type, gdb::array_view<const gdb_byte> valaddr,
2575 CORE_ADDR addr, const frame_info_ptr *frame = nullptr);
2577 /* * Predicate if the type has dynamic values, which are not resolved yet.
2578 See the caveat in 'resolve_dynamic_type' to understand a scenario
2579 where an apparently-resolved type may still be considered
2580 "dynamic". */
2581 extern int is_dynamic_type (struct type *type);
2583 extern struct type *check_typedef (struct type *);
2585 extern void check_stub_method_group (struct type *, int);
2587 extern char *gdb_mangle_name (struct type *, int, int);
2589 /* Lookup a typedef or primitive type named NAME, visible in lexical block
2590 BLOCK. If NOERR is nonzero, return zero if NAME is not suitably
2591 defined.
2593 If this function finds a suitable type then check_typedef is called on
2594 the type, this ensures that if the type being returned is a typedef
2595 then the length of the type will be correct. The original typedef will
2596 still be returned, not the result of calling check_typedef. */
2598 extern struct type *lookup_typename (const struct language_defn *language,
2599 const char *name,
2600 const struct block *block, int noerr);
2602 extern struct type *lookup_template_type (const char *, struct type *,
2603 const struct block *);
2605 extern int get_vptr_fieldno (struct type *, struct type **);
2607 /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type
2608 TYPE.
2610 Return true if the two bounds are available, false otherwise. */
2612 extern bool get_discrete_bounds (struct type *type, LONGEST *lowp,
2613 LONGEST *highp);
2615 /* If TYPE's low bound is a known constant, return it, else return nullopt. */
2617 extern gdb::optional<LONGEST> get_discrete_low_bound (struct type *type);
2619 /* If TYPE's high bound is a known constant, return it, else return nullopt. */
2621 extern gdb::optional<LONGEST> get_discrete_high_bound (struct type *type);
2623 /* Assuming TYPE is a simple, non-empty array type, compute its upper
2624 and lower bound. Save the low bound into LOW_BOUND if not NULL.
2625 Save the high bound into HIGH_BOUND if not NULL.
2627 Return true if the operation was successful. Return false otherwise,
2628 in which case the values of LOW_BOUND and HIGH_BOUNDS are unmodified. */
2630 extern bool get_array_bounds (struct type *type, LONGEST *low_bound,
2631 LONGEST *high_bound);
2633 extern gdb::optional<LONGEST> discrete_position (struct type *type,
2634 LONGEST val);
2636 extern int class_types_same_p (const struct type *, const struct type *);
2638 extern int is_ancestor (struct type *, struct type *);
2640 extern int is_public_ancestor (struct type *, struct type *);
2642 extern int is_unique_ancestor (struct type *, struct value *);
2644 /* Overload resolution */
2646 /* * Badness if parameter list length doesn't match arg list length. */
2647 extern const struct rank LENGTH_MISMATCH_BADNESS;
2649 /* * Dummy badness value for nonexistent parameter positions. */
2650 extern const struct rank TOO_FEW_PARAMS_BADNESS;
2651 /* * Badness if no conversion among types. */
2652 extern const struct rank INCOMPATIBLE_TYPE_BADNESS;
2654 /* * Badness of an exact match. */
2655 extern const struct rank EXACT_MATCH_BADNESS;
2657 /* * Badness of integral promotion. */
2658 extern const struct rank INTEGER_PROMOTION_BADNESS;
2659 /* * Badness of floating promotion. */
2660 extern const struct rank FLOAT_PROMOTION_BADNESS;
2661 /* * Badness of converting a derived class pointer
2662 to a base class pointer. */
2663 extern const struct rank BASE_PTR_CONVERSION_BADNESS;
2664 /* * Badness of integral conversion. */
2665 extern const struct rank INTEGER_CONVERSION_BADNESS;
2666 /* * Badness of floating conversion. */
2667 extern const struct rank FLOAT_CONVERSION_BADNESS;
2668 /* * Badness of integer<->floating conversions. */
2669 extern const struct rank INT_FLOAT_CONVERSION_BADNESS;
2670 /* * Badness of conversion of pointer to void pointer. */
2671 extern const struct rank VOID_PTR_CONVERSION_BADNESS;
2672 /* * Badness of conversion to boolean. */
2673 extern const struct rank BOOL_CONVERSION_BADNESS;
2674 /* * Badness of converting derived to base class. */
2675 extern const struct rank BASE_CONVERSION_BADNESS;
2676 /* * Badness of converting from non-reference to reference. Subrank
2677 is the type of reference conversion being done. */
2678 extern const struct rank REFERENCE_CONVERSION_BADNESS;
2679 extern const struct rank REFERENCE_SEE_THROUGH_BADNESS;
2680 /* * Conversion to rvalue reference. */
2681 #define REFERENCE_CONVERSION_RVALUE 1
2682 /* * Conversion to const lvalue reference. */
2683 #define REFERENCE_CONVERSION_CONST_LVALUE 2
2685 /* * Badness of converting integer 0 to NULL pointer. */
2686 extern const struct rank NULL_POINTER_CONVERSION;
2687 /* * Badness of cv-conversion. Subrank is a flag describing the conversions
2688 being done. */
2689 extern const struct rank CV_CONVERSION_BADNESS;
2690 #define CV_CONVERSION_CONST 1
2691 #define CV_CONVERSION_VOLATILE 2
2693 /* Non-standard conversions allowed by the debugger */
2695 /* * Converting a pointer to an int is usually OK. */
2696 extern const struct rank NS_POINTER_CONVERSION_BADNESS;
2698 /* * Badness of converting a (non-zero) integer constant
2699 to a pointer. */
2700 extern const struct rank NS_INTEGER_POINTER_CONVERSION_BADNESS;
2702 extern struct rank sum_ranks (struct rank a, struct rank b);
2703 extern int compare_ranks (struct rank a, struct rank b);
2705 extern int compare_badness (const badness_vector &,
2706 const badness_vector &);
2708 extern badness_vector rank_function (gdb::array_view<type *> parms,
2709 gdb::array_view<value *> args);
2711 extern struct rank rank_one_type (struct type *, struct type *,
2712 struct value *);
2714 extern void recursive_dump_type (struct type *, int);
2716 /* printcmd.c */
2718 extern void print_scalar_formatted (const gdb_byte *, struct type *,
2719 const struct value_print_options *,
2720 int, struct ui_file *);
2722 extern int can_dereference (struct type *);
2724 extern int is_integral_type (struct type *);
2726 extern int is_floating_type (struct type *);
2728 extern int is_scalar_type (struct type *type);
2730 extern int is_scalar_type_recursive (struct type *);
2732 extern int class_or_union_p (const struct type *);
2734 extern void maintenance_print_type (const char *, int);
2736 extern htab_up create_copied_types_hash ();
2738 extern struct type *copy_type_recursive (struct type *type,
2739 htab_t copied_types);
2741 extern struct type *copy_type (const struct type *type);
2743 extern bool types_equal (struct type *, struct type *);
2745 extern bool types_deeply_equal (struct type *, struct type *);
2747 extern int type_not_allocated (const struct type *type);
2749 extern int type_not_associated (const struct type *type);
2751 /* Return True if TYPE is a TYPE_CODE_FIXED_POINT or if TYPE is
2752 a range type whose base type is a TYPE_CODE_FIXED_POINT. */
2753 extern bool is_fixed_point_type (struct type *type);
2755 /* Allocate a fixed-point type info for TYPE. This should only be
2756 called by INIT_FIXED_POINT_SPECIFIC. */
2757 extern void allocate_fixed_point_type_info (struct type *type);
2759 /* * When the type includes explicit byte ordering, return that.
2760 Otherwise, the byte ordering from gdbarch_byte_order for
2761 the type's arch is returned. */
2763 extern enum bfd_endian type_byte_order (const struct type *type);
2765 /* A flag to enable printing of debugging information of C++
2766 overloading. */
2768 extern unsigned int overload_debug;
2770 /* Return whether the function type represented by TYPE is marked as unsafe
2771 to call by the debugger.
2773 This usually indicates that the function does not follow the target's
2774 standard calling convention. */
2776 extern bool is_nocall_function (const struct type *type);
2778 #endif /* GDBTYPES_H */