1 /* Internal type definitions for GDB.
2 Copyright (C) 1992, 1993, 1994, 1996 Free Software Foundation, Inc.
3 Contributed by Cygnus Support, using pieces from other GDB modules.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 #if !defined (GDBTYPES_H)
24 /* Codes for `fundamental types'. This is a monstrosity based on the
25 bogus notion that there are certain compiler-independent
26 `fundamental types'. None of these is well-defined (how big is
27 FT_SHORT? Does it depend on the language? How does the
28 language-specific code know which type to correlate to FT_SHORT?) */
32 #define FT_CHAR 2 /* we use this for not-unsigned C/C++ chars */
33 #define FT_SIGNED_CHAR 3 /* we use this for C++ signed chars */
34 #define FT_UNSIGNED_CHAR 4 /* we use this for C/C++ unsigned chars */
36 #define FT_SIGNED_SHORT 6
37 #define FT_UNSIGNED_SHORT 7
39 #define FT_SIGNED_INTEGER 9
40 #define FT_UNSIGNED_INTEGER 10
42 #define FT_SIGNED_LONG 12
43 #define FT_UNSIGNED_LONG 13
44 #define FT_LONG_LONG 14
45 #define FT_SIGNED_LONG_LONG 15
46 #define FT_UNSIGNED_LONG_LONG 16
48 #define FT_DBL_PREC_FLOAT 18
49 #define FT_EXT_PREC_FLOAT 19
51 #define FT_DBL_PREC_COMPLEX 21
52 #define FT_EXT_PREC_COMPLEX 22
54 #define FT_FIXED_DECIMAL 24
55 #define FT_FLOAT_DECIMAL 25
57 #define FT_UNSIGNED_BYTE 27
58 #define FT_TEMPLATE_ARG 28
60 #define FT_NUM_MEMBERS 29 /* Highest FT_* above, plus one. */
62 /* Some macros for char-based bitfields. */
64 #define B_SET(a,x) ((a)[(x)>>3] |= (1 << ((x)&7)))
65 #define B_CLR(a,x) ((a)[(x)>>3] &= ~(1 << ((x)&7)))
66 #define B_TST(a,x) ((a)[(x)>>3] & (1 << ((x)&7)))
67 #define B_TYPE unsigned char
68 #define B_BYTES(x) ( 1 + ((x)>>3) )
69 #define B_CLRALL(a,x) memset ((a), 0, B_BYTES(x))
71 /* Different kinds of data types are distinguished by the `code' field. */
75 TYPE_CODE_UNDEF, /* Not used; catches errors */
76 TYPE_CODE_PTR, /* Pointer type */
77 TYPE_CODE_ARRAY, /* Array type with lower & upper bounds. */
78 TYPE_CODE_STRUCT, /* C struct or Pascal record */
79 TYPE_CODE_UNION, /* C union or Pascal variant part */
80 TYPE_CODE_ENUM, /* Enumeration type */
81 TYPE_CODE_FUNC, /* Function type */
82 TYPE_CODE_INT, /* Integer type */
84 /* Floating type. This is *NOT* a complex type. Beware, there are parts
85 of GDB which bogusly assume that TYPE_CODE_FLT can mean complex. */
88 /* Void type. The length field specifies the length (probably always
89 one) which is used in pointer arithmetic involving pointers to
90 this type, but actually dereferencing such a pointer is invalid;
91 a void type has no length and no actual representation in memory
92 or registers. A pointer to a void type is a generic pointer. */
95 TYPE_CODE_SET, /* Pascal sets */
96 TYPE_CODE_RANGE, /* Range (integers within spec'd bounds) */
98 /* A string type which is like an array of character but prints
99 differently (at least for CHILL). It does not contain a length
100 field as Pascal strings (for many Pascals, anyway) do; if we want
101 to deal with such strings, we should use a new type code. */
104 /* String of bits; like TYPE_CODE_SET but prints differently (at least
108 /* Unknown type. The length field is valid if we were able to
109 deduce that much about the type, or 0 if we don't even know that. */
113 TYPE_CODE_MEMBER, /* Member type */
114 TYPE_CODE_METHOD, /* Method type */
115 TYPE_CODE_REF, /* C++ Reference types */
117 TYPE_CODE_CHAR, /* *real* character type */
119 /* Boolean type. 0 is false, 1 is true, and other values are non-boolean
120 (e.g. FORTRAN "logical" used as unsigned int). */
124 TYPE_CODE_COMPLEX, /* Complex float */
127 TYPE_CODE_TEMPLATE, /* C++ template */
128 TYPE_CODE_TEMPLATE_ARG /* C++ template arg */
132 /* For now allow source to use TYPE_CODE_CLASS for C++ classes, as an
133 alias for TYPE_CODE_STRUCT. This is for DWARF, which has a distinct
134 "class" attribute. Perhaps we should actually have a separate TYPE_CODE
135 so that we can print "class" or "struct" depending on what the debug
136 info said. It's not clear we should bother. */
138 #define TYPE_CODE_CLASS TYPE_CODE_STRUCT
140 /* Some bits for the type's flags word. */
142 /* Unsigned integer type. If this is not set for a TYPE_CODE_INT, the
143 type is signed (unless TYPE_FLAG_NOSIGN (below) is set). */
145 #define TYPE_FLAG_UNSIGNED (1 << 0)
147 /* No sign for this type. In C++, "char", "signed char", and "unsigned
148 char" are distinct types; so we need an extra flag to indicate the
151 #define TYPE_FLAG_NOSIGN (1 << 1)
153 /* This appears in a type's flags word if it is a stub type (e.g., if
154 someone referenced a type that wasn't defined in a source file
155 via (struct sir_not_appearing_in_this_film *)). */
157 #define TYPE_FLAG_STUB (1 << 2)
159 /* The target type of this type is a stub type, and this type needs to
160 be updated if it gets un-stubbed in check_typedef.
161 Used for arrays and ranges, in which TYPE_LENGTH of the array/range
162 gets set based on the TYPE_LENGTH of the target type.
163 Also, set for TYPE_CODE_TYPEDEF. */
165 #define TYPE_FLAG_TARGET_STUB (1 << 3)
167 /* Static type. If this is set, the corresponding type had
169 * Note: This may be unnecessary, since static data members
170 * are indicated by other means (bitpos == -1)
173 #define TYPE_FLAG_STATIC (1 << 4)
175 /* Constant type. If this is set, the corresponding type has a
179 #define TYPE_FLAG_CONST (1 << 5)
181 /* Volatile type. If this is set, the corresponding type has a
185 #define TYPE_FLAG_VOLATILE (1 << 6)
188 /* This is a function type which appears to have a prototype. We need this
189 for function calls in order to tell us if it's necessary to coerce the args,
190 or to just do the standard conversions. This is used with a short field. */
192 #define TYPE_FLAG_PROTOTYPED (1 << 7)
194 /* This flag is used to indicate that processing for this type
197 (Mostly intended for HP platforms, where class methods, for
198 instance, can be encountered before their classes in the debug
199 info; the incomplete type has to be marked so that the class and
200 the method can be assigned correct types.) */
202 #define TYPE_FLAG_INCOMPLETE (1 << 8)
208 /* Code for kind of type */
212 /* Name of this type, or NULL if none.
214 This is used for printing only, except by poorly designed C++ code.
215 For looking up a name, look for a symbol in the VAR_NAMESPACE. */
219 /* Tag name for this type, or NULL if none. This means that the
220 name of the type consists of a keyword followed by the tag name.
221 Which keyword is determined by the type code ("struct" for
222 TYPE_CODE_STRUCT, etc.). As far as I know C/C++ are the only languages
225 This is used for printing only, except by poorly designed C++ code.
226 For looking up a name, look for a symbol in the STRUCT_NAMESPACE.
227 One more legitimate use is that if TYPE_FLAG_STUB is set, this is
228 the name to use to look for definitions in other files. */
232 /* Length of storage for a value of this type. Various places pass
233 this to memcpy and such, meaning it must be in units of
234 HOST_CHAR_BIT. Various other places expect they can calculate
235 addresses by adding it and such, meaning it must be in units of
236 TARGET_CHAR_BIT. For some DSP targets, in which HOST_CHAR_BIT
237 will (presumably) be 8 and TARGET_CHAR_BIT will be (say) 32, this
238 is a problem. One fix would be to make this field in bits
239 (requiring that it always be a multiple of HOST_CHAR_BIT and
240 TARGET_CHAR_BIT)--the other choice would be to make it
241 consistently in units of HOST_CHAR_BIT. */
245 /* FIXME, these should probably be restricted to a Fortran-specific
246 field in some fashion. */
247 #define BOUND_CANNOT_BE_DETERMINED 5
248 #define BOUND_BY_REF_ON_STACK 4
249 #define BOUND_BY_VALUE_ON_STACK 3
250 #define BOUND_BY_REF_IN_REG 2
251 #define BOUND_BY_VALUE_IN_REG 1
252 #define BOUND_SIMPLE 0
253 int upper_bound_type;
254 int lower_bound_type;
256 /* Every type is now associated with a particular objfile, and the
257 type is allocated on the type_obstack for that objfile. One problem
258 however, is that there are times when gdb allocates new types while
259 it is not in the process of reading symbols from a particular objfile.
260 Fortunately, these happen when the type being created is a derived
261 type of an existing type, such as in lookup_pointer_type(). So
262 we can just allocate the new type using the same objfile as the
263 existing type, but to do this we need a backpointer to the objfile
264 from the existing type. Yes this is somewhat ugly, but without
265 major overhaul of the internal type system, it can't be avoided
268 struct objfile *objfile;
270 /* For a pointer type, describes the type of object pointed to.
271 For an array type, describes the type of the elements.
272 For a function or method type, describes the type of the return value.
273 For a range type, describes the type of the full range.
274 For a complex type, describes the type of each coordinate.
277 struct type *target_type;
279 /* Type that is a pointer to this type.
280 NULL if no such pointer-to type is known yet.
281 The debugger may add the address of such a type
282 if it has to construct one later. */
284 struct type *pointer_type;
286 /* C++: also need a reference type. */
288 struct type *reference_type;
290 /* C-v variant chain. This points to a type that
291 differs from this one only in a const or volatile
292 attribute (or both). The various c-v variants
293 are chained together in a ring. */
294 struct type *cv_type;
296 /* Flags about this type. */
300 /* Number of fields described for this type */
304 /* For structure and union types, a description of each field.
305 For set and pascal array types, there is one "field",
306 whose type is the domain type of the set or array.
307 For range types, there are two "fields",
308 the minimum and maximum values (both inclusive).
309 For enum types, each possible value is described by one "field".
310 For a function type, a "field" for each parameter type.
311 For C++ classes, there is one field for each base class (if it is
312 a derived class) plus one field for each class data member. Member
313 functions are recorded elsewhere.
315 Using a pointer to a separate array of fields
316 allows all types to have the same size, which is useful
317 because we can allocate the space for a type before
318 we know what to put in it. */
327 /* Position of this field, counting in bits from start of
328 containing structure.
329 For BITS_BIG_ENDIAN=1 targets, it is the bit offset to the MSB.
330 For BITS_BIG_ENDIAN=0 targets, it is the bit offset to the LSB.
331 For a function type, this is the position in the argument list
333 For a range bound or enum value, this is the value itself. */
337 /* For a static field, if TYPE_FIELD_STATIC_HAS_ADDR then physaddr
338 is the location (in the target) of the static field.
339 Otherwise, physname is the mangled label of the static field. */
345 /* Size of this field, in bits, or zero if not packed.
346 For an unpacked field, the field's type's length
347 says how many bytes the field occupies.
348 A value of -1 or -2 indicates a static field; -1 means the location
349 is specified by the label loc.physname; -2 means that loc.physaddr
350 specifies the actual address. */
354 /* In a struct or union type, type of this field.
355 In a function type, type of this argument.
356 In an array type, the domain-type of the array. */
360 /* Name of field, value or argument.
361 NULL for range bounds and array domains. */
367 /* For types with virtual functions (TYPE_CODE_STRUCT), VPTR_BASETYPE
368 is the base class which defined the virtual function table pointer.
370 For types that are pointer to member types (TYPE_CODE_MEMBER),
371 VPTR_BASETYPE is the type that this pointer is a member of.
373 For method types (TYPE_CODE_METHOD), VPTR_BASETYPE is the aggregate
374 type that contains the method.
378 struct type *vptr_basetype;
380 /* Field number of the virtual function table pointer in
381 VPTR_BASETYPE. If -1, we were unable to find the virtual
382 function table pointer in initial symbol reading, and
383 fill_in_vptr_fieldno should be called to find it if possible.
385 Unused if this type does not have virtual functions. */
389 /* Slot to point to additional language-specific fields of this type. */
394 /* ARG_TYPES is for TYPE_CODE_METHOD.
395 Contains the type of each argument, ending with a void type
396 after the last argument for normal member functions or a NULL
397 pointer after the last argument for functions with variable
400 struct type **arg_types;
402 /* CPLUS_STUFF is for TYPE_CODE_STRUCT. It is initialized to point to
403 cplus_struct_default, a default static instance of a struct
404 cplus_struct_type. */
406 struct cplus_struct_type *cplus_stuff;
411 #define NULL_TYPE ((struct type *) 0)
413 /* C++ language-specific information for TYPE_CODE_STRUCT and TYPE_CODE_UNION
416 struct cplus_struct_type
418 /* Number of base classes this type derives from. The baseclasses are
419 stored in the first N_BASECLASSES fields (i.e. the `fields' field of
420 the struct type). I think only the `type' field of such a field has
425 /* Number of methods with unique names. All overloaded methods with
426 the same name count only once. */
430 /* Number of methods described for this type, not including the
431 methods that it derives from. */
433 short nfn_fields_total;
435 /* The "declared_type" field contains a code saying how the
436 user really declared this type, e.g., "class s", "union s",
438 The 3 above things come out from the C++ compiler looking like classes,
439 but we keep track of the real declaration so we can give
440 the correct information on "ptype". (Note: TEMPLATE may not
441 belong in this list...) */
443 #define DECLARED_TYPE_CLASS 0
444 #define DECLARED_TYPE_UNION 1
445 #define DECLARED_TYPE_STRUCT 2
446 #define DECLARED_TYPE_TEMPLATE 3
447 short declared_type; /* One of the above codes */
449 /* For derived classes, the number of base classes is given by n_baseclasses
450 and virtual_field_bits is a bit vector containing one bit per base class.
451 If the base class is virtual, the corresponding bit will be set.
456 class C : public B, public virtual A {};
458 B is a baseclass of C; A is a virtual baseclass for C.
459 This is a C++ 2.0 language feature. */
461 B_TYPE *virtual_field_bits;
463 /* For classes with private fields, the number of fields is given by
464 nfields and private_field_bits is a bit vector containing one bit
466 If the field is private, the corresponding bit will be set. */
468 B_TYPE *private_field_bits;
470 /* For classes with protected fields, the number of fields is given by
471 nfields and protected_field_bits is a bit vector containing one bit
473 If the field is private, the corresponding bit will be set. */
475 B_TYPE *protected_field_bits;
477 /* for classes with fields to be ignored, either this is optimized out
478 or this field has length 0 */
480 B_TYPE *ignore_field_bits;
482 /* For classes, structures, and unions, a description of each field,
483 which consists of an overloaded name, followed by the types of
484 arguments that the method expects, and then the name after it
485 has been renamed to make it distinct.
487 fn_fieldlists points to an array of nfn_fields of these. */
492 /* The overloaded name. */
496 /* The number of methods with this name. */
500 /* The list of methods. */
505 /* If is_stub is clear, this is the mangled name which we can
506 look up to find the address of the method (FIXME: it would
507 be cleaner to have a pointer to the struct symbol here
510 /* If is_stub is set, this is the portion of the mangled
511 name which specifies the arguments. For example, "ii",
512 if there are two int arguments, or "" if there are no
513 arguments. See gdb_mangle_name for the conversion from this
514 format to the one used if is_stub is clear. */
518 /* The function type for the method.
519 (This comment used to say "The return value of the method",
520 but that's wrong. The function type
521 is expected here, i.e. something with TYPE_CODE_FUNC,
522 and *not* the return-value type). */
526 /* The argument list. Only valid if is_stub is clear. Contains
527 the type of each argument, including `this', and ending with
528 a NULL pointer after the last argument. Should not contain
529 a `this' pointer for static member functions. */
533 /* For virtual functions.
534 First baseclass that defines this virtual function. */
536 struct type *fcontext;
540 unsigned int is_const : 1;
541 unsigned int is_volatile : 1;
542 unsigned int is_private : 1;
543 unsigned int is_protected : 1;
545 /* A stub method only has some fields valid (but they are enough
546 to reconstruct the rest of the fields). */
547 unsigned int is_stub : 1;
549 /* C++ method that is inlined */
550 unsigned int is_inlined : 1;
553 unsigned int dummy : 2;
555 /* Index into that baseclass's virtual function table,
556 minus 2; else if static: VOFFSET_STATIC; else: 0. */
558 unsigned int voffset : 24;
560 # define VOFFSET_STATIC 1
566 /* If this "struct type" describes a template, then it
567 * has arguments. "template_args" points to an array of
568 * template arg descriptors, of length "ntemplate_args".
569 * The only real information in each of these template arg descriptors
570 * is a name. "type" will typically just point to a "struct type" with
571 * the placeholder TYPE_CODE_TEMPLATE_ARG type.
573 short ntemplate_args;
580 /* If this "struct type" describes a template, it has a list
581 * of instantiations. "instantiations" is a pointer to an array
582 * of type's, one representing each instantiation. There
583 * are "ninstantiations" elements in this array.
585 short ninstantiations;
586 struct type **instantiations;
588 /* The following points to information relevant to the runtime model
590 * Currently being used only for HP's ANSI C++ compiler.
591 * (This type may have to be changed/enhanced for other compilers.)
593 * RUNTIME_PTR is NULL if there is no runtime information (currently
594 * this means the type was not compiled by HP aCC).
596 * Fields in structure pointed to:
597 * ->HAS_VTABLE : 0 => no virtual table, 1 => vtable present
599 * ->PRIMARY_BASE points to the first non-virtual base class that has
602 * ->VIRTUAL_BASE_LIST points to a list of struct type * pointers that
603 * point to the type information for all virtual bases among this type's
606 struct runtime_info {
608 struct type * primary_base;
609 struct type ** virtual_base_list;
612 /* Pointer to information about enclosing scope, if this is a
613 * local type. If it is not a local type, this is NULL
615 struct local_type_info {
621 /* Struct used in computing virtual base list */
624 struct type * vbasetype; /* pointer to virtual base */
625 struct vbase * next; /* next in chain */
628 /* Struct used for ranking a function for overload resolution */
629 struct badness_vector {
634 /* The default value of TYPE_CPLUS_SPECIFIC(T) points to the
635 this shared static structure. */
637 extern const struct cplus_struct_type cplus_struct_default;
640 allocate_cplus_struct_type PARAMS ((struct type *));
642 #define INIT_CPLUS_SPECIFIC(type) \
643 (TYPE_CPLUS_SPECIFIC(type)=(struct cplus_struct_type*)&cplus_struct_default)
644 #define ALLOCATE_CPLUS_STRUCT_TYPE(type) allocate_cplus_struct_type (type)
645 #define HAVE_CPLUS_STRUCT(type) \
646 (TYPE_CPLUS_SPECIFIC(type) != &cplus_struct_default)
648 #define TYPE_NAME(thistype) (thistype)->name
649 #define TYPE_TAG_NAME(type) ((type)->tag_name)
650 #define TYPE_TARGET_TYPE(thistype) (thistype)->target_type
651 #define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
652 #define TYPE_REFERENCE_TYPE(thistype) (thistype)->reference_type
653 #define TYPE_CV_TYPE(thistype) (thistype)->cv_type
654 /* Note that if thistype is a TYPEDEF type, you have to call check_typedef.
655 But check_typedef does set the TYPE_LENGTH of the TYPEDEF type,
656 so you only have to call check_typedef once. Since allocate_value
657 calls check_typedef, TYPE_LENGTH (VALUE_TYPE (X)) is safe. */
658 #define TYPE_LENGTH(thistype) (thistype)->length
659 #define TYPE_OBJFILE(thistype) (thistype)->objfile
660 #define TYPE_FLAGS(thistype) (thistype)->flags
661 #define TYPE_UNSIGNED(thistype) ((thistype)->flags & TYPE_FLAG_UNSIGNED)
662 #define TYPE_NOSIGN(thistype) ((thistype)->flags & TYPE_FLAG_NOSIGN)
663 #define TYPE_CONST(thistype) ((thistype)->flags & TYPE_FLAG_CONST)
664 #define TYPE_VOLATILE(thistype) ((thistype)->flags & TYPE_FLAG_VOLATILE)
665 #define TYPE_INCOMPLETE(thistype) ((thistype)->flags & TYPE_FLAG_INCOMPLETE)
666 /* Note that TYPE_CODE can be TYPE_CODE_TYPEDEF, so if you wan the real
667 type, you need to do TYPE_CODE (check_type (this_type)). */
668 #define TYPE_CODE(thistype) (thistype)->code
669 #define TYPE_NFIELDS(thistype) (thistype)->nfields
670 #define TYPE_FIELDS(thistype) (thistype)->fields
671 #define TYPE_TEMPLATE_ARGS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->template_args
672 #define TYPE_INSTANTIATIONS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->instantiations
674 #define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0)
675 #define TYPE_LOW_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 0)
676 #define TYPE_HIGH_BOUND(range_type) TYPE_FIELD_BITPOS (range_type, 1)
678 /* Moto-specific stuff for FORTRAN arrays */
680 #define TYPE_ARRAY_UPPER_BOUND_TYPE(thistype) (thistype)->upper_bound_type
681 #define TYPE_ARRAY_LOWER_BOUND_TYPE(thistype) (thistype)->lower_bound_type
683 #define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
684 (TYPE_FIELD_BITPOS((TYPE_FIELD_TYPE((arraytype),0)),1))
686 #define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \
687 (TYPE_FIELD_BITPOS((TYPE_FIELD_TYPE((arraytype),0)),0))
691 #define TYPE_VPTR_BASETYPE(thistype) (thistype)->vptr_basetype
692 #define TYPE_DOMAIN_TYPE(thistype) (thistype)->vptr_basetype
693 #define TYPE_VPTR_FIELDNO(thistype) (thistype)->vptr_fieldno
694 #define TYPE_FN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fields
695 #define TYPE_NFN_FIELDS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields
696 #define TYPE_NFN_FIELDS_TOTAL(thistype) TYPE_CPLUS_SPECIFIC(thistype)->nfn_fields_total
697 #define TYPE_NTEMPLATE_ARGS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->ntemplate_args
698 #define TYPE_NINSTANTIATIONS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->ninstantiations
699 #define TYPE_DECLARED_TYPE(thistype) TYPE_CPLUS_SPECIFIC(thistype)->declared_type
700 #define TYPE_TYPE_SPECIFIC(thistype) (thistype)->type_specific
701 #define TYPE_ARG_TYPES(thistype) (thistype)->type_specific.arg_types
702 #define TYPE_CPLUS_SPECIFIC(thistype) (thistype)->type_specific.cplus_stuff
703 #define TYPE_BASECLASS(thistype,index) (thistype)->fields[index].type
704 #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses
705 #define TYPE_BASECLASS_NAME(thistype,index) (thistype)->fields[index].name
706 #define TYPE_BASECLASS_BITPOS(thistype,index) TYPE_FIELD_BITPOS(thistype,index)
707 #define BASETYPE_VIA_PUBLIC(thistype, index) \
708 ((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index)))
710 #define BASETYPE_VIA_VIRTUAL(thistype, index) \
711 (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
712 : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
714 #define FIELD_TYPE(thisfld) ((thisfld).type)
715 #define FIELD_NAME(thisfld) ((thisfld).name)
716 #define FIELD_BITPOS(thisfld) ((thisfld).loc.bitpos)
717 #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
718 #define FIELD_PHYSNAME(thisfld) ((thisfld).loc.physname)
719 #define FIELD_PHYSADDR(thisfld) ((thisfld).loc.physaddr)
720 #define SET_FIELD_PHYSNAME(thisfld, name) \
721 ((thisfld).bitsize = -1, FIELD_PHYSNAME(thisfld) = (name))
722 #define SET_FIELD_PHYSADDR(thisfld, name) \
723 ((thisfld).bitsize = -2, FIELD_PHYSADDR(thisfld) = (name))
724 #define TYPE_FIELD(thistype, n) (thistype)->fields[n]
725 #define TYPE_FIELD_TYPE(thistype, n) FIELD_TYPE(TYPE_FIELD(thistype, n))
726 #define TYPE_FIELD_NAME(thistype, n) FIELD_NAME(TYPE_FIELD(thistype, n))
727 #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS(TYPE_FIELD(thistype,n))
728 #define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE(TYPE_FIELD(thistype,n))
729 #define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE(TYPE_FIELD(thistype,n))!=0)
730 #define TYPE_TEMPLATE_ARG(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->template_args[n]
731 #define TYPE_INSTANTIATION(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->instantiations[n]
733 #define TYPE_FIELD_PRIVATE_BITS(thistype) \
734 TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits
735 #define TYPE_FIELD_PROTECTED_BITS(thistype) \
736 TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits
737 #define TYPE_FIELD_IGNORE_BITS(thistype) \
738 TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits
739 #define TYPE_FIELD_VIRTUAL_BITS(thistype) \
740 TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits
741 #define SET_TYPE_FIELD_PRIVATE(thistype, n) \
742 B_SET (TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n))
743 #define SET_TYPE_FIELD_PROTECTED(thistype, n) \
744 B_SET (TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n))
745 #define SET_TYPE_FIELD_IGNORE(thistype, n) \
746 B_SET (TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits, (n))
747 #define SET_TYPE_FIELD_VIRTUAL(thistype, n) \
748 B_SET (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n))
749 #define TYPE_FIELD_PRIVATE(thistype, n) \
750 (TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits == NULL ? 0 \
751 : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->private_field_bits, (n)))
752 #define TYPE_FIELD_PROTECTED(thistype, n) \
753 (TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits == NULL ? 0 \
754 : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->protected_field_bits, (n)))
755 #define TYPE_FIELD_IGNORE(thistype, n) \
756 (TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits == NULL ? 0 \
757 : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->ignore_field_bits, (n)))
758 #define TYPE_FIELD_VIRTUAL(thistype, n) \
759 (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
760 : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (n)))
762 #define TYPE_FIELD_STATIC(thistype, n) ((thistype)->fields[n].bitsize < 0)
763 #define TYPE_FIELD_STATIC_HAS_ADDR(thistype, n) ((thistype)->fields[n].bitsize == -2)
764 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_PHYSNAME(TYPE_FIELD(thistype, n))
765 #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_PHYSADDR(TYPE_FIELD(thistype, n))
767 #define TYPE_FN_FIELDLISTS(thistype) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists
768 #define TYPE_FN_FIELDLIST(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n]
769 #define TYPE_FN_FIELDLIST1(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].fn_fields
770 #define TYPE_FN_FIELDLIST_NAME(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].name
771 #define TYPE_FN_FIELDLIST_LENGTH(thistype, n) TYPE_CPLUS_SPECIFIC(thistype)->fn_fieldlists[n].length
773 #define TYPE_FN_FIELD(thisfn, n) (thisfn)[n]
774 #define TYPE_FN_FIELD_PHYSNAME(thisfn, n) (thisfn)[n].physname
775 #define TYPE_FN_FIELD_TYPE(thisfn, n) (thisfn)[n].type
776 #define TYPE_FN_FIELD_ARGS(thisfn, n) TYPE_ARG_TYPES ((thisfn)[n].type)
777 #define TYPE_FN_FIELD_CONST(thisfn, n) ((thisfn)[n].is_const)
778 #define TYPE_FN_FIELD_VOLATILE(thisfn, n) ((thisfn)[n].is_volatile)
779 #define TYPE_FN_FIELD_PRIVATE(thisfn, n) ((thisfn)[n].is_private)
780 #define TYPE_FN_FIELD_PROTECTED(thisfn, n) ((thisfn)[n].is_protected)
781 #define TYPE_FN_FIELD_STUB(thisfn, n) ((thisfn)[n].is_stub)
782 #define TYPE_FN_FIELD_INLINED(thisfn, n) ((thisfn)[n].is_inlined)
783 #define TYPE_FN_FIELD_FCONTEXT(thisfn, n) ((thisfn)[n].fcontext)
784 #define TYPE_FN_FIELD_VOFFSET(thisfn, n) ((thisfn)[n].voffset-2)
785 #define TYPE_FN_FIELD_VIRTUAL_P(thisfn, n) ((thisfn)[n].voffset > 1)
786 #define TYPE_FN_FIELD_STATIC_P(thisfn, n) ((thisfn)[n].voffset == VOFFSET_STATIC)
788 #define TYPE_RUNTIME_PTR(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->runtime_ptr)
789 #define TYPE_VTABLE(thistype) (TYPE_RUNTIME_PTR(thistype)->has_vtable)
790 #define TYPE_HAS_VTABLE(thistype) (TYPE_RUNTIME_PTR(thistype) && TYPE_VTABLE(thistype))
791 #define TYPE_PRIMARY_BASE(thistype) (TYPE_RUNTIME_PTR(thistype)->primary_base)
792 #define TYPE_VIRTUAL_BASE_LIST(thistype) (TYPE_RUNTIME_PTR(thistype)->virtual_base_list)
794 #define TYPE_LOCALTYPE_PTR(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->localtype_ptr)
795 #define TYPE_LOCALTYPE_FILE(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->localtype_ptr->file)
796 #define TYPE_LOCALTYPE_LINE(thistype) (TYPE_CPLUS_SPECIFIC(thistype)->localtype_ptr->line)
798 #define TYPE_IS_OPAQUE(thistype) (((TYPE_CODE (thistype) == TYPE_CODE_STRUCT) || \
799 (TYPE_CODE (thistype) == TYPE_CODE_UNION)) && \
800 (TYPE_NFIELDS (thistype) == 0) && \
801 (TYPE_CPLUS_SPECIFIC (thistype) && (TYPE_NFN_FIELDS (thistype) == 0)))
806 extern struct type *builtin_type_void;
807 extern struct type *builtin_type_char;
808 extern struct type *builtin_type_short;
809 extern struct type *builtin_type_int;
810 extern struct type *builtin_type_long;
811 extern struct type *builtin_type_signed_char;
812 extern struct type *builtin_type_unsigned_char;
813 extern struct type *builtin_type_unsigned_short;
814 extern struct type *builtin_type_unsigned_int;
815 extern struct type *builtin_type_unsigned_long;
816 extern struct type *builtin_type_float;
817 extern struct type *builtin_type_double;
818 extern struct type *builtin_type_long_double;
819 extern struct type *builtin_type_complex;
820 extern struct type *builtin_type_double_complex;
821 extern struct type *builtin_type_string;
822 extern struct type *builtin_type_bool;
824 /* Explicit sizes - see <intypes.h> for naming schema */
825 extern struct type *builtin_type_int8;
826 extern struct type *builtin_type_uint8;
827 extern struct type *builtin_type_int16;
828 extern struct type *builtin_type_uint16;
829 extern struct type *builtin_type_int32;
830 extern struct type *builtin_type_uint32;
831 extern struct type *builtin_type_int64;
832 extern struct type *builtin_type_uint64;
833 /* start-sanitize-r5900 */
834 extern struct type *builtin_type_int128;
835 extern struct type *builtin_type_uint128;
836 /* end-sanitize-r5900 */
838 /* This type represents a type that was unrecognized in symbol
841 extern struct type *builtin_type_error;
843 extern struct type *builtin_type_long_long;
844 extern struct type *builtin_type_unsigned_long_long;
848 extern struct type *builtin_type_m2_char;
849 extern struct type *builtin_type_m2_int;
850 extern struct type *builtin_type_m2_card;
851 extern struct type *builtin_type_m2_real;
852 extern struct type *builtin_type_m2_bool;
856 extern struct type *builtin_type_chill_bool;
857 extern struct type *builtin_type_chill_char;
858 extern struct type *builtin_type_chill_long;
859 extern struct type *builtin_type_chill_ulong;
860 extern struct type *builtin_type_chill_real;
862 /* Fortran (F77) types */
864 extern struct type *builtin_type_f_character;
865 extern struct type *builtin_type_f_integer;
866 extern struct type *builtin_type_f_logical;
867 extern struct type *builtin_type_f_logical_s1;
868 extern struct type *builtin_type_f_logical_s2;
869 extern struct type *builtin_type_f_integer;
870 extern struct type *builtin_type_f_integer_s2;
871 extern struct type *builtin_type_f_real;
872 extern struct type *builtin_type_f_real_s8;
873 extern struct type *builtin_type_f_real_s16;
874 extern struct type *builtin_type_f_complex_s8;
875 extern struct type *builtin_type_f_complex_s16;
876 extern struct type *builtin_type_f_complex_s32;
877 extern struct type *builtin_type_f_void;
880 /* extern struct type *builtin_type_cxx_typeinfo; */
882 /* Maximum and minimum values of built-in types */
884 #define MAX_OF_TYPE(t) \
885 TYPE_UNSIGNED(t) ? UMAX_OF_SIZE(TYPE_LENGTH(t)) \
886 : MAX_OF_SIZE(TYPE_LENGTH(t))
888 #define MIN_OF_TYPE(t) \
889 TYPE_UNSIGNED(t) ? UMIN_OF_SIZE(TYPE_LENGTH(t)) \
890 : MIN_OF_SIZE(TYPE_LENGTH(t))
892 /* Allocate space for storing data associated with a particular type.
893 We ensure that the space is allocated using the same mechanism that
894 was used to allocate the space for the type structure itself. I.E.
895 if the type is on an objfile's type_obstack, then the space for data
896 associated with that type will also be allocated on the type_obstack.
897 If the type is not associated with any particular objfile (such as
898 builtin types), then the data space will be allocated with xmalloc,
899 the same as for the type structure. */
901 #define TYPE_ALLOC(t,size) \
902 (TYPE_OBJFILE (t) != NULL \
903 ? obstack_alloc (&TYPE_OBJFILE (t) -> type_obstack, size) \
907 alloc_type PARAMS ((struct objfile *));
910 init_type PARAMS ((enum type_code, int, int, char *, struct objfile *));
913 lookup_reference_type PARAMS ((struct type *));
916 make_reference_type PARAMS ((struct type *, struct type **));
919 make_cv_type PARAMS ((int, int, struct type *, struct type **));
922 lookup_member_type PARAMS ((struct type *, struct type *));
925 smash_to_method_type PARAMS ((struct type *, struct type *, struct type *,
929 smash_to_member_type PARAMS ((struct type *, struct type *, struct type *));
932 allocate_stub_method PARAMS ((struct type *));
935 type_name_no_tag PARAMS ((const struct type *));
938 lookup_struct_elt_type PARAMS ((struct type *, char *, int));
941 make_pointer_type PARAMS ((struct type *, struct type **));
944 lookup_pointer_type PARAMS ((struct type *));
947 make_function_type PARAMS ((struct type *, struct type **));
950 lookup_function_type PARAMS ((struct type *));
953 create_range_type PARAMS ((struct type *, struct type *, int, int));
956 create_array_type PARAMS ((struct type *, struct type *, struct type *));
959 create_string_type PARAMS ((struct type *, struct type *));
961 extern struct type *create_set_type PARAMS ((struct type *, struct type *));
963 extern int chill_varying_type PARAMS ((struct type*));
966 lookup_unsigned_typename PARAMS ((char *));
969 lookup_signed_typename PARAMS ((char *));
972 check_typedef PARAMS ((struct type *));
974 #define CHECK_TYPEDEF(TYPE) (TYPE) = check_typedef (TYPE)
977 check_stub_method PARAMS ((struct type *, int, int));
980 lookup_primitive_typename PARAMS ((char *));
983 gdb_mangle_name PARAMS ((struct type *, int, int));
986 builtin_type PARAMS ((char **));
989 lookup_typename PARAMS ((char *, struct block *, int));
992 lookup_template_type PARAMS ((char *, struct type *, struct block *));
995 lookup_fundamental_type PARAMS ((struct objfile *, int));
998 fill_in_vptr_fieldno PARAMS ((struct type *));
1000 extern int get_destructor_fn_field PARAMS ((struct type *, int *, int *));
1002 extern int get_discrete_bounds PARAMS ((struct type*, LONGEST*, LONGEST*));
1005 get_discrete_bounds PARAMS ((struct type*, LONGEST*, LONGEST*));
1008 is_ancestor PARAMS ((struct type *, struct type *));
1011 has_vtable PARAMS ((struct type *));
1013 extern struct type *
1014 primary_base_class PARAMS ((struct type *));
1016 extern struct type **
1017 virtual_base_list PARAMS ((struct type *));
1020 virtual_base_list_length PARAMS ((struct type *));
1022 virtual_base_list_length_skip_primaries PARAMS ((struct type *));
1025 virtual_base_index PARAMS ((struct type *, struct type *));
1027 virtual_base_index_skip_primaries PARAMS ((struct type *, struct type *));
1031 class_index_in_primary_list PARAMS ((struct type *));
1034 count_virtual_fns PARAMS ((struct type*));
1036 /* Constants for HP/Taligent ANSI C++ runtime model */
1038 /* Where virtual function entries begin in the
1039 * virtual table, in the non-RRBC vtable format.
1040 * First 4 are the metavtable pointer, top offset,
1041 * typeinfo pointer, and dup base info pointer */
1042 #define HP_ACC_VFUNC_START 4
1044 /* (Negative) Offset where virtual base offset entries begin
1045 * in the virtual table. Skips over metavtable pointer and
1046 * the self-offset entry.
1047 * NOTE: NEGATE THIS BEFORE USING! The virtual base offsets
1048 * appear before the address point of the vtable (the slot
1049 * pointed to by the object's vtable pointer), i.e. at lower
1050 * addresses than the vtable pointer. */
1051 #define HP_ACC_VBASE_START 2
1053 /* (Positive) Offset where the pointer to the typeinfo
1054 * object is present in the virtual table */
1055 #define HP_ACC_TYPEINFO_OFFSET 2
1057 /* (Positive) Offset where the ``top offset'' entry of
1058 * the virtual table is */
1059 #define HP_ACC_TOP_OFFSET_OFFSET 1
1061 /* Overload resolution */
1063 #define LENGTH_MATCH(bv) ((bv)->rank[0])
1065 /* Badness if parameter list length doesn't match arg list length */
1066 #define LENGTH_MISMATCH_BADNESS 100
1067 /* Dummy badness value for nonexistent parameter positions */
1068 #define TOO_FEW_PARAMS_BADNESS 100
1069 /* Badness if no conversion among types */
1070 #define INCOMPATIBLE_TYPE_BADNESS 100
1071 /* Badness of coercing large integer to smaller size */
1072 #define INTEGER_COERCION_BADNESS 100
1073 /* Badness of coercing large floating type to smaller size */
1074 #define FLOAT_COERCION_BADNESS 100
1076 /* Badness of integral promotion */
1077 #define INTEGER_PROMOTION_BADNESS 1
1078 /* Badness of floating promotion */
1079 #define FLOAT_PROMOTION_BADNESS 1
1080 /* Badness of integral conversion */
1081 #define INTEGER_CONVERSION_BADNESS 2
1082 /* Badness of floating conversion */
1083 #define FLOAT_CONVERSION_BADNESS 2
1084 /* Badness of integer<->floating conversions */
1085 #define INT_FLOAT_CONVERSION_BADNESS 2
1086 /* Badness of converting to a boolean */
1087 #define BOOLEAN_CONVERSION_BADNESS 2
1088 /* Badness of pointer conversion */
1089 #define POINTER_CONVERSION_BADNESS 2
1090 /* Badness of conversion of pointer to void pointer */
1091 #define VOID_PTR_CONVERSION_BADNESS 2
1092 /* Badness of convering derived to base class */
1093 #define BASE_CONVERSION_BADNESS 2
1095 /* Non-standard conversions allowed by the debugger */
1096 /* Converting a pointer to an int is usually OK */
1097 #define NS_POINTER_CONVERSION_BADNESS 10
1101 compare_badness PARAMS ((struct badness_vector *, struct badness_vector *));
1103 extern struct badness_vector *
1104 rank_function PARAMS ((struct type **, int, struct type **, int));
1107 rank_one_type PARAMS ((struct type *, struct type *));
1110 #if MAINTENANCE_CMDS
1111 extern void recursive_dump_type PARAMS ((struct type *, int));
1117 print_scalar_formatted PARAMS ((char *, struct type *, int, int, GDB_FILE *));
1119 extern int can_dereference PARAMS ((struct type *));
1121 #if MAINTENANCE_CMDS
1122 extern void maintenance_print_type PARAMS ((char *, int));
1127 extern void print_type_scalar PARAMS ((struct type *, LONGEST, GDB_FILE *));
1129 #endif /* GDBTYPES_H */