1 /* Support routines for manipulating internal types for GDB.
2 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
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"
39 #include "gdb_assert.h"
41 /* These variables point to the objects
42 representing the predefined C data types. */
44 struct type
*builtin_type_void
;
45 struct type
*builtin_type_char
;
46 struct type
*builtin_type_true_char
;
47 struct type
*builtin_type_short
;
48 struct type
*builtin_type_int
;
49 struct type
*builtin_type_long
;
50 struct type
*builtin_type_long_long
;
51 struct type
*builtin_type_signed_char
;
52 struct type
*builtin_type_unsigned_char
;
53 struct type
*builtin_type_unsigned_short
;
54 struct type
*builtin_type_unsigned_int
;
55 struct type
*builtin_type_unsigned_long
;
56 struct type
*builtin_type_unsigned_long_long
;
57 struct type
*builtin_type_float
;
58 struct type
*builtin_type_double
;
59 struct type
*builtin_type_long_double
;
60 struct type
*builtin_type_complex
;
61 struct type
*builtin_type_double_complex
;
62 struct type
*builtin_type_string
;
63 struct type
*builtin_type_int8
;
64 struct type
*builtin_type_uint8
;
65 struct type
*builtin_type_int16
;
66 struct type
*builtin_type_uint16
;
67 struct type
*builtin_type_int32
;
68 struct type
*builtin_type_uint32
;
69 struct type
*builtin_type_int64
;
70 struct type
*builtin_type_uint64
;
71 struct type
*builtin_type_int128
;
72 struct type
*builtin_type_uint128
;
73 struct type
*builtin_type_bool
;
75 /* 128 bit long vector types */
76 struct type
*builtin_type_v2_double
;
77 struct type
*builtin_type_v4_float
;
78 struct type
*builtin_type_v2_int64
;
79 struct type
*builtin_type_v4_int32
;
80 struct type
*builtin_type_v8_int16
;
81 struct type
*builtin_type_v16_int8
;
82 /* 64 bit long vector types */
83 struct type
*builtin_type_v2_float
;
84 struct type
*builtin_type_v2_int32
;
85 struct type
*builtin_type_v4_int16
;
86 struct type
*builtin_type_v8_int8
;
88 struct type
*builtin_type_v4sf
;
89 struct type
*builtin_type_v4si
;
90 struct type
*builtin_type_v16qi
;
91 struct type
*builtin_type_v8qi
;
92 struct type
*builtin_type_v8hi
;
93 struct type
*builtin_type_v4hi
;
94 struct type
*builtin_type_v2si
;
95 struct type
*builtin_type_vec64
;
96 struct type
*builtin_type_vec64i
;
97 struct type
*builtin_type_vec128
;
98 struct type
*builtin_type_vec128i
;
99 struct type
*builtin_type_ieee_single_big
;
100 struct type
*builtin_type_ieee_single_little
;
101 struct type
*builtin_type_ieee_double_big
;
102 struct type
*builtin_type_ieee_double_little
;
103 struct type
*builtin_type_ieee_double_littlebyte_bigword
;
104 struct type
*builtin_type_i387_ext
;
105 struct type
*builtin_type_m68881_ext
;
106 struct type
*builtin_type_i960_ext
;
107 struct type
*builtin_type_m88110_ext
;
108 struct type
*builtin_type_m88110_harris_ext
;
109 struct type
*builtin_type_arm_ext_big
;
110 struct type
*builtin_type_arm_ext_littlebyte_bigword
;
111 struct type
*builtin_type_ia64_spill_big
;
112 struct type
*builtin_type_ia64_spill_little
;
113 struct type
*builtin_type_ia64_quad_big
;
114 struct type
*builtin_type_ia64_quad_little
;
115 struct type
*builtin_type_void_data_ptr
;
116 struct type
*builtin_type_void_func_ptr
;
117 struct type
*builtin_type_CORE_ADDR
;
118 struct type
*builtin_type_bfd_vma
;
120 int opaque_type_resolution
= 1;
121 int overload_debug
= 0;
127 }; /* maximum extension is 128! FIXME */
129 static void add_name (struct extra
*, char *);
130 static void add_mangled_type (struct extra
*, struct type
*);
132 static void cfront_mangle_name (struct type
*, int, int);
134 static void print_bit_vector (B_TYPE
*, int);
135 static void print_arg_types (struct field
*, int, int);
136 static void dump_fn_fieldlists (struct type
*, int);
137 static void print_cplus_stuff (struct type
*, int);
138 static void virtual_base_list_aux (struct type
*dclass
);
141 /* Alloc a new type structure and fill it with some defaults. If
142 OBJFILE is non-NULL, then allocate the space for the type structure
143 in that objfile's type_obstack. Otherwise allocate the new type structure
144 by xmalloc () (for permanent types). */
147 alloc_type (struct objfile
*objfile
)
149 register struct type
*type
;
151 /* Alloc the structure and start off with all fields zeroed. */
155 type
= xmalloc (sizeof (struct type
));
156 memset (type
, 0, sizeof (struct type
));
157 TYPE_MAIN_TYPE (type
) = xmalloc (sizeof (struct main_type
));
161 type
= obstack_alloc (&objfile
->type_obstack
,
162 sizeof (struct type
));
163 memset (type
, 0, sizeof (struct type
));
164 TYPE_MAIN_TYPE (type
) = obstack_alloc (&objfile
->type_obstack
,
165 sizeof (struct main_type
));
166 OBJSTAT (objfile
, n_types
++);
168 memset (TYPE_MAIN_TYPE (type
), 0, sizeof (struct main_type
));
170 /* Initialize the fields that might not be zero. */
172 TYPE_CODE (type
) = TYPE_CODE_UNDEF
;
173 TYPE_OBJFILE (type
) = objfile
;
174 TYPE_VPTR_FIELDNO (type
) = -1;
175 TYPE_CHAIN (type
) = type
; /* Chain back to itself. */
180 /* Alloc a new type instance structure, fill it with some defaults,
181 and point it at OLDTYPE. Allocate the new type instance from the
182 same place as OLDTYPE. */
185 alloc_type_instance (struct type
*oldtype
)
189 /* Allocate the structure. */
191 if (TYPE_OBJFILE (oldtype
) == NULL
)
193 type
= xmalloc (sizeof (struct type
));
194 memset (type
, 0, sizeof (struct type
));
198 type
= obstack_alloc (&TYPE_OBJFILE (oldtype
)->type_obstack
,
199 sizeof (struct type
));
200 memset (type
, 0, sizeof (struct type
));
202 TYPE_MAIN_TYPE (type
) = TYPE_MAIN_TYPE (oldtype
);
204 TYPE_CHAIN (type
) = type
; /* Chain back to itself for now. */
209 /* Clear all remnants of the previous type at TYPE, in preparation for
210 replacing it with something else. */
212 smash_type (struct type
*type
)
214 memset (TYPE_MAIN_TYPE (type
), 0, sizeof (struct main_type
));
216 /* For now, delete the rings. */
217 TYPE_CHAIN (type
) = type
;
219 /* For now, leave the pointer/reference types alone. */
222 /* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points
223 to a pointer to memory where the pointer type should be stored.
224 If *TYPEPTR is zero, update it to point to the pointer type we return.
225 We allocate new memory if needed. */
228 make_pointer_type (struct type
*type
, struct type
**typeptr
)
230 register struct type
*ntype
; /* New type */
231 struct objfile
*objfile
;
233 ntype
= TYPE_POINTER_TYPE (type
);
238 return ntype
; /* Don't care about alloc, and have new type. */
239 else if (*typeptr
== 0)
241 *typeptr
= ntype
; /* Tracking alloc, and we have new type. */
246 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
248 ntype
= alloc_type (TYPE_OBJFILE (type
));
253 /* We have storage, but need to reset it. */
256 objfile
= TYPE_OBJFILE (ntype
);
258 TYPE_OBJFILE (ntype
) = objfile
;
261 TYPE_TARGET_TYPE (ntype
) = type
;
262 TYPE_POINTER_TYPE (type
) = ntype
;
264 /* FIXME! Assume the machine has only one representation for pointers! */
266 TYPE_LENGTH (ntype
) = TARGET_PTR_BIT
/ TARGET_CHAR_BIT
;
267 TYPE_CODE (ntype
) = TYPE_CODE_PTR
;
269 /* Mark pointers as unsigned. The target converts between pointers
270 and addresses (CORE_ADDRs) using POINTER_TO_ADDRESS() and
271 ADDRESS_TO_POINTER(). */
272 TYPE_FLAGS (ntype
) |= TYPE_FLAG_UNSIGNED
;
274 if (!TYPE_POINTER_TYPE (type
)) /* Remember it, if don't have one. */
275 TYPE_POINTER_TYPE (type
) = ntype
;
280 /* Given a type TYPE, return a type of pointers to that type.
281 May need to construct such a type if this is the first use. */
284 lookup_pointer_type (struct type
*type
)
286 return make_pointer_type (type
, (struct type
**) 0);
289 /* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, points
290 to a pointer to memory where the reference type should be stored.
291 If *TYPEPTR is zero, update it to point to the reference type we return.
292 We allocate new memory if needed. */
295 make_reference_type (struct type
*type
, struct type
**typeptr
)
297 register struct type
*ntype
; /* New type */
298 struct objfile
*objfile
;
300 ntype
= TYPE_REFERENCE_TYPE (type
);
305 return ntype
; /* Don't care about alloc, and have new type. */
306 else if (*typeptr
== 0)
308 *typeptr
= ntype
; /* Tracking alloc, and we have new type. */
313 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
315 ntype
= alloc_type (TYPE_OBJFILE (type
));
320 /* We have storage, but need to reset it. */
323 objfile
= TYPE_OBJFILE (ntype
);
325 TYPE_OBJFILE (ntype
) = objfile
;
328 TYPE_TARGET_TYPE (ntype
) = type
;
329 TYPE_REFERENCE_TYPE (type
) = ntype
;
331 /* FIXME! Assume the machine has only one representation for references,
332 and that it matches the (only) representation for pointers! */
334 TYPE_LENGTH (ntype
) = TARGET_PTR_BIT
/ TARGET_CHAR_BIT
;
335 TYPE_CODE (ntype
) = TYPE_CODE_REF
;
337 if (!TYPE_REFERENCE_TYPE (type
)) /* Remember it, if don't have one. */
338 TYPE_REFERENCE_TYPE (type
) = ntype
;
343 /* Same as above, but caller doesn't care about memory allocation details. */
346 lookup_reference_type (struct type
*type
)
348 return make_reference_type (type
, (struct type
**) 0);
351 /* Lookup a function type that returns type TYPE. TYPEPTR, if nonzero, points
352 to a pointer to memory where the function type should be stored.
353 If *TYPEPTR is zero, update it to point to the function type we return.
354 We allocate new memory if needed. */
357 make_function_type (struct type
*type
, struct type
**typeptr
)
359 register struct type
*ntype
; /* New type */
360 struct objfile
*objfile
;
362 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
364 ntype
= alloc_type (TYPE_OBJFILE (type
));
369 /* We have storage, but need to reset it. */
372 objfile
= TYPE_OBJFILE (ntype
);
374 TYPE_OBJFILE (ntype
) = objfile
;
377 TYPE_TARGET_TYPE (ntype
) = type
;
379 TYPE_LENGTH (ntype
) = 1;
380 TYPE_CODE (ntype
) = TYPE_CODE_FUNC
;
386 /* Given a type TYPE, return a type of functions that return that type.
387 May need to construct such a type if this is the first use. */
390 lookup_function_type (struct type
*type
)
392 return make_function_type (type
, (struct type
**) 0);
395 /* Identify address space identifier by name --
396 return the integer flag defined in gdbtypes.h. */
398 address_space_name_to_int (char *space_identifier
)
400 /* Check for known address space delimiters. */
401 if (!strcmp (space_identifier
, "code"))
402 return TYPE_FLAG_CODE_SPACE
;
403 else if (!strcmp (space_identifier
, "data"))
404 return TYPE_FLAG_DATA_SPACE
;
406 error ("Unknown address space specifier: \"%s\"", space_identifier
);
409 /* Identify address space identifier by integer flag as defined in
410 gdbtypes.h -- return the string version of the adress space name. */
413 address_space_int_to_name (int space_flag
)
415 if (space_flag
& TYPE_FLAG_CODE_SPACE
)
417 else if (space_flag
& TYPE_FLAG_DATA_SPACE
)
423 /* Create a new type with instance flags NEW_FLAGS, based on TYPE.
424 If STORAGE is non-NULL, create the new type instance there. */
427 make_qualified_type (struct type
*type
, int new_flags
,
428 struct type
*storage
)
434 if (TYPE_INSTANCE_FLAGS (ntype
) == new_flags
)
436 ntype
= TYPE_CHAIN (ntype
);
437 } while (ntype
!= type
);
439 /* Create a new type instance. */
441 ntype
= alloc_type_instance (type
);
445 TYPE_MAIN_TYPE (ntype
) = TYPE_MAIN_TYPE (type
);
446 TYPE_CHAIN (ntype
) = ntype
;
449 /* Pointers or references to the original type are not relevant to
451 TYPE_POINTER_TYPE (ntype
) = (struct type
*) 0;
452 TYPE_REFERENCE_TYPE (ntype
) = (struct type
*) 0;
454 /* Chain the new qualified type to the old type. */
455 TYPE_CHAIN (ntype
) = TYPE_CHAIN (type
);
456 TYPE_CHAIN (type
) = ntype
;
458 /* Now set the instance flags and return the new type. */
459 TYPE_INSTANCE_FLAGS (ntype
) = new_flags
;
464 /* Make an address-space-delimited variant of a type -- a type that
465 is identical to the one supplied except that it has an address
466 space attribute attached to it (such as "code" or "data").
468 This is for Harvard architectures. */
471 make_type_with_address_space (struct type
*type
, int space_flag
)
474 int new_flags
= ((TYPE_INSTANCE_FLAGS (type
)
475 & ~(TYPE_FLAG_CODE_SPACE
| TYPE_FLAG_DATA_SPACE
))
478 return make_qualified_type (type
, new_flags
, NULL
);
481 /* Make a "c-v" variant of a type -- a type that is identical to the
482 one supplied except that it may have const or volatile attributes
483 CNST is a flag for setting the const attribute
484 VOLTL is a flag for setting the volatile attribute
485 TYPE is the base type whose variant we are creating.
486 TYPEPTR, if nonzero, points
487 to a pointer to memory where the reference type should be stored.
488 If *TYPEPTR is zero, update it to point to the reference type we return.
489 We allocate new memory if needed. */
492 make_cv_type (int cnst
, int voltl
, struct type
*type
, struct type
**typeptr
)
494 register struct type
*ntype
; /* New type */
495 register struct type
*tmp_type
= type
; /* tmp type */
496 struct objfile
*objfile
;
498 int new_flags
= (TYPE_INSTANCE_FLAGS (type
)
499 & ~(TYPE_FLAG_CONST
| TYPE_FLAG_VOLATILE
));
502 new_flags
|= TYPE_FLAG_CONST
;
505 new_flags
|= TYPE_FLAG_VOLATILE
;
507 if (typeptr
&& *typeptr
!= NULL
)
509 /* Objfile is per-core-type. This const-qualified type had best
510 belong to the same objfile as the type it is qualifying, unless
511 we are overwriting a stub type, in which case the safest thing
512 to do is to copy the core type into the new objfile. */
514 gdb_assert (TYPE_OBJFILE (*typeptr
) == TYPE_OBJFILE (type
)
515 || TYPE_STUB (*typeptr
));
516 if (TYPE_OBJFILE (*typeptr
) != TYPE_OBJFILE (type
))
518 TYPE_MAIN_TYPE (*typeptr
)
519 = TYPE_ALLOC (*typeptr
, sizeof (struct main_type
));
520 *TYPE_MAIN_TYPE (*typeptr
)
521 = *TYPE_MAIN_TYPE (type
);
525 ntype
= make_qualified_type (type
, new_flags
, typeptr
? *typeptr
: NULL
);
533 /* Replace the contents of ntype with the type *type. This changes the
534 contents, rather than the pointer for TYPE_MAIN_TYPE (ntype); thus
535 the changes are propogated to all types in the TYPE_CHAIN.
537 In order to build recursive types, it's inevitable that we'll need
538 to update types in place --- but this sort of indiscriminate
539 smashing is ugly, and needs to be replaced with something more
540 controlled. TYPE_MAIN_TYPE is a step in this direction; it's not
541 clear if more steps are needed. */
543 replace_type (struct type
*ntype
, struct type
*type
)
545 struct type
*cv_chain
, *as_chain
, *ptr
, *ref
;
547 *TYPE_MAIN_TYPE (ntype
) = *TYPE_MAIN_TYPE (type
);
549 /* Assert that the two types have equivalent instance qualifiers.
550 This should be true for at least all of our debug readers. */
551 gdb_assert (TYPE_INSTANCE_FLAGS (ntype
) == TYPE_INSTANCE_FLAGS (type
));
554 /* Implement direct support for MEMBER_TYPE in GNU C++.
555 May need to construct such a type if this is the first use.
556 The TYPE is the type of the member. The DOMAIN is the type
557 of the aggregate that the member belongs to. */
560 lookup_member_type (struct type
*type
, struct type
*domain
)
562 register struct type
*mtype
;
564 mtype
= alloc_type (TYPE_OBJFILE (type
));
565 smash_to_member_type (mtype
, domain
, type
);
569 /* Allocate a stub method whose return type is TYPE.
570 This apparently happens for speed of symbol reading, since parsing
571 out the arguments to the method is cpu-intensive, the way we are doing
572 it. So, we will fill in arguments later.
573 This always returns a fresh type. */
576 allocate_stub_method (struct type
*type
)
580 mtype
= init_type (TYPE_CODE_METHOD
, 1, TYPE_FLAG_STUB
, NULL
,
581 TYPE_OBJFILE (type
));
582 TYPE_TARGET_TYPE (mtype
) = type
;
583 /* _DOMAIN_TYPE (mtype) = unknown yet */
587 /* Create a range type using either a blank type supplied in RESULT_TYPE,
588 or creating a new type, inheriting the objfile from INDEX_TYPE.
590 Indices will be of type INDEX_TYPE, and will range from LOW_BOUND to
591 HIGH_BOUND, inclusive.
593 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
594 sure it is TYPE_CODE_UNDEF before we bash it into a range type? */
597 create_range_type (struct type
*result_type
, struct type
*index_type
,
598 int low_bound
, int high_bound
)
600 if (result_type
== NULL
)
602 result_type
= alloc_type (TYPE_OBJFILE (index_type
));
604 TYPE_CODE (result_type
) = TYPE_CODE_RANGE
;
605 TYPE_TARGET_TYPE (result_type
) = index_type
;
606 if (TYPE_STUB (index_type
))
607 TYPE_FLAGS (result_type
) |= TYPE_FLAG_TARGET_STUB
;
609 TYPE_LENGTH (result_type
) = TYPE_LENGTH (check_typedef (index_type
));
610 TYPE_NFIELDS (result_type
) = 2;
611 TYPE_FIELDS (result_type
) = (struct field
*)
612 TYPE_ALLOC (result_type
, 2 * sizeof (struct field
));
613 memset (TYPE_FIELDS (result_type
), 0, 2 * sizeof (struct field
));
614 TYPE_FIELD_BITPOS (result_type
, 0) = low_bound
;
615 TYPE_FIELD_BITPOS (result_type
, 1) = high_bound
;
616 TYPE_FIELD_TYPE (result_type
, 0) = builtin_type_int
; /* FIXME */
617 TYPE_FIELD_TYPE (result_type
, 1) = builtin_type_int
; /* FIXME */
620 TYPE_FLAGS (result_type
) |= TYPE_FLAG_UNSIGNED
;
622 return (result_type
);
625 /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type TYPE.
626 Return 1 of type is a range type, 0 if it is discrete (and bounds
627 will fit in LONGEST), or -1 otherwise. */
630 get_discrete_bounds (struct type
*type
, LONGEST
*lowp
, LONGEST
*highp
)
632 CHECK_TYPEDEF (type
);
633 switch (TYPE_CODE (type
))
635 case TYPE_CODE_RANGE
:
636 *lowp
= TYPE_LOW_BOUND (type
);
637 *highp
= TYPE_HIGH_BOUND (type
);
640 if (TYPE_NFIELDS (type
) > 0)
642 /* The enums may not be sorted by value, so search all
646 *lowp
= *highp
= TYPE_FIELD_BITPOS (type
, 0);
647 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
649 if (TYPE_FIELD_BITPOS (type
, i
) < *lowp
)
650 *lowp
= TYPE_FIELD_BITPOS (type
, i
);
651 if (TYPE_FIELD_BITPOS (type
, i
) > *highp
)
652 *highp
= TYPE_FIELD_BITPOS (type
, i
);
655 /* Set unsigned indicator if warranted. */
658 TYPE_FLAGS (type
) |= TYPE_FLAG_UNSIGNED
;
672 if (TYPE_LENGTH (type
) > sizeof (LONGEST
)) /* Too big */
674 if (!TYPE_UNSIGNED (type
))
676 *lowp
= -(1 << (TYPE_LENGTH (type
) * TARGET_CHAR_BIT
- 1));
680 /* ... fall through for unsigned ints ... */
683 /* This round-about calculation is to avoid shifting by
684 TYPE_LENGTH (type) * TARGET_CHAR_BIT, which will not work
685 if TYPE_LENGTH (type) == sizeof (LONGEST). */
686 *highp
= 1 << (TYPE_LENGTH (type
) * TARGET_CHAR_BIT
- 1);
687 *highp
= (*highp
- 1) | *highp
;
694 /* Create an array type using either a blank type supplied in RESULT_TYPE,
695 or creating a new type, inheriting the objfile from RANGE_TYPE.
697 Elements will be of type ELEMENT_TYPE, the indices will be of type
700 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
701 sure it is TYPE_CODE_UNDEF before we bash it into an array type? */
704 create_array_type (struct type
*result_type
, struct type
*element_type
,
705 struct type
*range_type
)
707 LONGEST low_bound
, high_bound
;
709 if (result_type
== NULL
)
711 result_type
= alloc_type (TYPE_OBJFILE (range_type
));
713 TYPE_CODE (result_type
) = TYPE_CODE_ARRAY
;
714 TYPE_TARGET_TYPE (result_type
) = element_type
;
715 if (get_discrete_bounds (range_type
, &low_bound
, &high_bound
) < 0)
716 low_bound
= high_bound
= 0;
717 CHECK_TYPEDEF (element_type
);
718 TYPE_LENGTH (result_type
) =
719 TYPE_LENGTH (element_type
) * (high_bound
- low_bound
+ 1);
720 TYPE_NFIELDS (result_type
) = 1;
721 TYPE_FIELDS (result_type
) =
722 (struct field
*) TYPE_ALLOC (result_type
, sizeof (struct field
));
723 memset (TYPE_FIELDS (result_type
), 0, sizeof (struct field
));
724 TYPE_FIELD_TYPE (result_type
, 0) = range_type
;
725 TYPE_VPTR_FIELDNO (result_type
) = -1;
727 /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays */
728 if (TYPE_LENGTH (result_type
) == 0)
729 TYPE_FLAGS (result_type
) |= TYPE_FLAG_TARGET_STUB
;
731 return (result_type
);
734 /* Create a string type using either a blank type supplied in RESULT_TYPE,
735 or creating a new type. String types are similar enough to array of
736 char types that we can use create_array_type to build the basic type
737 and then bash it into a string type.
739 For fixed length strings, the range type contains 0 as the lower
740 bound and the length of the string minus one as the upper bound.
742 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
743 sure it is TYPE_CODE_UNDEF before we bash it into a string type? */
746 create_string_type (struct type
*result_type
, struct type
*range_type
)
748 result_type
= create_array_type (result_type
,
749 *current_language
->string_char_type
,
751 TYPE_CODE (result_type
) = TYPE_CODE_STRING
;
752 return (result_type
);
756 create_set_type (struct type
*result_type
, struct type
*domain_type
)
758 LONGEST low_bound
, high_bound
, bit_length
;
759 if (result_type
== NULL
)
761 result_type
= alloc_type (TYPE_OBJFILE (domain_type
));
763 TYPE_CODE (result_type
) = TYPE_CODE_SET
;
764 TYPE_NFIELDS (result_type
) = 1;
765 TYPE_FIELDS (result_type
) = (struct field
*)
766 TYPE_ALLOC (result_type
, 1 * sizeof (struct field
));
767 memset (TYPE_FIELDS (result_type
), 0, sizeof (struct field
));
769 if (!TYPE_STUB (domain_type
))
771 if (get_discrete_bounds (domain_type
, &low_bound
, &high_bound
) < 0)
772 low_bound
= high_bound
= 0;
773 bit_length
= high_bound
- low_bound
+ 1;
774 TYPE_LENGTH (result_type
)
775 = (bit_length
+ TARGET_CHAR_BIT
- 1) / TARGET_CHAR_BIT
;
777 TYPE_FIELD_TYPE (result_type
, 0) = domain_type
;
780 TYPE_FLAGS (result_type
) |= TYPE_FLAG_UNSIGNED
;
782 return (result_type
);
785 /* Construct and return a type of the form:
786 struct NAME { ELT_TYPE ELT_NAME[N]; }
787 We use these types for SIMD registers. For example, the type of
788 the SSE registers on the late x86-family processors is:
789 struct __builtin_v4sf { float f[4]; }
790 built by the function call:
791 init_simd_type ("__builtin_v4sf", builtin_type_float, "f", 4)
792 The type returned is a permanent type, allocated using malloc; it
793 doesn't live in any objfile's obstack. */
795 init_simd_type (char *name
,
796 struct type
*elt_type
,
800 struct type
*simd_type
;
801 struct type
*array_type
;
803 simd_type
= init_composite_type (name
, TYPE_CODE_STRUCT
);
804 array_type
= create_array_type (0, elt_type
,
805 create_range_type (0, builtin_type_int
,
807 append_composite_type_field (simd_type
, elt_name
, array_type
);
812 init_vector_type (struct type
*elt_type
, int n
)
814 struct type
*array_type
;
816 array_type
= create_array_type (0, elt_type
,
817 create_range_type (0, builtin_type_int
,
819 TYPE_FLAGS (array_type
) |= TYPE_FLAG_VECTOR
;
824 build_builtin_type_vec64 (void)
826 /* Construct a type for the 64 bit registers. The type we're
829 union __gdb_builtin_type_vec64
841 t
= init_composite_type ("__gdb_builtin_type_vec64", TYPE_CODE_UNION
);
842 append_composite_type_field (t
, "uint64", builtin_type_int64
);
843 append_composite_type_field (t
, "v2_float", builtin_type_v2_float
);
844 append_composite_type_field (t
, "v2_int32", builtin_type_v2_int32
);
845 append_composite_type_field (t
, "v4_int16", builtin_type_v4_int16
);
846 append_composite_type_field (t
, "v8_int8", builtin_type_v8_int8
);
848 TYPE_FLAGS (t
) |= TYPE_FLAG_VECTOR
;
849 TYPE_NAME (t
) = "builtin_type_vec64";
854 build_builtin_type_vec64i (void)
856 /* Construct a type for the 64 bit registers. The type we're
859 union __gdb_builtin_type_vec64i
870 t
= init_composite_type ("__gdb_builtin_type_vec64i", TYPE_CODE_UNION
);
871 append_composite_type_field (t
, "uint64", builtin_type_int64
);
872 append_composite_type_field (t
, "v2_int32", builtin_type_v2_int32
);
873 append_composite_type_field (t
, "v4_int16", builtin_type_v4_int16
);
874 append_composite_type_field (t
, "v8_int8", builtin_type_v8_int8
);
876 TYPE_FLAGS (t
) |= TYPE_FLAG_VECTOR
;
877 TYPE_NAME (t
) = "builtin_type_vec64i";
882 build_builtin_type_vec128 (void)
884 /* Construct a type for the 128 bit registers. The type we're
887 union __gdb_builtin_type_vec128
899 t
= init_composite_type ("__gdb_builtin_type_vec128", TYPE_CODE_UNION
);
900 append_composite_type_field (t
, "uint128", builtin_type_int128
);
901 append_composite_type_field (t
, "v4_float", builtin_type_v4_float
);
902 append_composite_type_field (t
, "v4_int32", builtin_type_v4_int32
);
903 append_composite_type_field (t
, "v8_int16", builtin_type_v8_int16
);
904 append_composite_type_field (t
, "v16_int8", builtin_type_v16_int8
);
906 TYPE_FLAGS (t
) |= TYPE_FLAG_VECTOR
;
907 TYPE_NAME (t
) = "builtin_type_vec128";
912 build_builtin_type_vec128i (void)
914 /* 128-bit Intel SIMD registers */
917 t
= init_composite_type ("__gdb_builtin_type_vec128i", TYPE_CODE_UNION
);
918 append_composite_type_field (t
, "v4_float", builtin_type_v4_float
);
919 append_composite_type_field (t
, "v2_double", builtin_type_v2_double
);
920 append_composite_type_field (t
, "v16_int8", builtin_type_v16_int8
);
921 append_composite_type_field (t
, "v8_int16", builtin_type_v8_int16
);
922 append_composite_type_field (t
, "v4_int32", builtin_type_v4_int32
);
923 append_composite_type_field (t
, "v2_int64", builtin_type_v2_int64
);
924 append_composite_type_field (t
, "uint128", builtin_type_int128
);
926 TYPE_FLAGS (t
) |= TYPE_FLAG_VECTOR
;
927 TYPE_NAME (t
) = "builtin_type_vec128i";
931 /* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE.
932 A MEMBER is a wierd thing -- it amounts to a typed offset into
933 a struct, e.g. "an int at offset 8". A MEMBER TYPE doesn't
934 include the offset (that's the value of the MEMBER itself), but does
935 include the structure type into which it points (for some reason).
937 When "smashing" the type, we preserve the objfile that the
938 old type pointed to, since we aren't changing where the type is actually
942 smash_to_member_type (struct type
*type
, struct type
*domain
,
943 struct type
*to_type
)
945 struct objfile
*objfile
;
947 objfile
= TYPE_OBJFILE (type
);
950 TYPE_OBJFILE (type
) = objfile
;
951 TYPE_TARGET_TYPE (type
) = to_type
;
952 TYPE_DOMAIN_TYPE (type
) = domain
;
953 TYPE_LENGTH (type
) = 1; /* In practice, this is never needed. */
954 TYPE_CODE (type
) = TYPE_CODE_MEMBER
;
957 /* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE.
958 METHOD just means `function that gets an extra "this" argument'.
960 When "smashing" the type, we preserve the objfile that the
961 old type pointed to, since we aren't changing where the type is actually
965 smash_to_method_type (struct type
*type
, struct type
*domain
,
966 struct type
*to_type
, struct field
*args
,
967 int nargs
, int varargs
)
969 struct objfile
*objfile
;
971 objfile
= TYPE_OBJFILE (type
);
974 TYPE_OBJFILE (type
) = objfile
;
975 TYPE_TARGET_TYPE (type
) = to_type
;
976 TYPE_DOMAIN_TYPE (type
) = domain
;
977 TYPE_FIELDS (type
) = args
;
978 TYPE_NFIELDS (type
) = nargs
;
980 TYPE_FLAGS (type
) |= TYPE_FLAG_VARARGS
;
981 TYPE_LENGTH (type
) = 1; /* In practice, this is never needed. */
982 TYPE_CODE (type
) = TYPE_CODE_METHOD
;
985 /* Return a typename for a struct/union/enum type without "struct ",
986 "union ", or "enum ". If the type has a NULL name, return NULL. */
989 type_name_no_tag (register const struct type
*type
)
991 if (TYPE_TAG_NAME (type
) != NULL
)
992 return TYPE_TAG_NAME (type
);
994 /* Is there code which expects this to return the name if there is no
995 tag name? My guess is that this is mainly used for C++ in cases where
996 the two will always be the same. */
997 return TYPE_NAME (type
);
1000 /* Lookup a primitive type named NAME.
1001 Return zero if NAME is not a primitive type. */
1004 lookup_primitive_typename (char *name
)
1006 struct type
**const *p
;
1008 for (p
= current_language
->la_builtin_type_vector
; *p
!= NULL
; p
++)
1010 if (STREQ (TYPE_NAME (**p
), name
))
1018 /* Lookup a typedef or primitive type named NAME,
1019 visible in lexical block BLOCK.
1020 If NOERR is nonzero, return zero if NAME is not suitably defined. */
1023 lookup_typename (char *name
, struct block
*block
, int noerr
)
1025 register struct symbol
*sym
;
1026 register struct type
*tmp
;
1028 sym
= lookup_symbol (name
, block
, VAR_NAMESPACE
, 0, (struct symtab
**) NULL
);
1029 if (sym
== NULL
|| SYMBOL_CLASS (sym
) != LOC_TYPEDEF
)
1031 tmp
= lookup_primitive_typename (name
);
1036 else if (!tmp
&& noerr
)
1042 error ("No type named %s.", name
);
1045 return (SYMBOL_TYPE (sym
));
1049 lookup_unsigned_typename (char *name
)
1051 char *uns
= alloca (strlen (name
) + 10);
1053 strcpy (uns
, "unsigned ");
1054 strcpy (uns
+ 9, name
);
1055 return (lookup_typename (uns
, (struct block
*) NULL
, 0));
1059 lookup_signed_typename (char *name
)
1062 char *uns
= alloca (strlen (name
) + 8);
1064 strcpy (uns
, "signed ");
1065 strcpy (uns
+ 7, name
);
1066 t
= lookup_typename (uns
, (struct block
*) NULL
, 1);
1067 /* If we don't find "signed FOO" just try again with plain "FOO". */
1070 return lookup_typename (name
, (struct block
*) NULL
, 0);
1073 /* Lookup a structure type named "struct NAME",
1074 visible in lexical block BLOCK. */
1077 lookup_struct (char *name
, struct block
*block
)
1079 register struct symbol
*sym
;
1081 sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
, 0,
1082 (struct symtab
**) NULL
);
1086 error ("No struct type named %s.", name
);
1088 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_STRUCT
)
1090 error ("This context has class, union or enum %s, not a struct.", name
);
1092 return (SYMBOL_TYPE (sym
));
1095 /* Lookup a union type named "union NAME",
1096 visible in lexical block BLOCK. */
1099 lookup_union (char *name
, struct block
*block
)
1101 register struct symbol
*sym
;
1104 sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
, 0,
1105 (struct symtab
**) NULL
);
1108 error ("No union type named %s.", name
);
1110 t
= SYMBOL_TYPE (sym
);
1112 if (TYPE_CODE (t
) == TYPE_CODE_UNION
)
1115 /* C++ unions may come out with TYPE_CODE_CLASS, but we look at
1116 * a further "declared_type" field to discover it is really a union.
1118 if (HAVE_CPLUS_STRUCT (t
))
1119 if (TYPE_DECLARED_TYPE (t
) == DECLARED_TYPE_UNION
)
1122 /* If we get here, it's not a union */
1123 error ("This context has class, struct or enum %s, not a union.", name
);
1127 /* Lookup an enum type named "enum NAME",
1128 visible in lexical block BLOCK. */
1131 lookup_enum (char *name
, struct block
*block
)
1133 register struct symbol
*sym
;
1135 sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
, 0,
1136 (struct symtab
**) NULL
);
1139 error ("No enum type named %s.", name
);
1141 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_ENUM
)
1143 error ("This context has class, struct or union %s, not an enum.", name
);
1145 return (SYMBOL_TYPE (sym
));
1148 /* Lookup a template type named "template NAME<TYPE>",
1149 visible in lexical block BLOCK. */
1152 lookup_template_type (char *name
, struct type
*type
, struct block
*block
)
1155 char *nam
= (char *) alloca (strlen (name
) + strlen (TYPE_NAME (type
)) + 4);
1158 strcat (nam
, TYPE_NAME (type
));
1159 strcat (nam
, " >"); /* FIXME, extra space still introduced in gcc? */
1161 sym
= lookup_symbol (nam
, block
, VAR_NAMESPACE
, 0, (struct symtab
**) NULL
);
1165 error ("No template type named %s.", name
);
1167 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_STRUCT
)
1169 error ("This context has class, union or enum %s, not a struct.", name
);
1171 return (SYMBOL_TYPE (sym
));
1174 /* Given a type TYPE, lookup the type of the component of type named NAME.
1176 TYPE can be either a struct or union, or a pointer or reference to a struct or
1177 union. If it is a pointer or reference, its target type is automatically used.
1178 Thus '.' and '->' are interchangable, as specified for the definitions of the
1179 expression element types STRUCTOP_STRUCT and STRUCTOP_PTR.
1181 If NOERR is nonzero, return zero if NAME is not suitably defined.
1182 If NAME is the name of a baseclass type, return that type. */
1185 lookup_struct_elt_type (struct type
*type
, char *name
, int noerr
)
1191 CHECK_TYPEDEF (type
);
1192 if (TYPE_CODE (type
) != TYPE_CODE_PTR
1193 && TYPE_CODE (type
) != TYPE_CODE_REF
)
1195 type
= TYPE_TARGET_TYPE (type
);
1198 if (TYPE_CODE (type
) != TYPE_CODE_STRUCT
&&
1199 TYPE_CODE (type
) != TYPE_CODE_UNION
)
1201 target_terminal_ours ();
1202 gdb_flush (gdb_stdout
);
1203 fprintf_unfiltered (gdb_stderr
, "Type ");
1204 type_print (type
, "", gdb_stderr
, -1);
1205 error (" is not a structure or union type.");
1209 /* FIXME: This change put in by Michael seems incorrect for the case where
1210 the structure tag name is the same as the member name. I.E. when doing
1211 "ptype bell->bar" for "struct foo { int bar; int foo; } bell;"
1216 typename
= type_name_no_tag (type
);
1217 if (typename
!= NULL
&& STREQ (typename
, name
))
1222 for (i
= TYPE_NFIELDS (type
) - 1; i
>= TYPE_N_BASECLASSES (type
); i
--)
1224 char *t_field_name
= TYPE_FIELD_NAME (type
, i
);
1226 if (t_field_name
&& (strcmp_iw (t_field_name
, name
) == 0))
1228 return TYPE_FIELD_TYPE (type
, i
);
1232 /* OK, it's not in this class. Recursively check the baseclasses. */
1233 for (i
= TYPE_N_BASECLASSES (type
) - 1; i
>= 0; i
--)
1237 t
= lookup_struct_elt_type (TYPE_BASECLASS (type
, i
), name
, noerr
);
1249 target_terminal_ours ();
1250 gdb_flush (gdb_stdout
);
1251 fprintf_unfiltered (gdb_stderr
, "Type ");
1252 type_print (type
, "", gdb_stderr
, -1);
1253 fprintf_unfiltered (gdb_stderr
, " has no component named ");
1254 fputs_filtered (name
, gdb_stderr
);
1256 return (struct type
*) -1; /* For lint */
1259 /* If possible, make the vptr_fieldno and vptr_basetype fields of TYPE
1260 valid. Callers should be aware that in some cases (for example,
1261 the type or one of its baseclasses is a stub type and we are
1262 debugging a .o file), this function will not be able to find the virtual
1263 function table pointer, and vptr_fieldno will remain -1 and vptr_basetype
1264 will remain NULL. */
1267 fill_in_vptr_fieldno (struct type
*type
)
1269 CHECK_TYPEDEF (type
);
1271 if (TYPE_VPTR_FIELDNO (type
) < 0)
1275 /* We must start at zero in case the first (and only) baseclass is
1276 virtual (and hence we cannot share the table pointer). */
1277 for (i
= 0; i
< TYPE_N_BASECLASSES (type
); i
++)
1279 struct type
*baseclass
= check_typedef (TYPE_BASECLASS (type
, i
));
1280 fill_in_vptr_fieldno (baseclass
);
1281 if (TYPE_VPTR_FIELDNO (baseclass
) >= 0)
1283 TYPE_VPTR_FIELDNO (type
) = TYPE_VPTR_FIELDNO (baseclass
);
1284 TYPE_VPTR_BASETYPE (type
) = TYPE_VPTR_BASETYPE (baseclass
);
1291 /* Find the method and field indices for the destructor in class type T.
1292 Return 1 if the destructor was found, otherwise, return 0. */
1295 get_destructor_fn_field (struct type
*t
, int *method_indexp
, int *field_indexp
)
1299 for (i
= 0; i
< TYPE_NFN_FIELDS (t
); i
++)
1302 struct fn_field
*f
= TYPE_FN_FIELDLIST1 (t
, i
);
1304 for (j
= 0; j
< TYPE_FN_FIELDLIST_LENGTH (t
, i
); j
++)
1306 if (is_destructor_name (TYPE_FN_FIELD_PHYSNAME (f
, j
)) != 0)
1317 /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989.
1319 If this is a stubbed struct (i.e. declared as struct foo *), see if
1320 we can find a full definition in some other file. If so, copy this
1321 definition, so we can use it in future. There used to be a comment (but
1322 not any code) that if we don't find a full definition, we'd set a flag
1323 so we don't spend time in the future checking the same type. That would
1324 be a mistake, though--we might load in more symbols which contain a
1325 full definition for the type.
1327 This used to be coded as a macro, but I don't think it is called
1328 often enough to merit such treatment. */
1330 struct complaint stub_noname_complaint
=
1331 {"stub type has NULL name", 0, 0};
1334 check_typedef (struct type
*type
)
1336 struct type
*orig_type
= type
;
1337 int is_const
, is_volatile
;
1339 while (TYPE_CODE (type
) == TYPE_CODE_TYPEDEF
)
1341 if (!TYPE_TARGET_TYPE (type
))
1346 /* It is dangerous to call lookup_symbol if we are currently
1347 reading a symtab. Infinite recursion is one danger. */
1348 if (currently_reading_symtab
)
1351 name
= type_name_no_tag (type
);
1352 /* FIXME: shouldn't we separately check the TYPE_NAME and the
1353 TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE
1354 as appropriate? (this code was written before TYPE_NAME and
1355 TYPE_TAG_NAME were separate). */
1358 complain (&stub_noname_complaint
);
1361 sym
= lookup_symbol (name
, 0, STRUCT_NAMESPACE
, 0,
1362 (struct symtab
**) NULL
);
1364 TYPE_TARGET_TYPE (type
) = SYMBOL_TYPE (sym
);
1366 TYPE_TARGET_TYPE (type
) = alloc_type (NULL
); /* TYPE_CODE_UNDEF */
1368 type
= TYPE_TARGET_TYPE (type
);
1371 is_const
= TYPE_CONST (type
);
1372 is_volatile
= TYPE_VOLATILE (type
);
1374 /* If this is a struct/class/union with no fields, then check whether a
1375 full definition exists somewhere else. This is for systems where a
1376 type definition with no fields is issued for such types, instead of
1377 identifying them as stub types in the first place */
1379 if (TYPE_IS_OPAQUE (type
) && opaque_type_resolution
&& !currently_reading_symtab
)
1381 char *name
= type_name_no_tag (type
);
1382 struct type
*newtype
;
1385 complain (&stub_noname_complaint
);
1388 newtype
= lookup_transparent_type (name
);
1390 make_cv_type (is_const
, is_volatile
, newtype
, &type
);
1392 /* Otherwise, rely on the stub flag being set for opaque/stubbed types */
1393 else if (TYPE_STUB (type
) && !currently_reading_symtab
)
1395 char *name
= type_name_no_tag (type
);
1396 /* FIXME: shouldn't we separately check the TYPE_NAME and the
1397 TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE
1398 as appropriate? (this code was written before TYPE_NAME and
1399 TYPE_TAG_NAME were separate). */
1403 complain (&stub_noname_complaint
);
1406 sym
= lookup_symbol (name
, 0, STRUCT_NAMESPACE
, 0, (struct symtab
**) NULL
);
1408 make_cv_type (is_const
, is_volatile
, SYMBOL_TYPE (sym
), &type
);
1411 if (TYPE_TARGET_STUB (type
))
1413 struct type
*range_type
;
1414 struct type
*target_type
= check_typedef (TYPE_TARGET_TYPE (type
));
1416 if (TYPE_STUB (target_type
) || TYPE_TARGET_STUB (target_type
))
1419 else if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
1420 && TYPE_NFIELDS (type
) == 1
1421 && (TYPE_CODE (range_type
= TYPE_FIELD_TYPE (type
, 0))
1422 == TYPE_CODE_RANGE
))
1424 /* Now recompute the length of the array type, based on its
1425 number of elements and the target type's length. */
1426 TYPE_LENGTH (type
) =
1427 ((TYPE_FIELD_BITPOS (range_type
, 1)
1428 - TYPE_FIELD_BITPOS (range_type
, 0)
1430 * TYPE_LENGTH (target_type
));
1431 TYPE_FLAGS (type
) &= ~TYPE_FLAG_TARGET_STUB
;
1433 else if (TYPE_CODE (type
) == TYPE_CODE_RANGE
)
1435 TYPE_LENGTH (type
) = TYPE_LENGTH (target_type
);
1436 TYPE_FLAGS (type
) &= ~TYPE_FLAG_TARGET_STUB
;
1439 /* Cache TYPE_LENGTH for future use. */
1440 TYPE_LENGTH (orig_type
) = TYPE_LENGTH (type
);
1444 /* New code added to support parsing of Cfront stabs strings */
1445 #define INIT_EXTRA { pextras->len=0; pextras->str[0]='\0'; }
1446 #define ADD_EXTRA(c) { pextras->str[pextras->len++]=c; }
1449 add_name (struct extra
*pextras
, char *n
)
1453 if ((nlen
= (n
? strlen (n
) : 0)) == 0)
1455 sprintf (pextras
->str
+ pextras
->len
, "%d%s", nlen
, n
);
1456 pextras
->len
= strlen (pextras
->str
);
1460 add_mangled_type (struct extra
*pextras
, struct type
*t
)
1462 enum type_code tcode
;
1466 tcode
= TYPE_CODE (t
);
1467 tlen
= TYPE_LENGTH (t
);
1468 tflags
= TYPE_FLAGS (t
);
1469 tname
= TYPE_NAME (t
);
1470 /* args of "..." seem to get mangled as "e" */
1488 if ((pname
= strrchr (tname
, 'l'), pname
) && !strcmp (pname
, "long"))
1501 static struct complaint msg
=
1502 {"Bad int type code length x%x\n", 0, 0};
1504 complain (&msg
, tlen
);
1523 static struct complaint msg
=
1524 {"Bad float type code length x%x\n", 0, 0};
1525 complain (&msg
, tlen
);
1531 /* followed by what it's a ref to */
1535 /* followed by what it's a ptr to */
1537 case TYPE_CODE_TYPEDEF
:
1539 static struct complaint msg
=
1540 {"Typedefs in overloaded functions not yet supported\n", 0, 0};
1543 /* followed by type bytes & name */
1545 case TYPE_CODE_FUNC
:
1547 /* followed by func's arg '_' & ret types */
1549 case TYPE_CODE_VOID
:
1552 case TYPE_CODE_METHOD
:
1554 /* followed by name of class and func's arg '_' & ret types */
1555 add_name (pextras
, tname
);
1556 ADD_EXTRA ('F'); /* then mangle function */
1558 case TYPE_CODE_STRUCT
: /* C struct */
1559 case TYPE_CODE_UNION
: /* C union */
1560 case TYPE_CODE_ENUM
: /* Enumeration type */
1561 /* followed by name of type */
1562 add_name (pextras
, tname
);
1565 /* errors possible types/not supported */
1566 case TYPE_CODE_CHAR
:
1567 case TYPE_CODE_ARRAY
: /* Array type */
1568 case TYPE_CODE_MEMBER
: /* Member type */
1569 case TYPE_CODE_BOOL
:
1570 case TYPE_CODE_COMPLEX
: /* Complex float */
1571 case TYPE_CODE_UNDEF
:
1572 case TYPE_CODE_SET
: /* Pascal sets */
1573 case TYPE_CODE_RANGE
:
1574 case TYPE_CODE_STRING
:
1575 case TYPE_CODE_BITSTRING
:
1576 case TYPE_CODE_ERROR
:
1579 static struct complaint msg
=
1580 {"Unknown type code x%x\n", 0, 0};
1581 complain (&msg
, tcode
);
1584 if (TYPE_TARGET_TYPE (t
))
1585 add_mangled_type (pextras
, TYPE_TARGET_TYPE (t
));
1590 cfront_mangle_name (struct type
*type
, int i
, int j
)
1593 char *mangled_name
= gdb_mangle_name (type
, i
, j
);
1595 f
= TYPE_FN_FIELDLIST1 (type
, i
); /* moved from below */
1597 /* kludge to support cfront methods - gdb expects to find "F" for
1598 ARM_mangled names, so when we mangle, we have to add it here */
1602 char *arm_mangled_name
;
1603 struct fn_field
*method
= &f
[j
];
1604 char *field_name
= TYPE_FN_FIELDLIST_NAME (type
, i
);
1605 char *physname
= TYPE_FN_FIELD_PHYSNAME (f
, j
);
1606 char *newname
= type_name_no_tag (type
);
1608 struct type
*ftype
= TYPE_FN_FIELD_TYPE (f
, j
);
1609 int nargs
= TYPE_NFIELDS (ftype
); /* number of args */
1610 struct extra extras
, *pextras
= &extras
;
1613 if (TYPE_FN_FIELD_STATIC_P (f
, j
)) /* j for sublist within this list */
1616 /* add args here! */
1617 if (nargs
<= 1) /* no args besides this */
1621 for (k
= 1; k
< nargs
; k
++)
1624 t
= TYPE_FIELD_TYPE (ftype
, k
);
1625 add_mangled_type (pextras
, t
);
1629 printf ("add_mangled_type: %s\n", extras
.str
); /* FIXME */
1630 xasprintf (&arm_mangled_name
, "%s%s", mangled_name
, extras
.str
);
1631 xfree (mangled_name
);
1632 mangled_name
= arm_mangled_name
;
1638 /* End of new code added to support parsing of Cfront stabs strings */
1640 /* Parse a type expression in the string [P..P+LENGTH). If an error occurs,
1641 silently return builtin_type_void. */
1644 safe_parse_type (char *p
, int length
)
1646 struct ui_file
*saved_gdb_stderr
;
1649 /* Suppress error messages. */
1650 saved_gdb_stderr
= gdb_stderr
;
1651 gdb_stderr
= ui_file_new ();
1653 /* Call parse_and_eval_type() without fear of longjmp()s. */
1654 if (!gdb_parse_and_eval_type (p
, length
, &type
))
1655 type
= builtin_type_void
;
1657 /* Stop suppressing error messages. */
1658 ui_file_delete (gdb_stderr
);
1659 gdb_stderr
= saved_gdb_stderr
;
1664 /* Ugly hack to convert method stubs into method types.
1666 He ain't kiddin'. This demangles the name of the method into a string
1667 including argument types, parses out each argument type, generates
1668 a string casting a zero to that type, evaluates the string, and stuffs
1669 the resulting type into an argtype vector!!! Then it knows the type
1670 of the whole function (including argument types for overloading),
1671 which info used to be in the stab's but was removed to hack back
1672 the space required for them. */
1675 check_stub_method (struct type
*type
, int method_id
, int signature_id
)
1678 char *mangled_name
= gdb_mangle_name (type
, method_id
, signature_id
);
1679 char *demangled_name
= cplus_demangle (mangled_name
,
1680 DMGL_PARAMS
| DMGL_ANSI
);
1681 char *argtypetext
, *p
;
1682 int depth
= 0, argcount
= 1;
1683 struct field
*argtypes
;
1686 /* Make sure we got back a function string that we can use. */
1688 p
= strchr (demangled_name
, '(');
1692 if (demangled_name
== NULL
|| p
== NULL
)
1693 error ("Internal: Cannot demangle mangled name `%s'.", mangled_name
);
1695 /* Now, read in the parameters that define this type. */
1700 if (*p
== '(' || *p
== '<')
1704 else if (*p
== ')' || *p
== '>')
1708 else if (*p
== ',' && depth
== 0)
1716 /* If we read one argument and it was ``void'', don't count it. */
1717 if (strncmp (argtypetext
, "(void)", 6) == 0)
1720 /* We need one extra slot, for the THIS pointer. */
1722 argtypes
= (struct field
*)
1723 TYPE_ALLOC (type
, (argcount
+ 1) * sizeof (struct field
));
1726 /* Add THIS pointer for non-static methods. */
1727 f
= TYPE_FN_FIELDLIST1 (type
, method_id
);
1728 if (TYPE_FN_FIELD_STATIC_P (f
, signature_id
))
1732 argtypes
[0].type
= lookup_pointer_type (type
);
1736 if (*p
!= ')') /* () means no args, skip while */
1741 if (depth
<= 0 && (*p
== ',' || *p
== ')'))
1743 /* Avoid parsing of ellipsis, they will be handled below.
1744 Also avoid ``void'' as above. */
1745 if (strncmp (argtypetext
, "...", p
- argtypetext
) != 0
1746 && strncmp (argtypetext
, "void", p
- argtypetext
) != 0)
1748 argtypes
[argcount
].type
=
1749 safe_parse_type (argtypetext
, p
- argtypetext
);
1752 argtypetext
= p
+ 1;
1755 if (*p
== '(' || *p
== '<')
1759 else if (*p
== ')' || *p
== '>')
1768 TYPE_FN_FIELD_PHYSNAME (f
, signature_id
) = mangled_name
;
1770 /* Now update the old "stub" type into a real type. */
1771 mtype
= TYPE_FN_FIELD_TYPE (f
, signature_id
);
1772 TYPE_DOMAIN_TYPE (mtype
) = type
;
1773 TYPE_FIELDS (mtype
) = argtypes
;
1774 TYPE_NFIELDS (mtype
) = argcount
;
1775 TYPE_FLAGS (mtype
) &= ~TYPE_FLAG_STUB
;
1776 TYPE_FN_FIELD_STUB (f
, signature_id
) = 0;
1778 TYPE_FLAGS (mtype
) |= TYPE_FLAG_VARARGS
;
1780 xfree (demangled_name
);
1783 /* This is the external interface to check_stub_method, above. This function
1784 unstubs all of the signatures for TYPE's METHOD_ID method name. After
1785 calling this function TYPE_FN_FIELD_STUB will be cleared for each signature
1786 and TYPE_FN_FIELDLIST_NAME will be correct.
1788 This function unfortunately can not die until stabs do. */
1791 check_stub_method_group (struct type
*type
, int method_id
)
1793 int len
= TYPE_FN_FIELDLIST_LENGTH (type
, method_id
);
1794 struct fn_field
*f
= TYPE_FN_FIELDLIST1 (type
, method_id
);
1795 int j
, found_stub
= 0;
1797 for (j
= 0; j
< len
; j
++)
1798 if (TYPE_FN_FIELD_STUB (f
, j
))
1801 check_stub_method (type
, method_id
, j
);
1804 /* GNU v3 methods with incorrect names were corrected when we read in
1805 type information, because it was cheaper to do it then. The only GNU v2
1806 methods with incorrect method names are operators and destructors;
1807 destructors were also corrected when we read in type information.
1809 Therefore the only thing we need to handle here are v2 operator
1811 if (found_stub
&& strncmp (TYPE_FN_FIELD_PHYSNAME (f
, 0), "_Z", 2) != 0)
1814 char dem_opname
[256];
1816 ret
= cplus_demangle_opname (TYPE_FN_FIELDLIST_NAME (type
, method_id
),
1817 dem_opname
, DMGL_ANSI
);
1819 ret
= cplus_demangle_opname (TYPE_FN_FIELDLIST_NAME (type
, method_id
),
1822 TYPE_FN_FIELDLIST_NAME (type
, method_id
) = xstrdup (dem_opname
);
1826 const struct cplus_struct_type cplus_struct_default
;
1829 allocate_cplus_struct_type (struct type
*type
)
1831 if (!HAVE_CPLUS_STRUCT (type
))
1833 TYPE_CPLUS_SPECIFIC (type
) = (struct cplus_struct_type
*)
1834 TYPE_ALLOC (type
, sizeof (struct cplus_struct_type
));
1835 *(TYPE_CPLUS_SPECIFIC (type
)) = cplus_struct_default
;
1839 /* Helper function to initialize the standard scalar types.
1841 If NAME is non-NULL and OBJFILE is non-NULL, then we make a copy
1842 of the string pointed to by name in the type_obstack for that objfile,
1843 and initialize the type name to that copy. There are places (mipsread.c
1844 in particular, where init_type is called with a NULL value for NAME). */
1847 init_type (enum type_code code
, int length
, int flags
, char *name
,
1848 struct objfile
*objfile
)
1850 register struct type
*type
;
1852 type
= alloc_type (objfile
);
1853 TYPE_CODE (type
) = code
;
1854 TYPE_LENGTH (type
) = length
;
1855 TYPE_FLAGS (type
) |= flags
;
1856 if ((name
!= NULL
) && (objfile
!= NULL
))
1859 obsavestring (name
, strlen (name
), &objfile
->type_obstack
);
1863 TYPE_NAME (type
) = name
;
1868 if (code
== TYPE_CODE_STRUCT
|| code
== TYPE_CODE_UNION
)
1870 INIT_CPLUS_SPECIFIC (type
);
1875 /* Helper function. Create an empty composite type. */
1878 init_composite_type (char *name
, enum type_code code
)
1881 gdb_assert (code
== TYPE_CODE_STRUCT
1882 || code
== TYPE_CODE_UNION
);
1883 t
= init_type (code
, 0, 0, NULL
, NULL
);
1884 TYPE_TAG_NAME (t
) = name
;
1888 /* Helper function. Append a field to a composite type. */
1891 append_composite_type_field (struct type
*t
, char *name
, struct type
*field
)
1894 TYPE_NFIELDS (t
) = TYPE_NFIELDS (t
) + 1;
1895 TYPE_FIELDS (t
) = xrealloc (TYPE_FIELDS (t
),
1896 sizeof (struct field
) * TYPE_NFIELDS (t
));
1897 f
= &(TYPE_FIELDS (t
)[TYPE_NFIELDS (t
) - 1]);
1898 memset (f
, 0, sizeof f
[0]);
1899 FIELD_TYPE (f
[0]) = field
;
1900 FIELD_NAME (f
[0]) = name
;
1901 if (TYPE_CODE (t
) == TYPE_CODE_UNION
)
1903 if (TYPE_LENGTH (t
) < TYPE_LENGTH (field
))
1904 TYPE_LENGTH (t
) = TYPE_LENGTH (field
);
1906 else if (TYPE_CODE (t
) == TYPE_CODE_STRUCT
)
1908 TYPE_LENGTH (t
) = TYPE_LENGTH (t
) + TYPE_LENGTH (field
);
1909 if (TYPE_NFIELDS (t
) > 1)
1911 FIELD_BITPOS (f
[0]) = (FIELD_BITPOS (f
[-1])
1912 + TYPE_LENGTH (field
) * TARGET_CHAR_BIT
);
1917 /* Look up a fundamental type for the specified objfile.
1918 May need to construct such a type if this is the first use.
1920 Some object file formats (ELF, COFF, etc) do not define fundamental
1921 types such as "int" or "double". Others (stabs for example), do
1922 define fundamental types.
1924 For the formats which don't provide fundamental types, gdb can create
1925 such types, using defaults reasonable for the current language and
1926 the current target machine.
1928 NOTE: This routine is obsolescent. Each debugging format reader
1929 should manage it's own fundamental types, either creating them from
1930 suitable defaults or reading them from the debugging information,
1931 whichever is appropriate. The DWARF reader has already been
1932 fixed to do this. Once the other readers are fixed, this routine
1933 will go away. Also note that fundamental types should be managed
1934 on a compilation unit basis in a multi-language environment, not
1935 on a linkage unit basis as is done here. */
1939 lookup_fundamental_type (struct objfile
*objfile
, int typeid)
1941 register struct type
**typep
;
1942 register int nbytes
;
1944 if (typeid < 0 || typeid >= FT_NUM_MEMBERS
)
1946 error ("internal error - invalid fundamental type id %d", typeid);
1949 /* If this is the first time we need a fundamental type for this objfile
1950 then we need to initialize the vector of type pointers. */
1952 if (objfile
->fundamental_types
== NULL
)
1954 nbytes
= FT_NUM_MEMBERS
* sizeof (struct type
*);
1955 objfile
->fundamental_types
= (struct type
**)
1956 obstack_alloc (&objfile
->type_obstack
, nbytes
);
1957 memset ((char *) objfile
->fundamental_types
, 0, nbytes
);
1958 OBJSTAT (objfile
, n_types
+= FT_NUM_MEMBERS
);
1961 /* Look for this particular type in the fundamental type vector. If one is
1962 not found, create and install one appropriate for the current language. */
1964 typep
= objfile
->fundamental_types
+ typeid;
1967 *typep
= create_fundamental_type (objfile
, typeid);
1974 can_dereference (struct type
*t
)
1976 /* FIXME: Should we return true for references as well as pointers? */
1980 && TYPE_CODE (t
) == TYPE_CODE_PTR
1981 && TYPE_CODE (TYPE_TARGET_TYPE (t
)) != TYPE_CODE_VOID
);
1985 is_integral_type (struct type
*t
)
1990 && ((TYPE_CODE (t
) == TYPE_CODE_INT
)
1991 || (TYPE_CODE (t
) == TYPE_CODE_ENUM
)
1992 || (TYPE_CODE (t
) == TYPE_CODE_CHAR
)
1993 || (TYPE_CODE (t
) == TYPE_CODE_RANGE
)
1994 || (TYPE_CODE (t
) == TYPE_CODE_BOOL
)));
1997 /* (OBSOLETE) Chill (OBSOLETE) varying string and arrays are
1998 represented as follows:
2000 struct { int __var_length; ELEMENT_TYPE[MAX_SIZE] __var_data};
2002 Return true if TYPE is such a (OBSOLETE) Chill (OBSOLETE) varying
2006 /* OBSOLETE chill_varying_type (struct type *type) */
2008 /* OBSOLETE if (TYPE_CODE (type) != TYPE_CODE_STRUCT */
2009 /* OBSOLETE || TYPE_NFIELDS (type) != 2 */
2010 /* OBSOLETE || strcmp (TYPE_FIELD_NAME (type, 0), "__var_length") != 0) */
2011 /* OBSOLETE return 0; */
2012 /* OBSOLETE return 1; */
2015 /* Check whether BASE is an ancestor or base class or DCLASS
2016 Return 1 if so, and 0 if not.
2017 Note: callers may want to check for identity of the types before
2018 calling this function -- identical types are considered to satisfy
2019 the ancestor relationship even if they're identical */
2022 is_ancestor (struct type
*base
, struct type
*dclass
)
2026 CHECK_TYPEDEF (base
);
2027 CHECK_TYPEDEF (dclass
);
2031 if (TYPE_NAME (base
) && TYPE_NAME (dclass
) &&
2032 !strcmp (TYPE_NAME (base
), TYPE_NAME (dclass
)))
2035 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
2036 if (is_ancestor (base
, TYPE_BASECLASS (dclass
, i
)))
2044 /* See whether DCLASS has a virtual table. This routine is aimed at
2045 the HP/Taligent ANSI C++ runtime model, and may not work with other
2046 runtime models. Return 1 => Yes, 0 => No. */
2049 has_vtable (struct type
*dclass
)
2051 /* In the HP ANSI C++ runtime model, a class has a vtable only if it
2052 has virtual functions or virtual bases. */
2056 if (TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
2059 /* First check for the presence of virtual bases */
2060 if (TYPE_FIELD_VIRTUAL_BITS (dclass
))
2061 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
2062 if (B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass
), i
))
2065 /* Next check for virtual functions */
2066 if (TYPE_FN_FIELDLISTS (dclass
))
2067 for (i
= 0; i
< TYPE_NFN_FIELDS (dclass
); i
++)
2068 if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass
, i
), 0))
2071 /* Recurse on non-virtual bases to see if any of them needs a vtable */
2072 if (TYPE_FIELD_VIRTUAL_BITS (dclass
))
2073 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
2074 if ((!B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass
), i
)) &&
2075 (has_vtable (TYPE_FIELD_TYPE (dclass
, i
))))
2078 /* Well, maybe we don't need a virtual table */
2082 /* Return a pointer to the "primary base class" of DCLASS.
2084 A NULL return indicates that DCLASS has no primary base, or that it
2085 couldn't be found (insufficient information).
2087 This routine is aimed at the HP/Taligent ANSI C++ runtime model,
2088 and may not work with other runtime models. */
2091 primary_base_class (struct type
*dclass
)
2093 /* In HP ANSI C++'s runtime model, a "primary base class" of a class
2094 is the first directly inherited, non-virtual base class that
2095 requires a virtual table */
2099 if (TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
2102 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
2103 if (!TYPE_FIELD_VIRTUAL (dclass
, i
) &&
2104 has_vtable (TYPE_FIELD_TYPE (dclass
, i
)))
2105 return TYPE_FIELD_TYPE (dclass
, i
);
2110 /* Global manipulated by virtual_base_list[_aux]() */
2112 static struct vbase
*current_vbase_list
= NULL
;
2114 /* Return a pointer to a null-terminated list of struct vbase
2115 items. The vbasetype pointer of each item in the list points to the
2116 type information for a virtual base of the argument DCLASS.
2118 Helper function for virtual_base_list().
2119 Note: the list goes backward, right-to-left. virtual_base_list()
2120 copies the items out in reverse order. */
2123 virtual_base_list_aux (struct type
*dclass
)
2125 struct vbase
*tmp_vbase
;
2128 if (TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
2131 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
2133 /* Recurse on this ancestor, first */
2134 virtual_base_list_aux (TYPE_FIELD_TYPE (dclass
, i
));
2136 /* If this current base is itself virtual, add it to the list */
2137 if (BASETYPE_VIA_VIRTUAL (dclass
, i
))
2139 struct type
*basetype
= TYPE_FIELD_TYPE (dclass
, i
);
2141 /* Check if base already recorded */
2142 tmp_vbase
= current_vbase_list
;
2145 if (tmp_vbase
->vbasetype
== basetype
)
2146 break; /* found it */
2147 tmp_vbase
= tmp_vbase
->next
;
2150 if (!tmp_vbase
) /* normal exit from loop */
2152 /* Allocate new item for this virtual base */
2153 tmp_vbase
= (struct vbase
*) xmalloc (sizeof (struct vbase
));
2155 /* Stick it on at the end of the list */
2156 tmp_vbase
->vbasetype
= basetype
;
2157 tmp_vbase
->next
= current_vbase_list
;
2158 current_vbase_list
= tmp_vbase
;
2161 } /* for loop over bases */
2165 /* Compute the list of virtual bases in the right order. Virtual
2166 bases are laid out in the object's memory area in order of their
2167 occurrence in a depth-first, left-to-right search through the
2170 Argument DCLASS is the type whose virtual bases are required.
2171 Return value is the address of a null-terminated array of pointers
2172 to struct type items.
2174 This routine is aimed at the HP/Taligent ANSI C++ runtime model,
2175 and may not work with other runtime models.
2177 This routine merely hands off the argument to virtual_base_list_aux()
2178 and then copies the result into an array to save space. */
2181 virtual_base_list (struct type
*dclass
)
2183 register struct vbase
*tmp_vbase
;
2184 register struct vbase
*tmp_vbase_2
;
2187 struct type
**vbase_array
;
2189 current_vbase_list
= NULL
;
2190 virtual_base_list_aux (dclass
);
2192 for (i
= 0, tmp_vbase
= current_vbase_list
; tmp_vbase
!= NULL
; i
++, tmp_vbase
= tmp_vbase
->next
)
2197 vbase_array
= (struct type
**) xmalloc ((count
+ 1) * sizeof (struct type
*));
2199 for (i
= count
- 1, tmp_vbase
= current_vbase_list
; i
>= 0; i
--, tmp_vbase
= tmp_vbase
->next
)
2200 vbase_array
[i
] = tmp_vbase
->vbasetype
;
2202 /* Get rid of constructed chain */
2203 tmp_vbase_2
= tmp_vbase
= current_vbase_list
;
2206 tmp_vbase
= tmp_vbase
->next
;
2207 xfree (tmp_vbase_2
);
2208 tmp_vbase_2
= tmp_vbase
;
2211 vbase_array
[count
] = NULL
;
2215 /* Return the length of the virtual base list of the type DCLASS. */
2218 virtual_base_list_length (struct type
*dclass
)
2221 register struct vbase
*tmp_vbase
;
2223 current_vbase_list
= NULL
;
2224 virtual_base_list_aux (dclass
);
2226 for (i
= 0, tmp_vbase
= current_vbase_list
; tmp_vbase
!= NULL
; i
++, tmp_vbase
= tmp_vbase
->next
)
2231 /* Return the number of elements of the virtual base list of the type
2232 DCLASS, ignoring those appearing in the primary base (and its
2233 primary base, recursively). */
2236 virtual_base_list_length_skip_primaries (struct type
*dclass
)
2239 register struct vbase
*tmp_vbase
;
2240 struct type
*primary
;
2242 primary
= TYPE_RUNTIME_PTR (dclass
) ? TYPE_PRIMARY_BASE (dclass
) : NULL
;
2245 return virtual_base_list_length (dclass
);
2247 current_vbase_list
= NULL
;
2248 virtual_base_list_aux (dclass
);
2250 for (i
= 0, tmp_vbase
= current_vbase_list
; tmp_vbase
!= NULL
; tmp_vbase
= tmp_vbase
->next
)
2252 if (virtual_base_index (tmp_vbase
->vbasetype
, primary
) >= 0)
2260 /* Return the index (position) of type BASE, which is a virtual base
2261 class of DCLASS, in the latter's virtual base list. A return of -1
2262 indicates "not found" or a problem. */
2265 virtual_base_index (struct type
*base
, struct type
*dclass
)
2267 register struct type
*vbase
;
2270 if ((TYPE_CODE (dclass
) != TYPE_CODE_CLASS
) ||
2271 (TYPE_CODE (base
) != TYPE_CODE_CLASS
))
2275 vbase
= virtual_base_list (dclass
)[0];
2280 vbase
= virtual_base_list (dclass
)[++i
];
2283 return vbase
? i
: -1;
2288 /* Return the index (position) of type BASE, which is a virtual base
2289 class of DCLASS, in the latter's virtual base list. Skip over all
2290 bases that may appear in the virtual base list of the primary base
2291 class of DCLASS (recursively). A return of -1 indicates "not
2292 found" or a problem. */
2295 virtual_base_index_skip_primaries (struct type
*base
, struct type
*dclass
)
2297 register struct type
*vbase
;
2299 struct type
*primary
;
2301 if ((TYPE_CODE (dclass
) != TYPE_CODE_CLASS
) ||
2302 (TYPE_CODE (base
) != TYPE_CODE_CLASS
))
2305 primary
= TYPE_RUNTIME_PTR (dclass
) ? TYPE_PRIMARY_BASE (dclass
) : NULL
;
2309 vbase
= virtual_base_list (dclass
)[0];
2312 if (!primary
|| (virtual_base_index_skip_primaries (vbase
, primary
) < 0))
2316 vbase
= virtual_base_list (dclass
)[++i
];
2319 return vbase
? j
: -1;
2322 /* Return position of a derived class DCLASS in the list of
2323 * primary bases starting with the remotest ancestor.
2324 * Position returned is 0-based. */
2327 class_index_in_primary_list (struct type
*dclass
)
2329 struct type
*pbc
; /* primary base class */
2331 /* Simply recurse on primary base */
2332 pbc
= TYPE_PRIMARY_BASE (dclass
);
2334 return 1 + class_index_in_primary_list (pbc
);
2339 /* Return a count of the number of virtual functions a type has.
2340 * This includes all the virtual functions it inherits from its
2344 /* pai: FIXME This doesn't do the right thing: count redefined virtual
2345 * functions only once (latest redefinition)
2349 count_virtual_fns (struct type
*dclass
)
2351 int fn
, oi
; /* function and overloaded instance indices */
2352 int vfuncs
; /* count to return */
2354 /* recurse on bases that can share virtual table */
2355 struct type
*pbc
= primary_base_class (dclass
);
2357 vfuncs
= count_virtual_fns (pbc
);
2361 for (fn
= 0; fn
< TYPE_NFN_FIELDS (dclass
); fn
++)
2362 for (oi
= 0; oi
< TYPE_FN_FIELDLIST_LENGTH (dclass
, fn
); oi
++)
2363 if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass
, fn
), oi
))
2371 /* Functions for overload resolution begin here */
2373 /* Compare two badness vectors A and B and return the result.
2374 * 0 => A and B are identical
2375 * 1 => A and B are incomparable
2376 * 2 => A is better than B
2377 * 3 => A is worse than B */
2380 compare_badness (struct badness_vector
*a
, struct badness_vector
*b
)
2384 short found_pos
= 0; /* any positives in c? */
2385 short found_neg
= 0; /* any negatives in c? */
2387 /* differing lengths => incomparable */
2388 if (a
->length
!= b
->length
)
2391 /* Subtract b from a */
2392 for (i
= 0; i
< a
->length
; i
++)
2394 tmp
= a
->rank
[i
] - b
->rank
[i
];
2404 return 1; /* incomparable */
2406 return 3; /* A > B */
2412 return 2; /* A < B */
2414 return 0; /* A == B */
2418 /* Rank a function by comparing its parameter types (PARMS, length NPARMS),
2419 * to the types of an argument list (ARGS, length NARGS).
2420 * Return a pointer to a badness vector. This has NARGS + 1 entries. */
2422 struct badness_vector
*
2423 rank_function (struct type
**parms
, int nparms
, struct type
**args
, int nargs
)
2426 struct badness_vector
*bv
;
2427 int min_len
= nparms
< nargs
? nparms
: nargs
;
2429 bv
= xmalloc (sizeof (struct badness_vector
));
2430 bv
->length
= nargs
+ 1; /* add 1 for the length-match rank */
2431 bv
->rank
= xmalloc ((nargs
+ 1) * sizeof (int));
2433 /* First compare the lengths of the supplied lists.
2434 * If there is a mismatch, set it to a high value. */
2436 /* pai/1997-06-03 FIXME: when we have debug info about default
2437 * arguments and ellipsis parameter lists, we should consider those
2438 * and rank the length-match more finely. */
2440 LENGTH_MATCH (bv
) = (nargs
!= nparms
) ? LENGTH_MISMATCH_BADNESS
: 0;
2442 /* Now rank all the parameters of the candidate function */
2443 for (i
= 1; i
<= min_len
; i
++)
2444 bv
->rank
[i
] = rank_one_type (parms
[i
-1], args
[i
-1]);
2446 /* If more arguments than parameters, add dummy entries */
2447 for (i
= min_len
+ 1; i
<= nargs
; i
++)
2448 bv
->rank
[i
] = TOO_FEW_PARAMS_BADNESS
;
2453 /* Compare one type (PARM) for compatibility with another (ARG).
2454 * PARM is intended to be the parameter type of a function; and
2455 * ARG is the supplied argument's type. This function tests if
2456 * the latter can be converted to the former.
2458 * Return 0 if they are identical types;
2459 * Otherwise, return an integer which corresponds to how compatible
2460 * PARM is to ARG. The higher the return value, the worse the match.
2461 * Generally the "bad" conversions are all uniformly assigned a 100 */
2464 rank_one_type (struct type
*parm
, struct type
*arg
)
2466 /* Identical type pointers */
2467 /* However, this still doesn't catch all cases of same type for arg
2468 * and param. The reason is that builtin types are different from
2469 * the same ones constructed from the object. */
2473 /* Resolve typedefs */
2474 if (TYPE_CODE (parm
) == TYPE_CODE_TYPEDEF
)
2475 parm
= check_typedef (parm
);
2476 if (TYPE_CODE (arg
) == TYPE_CODE_TYPEDEF
)
2477 arg
= check_typedef (arg
);
2480 Well, damnit, if the names are exactly the same,
2481 i'll say they are exactly the same. This happens when we generate
2482 method stubs. The types won't point to the same address, but they
2483 really are the same.
2486 if (TYPE_NAME (parm
) && TYPE_NAME (arg
) &&
2487 !strcmp (TYPE_NAME (parm
), TYPE_NAME (arg
)))
2490 /* Check if identical after resolving typedefs */
2494 /* See through references, since we can almost make non-references
2496 if (TYPE_CODE (arg
) == TYPE_CODE_REF
)
2497 return (rank_one_type (parm
, TYPE_TARGET_TYPE (arg
))
2498 + REFERENCE_CONVERSION_BADNESS
);
2499 if (TYPE_CODE (parm
) == TYPE_CODE_REF
)
2500 return (rank_one_type (TYPE_TARGET_TYPE (parm
), arg
)
2501 + REFERENCE_CONVERSION_BADNESS
);
2503 /* Debugging only. */
2504 fprintf_filtered (gdb_stderr
,"------ Arg is %s [%d], parm is %s [%d]\n",
2505 TYPE_NAME (arg
), TYPE_CODE (arg
), TYPE_NAME (parm
), TYPE_CODE (parm
));
2507 /* x -> y means arg of type x being supplied for parameter of type y */
2509 switch (TYPE_CODE (parm
))
2512 switch (TYPE_CODE (arg
))
2515 if (TYPE_CODE (TYPE_TARGET_TYPE (parm
)) == TYPE_CODE_VOID
)
2516 return VOID_PTR_CONVERSION_BADNESS
;
2518 return rank_one_type (TYPE_TARGET_TYPE (parm
), TYPE_TARGET_TYPE (arg
));
2519 case TYPE_CODE_ARRAY
:
2520 return rank_one_type (TYPE_TARGET_TYPE (parm
), TYPE_TARGET_TYPE (arg
));
2521 case TYPE_CODE_FUNC
:
2522 return rank_one_type (TYPE_TARGET_TYPE (parm
), arg
);
2524 case TYPE_CODE_ENUM
:
2525 case TYPE_CODE_CHAR
:
2526 case TYPE_CODE_RANGE
:
2527 case TYPE_CODE_BOOL
:
2528 return POINTER_CONVERSION_BADNESS
;
2530 return INCOMPATIBLE_TYPE_BADNESS
;
2532 case TYPE_CODE_ARRAY
:
2533 switch (TYPE_CODE (arg
))
2536 case TYPE_CODE_ARRAY
:
2537 return rank_one_type (TYPE_TARGET_TYPE (parm
), TYPE_TARGET_TYPE (arg
));
2539 return INCOMPATIBLE_TYPE_BADNESS
;
2541 case TYPE_CODE_FUNC
:
2542 switch (TYPE_CODE (arg
))
2544 case TYPE_CODE_PTR
: /* funcptr -> func */
2545 return rank_one_type (parm
, TYPE_TARGET_TYPE (arg
));
2547 return INCOMPATIBLE_TYPE_BADNESS
;
2550 switch (TYPE_CODE (arg
))
2553 if (TYPE_LENGTH (arg
) == TYPE_LENGTH (parm
))
2555 /* Deal with signed, unsigned, and plain chars and
2556 signed and unsigned ints */
2557 if (TYPE_NOSIGN (parm
))
2559 /* This case only for character types */
2560 if (TYPE_NOSIGN (arg
)) /* plain char -> plain char */
2563 return INTEGER_COERCION_BADNESS
; /* signed/unsigned char -> plain char */
2565 else if (TYPE_UNSIGNED (parm
))
2567 if (TYPE_UNSIGNED (arg
))
2569 if (!strcmp_iw (TYPE_NAME (parm
), TYPE_NAME (arg
)))
2570 return 0; /* unsigned int -> unsigned int, or unsigned long -> unsigned long */
2571 else if (!strcmp_iw (TYPE_NAME (arg
), "int") && !strcmp_iw (TYPE_NAME (parm
), "long"))
2572 return INTEGER_PROMOTION_BADNESS
; /* unsigned int -> unsigned long */
2574 return INTEGER_COERCION_BADNESS
; /* unsigned long -> unsigned int */
2578 if (!strcmp_iw (TYPE_NAME (arg
), "long") && !strcmp_iw (TYPE_NAME (parm
), "int"))
2579 return INTEGER_COERCION_BADNESS
; /* signed long -> unsigned int */
2581 return INTEGER_CONVERSION_BADNESS
; /* signed int/long -> unsigned int/long */
2584 else if (!TYPE_NOSIGN (arg
) && !TYPE_UNSIGNED (arg
))
2586 if (!strcmp_iw (TYPE_NAME (parm
), TYPE_NAME (arg
)))
2588 else if (!strcmp_iw (TYPE_NAME (arg
), "int") && !strcmp_iw (TYPE_NAME (parm
), "long"))
2589 return INTEGER_PROMOTION_BADNESS
;
2591 return INTEGER_COERCION_BADNESS
;
2594 return INTEGER_COERCION_BADNESS
;
2596 else if (TYPE_LENGTH (arg
) < TYPE_LENGTH (parm
))
2597 return INTEGER_PROMOTION_BADNESS
;
2599 return INTEGER_COERCION_BADNESS
;
2600 case TYPE_CODE_ENUM
:
2601 case TYPE_CODE_CHAR
:
2602 case TYPE_CODE_RANGE
:
2603 case TYPE_CODE_BOOL
:
2604 return INTEGER_PROMOTION_BADNESS
;
2606 return INT_FLOAT_CONVERSION_BADNESS
;
2608 return NS_POINTER_CONVERSION_BADNESS
;
2610 return INCOMPATIBLE_TYPE_BADNESS
;
2613 case TYPE_CODE_ENUM
:
2614 switch (TYPE_CODE (arg
))
2617 case TYPE_CODE_CHAR
:
2618 case TYPE_CODE_RANGE
:
2619 case TYPE_CODE_BOOL
:
2620 case TYPE_CODE_ENUM
:
2621 return INTEGER_COERCION_BADNESS
;
2623 return INT_FLOAT_CONVERSION_BADNESS
;
2625 return INCOMPATIBLE_TYPE_BADNESS
;
2628 case TYPE_CODE_CHAR
:
2629 switch (TYPE_CODE (arg
))
2631 case TYPE_CODE_RANGE
:
2632 case TYPE_CODE_BOOL
:
2633 case TYPE_CODE_ENUM
:
2634 return INTEGER_COERCION_BADNESS
;
2636 return INT_FLOAT_CONVERSION_BADNESS
;
2638 if (TYPE_LENGTH (arg
) > TYPE_LENGTH (parm
))
2639 return INTEGER_COERCION_BADNESS
;
2640 else if (TYPE_LENGTH (arg
) < TYPE_LENGTH (parm
))
2641 return INTEGER_PROMOTION_BADNESS
;
2642 /* >>> !! else fall through !! <<< */
2643 case TYPE_CODE_CHAR
:
2644 /* Deal with signed, unsigned, and plain chars for C++
2645 and with int cases falling through from previous case */
2646 if (TYPE_NOSIGN (parm
))
2648 if (TYPE_NOSIGN (arg
))
2651 return INTEGER_COERCION_BADNESS
;
2653 else if (TYPE_UNSIGNED (parm
))
2655 if (TYPE_UNSIGNED (arg
))
2658 return INTEGER_PROMOTION_BADNESS
;
2660 else if (!TYPE_NOSIGN (arg
) && !TYPE_UNSIGNED (arg
))
2663 return INTEGER_COERCION_BADNESS
;
2665 return INCOMPATIBLE_TYPE_BADNESS
;
2668 case TYPE_CODE_RANGE
:
2669 switch (TYPE_CODE (arg
))
2672 case TYPE_CODE_CHAR
:
2673 case TYPE_CODE_RANGE
:
2674 case TYPE_CODE_BOOL
:
2675 case TYPE_CODE_ENUM
:
2676 return INTEGER_COERCION_BADNESS
;
2678 return INT_FLOAT_CONVERSION_BADNESS
;
2680 return INCOMPATIBLE_TYPE_BADNESS
;
2683 case TYPE_CODE_BOOL
:
2684 switch (TYPE_CODE (arg
))
2687 case TYPE_CODE_CHAR
:
2688 case TYPE_CODE_RANGE
:
2689 case TYPE_CODE_ENUM
:
2692 return BOOLEAN_CONVERSION_BADNESS
;
2693 case TYPE_CODE_BOOL
:
2696 return INCOMPATIBLE_TYPE_BADNESS
;
2700 switch (TYPE_CODE (arg
))
2703 if (TYPE_LENGTH (arg
) < TYPE_LENGTH (parm
))
2704 return FLOAT_PROMOTION_BADNESS
;
2705 else if (TYPE_LENGTH (arg
) == TYPE_LENGTH (parm
))
2708 return FLOAT_CONVERSION_BADNESS
;
2710 case TYPE_CODE_BOOL
:
2711 case TYPE_CODE_ENUM
:
2712 case TYPE_CODE_RANGE
:
2713 case TYPE_CODE_CHAR
:
2714 return INT_FLOAT_CONVERSION_BADNESS
;
2716 return INCOMPATIBLE_TYPE_BADNESS
;
2719 case TYPE_CODE_COMPLEX
:
2720 switch (TYPE_CODE (arg
))
2721 { /* Strictly not needed for C++, but... */
2723 return FLOAT_PROMOTION_BADNESS
;
2724 case TYPE_CODE_COMPLEX
:
2727 return INCOMPATIBLE_TYPE_BADNESS
;
2730 case TYPE_CODE_STRUCT
:
2731 /* currently same as TYPE_CODE_CLASS */
2732 switch (TYPE_CODE (arg
))
2734 case TYPE_CODE_STRUCT
:
2735 /* Check for derivation */
2736 if (is_ancestor (parm
, arg
))
2737 return BASE_CONVERSION_BADNESS
;
2738 /* else fall through */
2740 return INCOMPATIBLE_TYPE_BADNESS
;
2743 case TYPE_CODE_UNION
:
2744 switch (TYPE_CODE (arg
))
2746 case TYPE_CODE_UNION
:
2748 return INCOMPATIBLE_TYPE_BADNESS
;
2751 case TYPE_CODE_MEMBER
:
2752 switch (TYPE_CODE (arg
))
2755 return INCOMPATIBLE_TYPE_BADNESS
;
2758 case TYPE_CODE_METHOD
:
2759 switch (TYPE_CODE (arg
))
2763 return INCOMPATIBLE_TYPE_BADNESS
;
2767 switch (TYPE_CODE (arg
))
2771 return INCOMPATIBLE_TYPE_BADNESS
;
2776 switch (TYPE_CODE (arg
))
2780 return rank_one_type (TYPE_FIELD_TYPE (parm
, 0), TYPE_FIELD_TYPE (arg
, 0));
2782 return INCOMPATIBLE_TYPE_BADNESS
;
2785 case TYPE_CODE_VOID
:
2787 return INCOMPATIBLE_TYPE_BADNESS
;
2788 } /* switch (TYPE_CODE (arg)) */
2792 /* End of functions for overload resolution */
2795 print_bit_vector (B_TYPE
*bits
, int nbits
)
2799 for (bitno
= 0; bitno
< nbits
; bitno
++)
2801 if ((bitno
% 8) == 0)
2803 puts_filtered (" ");
2805 if (B_TST (bits
, bitno
))
2807 printf_filtered ("1");
2811 printf_filtered ("0");
2816 /* Note the first arg should be the "this" pointer, we may not want to
2817 include it since we may get into a infinitely recursive situation. */
2820 print_arg_types (struct field
*args
, int nargs
, int spaces
)
2826 for (i
= 0; i
< nargs
; i
++)
2827 recursive_dump_type (args
[i
].type
, spaces
+ 2);
2832 dump_fn_fieldlists (struct type
*type
, int spaces
)
2838 printfi_filtered (spaces
, "fn_fieldlists ");
2839 gdb_print_host_address (TYPE_FN_FIELDLISTS (type
), gdb_stdout
);
2840 printf_filtered ("\n");
2841 for (method_idx
= 0; method_idx
< TYPE_NFN_FIELDS (type
); method_idx
++)
2843 f
= TYPE_FN_FIELDLIST1 (type
, method_idx
);
2844 printfi_filtered (spaces
+ 2, "[%d] name '%s' (",
2846 TYPE_FN_FIELDLIST_NAME (type
, method_idx
));
2847 gdb_print_host_address (TYPE_FN_FIELDLIST_NAME (type
, method_idx
),
2849 printf_filtered (") length %d\n",
2850 TYPE_FN_FIELDLIST_LENGTH (type
, method_idx
));
2851 for (overload_idx
= 0;
2852 overload_idx
< TYPE_FN_FIELDLIST_LENGTH (type
, method_idx
);
2855 printfi_filtered (spaces
+ 4, "[%d] physname '%s' (",
2857 TYPE_FN_FIELD_PHYSNAME (f
, overload_idx
));
2858 gdb_print_host_address (TYPE_FN_FIELD_PHYSNAME (f
, overload_idx
),
2860 printf_filtered (")\n");
2861 printfi_filtered (spaces
+ 8, "type ");
2862 gdb_print_host_address (TYPE_FN_FIELD_TYPE (f
, overload_idx
), gdb_stdout
);
2863 printf_filtered ("\n");
2865 recursive_dump_type (TYPE_FN_FIELD_TYPE (f
, overload_idx
),
2868 printfi_filtered (spaces
+ 8, "args ");
2869 gdb_print_host_address (TYPE_FN_FIELD_ARGS (f
, overload_idx
), gdb_stdout
);
2870 printf_filtered ("\n");
2872 print_arg_types (TYPE_FN_FIELD_ARGS (f
, overload_idx
),
2873 TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (f
, overload_idx
)),
2875 printfi_filtered (spaces
+ 8, "fcontext ");
2876 gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f
, overload_idx
),
2878 printf_filtered ("\n");
2880 printfi_filtered (spaces
+ 8, "is_const %d\n",
2881 TYPE_FN_FIELD_CONST (f
, overload_idx
));
2882 printfi_filtered (spaces
+ 8, "is_volatile %d\n",
2883 TYPE_FN_FIELD_VOLATILE (f
, overload_idx
));
2884 printfi_filtered (spaces
+ 8, "is_private %d\n",
2885 TYPE_FN_FIELD_PRIVATE (f
, overload_idx
));
2886 printfi_filtered (spaces
+ 8, "is_protected %d\n",
2887 TYPE_FN_FIELD_PROTECTED (f
, overload_idx
));
2888 printfi_filtered (spaces
+ 8, "is_stub %d\n",
2889 TYPE_FN_FIELD_STUB (f
, overload_idx
));
2890 printfi_filtered (spaces
+ 8, "voffset %u\n",
2891 TYPE_FN_FIELD_VOFFSET (f
, overload_idx
));
2897 print_cplus_stuff (struct type
*type
, int spaces
)
2899 printfi_filtered (spaces
, "n_baseclasses %d\n",
2900 TYPE_N_BASECLASSES (type
));
2901 printfi_filtered (spaces
, "nfn_fields %d\n",
2902 TYPE_NFN_FIELDS (type
));
2903 printfi_filtered (spaces
, "nfn_fields_total %d\n",
2904 TYPE_NFN_FIELDS_TOTAL (type
));
2905 if (TYPE_N_BASECLASSES (type
) > 0)
2907 printfi_filtered (spaces
, "virtual_field_bits (%d bits at *",
2908 TYPE_N_BASECLASSES (type
));
2909 gdb_print_host_address (TYPE_FIELD_VIRTUAL_BITS (type
), gdb_stdout
);
2910 printf_filtered (")");
2912 print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type
),
2913 TYPE_N_BASECLASSES (type
));
2914 puts_filtered ("\n");
2916 if (TYPE_NFIELDS (type
) > 0)
2918 if (TYPE_FIELD_PRIVATE_BITS (type
) != NULL
)
2920 printfi_filtered (spaces
, "private_field_bits (%d bits at *",
2921 TYPE_NFIELDS (type
));
2922 gdb_print_host_address (TYPE_FIELD_PRIVATE_BITS (type
), gdb_stdout
);
2923 printf_filtered (")");
2924 print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type
),
2925 TYPE_NFIELDS (type
));
2926 puts_filtered ("\n");
2928 if (TYPE_FIELD_PROTECTED_BITS (type
) != NULL
)
2930 printfi_filtered (spaces
, "protected_field_bits (%d bits at *",
2931 TYPE_NFIELDS (type
));
2932 gdb_print_host_address (TYPE_FIELD_PROTECTED_BITS (type
), gdb_stdout
);
2933 printf_filtered (")");
2934 print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type
),
2935 TYPE_NFIELDS (type
));
2936 puts_filtered ("\n");
2939 if (TYPE_NFN_FIELDS (type
) > 0)
2941 dump_fn_fieldlists (type
, spaces
);
2946 print_bound_type (int bt
)
2950 case BOUND_CANNOT_BE_DETERMINED
:
2951 printf_filtered ("(BOUND_CANNOT_BE_DETERMINED)");
2953 case BOUND_BY_REF_ON_STACK
:
2954 printf_filtered ("(BOUND_BY_REF_ON_STACK)");
2956 case BOUND_BY_VALUE_ON_STACK
:
2957 printf_filtered ("(BOUND_BY_VALUE_ON_STACK)");
2959 case BOUND_BY_REF_IN_REG
:
2960 printf_filtered ("(BOUND_BY_REF_IN_REG)");
2962 case BOUND_BY_VALUE_IN_REG
:
2963 printf_filtered ("(BOUND_BY_VALUE_IN_REG)");
2966 printf_filtered ("(BOUND_SIMPLE)");
2969 printf_filtered ("(unknown bound type)");
2974 static struct obstack dont_print_type_obstack
;
2977 recursive_dump_type (struct type
*type
, int spaces
)
2982 obstack_begin (&dont_print_type_obstack
, 0);
2984 if (TYPE_NFIELDS (type
) > 0
2985 || (TYPE_CPLUS_SPECIFIC (type
) && TYPE_NFN_FIELDS (type
) > 0))
2987 struct type
**first_dont_print
2988 = (struct type
**) obstack_base (&dont_print_type_obstack
);
2990 int i
= (struct type
**) obstack_next_free (&dont_print_type_obstack
)
2995 if (type
== first_dont_print
[i
])
2997 printfi_filtered (spaces
, "type node ");
2998 gdb_print_host_address (type
, gdb_stdout
);
2999 printf_filtered (" <same as already seen type>\n");
3004 obstack_ptr_grow (&dont_print_type_obstack
, type
);
3007 printfi_filtered (spaces
, "type node ");
3008 gdb_print_host_address (type
, gdb_stdout
);
3009 printf_filtered ("\n");
3010 printfi_filtered (spaces
, "name '%s' (",
3011 TYPE_NAME (type
) ? TYPE_NAME (type
) : "<NULL>");
3012 gdb_print_host_address (TYPE_NAME (type
), gdb_stdout
);
3013 printf_filtered (")\n");
3014 printfi_filtered (spaces
, "tagname '%s' (",
3015 TYPE_TAG_NAME (type
) ? TYPE_TAG_NAME (type
) : "<NULL>");
3016 gdb_print_host_address (TYPE_TAG_NAME (type
), gdb_stdout
);
3017 printf_filtered (")\n");
3018 printfi_filtered (spaces
, "code 0x%x ", TYPE_CODE (type
));
3019 switch (TYPE_CODE (type
))
3021 case TYPE_CODE_UNDEF
:
3022 printf_filtered ("(TYPE_CODE_UNDEF)");
3025 printf_filtered ("(TYPE_CODE_PTR)");
3027 case TYPE_CODE_ARRAY
:
3028 printf_filtered ("(TYPE_CODE_ARRAY)");
3030 case TYPE_CODE_STRUCT
:
3031 printf_filtered ("(TYPE_CODE_STRUCT)");
3033 case TYPE_CODE_UNION
:
3034 printf_filtered ("(TYPE_CODE_UNION)");
3036 case TYPE_CODE_ENUM
:
3037 printf_filtered ("(TYPE_CODE_ENUM)");
3039 case TYPE_CODE_FUNC
:
3040 printf_filtered ("(TYPE_CODE_FUNC)");
3043 printf_filtered ("(TYPE_CODE_INT)");
3046 printf_filtered ("(TYPE_CODE_FLT)");
3048 case TYPE_CODE_VOID
:
3049 printf_filtered ("(TYPE_CODE_VOID)");
3052 printf_filtered ("(TYPE_CODE_SET)");
3054 case TYPE_CODE_RANGE
:
3055 printf_filtered ("(TYPE_CODE_RANGE)");
3057 case TYPE_CODE_STRING
:
3058 printf_filtered ("(TYPE_CODE_STRING)");
3060 case TYPE_CODE_BITSTRING
:
3061 printf_filtered ("(TYPE_CODE_BITSTRING)");
3063 case TYPE_CODE_ERROR
:
3064 printf_filtered ("(TYPE_CODE_ERROR)");
3066 case TYPE_CODE_MEMBER
:
3067 printf_filtered ("(TYPE_CODE_MEMBER)");
3069 case TYPE_CODE_METHOD
:
3070 printf_filtered ("(TYPE_CODE_METHOD)");
3073 printf_filtered ("(TYPE_CODE_REF)");
3075 case TYPE_CODE_CHAR
:
3076 printf_filtered ("(TYPE_CODE_CHAR)");
3078 case TYPE_CODE_BOOL
:
3079 printf_filtered ("(TYPE_CODE_BOOL)");
3081 case TYPE_CODE_COMPLEX
:
3082 printf_filtered ("(TYPE_CODE_COMPLEX)");
3084 case TYPE_CODE_TYPEDEF
:
3085 printf_filtered ("(TYPE_CODE_TYPEDEF)");
3087 case TYPE_CODE_TEMPLATE
:
3088 printf_filtered ("(TYPE_CODE_TEMPLATE)");
3090 case TYPE_CODE_TEMPLATE_ARG
:
3091 printf_filtered ("(TYPE_CODE_TEMPLATE_ARG)");
3094 printf_filtered ("(UNKNOWN TYPE CODE)");
3097 puts_filtered ("\n");
3098 printfi_filtered (spaces
, "length %d\n", TYPE_LENGTH (type
));
3099 printfi_filtered (spaces
, "upper_bound_type 0x%x ",
3100 TYPE_ARRAY_UPPER_BOUND_TYPE (type
));
3101 print_bound_type (TYPE_ARRAY_UPPER_BOUND_TYPE (type
));
3102 puts_filtered ("\n");
3103 printfi_filtered (spaces
, "lower_bound_type 0x%x ",
3104 TYPE_ARRAY_LOWER_BOUND_TYPE (type
));
3105 print_bound_type (TYPE_ARRAY_LOWER_BOUND_TYPE (type
));
3106 puts_filtered ("\n");
3107 printfi_filtered (spaces
, "objfile ");
3108 gdb_print_host_address (TYPE_OBJFILE (type
), gdb_stdout
);
3109 printf_filtered ("\n");
3110 printfi_filtered (spaces
, "target_type ");
3111 gdb_print_host_address (TYPE_TARGET_TYPE (type
), gdb_stdout
);
3112 printf_filtered ("\n");
3113 if (TYPE_TARGET_TYPE (type
) != NULL
)
3115 recursive_dump_type (TYPE_TARGET_TYPE (type
), spaces
+ 2);
3117 printfi_filtered (spaces
, "pointer_type ");
3118 gdb_print_host_address (TYPE_POINTER_TYPE (type
), gdb_stdout
);
3119 printf_filtered ("\n");
3120 printfi_filtered (spaces
, "reference_type ");
3121 gdb_print_host_address (TYPE_REFERENCE_TYPE (type
), gdb_stdout
);
3122 printf_filtered ("\n");
3123 printfi_filtered (spaces
, "type_chain ");
3124 gdb_print_host_address (TYPE_CHAIN (type
), gdb_stdout
);
3125 printf_filtered ("\n");
3126 printfi_filtered (spaces
, "instance_flags 0x%x", TYPE_INSTANCE_FLAGS (type
));
3127 if (TYPE_CONST (type
))
3129 puts_filtered (" TYPE_FLAG_CONST");
3131 if (TYPE_VOLATILE (type
))
3133 puts_filtered (" TYPE_FLAG_VOLATILE");
3135 if (TYPE_CODE_SPACE (type
))
3137 puts_filtered (" TYPE_FLAG_CODE_SPACE");
3139 if (TYPE_DATA_SPACE (type
))
3141 puts_filtered (" TYPE_FLAG_DATA_SPACE");
3143 puts_filtered ("\n");
3144 printfi_filtered (spaces
, "flags 0x%x", TYPE_FLAGS (type
));
3145 if (TYPE_UNSIGNED (type
))
3147 puts_filtered (" TYPE_FLAG_UNSIGNED");
3149 if (TYPE_NOSIGN (type
))
3151 puts_filtered (" TYPE_FLAG_NOSIGN");
3153 if (TYPE_STUB (type
))
3155 puts_filtered (" TYPE_FLAG_STUB");
3157 if (TYPE_TARGET_STUB (type
))
3159 puts_filtered (" TYPE_FLAG_TARGET_STUB");
3161 if (TYPE_STATIC (type
))
3163 puts_filtered (" TYPE_FLAG_STATIC");
3165 if (TYPE_PROTOTYPED (type
))
3167 puts_filtered (" TYPE_FLAG_PROTOTYPED");
3169 if (TYPE_INCOMPLETE (type
))
3171 puts_filtered (" TYPE_FLAG_INCOMPLETE");
3173 if (TYPE_VARARGS (type
))
3175 puts_filtered (" TYPE_FLAG_VARARGS");
3177 /* This is used for things like AltiVec registers on ppc. Gcc emits
3178 an attribute for the array type, which tells whether or not we
3179 have a vector, instead of a regular array. */
3180 if (TYPE_VECTOR (type
))
3182 puts_filtered (" TYPE_FLAG_VECTOR");
3184 puts_filtered ("\n");
3185 printfi_filtered (spaces
, "nfields %d ", TYPE_NFIELDS (type
));
3186 gdb_print_host_address (TYPE_FIELDS (type
), gdb_stdout
);
3187 puts_filtered ("\n");
3188 for (idx
= 0; idx
< TYPE_NFIELDS (type
); idx
++)
3190 printfi_filtered (spaces
+ 2,
3191 "[%d] bitpos %d bitsize %d type ",
3192 idx
, TYPE_FIELD_BITPOS (type
, idx
),
3193 TYPE_FIELD_BITSIZE (type
, idx
));
3194 gdb_print_host_address (TYPE_FIELD_TYPE (type
, idx
), gdb_stdout
);
3195 printf_filtered (" name '%s' (",
3196 TYPE_FIELD_NAME (type
, idx
) != NULL
3197 ? TYPE_FIELD_NAME (type
, idx
)
3199 gdb_print_host_address (TYPE_FIELD_NAME (type
, idx
), gdb_stdout
);
3200 printf_filtered (")\n");
3201 if (TYPE_FIELD_TYPE (type
, idx
) != NULL
)
3203 recursive_dump_type (TYPE_FIELD_TYPE (type
, idx
), spaces
+ 4);
3206 printfi_filtered (spaces
, "vptr_basetype ");
3207 gdb_print_host_address (TYPE_VPTR_BASETYPE (type
), gdb_stdout
);
3208 puts_filtered ("\n");
3209 if (TYPE_VPTR_BASETYPE (type
) != NULL
)
3211 recursive_dump_type (TYPE_VPTR_BASETYPE (type
), spaces
+ 2);
3213 printfi_filtered (spaces
, "vptr_fieldno %d\n", TYPE_VPTR_FIELDNO (type
));
3214 switch (TYPE_CODE (type
))
3216 case TYPE_CODE_STRUCT
:
3217 printfi_filtered (spaces
, "cplus_stuff ");
3218 gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type
), gdb_stdout
);
3219 puts_filtered ("\n");
3220 print_cplus_stuff (type
, spaces
);
3224 printfi_filtered (spaces
, "floatformat ");
3225 if (TYPE_FLOATFORMAT (type
) == NULL
3226 || TYPE_FLOATFORMAT (type
)->name
== NULL
)
3227 puts_filtered ("(null)");
3229 puts_filtered (TYPE_FLOATFORMAT (type
)->name
);
3230 puts_filtered ("\n");
3234 /* We have to pick one of the union types to be able print and test
3235 the value. Pick cplus_struct_type, even though we know it isn't
3236 any particular one. */
3237 printfi_filtered (spaces
, "type_specific ");
3238 gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type
), gdb_stdout
);
3239 if (TYPE_CPLUS_SPECIFIC (type
) != NULL
)
3241 printf_filtered (" (unknown data form)");
3243 printf_filtered ("\n");
3248 obstack_free (&dont_print_type_obstack
, NULL
);
3251 static void build_gdbtypes (void);
3253 build_gdbtypes (void)
3256 init_type (TYPE_CODE_VOID
, 1,
3258 "void", (struct objfile
*) NULL
);
3260 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3262 | (TARGET_CHAR_SIGNED
? 0 : TYPE_FLAG_UNSIGNED
)),
3263 "char", (struct objfile
*) NULL
);
3264 builtin_type_true_char
=
3265 init_type (TYPE_CODE_CHAR
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3267 "true character", (struct objfile
*) NULL
);
3268 builtin_type_signed_char
=
3269 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3271 "signed char", (struct objfile
*) NULL
);
3272 builtin_type_unsigned_char
=
3273 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3275 "unsigned char", (struct objfile
*) NULL
);
3276 builtin_type_short
=
3277 init_type (TYPE_CODE_INT
, TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
3279 "short", (struct objfile
*) NULL
);
3280 builtin_type_unsigned_short
=
3281 init_type (TYPE_CODE_INT
, TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
3283 "unsigned short", (struct objfile
*) NULL
);
3285 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
3287 "int", (struct objfile
*) NULL
);
3288 builtin_type_unsigned_int
=
3289 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
3291 "unsigned int", (struct objfile
*) NULL
);
3293 init_type (TYPE_CODE_INT
, TARGET_LONG_BIT
/ TARGET_CHAR_BIT
,
3295 "long", (struct objfile
*) NULL
);
3296 builtin_type_unsigned_long
=
3297 init_type (TYPE_CODE_INT
, TARGET_LONG_BIT
/ TARGET_CHAR_BIT
,
3299 "unsigned long", (struct objfile
*) NULL
);
3300 builtin_type_long_long
=
3301 init_type (TYPE_CODE_INT
, TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
,
3303 "long long", (struct objfile
*) NULL
);
3304 builtin_type_unsigned_long_long
=
3305 init_type (TYPE_CODE_INT
, TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
,
3307 "unsigned long long", (struct objfile
*) NULL
);
3308 builtin_type_float
=
3309 init_type (TYPE_CODE_FLT
, TARGET_FLOAT_BIT
/ TARGET_CHAR_BIT
,
3311 "float", (struct objfile
*) NULL
);
3312 /* vinschen@redhat.com 2002-02-08:
3313 The below lines are disabled since they are doing the wrong
3314 thing for non-multiarch targets. They are setting the correct
3315 type of floats for the target but while on multiarch targets
3316 this is done everytime the architecture changes, it's done on
3317 non-multiarch targets only on startup, leaving the wrong values
3318 in even if the architecture changes (eg. from big-endian to
3321 TYPE_FLOATFORMAT (builtin_type_float
) = TARGET_FLOAT_FORMAT
;
3323 builtin_type_double
=
3324 init_type (TYPE_CODE_FLT
, TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
3326 "double", (struct objfile
*) NULL
);
3328 TYPE_FLOATFORMAT (builtin_type_double
) = TARGET_DOUBLE_FORMAT
;
3330 builtin_type_long_double
=
3331 init_type (TYPE_CODE_FLT
, TARGET_LONG_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
3333 "long double", (struct objfile
*) NULL
);
3335 TYPE_FLOATFORMAT (builtin_type_long_double
) = TARGET_LONG_DOUBLE_FORMAT
;
3337 builtin_type_complex
=
3338 init_type (TYPE_CODE_COMPLEX
, 2 * TARGET_FLOAT_BIT
/ TARGET_CHAR_BIT
,
3340 "complex", (struct objfile
*) NULL
);
3341 TYPE_TARGET_TYPE (builtin_type_complex
) = builtin_type_float
;
3342 builtin_type_double_complex
=
3343 init_type (TYPE_CODE_COMPLEX
, 2 * TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
3345 "double complex", (struct objfile
*) NULL
);
3346 TYPE_TARGET_TYPE (builtin_type_double_complex
) = builtin_type_double
;
3347 builtin_type_string
=
3348 init_type (TYPE_CODE_STRING
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3350 "string", (struct objfile
*) NULL
);
3352 init_type (TYPE_CODE_INT
, 8 / 8,
3354 "int8_t", (struct objfile
*) NULL
);
3355 builtin_type_uint8
=
3356 init_type (TYPE_CODE_INT
, 8 / 8,
3358 "uint8_t", (struct objfile
*) NULL
);
3359 builtin_type_int16
=
3360 init_type (TYPE_CODE_INT
, 16 / 8,
3362 "int16_t", (struct objfile
*) NULL
);
3363 builtin_type_uint16
=
3364 init_type (TYPE_CODE_INT
, 16 / 8,
3366 "uint16_t", (struct objfile
*) NULL
);
3367 builtin_type_int32
=
3368 init_type (TYPE_CODE_INT
, 32 / 8,
3370 "int32_t", (struct objfile
*) NULL
);
3371 builtin_type_uint32
=
3372 init_type (TYPE_CODE_INT
, 32 / 8,
3374 "uint32_t", (struct objfile
*) NULL
);
3375 builtin_type_int64
=
3376 init_type (TYPE_CODE_INT
, 64 / 8,
3378 "int64_t", (struct objfile
*) NULL
);
3379 builtin_type_uint64
=
3380 init_type (TYPE_CODE_INT
, 64 / 8,
3382 "uint64_t", (struct objfile
*) NULL
);
3383 builtin_type_int128
=
3384 init_type (TYPE_CODE_INT
, 128 / 8,
3386 "int128_t", (struct objfile
*) NULL
);
3387 builtin_type_uint128
=
3388 init_type (TYPE_CODE_INT
, 128 / 8,
3390 "uint128_t", (struct objfile
*) NULL
);
3392 init_type (TYPE_CODE_BOOL
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3394 "bool", (struct objfile
*) NULL
);
3396 /* Add user knob for controlling resolution of opaque types */
3398 (add_set_cmd ("opaque-type-resolution", class_support
, var_boolean
, (char *) &opaque_type_resolution
,
3399 "Set resolution of opaque struct/class/union types (if set before loading symbols).",
3402 opaque_type_resolution
= 1;
3404 /* Build SIMD types. */
3406 = init_simd_type ("__builtin_v4sf", builtin_type_float
, "f", 4);
3408 = init_simd_type ("__builtin_v4si", builtin_type_int32
, "f", 4);
3410 = init_simd_type ("__builtin_v16qi", builtin_type_int8
, "f", 16);
3412 = init_simd_type ("__builtin_v8qi", builtin_type_int8
, "f", 8);
3414 = init_simd_type ("__builtin_v8hi", builtin_type_int16
, "f", 8);
3416 = init_simd_type ("__builtin_v4hi", builtin_type_int16
, "f", 4);
3418 = init_simd_type ("__builtin_v2si", builtin_type_int32
, "f", 2);
3420 /* 128 bit vectors. */
3421 builtin_type_v2_double
= init_vector_type (builtin_type_double
, 2);
3422 builtin_type_v4_float
= init_vector_type (builtin_type_float
, 4);
3423 builtin_type_v2_int64
= init_vector_type (builtin_type_int64
, 2);
3424 builtin_type_v4_int32
= init_vector_type (builtin_type_int32
, 4);
3425 builtin_type_v8_int16
= init_vector_type (builtin_type_int16
, 8);
3426 builtin_type_v16_int8
= init_vector_type (builtin_type_int8
, 16);
3427 /* 64 bit vectors. */
3428 builtin_type_v2_float
= init_vector_type (builtin_type_float
, 2);
3429 builtin_type_v2_int32
= init_vector_type (builtin_type_int32
, 2);
3430 builtin_type_v4_int16
= init_vector_type (builtin_type_int16
, 4);
3431 builtin_type_v8_int8
= init_vector_type (builtin_type_int8
, 8);
3434 builtin_type_vec64
= build_builtin_type_vec64 ();
3435 builtin_type_vec64i
= build_builtin_type_vec64i ();
3436 builtin_type_vec128
= build_builtin_type_vec128 ();
3437 builtin_type_vec128i
= build_builtin_type_vec128i ();
3439 /* Pointer/Address types. */
3441 /* NOTE: on some targets, addresses and pointers are not necessarily
3442 the same --- for example, on the D10V, pointers are 16 bits long,
3443 but addresses are 32 bits long. See doc/gdbint.texinfo,
3444 ``Pointers Are Not Always Addresses''.
3447 - gdb's `struct type' always describes the target's
3449 - gdb's `struct value' objects should always hold values in
3451 - gdb's CORE_ADDR values are addresses in the unified virtual
3452 address space that the assembler and linker work with. Thus,
3453 since target_read_memory takes a CORE_ADDR as an argument, it
3454 can access any memory on the target, even if the processor has
3455 separate code and data address spaces.
3458 - If v is a value holding a D10V code pointer, its contents are
3459 in target form: a big-endian address left-shifted two bits.
3460 - If p is a D10V pointer type, TYPE_LENGTH (p) == 2, just as
3461 sizeof (void *) == 2 on the target.
3463 In this context, builtin_type_CORE_ADDR is a bit odd: it's a
3464 target type for a value the target will never see. It's only
3465 used to hold the values of (typeless) linker symbols, which are
3466 indeed in the unified virtual address space. */
3467 builtin_type_void_data_ptr
= make_pointer_type (builtin_type_void
, NULL
);
3468 builtin_type_void_func_ptr
3469 = lookup_pointer_type (lookup_function_type (builtin_type_void
));
3470 builtin_type_CORE_ADDR
=
3471 init_type (TYPE_CODE_INT
, TARGET_ADDR_BIT
/ 8,
3473 "__CORE_ADDR", (struct objfile
*) NULL
);
3474 builtin_type_bfd_vma
=
3475 init_type (TYPE_CODE_INT
, TARGET_BFD_VMA_BIT
/ 8,
3477 "__bfd_vma", (struct objfile
*) NULL
);
3480 extern void _initialize_gdbtypes (void);
3482 _initialize_gdbtypes (void)
3484 struct cmd_list_element
*c
;
3487 /* FIXME - For the moment, handle types by swapping them in and out.
3488 Should be using the per-architecture data-pointer and a large
3490 register_gdbarch_swap (&builtin_type_void
, sizeof (struct type
*), NULL
);
3491 register_gdbarch_swap (&builtin_type_char
, sizeof (struct type
*), NULL
);
3492 register_gdbarch_swap (&builtin_type_short
, sizeof (struct type
*), NULL
);
3493 register_gdbarch_swap (&builtin_type_int
, sizeof (struct type
*), NULL
);
3494 register_gdbarch_swap (&builtin_type_long
, sizeof (struct type
*), NULL
);
3495 register_gdbarch_swap (&builtin_type_long_long
, sizeof (struct type
*), NULL
);
3496 register_gdbarch_swap (&builtin_type_signed_char
, sizeof (struct type
*), NULL
);
3497 register_gdbarch_swap (&builtin_type_unsigned_char
, sizeof (struct type
*), NULL
);
3498 register_gdbarch_swap (&builtin_type_unsigned_short
, sizeof (struct type
*), NULL
);
3499 register_gdbarch_swap (&builtin_type_unsigned_int
, sizeof (struct type
*), NULL
);
3500 register_gdbarch_swap (&builtin_type_unsigned_long
, sizeof (struct type
*), NULL
);
3501 register_gdbarch_swap (&builtin_type_unsigned_long_long
, sizeof (struct type
*), NULL
);
3502 register_gdbarch_swap (&builtin_type_float
, sizeof (struct type
*), NULL
);
3503 register_gdbarch_swap (&builtin_type_double
, sizeof (struct type
*), NULL
);
3504 register_gdbarch_swap (&builtin_type_long_double
, sizeof (struct type
*), NULL
);
3505 register_gdbarch_swap (&builtin_type_complex
, sizeof (struct type
*), NULL
);
3506 register_gdbarch_swap (&builtin_type_double_complex
, sizeof (struct type
*), NULL
);
3507 register_gdbarch_swap (&builtin_type_string
, sizeof (struct type
*), NULL
);
3508 register_gdbarch_swap (&builtin_type_int8
, sizeof (struct type
*), NULL
);
3509 register_gdbarch_swap (&builtin_type_uint8
, sizeof (struct type
*), NULL
);
3510 register_gdbarch_swap (&builtin_type_int16
, sizeof (struct type
*), NULL
);
3511 register_gdbarch_swap (&builtin_type_uint16
, sizeof (struct type
*), NULL
);
3512 register_gdbarch_swap (&builtin_type_int32
, sizeof (struct type
*), NULL
);
3513 register_gdbarch_swap (&builtin_type_uint32
, sizeof (struct type
*), NULL
);
3514 register_gdbarch_swap (&builtin_type_int64
, sizeof (struct type
*), NULL
);
3515 register_gdbarch_swap (&builtin_type_uint64
, sizeof (struct type
*), NULL
);
3516 register_gdbarch_swap (&builtin_type_int128
, sizeof (struct type
*), NULL
);
3517 register_gdbarch_swap (&builtin_type_uint128
, sizeof (struct type
*), NULL
);
3518 register_gdbarch_swap (&builtin_type_v4sf
, sizeof (struct type
*), NULL
);
3519 register_gdbarch_swap (&builtin_type_v4si
, sizeof (struct type
*), NULL
);
3520 register_gdbarch_swap (&builtin_type_v16qi
, sizeof (struct type
*), NULL
);
3521 register_gdbarch_swap (&builtin_type_v8qi
, sizeof (struct type
*), NULL
);
3522 register_gdbarch_swap (&builtin_type_v8hi
, sizeof (struct type
*), NULL
);
3523 register_gdbarch_swap (&builtin_type_v4hi
, sizeof (struct type
*), NULL
);
3524 register_gdbarch_swap (&builtin_type_v2si
, sizeof (struct type
*), NULL
);
3525 register_gdbarch_swap (&builtin_type_v2_double
, sizeof (struct type
*), NULL
);
3526 register_gdbarch_swap (&builtin_type_v4_float
, sizeof (struct type
*), NULL
);
3527 register_gdbarch_swap (&builtin_type_v2_int64
, sizeof (struct type
*), NULL
);
3528 register_gdbarch_swap (&builtin_type_v4_int32
, sizeof (struct type
*), NULL
);
3529 register_gdbarch_swap (&builtin_type_v8_int16
, sizeof (struct type
*), NULL
);
3530 register_gdbarch_swap (&builtin_type_v16_int8
, sizeof (struct type
*), NULL
);
3531 register_gdbarch_swap (&builtin_type_v2_float
, sizeof (struct type
*), NULL
);
3532 register_gdbarch_swap (&builtin_type_v2_int32
, sizeof (struct type
*), NULL
);
3533 register_gdbarch_swap (&builtin_type_v8_int8
, sizeof (struct type
*), NULL
);
3534 register_gdbarch_swap (&builtin_type_v4_int16
, sizeof (struct type
*), NULL
);
3535 register_gdbarch_swap (&builtin_type_vec128
, sizeof (struct type
*), NULL
);
3536 register_gdbarch_swap (&builtin_type_vec128i
, sizeof (struct type
*), NULL
);
3537 REGISTER_GDBARCH_SWAP (builtin_type_void_data_ptr
);
3538 REGISTER_GDBARCH_SWAP (builtin_type_void_func_ptr
);
3539 REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR
);
3540 REGISTER_GDBARCH_SWAP (builtin_type_bfd_vma
);
3541 register_gdbarch_swap (NULL
, 0, build_gdbtypes
);
3543 /* Note: These types do not need to be swapped - they are target
3545 builtin_type_ieee_single_big
=
3546 init_type (TYPE_CODE_FLT
, floatformat_ieee_single_big
.totalsize
/ 8,
3547 0, "builtin_type_ieee_single_big", NULL
);
3548 TYPE_FLOATFORMAT (builtin_type_ieee_single_big
) = &floatformat_ieee_single_big
;
3549 builtin_type_ieee_single_little
=
3550 init_type (TYPE_CODE_FLT
, floatformat_ieee_single_little
.totalsize
/ 8,
3551 0, "builtin_type_ieee_single_little", NULL
);
3552 TYPE_FLOATFORMAT (builtin_type_ieee_single_little
) = &floatformat_ieee_single_little
;
3553 builtin_type_ieee_double_big
=
3554 init_type (TYPE_CODE_FLT
, floatformat_ieee_double_big
.totalsize
/ 8,
3555 0, "builtin_type_ieee_double_big", NULL
);
3556 TYPE_FLOATFORMAT (builtin_type_ieee_double_big
) = &floatformat_ieee_double_big
;
3557 builtin_type_ieee_double_little
=
3558 init_type (TYPE_CODE_FLT
, floatformat_ieee_double_little
.totalsize
/ 8,
3559 0, "builtin_type_ieee_double_little", NULL
);
3560 TYPE_FLOATFORMAT (builtin_type_ieee_double_little
) = &floatformat_ieee_double_little
;
3561 builtin_type_ieee_double_littlebyte_bigword
=
3562 init_type (TYPE_CODE_FLT
, floatformat_ieee_double_littlebyte_bigword
.totalsize
/ 8,
3563 0, "builtin_type_ieee_double_littlebyte_bigword", NULL
);
3564 TYPE_FLOATFORMAT (builtin_type_ieee_double_littlebyte_bigword
) = &floatformat_ieee_double_littlebyte_bigword
;
3565 builtin_type_i387_ext
=
3566 init_type (TYPE_CODE_FLT
, floatformat_i387_ext
.totalsize
/ 8,
3567 0, "builtin_type_i387_ext", NULL
);
3568 TYPE_FLOATFORMAT (builtin_type_i387_ext
) = &floatformat_i387_ext
;
3569 builtin_type_m68881_ext
=
3570 init_type (TYPE_CODE_FLT
, floatformat_m68881_ext
.totalsize
/ 8,
3571 0, "builtin_type_m68881_ext", NULL
);
3572 TYPE_FLOATFORMAT (builtin_type_m68881_ext
) = &floatformat_m68881_ext
;
3573 builtin_type_i960_ext
=
3574 init_type (TYPE_CODE_FLT
, floatformat_i960_ext
.totalsize
/ 8,
3575 0, "builtin_type_i960_ext", NULL
);
3576 TYPE_FLOATFORMAT (builtin_type_i960_ext
) = &floatformat_i960_ext
;
3577 builtin_type_m88110_ext
=
3578 init_type (TYPE_CODE_FLT
, floatformat_m88110_ext
.totalsize
/ 8,
3579 0, "builtin_type_m88110_ext", NULL
);
3580 TYPE_FLOATFORMAT (builtin_type_m88110_ext
) = &floatformat_m88110_ext
;
3581 builtin_type_m88110_harris_ext
=
3582 init_type (TYPE_CODE_FLT
, floatformat_m88110_harris_ext
.totalsize
/ 8,
3583 0, "builtin_type_m88110_harris_ext", NULL
);
3584 TYPE_FLOATFORMAT (builtin_type_m88110_harris_ext
) = &floatformat_m88110_harris_ext
;
3585 builtin_type_arm_ext_big
=
3586 init_type (TYPE_CODE_FLT
, floatformat_arm_ext_big
.totalsize
/ 8,
3587 0, "builtin_type_arm_ext_big", NULL
);
3588 TYPE_FLOATFORMAT (builtin_type_arm_ext_big
) = &floatformat_arm_ext_big
;
3589 builtin_type_arm_ext_littlebyte_bigword
=
3590 init_type (TYPE_CODE_FLT
, floatformat_arm_ext_littlebyte_bigword
.totalsize
/ 8,
3591 0, "builtin_type_arm_ext_littlebyte_bigword", NULL
);
3592 TYPE_FLOATFORMAT (builtin_type_arm_ext_littlebyte_bigword
) = &floatformat_arm_ext_littlebyte_bigword
;
3593 builtin_type_ia64_spill_big
=
3594 init_type (TYPE_CODE_FLT
, floatformat_ia64_spill_big
.totalsize
/ 8,
3595 0, "builtin_type_ia64_spill_big", NULL
);
3596 TYPE_FLOATFORMAT (builtin_type_ia64_spill_big
) = &floatformat_ia64_spill_big
;
3597 builtin_type_ia64_spill_little
=
3598 init_type (TYPE_CODE_FLT
, floatformat_ia64_spill_little
.totalsize
/ 8,
3599 0, "builtin_type_ia64_spill_little", NULL
);
3600 TYPE_FLOATFORMAT (builtin_type_ia64_spill_little
) = &floatformat_ia64_spill_little
;
3601 builtin_type_ia64_quad_big
=
3602 init_type (TYPE_CODE_FLT
, floatformat_ia64_quad_big
.totalsize
/ 8,
3603 0, "builtin_type_ia64_quad_big", NULL
);
3604 TYPE_FLOATFORMAT (builtin_type_ia64_quad_big
) = &floatformat_ia64_quad_big
;
3605 builtin_type_ia64_quad_little
=
3606 init_type (TYPE_CODE_FLT
, floatformat_ia64_quad_little
.totalsize
/ 8,
3607 0, "builtin_type_ia64_quad_little", NULL
);
3608 TYPE_FLOATFORMAT (builtin_type_ia64_quad_little
) = &floatformat_ia64_quad_little
;
3611 add_set_cmd ("overload", no_class
, var_zinteger
, (char *) &overload_debug
,
3612 "Set debugging of C++ overloading.\n\
3613 When enabled, ranking of the functions\n\
3614 is displayed.", &setdebuglist
),