Add translations for various sub-directories
[binutils-gdb.git] / gdb / gdbtypes.h
blob8b00fec59a1883423ff10762296a1fa15913b8f0
1 /* Internal type definitions for GDB.
3 Copyright (C) 1992-2024 Free Software Foundation, Inc.
5 Contributed by Cygnus Support, using pieces from other GDB modules.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #ifndef GDB_GDBTYPES_H
23 #define GDB_GDBTYPES_H
25 /* * \page gdbtypes GDB Types
27 GDB represents all the different kinds of types in programming
28 languages using a common representation defined in gdbtypes.h.
30 The main data structure is main_type; it consists of a code (such
31 as #TYPE_CODE_ENUM for enumeration types), a number of
32 generally-useful fields such as the printable name, and finally a
33 field main_type::type_specific that is a union of info specific to
34 particular languages or other special cases (such as calling
35 convention).
37 The available type codes are defined in enum #type_code. The enum
38 includes codes both for types that are common across a variety
39 of languages, and for types that are language-specific.
41 Most accesses to type fields go through macros such as
42 #TYPE_CODE(thistype) and #TYPE_FN_FIELD_CONST(thisfn, n). These are
43 written such that they can be used as both rvalues and lvalues.
46 #include "gdbsupport/array-view.h"
47 #include <optional>
48 #include "gdbsupport/enum-flags.h"
49 #include "dwarf2.h"
50 #include "gdbsupport/gdb_obstack.h"
51 #include "gmp-utils.h"
52 #include "gdbsupport/unordered_map.h"
54 /* Forward declarations for prototypes. */
55 struct field;
56 struct block;
57 struct value_print_options;
58 struct language_defn;
59 struct dwarf2_per_cu_data;
60 struct dwarf2_per_objfile;
61 struct dwarf2_property_baton;
63 /* * Different kinds of data types are distinguished by the `code'
64 field. */
66 enum type_code
68 TYPE_CODE_UNDEF = 0, /**< Not used; catches errors */
70 #define OP(X) X,
71 #include "type-codes.def"
72 #undef OP
76 /* * Some bits for the type's instance_flags word. See the macros
77 below for documentation on each bit. */
79 enum type_instance_flag_value : unsigned
81 TYPE_INSTANCE_FLAG_CONST = (1 << 0),
82 TYPE_INSTANCE_FLAG_VOLATILE = (1 << 1),
83 TYPE_INSTANCE_FLAG_CODE_SPACE = (1 << 2),
84 TYPE_INSTANCE_FLAG_DATA_SPACE = (1 << 3),
85 TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 = (1 << 4),
86 TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2 = (1 << 5),
87 TYPE_INSTANCE_FLAG_NOTTEXT = (1 << 6),
88 TYPE_INSTANCE_FLAG_RESTRICT = (1 << 7),
89 TYPE_INSTANCE_FLAG_ATOMIC = (1 << 8)
92 DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags);
94 /* * Not textual. By default, GDB treats all single byte integers as
95 characters (or elements of strings) unless this flag is set. */
97 #define TYPE_NOTTEXT(t) (((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_NOTTEXT)
99 /* * Constant type. If this is set, the corresponding type has a
100 const modifier. */
102 #define TYPE_CONST(t) ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_CONST) != 0)
104 /* * Volatile type. If this is set, the corresponding type has a
105 volatile modifier. */
107 #define TYPE_VOLATILE(t) \
108 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_VOLATILE) != 0)
110 /* * Restrict type. If this is set, the corresponding type has a
111 restrict modifier. */
113 #define TYPE_RESTRICT(t) \
114 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_RESTRICT) != 0)
116 /* * Atomic type. If this is set, the corresponding type has an
117 _Atomic modifier. */
119 #define TYPE_ATOMIC(t) \
120 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_ATOMIC) != 0)
122 /* * True if this type represents either an lvalue or lvalue reference type. */
124 #define TYPE_IS_REFERENCE(t) \
125 ((t)->code () == TYPE_CODE_REF || (t)->code () == TYPE_CODE_RVALUE_REF)
127 /* * True if this type is allocatable. */
128 #define TYPE_IS_ALLOCATABLE(t) \
129 ((t)->dyn_prop (DYN_PROP_ALLOCATED) != NULL)
131 /* * True if this type has variant parts. */
132 #define TYPE_HAS_VARIANT_PARTS(t) \
133 ((t)->dyn_prop (DYN_PROP_VARIANT_PARTS) != nullptr)
135 /* * True if this type has a dynamic length. */
136 #define TYPE_HAS_DYNAMIC_LENGTH(t) \
137 ((t)->dyn_prop (DYN_PROP_BYTE_SIZE) != nullptr)
139 /* * Instruction-space delimited type. This is for Harvard architectures
140 which have separate instruction and data address spaces (and perhaps
141 others).
143 GDB usually defines a flat address space that is a superset of the
144 architecture's two (or more) address spaces, but this is an extension
145 of the architecture's model.
147 If TYPE_INSTANCE_FLAG_CODE_SPACE is set, an object of the corresponding type
148 resides in instruction memory, even if its address (in the extended
149 flat address space) does not reflect this.
151 Similarly, if TYPE_INSTANCE_FLAG_DATA_SPACE is set, then an object of the
152 corresponding type resides in the data memory space, even if
153 this is not indicated by its (flat address space) address.
155 If neither flag is set, the default space for functions / methods
156 is instruction space, and for data objects is data memory. */
158 #define TYPE_CODE_SPACE(t) \
159 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_CODE_SPACE) != 0)
161 #define TYPE_DATA_SPACE(t) \
162 ((((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_DATA_SPACE) != 0)
164 /* * Address class flags. Some environments provide for pointers
165 whose size is different from that of a normal pointer or address
166 types where the bits are interpreted differently than normal
167 addresses. The TYPE_INSTANCE_FLAG_ADDRESS_CLASS_n flags may be used in
168 target specific ways to represent these different types of address
169 classes. */
171 #define TYPE_ADDRESS_CLASS_1(t) (((t)->instance_flags ()) \
172 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
173 #define TYPE_ADDRESS_CLASS_2(t) (((t)->instance_flags ()) \
174 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2)
175 #define TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL \
176 (TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 | TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2)
177 #define TYPE_ADDRESS_CLASS_ALL(t) (((t)->instance_flags ()) \
178 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL)
180 /* * Information about a single discriminant. */
182 struct discriminant_range
184 /* * The range of values for the variant. This is an inclusive
185 range. */
186 ULONGEST low, high;
188 /* * Return true if VALUE is contained in this range. IS_UNSIGNED
189 is true if this should be an unsigned comparison; false for
190 signed. */
191 bool contains (ULONGEST value, bool is_unsigned) const
193 if (is_unsigned)
194 return value >= low && value <= high;
195 LONGEST valuel = (LONGEST) value;
196 return valuel >= (LONGEST) low && valuel <= (LONGEST) high;
200 struct variant_part;
202 /* * A single variant. A variant has a list of discriminant values.
203 When the discriminator matches one of these, the variant is
204 enabled. Each variant controls zero or more fields; and may also
205 control other variant parts as well. This struct corresponds to
206 DW_TAG_variant in DWARF. */
208 struct variant : allocate_on_obstack<variant>
210 /* * The discriminant ranges for this variant. */
211 gdb::array_view<discriminant_range> discriminants;
213 /* * The fields controlled by this variant. This is inclusive on
214 the low end and exclusive on the high end. A variant may not
215 control any fields, in which case the two values will be equal.
216 These are indexes into the type's array of fields. */
217 int first_field;
218 int last_field;
220 /* * Variant parts controlled by this variant. */
221 gdb::array_view<variant_part> parts;
223 /* * Return true if this is the default variant. The default
224 variant can be recognized because it has no associated
225 discriminants. */
226 bool is_default () const
228 return discriminants.empty ();
231 /* * Return true if this variant matches VALUE. IS_UNSIGNED is true
232 if this should be an unsigned comparison; false for signed. */
233 bool matches (ULONGEST value, bool is_unsigned) const;
236 /* * A variant part. Each variant part has an optional discriminant
237 and holds an array of variants. This struct corresponds to
238 DW_TAG_variant_part in DWARF. */
240 struct variant_part : allocate_on_obstack<variant_part>
242 /* * The index of the discriminant field in the outer type. This is
243 an index into the type's array of fields. If this is -1, there
244 is no discriminant, and only the default variant can be
245 considered to be selected. */
246 int discriminant_index;
248 /* * True if this discriminant is unsigned; false if signed. This
249 comes from the type of the discriminant. */
250 bool is_unsigned;
252 /* * The variants that are controlled by this variant part. Note
253 that these will always be sorted by field number. */
254 gdb::array_view<variant> variants;
258 enum dynamic_prop_kind
260 PROP_UNDEFINED, /* Not defined. */
261 PROP_CONST, /* Constant. */
262 PROP_ADDR_OFFSET, /* Address offset. */
263 PROP_LOCEXPR, /* Location expression. */
264 PROP_LOCLIST, /* Location list. */
265 PROP_VARIANT_PARTS, /* Variant parts. */
266 PROP_TYPE, /* Type. */
267 PROP_VARIABLE_NAME, /* Variable name. */
268 PROP_OPTIMIZED_OUT, /* Optimized out. */
271 union dynamic_prop_data
273 /* Storage for constant property. */
275 LONGEST const_val;
277 /* Storage for dynamic property. */
279 const dwarf2_property_baton *baton;
281 /* Storage of variant parts for a type. A type with variant parts
282 has all its fields "linearized" -- stored in a single field
283 array, just as if they had all been declared that way. The
284 variant parts are attached via a dynamic property, and then are
285 used to control which fields end up in the final type during
286 dynamic type resolution. */
288 const gdb::array_view<variant_part> *variant_parts;
290 /* Once a variant type is resolved, we may want to be able to go
291 from the resolved type to the original type. In this case we
292 rewrite the property's kind and set this field. */
294 struct type *original_type;
296 /* Name of a variable to look up; the variable holds the value of
297 this property. */
299 const char *variable_name;
302 /* * Used to store a dynamic property. */
304 struct dynamic_prop
306 dynamic_prop_kind kind () const
308 return m_kind;
311 void set_undefined ()
313 m_kind = PROP_UNDEFINED;
316 void set_optimized_out ()
318 m_kind = PROP_OPTIMIZED_OUT;
321 /* Return true if this property is "available", at least in theory
322 -- meaning it is neither undefined nor optimized out. */
323 bool is_available () const
325 return m_kind != PROP_UNDEFINED && m_kind != PROP_OPTIMIZED_OUT;
328 LONGEST const_val () const
330 gdb_assert (m_kind == PROP_CONST);
332 return m_data.const_val;
335 void set_const_val (LONGEST const_val)
337 m_kind = PROP_CONST;
338 m_data.const_val = const_val;
341 /* Return true if this property has a constant value, false
342 otherwise. */
343 bool is_constant () const
344 { return m_kind == PROP_CONST; }
346 const dwarf2_property_baton *baton () const
348 gdb_assert (m_kind == PROP_LOCEXPR
349 || m_kind == PROP_LOCLIST
350 || m_kind == PROP_ADDR_OFFSET);
352 return m_data.baton;
355 void set_locexpr (const dwarf2_property_baton *baton)
357 m_kind = PROP_LOCEXPR;
358 m_data.baton = baton;
361 void set_loclist (const dwarf2_property_baton *baton)
363 m_kind = PROP_LOCLIST;
364 m_data.baton = baton;
367 void set_addr_offset (const dwarf2_property_baton *baton)
369 m_kind = PROP_ADDR_OFFSET;
370 m_data.baton = baton;
373 const gdb::array_view<variant_part> *variant_parts () const
375 gdb_assert (m_kind == PROP_VARIANT_PARTS);
377 return m_data.variant_parts;
380 void set_variant_parts (gdb::array_view<variant_part> *variant_parts)
382 m_kind = PROP_VARIANT_PARTS;
383 m_data.variant_parts = variant_parts;
386 struct type *original_type () const
388 gdb_assert (m_kind == PROP_TYPE);
390 return m_data.original_type;
393 void set_original_type (struct type *original_type)
395 m_kind = PROP_TYPE;
396 m_data.original_type = original_type;
399 /* Return the name of the variable that holds this property's value.
400 Only valid for PROP_VARIABLE_NAME. */
401 const char *variable_name () const
403 gdb_assert (m_kind == PROP_VARIABLE_NAME);
404 return m_data.variable_name;
407 /* Set the name of the variable that holds this property's value,
408 and set this property to be of kind PROP_VARIABLE_NAME. */
409 void set_variable_name (const char *name)
411 m_kind = PROP_VARIABLE_NAME;
412 m_data.variable_name = name;
415 /* Determine which field of the union dynamic_prop.data is used. */
416 enum dynamic_prop_kind m_kind;
418 /* Storage for dynamic or static value. */
419 union dynamic_prop_data m_data;
422 /* Compare two dynamic_prop objects for equality. dynamic_prop
423 instances are equal iff they have the same type and storage. */
424 extern bool operator== (const dynamic_prop &l, const dynamic_prop &r);
426 /* Compare two dynamic_prop objects for inequality. */
427 static inline bool operator!= (const dynamic_prop &l, const dynamic_prop &r)
429 return !(l == r);
432 /* * Define a type's dynamic property node kind. */
433 enum dynamic_prop_node_kind
435 /* A property providing a type's data location.
436 Evaluating this field yields to the location of an object's data. */
437 DYN_PROP_DATA_LOCATION,
439 /* A property representing DW_AT_allocated. The presence of this attribute
440 indicates that the object of the type can be allocated/deallocated. */
441 DYN_PROP_ALLOCATED,
443 /* A property representing DW_AT_associated. The presence of this attribute
444 indicated that the object of the type can be associated. */
445 DYN_PROP_ASSOCIATED,
447 /* A property providing an array's byte stride. */
448 DYN_PROP_BYTE_STRIDE,
450 /* A property holding variant parts. */
451 DYN_PROP_VARIANT_PARTS,
453 /* A property representing DW_AT_rank. The presence of this attribute
454 indicates that the object is of assumed rank array type. */
455 DYN_PROP_RANK,
457 /* A property holding the size of the type. */
458 DYN_PROP_BYTE_SIZE,
461 /* * List for dynamic type attributes. */
462 struct dynamic_prop_list
464 /* The kind of dynamic prop in this node. */
465 enum dynamic_prop_node_kind prop_kind;
467 /* The dynamic property itself. */
468 struct dynamic_prop prop;
470 /* A pointer to the next dynamic property. */
471 struct dynamic_prop_list *next;
474 /* * Determine which field of the union main_type.fields[x].loc is
475 used. */
477 enum field_loc_kind
479 FIELD_LOC_KIND_BITPOS, /**< bitpos */
480 FIELD_LOC_KIND_ENUMVAL, /**< enumval */
481 FIELD_LOC_KIND_PHYSADDR, /**< physaddr */
482 FIELD_LOC_KIND_PHYSNAME, /**< physname */
483 FIELD_LOC_KIND_DWARF_BLOCK /**< dwarf_block */
486 /* * A discriminant to determine which field in the
487 main_type.type_specific union is being used, if any.
489 For types such as TYPE_CODE_FLT, the use of this
490 discriminant is really redundant, as we know from the type code
491 which field is going to be used. As such, it would be possible to
492 reduce the size of this enum in order to save a bit or two for
493 other fields of struct main_type. But, since we still have extra
494 room , and for the sake of clarity and consistency, we treat all fields
495 of the union the same way. */
497 enum type_specific_kind
499 TYPE_SPECIFIC_NONE,
500 TYPE_SPECIFIC_CPLUS_STUFF,
501 TYPE_SPECIFIC_GNAT_STUFF,
502 TYPE_SPECIFIC_FLOATFORMAT,
503 /* Note: This is used by TYPE_CODE_FUNC and TYPE_CODE_METHOD. */
504 TYPE_SPECIFIC_FUNC,
505 TYPE_SPECIFIC_SELF_TYPE,
506 TYPE_SPECIFIC_INT,
507 TYPE_SPECIFIC_FIXED_POINT,
510 union type_owner
512 struct objfile *objfile;
513 struct gdbarch *gdbarch;
516 union field_location
518 /* * Position of this field, counting in bits from start of
519 containing structure. For big-endian targets, it is the bit
520 offset to the MSB. For little-endian targets, it is the bit
521 offset to the LSB. */
523 LONGEST bitpos;
525 /* * Enum value. */
526 LONGEST enumval;
528 /* * For a static field, if TYPE_FIELD_STATIC_HAS_ADDR then
529 physaddr is the location (in the target) of the static
530 field. Otherwise, physname is the mangled label of the
531 static field. */
533 CORE_ADDR physaddr;
534 const char *physname;
536 /* * The field location can be computed by evaluating the
537 following DWARF block. Its DATA is allocated on
538 objfile_obstack - no CU load is needed to access it. */
540 struct dwarf2_locexpr_baton *dwarf_block;
543 /* Accessibility of a member. */
544 enum class accessibility : unsigned char
546 /* It's important that this be 0 so that fields default to
547 public. */
548 PUBLIC = 0,
549 PROTECTED = 1,
550 PRIVATE = 2,
553 struct field
555 struct type *type () const
557 return this->m_type;
560 void set_type (struct type *type)
562 this->m_type = type;
565 const char *name () const
567 return m_name;
570 void set_name (const char *name)
572 m_name = name;
575 bool is_artificial () const
577 return m_artificial;
580 void set_is_artificial (bool is_artificial)
582 m_artificial = is_artificial;
585 unsigned int bitsize () const
587 return m_bitsize;
590 void set_bitsize (unsigned int bitsize)
592 m_bitsize = bitsize;
595 bool is_packed () const
597 return m_bitsize != 0;
600 /* Return true if this field is static; false if not. */
601 bool is_static () const
603 /* "static" fields are the fields whose location is not relative
604 to the address of the enclosing struct. It would be nice to
605 have a dedicated flag that would be set for static fields when
606 the type is being created. But in practice, checking the field
607 loc_kind should give us an accurate answer. */
608 return (m_loc_kind == FIELD_LOC_KIND_PHYSNAME
609 || m_loc_kind == FIELD_LOC_KIND_PHYSADDR);
612 /* Location getters / setters. */
614 field_loc_kind loc_kind () const
616 return m_loc_kind;
619 LONGEST loc_bitpos () const
621 gdb_assert (m_loc_kind == FIELD_LOC_KIND_BITPOS);
622 return m_loc.bitpos;
625 void set_loc_bitpos (LONGEST bitpos)
627 m_loc_kind = FIELD_LOC_KIND_BITPOS;
628 m_loc.bitpos = bitpos;
631 LONGEST loc_enumval () const
633 gdb_assert (m_loc_kind == FIELD_LOC_KIND_ENUMVAL);
634 return m_loc.enumval;
637 void set_loc_enumval (LONGEST enumval)
639 m_loc_kind = FIELD_LOC_KIND_ENUMVAL;
640 m_loc.enumval = enumval;
643 CORE_ADDR loc_physaddr () const
645 gdb_assert (m_loc_kind == FIELD_LOC_KIND_PHYSADDR);
646 return m_loc.physaddr;
649 void set_loc_physaddr (CORE_ADDR physaddr)
651 m_loc_kind = FIELD_LOC_KIND_PHYSADDR;
652 m_loc.physaddr = physaddr;
655 const char *loc_physname () const
657 gdb_assert (m_loc_kind == FIELD_LOC_KIND_PHYSNAME);
658 return m_loc.physname;
661 void set_loc_physname (const char *physname)
663 m_loc_kind = FIELD_LOC_KIND_PHYSNAME;
664 m_loc.physname = physname;
667 dwarf2_locexpr_baton *loc_dwarf_block () const
669 gdb_assert (m_loc_kind == FIELD_LOC_KIND_DWARF_BLOCK);
670 return m_loc.dwarf_block;
673 void set_loc_dwarf_block (dwarf2_locexpr_baton *dwarf_block)
675 m_loc_kind = FIELD_LOC_KIND_DWARF_BLOCK;
676 m_loc.dwarf_block = dwarf_block;
679 /* Set the field's accessibility. */
680 void set_accessibility (accessibility acc)
681 { m_accessibility = acc; }
683 /* Fetch the field's accessibility. */
684 enum accessibility accessibility () const
685 { return m_accessibility; }
687 /* True if this field is 'public'. */
688 bool is_public () const
689 { return m_accessibility == accessibility::PUBLIC; }
691 /* True if this field is 'private'. */
692 bool is_private () const
693 { return m_accessibility == accessibility::PRIVATE; }
695 /* True if this field is 'protected'. */
696 bool is_protected () const
697 { return m_accessibility == accessibility::PROTECTED; }
699 /* True if this field is 'virtual'. */
700 bool is_virtual () const
701 { return m_virtual; }
703 /* Set the field's "virtual" flag. */
704 void set_virtual ()
705 { m_virtual = true; }
707 /* True if this field is 'ignored'. */
708 bool is_ignored () const
709 { return m_ignored; }
711 /* Set the field's "ignored" flag. Note that the 'ignored' bit is
712 deprecated. It was used by some unknown stabs generator, and has
713 been replaced by the optimized-out approach -- however, it
714 remains because the stabs reader was never updated. */
715 void set_ignored ()
716 { m_ignored = true; }
718 union field_location m_loc;
720 /* * For a function or member type, this is 1 if the argument is
721 marked artificial. Artificial arguments should not be shown
722 to the user. For TYPE_CODE_RANGE it is set if the specific
723 bound is not defined. */
725 unsigned int m_artificial : 1;
727 /* Whether the field is 'virtual'. */
728 bool m_virtual : 1;
729 /* Whether the field is 'ignored'. */
730 bool m_ignored : 1;
732 /* * Discriminant for union field_location. */
734 ENUM_BITFIELD(field_loc_kind) m_loc_kind : 3;
736 /* Accessibility of the field. */
737 enum accessibility m_accessibility;
739 /* * Size of this field, in bits, or zero if not packed.
740 If non-zero in an array type, indicates the element size in
741 bits (used only in Ada at the moment).
742 For an unpacked field, the field's type's length
743 says how many bytes the field occupies. */
745 unsigned int m_bitsize;
747 /* * In a struct or union type, type of this field.
748 - In a function or member type, type of this argument.
749 - In an array type, the domain-type of the array. */
751 struct type *m_type;
753 /* * Name of field, value or argument.
754 NULL for range bounds, array domains, and member function
755 arguments. */
757 const char *m_name;
760 struct range_bounds
762 ULONGEST bit_stride () const
764 if (this->flag_is_byte_stride)
765 return this->stride.const_val () * 8;
766 else
767 return this->stride.const_val ();
770 /* Return true if either bounds is optimized out. */
771 bool optimized_out () const
773 return (low.kind () == PROP_OPTIMIZED_OUT
774 || high.kind () == PROP_OPTIMIZED_OUT);
777 /* * Low bound of range. */
779 struct dynamic_prop low;
781 /* * High bound of range. */
783 struct dynamic_prop high;
785 /* The stride value for this range. This can be stored in bits or bytes
786 based on the value of BYTE_STRIDE_P. It is optional to have a stride
787 value, if this range has no stride value defined then this will be set
788 to the constant zero. */
790 struct dynamic_prop stride;
792 /* * The bias. Sometimes a range value is biased before storage.
793 The bias is added to the stored bits to form the true value. */
795 LONGEST bias;
797 /* True if HIGH range bound contains the number of elements in the
798 subrange. This affects how the final high bound is computed. */
800 unsigned int flag_upper_bound_is_count : 1;
802 /* True if LOW or/and HIGH are resolved into a static bound from
803 a dynamic one. */
805 unsigned int flag_bound_evaluated : 1;
807 /* If this is true this STRIDE is in bytes, otherwise STRIDE is in bits. */
809 unsigned int flag_is_byte_stride : 1;
812 /* Compare two range_bounds objects for equality. Simply does
813 memberwise comparison. */
814 extern bool operator== (const range_bounds &l, const range_bounds &r);
816 /* Compare two range_bounds objects for inequality. */
817 static inline bool operator!= (const range_bounds &l, const range_bounds &r)
819 return !(l == r);
822 union type_specific
824 /* * CPLUS_STUFF is for TYPE_CODE_STRUCT. It is initialized to
825 point to cplus_struct_default, a default static instance of a
826 struct cplus_struct_type. */
828 struct cplus_struct_type *cplus_stuff;
830 /* * GNAT_STUFF is for types for which the GNAT Ada compiler
831 provides additional information. */
833 struct gnat_aux_type *gnat_stuff;
835 /* * FLOATFORMAT is for TYPE_CODE_FLT. It is a pointer to a
836 floatformat object that describes the floating-point value
837 that resides within the type. */
839 const struct floatformat *floatformat;
841 /* * For TYPE_CODE_FUNC and TYPE_CODE_METHOD types. */
843 struct func_type *func_stuff;
845 /* * For types that are pointer to member types (TYPE_CODE_METHODPTR,
846 TYPE_CODE_MEMBERPTR), SELF_TYPE is the type that this pointer
847 is a member of. */
849 struct type *self_type;
851 /* * For TYPE_CODE_FIXED_POINT types, the info necessary to decode
852 values of that type. */
853 struct fixed_point_type_info *fixed_point_info;
855 /* * An integer-like scalar type may be stored in just part of its
856 enclosing storage bytes. This structure describes this
857 situation. */
858 struct
860 /* * The bit size of the integer. This can be 0. For integers
861 that fill their storage (the ordinary case), this field holds
862 the byte size times 8. */
863 unsigned short bit_size;
864 /* * The bit offset of the integer. This is ordinarily 0, and can
865 only be non-zero if the bit size is less than the storage
866 size. */
867 unsigned short bit_offset;
868 } int_stuff;
871 /* * Main structure representing a type in GDB.
873 This structure is space-critical. Its layout has been tweaked to
874 reduce the space used. */
876 struct main_type
878 /* * Code for kind of type. */
880 ENUM_BITFIELD(type_code) code : 8;
882 /* * Flags about this type. These fields appear at this location
883 because they packs nicely here. See the TYPE_* macros for
884 documentation about these fields. */
886 unsigned int m_flag_unsigned : 1;
887 unsigned int m_flag_nosign : 1;
888 unsigned int m_flag_stub : 1;
889 unsigned int m_flag_target_stub : 1;
890 unsigned int m_flag_prototyped : 1;
891 unsigned int m_flag_varargs : 1;
892 unsigned int m_flag_vector : 1;
893 unsigned int m_flag_stub_supported : 1;
894 unsigned int m_flag_gnu_ifunc : 1;
895 unsigned int m_flag_fixed_instance : 1;
896 unsigned int m_flag_objfile_owned : 1;
897 unsigned int m_flag_endianity_not_default : 1;
899 /* * True if this type was declared with "class" rather than
900 "struct". */
902 unsigned int m_flag_declared_class : 1;
904 /* * True if this is an enum type with disjoint values. This
905 affects how the enum is printed. */
907 unsigned int m_flag_flag_enum : 1;
909 /* * For TYPE_CODE_ARRAY, this is true if this type is part of a
910 multi-dimensional array. Multi-dimensional arrays are
911 represented internally as arrays of arrays, and this flag lets
912 gdb distinguish between multiple dimensions and an ordinary array
913 of arrays. The flag is set on each inner dimension, but not the
914 outermost dimension. */
916 unsigned int m_multi_dimensional : 1;
918 /* * A discriminant telling us which field of the type_specific
919 union is being used for this type, if any. */
921 ENUM_BITFIELD(type_specific_kind) type_specific_field : 3;
923 /* The language for this type. */
925 ENUM_BITFIELD(language) m_lang : LANGUAGE_BITS;
927 /* * Number of fields described for this type. This field appears
928 at this location because it packs nicely here. */
930 unsigned int m_nfields;
932 /* * Name of this type, or NULL if none.
934 This is used for printing only. For looking up a name, look for
935 a symbol in the VAR_DOMAIN. This is generally allocated in the
936 objfile's obstack. However coffread.c uses malloc. */
938 const char *name;
940 /* * Every type is now associated with a particular objfile, and the
941 type is allocated on the objfile_obstack for that objfile. One
942 problem however, is that there are times when gdb allocates new
943 types while it is not in the process of reading symbols from a
944 particular objfile. Fortunately, these happen when the type
945 being created is a derived type of an existing type, such as in
946 lookup_pointer_type(). So we can just allocate the new type
947 using the same objfile as the existing type, but to do this we
948 need a backpointer to the objfile from the existing type. Yes
949 this is somewhat ugly, but without major overhaul of the internal
950 type system, it can't be avoided for now. */
952 union type_owner m_owner;
954 /* * For a pointer type, describes the type of object pointed to.
955 - For an array type, describes the type of the elements.
956 - For a function or method type, describes the type of the return value.
957 - For a range type, describes the type of the full range.
958 - For a complex type, describes the type of each coordinate.
959 - For a special record or union type encoding a dynamic-sized type
960 in GNAT, a memoized pointer to a corresponding static version of
961 the type.
962 - Unused otherwise. */
964 struct type *m_target_type;
966 /* * For structure and union types, a description of each field.
967 For set and pascal array types, there is one "field",
968 whose type is the domain type of the set or array.
969 For range types, there are two "fields",
970 the minimum and maximum values (both inclusive).
971 For enum types, each possible value is described by one "field".
972 For a function or method type, a "field" for each parameter.
973 For C++ classes, there is one field for each base class (if it is
974 a derived class) plus one field for each class data member. Member
975 functions are recorded elsewhere.
977 Using a pointer to a separate array of fields
978 allows all types to have the same size, which is useful
979 because we can allocate the space for a type before
980 we know what to put in it. */
982 union
984 struct field *fields;
986 /* * Union member used for range types. */
988 struct range_bounds *bounds;
990 /* If this is a scalar type, then this is its corresponding
991 complex type. */
992 struct type *complex_type;
994 } flds_bnds;
996 /* * Slot to point to additional language-specific fields of this
997 type. */
999 union type_specific type_specific;
1001 /* * Contains all dynamic type properties. */
1002 struct dynamic_prop_list *dyn_prop_list;
1005 /* * Number of bits allocated for alignment. */
1007 #define TYPE_ALIGN_BITS 8
1009 /* * A ``struct type'' describes a particular instance of a type, with
1010 some particular qualification. */
1012 struct type
1014 /* Get the type code of this type.
1016 Note that the code can be TYPE_CODE_TYPEDEF, so if you want the real
1017 type, you need to do `check_typedef (type)->code ()`. */
1018 type_code code () const
1020 return this->main_type->code;
1023 /* Set the type code of this type. */
1024 void set_code (type_code code)
1026 this->main_type->code = code;
1029 /* Get the name of this type. */
1030 const char *name () const
1032 return this->main_type->name;
1035 /* Set the name of this type. */
1036 void set_name (const char *name)
1038 this->main_type->name = name;
1041 /* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
1042 But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
1043 so you only have to call check_typedef once. Since value::allocate
1044 calls check_typedef, X->type ()->length () is safe. */
1045 ULONGEST length () const
1047 return this->m_length;
1050 void set_length (ULONGEST length)
1052 this->m_length = length;
1055 /* Get the number of fields of this type. */
1056 unsigned int num_fields () const
1058 return this->main_type->m_nfields;
1061 /* Set the number of fields of this type. */
1062 void set_num_fields (unsigned int num_fields)
1064 this->main_type->m_nfields = num_fields;
1067 /* Get the fields array of this type. */
1068 struct field *fields () const
1070 return this->main_type->flds_bnds.fields;
1073 /* Get the field at index IDX. */
1074 struct field &field (int idx) const
1076 gdb_assert (idx >= 0 && idx < num_fields ());
1077 return this->fields ()[idx];
1080 /* Set the fields array of this type. */
1081 void set_fields (struct field *fields)
1083 this->main_type->flds_bnds.fields = fields;
1086 /* Allocate the fields array of this type, with NFIELDS elements. If INIT,
1087 zero-initialize the allocated memory. */
1088 void alloc_fields (unsigned int nfields, bool init = true);
1090 /* Allocate the fields array of this type, and copy the fields from SRC. */
1091 void copy_fields (struct type *src);
1092 void copy_fields (std::vector<struct field> &src);
1094 type *index_type () const
1096 return this->field (0).type ();
1099 struct type *target_type () const
1101 return this->main_type->m_target_type;
1104 void set_target_type (struct type *target_type)
1106 this->main_type->m_target_type = target_type;
1109 void set_index_type (type *index_type)
1111 this->field (0).set_type (index_type);
1114 /* Return the instance flags converted to the correct type. */
1115 const type_instance_flags instance_flags () const
1117 return (enum type_instance_flag_value) this->m_instance_flags;
1120 /* Set the instance flags. */
1121 void set_instance_flags (type_instance_flags flags)
1123 this->m_instance_flags = flags;
1126 /* Get the bounds bounds of this type. The type must be a range type. */
1127 range_bounds *bounds () const
1129 switch (this->code ())
1131 case TYPE_CODE_RANGE:
1132 return this->main_type->flds_bnds.bounds;
1134 case TYPE_CODE_ARRAY:
1135 case TYPE_CODE_STRING:
1136 return this->index_type ()->bounds ();
1138 default:
1139 gdb_assert_not_reached
1140 ("type::bounds called on type with invalid code");
1144 /* Set the bounds of this type. The type must be a range type. */
1145 void set_bounds (range_bounds *bounds)
1147 gdb_assert (this->code () == TYPE_CODE_RANGE);
1149 this->main_type->flds_bnds.bounds = bounds;
1152 /* Return true if this type's bounds were optimized out. */
1153 bool bound_optimized_out () const
1155 return bounds ()->optimized_out ();
1158 ULONGEST bit_stride () const
1160 if (this->code () == TYPE_CODE_ARRAY && this->field (0).bitsize () != 0)
1161 return this->field (0).bitsize ();
1162 return this->bounds ()->bit_stride ();
1165 /* Unsigned integer type. If this is not set for a TYPE_CODE_INT,
1166 the type is signed (unless TYPE_NOSIGN is set). */
1168 bool is_unsigned () const
1170 return this->main_type->m_flag_unsigned;
1173 void set_is_unsigned (bool is_unsigned)
1175 this->main_type->m_flag_unsigned = is_unsigned;
1178 /* No sign for this type. In C++, "char", "signed char", and
1179 "unsigned char" are distinct types; so we need an extra flag to
1180 indicate the absence of a sign! */
1182 bool has_no_signedness () const
1184 return this->main_type->m_flag_nosign;
1187 void set_has_no_signedness (bool has_no_signedness)
1189 this->main_type->m_flag_nosign = has_no_signedness;
1192 /* This appears in a type's flags word if it is a stub type (e.g.,
1193 if someone referenced a type that wasn't defined in a source file
1194 via (struct sir_not_appearing_in_this_film *)). */
1196 bool is_stub () const
1198 return this->main_type->m_flag_stub;
1201 void set_is_stub (bool is_stub)
1203 this->main_type->m_flag_stub = is_stub;
1206 /* The target type of this type is a stub type, and this type needs
1207 to be updated if it gets un-stubbed in check_typedef. Used for
1208 arrays and ranges, in which TYPE_LENGTH of the array/range gets set
1209 based on the TYPE_LENGTH of the target type. Also, set for
1210 TYPE_CODE_TYPEDEF. */
1212 bool target_is_stub () const
1214 return this->main_type->m_flag_target_stub;
1217 void set_target_is_stub (bool target_is_stub)
1219 this->main_type->m_flag_target_stub = target_is_stub;
1222 /* This is a function type which appears to have a prototype. We
1223 need this for function calls in order to tell us if it's necessary
1224 to coerce the args, or to just do the standard conversions. This
1225 is used with a short field. */
1227 bool is_prototyped () const
1229 return this->main_type->m_flag_prototyped;
1232 void set_is_prototyped (bool is_prototyped)
1234 this->main_type->m_flag_prototyped = is_prototyped;
1237 /* FIXME drow/2002-06-03: Only used for methods, but applies as well
1238 to functions. */
1240 bool has_varargs () const
1242 return this->main_type->m_flag_varargs;
1245 void set_has_varargs (bool has_varargs)
1247 this->main_type->m_flag_varargs = has_varargs;
1250 /* Identify a vector type. Gcc is handling this by adding an extra
1251 attribute to the array type. We slurp that in as a new flag of a
1252 type. This is used only in dwarf2read.c. */
1254 bool is_vector () const
1256 return this->main_type->m_flag_vector;
1259 void set_is_vector (bool is_vector)
1261 this->main_type->m_flag_vector = is_vector;
1264 /* This debug target supports TYPE_STUB(t). In the unsupported case
1265 we have to rely on NFIELDS to be zero etc., see TYPE_IS_OPAQUE().
1266 TYPE_STUB(t) with !TYPE_STUB_SUPPORTED(t) may exist if we only
1267 guessed the TYPE_STUB(t) value (see dwarfread.c). */
1269 bool stub_is_supported () const
1271 return this->main_type->m_flag_stub_supported;
1274 void set_stub_is_supported (bool stub_is_supported)
1276 this->main_type->m_flag_stub_supported = stub_is_supported;
1279 /* Used only for TYPE_CODE_FUNC where it specifies the real function
1280 address is returned by this function call. The target_type method
1281 determines the final returned function type to be presented to
1282 user. */
1284 bool is_gnu_ifunc () const
1286 return this->main_type->m_flag_gnu_ifunc;
1289 void set_is_gnu_ifunc (bool is_gnu_ifunc)
1291 this->main_type->m_flag_gnu_ifunc = is_gnu_ifunc;
1294 /* The debugging formats (especially STABS) do not contain enough
1295 information to represent all Ada types---especially those whose
1296 size depends on dynamic quantities. Therefore, the GNAT Ada
1297 compiler includes extra information in the form of additional type
1298 definitions connected by naming conventions. This flag indicates
1299 that the type is an ordinary (unencoded) GDB type that has been
1300 created from the necessary run-time information, and does not need
1301 further interpretation. Optionally marks ordinary, fixed-size GDB
1302 type. */
1304 bool is_fixed_instance () const
1306 return this->main_type->m_flag_fixed_instance;
1309 void set_is_fixed_instance (bool is_fixed_instance)
1311 this->main_type->m_flag_fixed_instance = is_fixed_instance;
1314 /* A compiler may supply dwarf instrumentation that indicates the desired
1315 endian interpretation of the variable differs from the native endian
1316 representation. */
1318 bool endianity_is_not_default () const
1320 return this->main_type->m_flag_endianity_not_default;
1323 void set_endianity_is_not_default (bool endianity_is_not_default)
1325 this->main_type->m_flag_endianity_not_default = endianity_is_not_default;
1329 /* True if this type was declared using the "class" keyword. This is
1330 only valid for C++ structure and enum types. If false, a structure
1331 was declared as a "struct"; if true it was declared "class". For
1332 enum types, this is true when "enum class" or "enum struct" was
1333 used to declare the type. */
1335 bool is_declared_class () const
1337 return this->main_type->m_flag_declared_class;
1340 void set_is_declared_class (bool is_declared_class) const
1342 this->main_type->m_flag_declared_class = is_declared_class;
1345 /* True if this type is a "flag" enum. A flag enum is one where all
1346 the values are pairwise disjoint when "and"ed together. This
1347 affects how enum values are printed. */
1349 bool is_flag_enum () const
1351 return this->main_type->m_flag_flag_enum;
1354 void set_is_flag_enum (bool is_flag_enum)
1356 this->main_type->m_flag_flag_enum = is_flag_enum;
1359 /* True if this array type is part of a multi-dimensional array. */
1361 bool is_multi_dimensional () const
1363 return this->main_type->m_multi_dimensional;
1366 void set_is_multi_dimensional (bool value)
1368 this->main_type->m_multi_dimensional = value;
1371 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return a reference
1372 to this type's fixed_point_info. */
1374 struct fixed_point_type_info &fixed_point_info () const
1376 gdb_assert (this->code () == TYPE_CODE_FIXED_POINT);
1377 gdb_assert (this->main_type->type_specific.fixed_point_info != nullptr);
1379 return *this->main_type->type_specific.fixed_point_info;
1382 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, set this type's
1383 fixed_point_info to INFO. */
1385 void set_fixed_point_info (struct fixed_point_type_info *info) const
1387 gdb_assert (this->code () == TYPE_CODE_FIXED_POINT);
1389 this->main_type->type_specific.fixed_point_info = info;
1392 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return its base type.
1394 In other words, this returns the type after having peeled all
1395 intermediate type layers (such as TYPE_CODE_RANGE, for instance).
1396 The TYPE_CODE of the type returned is guaranteed to be
1397 a TYPE_CODE_FIXED_POINT. */
1399 struct type *fixed_point_type_base_type ();
1401 /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return its scaling
1402 factor. */
1404 const gdb_mpq &fixed_point_scaling_factor ();
1406 /* * Return the dynamic property of the requested KIND from this type's
1407 list of dynamic properties. */
1408 dynamic_prop *dyn_prop (dynamic_prop_node_kind kind) const;
1410 /* * Given a dynamic property PROP of a given KIND, add this dynamic
1411 property to this type.
1413 This function assumes that this type is objfile-owned. */
1414 void add_dyn_prop (dynamic_prop_node_kind kind, dynamic_prop prop);
1416 /* * Remove dynamic property of kind KIND from this type, if it exists. */
1417 void remove_dyn_prop (dynamic_prop_node_kind kind);
1419 /* Return true if this type is owned by an objfile. Return false if it is
1420 owned by an architecture. */
1421 bool is_objfile_owned () const
1423 return this->main_type->m_flag_objfile_owned;
1426 /* Set the owner of the type to be OBJFILE. */
1427 void set_owner (objfile *objfile)
1429 gdb_assert (objfile != nullptr);
1431 this->main_type->m_owner.objfile = objfile;
1432 this->main_type->m_flag_objfile_owned = true;
1435 /* Set the owner of the type to be ARCH. */
1436 void set_owner (gdbarch *arch)
1438 gdb_assert (arch != nullptr);
1440 this->main_type->m_owner.gdbarch = arch;
1441 this->main_type->m_flag_objfile_owned = false;
1444 /* Return the objfile owner of this type.
1446 Return nullptr if this type is not objfile-owned. */
1447 struct objfile *objfile_owner () const
1449 if (!this->is_objfile_owned ())
1450 return nullptr;
1452 return this->main_type->m_owner.objfile;
1455 /* Return the gdbarch owner of this type.
1457 Return nullptr if this type is not gdbarch-owned. */
1458 gdbarch *arch_owner () const
1460 if (this->is_objfile_owned ())
1461 return nullptr;
1463 return this->main_type->m_owner.gdbarch;
1466 /* Return the type's architecture. For types owned by an
1467 architecture, that architecture is returned. For types owned by an
1468 objfile, that objfile's architecture is returned.
1470 The return value is always non-nullptr. */
1471 gdbarch *arch () const;
1473 /* * Return true if this is an integer type whose logical (bit) size
1474 differs from its storage size; false otherwise. Always return
1475 false for non-integer (i.e., non-TYPE_SPECIFIC_INT) types. */
1476 bool bit_size_differs_p () const
1478 return (main_type->type_specific_field == TYPE_SPECIFIC_INT
1479 && main_type->type_specific.int_stuff.bit_size != 8 * length ());
1482 /* * Return the logical (bit) size for this integer type. Only
1483 valid for integer (TYPE_SPECIFIC_INT) types. */
1484 unsigned short bit_size () const
1486 gdb_assert (main_type->type_specific_field == TYPE_SPECIFIC_INT);
1487 return main_type->type_specific.int_stuff.bit_size;
1490 /* * Return the bit offset for this integer type. Only valid for
1491 integer (TYPE_SPECIFIC_INT) types. */
1492 unsigned short bit_offset () const
1494 gdb_assert (main_type->type_specific_field == TYPE_SPECIFIC_INT);
1495 return main_type->type_specific.int_stuff.bit_offset;
1498 /* Return true if this is a pointer or reference type. */
1499 bool is_pointer_or_reference () const
1501 return this->code () == TYPE_CODE_PTR || TYPE_IS_REFERENCE (this);
1504 /* Return true if this type is "string-like", according to its
1505 defining language. */
1506 bool is_string_like ();
1508 /* Return true if this type is "array-like". This includes arrays,
1509 but also some forms of structure type that are recognized as
1510 representations of arrays by the type's language. */
1511 bool is_array_like ();
1513 /* Return the language that this type came from. */
1514 enum language language () const
1515 { return main_type->m_lang; }
1517 /* * Type that is a pointer to this type.
1518 NULL if no such pointer-to type is known yet.
1519 The debugger may add the address of such a type
1520 if it has to construct one later. */
1522 struct type *pointer_type;
1524 /* * C++: also need a reference type. */
1526 struct type *reference_type;
1528 /* * A C++ rvalue reference type added in C++11. */
1530 struct type *rvalue_reference_type;
1532 /* * Variant chain. This points to a type that differs from this
1533 one only in qualifiers and length. Currently, the possible
1534 qualifiers are const, volatile, code-space, data-space, and
1535 address class. The length may differ only when one of the
1536 address class flags are set. The variants are linked in a
1537 circular ring and share MAIN_TYPE. */
1539 struct type *chain;
1541 /* * The alignment for this type. Zero means that the alignment was
1542 not specified in the debug info. Note that this is stored in a
1543 funny way: as the log base 2 (plus 1) of the alignment; so a
1544 value of 1 means the alignment is 1, and a value of 9 means the
1545 alignment is 256. */
1547 unsigned align_log2 : TYPE_ALIGN_BITS;
1549 /* * Flags specific to this instance of the type, indicating where
1550 on the ring we are.
1552 For TYPE_CODE_TYPEDEF the flags of the typedef type should be
1553 binary or-ed with the target type, with a special case for
1554 address class and space class. For example if this typedef does
1555 not specify any new qualifiers, TYPE_INSTANCE_FLAGS is 0 and the
1556 instance flags are completely inherited from the target type. No
1557 qualifiers can be cleared by the typedef. See also
1558 check_typedef. */
1559 unsigned m_instance_flags : 9;
1561 /* * Length of storage for a value of this type. The value is the
1562 expression in host bytes of what sizeof(type) would return. This
1563 size includes padding. For example, an i386 extended-precision
1564 floating point value really only occupies ten bytes, but most
1565 ABI's declare its size to be 12 bytes, to preserve alignment.
1566 A `struct type' representing such a floating-point type would
1567 have a `length' value of 12, even though the last two bytes are
1568 unused.
1570 Since this field is expressed in host bytes, its value is appropriate
1571 to pass to memcpy and such (it is assumed that GDB itself always runs
1572 on an 8-bits addressable architecture). However, when using it for
1573 target address arithmetic (e.g. adding it to a target address), the
1574 type_length_units function should be used in order to get the length
1575 expressed in target addressable memory units. */
1577 ULONGEST m_length;
1579 /* * Core type, shared by a group of qualified types. */
1581 struct main_type *main_type;
1584 struct fn_fieldlist
1587 /* * The overloaded name.
1588 This is generally allocated in the objfile's obstack.
1589 However stabsread.c sometimes uses malloc. */
1591 const char *name;
1593 /* * The number of methods with this name. */
1595 int length;
1597 /* * The list of methods. */
1599 struct fn_field *fn_fields;
1604 struct fn_field
1606 /* * If is_stub is clear, this is the mangled name which we can look
1607 up to find the address of the method (FIXME: it would be cleaner
1608 to have a pointer to the struct symbol here instead).
1610 If is_stub is set, this is the portion of the mangled name which
1611 specifies the arguments. For example, "ii", if there are two int
1612 arguments, or "" if there are no arguments. See gdb_mangle_name
1613 for the conversion from this format to the one used if is_stub is
1614 clear. */
1616 const char *physname;
1618 /* * The function type for the method.
1620 (This comment used to say "The return value of the method", but
1621 that's wrong. The function type is expected here, i.e. something
1622 with TYPE_CODE_METHOD, and *not* the return-value type). */
1624 struct type *type;
1626 /* * For virtual functions. First baseclass that defines this
1627 virtual function. */
1629 struct type *fcontext;
1631 /* Attributes. */
1633 unsigned int is_const:1;
1634 unsigned int is_volatile:1;
1635 unsigned int is_artificial:1;
1637 /* * A stub method only has some fields valid (but they are enough
1638 to reconstruct the rest of the fields). */
1640 unsigned int is_stub:1;
1642 /* * True if this function is a constructor, false otherwise. */
1644 unsigned int is_constructor : 1;
1646 /* * True if this function is deleted, false otherwise. */
1648 unsigned int is_deleted : 1;
1650 /* * DW_AT_defaulted attribute for this function. The value is one
1651 of the DW_DEFAULTED constants. */
1653 ENUM_BITFIELD (dwarf_defaulted_attribute) defaulted : 2;
1655 /* Accessibility of the field. */
1656 enum accessibility accessibility;
1658 /* * Index into that baseclass's virtual function table, minus 2;
1659 else if static: VOFFSET_STATIC; else: 0. */
1661 unsigned int voffset:16;
1663 #define VOFFSET_STATIC 1
1667 struct decl_field
1669 /* * Unqualified name to be prefixed by owning class qualified
1670 name. */
1672 const char *name;
1674 /* * Type this typedef named NAME represents. */
1676 struct type *type;
1678 /* Accessibility of the field. */
1679 enum accessibility accessibility;
1682 /* * C++ language-specific information for TYPE_CODE_STRUCT and
1683 TYPE_CODE_UNION nodes. */
1685 struct cplus_struct_type
1687 /* * Number of base classes this type derives from. The
1688 baseclasses are stored in the first N_BASECLASSES fields
1689 (i.e. the `fields' field of the struct type). The only fields
1690 of struct field that are used are: type, name, loc.bitpos. */
1692 short n_baseclasses;
1694 /* * Field number of the virtual function table pointer in VPTR_BASETYPE.
1695 All access to this field must be through TYPE_VPTR_FIELDNO as one
1696 thing it does is check whether the field has been initialized.
1697 Initially TYPE_RAW_CPLUS_SPECIFIC has the value of cplus_struct_default,
1698 which for portability reasons doesn't initialize this field.
1699 TYPE_VPTR_FIELDNO returns -1 for this case.
1701 If -1, we were unable to find the virtual function table pointer in
1702 initial symbol reading, and get_vptr_fieldno should be called to find
1703 it if possible. get_vptr_fieldno will update this field if possible.
1704 Otherwise the value is left at -1.
1706 Unused if this type does not have virtual functions. */
1708 short vptr_fieldno;
1710 /* * Number of methods with unique names. All overloaded methods
1711 with the same name count only once. */
1713 short nfn_fields;
1715 /* * Number of template arguments. */
1717 unsigned short n_template_arguments;
1719 /* * One if this struct is a dynamic class, as defined by the
1720 Itanium C++ ABI: if it requires a virtual table pointer,
1721 because it or any of its base classes have one or more virtual
1722 member functions or virtual base classes. Minus one if not
1723 dynamic. Zero if not yet computed. */
1725 int is_dynamic : 2;
1727 /* * The calling convention for this type, fetched from the
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 /* * The base class which defined the virtual function table pointer. */
1735 struct type *vptr_basetype;
1737 /* * For classes, structures, and unions, a description of each
1738 field, which consists of an overloaded name, followed by the
1739 types of arguments that the method expects, and then the name
1740 after it has been renamed to make it distinct.
1742 fn_fieldlists points to an array of nfn_fields of these. */
1744 struct fn_fieldlist *fn_fieldlists;
1746 /* * typedefs defined inside this class. typedef_field points to
1747 an array of typedef_field_count elements. */
1749 struct decl_field *typedef_field;
1751 unsigned typedef_field_count;
1753 /* * The nested types defined by this type. nested_types points to
1754 an array of nested_types_count elements. */
1756 struct decl_field *nested_types;
1758 unsigned nested_types_count;
1760 /* * The template arguments. This is an array with
1761 N_TEMPLATE_ARGUMENTS elements. This is NULL for non-template
1762 classes. */
1764 struct symbol **template_arguments;
1767 /* * Struct used to store conversion rankings. */
1769 struct rank
1771 short rank;
1773 /* * When two conversions are of the same type and therefore have
1774 the same rank, subrank is used to differentiate the two.
1776 Eg: Two derived-class-pointer to base-class-pointer conversions
1777 would both have base pointer conversion rank, but the
1778 conversion with the shorter distance to the ancestor is
1779 preferable. 'subrank' would be used to reflect that. */
1781 short subrank;
1784 /* * Used for ranking a function for overload resolution. */
1786 typedef std::vector<rank> badness_vector;
1788 /* * GNAT Ada-specific information for various Ada types. */
1790 struct gnat_aux_type
1792 /* * Parallel type used to encode information about dynamic types
1793 used in Ada (such as variant records, variable-size array,
1794 etc). */
1795 struct type* descriptive_type;
1798 /* * For TYPE_CODE_FUNC and TYPE_CODE_METHOD types. */
1800 struct func_type
1802 /* * The calling convention for targets supporting multiple ABIs.
1803 Right now this is only fetched from the Dwarf-2
1804 DW_AT_calling_convention attribute. The value is one of the
1805 DW_CC constants. */
1807 ENUM_BITFIELD (dwarf_calling_convention) calling_convention : 8;
1809 /* * Whether this function normally returns to its caller. It is
1810 set from the DW_AT_noreturn attribute if set on the
1811 DW_TAG_subprogram. */
1813 unsigned int is_noreturn : 1;
1815 /* * Only those DW_TAG_call_site's in this function that have
1816 DW_AT_call_tail_call set are linked in this list. Function
1817 without its tail call list complete
1818 (DW_AT_call_all_tail_calls or its superset
1819 DW_AT_call_all_calls) has TAIL_CALL_LIST NULL, even if some
1820 DW_TAG_call_site's exist in such function. */
1822 struct call_site *tail_call_list;
1824 /* * For method types (TYPE_CODE_METHOD), the aggregate type that
1825 contains the method. */
1827 struct type *self_type;
1830 /* The type-specific info for TYPE_CODE_FIXED_POINT types. */
1832 struct fixed_point_type_info
1834 /* The fixed point type's scaling factor. */
1835 gdb_mpq scaling_factor;
1838 /* * The default value of TYPE_CPLUS_SPECIFIC(T) points to this shared
1839 static structure. */
1841 extern const struct cplus_struct_type cplus_struct_default;
1843 extern void allocate_cplus_struct_type (struct type *);
1845 #define INIT_CPLUS_SPECIFIC(type) \
1846 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_CPLUS_STUFF, \
1847 TYPE_RAW_CPLUS_SPECIFIC (type) = (struct cplus_struct_type*) \
1848 &cplus_struct_default)
1850 #define ALLOCATE_CPLUS_STRUCT_TYPE(type) allocate_cplus_struct_type (type)
1852 #define HAVE_CPLUS_STRUCT(type) \
1853 (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_CPLUS_STUFF \
1854 && TYPE_RAW_CPLUS_SPECIFIC (type) != &cplus_struct_default)
1856 #define INIT_NONE_SPECIFIC(type) \
1857 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_NONE, \
1858 TYPE_MAIN_TYPE (type)->type_specific = {})
1860 extern const struct gnat_aux_type gnat_aux_default;
1862 extern void allocate_gnat_aux_type (struct type *);
1864 #define INIT_GNAT_SPECIFIC(type) \
1865 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_GNAT_STUFF, \
1866 TYPE_GNAT_SPECIFIC (type) = (struct gnat_aux_type *) &gnat_aux_default)
1867 #define ALLOCATE_GNAT_AUX_TYPE(type) allocate_gnat_aux_type (type)
1868 /* * A macro that returns non-zero if the type-specific data should be
1869 read as "gnat-stuff". */
1870 #define HAVE_GNAT_AUX_INFO(type) \
1871 (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_GNAT_STUFF)
1873 /* * True if TYPE is known to be an Ada type of some kind. */
1874 #define ADA_TYPE_P(type) \
1875 (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_GNAT_STUFF \
1876 || (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_NONE \
1877 && (type)->is_fixed_instance ()))
1879 #define INIT_FUNC_SPECIFIC(type) \
1880 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FUNC, \
1881 TYPE_MAIN_TYPE (type)->type_specific.func_stuff = (struct func_type *) \
1882 TYPE_ZALLOC (type, \
1883 sizeof (*TYPE_MAIN_TYPE (type)->type_specific.func_stuff)))
1885 /* "struct fixed_point_type_info" has a field that has a destructor.
1886 See allocate_fixed_point_type_info to understand how this is
1887 handled. */
1888 #define INIT_FIXED_POINT_SPECIFIC(type) \
1889 (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FIXED_POINT, \
1890 allocate_fixed_point_type_info (type))
1892 #define TYPE_MAIN_TYPE(thistype) (thistype)->main_type
1893 #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
1894 #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
1895 #define TYPE_RVALUE_REFERENCE_TYPE(thistype) (thistype)->rvalue_reference_type
1896 #define TYPE_CHAIN(thistype) (thistype)->chain
1898 /* * Return the alignment of the type in target addressable memory
1899 units, or 0 if no alignment was specified. */
1900 #define TYPE_RAW_ALIGN(thistype) type_raw_align (thistype)
1902 /* * Return the alignment of the type in target addressable memory
1903 units, or 0 if no alignment was specified. */
1904 extern unsigned type_raw_align (struct type *);
1906 /* * Return the alignment of the type in target addressable memory
1907 units. Return 0 if the alignment cannot be determined; but note
1908 that this makes an effort to compute the alignment even it it was
1909 not specified in the debug info. */
1910 extern unsigned type_align (struct type *);
1912 /* * Set the alignment of the type. The alignment must be a power of
1913 2. Returns false if the given value does not fit in the available
1914 space in struct type. */
1915 extern bool set_type_align (struct type *, ULONGEST);
1917 /* Property accessors for the type data location. */
1918 #define TYPE_DATA_LOCATION(thistype) \
1919 ((thistype)->dyn_prop (DYN_PROP_DATA_LOCATION))
1920 #define TYPE_DATA_LOCATION_BATON(thistype) \
1921 TYPE_DATA_LOCATION (thistype)->data.baton
1922 #define TYPE_DATA_LOCATION_ADDR(thistype) \
1923 (TYPE_DATA_LOCATION (thistype)->const_val ())
1924 #define TYPE_DATA_LOCATION_KIND(thistype) \
1925 (TYPE_DATA_LOCATION (thistype)->kind ())
1926 #define TYPE_DYNAMIC_LENGTH(thistype) \
1927 ((thistype)->dyn_prop (DYN_PROP_BYTE_SIZE))
1929 /* Property accessors for the type allocated/associated. */
1930 #define TYPE_ALLOCATED_PROP(thistype) \
1931 ((thistype)->dyn_prop (DYN_PROP_ALLOCATED))
1932 #define TYPE_ASSOCIATED_PROP(thistype) \
1933 ((thistype)->dyn_prop (DYN_PROP_ASSOCIATED))
1934 #define TYPE_RANK_PROP(thistype) \
1935 ((thistype)->dyn_prop (DYN_PROP_RANK))
1937 /* C++ */
1939 #define TYPE_SELF_TYPE(thistype) internal_type_self_type (thistype)
1940 /* Do not call this, use TYPE_SELF_TYPE. */
1941 extern struct type *internal_type_self_type (struct type *);
1942 extern void set_type_self_type (struct type *, struct type *);
1944 extern int internal_type_vptr_fieldno (struct type *);
1945 extern void set_type_vptr_fieldno (struct type *, int);
1946 extern struct type *internal_type_vptr_basetype (struct type *);
1947 extern void set_type_vptr_basetype (struct type *, struct type *);
1948 #define TYPE_VPTR_FIELDNO(thistype) internal_type_vptr_fieldno (thistype)
1949 #define TYPE_VPTR_BASETYPE(thistype) internal_type_vptr_basetype (thistype)
1951 #define TYPE_NFN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields
1952 #define TYPE_SPECIFIC_FIELD(thistype) \
1953 TYPE_MAIN_TYPE(thistype)->type_specific_field
1954 /* We need this tap-dance with the TYPE_RAW_SPECIFIC because of the case
1955 where we're trying to print an Ada array using the C language.
1956 In that case, there is no "cplus_stuff", but the C language assumes
1957 that there is. What we do, in that case, is pretend that there is
1958 an implicit one which is the default cplus stuff. */
1959 #define TYPE_CPLUS_SPECIFIC(thistype) \
1960 (!HAVE_CPLUS_STRUCT(thistype) \
1961 ? (struct cplus_struct_type*)&cplus_struct_default \
1962 : TYPE_RAW_CPLUS_SPECIFIC(thistype))
1963 #define TYPE_RAW_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff
1964 #define TYPE_CPLUS_CALLING_CONVENTION(thistype) \
1965 TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff->calling_convention
1966 #define TYPE_FLOATFORMAT(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.floatformat
1967 #define TYPE_GNAT_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.gnat_stuff
1968 #define TYPE_DESCRIPTIVE_TYPE(thistype) TYPE_GNAT_SPECIFIC(thistype)->descriptive_type
1969 #define TYPE_CALLING_CONVENTION(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->calling_convention
1970 #define TYPE_NO_RETURN(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->is_noreturn
1971 #define TYPE_TAIL_CALL_LIST(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->tail_call_list
1972 #define TYPE_BASECLASS(thistype,index) ((thistype)->field (index).type ())
1973 #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
1974 #define TYPE_BASECLASS_NAME(thistype,index) (thistype->field (index).name ())
1975 #define TYPE_BASECLASS_BITPOS(thistype,index) (thistype->field (index).loc_bitpos ())
1976 #define BASETYPE_VIA_PUBLIC(thistype, index) \
1977 ((thistype)->field (index).is_public ())
1978 #define TYPE_CPLUS_DYNAMIC(thistype) TYPE_CPLUS_SPECIFIC (thistype)->is_dynamic
1980 #define BASETYPE_VIA_VIRTUAL(thistype, index) \
1981 ((thistype)->field (index).is_virtual ())
1983 #define TYPE_FN_FIELDLISTS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists
1984 #define TYPE_FN_FIELDLIST(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n]
1985 #define TYPE_FN_FIELDLIST1(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].fn_fields
1986 #define TYPE_FN_FIELDLIST_NAME(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].name
1987 #define TYPE_FN_FIELDLIST_LENGTH(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].length
1989 #define TYPE_N_TEMPLATE_ARGUMENTS(thistype) \
1990 TYPE_CPLUS_SPECIFIC (thistype)->n_template_arguments
1991 #define TYPE_TEMPLATE_ARGUMENTS(thistype) \
1992 TYPE_CPLUS_SPECIFIC (thistype)->template_arguments
1993 #define TYPE_TEMPLATE_ARGUMENT(thistype, n) \
1994 TYPE_CPLUS_SPECIFIC (thistype)->template_arguments[n]
1996 #define TYPE_FN_FIELD(thisfn, n) (thisfn)[n]
1997 #define TYPE_FN_FIELD_PHYSNAME(thisfn, n) (thisfn)[n].physname
1998 #define TYPE_FN_FIELD_TYPE(thisfn, n) (thisfn)[n].type
1999 #define TYPE_FN_FIELD_ARGS(thisfn, n) (((thisfn)[n].type)->fields ())
2000 #define TYPE_FN_FIELD_CONST(thisfn, n) ((thisfn)[n].is_const)
2001 #define TYPE_FN_FIELD_VOLATILE(thisfn, n) ((thisfn)[n].is_volatile)
2002 #define TYPE_FN_FIELD_PRIVATE(thisfn, n) \
2003 ((thisfn)[n].accessibility == accessibility::PRIVATE)
2004 #define TYPE_FN_FIELD_PROTECTED(thisfn, n) \
2005 ((thisfn)[n].accessibility == accessibility::PROTECTED)
2006 #define TYPE_FN_FIELD_ARTIFICIAL(thisfn, n) ((thisfn)[n].is_artificial)
2007 #define TYPE_FN_FIELD_STUB(thisfn, n) ((thisfn)[n].is_stub)
2008 #define TYPE_FN_FIELD_CONSTRUCTOR(thisfn, n) ((thisfn)[n].is_constructor)
2009 #define TYPE_FN_FIELD_FCONTEXT(thisfn, n) ((thisfn)[n].fcontext)
2010 #define TYPE_FN_FIELD_VOFFSET(thisfn, n) ((thisfn)[n].voffset-2)
2011 #define TYPE_FN_FIELD_VIRTUAL_P(thisfn, n) ((thisfn)[n].voffset > 1)
2012 #define TYPE_FN_FIELD_STATIC_P(thisfn, n) ((thisfn)[n].voffset == VOFFSET_STATIC)
2013 #define TYPE_FN_FIELD_DEFAULTED(thisfn, n) ((thisfn)[n].defaulted)
2014 #define TYPE_FN_FIELD_DELETED(thisfn, n) ((thisfn)[n].is_deleted)
2016 /* Accessors for typedefs defined by a class. */
2017 #define TYPE_TYPEDEF_FIELD_ARRAY(thistype) \
2018 TYPE_CPLUS_SPECIFIC (thistype)->typedef_field
2019 #define TYPE_TYPEDEF_FIELD(thistype, n) \
2020 TYPE_CPLUS_SPECIFIC (thistype)->typedef_field[n]
2021 #define TYPE_TYPEDEF_FIELD_NAME(thistype, n) \
2022 TYPE_TYPEDEF_FIELD (thistype, n).name
2023 #define TYPE_TYPEDEF_FIELD_TYPE(thistype, n) \
2024 TYPE_TYPEDEF_FIELD (thistype, n).type
2025 #define TYPE_TYPEDEF_FIELD_COUNT(thistype) \
2026 TYPE_CPLUS_SPECIFIC (thistype)->typedef_field_count
2027 #define TYPE_TYPEDEF_FIELD_PROTECTED(thistype, n) \
2028 (TYPE_TYPEDEF_FIELD (thistype, n).accessibility == accessibility::PROTECTED)
2029 #define TYPE_TYPEDEF_FIELD_PRIVATE(thistype, n) \
2030 (TYPE_TYPEDEF_FIELD (thistype, n).accessibility == accessibility::PRIVATE)
2032 #define TYPE_NESTED_TYPES_ARRAY(thistype) \
2033 TYPE_CPLUS_SPECIFIC (thistype)->nested_types
2034 #define TYPE_NESTED_TYPES_FIELD(thistype, n) \
2035 TYPE_CPLUS_SPECIFIC (thistype)->nested_types[n]
2036 #define TYPE_NESTED_TYPES_FIELD_NAME(thistype, n) \
2037 TYPE_NESTED_TYPES_FIELD (thistype, n).name
2038 #define TYPE_NESTED_TYPES_FIELD_TYPE(thistype, n) \
2039 TYPE_NESTED_TYPES_FIELD (thistype, n).type
2040 #define TYPE_NESTED_TYPES_COUNT(thistype) \
2041 TYPE_CPLUS_SPECIFIC (thistype)->nested_types_count
2042 #define TYPE_NESTED_TYPES_FIELD_PROTECTED(thistype, n) \
2043 (TYPE_NESTED_TYPES_FIELD (thistype, n).accessibility \
2044 == accessibility::PROTECTED)
2045 #define TYPE_NESTED_TYPES_FIELD_PRIVATE(thistype, n) \
2046 (TYPE_NESTED_TYPES_FIELD (thistype, n).accessibility \
2047 == accessibility::PRIVATE)
2049 #define TYPE_IS_OPAQUE(thistype) \
2050 ((((thistype)->code () == TYPE_CODE_STRUCT) \
2051 || ((thistype)->code () == TYPE_CODE_UNION)) \
2052 && ((thistype)->num_fields () == 0) \
2053 && (!HAVE_CPLUS_STRUCT (thistype) \
2054 || TYPE_NFN_FIELDS (thistype) == 0) \
2055 && ((thistype)->is_stub () || !(thistype)->stub_is_supported ()))
2057 /* * A helper macro that returns the name of a type or "unnamed type"
2058 if the type has no name. */
2060 #define TYPE_SAFE_NAME(type) \
2061 (type->name () != nullptr ? type->name () : _("<unnamed type>"))
2063 /* * A helper macro that returns the name of an error type. If the
2064 type has a name, it is used; otherwise, a default is used. */
2066 #define TYPE_ERROR_NAME(type) \
2067 (type->name () ? type->name () : _("<error type>"))
2069 /* Given TYPE, return its floatformat. */
2070 const struct floatformat *floatformat_from_type (const struct type *type);
2072 struct builtin_type
2074 /* Integral types. */
2076 /* Implicit size/sign (based on the architecture's ABI). */
2077 struct type *builtin_void = nullptr;
2078 struct type *builtin_char = nullptr;
2079 struct type *builtin_short = nullptr;
2080 struct type *builtin_int = nullptr;
2081 struct type *builtin_long = nullptr;
2082 struct type *builtin_signed_char = nullptr;
2083 struct type *builtin_unsigned_char = nullptr;
2084 struct type *builtin_unsigned_short = nullptr;
2085 struct type *builtin_unsigned_int = nullptr;
2086 struct type *builtin_unsigned_long = nullptr;
2087 struct type *builtin_bfloat16 = nullptr;
2088 struct type *builtin_half = nullptr;
2089 struct type *builtin_float = nullptr;
2090 struct type *builtin_double = nullptr;
2091 struct type *builtin_long_double = nullptr;
2092 struct type *builtin_complex = nullptr;
2093 struct type *builtin_double_complex = nullptr;
2094 struct type *builtin_string = nullptr;
2095 struct type *builtin_bool = nullptr;
2096 struct type *builtin_long_long = nullptr;
2097 struct type *builtin_unsigned_long_long = nullptr;
2098 struct type *builtin_decfloat = nullptr;
2099 struct type *builtin_decdouble = nullptr;
2100 struct type *builtin_declong = nullptr;
2102 /* "True" character types.
2103 We use these for the '/c' print format, because c_char is just a
2104 one-byte integral type, which languages less laid back than C
2105 will print as ... well, a one-byte integral type. */
2106 struct type *builtin_true_char = nullptr;
2107 struct type *builtin_true_unsigned_char = nullptr;
2109 /* Explicit sizes - see C9X <intypes.h> for naming scheme. The "int0"
2110 is for when an architecture needs to describe a register that has
2111 no size. */
2112 struct type *builtin_int0 = nullptr;
2113 struct type *builtin_int8 = nullptr;
2114 struct type *builtin_uint8 = nullptr;
2115 struct type *builtin_int16 = nullptr;
2116 struct type *builtin_uint16 = nullptr;
2117 struct type *builtin_int24 = nullptr;
2118 struct type *builtin_uint24 = nullptr;
2119 struct type *builtin_int32 = nullptr;
2120 struct type *builtin_uint32 = nullptr;
2121 struct type *builtin_int64 = nullptr;
2122 struct type *builtin_uint64 = nullptr;
2123 struct type *builtin_int128 = nullptr;
2124 struct type *builtin_uint128 = nullptr;
2126 /* Wide character types. */
2127 struct type *builtin_char16 = nullptr;
2128 struct type *builtin_char32 = nullptr;
2129 struct type *builtin_wchar = nullptr;
2131 /* Pointer types. */
2133 /* * `pointer to data' type. Some target platforms use an implicitly
2134 {sign,zero} -extended 32-bit ABI pointer on a 64-bit ISA. */
2135 struct type *builtin_data_ptr = nullptr;
2137 /* * `pointer to function (returning void)' type. Harvard
2138 architectures mean that ABI function and code pointers are not
2139 interconvertible. Similarly, since ANSI, C standards have
2140 explicitly said that pointers to functions and pointers to data
2141 are not interconvertible --- that is, you can't cast a function
2142 pointer to void * and back, and expect to get the same value.
2143 However, all function pointer types are interconvertible, so void
2144 (*) () can server as a generic function pointer. */
2146 struct type *builtin_func_ptr = nullptr;
2148 /* * `function returning pointer to function (returning void)' type.
2149 The final void return type is not significant for it. */
2151 struct type *builtin_func_func = nullptr;
2153 /* Special-purpose types. */
2155 /* * This type is used to represent a GDB internal function. */
2157 struct type *internal_fn = nullptr;
2159 /* * This type is used to represent an xmethod. */
2160 struct type *xmethod = nullptr;
2162 /* * This type is used to represent symbol addresses. */
2163 struct type *builtin_core_addr = nullptr;
2165 /* * This type represents a type that was unrecognized in symbol
2166 read-in. */
2167 struct type *builtin_error = nullptr;
2169 /* * Types used for symbols with no debug information. */
2170 struct type *nodebug_text_symbol = nullptr;
2171 struct type *nodebug_text_gnu_ifunc_symbol = nullptr;
2172 struct type *nodebug_got_plt_symbol = nullptr;
2173 struct type *nodebug_data_symbol = nullptr;
2174 struct type *nodebug_unknown_symbol = nullptr;
2175 struct type *nodebug_tls_symbol = nullptr;
2178 /* * Return the type table for the specified architecture. */
2180 extern const struct builtin_type *builtin_type (struct gdbarch *gdbarch);
2182 /* * Return the type table for the specified objfile. */
2184 extern const struct builtin_type *builtin_type (struct objfile *objfile);
2186 /* Explicit floating-point formats. See "floatformat.h". */
2187 extern const struct floatformat *floatformats_ieee_half[BFD_ENDIAN_UNKNOWN];
2188 extern const struct floatformat *floatformats_ieee_single[BFD_ENDIAN_UNKNOWN];
2189 extern const struct floatformat *floatformats_ieee_double[BFD_ENDIAN_UNKNOWN];
2190 extern const struct floatformat *floatformats_ieee_quad[BFD_ENDIAN_UNKNOWN];
2191 extern const struct floatformat *floatformats_ieee_double_littlebyte_bigword[BFD_ENDIAN_UNKNOWN];
2192 extern const struct floatformat *floatformats_i387_ext[BFD_ENDIAN_UNKNOWN];
2193 extern const struct floatformat *floatformats_m68881_ext[BFD_ENDIAN_UNKNOWN];
2194 extern const struct floatformat *floatformats_arm_ext[BFD_ENDIAN_UNKNOWN];
2195 extern const struct floatformat *floatformats_ia64_spill[BFD_ENDIAN_UNKNOWN];
2196 extern const struct floatformat *floatformats_vax_f[BFD_ENDIAN_UNKNOWN];
2197 extern const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN];
2198 extern const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN];
2199 extern const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN];
2201 /* Allocate space for storing data associated with a particular
2202 type. We ensure that the space is allocated using the same
2203 mechanism that was used to allocate the space for the type
2204 structure itself. I.e. if the type is on an objfile's
2205 objfile_obstack, then the space for data associated with that type
2206 will also be allocated on the objfile_obstack. If the type is
2207 associated with a gdbarch, then the space for data associated with that
2208 type will also be allocated on the gdbarch_obstack.
2210 If a type is not associated with neither an objfile or a gdbarch then
2211 you should not use this macro to allocate space for data, instead you
2212 should call xmalloc directly, and ensure the memory is correctly freed
2213 when it is no longer needed. */
2215 #define TYPE_ALLOC(t,size) \
2216 (obstack_alloc (((t)->is_objfile_owned () \
2217 ? &((t)->objfile_owner ()->objfile_obstack) \
2218 : gdbarch_obstack ((t)->arch_owner ())), \
2219 size))
2222 /* See comment on TYPE_ALLOC. */
2224 #define TYPE_ZALLOC(t,size) (memset (TYPE_ALLOC (t, size), 0, size))
2226 /* * This returns the target type (or NULL) of TYPE, also skipping
2227 past typedefs. */
2229 extern struct type *get_target_type (struct type *type);
2231 /* Return the equivalent of TYPE_LENGTH, but in number of target
2232 addressable memory units of the associated gdbarch instead of bytes. */
2234 extern unsigned int type_length_units (struct type *type);
2236 /* An object of this type is passed when allocating certain types. It
2237 determines where the new type is allocated. Ultimately a type is
2238 either allocated on a on an objfile obstack or on a gdbarch
2239 obstack. However, it's also possible to request that a new type be
2240 allocated on the same obstack as some existing type, or that a
2241 "new" type instead overwrite a supplied type object. */
2243 class type_allocator
2245 public:
2247 /* Create new types on OBJFILE. */
2248 type_allocator (objfile *objfile, enum language lang)
2249 : m_is_objfile (true),
2250 m_lang (lang)
2252 m_data.objfile = objfile;
2255 /* Create new types on GDBARCH. */
2256 explicit type_allocator (gdbarch *gdbarch)
2257 : m_lang (language_minimal)
2259 m_data.gdbarch = gdbarch;
2262 /* This determines whether a passed-in type should be rewritten in
2263 place, or whether it should simply determine where the new type
2264 is created. */
2265 enum type_allocator_kind
2267 /* Allocate on same obstack as existing type. */
2268 SAME = 0,
2269 /* Smash the existing type. */
2270 SMASH = 1,
2273 /* Create new types either on the same obstack as TYPE; or if SMASH
2274 is passed, overwrite TYPE. */
2275 explicit type_allocator (struct type *type,
2276 type_allocator_kind kind = SAME)
2277 : m_lang (type->language ())
2279 if (kind == SAME)
2281 if (type->is_objfile_owned ())
2283 m_data.objfile = type->objfile_owner ();
2284 m_is_objfile = true;
2286 else
2287 m_data.gdbarch = type->arch_owner ();
2289 else
2291 m_smash = true;
2292 m_data.type = type;
2296 /* Create new types on the same obstack as TYPE. */
2297 explicit type_allocator (const struct type *type)
2298 : m_is_objfile (type->is_objfile_owned ()),
2299 m_lang (type->language ())
2301 if (type->is_objfile_owned ())
2302 m_data.objfile = type->objfile_owner ();
2303 else
2304 m_data.gdbarch = type->arch_owner ();
2307 /* Create a new type on the desired obstack. Note that a "new" type
2308 is not created if type-smashing was selected at construction. */
2309 type *new_type ();
2311 /* Create a new type on the desired obstack, and fill in its code,
2312 length, and name. If NAME is non-null, it is copied to the
2313 destination obstack first. Note that a "new" type is not created
2314 if type-smashing was selected at construction. */
2315 type *new_type (enum type_code code, int bit, const char *name);
2317 /* Return the architecture associated with this allocator. This
2318 comes from whatever object was supplied to the constructor. */
2319 gdbarch *arch ();
2321 private:
2323 /* Where the type should wind up. */
2324 union
2326 struct objfile *objfile;
2327 struct gdbarch *gdbarch;
2328 struct type *type;
2329 } m_data {};
2331 /* True if this allocator uses the objfile field above. */
2332 bool m_is_objfile = false;
2333 /* True if this allocator uses the type field above, indicating that
2334 the "allocation" should be done in-place. */
2335 bool m_smash = false;
2336 /* The language for types created by this allocator. */
2337 enum language m_lang;
2340 /* Allocate a TYPE_CODE_INT type structure using ALLOC. BIT is the
2341 type size in bits. If UNSIGNED_P is non-zero, set the type's
2342 TYPE_UNSIGNED flag. NAME is the type name. */
2344 extern struct type *init_integer_type (type_allocator &alloc, int bit,
2345 int unsigned_p, const char *name);
2347 /* Allocate a TYPE_CODE_CHAR type structure using ALLOC. BIT is the
2348 type size in bits. If UNSIGNED_P is non-zero, set the type's
2349 TYPE_UNSIGNED flag. NAME is the type name. */
2351 extern struct type *init_character_type (type_allocator &alloc, int bit,
2352 int unsigned_p, const char *name);
2354 /* Allocate a TYPE_CODE_BOOL type structure using ALLOC. BIT is the
2355 type size in bits. If UNSIGNED_P is non-zero, set the type's
2356 TYPE_UNSIGNED flag. NAME is the type name. */
2358 extern struct type *init_boolean_type (type_allocator &alloc, int bit,
2359 int unsigned_p, const char *name);
2361 /* Allocate a TYPE_CODE_FLT type structure using ALLOC.
2362 BIT is the type size in bits; if BIT equals -1, the size is
2363 determined by the floatformat. NAME is the type name. Set the
2364 TYPE_FLOATFORMAT from FLOATFORMATS. BYTE_ORDER is the byte order
2365 to use. If it is BFD_ENDIAN_UNKNOWN (the default), then the byte
2366 order of the objfile's architecture is used. */
2368 extern struct type *init_float_type
2369 (type_allocator &alloc, int bit, const char *name,
2370 const struct floatformat **floatformats,
2371 enum bfd_endian byte_order = BFD_ENDIAN_UNKNOWN);
2373 /* Allocate a TYPE_CODE_DECFLOAT type structure using ALLOC.
2374 BIT is the type size in bits. NAME is the type name. */
2376 extern struct type *init_decfloat_type (type_allocator &alloc, int bit,
2377 const char *name);
2379 extern bool can_create_complex_type (struct type *);
2380 extern struct type *init_complex_type (const char *, struct type *);
2382 /* Allocate a TYPE_CODE_PTR type structure using ALLOC.
2383 BIT is the pointer type size in bits. NAME is the type name.
2384 TARGET_TYPE is the pointer target type. Always sets the pointer type's
2385 TYPE_UNSIGNED flag. */
2387 extern struct type *init_pointer_type (type_allocator &alloc, int bit,
2388 const char *name,
2389 struct type *target_type);
2391 extern struct type *init_fixed_point_type (type_allocator &, int, int,
2392 const char *);
2394 /* Helper functions to construct a struct or record type. An
2395 initially empty type is created using arch_composite_type().
2396 Fields are then added using append_composite_type_field*(). A union
2397 type has its size set to the largest field. A struct type has each
2398 field packed against the previous. */
2400 extern struct type *arch_composite_type (struct gdbarch *gdbarch,
2401 const char *name, enum type_code code);
2402 extern void append_composite_type_field (struct type *t, const char *name,
2403 struct type *field);
2404 extern void append_composite_type_field_aligned (struct type *t,
2405 const char *name,
2406 struct type *field,
2407 int alignment);
2408 struct field *append_composite_type_field_raw (struct type *t, const char *name,
2409 struct type *field);
2411 /* Helper functions to construct a bit flags type. An initially empty
2412 type is created using arch_flag_type(). Flags are then added using
2413 append_flag_type_field() and append_flag_type_flag(). */
2414 extern struct type *arch_flags_type (struct gdbarch *gdbarch,
2415 const char *name, int bit);
2416 extern void append_flags_type_field (struct type *type,
2417 int start_bitpos, int nr_bits,
2418 struct type *field_type, const char *name);
2419 extern void append_flags_type_flag (struct type *type, int bitpos,
2420 const char *name);
2422 extern void make_vector_type (struct type *array_type);
2423 extern struct type *init_vector_type (struct type *elt_type, int n);
2425 extern struct type *lookup_reference_type (struct type *, enum type_code);
2426 extern struct type *lookup_lvalue_reference_type (struct type *);
2427 extern struct type *lookup_rvalue_reference_type (struct type *);
2430 extern struct type *make_reference_type (struct type *, struct type **,
2431 enum type_code);
2433 extern struct type *make_cv_type (int, int, struct type *, struct type **);
2435 extern struct type *make_restrict_type (struct type *);
2437 extern struct type *make_unqualified_type (struct type *);
2439 extern struct type *make_atomic_type (struct type *);
2441 extern void replace_type (struct type *, struct type *);
2443 extern type_instance_flags address_space_name_to_type_instance_flags
2444 (struct gdbarch *, const char *);
2446 extern const char *address_space_type_instance_flags_to_name
2447 (struct gdbarch *, type_instance_flags);
2449 extern struct type *make_type_with_address_space
2450 (struct type *type, type_instance_flags space_identifier);
2452 extern struct type *lookup_memberptr_type (struct type *, struct type *);
2454 extern struct type *lookup_methodptr_type (struct type *);
2456 extern void smash_to_method_type (struct type *type, struct type *self_type,
2457 struct type *to_type, struct field *args,
2458 int nargs, int varargs);
2460 extern void smash_to_memberptr_type (struct type *, struct type *,
2461 struct type *);
2463 extern void smash_to_methodptr_type (struct type *, struct type *);
2465 extern const char *type_name_or_error (struct type *type);
2467 struct struct_elt
2469 /* The field of the element, or NULL if no element was found. */
2470 struct field *field;
2472 /* The bit offset of the element in the parent structure. */
2473 LONGEST offset;
2476 /* Given a type TYPE, lookup the field and offset of the component named
2477 NAME.
2479 TYPE can be either a struct or union, or a pointer or reference to
2480 a struct or union. If it is a pointer or reference, its target
2481 type is automatically used. Thus '.' and '->' are interchangeable,
2482 as specified for the definitions of the expression element types
2483 STRUCTOP_STRUCT and STRUCTOP_PTR.
2485 If NOERR is nonzero, the returned structure will have field set to
2486 NULL if there is no component named NAME.
2488 If the component NAME is a field in an anonymous substructure of
2489 TYPE, the returned offset is a "global" offset relative to TYPE
2490 rather than an offset within the substructure. */
2492 extern struct_elt lookup_struct_elt (struct type *, const char *, int);
2494 /* Given a type TYPE, lookup the type of the component named NAME.
2496 TYPE can be either a struct or union, or a pointer or reference to
2497 a struct or union. If it is a pointer or reference, its target
2498 type is automatically used. Thus '.' and '->' are interchangeable,
2499 as specified for the definitions of the expression element types
2500 STRUCTOP_STRUCT and STRUCTOP_PTR.
2502 If NOERR is nonzero, return NULL if there is no component named
2503 NAME. */
2505 extern struct type *lookup_struct_elt_type (struct type *, const char *, int);
2507 extern struct type *make_pointer_type (struct type *, struct type **);
2509 extern struct type *lookup_pointer_type (struct type *);
2511 extern struct type *make_function_type (struct type *, struct type **);
2513 extern struct type *lookup_function_type (struct type *);
2515 extern struct type *lookup_function_type_with_arguments (struct type *,
2516 int,
2517 struct type **);
2519 /* Create a range type using ALLOC.
2521 Indices will be of type INDEX_TYPE, and will range from LOW_BOUND
2522 to HIGH_BOUND, inclusive. */
2524 extern struct type *create_static_range_type (type_allocator &alloc,
2525 struct type *index_type,
2526 LONGEST low_bound,
2527 LONGEST high_bound);
2529 /* Create an array type using ALLOC.
2531 Elements will be of type ELEMENT_TYPE, the indices will be of type
2532 RANGE_TYPE.
2534 BYTE_STRIDE_PROP, when not NULL, provides the array's byte stride.
2535 This byte stride property is added to the resulting array type
2536 as a DYN_PROP_BYTE_STRIDE. As a consequence, the BYTE_STRIDE_PROP
2537 argument can only be used to create types that are objfile-owned
2538 (see add_dyn_prop), meaning that either this function must be called
2539 with an objfile-owned RESULT_TYPE, or an objfile-owned RANGE_TYPE.
2541 BIT_STRIDE is taken into account only when BYTE_STRIDE_PROP is NULL.
2542 If BIT_STRIDE is not zero, build a packed array type whose element
2543 size is BIT_STRIDE. Otherwise, ignore this parameter. */
2545 extern struct type *create_array_type_with_stride
2546 (type_allocator &alloc, struct type *element_type,
2547 struct type *range_type, struct dynamic_prop *byte_stride_prop,
2548 unsigned int bit_stride);
2550 /* Create a range type using ALLOC with a dynamic range from LOW_BOUND
2551 to HIGH_BOUND, inclusive. INDEX_TYPE is the underlying type. BIAS
2552 is the bias to be applied when storing or retrieving values of this
2553 type. */
2555 extern struct type *create_range_type (type_allocator &alloc,
2556 struct type *index_type,
2557 const struct dynamic_prop *low_bound,
2558 const struct dynamic_prop *high_bound,
2559 LONGEST bias);
2561 /* Like CREATE_RANGE_TYPE but also sets up a stride. When BYTE_STRIDE_P
2562 is true the value in STRIDE is a byte stride, otherwise STRIDE is a bit
2563 stride. */
2565 extern struct type *create_range_type_with_stride
2566 (type_allocator &alloc, struct type *index_type,
2567 const struct dynamic_prop *low_bound,
2568 const struct dynamic_prop *high_bound, LONGEST bias,
2569 const struct dynamic_prop *stride, bool byte_stride_p);
2571 /* Same as create_array_type_with_stride but with no bit_stride
2572 (BIT_STRIDE = 0), thus building an unpacked array. */
2574 extern struct type *create_array_type (type_allocator &alloc,
2575 struct type *element_type,
2576 struct type *range_type);
2578 extern struct type *lookup_array_range_type (struct type *, LONGEST, LONGEST);
2580 /* Create a string type using ALLOC. String types are similar enough
2581 to array of char types that we can use create_array_type to build
2582 the basic type and then bash it into a string type.
2584 For fixed length strings, the range type contains 0 as the lower
2585 bound and the length of the string minus one as the upper bound. */
2587 extern struct type *create_string_type (type_allocator &alloc,
2588 struct type *string_char_type,
2589 struct type *range_type);
2591 extern struct type *lookup_string_range_type (struct type *, LONGEST, LONGEST);
2593 extern struct type *create_set_type (type_allocator &alloc,
2594 struct type *domain_type);
2596 extern struct type *lookup_unsigned_typename (const struct language_defn *,
2597 const char *);
2599 extern struct type *lookup_signed_typename (const struct language_defn *,
2600 const char *);
2602 extern ULONGEST get_unsigned_type_max (struct type *);
2604 extern void get_signed_type_minmax (struct type *, LONGEST *, LONGEST *);
2606 extern CORE_ADDR get_pointer_type_max (struct type *);
2608 /* * Resolve all dynamic values of a type e.g. array bounds to static values.
2609 ADDR specifies the location of the variable the type is bound to.
2610 If TYPE has no dynamic properties return TYPE; otherwise a new type with
2611 static properties is returned.
2613 If FRAME is given, it is used when evaluating dynamic properties.
2614 This can be important when a static link is seen. If not given,
2615 the selected frame is used.
2617 For an array type, if the element type is dynamic, then that will
2618 not be resolved. This is done because each individual element may
2619 have a different type when resolved (depending on the contents of
2620 memory). In this situation, 'is_dynamic_type' will still return
2621 true for the return value of this function. */
2622 extern struct type *resolve_dynamic_type
2623 (struct type *type, gdb::array_view<const gdb_byte> valaddr,
2624 CORE_ADDR addr, const frame_info_ptr *frame = nullptr);
2626 /* * Predicate if the type has dynamic values, which are not resolved yet.
2627 See the caveat in 'resolve_dynamic_type' to understand a scenario
2628 where an apparently-resolved type may still be considered
2629 "dynamic". */
2630 extern bool is_dynamic_type (struct type *type);
2632 extern struct type *check_typedef (struct type *);
2634 extern void check_stub_method_group (struct type *, int);
2636 extern char *gdb_mangle_name (struct type *, int, int);
2638 /* Lookup a typedef or primitive type named NAME, visible in lexical block
2639 BLOCK. If NOERR is nonzero, return zero if NAME is not suitably
2640 defined.
2642 If this function finds a suitable type then check_typedef is called on
2643 the type, this ensures that if the type being returned is a typedef
2644 then the length of the type will be correct. The original typedef will
2645 still be returned, not the result of calling check_typedef. */
2647 extern struct type *lookup_typename (const struct language_defn *language,
2648 const char *name,
2649 const struct block *block, int noerr);
2651 extern struct type *lookup_template_type (const char *, struct type *,
2652 const struct block *);
2654 extern int get_vptr_fieldno (struct type *, struct type **);
2656 /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type
2657 TYPE.
2659 Return true if the two bounds are available, false otherwise. */
2661 extern bool get_discrete_bounds (struct type *type, LONGEST *lowp,
2662 LONGEST *highp);
2664 /* If TYPE's low bound is a known constant, return it, else return nullopt. */
2666 extern std::optional<LONGEST> get_discrete_low_bound (struct type *type);
2668 /* If TYPE's high bound is a known constant, return it, else return nullopt. */
2670 extern std::optional<LONGEST> get_discrete_high_bound (struct type *type);
2672 /* Assuming TYPE is a simple, non-empty array type, compute its upper
2673 and lower bound. Save the low bound into LOW_BOUND if not NULL.
2674 Save the high bound into HIGH_BOUND if not NULL.
2676 Return true if the operation was successful. Return false otherwise,
2677 in which case the values of LOW_BOUND and HIGH_BOUNDS are unmodified. */
2679 extern bool get_array_bounds (struct type *type, LONGEST *low_bound,
2680 LONGEST *high_bound);
2682 extern std::optional<LONGEST> discrete_position (struct type *type,
2683 LONGEST val);
2685 extern int class_types_same_p (const struct type *, const struct type *);
2687 extern int is_ancestor (struct type *, struct type *);
2689 extern int is_public_ancestor (struct type *, struct type *);
2691 extern int is_unique_ancestor (struct type *, struct value *);
2693 /* Overload resolution */
2695 /* * Badness if parameter list length doesn't match arg list length. */
2696 extern const struct rank LENGTH_MISMATCH_BADNESS;
2698 /* * Dummy badness value for nonexistent parameter positions. */
2699 extern const struct rank TOO_FEW_PARAMS_BADNESS;
2700 /* * Badness if no conversion among types. */
2701 extern const struct rank INCOMPATIBLE_TYPE_BADNESS;
2703 /* * Badness of an exact match. */
2704 extern const struct rank EXACT_MATCH_BADNESS;
2706 /* * Badness of integral promotion. */
2707 extern const struct rank INTEGER_PROMOTION_BADNESS;
2708 /* * Badness of floating promotion. */
2709 extern const struct rank FLOAT_PROMOTION_BADNESS;
2710 /* * Badness of converting a derived class pointer
2711 to a base class pointer. */
2712 extern const struct rank BASE_PTR_CONVERSION_BADNESS;
2713 /* * Badness of integral conversion. */
2714 extern const struct rank INTEGER_CONVERSION_BADNESS;
2715 /* * Badness of floating conversion. */
2716 extern const struct rank FLOAT_CONVERSION_BADNESS;
2717 /* * Badness of integer<->floating conversions. */
2718 extern const struct rank INT_FLOAT_CONVERSION_BADNESS;
2719 /* * Badness of conversion of pointer to void pointer. */
2720 extern const struct rank VOID_PTR_CONVERSION_BADNESS;
2721 /* * Badness of conversion to boolean. */
2722 extern const struct rank BOOL_CONVERSION_BADNESS;
2723 /* * Badness of converting derived to base class. */
2724 extern const struct rank BASE_CONVERSION_BADNESS;
2725 /* * Badness of converting from non-reference to reference. Subrank
2726 is the type of reference conversion being done. */
2727 extern const struct rank REFERENCE_CONVERSION_BADNESS;
2728 extern const struct rank REFERENCE_SEE_THROUGH_BADNESS;
2729 /* * Conversion to rvalue reference. */
2730 #define REFERENCE_CONVERSION_RVALUE 1
2731 /* * Conversion to const lvalue reference. */
2732 #define REFERENCE_CONVERSION_CONST_LVALUE 2
2734 /* * Badness of converting integer 0 to NULL pointer. */
2735 extern const struct rank NULL_POINTER_CONVERSION;
2736 /* * Badness of cv-conversion. Subrank is a flag describing the conversions
2737 being done. */
2738 extern const struct rank CV_CONVERSION_BADNESS;
2739 #define CV_CONVERSION_CONST 1
2740 #define CV_CONVERSION_VOLATILE 2
2742 /* Non-standard conversions allowed by the debugger */
2744 /* * Converting a pointer to an int is usually OK. */
2745 extern const struct rank NS_POINTER_CONVERSION_BADNESS;
2747 /* * Badness of converting a (non-zero) integer constant
2748 to a pointer. */
2749 extern const struct rank NS_INTEGER_POINTER_CONVERSION_BADNESS;
2751 extern struct rank sum_ranks (struct rank a, struct rank b);
2752 extern int compare_ranks (struct rank a, struct rank b);
2754 extern int compare_badness (const badness_vector &,
2755 const badness_vector &);
2757 extern badness_vector rank_function (gdb::array_view<type *> parms,
2758 gdb::array_view<value *> args,
2759 bool varargs = false);
2761 extern struct rank rank_one_type (struct type *, struct type *,
2762 struct value *);
2764 extern void recursive_dump_type (struct type *, int);
2766 /* printcmd.c */
2768 extern void print_scalar_formatted (const gdb_byte *, struct type *,
2769 const struct value_print_options *,
2770 int, struct ui_file *);
2772 extern int can_dereference (struct type *);
2774 extern int is_integral_type (struct type *);
2776 extern int is_floating_type (struct type *);
2778 extern int is_scalar_type (struct type *type);
2780 extern int is_scalar_type_recursive (struct type *);
2782 extern int class_or_union_p (const struct type *);
2784 extern void maintenance_print_type (const char *, int);
2786 using copied_types_hash_t = gdb::unordered_map<type *, type *>;
2788 extern struct type *copy_type_recursive (struct type *type,
2789 copied_types_hash_t &copied_types);
2791 extern struct type *copy_type (const struct type *type);
2793 extern bool types_equal (struct type *, struct type *);
2795 extern bool types_deeply_equal (struct type *, struct type *);
2797 extern int type_not_allocated (const struct type *type);
2799 extern int type_not_associated (const struct type *type);
2801 /* Return True if TYPE is a TYPE_CODE_FIXED_POINT or if TYPE is
2802 a range type whose base type is a TYPE_CODE_FIXED_POINT. */
2803 extern bool is_fixed_point_type (struct type *type);
2805 /* Allocate a fixed-point type info for TYPE. This should only be
2806 called by INIT_FIXED_POINT_SPECIFIC. */
2807 extern void allocate_fixed_point_type_info (struct type *type);
2809 /* * When the type includes explicit byte ordering, return that.
2810 Otherwise, the byte ordering from gdbarch_byte_order for
2811 the type's arch is returned. */
2813 extern enum bfd_endian type_byte_order (const struct type *type);
2815 /* A flag to enable printing of debugging information of C++
2816 overloading. */
2818 extern unsigned int overload_debug;
2820 /* Return whether the function type represented by TYPE is marked as unsafe
2821 to call by the debugger.
2823 This usually indicates that the function does not follow the target's
2824 standard calling convention. */
2826 extern bool is_nocall_function (const struct type *type);
2828 #endif /* GDB_GDBTYPES_H */