xref: /dragonfly/contrib/gdb-7/gdb/gdbtypes.h (revision ef5ccd6c)
15796c8dcSSimon Schubert /* Internal type definitions for GDB.
25796c8dcSSimon Schubert 
3*ef5ccd6cSJohn Marino    Copyright (C) 1992-2013 Free Software Foundation, Inc.
45796c8dcSSimon Schubert 
55796c8dcSSimon Schubert    Contributed by Cygnus Support, using pieces from other GDB modules.
65796c8dcSSimon Schubert 
75796c8dcSSimon Schubert    This file is part of GDB.
85796c8dcSSimon Schubert 
95796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
105796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
115796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
125796c8dcSSimon Schubert    (at your option) any later version.
135796c8dcSSimon Schubert 
145796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
155796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
165796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
175796c8dcSSimon Schubert    GNU General Public License for more details.
185796c8dcSSimon Schubert 
195796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
205796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
215796c8dcSSimon Schubert 
225796c8dcSSimon Schubert #if !defined (GDBTYPES_H)
235796c8dcSSimon Schubert #define GDBTYPES_H 1
245796c8dcSSimon Schubert 
255796c8dcSSimon Schubert #include "hashtab.h"
265796c8dcSSimon Schubert 
275796c8dcSSimon Schubert /* Forward declarations for prototypes.  */
285796c8dcSSimon Schubert struct field;
295796c8dcSSimon Schubert struct block;
305796c8dcSSimon Schubert struct value_print_options;
315796c8dcSSimon Schubert struct language_defn;
325796c8dcSSimon Schubert 
33*ef5ccd6cSJohn Marino /* These declarations are DWARF-specific as some of the gdbtypes.h data types
34*ef5ccd6cSJohn Marino    are already DWARF-specific.  */
35*ef5ccd6cSJohn Marino 
36*ef5ccd6cSJohn Marino /* Offset relative to the start of its containing CU (compilation unit).  */
37*ef5ccd6cSJohn Marino typedef struct
38*ef5ccd6cSJohn Marino {
39*ef5ccd6cSJohn Marino   unsigned int cu_off;
40*ef5ccd6cSJohn Marino } cu_offset;
41*ef5ccd6cSJohn Marino 
42*ef5ccd6cSJohn Marino /* Offset relative to the start of its .debug_info or .debug_types section.  */
43*ef5ccd6cSJohn Marino typedef struct
44*ef5ccd6cSJohn Marino {
45*ef5ccd6cSJohn Marino   unsigned int sect_off;
46*ef5ccd6cSJohn Marino } sect_offset;
47*ef5ccd6cSJohn Marino 
485796c8dcSSimon Schubert /* Some macros for char-based bitfields.  */
495796c8dcSSimon Schubert 
505796c8dcSSimon Schubert #define B_SET(a,x)	((a)[(x)>>3] |= (1 << ((x)&7)))
515796c8dcSSimon Schubert #define B_CLR(a,x)	((a)[(x)>>3] &= ~(1 << ((x)&7)))
525796c8dcSSimon Schubert #define B_TST(a,x)	((a)[(x)>>3] & (1 << ((x)&7)))
535796c8dcSSimon Schubert #define B_TYPE		unsigned char
545796c8dcSSimon Schubert #define	B_BYTES(x)	( 1 + ((x)>>3) )
555796c8dcSSimon Schubert #define	B_CLRALL(a,x)	memset ((a), 0, B_BYTES(x))
565796c8dcSSimon Schubert 
575796c8dcSSimon Schubert /* Different kinds of data types are distinguished by the `code' field.  */
585796c8dcSSimon Schubert 
595796c8dcSSimon Schubert enum type_code
605796c8dcSSimon Schubert   {
61*ef5ccd6cSJohn Marino     TYPE_CODE_BITSTRING = -1,	/* Deprecated  */
62*ef5ccd6cSJohn Marino     TYPE_CODE_UNDEF = 0,	/* Not used; catches errors */
635796c8dcSSimon Schubert     TYPE_CODE_PTR,		/* Pointer type */
645796c8dcSSimon Schubert 
655796c8dcSSimon Schubert     /* Array type with lower & upper bounds.
665796c8dcSSimon Schubert 
675796c8dcSSimon Schubert        Regardless of the language, GDB represents multidimensional
685796c8dcSSimon Schubert        array types the way C does: as arrays of arrays.  So an
695796c8dcSSimon Schubert        instance of a GDB array type T can always be seen as a series
705796c8dcSSimon Schubert        of instances of TYPE_TARGET_TYPE (T) laid out sequentially in
715796c8dcSSimon Schubert        memory.
725796c8dcSSimon Schubert 
735796c8dcSSimon Schubert        Row-major languages like C lay out multi-dimensional arrays so
745796c8dcSSimon Schubert        that incrementing the rightmost index in a subscripting
755796c8dcSSimon Schubert        expression results in the smallest change in the address of the
765796c8dcSSimon Schubert        element referred to.  Column-major languages like Fortran lay
775796c8dcSSimon Schubert        them out so that incrementing the leftmost index results in the
785796c8dcSSimon Schubert        smallest change.
795796c8dcSSimon Schubert 
805796c8dcSSimon Schubert        This means that, in column-major languages, working our way
815796c8dcSSimon Schubert        from type to target type corresponds to working through indices
825796c8dcSSimon Schubert        from right to left, not left to right.  */
835796c8dcSSimon Schubert     TYPE_CODE_ARRAY,
845796c8dcSSimon Schubert 
855796c8dcSSimon Schubert     TYPE_CODE_STRUCT,		/* C struct or Pascal record */
865796c8dcSSimon Schubert     TYPE_CODE_UNION,		/* C union or Pascal variant part */
875796c8dcSSimon Schubert     TYPE_CODE_ENUM,		/* Enumeration type */
885796c8dcSSimon Schubert     TYPE_CODE_FLAGS,		/* Bit flags type */
895796c8dcSSimon Schubert     TYPE_CODE_FUNC,		/* Function type */
905796c8dcSSimon Schubert     TYPE_CODE_INT,		/* Integer type */
915796c8dcSSimon Schubert 
925796c8dcSSimon Schubert     /* Floating type.  This is *NOT* a complex type.  Beware, there are parts
935796c8dcSSimon Schubert        of GDB which bogusly assume that TYPE_CODE_FLT can mean complex.  */
945796c8dcSSimon Schubert     TYPE_CODE_FLT,
955796c8dcSSimon Schubert 
965796c8dcSSimon Schubert     /* Void type.  The length field specifies the length (probably always
975796c8dcSSimon Schubert        one) which is used in pointer arithmetic involving pointers to
985796c8dcSSimon Schubert        this type, but actually dereferencing such a pointer is invalid;
995796c8dcSSimon Schubert        a void type has no length and no actual representation in memory
1005796c8dcSSimon Schubert        or registers.  A pointer to a void type is a generic pointer.  */
1015796c8dcSSimon Schubert     TYPE_CODE_VOID,
1025796c8dcSSimon Schubert 
1035796c8dcSSimon Schubert     TYPE_CODE_SET,		/* Pascal sets */
104c50c785cSJohn Marino     TYPE_CODE_RANGE,		/* Range (integers within spec'd bounds).  */
1055796c8dcSSimon Schubert 
1065796c8dcSSimon Schubert     /* A string type which is like an array of character but prints
1075796c8dcSSimon Schubert        differently (at least for (the deleted) CHILL).  It does not
1085796c8dcSSimon Schubert        contain a length field as Pascal strings (for many Pascals,
1095796c8dcSSimon Schubert        anyway) do; if we want to deal with such strings, we should use
1105796c8dcSSimon Schubert        a new type code.  */
1115796c8dcSSimon Schubert     TYPE_CODE_STRING,
1125796c8dcSSimon Schubert 
1135796c8dcSSimon Schubert     /* Unknown type.  The length field is valid if we were able to
1145796c8dcSSimon Schubert        deduce that much about the type, or 0 if we don't even know that.  */
1155796c8dcSSimon Schubert     TYPE_CODE_ERROR,
1165796c8dcSSimon Schubert 
1175796c8dcSSimon Schubert     /* C++ */
1185796c8dcSSimon Schubert     TYPE_CODE_METHOD,		/* Method type */
1195796c8dcSSimon Schubert 
1205796c8dcSSimon Schubert     /* Pointer-to-member-function type.  This describes how to access a
1215796c8dcSSimon Schubert        particular member function of a class (possibly a virtual
1225796c8dcSSimon Schubert        member function).  The representation may vary between different
1235796c8dcSSimon Schubert        C++ ABIs.  */
1245796c8dcSSimon Schubert     TYPE_CODE_METHODPTR,
1255796c8dcSSimon Schubert 
1265796c8dcSSimon Schubert     /* Pointer-to-member type.  This is the offset within a class to some
1275796c8dcSSimon Schubert        particular data member.  The only currently supported representation
1285796c8dcSSimon Schubert        uses an unbiased offset, with -1 representing NULL; this is used
1295796c8dcSSimon Schubert        by the Itanium C++ ABI (used by GCC on all platforms).  */
1305796c8dcSSimon Schubert     TYPE_CODE_MEMBERPTR,
1315796c8dcSSimon Schubert 
1325796c8dcSSimon Schubert     TYPE_CODE_REF,		/* C++ Reference types */
1335796c8dcSSimon Schubert 
1345796c8dcSSimon Schubert     TYPE_CODE_CHAR,		/* *real* character type */
1355796c8dcSSimon Schubert 
1365796c8dcSSimon Schubert     /* Boolean type.  0 is false, 1 is true, and other values are non-boolean
1375796c8dcSSimon Schubert        (e.g. FORTRAN "logical" used as unsigned int).  */
1385796c8dcSSimon Schubert     TYPE_CODE_BOOL,
1395796c8dcSSimon Schubert 
1405796c8dcSSimon Schubert     /* Fortran */
1415796c8dcSSimon Schubert     TYPE_CODE_COMPLEX,		/* Complex float */
1425796c8dcSSimon Schubert 
1435796c8dcSSimon Schubert     TYPE_CODE_TYPEDEF,
1445796c8dcSSimon Schubert 
1455796c8dcSSimon Schubert     TYPE_CODE_NAMESPACE,	/* C++ namespace.  */
1465796c8dcSSimon Schubert 
1475796c8dcSSimon Schubert     TYPE_CODE_DECFLOAT,		/* Decimal floating point.  */
1485796c8dcSSimon Schubert 
149cf7f2e2dSJohn Marino     TYPE_CODE_MODULE,		/* Fortran module.  */
150cf7f2e2dSJohn Marino 
1515796c8dcSSimon Schubert     /* Internal function type.  */
1525796c8dcSSimon Schubert     TYPE_CODE_INTERNAL_FUNCTION
1535796c8dcSSimon Schubert   };
1545796c8dcSSimon Schubert 
1555796c8dcSSimon Schubert /* For now allow source to use TYPE_CODE_CLASS for C++ classes, as an
1565796c8dcSSimon Schubert    alias for TYPE_CODE_STRUCT.  This is for DWARF, which has a distinct
1575796c8dcSSimon Schubert    "class" attribute.  Perhaps we should actually have a separate TYPE_CODE
1585796c8dcSSimon Schubert    so that we can print "class" or "struct" depending on what the debug
1595796c8dcSSimon Schubert    info said.  It's not clear we should bother.  */
1605796c8dcSSimon Schubert 
1615796c8dcSSimon Schubert #define TYPE_CODE_CLASS TYPE_CODE_STRUCT
1625796c8dcSSimon Schubert 
1635796c8dcSSimon Schubert /* Some constants representing each bit field in the main_type.  See
1645796c8dcSSimon Schubert    the bit-field-specific macros, below, for documentation of each
1655796c8dcSSimon Schubert    constant in this enum.  These enum values are only used with
1665796c8dcSSimon Schubert    init_type.  Note that the values are chosen not to conflict with
1675796c8dcSSimon Schubert    type_instance_flag_value; this lets init_type error-check its
1685796c8dcSSimon Schubert    input.  */
1695796c8dcSSimon Schubert 
1705796c8dcSSimon Schubert enum type_flag_value
1715796c8dcSSimon Schubert {
172*ef5ccd6cSJohn Marino   TYPE_FLAG_UNSIGNED = (1 << 8),
173*ef5ccd6cSJohn Marino   TYPE_FLAG_NOSIGN = (1 << 9),
174*ef5ccd6cSJohn Marino   TYPE_FLAG_STUB = (1 << 10),
175*ef5ccd6cSJohn Marino   TYPE_FLAG_TARGET_STUB = (1 << 11),
176*ef5ccd6cSJohn Marino   TYPE_FLAG_STATIC = (1 << 12),
177*ef5ccd6cSJohn Marino   TYPE_FLAG_PROTOTYPED = (1 << 13),
178*ef5ccd6cSJohn Marino   TYPE_FLAG_INCOMPLETE = (1 << 14),
179*ef5ccd6cSJohn Marino   TYPE_FLAG_VARARGS = (1 << 15),
180*ef5ccd6cSJohn Marino   TYPE_FLAG_VECTOR = (1 << 16),
181*ef5ccd6cSJohn Marino   TYPE_FLAG_FIXED_INSTANCE = (1 << 17),
182*ef5ccd6cSJohn Marino   TYPE_FLAG_STUB_SUPPORTED = (1 << 18),
183*ef5ccd6cSJohn Marino   TYPE_FLAG_GNU_IFUNC = (1 << 19),
1845796c8dcSSimon Schubert 
1855796c8dcSSimon Schubert   /* Used for error-checking.  */
1865796c8dcSSimon Schubert   TYPE_FLAG_MIN = TYPE_FLAG_UNSIGNED
1875796c8dcSSimon Schubert };
1885796c8dcSSimon Schubert 
1895796c8dcSSimon Schubert /* Some bits for the type's instance_flags word.  See the macros below
1905796c8dcSSimon Schubert    for documentation on each bit.  Note that if you add a value here,
1915796c8dcSSimon Schubert    you must update the enum type_flag_value as well.  */
1925796c8dcSSimon Schubert enum type_instance_flag_value
1935796c8dcSSimon Schubert {
1945796c8dcSSimon Schubert   TYPE_INSTANCE_FLAG_CONST = (1 << 0),
1955796c8dcSSimon Schubert   TYPE_INSTANCE_FLAG_VOLATILE = (1 << 1),
1965796c8dcSSimon Schubert   TYPE_INSTANCE_FLAG_CODE_SPACE = (1 << 2),
1975796c8dcSSimon Schubert   TYPE_INSTANCE_FLAG_DATA_SPACE = (1 << 3),
1985796c8dcSSimon Schubert   TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 = (1 << 4),
199c50c785cSJohn Marino   TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2 = (1 << 5),
200c50c785cSJohn Marino   TYPE_INSTANCE_FLAG_NOTTEXT = (1 << 6),
201*ef5ccd6cSJohn Marino   TYPE_INSTANCE_FLAG_RESTRICT = (1 << 7)
2025796c8dcSSimon Schubert };
2035796c8dcSSimon Schubert 
2045796c8dcSSimon Schubert /* Unsigned integer type.  If this is not set for a TYPE_CODE_INT, the
2055796c8dcSSimon Schubert    type is signed (unless TYPE_FLAG_NOSIGN (below) is set).  */
2065796c8dcSSimon Schubert 
2075796c8dcSSimon Schubert #define TYPE_UNSIGNED(t)	(TYPE_MAIN_TYPE (t)->flag_unsigned)
2085796c8dcSSimon Schubert 
2095796c8dcSSimon Schubert /* No sign for this type.  In C++, "char", "signed char", and "unsigned
2105796c8dcSSimon Schubert    char" are distinct types; so we need an extra flag to indicate the
2115796c8dcSSimon Schubert    absence of a sign!  */
2125796c8dcSSimon Schubert 
2135796c8dcSSimon Schubert #define TYPE_NOSIGN(t)		(TYPE_MAIN_TYPE (t)->flag_nosign)
2145796c8dcSSimon Schubert 
2155796c8dcSSimon Schubert /* This appears in a type's flags word if it is a stub type (e.g., if
2165796c8dcSSimon Schubert    someone referenced a type that wasn't defined in a source file
2175796c8dcSSimon Schubert    via (struct sir_not_appearing_in_this_film *)).  */
2185796c8dcSSimon Schubert 
2195796c8dcSSimon Schubert #define TYPE_STUB(t)		(TYPE_MAIN_TYPE (t)->flag_stub)
2205796c8dcSSimon Schubert 
2215796c8dcSSimon Schubert /* The target type of this type is a stub type, and this type needs to
2225796c8dcSSimon Schubert    be updated if it gets un-stubbed in check_typedef.
2235796c8dcSSimon Schubert    Used for arrays and ranges, in which TYPE_LENGTH of the array/range
2245796c8dcSSimon Schubert    gets set based on the TYPE_LENGTH of the target type.
2255796c8dcSSimon Schubert    Also, set for TYPE_CODE_TYPEDEF.  */
2265796c8dcSSimon Schubert 
2275796c8dcSSimon Schubert #define TYPE_TARGET_STUB(t)	(TYPE_MAIN_TYPE (t)->flag_target_stub)
2285796c8dcSSimon Schubert 
2295796c8dcSSimon Schubert /* Static type.  If this is set, the corresponding type had
230c50c785cSJohn Marino    a static modifier.
231c50c785cSJohn Marino    Note: This may be unnecessary, since static data members
232c50c785cSJohn Marino    are indicated by other means (bitpos == -1).  */
2335796c8dcSSimon Schubert 
2345796c8dcSSimon Schubert #define TYPE_STATIC(t)		(TYPE_MAIN_TYPE (t)->flag_static)
2355796c8dcSSimon Schubert 
236c50c785cSJohn Marino /* This is a function type which appears to have a prototype.  We need
237c50c785cSJohn Marino    this for function calls in order to tell us if it's necessary to
238c50c785cSJohn Marino    coerce the args, or to just do the standard conversions.  This is
239c50c785cSJohn Marino    used with a short field.  */
2405796c8dcSSimon Schubert 
2415796c8dcSSimon Schubert #define TYPE_PROTOTYPED(t)	(TYPE_MAIN_TYPE (t)->flag_prototyped)
2425796c8dcSSimon Schubert 
2435796c8dcSSimon Schubert /* This flag is used to indicate that processing for this type
2445796c8dcSSimon Schubert    is incomplete.
2455796c8dcSSimon Schubert 
2465796c8dcSSimon Schubert    (Mostly intended for HP platforms, where class methods, for
2475796c8dcSSimon Schubert    instance, can be encountered before their classes in the debug
2485796c8dcSSimon Schubert    info; the incomplete type has to be marked so that the class and
2495796c8dcSSimon Schubert    the method can be assigned correct types.)  */
2505796c8dcSSimon Schubert 
2515796c8dcSSimon Schubert #define TYPE_INCOMPLETE(t)	(TYPE_MAIN_TYPE (t)->flag_incomplete)
2525796c8dcSSimon Schubert 
2535796c8dcSSimon Schubert /* FIXME drow/2002-06-03:  Only used for methods, but applies as well
2545796c8dcSSimon Schubert    to functions.  */
2555796c8dcSSimon Schubert 
2565796c8dcSSimon Schubert #define TYPE_VARARGS(t)		(TYPE_MAIN_TYPE (t)->flag_varargs)
2575796c8dcSSimon Schubert 
2585796c8dcSSimon Schubert /* Identify a vector type.  Gcc is handling this by adding an extra
2595796c8dcSSimon Schubert    attribute to the array type.  We slurp that in as a new flag of a
2605796c8dcSSimon Schubert    type.  This is used only in dwarf2read.c.  */
2615796c8dcSSimon Schubert #define TYPE_VECTOR(t)		(TYPE_MAIN_TYPE (t)->flag_vector)
2625796c8dcSSimon Schubert 
2635796c8dcSSimon Schubert /* The debugging formats (especially STABS) do not contain enough information
2645796c8dcSSimon Schubert    to represent all Ada types---especially those whose size depends on
2655796c8dcSSimon Schubert    dynamic quantities.  Therefore, the GNAT Ada compiler includes
2665796c8dcSSimon Schubert    extra information in the form of additional type definitions
2675796c8dcSSimon Schubert    connected by naming conventions.  This flag indicates that the
2685796c8dcSSimon Schubert    type is an ordinary (unencoded) GDB type that has been created from
2695796c8dcSSimon Schubert    the necessary run-time information, and does not need further
2705796c8dcSSimon Schubert    interpretation.  Optionally marks ordinary, fixed-size GDB type.  */
2715796c8dcSSimon Schubert 
2725796c8dcSSimon Schubert #define TYPE_FIXED_INSTANCE(t) (TYPE_MAIN_TYPE (t)->flag_fixed_instance)
2735796c8dcSSimon Schubert 
2745796c8dcSSimon Schubert /* This debug target supports TYPE_STUB(t).  In the unsupported case we have to
2755796c8dcSSimon Schubert    rely on NFIELDS to be zero etc., see TYPE_IS_OPAQUE ().
2765796c8dcSSimon Schubert    TYPE_STUB(t) with !TYPE_STUB_SUPPORTED(t) may exist if we only guessed
2775796c8dcSSimon Schubert    the TYPE_STUB(t) value (see dwarfread.c).  */
2785796c8dcSSimon Schubert 
2795796c8dcSSimon Schubert #define TYPE_STUB_SUPPORTED(t)   (TYPE_MAIN_TYPE (t)->flag_stub_supported)
2805796c8dcSSimon Schubert 
2815796c8dcSSimon Schubert /* Not textual.  By default, GDB treats all single byte integers as
2825796c8dcSSimon Schubert    characters (or elements of strings) unless this flag is set.  */
2835796c8dcSSimon Schubert 
284c50c785cSJohn Marino #define TYPE_NOTTEXT(t)	(TYPE_INSTANCE_FLAGS (t) & TYPE_INSTANCE_FLAG_NOTTEXT)
285c50c785cSJohn Marino 
286c50c785cSJohn Marino /* Used only for TYPE_CODE_FUNC where it specifies the real function
287c50c785cSJohn Marino    address is returned by this function call.  TYPE_TARGET_TYPE determines the
288c50c785cSJohn Marino    final returned function type to be presented to user.  */
289c50c785cSJohn Marino 
290c50c785cSJohn Marino #define TYPE_GNU_IFUNC(t)	(TYPE_MAIN_TYPE (t)->flag_gnu_ifunc)
2915796c8dcSSimon Schubert 
2925796c8dcSSimon Schubert /* Type owner.  If TYPE_OBJFILE_OWNED is true, the type is owned by
2935796c8dcSSimon Schubert    the objfile retrieved as TYPE_OBJFILE.  Otherweise, the type is
2945796c8dcSSimon Schubert    owned by an architecture; TYPE_OBJFILE is NULL in this case.  */
2955796c8dcSSimon Schubert 
2965796c8dcSSimon Schubert #define TYPE_OBJFILE_OWNED(t) (TYPE_MAIN_TYPE (t)->flag_objfile_owned)
2975796c8dcSSimon Schubert #define TYPE_OWNER(t) TYPE_MAIN_TYPE(t)->owner
2985796c8dcSSimon Schubert #define TYPE_OBJFILE(t) (TYPE_OBJFILE_OWNED(t)? TYPE_OWNER(t).objfile : NULL)
2995796c8dcSSimon Schubert 
300cf7f2e2dSJohn Marino /* True if this type was declared using the "class" keyword.  This is
301cf7f2e2dSJohn Marino    only valid for C++ structure types, and only used for displaying
302cf7f2e2dSJohn Marino    the type.  If false, the structure was declared as a "struct".  */
303cf7f2e2dSJohn Marino 
304cf7f2e2dSJohn Marino #define TYPE_DECLARED_CLASS(t) (TYPE_MAIN_TYPE (t)->flag_declared_class)
305cf7f2e2dSJohn Marino 
306*ef5ccd6cSJohn Marino /* True if this type is a "flag" enum.  A flag enum is one where all
307*ef5ccd6cSJohn Marino    the values are pairwise disjoint when "and"ed together.  This
308*ef5ccd6cSJohn Marino    affects how enum values are printed.  */
309*ef5ccd6cSJohn Marino 
310*ef5ccd6cSJohn Marino #define TYPE_FLAG_ENUM(t) (TYPE_MAIN_TYPE (t)->flag_flag_enum)
311*ef5ccd6cSJohn Marino 
3125796c8dcSSimon Schubert /* Constant type.  If this is set, the corresponding type has a
313c50c785cSJohn Marino    const modifier.  */
3145796c8dcSSimon Schubert 
3155796c8dcSSimon Schubert #define TYPE_CONST(t) (TYPE_INSTANCE_FLAGS (t) & TYPE_INSTANCE_FLAG_CONST)
3165796c8dcSSimon Schubert 
3175796c8dcSSimon Schubert /* Volatile type.  If this is set, the corresponding type has a
318c50c785cSJohn Marino    volatile modifier.  */
3195796c8dcSSimon Schubert 
320c50c785cSJohn Marino #define TYPE_VOLATILE(t) \
321c50c785cSJohn Marino   (TYPE_INSTANCE_FLAGS (t) & TYPE_INSTANCE_FLAG_VOLATILE)
3225796c8dcSSimon Schubert 
323*ef5ccd6cSJohn Marino /* Restrict type.  If this is set, the corresponding type has a
324*ef5ccd6cSJohn Marino    restrict modifier.  */
325*ef5ccd6cSJohn Marino 
326*ef5ccd6cSJohn Marino #define TYPE_RESTRICT(t) \
327*ef5ccd6cSJohn Marino   (TYPE_INSTANCE_FLAGS (t) & TYPE_INSTANCE_FLAG_RESTRICT)
328*ef5ccd6cSJohn Marino 
3295796c8dcSSimon Schubert /* Instruction-space delimited type.  This is for Harvard architectures
3305796c8dcSSimon Schubert    which have separate instruction and data address spaces (and perhaps
3315796c8dcSSimon Schubert    others).
3325796c8dcSSimon Schubert 
3335796c8dcSSimon Schubert    GDB usually defines a flat address space that is a superset of the
3345796c8dcSSimon Schubert    architecture's two (or more) address spaces, but this is an extension
3355796c8dcSSimon Schubert    of the architecture's model.
3365796c8dcSSimon Schubert 
3375796c8dcSSimon Schubert    If TYPE_FLAG_INST is set, an object of the corresponding type
3385796c8dcSSimon Schubert    resides in instruction memory, even if its address (in the extended
3395796c8dcSSimon Schubert    flat address space) does not reflect this.
3405796c8dcSSimon Schubert 
3415796c8dcSSimon Schubert    Similarly, if TYPE_FLAG_DATA is set, then an object of the
3425796c8dcSSimon Schubert    corresponding type resides in the data memory space, even if
3435796c8dcSSimon Schubert    this is not indicated by its (flat address space) address.
3445796c8dcSSimon Schubert 
3455796c8dcSSimon Schubert    If neither flag is set, the default space for functions / methods
3465796c8dcSSimon Schubert    is instruction space, and for data objects is data memory.  */
3475796c8dcSSimon Schubert 
3485796c8dcSSimon Schubert #define TYPE_CODE_SPACE(t) \
3495796c8dcSSimon Schubert   (TYPE_INSTANCE_FLAGS (t) & TYPE_INSTANCE_FLAG_CODE_SPACE)
3505796c8dcSSimon Schubert 
3515796c8dcSSimon Schubert #define TYPE_DATA_SPACE(t) \
3525796c8dcSSimon Schubert   (TYPE_INSTANCE_FLAGS (t) & TYPE_INSTANCE_FLAG_DATA_SPACE)
3535796c8dcSSimon Schubert 
3545796c8dcSSimon Schubert /* Address class flags.  Some environments provide for pointers whose
3555796c8dcSSimon Schubert    size is different from that of a normal pointer or address types
3565796c8dcSSimon Schubert    where the bits are interpreted differently than normal addresses.  The
3575796c8dcSSimon Schubert    TYPE_FLAG_ADDRESS_CLASS_n flags may be used in target specific
3585796c8dcSSimon Schubert    ways to represent these different types of address classes.  */
3595796c8dcSSimon Schubert #define TYPE_ADDRESS_CLASS_1(t) (TYPE_INSTANCE_FLAGS(t) \
3605796c8dcSSimon Schubert                                  & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1)
3615796c8dcSSimon Schubert #define TYPE_ADDRESS_CLASS_2(t) (TYPE_INSTANCE_FLAGS(t) \
3625796c8dcSSimon Schubert 				 & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2)
3635796c8dcSSimon Schubert #define TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL \
3645796c8dcSSimon Schubert   (TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1 | TYPE_INSTANCE_FLAG_ADDRESS_CLASS_2)
3655796c8dcSSimon Schubert #define TYPE_ADDRESS_CLASS_ALL(t) (TYPE_INSTANCE_FLAGS(t) \
3665796c8dcSSimon Schubert 				   & TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL)
3675796c8dcSSimon Schubert 
3685796c8dcSSimon Schubert /* Determine which field of the union main_type.fields[x].loc is used.  */
3695796c8dcSSimon Schubert 
3705796c8dcSSimon Schubert enum field_loc_kind
3715796c8dcSSimon Schubert   {
3725796c8dcSSimon Schubert     FIELD_LOC_KIND_BITPOS,	/* bitpos */
373*ef5ccd6cSJohn Marino     FIELD_LOC_KIND_ENUMVAL,	/* enumval */
3745796c8dcSSimon Schubert     FIELD_LOC_KIND_PHYSADDR,	/* physaddr */
375a45ae5f8SJohn Marino     FIELD_LOC_KIND_PHYSNAME,	/* physname */
376a45ae5f8SJohn Marino     FIELD_LOC_KIND_DWARF_BLOCK	/* dwarf_block */
377cf7f2e2dSJohn Marino   };
378cf7f2e2dSJohn Marino 
379cf7f2e2dSJohn Marino /* A discriminant to determine which field in the main_type.type_specific
380cf7f2e2dSJohn Marino    union is being used, if any.
381cf7f2e2dSJohn Marino 
382cf7f2e2dSJohn Marino    For types such as TYPE_CODE_FLT or TYPE_CODE_FUNC, the use of this
383cf7f2e2dSJohn Marino    discriminant is really redundant, as we know from the type code
384cf7f2e2dSJohn Marino    which field is going to be used.  As such, it would be possible to
385cf7f2e2dSJohn Marino    reduce the size of this enum in order to save a bit or two for
386cf7f2e2dSJohn Marino    other fields of struct main_type.  But, since we still have extra
387cf7f2e2dSJohn Marino    room , and for the sake of clarity and consistency, we treat all fields
388cf7f2e2dSJohn Marino    of the union the same way.  */
389cf7f2e2dSJohn Marino 
390cf7f2e2dSJohn Marino enum type_specific_kind
391cf7f2e2dSJohn Marino {
392cf7f2e2dSJohn Marino   TYPE_SPECIFIC_NONE,
393cf7f2e2dSJohn Marino   TYPE_SPECIFIC_CPLUS_STUFF,
394cf7f2e2dSJohn Marino   TYPE_SPECIFIC_GNAT_STUFF,
395cf7f2e2dSJohn Marino   TYPE_SPECIFIC_FLOATFORMAT,
396a45ae5f8SJohn Marino   TYPE_SPECIFIC_FUNC
3975796c8dcSSimon Schubert };
3985796c8dcSSimon Schubert 
3995796c8dcSSimon Schubert /* This structure is space-critical.
4005796c8dcSSimon Schubert    Its layout has been tweaked to reduce the space used.  */
4015796c8dcSSimon Schubert 
4025796c8dcSSimon Schubert struct main_type
4035796c8dcSSimon Schubert {
404c50c785cSJohn Marino   /* Code for kind of type.  */
4055796c8dcSSimon Schubert 
4065796c8dcSSimon Schubert   ENUM_BITFIELD(type_code) code : 8;
4075796c8dcSSimon Schubert 
4085796c8dcSSimon Schubert   /* Flags about this type.  These fields appear at this location
4095796c8dcSSimon Schubert      because they packs nicely here.  See the TYPE_* macros for
4105796c8dcSSimon Schubert      documentation about these fields.  */
4115796c8dcSSimon Schubert 
4125796c8dcSSimon Schubert   unsigned int flag_unsigned : 1;
4135796c8dcSSimon Schubert   unsigned int flag_nosign : 1;
4145796c8dcSSimon Schubert   unsigned int flag_stub : 1;
4155796c8dcSSimon Schubert   unsigned int flag_target_stub : 1;
4165796c8dcSSimon Schubert   unsigned int flag_static : 1;
4175796c8dcSSimon Schubert   unsigned int flag_prototyped : 1;
4185796c8dcSSimon Schubert   unsigned int flag_incomplete : 1;
4195796c8dcSSimon Schubert   unsigned int flag_varargs : 1;
4205796c8dcSSimon Schubert   unsigned int flag_vector : 1;
4215796c8dcSSimon Schubert   unsigned int flag_stub_supported : 1;
422c50c785cSJohn Marino   unsigned int flag_gnu_ifunc : 1;
4235796c8dcSSimon Schubert   unsigned int flag_fixed_instance : 1;
4245796c8dcSSimon Schubert   unsigned int flag_objfile_owned : 1;
425cf7f2e2dSJohn Marino   /* True if this type was declared with "class" rather than
426cf7f2e2dSJohn Marino      "struct".  */
427cf7f2e2dSJohn Marino   unsigned int flag_declared_class : 1;
428cf7f2e2dSJohn Marino 
429*ef5ccd6cSJohn Marino   /* True if this is an enum type with disjoint values.  This affects
430*ef5ccd6cSJohn Marino      how the enum is printed.  */
431*ef5ccd6cSJohn Marino 
432*ef5ccd6cSJohn Marino   unsigned int flag_flag_enum : 1;
433*ef5ccd6cSJohn Marino 
434cf7f2e2dSJohn Marino   /* A discriminant telling us which field of the type_specific union
435cf7f2e2dSJohn Marino      is being used for this type, if any.  */
436cf7f2e2dSJohn Marino   ENUM_BITFIELD(type_specific_kind) type_specific_field : 3;
4375796c8dcSSimon Schubert 
4385796c8dcSSimon Schubert   /* Number of fields described for this type.  This field appears at
4395796c8dcSSimon Schubert      this location because it packs nicely here.  */
4405796c8dcSSimon Schubert 
4415796c8dcSSimon Schubert   short nfields;
4425796c8dcSSimon Schubert 
4435796c8dcSSimon Schubert   /* Field number of the virtual function table pointer in
4445796c8dcSSimon Schubert      VPTR_BASETYPE.  If -1, we were unable to find the virtual
4455796c8dcSSimon Schubert      function table pointer in initial symbol reading, and
4465796c8dcSSimon Schubert      get_vptr_fieldno should be called to find it if possible.
4475796c8dcSSimon Schubert      get_vptr_fieldno will update this field if possible.
4485796c8dcSSimon Schubert      Otherwise the value is left at -1.
4495796c8dcSSimon Schubert 
4505796c8dcSSimon Schubert      Unused if this type does not have virtual functions.
4515796c8dcSSimon Schubert 
4525796c8dcSSimon Schubert      This field appears at this location because it packs nicely here.  */
4535796c8dcSSimon Schubert 
4545796c8dcSSimon Schubert   short vptr_fieldno;
4555796c8dcSSimon Schubert 
4565796c8dcSSimon Schubert   /* Name of this type, or NULL if none.
4575796c8dcSSimon Schubert 
4585796c8dcSSimon Schubert      This is used for printing only, except by poorly designed C++ code.
459*ef5ccd6cSJohn Marino      For looking up a name, look for a symbol in the VAR_DOMAIN.
460*ef5ccd6cSJohn Marino      This is generally allocated in the objfile's obstack.
461*ef5ccd6cSJohn Marino      However coffread.c uses malloc.  */
4625796c8dcSSimon Schubert 
463*ef5ccd6cSJohn Marino   const char *name;
4645796c8dcSSimon Schubert 
4655796c8dcSSimon Schubert   /* Tag name for this type, or NULL if none.  This means that the
4665796c8dcSSimon Schubert      name of the type consists of a keyword followed by the tag name.
4675796c8dcSSimon Schubert      Which keyword is determined by the type code ("struct" for
4685796c8dcSSimon Schubert      TYPE_CODE_STRUCT, etc.).  As far as I know C/C++ are the only languages
4695796c8dcSSimon Schubert      with this feature.
4705796c8dcSSimon Schubert 
4715796c8dcSSimon Schubert      This is used for printing only, except by poorly designed C++ code.
4725796c8dcSSimon Schubert      For looking up a name, look for a symbol in the STRUCT_DOMAIN.
4735796c8dcSSimon Schubert      One more legitimate use is that if TYPE_FLAG_STUB is set, this is
4745796c8dcSSimon Schubert      the name to use to look for definitions in other files.  */
4755796c8dcSSimon Schubert 
476*ef5ccd6cSJohn Marino   const char *tag_name;
4775796c8dcSSimon Schubert 
4785796c8dcSSimon Schubert   /* Every type is now associated with a particular objfile, and the
4795796c8dcSSimon Schubert      type is allocated on the objfile_obstack for that objfile.  One problem
4805796c8dcSSimon Schubert      however, is that there are times when gdb allocates new types while
4815796c8dcSSimon Schubert      it is not in the process of reading symbols from a particular objfile.
4825796c8dcSSimon Schubert      Fortunately, these happen when the type being created is a derived
4835796c8dcSSimon Schubert      type of an existing type, such as in lookup_pointer_type().  So
4845796c8dcSSimon Schubert      we can just allocate the new type using the same objfile as the
4855796c8dcSSimon Schubert      existing type, but to do this we need a backpointer to the objfile
4865796c8dcSSimon Schubert      from the existing type.  Yes this is somewhat ugly, but without
4875796c8dcSSimon Schubert      major overhaul of the internal type system, it can't be avoided
4885796c8dcSSimon Schubert      for now.  */
4895796c8dcSSimon Schubert 
4905796c8dcSSimon Schubert   union type_owner
4915796c8dcSSimon Schubert     {
4925796c8dcSSimon Schubert       struct objfile *objfile;
4935796c8dcSSimon Schubert       struct gdbarch *gdbarch;
4945796c8dcSSimon Schubert     } owner;
4955796c8dcSSimon Schubert 
4965796c8dcSSimon Schubert   /* For a pointer type, describes the type of object pointed to.
4975796c8dcSSimon Schubert      For an array type, describes the type of the elements.
4985796c8dcSSimon Schubert      For a function or method type, describes the type of the return value.
4995796c8dcSSimon Schubert      For a range type, describes the type of the full range.
5005796c8dcSSimon Schubert      For a complex type, describes the type of each coordinate.
501cf7f2e2dSJohn Marino      For a special record or union type encoding a dynamic-sized type
502cf7f2e2dSJohn Marino      in GNAT, a memoized pointer to a corresponding static version of
503cf7f2e2dSJohn Marino      the type.
5045796c8dcSSimon Schubert      Unused otherwise.  */
5055796c8dcSSimon Schubert 
5065796c8dcSSimon Schubert   struct type *target_type;
5075796c8dcSSimon Schubert 
5085796c8dcSSimon Schubert   /* For structure and union types, a description of each field.
5095796c8dcSSimon Schubert      For set and pascal array types, there is one "field",
5105796c8dcSSimon Schubert      whose type is the domain type of the set or array.
5115796c8dcSSimon Schubert      For range types, there are two "fields",
5125796c8dcSSimon Schubert      the minimum and maximum values (both inclusive).
5135796c8dcSSimon Schubert      For enum types, each possible value is described by one "field".
5145796c8dcSSimon Schubert      For a function or method type, a "field" for each parameter.
5155796c8dcSSimon Schubert      For C++ classes, there is one field for each base class (if it is
5165796c8dcSSimon Schubert      a derived class) plus one field for each class data member.  Member
5175796c8dcSSimon Schubert      functions are recorded elsewhere.
5185796c8dcSSimon Schubert 
5195796c8dcSSimon Schubert      Using a pointer to a separate array of fields
5205796c8dcSSimon Schubert      allows all types to have the same size, which is useful
5215796c8dcSSimon Schubert      because we can allocate the space for a type before
5225796c8dcSSimon Schubert      we know what to put in it.  */
5235796c8dcSSimon Schubert 
524cf7f2e2dSJohn Marino   union
525cf7f2e2dSJohn Marino   {
5265796c8dcSSimon Schubert     struct field
5275796c8dcSSimon Schubert     {
5285796c8dcSSimon Schubert       union field_location
5295796c8dcSSimon Schubert       {
5305796c8dcSSimon Schubert 	/* Position of this field, counting in bits from start of
531c50c785cSJohn Marino 	   containing structure.  For gdbarch_bits_big_endian=1
532c50c785cSJohn Marino 	   targets, it is the bit offset to the MSB.  For
533c50c785cSJohn Marino 	   gdbarch_bits_big_endian=0 targets, it is the bit offset to
534*ef5ccd6cSJohn Marino 	   the LSB.  */
5355796c8dcSSimon Schubert 
5365796c8dcSSimon Schubert 	int bitpos;
5375796c8dcSSimon Schubert 
538*ef5ccd6cSJohn Marino 	/* Enum value.  */
539*ef5ccd6cSJohn Marino 	LONGEST enumval;
540*ef5ccd6cSJohn Marino 
5415796c8dcSSimon Schubert 	/* For a static field, if TYPE_FIELD_STATIC_HAS_ADDR then physaddr
5425796c8dcSSimon Schubert 	   is the location (in the target) of the static field.
5435796c8dcSSimon Schubert 	   Otherwise, physname is the mangled label of the static field.  */
5445796c8dcSSimon Schubert 
5455796c8dcSSimon Schubert 	CORE_ADDR physaddr;
546a45ae5f8SJohn Marino 	const char *physname;
547a45ae5f8SJohn Marino 
548a45ae5f8SJohn Marino 	/* The field location can be computed by evaluating the following DWARF
549a45ae5f8SJohn Marino 	   block.  Its DATA is allocated on objfile_obstack - no CU load is
550a45ae5f8SJohn Marino 	   needed to access it.  */
551a45ae5f8SJohn Marino 
552a45ae5f8SJohn Marino 	struct dwarf2_locexpr_baton *dwarf_block;
5535796c8dcSSimon Schubert       }
5545796c8dcSSimon Schubert       loc;
5555796c8dcSSimon Schubert 
5565796c8dcSSimon Schubert       /* For a function or member type, this is 1 if the argument is marked
5575796c8dcSSimon Schubert 	 artificial.  Artificial arguments should not be shown to the
5585796c8dcSSimon Schubert 	 user.  For TYPE_CODE_RANGE it is set if the specific bound is not
5595796c8dcSSimon Schubert 	 defined.  */
5605796c8dcSSimon Schubert       unsigned int artificial : 1;
5615796c8dcSSimon Schubert 
5625796c8dcSSimon Schubert       /* Discriminant for union field_location.  */
563*ef5ccd6cSJohn Marino       ENUM_BITFIELD(field_loc_kind) loc_kind : 3;
5645796c8dcSSimon Schubert 
5655796c8dcSSimon Schubert       /* Size of this field, in bits, or zero if not packed.
566cf7f2e2dSJohn Marino 	 If non-zero in an array type, indicates the element size in
567cf7f2e2dSJohn Marino 	 bits (used only in Ada at the moment).
5685796c8dcSSimon Schubert 	 For an unpacked field, the field's type's length
5695796c8dcSSimon Schubert 	 says how many bytes the field occupies.  */
5705796c8dcSSimon Schubert 
571*ef5ccd6cSJohn Marino       unsigned int bitsize : 28;
5725796c8dcSSimon Schubert 
5735796c8dcSSimon Schubert       /* In a struct or union type, type of this field.
5745796c8dcSSimon Schubert 	 In a function or member type, type of this argument.
5755796c8dcSSimon Schubert 	 In an array type, the domain-type of the array.  */
5765796c8dcSSimon Schubert 
5775796c8dcSSimon Schubert       struct type *type;
5785796c8dcSSimon Schubert 
5795796c8dcSSimon Schubert       /* Name of field, value or argument.
5805796c8dcSSimon Schubert 	 NULL for range bounds, array domains, and member function
5815796c8dcSSimon Schubert 	 arguments.  */
5825796c8dcSSimon Schubert 
583*ef5ccd6cSJohn Marino       const char *name;
5845796c8dcSSimon Schubert     } *fields;
5855796c8dcSSimon Schubert 
586cf7f2e2dSJohn Marino     /* Union member used for range types.  */
587cf7f2e2dSJohn Marino 
588cf7f2e2dSJohn Marino     struct range_bounds
589cf7f2e2dSJohn Marino     {
590cf7f2e2dSJohn Marino       /* Low bound of range.  */
591cf7f2e2dSJohn Marino 
592cf7f2e2dSJohn Marino       LONGEST low;
593cf7f2e2dSJohn Marino 
594cf7f2e2dSJohn Marino       /* High bound of range.  */
595cf7f2e2dSJohn Marino 
596cf7f2e2dSJohn Marino       LONGEST high;
597cf7f2e2dSJohn Marino 
598cf7f2e2dSJohn Marino       /* Flags indicating whether the values of low and high are
599cf7f2e2dSJohn Marino          valid.  When true, the respective range value is
600cf7f2e2dSJohn Marino          undefined.  Currently used only for FORTRAN arrays.  */
601cf7f2e2dSJohn Marino 
602cf7f2e2dSJohn Marino       char low_undefined;
603cf7f2e2dSJohn Marino       char high_undefined;
604cf7f2e2dSJohn Marino 
605cf7f2e2dSJohn Marino     } *bounds;
606cf7f2e2dSJohn Marino 
607cf7f2e2dSJohn Marino   } flds_bnds;
608cf7f2e2dSJohn Marino 
6095796c8dcSSimon Schubert   /* For types with virtual functions (TYPE_CODE_STRUCT), VPTR_BASETYPE
6105796c8dcSSimon Schubert      is the base class which defined the virtual function table pointer.
6115796c8dcSSimon Schubert 
6125796c8dcSSimon Schubert      For types that are pointer to member types (TYPE_CODE_METHODPTR,
6135796c8dcSSimon Schubert      TYPE_CODE_MEMBERPTR), VPTR_BASETYPE is the type that this pointer
6145796c8dcSSimon Schubert      is a member of.
6155796c8dcSSimon Schubert 
6165796c8dcSSimon Schubert      For method types (TYPE_CODE_METHOD), VPTR_BASETYPE is the aggregate
6175796c8dcSSimon Schubert      type that contains the method.
6185796c8dcSSimon Schubert 
6195796c8dcSSimon Schubert      Unused otherwise.  */
6205796c8dcSSimon Schubert 
6215796c8dcSSimon Schubert   struct type *vptr_basetype;
6225796c8dcSSimon Schubert 
6235796c8dcSSimon Schubert   /* Slot to point to additional language-specific fields of this type.  */
6245796c8dcSSimon Schubert 
6255796c8dcSSimon Schubert   union type_specific
6265796c8dcSSimon Schubert   {
6275796c8dcSSimon Schubert     /* CPLUS_STUFF is for TYPE_CODE_STRUCT.  It is initialized to point to
6285796c8dcSSimon Schubert        cplus_struct_default, a default static instance of a struct
6295796c8dcSSimon Schubert        cplus_struct_type.  */
6305796c8dcSSimon Schubert 
6315796c8dcSSimon Schubert     struct cplus_struct_type *cplus_stuff;
6325796c8dcSSimon Schubert 
633cf7f2e2dSJohn Marino     /* GNAT_STUFF is for types for which the GNAT Ada compiler
634cf7f2e2dSJohn Marino        provides additional information.  */
635cf7f2e2dSJohn Marino     struct gnat_aux_type *gnat_stuff;
636cf7f2e2dSJohn Marino 
6375796c8dcSSimon Schubert     /* FLOATFORMAT is for TYPE_CODE_FLT.  It is a pointer to two
6385796c8dcSSimon Schubert        floatformat objects that describe the floating-point value
6395796c8dcSSimon Schubert        that resides within the type.  The first is for big endian
6405796c8dcSSimon Schubert        targets and the second is for little endian targets.  */
6415796c8dcSSimon Schubert 
6425796c8dcSSimon Schubert     const struct floatformat **floatformat;
6435796c8dcSSimon Schubert 
644a45ae5f8SJohn Marino     /* For TYPE_CODE_FUNC types,  */
645a45ae5f8SJohn Marino     struct func_type *func_stuff;
6465796c8dcSSimon Schubert   } type_specific;
6475796c8dcSSimon Schubert };
6485796c8dcSSimon Schubert 
6495796c8dcSSimon Schubert /* A ``struct type'' describes a particular instance of a type, with
6505796c8dcSSimon Schubert    some particular qualification.  */
6515796c8dcSSimon Schubert struct type
6525796c8dcSSimon Schubert {
6535796c8dcSSimon Schubert   /* Type that is a pointer to this type.
6545796c8dcSSimon Schubert      NULL if no such pointer-to type is known yet.
6555796c8dcSSimon Schubert      The debugger may add the address of such a type
6565796c8dcSSimon Schubert      if it has to construct one later.  */
6575796c8dcSSimon Schubert 
6585796c8dcSSimon Schubert   struct type *pointer_type;
6595796c8dcSSimon Schubert 
6605796c8dcSSimon Schubert   /* C++: also need a reference type.  */
6615796c8dcSSimon Schubert 
6625796c8dcSSimon Schubert   struct type *reference_type;
6635796c8dcSSimon Schubert 
6645796c8dcSSimon Schubert   /* Variant chain.  This points to a type that differs from this one only
6655796c8dcSSimon Schubert      in qualifiers and length.  Currently, the possible qualifiers are
6665796c8dcSSimon Schubert      const, volatile, code-space, data-space, and address class.  The
6675796c8dcSSimon Schubert      length may differ only when one of the address class flags are set.
6685796c8dcSSimon Schubert      The variants are linked in a circular ring and share MAIN_TYPE.  */
6695796c8dcSSimon Schubert   struct type *chain;
6705796c8dcSSimon Schubert 
6715796c8dcSSimon Schubert   /* Flags specific to this instance of the type, indicating where
672c50c785cSJohn Marino      on the ring we are.
673c50c785cSJohn Marino 
674c50c785cSJohn Marino      For TYPE_CODE_TYPEDEF the flags of the typedef type should be binary
675c50c785cSJohn Marino      or-ed with the target type, with a special case for address class and
676c50c785cSJohn Marino      space class.  For example if this typedef does not specify any new
677c50c785cSJohn Marino      qualifiers, TYPE_INSTANCE_FLAGS is 0 and the instance flags are
678c50c785cSJohn Marino      completely inherited from the target type.  No qualifiers can be cleared
679c50c785cSJohn Marino      by the typedef.  See also check_typedef.  */
6805796c8dcSSimon Schubert   int instance_flags;
6815796c8dcSSimon Schubert 
6825796c8dcSSimon Schubert   /* Length of storage for a value of this type.  This is what
6835796c8dcSSimon Schubert      sizeof(type) would return; use it for address arithmetic,
6845796c8dcSSimon Schubert      memory reads and writes, etc.  This size includes padding.  For
6855796c8dcSSimon Schubert      example, an i386 extended-precision floating point value really
6865796c8dcSSimon Schubert      only occupies ten bytes, but most ABI's declare its size to be
6875796c8dcSSimon Schubert      12 bytes, to preserve alignment.  A `struct type' representing
6885796c8dcSSimon Schubert      such a floating-point type would have a `length' value of 12,
6895796c8dcSSimon Schubert      even though the last two bytes are unused.
6905796c8dcSSimon Schubert 
6915796c8dcSSimon Schubert      There's a bit of a host/target mess here, if you're concerned
6925796c8dcSSimon Schubert      about machines whose bytes aren't eight bits long, or who don't
6935796c8dcSSimon Schubert      have byte-addressed memory.  Various places pass this to memcpy
6945796c8dcSSimon Schubert      and such, meaning it must be in units of host bytes.  Various
6955796c8dcSSimon Schubert      other places expect they can calculate addresses by adding it
6965796c8dcSSimon Schubert      and such, meaning it must be in units of target bytes.  For
6975796c8dcSSimon Schubert      some DSP targets, in which HOST_CHAR_BIT will (presumably) be 8
6985796c8dcSSimon Schubert      and TARGET_CHAR_BIT will be (say) 32, this is a problem.
6995796c8dcSSimon Schubert 
7005796c8dcSSimon Schubert      One fix would be to make this field in bits (requiring that it
7015796c8dcSSimon Schubert      always be a multiple of HOST_CHAR_BIT and TARGET_CHAR_BIT) ---
7025796c8dcSSimon Schubert      the other choice would be to make it consistently in units of
7035796c8dcSSimon Schubert      HOST_CHAR_BIT.  However, this would still fail to address
7045796c8dcSSimon Schubert      machines based on a ternary or decimal representation.  */
7055796c8dcSSimon Schubert 
7065796c8dcSSimon Schubert   unsigned length;
7075796c8dcSSimon Schubert 
7085796c8dcSSimon Schubert   /* Core type, shared by a group of qualified types.  */
7095796c8dcSSimon Schubert   struct main_type *main_type;
7105796c8dcSSimon Schubert };
7115796c8dcSSimon Schubert 
7125796c8dcSSimon Schubert #define	NULL_TYPE ((struct type *) 0)
7135796c8dcSSimon Schubert 
7145796c8dcSSimon Schubert /* C++ language-specific information for TYPE_CODE_STRUCT and TYPE_CODE_UNION
7155796c8dcSSimon Schubert    nodes.  */
7165796c8dcSSimon Schubert 
7175796c8dcSSimon Schubert struct cplus_struct_type
7185796c8dcSSimon Schubert   {
7195796c8dcSSimon Schubert     /* Number of base classes this type derives from.  The baseclasses are
7205796c8dcSSimon Schubert        stored in the first N_BASECLASSES fields (i.e. the `fields' field of
7215796c8dcSSimon Schubert        the struct type).  I think only the `type' field of such a field has
7225796c8dcSSimon Schubert        any meaning.  */
7235796c8dcSSimon Schubert 
7245796c8dcSSimon Schubert     short n_baseclasses;
7255796c8dcSSimon Schubert 
7265796c8dcSSimon Schubert     /* Number of methods with unique names.  All overloaded methods with
7275796c8dcSSimon Schubert        the same name count only once.  */
7285796c8dcSSimon Schubert 
7295796c8dcSSimon Schubert     short nfn_fields;
7305796c8dcSSimon Schubert 
731c50c785cSJohn Marino     /* Number of template arguments.  */
732c50c785cSJohn Marino     unsigned short n_template_arguments;
733c50c785cSJohn Marino 
734cf7f2e2dSJohn Marino     /* One if this struct is a dynamic class, as defined by the
735cf7f2e2dSJohn Marino        Itanium C++ ABI: if it requires a virtual table pointer,
736cf7f2e2dSJohn Marino        because it or any of its base classes have one or more virtual
737cf7f2e2dSJohn Marino        member functions or virtual base classes.  Minus one if not
738cf7f2e2dSJohn Marino        dynamic.  Zero if not yet computed.  */
739cf7f2e2dSJohn Marino     int is_dynamic : 2;
7405796c8dcSSimon Schubert 
741a45ae5f8SJohn Marino     /* Non-zero if this type came from a Java CU.  */
742a45ae5f8SJohn Marino     unsigned int is_java : 1;
743a45ae5f8SJohn Marino 
744c50c785cSJohn Marino     /* For derived classes, the number of base classes is given by
745c50c785cSJohn Marino        n_baseclasses and virtual_field_bits is a bit vector containing
746c50c785cSJohn Marino        one bit per base class.  If the base class is virtual, the
747c50c785cSJohn Marino        corresponding bit will be set.
7485796c8dcSSimon Schubert        I.E, given:
7495796c8dcSSimon Schubert 
7505796c8dcSSimon Schubert        class A{};
7515796c8dcSSimon Schubert        class B{};
7525796c8dcSSimon Schubert        class C : public B, public virtual A {};
7535796c8dcSSimon Schubert 
7545796c8dcSSimon Schubert        B is a baseclass of C; A is a virtual baseclass for C.
7555796c8dcSSimon Schubert        This is a C++ 2.0 language feature.  */
7565796c8dcSSimon Schubert 
7575796c8dcSSimon Schubert     B_TYPE *virtual_field_bits;
7585796c8dcSSimon Schubert 
7595796c8dcSSimon Schubert     /* For classes with private fields, the number of fields is given by
7605796c8dcSSimon Schubert        nfields and private_field_bits is a bit vector containing one bit
7615796c8dcSSimon Schubert        per field.
7625796c8dcSSimon Schubert        If the field is private, the corresponding bit will be set.  */
7635796c8dcSSimon Schubert 
7645796c8dcSSimon Schubert     B_TYPE *private_field_bits;
7655796c8dcSSimon Schubert 
7665796c8dcSSimon Schubert     /* For classes with protected fields, the number of fields is given by
7675796c8dcSSimon Schubert        nfields and protected_field_bits is a bit vector containing one bit
7685796c8dcSSimon Schubert        per field.
7695796c8dcSSimon Schubert        If the field is private, the corresponding bit will be set.  */
7705796c8dcSSimon Schubert 
7715796c8dcSSimon Schubert     B_TYPE *protected_field_bits;
7725796c8dcSSimon Schubert 
773c50c785cSJohn Marino     /* For classes with fields to be ignored, either this is optimized out
774c50c785cSJohn Marino        or this field has length 0.  */
7755796c8dcSSimon Schubert 
7765796c8dcSSimon Schubert     B_TYPE *ignore_field_bits;
7775796c8dcSSimon Schubert 
7785796c8dcSSimon Schubert     /* For classes, structures, and unions, a description of each field,
7795796c8dcSSimon Schubert        which consists of an overloaded name, followed by the types of
7805796c8dcSSimon Schubert        arguments that the method expects, and then the name after it
7815796c8dcSSimon Schubert        has been renamed to make it distinct.
7825796c8dcSSimon Schubert 
7835796c8dcSSimon Schubert        fn_fieldlists points to an array of nfn_fields of these.  */
7845796c8dcSSimon Schubert 
7855796c8dcSSimon Schubert     struct fn_fieldlist
7865796c8dcSSimon Schubert       {
7875796c8dcSSimon Schubert 
788*ef5ccd6cSJohn Marino 	/* The overloaded name.
789*ef5ccd6cSJohn Marino 	   This is generally allocated in the objfile's obstack.
790*ef5ccd6cSJohn Marino 	   However stabsread.c sometimes uses malloc.  */
7915796c8dcSSimon Schubert 
792*ef5ccd6cSJohn Marino 	const char *name;
7935796c8dcSSimon Schubert 
7945796c8dcSSimon Schubert 	/* The number of methods with this name.  */
7955796c8dcSSimon Schubert 
7965796c8dcSSimon Schubert 	int length;
7975796c8dcSSimon Schubert 
7985796c8dcSSimon Schubert 	/* The list of methods.  */
7995796c8dcSSimon Schubert 
8005796c8dcSSimon Schubert 	struct fn_field
8015796c8dcSSimon Schubert 	  {
8025796c8dcSSimon Schubert 
8035796c8dcSSimon Schubert 	    /* If is_stub is clear, this is the mangled name which we can
8045796c8dcSSimon Schubert 	       look up to find the address of the method (FIXME: it would
8055796c8dcSSimon Schubert 	       be cleaner to have a pointer to the struct symbol here
8065796c8dcSSimon Schubert 	       instead).  */
8075796c8dcSSimon Schubert 
8085796c8dcSSimon Schubert 	    /* If is_stub is set, this is the portion of the mangled
8095796c8dcSSimon Schubert 	       name which specifies the arguments.  For example, "ii",
8105796c8dcSSimon Schubert 	       if there are two int arguments, or "" if there are no
8115796c8dcSSimon Schubert 	       arguments.  See gdb_mangle_name for the conversion from this
8125796c8dcSSimon Schubert 	       format to the one used if is_stub is clear.  */
8135796c8dcSSimon Schubert 
814a45ae5f8SJohn Marino 	    const char *physname;
8155796c8dcSSimon Schubert 
8165796c8dcSSimon Schubert 	    /* The function type for the method.
8175796c8dcSSimon Schubert 	       (This comment used to say "The return value of the method",
8185796c8dcSSimon Schubert 	       but that's wrong.  The function type
8195796c8dcSSimon Schubert 	       is expected here, i.e. something with TYPE_CODE_FUNC,
8205796c8dcSSimon Schubert 	       and *not* the return-value type).  */
8215796c8dcSSimon Schubert 
8225796c8dcSSimon Schubert 	    struct type *type;
8235796c8dcSSimon Schubert 
8245796c8dcSSimon Schubert 	    /* For virtual functions.
8255796c8dcSSimon Schubert 	       First baseclass that defines this virtual function.  */
8265796c8dcSSimon Schubert 
8275796c8dcSSimon Schubert 	    struct type *fcontext;
8285796c8dcSSimon Schubert 
8295796c8dcSSimon Schubert 	    /* Attributes.  */
8305796c8dcSSimon Schubert 
8315796c8dcSSimon Schubert 	    unsigned int is_const:1;
8325796c8dcSSimon Schubert 	    unsigned int is_volatile:1;
8335796c8dcSSimon Schubert 	    unsigned int is_private:1;
8345796c8dcSSimon Schubert 	    unsigned int is_protected:1;
8355796c8dcSSimon Schubert 	    unsigned int is_public:1;
8365796c8dcSSimon Schubert 	    unsigned int is_abstract:1;
8375796c8dcSSimon Schubert 	    unsigned int is_static:1;
8385796c8dcSSimon Schubert 	    unsigned int is_final:1;
8395796c8dcSSimon Schubert 	    unsigned int is_synchronized:1;
8405796c8dcSSimon Schubert 	    unsigned int is_native:1;
8415796c8dcSSimon Schubert 	    unsigned int is_artificial:1;
8425796c8dcSSimon Schubert 
8435796c8dcSSimon Schubert 	    /* A stub method only has some fields valid (but they are enough
8445796c8dcSSimon Schubert 	       to reconstruct the rest of the fields).  */
8455796c8dcSSimon Schubert 	    unsigned int is_stub:1;
8465796c8dcSSimon Schubert 
847*ef5ccd6cSJohn Marino 	    /* True if this function is a constructor, false
848*ef5ccd6cSJohn Marino 	       otherwise.  */
849*ef5ccd6cSJohn Marino 	    unsigned int is_constructor : 1;
850*ef5ccd6cSJohn Marino 
8515796c8dcSSimon Schubert 	    /* Unused.  */
852*ef5ccd6cSJohn Marino 	    unsigned int dummy:3;
8535796c8dcSSimon Schubert 
8545796c8dcSSimon Schubert 	    /* Index into that baseclass's virtual function table,
8555796c8dcSSimon Schubert 	       minus 2; else if static: VOFFSET_STATIC; else: 0.  */
8565796c8dcSSimon Schubert 
8575796c8dcSSimon Schubert 	    unsigned int voffset:16;
8585796c8dcSSimon Schubert 
8595796c8dcSSimon Schubert #define VOFFSET_STATIC 1
8605796c8dcSSimon Schubert 
8615796c8dcSSimon Schubert 	  }
8625796c8dcSSimon Schubert 	 *fn_fields;
8635796c8dcSSimon Schubert 
8645796c8dcSSimon Schubert       }
8655796c8dcSSimon Schubert      *fn_fieldlists;
8665796c8dcSSimon Schubert 
867cf7f2e2dSJohn Marino     /* typedefs defined inside this class.  TYPEDEF_FIELD points to an array of
868cf7f2e2dSJohn Marino        TYPEDEF_FIELD_COUNT elements.  */
869cf7f2e2dSJohn Marino     struct typedef_field
870cf7f2e2dSJohn Marino       {
871cf7f2e2dSJohn Marino 	/* Unqualified name to be prefixed by owning class qualified name.  */
872cf7f2e2dSJohn Marino 	const char *name;
873cf7f2e2dSJohn Marino 
874cf7f2e2dSJohn Marino 	/* Type this typedef named NAME represents.  */
875cf7f2e2dSJohn Marino 	struct type *type;
876cf7f2e2dSJohn Marino       }
877cf7f2e2dSJohn Marino     *typedef_field;
878cf7f2e2dSJohn Marino     unsigned typedef_field_count;
879c50c785cSJohn Marino 
880c50c785cSJohn Marino     /* The template arguments.  This is an array with
881c50c785cSJohn Marino        N_TEMPLATE_ARGUMENTS elements.  This is NULL for non-template
882c50c785cSJohn Marino        classes.  */
883c50c785cSJohn Marino     struct symbol **template_arguments;
8845796c8dcSSimon Schubert   };
8855796c8dcSSimon Schubert 
886c50c785cSJohn Marino /* Struct used to store conversion rankings.  */
887c50c785cSJohn Marino struct rank
888c50c785cSJohn Marino   {
889c50c785cSJohn Marino     short rank;
890c50c785cSJohn Marino 
891c50c785cSJohn Marino     /* When two conversions are of the same type and therefore have the same
892c50c785cSJohn Marino        rank, subrank is used to differentiate the two.
893c50c785cSJohn Marino        Eg: Two derived-class-pointer to base-class-pointer conversions would
894c50c785cSJohn Marino        both have base pointer conversion rank, but the conversion with the
895c50c785cSJohn Marino        shorter distance to the ancestor is preferable.  'subrank' would be used
896c50c785cSJohn Marino        to reflect that.  */
897c50c785cSJohn Marino     short subrank;
898c50c785cSJohn Marino   };
899c50c785cSJohn Marino 
900c50c785cSJohn Marino /* Struct used for ranking a function for overload resolution.  */
9015796c8dcSSimon Schubert struct badness_vector
9025796c8dcSSimon Schubert   {
9035796c8dcSSimon Schubert     int length;
904c50c785cSJohn Marino     struct rank *rank;
9055796c8dcSSimon Schubert   };
9065796c8dcSSimon Schubert 
907cf7f2e2dSJohn Marino /* GNAT Ada-specific information for various Ada types.  */
908cf7f2e2dSJohn Marino struct gnat_aux_type
909cf7f2e2dSJohn Marino   {
910cf7f2e2dSJohn Marino     /* Parallel type used to encode information about dynamic types
911cf7f2e2dSJohn Marino        used in Ada (such as variant records, variable-size array,
912cf7f2e2dSJohn Marino        etc).  */
913cf7f2e2dSJohn Marino     struct type* descriptive_type;
914cf7f2e2dSJohn Marino   };
915cf7f2e2dSJohn Marino 
916a45ae5f8SJohn Marino /* For TYPE_CODE_FUNC types,  */
917a45ae5f8SJohn Marino struct func_type
918a45ae5f8SJohn Marino   {
919a45ae5f8SJohn Marino     /* The calling convention for targets supporting multiple ABIs.  Right now
920a45ae5f8SJohn Marino        this is only fetched from the Dwarf-2 DW_AT_calling_convention
921a45ae5f8SJohn Marino        attribute.  */
922a45ae5f8SJohn Marino     unsigned calling_convention;
923a45ae5f8SJohn Marino 
924a45ae5f8SJohn Marino     /* Only those DW_TAG_GNU_call_site's in this function that have
925a45ae5f8SJohn Marino        DW_AT_GNU_tail_call set are linked in this list.  Function without its
926a45ae5f8SJohn Marino        tail call list complete (DW_AT_GNU_all_tail_call_sites or its superset
927a45ae5f8SJohn Marino        DW_AT_GNU_all_call_sites) has TAIL_CALL_LIST NULL, even if some
928a45ae5f8SJohn Marino        DW_TAG_GNU_call_site's exist in such function. */
929a45ae5f8SJohn Marino     struct call_site *tail_call_list;
930a45ae5f8SJohn Marino   };
931a45ae5f8SJohn Marino 
932*ef5ccd6cSJohn Marino /* struct call_site_parameter can be referenced in callees by several ways.  */
933*ef5ccd6cSJohn Marino 
934*ef5ccd6cSJohn Marino enum call_site_parameter_kind
935*ef5ccd6cSJohn Marino {
936*ef5ccd6cSJohn Marino   /* Use field call_site_parameter.u.dwarf_reg.  */
937*ef5ccd6cSJohn Marino   CALL_SITE_PARAMETER_DWARF_REG,
938*ef5ccd6cSJohn Marino 
939*ef5ccd6cSJohn Marino   /* Use field call_site_parameter.u.fb_offset.  */
940*ef5ccd6cSJohn Marino   CALL_SITE_PARAMETER_FB_OFFSET,
941*ef5ccd6cSJohn Marino 
942*ef5ccd6cSJohn Marino   /* Use field call_site_parameter.u.param_offset.  */
943*ef5ccd6cSJohn Marino   CALL_SITE_PARAMETER_PARAM_OFFSET
944*ef5ccd6cSJohn Marino };
945*ef5ccd6cSJohn Marino 
946a45ae5f8SJohn Marino /* A place where a function gets called from, represented by
947a45ae5f8SJohn Marino    DW_TAG_GNU_call_site.  It can be looked up from symtab->call_site_htab.  */
948a45ae5f8SJohn Marino 
949a45ae5f8SJohn Marino struct call_site
950a45ae5f8SJohn Marino   {
951a45ae5f8SJohn Marino     /* Address of the first instruction after this call.  It must be the first
952a45ae5f8SJohn Marino        field as we overload core_addr_hash and core_addr_eq for it.  */
953a45ae5f8SJohn Marino     CORE_ADDR pc;
954a45ae5f8SJohn Marino 
955a45ae5f8SJohn Marino     /* List successor with head in FUNC_TYPE.TAIL_CALL_LIST.  */
956a45ae5f8SJohn Marino     struct call_site *tail_call_next;
957a45ae5f8SJohn Marino 
958a45ae5f8SJohn Marino     /* Describe DW_AT_GNU_call_site_target.  Missing attribute uses
959a45ae5f8SJohn Marino        FIELD_LOC_KIND_DWARF_BLOCK with FIELD_DWARF_BLOCK == NULL.  */
960a45ae5f8SJohn Marino     struct
961a45ae5f8SJohn Marino       {
962a45ae5f8SJohn Marino 	union field_location loc;
963a45ae5f8SJohn Marino 
964a45ae5f8SJohn Marino 	/* Discriminant for union field_location.  */
965*ef5ccd6cSJohn Marino 	ENUM_BITFIELD(field_loc_kind) loc_kind : 3;
966a45ae5f8SJohn Marino       }
967a45ae5f8SJohn Marino     target;
968a45ae5f8SJohn Marino 
969a45ae5f8SJohn Marino     /* Size of the PARAMETER array.  */
970a45ae5f8SJohn Marino     unsigned parameter_count;
971a45ae5f8SJohn Marino 
972a45ae5f8SJohn Marino     /* CU of the function where the call is located.  It gets used for DWARF
973a45ae5f8SJohn Marino        blocks execution in the parameter array below.  */
974a45ae5f8SJohn Marino     struct dwarf2_per_cu_data *per_cu;
975a45ae5f8SJohn Marino 
976a45ae5f8SJohn Marino     /* Describe DW_TAG_GNU_call_site's DW_TAG_formal_parameter.  */
977a45ae5f8SJohn Marino     struct call_site_parameter
978a45ae5f8SJohn Marino       {
979*ef5ccd6cSJohn Marino 	ENUM_BITFIELD (call_site_parameter_kind) kind : 2;
980*ef5ccd6cSJohn Marino 
981*ef5ccd6cSJohn Marino 	union call_site_parameter_u
982*ef5ccd6cSJohn Marino 	  {
983a45ae5f8SJohn Marino 	    /* DW_TAG_formal_parameter's DW_AT_location's DW_OP_regX as DWARF
984*ef5ccd6cSJohn Marino 	       register number, for register passed parameters.  */
985a45ae5f8SJohn Marino 	    int dwarf_reg;
986a45ae5f8SJohn Marino 
987a45ae5f8SJohn Marino 	    /* Offset from the callee's frame base, for stack passed parameters.
988*ef5ccd6cSJohn Marino 	       This equals offset from the caller's stack pointer.  */
989a45ae5f8SJohn Marino 	    CORE_ADDR fb_offset;
990a45ae5f8SJohn Marino 
991*ef5ccd6cSJohn Marino 	    /* Offset relative to the start of this PER_CU to
992*ef5ccd6cSJohn Marino 	       DW_TAG_formal_parameter which is referenced by both caller and
993*ef5ccd6cSJohn Marino 	       the callee.  */
994*ef5ccd6cSJohn Marino 	    cu_offset param_offset;
995*ef5ccd6cSJohn Marino 	  }
996*ef5ccd6cSJohn Marino 	u;
997*ef5ccd6cSJohn Marino 
998a45ae5f8SJohn Marino 	/* DW_TAG_formal_parameter's DW_AT_GNU_call_site_value.  It is never
999a45ae5f8SJohn Marino 	   NULL.  */
1000a45ae5f8SJohn Marino 	const gdb_byte *value;
1001a45ae5f8SJohn Marino 	size_t value_size;
1002a45ae5f8SJohn Marino 
1003a45ae5f8SJohn Marino 	/* DW_TAG_formal_parameter's DW_AT_GNU_call_site_data_value.  It may be
1004a45ae5f8SJohn Marino 	   NULL if not provided by DWARF.  */
1005a45ae5f8SJohn Marino 	const gdb_byte *data_value;
1006a45ae5f8SJohn Marino 	size_t data_value_size;
1007a45ae5f8SJohn Marino       }
1008a45ae5f8SJohn Marino     parameter[1];
1009a45ae5f8SJohn Marino   };
1010a45ae5f8SJohn Marino 
10115796c8dcSSimon Schubert /* The default value of TYPE_CPLUS_SPECIFIC(T) points to the
10125796c8dcSSimon Schubert    this shared static structure.  */
10135796c8dcSSimon Schubert 
10145796c8dcSSimon Schubert extern const struct cplus_struct_type cplus_struct_default;
10155796c8dcSSimon Schubert 
10165796c8dcSSimon Schubert extern void allocate_cplus_struct_type (struct type *);
10175796c8dcSSimon Schubert 
10185796c8dcSSimon Schubert #define INIT_CPLUS_SPECIFIC(type) \
1019cf7f2e2dSJohn Marino   (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_CPLUS_STUFF, \
1020c50c785cSJohn Marino    TYPE_RAW_CPLUS_SPECIFIC (type) = (struct cplus_struct_type*) \
1021c50c785cSJohn Marino    &cplus_struct_default)
1022cf7f2e2dSJohn Marino 
10235796c8dcSSimon Schubert #define ALLOCATE_CPLUS_STRUCT_TYPE(type) allocate_cplus_struct_type (type)
1024cf7f2e2dSJohn Marino 
10255796c8dcSSimon Schubert #define HAVE_CPLUS_STRUCT(type) \
1026cf7f2e2dSJohn Marino   (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_CPLUS_STUFF \
1027cf7f2e2dSJohn Marino    && TYPE_RAW_CPLUS_SPECIFIC (type) !=  &cplus_struct_default)
1028cf7f2e2dSJohn Marino 
1029cf7f2e2dSJohn Marino extern const struct gnat_aux_type gnat_aux_default;
1030cf7f2e2dSJohn Marino 
1031cf7f2e2dSJohn Marino extern void allocate_gnat_aux_type (struct type *);
1032cf7f2e2dSJohn Marino 
1033cf7f2e2dSJohn Marino #define INIT_GNAT_SPECIFIC(type) \
1034cf7f2e2dSJohn Marino   (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_GNAT_STUFF, \
1035cf7f2e2dSJohn Marino    TYPE_GNAT_SPECIFIC (type) = (struct gnat_aux_type *) &gnat_aux_default)
1036cf7f2e2dSJohn Marino #define ALLOCATE_GNAT_AUX_TYPE(type) allocate_gnat_aux_type (type)
1037cf7f2e2dSJohn Marino /* A macro that returns non-zero if the type-specific data should be
1038cf7f2e2dSJohn Marino    read as "gnat-stuff".  */
1039cf7f2e2dSJohn Marino #define HAVE_GNAT_AUX_INFO(type) \
1040cf7f2e2dSJohn Marino   (TYPE_SPECIFIC_FIELD (type) == TYPE_SPECIFIC_GNAT_STUFF)
10415796c8dcSSimon Schubert 
1042a45ae5f8SJohn Marino #define INIT_FUNC_SPECIFIC(type)					       \
1043a45ae5f8SJohn Marino   (TYPE_SPECIFIC_FIELD (type) = TYPE_SPECIFIC_FUNC,			       \
1044a45ae5f8SJohn Marino    TYPE_MAIN_TYPE (type)->type_specific.func_stuff			       \
1045a45ae5f8SJohn Marino      = TYPE_ZALLOC (type,						       \
1046a45ae5f8SJohn Marino 		    sizeof (*TYPE_MAIN_TYPE (type)->type_specific.func_stuff)))
1047a45ae5f8SJohn Marino 
10485796c8dcSSimon Schubert #define TYPE_INSTANCE_FLAGS(thistype) (thistype)->instance_flags
10495796c8dcSSimon Schubert #define TYPE_MAIN_TYPE(thistype) (thistype)->main_type
10505796c8dcSSimon Schubert #define TYPE_NAME(thistype) TYPE_MAIN_TYPE(thistype)->name
10515796c8dcSSimon Schubert #define TYPE_TAG_NAME(type) TYPE_MAIN_TYPE(type)->tag_name
10525796c8dcSSimon Schubert #define TYPE_TARGET_TYPE(thistype) TYPE_MAIN_TYPE(thistype)->target_type
10535796c8dcSSimon Schubert #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
10545796c8dcSSimon Schubert #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
10555796c8dcSSimon Schubert #define TYPE_CHAIN(thistype) (thistype)->chain
10565796c8dcSSimon Schubert /* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
10575796c8dcSSimon Schubert    But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
10585796c8dcSSimon Schubert    so you only have to call check_typedef once.  Since allocate_value
10595796c8dcSSimon Schubert    calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe.  */
10605796c8dcSSimon Schubert #define TYPE_LENGTH(thistype) (thistype)->length
10615796c8dcSSimon Schubert /* Note that TYPE_CODE can be TYPE_CODE_TYPEDEF, so if you want the real
10625796c8dcSSimon Schubert    type, you need to do TYPE_CODE (check_type (this_type)).  */
10635796c8dcSSimon Schubert #define TYPE_CODE(thistype) TYPE_MAIN_TYPE(thistype)->code
10645796c8dcSSimon Schubert #define TYPE_NFIELDS(thistype) TYPE_MAIN_TYPE(thistype)->nfields
1065cf7f2e2dSJohn Marino #define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields
10665796c8dcSSimon Schubert 
10675796c8dcSSimon Schubert #define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0)
1068cf7f2e2dSJohn Marino #define TYPE_RANGE_DATA(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.bounds
1069cf7f2e2dSJohn Marino #define TYPE_LOW_BOUND(range_type) TYPE_RANGE_DATA(range_type)->low
1070cf7f2e2dSJohn Marino #define TYPE_HIGH_BOUND(range_type) TYPE_RANGE_DATA(range_type)->high
1071cf7f2e2dSJohn Marino #define TYPE_LOW_BOUND_UNDEFINED(range_type) \
1072cf7f2e2dSJohn Marino    TYPE_RANGE_DATA(range_type)->low_undefined
1073cf7f2e2dSJohn Marino #define TYPE_HIGH_BOUND_UNDEFINED(range_type) \
1074cf7f2e2dSJohn Marino    TYPE_RANGE_DATA(range_type)->high_undefined
10755796c8dcSSimon Schubert 
1076c50c785cSJohn Marino /* Moto-specific stuff for FORTRAN arrays.  */
10775796c8dcSSimon Schubert 
10785796c8dcSSimon Schubert #define TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED(arraytype) \
1079cf7f2e2dSJohn Marino    TYPE_HIGH_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
10805796c8dcSSimon Schubert #define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
1081cf7f2e2dSJohn Marino    TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
10825796c8dcSSimon Schubert 
10835796c8dcSSimon Schubert #define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
10845796c8dcSSimon Schubert    (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
10855796c8dcSSimon Schubert 
10865796c8dcSSimon Schubert #define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \
10875796c8dcSSimon Schubert    (TYPE_LOW_BOUND(TYPE_INDEX_TYPE((arraytype))))
10885796c8dcSSimon Schubert 
10895796c8dcSSimon Schubert /* C++ */
10905796c8dcSSimon Schubert 
10915796c8dcSSimon Schubert #define TYPE_VPTR_BASETYPE(thistype) TYPE_MAIN_TYPE(thistype)->vptr_basetype
10925796c8dcSSimon Schubert #define TYPE_DOMAIN_TYPE(thistype) TYPE_MAIN_TYPE(thistype)->vptr_basetype
10935796c8dcSSimon Schubert #define TYPE_VPTR_FIELDNO(thistype) TYPE_MAIN_TYPE(thistype)->vptr_fieldno
10945796c8dcSSimon Schubert #define TYPE_FN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fields
10955796c8dcSSimon Schubert #define TYPE_NFN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields
1096cf7f2e2dSJohn Marino #define TYPE_SPECIFIC_FIELD(thistype) \
1097cf7f2e2dSJohn Marino   TYPE_MAIN_TYPE(thistype)->type_specific_field
10985796c8dcSSimon Schubert #define	TYPE_TYPE_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific
1099cf7f2e2dSJohn Marino /* We need this tap-dance with the TYPE_RAW_SPECIFIC because of the case
1100cf7f2e2dSJohn Marino    where we're trying to print an Ada array using the C language.
1101cf7f2e2dSJohn Marino    In that case, there is no "cplus_stuff", but the C language assumes
1102cf7f2e2dSJohn Marino    that there is.  What we do, in that case, is pretend that there is
1103cf7f2e2dSJohn Marino    an implicit one which is the default cplus stuff.  */
1104cf7f2e2dSJohn Marino #define TYPE_CPLUS_SPECIFIC(thistype) \
1105cf7f2e2dSJohn Marino    (!HAVE_CPLUS_STRUCT(thistype) \
1106cf7f2e2dSJohn Marino     ? (struct cplus_struct_type*)&cplus_struct_default \
1107cf7f2e2dSJohn Marino     : TYPE_RAW_CPLUS_SPECIFIC(thistype))
1108cf7f2e2dSJohn Marino #define TYPE_RAW_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff
11095796c8dcSSimon Schubert #define TYPE_FLOATFORMAT(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.floatformat
1110cf7f2e2dSJohn Marino #define TYPE_GNAT_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.gnat_stuff
1111cf7f2e2dSJohn Marino #define TYPE_DESCRIPTIVE_TYPE(thistype) TYPE_GNAT_SPECIFIC(thistype)->descriptive_type
1112a45ae5f8SJohn Marino #define TYPE_CALLING_CONVENTION(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->calling_convention
1113a45ae5f8SJohn Marino #define TYPE_TAIL_CALL_LIST(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->tail_call_list
1114cf7f2e2dSJohn Marino #define TYPE_BASECLASS(thistype,index) TYPE_FIELD_TYPE(thistype, index)
11155796c8dcSSimon Schubert #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
1116cf7f2e2dSJohn Marino #define TYPE_BASECLASS_NAME(thistype,index) TYPE_FIELD_NAME(thistype, index)
11175796c8dcSSimon Schubert #define TYPE_BASECLASS_BITPOS(thistype,index) TYPE_FIELD_BITPOS(thistype,index)
11185796c8dcSSimon Schubert #define BASETYPE_VIA_PUBLIC(thistype, index) \
11195796c8dcSSimon Schubert   ((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index)))
1120cf7f2e2dSJohn Marino #define TYPE_CPLUS_DYNAMIC(thistype) TYPE_CPLUS_SPECIFIC (thistype)->is_dynamic
1121a45ae5f8SJohn Marino #define TYPE_CPLUS_REALLY_JAVA(thistype) TYPE_CPLUS_SPECIFIC (thistype)->is_java
11225796c8dcSSimon Schubert 
11235796c8dcSSimon Schubert #define BASETYPE_VIA_VIRTUAL(thistype, index) \
11245796c8dcSSimon Schubert   (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
11255796c8dcSSimon Schubert     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
11265796c8dcSSimon Schubert 
11275796c8dcSSimon Schubert #define FIELD_TYPE(thisfld) ((thisfld).type)
11285796c8dcSSimon Schubert #define FIELD_NAME(thisfld) ((thisfld).name)
11295796c8dcSSimon Schubert #define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind)
1130*ef5ccd6cSJohn Marino #define FIELD_BITPOS_LVAL(thisfld) ((thisfld).loc.bitpos)
1131*ef5ccd6cSJohn Marino #define FIELD_BITPOS(thisfld) (FIELD_BITPOS_LVAL (thisfld) + 0)
1132*ef5ccd6cSJohn Marino #define FIELD_ENUMVAL_LVAL(thisfld) ((thisfld).loc.enumval)
1133*ef5ccd6cSJohn Marino #define FIELD_ENUMVAL(thisfld) (FIELD_ENUMVAL_LVAL (thisfld) + 0)
11345796c8dcSSimon Schubert #define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc.physname)
11355796c8dcSSimon Schubert #define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc.physaddr)
1136a45ae5f8SJohn Marino #define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc.dwarf_block)
11375796c8dcSSimon Schubert #define SET_FIELD_BITPOS(thisfld, bitpos)			\
11385796c8dcSSimon Schubert   (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_BITPOS,		\
1139*ef5ccd6cSJohn Marino    FIELD_BITPOS_LVAL (thisfld) = (bitpos))
1140*ef5ccd6cSJohn Marino #define SET_FIELD_ENUMVAL(thisfld, enumval)			\
1141*ef5ccd6cSJohn Marino   (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_ENUMVAL,		\
1142*ef5ccd6cSJohn Marino    FIELD_ENUMVAL_LVAL (thisfld) = (enumval))
11435796c8dcSSimon Schubert #define SET_FIELD_PHYSNAME(thisfld, name)			\
11445796c8dcSSimon Schubert   (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSNAME,		\
11455796c8dcSSimon Schubert    FIELD_STATIC_PHYSNAME (thisfld) = (name))
11465796c8dcSSimon Schubert #define SET_FIELD_PHYSADDR(thisfld, addr)			\
11475796c8dcSSimon Schubert   (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_PHYSADDR,		\
11485796c8dcSSimon Schubert    FIELD_STATIC_PHYSADDR (thisfld) = (addr))
1149a45ae5f8SJohn Marino #define SET_FIELD_DWARF_BLOCK(thisfld, addr)			\
1150a45ae5f8SJohn Marino   (FIELD_LOC_KIND (thisfld) = FIELD_LOC_KIND_DWARF_BLOCK,	\
1151a45ae5f8SJohn Marino    FIELD_DWARF_BLOCK (thisfld) = (addr))
11525796c8dcSSimon Schubert #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
11535796c8dcSSimon Schubert #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
11545796c8dcSSimon Schubert 
1155cf7f2e2dSJohn Marino #define TYPE_FIELD(thistype, n) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields[n]
11565796c8dcSSimon Schubert #define TYPE_FIELD_TYPE(thistype, n) FIELD_TYPE(TYPE_FIELD(thistype, n))
11575796c8dcSSimon Schubert #define TYPE_FIELD_NAME(thistype, n) FIELD_NAME(TYPE_FIELD(thistype, n))
11585796c8dcSSimon Schubert #define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND (TYPE_FIELD (thistype, n))
11595796c8dcSSimon Schubert #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS (TYPE_FIELD (thistype, n))
1160*ef5ccd6cSJohn Marino #define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL (TYPE_FIELD (thistype, n))
11615796c8dcSSimon Schubert #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME (TYPE_FIELD (thistype, n))
11625796c8dcSSimon Schubert #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR (TYPE_FIELD (thistype, n))
1163a45ae5f8SJohn Marino #define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK (TYPE_FIELD (thistype, n))
11645796c8dcSSimon Schubert #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n))
11655796c8dcSSimon Schubert #define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE(TYPE_FIELD(thistype,n))
11665796c8dcSSimon Schubert #define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE(TYPE_FIELD(thistype,n))!=0)
11675796c8dcSSimon Schubert 
11685796c8dcSSimon Schubert #define TYPE_FIELD_PRIVATE_BITS(thistype) \
11695796c8dcSSimon Schubert   TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits
11705796c8dcSSimon Schubert #define TYPE_FIELD_PROTECTED_BITS(thistype) \
11715796c8dcSSimon Schubert   TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits
11725796c8dcSSimon Schubert #define TYPE_FIELD_IGNORE_BITS(thistype) \
11735796c8dcSSimon Schubert   TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits
11745796c8dcSSimon Schubert #define TYPE_FIELD_VIRTUAL_BITS(thistype) \
11755796c8dcSSimon Schubert   TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits
11765796c8dcSSimon Schubert #define SET_TYPE_FIELD_PRIVATE(thistype, n) \
11775796c8dcSSimon Schubert   B_SET (TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n))
11785796c8dcSSimon Schubert #define SET_TYPE_FIELD_PROTECTED(thistype, n) \
11795796c8dcSSimon Schubert   B_SET (TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n))
11805796c8dcSSimon Schubert #define SET_TYPE_FIELD_IGNORE(thistype, n) \
11815796c8dcSSimon Schubert   B_SET (TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits, (n))
11825796c8dcSSimon Schubert #define SET_TYPE_FIELD_VIRTUAL(thistype, n) \
11835796c8dcSSimon Schubert   B_SET (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n))
11845796c8dcSSimon Schubert #define TYPE_FIELD_PRIVATE(thistype, n) \
11855796c8dcSSimon Schubert   (TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits == NULL ? 0 \
11865796c8dcSSimon Schubert     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n)))
11875796c8dcSSimon Schubert #define TYPE_FIELD_PROTECTED(thistype, n) \
11885796c8dcSSimon Schubert   (TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits == NULL ? 0 \
11895796c8dcSSimon Schubert     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n)))
11905796c8dcSSimon Schubert #define TYPE_FIELD_IGNORE(thistype, n) \
11915796c8dcSSimon Schubert   (TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits == NULL ? 0 \
11925796c8dcSSimon Schubert     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits, (n)))
11935796c8dcSSimon Schubert #define TYPE_FIELD_VIRTUAL(thistype, n) \
11945796c8dcSSimon Schubert   (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
11955796c8dcSSimon Schubert     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n)))
11965796c8dcSSimon Schubert 
11975796c8dcSSimon Schubert #define TYPE_FN_FIELDLISTS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists
11985796c8dcSSimon Schubert #define TYPE_FN_FIELDLIST(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n]
11995796c8dcSSimon Schubert #define TYPE_FN_FIELDLIST1(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].fn_fields
12005796c8dcSSimon Schubert #define TYPE_FN_FIELDLIST_NAME(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].name
12015796c8dcSSimon Schubert #define TYPE_FN_FIELDLIST_LENGTH(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].length
12025796c8dcSSimon Schubert 
1203c50c785cSJohn Marino #define TYPE_N_TEMPLATE_ARGUMENTS(thistype) \
1204c50c785cSJohn Marino   TYPE_CPLUS_SPECIFIC (thistype)->n_template_arguments
1205c50c785cSJohn Marino #define TYPE_TEMPLATE_ARGUMENTS(thistype) \
1206c50c785cSJohn Marino   TYPE_CPLUS_SPECIFIC (thistype)->template_arguments
1207c50c785cSJohn Marino #define TYPE_TEMPLATE_ARGUMENT(thistype, n) \
1208c50c785cSJohn Marino   TYPE_CPLUS_SPECIFIC (thistype)->template_arguments[n]
1209c50c785cSJohn Marino 
12105796c8dcSSimon Schubert #define TYPE_FN_FIELD(thisfn, n) (thisfn)[n]
12115796c8dcSSimon Schubert #define TYPE_FN_FIELD_PHYSNAME(thisfn, n) (thisfn)[n].physname
12125796c8dcSSimon Schubert #define TYPE_FN_FIELD_TYPE(thisfn, n) (thisfn)[n].type
12135796c8dcSSimon Schubert #define TYPE_FN_FIELD_ARGS(thisfn, n) TYPE_FIELDS ((thisfn)[n].type)
12145796c8dcSSimon Schubert #define TYPE_FN_FIELD_CONST(thisfn, n) ((thisfn)[n].is_const)
12155796c8dcSSimon Schubert #define TYPE_FN_FIELD_VOLATILE(thisfn, n) ((thisfn)[n].is_volatile)
12165796c8dcSSimon Schubert #define TYPE_FN_FIELD_PRIVATE(thisfn, n) ((thisfn)[n].is_private)
12175796c8dcSSimon Schubert #define TYPE_FN_FIELD_PROTECTED(thisfn, n) ((thisfn)[n].is_protected)
12185796c8dcSSimon Schubert #define TYPE_FN_FIELD_PUBLIC(thisfn, n) ((thisfn)[n].is_public)
12195796c8dcSSimon Schubert #define TYPE_FN_FIELD_STATIC(thisfn, n) ((thisfn)[n].is_static)
12205796c8dcSSimon Schubert #define TYPE_FN_FIELD_FINAL(thisfn, n) ((thisfn)[n].is_final)
12215796c8dcSSimon Schubert #define TYPE_FN_FIELD_SYNCHRONIZED(thisfn, n) ((thisfn)[n].is_synchronized)
12225796c8dcSSimon Schubert #define TYPE_FN_FIELD_NATIVE(thisfn, n) ((thisfn)[n].is_native)
12235796c8dcSSimon Schubert #define TYPE_FN_FIELD_ARTIFICIAL(thisfn, n) ((thisfn)[n].is_artificial)
12245796c8dcSSimon Schubert #define TYPE_FN_FIELD_ABSTRACT(thisfn, n) ((thisfn)[n].is_abstract)
12255796c8dcSSimon Schubert #define TYPE_FN_FIELD_STUB(thisfn, n) ((thisfn)[n].is_stub)
1226*ef5ccd6cSJohn Marino #define TYPE_FN_FIELD_CONSTRUCTOR(thisfn, n) ((thisfn)[n].is_constructor)
12275796c8dcSSimon Schubert #define TYPE_FN_FIELD_FCONTEXT(thisfn, n) ((thisfn)[n].fcontext)
12285796c8dcSSimon Schubert #define TYPE_FN_FIELD_VOFFSET(thisfn, n) ((thisfn)[n].voffset-2)
12295796c8dcSSimon Schubert #define TYPE_FN_FIELD_VIRTUAL_P(thisfn, n) ((thisfn)[n].voffset > 1)
12305796c8dcSSimon Schubert #define TYPE_FN_FIELD_STATIC_P(thisfn, n) ((thisfn)[n].voffset == VOFFSET_STATIC)
12315796c8dcSSimon Schubert 
1232cf7f2e2dSJohn Marino #define TYPE_TYPEDEF_FIELD_ARRAY(thistype) \
1233cf7f2e2dSJohn Marino   TYPE_CPLUS_SPECIFIC (thistype)->typedef_field
1234cf7f2e2dSJohn Marino #define TYPE_TYPEDEF_FIELD(thistype, n) \
1235cf7f2e2dSJohn Marino   TYPE_CPLUS_SPECIFIC (thistype)->typedef_field[n]
1236cf7f2e2dSJohn Marino #define TYPE_TYPEDEF_FIELD_NAME(thistype, n) \
1237cf7f2e2dSJohn Marino   TYPE_TYPEDEF_FIELD (thistype, n).name
1238cf7f2e2dSJohn Marino #define TYPE_TYPEDEF_FIELD_TYPE(thistype, n) \
1239cf7f2e2dSJohn Marino   TYPE_TYPEDEF_FIELD (thistype, n).type
1240cf7f2e2dSJohn Marino #define TYPE_TYPEDEF_FIELD_COUNT(thistype) \
1241cf7f2e2dSJohn Marino   TYPE_CPLUS_SPECIFIC (thistype)->typedef_field_count
1242cf7f2e2dSJohn Marino 
1243c50c785cSJohn Marino #define TYPE_IS_OPAQUE(thistype) \
1244c50c785cSJohn Marino   (((TYPE_CODE (thistype) == TYPE_CODE_STRUCT) \
1245c50c785cSJohn Marino     || (TYPE_CODE (thistype) == TYPE_CODE_UNION)) \
1246c50c785cSJohn Marino    && (TYPE_NFIELDS (thistype) == 0) \
1247c50c785cSJohn Marino    && (!HAVE_CPLUS_STRUCT (thistype) \
1248c50c785cSJohn Marino        || TYPE_NFN_FIELDS (thistype) == 0) \
1249c50c785cSJohn Marino    && (TYPE_STUB (thistype) || !TYPE_STUB_SUPPORTED (thistype)))
12505796c8dcSSimon Schubert 
1251a45ae5f8SJohn Marino /* A helper macro that returns the name of a type or "unnamed type" if the type
1252a45ae5f8SJohn Marino    has no name.  */
1253a45ae5f8SJohn Marino #define TYPE_SAFE_NAME(type) \
1254a45ae5f8SJohn Marino   (TYPE_NAME (type) ? TYPE_NAME (type) : _("<unnamed type>"))
1255a45ae5f8SJohn Marino 
1256cf7f2e2dSJohn Marino /* A helper macro that returns the name of an error type.  If the type
1257cf7f2e2dSJohn Marino    has a name, it is used; otherwise, a default is used.  */
1258cf7f2e2dSJohn Marino #define TYPE_ERROR_NAME(type) \
1259cf7f2e2dSJohn Marino   (TYPE_NAME (type) ? TYPE_NAME (type) : _("<error type>"))
1260cf7f2e2dSJohn Marino 
12615796c8dcSSimon Schubert struct builtin_type
12625796c8dcSSimon Schubert {
12635796c8dcSSimon Schubert   /* Integral types.  */
12645796c8dcSSimon Schubert 
1265c50c785cSJohn Marino   /* Implicit size/sign (based on the architecture's ABI).  */
12665796c8dcSSimon Schubert   struct type *builtin_void;
12675796c8dcSSimon Schubert   struct type *builtin_char;
12685796c8dcSSimon Schubert   struct type *builtin_short;
12695796c8dcSSimon Schubert   struct type *builtin_int;
12705796c8dcSSimon Schubert   struct type *builtin_long;
12715796c8dcSSimon Schubert   struct type *builtin_signed_char;
12725796c8dcSSimon Schubert   struct type *builtin_unsigned_char;
12735796c8dcSSimon Schubert   struct type *builtin_unsigned_short;
12745796c8dcSSimon Schubert   struct type *builtin_unsigned_int;
12755796c8dcSSimon Schubert   struct type *builtin_unsigned_long;
12765796c8dcSSimon Schubert   struct type *builtin_float;
12775796c8dcSSimon Schubert   struct type *builtin_double;
12785796c8dcSSimon Schubert   struct type *builtin_long_double;
12795796c8dcSSimon Schubert   struct type *builtin_complex;
12805796c8dcSSimon Schubert   struct type *builtin_double_complex;
12815796c8dcSSimon Schubert   struct type *builtin_string;
12825796c8dcSSimon Schubert   struct type *builtin_bool;
12835796c8dcSSimon Schubert   struct type *builtin_long_long;
12845796c8dcSSimon Schubert   struct type *builtin_unsigned_long_long;
12855796c8dcSSimon Schubert   struct type *builtin_decfloat;
12865796c8dcSSimon Schubert   struct type *builtin_decdouble;
12875796c8dcSSimon Schubert   struct type *builtin_declong;
12885796c8dcSSimon Schubert 
12895796c8dcSSimon Schubert   /* "True" character types.
12905796c8dcSSimon Schubert       We use these for the '/c' print format, because c_char is just a
12915796c8dcSSimon Schubert       one-byte integral type, which languages less laid back than C
12925796c8dcSSimon Schubert       will print as ... well, a one-byte integral type.  */
12935796c8dcSSimon Schubert   struct type *builtin_true_char;
12945796c8dcSSimon Schubert   struct type *builtin_true_unsigned_char;
12955796c8dcSSimon Schubert 
12965796c8dcSSimon Schubert   /* Explicit sizes - see C9X <intypes.h> for naming scheme.  The "int0"
12975796c8dcSSimon Schubert      is for when an architecture needs to describe a register that has
12985796c8dcSSimon Schubert      no size.  */
12995796c8dcSSimon Schubert   struct type *builtin_int0;
13005796c8dcSSimon Schubert   struct type *builtin_int8;
13015796c8dcSSimon Schubert   struct type *builtin_uint8;
13025796c8dcSSimon Schubert   struct type *builtin_int16;
13035796c8dcSSimon Schubert   struct type *builtin_uint16;
13045796c8dcSSimon Schubert   struct type *builtin_int32;
13055796c8dcSSimon Schubert   struct type *builtin_uint32;
13065796c8dcSSimon Schubert   struct type *builtin_int64;
13075796c8dcSSimon Schubert   struct type *builtin_uint64;
13085796c8dcSSimon Schubert   struct type *builtin_int128;
13095796c8dcSSimon Schubert   struct type *builtin_uint128;
13105796c8dcSSimon Schubert 
1311cf7f2e2dSJohn Marino   /* Wide character types.  */
1312cf7f2e2dSJohn Marino   struct type *builtin_char16;
1313cf7f2e2dSJohn Marino   struct type *builtin_char32;
13145796c8dcSSimon Schubert 
13155796c8dcSSimon Schubert   /* Pointer types.  */
13165796c8dcSSimon Schubert 
13175796c8dcSSimon Schubert   /* `pointer to data' type.  Some target platforms use an implicitly
13185796c8dcSSimon Schubert      {sign,zero} -extended 32-bit ABI pointer on a 64-bit ISA.  */
13195796c8dcSSimon Schubert   struct type *builtin_data_ptr;
13205796c8dcSSimon Schubert 
13215796c8dcSSimon Schubert   /* `pointer to function (returning void)' type.  Harvard
13225796c8dcSSimon Schubert      architectures mean that ABI function and code pointers are not
13235796c8dcSSimon Schubert      interconvertible.  Similarly, since ANSI, C standards have
13245796c8dcSSimon Schubert      explicitly said that pointers to functions and pointers to data
13255796c8dcSSimon Schubert      are not interconvertible --- that is, you can't cast a function
13265796c8dcSSimon Schubert      pointer to void * and back, and expect to get the same value.
13275796c8dcSSimon Schubert      However, all function pointer types are interconvertible, so void
13285796c8dcSSimon Schubert      (*) () can server as a generic function pointer.  */
13295796c8dcSSimon Schubert   struct type *builtin_func_ptr;
13305796c8dcSSimon Schubert 
1331c50c785cSJohn Marino   /* `function returning pointer to function (returning void)' type.
1332c50c785cSJohn Marino      The final void return type is not significant for it.  */
1333c50c785cSJohn Marino   struct type *builtin_func_func;
1334c50c785cSJohn Marino 
13355796c8dcSSimon Schubert 
13365796c8dcSSimon Schubert   /* Special-purpose types.  */
13375796c8dcSSimon Schubert 
13385796c8dcSSimon Schubert   /* This type is used to represent a GDB internal function.  */
13395796c8dcSSimon Schubert   struct type *internal_fn;
13405796c8dcSSimon Schubert };
13415796c8dcSSimon Schubert 
13425796c8dcSSimon Schubert /* Return the type table for the specified architecture.  */
13435796c8dcSSimon Schubert extern const struct builtin_type *builtin_type (struct gdbarch *gdbarch);
13445796c8dcSSimon Schubert 
13455796c8dcSSimon Schubert 
13465796c8dcSSimon Schubert /* Per-objfile types used by symbol readers.  */
13475796c8dcSSimon Schubert 
13485796c8dcSSimon Schubert struct objfile_type
13495796c8dcSSimon Schubert {
13505796c8dcSSimon Schubert   /* Basic types based on the objfile architecture.  */
13515796c8dcSSimon Schubert   struct type *builtin_void;
13525796c8dcSSimon Schubert   struct type *builtin_char;
13535796c8dcSSimon Schubert   struct type *builtin_short;
13545796c8dcSSimon Schubert   struct type *builtin_int;
13555796c8dcSSimon Schubert   struct type *builtin_long;
13565796c8dcSSimon Schubert   struct type *builtin_long_long;
13575796c8dcSSimon Schubert   struct type *builtin_signed_char;
13585796c8dcSSimon Schubert   struct type *builtin_unsigned_char;
13595796c8dcSSimon Schubert   struct type *builtin_unsigned_short;
13605796c8dcSSimon Schubert   struct type *builtin_unsigned_int;
13615796c8dcSSimon Schubert   struct type *builtin_unsigned_long;
13625796c8dcSSimon Schubert   struct type *builtin_unsigned_long_long;
13635796c8dcSSimon Schubert   struct type *builtin_float;
13645796c8dcSSimon Schubert   struct type *builtin_double;
13655796c8dcSSimon Schubert   struct type *builtin_long_double;
13665796c8dcSSimon Schubert 
13675796c8dcSSimon Schubert   /* This type is used to represent symbol addresses.  */
13685796c8dcSSimon Schubert   struct type *builtin_core_addr;
13695796c8dcSSimon Schubert 
13705796c8dcSSimon Schubert   /* This type represents a type that was unrecognized in symbol read-in.  */
13715796c8dcSSimon Schubert   struct type *builtin_error;
13725796c8dcSSimon Schubert 
13735796c8dcSSimon Schubert   /* Types used for symbols with no debug information.  */
13745796c8dcSSimon Schubert   struct type *nodebug_text_symbol;
1375c50c785cSJohn Marino   struct type *nodebug_text_gnu_ifunc_symbol;
1376c50c785cSJohn Marino   struct type *nodebug_got_plt_symbol;
13775796c8dcSSimon Schubert   struct type *nodebug_data_symbol;
13785796c8dcSSimon Schubert   struct type *nodebug_unknown_symbol;
13795796c8dcSSimon Schubert   struct type *nodebug_tls_symbol;
13805796c8dcSSimon Schubert };
13815796c8dcSSimon Schubert 
13825796c8dcSSimon Schubert /* Return the type table for the specified objfile.  */
13835796c8dcSSimon Schubert extern const struct objfile_type *objfile_type (struct objfile *objfile);
13845796c8dcSSimon Schubert 
13855796c8dcSSimon Schubert 
13865796c8dcSSimon Schubert /* Explicit floating-point formats.  See "floatformat.h".  */
1387cf7f2e2dSJohn Marino extern const struct floatformat *floatformats_ieee_half[BFD_ENDIAN_UNKNOWN];
13885796c8dcSSimon Schubert extern const struct floatformat *floatformats_ieee_single[BFD_ENDIAN_UNKNOWN];
13895796c8dcSSimon Schubert extern const struct floatformat *floatformats_ieee_double[BFD_ENDIAN_UNKNOWN];
13905796c8dcSSimon Schubert extern const struct floatformat *floatformats_ieee_double_littlebyte_bigword[BFD_ENDIAN_UNKNOWN];
13915796c8dcSSimon Schubert extern const struct floatformat *floatformats_i387_ext[BFD_ENDIAN_UNKNOWN];
13925796c8dcSSimon Schubert extern const struct floatformat *floatformats_m68881_ext[BFD_ENDIAN_UNKNOWN];
13935796c8dcSSimon Schubert extern const struct floatformat *floatformats_arm_ext[BFD_ENDIAN_UNKNOWN];
13945796c8dcSSimon Schubert extern const struct floatformat *floatformats_ia64_spill[BFD_ENDIAN_UNKNOWN];
13955796c8dcSSimon Schubert extern const struct floatformat *floatformats_ia64_quad[BFD_ENDIAN_UNKNOWN];
13965796c8dcSSimon Schubert extern const struct floatformat *floatformats_vax_f[BFD_ENDIAN_UNKNOWN];
13975796c8dcSSimon Schubert extern const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN];
13985796c8dcSSimon Schubert extern const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN];
13995796c8dcSSimon Schubert 
14005796c8dcSSimon Schubert 
14015796c8dcSSimon Schubert /* Allocate space for storing data associated with a particular type.
14025796c8dcSSimon Schubert    We ensure that the space is allocated using the same mechanism that
1403c50c785cSJohn Marino    was used to allocate the space for the type structure itself.  I.e.
14045796c8dcSSimon Schubert    if the type is on an objfile's objfile_obstack, then the space for data
14055796c8dcSSimon Schubert    associated with that type will also be allocated on the objfile_obstack.
14065796c8dcSSimon Schubert    If the type is not associated with any particular objfile (such as
14075796c8dcSSimon Schubert    builtin types), then the data space will be allocated with xmalloc,
14085796c8dcSSimon Schubert    the same as for the type structure.  */
14095796c8dcSSimon Schubert 
14105796c8dcSSimon Schubert #define TYPE_ALLOC(t,size)  \
14115796c8dcSSimon Schubert    (TYPE_OBJFILE_OWNED (t) \
14125796c8dcSSimon Schubert     ? obstack_alloc (&TYPE_OBJFILE (t) -> objfile_obstack, size) \
14135796c8dcSSimon Schubert     : xmalloc (size))
14145796c8dcSSimon Schubert 
14155796c8dcSSimon Schubert #define TYPE_ZALLOC(t,size)  \
14165796c8dcSSimon Schubert    (TYPE_OBJFILE_OWNED (t) \
14175796c8dcSSimon Schubert     ? memset (obstack_alloc (&TYPE_OBJFILE (t)->objfile_obstack, size),  \
14185796c8dcSSimon Schubert 	      0, size)  \
14195796c8dcSSimon Schubert     : xzalloc (size))
14205796c8dcSSimon Schubert 
14215796c8dcSSimon Schubert /* Use alloc_type to allocate a type owned by an objfile.
14225796c8dcSSimon Schubert    Use alloc_type_arch to allocate a type owned by an architecture.
14235796c8dcSSimon Schubert    Use alloc_type_copy to allocate a type with the same owner as a
14245796c8dcSSimon Schubert    pre-existing template type, no matter whether objfile or gdbarch.  */
14255796c8dcSSimon Schubert extern struct type *alloc_type (struct objfile *);
14265796c8dcSSimon Schubert extern struct type *alloc_type_arch (struct gdbarch *);
14275796c8dcSSimon Schubert extern struct type *alloc_type_copy (const struct type *);
14285796c8dcSSimon Schubert 
14295796c8dcSSimon Schubert /* Return the type's architecture.  For types owned by an architecture,
14305796c8dcSSimon Schubert    that architecture is returned.  For types owned by an objfile, that
14315796c8dcSSimon Schubert    objfile's architecture is returned.  */
14325796c8dcSSimon Schubert extern struct gdbarch *get_type_arch (const struct type *);
14335796c8dcSSimon Schubert 
14345796c8dcSSimon Schubert /* Helper function to construct objfile-owned types.  */
1435*ef5ccd6cSJohn Marino extern struct type *init_type (enum type_code, int, int, const char *,
14365796c8dcSSimon Schubert 			       struct objfile *);
14375796c8dcSSimon Schubert 
14385796c8dcSSimon Schubert /* Helper functions to construct architecture-owned types.  */
14395796c8dcSSimon Schubert extern struct type *arch_type (struct gdbarch *, enum type_code, int, char *);
14405796c8dcSSimon Schubert extern struct type *arch_integer_type (struct gdbarch *, int, int, char *);
14415796c8dcSSimon Schubert extern struct type *arch_character_type (struct gdbarch *, int, int, char *);
14425796c8dcSSimon Schubert extern struct type *arch_boolean_type (struct gdbarch *, int, int, char *);
14435796c8dcSSimon Schubert extern struct type *arch_float_type (struct gdbarch *, int, char *,
14445796c8dcSSimon Schubert 				     const struct floatformat **);
14455796c8dcSSimon Schubert extern struct type *arch_complex_type (struct gdbarch *, char *,
14465796c8dcSSimon Schubert 				       struct type *);
14475796c8dcSSimon Schubert 
14485796c8dcSSimon Schubert /* Helper functions to construct a struct or record type.  An
14495796c8dcSSimon Schubert    initially empty type is created using arch_composite_type().
1450cf7f2e2dSJohn Marino    Fields are then added using append_composite_type_field*().  A union
14515796c8dcSSimon Schubert    type has its size set to the largest field.  A struct type has each
14525796c8dcSSimon Schubert    field packed against the previous.  */
14535796c8dcSSimon Schubert 
14545796c8dcSSimon Schubert extern struct type *arch_composite_type (struct gdbarch *gdbarch,
14555796c8dcSSimon Schubert 					 char *name, enum type_code code);
14565796c8dcSSimon Schubert extern void append_composite_type_field (struct type *t, char *name,
14575796c8dcSSimon Schubert 					 struct type *field);
14585796c8dcSSimon Schubert extern void append_composite_type_field_aligned (struct type *t,
14595796c8dcSSimon Schubert 						 char *name,
14605796c8dcSSimon Schubert 						 struct type *field,
14615796c8dcSSimon Schubert 						 int alignment);
1462cf7f2e2dSJohn Marino struct field *append_composite_type_field_raw (struct type *t, char *name,
1463cf7f2e2dSJohn Marino 					       struct type *field);
14645796c8dcSSimon Schubert 
14655796c8dcSSimon Schubert /* Helper functions to construct a bit flags type.  An initially empty
14665796c8dcSSimon Schubert    type is created using arch_flag_type().  Flags are then added using
14675796c8dcSSimon Schubert    append_flag_type_flag().  */
14685796c8dcSSimon Schubert extern struct type *arch_flags_type (struct gdbarch *gdbarch,
14695796c8dcSSimon Schubert 				     char *name, int length);
14705796c8dcSSimon Schubert extern void append_flags_type_flag (struct type *type, int bitpos, char *name);
14715796c8dcSSimon Schubert 
14725796c8dcSSimon Schubert extern void make_vector_type (struct type *array_type);
14735796c8dcSSimon Schubert extern struct type *init_vector_type (struct type *elt_type, int n);
14745796c8dcSSimon Schubert 
14755796c8dcSSimon Schubert extern struct type *lookup_reference_type (struct type *);
14765796c8dcSSimon Schubert 
14775796c8dcSSimon Schubert extern struct type *make_reference_type (struct type *, struct type **);
14785796c8dcSSimon Schubert 
14795796c8dcSSimon Schubert extern struct type *make_cv_type (int, int, struct type *, struct type **);
14805796c8dcSSimon Schubert 
1481*ef5ccd6cSJohn Marino extern struct type *make_restrict_type (struct type *);
1482*ef5ccd6cSJohn Marino 
14835796c8dcSSimon Schubert extern void replace_type (struct type *, struct type *);
14845796c8dcSSimon Schubert 
14855796c8dcSSimon Schubert extern int address_space_name_to_int (struct gdbarch *, char *);
14865796c8dcSSimon Schubert 
14875796c8dcSSimon Schubert extern const char *address_space_int_to_name (struct gdbarch *, int);
14885796c8dcSSimon Schubert 
14895796c8dcSSimon Schubert extern struct type *make_type_with_address_space (struct type *type,
14905796c8dcSSimon Schubert 						  int space_identifier);
14915796c8dcSSimon Schubert 
14925796c8dcSSimon Schubert extern struct type *lookup_memberptr_type (struct type *, struct type *);
14935796c8dcSSimon Schubert 
14945796c8dcSSimon Schubert extern struct type *lookup_methodptr_type (struct type *);
14955796c8dcSSimon Schubert 
14965796c8dcSSimon Schubert extern void smash_to_method_type (struct type *type, struct type *domain,
14975796c8dcSSimon Schubert 				  struct type *to_type, struct field *args,
14985796c8dcSSimon Schubert 				  int nargs, int varargs);
14995796c8dcSSimon Schubert 
15005796c8dcSSimon Schubert extern void smash_to_memberptr_type (struct type *, struct type *,
15015796c8dcSSimon Schubert 				     struct type *);
15025796c8dcSSimon Schubert 
1503cf7f2e2dSJohn Marino extern void smash_to_methodptr_type (struct type *, struct type *);
1504cf7f2e2dSJohn Marino 
15055796c8dcSSimon Schubert extern struct type *allocate_stub_method (struct type *);
15065796c8dcSSimon Schubert 
1507*ef5ccd6cSJohn Marino extern const char *type_name_no_tag (const struct type *);
15085796c8dcSSimon Schubert 
1509a45ae5f8SJohn Marino extern const char *type_name_no_tag_or_error (struct type *type);
1510a45ae5f8SJohn Marino 
15115796c8dcSSimon Schubert extern struct type *lookup_struct_elt_type (struct type *, char *, int);
15125796c8dcSSimon Schubert 
15135796c8dcSSimon Schubert extern struct type *make_pointer_type (struct type *, struct type **);
15145796c8dcSSimon Schubert 
15155796c8dcSSimon Schubert extern struct type *lookup_pointer_type (struct type *);
15165796c8dcSSimon Schubert 
15175796c8dcSSimon Schubert extern struct type *make_function_type (struct type *, struct type **);
15185796c8dcSSimon Schubert 
15195796c8dcSSimon Schubert extern struct type *lookup_function_type (struct type *);
15205796c8dcSSimon Schubert 
1521*ef5ccd6cSJohn Marino extern struct type *lookup_function_type_with_arguments (struct type *,
1522*ef5ccd6cSJohn Marino 							 int,
1523*ef5ccd6cSJohn Marino 							 struct type **);
1524*ef5ccd6cSJohn Marino 
1525cf7f2e2dSJohn Marino extern struct type *create_range_type (struct type *, struct type *, LONGEST,
1526cf7f2e2dSJohn Marino 				       LONGEST);
15275796c8dcSSimon Schubert 
15285796c8dcSSimon Schubert extern struct type *create_array_type (struct type *, struct type *,
15295796c8dcSSimon Schubert 				       struct type *);
1530*ef5ccd6cSJohn Marino extern struct type *lookup_array_range_type (struct type *, LONGEST, LONGEST);
15315796c8dcSSimon Schubert 
15325796c8dcSSimon Schubert extern struct type *create_string_type (struct type *, struct type *,
15335796c8dcSSimon Schubert 					struct type *);
1534*ef5ccd6cSJohn Marino extern struct type *lookup_string_range_type (struct type *, LONGEST, LONGEST);
15355796c8dcSSimon Schubert 
15365796c8dcSSimon Schubert extern struct type *create_set_type (struct type *, struct type *);
15375796c8dcSSimon Schubert 
15385796c8dcSSimon Schubert extern struct type *lookup_unsigned_typename (const struct language_defn *,
1539*ef5ccd6cSJohn Marino 					      struct gdbarch *, const char *);
15405796c8dcSSimon Schubert 
15415796c8dcSSimon Schubert extern struct type *lookup_signed_typename (const struct language_defn *,
1542*ef5ccd6cSJohn Marino 					    struct gdbarch *, const char *);
15435796c8dcSSimon Schubert 
15445796c8dcSSimon Schubert extern struct type *check_typedef (struct type *);
15455796c8dcSSimon Schubert 
15465796c8dcSSimon Schubert #define CHECK_TYPEDEF(TYPE)			\
15475796c8dcSSimon Schubert   do {						\
15485796c8dcSSimon Schubert     (TYPE) = check_typedef (TYPE);		\
15495796c8dcSSimon Schubert   } while (0)
15505796c8dcSSimon Schubert 
15515796c8dcSSimon Schubert extern void check_stub_method_group (struct type *, int);
15525796c8dcSSimon Schubert 
15535796c8dcSSimon Schubert extern char *gdb_mangle_name (struct type *, int, int);
15545796c8dcSSimon Schubert 
15555796c8dcSSimon Schubert extern struct type *lookup_typename (const struct language_defn *,
1556a45ae5f8SJohn Marino 				     struct gdbarch *, const char *,
1557c50c785cSJohn Marino 				     const struct block *, int);
15585796c8dcSSimon Schubert 
15595796c8dcSSimon Schubert extern struct type *lookup_template_type (char *, struct type *,
1560*ef5ccd6cSJohn Marino 					  const struct block *);
15615796c8dcSSimon Schubert 
15625796c8dcSSimon Schubert extern int get_vptr_fieldno (struct type *, struct type **);
15635796c8dcSSimon Schubert 
15645796c8dcSSimon Schubert extern int get_discrete_bounds (struct type *, LONGEST *, LONGEST *);
15655796c8dcSSimon Schubert 
1566c50c785cSJohn Marino extern int get_array_bounds (struct type *type, LONGEST *low_bound,
1567c50c785cSJohn Marino 			     LONGEST *high_bound);
1568c50c785cSJohn Marino 
1569cf7f2e2dSJohn Marino extern int class_types_same_p (const struct type *, const struct type *);
1570cf7f2e2dSJohn Marino 
15715796c8dcSSimon Schubert extern int is_ancestor (struct type *, struct type *);
15725796c8dcSSimon Schubert 
1573cf7f2e2dSJohn Marino extern int is_public_ancestor (struct type *, struct type *);
1574cf7f2e2dSJohn Marino 
1575cf7f2e2dSJohn Marino extern int is_unique_ancestor (struct type *, struct value *);
1576cf7f2e2dSJohn Marino 
15775796c8dcSSimon Schubert /* Overload resolution */
15785796c8dcSSimon Schubert 
15795796c8dcSSimon Schubert #define LENGTH_MATCH(bv) ((bv)->rank[0])
15805796c8dcSSimon Schubert 
1581c50c785cSJohn Marino /* Badness if parameter list length doesn't match arg list length.  */
1582c50c785cSJohn Marino extern const struct rank LENGTH_MISMATCH_BADNESS;
15835796c8dcSSimon Schubert 
1584c50c785cSJohn Marino /* Dummy badness value for nonexistent parameter positions.  */
1585c50c785cSJohn Marino extern const struct rank TOO_FEW_PARAMS_BADNESS;
1586c50c785cSJohn Marino /* Badness if no conversion among types.  */
1587c50c785cSJohn Marino extern const struct rank INCOMPATIBLE_TYPE_BADNESS;
1588c50c785cSJohn Marino 
1589c50c785cSJohn Marino /* Badness of an exact match.  */
1590c50c785cSJohn Marino extern const struct rank EXACT_MATCH_BADNESS;
1591c50c785cSJohn Marino 
1592c50c785cSJohn Marino /* Badness of integral promotion.  */
1593c50c785cSJohn Marino extern const struct rank INTEGER_PROMOTION_BADNESS;
1594c50c785cSJohn Marino /* Badness of floating promotion.  */
1595c50c785cSJohn Marino extern const struct rank FLOAT_PROMOTION_BADNESS;
1596c50c785cSJohn Marino /* Badness of converting a derived class pointer
1597c50c785cSJohn Marino    to a base class pointer.  */
1598c50c785cSJohn Marino extern const struct rank BASE_PTR_CONVERSION_BADNESS;
1599c50c785cSJohn Marino /* Badness of integral conversion.  */
1600c50c785cSJohn Marino extern const struct rank INTEGER_CONVERSION_BADNESS;
1601c50c785cSJohn Marino /* Badness of floating conversion.  */
1602c50c785cSJohn Marino extern const struct rank FLOAT_CONVERSION_BADNESS;
1603c50c785cSJohn Marino /* Badness of integer<->floating conversions.  */
1604c50c785cSJohn Marino extern const struct rank INT_FLOAT_CONVERSION_BADNESS;
1605c50c785cSJohn Marino /* Badness of conversion of pointer to void pointer.  */
1606c50c785cSJohn Marino extern const struct rank VOID_PTR_CONVERSION_BADNESS;
1607*ef5ccd6cSJohn Marino /* Badness of conversion to boolean.  */
1608*ef5ccd6cSJohn Marino extern const struct rank BOOL_CONVERSION_BADNESS;
1609c50c785cSJohn Marino /* Badness of converting derived to base class.  */
1610c50c785cSJohn Marino extern const struct rank BASE_CONVERSION_BADNESS;
1611c50c785cSJohn Marino /* Badness of converting from non-reference to reference.  */
1612c50c785cSJohn Marino extern const struct rank REFERENCE_CONVERSION_BADNESS;
1613a45ae5f8SJohn Marino /* Badness of converting integer 0 to NULL pointer.  */
1614a45ae5f8SJohn Marino extern const struct rank NULL_POINTER_CONVERSION;
16155796c8dcSSimon Schubert 
16165796c8dcSSimon Schubert /* Non-standard conversions allowed by the debugger */
1617c50c785cSJohn Marino /* Converting a pointer to an int is usually OK.  */
1618c50c785cSJohn Marino extern const struct rank NS_POINTER_CONVERSION_BADNESS;
16195796c8dcSSimon Schubert 
1620*ef5ccd6cSJohn Marino /* Badness of converting a (non-zero) integer constant
1621*ef5ccd6cSJohn Marino    to a pointer.  */
1622*ef5ccd6cSJohn Marino extern const struct rank NS_INTEGER_POINTER_CONVERSION_BADNESS;
16235796c8dcSSimon Schubert 
1624c50c785cSJohn Marino extern struct rank sum_ranks (struct rank a, struct rank b);
1625c50c785cSJohn Marino extern int compare_ranks (struct rank a, struct rank b);
1626c50c785cSJohn Marino 
16275796c8dcSSimon Schubert extern int compare_badness (struct badness_vector *, struct badness_vector *);
16285796c8dcSSimon Schubert 
16295796c8dcSSimon Schubert extern struct badness_vector *rank_function (struct type **, int,
1630a45ae5f8SJohn Marino 					     struct value **, int);
16315796c8dcSSimon Schubert 
1632a45ae5f8SJohn Marino extern struct rank rank_one_type (struct type *, struct type *,
1633a45ae5f8SJohn Marino 				  struct value *);
16345796c8dcSSimon Schubert 
16355796c8dcSSimon Schubert extern void recursive_dump_type (struct type *, int);
16365796c8dcSSimon Schubert 
16375796c8dcSSimon Schubert extern int field_is_static (struct field *);
16385796c8dcSSimon Schubert 
16395796c8dcSSimon Schubert /* printcmd.c */
16405796c8dcSSimon Schubert 
16415796c8dcSSimon Schubert extern void print_scalar_formatted (const void *, struct type *,
16425796c8dcSSimon Schubert 				    const struct value_print_options *,
16435796c8dcSSimon Schubert 				    int, struct ui_file *);
16445796c8dcSSimon Schubert 
16455796c8dcSSimon Schubert extern int can_dereference (struct type *);
16465796c8dcSSimon Schubert 
16475796c8dcSSimon Schubert extern int is_integral_type (struct type *);
16485796c8dcSSimon Schubert 
1649c50c785cSJohn Marino extern int is_scalar_type_recursive (struct type *);
1650c50c785cSJohn Marino 
16515796c8dcSSimon Schubert extern void maintenance_print_type (char *, int);
16525796c8dcSSimon Schubert 
16535796c8dcSSimon Schubert extern htab_t create_copied_types_hash (struct objfile *objfile);
16545796c8dcSSimon Schubert 
16555796c8dcSSimon Schubert extern struct type *copy_type_recursive (struct objfile *objfile,
16565796c8dcSSimon Schubert 					 struct type *type,
16575796c8dcSSimon Schubert 					 htab_t copied_types);
16585796c8dcSSimon Schubert 
16595796c8dcSSimon Schubert extern struct type *copy_type (const struct type *type);
16605796c8dcSSimon Schubert 
1661*ef5ccd6cSJohn Marino extern int types_equal (struct type *, struct type *);
1662*ef5ccd6cSJohn Marino 
16635796c8dcSSimon Schubert #endif /* GDBTYPES_H */
1664