1 /* Support routines for manipulating internal types for GDB.
2 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000
3 Free Software Foundation, Inc.
4 Contributed by Cygnus Support, using pieces from other GDB modules.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
24 #include "gdb_string.h"
30 #include "expression.h"
35 #include "complaints.h"
40 /* These variables point to the objects
41 representing the predefined C data types. */
43 struct type
*builtin_type_void
;
44 struct type
*builtin_type_char
;
45 struct type
*builtin_type_true_char
;
46 struct type
*builtin_type_short
;
47 struct type
*builtin_type_int
;
48 struct type
*builtin_type_long
;
49 struct type
*builtin_type_long_long
;
50 struct type
*builtin_type_signed_char
;
51 struct type
*builtin_type_unsigned_char
;
52 struct type
*builtin_type_unsigned_short
;
53 struct type
*builtin_type_unsigned_int
;
54 struct type
*builtin_type_unsigned_long
;
55 struct type
*builtin_type_unsigned_long_long
;
56 struct type
*builtin_type_float
;
57 struct type
*builtin_type_double
;
58 struct type
*builtin_type_long_double
;
59 struct type
*builtin_type_complex
;
60 struct type
*builtin_type_double_complex
;
61 struct type
*builtin_type_string
;
62 struct type
*builtin_type_int8
;
63 struct type
*builtin_type_uint8
;
64 struct type
*builtin_type_int16
;
65 struct type
*builtin_type_uint16
;
66 struct type
*builtin_type_int32
;
67 struct type
*builtin_type_uint32
;
68 struct type
*builtin_type_int64
;
69 struct type
*builtin_type_uint64
;
70 struct type
*builtin_type_bool
;
71 struct type
*builtin_type_v4sf
;
72 struct type
*builtin_type_v4si
;
73 struct type
*builtin_type_v8qi
;
74 struct type
*builtin_type_v4hi
;
75 struct type
*builtin_type_v2si
;
76 struct type
*builtin_type_ptr
;
77 struct type
*builtin_type_CORE_ADDR
;
78 struct type
*builtin_type_bfd_vma
;
80 int opaque_type_resolution
= 1;
81 int overload_debug
= 0;
87 }; /* maximum extension is 128! FIXME */
89 static void add_name (struct extra
*, char *);
90 static void add_mangled_type (struct extra
*, struct type
*);
92 static void cfront_mangle_name (struct type
*, int, int);
94 static void print_bit_vector (B_TYPE
*, int);
95 static void print_arg_types (struct type
**, int);
96 static void dump_fn_fieldlists (struct type
*, int);
97 static void print_cplus_stuff (struct type
*, int);
98 static void virtual_base_list_aux (struct type
*dclass
);
101 /* Alloc a new type structure and fill it with some defaults. If
102 OBJFILE is non-NULL, then allocate the space for the type structure
103 in that objfile's type_obstack. */
106 alloc_type (struct objfile
*objfile
)
108 register struct type
*type
;
110 /* Alloc the structure and start off with all fields zeroed. */
114 type
= (struct type
*) xmalloc (sizeof (struct type
));
118 type
= (struct type
*) obstack_alloc (&objfile
->type_obstack
,
119 sizeof (struct type
));
120 OBJSTAT (objfile
, n_types
++);
122 memset ((char *) type
, 0, sizeof (struct type
));
124 /* Initialize the fields that might not be zero. */
126 TYPE_CODE (type
) = TYPE_CODE_UNDEF
;
127 TYPE_OBJFILE (type
) = objfile
;
128 TYPE_VPTR_FIELDNO (type
) = -1;
129 TYPE_CV_TYPE (type
) = type
; /* chain back to itself */
134 /* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points
135 to a pointer to memory where the pointer type should be stored.
136 If *TYPEPTR is zero, update it to point to the pointer type we return.
137 We allocate new memory if needed. */
140 make_pointer_type (struct type
*type
, struct type
**typeptr
)
142 register struct type
*ntype
; /* New type */
143 struct objfile
*objfile
;
145 ntype
= TYPE_POINTER_TYPE (type
);
150 return ntype
; /* Don't care about alloc, and have new type. */
151 else if (*typeptr
== 0)
153 *typeptr
= ntype
; /* Tracking alloc, and we have new type. */
158 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
160 ntype
= alloc_type (TYPE_OBJFILE (type
));
165 /* We have storage, but need to reset it. */
168 objfile
= TYPE_OBJFILE (ntype
);
169 memset ((char *) ntype
, 0, sizeof (struct type
));
170 TYPE_OBJFILE (ntype
) = objfile
;
173 TYPE_TARGET_TYPE (ntype
) = type
;
174 TYPE_POINTER_TYPE (type
) = ntype
;
176 /* FIXME! Assume the machine has only one representation for pointers! */
178 TYPE_LENGTH (ntype
) = TARGET_PTR_BIT
/ TARGET_CHAR_BIT
;
179 TYPE_CODE (ntype
) = TYPE_CODE_PTR
;
181 /* Mark pointers as unsigned. The target converts between pointers
182 and addresses (CORE_ADDRs) using POINTER_TO_ADDRESS() and
183 ADDRESS_TO_POINTER(). */
184 TYPE_FLAGS (ntype
) |= TYPE_FLAG_UNSIGNED
;
186 if (!TYPE_POINTER_TYPE (type
)) /* Remember it, if don't have one. */
187 TYPE_POINTER_TYPE (type
) = ntype
;
192 /* Given a type TYPE, return a type of pointers to that type.
193 May need to construct such a type if this is the first use. */
196 lookup_pointer_type (struct type
*type
)
198 return make_pointer_type (type
, (struct type
**) 0);
201 /* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, points
202 to a pointer to memory where the reference type should be stored.
203 If *TYPEPTR is zero, update it to point to the reference type we return.
204 We allocate new memory if needed. */
207 make_reference_type (struct type
*type
, struct type
**typeptr
)
209 register struct type
*ntype
; /* New type */
210 struct objfile
*objfile
;
212 ntype
= TYPE_REFERENCE_TYPE (type
);
217 return ntype
; /* Don't care about alloc, and have new type. */
218 else if (*typeptr
== 0)
220 *typeptr
= ntype
; /* Tracking alloc, and we have new type. */
225 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
227 ntype
= alloc_type (TYPE_OBJFILE (type
));
232 /* We have storage, but need to reset it. */
235 objfile
= TYPE_OBJFILE (ntype
);
236 memset ((char *) ntype
, 0, sizeof (struct type
));
237 TYPE_OBJFILE (ntype
) = objfile
;
240 TYPE_TARGET_TYPE (ntype
) = type
;
241 TYPE_REFERENCE_TYPE (type
) = ntype
;
243 /* FIXME! Assume the machine has only one representation for references,
244 and that it matches the (only) representation for pointers! */
246 TYPE_LENGTH (ntype
) = TARGET_PTR_BIT
/ TARGET_CHAR_BIT
;
247 TYPE_CODE (ntype
) = TYPE_CODE_REF
;
249 if (!TYPE_REFERENCE_TYPE (type
)) /* Remember it, if don't have one. */
250 TYPE_REFERENCE_TYPE (type
) = ntype
;
255 /* Same as above, but caller doesn't care about memory allocation details. */
258 lookup_reference_type (struct type
*type
)
260 return make_reference_type (type
, (struct type
**) 0);
263 /* Lookup a function type that returns type TYPE. TYPEPTR, if nonzero, points
264 to a pointer to memory where the function type should be stored.
265 If *TYPEPTR is zero, update it to point to the function type we return.
266 We allocate new memory if needed. */
269 make_function_type (struct type
*type
, struct type
**typeptr
)
271 register struct type
*ntype
; /* New type */
272 struct objfile
*objfile
;
274 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
276 ntype
= alloc_type (TYPE_OBJFILE (type
));
281 /* We have storage, but need to reset it. */
284 objfile
= TYPE_OBJFILE (ntype
);
285 memset ((char *) ntype
, 0, sizeof (struct type
));
286 TYPE_OBJFILE (ntype
) = objfile
;
289 TYPE_TARGET_TYPE (ntype
) = type
;
291 TYPE_LENGTH (ntype
) = 1;
292 TYPE_CODE (ntype
) = TYPE_CODE_FUNC
;
298 /* Given a type TYPE, return a type of functions that return that type.
299 May need to construct such a type if this is the first use. */
302 lookup_function_type (struct type
*type
)
304 return make_function_type (type
, (struct type
**) 0);
308 /* Make a "c-v" variant of a type -- a type that is identical to the
309 one supplied except that it may have const or volatile attributes
310 CNST is a flag for setting the const attribute
311 VOLTL is a flag for setting the volatile attribute
312 TYPE is the base type whose variant we are creating.
313 TYPEPTR, if nonzero, points
314 to a pointer to memory where the reference type should be stored.
315 If *TYPEPTR is zero, update it to point to the reference type we return.
316 We allocate new memory if needed. */
319 make_cv_type (int cnst
, int voltl
, struct type
*type
, struct type
**typeptr
)
321 register struct type
*ntype
; /* New type */
322 register struct type
*tmp_type
= type
; /* tmp type */
323 struct objfile
*objfile
;
325 ntype
= TYPE_CV_TYPE (type
);
327 while (ntype
!= type
)
329 if ((TYPE_CONST (ntype
) == cnst
) &&
330 (TYPE_VOLATILE (ntype
) == voltl
))
334 else if (*typeptr
== 0)
336 *typeptr
= ntype
; /* Tracking alloc, and we have new type. */
341 ntype
= TYPE_CV_TYPE (ntype
);
344 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
346 ntype
= alloc_type (TYPE_OBJFILE (type
));
351 /* We have storage, but need to reset it. */
354 objfile
= TYPE_OBJFILE (ntype
);
355 /* memset ((char *) ntype, 0, sizeof (struct type)); */
356 TYPE_OBJFILE (ntype
) = objfile
;
359 /* Copy original type */
360 memcpy ((char *) ntype
, (char *) type
, sizeof (struct type
));
361 /* But zero out fields that shouldn't be copied */
362 TYPE_POINTER_TYPE (ntype
) = (struct type
*) 0; /* Need new pointer kind */
363 TYPE_REFERENCE_TYPE (ntype
) = (struct type
*) 0; /* Need new referene kind */
364 /* Note: TYPE_TARGET_TYPE can be left as is */
366 /* Set flags appropriately */
368 TYPE_FLAGS (ntype
) |= TYPE_FLAG_CONST
;
370 TYPE_FLAGS (ntype
) &= ~TYPE_FLAG_CONST
;
373 TYPE_FLAGS (ntype
) |= TYPE_FLAG_VOLATILE
;
375 TYPE_FLAGS (ntype
) &= ~TYPE_FLAG_VOLATILE
;
377 /* Fix the chain of cv variants */
378 TYPE_CV_TYPE (ntype
) = type
;
379 TYPE_CV_TYPE (tmp_type
) = ntype
;
387 /* Implement direct support for MEMBER_TYPE in GNU C++.
388 May need to construct such a type if this is the first use.
389 The TYPE is the type of the member. The DOMAIN is the type
390 of the aggregate that the member belongs to. */
393 lookup_member_type (struct type
*type
, struct type
*domain
)
395 register struct type
*mtype
;
397 mtype
= alloc_type (TYPE_OBJFILE (type
));
398 smash_to_member_type (mtype
, domain
, type
);
402 /* Allocate a stub method whose return type is TYPE.
403 This apparently happens for speed of symbol reading, since parsing
404 out the arguments to the method is cpu-intensive, the way we are doing
405 it. So, we will fill in arguments later.
406 This always returns a fresh type. */
409 allocate_stub_method (struct type
*type
)
413 mtype
= alloc_type (TYPE_OBJFILE (type
));
414 TYPE_TARGET_TYPE (mtype
) = type
;
415 /* _DOMAIN_TYPE (mtype) = unknown yet */
416 /* _ARG_TYPES (mtype) = unknown yet */
417 TYPE_FLAGS (mtype
) = TYPE_FLAG_STUB
;
418 TYPE_CODE (mtype
) = TYPE_CODE_METHOD
;
419 TYPE_LENGTH (mtype
) = 1;
423 /* Create a range type using either a blank type supplied in RESULT_TYPE,
424 or creating a new type, inheriting the objfile from INDEX_TYPE.
426 Indices will be of type INDEX_TYPE, and will range from LOW_BOUND to
427 HIGH_BOUND, inclusive.
429 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
430 sure it is TYPE_CODE_UNDEF before we bash it into a range type? */
433 create_range_type (struct type
*result_type
, struct type
*index_type
,
434 int low_bound
, int high_bound
)
436 if (result_type
== NULL
)
438 result_type
= alloc_type (TYPE_OBJFILE (index_type
));
440 TYPE_CODE (result_type
) = TYPE_CODE_RANGE
;
441 TYPE_TARGET_TYPE (result_type
) = index_type
;
442 if (TYPE_FLAGS (index_type
) & TYPE_FLAG_STUB
)
443 TYPE_FLAGS (result_type
) |= TYPE_FLAG_TARGET_STUB
;
445 TYPE_LENGTH (result_type
) = TYPE_LENGTH (check_typedef (index_type
));
446 TYPE_NFIELDS (result_type
) = 2;
447 TYPE_FIELDS (result_type
) = (struct field
*)
448 TYPE_ALLOC (result_type
, 2 * sizeof (struct field
));
449 memset (TYPE_FIELDS (result_type
), 0, 2 * sizeof (struct field
));
450 TYPE_FIELD_BITPOS (result_type
, 0) = low_bound
;
451 TYPE_FIELD_BITPOS (result_type
, 1) = high_bound
;
452 TYPE_FIELD_TYPE (result_type
, 0) = builtin_type_int
; /* FIXME */
453 TYPE_FIELD_TYPE (result_type
, 1) = builtin_type_int
; /* FIXME */
456 TYPE_FLAGS (result_type
) |= TYPE_FLAG_UNSIGNED
;
458 return (result_type
);
461 /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type TYPE.
462 Return 1 of type is a range type, 0 if it is discrete (and bounds
463 will fit in LONGEST), or -1 otherwise. */
466 get_discrete_bounds (struct type
*type
, LONGEST
*lowp
, LONGEST
*highp
)
468 CHECK_TYPEDEF (type
);
469 switch (TYPE_CODE (type
))
471 case TYPE_CODE_RANGE
:
472 *lowp
= TYPE_LOW_BOUND (type
);
473 *highp
= TYPE_HIGH_BOUND (type
);
476 if (TYPE_NFIELDS (type
) > 0)
478 /* The enums may not be sorted by value, so search all
482 *lowp
= *highp
= TYPE_FIELD_BITPOS (type
, 0);
483 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
485 if (TYPE_FIELD_BITPOS (type
, i
) < *lowp
)
486 *lowp
= TYPE_FIELD_BITPOS (type
, i
);
487 if (TYPE_FIELD_BITPOS (type
, i
) > *highp
)
488 *highp
= TYPE_FIELD_BITPOS (type
, i
);
491 /* Set unsigned indicator if warranted. */
494 TYPE_FLAGS (type
) |= TYPE_FLAG_UNSIGNED
;
508 if (TYPE_LENGTH (type
) > sizeof (LONGEST
)) /* Too big */
510 if (!TYPE_UNSIGNED (type
))
512 *lowp
= -(1 << (TYPE_LENGTH (type
) * TARGET_CHAR_BIT
- 1));
516 /* ... fall through for unsigned ints ... */
519 /* This round-about calculation is to avoid shifting by
520 TYPE_LENGTH (type) * TARGET_CHAR_BIT, which will not work
521 if TYPE_LENGTH (type) == sizeof (LONGEST). */
522 *highp
= 1 << (TYPE_LENGTH (type
) * TARGET_CHAR_BIT
- 1);
523 *highp
= (*highp
- 1) | *highp
;
530 /* Create an array type using either a blank type supplied in RESULT_TYPE,
531 or creating a new type, inheriting the objfile from RANGE_TYPE.
533 Elements will be of type ELEMENT_TYPE, the indices will be of type
536 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
537 sure it is TYPE_CODE_UNDEF before we bash it into an array type? */
540 create_array_type (struct type
*result_type
, struct type
*element_type
,
541 struct type
*range_type
)
543 LONGEST low_bound
, high_bound
;
545 if (result_type
== NULL
)
547 result_type
= alloc_type (TYPE_OBJFILE (range_type
));
549 TYPE_CODE (result_type
) = TYPE_CODE_ARRAY
;
550 TYPE_TARGET_TYPE (result_type
) = element_type
;
551 if (get_discrete_bounds (range_type
, &low_bound
, &high_bound
) < 0)
552 low_bound
= high_bound
= 0;
553 CHECK_TYPEDEF (element_type
);
554 TYPE_LENGTH (result_type
) =
555 TYPE_LENGTH (element_type
) * (high_bound
- low_bound
+ 1);
556 TYPE_NFIELDS (result_type
) = 1;
557 TYPE_FIELDS (result_type
) =
558 (struct field
*) TYPE_ALLOC (result_type
, sizeof (struct field
));
559 memset (TYPE_FIELDS (result_type
), 0, sizeof (struct field
));
560 TYPE_FIELD_TYPE (result_type
, 0) = range_type
;
561 TYPE_VPTR_FIELDNO (result_type
) = -1;
563 /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays */
564 if (TYPE_LENGTH (result_type
) == 0)
565 TYPE_FLAGS (result_type
) |= TYPE_FLAG_TARGET_STUB
;
567 return (result_type
);
570 /* Create a string type using either a blank type supplied in RESULT_TYPE,
571 or creating a new type. String types are similar enough to array of
572 char types that we can use create_array_type to build the basic type
573 and then bash it into a string type.
575 For fixed length strings, the range type contains 0 as the lower
576 bound and the length of the string minus one as the upper bound.
578 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
579 sure it is TYPE_CODE_UNDEF before we bash it into a string type? */
582 create_string_type (struct type
*result_type
, struct type
*range_type
)
584 result_type
= create_array_type (result_type
,
585 *current_language
->string_char_type
,
587 TYPE_CODE (result_type
) = TYPE_CODE_STRING
;
588 return (result_type
);
592 create_set_type (struct type
*result_type
, struct type
*domain_type
)
594 LONGEST low_bound
, high_bound
, bit_length
;
595 if (result_type
== NULL
)
597 result_type
= alloc_type (TYPE_OBJFILE (domain_type
));
599 TYPE_CODE (result_type
) = TYPE_CODE_SET
;
600 TYPE_NFIELDS (result_type
) = 1;
601 TYPE_FIELDS (result_type
) = (struct field
*)
602 TYPE_ALLOC (result_type
, 1 * sizeof (struct field
));
603 memset (TYPE_FIELDS (result_type
), 0, sizeof (struct field
));
605 if (!(TYPE_FLAGS (domain_type
) & TYPE_FLAG_STUB
))
607 if (get_discrete_bounds (domain_type
, &low_bound
, &high_bound
) < 0)
608 low_bound
= high_bound
= 0;
609 bit_length
= high_bound
- low_bound
+ 1;
610 TYPE_LENGTH (result_type
)
611 = (bit_length
+ TARGET_CHAR_BIT
- 1) / TARGET_CHAR_BIT
;
613 TYPE_FIELD_TYPE (result_type
, 0) = domain_type
;
616 TYPE_FLAGS (result_type
) |= TYPE_FLAG_UNSIGNED
;
618 return (result_type
);
622 /* Construct and return a type of the form:
623 struct NAME { ELT_TYPE ELT_NAME[N]; }
624 We use these types for SIMD registers. For example, the type of
625 the SSE registers on the late x86-family processors is:
626 struct __builtin_v4sf { float f[4]; }
627 built by the function call:
628 init_simd_type ("__builtin_v4sf", builtin_type_float, "f", 4)
629 The type returned is a permanent type, allocated using malloc; it
630 doesn't live in any objfile's obstack. */
632 init_simd_type (char *name
,
633 struct type
*elt_type
,
640 /* Build the field structure. */
641 f
= xmalloc (sizeof (*f
));
642 memset (f
, 0, sizeof (*f
));
644 f
->type
= create_array_type (0, elt_type
,
645 create_range_type (0, builtin_type_int
,
649 /* Build a struct type with that field. */
650 t
= init_type (TYPE_CODE_STRUCT
, n
* TYPE_LENGTH (elt_type
), 0, 0, 0);
659 /* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE.
660 A MEMBER is a wierd thing -- it amounts to a typed offset into
661 a struct, e.g. "an int at offset 8". A MEMBER TYPE doesn't
662 include the offset (that's the value of the MEMBER itself), but does
663 include the structure type into which it points (for some reason).
665 When "smashing" the type, we preserve the objfile that the
666 old type pointed to, since we aren't changing where the type is actually
670 smash_to_member_type (struct type
*type
, struct type
*domain
,
671 struct type
*to_type
)
673 struct objfile
*objfile
;
675 objfile
= TYPE_OBJFILE (type
);
677 memset ((char *) type
, 0, sizeof (struct type
));
678 TYPE_OBJFILE (type
) = objfile
;
679 TYPE_TARGET_TYPE (type
) = to_type
;
680 TYPE_DOMAIN_TYPE (type
) = domain
;
681 TYPE_LENGTH (type
) = 1; /* In practice, this is never needed. */
682 TYPE_CODE (type
) = TYPE_CODE_MEMBER
;
685 /* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE.
686 METHOD just means `function that gets an extra "this" argument'.
688 When "smashing" the type, we preserve the objfile that the
689 old type pointed to, since we aren't changing where the type is actually
693 smash_to_method_type (struct type
*type
, struct type
*domain
,
694 struct type
*to_type
, struct type
**args
)
696 struct objfile
*objfile
;
698 objfile
= TYPE_OBJFILE (type
);
700 memset ((char *) type
, 0, sizeof (struct type
));
701 TYPE_OBJFILE (type
) = objfile
;
702 TYPE_TARGET_TYPE (type
) = to_type
;
703 TYPE_DOMAIN_TYPE (type
) = domain
;
704 TYPE_ARG_TYPES (type
) = args
;
705 TYPE_LENGTH (type
) = 1; /* In practice, this is never needed. */
706 TYPE_CODE (type
) = TYPE_CODE_METHOD
;
709 /* Return a typename for a struct/union/enum type without "struct ",
710 "union ", or "enum ". If the type has a NULL name, return NULL. */
713 type_name_no_tag (register const struct type
*type
)
715 if (TYPE_TAG_NAME (type
) != NULL
)
716 return TYPE_TAG_NAME (type
);
718 /* Is there code which expects this to return the name if there is no
719 tag name? My guess is that this is mainly used for C++ in cases where
720 the two will always be the same. */
721 return TYPE_NAME (type
);
724 /* Lookup a primitive type named NAME.
725 Return zero if NAME is not a primitive type. */
728 lookup_primitive_typename (char *name
)
730 struct type
**const *p
;
732 for (p
= current_language
->la_builtin_type_vector
; *p
!= NULL
; p
++)
734 if (STREQ ((**p
)->name
, name
))
742 /* Lookup a typedef or primitive type named NAME,
743 visible in lexical block BLOCK.
744 If NOERR is nonzero, return zero if NAME is not suitably defined. */
747 lookup_typename (char *name
, struct block
*block
, int noerr
)
749 register struct symbol
*sym
;
750 register struct type
*tmp
;
752 sym
= lookup_symbol (name
, block
, VAR_NAMESPACE
, 0, (struct symtab
**) NULL
);
753 if (sym
== NULL
|| SYMBOL_CLASS (sym
) != LOC_TYPEDEF
)
755 tmp
= lookup_primitive_typename (name
);
760 else if (!tmp
&& noerr
)
766 error ("No type named %s.", name
);
769 return (SYMBOL_TYPE (sym
));
773 lookup_unsigned_typename (char *name
)
775 char *uns
= alloca (strlen (name
) + 10);
777 strcpy (uns
, "unsigned ");
778 strcpy (uns
+ 9, name
);
779 return (lookup_typename (uns
, (struct block
*) NULL
, 0));
783 lookup_signed_typename (char *name
)
786 char *uns
= alloca (strlen (name
) + 8);
788 strcpy (uns
, "signed ");
789 strcpy (uns
+ 7, name
);
790 t
= lookup_typename (uns
, (struct block
*) NULL
, 1);
791 /* If we don't find "signed FOO" just try again with plain "FOO". */
794 return lookup_typename (name
, (struct block
*) NULL
, 0);
797 /* Lookup a structure type named "struct NAME",
798 visible in lexical block BLOCK. */
801 lookup_struct (char *name
, struct block
*block
)
803 register struct symbol
*sym
;
805 sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
, 0,
806 (struct symtab
**) NULL
);
810 error ("No struct type named %s.", name
);
812 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_STRUCT
)
814 error ("This context has class, union or enum %s, not a struct.", name
);
816 return (SYMBOL_TYPE (sym
));
819 /* Lookup a union type named "union NAME",
820 visible in lexical block BLOCK. */
823 lookup_union (char *name
, struct block
*block
)
825 register struct symbol
*sym
;
828 sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
, 0,
829 (struct symtab
**) NULL
);
832 error ("No union type named %s.", name
);
834 t
= SYMBOL_TYPE (sym
);
836 if (TYPE_CODE (t
) == TYPE_CODE_UNION
)
839 /* C++ unions may come out with TYPE_CODE_CLASS, but we look at
840 * a further "declared_type" field to discover it is really a union.
842 if (HAVE_CPLUS_STRUCT (t
))
843 if (TYPE_DECLARED_TYPE (t
) == DECLARED_TYPE_UNION
)
846 /* If we get here, it's not a union */
847 error ("This context has class, struct or enum %s, not a union.", name
);
851 /* Lookup an enum type named "enum NAME",
852 visible in lexical block BLOCK. */
855 lookup_enum (char *name
, struct block
*block
)
857 register struct symbol
*sym
;
859 sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
, 0,
860 (struct symtab
**) NULL
);
863 error ("No enum type named %s.", name
);
865 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_ENUM
)
867 error ("This context has class, struct or union %s, not an enum.", name
);
869 return (SYMBOL_TYPE (sym
));
872 /* Lookup a template type named "template NAME<TYPE>",
873 visible in lexical block BLOCK. */
876 lookup_template_type (char *name
, struct type
*type
, struct block
*block
)
879 char *nam
= (char *) alloca (strlen (name
) + strlen (type
->name
) + 4);
882 strcat (nam
, type
->name
);
883 strcat (nam
, " >"); /* FIXME, extra space still introduced in gcc? */
885 sym
= lookup_symbol (nam
, block
, VAR_NAMESPACE
, 0, (struct symtab
**) NULL
);
889 error ("No template type named %s.", name
);
891 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_STRUCT
)
893 error ("This context has class, union or enum %s, not a struct.", name
);
895 return (SYMBOL_TYPE (sym
));
898 /* Given a type TYPE, lookup the type of the component of type named NAME.
900 TYPE can be either a struct or union, or a pointer or reference to a struct or
901 union. If it is a pointer or reference, its target type is automatically used.
902 Thus '.' and '->' are interchangable, as specified for the definitions of the
903 expression element types STRUCTOP_STRUCT and STRUCTOP_PTR.
905 If NOERR is nonzero, return zero if NAME is not suitably defined.
906 If NAME is the name of a baseclass type, return that type. */
909 lookup_struct_elt_type (struct type
*type
, char *name
, int noerr
)
915 CHECK_TYPEDEF (type
);
916 if (TYPE_CODE (type
) != TYPE_CODE_PTR
917 && TYPE_CODE (type
) != TYPE_CODE_REF
)
919 type
= TYPE_TARGET_TYPE (type
);
922 if (TYPE_CODE (type
) != TYPE_CODE_STRUCT
&&
923 TYPE_CODE (type
) != TYPE_CODE_UNION
)
925 target_terminal_ours ();
926 gdb_flush (gdb_stdout
);
927 fprintf_unfiltered (gdb_stderr
, "Type ");
928 type_print (type
, "", gdb_stderr
, -1);
929 error (" is not a structure or union type.");
933 /* FIXME: This change put in by Michael seems incorrect for the case where
934 the structure tag name is the same as the member name. I.E. when doing
935 "ptype bell->bar" for "struct foo { int bar; int foo; } bell;"
940 typename
= type_name_no_tag (type
);
941 if (typename
!= NULL
&& STREQ (typename
, name
))
946 for (i
= TYPE_NFIELDS (type
) - 1; i
>= TYPE_N_BASECLASSES (type
); i
--)
948 char *t_field_name
= TYPE_FIELD_NAME (type
, i
);
950 if (t_field_name
&& (strcmp_iw (t_field_name
, name
) == 0))
952 return TYPE_FIELD_TYPE (type
, i
);
956 /* OK, it's not in this class. Recursively check the baseclasses. */
957 for (i
= TYPE_N_BASECLASSES (type
) - 1; i
>= 0; i
--)
961 t
= lookup_struct_elt_type (TYPE_BASECLASS (type
, i
), name
, noerr
);
973 target_terminal_ours ();
974 gdb_flush (gdb_stdout
);
975 fprintf_unfiltered (gdb_stderr
, "Type ");
976 type_print (type
, "", gdb_stderr
, -1);
977 fprintf_unfiltered (gdb_stderr
, " has no component named ");
978 fputs_filtered (name
, gdb_stderr
);
980 return (struct type
*) -1; /* For lint */
983 /* If possible, make the vptr_fieldno and vptr_basetype fields of TYPE
984 valid. Callers should be aware that in some cases (for example,
985 the type or one of its baseclasses is a stub type and we are
986 debugging a .o file), this function will not be able to find the virtual
987 function table pointer, and vptr_fieldno will remain -1 and vptr_basetype
991 fill_in_vptr_fieldno (struct type
*type
)
993 CHECK_TYPEDEF (type
);
995 if (TYPE_VPTR_FIELDNO (type
) < 0)
999 /* We must start at zero in case the first (and only) baseclass is
1000 virtual (and hence we cannot share the table pointer). */
1001 for (i
= 0; i
< TYPE_N_BASECLASSES (type
); i
++)
1003 fill_in_vptr_fieldno (TYPE_BASECLASS (type
, i
));
1004 if (TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type
, i
)) >= 0)
1006 TYPE_VPTR_FIELDNO (type
)
1007 = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type
, i
));
1008 TYPE_VPTR_BASETYPE (type
)
1009 = TYPE_VPTR_BASETYPE (TYPE_BASECLASS (type
, i
));
1016 /* Find the method and field indices for the destructor in class type T.
1017 Return 1 if the destructor was found, otherwise, return 0. */
1020 get_destructor_fn_field (struct type
*t
, int *method_indexp
, int *field_indexp
)
1024 for (i
= 0; i
< TYPE_NFN_FIELDS (t
); i
++)
1027 struct fn_field
*f
= TYPE_FN_FIELDLIST1 (t
, i
);
1029 for (j
= 0; j
< TYPE_FN_FIELDLIST_LENGTH (t
, i
); j
++)
1031 if (is_destructor_name (TYPE_FN_FIELD_PHYSNAME (f
, j
)) != 0)
1042 /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989.
1044 If this is a stubbed struct (i.e. declared as struct foo *), see if
1045 we can find a full definition in some other file. If so, copy this
1046 definition, so we can use it in future. There used to be a comment (but
1047 not any code) that if we don't find a full definition, we'd set a flag
1048 so we don't spend time in the future checking the same type. That would
1049 be a mistake, though--we might load in more symbols which contain a
1050 full definition for the type.
1052 This used to be coded as a macro, but I don't think it is called
1053 often enough to merit such treatment. */
1055 struct complaint stub_noname_complaint
=
1056 {"stub type has NULL name", 0, 0};
1059 check_typedef (register struct type
*type
)
1061 struct type
*orig_type
= type
;
1062 while (TYPE_CODE (type
) == TYPE_CODE_TYPEDEF
)
1064 if (!TYPE_TARGET_TYPE (type
))
1069 /* It is dangerous to call lookup_symbol if we are currently
1070 reading a symtab. Infinite recursion is one danger. */
1071 if (currently_reading_symtab
)
1074 name
= type_name_no_tag (type
);
1075 /* FIXME: shouldn't we separately check the TYPE_NAME and the
1076 TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE
1077 as appropriate? (this code was written before TYPE_NAME and
1078 TYPE_TAG_NAME were separate). */
1081 complain (&stub_noname_complaint
);
1084 sym
= lookup_symbol (name
, 0, STRUCT_NAMESPACE
, 0,
1085 (struct symtab
**) NULL
);
1087 TYPE_TARGET_TYPE (type
) = SYMBOL_TYPE (sym
);
1089 TYPE_TARGET_TYPE (type
) = alloc_type (NULL
); /* TYPE_CODE_UNDEF */
1091 type
= TYPE_TARGET_TYPE (type
);
1094 /* If this is a struct/class/union with no fields, then check whether a
1095 full definition exists somewhere else. This is for systems where a
1096 type definition with no fields is issued for such types, instead of
1097 identifying them as stub types in the first place */
1099 if (TYPE_IS_OPAQUE (type
) && opaque_type_resolution
&& !currently_reading_symtab
)
1101 char *name
= type_name_no_tag (type
);
1102 struct type
*newtype
;
1105 complain (&stub_noname_complaint
);
1108 newtype
= lookup_transparent_type (name
);
1111 memcpy ((char *) type
, (char *) newtype
, sizeof (struct type
));
1114 /* Otherwise, rely on the stub flag being set for opaque/stubbed types */
1115 else if ((TYPE_FLAGS (type
) & TYPE_FLAG_STUB
) && !currently_reading_symtab
)
1117 char *name
= type_name_no_tag (type
);
1118 /* FIXME: shouldn't we separately check the TYPE_NAME and the
1119 TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE
1120 as appropriate? (this code was written before TYPE_NAME and
1121 TYPE_TAG_NAME were separate). */
1125 complain (&stub_noname_complaint
);
1128 sym
= lookup_symbol (name
, 0, STRUCT_NAMESPACE
, 0, (struct symtab
**) NULL
);
1131 memcpy ((char *) type
, (char *) SYMBOL_TYPE (sym
), sizeof (struct type
));
1135 if (TYPE_FLAGS (type
) & TYPE_FLAG_TARGET_STUB
)
1137 struct type
*range_type
;
1138 struct type
*target_type
= check_typedef (TYPE_TARGET_TYPE (type
));
1140 if (TYPE_FLAGS (target_type
) & (TYPE_FLAG_STUB
| TYPE_FLAG_TARGET_STUB
))
1143 else if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
1144 && TYPE_NFIELDS (type
) == 1
1145 && (TYPE_CODE (range_type
= TYPE_FIELD_TYPE (type
, 0))
1146 == TYPE_CODE_RANGE
))
1148 /* Now recompute the length of the array type, based on its
1149 number of elements and the target type's length. */
1150 TYPE_LENGTH (type
) =
1151 ((TYPE_FIELD_BITPOS (range_type
, 1)
1152 - TYPE_FIELD_BITPOS (range_type
, 0)
1154 * TYPE_LENGTH (target_type
));
1155 TYPE_FLAGS (type
) &= ~TYPE_FLAG_TARGET_STUB
;
1157 else if (TYPE_CODE (type
) == TYPE_CODE_RANGE
)
1159 TYPE_LENGTH (type
) = TYPE_LENGTH (target_type
);
1160 TYPE_FLAGS (type
) &= ~TYPE_FLAG_TARGET_STUB
;
1163 /* Cache TYPE_LENGTH for future use. */
1164 TYPE_LENGTH (orig_type
) = TYPE_LENGTH (type
);
1168 /* New code added to support parsing of Cfront stabs strings */
1169 #define INIT_EXTRA { pextras->len=0; pextras->str[0]='\0'; }
1170 #define ADD_EXTRA(c) { pextras->str[pextras->len++]=c; }
1173 add_name (struct extra
*pextras
, char *n
)
1177 if ((nlen
= (n
? strlen (n
) : 0)) == 0)
1179 sprintf (pextras
->str
+ pextras
->len
, "%d%s", nlen
, n
);
1180 pextras
->len
= strlen (pextras
->str
);
1184 add_mangled_type (struct extra
*pextras
, struct type
*t
)
1186 enum type_code tcode
;
1190 tcode
= TYPE_CODE (t
);
1191 tlen
= TYPE_LENGTH (t
);
1192 tflags
= TYPE_FLAGS (t
);
1193 tname
= TYPE_NAME (t
);
1194 /* args of "..." seem to get mangled as "e" */
1212 if ((pname
= strrchr (tname
, 'l'), pname
) && !strcmp (pname
, "long"))
1225 static struct complaint msg
=
1226 {"Bad int type code length x%x\n", 0, 0};
1228 complain (&msg
, tlen
);
1247 static struct complaint msg
=
1248 {"Bad float type code length x%x\n", 0, 0};
1249 complain (&msg
, tlen
);
1255 /* followed by what it's a ref to */
1259 /* followed by what it's a ptr to */
1261 case TYPE_CODE_TYPEDEF
:
1263 static struct complaint msg
=
1264 {"Typedefs in overloaded functions not yet supported\n", 0, 0};
1267 /* followed by type bytes & name */
1269 case TYPE_CODE_FUNC
:
1271 /* followed by func's arg '_' & ret types */
1273 case TYPE_CODE_VOID
:
1276 case TYPE_CODE_METHOD
:
1278 /* followed by name of class and func's arg '_' & ret types */
1279 add_name (pextras
, tname
);
1280 ADD_EXTRA ('F'); /* then mangle function */
1282 case TYPE_CODE_STRUCT
: /* C struct */
1283 case TYPE_CODE_UNION
: /* C union */
1284 case TYPE_CODE_ENUM
: /* Enumeration type */
1285 /* followed by name of type */
1286 add_name (pextras
, tname
);
1289 /* errors possible types/not supported */
1290 case TYPE_CODE_CHAR
:
1291 case TYPE_CODE_ARRAY
: /* Array type */
1292 case TYPE_CODE_MEMBER
: /* Member type */
1293 case TYPE_CODE_BOOL
:
1294 case TYPE_CODE_COMPLEX
: /* Complex float */
1295 case TYPE_CODE_UNDEF
:
1296 case TYPE_CODE_SET
: /* Pascal sets */
1297 case TYPE_CODE_RANGE
:
1298 case TYPE_CODE_STRING
:
1299 case TYPE_CODE_BITSTRING
:
1300 case TYPE_CODE_ERROR
:
1303 static struct complaint msg
=
1304 {"Unknown type code x%x\n", 0, 0};
1305 complain (&msg
, tcode
);
1309 add_mangled_type (pextras
, t
->target_type
);
1314 cfront_mangle_name (struct type
*type
, int i
, int j
)
1317 char *mangled_name
= gdb_mangle_name (type
, i
, j
);
1319 f
= TYPE_FN_FIELDLIST1 (type
, i
); /* moved from below */
1321 /* kludge to support cfront methods - gdb expects to find "F" for
1322 ARM_mangled names, so when we mangle, we have to add it here */
1326 char *arm_mangled_name
;
1327 struct fn_field
*method
= &f
[j
];
1328 char *field_name
= TYPE_FN_FIELDLIST_NAME (type
, i
);
1329 char *physname
= TYPE_FN_FIELD_PHYSNAME (f
, j
);
1330 char *newname
= type_name_no_tag (type
);
1332 struct type
*ftype
= TYPE_FN_FIELD_TYPE (f
, j
);
1333 int nargs
= TYPE_NFIELDS (ftype
); /* number of args */
1334 struct extra extras
, *pextras
= &extras
;
1337 if (TYPE_FN_FIELD_STATIC_P (f
, j
)) /* j for sublist within this list */
1340 /* add args here! */
1341 if (nargs
<= 1) /* no args besides this */
1345 for (k
= 1; k
< nargs
; k
++)
1348 t
= TYPE_FIELD_TYPE (ftype
, k
);
1349 add_mangled_type (pextras
, t
);
1353 printf ("add_mangled_type: %s\n", extras
.str
); /* FIXME */
1354 xasprintf (&arm_mangled_name
, "%s%s", mangled_name
, extras
.str
);
1355 xfree (mangled_name
);
1356 mangled_name
= arm_mangled_name
;
1362 /* End of new code added to support parsing of Cfront stabs strings */
1364 /* Parse a type expression in the string [P..P+LENGTH). If an error occurs,
1365 silently return builtin_type_void. */
1368 safe_parse_type (char *p
, int length
)
1370 struct ui_file
*saved_gdb_stderr
;
1373 /* Suppress error messages. */
1374 saved_gdb_stderr
= gdb_stderr
;
1375 gdb_stderr
= ui_file_new ();
1377 /* Call parse_and_eval_type() without fear of longjmp()s. */
1378 if (!gdb_parse_and_eval_type (p
, length
, &type
))
1379 type
= builtin_type_void
;
1381 /* Stop suppressing error messages. */
1382 ui_file_delete (gdb_stderr
);
1383 gdb_stderr
= saved_gdb_stderr
;
1388 /* Ugly hack to convert method stubs into method types.
1390 He ain't kiddin'. This demangles the name of the method into a string
1391 including argument types, parses out each argument type, generates
1392 a string casting a zero to that type, evaluates the string, and stuffs
1393 the resulting type into an argtype vector!!! Then it knows the type
1394 of the whole function (including argument types for overloading),
1395 which info used to be in the stab's but was removed to hack back
1396 the space required for them. */
1399 check_stub_method (struct type
*type
, int method_id
, int signature_id
)
1402 char *mangled_name
= gdb_mangle_name (type
, method_id
, signature_id
);
1403 char *demangled_name
= cplus_demangle (mangled_name
,
1404 DMGL_PARAMS
| DMGL_ANSI
);
1405 char *argtypetext
, *p
;
1406 int depth
= 0, argcount
= 1;
1407 struct type
**argtypes
;
1410 /* Make sure we got back a function string that we can use. */
1412 p
= strchr (demangled_name
, '(');
1416 if (demangled_name
== NULL
|| p
== NULL
)
1417 error ("Internal: Cannot demangle mangled name `%s'.", mangled_name
);
1419 /* Now, read in the parameters that define this type. */
1424 if (*p
== '(' || *p
== '<')
1428 else if (*p
== ')' || *p
== '>')
1432 else if (*p
== ',' && depth
== 0)
1440 /* We need two more slots: one for the THIS pointer, and one for the
1441 NULL [...] or void [end of arglist]. */
1443 argtypes
= (struct type
**)
1444 TYPE_ALLOC (type
, (argcount
+ 2) * sizeof (struct type
*));
1446 /* FIXME: This is wrong for static member functions. */
1447 argtypes
[0] = lookup_pointer_type (type
);
1450 if (*p
!= ')') /* () means no args, skip while */
1455 if (depth
<= 0 && (*p
== ',' || *p
== ')'))
1457 /* Avoid parsing of ellipsis, they will be handled below. */
1458 if (strncmp (argtypetext
, "...", p
- argtypetext
) != 0)
1460 argtypes
[argcount
] =
1461 safe_parse_type (argtypetext
, p
- argtypetext
);
1464 argtypetext
= p
+ 1;
1467 if (*p
== '(' || *p
== '<')
1471 else if (*p
== ')' || *p
== '>')
1480 if (p
[-2] != '.') /* Not '...' */
1482 argtypes
[argcount
] = builtin_type_void
; /* List terminator */
1486 argtypes
[argcount
] = NULL
; /* Ellist terminator */
1489 xfree (demangled_name
);
1491 f
= TYPE_FN_FIELDLIST1 (type
, method_id
);
1493 TYPE_FN_FIELD_PHYSNAME (f
, signature_id
) = mangled_name
;
1495 /* Now update the old "stub" type into a real type. */
1496 mtype
= TYPE_FN_FIELD_TYPE (f
, signature_id
);
1497 TYPE_DOMAIN_TYPE (mtype
) = type
;
1498 TYPE_ARG_TYPES (mtype
) = argtypes
;
1499 TYPE_FLAGS (mtype
) &= ~TYPE_FLAG_STUB
;
1500 TYPE_FN_FIELD_STUB (f
, signature_id
) = 0;
1503 const struct cplus_struct_type cplus_struct_default
;
1506 allocate_cplus_struct_type (struct type
*type
)
1508 if (!HAVE_CPLUS_STRUCT (type
))
1510 TYPE_CPLUS_SPECIFIC (type
) = (struct cplus_struct_type
*)
1511 TYPE_ALLOC (type
, sizeof (struct cplus_struct_type
));
1512 *(TYPE_CPLUS_SPECIFIC (type
)) = cplus_struct_default
;
1516 /* Helper function to initialize the standard scalar types.
1518 If NAME is non-NULL and OBJFILE is non-NULL, then we make a copy
1519 of the string pointed to by name in the type_obstack for that objfile,
1520 and initialize the type name to that copy. There are places (mipsread.c
1521 in particular, where init_type is called with a NULL value for NAME). */
1524 init_type (enum type_code code
, int length
, int flags
, char *name
,
1525 struct objfile
*objfile
)
1527 register struct type
*type
;
1529 type
= alloc_type (objfile
);
1530 TYPE_CODE (type
) = code
;
1531 TYPE_LENGTH (type
) = length
;
1532 TYPE_FLAGS (type
) |= flags
;
1533 if ((name
!= NULL
) && (objfile
!= NULL
))
1536 obsavestring (name
, strlen (name
), &objfile
->type_obstack
);
1540 TYPE_NAME (type
) = name
;
1545 if (code
== TYPE_CODE_STRUCT
|| code
== TYPE_CODE_UNION
)
1547 INIT_CPLUS_SPECIFIC (type
);
1552 /* Look up a fundamental type for the specified objfile.
1553 May need to construct such a type if this is the first use.
1555 Some object file formats (ELF, COFF, etc) do not define fundamental
1556 types such as "int" or "double". Others (stabs for example), do
1557 define fundamental types.
1559 For the formats which don't provide fundamental types, gdb can create
1560 such types, using defaults reasonable for the current language and
1561 the current target machine.
1563 NOTE: This routine is obsolescent. Each debugging format reader
1564 should manage it's own fundamental types, either creating them from
1565 suitable defaults or reading them from the debugging information,
1566 whichever is appropriate. The DWARF reader has already been
1567 fixed to do this. Once the other readers are fixed, this routine
1568 will go away. Also note that fundamental types should be managed
1569 on a compilation unit basis in a multi-language environment, not
1570 on a linkage unit basis as is done here. */
1574 lookup_fundamental_type (struct objfile
*objfile
, int typeid)
1576 register struct type
**typep
;
1577 register int nbytes
;
1579 if (typeid < 0 || typeid >= FT_NUM_MEMBERS
)
1581 error ("internal error - invalid fundamental type id %d", typeid);
1584 /* If this is the first time we need a fundamental type for this objfile
1585 then we need to initialize the vector of type pointers. */
1587 if (objfile
->fundamental_types
== NULL
)
1589 nbytes
= FT_NUM_MEMBERS
* sizeof (struct type
*);
1590 objfile
->fundamental_types
= (struct type
**)
1591 obstack_alloc (&objfile
->type_obstack
, nbytes
);
1592 memset ((char *) objfile
->fundamental_types
, 0, nbytes
);
1593 OBJSTAT (objfile
, n_types
+= FT_NUM_MEMBERS
);
1596 /* Look for this particular type in the fundamental type vector. If one is
1597 not found, create and install one appropriate for the current language. */
1599 typep
= objfile
->fundamental_types
+ typeid;
1602 *typep
= create_fundamental_type (objfile
, typeid);
1609 can_dereference (struct type
*t
)
1611 /* FIXME: Should we return true for references as well as pointers? */
1615 && TYPE_CODE (t
) == TYPE_CODE_PTR
1616 && TYPE_CODE (TYPE_TARGET_TYPE (t
)) != TYPE_CODE_VOID
);
1620 is_integral_type (struct type
*t
)
1625 && ((TYPE_CODE (t
) == TYPE_CODE_INT
)
1626 || (TYPE_CODE (t
) == TYPE_CODE_ENUM
)
1627 || (TYPE_CODE (t
) == TYPE_CODE_CHAR
)
1628 || (TYPE_CODE (t
) == TYPE_CODE_RANGE
)
1629 || (TYPE_CODE (t
) == TYPE_CODE_BOOL
)));
1632 /* Chill varying string and arrays are represented as follows:
1634 struct { int __var_length; ELEMENT_TYPE[MAX_SIZE] __var_data};
1636 Return true if TYPE is such a Chill varying type. */
1639 chill_varying_type (struct type
*type
)
1641 if (TYPE_CODE (type
) != TYPE_CODE_STRUCT
1642 || TYPE_NFIELDS (type
) != 2
1643 || strcmp (TYPE_FIELD_NAME (type
, 0), "__var_length") != 0)
1648 /* Check whether BASE is an ancestor or base class or DCLASS
1649 Return 1 if so, and 0 if not.
1650 Note: callers may want to check for identity of the types before
1651 calling this function -- identical types are considered to satisfy
1652 the ancestor relationship even if they're identical */
1655 is_ancestor (struct type
*base
, struct type
*dclass
)
1659 CHECK_TYPEDEF (base
);
1660 CHECK_TYPEDEF (dclass
);
1664 if (TYPE_NAME (base
) && TYPE_NAME (dclass
) &&
1665 !strcmp (TYPE_NAME (base
), TYPE_NAME (dclass
)))
1668 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1669 if (is_ancestor (base
, TYPE_BASECLASS (dclass
, i
)))
1677 /* See whether DCLASS has a virtual table. This routine is aimed at
1678 the HP/Taligent ANSI C++ runtime model, and may not work with other
1679 runtime models. Return 1 => Yes, 0 => No. */
1682 has_vtable (struct type
*dclass
)
1684 /* In the HP ANSI C++ runtime model, a class has a vtable only if it
1685 has virtual functions or virtual bases. */
1689 if (TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
1692 /* First check for the presence of virtual bases */
1693 if (TYPE_FIELD_VIRTUAL_BITS (dclass
))
1694 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1695 if (B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass
), i
))
1698 /* Next check for virtual functions */
1699 if (TYPE_FN_FIELDLISTS (dclass
))
1700 for (i
= 0; i
< TYPE_NFN_FIELDS (dclass
); i
++)
1701 if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass
, i
), 0))
1704 /* Recurse on non-virtual bases to see if any of them needs a vtable */
1705 if (TYPE_FIELD_VIRTUAL_BITS (dclass
))
1706 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1707 if ((!B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass
), i
)) &&
1708 (has_vtable (TYPE_FIELD_TYPE (dclass
, i
))))
1711 /* Well, maybe we don't need a virtual table */
1715 /* Return a pointer to the "primary base class" of DCLASS.
1717 A NULL return indicates that DCLASS has no primary base, or that it
1718 couldn't be found (insufficient information).
1720 This routine is aimed at the HP/Taligent ANSI C++ runtime model,
1721 and may not work with other runtime models. */
1724 primary_base_class (struct type
*dclass
)
1726 /* In HP ANSI C++'s runtime model, a "primary base class" of a class
1727 is the first directly inherited, non-virtual base class that
1728 requires a virtual table */
1732 if (TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
1735 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1736 if (!TYPE_FIELD_VIRTUAL (dclass
, i
) &&
1737 has_vtable (TYPE_FIELD_TYPE (dclass
, i
)))
1738 return TYPE_FIELD_TYPE (dclass
, i
);
1743 /* Global manipulated by virtual_base_list[_aux]() */
1745 static struct vbase
*current_vbase_list
= NULL
;
1747 /* Return a pointer to a null-terminated list of struct vbase
1748 items. The vbasetype pointer of each item in the list points to the
1749 type information for a virtual base of the argument DCLASS.
1751 Helper function for virtual_base_list().
1752 Note: the list goes backward, right-to-left. virtual_base_list()
1753 copies the items out in reverse order. */
1756 virtual_base_list_aux (struct type
*dclass
)
1758 struct vbase
*tmp_vbase
;
1761 if (TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
1764 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1766 /* Recurse on this ancestor, first */
1767 virtual_base_list_aux (TYPE_FIELD_TYPE (dclass
, i
));
1769 /* If this current base is itself virtual, add it to the list */
1770 if (BASETYPE_VIA_VIRTUAL (dclass
, i
))
1772 struct type
*basetype
= TYPE_FIELD_TYPE (dclass
, i
);
1774 /* Check if base already recorded */
1775 tmp_vbase
= current_vbase_list
;
1778 if (tmp_vbase
->vbasetype
== basetype
)
1779 break; /* found it */
1780 tmp_vbase
= tmp_vbase
->next
;
1783 if (!tmp_vbase
) /* normal exit from loop */
1785 /* Allocate new item for this virtual base */
1786 tmp_vbase
= (struct vbase
*) xmalloc (sizeof (struct vbase
));
1788 /* Stick it on at the end of the list */
1789 tmp_vbase
->vbasetype
= basetype
;
1790 tmp_vbase
->next
= current_vbase_list
;
1791 current_vbase_list
= tmp_vbase
;
1794 } /* for loop over bases */
1798 /* Compute the list of virtual bases in the right order. Virtual
1799 bases are laid out in the object's memory area in order of their
1800 occurrence in a depth-first, left-to-right search through the
1803 Argument DCLASS is the type whose virtual bases are required.
1804 Return value is the address of a null-terminated array of pointers
1805 to struct type items.
1807 This routine is aimed at the HP/Taligent ANSI C++ runtime model,
1808 and may not work with other runtime models.
1810 This routine merely hands off the argument to virtual_base_list_aux()
1811 and then copies the result into an array to save space. */
1814 virtual_base_list (struct type
*dclass
)
1816 register struct vbase
*tmp_vbase
;
1817 register struct vbase
*tmp_vbase_2
;
1820 struct type
**vbase_array
;
1822 current_vbase_list
= NULL
;
1823 virtual_base_list_aux (dclass
);
1825 for (i
= 0, tmp_vbase
= current_vbase_list
; tmp_vbase
!= NULL
; i
++, tmp_vbase
= tmp_vbase
->next
)
1830 vbase_array
= (struct type
**) xmalloc ((count
+ 1) * sizeof (struct type
*));
1832 for (i
= count
- 1, tmp_vbase
= current_vbase_list
; i
>= 0; i
--, tmp_vbase
= tmp_vbase
->next
)
1833 vbase_array
[i
] = tmp_vbase
->vbasetype
;
1835 /* Get rid of constructed chain */
1836 tmp_vbase_2
= tmp_vbase
= current_vbase_list
;
1839 tmp_vbase
= tmp_vbase
->next
;
1840 xfree (tmp_vbase_2
);
1841 tmp_vbase_2
= tmp_vbase
;
1844 vbase_array
[count
] = NULL
;
1848 /* Return the length of the virtual base list of the type DCLASS. */
1851 virtual_base_list_length (struct type
*dclass
)
1854 register struct vbase
*tmp_vbase
;
1856 current_vbase_list
= NULL
;
1857 virtual_base_list_aux (dclass
);
1859 for (i
= 0, tmp_vbase
= current_vbase_list
; tmp_vbase
!= NULL
; i
++, tmp_vbase
= tmp_vbase
->next
)
1864 /* Return the number of elements of the virtual base list of the type
1865 DCLASS, ignoring those appearing in the primary base (and its
1866 primary base, recursively). */
1869 virtual_base_list_length_skip_primaries (struct type
*dclass
)
1872 register struct vbase
*tmp_vbase
;
1873 struct type
*primary
;
1875 primary
= TYPE_RUNTIME_PTR (dclass
) ? TYPE_PRIMARY_BASE (dclass
) : NULL
;
1878 return virtual_base_list_length (dclass
);
1880 current_vbase_list
= NULL
;
1881 virtual_base_list_aux (dclass
);
1883 for (i
= 0, tmp_vbase
= current_vbase_list
; tmp_vbase
!= NULL
; tmp_vbase
= tmp_vbase
->next
)
1885 if (virtual_base_index (tmp_vbase
->vbasetype
, primary
) >= 0)
1893 /* Return the index (position) of type BASE, which is a virtual base
1894 class of DCLASS, in the latter's virtual base list. A return of -1
1895 indicates "not found" or a problem. */
1898 virtual_base_index (struct type
*base
, struct type
*dclass
)
1900 register struct type
*vbase
;
1903 if ((TYPE_CODE (dclass
) != TYPE_CODE_CLASS
) ||
1904 (TYPE_CODE (base
) != TYPE_CODE_CLASS
))
1908 vbase
= virtual_base_list (dclass
)[0];
1913 vbase
= virtual_base_list (dclass
)[++i
];
1916 return vbase
? i
: -1;
1921 /* Return the index (position) of type BASE, which is a virtual base
1922 class of DCLASS, in the latter's virtual base list. Skip over all
1923 bases that may appear in the virtual base list of the primary base
1924 class of DCLASS (recursively). A return of -1 indicates "not
1925 found" or a problem. */
1928 virtual_base_index_skip_primaries (struct type
*base
, struct type
*dclass
)
1930 register struct type
*vbase
;
1932 struct type
*primary
;
1934 if ((TYPE_CODE (dclass
) != TYPE_CODE_CLASS
) ||
1935 (TYPE_CODE (base
) != TYPE_CODE_CLASS
))
1938 primary
= TYPE_RUNTIME_PTR (dclass
) ? TYPE_PRIMARY_BASE (dclass
) : NULL
;
1942 vbase
= virtual_base_list (dclass
)[0];
1945 if (!primary
|| (virtual_base_index_skip_primaries (vbase
, primary
) < 0))
1949 vbase
= virtual_base_list (dclass
)[++i
];
1952 return vbase
? j
: -1;
1955 /* Return position of a derived class DCLASS in the list of
1956 * primary bases starting with the remotest ancestor.
1957 * Position returned is 0-based. */
1960 class_index_in_primary_list (struct type
*dclass
)
1962 struct type
*pbc
; /* primary base class */
1964 /* Simply recurse on primary base */
1965 pbc
= TYPE_PRIMARY_BASE (dclass
);
1967 return 1 + class_index_in_primary_list (pbc
);
1972 /* Return a count of the number of virtual functions a type has.
1973 * This includes all the virtual functions it inherits from its
1977 /* pai: FIXME This doesn't do the right thing: count redefined virtual
1978 * functions only once (latest redefinition)
1982 count_virtual_fns (struct type
*dclass
)
1984 int fn
, oi
; /* function and overloaded instance indices */
1985 int vfuncs
; /* count to return */
1987 /* recurse on bases that can share virtual table */
1988 struct type
*pbc
= primary_base_class (dclass
);
1990 vfuncs
= count_virtual_fns (pbc
);
1994 for (fn
= 0; fn
< TYPE_NFN_FIELDS (dclass
); fn
++)
1995 for (oi
= 0; oi
< TYPE_FN_FIELDLIST_LENGTH (dclass
, fn
); oi
++)
1996 if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass
, fn
), oi
))
2004 /* Functions for overload resolution begin here */
2006 /* Compare two badness vectors A and B and return the result.
2007 * 0 => A and B are identical
2008 * 1 => A and B are incomparable
2009 * 2 => A is better than B
2010 * 3 => A is worse than B */
2013 compare_badness (struct badness_vector
*a
, struct badness_vector
*b
)
2017 short found_pos
= 0; /* any positives in c? */
2018 short found_neg
= 0; /* any negatives in c? */
2020 /* differing lengths => incomparable */
2021 if (a
->length
!= b
->length
)
2024 /* Subtract b from a */
2025 for (i
= 0; i
< a
->length
; i
++)
2027 tmp
= a
->rank
[i
] - b
->rank
[i
];
2037 return 1; /* incomparable */
2039 return 3; /* A > B */
2045 return 2; /* A < B */
2047 return 0; /* A == B */
2051 /* Rank a function by comparing its parameter types (PARMS, length NPARMS),
2052 * to the types of an argument list (ARGS, length NARGS).
2053 * Return a pointer to a badness vector. This has NARGS + 1 entries. */
2055 struct badness_vector
*
2056 rank_function (struct type
**parms
, int nparms
, struct type
**args
, int nargs
)
2059 struct badness_vector
*bv
;
2060 int min_len
= nparms
< nargs
? nparms
: nargs
;
2062 bv
= xmalloc (sizeof (struct badness_vector
));
2063 bv
->length
= nargs
+ 1; /* add 1 for the length-match rank */
2064 bv
->rank
= xmalloc ((nargs
+ 1) * sizeof (int));
2066 /* First compare the lengths of the supplied lists.
2067 * If there is a mismatch, set it to a high value. */
2069 /* pai/1997-06-03 FIXME: when we have debug info about default
2070 * arguments and ellipsis parameter lists, we should consider those
2071 * and rank the length-match more finely. */
2073 LENGTH_MATCH (bv
) = (nargs
!= nparms
) ? LENGTH_MISMATCH_BADNESS
: 0;
2075 /* Now rank all the parameters of the candidate function */
2076 for (i
= 1; i
<= min_len
; i
++)
2077 bv
->rank
[i
] = rank_one_type (parms
[i
-1], args
[i
-1]);
2079 /* If more arguments than parameters, add dummy entries */
2080 for (i
= min_len
+ 1; i
<= nargs
; i
++)
2081 bv
->rank
[i
] = TOO_FEW_PARAMS_BADNESS
;
2086 /* Compare one type (PARM) for compatibility with another (ARG).
2087 * PARM is intended to be the parameter type of a function; and
2088 * ARG is the supplied argument's type. This function tests if
2089 * the latter can be converted to the former.
2091 * Return 0 if they are identical types;
2092 * Otherwise, return an integer which corresponds to how compatible
2093 * PARM is to ARG. The higher the return value, the worse the match.
2094 * Generally the "bad" conversions are all uniformly assigned a 100 */
2097 rank_one_type (struct type
*parm
, struct type
*arg
)
2099 /* Identical type pointers */
2100 /* However, this still doesn't catch all cases of same type for arg
2101 * and param. The reason is that builtin types are different from
2102 * the same ones constructed from the object. */
2106 /* Resolve typedefs */
2107 if (TYPE_CODE (parm
) == TYPE_CODE_TYPEDEF
)
2108 parm
= check_typedef (parm
);
2109 if (TYPE_CODE (arg
) == TYPE_CODE_TYPEDEF
)
2110 arg
= check_typedef (arg
);
2113 Well, damnit, if the names are exactly the same,
2114 i'll say they are exactly the same. This happens when we generate
2115 method stubs. The types won't point to the same address, but they
2116 really are the same.
2119 if (TYPE_NAME (parm
) && TYPE_NAME (arg
) &&
2120 !strcmp (TYPE_NAME (parm
), TYPE_NAME (arg
)))
2123 /* Check if identical after resolving typedefs */
2127 /* See through references, since we can almost make non-references
2129 if (TYPE_CODE (arg
) == TYPE_CODE_REF
)
2130 return (rank_one_type (parm
, TYPE_TARGET_TYPE (arg
))
2131 + REFERENCE_CONVERSION_BADNESS
);
2132 if (TYPE_CODE (parm
) == TYPE_CODE_REF
)
2133 return (rank_one_type (TYPE_TARGET_TYPE (parm
), arg
)
2134 + REFERENCE_CONVERSION_BADNESS
);
2136 /* Debugging only. */
2137 fprintf_filtered (gdb_stderr
,"------ Arg is %s [%d], parm is %s [%d]\n",
2138 TYPE_NAME (arg
), TYPE_CODE (arg
), TYPE_NAME (parm
), TYPE_CODE (parm
));
2140 /* x -> y means arg of type x being supplied for parameter of type y */
2142 switch (TYPE_CODE (parm
))
2145 switch (TYPE_CODE (arg
))
2148 if (TYPE_CODE (TYPE_TARGET_TYPE (parm
)) == TYPE_CODE_VOID
)
2149 return VOID_PTR_CONVERSION_BADNESS
;
2151 return rank_one_type (TYPE_TARGET_TYPE (parm
), TYPE_TARGET_TYPE (arg
));
2152 case TYPE_CODE_ARRAY
:
2153 return rank_one_type (TYPE_TARGET_TYPE (parm
), TYPE_TARGET_TYPE (arg
));
2154 case TYPE_CODE_FUNC
:
2155 return rank_one_type (TYPE_TARGET_TYPE (parm
), arg
);
2157 case TYPE_CODE_ENUM
:
2158 case TYPE_CODE_CHAR
:
2159 case TYPE_CODE_RANGE
:
2160 case TYPE_CODE_BOOL
:
2161 return POINTER_CONVERSION_BADNESS
;
2163 return INCOMPATIBLE_TYPE_BADNESS
;
2165 case TYPE_CODE_ARRAY
:
2166 switch (TYPE_CODE (arg
))
2169 case TYPE_CODE_ARRAY
:
2170 return rank_one_type (TYPE_TARGET_TYPE (parm
), TYPE_TARGET_TYPE (arg
));
2172 return INCOMPATIBLE_TYPE_BADNESS
;
2174 case TYPE_CODE_FUNC
:
2175 switch (TYPE_CODE (arg
))
2177 case TYPE_CODE_PTR
: /* funcptr -> func */
2178 return rank_one_type (parm
, TYPE_TARGET_TYPE (arg
));
2180 return INCOMPATIBLE_TYPE_BADNESS
;
2183 switch (TYPE_CODE (arg
))
2186 if (TYPE_LENGTH (arg
) == TYPE_LENGTH (parm
))
2188 /* Deal with signed, unsigned, and plain chars and
2189 signed and unsigned ints */
2190 if (TYPE_NOSIGN (parm
))
2192 /* This case only for character types */
2193 if (TYPE_NOSIGN (arg
)) /* plain char -> plain char */
2196 return INTEGER_COERCION_BADNESS
; /* signed/unsigned char -> plain char */
2198 else if (TYPE_UNSIGNED (parm
))
2200 if (TYPE_UNSIGNED (arg
))
2202 if (!strcmp_iw (TYPE_NAME (parm
), TYPE_NAME (arg
)))
2203 return 0; /* unsigned int -> unsigned int, or unsigned long -> unsigned long */
2204 else if (!strcmp_iw (TYPE_NAME (arg
), "int") && !strcmp_iw (TYPE_NAME (parm
), "long"))
2205 return INTEGER_PROMOTION_BADNESS
; /* unsigned int -> unsigned long */
2207 return INTEGER_COERCION_BADNESS
; /* unsigned long -> unsigned int */
2211 if (!strcmp_iw (TYPE_NAME (arg
), "long") && !strcmp_iw (TYPE_NAME (parm
), "int"))
2212 return INTEGER_COERCION_BADNESS
; /* signed long -> unsigned int */
2214 return INTEGER_CONVERSION_BADNESS
; /* signed int/long -> unsigned int/long */
2217 else if (!TYPE_NOSIGN (arg
) && !TYPE_UNSIGNED (arg
))
2219 if (!strcmp_iw (TYPE_NAME (parm
), TYPE_NAME (arg
)))
2221 else if (!strcmp_iw (TYPE_NAME (arg
), "int") && !strcmp_iw (TYPE_NAME (parm
), "long"))
2222 return INTEGER_PROMOTION_BADNESS
;
2224 return INTEGER_COERCION_BADNESS
;
2227 return INTEGER_COERCION_BADNESS
;
2229 else if (TYPE_LENGTH (arg
) < TYPE_LENGTH (parm
))
2230 return INTEGER_PROMOTION_BADNESS
;
2232 return INTEGER_COERCION_BADNESS
;
2233 case TYPE_CODE_ENUM
:
2234 case TYPE_CODE_CHAR
:
2235 case TYPE_CODE_RANGE
:
2236 case TYPE_CODE_BOOL
:
2237 return INTEGER_PROMOTION_BADNESS
;
2239 return INT_FLOAT_CONVERSION_BADNESS
;
2241 return NS_POINTER_CONVERSION_BADNESS
;
2243 return INCOMPATIBLE_TYPE_BADNESS
;
2246 case TYPE_CODE_ENUM
:
2247 switch (TYPE_CODE (arg
))
2250 case TYPE_CODE_CHAR
:
2251 case TYPE_CODE_RANGE
:
2252 case TYPE_CODE_BOOL
:
2253 case TYPE_CODE_ENUM
:
2254 return INTEGER_COERCION_BADNESS
;
2256 return INT_FLOAT_CONVERSION_BADNESS
;
2258 return INCOMPATIBLE_TYPE_BADNESS
;
2261 case TYPE_CODE_CHAR
:
2262 switch (TYPE_CODE (arg
))
2264 case TYPE_CODE_RANGE
:
2265 case TYPE_CODE_BOOL
:
2266 case TYPE_CODE_ENUM
:
2267 return INTEGER_COERCION_BADNESS
;
2269 return INT_FLOAT_CONVERSION_BADNESS
;
2271 if (TYPE_LENGTH (arg
) > TYPE_LENGTH (parm
))
2272 return INTEGER_COERCION_BADNESS
;
2273 else if (TYPE_LENGTH (arg
) < TYPE_LENGTH (parm
))
2274 return INTEGER_PROMOTION_BADNESS
;
2275 /* >>> !! else fall through !! <<< */
2276 case TYPE_CODE_CHAR
:
2277 /* Deal with signed, unsigned, and plain chars for C++
2278 and with int cases falling through from previous case */
2279 if (TYPE_NOSIGN (parm
))
2281 if (TYPE_NOSIGN (arg
))
2284 return INTEGER_COERCION_BADNESS
;
2286 else if (TYPE_UNSIGNED (parm
))
2288 if (TYPE_UNSIGNED (arg
))
2291 return INTEGER_PROMOTION_BADNESS
;
2293 else if (!TYPE_NOSIGN (arg
) && !TYPE_UNSIGNED (arg
))
2296 return INTEGER_COERCION_BADNESS
;
2298 return INCOMPATIBLE_TYPE_BADNESS
;
2301 case TYPE_CODE_RANGE
:
2302 switch (TYPE_CODE (arg
))
2305 case TYPE_CODE_CHAR
:
2306 case TYPE_CODE_RANGE
:
2307 case TYPE_CODE_BOOL
:
2308 case TYPE_CODE_ENUM
:
2309 return INTEGER_COERCION_BADNESS
;
2311 return INT_FLOAT_CONVERSION_BADNESS
;
2313 return INCOMPATIBLE_TYPE_BADNESS
;
2316 case TYPE_CODE_BOOL
:
2317 switch (TYPE_CODE (arg
))
2320 case TYPE_CODE_CHAR
:
2321 case TYPE_CODE_RANGE
:
2322 case TYPE_CODE_ENUM
:
2325 return BOOLEAN_CONVERSION_BADNESS
;
2326 case TYPE_CODE_BOOL
:
2329 return INCOMPATIBLE_TYPE_BADNESS
;
2333 switch (TYPE_CODE (arg
))
2336 if (TYPE_LENGTH (arg
) < TYPE_LENGTH (parm
))
2337 return FLOAT_PROMOTION_BADNESS
;
2338 else if (TYPE_LENGTH (arg
) == TYPE_LENGTH (parm
))
2341 return FLOAT_CONVERSION_BADNESS
;
2343 case TYPE_CODE_BOOL
:
2344 case TYPE_CODE_ENUM
:
2345 case TYPE_CODE_RANGE
:
2346 case TYPE_CODE_CHAR
:
2347 return INT_FLOAT_CONVERSION_BADNESS
;
2349 return INCOMPATIBLE_TYPE_BADNESS
;
2352 case TYPE_CODE_COMPLEX
:
2353 switch (TYPE_CODE (arg
))
2354 { /* Strictly not needed for C++, but... */
2356 return FLOAT_PROMOTION_BADNESS
;
2357 case TYPE_CODE_COMPLEX
:
2360 return INCOMPATIBLE_TYPE_BADNESS
;
2363 case TYPE_CODE_STRUCT
:
2364 /* currently same as TYPE_CODE_CLASS */
2365 switch (TYPE_CODE (arg
))
2367 case TYPE_CODE_STRUCT
:
2368 /* Check for derivation */
2369 if (is_ancestor (parm
, arg
))
2370 return BASE_CONVERSION_BADNESS
;
2371 /* else fall through */
2373 return INCOMPATIBLE_TYPE_BADNESS
;
2376 case TYPE_CODE_UNION
:
2377 switch (TYPE_CODE (arg
))
2379 case TYPE_CODE_UNION
:
2381 return INCOMPATIBLE_TYPE_BADNESS
;
2384 case TYPE_CODE_MEMBER
:
2385 switch (TYPE_CODE (arg
))
2388 return INCOMPATIBLE_TYPE_BADNESS
;
2391 case TYPE_CODE_METHOD
:
2392 switch (TYPE_CODE (arg
))
2396 return INCOMPATIBLE_TYPE_BADNESS
;
2400 switch (TYPE_CODE (arg
))
2404 return INCOMPATIBLE_TYPE_BADNESS
;
2409 switch (TYPE_CODE (arg
))
2413 return rank_one_type (TYPE_FIELD_TYPE (parm
, 0), TYPE_FIELD_TYPE (arg
, 0));
2415 return INCOMPATIBLE_TYPE_BADNESS
;
2418 case TYPE_CODE_VOID
:
2420 return INCOMPATIBLE_TYPE_BADNESS
;
2421 } /* switch (TYPE_CODE (arg)) */
2425 /* End of functions for overload resolution */
2428 print_bit_vector (B_TYPE
*bits
, int nbits
)
2432 for (bitno
= 0; bitno
< nbits
; bitno
++)
2434 if ((bitno
% 8) == 0)
2436 puts_filtered (" ");
2438 if (B_TST (bits
, bitno
))
2440 printf_filtered ("1");
2444 printf_filtered ("0");
2449 /* The args list is a strange beast. It is either terminated by a NULL
2450 pointer for varargs functions, or by a pointer to a TYPE_CODE_VOID
2451 type for normal fixed argcount functions. (FIXME someday)
2452 Also note the first arg should be the "this" pointer, we may not want to
2453 include it since we may get into a infinitely recursive situation. */
2456 print_arg_types (struct type
**args
, int spaces
)
2460 while (*args
!= NULL
)
2462 recursive_dump_type (*args
, spaces
+ 2);
2463 if ((*args
++)->code
== TYPE_CODE_VOID
)
2472 dump_fn_fieldlists (struct type
*type
, int spaces
)
2478 printfi_filtered (spaces
, "fn_fieldlists ");
2479 gdb_print_host_address (TYPE_FN_FIELDLISTS (type
), gdb_stdout
);
2480 printf_filtered ("\n");
2481 for (method_idx
= 0; method_idx
< TYPE_NFN_FIELDS (type
); method_idx
++)
2483 f
= TYPE_FN_FIELDLIST1 (type
, method_idx
);
2484 printfi_filtered (spaces
+ 2, "[%d] name '%s' (",
2486 TYPE_FN_FIELDLIST_NAME (type
, method_idx
));
2487 gdb_print_host_address (TYPE_FN_FIELDLIST_NAME (type
, method_idx
),
2489 printf_filtered (") length %d\n",
2490 TYPE_FN_FIELDLIST_LENGTH (type
, method_idx
));
2491 for (overload_idx
= 0;
2492 overload_idx
< TYPE_FN_FIELDLIST_LENGTH (type
, method_idx
);
2495 printfi_filtered (spaces
+ 4, "[%d] physname '%s' (",
2497 TYPE_FN_FIELD_PHYSNAME (f
, overload_idx
));
2498 gdb_print_host_address (TYPE_FN_FIELD_PHYSNAME (f
, overload_idx
),
2500 printf_filtered (")\n");
2501 printfi_filtered (spaces
+ 8, "type ");
2502 gdb_print_host_address (TYPE_FN_FIELD_TYPE (f
, overload_idx
), gdb_stdout
);
2503 printf_filtered ("\n");
2505 recursive_dump_type (TYPE_FN_FIELD_TYPE (f
, overload_idx
),
2508 printfi_filtered (spaces
+ 8, "args ");
2509 gdb_print_host_address (TYPE_FN_FIELD_ARGS (f
, overload_idx
), gdb_stdout
);
2510 printf_filtered ("\n");
2512 print_arg_types (TYPE_FN_FIELD_ARGS (f
, overload_idx
), spaces
);
2513 printfi_filtered (spaces
+ 8, "fcontext ");
2514 gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f
, overload_idx
),
2516 printf_filtered ("\n");
2518 printfi_filtered (spaces
+ 8, "is_const %d\n",
2519 TYPE_FN_FIELD_CONST (f
, overload_idx
));
2520 printfi_filtered (spaces
+ 8, "is_volatile %d\n",
2521 TYPE_FN_FIELD_VOLATILE (f
, overload_idx
));
2522 printfi_filtered (spaces
+ 8, "is_private %d\n",
2523 TYPE_FN_FIELD_PRIVATE (f
, overload_idx
));
2524 printfi_filtered (spaces
+ 8, "is_protected %d\n",
2525 TYPE_FN_FIELD_PROTECTED (f
, overload_idx
));
2526 printfi_filtered (spaces
+ 8, "is_stub %d\n",
2527 TYPE_FN_FIELD_STUB (f
, overload_idx
));
2528 printfi_filtered (spaces
+ 8, "voffset %u\n",
2529 TYPE_FN_FIELD_VOFFSET (f
, overload_idx
));
2535 print_cplus_stuff (struct type
*type
, int spaces
)
2537 printfi_filtered (spaces
, "n_baseclasses %d\n",
2538 TYPE_N_BASECLASSES (type
));
2539 printfi_filtered (spaces
, "nfn_fields %d\n",
2540 TYPE_NFN_FIELDS (type
));
2541 printfi_filtered (spaces
, "nfn_fields_total %d\n",
2542 TYPE_NFN_FIELDS_TOTAL (type
));
2543 if (TYPE_N_BASECLASSES (type
) > 0)
2545 printfi_filtered (spaces
, "virtual_field_bits (%d bits at *",
2546 TYPE_N_BASECLASSES (type
));
2547 gdb_print_host_address (TYPE_FIELD_VIRTUAL_BITS (type
), gdb_stdout
);
2548 printf_filtered (")");
2550 print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type
),
2551 TYPE_N_BASECLASSES (type
));
2552 puts_filtered ("\n");
2554 if (TYPE_NFIELDS (type
) > 0)
2556 if (TYPE_FIELD_PRIVATE_BITS (type
) != NULL
)
2558 printfi_filtered (spaces
, "private_field_bits (%d bits at *",
2559 TYPE_NFIELDS (type
));
2560 gdb_print_host_address (TYPE_FIELD_PRIVATE_BITS (type
), gdb_stdout
);
2561 printf_filtered (")");
2562 print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type
),
2563 TYPE_NFIELDS (type
));
2564 puts_filtered ("\n");
2566 if (TYPE_FIELD_PROTECTED_BITS (type
) != NULL
)
2568 printfi_filtered (spaces
, "protected_field_bits (%d bits at *",
2569 TYPE_NFIELDS (type
));
2570 gdb_print_host_address (TYPE_FIELD_PROTECTED_BITS (type
), gdb_stdout
);
2571 printf_filtered (")");
2572 print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type
),
2573 TYPE_NFIELDS (type
));
2574 puts_filtered ("\n");
2577 if (TYPE_NFN_FIELDS (type
) > 0)
2579 dump_fn_fieldlists (type
, spaces
);
2583 static struct obstack dont_print_type_obstack
;
2586 recursive_dump_type (struct type
*type
, int spaces
)
2591 obstack_begin (&dont_print_type_obstack
, 0);
2593 if (TYPE_NFIELDS (type
) > 0
2594 || (TYPE_CPLUS_SPECIFIC (type
) && TYPE_NFN_FIELDS (type
) > 0))
2596 struct type
**first_dont_print
2597 = (struct type
**) obstack_base (&dont_print_type_obstack
);
2599 int i
= (struct type
**) obstack_next_free (&dont_print_type_obstack
)
2604 if (type
== first_dont_print
[i
])
2606 printfi_filtered (spaces
, "type node ");
2607 gdb_print_host_address (type
, gdb_stdout
);
2608 printf_filtered (" <same as already seen type>\n");
2613 obstack_ptr_grow (&dont_print_type_obstack
, type
);
2616 printfi_filtered (spaces
, "type node ");
2617 gdb_print_host_address (type
, gdb_stdout
);
2618 printf_filtered ("\n");
2619 printfi_filtered (spaces
, "name '%s' (",
2620 TYPE_NAME (type
) ? TYPE_NAME (type
) : "<NULL>");
2621 gdb_print_host_address (TYPE_NAME (type
), gdb_stdout
);
2622 printf_filtered (")\n");
2623 if (TYPE_TAG_NAME (type
) != NULL
)
2625 printfi_filtered (spaces
, "tagname '%s' (",
2626 TYPE_TAG_NAME (type
));
2627 gdb_print_host_address (TYPE_TAG_NAME (type
), gdb_stdout
);
2628 printf_filtered (")\n");
2630 printfi_filtered (spaces
, "code 0x%x ", TYPE_CODE (type
));
2631 switch (TYPE_CODE (type
))
2633 case TYPE_CODE_UNDEF
:
2634 printf_filtered ("(TYPE_CODE_UNDEF)");
2637 printf_filtered ("(TYPE_CODE_PTR)");
2639 case TYPE_CODE_ARRAY
:
2640 printf_filtered ("(TYPE_CODE_ARRAY)");
2642 case TYPE_CODE_STRUCT
:
2643 printf_filtered ("(TYPE_CODE_STRUCT)");
2645 case TYPE_CODE_UNION
:
2646 printf_filtered ("(TYPE_CODE_UNION)");
2648 case TYPE_CODE_ENUM
:
2649 printf_filtered ("(TYPE_CODE_ENUM)");
2651 case TYPE_CODE_FUNC
:
2652 printf_filtered ("(TYPE_CODE_FUNC)");
2655 printf_filtered ("(TYPE_CODE_INT)");
2658 printf_filtered ("(TYPE_CODE_FLT)");
2660 case TYPE_CODE_VOID
:
2661 printf_filtered ("(TYPE_CODE_VOID)");
2664 printf_filtered ("(TYPE_CODE_SET)");
2666 case TYPE_CODE_RANGE
:
2667 printf_filtered ("(TYPE_CODE_RANGE)");
2669 case TYPE_CODE_STRING
:
2670 printf_filtered ("(TYPE_CODE_STRING)");
2672 case TYPE_CODE_ERROR
:
2673 printf_filtered ("(TYPE_CODE_ERROR)");
2675 case TYPE_CODE_MEMBER
:
2676 printf_filtered ("(TYPE_CODE_MEMBER)");
2678 case TYPE_CODE_METHOD
:
2679 printf_filtered ("(TYPE_CODE_METHOD)");
2682 printf_filtered ("(TYPE_CODE_REF)");
2684 case TYPE_CODE_CHAR
:
2685 printf_filtered ("(TYPE_CODE_CHAR)");
2687 case TYPE_CODE_BOOL
:
2688 printf_filtered ("(TYPE_CODE_BOOL)");
2690 case TYPE_CODE_TYPEDEF
:
2691 printf_filtered ("(TYPE_CODE_TYPEDEF)");
2694 printf_filtered ("(UNKNOWN TYPE CODE)");
2697 puts_filtered ("\n");
2698 printfi_filtered (spaces
, "length %d\n", TYPE_LENGTH (type
));
2699 printfi_filtered (spaces
, "objfile ");
2700 gdb_print_host_address (TYPE_OBJFILE (type
), gdb_stdout
);
2701 printf_filtered ("\n");
2702 printfi_filtered (spaces
, "target_type ");
2703 gdb_print_host_address (TYPE_TARGET_TYPE (type
), gdb_stdout
);
2704 printf_filtered ("\n");
2705 if (TYPE_TARGET_TYPE (type
) != NULL
)
2707 recursive_dump_type (TYPE_TARGET_TYPE (type
), spaces
+ 2);
2709 printfi_filtered (spaces
, "pointer_type ");
2710 gdb_print_host_address (TYPE_POINTER_TYPE (type
), gdb_stdout
);
2711 printf_filtered ("\n");
2712 printfi_filtered (spaces
, "reference_type ");
2713 gdb_print_host_address (TYPE_REFERENCE_TYPE (type
), gdb_stdout
);
2714 printf_filtered ("\n");
2715 printfi_filtered (spaces
, "flags 0x%x", TYPE_FLAGS (type
));
2716 if (TYPE_FLAGS (type
) & TYPE_FLAG_UNSIGNED
)
2718 puts_filtered (" TYPE_FLAG_UNSIGNED");
2720 if (TYPE_FLAGS (type
) & TYPE_FLAG_STUB
)
2722 puts_filtered (" TYPE_FLAG_STUB");
2724 puts_filtered ("\n");
2725 printfi_filtered (spaces
, "nfields %d ", TYPE_NFIELDS (type
));
2726 gdb_print_host_address (TYPE_FIELDS (type
), gdb_stdout
);
2727 puts_filtered ("\n");
2728 for (idx
= 0; idx
< TYPE_NFIELDS (type
); idx
++)
2730 printfi_filtered (spaces
+ 2,
2731 "[%d] bitpos %d bitsize %d type ",
2732 idx
, TYPE_FIELD_BITPOS (type
, idx
),
2733 TYPE_FIELD_BITSIZE (type
, idx
));
2734 gdb_print_host_address (TYPE_FIELD_TYPE (type
, idx
), gdb_stdout
);
2735 printf_filtered (" name '%s' (",
2736 TYPE_FIELD_NAME (type
, idx
) != NULL
2737 ? TYPE_FIELD_NAME (type
, idx
)
2739 gdb_print_host_address (TYPE_FIELD_NAME (type
, idx
), gdb_stdout
);
2740 printf_filtered (")\n");
2741 if (TYPE_FIELD_TYPE (type
, idx
) != NULL
)
2743 recursive_dump_type (TYPE_FIELD_TYPE (type
, idx
), spaces
+ 4);
2746 printfi_filtered (spaces
, "vptr_basetype ");
2747 gdb_print_host_address (TYPE_VPTR_BASETYPE (type
), gdb_stdout
);
2748 puts_filtered ("\n");
2749 if (TYPE_VPTR_BASETYPE (type
) != NULL
)
2751 recursive_dump_type (TYPE_VPTR_BASETYPE (type
), spaces
+ 2);
2753 printfi_filtered (spaces
, "vptr_fieldno %d\n", TYPE_VPTR_FIELDNO (type
));
2754 switch (TYPE_CODE (type
))
2756 case TYPE_CODE_METHOD
:
2757 case TYPE_CODE_FUNC
:
2758 printfi_filtered (spaces
, "arg_types ");
2759 gdb_print_host_address (TYPE_ARG_TYPES (type
), gdb_stdout
);
2760 puts_filtered ("\n");
2761 print_arg_types (TYPE_ARG_TYPES (type
), spaces
);
2764 case TYPE_CODE_STRUCT
:
2765 printfi_filtered (spaces
, "cplus_stuff ");
2766 gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type
), gdb_stdout
);
2767 puts_filtered ("\n");
2768 print_cplus_stuff (type
, spaces
);
2772 /* We have to pick one of the union types to be able print and test
2773 the value. Pick cplus_struct_type, even though we know it isn't
2774 any particular one. */
2775 printfi_filtered (spaces
, "type_specific ");
2776 gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type
), gdb_stdout
);
2777 if (TYPE_CPLUS_SPECIFIC (type
) != NULL
)
2779 printf_filtered (" (unknown data form)");
2781 printf_filtered ("\n");
2786 obstack_free (&dont_print_type_obstack
, NULL
);
2789 static void build_gdbtypes (void);
2791 build_gdbtypes (void)
2794 init_type (TYPE_CODE_VOID
, 1,
2796 "void", (struct objfile
*) NULL
);
2798 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
2800 "char", (struct objfile
*) NULL
);
2801 TYPE_FLAGS (builtin_type_char
) |= TYPE_FLAG_NOSIGN
;
2802 builtin_type_true_char
=
2803 init_type (TYPE_CODE_CHAR
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
2805 "true character", (struct objfile
*) NULL
);
2806 builtin_type_signed_char
=
2807 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
2809 "signed char", (struct objfile
*) NULL
);
2810 builtin_type_unsigned_char
=
2811 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
2813 "unsigned char", (struct objfile
*) NULL
);
2814 builtin_type_short
=
2815 init_type (TYPE_CODE_INT
, TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
2817 "short", (struct objfile
*) NULL
);
2818 builtin_type_unsigned_short
=
2819 init_type (TYPE_CODE_INT
, TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
2821 "unsigned short", (struct objfile
*) NULL
);
2823 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
2825 "int", (struct objfile
*) NULL
);
2826 builtin_type_unsigned_int
=
2827 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
2829 "unsigned int", (struct objfile
*) NULL
);
2831 init_type (TYPE_CODE_INT
, TARGET_LONG_BIT
/ TARGET_CHAR_BIT
,
2833 "long", (struct objfile
*) NULL
);
2834 builtin_type_unsigned_long
=
2835 init_type (TYPE_CODE_INT
, TARGET_LONG_BIT
/ TARGET_CHAR_BIT
,
2837 "unsigned long", (struct objfile
*) NULL
);
2838 builtin_type_long_long
=
2839 init_type (TYPE_CODE_INT
, TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
,
2841 "long long", (struct objfile
*) NULL
);
2842 builtin_type_unsigned_long_long
=
2843 init_type (TYPE_CODE_INT
, TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
,
2845 "unsigned long long", (struct objfile
*) NULL
);
2846 builtin_type_float
=
2847 init_type (TYPE_CODE_FLT
, TARGET_FLOAT_BIT
/ TARGET_CHAR_BIT
,
2849 "float", (struct objfile
*) NULL
);
2850 builtin_type_double
=
2851 init_type (TYPE_CODE_FLT
, TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
2853 "double", (struct objfile
*) NULL
);
2854 builtin_type_long_double
=
2855 init_type (TYPE_CODE_FLT
, TARGET_LONG_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
2857 "long double", (struct objfile
*) NULL
);
2858 builtin_type_complex
=
2859 init_type (TYPE_CODE_COMPLEX
, 2 * TARGET_FLOAT_BIT
/ TARGET_CHAR_BIT
,
2861 "complex", (struct objfile
*) NULL
);
2862 TYPE_TARGET_TYPE (builtin_type_complex
) = builtin_type_float
;
2863 builtin_type_double_complex
=
2864 init_type (TYPE_CODE_COMPLEX
, 2 * TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
2866 "double complex", (struct objfile
*) NULL
);
2867 TYPE_TARGET_TYPE (builtin_type_double_complex
) = builtin_type_double
;
2868 builtin_type_string
=
2869 init_type (TYPE_CODE_STRING
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
2871 "string", (struct objfile
*) NULL
);
2873 init_type (TYPE_CODE_INT
, 8 / 8,
2875 "int8_t", (struct objfile
*) NULL
);
2876 builtin_type_uint8
=
2877 init_type (TYPE_CODE_INT
, 8 / 8,
2879 "uint8_t", (struct objfile
*) NULL
);
2880 builtin_type_int16
=
2881 init_type (TYPE_CODE_INT
, 16 / 8,
2883 "int16_t", (struct objfile
*) NULL
);
2884 builtin_type_uint16
=
2885 init_type (TYPE_CODE_INT
, 16 / 8,
2887 "uint16_t", (struct objfile
*) NULL
);
2888 builtin_type_int32
=
2889 init_type (TYPE_CODE_INT
, 32 / 8,
2891 "int32_t", (struct objfile
*) NULL
);
2892 builtin_type_uint32
=
2893 init_type (TYPE_CODE_INT
, 32 / 8,
2895 "uint32_t", (struct objfile
*) NULL
);
2896 builtin_type_int64
=
2897 init_type (TYPE_CODE_INT
, 64 / 8,
2899 "int64_t", (struct objfile
*) NULL
);
2900 builtin_type_uint64
=
2901 init_type (TYPE_CODE_INT
, 64 / 8,
2903 "uint64_t", (struct objfile
*) NULL
);
2905 init_type (TYPE_CODE_BOOL
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
2907 "bool", (struct objfile
*) NULL
);
2909 /* Add user knob for controlling resolution of opaque types */
2911 (add_set_cmd ("opaque-type-resolution", class_support
, var_boolean
, (char *) &opaque_type_resolution
,
2912 "Set resolution of opaque struct/class/union types (if set before loading symbols).",
2915 opaque_type_resolution
= 1;
2918 /* Build SIMD types. */
2920 = init_simd_type ("__builtin_v4sf", builtin_type_float
, "f", 4);
2922 = init_simd_type ("__builtin_v4si", builtin_type_int32
, "f", 4);
2924 = init_simd_type ("__builtin_v8qi", builtin_type_int8
, "f", 8);
2926 = init_simd_type ("__builtin_v4hi", builtin_type_int16
, "f", 4);
2928 = init_simd_type ("__builtin_v2si", builtin_type_int32
, "f", 2);
2930 /* Pointer/Address types. */
2931 /* NOTE: At present there is no way of differentiating between at
2932 target address and the target C language pointer type type even
2933 though the two can be different (cf d10v) */
2934 builtin_type_ptr
= make_pointer_type (builtin_type_void
, NULL
);
2935 builtin_type_CORE_ADDR
=
2936 init_type (TYPE_CODE_INT
, TARGET_ADDR_BIT
/ 8,
2938 "__CORE_ADDR", (struct objfile
*) NULL
);
2939 builtin_type_bfd_vma
=
2940 init_type (TYPE_CODE_INT
, TARGET_BFD_VMA_BIT
/ 8,
2942 "__bfd_vma", (struct objfile
*) NULL
);
2946 extern void _initialize_gdbtypes (void);
2948 _initialize_gdbtypes (void)
2950 struct cmd_list_element
*c
;
2953 /* FIXME - For the moment, handle types by swapping them in and out.
2954 Should be using the per-architecture data-pointer and a large
2956 register_gdbarch_swap (&builtin_type_void
, sizeof (struct type
*), NULL
);
2957 register_gdbarch_swap (&builtin_type_char
, sizeof (struct type
*), NULL
);
2958 register_gdbarch_swap (&builtin_type_short
, sizeof (struct type
*), NULL
);
2959 register_gdbarch_swap (&builtin_type_int
, sizeof (struct type
*), NULL
);
2960 register_gdbarch_swap (&builtin_type_long
, sizeof (struct type
*), NULL
);
2961 register_gdbarch_swap (&builtin_type_long_long
, sizeof (struct type
*), NULL
);
2962 register_gdbarch_swap (&builtin_type_signed_char
, sizeof (struct type
*), NULL
);
2963 register_gdbarch_swap (&builtin_type_unsigned_char
, sizeof (struct type
*), NULL
);
2964 register_gdbarch_swap (&builtin_type_unsigned_short
, sizeof (struct type
*), NULL
);
2965 register_gdbarch_swap (&builtin_type_unsigned_int
, sizeof (struct type
*), NULL
);
2966 register_gdbarch_swap (&builtin_type_unsigned_long
, sizeof (struct type
*), NULL
);
2967 register_gdbarch_swap (&builtin_type_unsigned_long_long
, sizeof (struct type
*), NULL
);
2968 register_gdbarch_swap (&builtin_type_float
, sizeof (struct type
*), NULL
);
2969 register_gdbarch_swap (&builtin_type_double
, sizeof (struct type
*), NULL
);
2970 register_gdbarch_swap (&builtin_type_long_double
, sizeof (struct type
*), NULL
);
2971 register_gdbarch_swap (&builtin_type_complex
, sizeof (struct type
*), NULL
);
2972 register_gdbarch_swap (&builtin_type_double_complex
, sizeof (struct type
*), NULL
);
2973 register_gdbarch_swap (&builtin_type_string
, sizeof (struct type
*), NULL
);
2974 register_gdbarch_swap (&builtin_type_int8
, sizeof (struct type
*), NULL
);
2975 register_gdbarch_swap (&builtin_type_uint8
, sizeof (struct type
*), NULL
);
2976 register_gdbarch_swap (&builtin_type_int16
, sizeof (struct type
*), NULL
);
2977 register_gdbarch_swap (&builtin_type_uint16
, sizeof (struct type
*), NULL
);
2978 register_gdbarch_swap (&builtin_type_int32
, sizeof (struct type
*), NULL
);
2979 register_gdbarch_swap (&builtin_type_uint32
, sizeof (struct type
*), NULL
);
2980 register_gdbarch_swap (&builtin_type_int64
, sizeof (struct type
*), NULL
);
2981 register_gdbarch_swap (&builtin_type_uint64
, sizeof (struct type
*), NULL
);
2982 register_gdbarch_swap (&builtin_type_v4sf
, sizeof (struct type
*), NULL
);
2983 register_gdbarch_swap (&builtin_type_v4si
, sizeof (struct type
*), NULL
);
2984 register_gdbarch_swap (&builtin_type_v8qi
, sizeof (struct type
*), NULL
);
2985 register_gdbarch_swap (&builtin_type_v4hi
, sizeof (struct type
*), NULL
);
2986 register_gdbarch_swap (&builtin_type_v2si
, sizeof (struct type
*), NULL
);
2987 REGISTER_GDBARCH_SWAP (builtin_type_ptr
);
2988 REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR
);
2989 REGISTER_GDBARCH_SWAP (builtin_type_bfd_vma
);
2990 register_gdbarch_swap (NULL
, 0, build_gdbtypes
);
2993 add_set_cmd ("overload", no_class
, var_zinteger
, (char *) &overload_debug
,
2994 "Set debugging of C++ overloading.\n\
2995 When enabled, ranking of the functions\n\
2996 is displayed.", &setdebuglist
),