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_void_data_ptr
;
77 struct type
*builtin_type_void_func_ptr
;
78 struct type
*builtin_type_CORE_ADDR
;
79 struct type
*builtin_type_bfd_vma
;
81 int opaque_type_resolution
= 1;
82 int overload_debug
= 0;
88 }; /* maximum extension is 128! FIXME */
90 static void add_name (struct extra
*, char *);
91 static void add_mangled_type (struct extra
*, struct type
*);
93 static void cfront_mangle_name (struct type
*, int, int);
95 static void print_bit_vector (B_TYPE
*, int);
96 static void print_arg_types (struct type
**, int);
97 static void dump_fn_fieldlists (struct type
*, int);
98 static void print_cplus_stuff (struct type
*, int);
99 static void virtual_base_list_aux (struct type
*dclass
);
102 /* Alloc a new type structure and fill it with some defaults. If
103 OBJFILE is non-NULL, then allocate the space for the type structure
104 in that objfile's type_obstack. */
107 alloc_type (struct objfile
*objfile
)
109 register struct type
*type
;
111 /* Alloc the structure and start off with all fields zeroed. */
115 type
= (struct type
*) xmalloc (sizeof (struct type
));
119 type
= (struct type
*) obstack_alloc (&objfile
->type_obstack
,
120 sizeof (struct type
));
121 OBJSTAT (objfile
, n_types
++);
123 memset ((char *) type
, 0, sizeof (struct type
));
125 /* Initialize the fields that might not be zero. */
127 TYPE_CODE (type
) = TYPE_CODE_UNDEF
;
128 TYPE_OBJFILE (type
) = objfile
;
129 TYPE_VPTR_FIELDNO (type
) = -1;
130 TYPE_CV_TYPE (type
) = type
; /* chain back to itself */
135 /* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points
136 to a pointer to memory where the pointer type should be stored.
137 If *TYPEPTR is zero, update it to point to the pointer type we return.
138 We allocate new memory if needed. */
141 make_pointer_type (struct type
*type
, struct type
**typeptr
)
143 register struct type
*ntype
; /* New type */
144 struct objfile
*objfile
;
146 ntype
= TYPE_POINTER_TYPE (type
);
151 return ntype
; /* Don't care about alloc, and have new type. */
152 else if (*typeptr
== 0)
154 *typeptr
= ntype
; /* Tracking alloc, and we have new type. */
159 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
161 ntype
= alloc_type (TYPE_OBJFILE (type
));
166 /* We have storage, but need to reset it. */
169 objfile
= TYPE_OBJFILE (ntype
);
170 memset ((char *) ntype
, 0, sizeof (struct type
));
171 TYPE_OBJFILE (ntype
) = objfile
;
174 TYPE_TARGET_TYPE (ntype
) = type
;
175 TYPE_POINTER_TYPE (type
) = ntype
;
177 /* FIXME! Assume the machine has only one representation for pointers! */
179 TYPE_LENGTH (ntype
) = TARGET_PTR_BIT
/ TARGET_CHAR_BIT
;
180 TYPE_CODE (ntype
) = TYPE_CODE_PTR
;
182 /* Mark pointers as unsigned. The target converts between pointers
183 and addresses (CORE_ADDRs) using POINTER_TO_ADDRESS() and
184 ADDRESS_TO_POINTER(). */
185 TYPE_FLAGS (ntype
) |= TYPE_FLAG_UNSIGNED
;
187 if (!TYPE_POINTER_TYPE (type
)) /* Remember it, if don't have one. */
188 TYPE_POINTER_TYPE (type
) = ntype
;
193 /* Given a type TYPE, return a type of pointers to that type.
194 May need to construct such a type if this is the first use. */
197 lookup_pointer_type (struct type
*type
)
199 return make_pointer_type (type
, (struct type
**) 0);
202 /* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, points
203 to a pointer to memory where the reference type should be stored.
204 If *TYPEPTR is zero, update it to point to the reference type we return.
205 We allocate new memory if needed. */
208 make_reference_type (struct type
*type
, struct type
**typeptr
)
210 register struct type
*ntype
; /* New type */
211 struct objfile
*objfile
;
213 ntype
= TYPE_REFERENCE_TYPE (type
);
218 return ntype
; /* Don't care about alloc, and have new type. */
219 else if (*typeptr
== 0)
221 *typeptr
= ntype
; /* Tracking alloc, and we have new type. */
226 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
228 ntype
= alloc_type (TYPE_OBJFILE (type
));
233 /* We have storage, but need to reset it. */
236 objfile
= TYPE_OBJFILE (ntype
);
237 memset ((char *) ntype
, 0, sizeof (struct type
));
238 TYPE_OBJFILE (ntype
) = objfile
;
241 TYPE_TARGET_TYPE (ntype
) = type
;
242 TYPE_REFERENCE_TYPE (type
) = ntype
;
244 /* FIXME! Assume the machine has only one representation for references,
245 and that it matches the (only) representation for pointers! */
247 TYPE_LENGTH (ntype
) = TARGET_PTR_BIT
/ TARGET_CHAR_BIT
;
248 TYPE_CODE (ntype
) = TYPE_CODE_REF
;
250 if (!TYPE_REFERENCE_TYPE (type
)) /* Remember it, if don't have one. */
251 TYPE_REFERENCE_TYPE (type
) = ntype
;
256 /* Same as above, but caller doesn't care about memory allocation details. */
259 lookup_reference_type (struct type
*type
)
261 return make_reference_type (type
, (struct type
**) 0);
264 /* Lookup a function type that returns type TYPE. TYPEPTR, if nonzero, points
265 to a pointer to memory where the function type should be stored.
266 If *TYPEPTR is zero, update it to point to the function type we return.
267 We allocate new memory if needed. */
270 make_function_type (struct type
*type
, struct type
**typeptr
)
272 register struct type
*ntype
; /* New type */
273 struct objfile
*objfile
;
275 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
277 ntype
= alloc_type (TYPE_OBJFILE (type
));
282 /* We have storage, but need to reset it. */
285 objfile
= TYPE_OBJFILE (ntype
);
286 memset ((char *) ntype
, 0, sizeof (struct type
));
287 TYPE_OBJFILE (ntype
) = objfile
;
290 TYPE_TARGET_TYPE (ntype
) = type
;
292 TYPE_LENGTH (ntype
) = 1;
293 TYPE_CODE (ntype
) = TYPE_CODE_FUNC
;
299 /* Given a type TYPE, return a type of functions that return that type.
300 May need to construct such a type if this is the first use. */
303 lookup_function_type (struct type
*type
)
305 return make_function_type (type
, (struct type
**) 0);
309 /* Make a "c-v" variant of a type -- a type that is identical to the
310 one supplied except that it may have const or volatile attributes
311 CNST is a flag for setting the const attribute
312 VOLTL is a flag for setting the volatile attribute
313 TYPE is the base type whose variant we are creating.
314 TYPEPTR, if nonzero, points
315 to a pointer to memory where the reference type should be stored.
316 If *TYPEPTR is zero, update it to point to the reference type we return.
317 We allocate new memory if needed. */
320 make_cv_type (int cnst
, int voltl
, struct type
*type
, struct type
**typeptr
)
322 register struct type
*ntype
; /* New type */
323 register struct type
*tmp_type
= type
; /* tmp type */
324 struct objfile
*objfile
;
326 ntype
= TYPE_CV_TYPE (type
);
328 while (ntype
!= type
)
330 if ((TYPE_CONST (ntype
) == cnst
) &&
331 (TYPE_VOLATILE (ntype
) == voltl
))
335 else if (*typeptr
== 0)
337 *typeptr
= ntype
; /* Tracking alloc, and we have new type. */
342 ntype
= TYPE_CV_TYPE (ntype
);
345 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
347 ntype
= alloc_type (TYPE_OBJFILE (type
));
352 /* We have storage, but need to reset it. */
355 objfile
= TYPE_OBJFILE (ntype
);
356 /* memset ((char *) ntype, 0, sizeof (struct type)); */
357 TYPE_OBJFILE (ntype
) = objfile
;
360 /* Copy original type */
361 memcpy ((char *) ntype
, (char *) type
, sizeof (struct type
));
362 /* But zero out fields that shouldn't be copied */
363 TYPE_POINTER_TYPE (ntype
) = (struct type
*) 0; /* Need new pointer kind */
364 TYPE_REFERENCE_TYPE (ntype
) = (struct type
*) 0; /* Need new referene kind */
365 /* Note: TYPE_TARGET_TYPE can be left as is */
367 /* Set flags appropriately */
369 TYPE_FLAGS (ntype
) |= TYPE_FLAG_CONST
;
371 TYPE_FLAGS (ntype
) &= ~TYPE_FLAG_CONST
;
374 TYPE_FLAGS (ntype
) |= TYPE_FLAG_VOLATILE
;
376 TYPE_FLAGS (ntype
) &= ~TYPE_FLAG_VOLATILE
;
378 /* Fix the chain of cv variants */
379 TYPE_CV_TYPE (ntype
) = type
;
380 TYPE_CV_TYPE (tmp_type
) = ntype
;
388 /* Implement direct support for MEMBER_TYPE in GNU C++.
389 May need to construct such a type if this is the first use.
390 The TYPE is the type of the member. The DOMAIN is the type
391 of the aggregate that the member belongs to. */
394 lookup_member_type (struct type
*type
, struct type
*domain
)
396 register struct type
*mtype
;
398 mtype
= alloc_type (TYPE_OBJFILE (type
));
399 smash_to_member_type (mtype
, domain
, type
);
403 /* Allocate a stub method whose return type is TYPE.
404 This apparently happens for speed of symbol reading, since parsing
405 out the arguments to the method is cpu-intensive, the way we are doing
406 it. So, we will fill in arguments later.
407 This always returns a fresh type. */
410 allocate_stub_method (struct type
*type
)
414 mtype
= alloc_type (TYPE_OBJFILE (type
));
415 TYPE_TARGET_TYPE (mtype
) = type
;
416 /* _DOMAIN_TYPE (mtype) = unknown yet */
417 /* _ARG_TYPES (mtype) = unknown yet */
418 TYPE_FLAGS (mtype
) = TYPE_FLAG_STUB
;
419 TYPE_CODE (mtype
) = TYPE_CODE_METHOD
;
420 TYPE_LENGTH (mtype
) = 1;
424 /* Create a range type using either a blank type supplied in RESULT_TYPE,
425 or creating a new type, inheriting the objfile from INDEX_TYPE.
427 Indices will be of type INDEX_TYPE, and will range from LOW_BOUND to
428 HIGH_BOUND, inclusive.
430 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
431 sure it is TYPE_CODE_UNDEF before we bash it into a range type? */
434 create_range_type (struct type
*result_type
, struct type
*index_type
,
435 int low_bound
, int high_bound
)
437 if (result_type
== NULL
)
439 result_type
= alloc_type (TYPE_OBJFILE (index_type
));
441 TYPE_CODE (result_type
) = TYPE_CODE_RANGE
;
442 TYPE_TARGET_TYPE (result_type
) = index_type
;
443 if (TYPE_FLAGS (index_type
) & TYPE_FLAG_STUB
)
444 TYPE_FLAGS (result_type
) |= TYPE_FLAG_TARGET_STUB
;
446 TYPE_LENGTH (result_type
) = TYPE_LENGTH (check_typedef (index_type
));
447 TYPE_NFIELDS (result_type
) = 2;
448 TYPE_FIELDS (result_type
) = (struct field
*)
449 TYPE_ALLOC (result_type
, 2 * sizeof (struct field
));
450 memset (TYPE_FIELDS (result_type
), 0, 2 * sizeof (struct field
));
451 TYPE_FIELD_BITPOS (result_type
, 0) = low_bound
;
452 TYPE_FIELD_BITPOS (result_type
, 1) = high_bound
;
453 TYPE_FIELD_TYPE (result_type
, 0) = builtin_type_int
; /* FIXME */
454 TYPE_FIELD_TYPE (result_type
, 1) = builtin_type_int
; /* FIXME */
457 TYPE_FLAGS (result_type
) |= TYPE_FLAG_UNSIGNED
;
459 return (result_type
);
462 /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type TYPE.
463 Return 1 of type is a range type, 0 if it is discrete (and bounds
464 will fit in LONGEST), or -1 otherwise. */
467 get_discrete_bounds (struct type
*type
, LONGEST
*lowp
, LONGEST
*highp
)
469 CHECK_TYPEDEF (type
);
470 switch (TYPE_CODE (type
))
472 case TYPE_CODE_RANGE
:
473 *lowp
= TYPE_LOW_BOUND (type
);
474 *highp
= TYPE_HIGH_BOUND (type
);
477 if (TYPE_NFIELDS (type
) > 0)
479 /* The enums may not be sorted by value, so search all
483 *lowp
= *highp
= TYPE_FIELD_BITPOS (type
, 0);
484 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
486 if (TYPE_FIELD_BITPOS (type
, i
) < *lowp
)
487 *lowp
= TYPE_FIELD_BITPOS (type
, i
);
488 if (TYPE_FIELD_BITPOS (type
, i
) > *highp
)
489 *highp
= TYPE_FIELD_BITPOS (type
, i
);
492 /* Set unsigned indicator if warranted. */
495 TYPE_FLAGS (type
) |= TYPE_FLAG_UNSIGNED
;
509 if (TYPE_LENGTH (type
) > sizeof (LONGEST
)) /* Too big */
511 if (!TYPE_UNSIGNED (type
))
513 *lowp
= -(1 << (TYPE_LENGTH (type
) * TARGET_CHAR_BIT
- 1));
517 /* ... fall through for unsigned ints ... */
520 /* This round-about calculation is to avoid shifting by
521 TYPE_LENGTH (type) * TARGET_CHAR_BIT, which will not work
522 if TYPE_LENGTH (type) == sizeof (LONGEST). */
523 *highp
= 1 << (TYPE_LENGTH (type
) * TARGET_CHAR_BIT
- 1);
524 *highp
= (*highp
- 1) | *highp
;
531 /* Create an array type using either a blank type supplied in RESULT_TYPE,
532 or creating a new type, inheriting the objfile from RANGE_TYPE.
534 Elements will be of type ELEMENT_TYPE, the indices will be of type
537 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
538 sure it is TYPE_CODE_UNDEF before we bash it into an array type? */
541 create_array_type (struct type
*result_type
, struct type
*element_type
,
542 struct type
*range_type
)
544 LONGEST low_bound
, high_bound
;
546 if (result_type
== NULL
)
548 result_type
= alloc_type (TYPE_OBJFILE (range_type
));
550 TYPE_CODE (result_type
) = TYPE_CODE_ARRAY
;
551 TYPE_TARGET_TYPE (result_type
) = element_type
;
552 if (get_discrete_bounds (range_type
, &low_bound
, &high_bound
) < 0)
553 low_bound
= high_bound
= 0;
554 CHECK_TYPEDEF (element_type
);
555 TYPE_LENGTH (result_type
) =
556 TYPE_LENGTH (element_type
) * (high_bound
- low_bound
+ 1);
557 TYPE_NFIELDS (result_type
) = 1;
558 TYPE_FIELDS (result_type
) =
559 (struct field
*) TYPE_ALLOC (result_type
, sizeof (struct field
));
560 memset (TYPE_FIELDS (result_type
), 0, sizeof (struct field
));
561 TYPE_FIELD_TYPE (result_type
, 0) = range_type
;
562 TYPE_VPTR_FIELDNO (result_type
) = -1;
564 /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays */
565 if (TYPE_LENGTH (result_type
) == 0)
566 TYPE_FLAGS (result_type
) |= TYPE_FLAG_TARGET_STUB
;
568 return (result_type
);
571 /* Create a string type using either a blank type supplied in RESULT_TYPE,
572 or creating a new type. String types are similar enough to array of
573 char types that we can use create_array_type to build the basic type
574 and then bash it into a string type.
576 For fixed length strings, the range type contains 0 as the lower
577 bound and the length of the string minus one as the upper bound.
579 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
580 sure it is TYPE_CODE_UNDEF before we bash it into a string type? */
583 create_string_type (struct type
*result_type
, struct type
*range_type
)
585 result_type
= create_array_type (result_type
,
586 *current_language
->string_char_type
,
588 TYPE_CODE (result_type
) = TYPE_CODE_STRING
;
589 return (result_type
);
593 create_set_type (struct type
*result_type
, struct type
*domain_type
)
595 LONGEST low_bound
, high_bound
, bit_length
;
596 if (result_type
== NULL
)
598 result_type
= alloc_type (TYPE_OBJFILE (domain_type
));
600 TYPE_CODE (result_type
) = TYPE_CODE_SET
;
601 TYPE_NFIELDS (result_type
) = 1;
602 TYPE_FIELDS (result_type
) = (struct field
*)
603 TYPE_ALLOC (result_type
, 1 * sizeof (struct field
));
604 memset (TYPE_FIELDS (result_type
), 0, sizeof (struct field
));
606 if (!(TYPE_FLAGS (domain_type
) & TYPE_FLAG_STUB
))
608 if (get_discrete_bounds (domain_type
, &low_bound
, &high_bound
) < 0)
609 low_bound
= high_bound
= 0;
610 bit_length
= high_bound
- low_bound
+ 1;
611 TYPE_LENGTH (result_type
)
612 = (bit_length
+ TARGET_CHAR_BIT
- 1) / TARGET_CHAR_BIT
;
614 TYPE_FIELD_TYPE (result_type
, 0) = domain_type
;
617 TYPE_FLAGS (result_type
) |= TYPE_FLAG_UNSIGNED
;
619 return (result_type
);
623 /* Construct and return a type of the form:
624 struct NAME { ELT_TYPE ELT_NAME[N]; }
625 We use these types for SIMD registers. For example, the type of
626 the SSE registers on the late x86-family processors is:
627 struct __builtin_v4sf { float f[4]; }
628 built by the function call:
629 init_simd_type ("__builtin_v4sf", builtin_type_float, "f", 4)
630 The type returned is a permanent type, allocated using malloc; it
631 doesn't live in any objfile's obstack. */
633 init_simd_type (char *name
,
634 struct type
*elt_type
,
641 /* Build the field structure. */
642 f
= xmalloc (sizeof (*f
));
643 memset (f
, 0, sizeof (*f
));
645 f
->type
= create_array_type (0, elt_type
,
646 create_range_type (0, builtin_type_int
,
650 /* Build a struct type with that field. */
651 t
= init_type (TYPE_CODE_STRUCT
, n
* TYPE_LENGTH (elt_type
), 0, 0, 0);
660 /* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE.
661 A MEMBER is a wierd thing -- it amounts to a typed offset into
662 a struct, e.g. "an int at offset 8". A MEMBER TYPE doesn't
663 include the offset (that's the value of the MEMBER itself), but does
664 include the structure type into which it points (for some reason).
666 When "smashing" the type, we preserve the objfile that the
667 old type pointed to, since we aren't changing where the type is actually
671 smash_to_member_type (struct type
*type
, struct type
*domain
,
672 struct type
*to_type
)
674 struct objfile
*objfile
;
676 objfile
= TYPE_OBJFILE (type
);
678 memset ((char *) type
, 0, sizeof (struct type
));
679 TYPE_OBJFILE (type
) = objfile
;
680 TYPE_TARGET_TYPE (type
) = to_type
;
681 TYPE_DOMAIN_TYPE (type
) = domain
;
682 TYPE_LENGTH (type
) = 1; /* In practice, this is never needed. */
683 TYPE_CODE (type
) = TYPE_CODE_MEMBER
;
686 /* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE.
687 METHOD just means `function that gets an extra "this" argument'.
689 When "smashing" the type, we preserve the objfile that the
690 old type pointed to, since we aren't changing where the type is actually
694 smash_to_method_type (struct type
*type
, struct type
*domain
,
695 struct type
*to_type
, struct type
**args
)
697 struct objfile
*objfile
;
699 objfile
= TYPE_OBJFILE (type
);
701 memset ((char *) type
, 0, sizeof (struct type
));
702 TYPE_OBJFILE (type
) = objfile
;
703 TYPE_TARGET_TYPE (type
) = to_type
;
704 TYPE_DOMAIN_TYPE (type
) = domain
;
705 TYPE_ARG_TYPES (type
) = args
;
706 TYPE_LENGTH (type
) = 1; /* In practice, this is never needed. */
707 TYPE_CODE (type
) = TYPE_CODE_METHOD
;
710 /* Return a typename for a struct/union/enum type without "struct ",
711 "union ", or "enum ". If the type has a NULL name, return NULL. */
714 type_name_no_tag (register const struct type
*type
)
716 if (TYPE_TAG_NAME (type
) != NULL
)
717 return TYPE_TAG_NAME (type
);
719 /* Is there code which expects this to return the name if there is no
720 tag name? My guess is that this is mainly used for C++ in cases where
721 the two will always be the same. */
722 return TYPE_NAME (type
);
725 /* Lookup a primitive type named NAME.
726 Return zero if NAME is not a primitive type. */
729 lookup_primitive_typename (char *name
)
731 struct type
**const *p
;
733 for (p
= current_language
->la_builtin_type_vector
; *p
!= NULL
; p
++)
735 if (STREQ ((**p
)->name
, name
))
743 /* Lookup a typedef or primitive type named NAME,
744 visible in lexical block BLOCK.
745 If NOERR is nonzero, return zero if NAME is not suitably defined. */
748 lookup_typename (char *name
, struct block
*block
, int noerr
)
750 register struct symbol
*sym
;
751 register struct type
*tmp
;
753 sym
= lookup_symbol (name
, block
, VAR_NAMESPACE
, 0, (struct symtab
**) NULL
);
754 if (sym
== NULL
|| SYMBOL_CLASS (sym
) != LOC_TYPEDEF
)
756 tmp
= lookup_primitive_typename (name
);
761 else if (!tmp
&& noerr
)
767 error ("No type named %s.", name
);
770 return (SYMBOL_TYPE (sym
));
774 lookup_unsigned_typename (char *name
)
776 char *uns
= alloca (strlen (name
) + 10);
778 strcpy (uns
, "unsigned ");
779 strcpy (uns
+ 9, name
);
780 return (lookup_typename (uns
, (struct block
*) NULL
, 0));
784 lookup_signed_typename (char *name
)
787 char *uns
= alloca (strlen (name
) + 8);
789 strcpy (uns
, "signed ");
790 strcpy (uns
+ 7, name
);
791 t
= lookup_typename (uns
, (struct block
*) NULL
, 1);
792 /* If we don't find "signed FOO" just try again with plain "FOO". */
795 return lookup_typename (name
, (struct block
*) NULL
, 0);
798 /* Lookup a structure type named "struct NAME",
799 visible in lexical block BLOCK. */
802 lookup_struct (char *name
, struct block
*block
)
804 register struct symbol
*sym
;
806 sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
, 0,
807 (struct symtab
**) NULL
);
811 error ("No struct type named %s.", name
);
813 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_STRUCT
)
815 error ("This context has class, union or enum %s, not a struct.", name
);
817 return (SYMBOL_TYPE (sym
));
820 /* Lookup a union type named "union NAME",
821 visible in lexical block BLOCK. */
824 lookup_union (char *name
, struct block
*block
)
826 register struct symbol
*sym
;
829 sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
, 0,
830 (struct symtab
**) NULL
);
833 error ("No union type named %s.", name
);
835 t
= SYMBOL_TYPE (sym
);
837 if (TYPE_CODE (t
) == TYPE_CODE_UNION
)
840 /* C++ unions may come out with TYPE_CODE_CLASS, but we look at
841 * a further "declared_type" field to discover it is really a union.
843 if (HAVE_CPLUS_STRUCT (t
))
844 if (TYPE_DECLARED_TYPE (t
) == DECLARED_TYPE_UNION
)
847 /* If we get here, it's not a union */
848 error ("This context has class, struct or enum %s, not a union.", name
);
852 /* Lookup an enum type named "enum NAME",
853 visible in lexical block BLOCK. */
856 lookup_enum (char *name
, struct block
*block
)
858 register struct symbol
*sym
;
860 sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
, 0,
861 (struct symtab
**) NULL
);
864 error ("No enum type named %s.", name
);
866 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_ENUM
)
868 error ("This context has class, struct or union %s, not an enum.", name
);
870 return (SYMBOL_TYPE (sym
));
873 /* Lookup a template type named "template NAME<TYPE>",
874 visible in lexical block BLOCK. */
877 lookup_template_type (char *name
, struct type
*type
, struct block
*block
)
880 char *nam
= (char *) alloca (strlen (name
) + strlen (type
->name
) + 4);
883 strcat (nam
, type
->name
);
884 strcat (nam
, " >"); /* FIXME, extra space still introduced in gcc? */
886 sym
= lookup_symbol (nam
, block
, VAR_NAMESPACE
, 0, (struct symtab
**) NULL
);
890 error ("No template type named %s.", name
);
892 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_STRUCT
)
894 error ("This context has class, union or enum %s, not a struct.", name
);
896 return (SYMBOL_TYPE (sym
));
899 /* Given a type TYPE, lookup the type of the component of type named NAME.
901 TYPE can be either a struct or union, or a pointer or reference to a struct or
902 union. If it is a pointer or reference, its target type is automatically used.
903 Thus '.' and '->' are interchangable, as specified for the definitions of the
904 expression element types STRUCTOP_STRUCT and STRUCTOP_PTR.
906 If NOERR is nonzero, return zero if NAME is not suitably defined.
907 If NAME is the name of a baseclass type, return that type. */
910 lookup_struct_elt_type (struct type
*type
, char *name
, int noerr
)
916 CHECK_TYPEDEF (type
);
917 if (TYPE_CODE (type
) != TYPE_CODE_PTR
918 && TYPE_CODE (type
) != TYPE_CODE_REF
)
920 type
= TYPE_TARGET_TYPE (type
);
923 if (TYPE_CODE (type
) != TYPE_CODE_STRUCT
&&
924 TYPE_CODE (type
) != TYPE_CODE_UNION
)
926 target_terminal_ours ();
927 gdb_flush (gdb_stdout
);
928 fprintf_unfiltered (gdb_stderr
, "Type ");
929 type_print (type
, "", gdb_stderr
, -1);
930 error (" is not a structure or union type.");
934 /* FIXME: This change put in by Michael seems incorrect for the case where
935 the structure tag name is the same as the member name. I.E. when doing
936 "ptype bell->bar" for "struct foo { int bar; int foo; } bell;"
941 typename
= type_name_no_tag (type
);
942 if (typename
!= NULL
&& STREQ (typename
, name
))
947 for (i
= TYPE_NFIELDS (type
) - 1; i
>= TYPE_N_BASECLASSES (type
); i
--)
949 char *t_field_name
= TYPE_FIELD_NAME (type
, i
);
951 if (t_field_name
&& (strcmp_iw (t_field_name
, name
) == 0))
953 return TYPE_FIELD_TYPE (type
, i
);
957 /* OK, it's not in this class. Recursively check the baseclasses. */
958 for (i
= TYPE_N_BASECLASSES (type
) - 1; i
>= 0; i
--)
962 t
= lookup_struct_elt_type (TYPE_BASECLASS (type
, i
), name
, noerr
);
974 target_terminal_ours ();
975 gdb_flush (gdb_stdout
);
976 fprintf_unfiltered (gdb_stderr
, "Type ");
977 type_print (type
, "", gdb_stderr
, -1);
978 fprintf_unfiltered (gdb_stderr
, " has no component named ");
979 fputs_filtered (name
, gdb_stderr
);
981 return (struct type
*) -1; /* For lint */
984 /* If possible, make the vptr_fieldno and vptr_basetype fields of TYPE
985 valid. Callers should be aware that in some cases (for example,
986 the type or one of its baseclasses is a stub type and we are
987 debugging a .o file), this function will not be able to find the virtual
988 function table pointer, and vptr_fieldno will remain -1 and vptr_basetype
992 fill_in_vptr_fieldno (struct type
*type
)
994 CHECK_TYPEDEF (type
);
996 if (TYPE_VPTR_FIELDNO (type
) < 0)
1000 /* We must start at zero in case the first (and only) baseclass is
1001 virtual (and hence we cannot share the table pointer). */
1002 for (i
= 0; i
< TYPE_N_BASECLASSES (type
); i
++)
1004 fill_in_vptr_fieldno (TYPE_BASECLASS (type
, i
));
1005 if (TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type
, i
)) >= 0)
1007 TYPE_VPTR_FIELDNO (type
)
1008 = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type
, i
));
1009 TYPE_VPTR_BASETYPE (type
)
1010 = TYPE_VPTR_BASETYPE (TYPE_BASECLASS (type
, i
));
1017 /* Find the method and field indices for the destructor in class type T.
1018 Return 1 if the destructor was found, otherwise, return 0. */
1021 get_destructor_fn_field (struct type
*t
, int *method_indexp
, int *field_indexp
)
1025 for (i
= 0; i
< TYPE_NFN_FIELDS (t
); i
++)
1028 struct fn_field
*f
= TYPE_FN_FIELDLIST1 (t
, i
);
1030 for (j
= 0; j
< TYPE_FN_FIELDLIST_LENGTH (t
, i
); j
++)
1032 if (is_destructor_name (TYPE_FN_FIELD_PHYSNAME (f
, j
)) != 0)
1043 /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989.
1045 If this is a stubbed struct (i.e. declared as struct foo *), see if
1046 we can find a full definition in some other file. If so, copy this
1047 definition, so we can use it in future. There used to be a comment (but
1048 not any code) that if we don't find a full definition, we'd set a flag
1049 so we don't spend time in the future checking the same type. That would
1050 be a mistake, though--we might load in more symbols which contain a
1051 full definition for the type.
1053 This used to be coded as a macro, but I don't think it is called
1054 often enough to merit such treatment. */
1056 struct complaint stub_noname_complaint
=
1057 {"stub type has NULL name", 0, 0};
1060 check_typedef (register struct type
*type
)
1062 struct type
*orig_type
= type
;
1063 while (TYPE_CODE (type
) == TYPE_CODE_TYPEDEF
)
1065 if (!TYPE_TARGET_TYPE (type
))
1070 /* It is dangerous to call lookup_symbol if we are currently
1071 reading a symtab. Infinite recursion is one danger. */
1072 if (currently_reading_symtab
)
1075 name
= type_name_no_tag (type
);
1076 /* FIXME: shouldn't we separately check the TYPE_NAME and the
1077 TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE
1078 as appropriate? (this code was written before TYPE_NAME and
1079 TYPE_TAG_NAME were separate). */
1082 complain (&stub_noname_complaint
);
1085 sym
= lookup_symbol (name
, 0, STRUCT_NAMESPACE
, 0,
1086 (struct symtab
**) NULL
);
1088 TYPE_TARGET_TYPE (type
) = SYMBOL_TYPE (sym
);
1090 TYPE_TARGET_TYPE (type
) = alloc_type (NULL
); /* TYPE_CODE_UNDEF */
1092 type
= TYPE_TARGET_TYPE (type
);
1095 /* If this is a struct/class/union with no fields, then check whether a
1096 full definition exists somewhere else. This is for systems where a
1097 type definition with no fields is issued for such types, instead of
1098 identifying them as stub types in the first place */
1100 if (TYPE_IS_OPAQUE (type
) && opaque_type_resolution
&& !currently_reading_symtab
)
1102 char *name
= type_name_no_tag (type
);
1103 struct type
*newtype
;
1106 complain (&stub_noname_complaint
);
1109 newtype
= lookup_transparent_type (name
);
1112 memcpy ((char *) type
, (char *) newtype
, sizeof (struct type
));
1115 /* Otherwise, rely on the stub flag being set for opaque/stubbed types */
1116 else if ((TYPE_FLAGS (type
) & TYPE_FLAG_STUB
) && !currently_reading_symtab
)
1118 char *name
= type_name_no_tag (type
);
1119 /* FIXME: shouldn't we separately check the TYPE_NAME and the
1120 TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE
1121 as appropriate? (this code was written before TYPE_NAME and
1122 TYPE_TAG_NAME were separate). */
1126 complain (&stub_noname_complaint
);
1129 sym
= lookup_symbol (name
, 0, STRUCT_NAMESPACE
, 0, (struct symtab
**) NULL
);
1132 memcpy ((char *) type
, (char *) SYMBOL_TYPE (sym
), sizeof (struct type
));
1136 if (TYPE_FLAGS (type
) & TYPE_FLAG_TARGET_STUB
)
1138 struct type
*range_type
;
1139 struct type
*target_type
= check_typedef (TYPE_TARGET_TYPE (type
));
1141 if (TYPE_FLAGS (target_type
) & (TYPE_FLAG_STUB
| TYPE_FLAG_TARGET_STUB
))
1144 else if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
1145 && TYPE_NFIELDS (type
) == 1
1146 && (TYPE_CODE (range_type
= TYPE_FIELD_TYPE (type
, 0))
1147 == TYPE_CODE_RANGE
))
1149 /* Now recompute the length of the array type, based on its
1150 number of elements and the target type's length. */
1151 TYPE_LENGTH (type
) =
1152 ((TYPE_FIELD_BITPOS (range_type
, 1)
1153 - TYPE_FIELD_BITPOS (range_type
, 0)
1155 * TYPE_LENGTH (target_type
));
1156 TYPE_FLAGS (type
) &= ~TYPE_FLAG_TARGET_STUB
;
1158 else if (TYPE_CODE (type
) == TYPE_CODE_RANGE
)
1160 TYPE_LENGTH (type
) = TYPE_LENGTH (target_type
);
1161 TYPE_FLAGS (type
) &= ~TYPE_FLAG_TARGET_STUB
;
1164 /* Cache TYPE_LENGTH for future use. */
1165 TYPE_LENGTH (orig_type
) = TYPE_LENGTH (type
);
1169 /* New code added to support parsing of Cfront stabs strings */
1170 #define INIT_EXTRA { pextras->len=0; pextras->str[0]='\0'; }
1171 #define ADD_EXTRA(c) { pextras->str[pextras->len++]=c; }
1174 add_name (struct extra
*pextras
, char *n
)
1178 if ((nlen
= (n
? strlen (n
) : 0)) == 0)
1180 sprintf (pextras
->str
+ pextras
->len
, "%d%s", nlen
, n
);
1181 pextras
->len
= strlen (pextras
->str
);
1185 add_mangled_type (struct extra
*pextras
, struct type
*t
)
1187 enum type_code tcode
;
1191 tcode
= TYPE_CODE (t
);
1192 tlen
= TYPE_LENGTH (t
);
1193 tflags
= TYPE_FLAGS (t
);
1194 tname
= TYPE_NAME (t
);
1195 /* args of "..." seem to get mangled as "e" */
1213 if ((pname
= strrchr (tname
, 'l'), pname
) && !strcmp (pname
, "long"))
1226 static struct complaint msg
=
1227 {"Bad int type code length x%x\n", 0, 0};
1229 complain (&msg
, tlen
);
1248 static struct complaint msg
=
1249 {"Bad float type code length x%x\n", 0, 0};
1250 complain (&msg
, tlen
);
1256 /* followed by what it's a ref to */
1260 /* followed by what it's a ptr to */
1262 case TYPE_CODE_TYPEDEF
:
1264 static struct complaint msg
=
1265 {"Typedefs in overloaded functions not yet supported\n", 0, 0};
1268 /* followed by type bytes & name */
1270 case TYPE_CODE_FUNC
:
1272 /* followed by func's arg '_' & ret types */
1274 case TYPE_CODE_VOID
:
1277 case TYPE_CODE_METHOD
:
1279 /* followed by name of class and func's arg '_' & ret types */
1280 add_name (pextras
, tname
);
1281 ADD_EXTRA ('F'); /* then mangle function */
1283 case TYPE_CODE_STRUCT
: /* C struct */
1284 case TYPE_CODE_UNION
: /* C union */
1285 case TYPE_CODE_ENUM
: /* Enumeration type */
1286 /* followed by name of type */
1287 add_name (pextras
, tname
);
1290 /* errors possible types/not supported */
1291 case TYPE_CODE_CHAR
:
1292 case TYPE_CODE_ARRAY
: /* Array type */
1293 case TYPE_CODE_MEMBER
: /* Member type */
1294 case TYPE_CODE_BOOL
:
1295 case TYPE_CODE_COMPLEX
: /* Complex float */
1296 case TYPE_CODE_UNDEF
:
1297 case TYPE_CODE_SET
: /* Pascal sets */
1298 case TYPE_CODE_RANGE
:
1299 case TYPE_CODE_STRING
:
1300 case TYPE_CODE_BITSTRING
:
1301 case TYPE_CODE_ERROR
:
1304 static struct complaint msg
=
1305 {"Unknown type code x%x\n", 0, 0};
1306 complain (&msg
, tcode
);
1310 add_mangled_type (pextras
, t
->target_type
);
1315 cfront_mangle_name (struct type
*type
, int i
, int j
)
1318 char *mangled_name
= gdb_mangle_name (type
, i
, j
);
1320 f
= TYPE_FN_FIELDLIST1 (type
, i
); /* moved from below */
1322 /* kludge to support cfront methods - gdb expects to find "F" for
1323 ARM_mangled names, so when we mangle, we have to add it here */
1327 char *arm_mangled_name
;
1328 struct fn_field
*method
= &f
[j
];
1329 char *field_name
= TYPE_FN_FIELDLIST_NAME (type
, i
);
1330 char *physname
= TYPE_FN_FIELD_PHYSNAME (f
, j
);
1331 char *newname
= type_name_no_tag (type
);
1333 struct type
*ftype
= TYPE_FN_FIELD_TYPE (f
, j
);
1334 int nargs
= TYPE_NFIELDS (ftype
); /* number of args */
1335 struct extra extras
, *pextras
= &extras
;
1338 if (TYPE_FN_FIELD_STATIC_P (f
, j
)) /* j for sublist within this list */
1341 /* add args here! */
1342 if (nargs
<= 1) /* no args besides this */
1346 for (k
= 1; k
< nargs
; k
++)
1349 t
= TYPE_FIELD_TYPE (ftype
, k
);
1350 add_mangled_type (pextras
, t
);
1354 printf ("add_mangled_type: %s\n", extras
.str
); /* FIXME */
1355 xasprintf (&arm_mangled_name
, "%s%s", mangled_name
, extras
.str
);
1356 xfree (mangled_name
);
1357 mangled_name
= arm_mangled_name
;
1363 /* End of new code added to support parsing of Cfront stabs strings */
1365 /* Parse a type expression in the string [P..P+LENGTH). If an error occurs,
1366 silently return builtin_type_void. */
1369 safe_parse_type (char *p
, int length
)
1371 struct ui_file
*saved_gdb_stderr
;
1374 /* Suppress error messages. */
1375 saved_gdb_stderr
= gdb_stderr
;
1376 gdb_stderr
= ui_file_new ();
1378 /* Call parse_and_eval_type() without fear of longjmp()s. */
1379 if (!gdb_parse_and_eval_type (p
, length
, &type
))
1380 type
= builtin_type_void
;
1382 /* Stop suppressing error messages. */
1383 ui_file_delete (gdb_stderr
);
1384 gdb_stderr
= saved_gdb_stderr
;
1389 /* Ugly hack to convert method stubs into method types.
1391 He ain't kiddin'. This demangles the name of the method into a string
1392 including argument types, parses out each argument type, generates
1393 a string casting a zero to that type, evaluates the string, and stuffs
1394 the resulting type into an argtype vector!!! Then it knows the type
1395 of the whole function (including argument types for overloading),
1396 which info used to be in the stab's but was removed to hack back
1397 the space required for them. */
1400 check_stub_method (struct type
*type
, int method_id
, int signature_id
)
1403 char *mangled_name
= gdb_mangle_name (type
, method_id
, signature_id
);
1404 char *demangled_name
= cplus_demangle (mangled_name
,
1405 DMGL_PARAMS
| DMGL_ANSI
);
1406 char *argtypetext
, *p
;
1407 int depth
= 0, argcount
= 1;
1408 struct type
**argtypes
;
1411 /* Make sure we got back a function string that we can use. */
1413 p
= strchr (demangled_name
, '(');
1417 if (demangled_name
== NULL
|| p
== NULL
)
1418 error ("Internal: Cannot demangle mangled name `%s'.", mangled_name
);
1420 /* Now, read in the parameters that define this type. */
1425 if (*p
== '(' || *p
== '<')
1429 else if (*p
== ')' || *p
== '>')
1433 else if (*p
== ',' && depth
== 0)
1441 /* We need two more slots: one for the THIS pointer, and one for the
1442 NULL [...] or void [end of arglist]. */
1444 argtypes
= (struct type
**)
1445 TYPE_ALLOC (type
, (argcount
+ 2) * sizeof (struct type
*));
1447 /* FIXME: This is wrong for static member functions. */
1448 argtypes
[0] = lookup_pointer_type (type
);
1451 if (*p
!= ')') /* () means no args, skip while */
1456 if (depth
<= 0 && (*p
== ',' || *p
== ')'))
1458 /* Avoid parsing of ellipsis, they will be handled below. */
1459 if (strncmp (argtypetext
, "...", p
- argtypetext
) != 0)
1461 argtypes
[argcount
] =
1462 safe_parse_type (argtypetext
, p
- argtypetext
);
1465 argtypetext
= p
+ 1;
1468 if (*p
== '(' || *p
== '<')
1472 else if (*p
== ')' || *p
== '>')
1481 if (p
[-2] != '.') /* Not '...' */
1483 argtypes
[argcount
] = builtin_type_void
; /* List terminator */
1487 argtypes
[argcount
] = NULL
; /* Ellist terminator */
1490 xfree (demangled_name
);
1492 f
= TYPE_FN_FIELDLIST1 (type
, method_id
);
1494 TYPE_FN_FIELD_PHYSNAME (f
, signature_id
) = mangled_name
;
1496 /* Now update the old "stub" type into a real type. */
1497 mtype
= TYPE_FN_FIELD_TYPE (f
, signature_id
);
1498 TYPE_DOMAIN_TYPE (mtype
) = type
;
1499 TYPE_ARG_TYPES (mtype
) = argtypes
;
1500 TYPE_FLAGS (mtype
) &= ~TYPE_FLAG_STUB
;
1501 TYPE_FN_FIELD_STUB (f
, signature_id
) = 0;
1504 const struct cplus_struct_type cplus_struct_default
;
1507 allocate_cplus_struct_type (struct type
*type
)
1509 if (!HAVE_CPLUS_STRUCT (type
))
1511 TYPE_CPLUS_SPECIFIC (type
) = (struct cplus_struct_type
*)
1512 TYPE_ALLOC (type
, sizeof (struct cplus_struct_type
));
1513 *(TYPE_CPLUS_SPECIFIC (type
)) = cplus_struct_default
;
1517 /* Helper function to initialize the standard scalar types.
1519 If NAME is non-NULL and OBJFILE is non-NULL, then we make a copy
1520 of the string pointed to by name in the type_obstack for that objfile,
1521 and initialize the type name to that copy. There are places (mipsread.c
1522 in particular, where init_type is called with a NULL value for NAME). */
1525 init_type (enum type_code code
, int length
, int flags
, char *name
,
1526 struct objfile
*objfile
)
1528 register struct type
*type
;
1530 type
= alloc_type (objfile
);
1531 TYPE_CODE (type
) = code
;
1532 TYPE_LENGTH (type
) = length
;
1533 TYPE_FLAGS (type
) |= flags
;
1534 if ((name
!= NULL
) && (objfile
!= NULL
))
1537 obsavestring (name
, strlen (name
), &objfile
->type_obstack
);
1541 TYPE_NAME (type
) = name
;
1546 if (code
== TYPE_CODE_STRUCT
|| code
== TYPE_CODE_UNION
)
1548 INIT_CPLUS_SPECIFIC (type
);
1553 /* Look up a fundamental type for the specified objfile.
1554 May need to construct such a type if this is the first use.
1556 Some object file formats (ELF, COFF, etc) do not define fundamental
1557 types such as "int" or "double". Others (stabs for example), do
1558 define fundamental types.
1560 For the formats which don't provide fundamental types, gdb can create
1561 such types, using defaults reasonable for the current language and
1562 the current target machine.
1564 NOTE: This routine is obsolescent. Each debugging format reader
1565 should manage it's own fundamental types, either creating them from
1566 suitable defaults or reading them from the debugging information,
1567 whichever is appropriate. The DWARF reader has already been
1568 fixed to do this. Once the other readers are fixed, this routine
1569 will go away. Also note that fundamental types should be managed
1570 on a compilation unit basis in a multi-language environment, not
1571 on a linkage unit basis as is done here. */
1575 lookup_fundamental_type (struct objfile
*objfile
, int typeid)
1577 register struct type
**typep
;
1578 register int nbytes
;
1580 if (typeid < 0 || typeid >= FT_NUM_MEMBERS
)
1582 error ("internal error - invalid fundamental type id %d", typeid);
1585 /* If this is the first time we need a fundamental type for this objfile
1586 then we need to initialize the vector of type pointers. */
1588 if (objfile
->fundamental_types
== NULL
)
1590 nbytes
= FT_NUM_MEMBERS
* sizeof (struct type
*);
1591 objfile
->fundamental_types
= (struct type
**)
1592 obstack_alloc (&objfile
->type_obstack
, nbytes
);
1593 memset ((char *) objfile
->fundamental_types
, 0, nbytes
);
1594 OBJSTAT (objfile
, n_types
+= FT_NUM_MEMBERS
);
1597 /* Look for this particular type in the fundamental type vector. If one is
1598 not found, create and install one appropriate for the current language. */
1600 typep
= objfile
->fundamental_types
+ typeid;
1603 *typep
= create_fundamental_type (objfile
, typeid);
1610 can_dereference (struct type
*t
)
1612 /* FIXME: Should we return true for references as well as pointers? */
1616 && TYPE_CODE (t
) == TYPE_CODE_PTR
1617 && TYPE_CODE (TYPE_TARGET_TYPE (t
)) != TYPE_CODE_VOID
);
1621 is_integral_type (struct type
*t
)
1626 && ((TYPE_CODE (t
) == TYPE_CODE_INT
)
1627 || (TYPE_CODE (t
) == TYPE_CODE_ENUM
)
1628 || (TYPE_CODE (t
) == TYPE_CODE_CHAR
)
1629 || (TYPE_CODE (t
) == TYPE_CODE_RANGE
)
1630 || (TYPE_CODE (t
) == TYPE_CODE_BOOL
)));
1633 /* Chill varying string and arrays are represented as follows:
1635 struct { int __var_length; ELEMENT_TYPE[MAX_SIZE] __var_data};
1637 Return true if TYPE is such a Chill varying type. */
1640 chill_varying_type (struct type
*type
)
1642 if (TYPE_CODE (type
) != TYPE_CODE_STRUCT
1643 || TYPE_NFIELDS (type
) != 2
1644 || strcmp (TYPE_FIELD_NAME (type
, 0), "__var_length") != 0)
1649 /* Check whether BASE is an ancestor or base class or DCLASS
1650 Return 1 if so, and 0 if not.
1651 Note: callers may want to check for identity of the types before
1652 calling this function -- identical types are considered to satisfy
1653 the ancestor relationship even if they're identical */
1656 is_ancestor (struct type
*base
, struct type
*dclass
)
1660 CHECK_TYPEDEF (base
);
1661 CHECK_TYPEDEF (dclass
);
1665 if (TYPE_NAME (base
) && TYPE_NAME (dclass
) &&
1666 !strcmp (TYPE_NAME (base
), TYPE_NAME (dclass
)))
1669 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1670 if (is_ancestor (base
, TYPE_BASECLASS (dclass
, i
)))
1678 /* See whether DCLASS has a virtual table. This routine is aimed at
1679 the HP/Taligent ANSI C++ runtime model, and may not work with other
1680 runtime models. Return 1 => Yes, 0 => No. */
1683 has_vtable (struct type
*dclass
)
1685 /* In the HP ANSI C++ runtime model, a class has a vtable only if it
1686 has virtual functions or virtual bases. */
1690 if (TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
1693 /* First check for the presence of virtual bases */
1694 if (TYPE_FIELD_VIRTUAL_BITS (dclass
))
1695 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1696 if (B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass
), i
))
1699 /* Next check for virtual functions */
1700 if (TYPE_FN_FIELDLISTS (dclass
))
1701 for (i
= 0; i
< TYPE_NFN_FIELDS (dclass
); i
++)
1702 if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass
, i
), 0))
1705 /* Recurse on non-virtual bases to see if any of them needs a vtable */
1706 if (TYPE_FIELD_VIRTUAL_BITS (dclass
))
1707 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1708 if ((!B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass
), i
)) &&
1709 (has_vtable (TYPE_FIELD_TYPE (dclass
, i
))))
1712 /* Well, maybe we don't need a virtual table */
1716 /* Return a pointer to the "primary base class" of DCLASS.
1718 A NULL return indicates that DCLASS has no primary base, or that it
1719 couldn't be found (insufficient information).
1721 This routine is aimed at the HP/Taligent ANSI C++ runtime model,
1722 and may not work with other runtime models. */
1725 primary_base_class (struct type
*dclass
)
1727 /* In HP ANSI C++'s runtime model, a "primary base class" of a class
1728 is the first directly inherited, non-virtual base class that
1729 requires a virtual table */
1733 if (TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
1736 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1737 if (!TYPE_FIELD_VIRTUAL (dclass
, i
) &&
1738 has_vtable (TYPE_FIELD_TYPE (dclass
, i
)))
1739 return TYPE_FIELD_TYPE (dclass
, i
);
1744 /* Global manipulated by virtual_base_list[_aux]() */
1746 static struct vbase
*current_vbase_list
= NULL
;
1748 /* Return a pointer to a null-terminated list of struct vbase
1749 items. The vbasetype pointer of each item in the list points to the
1750 type information for a virtual base of the argument DCLASS.
1752 Helper function for virtual_base_list().
1753 Note: the list goes backward, right-to-left. virtual_base_list()
1754 copies the items out in reverse order. */
1757 virtual_base_list_aux (struct type
*dclass
)
1759 struct vbase
*tmp_vbase
;
1762 if (TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
1765 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1767 /* Recurse on this ancestor, first */
1768 virtual_base_list_aux (TYPE_FIELD_TYPE (dclass
, i
));
1770 /* If this current base is itself virtual, add it to the list */
1771 if (BASETYPE_VIA_VIRTUAL (dclass
, i
))
1773 struct type
*basetype
= TYPE_FIELD_TYPE (dclass
, i
);
1775 /* Check if base already recorded */
1776 tmp_vbase
= current_vbase_list
;
1779 if (tmp_vbase
->vbasetype
== basetype
)
1780 break; /* found it */
1781 tmp_vbase
= tmp_vbase
->next
;
1784 if (!tmp_vbase
) /* normal exit from loop */
1786 /* Allocate new item for this virtual base */
1787 tmp_vbase
= (struct vbase
*) xmalloc (sizeof (struct vbase
));
1789 /* Stick it on at the end of the list */
1790 tmp_vbase
->vbasetype
= basetype
;
1791 tmp_vbase
->next
= current_vbase_list
;
1792 current_vbase_list
= tmp_vbase
;
1795 } /* for loop over bases */
1799 /* Compute the list of virtual bases in the right order. Virtual
1800 bases are laid out in the object's memory area in order of their
1801 occurrence in a depth-first, left-to-right search through the
1804 Argument DCLASS is the type whose virtual bases are required.
1805 Return value is the address of a null-terminated array of pointers
1806 to struct type items.
1808 This routine is aimed at the HP/Taligent ANSI C++ runtime model,
1809 and may not work with other runtime models.
1811 This routine merely hands off the argument to virtual_base_list_aux()
1812 and then copies the result into an array to save space. */
1815 virtual_base_list (struct type
*dclass
)
1817 register struct vbase
*tmp_vbase
;
1818 register struct vbase
*tmp_vbase_2
;
1821 struct type
**vbase_array
;
1823 current_vbase_list
= NULL
;
1824 virtual_base_list_aux (dclass
);
1826 for (i
= 0, tmp_vbase
= current_vbase_list
; tmp_vbase
!= NULL
; i
++, tmp_vbase
= tmp_vbase
->next
)
1831 vbase_array
= (struct type
**) xmalloc ((count
+ 1) * sizeof (struct type
*));
1833 for (i
= count
- 1, tmp_vbase
= current_vbase_list
; i
>= 0; i
--, tmp_vbase
= tmp_vbase
->next
)
1834 vbase_array
[i
] = tmp_vbase
->vbasetype
;
1836 /* Get rid of constructed chain */
1837 tmp_vbase_2
= tmp_vbase
= current_vbase_list
;
1840 tmp_vbase
= tmp_vbase
->next
;
1841 xfree (tmp_vbase_2
);
1842 tmp_vbase_2
= tmp_vbase
;
1845 vbase_array
[count
] = NULL
;
1849 /* Return the length of the virtual base list of the type DCLASS. */
1852 virtual_base_list_length (struct type
*dclass
)
1855 register struct vbase
*tmp_vbase
;
1857 current_vbase_list
= NULL
;
1858 virtual_base_list_aux (dclass
);
1860 for (i
= 0, tmp_vbase
= current_vbase_list
; tmp_vbase
!= NULL
; i
++, tmp_vbase
= tmp_vbase
->next
)
1865 /* Return the number of elements of the virtual base list of the type
1866 DCLASS, ignoring those appearing in the primary base (and its
1867 primary base, recursively). */
1870 virtual_base_list_length_skip_primaries (struct type
*dclass
)
1873 register struct vbase
*tmp_vbase
;
1874 struct type
*primary
;
1876 primary
= TYPE_RUNTIME_PTR (dclass
) ? TYPE_PRIMARY_BASE (dclass
) : NULL
;
1879 return virtual_base_list_length (dclass
);
1881 current_vbase_list
= NULL
;
1882 virtual_base_list_aux (dclass
);
1884 for (i
= 0, tmp_vbase
= current_vbase_list
; tmp_vbase
!= NULL
; tmp_vbase
= tmp_vbase
->next
)
1886 if (virtual_base_index (tmp_vbase
->vbasetype
, primary
) >= 0)
1894 /* Return the index (position) of type BASE, which is a virtual base
1895 class of DCLASS, in the latter's virtual base list. A return of -1
1896 indicates "not found" or a problem. */
1899 virtual_base_index (struct type
*base
, struct type
*dclass
)
1901 register struct type
*vbase
;
1904 if ((TYPE_CODE (dclass
) != TYPE_CODE_CLASS
) ||
1905 (TYPE_CODE (base
) != TYPE_CODE_CLASS
))
1909 vbase
= virtual_base_list (dclass
)[0];
1914 vbase
= virtual_base_list (dclass
)[++i
];
1917 return vbase
? i
: -1;
1922 /* Return the index (position) of type BASE, which is a virtual base
1923 class of DCLASS, in the latter's virtual base list. Skip over all
1924 bases that may appear in the virtual base list of the primary base
1925 class of DCLASS (recursively). A return of -1 indicates "not
1926 found" or a problem. */
1929 virtual_base_index_skip_primaries (struct type
*base
, struct type
*dclass
)
1931 register struct type
*vbase
;
1933 struct type
*primary
;
1935 if ((TYPE_CODE (dclass
) != TYPE_CODE_CLASS
) ||
1936 (TYPE_CODE (base
) != TYPE_CODE_CLASS
))
1939 primary
= TYPE_RUNTIME_PTR (dclass
) ? TYPE_PRIMARY_BASE (dclass
) : NULL
;
1943 vbase
= virtual_base_list (dclass
)[0];
1946 if (!primary
|| (virtual_base_index_skip_primaries (vbase
, primary
) < 0))
1950 vbase
= virtual_base_list (dclass
)[++i
];
1953 return vbase
? j
: -1;
1956 /* Return position of a derived class DCLASS in the list of
1957 * primary bases starting with the remotest ancestor.
1958 * Position returned is 0-based. */
1961 class_index_in_primary_list (struct type
*dclass
)
1963 struct type
*pbc
; /* primary base class */
1965 /* Simply recurse on primary base */
1966 pbc
= TYPE_PRIMARY_BASE (dclass
);
1968 return 1 + class_index_in_primary_list (pbc
);
1973 /* Return a count of the number of virtual functions a type has.
1974 * This includes all the virtual functions it inherits from its
1978 /* pai: FIXME This doesn't do the right thing: count redefined virtual
1979 * functions only once (latest redefinition)
1983 count_virtual_fns (struct type
*dclass
)
1985 int fn
, oi
; /* function and overloaded instance indices */
1986 int vfuncs
; /* count to return */
1988 /* recurse on bases that can share virtual table */
1989 struct type
*pbc
= primary_base_class (dclass
);
1991 vfuncs
= count_virtual_fns (pbc
);
1995 for (fn
= 0; fn
< TYPE_NFN_FIELDS (dclass
); fn
++)
1996 for (oi
= 0; oi
< TYPE_FN_FIELDLIST_LENGTH (dclass
, fn
); oi
++)
1997 if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass
, fn
), oi
))
2005 /* Functions for overload resolution begin here */
2007 /* Compare two badness vectors A and B and return the result.
2008 * 0 => A and B are identical
2009 * 1 => A and B are incomparable
2010 * 2 => A is better than B
2011 * 3 => A is worse than B */
2014 compare_badness (struct badness_vector
*a
, struct badness_vector
*b
)
2018 short found_pos
= 0; /* any positives in c? */
2019 short found_neg
= 0; /* any negatives in c? */
2021 /* differing lengths => incomparable */
2022 if (a
->length
!= b
->length
)
2025 /* Subtract b from a */
2026 for (i
= 0; i
< a
->length
; i
++)
2028 tmp
= a
->rank
[i
] - b
->rank
[i
];
2038 return 1; /* incomparable */
2040 return 3; /* A > B */
2046 return 2; /* A < B */
2048 return 0; /* A == B */
2052 /* Rank a function by comparing its parameter types (PARMS, length NPARMS),
2053 * to the types of an argument list (ARGS, length NARGS).
2054 * Return a pointer to a badness vector. This has NARGS + 1 entries. */
2056 struct badness_vector
*
2057 rank_function (struct type
**parms
, int nparms
, struct type
**args
, int nargs
)
2060 struct badness_vector
*bv
;
2061 int min_len
= nparms
< nargs
? nparms
: nargs
;
2063 bv
= xmalloc (sizeof (struct badness_vector
));
2064 bv
->length
= nargs
+ 1; /* add 1 for the length-match rank */
2065 bv
->rank
= xmalloc ((nargs
+ 1) * sizeof (int));
2067 /* First compare the lengths of the supplied lists.
2068 * If there is a mismatch, set it to a high value. */
2070 /* pai/1997-06-03 FIXME: when we have debug info about default
2071 * arguments and ellipsis parameter lists, we should consider those
2072 * and rank the length-match more finely. */
2074 LENGTH_MATCH (bv
) = (nargs
!= nparms
) ? LENGTH_MISMATCH_BADNESS
: 0;
2076 /* Now rank all the parameters of the candidate function */
2077 for (i
= 1; i
<= min_len
; i
++)
2078 bv
->rank
[i
] = rank_one_type (parms
[i
-1], args
[i
-1]);
2080 /* If more arguments than parameters, add dummy entries */
2081 for (i
= min_len
+ 1; i
<= nargs
; i
++)
2082 bv
->rank
[i
] = TOO_FEW_PARAMS_BADNESS
;
2087 /* Compare one type (PARM) for compatibility with another (ARG).
2088 * PARM is intended to be the parameter type of a function; and
2089 * ARG is the supplied argument's type. This function tests if
2090 * the latter can be converted to the former.
2092 * Return 0 if they are identical types;
2093 * Otherwise, return an integer which corresponds to how compatible
2094 * PARM is to ARG. The higher the return value, the worse the match.
2095 * Generally the "bad" conversions are all uniformly assigned a 100 */
2098 rank_one_type (struct type
*parm
, struct type
*arg
)
2100 /* Identical type pointers */
2101 /* However, this still doesn't catch all cases of same type for arg
2102 * and param. The reason is that builtin types are different from
2103 * the same ones constructed from the object. */
2107 /* Resolve typedefs */
2108 if (TYPE_CODE (parm
) == TYPE_CODE_TYPEDEF
)
2109 parm
= check_typedef (parm
);
2110 if (TYPE_CODE (arg
) == TYPE_CODE_TYPEDEF
)
2111 arg
= check_typedef (arg
);
2114 Well, damnit, if the names are exactly the same,
2115 i'll say they are exactly the same. This happens when we generate
2116 method stubs. The types won't point to the same address, but they
2117 really are the same.
2120 if (TYPE_NAME (parm
) && TYPE_NAME (arg
) &&
2121 !strcmp (TYPE_NAME (parm
), TYPE_NAME (arg
)))
2124 /* Check if identical after resolving typedefs */
2128 /* See through references, since we can almost make non-references
2130 if (TYPE_CODE (arg
) == TYPE_CODE_REF
)
2131 return (rank_one_type (parm
, TYPE_TARGET_TYPE (arg
))
2132 + REFERENCE_CONVERSION_BADNESS
);
2133 if (TYPE_CODE (parm
) == TYPE_CODE_REF
)
2134 return (rank_one_type (TYPE_TARGET_TYPE (parm
), arg
)
2135 + REFERENCE_CONVERSION_BADNESS
);
2137 /* Debugging only. */
2138 fprintf_filtered (gdb_stderr
,"------ Arg is %s [%d], parm is %s [%d]\n",
2139 TYPE_NAME (arg
), TYPE_CODE (arg
), TYPE_NAME (parm
), TYPE_CODE (parm
));
2141 /* x -> y means arg of type x being supplied for parameter of type y */
2143 switch (TYPE_CODE (parm
))
2146 switch (TYPE_CODE (arg
))
2149 if (TYPE_CODE (TYPE_TARGET_TYPE (parm
)) == TYPE_CODE_VOID
)
2150 return VOID_PTR_CONVERSION_BADNESS
;
2152 return rank_one_type (TYPE_TARGET_TYPE (parm
), TYPE_TARGET_TYPE (arg
));
2153 case TYPE_CODE_ARRAY
:
2154 return rank_one_type (TYPE_TARGET_TYPE (parm
), TYPE_TARGET_TYPE (arg
));
2155 case TYPE_CODE_FUNC
:
2156 return rank_one_type (TYPE_TARGET_TYPE (parm
), arg
);
2158 case TYPE_CODE_ENUM
:
2159 case TYPE_CODE_CHAR
:
2160 case TYPE_CODE_RANGE
:
2161 case TYPE_CODE_BOOL
:
2162 return POINTER_CONVERSION_BADNESS
;
2164 return INCOMPATIBLE_TYPE_BADNESS
;
2166 case TYPE_CODE_ARRAY
:
2167 switch (TYPE_CODE (arg
))
2170 case TYPE_CODE_ARRAY
:
2171 return rank_one_type (TYPE_TARGET_TYPE (parm
), TYPE_TARGET_TYPE (arg
));
2173 return INCOMPATIBLE_TYPE_BADNESS
;
2175 case TYPE_CODE_FUNC
:
2176 switch (TYPE_CODE (arg
))
2178 case TYPE_CODE_PTR
: /* funcptr -> func */
2179 return rank_one_type (parm
, TYPE_TARGET_TYPE (arg
));
2181 return INCOMPATIBLE_TYPE_BADNESS
;
2184 switch (TYPE_CODE (arg
))
2187 if (TYPE_LENGTH (arg
) == TYPE_LENGTH (parm
))
2189 /* Deal with signed, unsigned, and plain chars and
2190 signed and unsigned ints */
2191 if (TYPE_NOSIGN (parm
))
2193 /* This case only for character types */
2194 if (TYPE_NOSIGN (arg
)) /* plain char -> plain char */
2197 return INTEGER_COERCION_BADNESS
; /* signed/unsigned char -> plain char */
2199 else if (TYPE_UNSIGNED (parm
))
2201 if (TYPE_UNSIGNED (arg
))
2203 if (!strcmp_iw (TYPE_NAME (parm
), TYPE_NAME (arg
)))
2204 return 0; /* unsigned int -> unsigned int, or unsigned long -> unsigned long */
2205 else if (!strcmp_iw (TYPE_NAME (arg
), "int") && !strcmp_iw (TYPE_NAME (parm
), "long"))
2206 return INTEGER_PROMOTION_BADNESS
; /* unsigned int -> unsigned long */
2208 return INTEGER_COERCION_BADNESS
; /* unsigned long -> unsigned int */
2212 if (!strcmp_iw (TYPE_NAME (arg
), "long") && !strcmp_iw (TYPE_NAME (parm
), "int"))
2213 return INTEGER_COERCION_BADNESS
; /* signed long -> unsigned int */
2215 return INTEGER_CONVERSION_BADNESS
; /* signed int/long -> unsigned int/long */
2218 else if (!TYPE_NOSIGN (arg
) && !TYPE_UNSIGNED (arg
))
2220 if (!strcmp_iw (TYPE_NAME (parm
), TYPE_NAME (arg
)))
2222 else if (!strcmp_iw (TYPE_NAME (arg
), "int") && !strcmp_iw (TYPE_NAME (parm
), "long"))
2223 return INTEGER_PROMOTION_BADNESS
;
2225 return INTEGER_COERCION_BADNESS
;
2228 return INTEGER_COERCION_BADNESS
;
2230 else if (TYPE_LENGTH (arg
) < TYPE_LENGTH (parm
))
2231 return INTEGER_PROMOTION_BADNESS
;
2233 return INTEGER_COERCION_BADNESS
;
2234 case TYPE_CODE_ENUM
:
2235 case TYPE_CODE_CHAR
:
2236 case TYPE_CODE_RANGE
:
2237 case TYPE_CODE_BOOL
:
2238 return INTEGER_PROMOTION_BADNESS
;
2240 return INT_FLOAT_CONVERSION_BADNESS
;
2242 return NS_POINTER_CONVERSION_BADNESS
;
2244 return INCOMPATIBLE_TYPE_BADNESS
;
2247 case TYPE_CODE_ENUM
:
2248 switch (TYPE_CODE (arg
))
2251 case TYPE_CODE_CHAR
:
2252 case TYPE_CODE_RANGE
:
2253 case TYPE_CODE_BOOL
:
2254 case TYPE_CODE_ENUM
:
2255 return INTEGER_COERCION_BADNESS
;
2257 return INT_FLOAT_CONVERSION_BADNESS
;
2259 return INCOMPATIBLE_TYPE_BADNESS
;
2262 case TYPE_CODE_CHAR
:
2263 switch (TYPE_CODE (arg
))
2265 case TYPE_CODE_RANGE
:
2266 case TYPE_CODE_BOOL
:
2267 case TYPE_CODE_ENUM
:
2268 return INTEGER_COERCION_BADNESS
;
2270 return INT_FLOAT_CONVERSION_BADNESS
;
2272 if (TYPE_LENGTH (arg
) > TYPE_LENGTH (parm
))
2273 return INTEGER_COERCION_BADNESS
;
2274 else if (TYPE_LENGTH (arg
) < TYPE_LENGTH (parm
))
2275 return INTEGER_PROMOTION_BADNESS
;
2276 /* >>> !! else fall through !! <<< */
2277 case TYPE_CODE_CHAR
:
2278 /* Deal with signed, unsigned, and plain chars for C++
2279 and with int cases falling through from previous case */
2280 if (TYPE_NOSIGN (parm
))
2282 if (TYPE_NOSIGN (arg
))
2285 return INTEGER_COERCION_BADNESS
;
2287 else if (TYPE_UNSIGNED (parm
))
2289 if (TYPE_UNSIGNED (arg
))
2292 return INTEGER_PROMOTION_BADNESS
;
2294 else if (!TYPE_NOSIGN (arg
) && !TYPE_UNSIGNED (arg
))
2297 return INTEGER_COERCION_BADNESS
;
2299 return INCOMPATIBLE_TYPE_BADNESS
;
2302 case TYPE_CODE_RANGE
:
2303 switch (TYPE_CODE (arg
))
2306 case TYPE_CODE_CHAR
:
2307 case TYPE_CODE_RANGE
:
2308 case TYPE_CODE_BOOL
:
2309 case TYPE_CODE_ENUM
:
2310 return INTEGER_COERCION_BADNESS
;
2312 return INT_FLOAT_CONVERSION_BADNESS
;
2314 return INCOMPATIBLE_TYPE_BADNESS
;
2317 case TYPE_CODE_BOOL
:
2318 switch (TYPE_CODE (arg
))
2321 case TYPE_CODE_CHAR
:
2322 case TYPE_CODE_RANGE
:
2323 case TYPE_CODE_ENUM
:
2326 return BOOLEAN_CONVERSION_BADNESS
;
2327 case TYPE_CODE_BOOL
:
2330 return INCOMPATIBLE_TYPE_BADNESS
;
2334 switch (TYPE_CODE (arg
))
2337 if (TYPE_LENGTH (arg
) < TYPE_LENGTH (parm
))
2338 return FLOAT_PROMOTION_BADNESS
;
2339 else if (TYPE_LENGTH (arg
) == TYPE_LENGTH (parm
))
2342 return FLOAT_CONVERSION_BADNESS
;
2344 case TYPE_CODE_BOOL
:
2345 case TYPE_CODE_ENUM
:
2346 case TYPE_CODE_RANGE
:
2347 case TYPE_CODE_CHAR
:
2348 return INT_FLOAT_CONVERSION_BADNESS
;
2350 return INCOMPATIBLE_TYPE_BADNESS
;
2353 case TYPE_CODE_COMPLEX
:
2354 switch (TYPE_CODE (arg
))
2355 { /* Strictly not needed for C++, but... */
2357 return FLOAT_PROMOTION_BADNESS
;
2358 case TYPE_CODE_COMPLEX
:
2361 return INCOMPATIBLE_TYPE_BADNESS
;
2364 case TYPE_CODE_STRUCT
:
2365 /* currently same as TYPE_CODE_CLASS */
2366 switch (TYPE_CODE (arg
))
2368 case TYPE_CODE_STRUCT
:
2369 /* Check for derivation */
2370 if (is_ancestor (parm
, arg
))
2371 return BASE_CONVERSION_BADNESS
;
2372 /* else fall through */
2374 return INCOMPATIBLE_TYPE_BADNESS
;
2377 case TYPE_CODE_UNION
:
2378 switch (TYPE_CODE (arg
))
2380 case TYPE_CODE_UNION
:
2382 return INCOMPATIBLE_TYPE_BADNESS
;
2385 case TYPE_CODE_MEMBER
:
2386 switch (TYPE_CODE (arg
))
2389 return INCOMPATIBLE_TYPE_BADNESS
;
2392 case TYPE_CODE_METHOD
:
2393 switch (TYPE_CODE (arg
))
2397 return INCOMPATIBLE_TYPE_BADNESS
;
2401 switch (TYPE_CODE (arg
))
2405 return INCOMPATIBLE_TYPE_BADNESS
;
2410 switch (TYPE_CODE (arg
))
2414 return rank_one_type (TYPE_FIELD_TYPE (parm
, 0), TYPE_FIELD_TYPE (arg
, 0));
2416 return INCOMPATIBLE_TYPE_BADNESS
;
2419 case TYPE_CODE_VOID
:
2421 return INCOMPATIBLE_TYPE_BADNESS
;
2422 } /* switch (TYPE_CODE (arg)) */
2426 /* End of functions for overload resolution */
2429 print_bit_vector (B_TYPE
*bits
, int nbits
)
2433 for (bitno
= 0; bitno
< nbits
; bitno
++)
2435 if ((bitno
% 8) == 0)
2437 puts_filtered (" ");
2439 if (B_TST (bits
, bitno
))
2441 printf_filtered ("1");
2445 printf_filtered ("0");
2450 /* The args list is a strange beast. It is either terminated by a NULL
2451 pointer for varargs functions, or by a pointer to a TYPE_CODE_VOID
2452 type for normal fixed argcount functions. (FIXME someday)
2453 Also note the first arg should be the "this" pointer, we may not want to
2454 include it since we may get into a infinitely recursive situation. */
2457 print_arg_types (struct type
**args
, int spaces
)
2461 while (*args
!= NULL
)
2463 recursive_dump_type (*args
, spaces
+ 2);
2464 if ((*args
++)->code
== TYPE_CODE_VOID
)
2473 dump_fn_fieldlists (struct type
*type
, int spaces
)
2479 printfi_filtered (spaces
, "fn_fieldlists ");
2480 gdb_print_host_address (TYPE_FN_FIELDLISTS (type
), gdb_stdout
);
2481 printf_filtered ("\n");
2482 for (method_idx
= 0; method_idx
< TYPE_NFN_FIELDS (type
); method_idx
++)
2484 f
= TYPE_FN_FIELDLIST1 (type
, method_idx
);
2485 printfi_filtered (spaces
+ 2, "[%d] name '%s' (",
2487 TYPE_FN_FIELDLIST_NAME (type
, method_idx
));
2488 gdb_print_host_address (TYPE_FN_FIELDLIST_NAME (type
, method_idx
),
2490 printf_filtered (") length %d\n",
2491 TYPE_FN_FIELDLIST_LENGTH (type
, method_idx
));
2492 for (overload_idx
= 0;
2493 overload_idx
< TYPE_FN_FIELDLIST_LENGTH (type
, method_idx
);
2496 printfi_filtered (spaces
+ 4, "[%d] physname '%s' (",
2498 TYPE_FN_FIELD_PHYSNAME (f
, overload_idx
));
2499 gdb_print_host_address (TYPE_FN_FIELD_PHYSNAME (f
, overload_idx
),
2501 printf_filtered (")\n");
2502 printfi_filtered (spaces
+ 8, "type ");
2503 gdb_print_host_address (TYPE_FN_FIELD_TYPE (f
, overload_idx
), gdb_stdout
);
2504 printf_filtered ("\n");
2506 recursive_dump_type (TYPE_FN_FIELD_TYPE (f
, overload_idx
),
2509 printfi_filtered (spaces
+ 8, "args ");
2510 gdb_print_host_address (TYPE_FN_FIELD_ARGS (f
, overload_idx
), gdb_stdout
);
2511 printf_filtered ("\n");
2513 print_arg_types (TYPE_FN_FIELD_ARGS (f
, overload_idx
), spaces
);
2514 printfi_filtered (spaces
+ 8, "fcontext ");
2515 gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f
, overload_idx
),
2517 printf_filtered ("\n");
2519 printfi_filtered (spaces
+ 8, "is_const %d\n",
2520 TYPE_FN_FIELD_CONST (f
, overload_idx
));
2521 printfi_filtered (spaces
+ 8, "is_volatile %d\n",
2522 TYPE_FN_FIELD_VOLATILE (f
, overload_idx
));
2523 printfi_filtered (spaces
+ 8, "is_private %d\n",
2524 TYPE_FN_FIELD_PRIVATE (f
, overload_idx
));
2525 printfi_filtered (spaces
+ 8, "is_protected %d\n",
2526 TYPE_FN_FIELD_PROTECTED (f
, overload_idx
));
2527 printfi_filtered (spaces
+ 8, "is_stub %d\n",
2528 TYPE_FN_FIELD_STUB (f
, overload_idx
));
2529 printfi_filtered (spaces
+ 8, "voffset %u\n",
2530 TYPE_FN_FIELD_VOFFSET (f
, overload_idx
));
2536 print_cplus_stuff (struct type
*type
, int spaces
)
2538 printfi_filtered (spaces
, "n_baseclasses %d\n",
2539 TYPE_N_BASECLASSES (type
));
2540 printfi_filtered (spaces
, "nfn_fields %d\n",
2541 TYPE_NFN_FIELDS (type
));
2542 printfi_filtered (spaces
, "nfn_fields_total %d\n",
2543 TYPE_NFN_FIELDS_TOTAL (type
));
2544 if (TYPE_N_BASECLASSES (type
) > 0)
2546 printfi_filtered (spaces
, "virtual_field_bits (%d bits at *",
2547 TYPE_N_BASECLASSES (type
));
2548 gdb_print_host_address (TYPE_FIELD_VIRTUAL_BITS (type
), gdb_stdout
);
2549 printf_filtered (")");
2551 print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type
),
2552 TYPE_N_BASECLASSES (type
));
2553 puts_filtered ("\n");
2555 if (TYPE_NFIELDS (type
) > 0)
2557 if (TYPE_FIELD_PRIVATE_BITS (type
) != NULL
)
2559 printfi_filtered (spaces
, "private_field_bits (%d bits at *",
2560 TYPE_NFIELDS (type
));
2561 gdb_print_host_address (TYPE_FIELD_PRIVATE_BITS (type
), gdb_stdout
);
2562 printf_filtered (")");
2563 print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type
),
2564 TYPE_NFIELDS (type
));
2565 puts_filtered ("\n");
2567 if (TYPE_FIELD_PROTECTED_BITS (type
) != NULL
)
2569 printfi_filtered (spaces
, "protected_field_bits (%d bits at *",
2570 TYPE_NFIELDS (type
));
2571 gdb_print_host_address (TYPE_FIELD_PROTECTED_BITS (type
), gdb_stdout
);
2572 printf_filtered (")");
2573 print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type
),
2574 TYPE_NFIELDS (type
));
2575 puts_filtered ("\n");
2578 if (TYPE_NFN_FIELDS (type
) > 0)
2580 dump_fn_fieldlists (type
, spaces
);
2584 static struct obstack dont_print_type_obstack
;
2587 recursive_dump_type (struct type
*type
, int spaces
)
2592 obstack_begin (&dont_print_type_obstack
, 0);
2594 if (TYPE_NFIELDS (type
) > 0
2595 || (TYPE_CPLUS_SPECIFIC (type
) && TYPE_NFN_FIELDS (type
) > 0))
2597 struct type
**first_dont_print
2598 = (struct type
**) obstack_base (&dont_print_type_obstack
);
2600 int i
= (struct type
**) obstack_next_free (&dont_print_type_obstack
)
2605 if (type
== first_dont_print
[i
])
2607 printfi_filtered (spaces
, "type node ");
2608 gdb_print_host_address (type
, gdb_stdout
);
2609 printf_filtered (" <same as already seen type>\n");
2614 obstack_ptr_grow (&dont_print_type_obstack
, type
);
2617 printfi_filtered (spaces
, "type node ");
2618 gdb_print_host_address (type
, gdb_stdout
);
2619 printf_filtered ("\n");
2620 printfi_filtered (spaces
, "name '%s' (",
2621 TYPE_NAME (type
) ? TYPE_NAME (type
) : "<NULL>");
2622 gdb_print_host_address (TYPE_NAME (type
), gdb_stdout
);
2623 printf_filtered (")\n");
2624 if (TYPE_TAG_NAME (type
) != NULL
)
2626 printfi_filtered (spaces
, "tagname '%s' (",
2627 TYPE_TAG_NAME (type
));
2628 gdb_print_host_address (TYPE_TAG_NAME (type
), gdb_stdout
);
2629 printf_filtered (")\n");
2631 printfi_filtered (spaces
, "code 0x%x ", TYPE_CODE (type
));
2632 switch (TYPE_CODE (type
))
2634 case TYPE_CODE_UNDEF
:
2635 printf_filtered ("(TYPE_CODE_UNDEF)");
2638 printf_filtered ("(TYPE_CODE_PTR)");
2640 case TYPE_CODE_ARRAY
:
2641 printf_filtered ("(TYPE_CODE_ARRAY)");
2643 case TYPE_CODE_STRUCT
:
2644 printf_filtered ("(TYPE_CODE_STRUCT)");
2646 case TYPE_CODE_UNION
:
2647 printf_filtered ("(TYPE_CODE_UNION)");
2649 case TYPE_CODE_ENUM
:
2650 printf_filtered ("(TYPE_CODE_ENUM)");
2652 case TYPE_CODE_FUNC
:
2653 printf_filtered ("(TYPE_CODE_FUNC)");
2656 printf_filtered ("(TYPE_CODE_INT)");
2659 printf_filtered ("(TYPE_CODE_FLT)");
2661 case TYPE_CODE_VOID
:
2662 printf_filtered ("(TYPE_CODE_VOID)");
2665 printf_filtered ("(TYPE_CODE_SET)");
2667 case TYPE_CODE_RANGE
:
2668 printf_filtered ("(TYPE_CODE_RANGE)");
2670 case TYPE_CODE_STRING
:
2671 printf_filtered ("(TYPE_CODE_STRING)");
2673 case TYPE_CODE_ERROR
:
2674 printf_filtered ("(TYPE_CODE_ERROR)");
2676 case TYPE_CODE_MEMBER
:
2677 printf_filtered ("(TYPE_CODE_MEMBER)");
2679 case TYPE_CODE_METHOD
:
2680 printf_filtered ("(TYPE_CODE_METHOD)");
2683 printf_filtered ("(TYPE_CODE_REF)");
2685 case TYPE_CODE_CHAR
:
2686 printf_filtered ("(TYPE_CODE_CHAR)");
2688 case TYPE_CODE_BOOL
:
2689 printf_filtered ("(TYPE_CODE_BOOL)");
2691 case TYPE_CODE_TYPEDEF
:
2692 printf_filtered ("(TYPE_CODE_TYPEDEF)");
2695 printf_filtered ("(UNKNOWN TYPE CODE)");
2698 puts_filtered ("\n");
2699 printfi_filtered (spaces
, "length %d\n", TYPE_LENGTH (type
));
2700 printfi_filtered (spaces
, "objfile ");
2701 gdb_print_host_address (TYPE_OBJFILE (type
), gdb_stdout
);
2702 printf_filtered ("\n");
2703 printfi_filtered (spaces
, "target_type ");
2704 gdb_print_host_address (TYPE_TARGET_TYPE (type
), gdb_stdout
);
2705 printf_filtered ("\n");
2706 if (TYPE_TARGET_TYPE (type
) != NULL
)
2708 recursive_dump_type (TYPE_TARGET_TYPE (type
), spaces
+ 2);
2710 printfi_filtered (spaces
, "pointer_type ");
2711 gdb_print_host_address (TYPE_POINTER_TYPE (type
), gdb_stdout
);
2712 printf_filtered ("\n");
2713 printfi_filtered (spaces
, "reference_type ");
2714 gdb_print_host_address (TYPE_REFERENCE_TYPE (type
), gdb_stdout
);
2715 printf_filtered ("\n");
2716 printfi_filtered (spaces
, "flags 0x%x", TYPE_FLAGS (type
));
2717 if (TYPE_FLAGS (type
) & TYPE_FLAG_UNSIGNED
)
2719 puts_filtered (" TYPE_FLAG_UNSIGNED");
2721 if (TYPE_FLAGS (type
) & TYPE_FLAG_STUB
)
2723 puts_filtered (" TYPE_FLAG_STUB");
2725 puts_filtered ("\n");
2726 printfi_filtered (spaces
, "nfields %d ", TYPE_NFIELDS (type
));
2727 gdb_print_host_address (TYPE_FIELDS (type
), gdb_stdout
);
2728 puts_filtered ("\n");
2729 for (idx
= 0; idx
< TYPE_NFIELDS (type
); idx
++)
2731 printfi_filtered (spaces
+ 2,
2732 "[%d] bitpos %d bitsize %d type ",
2733 idx
, TYPE_FIELD_BITPOS (type
, idx
),
2734 TYPE_FIELD_BITSIZE (type
, idx
));
2735 gdb_print_host_address (TYPE_FIELD_TYPE (type
, idx
), gdb_stdout
);
2736 printf_filtered (" name '%s' (",
2737 TYPE_FIELD_NAME (type
, idx
) != NULL
2738 ? TYPE_FIELD_NAME (type
, idx
)
2740 gdb_print_host_address (TYPE_FIELD_NAME (type
, idx
), gdb_stdout
);
2741 printf_filtered (")\n");
2742 if (TYPE_FIELD_TYPE (type
, idx
) != NULL
)
2744 recursive_dump_type (TYPE_FIELD_TYPE (type
, idx
), spaces
+ 4);
2747 printfi_filtered (spaces
, "vptr_basetype ");
2748 gdb_print_host_address (TYPE_VPTR_BASETYPE (type
), gdb_stdout
);
2749 puts_filtered ("\n");
2750 if (TYPE_VPTR_BASETYPE (type
) != NULL
)
2752 recursive_dump_type (TYPE_VPTR_BASETYPE (type
), spaces
+ 2);
2754 printfi_filtered (spaces
, "vptr_fieldno %d\n", TYPE_VPTR_FIELDNO (type
));
2755 switch (TYPE_CODE (type
))
2757 case TYPE_CODE_METHOD
:
2758 case TYPE_CODE_FUNC
:
2759 printfi_filtered (spaces
, "arg_types ");
2760 gdb_print_host_address (TYPE_ARG_TYPES (type
), gdb_stdout
);
2761 puts_filtered ("\n");
2762 print_arg_types (TYPE_ARG_TYPES (type
), spaces
);
2765 case TYPE_CODE_STRUCT
:
2766 printfi_filtered (spaces
, "cplus_stuff ");
2767 gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type
), gdb_stdout
);
2768 puts_filtered ("\n");
2769 print_cplus_stuff (type
, spaces
);
2773 /* We have to pick one of the union types to be able print and test
2774 the value. Pick cplus_struct_type, even though we know it isn't
2775 any particular one. */
2776 printfi_filtered (spaces
, "type_specific ");
2777 gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type
), gdb_stdout
);
2778 if (TYPE_CPLUS_SPECIFIC (type
) != NULL
)
2780 printf_filtered (" (unknown data form)");
2782 printf_filtered ("\n");
2787 obstack_free (&dont_print_type_obstack
, NULL
);
2790 static void build_gdbtypes (void);
2792 build_gdbtypes (void)
2795 init_type (TYPE_CODE_VOID
, 1,
2797 "void", (struct objfile
*) NULL
);
2799 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
2801 "char", (struct objfile
*) NULL
);
2802 TYPE_FLAGS (builtin_type_char
) |= TYPE_FLAG_NOSIGN
;
2803 builtin_type_true_char
=
2804 init_type (TYPE_CODE_CHAR
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
2806 "true character", (struct objfile
*) NULL
);
2807 builtin_type_signed_char
=
2808 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
2810 "signed char", (struct objfile
*) NULL
);
2811 builtin_type_unsigned_char
=
2812 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
2814 "unsigned char", (struct objfile
*) NULL
);
2815 builtin_type_short
=
2816 init_type (TYPE_CODE_INT
, TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
2818 "short", (struct objfile
*) NULL
);
2819 builtin_type_unsigned_short
=
2820 init_type (TYPE_CODE_INT
, TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
2822 "unsigned short", (struct objfile
*) NULL
);
2824 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
2826 "int", (struct objfile
*) NULL
);
2827 builtin_type_unsigned_int
=
2828 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
2830 "unsigned int", (struct objfile
*) NULL
);
2832 init_type (TYPE_CODE_INT
, TARGET_LONG_BIT
/ TARGET_CHAR_BIT
,
2834 "long", (struct objfile
*) NULL
);
2835 builtin_type_unsigned_long
=
2836 init_type (TYPE_CODE_INT
, TARGET_LONG_BIT
/ TARGET_CHAR_BIT
,
2838 "unsigned long", (struct objfile
*) NULL
);
2839 builtin_type_long_long
=
2840 init_type (TYPE_CODE_INT
, TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
,
2842 "long long", (struct objfile
*) NULL
);
2843 builtin_type_unsigned_long_long
=
2844 init_type (TYPE_CODE_INT
, TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
,
2846 "unsigned long long", (struct objfile
*) NULL
);
2847 builtin_type_float
=
2848 init_type (TYPE_CODE_FLT
, TARGET_FLOAT_BIT
/ TARGET_CHAR_BIT
,
2850 "float", (struct objfile
*) NULL
);
2851 builtin_type_double
=
2852 init_type (TYPE_CODE_FLT
, TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
2854 "double", (struct objfile
*) NULL
);
2855 builtin_type_long_double
=
2856 init_type (TYPE_CODE_FLT
, TARGET_LONG_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
2858 "long double", (struct objfile
*) NULL
);
2859 builtin_type_complex
=
2860 init_type (TYPE_CODE_COMPLEX
, 2 * TARGET_FLOAT_BIT
/ TARGET_CHAR_BIT
,
2862 "complex", (struct objfile
*) NULL
);
2863 TYPE_TARGET_TYPE (builtin_type_complex
) = builtin_type_float
;
2864 builtin_type_double_complex
=
2865 init_type (TYPE_CODE_COMPLEX
, 2 * TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
2867 "double complex", (struct objfile
*) NULL
);
2868 TYPE_TARGET_TYPE (builtin_type_double_complex
) = builtin_type_double
;
2869 builtin_type_string
=
2870 init_type (TYPE_CODE_STRING
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
2872 "string", (struct objfile
*) NULL
);
2874 init_type (TYPE_CODE_INT
, 8 / 8,
2876 "int8_t", (struct objfile
*) NULL
);
2877 builtin_type_uint8
=
2878 init_type (TYPE_CODE_INT
, 8 / 8,
2880 "uint8_t", (struct objfile
*) NULL
);
2881 builtin_type_int16
=
2882 init_type (TYPE_CODE_INT
, 16 / 8,
2884 "int16_t", (struct objfile
*) NULL
);
2885 builtin_type_uint16
=
2886 init_type (TYPE_CODE_INT
, 16 / 8,
2888 "uint16_t", (struct objfile
*) NULL
);
2889 builtin_type_int32
=
2890 init_type (TYPE_CODE_INT
, 32 / 8,
2892 "int32_t", (struct objfile
*) NULL
);
2893 builtin_type_uint32
=
2894 init_type (TYPE_CODE_INT
, 32 / 8,
2896 "uint32_t", (struct objfile
*) NULL
);
2897 builtin_type_int64
=
2898 init_type (TYPE_CODE_INT
, 64 / 8,
2900 "int64_t", (struct objfile
*) NULL
);
2901 builtin_type_uint64
=
2902 init_type (TYPE_CODE_INT
, 64 / 8,
2904 "uint64_t", (struct objfile
*) NULL
);
2906 init_type (TYPE_CODE_BOOL
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
2908 "bool", (struct objfile
*) NULL
);
2910 /* Add user knob for controlling resolution of opaque types */
2912 (add_set_cmd ("opaque-type-resolution", class_support
, var_boolean
, (char *) &opaque_type_resolution
,
2913 "Set resolution of opaque struct/class/union types (if set before loading symbols).",
2916 opaque_type_resolution
= 1;
2919 /* Build SIMD types. */
2921 = init_simd_type ("__builtin_v4sf", builtin_type_float
, "f", 4);
2923 = init_simd_type ("__builtin_v4si", builtin_type_int32
, "f", 4);
2925 = init_simd_type ("__builtin_v8qi", builtin_type_int8
, "f", 8);
2927 = init_simd_type ("__builtin_v4hi", builtin_type_int16
, "f", 4);
2929 = init_simd_type ("__builtin_v2si", builtin_type_int32
, "f", 2);
2931 /* Pointer/Address types. */
2933 /* NOTE: on some targets, addresses and pointers are not necessarily
2934 the same --- for example, on the D10V, pointers are 16 bits long,
2935 but addresses are 32 bits long. See doc/gdbint.texinfo,
2936 ``Pointers Are Not Always Addresses''.
2939 - gdb's `struct type' always describes the target's
2941 - gdb's `struct value' objects should always hold values in
2943 - gdb's CORE_ADDR values are addresses in the unified virtual
2944 address space that the assembler and linker work with. Thus,
2945 since target_read_memory takes a CORE_ADDR as an argument, it
2946 can access any memory on the target, even if the processor has
2947 separate code and data address spaces.
2950 - If v is a value holding a D10V code pointer, its contents are
2951 in target form: a big-endian address left-shifted two bits.
2952 - If p is a D10V pointer type, TYPE_LENGTH (p) == 2, just as
2953 sizeof (void *) == 2 on the target.
2955 In this context, builtin_type_CORE_ADDR is a bit odd: it's a
2956 target type for a value the target will never see. It's only
2957 used to hold the values of (typeless) linker symbols, which are
2958 indeed in the unified virtual address space. */
2959 builtin_type_void_data_ptr
= make_pointer_type (builtin_type_void
, NULL
);
2960 builtin_type_void_func_ptr
2961 = lookup_pointer_type (lookup_function_type (builtin_type_void
));
2962 builtin_type_CORE_ADDR
=
2963 init_type (TYPE_CODE_INT
, TARGET_ADDR_BIT
/ 8,
2965 "__CORE_ADDR", (struct objfile
*) NULL
);
2966 builtin_type_bfd_vma
=
2967 init_type (TYPE_CODE_INT
, TARGET_BFD_VMA_BIT
/ 8,
2969 "__bfd_vma", (struct objfile
*) NULL
);
2973 extern void _initialize_gdbtypes (void);
2975 _initialize_gdbtypes (void)
2977 struct cmd_list_element
*c
;
2980 /* FIXME - For the moment, handle types by swapping them in and out.
2981 Should be using the per-architecture data-pointer and a large
2983 register_gdbarch_swap (&builtin_type_void
, sizeof (struct type
*), NULL
);
2984 register_gdbarch_swap (&builtin_type_char
, sizeof (struct type
*), NULL
);
2985 register_gdbarch_swap (&builtin_type_short
, sizeof (struct type
*), NULL
);
2986 register_gdbarch_swap (&builtin_type_int
, sizeof (struct type
*), NULL
);
2987 register_gdbarch_swap (&builtin_type_long
, sizeof (struct type
*), NULL
);
2988 register_gdbarch_swap (&builtin_type_long_long
, sizeof (struct type
*), NULL
);
2989 register_gdbarch_swap (&builtin_type_signed_char
, sizeof (struct type
*), NULL
);
2990 register_gdbarch_swap (&builtin_type_unsigned_char
, sizeof (struct type
*), NULL
);
2991 register_gdbarch_swap (&builtin_type_unsigned_short
, sizeof (struct type
*), NULL
);
2992 register_gdbarch_swap (&builtin_type_unsigned_int
, sizeof (struct type
*), NULL
);
2993 register_gdbarch_swap (&builtin_type_unsigned_long
, sizeof (struct type
*), NULL
);
2994 register_gdbarch_swap (&builtin_type_unsigned_long_long
, sizeof (struct type
*), NULL
);
2995 register_gdbarch_swap (&builtin_type_float
, sizeof (struct type
*), NULL
);
2996 register_gdbarch_swap (&builtin_type_double
, sizeof (struct type
*), NULL
);
2997 register_gdbarch_swap (&builtin_type_long_double
, sizeof (struct type
*), NULL
);
2998 register_gdbarch_swap (&builtin_type_complex
, sizeof (struct type
*), NULL
);
2999 register_gdbarch_swap (&builtin_type_double_complex
, sizeof (struct type
*), NULL
);
3000 register_gdbarch_swap (&builtin_type_string
, sizeof (struct type
*), NULL
);
3001 register_gdbarch_swap (&builtin_type_int8
, sizeof (struct type
*), NULL
);
3002 register_gdbarch_swap (&builtin_type_uint8
, sizeof (struct type
*), NULL
);
3003 register_gdbarch_swap (&builtin_type_int16
, sizeof (struct type
*), NULL
);
3004 register_gdbarch_swap (&builtin_type_uint16
, sizeof (struct type
*), NULL
);
3005 register_gdbarch_swap (&builtin_type_int32
, sizeof (struct type
*), NULL
);
3006 register_gdbarch_swap (&builtin_type_uint32
, sizeof (struct type
*), NULL
);
3007 register_gdbarch_swap (&builtin_type_int64
, sizeof (struct type
*), NULL
);
3008 register_gdbarch_swap (&builtin_type_uint64
, sizeof (struct type
*), NULL
);
3009 register_gdbarch_swap (&builtin_type_v4sf
, sizeof (struct type
*), NULL
);
3010 register_gdbarch_swap (&builtin_type_v4si
, sizeof (struct type
*), NULL
);
3011 register_gdbarch_swap (&builtin_type_v8qi
, sizeof (struct type
*), NULL
);
3012 register_gdbarch_swap (&builtin_type_v4hi
, sizeof (struct type
*), NULL
);
3013 register_gdbarch_swap (&builtin_type_v2si
, sizeof (struct type
*), NULL
);
3014 REGISTER_GDBARCH_SWAP (builtin_type_void_data_ptr
);
3015 REGISTER_GDBARCH_SWAP (builtin_type_void_func_ptr
);
3016 REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR
);
3017 REGISTER_GDBARCH_SWAP (builtin_type_bfd_vma
);
3018 register_gdbarch_swap (NULL
, 0, build_gdbtypes
);
3021 add_set_cmd ("overload", no_class
, var_zinteger
, (char *) &overload_debug
,
3022 "Set debugging of C++ overloading.\n\
3023 When enabled, ranking of the functions\n\
3024 is displayed.", &setdebuglist
),