xref: /openbsd/gnu/usr.bin/binutils/gdb/gdbtypes.h (revision 63addd46)
1e93f7393Sniklas /* Internal type definitions for GDB.
2b725ae77Skettenis 
3b725ae77Skettenis    Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
4b725ae77Skettenis    2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5b725ae77Skettenis 
6e93f7393Sniklas    Contributed by Cygnus Support, using pieces from other GDB modules.
7e93f7393Sniklas 
8e93f7393Sniklas    This file is part of GDB.
9e93f7393Sniklas 
10e93f7393Sniklas    This program is free software; you can redistribute it and/or modify
11e93f7393Sniklas    it under the terms of the GNU General Public License as published by
12e93f7393Sniklas    the Free Software Foundation; either version 2 of the License, or
13e93f7393Sniklas    (at your option) any later version.
14e93f7393Sniklas 
15e93f7393Sniklas    This program is distributed in the hope that it will be useful,
16e93f7393Sniklas    but WITHOUT ANY WARRANTY; without even the implied warranty of
17e93f7393Sniklas    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18e93f7393Sniklas    GNU General Public License for more details.
19e93f7393Sniklas 
20e93f7393Sniklas    You should have received a copy of the GNU General Public License
21e93f7393Sniklas    along with this program; if not, write to the Free Software
22b725ae77Skettenis    Foundation, Inc., 59 Temple Place - Suite 330,
23b725ae77Skettenis    Boston, MA 02111-1307, USA.  */
24e93f7393Sniklas 
25e93f7393Sniklas #if !defined (GDBTYPES_H)
26e93f7393Sniklas #define GDBTYPES_H 1
27e93f7393Sniklas 
28b725ae77Skettenis /* Forward declarations for prototypes.  */
29b725ae77Skettenis struct field;
30b725ae77Skettenis struct block;
31b725ae77Skettenis 
32e93f7393Sniklas /* Codes for `fundamental types'.  This is a monstrosity based on the
33e93f7393Sniklas    bogus notion that there are certain compiler-independent
34e93f7393Sniklas    `fundamental types'.  None of these is well-defined (how big is
35e93f7393Sniklas    FT_SHORT?  Does it depend on the language?  How does the
36e93f7393Sniklas    language-specific code know which type to correlate to FT_SHORT?)  */
37e93f7393Sniklas 
38e93f7393Sniklas #define FT_VOID			0
39e93f7393Sniklas #define FT_BOOLEAN		1
40b725ae77Skettenis #define FT_CHAR			2	/* we use this for not-unsigned C/C++ chars */
41b725ae77Skettenis #define FT_SIGNED_CHAR		3	/* we use this for C++ signed chars */
42b725ae77Skettenis #define FT_UNSIGNED_CHAR	4	/* we use this for C/C++ unsigned chars */
43e93f7393Sniklas #define FT_SHORT		5
44e93f7393Sniklas #define FT_SIGNED_SHORT		6
45e93f7393Sniklas #define FT_UNSIGNED_SHORT	7
46e93f7393Sniklas #define FT_INTEGER		8
47e93f7393Sniklas #define FT_SIGNED_INTEGER	9
48e93f7393Sniklas #define FT_UNSIGNED_INTEGER	10
49e93f7393Sniklas #define FT_LONG			11
50e93f7393Sniklas #define FT_SIGNED_LONG		12
51e93f7393Sniklas #define FT_UNSIGNED_LONG	13
52e93f7393Sniklas #define FT_LONG_LONG		14
53e93f7393Sniklas #define FT_SIGNED_LONG_LONG	15
54e93f7393Sniklas #define FT_UNSIGNED_LONG_LONG	16
55e93f7393Sniklas #define FT_FLOAT		17
56e93f7393Sniklas #define FT_DBL_PREC_FLOAT	18
57e93f7393Sniklas #define FT_EXT_PREC_FLOAT	19
58e93f7393Sniklas #define FT_COMPLEX		20
59e93f7393Sniklas #define FT_DBL_PREC_COMPLEX	21
60e93f7393Sniklas #define FT_EXT_PREC_COMPLEX	22
61e93f7393Sniklas #define FT_STRING		23
62e93f7393Sniklas #define FT_FIXED_DECIMAL	24
63e93f7393Sniklas #define FT_FLOAT_DECIMAL	25
64e93f7393Sniklas #define FT_BYTE			26
65e93f7393Sniklas #define FT_UNSIGNED_BYTE	27
66b725ae77Skettenis #define FT_TEMPLATE_ARG		28
67e93f7393Sniklas 
68b725ae77Skettenis #define FT_NUM_MEMBERS		29	/* Highest FT_* above, plus one. */
69e93f7393Sniklas 
70e93f7393Sniklas /* Some macros for char-based bitfields.  */
71e93f7393Sniklas 
72e93f7393Sniklas #define B_SET(a,x)	((a)[(x)>>3] |= (1 << ((x)&7)))
73e93f7393Sniklas #define B_CLR(a,x)	((a)[(x)>>3] &= ~(1 << ((x)&7)))
74e93f7393Sniklas #define B_TST(a,x)	((a)[(x)>>3] & (1 << ((x)&7)))
75e93f7393Sniklas #define B_TYPE		unsigned char
76e93f7393Sniklas #define	B_BYTES(x)	( 1 + ((x)>>3) )
77e93f7393Sniklas #define	B_CLRALL(a,x)	memset ((a), 0, B_BYTES(x))
78e93f7393Sniklas 
79e93f7393Sniklas /* Different kinds of data types are distinguished by the `code' field.  */
80e93f7393Sniklas 
81e93f7393Sniklas enum type_code
82e93f7393Sniklas   {
83e93f7393Sniklas     TYPE_CODE_UNDEF,		/* Not used; catches errors */
84e93f7393Sniklas     TYPE_CODE_PTR,		/* Pointer type */
85*63addd46Skettenis 
86*63addd46Skettenis     /* Array type with lower & upper bounds.
87*63addd46Skettenis 
88*63addd46Skettenis        Regardless of the language, GDB represents multidimensional
89*63addd46Skettenis        array types the way C does: as arrays of arrays.  So an
90*63addd46Skettenis        instance of a GDB array type T can always be seen as a series
91*63addd46Skettenis        of instances of TYPE_TARGET_TYPE (T) laid out sequentially in
92*63addd46Skettenis        memory.
93*63addd46Skettenis 
94*63addd46Skettenis        Row-major languages like C lay out multi-dimensional arrays so
95*63addd46Skettenis        that incrementing the rightmost index in a subscripting
96*63addd46Skettenis        expression results in the smallest change in the address of the
97*63addd46Skettenis        element referred to.  Column-major languages like Fortran lay
98*63addd46Skettenis        them out so that incrementing the leftmost index results in the
99*63addd46Skettenis        smallest change.
100*63addd46Skettenis 
101*63addd46Skettenis        This means that, in column-major languages, working our way
102*63addd46Skettenis        from type to target type corresponds to working through indices
103*63addd46Skettenis        from right to left, not left to right.  */
104*63addd46Skettenis     TYPE_CODE_ARRAY,
105*63addd46Skettenis 
106e93f7393Sniklas     TYPE_CODE_STRUCT,		/* C struct or Pascal record */
107e93f7393Sniklas     TYPE_CODE_UNION,		/* C union or Pascal variant part */
108e93f7393Sniklas     TYPE_CODE_ENUM,		/* Enumeration type */
109e93f7393Sniklas     TYPE_CODE_FUNC,		/* Function type */
110e93f7393Sniklas     TYPE_CODE_INT,		/* Integer type */
111e93f7393Sniklas 
112e93f7393Sniklas     /* Floating type.  This is *NOT* a complex type.  Beware, there are parts
113e93f7393Sniklas        of GDB which bogusly assume that TYPE_CODE_FLT can mean complex.  */
114e93f7393Sniklas     TYPE_CODE_FLT,
115e93f7393Sniklas 
116e93f7393Sniklas     /* Void type.  The length field specifies the length (probably always
117e93f7393Sniklas        one) which is used in pointer arithmetic involving pointers to
118e93f7393Sniklas        this type, but actually dereferencing such a pointer is invalid;
119e93f7393Sniklas        a void type has no length and no actual representation in memory
120e93f7393Sniklas        or registers.  A pointer to a void type is a generic pointer.  */
121e93f7393Sniklas     TYPE_CODE_VOID,
122e93f7393Sniklas 
123e93f7393Sniklas     TYPE_CODE_SET,		/* Pascal sets */
124e93f7393Sniklas     TYPE_CODE_RANGE,		/* Range (integers within spec'd bounds) */
125e93f7393Sniklas 
126e93f7393Sniklas     /* A string type which is like an array of character but prints
127b725ae77Skettenis        differently (at least for (the deleted) CHILL).  It does not
128b725ae77Skettenis        contain a length field as Pascal strings (for many Pascals,
129b725ae77Skettenis        anyway) do; if we want to deal with such strings, we should use
130b725ae77Skettenis        a new type code.  */
131e93f7393Sniklas     TYPE_CODE_STRING,
132e93f7393Sniklas 
133b725ae77Skettenis     /* String of bits; like TYPE_CODE_SET but prints differently (at
134b725ae77Skettenis        least for (the deleted) CHILL).  */
135e93f7393Sniklas     TYPE_CODE_BITSTRING,
136e93f7393Sniklas 
137e93f7393Sniklas     /* Unknown type.  The length field is valid if we were able to
138e93f7393Sniklas        deduce that much about the type, or 0 if we don't even know that.  */
139e93f7393Sniklas     TYPE_CODE_ERROR,
140e93f7393Sniklas 
141e93f7393Sniklas     /* C++ */
142e93f7393Sniklas     TYPE_CODE_MEMBER,		/* Member type */
143e93f7393Sniklas     TYPE_CODE_METHOD,		/* Method type */
144e93f7393Sniklas     TYPE_CODE_REF,		/* C++ Reference types */
145e93f7393Sniklas 
146e93f7393Sniklas     TYPE_CODE_CHAR,		/* *real* character type */
147e93f7393Sniklas 
148e93f7393Sniklas     /* Boolean type.  0 is false, 1 is true, and other values are non-boolean
149e93f7393Sniklas        (e.g. FORTRAN "logical" used as unsigned int).  */
150e93f7393Sniklas     TYPE_CODE_BOOL,
151e93f7393Sniklas 
152e93f7393Sniklas     /* Fortran */
153e93f7393Sniklas     TYPE_CODE_COMPLEX,		/* Complex float */
154e93f7393Sniklas 
155b725ae77Skettenis     TYPE_CODE_TYPEDEF,
156b725ae77Skettenis     TYPE_CODE_TEMPLATE,		/* C++ template */
157b725ae77Skettenis     TYPE_CODE_TEMPLATE_ARG,	/* C++ template arg */
158b725ae77Skettenis 
159*63addd46Skettenis     TYPE_CODE_NAMESPACE		/* C++ namespace.  */
160e93f7393Sniklas   };
161e93f7393Sniklas 
162e93f7393Sniklas /* For now allow source to use TYPE_CODE_CLASS for C++ classes, as an
163e93f7393Sniklas    alias for TYPE_CODE_STRUCT.  This is for DWARF, which has a distinct
164e93f7393Sniklas    "class" attribute.  Perhaps we should actually have a separate TYPE_CODE
165e93f7393Sniklas    so that we can print "class" or "struct" depending on what the debug
166e93f7393Sniklas    info said.  It's not clear we should bother.  */
167e93f7393Sniklas 
168e93f7393Sniklas #define TYPE_CODE_CLASS TYPE_CODE_STRUCT
169e93f7393Sniklas 
170b725ae77Skettenis /* Some bits for the type's flags word, and macros to test them. */
171e93f7393Sniklas 
172e93f7393Sniklas /* Unsigned integer type.  If this is not set for a TYPE_CODE_INT, the
173b725ae77Skettenis    type is signed (unless TYPE_FLAG_NOSIGN (below) is set). */
174e93f7393Sniklas 
175e93f7393Sniklas #define TYPE_FLAG_UNSIGNED	(1 << 0)
176b725ae77Skettenis #define TYPE_UNSIGNED(t)	(TYPE_FLAGS (t) & TYPE_FLAG_UNSIGNED)
177b725ae77Skettenis 
178b725ae77Skettenis /* No sign for this type.  In C++, "char", "signed char", and "unsigned
179b725ae77Skettenis    char" are distinct types; so we need an extra flag to indicate the
180b725ae77Skettenis    absence of a sign! */
181b725ae77Skettenis 
182b725ae77Skettenis #define TYPE_FLAG_NOSIGN	(1 << 1)
183b725ae77Skettenis #define TYPE_NOSIGN(t)		(TYPE_FLAGS (t) & TYPE_FLAG_NOSIGN)
184e93f7393Sniklas 
185e93f7393Sniklas /* This appears in a type's flags word if it is a stub type (e.g., if
186e93f7393Sniklas    someone referenced a type that wasn't defined in a source file
187e93f7393Sniklas    via (struct sir_not_appearing_in_this_film *)).  */
188e93f7393Sniklas 
189e93f7393Sniklas #define TYPE_FLAG_STUB		(1 << 2)
190b725ae77Skettenis #define TYPE_STUB(t)		(TYPE_FLAGS (t) & TYPE_FLAG_STUB)
191e93f7393Sniklas 
192e93f7393Sniklas /* The target type of this type is a stub type, and this type needs to
193e93f7393Sniklas    be updated if it gets un-stubbed in check_typedef.
194e93f7393Sniklas    Used for arrays and ranges, in which TYPE_LENGTH of the array/range
195e93f7393Sniklas    gets set based on the TYPE_LENGTH of the target type.
196e93f7393Sniklas    Also, set for TYPE_CODE_TYPEDEF. */
197e93f7393Sniklas 
198e93f7393Sniklas #define TYPE_FLAG_TARGET_STUB	(1 << 3)
199b725ae77Skettenis #define TYPE_TARGET_STUB(t)	(TYPE_FLAGS (t) & TYPE_FLAG_TARGET_STUB)
200b725ae77Skettenis 
201b725ae77Skettenis /* Static type.  If this is set, the corresponding type had
202b725ae77Skettenis  * a static modifier.
203b725ae77Skettenis  * Note: This may be unnecessary, since static data members
204b725ae77Skettenis  * are indicated by other means (bitpos == -1)
205b725ae77Skettenis  */
206b725ae77Skettenis 
207b725ae77Skettenis #define TYPE_FLAG_STATIC	(1 << 4)
208b725ae77Skettenis #define TYPE_STATIC(t)		(TYPE_FLAGS (t) & TYPE_FLAG_STATIC)
209b725ae77Skettenis 
210b725ae77Skettenis /* Constant type.  If this is set, the corresponding type has a
211b725ae77Skettenis  * const modifier.
212b725ae77Skettenis  */
213b725ae77Skettenis 
214b725ae77Skettenis #define TYPE_FLAG_CONST		(1 << 5)
215b725ae77Skettenis #define TYPE_CONST(t)		(TYPE_INSTANCE_FLAGS (t) & TYPE_FLAG_CONST)
216b725ae77Skettenis 
217b725ae77Skettenis /* Volatile type.  If this is set, the corresponding type has a
218b725ae77Skettenis  * volatile modifier.
219b725ae77Skettenis  */
220b725ae77Skettenis 
221b725ae77Skettenis #define TYPE_FLAG_VOLATILE	(1 << 6)
222b725ae77Skettenis #define TYPE_VOLATILE(t)	(TYPE_INSTANCE_FLAGS (t) & TYPE_FLAG_VOLATILE)
223b725ae77Skettenis 
224e93f7393Sniklas 
225e93f7393Sniklas /* This is a function type which appears to have a prototype.  We need this
226e93f7393Sniklas    for function calls in order to tell us if it's necessary to coerce the args,
227b725ae77Skettenis    or to just do the standard conversions.  This is used with a short field. */
228e93f7393Sniklas 
229b725ae77Skettenis #define TYPE_FLAG_PROTOTYPED	(1 << 7)
230b725ae77Skettenis #define TYPE_PROTOTYPED(t)	(TYPE_FLAGS (t) & TYPE_FLAG_PROTOTYPED)
231e93f7393Sniklas 
232b725ae77Skettenis /* This flag is used to indicate that processing for this type
233b725ae77Skettenis    is incomplete.
234b725ae77Skettenis 
235b725ae77Skettenis    (Mostly intended for HP platforms, where class methods, for
236b725ae77Skettenis    instance, can be encountered before their classes in the debug
237b725ae77Skettenis    info; the incomplete type has to be marked so that the class and
238b725ae77Skettenis    the method can be assigned correct types.) */
239b725ae77Skettenis 
240b725ae77Skettenis #define TYPE_FLAG_INCOMPLETE	(1 << 8)
241b725ae77Skettenis #define TYPE_INCOMPLETE(t)	(TYPE_FLAGS (t) & TYPE_FLAG_INCOMPLETE)
242b725ae77Skettenis 
243b725ae77Skettenis /* Instruction-space delimited type.  This is for Harvard architectures
244b725ae77Skettenis    which have separate instruction and data address spaces (and perhaps
245b725ae77Skettenis    others).
246b725ae77Skettenis 
247b725ae77Skettenis    GDB usually defines a flat address space that is a superset of the
248b725ae77Skettenis    architecture's two (or more) address spaces, but this is an extension
249b725ae77Skettenis    of the architecture's model.
250b725ae77Skettenis 
251b725ae77Skettenis    If TYPE_FLAG_INST is set, an object of the corresponding type
252b725ae77Skettenis    resides in instruction memory, even if its address (in the extended
253b725ae77Skettenis    flat address space) does not reflect this.
254b725ae77Skettenis 
255b725ae77Skettenis    Similarly, if TYPE_FLAG_DATA is set, then an object of the
256b725ae77Skettenis    corresponding type resides in the data memory space, even if
257b725ae77Skettenis    this is not indicated by its (flat address space) address.
258b725ae77Skettenis 
259b725ae77Skettenis    If neither flag is set, the default space for functions / methods
260b725ae77Skettenis    is instruction space, and for data objects is data memory.  */
261b725ae77Skettenis 
262b725ae77Skettenis #define TYPE_FLAG_CODE_SPACE	(1 << 9)
263b725ae77Skettenis #define TYPE_CODE_SPACE(t)	(TYPE_INSTANCE_FLAGS (t) & TYPE_FLAG_CODE_SPACE)
264b725ae77Skettenis 
265b725ae77Skettenis #define TYPE_FLAG_DATA_SPACE	(1 << 10)
266b725ae77Skettenis #define TYPE_DATA_SPACE(t)	(TYPE_INSTANCE_FLAGS (t) & TYPE_FLAG_DATA_SPACE)
267b725ae77Skettenis 
268b725ae77Skettenis /* FIXME drow/2002-06-03:  Only used for methods, but applies as well
269b725ae77Skettenis    to functions.  */
270b725ae77Skettenis 
271b725ae77Skettenis #define TYPE_FLAG_VARARGS	(1 << 11)
272b725ae77Skettenis #define TYPE_VARARGS(t)		(TYPE_FLAGS (t) & TYPE_FLAG_VARARGS)
273b725ae77Skettenis 
274b725ae77Skettenis /* Identify a vector type.  Gcc is handling this by adding an extra
275b725ae77Skettenis    attribute to the array type.  We slurp that in as a new flag of a
276b725ae77Skettenis    type.  This is used only in dwarf2read.c.  */
277b725ae77Skettenis #define TYPE_FLAG_VECTOR	(1 << 12)
278b725ae77Skettenis #define TYPE_VECTOR(t)		(TYPE_FLAGS (t) & TYPE_FLAG_VECTOR)
279b725ae77Skettenis 
280b725ae77Skettenis /* Address class flags.  Some environments provide for pointers whose
281b725ae77Skettenis    size is different from that of a normal pointer or address types
282b725ae77Skettenis    where the bits are interpreted differently than normal addresses.  The
283b725ae77Skettenis    TYPE_FLAG_ADDRESS_CLASS_n flags may be used in target specific
284b725ae77Skettenis    ways to represent these different types of address classes.  */
285b725ae77Skettenis #define TYPE_FLAG_ADDRESS_CLASS_1 (1 << 13)
286b725ae77Skettenis #define TYPE_ADDRESS_CLASS_1(t) (TYPE_INSTANCE_FLAGS(t) \
287b725ae77Skettenis                                  & TYPE_FLAG_ADDRESS_CLASS_1)
288b725ae77Skettenis #define TYPE_FLAG_ADDRESS_CLASS_2 (1 << 14)
289b725ae77Skettenis #define TYPE_ADDRESS_CLASS_2(t) (TYPE_INSTANCE_FLAGS(t) \
290b725ae77Skettenis 				 & TYPE_FLAG_ADDRESS_CLASS_2)
291b725ae77Skettenis #define TYPE_FLAG_ADDRESS_CLASS_ALL (TYPE_FLAG_ADDRESS_CLASS_1 \
292b725ae77Skettenis 				     | TYPE_FLAG_ADDRESS_CLASS_2)
293b725ae77Skettenis #define TYPE_ADDRESS_CLASS_ALL(t) (TYPE_INSTANCE_FLAGS(t) \
294b725ae77Skettenis 				   & TYPE_FLAG_ADDRESS_CLASS_ALL)
295b725ae77Skettenis 
296*63addd46Skettenis /* The debugging formats (especially STABS) do not contain enough information
297*63addd46Skettenis    to represent all Ada types---especially those whose size depends on
298*63addd46Skettenis    dynamic quantities.  Therefore, the GNAT Ada compiler includes
299*63addd46Skettenis    extra information in the form of additional type definitions
300*63addd46Skettenis    connected by naming conventions.  This flag indicates that the
301*63addd46Skettenis    type is an ordinary (unencoded) GDB type that has been created from
302*63addd46Skettenis    the necessary run-time information, and does not need further
303*63addd46Skettenis    interpretation. Optionally marks ordinary, fixed-size GDB type. */
304*63addd46Skettenis 
305*63addd46Skettenis #define TYPE_FLAG_FIXED_INSTANCE (1 << 15)
306*63addd46Skettenis 
307b725ae77Skettenis /*  Array bound type.  */
308b725ae77Skettenis enum array_bound_type
309e93f7393Sniklas {
310b725ae77Skettenis   BOUND_SIMPLE = 0,
311b725ae77Skettenis   BOUND_BY_VALUE_IN_REG,
312b725ae77Skettenis   BOUND_BY_REF_IN_REG,
313b725ae77Skettenis   BOUND_BY_VALUE_ON_STACK,
314b725ae77Skettenis   BOUND_BY_REF_ON_STACK,
315b725ae77Skettenis   BOUND_CANNOT_BE_DETERMINED
316b725ae77Skettenis };
317e93f7393Sniklas 
318b725ae77Skettenis /* This structure is space-critical.
319b725ae77Skettenis    Its layout has been tweaked to reduce the space used.  */
320b725ae77Skettenis 
321b725ae77Skettenis struct main_type
322b725ae77Skettenis {
323e93f7393Sniklas   /* Code for kind of type */
324e93f7393Sniklas 
325b725ae77Skettenis   ENUM_BITFIELD(type_code) code : 8;
326b725ae77Skettenis 
327b725ae77Skettenis   /* Array bounds.  These fields appear at this location because
328b725ae77Skettenis      they pack nicely here.  */
329b725ae77Skettenis 
330b725ae77Skettenis   ENUM_BITFIELD(array_bound_type) upper_bound_type : 4;
331b725ae77Skettenis   ENUM_BITFIELD(array_bound_type) lower_bound_type : 4;
332e93f7393Sniklas 
333e93f7393Sniklas   /* Name of this type, or NULL if none.
334e93f7393Sniklas 
335e93f7393Sniklas      This is used for printing only, except by poorly designed C++ code.
336b725ae77Skettenis      For looking up a name, look for a symbol in the VAR_DOMAIN.  */
337e93f7393Sniklas 
338e93f7393Sniklas   char *name;
339e93f7393Sniklas 
340e93f7393Sniklas   /* Tag name for this type, or NULL if none.  This means that the
341e93f7393Sniklas      name of the type consists of a keyword followed by the tag name.
342e93f7393Sniklas      Which keyword is determined by the type code ("struct" for
343e93f7393Sniklas      TYPE_CODE_STRUCT, etc.).  As far as I know C/C++ are the only languages
344e93f7393Sniklas      with this feature.
345e93f7393Sniklas 
346e93f7393Sniklas      This is used for printing only, except by poorly designed C++ code.
347b725ae77Skettenis      For looking up a name, look for a symbol in the STRUCT_DOMAIN.
348e93f7393Sniklas      One more legitimate use is that if TYPE_FLAG_STUB is set, this is
349e93f7393Sniklas      the name to use to look for definitions in other files.  */
350e93f7393Sniklas 
351e93f7393Sniklas   char *tag_name;
352e93f7393Sniklas 
353e93f7393Sniklas   /* Every type is now associated with a particular objfile, and the
354b725ae77Skettenis      type is allocated on the objfile_obstack for that objfile.  One problem
355e93f7393Sniklas      however, is that there are times when gdb allocates new types while
356e93f7393Sniklas      it is not in the process of reading symbols from a particular objfile.
357e93f7393Sniklas      Fortunately, these happen when the type being created is a derived
358e93f7393Sniklas      type of an existing type, such as in lookup_pointer_type().  So
359e93f7393Sniklas      we can just allocate the new type using the same objfile as the
360e93f7393Sniklas      existing type, but to do this we need a backpointer to the objfile
361e93f7393Sniklas      from the existing type.  Yes this is somewhat ugly, but without
362e93f7393Sniklas      major overhaul of the internal type system, it can't be avoided
363e93f7393Sniklas      for now. */
364e93f7393Sniklas 
365e93f7393Sniklas   struct objfile *objfile;
366e93f7393Sniklas 
367e93f7393Sniklas   /* For a pointer type, describes the type of object pointed to.
368e93f7393Sniklas      For an array type, describes the type of the elements.
369e93f7393Sniklas      For a function or method type, describes the type of the return value.
370e93f7393Sniklas      For a range type, describes the type of the full range.
371e93f7393Sniklas      For a complex type, describes the type of each coordinate.
372e93f7393Sniklas      Unused otherwise.  */
373e93f7393Sniklas 
374e93f7393Sniklas   struct type *target_type;
375e93f7393Sniklas 
376e93f7393Sniklas   /* Flags about this type.  */
377e93f7393Sniklas 
378b725ae77Skettenis   int flags;
379e93f7393Sniklas 
380e93f7393Sniklas   /* Number of fields described for this type */
381e93f7393Sniklas 
382e93f7393Sniklas   short nfields;
383e93f7393Sniklas 
384b725ae77Skettenis   /* Field number of the virtual function table pointer in
385b725ae77Skettenis      VPTR_BASETYPE.  If -1, we were unable to find the virtual
386b725ae77Skettenis      function table pointer in initial symbol reading, and
387b725ae77Skettenis      fill_in_vptr_fieldno should be called to find it if possible.
388b725ae77Skettenis 
389b725ae77Skettenis      Unused if this type does not have virtual functions.  */
390b725ae77Skettenis 
391b725ae77Skettenis   short vptr_fieldno;
392b725ae77Skettenis 
393e93f7393Sniklas   /* For structure and union types, a description of each field.
394e93f7393Sniklas      For set and pascal array types, there is one "field",
395e93f7393Sniklas      whose type is the domain type of the set or array.
396e93f7393Sniklas      For range types, there are two "fields",
397e93f7393Sniklas      the minimum and maximum values (both inclusive).
398e93f7393Sniklas      For enum types, each possible value is described by one "field".
399b725ae77Skettenis      For a function or method type, a "field" for each parameter.
400e93f7393Sniklas      For C++ classes, there is one field for each base class (if it is
401e93f7393Sniklas      a derived class) plus one field for each class data member.  Member
402e93f7393Sniklas      functions are recorded elsewhere.
403e93f7393Sniklas 
404e93f7393Sniklas      Using a pointer to a separate array of fields
405e93f7393Sniklas      allows all types to have the same size, which is useful
406e93f7393Sniklas      because we can allocate the space for a type before
407e93f7393Sniklas      we know what to put in it.  */
408e93f7393Sniklas 
409e93f7393Sniklas   struct field
410e93f7393Sniklas   {
411b725ae77Skettenis     union field_location
412b725ae77Skettenis     {
413e93f7393Sniklas       /* Position of this field, counting in bits from start of
414b725ae77Skettenis 	 containing structure.
415e93f7393Sniklas 	 For BITS_BIG_ENDIAN=1 targets, it is the bit offset to the MSB.
416b725ae77Skettenis 	 For BITS_BIG_ENDIAN=0 targets, it is the bit offset to the LSB.
417b725ae77Skettenis 	 For a range bound or enum value, this is the value itself. */
418e93f7393Sniklas 
419e93f7393Sniklas       int bitpos;
420e93f7393Sniklas 
421b725ae77Skettenis       /* For a static field, if TYPE_FIELD_STATIC_HAS_ADDR then physaddr
422b725ae77Skettenis 	 is the location (in the target) of the static field.
423b725ae77Skettenis 	 Otherwise, physname is the mangled label of the static field. */
424b725ae77Skettenis 
425b725ae77Skettenis       CORE_ADDR physaddr;
426b725ae77Skettenis       char *physname;
427b725ae77Skettenis     }
428b725ae77Skettenis     loc;
429b725ae77Skettenis 
430b725ae77Skettenis     /* For a function or member type, this is 1 if the argument is marked
431b725ae77Skettenis        artificial.  Artificial arguments should not be shown to the
432b725ae77Skettenis        user.  */
433b725ae77Skettenis     unsigned int artificial : 1;
434b725ae77Skettenis 
435b725ae77Skettenis     /* This flag is zero for non-static fields, 1 for fields whose location
436b725ae77Skettenis        is specified by the label loc.physname, and 2 for fields whose location
437b725ae77Skettenis        is specified by loc.physaddr.  */
438b725ae77Skettenis 
439b725ae77Skettenis     unsigned int static_kind : 2;
440b725ae77Skettenis 
441e93f7393Sniklas     /* Size of this field, in bits, or zero if not packed.
442e93f7393Sniklas        For an unpacked field, the field's type's length
443e93f7393Sniklas        says how many bytes the field occupies.  */
444e93f7393Sniklas 
445b725ae77Skettenis     unsigned int bitsize : 29;
446e93f7393Sniklas 
447b725ae77Skettenis     /* In a struct or union type, type of this field.
448b725ae77Skettenis        In a function or member type, type of this argument.
449e93f7393Sniklas        In an array type, the domain-type of the array.  */
450e93f7393Sniklas 
451e93f7393Sniklas     struct type *type;
452e93f7393Sniklas 
453e93f7393Sniklas     /* Name of field, value or argument.
454b725ae77Skettenis        NULL for range bounds, array domains, and member function
455b725ae77Skettenis        arguments.  */
456e93f7393Sniklas 
457e93f7393Sniklas     char *name;
458e93f7393Sniklas 
459e93f7393Sniklas   } *fields;
460e93f7393Sniklas 
461b725ae77Skettenis   /* For types with virtual functions (TYPE_CODE_STRUCT), VPTR_BASETYPE
462b725ae77Skettenis      is the base class which defined the virtual function table pointer.
463e93f7393Sniklas 
464b725ae77Skettenis      For types that are pointer to member types (TYPE_CODE_MEMBER),
465b725ae77Skettenis      VPTR_BASETYPE is the type that this pointer is a member of.
466b725ae77Skettenis 
467b725ae77Skettenis      For method types (TYPE_CODE_METHOD), VPTR_BASETYPE is the aggregate
468b725ae77Skettenis      type that contains the method.
469e93f7393Sniklas 
470e93f7393Sniklas      Unused otherwise.  */
471e93f7393Sniklas 
472e93f7393Sniklas   struct type *vptr_basetype;
473e93f7393Sniklas 
474e93f7393Sniklas   /* Slot to point to additional language-specific fields of this type.  */
475e93f7393Sniklas 
476e93f7393Sniklas   union type_specific
477e93f7393Sniklas   {
478e93f7393Sniklas     /* CPLUS_STUFF is for TYPE_CODE_STRUCT.  It is initialized to point to
479e93f7393Sniklas        cplus_struct_default, a default static instance of a struct
480e93f7393Sniklas        cplus_struct_type. */
481e93f7393Sniklas 
482e93f7393Sniklas     struct cplus_struct_type *cplus_stuff;
483e93f7393Sniklas 
484b725ae77Skettenis     /* FLOATFORMAT is for TYPE_CODE_FLT.  It is a pointer to the
485b725ae77Skettenis        floatformat object that describes the floating-point value
486b725ae77Skettenis        that resides within the type.  */
487b725ae77Skettenis 
488b725ae77Skettenis     const struct floatformat *floatformat;
489e93f7393Sniklas   } type_specific;
490e93f7393Sniklas };
491e93f7393Sniklas 
492b725ae77Skettenis /* A ``struct type'' describes a particular instance of a type, with
493b725ae77Skettenis    some particular qualification.  */
494b725ae77Skettenis struct type
495b725ae77Skettenis {
496b725ae77Skettenis   /* Type that is a pointer to this type.
497b725ae77Skettenis      NULL if no such pointer-to type is known yet.
498b725ae77Skettenis      The debugger may add the address of such a type
499b725ae77Skettenis      if it has to construct one later.  */
500b725ae77Skettenis 
501b725ae77Skettenis   struct type *pointer_type;
502b725ae77Skettenis 
503b725ae77Skettenis   /* C++: also need a reference type.  */
504b725ae77Skettenis 
505b725ae77Skettenis   struct type *reference_type;
506b725ae77Skettenis 
507b725ae77Skettenis   /* Variant chain.  This points to a type that differs from this one only
508b725ae77Skettenis      in qualifiers and length.  Currently, the possible qualifiers are
509b725ae77Skettenis      const, volatile, code-space, data-space, and address class.  The
510b725ae77Skettenis      length may differ only when one of the address class flags are set.
511b725ae77Skettenis      The variants are linked in a circular ring and share MAIN_TYPE.  */
512b725ae77Skettenis   struct type *chain;
513b725ae77Skettenis 
514b725ae77Skettenis   /* Flags specific to this instance of the type, indicating where
515b725ae77Skettenis      on the ring we are.  */
516b725ae77Skettenis   int instance_flags;
517b725ae77Skettenis 
518b725ae77Skettenis   /* Length of storage for a value of this type.  This is what
519b725ae77Skettenis      sizeof(type) would return; use it for address arithmetic,
520b725ae77Skettenis      memory reads and writes, etc.  This size includes padding.  For
521b725ae77Skettenis      example, an i386 extended-precision floating point value really
522b725ae77Skettenis      only occupies ten bytes, but most ABI's declare its size to be
523b725ae77Skettenis      12 bytes, to preserve alignment.  A `struct type' representing
524b725ae77Skettenis      such a floating-point type would have a `length' value of 12,
525b725ae77Skettenis      even though the last two bytes are unused.
526b725ae77Skettenis 
527b725ae77Skettenis      There's a bit of a host/target mess here, if you're concerned
528b725ae77Skettenis      about machines whose bytes aren't eight bits long, or who don't
529b725ae77Skettenis      have byte-addressed memory.  Various places pass this to memcpy
530b725ae77Skettenis      and such, meaning it must be in units of host bytes.  Various
531b725ae77Skettenis      other places expect they can calculate addresses by adding it
532b725ae77Skettenis      and such, meaning it must be in units of target bytes.  For
533b725ae77Skettenis      some DSP targets, in which HOST_CHAR_BIT will (presumably) be 8
534b725ae77Skettenis      and TARGET_CHAR_BIT will be (say) 32, this is a problem.
535b725ae77Skettenis 
536b725ae77Skettenis      One fix would be to make this field in bits (requiring that it
537b725ae77Skettenis      always be a multiple of HOST_CHAR_BIT and TARGET_CHAR_BIT) ---
538b725ae77Skettenis      the other choice would be to make it consistently in units of
539b725ae77Skettenis      HOST_CHAR_BIT.  However, this would still fail to address
540b725ae77Skettenis      machines based on a ternary or decimal representation.  */
541b725ae77Skettenis 
542b725ae77Skettenis   unsigned length;
543b725ae77Skettenis 
544b725ae77Skettenis   /* Core type, shared by a group of qualified types.  */
545b725ae77Skettenis   struct main_type *main_type;
546b725ae77Skettenis };
547b725ae77Skettenis 
548e93f7393Sniklas #define	NULL_TYPE ((struct type *) 0)
549e93f7393Sniklas 
550e93f7393Sniklas /* C++ language-specific information for TYPE_CODE_STRUCT and TYPE_CODE_UNION
551e93f7393Sniklas    nodes.  */
552e93f7393Sniklas 
553e93f7393Sniklas struct cplus_struct_type
554e93f7393Sniklas   {
555e93f7393Sniklas     /* Number of base classes this type derives from.  The baseclasses are
556e93f7393Sniklas        stored in the first N_BASECLASSES fields (i.e. the `fields' field of
557e93f7393Sniklas        the struct type).  I think only the `type' field of such a field has
558e93f7393Sniklas        any meaning.  */
559e93f7393Sniklas 
560e93f7393Sniklas     short n_baseclasses;
561e93f7393Sniklas 
562e93f7393Sniklas     /* Number of methods with unique names.  All overloaded methods with
563e93f7393Sniklas        the same name count only once. */
564e93f7393Sniklas 
565e93f7393Sniklas     short nfn_fields;
566e93f7393Sniklas 
567e93f7393Sniklas     /* Number of methods described for this type, not including the
568e93f7393Sniklas        methods that it derives from.  */
569e93f7393Sniklas 
570b725ae77Skettenis     short nfn_fields_total;
571b725ae77Skettenis 
572b725ae77Skettenis     /* The "declared_type" field contains a code saying how the
573b725ae77Skettenis        user really declared this type, e.g., "class s", "union s",
574b725ae77Skettenis        "struct s".
575b725ae77Skettenis        The 3 above things come out from the C++ compiler looking like classes,
576b725ae77Skettenis        but we keep track of the real declaration so we can give
577b725ae77Skettenis        the correct information on "ptype". (Note: TEMPLATE may not
578b725ae77Skettenis        belong in this list...)  */
579b725ae77Skettenis 
580b725ae77Skettenis #define DECLARED_TYPE_CLASS 0
581b725ae77Skettenis #define DECLARED_TYPE_UNION 1
582b725ae77Skettenis #define DECLARED_TYPE_STRUCT 2
583b725ae77Skettenis #define DECLARED_TYPE_TEMPLATE 3
584b725ae77Skettenis     short declared_type;	/* One of the above codes */
585e93f7393Sniklas 
586e93f7393Sniklas     /* For derived classes, the number of base classes is given by n_baseclasses
587e93f7393Sniklas        and virtual_field_bits is a bit vector containing one bit per base class.
588e93f7393Sniklas        If the base class is virtual, the corresponding bit will be set.
589e93f7393Sniklas        I.E, given:
590e93f7393Sniklas 
591e93f7393Sniklas        class A{};
592e93f7393Sniklas        class B{};
593e93f7393Sniklas        class C : public B, public virtual A {};
594e93f7393Sniklas 
595e93f7393Sniklas        B is a baseclass of C; A is a virtual baseclass for C.
596e93f7393Sniklas        This is a C++ 2.0 language feature. */
597e93f7393Sniklas 
598e93f7393Sniklas     B_TYPE *virtual_field_bits;
599e93f7393Sniklas 
600e93f7393Sniklas     /* For classes with private fields, the number of fields is given by
601e93f7393Sniklas        nfields and private_field_bits is a bit vector containing one bit
602e93f7393Sniklas        per field.
603e93f7393Sniklas        If the field is private, the corresponding bit will be set. */
604e93f7393Sniklas 
605e93f7393Sniklas     B_TYPE *private_field_bits;
606e93f7393Sniklas 
607e93f7393Sniklas     /* For classes with protected fields, the number of fields is given by
608e93f7393Sniklas        nfields and protected_field_bits is a bit vector containing one bit
609e93f7393Sniklas        per field.
610e93f7393Sniklas        If the field is private, the corresponding bit will be set. */
611e93f7393Sniklas 
612e93f7393Sniklas     B_TYPE *protected_field_bits;
613e93f7393Sniklas 
614e93f7393Sniklas     /* for classes with fields to be ignored, either this is optimized out
615e93f7393Sniklas        or this field has length 0 */
616e93f7393Sniklas 
617e93f7393Sniklas     B_TYPE *ignore_field_bits;
618e93f7393Sniklas 
619e93f7393Sniklas     /* For classes, structures, and unions, a description of each field,
620e93f7393Sniklas        which consists of an overloaded name, followed by the types of
621e93f7393Sniklas        arguments that the method expects, and then the name after it
622e93f7393Sniklas        has been renamed to make it distinct.
623e93f7393Sniklas 
624e93f7393Sniklas        fn_fieldlists points to an array of nfn_fields of these. */
625e93f7393Sniklas 
626e93f7393Sniklas     struct fn_fieldlist
627e93f7393Sniklas       {
628e93f7393Sniklas 
629e93f7393Sniklas 	/* The overloaded name.  */
630e93f7393Sniklas 
631e93f7393Sniklas 	char *name;
632e93f7393Sniklas 
633e93f7393Sniklas 	/* The number of methods with this name.  */
634e93f7393Sniklas 
635e93f7393Sniklas 	int length;
636e93f7393Sniklas 
637e93f7393Sniklas 	/* The list of methods.  */
638e93f7393Sniklas 
639e93f7393Sniklas 	struct fn_field
640e93f7393Sniklas 	  {
641e93f7393Sniklas 
642e93f7393Sniklas 	    /* If is_stub is clear, this is the mangled name which we can
643e93f7393Sniklas 	       look up to find the address of the method (FIXME: it would
644e93f7393Sniklas 	       be cleaner to have a pointer to the struct symbol here
645e93f7393Sniklas 	       instead).  */
646e93f7393Sniklas 
647e93f7393Sniklas 	    /* If is_stub is set, this is the portion of the mangled
648e93f7393Sniklas 	       name which specifies the arguments.  For example, "ii",
649e93f7393Sniklas 	       if there are two int arguments, or "" if there are no
650e93f7393Sniklas 	       arguments.  See gdb_mangle_name for the conversion from this
651e93f7393Sniklas 	       format to the one used if is_stub is clear.  */
652e93f7393Sniklas 
653e93f7393Sniklas 	    char *physname;
654e93f7393Sniklas 
655b725ae77Skettenis 	    /* The function type for the method.
656b725ae77Skettenis 	       (This comment used to say "The return value of the method",
657b725ae77Skettenis 	       but that's wrong. The function type
658b725ae77Skettenis 	       is expected here, i.e. something with TYPE_CODE_FUNC,
659b725ae77Skettenis 	       and *not* the return-value type). */
660e93f7393Sniklas 
661e93f7393Sniklas 	    struct type *type;
662e93f7393Sniklas 
663e93f7393Sniklas 	    /* For virtual functions.
664e93f7393Sniklas 	       First baseclass that defines this virtual function.   */
665e93f7393Sniklas 
666e93f7393Sniklas 	    struct type *fcontext;
667e93f7393Sniklas 
668e93f7393Sniklas 	    /* Attributes. */
669e93f7393Sniklas 
670e93f7393Sniklas 	    unsigned int is_const:1;
671e93f7393Sniklas 	    unsigned int is_volatile:1;
672e93f7393Sniklas 	    unsigned int is_private:1;
673e93f7393Sniklas 	    unsigned int is_protected:1;
674b725ae77Skettenis 	    unsigned int is_public:1;
675b725ae77Skettenis 	    unsigned int is_abstract:1;
676b725ae77Skettenis 	    unsigned int is_static:1;
677b725ae77Skettenis 	    unsigned int is_final:1;
678b725ae77Skettenis 	    unsigned int is_synchronized:1;
679b725ae77Skettenis 	    unsigned int is_native:1;
680b725ae77Skettenis 	    unsigned int is_artificial:1;
681e93f7393Sniklas 
682e93f7393Sniklas 	    /* A stub method only has some fields valid (but they are enough
683e93f7393Sniklas 	       to reconstruct the rest of the fields).  */
684e93f7393Sniklas 	    unsigned int is_stub:1;
685e93f7393Sniklas 
686b725ae77Skettenis 	    /* C++ method that is inlined */
687b725ae77Skettenis 	    unsigned int is_inlined:1;
688b725ae77Skettenis 
689e93f7393Sniklas 	    /* Unused.  */
690e93f7393Sniklas 	    unsigned int dummy:3;
691e93f7393Sniklas 
692e93f7393Sniklas 	    /* Index into that baseclass's virtual function table,
693e93f7393Sniklas 	       minus 2; else if static: VOFFSET_STATIC; else: 0.  */
694e93f7393Sniklas 
695b725ae77Skettenis 	    unsigned int voffset:16;
696e93f7393Sniklas 
697e93f7393Sniklas #define VOFFSET_STATIC 1
698e93f7393Sniklas 
699b725ae77Skettenis 	  }
700b725ae77Skettenis 	 *fn_fields;
701e93f7393Sniklas 
702b725ae77Skettenis       }
703b725ae77Skettenis      *fn_fieldlists;
704e93f7393Sniklas 
705b725ae77Skettenis     /* If this "struct type" describes a template, then it
706b725ae77Skettenis      * has arguments. "template_args" points to an array of
707b725ae77Skettenis      * template arg descriptors, of length "ntemplate_args".
708b725ae77Skettenis      * The only real information in each of these template arg descriptors
709b725ae77Skettenis      * is a name. "type" will typically just point to a "struct type" with
710b725ae77Skettenis      * the placeholder TYPE_CODE_TEMPLATE_ARG type.
711b725ae77Skettenis      */
712b725ae77Skettenis     short ntemplate_args;
713b725ae77Skettenis     struct template_arg
714b725ae77Skettenis       {
715b725ae77Skettenis 	char *name;
716b725ae77Skettenis 	struct type *type;
717b725ae77Skettenis       }
718b725ae77Skettenis      *template_args;
719b725ae77Skettenis 
720b725ae77Skettenis     /* If this "struct type" describes a template, it has a list
721b725ae77Skettenis      * of instantiations. "instantiations" is a pointer to an array
722b725ae77Skettenis      * of type's, one representing each instantiation. There
723b725ae77Skettenis      * are "ninstantiations" elements in this array.
724b725ae77Skettenis      */
725b725ae77Skettenis     short ninstantiations;
726b725ae77Skettenis     struct type **instantiations;
727b725ae77Skettenis 
728b725ae77Skettenis     /* The following points to information relevant to the runtime model
729b725ae77Skettenis      * of the compiler.
730b725ae77Skettenis      * Currently being used only for HP's ANSI C++ compiler.
731b725ae77Skettenis      * (This type may have to be changed/enhanced for other compilers.)
732b725ae77Skettenis      *
733b725ae77Skettenis      * RUNTIME_PTR is NULL if there is no runtime information (currently
734b725ae77Skettenis      * this means the type was not compiled by HP aCC).
735b725ae77Skettenis      *
736b725ae77Skettenis      * Fields in structure pointed to:
737b725ae77Skettenis      * ->HAS_VTABLE : 0 => no virtual table, 1 => vtable present
738b725ae77Skettenis      *
739b725ae77Skettenis      * ->PRIMARY_BASE points to the first non-virtual base class that has
740b725ae77Skettenis      * a virtual table.
741b725ae77Skettenis      *
742b725ae77Skettenis      * ->VIRTUAL_BASE_LIST points to a list of struct type * pointers that
743b725ae77Skettenis      * point to the type information for all virtual bases among this type's
744b725ae77Skettenis      * ancestors.
745b725ae77Skettenis      */
746b725ae77Skettenis     struct runtime_info
747b725ae77Skettenis       {
748b725ae77Skettenis 	short has_vtable;
749b725ae77Skettenis 	struct type *primary_base;
750b725ae77Skettenis 	struct type **virtual_base_list;
751b725ae77Skettenis       }
752b725ae77Skettenis      *runtime_ptr;
753b725ae77Skettenis 
754b725ae77Skettenis     /* Pointer to information about enclosing scope, if this is a
755b725ae77Skettenis      * local type.  If it is not a local type, this is NULL
756b725ae77Skettenis      */
757b725ae77Skettenis     struct local_type_info
758b725ae77Skettenis       {
759b725ae77Skettenis 	char *file;
760b725ae77Skettenis 	int line;
761b725ae77Skettenis       }
762b725ae77Skettenis      *localtype_ptr;
763b725ae77Skettenis   };
764b725ae77Skettenis 
765b725ae77Skettenis /* Struct used in computing virtual base list */
766b725ae77Skettenis struct vbase
767b725ae77Skettenis   {
768b725ae77Skettenis     struct type *vbasetype;	/* pointer to virtual base */
769b725ae77Skettenis     struct vbase *next;		/* next in chain */
770b725ae77Skettenis   };
771b725ae77Skettenis 
772b725ae77Skettenis /* Struct used for ranking a function for overload resolution */
773b725ae77Skettenis struct badness_vector
774b725ae77Skettenis   {
775b725ae77Skettenis     int length;
776b725ae77Skettenis     int *rank;
777e93f7393Sniklas   };
778e93f7393Sniklas 
779e93f7393Sniklas /* The default value of TYPE_CPLUS_SPECIFIC(T) points to the
780e93f7393Sniklas    this shared static structure. */
781e93f7393Sniklas 
782e93f7393Sniklas extern const struct cplus_struct_type cplus_struct_default;
783e93f7393Sniklas 
784b725ae77Skettenis extern void allocate_cplus_struct_type (struct type *);
785e93f7393Sniklas 
786e93f7393Sniklas #define INIT_CPLUS_SPECIFIC(type) \
787e93f7393Sniklas   (TYPE_CPLUS_SPECIFIC(type)=(struct cplus_struct_type*)&cplus_struct_default)
788e93f7393Sniklas #define ALLOCATE_CPLUS_STRUCT_TYPE(type) allocate_cplus_struct_type (type)
789e93f7393Sniklas #define HAVE_CPLUS_STRUCT(type) \
790e93f7393Sniklas   (TYPE_CPLUS_SPECIFIC(type) != &cplus_struct_default)
791e93f7393Sniklas 
792b725ae77Skettenis #define TYPE_INSTANCE_FLAGS(thistype) (thistype)->instance_flags
793b725ae77Skettenis #define TYPE_MAIN_TYPE(thistype) (thistype)->main_type
794b725ae77Skettenis #define TYPE_NAME(thistype) TYPE_MAIN_TYPE(thistype)->name
795b725ae77Skettenis #define TYPE_TAG_NAME(type) TYPE_MAIN_TYPE(type)->tag_name
796b725ae77Skettenis #define TYPE_TARGET_TYPE(thistype) TYPE_MAIN_TYPE(thistype)->target_type
797e93f7393Sniklas #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
798e93f7393Sniklas #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
799b725ae77Skettenis #define TYPE_CHAIN(thistype) (thistype)->chain
800e93f7393Sniklas /* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
801e93f7393Sniklas    But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
802e93f7393Sniklas    so you only have to call check_typedef once.  Since allocate_value
803e93f7393Sniklas    calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe.  */
804e93f7393Sniklas #define TYPE_LENGTH(thistype) (thistype)->length
805b725ae77Skettenis #define TYPE_OBJFILE(thistype) TYPE_MAIN_TYPE(thistype)->objfile
806b725ae77Skettenis #define TYPE_FLAGS(thistype) TYPE_MAIN_TYPE(thistype)->flags
807b725ae77Skettenis /* Note that TYPE_CODE can be TYPE_CODE_TYPEDEF, so if you want the real
808e93f7393Sniklas    type, you need to do TYPE_CODE (check_type (this_type)). */
809b725ae77Skettenis #define TYPE_CODE(thistype) TYPE_MAIN_TYPE(thistype)->code
810b725ae77Skettenis #define TYPE_NFIELDS(thistype) TYPE_MAIN_TYPE(thistype)->nfields
811b725ae77Skettenis #define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->fields
812b725ae77Skettenis #define TYPE_TEMPLATE_ARGS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->template_args
813b725ae77Skettenis #define TYPE_INSTANTIATIONS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->instantiations
814e93f7393Sniklas 
815e93f7393Sniklas #define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0)
816e93f7393Sniklas #define TYPE_LOW_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 0)
817e93f7393Sniklas #define TYPE_HIGH_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 1)
818e93f7393Sniklas 
819e93f7393Sniklas /* Moto-specific stuff for FORTRAN arrays */
820e93f7393Sniklas 
821b725ae77Skettenis #define TYPE_ARRAY_UPPER_BOUND_TYPE(thistype) \
822b725ae77Skettenis 	TYPE_MAIN_TYPE(thistype)->upper_bound_type
823b725ae77Skettenis #define TYPE_ARRAY_LOWER_BOUND_TYPE(thistype) \
824b725ae77Skettenis 	TYPE_MAIN_TYPE(thistype)->lower_bound_type
825e93f7393Sniklas 
826e93f7393Sniklas #define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
827e93f7393Sniklas    (TYPE_FIELD_BITPOS((TYPE_FIELD_TYPE((arraytype),0)),1))
828e93f7393Sniklas 
829e93f7393Sniklas #define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \
830e93f7393Sniklas    (TYPE_FIELD_BITPOS((TYPE_FIELD_TYPE((arraytype),0)),0))
831e93f7393Sniklas 
832e93f7393Sniklas /* C++ */
833e93f7393Sniklas 
834b725ae77Skettenis #define TYPE_VPTR_BASETYPE(thistype) TYPE_MAIN_TYPE(thistype)->vptr_basetype
835b725ae77Skettenis #define TYPE_DOMAIN_TYPE(thistype) TYPE_MAIN_TYPE(thistype)->vptr_basetype
836b725ae77Skettenis #define TYPE_VPTR_FIELDNO(thistype) TYPE_MAIN_TYPE(thistype)->vptr_fieldno
837e93f7393Sniklas #define TYPE_FN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fields
838e93f7393Sniklas #define TYPE_NFN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields
839e93f7393Sniklas #define TYPE_NFN_FIELDS_TOTAL(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields_total
840b725ae77Skettenis #define TYPE_NTEMPLATE_ARGS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->ntemplate_args
841b725ae77Skettenis #define TYPE_NINSTANTIATIONS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->ninstantiations
842b725ae77Skettenis #define TYPE_DECLARED_TYPE(thistype) TYPE_CPLUS_SPECIFIC(thistype)->declared_type
843b725ae77Skettenis #define	TYPE_TYPE_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific
844b725ae77Skettenis #define TYPE_CPLUS_SPECIFIC(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.cplus_stuff
845b725ae77Skettenis #define TYPE_FLOATFORMAT(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.floatformat
846b725ae77Skettenis #define TYPE_BASECLASS(thistype,index) TYPE_MAIN_TYPE(thistype)->fields[index].type
847e93f7393Sniklas #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
848b725ae77Skettenis #define TYPE_BASECLASS_NAME(thistype,index) TYPE_MAIN_TYPE(thistype)->fields[index].name
849b725ae77Skettenis #define TYPE_BASECLASS_BITPOS(thistype,index) TYPE_FIELD_BITPOS(thistype,index)
850b725ae77Skettenis #define BASETYPE_VIA_PUBLIC(thistype, index) \
851b725ae77Skettenis   ((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index)))
852e93f7393Sniklas 
853b725ae77Skettenis #define BASETYPE_VIA_VIRTUAL(thistype, index) \
854b725ae77Skettenis   (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
855b725ae77Skettenis     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
856b725ae77Skettenis 
857b725ae77Skettenis #define FIELD_TYPE(thisfld) ((thisfld).type)
858b725ae77Skettenis #define FIELD_NAME(thisfld) ((thisfld).name)
859b725ae77Skettenis #define FIELD_BITPOS(thisfld) ((thisfld).loc.bitpos)
860b725ae77Skettenis #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
861b725ae77Skettenis #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
862b725ae77Skettenis #define FIELD_STATIC_KIND(thisfld) ((thisfld).static_kind)
863b725ae77Skettenis #define FIELD_PHYSNAME(thisfld) ((thisfld).loc.physname)
864b725ae77Skettenis #define FIELD_PHYSADDR(thisfld) ((thisfld).loc.physaddr)
865b725ae77Skettenis #define SET_FIELD_PHYSNAME(thisfld, name) \
866b725ae77Skettenis   ((thisfld).static_kind = 1, FIELD_PHYSNAME(thisfld) = (name))
867b725ae77Skettenis #define SET_FIELD_PHYSADDR(thisfld, name) \
868b725ae77Skettenis   ((thisfld).static_kind = 2, FIELD_PHYSADDR(thisfld) = (name))
869b725ae77Skettenis #define TYPE_FIELD(thistype, n) TYPE_MAIN_TYPE(thistype)->fields[n]
870b725ae77Skettenis #define TYPE_FIELD_TYPE(thistype, n) FIELD_TYPE(TYPE_FIELD(thistype, n))
871b725ae77Skettenis #define TYPE_FIELD_NAME(thistype, n) FIELD_NAME(TYPE_FIELD(thistype, n))
872b725ae77Skettenis #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS(TYPE_FIELD(thistype,n))
873b725ae77Skettenis #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL(TYPE_FIELD(thistype,n))
874b725ae77Skettenis #define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE(TYPE_FIELD(thistype,n))
875b725ae77Skettenis #define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE(TYPE_FIELD(thistype,n))!=0)
876b725ae77Skettenis #define TYPE_TEMPLATE_ARG(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->template_args[n]
877b725ae77Skettenis #define TYPE_INSTANTIATION(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->instantiations[n]
878e93f7393Sniklas 
879e93f7393Sniklas #define TYPE_FIELD_PRIVATE_BITS(thistype) \
880e93f7393Sniklas   TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits
881e93f7393Sniklas #define TYPE_FIELD_PROTECTED_BITS(thistype) \
882e93f7393Sniklas   TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits
883e93f7393Sniklas #define TYPE_FIELD_IGNORE_BITS(thistype) \
884e93f7393Sniklas   TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits
885e93f7393Sniklas #define TYPE_FIELD_VIRTUAL_BITS(thistype) \
886e93f7393Sniklas   TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits
887e93f7393Sniklas #define SET_TYPE_FIELD_PRIVATE(thistype, n) \
888e93f7393Sniklas   B_SET (TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n))
889e93f7393Sniklas #define SET_TYPE_FIELD_PROTECTED(thistype, n) \
890e93f7393Sniklas   B_SET (TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n))
891e93f7393Sniklas #define SET_TYPE_FIELD_IGNORE(thistype, n) \
892e93f7393Sniklas   B_SET (TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits, (n))
893e93f7393Sniklas #define SET_TYPE_FIELD_VIRTUAL(thistype, n) \
894e93f7393Sniklas   B_SET (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n))
895e93f7393Sniklas #define TYPE_FIELD_PRIVATE(thistype, n) \
896e93f7393Sniklas   (TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits == NULL ? 0 \
897e93f7393Sniklas     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n)))
898e93f7393Sniklas #define TYPE_FIELD_PROTECTED(thistype, n) \
899e93f7393Sniklas   (TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits == NULL ? 0 \
900e93f7393Sniklas     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n)))
901e93f7393Sniklas #define TYPE_FIELD_IGNORE(thistype, n) \
902e93f7393Sniklas   (TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits == NULL ? 0 \
903e93f7393Sniklas     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits, (n)))
904e93f7393Sniklas #define TYPE_FIELD_VIRTUAL(thistype, n) \
905b725ae77Skettenis   (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
906b725ae77Skettenis     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n)))
907e93f7393Sniklas 
908b725ae77Skettenis #define TYPE_FIELD_STATIC(thistype, n) (TYPE_MAIN_TYPE (thistype)->fields[n].static_kind != 0)
909b725ae77Skettenis #define TYPE_FIELD_STATIC_KIND(thistype, n) TYPE_MAIN_TYPE (thistype)->fields[n].static_kind
910b725ae77Skettenis #define TYPE_FIELD_STATIC_HAS_ADDR(thistype, n) (TYPE_MAIN_TYPE (thistype)->fields[n].static_kind == 2)
911b725ae77Skettenis #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_PHYSNAME(TYPE_FIELD(thistype, n))
912b725ae77Skettenis #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_PHYSADDR(TYPE_FIELD(thistype, n))
913e93f7393Sniklas 
914e93f7393Sniklas #define TYPE_FN_FIELDLISTS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists
915e93f7393Sniklas #define TYPE_FN_FIELDLIST(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n]
916e93f7393Sniklas #define TYPE_FN_FIELDLIST1(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].fn_fields
917e93f7393Sniklas #define TYPE_FN_FIELDLIST_NAME(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].name
918e93f7393Sniklas #define TYPE_FN_FIELDLIST_LENGTH(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].length
919e93f7393Sniklas 
920e93f7393Sniklas #define TYPE_FN_FIELD(thisfn, n) (thisfn)[n]
921e93f7393Sniklas #define TYPE_FN_FIELD_PHYSNAME(thisfn, n) (thisfn)[n].physname
922e93f7393Sniklas #define TYPE_FN_FIELD_TYPE(thisfn, n) (thisfn)[n].type
923b725ae77Skettenis #define TYPE_FN_FIELD_ARGS(thisfn, n) TYPE_FIELDS ((thisfn)[n].type)
924e93f7393Sniklas #define TYPE_FN_FIELD_CONST(thisfn, n) ((thisfn)[n].is_const)
925e93f7393Sniklas #define TYPE_FN_FIELD_VOLATILE(thisfn, n) ((thisfn)[n].is_volatile)
926e93f7393Sniklas #define TYPE_FN_FIELD_PRIVATE(thisfn, n) ((thisfn)[n].is_private)
927e93f7393Sniklas #define TYPE_FN_FIELD_PROTECTED(thisfn, n) ((thisfn)[n].is_protected)
928b725ae77Skettenis #define TYPE_FN_FIELD_PUBLIC(thisfn, n) ((thisfn)[n].is_public)
929b725ae77Skettenis #define TYPE_FN_FIELD_STATIC(thisfn, n) ((thisfn)[n].is_static)
930b725ae77Skettenis #define TYPE_FN_FIELD_FINAL(thisfn, n) ((thisfn)[n].is_final)
931b725ae77Skettenis #define TYPE_FN_FIELD_SYNCHRONIZED(thisfn, n) ((thisfn)[n].is_synchronized)
932b725ae77Skettenis #define TYPE_FN_FIELD_NATIVE(thisfn, n) ((thisfn)[n].is_native)
933b725ae77Skettenis #define TYPE_FN_FIELD_ARTIFICIAL(thisfn, n) ((thisfn)[n].is_artificial)
934b725ae77Skettenis #define TYPE_FN_FIELD_ABSTRACT(thisfn, n) ((thisfn)[n].is_abstract)
935e93f7393Sniklas #define TYPE_FN_FIELD_STUB(thisfn, n) ((thisfn)[n].is_stub)
936b725ae77Skettenis #define TYPE_FN_FIELD_INLINED(thisfn, n) ((thisfn)[n].is_inlined)
937e93f7393Sniklas #define TYPE_FN_FIELD_FCONTEXT(thisfn, n) ((thisfn)[n].fcontext)
938e93f7393Sniklas #define TYPE_FN_FIELD_VOFFSET(thisfn, n) ((thisfn)[n].voffset-2)
939e93f7393Sniklas #define TYPE_FN_FIELD_VIRTUAL_P(thisfn, n) ((thisfn)[n].voffset > 1)
940e93f7393Sniklas #define TYPE_FN_FIELD_STATIC_P(thisfn, n) ((thisfn)[n].voffset == VOFFSET_STATIC)
941e93f7393Sniklas 
942b725ae77Skettenis #define TYPE_RUNTIME_PTR(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->runtime_ptr)
943b725ae77Skettenis #define TYPE_VTABLE(thistype) (TYPE_RUNTIME_PTR(thistype)->has_vtable)
944b725ae77Skettenis #define TYPE_HAS_VTABLE(thistype) (TYPE_RUNTIME_PTR(thistype) && TYPE_VTABLE(thistype))
945b725ae77Skettenis #define TYPE_PRIMARY_BASE(thistype) (TYPE_RUNTIME_PTR(thistype)->primary_base)
946b725ae77Skettenis #define TYPE_VIRTUAL_BASE_LIST(thistype) (TYPE_RUNTIME_PTR(thistype)->virtual_base_list)
947b725ae77Skettenis 
948b725ae77Skettenis #define TYPE_LOCALTYPE_PTR(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->localtype_ptr)
949b725ae77Skettenis #define TYPE_LOCALTYPE_FILE(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->localtype_ptr->file)
950b725ae77Skettenis #define TYPE_LOCALTYPE_LINE(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->localtype_ptr->line)
951b725ae77Skettenis 
952b725ae77Skettenis #define TYPE_IS_OPAQUE(thistype) (((TYPE_CODE (thistype) == TYPE_CODE_STRUCT) ||        \
953b725ae77Skettenis                                    (TYPE_CODE (thistype) == TYPE_CODE_UNION))        && \
954b725ae77Skettenis                                   (TYPE_NFIELDS (thistype) == 0)                     && \
955b725ae77Skettenis                                   (TYPE_CPLUS_SPECIFIC (thistype) && (TYPE_NFN_FIELDS (thistype) == 0)))
956b725ae77Skettenis 
957*63addd46Skettenis struct builtin_type
958*63addd46Skettenis {
959*63addd46Skettenis   /* Address/pointer types.  */
960b725ae77Skettenis 
961*63addd46Skettenis   /* `pointer to data' type.  Some target platforms use an implicitly
962*63addd46Skettenis      {sign,zero} -extended 32-bit ABI pointer on a 64-bit ISA.  */
963*63addd46Skettenis   struct type *builtin_data_ptr;
964*63addd46Skettenis 
965*63addd46Skettenis   /* `pointer to function (returning void)' type.  Harvard
966*63addd46Skettenis      architectures mean that ABI function and code pointers are not
967*63addd46Skettenis      interconvertible.  Similarly, since ANSI, C standards have
968*63addd46Skettenis      explicitly said that pointers to functions and pointers to data
969*63addd46Skettenis      are not interconvertible --- that is, you can't cast a function
970*63addd46Skettenis      pointer to void * and back, and expect to get the same value.
971*63addd46Skettenis      However, all function pointer types are interconvertible, so void
972*63addd46Skettenis      (*) () can server as a generic function pointer.  */
973*63addd46Skettenis   struct type *builtin_func_ptr;
974*63addd46Skettenis 
975*63addd46Skettenis   /* The target CPU's address type.  This is the ISA address size.  */
976*63addd46Skettenis   struct type *builtin_core_addr;
977*63addd46Skettenis 
978*63addd46Skettenis   /* Integral types.  */
979*63addd46Skettenis 
980*63addd46Skettenis   /* We use this for the '/c' print format, because c_char is just a
981*63addd46Skettenis      one-byte integral type, which languages less laid back than C
982*63addd46Skettenis      will print as ... well, a one-byte integral type.  */
983*63addd46Skettenis   struct type *builtin_true_char;
984*63addd46Skettenis 
985*63addd46Skettenis   /* Implicit size/sign (based on the the architecture's ABI).  */
986*63addd46Skettenis   struct type *builtin_void;
987*63addd46Skettenis   struct type *builtin_char;
988*63addd46Skettenis   struct type *builtin_short;
989*63addd46Skettenis   struct type *builtin_int;
990*63addd46Skettenis   struct type *builtin_long;
991*63addd46Skettenis   struct type *builtin_signed_char;
992*63addd46Skettenis   struct type *builtin_unsigned_char;
993*63addd46Skettenis   struct type *builtin_unsigned_short;
994*63addd46Skettenis   struct type *builtin_unsigned_int;
995*63addd46Skettenis   struct type *builtin_unsigned_long;
996*63addd46Skettenis   struct type *builtin_float;
997*63addd46Skettenis   struct type *builtin_double;
998*63addd46Skettenis   struct type *builtin_long_double;
999*63addd46Skettenis   struct type *builtin_complex;
1000*63addd46Skettenis   struct type *builtin_double_complex;
1001*63addd46Skettenis   struct type *builtin_string;
1002*63addd46Skettenis   struct type *builtin_bool;
1003*63addd46Skettenis   struct type *builtin_long_long;
1004*63addd46Skettenis   struct type *builtin_unsigned_long_long;
1005*63addd46Skettenis };
1006*63addd46Skettenis 
1007*63addd46Skettenis /* Return the type table for the specified architecture.  */
1008*63addd46Skettenis extern const struct builtin_type *builtin_type (struct gdbarch *gdbarch);
1009b725ae77Skettenis 
1010b725ae77Skettenis /* Implicit sizes */
1011e93f7393Sniklas extern struct type *builtin_type_void;
1012e93f7393Sniklas extern struct type *builtin_type_char;
1013e93f7393Sniklas extern struct type *builtin_type_short;
1014e93f7393Sniklas extern struct type *builtin_type_int;
1015e93f7393Sniklas extern struct type *builtin_type_long;
1016e93f7393Sniklas extern struct type *builtin_type_signed_char;
1017e93f7393Sniklas extern struct type *builtin_type_unsigned_char;
1018e93f7393Sniklas extern struct type *builtin_type_unsigned_short;
1019e93f7393Sniklas extern struct type *builtin_type_unsigned_int;
1020e93f7393Sniklas extern struct type *builtin_type_unsigned_long;
1021e93f7393Sniklas extern struct type *builtin_type_float;
1022e93f7393Sniklas extern struct type *builtin_type_double;
1023e93f7393Sniklas extern struct type *builtin_type_long_double;
1024e93f7393Sniklas extern struct type *builtin_type_complex;
1025e93f7393Sniklas extern struct type *builtin_type_double_complex;
1026e93f7393Sniklas extern struct type *builtin_type_string;
1027b725ae77Skettenis extern struct type *builtin_type_bool;
1028b725ae77Skettenis 
1029b725ae77Skettenis /* Address/pointer types: */
1030b725ae77Skettenis /* (C) Language `pointer to data' type.  Some target platforms use an
1031b725ae77Skettenis    implicitly {sign,zero} -extended 32 bit C language pointer on a 64
1032b725ae77Skettenis    bit ISA.  */
1033b725ae77Skettenis extern struct type *builtin_type_void_data_ptr;
1034b725ae77Skettenis 
1035b725ae77Skettenis /* (C) Language `pointer to function returning void' type.  Since
1036b725ae77Skettenis    ANSI, C standards have explicitly said that pointers to functions
1037b725ae77Skettenis    and pointers to data are not interconvertible --- that is, you
1038b725ae77Skettenis    can't cast a function pointer to void * and back, and expect to get
1039b725ae77Skettenis    the same value.  However, all function pointer types are
1040b725ae77Skettenis    interconvertible, so void (*) () can server as a generic function
1041b725ae77Skettenis    pointer.  */
1042b725ae77Skettenis extern struct type *builtin_type_void_func_ptr;
1043b725ae77Skettenis 
1044b725ae77Skettenis /* The target CPU's address type.  This is the ISA address size. */
1045b725ae77Skettenis extern struct type *builtin_type_CORE_ADDR;
1046b725ae77Skettenis /* The symbol table address type.  Some object file formats have a 32
1047b725ae77Skettenis    bit address type even though the TARGET has a 64 bit pointer type
1048b725ae77Skettenis    (cf MIPS). */
1049b725ae77Skettenis extern struct type *builtin_type_bfd_vma;
1050b725ae77Skettenis 
1051b725ae77Skettenis /* Explicit sizes - see C9X <intypes.h> for naming scheme.  The "int0"
1052b725ae77Skettenis    is for when an architecture needs to describe a register that has
1053b725ae77Skettenis    no size.  */
1054b725ae77Skettenis extern struct type *builtin_type_int0;
1055b725ae77Skettenis extern struct type *builtin_type_int8;
1056b725ae77Skettenis extern struct type *builtin_type_uint8;
1057b725ae77Skettenis extern struct type *builtin_type_int16;
1058b725ae77Skettenis extern struct type *builtin_type_uint16;
1059b725ae77Skettenis extern struct type *builtin_type_int32;
1060b725ae77Skettenis extern struct type *builtin_type_uint32;
1061b725ae77Skettenis extern struct type *builtin_type_int64;
1062b725ae77Skettenis extern struct type *builtin_type_uint64;
1063b725ae77Skettenis extern struct type *builtin_type_int128;
1064b725ae77Skettenis extern struct type *builtin_type_uint128;
1065b725ae77Skettenis 
1066b725ae77Skettenis /* SIMD types.  We inherit these names from GCC.  */
1067b725ae77Skettenis extern struct type *builtin_type_v4sf;
1068b725ae77Skettenis extern struct type *builtin_type_v4si;
1069b725ae77Skettenis extern struct type *builtin_type_v16qi;
1070b725ae77Skettenis extern struct type *builtin_type_v8qi;
1071b725ae77Skettenis extern struct type *builtin_type_v8hi;
1072b725ae77Skettenis extern struct type *builtin_type_v4hi;
1073b725ae77Skettenis extern struct type *builtin_type_v2si;
1074b725ae77Skettenis 
1075b725ae77Skettenis /* Type for 64 bit vectors. */
1076b725ae77Skettenis extern struct type *builtin_type_vec64;
1077b725ae77Skettenis extern struct type *builtin_type_vec64i;
1078b725ae77Skettenis 
1079b725ae77Skettenis /* Type for 128 bit vectors. */
1080b725ae77Skettenis extern struct type *builtin_type_vec128;
1081b725ae77Skettenis extern struct type *builtin_type_vec128i;
1082b725ae77Skettenis 
1083b725ae77Skettenis /* Explicit floating-point formats.  See "floatformat.h".  */
1084*63addd46Skettenis extern struct type *builtin_type_ieee_single[BFD_ENDIAN_UNKNOWN];
1085b725ae77Skettenis extern struct type *builtin_type_ieee_single_big;
1086b725ae77Skettenis extern struct type *builtin_type_ieee_single_little;
1087*63addd46Skettenis extern struct type *builtin_type_ieee_double[BFD_ENDIAN_UNKNOWN];
1088b725ae77Skettenis extern struct type *builtin_type_ieee_double_big;
1089b725ae77Skettenis extern struct type *builtin_type_ieee_double_little;
1090b725ae77Skettenis extern struct type *builtin_type_ieee_double_littlebyte_bigword;
1091b725ae77Skettenis extern struct type *builtin_type_i387_ext;
1092b725ae77Skettenis extern struct type *builtin_type_m68881_ext;
1093b725ae77Skettenis extern struct type *builtin_type_i960_ext;
1094b725ae77Skettenis extern struct type *builtin_type_m88110_ext;
1095b725ae77Skettenis extern struct type *builtin_type_m88110_harris_ext;
1096*63addd46Skettenis extern struct type *builtin_type_arm_ext[BFD_ENDIAN_UNKNOWN];
1097b725ae77Skettenis extern struct type *builtin_type_arm_ext_big;
1098b725ae77Skettenis extern struct type *builtin_type_arm_ext_littlebyte_bigword;
1099*63addd46Skettenis extern struct type *builtin_type_ia64_spill[BFD_ENDIAN_UNKNOWN];
1100b725ae77Skettenis extern struct type *builtin_type_ia64_spill_big;
1101b725ae77Skettenis extern struct type *builtin_type_ia64_spill_little;
1102*63addd46Skettenis extern struct type *builtin_type_ia64_quad[BFD_ENDIAN_UNKNOWN];
1103b725ae77Skettenis extern struct type *builtin_type_ia64_quad_big;
1104b725ae77Skettenis extern struct type *builtin_type_ia64_quad_little;
1105b725ae77Skettenis 
1106b725ae77Skettenis /* We use this for the '/c' print format, because builtin_type_char is
1107b725ae77Skettenis    just a one-byte integral type, which languages less laid back than
1108b725ae77Skettenis    C will print as ... well, a one-byte integral type.  */
1109b725ae77Skettenis extern struct type *builtin_type_true_char;
1110e93f7393Sniklas 
1111e93f7393Sniklas /* This type represents a type that was unrecognized in symbol
1112e93f7393Sniklas    read-in.  */
1113e93f7393Sniklas 
1114e93f7393Sniklas extern struct type *builtin_type_error;
1115e93f7393Sniklas 
1116e93f7393Sniklas extern struct type *builtin_type_long_long;
1117e93f7393Sniklas extern struct type *builtin_type_unsigned_long_long;
1118e93f7393Sniklas 
1119e93f7393Sniklas /* Modula-2 types */
1120e93f7393Sniklas 
1121e93f7393Sniklas extern struct type *builtin_type_m2_char;
1122e93f7393Sniklas extern struct type *builtin_type_m2_int;
1123e93f7393Sniklas extern struct type *builtin_type_m2_card;
1124e93f7393Sniklas extern struct type *builtin_type_m2_real;
1125e93f7393Sniklas extern struct type *builtin_type_m2_bool;
1126e93f7393Sniklas 
1127e93f7393Sniklas /* Fortran (F77) types */
1128e93f7393Sniklas 
1129e93f7393Sniklas extern struct type *builtin_type_f_character;
1130e93f7393Sniklas extern struct type *builtin_type_f_integer;
1131b725ae77Skettenis extern struct type *builtin_type_f_integer_s2;
1132e93f7393Sniklas extern struct type *builtin_type_f_logical;
1133e93f7393Sniklas extern struct type *builtin_type_f_logical_s1;
1134e93f7393Sniklas extern struct type *builtin_type_f_logical_s2;
1135e93f7393Sniklas extern struct type *builtin_type_f_real;
1136e93f7393Sniklas extern struct type *builtin_type_f_real_s8;
1137e93f7393Sniklas extern struct type *builtin_type_f_real_s16;
1138e93f7393Sniklas extern struct type *builtin_type_f_complex_s8;
1139e93f7393Sniklas extern struct type *builtin_type_f_complex_s16;
1140e93f7393Sniklas extern struct type *builtin_type_f_complex_s32;
1141e93f7393Sniklas extern struct type *builtin_type_f_void;
1142e93f7393Sniklas 
1143b725ae77Skettenis /* RTTI for C++ */
1144b725ae77Skettenis /* extern struct type *builtin_type_cxx_typeinfo; */
1145b725ae77Skettenis 
1146e93f7393Sniklas /* Maximum and minimum values of built-in types */
1147e93f7393Sniklas 
1148e93f7393Sniklas #define	MAX_OF_TYPE(t)	\
1149b725ae77Skettenis    (TYPE_UNSIGNED(t) ? UMAX_OF_SIZE(TYPE_LENGTH(t)) \
1150b725ae77Skettenis     : MAX_OF_SIZE(TYPE_LENGTH(t)))
1151e93f7393Sniklas 
1152e93f7393Sniklas #define MIN_OF_TYPE(t)	\
1153b725ae77Skettenis    (TYPE_UNSIGNED(t) ? UMIN_OF_SIZE(TYPE_LENGTH(t)) \
1154b725ae77Skettenis     : MIN_OF_SIZE(TYPE_LENGTH(t)))
1155e93f7393Sniklas 
1156e93f7393Sniklas /* Allocate space for storing data associated with a particular type.
1157e93f7393Sniklas    We ensure that the space is allocated using the same mechanism that
1158e93f7393Sniklas    was used to allocate the space for the type structure itself.  I.E.
1159b725ae77Skettenis    if the type is on an objfile's objfile_obstack, then the space for data
1160b725ae77Skettenis    associated with that type will also be allocated on the objfile_obstack.
1161e93f7393Sniklas    If the type is not associated with any particular objfile (such as
1162e93f7393Sniklas    builtin types), then the data space will be allocated with xmalloc,
1163e93f7393Sniklas    the same as for the type structure. */
1164e93f7393Sniklas 
1165e93f7393Sniklas #define TYPE_ALLOC(t,size)  \
1166e93f7393Sniklas    (TYPE_OBJFILE (t) != NULL  \
1167b725ae77Skettenis     ? obstack_alloc (&TYPE_OBJFILE (t) -> objfile_obstack, size) \
1168e93f7393Sniklas     : xmalloc (size))
1169e93f7393Sniklas 
1170b725ae77Skettenis extern struct type *alloc_type (struct objfile *);
1171e93f7393Sniklas 
1172b725ae77Skettenis extern struct type *init_type (enum type_code, int, int, char *,
1173b725ae77Skettenis 			       struct objfile *);
1174e93f7393Sniklas 
1175b725ae77Skettenis /* Helper functions to construct a struct or record type.  An
1176b725ae77Skettenis    initially empty type is created using init_composite_type().
1177b725ae77Skettenis    Fields are then added using append_struct_type_field().  A union
1178b725ae77Skettenis    type has its size set to the largest field.  A struct type has each
1179b725ae77Skettenis    field packed against the previous.  */
1180e93f7393Sniklas 
1181b725ae77Skettenis extern struct type *init_composite_type (char *name, enum type_code code);
1182b725ae77Skettenis extern void append_composite_type_field (struct type *t, char *name,
1183b725ae77Skettenis 					 struct type *field);
1184e93f7393Sniklas 
1185b725ae77Skettenis extern struct type *lookup_reference_type (struct type *);
1186b725ae77Skettenis 
1187b725ae77Skettenis extern struct type *make_reference_type (struct type *, struct type **);
1188b725ae77Skettenis 
1189b725ae77Skettenis extern struct type *make_cv_type (int, int, struct type *, struct type **);
1190b725ae77Skettenis 
1191b725ae77Skettenis extern void replace_type (struct type *, struct type *);
1192b725ae77Skettenis 
1193b725ae77Skettenis extern int address_space_name_to_int (char *);
1194b725ae77Skettenis 
1195b725ae77Skettenis extern const char *address_space_int_to_name (int);
1196b725ae77Skettenis 
1197b725ae77Skettenis extern struct type *make_type_with_address_space (struct type *type,
1198b725ae77Skettenis 						  int space_identifier);
1199b725ae77Skettenis 
1200b725ae77Skettenis extern struct type *lookup_member_type (struct type *, struct type *);
1201e93f7393Sniklas 
1202e93f7393Sniklas extern void
1203b725ae77Skettenis smash_to_method_type (struct type *type, struct type *domain,
1204b725ae77Skettenis 		      struct type *to_type, struct field *args,
1205b725ae77Skettenis 		      int nargs, int varargs);
1206e93f7393Sniklas 
1207b725ae77Skettenis extern void smash_to_member_type (struct type *, struct type *, struct type *);
1208e93f7393Sniklas 
1209b725ae77Skettenis extern struct type *allocate_stub_method (struct type *);
1210e93f7393Sniklas 
1211b725ae77Skettenis extern char *type_name_no_tag (const struct type *);
1212e93f7393Sniklas 
1213b725ae77Skettenis extern struct type *lookup_struct_elt_type (struct type *, char *, int);
1214e93f7393Sniklas 
1215b725ae77Skettenis extern struct type *make_pointer_type (struct type *, struct type **);
1216e93f7393Sniklas 
1217b725ae77Skettenis extern struct type *lookup_pointer_type (struct type *);
1218e93f7393Sniklas 
1219b725ae77Skettenis extern struct type *make_function_type (struct type *, struct type **);
1220e93f7393Sniklas 
1221b725ae77Skettenis extern struct type *lookup_function_type (struct type *);
1222e93f7393Sniklas 
1223b725ae77Skettenis extern struct type *create_range_type (struct type *, struct type *, int,
1224b725ae77Skettenis 				       int);
1225e93f7393Sniklas 
1226b725ae77Skettenis extern struct type *create_array_type (struct type *, struct type *,
1227b725ae77Skettenis 				       struct type *);
1228e93f7393Sniklas 
1229b725ae77Skettenis extern struct type *create_string_type (struct type *, struct type *);
1230e93f7393Sniklas 
1231b725ae77Skettenis extern struct type *create_set_type (struct type *, struct type *);
1232e93f7393Sniklas 
1233b725ae77Skettenis extern struct type *lookup_unsigned_typename (char *);
1234e93f7393Sniklas 
1235b725ae77Skettenis extern struct type *lookup_signed_typename (char *);
1236e93f7393Sniklas 
1237b725ae77Skettenis extern struct type *check_typedef (struct type *);
1238e93f7393Sniklas 
1239e93f7393Sniklas #define CHECK_TYPEDEF(TYPE) (TYPE) = check_typedef (TYPE)
1240e93f7393Sniklas 
1241b725ae77Skettenis extern void check_stub_method_group (struct type *, int);
1242e93f7393Sniklas 
1243b725ae77Skettenis extern char *gdb_mangle_name (struct type *, int, int);
1244e93f7393Sniklas 
1245b725ae77Skettenis extern struct type *lookup_typename (char *, struct block *, int);
1246e93f7393Sniklas 
1247b725ae77Skettenis extern struct type *lookup_template_type (char *, struct type *,
1248b725ae77Skettenis 					  struct block *);
1249e93f7393Sniklas 
1250b725ae77Skettenis extern struct type *lookup_fundamental_type (struct objfile *, int);
1251e93f7393Sniklas 
1252b725ae77Skettenis extern void fill_in_vptr_fieldno (struct type *);
1253e93f7393Sniklas 
1254b725ae77Skettenis extern int get_destructor_fn_field (struct type *, int *, int *);
1255e93f7393Sniklas 
1256b725ae77Skettenis extern int get_discrete_bounds (struct type *, LONGEST *, LONGEST *);
1257b725ae77Skettenis 
1258b725ae77Skettenis extern int is_ancestor (struct type *, struct type *);
1259b725ae77Skettenis 
1260b725ae77Skettenis extern int has_vtable (struct type *);
1261b725ae77Skettenis 
1262b725ae77Skettenis extern struct type *primary_base_class (struct type *);
1263b725ae77Skettenis 
1264b725ae77Skettenis extern struct type **virtual_base_list (struct type *);
1265b725ae77Skettenis 
1266b725ae77Skettenis extern int virtual_base_list_length (struct type *);
1267b725ae77Skettenis extern int virtual_base_list_length_skip_primaries (struct type *);
1268b725ae77Skettenis 
1269b725ae77Skettenis extern int virtual_base_index (struct type *, struct type *);
1270b725ae77Skettenis extern int virtual_base_index_skip_primaries (struct type *, struct type *);
1271b725ae77Skettenis 
1272b725ae77Skettenis 
1273b725ae77Skettenis extern int class_index_in_primary_list (struct type *);
1274b725ae77Skettenis 
1275b725ae77Skettenis extern int count_virtual_fns (struct type *);
1276b725ae77Skettenis 
1277b725ae77Skettenis /* Constants for HP/Taligent ANSI C++ runtime model */
1278b725ae77Skettenis 
1279b725ae77Skettenis /* Where virtual function entries begin in the
1280b725ae77Skettenis  * virtual table, in the non-RRBC vtable format.
1281b725ae77Skettenis  * First 4 are the metavtable pointer, top offset,
1282b725ae77Skettenis  * typeinfo pointer, and dup base info pointer */
1283b725ae77Skettenis #define HP_ACC_VFUNC_START        4
1284b725ae77Skettenis 
1285b725ae77Skettenis /* (Negative) Offset where virtual base offset entries begin
1286b725ae77Skettenis  * in the virtual table. Skips over metavtable pointer and
1287b725ae77Skettenis  * the self-offset entry.
1288b725ae77Skettenis  * NOTE: NEGATE THIS BEFORE USING! The virtual base offsets
1289b725ae77Skettenis  * appear before the address point of the vtable (the slot
1290b725ae77Skettenis  * pointed to by the object's vtable pointer), i.e. at lower
1291b725ae77Skettenis  * addresses than the vtable pointer. */
1292b725ae77Skettenis #define HP_ACC_VBASE_START        2
1293b725ae77Skettenis 
1294b725ae77Skettenis /* (Positive) Offset where the pointer to the typeinfo
1295b725ae77Skettenis  * object is present in the virtual table */
1296b725ae77Skettenis #define HP_ACC_TYPEINFO_OFFSET    2
1297b725ae77Skettenis 
1298b725ae77Skettenis /* (Positive) Offset where the ``top offset'' entry of
1299b725ae77Skettenis  * the virtual table is */
1300b725ae77Skettenis #define HP_ACC_TOP_OFFSET_OFFSET  1
1301b725ae77Skettenis 
1302b725ae77Skettenis /* Overload resolution */
1303b725ae77Skettenis 
1304b725ae77Skettenis #define LENGTH_MATCH(bv) ((bv)->rank[0])
1305b725ae77Skettenis 
1306b725ae77Skettenis /* Badness if parameter list length doesn't match arg list length */
1307b725ae77Skettenis #define LENGTH_MISMATCH_BADNESS      100
1308b725ae77Skettenis /* Dummy badness value for nonexistent parameter positions */
1309b725ae77Skettenis #define TOO_FEW_PARAMS_BADNESS       100
1310b725ae77Skettenis /* Badness if no conversion among types */
1311b725ae77Skettenis #define INCOMPATIBLE_TYPE_BADNESS    100
1312b725ae77Skettenis 
1313b725ae77Skettenis /* Badness of integral promotion */
1314b725ae77Skettenis #define INTEGER_PROMOTION_BADNESS      1
1315b725ae77Skettenis /* Badness of floating promotion */
1316b725ae77Skettenis #define FLOAT_PROMOTION_BADNESS        1
1317b725ae77Skettenis /* Badness of integral conversion */
1318b725ae77Skettenis #define INTEGER_CONVERSION_BADNESS     2
1319b725ae77Skettenis /* Badness of floating conversion */
1320b725ae77Skettenis #define FLOAT_CONVERSION_BADNESS       2
1321b725ae77Skettenis /* Badness of integer<->floating conversions */
1322b725ae77Skettenis #define INT_FLOAT_CONVERSION_BADNESS   2
1323b725ae77Skettenis /* Badness of converting to a boolean */
1324b725ae77Skettenis #define BOOLEAN_CONVERSION_BADNESS     2
1325b725ae77Skettenis /* Badness of pointer conversion */
1326b725ae77Skettenis #define POINTER_CONVERSION_BADNESS     2
1327b725ae77Skettenis /* Badness of conversion of pointer to void pointer */
1328b725ae77Skettenis #define VOID_PTR_CONVERSION_BADNESS    2
1329b725ae77Skettenis /* Badness of converting derived to base class */
1330b725ae77Skettenis #define BASE_CONVERSION_BADNESS        2
1331b725ae77Skettenis /* Badness of converting from non-reference to reference */
1332b725ae77Skettenis #define REFERENCE_CONVERSION_BADNESS   2
1333b725ae77Skettenis 
1334b725ae77Skettenis /* Non-standard conversions allowed by the debugger */
1335b725ae77Skettenis /* Converting a pointer to an int is usually OK */
1336b725ae77Skettenis #define NS_POINTER_CONVERSION_BADNESS 10
1337b725ae77Skettenis 
1338b725ae77Skettenis 
1339b725ae77Skettenis extern int compare_badness (struct badness_vector *, struct badness_vector *);
1340b725ae77Skettenis 
1341b725ae77Skettenis extern struct badness_vector *rank_function (struct type **, int,
1342b725ae77Skettenis 					     struct type **, int);
1343b725ae77Skettenis 
1344b725ae77Skettenis extern int rank_one_type (struct type *, struct type *);
1345b725ae77Skettenis 
1346b725ae77Skettenis extern void recursive_dump_type (struct type *, int);
1347e93f7393Sniklas 
1348e93f7393Sniklas /* printcmd.c */
1349e93f7393Sniklas 
1350b725ae77Skettenis extern void print_scalar_formatted (void *, struct type *, int, int,
1351b725ae77Skettenis 				    struct ui_file *);
1352e93f7393Sniklas 
1353b725ae77Skettenis extern int can_dereference (struct type *);
1354e93f7393Sniklas 
1355b725ae77Skettenis extern int is_integral_type (struct type *);
1356e93f7393Sniklas 
1357b725ae77Skettenis extern void maintenance_print_type (char *, int);
1358e93f7393Sniklas 
1359e93f7393Sniklas #endif /* GDBTYPES_H */
1360