1 /* Support routines for manipulating internal types for GDB.
2 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
3 2004 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_int0;
64 struct type *builtin_type_int8;
65 struct type *builtin_type_uint8;
66 struct type *builtin_type_int16;
67 struct type *builtin_type_uint16;
68 struct type *builtin_type_int32;
69 struct type *builtin_type_uint32;
70 struct type *builtin_type_int64;
71 struct type *builtin_type_uint64;
72 struct type *builtin_type_int128;
73 struct type *builtin_type_uint128;
74 struct type *builtin_type_bool;
76 /* 128 bit long vector types */
77 struct type *builtin_type_v2_double;
78 struct type *builtin_type_v4_float;
79 struct type *builtin_type_v2_int64;
80 struct type *builtin_type_v4_int32;
81 struct type *builtin_type_v8_int16;
82 struct type *builtin_type_v16_int8;
83 /* 64 bit long vector types */
84 struct type *builtin_type_v2_float;
85 struct type *builtin_type_v2_int32;
86 struct type *builtin_type_v4_int16;
87 struct type *builtin_type_v8_int8;
89 struct type *builtin_type_v4sf;
90 struct type *builtin_type_v4si;
91 struct type *builtin_type_v16qi;
92 struct type *builtin_type_v8qi;
93 struct type *builtin_type_v8hi;
94 struct type *builtin_type_v4hi;
95 struct type *builtin_type_v2si;
96 struct type *builtin_type_vec64;
97 struct type *builtin_type_vec64i;
98 struct type *builtin_type_vec128;
99 struct type *builtin_type_vec128i;
100 struct type *builtin_type_ieee_single[BFD_ENDIAN_UNKNOWN];
101 struct type *builtin_type_ieee_single_big;
102 struct type *builtin_type_ieee_single_little;
103 struct type *builtin_type_ieee_double[BFD_ENDIAN_UNKNOWN];
104 struct type *builtin_type_ieee_double_big;
105 struct type *builtin_type_ieee_double_little;
106 struct type *builtin_type_ieee_double_littlebyte_bigword;
107 struct type *builtin_type_i387_ext;
108 struct type *builtin_type_m68881_ext;
109 struct type *builtin_type_i960_ext;
110 struct type *builtin_type_m88110_ext;
111 struct type *builtin_type_m88110_harris_ext;
112 struct type *builtin_type_arm_ext[BFD_ENDIAN_UNKNOWN];
113 struct type *builtin_type_arm_ext_big;
114 struct type *builtin_type_arm_ext_littlebyte_bigword;
115 struct type *builtin_type_ia64_spill[BFD_ENDIAN_UNKNOWN];
116 struct type *builtin_type_ia64_spill_big;
117 struct type *builtin_type_ia64_spill_little;
118 struct type *builtin_type_ia64_quad[BFD_ENDIAN_UNKNOWN];
119 struct type *builtin_type_ia64_quad_big;
120 struct type *builtin_type_ia64_quad_little;
121 struct type *builtin_type_void_data_ptr;
122 struct type *builtin_type_void_func_ptr;
123 struct type *builtin_type_CORE_ADDR;
124 struct type *builtin_type_bfd_vma;
126 int opaque_type_resolution = 1;
127 int overload_debug = 0;
133 }; /* maximum extension is 128! FIXME */
135 static void print_bit_vector (B_TYPE *, int);
136 static void print_arg_types (struct field *, int, int);
137 static void dump_fn_fieldlists (struct type *, int);
138 static void print_cplus_stuff (struct type *, int);
139 static void virtual_base_list_aux (struct type *dclass);
142 /* Alloc a new type structure and fill it with some defaults. If
143 OBJFILE is non-NULL, then allocate the space for the type structure
144 in that objfile's objfile_obstack. Otherwise allocate the new type structure
145 by xmalloc () (for permanent types). */
148 alloc_type (struct objfile *objfile)
152 /* Alloc the structure and start off with all fields zeroed. */
156 type = xmalloc (sizeof (struct type));
157 memset (type, 0, sizeof (struct type));
158 TYPE_MAIN_TYPE (type) = xmalloc (sizeof (struct main_type));
162 type = obstack_alloc (&objfile->objfile_obstack,
163 sizeof (struct type));
164 memset (type, 0, sizeof (struct type));
165 TYPE_MAIN_TYPE (type) = obstack_alloc (&objfile->objfile_obstack,
166 sizeof (struct main_type));
167 OBJSTAT (objfile, n_types++);
169 memset (TYPE_MAIN_TYPE (type), 0, sizeof (struct main_type));
171 /* Initialize the fields that might not be zero. */
173 TYPE_CODE (type) = TYPE_CODE_UNDEF;
174 TYPE_OBJFILE (type) = objfile;
175 TYPE_VPTR_FIELDNO (type) = -1;
176 TYPE_CHAIN (type) = type; /* Chain back to itself. */
181 /* Alloc a new type instance structure, fill it with some defaults,
182 and point it at OLDTYPE. Allocate the new type instance from the
183 same place as OLDTYPE. */
186 alloc_type_instance (struct type *oldtype)
190 /* Allocate the structure. */
192 if (TYPE_OBJFILE (oldtype) == NULL)
194 type = xmalloc (sizeof (struct type));
195 memset (type, 0, sizeof (struct type));
199 type = obstack_alloc (&TYPE_OBJFILE (oldtype)->objfile_obstack,
200 sizeof (struct type));
201 memset (type, 0, sizeof (struct type));
203 TYPE_MAIN_TYPE (type) = TYPE_MAIN_TYPE (oldtype);
205 TYPE_CHAIN (type) = type; /* Chain back to itself for now. */
210 /* Clear all remnants of the previous type at TYPE, in preparation for
211 replacing it with something else. */
213 smash_type (struct type *type)
215 memset (TYPE_MAIN_TYPE (type), 0, sizeof (struct main_type));
217 /* For now, delete the rings. */
218 TYPE_CHAIN (type) = type;
220 /* For now, leave the pointer/reference types alone. */
223 /* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points
224 to a pointer to memory where the pointer type should be stored.
225 If *TYPEPTR is zero, update it to point to the pointer type we return.
226 We allocate new memory if needed. */
229 make_pointer_type (struct type *type, struct type **typeptr)
231 struct type *ntype; /* New type */
232 struct objfile *objfile;
234 ntype = TYPE_POINTER_TYPE (type);
239 return ntype; /* Don't care about alloc, and have new type. */
240 else if (*typeptr == 0)
242 *typeptr = ntype; /* Tracking alloc, and we have new type. */
247 if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
249 ntype = alloc_type (TYPE_OBJFILE (type));
254 /* We have storage, but need to reset it. */
257 objfile = TYPE_OBJFILE (ntype);
259 TYPE_OBJFILE (ntype) = objfile;
262 TYPE_TARGET_TYPE (ntype) = type;
263 TYPE_POINTER_TYPE (type) = ntype;
265 /* FIXME! Assume the machine has only one representation for pointers! */
267 TYPE_LENGTH (ntype) = TARGET_PTR_BIT / TARGET_CHAR_BIT;
268 TYPE_CODE (ntype) = TYPE_CODE_PTR;
270 /* Mark pointers as unsigned. The target converts between pointers
271 and addresses (CORE_ADDRs) using POINTER_TO_ADDRESS() and
272 ADDRESS_TO_POINTER(). */
273 TYPE_FLAGS (ntype) |= TYPE_FLAG_UNSIGNED;
275 if (!TYPE_POINTER_TYPE (type)) /* Remember it, if don't have one. */
276 TYPE_POINTER_TYPE (type) = ntype;
281 /* Given a type TYPE, return a type of pointers to that type.
282 May need to construct such a type if this is the first use. */
285 lookup_pointer_type (struct type *type)
287 return make_pointer_type (type, (struct type **) 0);
290 /* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, points
291 to a pointer to memory where the reference type should be stored.
292 If *TYPEPTR is zero, update it to point to the reference type we return.
293 We allocate new memory if needed. */
296 make_reference_type (struct type *type, struct type **typeptr)
298 struct type *ntype; /* New type */
299 struct objfile *objfile;
301 ntype = TYPE_REFERENCE_TYPE (type);
306 return ntype; /* Don't care about alloc, and have new type. */
307 else if (*typeptr == 0)
309 *typeptr = ntype; /* Tracking alloc, and we have new type. */
314 if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
316 ntype = alloc_type (TYPE_OBJFILE (type));
321 /* We have storage, but need to reset it. */
324 objfile = TYPE_OBJFILE (ntype);
326 TYPE_OBJFILE (ntype) = objfile;
329 TYPE_TARGET_TYPE (ntype) = type;
330 TYPE_REFERENCE_TYPE (type) = ntype;
332 /* FIXME! Assume the machine has only one representation for references,
333 and that it matches the (only) representation for pointers! */
335 TYPE_LENGTH (ntype) = TARGET_PTR_BIT / TARGET_CHAR_BIT;
336 TYPE_CODE (ntype) = TYPE_CODE_REF;
338 if (!TYPE_REFERENCE_TYPE (type)) /* Remember it, if don't have one. */
339 TYPE_REFERENCE_TYPE (type) = ntype;
344 /* Same as above, but caller doesn't care about memory allocation details. */
347 lookup_reference_type (struct type *type)
349 return make_reference_type (type, (struct type **) 0);
352 /* Lookup a function type that returns type TYPE. TYPEPTR, if nonzero, points
353 to a pointer to memory where the function type should be stored.
354 If *TYPEPTR is zero, update it to point to the function type we return.
355 We allocate new memory if needed. */
358 make_function_type (struct type *type, struct type **typeptr)
360 struct type *ntype; /* New type */
361 struct objfile *objfile;
363 if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
365 ntype = alloc_type (TYPE_OBJFILE (type));
370 /* We have storage, but need to reset it. */
373 objfile = TYPE_OBJFILE (ntype);
375 TYPE_OBJFILE (ntype) = objfile;
378 TYPE_TARGET_TYPE (ntype) = type;
380 TYPE_LENGTH (ntype) = 1;
381 TYPE_CODE (ntype) = TYPE_CODE_FUNC;
387 /* Given a type TYPE, return a type of functions that return that type.
388 May need to construct such a type if this is the first use. */
391 lookup_function_type (struct type *type)
393 return make_function_type (type, (struct type **) 0);
396 /* Identify address space identifier by name --
397 return the integer flag defined in gdbtypes.h. */
399 address_space_name_to_int (char *space_identifier)
401 struct gdbarch *gdbarch = current_gdbarch;
403 /* Check for known address space delimiters. */
404 if (!strcmp (space_identifier, "code"))
405 return TYPE_FLAG_CODE_SPACE;
406 else if (!strcmp (space_identifier, "data"))
407 return TYPE_FLAG_DATA_SPACE;
408 else if (gdbarch_address_class_name_to_type_flags_p (gdbarch)
409 && gdbarch_address_class_name_to_type_flags (gdbarch,
414 error ("Unknown address space specifier: \"%s\"", space_identifier);
417 /* Identify address space identifier by integer flag as defined in
418 gdbtypes.h -- return the string version of the adress space name. */
421 address_space_int_to_name (int space_flag)
423 struct gdbarch *gdbarch = current_gdbarch;
424 if (space_flag & TYPE_FLAG_CODE_SPACE)
426 else if (space_flag & TYPE_FLAG_DATA_SPACE)
428 else if ((space_flag & TYPE_FLAG_ADDRESS_CLASS_ALL)
429 && gdbarch_address_class_type_flags_to_name_p (gdbarch))
430 return gdbarch_address_class_type_flags_to_name (gdbarch, space_flag);
435 /* Create a new type with instance flags NEW_FLAGS, based on TYPE.
437 If STORAGE is non-NULL, create the new type instance there.
438 STORAGE must be in the same obstack as TYPE. */
441 make_qualified_type (struct type *type, int new_flags,
442 struct type *storage)
448 if (TYPE_INSTANCE_FLAGS (ntype) == new_flags)
450 ntype = TYPE_CHAIN (ntype);
451 } while (ntype != type);
453 /* Create a new type instance. */
455 ntype = alloc_type_instance (type);
458 /* If STORAGE was provided, it had better be in the same objfile as
459 TYPE. Otherwise, we can't link it into TYPE's cv chain: if one
460 objfile is freed and the other kept, we'd have dangling
462 gdb_assert (TYPE_OBJFILE (type) == TYPE_OBJFILE (storage));
465 TYPE_MAIN_TYPE (ntype) = TYPE_MAIN_TYPE (type);
466 TYPE_CHAIN (ntype) = ntype;
469 /* Pointers or references to the original type are not relevant to
471 TYPE_POINTER_TYPE (ntype) = (struct type *) 0;
472 TYPE_REFERENCE_TYPE (ntype) = (struct type *) 0;
474 /* Chain the new qualified type to the old type. */
475 TYPE_CHAIN (ntype) = TYPE_CHAIN (type);
476 TYPE_CHAIN (type) = ntype;
478 /* Now set the instance flags and return the new type. */
479 TYPE_INSTANCE_FLAGS (ntype) = new_flags;
481 /* Set length of new type to that of the original type. */
482 TYPE_LENGTH (ntype) = TYPE_LENGTH (type);
487 /* Make an address-space-delimited variant of a type -- a type that
488 is identical to the one supplied except that it has an address
489 space attribute attached to it (such as "code" or "data").
491 The space attributes "code" and "data" are for Harvard architectures.
492 The address space attributes are for architectures which have
493 alternately sized pointers or pointers with alternate representations. */
496 make_type_with_address_space (struct type *type, int space_flag)
499 int new_flags = ((TYPE_INSTANCE_FLAGS (type)
500 & ~(TYPE_FLAG_CODE_SPACE | TYPE_FLAG_DATA_SPACE
501 | TYPE_FLAG_ADDRESS_CLASS_ALL))
504 return make_qualified_type (type, new_flags, NULL);
507 /* Make a "c-v" variant of a type -- a type that is identical to the
508 one supplied except that it may have const or volatile attributes
509 CNST is a flag for setting the const attribute
510 VOLTL is a flag for setting the volatile attribute
511 TYPE is the base type whose variant we are creating.
513 If TYPEPTR and *TYPEPTR are non-zero, then *TYPEPTR points to
514 storage to hold the new qualified type; *TYPEPTR and TYPE must be
515 in the same objfile. Otherwise, allocate fresh memory for the new
516 type whereever TYPE lives. If TYPEPTR is non-zero, set it to the
517 new type we construct. */
519 make_cv_type (int cnst, int voltl, struct type *type, struct type **typeptr)
521 struct type *ntype; /* New type */
522 struct type *tmp_type = type; /* tmp type */
523 struct objfile *objfile;
525 int new_flags = (TYPE_INSTANCE_FLAGS (type)
526 & ~(TYPE_FLAG_CONST | TYPE_FLAG_VOLATILE));
529 new_flags |= TYPE_FLAG_CONST;
532 new_flags |= TYPE_FLAG_VOLATILE;
534 if (typeptr && *typeptr != NULL)
536 /* TYPE and *TYPEPTR must be in the same objfile. We can't have
537 a C-V variant chain that threads across objfiles: if one
538 objfile gets freed, then the other has a broken C-V chain.
540 This code used to try to copy over the main type from TYPE to
541 *TYPEPTR if they were in different objfiles, but that's
542 wrong, too: TYPE may have a field list or member function
543 lists, which refer to types of their own, etc. etc. The
544 whole shebang would need to be copied over recursively; you
545 can't have inter-objfile pointers. The only thing to do is
546 to leave stub types as stub types, and look them up afresh by
547 name each time you encounter them. */
548 gdb_assert (TYPE_OBJFILE (*typeptr) == TYPE_OBJFILE (type));
551 ntype = make_qualified_type (type, new_flags, typeptr ? *typeptr : NULL);
559 /* Replace the contents of ntype with the type *type. This changes the
560 contents, rather than the pointer for TYPE_MAIN_TYPE (ntype); thus
561 the changes are propogated to all types in the TYPE_CHAIN.
563 In order to build recursive types, it's inevitable that we'll need
564 to update types in place --- but this sort of indiscriminate
565 smashing is ugly, and needs to be replaced with something more
566 controlled. TYPE_MAIN_TYPE is a step in this direction; it's not
567 clear if more steps are needed. */
569 replace_type (struct type *ntype, struct type *type)
573 /* These two types had better be in the same objfile. Otherwise,
574 the assignment of one type's main type structure to the other
575 will produce a type with references to objects (names; field
576 lists; etc.) allocated on an objfile other than its own. */
577 gdb_assert (TYPE_OBJFILE (ntype) == TYPE_OBJFILE (ntype));
579 *TYPE_MAIN_TYPE (ntype) = *TYPE_MAIN_TYPE (type);
581 /* The type length is not a part of the main type. Update it for each
582 type on the variant chain. */
585 /* Assert that this element of the chain has no address-class bits
586 set in its flags. Such type variants might have type lengths
587 which are supposed to be different from the non-address-class
588 variants. This assertion shouldn't ever be triggered because
589 symbol readers which do construct address-class variants don't
590 call replace_type(). */
591 gdb_assert (TYPE_ADDRESS_CLASS_ALL (chain) == 0);
593 TYPE_LENGTH (ntype) = TYPE_LENGTH (type);
594 chain = TYPE_CHAIN (chain);
595 } while (ntype != chain);
597 /* Assert that the two types have equivalent instance qualifiers.
598 This should be true for at least all of our debug readers. */
599 gdb_assert (TYPE_INSTANCE_FLAGS (ntype) == TYPE_INSTANCE_FLAGS (type));
602 /* Implement direct support for MEMBER_TYPE in GNU C++.
603 May need to construct such a type if this is the first use.
604 The TYPE is the type of the member. The DOMAIN is the type
605 of the aggregate that the member belongs to. */
608 lookup_member_type (struct type *type, struct type *domain)
612 mtype = alloc_type (TYPE_OBJFILE (type));
613 smash_to_member_type (mtype, domain, type);
617 /* Allocate a stub method whose return type is TYPE.
618 This apparently happens for speed of symbol reading, since parsing
619 out the arguments to the method is cpu-intensive, the way we are doing
620 it. So, we will fill in arguments later.
621 This always returns a fresh type. */
624 allocate_stub_method (struct type *type)
628 mtype = init_type (TYPE_CODE_METHOD, 1, TYPE_FLAG_STUB, NULL,
629 TYPE_OBJFILE (type));
630 TYPE_TARGET_TYPE (mtype) = type;
631 /* _DOMAIN_TYPE (mtype) = unknown yet */
635 /* Create a range type using either a blank type supplied in RESULT_TYPE,
636 or creating a new type, inheriting the objfile from INDEX_TYPE.
638 Indices will be of type INDEX_TYPE, and will range from LOW_BOUND to
639 HIGH_BOUND, inclusive.
641 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
642 sure it is TYPE_CODE_UNDEF before we bash it into a range type? */
645 create_range_type (struct type *result_type, struct type *index_type,
646 int low_bound, int high_bound)
648 if (result_type == NULL)
650 result_type = alloc_type (TYPE_OBJFILE (index_type));
652 TYPE_CODE (result_type) = TYPE_CODE_RANGE;
653 TYPE_TARGET_TYPE (result_type) = index_type;
654 if (TYPE_STUB (index_type))
655 TYPE_FLAGS (result_type) |= TYPE_FLAG_TARGET_STUB;
657 TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type));
658 TYPE_NFIELDS (result_type) = 2;
659 TYPE_FIELDS (result_type) = (struct field *)
660 TYPE_ALLOC (result_type, 2 * sizeof (struct field));
661 memset (TYPE_FIELDS (result_type), 0, 2 * sizeof (struct field));
662 TYPE_FIELD_BITPOS (result_type, 0) = low_bound;
663 TYPE_FIELD_BITPOS (result_type, 1) = high_bound;
664 TYPE_FIELD_TYPE (result_type, 0) = builtin_type_int; /* FIXME */
665 TYPE_FIELD_TYPE (result_type, 1) = builtin_type_int; /* FIXME */
668 TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED;
670 return (result_type);
673 /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type TYPE.
674 Return 1 of type is a range type, 0 if it is discrete (and bounds
675 will fit in LONGEST), or -1 otherwise. */
678 get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp)
680 CHECK_TYPEDEF (type);
681 switch (TYPE_CODE (type))
683 case TYPE_CODE_RANGE:
684 *lowp = TYPE_LOW_BOUND (type);
685 *highp = TYPE_HIGH_BOUND (type);
688 if (TYPE_NFIELDS (type) > 0)
690 /* The enums may not be sorted by value, so search all
694 *lowp = *highp = TYPE_FIELD_BITPOS (type, 0);
695 for (i = 0; i < TYPE_NFIELDS (type); i++)
697 if (TYPE_FIELD_BITPOS (type, i) < *lowp)
698 *lowp = TYPE_FIELD_BITPOS (type, i);
699 if (TYPE_FIELD_BITPOS (type, i) > *highp)
700 *highp = TYPE_FIELD_BITPOS (type, i);
703 /* Set unsigned indicator if warranted. */
706 TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
720 if (TYPE_LENGTH (type) > sizeof (LONGEST)) /* Too big */
722 if (!TYPE_UNSIGNED (type))
724 *lowp = -(1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1));
728 /* ... fall through for unsigned ints ... */
731 /* This round-about calculation is to avoid shifting by
732 TYPE_LENGTH (type) * TARGET_CHAR_BIT, which will not work
733 if TYPE_LENGTH (type) == sizeof (LONGEST). */
734 *highp = 1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1);
735 *highp = (*highp - 1) | *highp;
742 /* Create an array type using either a blank type supplied in RESULT_TYPE,
743 or creating a new type, inheriting the objfile from RANGE_TYPE.
745 Elements will be of type ELEMENT_TYPE, the indices will be of type
748 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
749 sure it is TYPE_CODE_UNDEF before we bash it into an array type? */
752 create_array_type (struct type *result_type, struct type *element_type,
753 struct type *range_type)
755 LONGEST low_bound, high_bound;
757 if (result_type == NULL)
759 result_type = alloc_type (TYPE_OBJFILE (range_type));
761 TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
762 TYPE_TARGET_TYPE (result_type) = element_type;
763 if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
764 low_bound = high_bound = 0;
765 CHECK_TYPEDEF (element_type);
766 TYPE_LENGTH (result_type) =
767 TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
768 TYPE_NFIELDS (result_type) = 1;
769 TYPE_FIELDS (result_type) =
770 (struct field *) TYPE_ALLOC (result_type, sizeof (struct field));
771 memset (TYPE_FIELDS (result_type), 0, sizeof (struct field));
772 TYPE_FIELD_TYPE (result_type, 0) = range_type;
773 TYPE_VPTR_FIELDNO (result_type) = -1;
775 /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays */
776 if (TYPE_LENGTH (result_type) == 0)
777 TYPE_FLAGS (result_type) |= TYPE_FLAG_TARGET_STUB;
779 return (result_type);
782 /* Create a string type using either a blank type supplied in RESULT_TYPE,
783 or creating a new type. String types are similar enough to array of
784 char types that we can use create_array_type to build the basic type
785 and then bash it into a string type.
787 For fixed length strings, the range type contains 0 as the lower
788 bound and the length of the string minus one as the upper bound.
790 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
791 sure it is TYPE_CODE_UNDEF before we bash it into a string type? */
794 create_string_type (struct type *result_type, struct type *range_type)
796 struct type *string_char_type;
798 string_char_type = language_string_char_type (current_language,
800 result_type = create_array_type (result_type,
803 TYPE_CODE (result_type) = TYPE_CODE_STRING;
804 return (result_type);
808 create_set_type (struct type *result_type, struct type *domain_type)
810 LONGEST low_bound, high_bound, bit_length;
811 if (result_type == NULL)
813 result_type = alloc_type (TYPE_OBJFILE (domain_type));
815 TYPE_CODE (result_type) = TYPE_CODE_SET;
816 TYPE_NFIELDS (result_type) = 1;
817 TYPE_FIELDS (result_type) = (struct field *)
818 TYPE_ALLOC (result_type, 1 * sizeof (struct field));
819 memset (TYPE_FIELDS (result_type), 0, sizeof (struct field));
821 if (!TYPE_STUB (domain_type))
823 if (get_discrete_bounds (domain_type, &low_bound, &high_bound) < 0)
824 low_bound = high_bound = 0;
825 bit_length = high_bound - low_bound + 1;
826 TYPE_LENGTH (result_type)
827 = (bit_length + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
829 TYPE_FIELD_TYPE (result_type, 0) = domain_type;
832 TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED;
834 return (result_type);
837 /* Construct and return a type of the form:
838 struct NAME { ELT_TYPE ELT_NAME[N]; }
839 We use these types for SIMD registers. For example, the type of
840 the SSE registers on the late x86-family processors is:
841 struct __builtin_v4sf { float f[4]; }
842 built by the function call:
843 init_simd_type ("__builtin_v4sf", builtin_type_float, "f", 4)
844 The type returned is a permanent type, allocated using malloc; it
845 doesn't live in any objfile's obstack. */
847 init_simd_type (char *name,
848 struct type *elt_type,
852 struct type *simd_type;
853 struct type *array_type;
855 simd_type = init_composite_type (name, TYPE_CODE_STRUCT);
856 array_type = create_array_type (0, elt_type,
857 create_range_type (0, builtin_type_int,
859 append_composite_type_field (simd_type, elt_name, array_type);
864 init_vector_type (struct type *elt_type, int n)
866 struct type *array_type;
868 array_type = create_array_type (0, elt_type,
869 create_range_type (0, builtin_type_int,
871 TYPE_FLAGS (array_type) |= TYPE_FLAG_VECTOR;
876 build_builtin_type_vec64 (void)
878 /* Construct a type for the 64 bit registers. The type we're
881 union __gdb_builtin_type_vec64
893 t = init_composite_type ("__gdb_builtin_type_vec64", TYPE_CODE_UNION);
894 append_composite_type_field (t, "uint64", builtin_type_int64);
895 append_composite_type_field (t, "v2_float", builtin_type_v2_float);
896 append_composite_type_field (t, "v2_int32", builtin_type_v2_int32);
897 append_composite_type_field (t, "v4_int16", builtin_type_v4_int16);
898 append_composite_type_field (t, "v8_int8", builtin_type_v8_int8);
900 TYPE_FLAGS (t) |= TYPE_FLAG_VECTOR;
901 TYPE_NAME (t) = "builtin_type_vec64";
906 build_builtin_type_vec64i (void)
908 /* Construct a type for the 64 bit registers. The type we're
911 union __gdb_builtin_type_vec64i
922 t = init_composite_type ("__gdb_builtin_type_vec64i", TYPE_CODE_UNION);
923 append_composite_type_field (t, "uint64", builtin_type_int64);
924 append_composite_type_field (t, "v2_int32", builtin_type_v2_int32);
925 append_composite_type_field (t, "v4_int16", builtin_type_v4_int16);
926 append_composite_type_field (t, "v8_int8", builtin_type_v8_int8);
928 TYPE_FLAGS (t) |= TYPE_FLAG_VECTOR;
929 TYPE_NAME (t) = "builtin_type_vec64i";
934 build_builtin_type_vec128 (void)
936 /* Construct a type for the 128 bit registers. The type we're
939 union __gdb_builtin_type_vec128
951 t = init_composite_type ("__gdb_builtin_type_vec128", TYPE_CODE_UNION);
952 append_composite_type_field (t, "uint128", builtin_type_int128);
953 append_composite_type_field (t, "v4_float", builtin_type_v4_float);
954 append_composite_type_field (t, "v4_int32", builtin_type_v4_int32);
955 append_composite_type_field (t, "v8_int16", builtin_type_v8_int16);
956 append_composite_type_field (t, "v16_int8", builtin_type_v16_int8);
958 TYPE_FLAGS (t) |= TYPE_FLAG_VECTOR;
959 TYPE_NAME (t) = "builtin_type_vec128";
964 build_builtin_type_vec128i (void)
966 /* 128-bit Intel SIMD registers */
969 t = init_composite_type ("__gdb_builtin_type_vec128i", TYPE_CODE_UNION);
970 append_composite_type_field (t, "v4_float", builtin_type_v4_float);
971 append_composite_type_field (t, "v2_double", builtin_type_v2_double);
972 append_composite_type_field (t, "v16_int8", builtin_type_v16_int8);
973 append_composite_type_field (t, "v8_int16", builtin_type_v8_int16);
974 append_composite_type_field (t, "v4_int32", builtin_type_v4_int32);
975 append_composite_type_field (t, "v2_int64", builtin_type_v2_int64);
976 append_composite_type_field (t, "uint128", builtin_type_int128);
978 TYPE_FLAGS (t) |= TYPE_FLAG_VECTOR;
979 TYPE_NAME (t) = "builtin_type_vec128i";
983 /* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE.
984 A MEMBER is a wierd thing -- it amounts to a typed offset into
985 a struct, e.g. "an int at offset 8". A MEMBER TYPE doesn't
986 include the offset (that's the value of the MEMBER itself), but does
987 include the structure type into which it points (for some reason).
989 When "smashing" the type, we preserve the objfile that the
990 old type pointed to, since we aren't changing where the type is actually
994 smash_to_member_type (struct type *type, struct type *domain,
995 struct type *to_type)
997 struct objfile *objfile;
999 objfile = TYPE_OBJFILE (type);
1002 TYPE_OBJFILE (type) = objfile;
1003 TYPE_TARGET_TYPE (type) = to_type;
1004 TYPE_DOMAIN_TYPE (type) = domain;
1005 TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */
1006 TYPE_CODE (type) = TYPE_CODE_MEMBER;
1009 /* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE.
1010 METHOD just means `function that gets an extra "this" argument'.
1012 When "smashing" the type, we preserve the objfile that the
1013 old type pointed to, since we aren't changing where the type is actually
1017 smash_to_method_type (struct type *type, struct type *domain,
1018 struct type *to_type, struct field *args,
1019 int nargs, int varargs)
1021 struct objfile *objfile;
1023 objfile = TYPE_OBJFILE (type);
1026 TYPE_OBJFILE (type) = objfile;
1027 TYPE_TARGET_TYPE (type) = to_type;
1028 TYPE_DOMAIN_TYPE (type) = domain;
1029 TYPE_FIELDS (type) = args;
1030 TYPE_NFIELDS (type) = nargs;
1032 TYPE_FLAGS (type) |= TYPE_FLAG_VARARGS;
1033 TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */
1034 TYPE_CODE (type) = TYPE_CODE_METHOD;
1037 /* Return a typename for a struct/union/enum type without "struct ",
1038 "union ", or "enum ". If the type has a NULL name, return NULL. */
1041 type_name_no_tag (const struct type *type)
1043 if (TYPE_TAG_NAME (type) != NULL)
1044 return TYPE_TAG_NAME (type);
1046 /* Is there code which expects this to return the name if there is no
1047 tag name? My guess is that this is mainly used for C++ in cases where
1048 the two will always be the same. */
1049 return TYPE_NAME (type);
1052 /* Lookup a typedef or primitive type named NAME,
1053 visible in lexical block BLOCK.
1054 If NOERR is nonzero, return zero if NAME is not suitably defined. */
1057 lookup_typename (char *name, struct block *block, int noerr)
1062 sym = lookup_symbol (name, block, VAR_DOMAIN, 0, (struct symtab **) NULL);
1063 if (sym == NULL || SYMBOL_CLASS (sym) != LOC_TYPEDEF)
1065 tmp = language_lookup_primitive_type_by_name (current_language,
1072 else if (!tmp && noerr)
1078 error ("No type named %s.", name);
1081 return (SYMBOL_TYPE (sym));
1085 lookup_unsigned_typename (char *name)
1087 char *uns = alloca (strlen (name) + 10);
1089 strcpy (uns, "unsigned ");
1090 strcpy (uns + 9, name);
1091 return (lookup_typename (uns, (struct block *) NULL, 0));
1095 lookup_signed_typename (char *name)
1098 char *uns = alloca (strlen (name) + 8);
1100 strcpy (uns, "signed ");
1101 strcpy (uns + 7, name);
1102 t = lookup_typename (uns, (struct block *) NULL, 1);
1103 /* If we don't find "signed FOO" just try again with plain "FOO". */
1106 return lookup_typename (name, (struct block *) NULL, 0);
1109 /* Lookup a structure type named "struct NAME",
1110 visible in lexical block BLOCK. */
1113 lookup_struct (char *name, struct block *block)
1117 sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0,
1118 (struct symtab **) NULL);
1122 error ("No struct type named %s.", name);
1124 if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT)
1126 error ("This context has class, union or enum %s, not a struct.", name);
1128 return (SYMBOL_TYPE (sym));
1131 /* Lookup a union type named "union NAME",
1132 visible in lexical block BLOCK. */
1135 lookup_union (char *name, struct block *block)
1140 sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0,
1141 (struct symtab **) NULL);
1144 error ("No union type named %s.", name);
1146 t = SYMBOL_TYPE (sym);
1148 if (TYPE_CODE (t) == TYPE_CODE_UNION)
1151 /* C++ unions may come out with TYPE_CODE_CLASS, but we look at
1152 * a further "declared_type" field to discover it is really a union.
1154 if (HAVE_CPLUS_STRUCT (t))
1155 if (TYPE_DECLARED_TYPE (t) == DECLARED_TYPE_UNION)
1158 /* If we get here, it's not a union */
1159 error ("This context has class, struct or enum %s, not a union.", name);
1163 /* Lookup an enum type named "enum NAME",
1164 visible in lexical block BLOCK. */
1167 lookup_enum (char *name, struct block *block)
1171 sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0,
1172 (struct symtab **) NULL);
1175 error ("No enum type named %s.", name);
1177 if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_ENUM)
1179 error ("This context has class, struct or union %s, not an enum.", name);
1181 return (SYMBOL_TYPE (sym));
1184 /* Lookup a template type named "template NAME<TYPE>",
1185 visible in lexical block BLOCK. */
1188 lookup_template_type (char *name, struct type *type, struct block *block)
1191 char *nam = (char *) alloca (strlen (name) + strlen (TYPE_NAME (type)) + 4);
1194 strcat (nam, TYPE_NAME (type));
1195 strcat (nam, " >"); /* FIXME, extra space still introduced in gcc? */
1197 sym = lookup_symbol (nam, block, VAR_DOMAIN, 0, (struct symtab **) NULL);
1201 error ("No template type named %s.", name);
1203 if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT)
1205 error ("This context has class, union or enum %s, not a struct.", name);
1207 return (SYMBOL_TYPE (sym));
1210 /* Given a type TYPE, lookup the type of the component of type named NAME.
1212 TYPE can be either a struct or union, or a pointer or reference to a struct or
1213 union. If it is a pointer or reference, its target type is automatically used.
1214 Thus '.' and '->' are interchangable, as specified for the definitions of the
1215 expression element types STRUCTOP_STRUCT and STRUCTOP_PTR.
1217 If NOERR is nonzero, return zero if NAME is not suitably defined.
1218 If NAME is the name of a baseclass type, return that type. */
1221 lookup_struct_elt_type (struct type *type, char *name, int noerr)
1227 CHECK_TYPEDEF (type);
1228 if (TYPE_CODE (type) != TYPE_CODE_PTR
1229 && TYPE_CODE (type) != TYPE_CODE_REF)
1231 type = TYPE_TARGET_TYPE (type);
1234 if (TYPE_CODE (type) != TYPE_CODE_STRUCT &&
1235 TYPE_CODE (type) != TYPE_CODE_UNION)
1237 target_terminal_ours ();
1238 gdb_flush (gdb_stdout);
1239 fprintf_unfiltered (gdb_stderr, "Type ");
1240 type_print (type, "", gdb_stderr, -1);
1241 error (" is not a structure or union type.");
1245 /* FIXME: This change put in by Michael seems incorrect for the case where
1246 the structure tag name is the same as the member name. I.E. when doing
1247 "ptype bell->bar" for "struct foo { int bar; int foo; } bell;"
1252 typename = type_name_no_tag (type);
1253 if (typename != NULL && strcmp (typename, name) == 0)
1258 for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--)
1260 char *t_field_name = TYPE_FIELD_NAME (type, i);
1262 if (t_field_name && (strcmp_iw (t_field_name, name) == 0))
1264 return TYPE_FIELD_TYPE (type, i);
1268 /* OK, it's not in this class. Recursively check the baseclasses. */
1269 for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
1273 t = lookup_struct_elt_type (TYPE_BASECLASS (type, i), name, noerr);
1285 target_terminal_ours ();
1286 gdb_flush (gdb_stdout);
1287 fprintf_unfiltered (gdb_stderr, "Type ");
1288 type_print (type, "", gdb_stderr, -1);
1289 fprintf_unfiltered (gdb_stderr, " has no component named ");
1290 fputs_filtered (name, gdb_stderr);
1292 return (struct type *) -1; /* For lint */
1295 /* If possible, make the vptr_fieldno and vptr_basetype fields of TYPE
1296 valid. Callers should be aware that in some cases (for example,
1297 the type or one of its baseclasses is a stub type and we are
1298 debugging a .o file), this function will not be able to find the virtual
1299 function table pointer, and vptr_fieldno will remain -1 and vptr_basetype
1300 will remain NULL. */
1303 fill_in_vptr_fieldno (struct type *type)
1305 CHECK_TYPEDEF (type);
1307 if (TYPE_VPTR_FIELDNO (type) < 0)
1311 /* We must start at zero in case the first (and only) baseclass is
1312 virtual (and hence we cannot share the table pointer). */
1313 for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
1315 struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
1316 fill_in_vptr_fieldno (baseclass);
1317 if (TYPE_VPTR_FIELDNO (baseclass) >= 0)
1319 TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (baseclass);
1320 TYPE_VPTR_BASETYPE (type) = TYPE_VPTR_BASETYPE (baseclass);
1327 /* Find the method and field indices for the destructor in class type T.
1328 Return 1 if the destructor was found, otherwise, return 0. */
1331 get_destructor_fn_field (struct type *t, int *method_indexp, int *field_indexp)
1335 for (i = 0; i < TYPE_NFN_FIELDS (t); i++)
1338 struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i);
1340 for (j = 0; j < TYPE_FN_FIELDLIST_LENGTH (t, i); j++)
1342 if (is_destructor_name (TYPE_FN_FIELD_PHYSNAME (f, j)) != 0)
1354 stub_noname_complaint (void)
1356 complaint (&symfile_complaints, "stub type has NULL name");
1359 /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989.
1361 If this is a stubbed struct (i.e. declared as struct foo *), see if
1362 we can find a full definition in some other file. If so, copy this
1363 definition, so we can use it in future. There used to be a comment (but
1364 not any code) that if we don't find a full definition, we'd set a flag
1365 so we don't spend time in the future checking the same type. That would
1366 be a mistake, though--we might load in more symbols which contain a
1367 full definition for the type.
1369 This used to be coded as a macro, but I don't think it is called
1370 often enough to merit such treatment. */
1372 /* Find the real type of TYPE. This function returns the real type, after
1373 removing all layers of typedefs and completing opaque or stub types.
1374 Completion changes the TYPE argument, but stripping of typedefs does
1378 check_typedef (struct type *type)
1380 struct type *orig_type = type;
1381 int is_const, is_volatile;
1383 while (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
1385 if (!TYPE_TARGET_TYPE (type))
1390 /* It is dangerous to call lookup_symbol if we are currently
1391 reading a symtab. Infinite recursion is one danger. */
1392 if (currently_reading_symtab)
1395 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_DOMAIN and/or VAR_DOMAIN
1398 as appropriate? (this code was written before TYPE_NAME and
1399 TYPE_TAG_NAME were separate). */
1402 stub_noname_complaint ();
1405 sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0,
1406 (struct symtab **) NULL);
1408 TYPE_TARGET_TYPE (type) = SYMBOL_TYPE (sym);
1410 TYPE_TARGET_TYPE (type) = alloc_type (NULL); /* TYPE_CODE_UNDEF */
1412 type = TYPE_TARGET_TYPE (type);
1415 is_const = TYPE_CONST (type);
1416 is_volatile = TYPE_VOLATILE (type);
1418 /* If this is a struct/class/union with no fields, then check whether a
1419 full definition exists somewhere else. This is for systems where a
1420 type definition with no fields is issued for such types, instead of
1421 identifying them as stub types in the first place */
1423 if (TYPE_IS_OPAQUE (type) && opaque_type_resolution && !currently_reading_symtab)
1425 char *name = type_name_no_tag (type);
1426 struct type *newtype;
1429 stub_noname_complaint ();
1432 newtype = lookup_transparent_type (name);
1436 /* If the resolved type and the stub are in the same objfile,
1437 then replace the stub type with the real deal. But if
1438 they're in separate objfiles, leave the stub alone; we'll
1439 just look up the transparent type every time we call
1440 check_typedef. We can't create pointers between types
1441 allocated to different objfiles, since they may have
1442 different lifetimes. Trying to copy NEWTYPE over to TYPE's
1443 objfile is pointless, too, since you'll have to move over any
1444 other types NEWTYPE refers to, which could be an unbounded
1446 if (TYPE_OBJFILE (newtype) == TYPE_OBJFILE (type))
1447 make_cv_type (is_const, is_volatile, newtype, &type);
1452 /* Otherwise, rely on the stub flag being set for opaque/stubbed types */
1453 else if (TYPE_STUB (type) && !currently_reading_symtab)
1455 char *name = type_name_no_tag (type);
1456 /* FIXME: shouldn't we separately check the TYPE_NAME and the
1457 TYPE_TAG_NAME, and look in STRUCT_DOMAIN and/or VAR_DOMAIN
1458 as appropriate? (this code was written before TYPE_NAME and
1459 TYPE_TAG_NAME were separate). */
1463 stub_noname_complaint ();
1466 sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);
1468 make_cv_type (is_const, is_volatile, SYMBOL_TYPE (sym), &type);
1471 if (TYPE_TARGET_STUB (type))
1473 struct type *range_type;
1474 struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type));
1476 if (TYPE_STUB (target_type) || TYPE_TARGET_STUB (target_type))
1479 else if (TYPE_CODE (type) == TYPE_CODE_ARRAY
1480 && TYPE_NFIELDS (type) == 1
1481 && (TYPE_CODE (range_type = TYPE_FIELD_TYPE (type, 0))
1482 == TYPE_CODE_RANGE))
1484 /* Now recompute the length of the array type, based on its
1485 number of elements and the target type's length. */
1486 TYPE_LENGTH (type) =
1487 ((TYPE_FIELD_BITPOS (range_type, 1)
1488 - TYPE_FIELD_BITPOS (range_type, 0)
1490 * TYPE_LENGTH (target_type));
1491 TYPE_FLAGS (type) &= ~TYPE_FLAG_TARGET_STUB;
1493 else if (TYPE_CODE (type) == TYPE_CODE_RANGE)
1495 TYPE_LENGTH (type) = TYPE_LENGTH (target_type);
1496 TYPE_FLAGS (type) &= ~TYPE_FLAG_TARGET_STUB;
1499 /* Cache TYPE_LENGTH for future use. */
1500 TYPE_LENGTH (orig_type) = TYPE_LENGTH (type);
1504 /* Parse a type expression in the string [P..P+LENGTH). If an error occurs,
1505 silently return builtin_type_void. */
1507 static struct type *
1508 safe_parse_type (char *p, int length)
1510 struct ui_file *saved_gdb_stderr;
1513 /* Suppress error messages. */
1514 saved_gdb_stderr = gdb_stderr;
1515 gdb_stderr = ui_file_new ();
1517 /* Call parse_and_eval_type() without fear of longjmp()s. */
1518 if (!gdb_parse_and_eval_type (p, length, &type))
1519 type = builtin_type_void;
1521 /* Stop suppressing error messages. */
1522 ui_file_delete (gdb_stderr);
1523 gdb_stderr = saved_gdb_stderr;
1528 /* Ugly hack to convert method stubs into method types.
1530 He ain't kiddin'. This demangles the name of the method into a string
1531 including argument types, parses out each argument type, generates
1532 a string casting a zero to that type, evaluates the string, and stuffs
1533 the resulting type into an argtype vector!!! Then it knows the type
1534 of the whole function (including argument types for overloading),
1535 which info used to be in the stab's but was removed to hack back
1536 the space required for them. */
1539 check_stub_method (struct type *type, int method_id, int signature_id)
1542 char *mangled_name = gdb_mangle_name (type, method_id, signature_id);
1543 char *demangled_name = cplus_demangle (mangled_name,
1544 DMGL_PARAMS | DMGL_ANSI);
1545 char *argtypetext, *p;
1546 int depth = 0, argcount = 1;
1547 struct field *argtypes;
1550 /* Make sure we got back a function string that we can use. */
1552 p = strchr (demangled_name, '(');
1556 if (demangled_name == NULL || p == NULL)
1557 error ("Internal: Cannot demangle mangled name `%s'.", mangled_name);
1559 /* Now, read in the parameters that define this type. */
1564 if (*p == '(' || *p == '<')
1568 else if (*p == ')' || *p == '>')
1572 else if (*p == ',' && depth == 0)
1580 /* If we read one argument and it was ``void'', don't count it. */
1581 if (strncmp (argtypetext, "(void)", 6) == 0)
1584 /* We need one extra slot, for the THIS pointer. */
1586 argtypes = (struct field *)
1587 TYPE_ALLOC (type, (argcount + 1) * sizeof (struct field));
1590 /* Add THIS pointer for non-static methods. */
1591 f = TYPE_FN_FIELDLIST1 (type, method_id);
1592 if (TYPE_FN_FIELD_STATIC_P (f, signature_id))
1596 argtypes[0].type = lookup_pointer_type (type);
1600 if (*p != ')') /* () means no args, skip while */
1605 if (depth <= 0 && (*p == ',' || *p == ')'))
1607 /* Avoid parsing of ellipsis, they will be handled below.
1608 Also avoid ``void'' as above. */
1609 if (strncmp (argtypetext, "...", p - argtypetext) != 0
1610 && strncmp (argtypetext, "void", p - argtypetext) != 0)
1612 argtypes[argcount].type =
1613 safe_parse_type (argtypetext, p - argtypetext);
1616 argtypetext = p + 1;
1619 if (*p == '(' || *p == '<')
1623 else if (*p == ')' || *p == '>')
1632 TYPE_FN_FIELD_PHYSNAME (f, signature_id) = mangled_name;
1634 /* Now update the old "stub" type into a real type. */
1635 mtype = TYPE_FN_FIELD_TYPE (f, signature_id);
1636 TYPE_DOMAIN_TYPE (mtype) = type;
1637 TYPE_FIELDS (mtype) = argtypes;
1638 TYPE_NFIELDS (mtype) = argcount;
1639 TYPE_FLAGS (mtype) &= ~TYPE_FLAG_STUB;
1640 TYPE_FN_FIELD_STUB (f, signature_id) = 0;
1642 TYPE_FLAGS (mtype) |= TYPE_FLAG_VARARGS;
1644 xfree (demangled_name);
1647 /* This is the external interface to check_stub_method, above. This function
1648 unstubs all of the signatures for TYPE's METHOD_ID method name. After
1649 calling this function TYPE_FN_FIELD_STUB will be cleared for each signature
1650 and TYPE_FN_FIELDLIST_NAME will be correct.
1652 This function unfortunately can not die until stabs do. */
1655 check_stub_method_group (struct type *type, int method_id)
1657 int len = TYPE_FN_FIELDLIST_LENGTH (type, method_id);
1658 struct fn_field *f = TYPE_FN_FIELDLIST1 (type, method_id);
1659 int j, found_stub = 0;
1661 for (j = 0; j < len; j++)
1662 if (TYPE_FN_FIELD_STUB (f, j))
1665 check_stub_method (type, method_id, j);
1668 /* GNU v3 methods with incorrect names were corrected when we read in
1669 type information, because it was cheaper to do it then. The only GNU v2
1670 methods with incorrect method names are operators and destructors;
1671 destructors were also corrected when we read in type information.
1673 Therefore the only thing we need to handle here are v2 operator
1675 if (found_stub && strncmp (TYPE_FN_FIELD_PHYSNAME (f, 0), "_Z", 2) != 0)
1678 char dem_opname[256];
1680 ret = cplus_demangle_opname (TYPE_FN_FIELDLIST_NAME (type, method_id),
1681 dem_opname, DMGL_ANSI);
1683 ret = cplus_demangle_opname (TYPE_FN_FIELDLIST_NAME (type, method_id),
1686 TYPE_FN_FIELDLIST_NAME (type, method_id) = xstrdup (dem_opname);
1690 const struct cplus_struct_type cplus_struct_default;
1693 allocate_cplus_struct_type (struct type *type)
1695 if (!HAVE_CPLUS_STRUCT (type))
1697 TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *)
1698 TYPE_ALLOC (type, sizeof (struct cplus_struct_type));
1699 *(TYPE_CPLUS_SPECIFIC (type)) = cplus_struct_default;
1703 /* Helper function to initialize the standard scalar types.
1705 If NAME is non-NULL and OBJFILE is non-NULL, then we make a copy
1706 of the string pointed to by name in the objfile_obstack for that objfile,
1707 and initialize the type name to that copy. There are places (mipsread.c
1708 in particular, where init_type is called with a NULL value for NAME). */
1711 init_type (enum type_code code, int length, int flags, char *name,
1712 struct objfile *objfile)
1716 type = alloc_type (objfile);
1717 TYPE_CODE (type) = code;
1718 TYPE_LENGTH (type) = length;
1719 TYPE_FLAGS (type) |= flags;
1720 if ((name != NULL) && (objfile != NULL))
1723 obsavestring (name, strlen (name), &objfile->objfile_obstack);
1727 TYPE_NAME (type) = name;
1732 if (name && strcmp (name, "char") == 0)
1733 TYPE_FLAGS (type) |= TYPE_FLAG_NOSIGN;
1735 if (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
1736 || code == TYPE_CODE_NAMESPACE)
1738 INIT_CPLUS_SPECIFIC (type);
1743 /* Helper function. Create an empty composite type. */
1746 init_composite_type (char *name, enum type_code code)
1749 gdb_assert (code == TYPE_CODE_STRUCT
1750 || code == TYPE_CODE_UNION);
1751 t = init_type (code, 0, 0, NULL, NULL);
1752 TYPE_TAG_NAME (t) = name;
1756 /* Helper function. Append a field to a composite type. */
1759 append_composite_type_field (struct type *t, char *name, struct type *field)
1762 TYPE_NFIELDS (t) = TYPE_NFIELDS (t) + 1;
1763 TYPE_FIELDS (t) = xrealloc (TYPE_FIELDS (t),
1764 sizeof (struct field) * TYPE_NFIELDS (t));
1765 f = &(TYPE_FIELDS (t)[TYPE_NFIELDS (t) - 1]);
1766 memset (f, 0, sizeof f[0]);
1767 FIELD_TYPE (f[0]) = field;
1768 FIELD_NAME (f[0]) = name;
1769 if (TYPE_CODE (t) == TYPE_CODE_UNION)
1771 if (TYPE_LENGTH (t) < TYPE_LENGTH (field))
1772 TYPE_LENGTH (t) = TYPE_LENGTH (field);
1774 else if (TYPE_CODE (t) == TYPE_CODE_STRUCT)
1776 TYPE_LENGTH (t) = TYPE_LENGTH (t) + TYPE_LENGTH (field);
1777 if (TYPE_NFIELDS (t) > 1)
1779 FIELD_BITPOS (f[0]) = (FIELD_BITPOS (f[-1])
1780 + TYPE_LENGTH (field) * TARGET_CHAR_BIT);
1785 /* Look up a fundamental type for the specified objfile.
1786 May need to construct such a type if this is the first use.
1788 Some object file formats (ELF, COFF, etc) do not define fundamental
1789 types such as "int" or "double". Others (stabs for example), do
1790 define fundamental types.
1792 For the formats which don't provide fundamental types, gdb can create
1793 such types, using defaults reasonable for the current language and
1794 the current target machine.
1796 NOTE: This routine is obsolescent. Each debugging format reader
1797 should manage it's own fundamental types, either creating them from
1798 suitable defaults or reading them from the debugging information,
1799 whichever is appropriate. The DWARF reader has already been
1800 fixed to do this. Once the other readers are fixed, this routine
1801 will go away. Also note that fundamental types should be managed
1802 on a compilation unit basis in a multi-language environment, not
1803 on a linkage unit basis as is done here. */
1807 lookup_fundamental_type (struct objfile *objfile, int typeid)
1809 struct type **typep;
1812 if (typeid < 0 || typeid >= FT_NUM_MEMBERS)
1814 error ("internal error - invalid fundamental type id %d", typeid);
1817 /* If this is the first time we need a fundamental type for this objfile
1818 then we need to initialize the vector of type pointers. */
1820 if (objfile->fundamental_types == NULL)
1822 nbytes = FT_NUM_MEMBERS * sizeof (struct type *);
1823 objfile->fundamental_types = (struct type **)
1824 obstack_alloc (&objfile->objfile_obstack, nbytes);
1825 memset ((char *) objfile->fundamental_types, 0, nbytes);
1826 OBJSTAT (objfile, n_types += FT_NUM_MEMBERS);
1829 /* Look for this particular type in the fundamental type vector. If one is
1830 not found, create and install one appropriate for the current language. */
1832 typep = objfile->fundamental_types + typeid;
1835 *typep = create_fundamental_type (objfile, typeid);
1842 can_dereference (struct type *t)
1844 /* FIXME: Should we return true for references as well as pointers? */
1848 && TYPE_CODE (t) == TYPE_CODE_PTR
1849 && TYPE_CODE (TYPE_TARGET_TYPE (t)) != TYPE_CODE_VOID);
1853 is_integral_type (struct type *t)
1858 && ((TYPE_CODE (t) == TYPE_CODE_INT)
1859 || (TYPE_CODE (t) == TYPE_CODE_ENUM)
1860 || (TYPE_CODE (t) == TYPE_CODE_CHAR)
1861 || (TYPE_CODE (t) == TYPE_CODE_RANGE)
1862 || (TYPE_CODE (t) == TYPE_CODE_BOOL)));
1865 /* Check whether BASE is an ancestor or base class or DCLASS
1866 Return 1 if so, and 0 if not.
1867 Note: callers may want to check for identity of the types before
1868 calling this function -- identical types are considered to satisfy
1869 the ancestor relationship even if they're identical */
1872 is_ancestor (struct type *base, struct type *dclass)
1876 CHECK_TYPEDEF (base);
1877 CHECK_TYPEDEF (dclass);
1881 if (TYPE_NAME (base) && TYPE_NAME (dclass) &&
1882 !strcmp (TYPE_NAME (base), TYPE_NAME (dclass)))
1885 for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++)
1886 if (is_ancestor (base, TYPE_BASECLASS (dclass, i)))
1894 /* See whether DCLASS has a virtual table. This routine is aimed at
1895 the HP/Taligent ANSI C++ runtime model, and may not work with other
1896 runtime models. Return 1 => Yes, 0 => No. */
1899 has_vtable (struct type *dclass)
1901 /* In the HP ANSI C++ runtime model, a class has a vtable only if it
1902 has virtual functions or virtual bases. */
1906 if (TYPE_CODE (dclass) != TYPE_CODE_CLASS)
1909 /* First check for the presence of virtual bases */
1910 if (TYPE_FIELD_VIRTUAL_BITS (dclass))
1911 for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++)
1912 if (B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass), i))
1915 /* Next check for virtual functions */
1916 if (TYPE_FN_FIELDLISTS (dclass))
1917 for (i = 0; i < TYPE_NFN_FIELDS (dclass); i++)
1918 if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass, i), 0))
1921 /* Recurse on non-virtual bases to see if any of them needs a vtable */
1922 if (TYPE_FIELD_VIRTUAL_BITS (dclass))
1923 for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++)
1924 if ((!B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass), i)) &&
1925 (has_vtable (TYPE_FIELD_TYPE (dclass, i))))
1928 /* Well, maybe we don't need a virtual table */
1932 /* Return a pointer to the "primary base class" of DCLASS.
1934 A NULL return indicates that DCLASS has no primary base, or that it
1935 couldn't be found (insufficient information).
1937 This routine is aimed at the HP/Taligent ANSI C++ runtime model,
1938 and may not work with other runtime models. */
1941 primary_base_class (struct type *dclass)
1943 /* In HP ANSI C++'s runtime model, a "primary base class" of a class
1944 is the first directly inherited, non-virtual base class that
1945 requires a virtual table */
1949 if (TYPE_CODE (dclass) != TYPE_CODE_CLASS)
1952 for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++)
1953 if (!TYPE_FIELD_VIRTUAL (dclass, i) &&
1954 has_vtable (TYPE_FIELD_TYPE (dclass, i)))
1955 return TYPE_FIELD_TYPE (dclass, i);
1960 /* Global manipulated by virtual_base_list[_aux]() */
1962 static struct vbase *current_vbase_list = NULL;
1964 /* Return a pointer to a null-terminated list of struct vbase
1965 items. The vbasetype pointer of each item in the list points to the
1966 type information for a virtual base of the argument DCLASS.
1968 Helper function for virtual_base_list().
1969 Note: the list goes backward, right-to-left. virtual_base_list()
1970 copies the items out in reverse order. */
1973 virtual_base_list_aux (struct type *dclass)
1975 struct vbase *tmp_vbase;
1978 if (TYPE_CODE (dclass) != TYPE_CODE_CLASS)
1981 for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++)
1983 /* Recurse on this ancestor, first */
1984 virtual_base_list_aux (TYPE_FIELD_TYPE (dclass, i));
1986 /* If this current base is itself virtual, add it to the list */
1987 if (BASETYPE_VIA_VIRTUAL (dclass, i))
1989 struct type *basetype = TYPE_FIELD_TYPE (dclass, i);
1991 /* Check if base already recorded */
1992 tmp_vbase = current_vbase_list;
1995 if (tmp_vbase->vbasetype == basetype)
1996 break; /* found it */
1997 tmp_vbase = tmp_vbase->next;
2000 if (!tmp_vbase) /* normal exit from loop */
2002 /* Allocate new item for this virtual base */
2003 tmp_vbase = (struct vbase *) xmalloc (sizeof (struct vbase));
2005 /* Stick it on at the end of the list */
2006 tmp_vbase->vbasetype = basetype;
2007 tmp_vbase->next = current_vbase_list;
2008 current_vbase_list = tmp_vbase;
2011 } /* for loop over bases */
2015 /* Compute the list of virtual bases in the right order. Virtual
2016 bases are laid out in the object's memory area in order of their
2017 occurrence in a depth-first, left-to-right search through the
2020 Argument DCLASS is the type whose virtual bases are required.
2021 Return value is the address of a null-terminated array of pointers
2022 to struct type items.
2024 This routine is aimed at the HP/Taligent ANSI C++ runtime model,
2025 and may not work with other runtime models.
2027 This routine merely hands off the argument to virtual_base_list_aux()
2028 and then copies the result into an array to save space. */
2031 virtual_base_list (struct type *dclass)
2033 struct vbase *tmp_vbase;
2034 struct vbase *tmp_vbase_2;
2037 struct type **vbase_array;
2039 current_vbase_list = NULL;
2040 virtual_base_list_aux (dclass);
2042 for (i = 0, tmp_vbase = current_vbase_list; tmp_vbase != NULL; i++, tmp_vbase = tmp_vbase->next)
2047 vbase_array = (struct type **) xmalloc ((count + 1) * sizeof (struct type *));
2049 for (i = count - 1, tmp_vbase = current_vbase_list; i >= 0; i--, tmp_vbase = tmp_vbase->next)
2050 vbase_array[i] = tmp_vbase->vbasetype;
2052 /* Get rid of constructed chain */
2053 tmp_vbase_2 = tmp_vbase = current_vbase_list;
2056 tmp_vbase = tmp_vbase->next;
2057 xfree (tmp_vbase_2);
2058 tmp_vbase_2 = tmp_vbase;
2061 vbase_array[count] = NULL;
2065 /* Return the length of the virtual base list of the type DCLASS. */
2068 virtual_base_list_length (struct type *dclass)
2071 struct vbase *tmp_vbase;
2073 current_vbase_list = NULL;
2074 virtual_base_list_aux (dclass);
2076 for (i = 0, tmp_vbase = current_vbase_list; tmp_vbase != NULL; i++, tmp_vbase = tmp_vbase->next)
2081 /* Return the number of elements of the virtual base list of the type
2082 DCLASS, ignoring those appearing in the primary base (and its
2083 primary base, recursively). */
2086 virtual_base_list_length_skip_primaries (struct type *dclass)
2089 struct vbase *tmp_vbase;
2090 struct type *primary;
2092 primary = TYPE_RUNTIME_PTR (dclass) ? TYPE_PRIMARY_BASE (dclass) : NULL;
2095 return virtual_base_list_length (dclass);
2097 current_vbase_list = NULL;
2098 virtual_base_list_aux (dclass);
2100 for (i = 0, tmp_vbase = current_vbase_list; tmp_vbase != NULL; tmp_vbase = tmp_vbase->next)
2102 if (virtual_base_index (tmp_vbase->vbasetype, primary) >= 0)
2110 /* Return the index (position) of type BASE, which is a virtual base
2111 class of DCLASS, in the latter's virtual base list. A return of -1
2112 indicates "not found" or a problem. */
2115 virtual_base_index (struct type *base, struct type *dclass)
2120 if ((TYPE_CODE (dclass) != TYPE_CODE_CLASS) ||
2121 (TYPE_CODE (base) != TYPE_CODE_CLASS))
2125 vbase = virtual_base_list (dclass)[0];
2130 vbase = virtual_base_list (dclass)[++i];
2133 return vbase ? i : -1;
2138 /* Return the index (position) of type BASE, which is a virtual base
2139 class of DCLASS, in the latter's virtual base list. Skip over all
2140 bases that may appear in the virtual base list of the primary base
2141 class of DCLASS (recursively). A return of -1 indicates "not
2142 found" or a problem. */
2145 virtual_base_index_skip_primaries (struct type *base, struct type *dclass)
2149 struct type *primary;
2151 if ((TYPE_CODE (dclass) != TYPE_CODE_CLASS) ||
2152 (TYPE_CODE (base) != TYPE_CODE_CLASS))
2155 primary = TYPE_RUNTIME_PTR (dclass) ? TYPE_PRIMARY_BASE (dclass) : NULL;
2159 vbase = virtual_base_list (dclass)[0];
2162 if (!primary || (virtual_base_index_skip_primaries (vbase, primary) < 0))
2166 vbase = virtual_base_list (dclass)[++i];
2169 return vbase ? j : -1;
2172 /* Return position of a derived class DCLASS in the list of
2173 * primary bases starting with the remotest ancestor.
2174 * Position returned is 0-based. */
2177 class_index_in_primary_list (struct type *dclass)
2179 struct type *pbc; /* primary base class */
2181 /* Simply recurse on primary base */
2182 pbc = TYPE_PRIMARY_BASE (dclass);
2184 return 1 + class_index_in_primary_list (pbc);
2189 /* Return a count of the number of virtual functions a type has.
2190 * This includes all the virtual functions it inherits from its
2194 /* pai: FIXME This doesn't do the right thing: count redefined virtual
2195 * functions only once (latest redefinition)
2199 count_virtual_fns (struct type *dclass)
2201 int fn, oi; /* function and overloaded instance indices */
2202 int vfuncs; /* count to return */
2204 /* recurse on bases that can share virtual table */
2205 struct type *pbc = primary_base_class (dclass);
2207 vfuncs = count_virtual_fns (pbc);
2211 for (fn = 0; fn < TYPE_NFN_FIELDS (dclass); fn++)
2212 for (oi = 0; oi < TYPE_FN_FIELDLIST_LENGTH (dclass, fn); oi++)
2213 if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass, fn), oi))
2221 /* Functions for overload resolution begin here */
2223 /* Compare two badness vectors A and B and return the result.
2224 * 0 => A and B are identical
2225 * 1 => A and B are incomparable
2226 * 2 => A is better than B
2227 * 3 => A is worse than B */
2230 compare_badness (struct badness_vector *a, struct badness_vector *b)
2234 short found_pos = 0; /* any positives in c? */
2235 short found_neg = 0; /* any negatives in c? */
2237 /* differing lengths => incomparable */
2238 if (a->length != b->length)
2241 /* Subtract b from a */
2242 for (i = 0; i < a->length; i++)
2244 tmp = a->rank[i] - b->rank[i];
2254 return 1; /* incomparable */
2256 return 3; /* A > B */
2262 return 2; /* A < B */
2264 return 0; /* A == B */
2268 /* Rank a function by comparing its parameter types (PARMS, length NPARMS),
2269 * to the types of an argument list (ARGS, length NARGS).
2270 * Return a pointer to a badness vector. This has NARGS + 1 entries. */
2272 struct badness_vector *
2273 rank_function (struct type **parms, int nparms, struct type **args, int nargs)
2276 struct badness_vector *bv;
2277 int min_len = nparms < nargs ? nparms : nargs;
2279 bv = xmalloc (sizeof (struct badness_vector));
2280 bv->length = nargs + 1; /* add 1 for the length-match rank */
2281 bv->rank = xmalloc ((nargs + 1) * sizeof (int));
2283 /* First compare the lengths of the supplied lists.
2284 * If there is a mismatch, set it to a high value. */
2286 /* pai/1997-06-03 FIXME: when we have debug info about default
2287 * arguments and ellipsis parameter lists, we should consider those
2288 * and rank the length-match more finely. */
2290 LENGTH_MATCH (bv) = (nargs != nparms) ? LENGTH_MISMATCH_BADNESS : 0;
2292 /* Now rank all the parameters of the candidate function */
2293 for (i = 1; i <= min_len; i++)
2294 bv->rank[i] = rank_one_type (parms[i-1], args[i-1]);
2296 /* If more arguments than parameters, add dummy entries */
2297 for (i = min_len + 1; i <= nargs; i++)
2298 bv->rank[i] = TOO_FEW_PARAMS_BADNESS;
2303 /* Compare the names of two integer types, assuming that any sign
2304 qualifiers have been checked already. We do it this way because
2305 there may be an "int" in the name of one of the types. */
2308 integer_types_same_name_p (const char *first, const char *second)
2310 int first_p, second_p;
2312 /* If both are shorts, return 1; if neither is a short, keep checking. */
2313 first_p = (strstr (first, "short") != NULL);
2314 second_p = (strstr (second, "short") != NULL);
2315 if (first_p && second_p)
2317 if (first_p || second_p)
2320 /* Likewise for long. */
2321 first_p = (strstr (first, "long") != NULL);
2322 second_p = (strstr (second, "long") != NULL);
2323 if (first_p && second_p)
2325 if (first_p || second_p)
2328 /* Likewise for char. */
2329 first_p = (strstr (first, "char") != NULL);
2330 second_p = (strstr (second, "char") != NULL);
2331 if (first_p && second_p)
2333 if (first_p || second_p)
2336 /* They must both be ints. */
2340 /* Compare one type (PARM) for compatibility with another (ARG).
2341 * PARM is intended to be the parameter type of a function; and
2342 * ARG is the supplied argument's type. This function tests if
2343 * the latter can be converted to the former.
2345 * Return 0 if they are identical types;
2346 * Otherwise, return an integer which corresponds to how compatible
2347 * PARM is to ARG. The higher the return value, the worse the match.
2348 * Generally the "bad" conversions are all uniformly assigned a 100 */
2351 rank_one_type (struct type *parm, struct type *arg)
2353 /* Identical type pointers */
2354 /* However, this still doesn't catch all cases of same type for arg
2355 * and param. The reason is that builtin types are different from
2356 * the same ones constructed from the object. */
2360 /* Resolve typedefs */
2361 if (TYPE_CODE (parm) == TYPE_CODE_TYPEDEF)
2362 parm = check_typedef (parm);
2363 if (TYPE_CODE (arg) == TYPE_CODE_TYPEDEF)
2364 arg = check_typedef (arg);
2367 Well, damnit, if the names are exactly the same,
2368 i'll say they are exactly the same. This happens when we generate
2369 method stubs. The types won't point to the same address, but they
2370 really are the same.
2373 if (TYPE_NAME (parm) && TYPE_NAME (arg) &&
2374 !strcmp (TYPE_NAME (parm), TYPE_NAME (arg)))
2377 /* Check if identical after resolving typedefs */
2381 /* See through references, since we can almost make non-references
2383 if (TYPE_CODE (arg) == TYPE_CODE_REF)
2384 return (rank_one_type (parm, TYPE_TARGET_TYPE (arg))
2385 + REFERENCE_CONVERSION_BADNESS);
2386 if (TYPE_CODE (parm) == TYPE_CODE_REF)
2387 return (rank_one_type (TYPE_TARGET_TYPE (parm), arg)
2388 + REFERENCE_CONVERSION_BADNESS);
2390 /* Debugging only. */
2391 fprintf_filtered (gdb_stderr,"------ Arg is %s [%d], parm is %s [%d]\n",
2392 TYPE_NAME (arg), TYPE_CODE (arg), TYPE_NAME (parm), TYPE_CODE (parm));
2394 /* x -> y means arg of type x being supplied for parameter of type y */
2396 switch (TYPE_CODE (parm))
2399 switch (TYPE_CODE (arg))
2402 if (TYPE_CODE (TYPE_TARGET_TYPE (parm)) == TYPE_CODE_VOID)
2403 return VOID_PTR_CONVERSION_BADNESS;
2405 return rank_one_type (TYPE_TARGET_TYPE (parm), TYPE_TARGET_TYPE (arg));
2406 case TYPE_CODE_ARRAY:
2407 return rank_one_type (TYPE_TARGET_TYPE (parm), TYPE_TARGET_TYPE (arg));
2408 case TYPE_CODE_FUNC:
2409 return rank_one_type (TYPE_TARGET_TYPE (parm), arg);
2411 case TYPE_CODE_ENUM:
2412 case TYPE_CODE_CHAR:
2413 case TYPE_CODE_RANGE:
2414 case TYPE_CODE_BOOL:
2415 return POINTER_CONVERSION_BADNESS;
2417 return INCOMPATIBLE_TYPE_BADNESS;
2419 case TYPE_CODE_ARRAY:
2420 switch (TYPE_CODE (arg))
2423 case TYPE_CODE_ARRAY:
2424 return rank_one_type (TYPE_TARGET_TYPE (parm), TYPE_TARGET_TYPE (arg));
2426 return INCOMPATIBLE_TYPE_BADNESS;
2428 case TYPE_CODE_FUNC:
2429 switch (TYPE_CODE (arg))
2431 case TYPE_CODE_PTR: /* funcptr -> func */
2432 return rank_one_type (parm, TYPE_TARGET_TYPE (arg));
2434 return INCOMPATIBLE_TYPE_BADNESS;
2437 switch (TYPE_CODE (arg))
2440 if (TYPE_LENGTH (arg) == TYPE_LENGTH (parm))
2442 /* Deal with signed, unsigned, and plain chars and
2443 signed and unsigned ints */
2444 if (TYPE_NOSIGN (parm))
2446 /* This case only for character types */
2447 if (TYPE_NOSIGN (arg)) /* plain char -> plain char */
2450 return INTEGER_CONVERSION_BADNESS; /* signed/unsigned char -> plain char */
2452 else if (TYPE_UNSIGNED (parm))
2454 if (TYPE_UNSIGNED (arg))
2456 /* unsigned int -> unsigned int, or unsigned long -> unsigned long */
2457 if (integer_types_same_name_p (TYPE_NAME (parm), TYPE_NAME (arg)))
2459 else if (integer_types_same_name_p (TYPE_NAME (arg), "int")
2460 && integer_types_same_name_p (TYPE_NAME (parm), "long"))
2461 return INTEGER_PROMOTION_BADNESS; /* unsigned int -> unsigned long */
2463 return INTEGER_CONVERSION_BADNESS; /* unsigned long -> unsigned int */
2467 if (integer_types_same_name_p (TYPE_NAME (arg), "long")
2468 && integer_types_same_name_p (TYPE_NAME (parm), "int"))
2469 return INTEGER_CONVERSION_BADNESS; /* signed long -> unsigned int */
2471 return INTEGER_CONVERSION_BADNESS; /* signed int/long -> unsigned int/long */
2474 else if (!TYPE_NOSIGN (arg) && !TYPE_UNSIGNED (arg))
2476 if (integer_types_same_name_p (TYPE_NAME (parm), TYPE_NAME (arg)))
2478 else if (integer_types_same_name_p (TYPE_NAME (arg), "int")
2479 && integer_types_same_name_p (TYPE_NAME (parm), "long"))
2480 return INTEGER_PROMOTION_BADNESS;
2482 return INTEGER_CONVERSION_BADNESS;
2485 return INTEGER_CONVERSION_BADNESS;
2487 else if (TYPE_LENGTH (arg) < TYPE_LENGTH (parm))
2488 return INTEGER_PROMOTION_BADNESS;
2490 return INTEGER_CONVERSION_BADNESS;
2491 case TYPE_CODE_ENUM:
2492 case TYPE_CODE_CHAR:
2493 case TYPE_CODE_RANGE:
2494 case TYPE_CODE_BOOL:
2495 return INTEGER_PROMOTION_BADNESS;
2497 return INT_FLOAT_CONVERSION_BADNESS;
2499 return NS_POINTER_CONVERSION_BADNESS;
2501 return INCOMPATIBLE_TYPE_BADNESS;
2504 case TYPE_CODE_ENUM:
2505 switch (TYPE_CODE (arg))
2508 case TYPE_CODE_CHAR:
2509 case TYPE_CODE_RANGE:
2510 case TYPE_CODE_BOOL:
2511 case TYPE_CODE_ENUM:
2512 return INTEGER_CONVERSION_BADNESS;
2514 return INT_FLOAT_CONVERSION_BADNESS;
2516 return INCOMPATIBLE_TYPE_BADNESS;
2519 case TYPE_CODE_CHAR:
2520 switch (TYPE_CODE (arg))
2522 case TYPE_CODE_RANGE:
2523 case TYPE_CODE_BOOL:
2524 case TYPE_CODE_ENUM:
2525 return INTEGER_CONVERSION_BADNESS;
2527 return INT_FLOAT_CONVERSION_BADNESS;
2529 if (TYPE_LENGTH (arg) > TYPE_LENGTH (parm))
2530 return INTEGER_CONVERSION_BADNESS;
2531 else if (TYPE_LENGTH (arg) < TYPE_LENGTH (parm))
2532 return INTEGER_PROMOTION_BADNESS;
2533 /* >>> !! else fall through !! <<< */
2534 case TYPE_CODE_CHAR:
2535 /* Deal with signed, unsigned, and plain chars for C++
2536 and with int cases falling through from previous case */
2537 if (TYPE_NOSIGN (parm))
2539 if (TYPE_NOSIGN (arg))
2542 return INTEGER_CONVERSION_BADNESS;
2544 else if (TYPE_UNSIGNED (parm))
2546 if (TYPE_UNSIGNED (arg))
2549 return INTEGER_PROMOTION_BADNESS;
2551 else if (!TYPE_NOSIGN (arg) && !TYPE_UNSIGNED (arg))
2554 return INTEGER_CONVERSION_BADNESS;
2556 return INCOMPATIBLE_TYPE_BADNESS;
2559 case TYPE_CODE_RANGE:
2560 switch (TYPE_CODE (arg))
2563 case TYPE_CODE_CHAR:
2564 case TYPE_CODE_RANGE:
2565 case TYPE_CODE_BOOL:
2566 case TYPE_CODE_ENUM:
2567 return INTEGER_CONVERSION_BADNESS;
2569 return INT_FLOAT_CONVERSION_BADNESS;
2571 return INCOMPATIBLE_TYPE_BADNESS;
2574 case TYPE_CODE_BOOL:
2575 switch (TYPE_CODE (arg))
2578 case TYPE_CODE_CHAR:
2579 case TYPE_CODE_RANGE:
2580 case TYPE_CODE_ENUM:
2583 return BOOLEAN_CONVERSION_BADNESS;
2584 case TYPE_CODE_BOOL:
2587 return INCOMPATIBLE_TYPE_BADNESS;
2591 switch (TYPE_CODE (arg))
2594 if (TYPE_LENGTH (arg) < TYPE_LENGTH (parm))
2595 return FLOAT_PROMOTION_BADNESS;
2596 else if (TYPE_LENGTH (arg) == TYPE_LENGTH (parm))
2599 return FLOAT_CONVERSION_BADNESS;
2601 case TYPE_CODE_BOOL:
2602 case TYPE_CODE_ENUM:
2603 case TYPE_CODE_RANGE:
2604 case TYPE_CODE_CHAR:
2605 return INT_FLOAT_CONVERSION_BADNESS;
2607 return INCOMPATIBLE_TYPE_BADNESS;
2610 case TYPE_CODE_COMPLEX:
2611 switch (TYPE_CODE (arg))
2612 { /* Strictly not needed for C++, but... */
2614 return FLOAT_PROMOTION_BADNESS;
2615 case TYPE_CODE_COMPLEX:
2618 return INCOMPATIBLE_TYPE_BADNESS;
2621 case TYPE_CODE_STRUCT:
2622 /* currently same as TYPE_CODE_CLASS */
2623 switch (TYPE_CODE (arg))
2625 case TYPE_CODE_STRUCT:
2626 /* Check for derivation */
2627 if (is_ancestor (parm, arg))
2628 return BASE_CONVERSION_BADNESS;
2629 /* else fall through */
2631 return INCOMPATIBLE_TYPE_BADNESS;
2634 case TYPE_CODE_UNION:
2635 switch (TYPE_CODE (arg))
2637 case TYPE_CODE_UNION:
2639 return INCOMPATIBLE_TYPE_BADNESS;
2642 case TYPE_CODE_MEMBER:
2643 switch (TYPE_CODE (arg))
2646 return INCOMPATIBLE_TYPE_BADNESS;
2649 case TYPE_CODE_METHOD:
2650 switch (TYPE_CODE (arg))
2654 return INCOMPATIBLE_TYPE_BADNESS;
2658 switch (TYPE_CODE (arg))
2662 return INCOMPATIBLE_TYPE_BADNESS;
2667 switch (TYPE_CODE (arg))
2671 return rank_one_type (TYPE_FIELD_TYPE (parm, 0), TYPE_FIELD_TYPE (arg, 0));
2673 return INCOMPATIBLE_TYPE_BADNESS;
2676 case TYPE_CODE_VOID:
2678 return INCOMPATIBLE_TYPE_BADNESS;
2679 } /* switch (TYPE_CODE (arg)) */
2683 /* End of functions for overload resolution */
2686 print_bit_vector (B_TYPE *bits, int nbits)
2690 for (bitno = 0; bitno < nbits; bitno++)
2692 if ((bitno % 8) == 0)
2694 puts_filtered (" ");
2696 if (B_TST (bits, bitno))
2698 printf_filtered ("1");
2702 printf_filtered ("0");
2707 /* Note the first arg should be the "this" pointer, we may not want to
2708 include it since we may get into a infinitely recursive situation. */
2711 print_arg_types (struct field *args, int nargs, int spaces)
2717 for (i = 0; i < nargs; i++)
2718 recursive_dump_type (args[i].type, spaces + 2);
2723 dump_fn_fieldlists (struct type *type, int spaces)
2729 printfi_filtered (spaces, "fn_fieldlists ");
2730 gdb_print_host_address (TYPE_FN_FIELDLISTS (type), gdb_stdout);
2731 printf_filtered ("\n");
2732 for (method_idx = 0; method_idx < TYPE_NFN_FIELDS (type); method_idx++)
2734 f = TYPE_FN_FIELDLIST1 (type, method_idx);
2735 printfi_filtered (spaces + 2, "[%d] name '%s' (",
2737 TYPE_FN_FIELDLIST_NAME (type, method_idx));
2738 gdb_print_host_address (TYPE_FN_FIELDLIST_NAME (type, method_idx),
2740 printf_filtered (") length %d\n",
2741 TYPE_FN_FIELDLIST_LENGTH (type, method_idx));
2742 for (overload_idx = 0;
2743 overload_idx < TYPE_FN_FIELDLIST_LENGTH (type, method_idx);
2746 printfi_filtered (spaces + 4, "[%d] physname '%s' (",
2748 TYPE_FN_FIELD_PHYSNAME (f, overload_idx));
2749 gdb_print_host_address (TYPE_FN_FIELD_PHYSNAME (f, overload_idx),
2751 printf_filtered (")\n");
2752 printfi_filtered (spaces + 8, "type ");
2753 gdb_print_host_address (TYPE_FN_FIELD_TYPE (f, overload_idx), gdb_stdout);
2754 printf_filtered ("\n");
2756 recursive_dump_type (TYPE_FN_FIELD_TYPE (f, overload_idx),
2759 printfi_filtered (spaces + 8, "args ");
2760 gdb_print_host_address (TYPE_FN_FIELD_ARGS (f, overload_idx), gdb_stdout);
2761 printf_filtered ("\n");
2763 print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx),
2764 TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (f, overload_idx)),
2766 printfi_filtered (spaces + 8, "fcontext ");
2767 gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx),
2769 printf_filtered ("\n");
2771 printfi_filtered (spaces + 8, "is_const %d\n",
2772 TYPE_FN_FIELD_CONST (f, overload_idx));
2773 printfi_filtered (spaces + 8, "is_volatile %d\n",
2774 TYPE_FN_FIELD_VOLATILE (f, overload_idx));
2775 printfi_filtered (spaces + 8, "is_private %d\n",
2776 TYPE_FN_FIELD_PRIVATE (f, overload_idx));
2777 printfi_filtered (spaces + 8, "is_protected %d\n",
2778 TYPE_FN_FIELD_PROTECTED (f, overload_idx));
2779 printfi_filtered (spaces + 8, "is_stub %d\n",
2780 TYPE_FN_FIELD_STUB (f, overload_idx));
2781 printfi_filtered (spaces + 8, "voffset %u\n",
2782 TYPE_FN_FIELD_VOFFSET (f, overload_idx));
2788 print_cplus_stuff (struct type *type, int spaces)
2790 printfi_filtered (spaces, "n_baseclasses %d\n",
2791 TYPE_N_BASECLASSES (type));
2792 printfi_filtered (spaces, "nfn_fields %d\n",
2793 TYPE_NFN_FIELDS (type));
2794 printfi_filtered (spaces, "nfn_fields_total %d\n",
2795 TYPE_NFN_FIELDS_TOTAL (type));
2796 if (TYPE_N_BASECLASSES (type) > 0)
2798 printfi_filtered (spaces, "virtual_field_bits (%d bits at *",
2799 TYPE_N_BASECLASSES (type));
2800 gdb_print_host_address (TYPE_FIELD_VIRTUAL_BITS (type), gdb_stdout);
2801 printf_filtered (")");
2803 print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type),
2804 TYPE_N_BASECLASSES (type));
2805 puts_filtered ("\n");
2807 if (TYPE_NFIELDS (type) > 0)
2809 if (TYPE_FIELD_PRIVATE_BITS (type) != NULL)
2811 printfi_filtered (spaces, "private_field_bits (%d bits at *",
2812 TYPE_NFIELDS (type));
2813 gdb_print_host_address (TYPE_FIELD_PRIVATE_BITS (type), gdb_stdout);
2814 printf_filtered (")");
2815 print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type),
2816 TYPE_NFIELDS (type));
2817 puts_filtered ("\n");
2819 if (TYPE_FIELD_PROTECTED_BITS (type) != NULL)
2821 printfi_filtered (spaces, "protected_field_bits (%d bits at *",
2822 TYPE_NFIELDS (type));
2823 gdb_print_host_address (TYPE_FIELD_PROTECTED_BITS (type), gdb_stdout);
2824 printf_filtered (")");
2825 print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type),
2826 TYPE_NFIELDS (type));
2827 puts_filtered ("\n");
2830 if (TYPE_NFN_FIELDS (type) > 0)
2832 dump_fn_fieldlists (type, spaces);
2837 print_bound_type (int bt)
2841 case BOUND_CANNOT_BE_DETERMINED:
2842 printf_filtered ("(BOUND_CANNOT_BE_DETERMINED)");
2844 case BOUND_BY_REF_ON_STACK:
2845 printf_filtered ("(BOUND_BY_REF_ON_STACK)");
2847 case BOUND_BY_VALUE_ON_STACK:
2848 printf_filtered ("(BOUND_BY_VALUE_ON_STACK)");
2850 case BOUND_BY_REF_IN_REG:
2851 printf_filtered ("(BOUND_BY_REF_IN_REG)");
2853 case BOUND_BY_VALUE_IN_REG:
2854 printf_filtered ("(BOUND_BY_VALUE_IN_REG)");
2857 printf_filtered ("(BOUND_SIMPLE)");
2860 printf_filtered ("(unknown bound type)");
2865 static struct obstack dont_print_type_obstack;
2868 recursive_dump_type (struct type *type, int spaces)
2873 obstack_begin (&dont_print_type_obstack, 0);
2875 if (TYPE_NFIELDS (type) > 0
2876 || (TYPE_CPLUS_SPECIFIC (type) && TYPE_NFN_FIELDS (type) > 0))
2878 struct type **first_dont_print
2879 = (struct type **) obstack_base (&dont_print_type_obstack);
2881 int i = (struct type **) obstack_next_free (&dont_print_type_obstack)
2886 if (type == first_dont_print[i])
2888 printfi_filtered (spaces, "type node ");
2889 gdb_print_host_address (type, gdb_stdout);
2890 printf_filtered (" <same as already seen type>\n");
2895 obstack_ptr_grow (&dont_print_type_obstack, type);
2898 printfi_filtered (spaces, "type node ");
2899 gdb_print_host_address (type, gdb_stdout);
2900 printf_filtered ("\n");
2901 printfi_filtered (spaces, "name '%s' (",
2902 TYPE_NAME (type) ? TYPE_NAME (type) : "<NULL>");
2903 gdb_print_host_address (TYPE_NAME (type), gdb_stdout);
2904 printf_filtered (")\n");
2905 printfi_filtered (spaces, "tagname '%s' (",
2906 TYPE_TAG_NAME (type) ? TYPE_TAG_NAME (type) : "<NULL>");
2907 gdb_print_host_address (TYPE_TAG_NAME (type), gdb_stdout);
2908 printf_filtered (")\n");
2909 printfi_filtered (spaces, "code 0x%x ", TYPE_CODE (type));
2910 switch (TYPE_CODE (type))
2912 case TYPE_CODE_UNDEF:
2913 printf_filtered ("(TYPE_CODE_UNDEF)");
2916 printf_filtered ("(TYPE_CODE_PTR)");
2918 case TYPE_CODE_ARRAY:
2919 printf_filtered ("(TYPE_CODE_ARRAY)");
2921 case TYPE_CODE_STRUCT:
2922 printf_filtered ("(TYPE_CODE_STRUCT)");
2924 case TYPE_CODE_UNION:
2925 printf_filtered ("(TYPE_CODE_UNION)");
2927 case TYPE_CODE_ENUM:
2928 printf_filtered ("(TYPE_CODE_ENUM)");
2930 case TYPE_CODE_FUNC:
2931 printf_filtered ("(TYPE_CODE_FUNC)");
2934 printf_filtered ("(TYPE_CODE_INT)");
2937 printf_filtered ("(TYPE_CODE_FLT)");
2939 case TYPE_CODE_VOID:
2940 printf_filtered ("(TYPE_CODE_VOID)");
2943 printf_filtered ("(TYPE_CODE_SET)");
2945 case TYPE_CODE_RANGE:
2946 printf_filtered ("(TYPE_CODE_RANGE)");
2948 case TYPE_CODE_STRING:
2949 printf_filtered ("(TYPE_CODE_STRING)");
2951 case TYPE_CODE_BITSTRING:
2952 printf_filtered ("(TYPE_CODE_BITSTRING)");
2954 case TYPE_CODE_ERROR:
2955 printf_filtered ("(TYPE_CODE_ERROR)");
2957 case TYPE_CODE_MEMBER:
2958 printf_filtered ("(TYPE_CODE_MEMBER)");
2960 case TYPE_CODE_METHOD:
2961 printf_filtered ("(TYPE_CODE_METHOD)");
2964 printf_filtered ("(TYPE_CODE_REF)");
2966 case TYPE_CODE_CHAR:
2967 printf_filtered ("(TYPE_CODE_CHAR)");
2969 case TYPE_CODE_BOOL:
2970 printf_filtered ("(TYPE_CODE_BOOL)");
2972 case TYPE_CODE_COMPLEX:
2973 printf_filtered ("(TYPE_CODE_COMPLEX)");
2975 case TYPE_CODE_TYPEDEF:
2976 printf_filtered ("(TYPE_CODE_TYPEDEF)");
2978 case TYPE_CODE_TEMPLATE:
2979 printf_filtered ("(TYPE_CODE_TEMPLATE)");
2981 case TYPE_CODE_TEMPLATE_ARG:
2982 printf_filtered ("(TYPE_CODE_TEMPLATE_ARG)");
2984 case TYPE_CODE_NAMESPACE:
2985 printf_filtered ("(TYPE_CODE_NAMESPACE)");
2988 printf_filtered ("(UNKNOWN TYPE CODE)");
2991 puts_filtered ("\n");
2992 printfi_filtered (spaces, "length %d\n", TYPE_LENGTH (type));
2993 printfi_filtered (spaces, "upper_bound_type 0x%x ",
2994 TYPE_ARRAY_UPPER_BOUND_TYPE (type));
2995 print_bound_type (TYPE_ARRAY_UPPER_BOUND_TYPE (type));
2996 puts_filtered ("\n");
2997 printfi_filtered (spaces, "lower_bound_type 0x%x ",
2998 TYPE_ARRAY_LOWER_BOUND_TYPE (type));
2999 print_bound_type (TYPE_ARRAY_LOWER_BOUND_TYPE (type));
3000 puts_filtered ("\n");
3001 printfi_filtered (spaces, "objfile ");
3002 gdb_print_host_address (TYPE_OBJFILE (type), gdb_stdout);
3003 printf_filtered ("\n");
3004 printfi_filtered (spaces, "target_type ");
3005 gdb_print_host_address (TYPE_TARGET_TYPE (type), gdb_stdout);
3006 printf_filtered ("\n");
3007 if (TYPE_TARGET_TYPE (type) != NULL)
3009 recursive_dump_type (TYPE_TARGET_TYPE (type), spaces + 2);
3011 printfi_filtered (spaces, "pointer_type ");
3012 gdb_print_host_address (TYPE_POINTER_TYPE (type), gdb_stdout);
3013 printf_filtered ("\n");
3014 printfi_filtered (spaces, "reference_type ");
3015 gdb_print_host_address (TYPE_REFERENCE_TYPE (type), gdb_stdout);
3016 printf_filtered ("\n");
3017 printfi_filtered (spaces, "type_chain ");
3018 gdb_print_host_address (TYPE_CHAIN (type), gdb_stdout);
3019 printf_filtered ("\n");
3020 printfi_filtered (spaces, "instance_flags 0x%x", TYPE_INSTANCE_FLAGS (type));
3021 if (TYPE_CONST (type))
3023 puts_filtered (" TYPE_FLAG_CONST");
3025 if (TYPE_VOLATILE (type))
3027 puts_filtered (" TYPE_FLAG_VOLATILE");
3029 if (TYPE_CODE_SPACE (type))
3031 puts_filtered (" TYPE_FLAG_CODE_SPACE");
3033 if (TYPE_DATA_SPACE (type))
3035 puts_filtered (" TYPE_FLAG_DATA_SPACE");
3037 if (TYPE_ADDRESS_CLASS_1 (type))
3039 puts_filtered (" TYPE_FLAG_ADDRESS_CLASS_1");
3041 if (TYPE_ADDRESS_CLASS_2 (type))
3043 puts_filtered (" TYPE_FLAG_ADDRESS_CLASS_2");
3045 puts_filtered ("\n");
3046 printfi_filtered (spaces, "flags 0x%x", TYPE_FLAGS (type));
3047 if (TYPE_UNSIGNED (type))
3049 puts_filtered (" TYPE_FLAG_UNSIGNED");
3051 if (TYPE_NOSIGN (type))
3053 puts_filtered (" TYPE_FLAG_NOSIGN");
3055 if (TYPE_STUB (type))
3057 puts_filtered (" TYPE_FLAG_STUB");
3059 if (TYPE_TARGET_STUB (type))
3061 puts_filtered (" TYPE_FLAG_TARGET_STUB");
3063 if (TYPE_STATIC (type))
3065 puts_filtered (" TYPE_FLAG_STATIC");
3067 if (TYPE_PROTOTYPED (type))
3069 puts_filtered (" TYPE_FLAG_PROTOTYPED");
3071 if (TYPE_INCOMPLETE (type))
3073 puts_filtered (" TYPE_FLAG_INCOMPLETE");
3075 if (TYPE_VARARGS (type))
3077 puts_filtered (" TYPE_FLAG_VARARGS");
3079 /* This is used for things like AltiVec registers on ppc. Gcc emits
3080 an attribute for the array type, which tells whether or not we
3081 have a vector, instead of a regular array. */
3082 if (TYPE_VECTOR (type))
3084 puts_filtered (" TYPE_FLAG_VECTOR");
3086 puts_filtered ("\n");
3087 printfi_filtered (spaces, "nfields %d ", TYPE_NFIELDS (type));
3088 gdb_print_host_address (TYPE_FIELDS (type), gdb_stdout);
3089 puts_filtered ("\n");
3090 for (idx = 0; idx < TYPE_NFIELDS (type); idx++)
3092 printfi_filtered (spaces + 2,
3093 "[%d] bitpos %d bitsize %d type ",
3094 idx, TYPE_FIELD_BITPOS (type, idx),
3095 TYPE_FIELD_BITSIZE (type, idx));
3096 gdb_print_host_address (TYPE_FIELD_TYPE (type, idx), gdb_stdout);
3097 printf_filtered (" name '%s' (",
3098 TYPE_FIELD_NAME (type, idx) != NULL
3099 ? TYPE_FIELD_NAME (type, idx)
3101 gdb_print_host_address (TYPE_FIELD_NAME (type, idx), gdb_stdout);
3102 printf_filtered (")\n");
3103 if (TYPE_FIELD_TYPE (type, idx) != NULL)
3105 recursive_dump_type (TYPE_FIELD_TYPE (type, idx), spaces + 4);
3108 printfi_filtered (spaces, "vptr_basetype ");
3109 gdb_print_host_address (TYPE_VPTR_BASETYPE (type), gdb_stdout);
3110 puts_filtered ("\n");
3111 if (TYPE_VPTR_BASETYPE (type) != NULL)
3113 recursive_dump_type (TYPE_VPTR_BASETYPE (type), spaces + 2);
3115 printfi_filtered (spaces, "vptr_fieldno %d\n", TYPE_VPTR_FIELDNO (type));
3116 switch (TYPE_CODE (type))
3118 case TYPE_CODE_STRUCT:
3119 printfi_filtered (spaces, "cplus_stuff ");
3120 gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout);
3121 puts_filtered ("\n");
3122 print_cplus_stuff (type, spaces);
3126 printfi_filtered (spaces, "floatformat ");
3127 if (TYPE_FLOATFORMAT (type) == NULL
3128 || TYPE_FLOATFORMAT (type)->name == NULL)
3129 puts_filtered ("(null)");
3131 puts_filtered (TYPE_FLOATFORMAT (type)->name);
3132 puts_filtered ("\n");
3136 /* We have to pick one of the union types to be able print and test
3137 the value. Pick cplus_struct_type, even though we know it isn't
3138 any particular one. */
3139 printfi_filtered (spaces, "type_specific ");
3140 gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout);
3141 if (TYPE_CPLUS_SPECIFIC (type) != NULL)
3143 printf_filtered (" (unknown data form)");
3145 printf_filtered ("\n");
3150 obstack_free (&dont_print_type_obstack, NULL);
3153 static void build_gdbtypes (void);
3155 build_gdbtypes (void)
3158 init_type (TYPE_CODE_VOID, 1,
3160 "void", (struct objfile *) NULL);
3162 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3164 | (TARGET_CHAR_SIGNED ? 0 : TYPE_FLAG_UNSIGNED)),
3165 "char", (struct objfile *) NULL);
3166 builtin_type_true_char =
3167 init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3169 "true character", (struct objfile *) NULL);
3170 builtin_type_signed_char =
3171 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3173 "signed char", (struct objfile *) NULL);
3174 builtin_type_unsigned_char =
3175 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3177 "unsigned char", (struct objfile *) NULL);
3178 builtin_type_short =
3179 init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
3181 "short", (struct objfile *) NULL);
3182 builtin_type_unsigned_short =
3183 init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
3185 "unsigned short", (struct objfile *) NULL);
3187 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
3189 "int", (struct objfile *) NULL);
3190 builtin_type_unsigned_int =
3191 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
3193 "unsigned int", (struct objfile *) NULL);
3195 init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
3197 "long", (struct objfile *) NULL);
3198 builtin_type_unsigned_long =
3199 init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
3201 "unsigned long", (struct objfile *) NULL);
3202 builtin_type_long_long =
3203 init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
3205 "long long", (struct objfile *) NULL);
3206 builtin_type_unsigned_long_long =
3207 init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
3209 "unsigned long long", (struct objfile *) NULL);
3210 builtin_type_float =
3211 init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
3213 "float", (struct objfile *) NULL);
3215 The below lines are disabled since they are doing the wrong
3216 thing for non-multiarch targets. They are setting the correct
3217 type of floats for the target but while on multiarch targets
3218 this is done everytime the architecture changes, it's done on
3219 non-multiarch targets only on startup, leaving the wrong values
3220 in even if the architecture changes (eg. from big-endian to
3223 TYPE_FLOATFORMAT (builtin_type_float) = TARGET_FLOAT_FORMAT;
3225 builtin_type_double =
3226 init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
3228 "double", (struct objfile *) NULL);
3230 TYPE_FLOATFORMAT (builtin_type_double) = TARGET_DOUBLE_FORMAT;
3232 builtin_type_long_double =
3233 init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
3235 "long double", (struct objfile *) NULL);
3237 TYPE_FLOATFORMAT (builtin_type_long_double) = TARGET_LONG_DOUBLE_FORMAT;
3239 builtin_type_complex =
3240 init_type (TYPE_CODE_COMPLEX, 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
3242 "complex", (struct objfile *) NULL);
3243 TYPE_TARGET_TYPE (builtin_type_complex) = builtin_type_float;
3244 builtin_type_double_complex =
3245 init_type (TYPE_CODE_COMPLEX, 2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
3247 "double complex", (struct objfile *) NULL);
3248 TYPE_TARGET_TYPE (builtin_type_double_complex) = builtin_type_double;
3249 builtin_type_string =
3250 init_type (TYPE_CODE_STRING, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3252 "string", (struct objfile *) NULL);
3254 init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3256 "bool", (struct objfile *) NULL);
3258 /* Add user knob for controlling resolution of opaque types */
3259 deprecated_add_show_from_set
3260 (add_set_cmd ("opaque-type-resolution", class_support, var_boolean, (char *) &opaque_type_resolution,
3261 "Set resolution of opaque struct/class/union types (if set before loading symbols).",
3264 opaque_type_resolution = 1;
3266 /* Build SIMD types. */
3268 = init_simd_type ("__builtin_v4sf", builtin_type_float, "f", 4);
3270 = init_simd_type ("__builtin_v4si", builtin_type_int32, "f", 4);
3272 = init_simd_type ("__builtin_v16qi", builtin_type_int8, "f", 16);
3274 = init_simd_type ("__builtin_v8qi", builtin_type_int8, "f", 8);
3276 = init_simd_type ("__builtin_v8hi", builtin_type_int16, "f", 8);
3278 = init_simd_type ("__builtin_v4hi", builtin_type_int16, "f", 4);
3280 = init_simd_type ("__builtin_v2si", builtin_type_int32, "f", 2);
3282 /* 128 bit vectors. */
3283 builtin_type_v2_double = init_vector_type (builtin_type_double, 2);
3284 builtin_type_v4_float = init_vector_type (builtin_type_float, 4);
3285 builtin_type_v2_int64 = init_vector_type (builtin_type_int64, 2);
3286 builtin_type_v4_int32 = init_vector_type (builtin_type_int32, 4);
3287 builtin_type_v8_int16 = init_vector_type (builtin_type_int16, 8);
3288 builtin_type_v16_int8 = init_vector_type (builtin_type_int8, 16);
3289 /* 64 bit vectors. */
3290 builtin_type_v2_float = init_vector_type (builtin_type_float, 2);
3291 builtin_type_v2_int32 = init_vector_type (builtin_type_int32, 2);
3292 builtin_type_v4_int16 = init_vector_type (builtin_type_int16, 4);
3293 builtin_type_v8_int8 = init_vector_type (builtin_type_int8, 8);
3296 builtin_type_vec64 = build_builtin_type_vec64 ();
3297 builtin_type_vec64i = build_builtin_type_vec64i ();
3298 builtin_type_vec128 = build_builtin_type_vec128 ();
3299 builtin_type_vec128i = build_builtin_type_vec128i ();
3301 /* Pointer/Address types. */
3303 /* NOTE: on some targets, addresses and pointers are not necessarily
3304 the same --- for example, on the D10V, pointers are 16 bits long,
3305 but addresses are 32 bits long. See doc/gdbint.texinfo,
3306 ``Pointers Are Not Always Addresses''.
3309 - gdb's `struct type' always describes the target's
3311 - gdb's `struct value' objects should always hold values in
3313 - gdb's CORE_ADDR values are addresses in the unified virtual
3314 address space that the assembler and linker work with. Thus,
3315 since target_read_memory takes a CORE_ADDR as an argument, it
3316 can access any memory on the target, even if the processor has
3317 separate code and data address spaces.
3320 - If v is a value holding a D10V code pointer, its contents are
3321 in target form: a big-endian address left-shifted two bits.
3322 - If p is a D10V pointer type, TYPE_LENGTH (p) == 2, just as
3323 sizeof (void *) == 2 on the target.
3325 In this context, builtin_type_CORE_ADDR is a bit odd: it's a
3326 target type for a value the target will never see. It's only
3327 used to hold the values of (typeless) linker symbols, which are
3328 indeed in the unified virtual address space. */
3329 builtin_type_void_data_ptr = make_pointer_type (builtin_type_void, NULL);
3330 builtin_type_void_func_ptr
3331 = lookup_pointer_type (lookup_function_type (builtin_type_void));
3332 builtin_type_CORE_ADDR =
3333 init_type (TYPE_CODE_INT, TARGET_ADDR_BIT / 8,
3335 "__CORE_ADDR", (struct objfile *) NULL);
3336 builtin_type_bfd_vma =
3337 init_type (TYPE_CODE_INT, TARGET_BFD_VMA_BIT / 8,
3339 "__bfd_vma", (struct objfile *) NULL);
3342 static struct gdbarch_data *gdbtypes_data;
3344 const struct builtin_type *
3345 builtin_type (struct gdbarch *gdbarch)
3347 return gdbarch_data (gdbarch, gdbtypes_data);
3351 static struct type *
3352 build_flt (int bit, char *name, const struct floatformat *floatformat)
3355 if (bit <= 0 || floatformat == NULL)
3357 gdb_assert (builtin_type_error != NULL);
3358 return builtin_type_error;
3360 t = init_type (TYPE_CODE_FLT, bit / TARGET_CHAR_BIT,
3361 0, name, (struct objfile *) NULL);
3362 TYPE_FLOATFORMAT (t) = floatformat;
3366 static struct type *
3367 build_complex (int bit, char *name, struct type *target_type)
3370 if (bit <= 0 || target_type == builtin_type_error)
3372 gdb_assert (builtin_type_error != NULL);
3373 return builtin_type_error;
3375 t = init_type (TYPE_CODE_COMPLEX, 2 * bit / TARGET_CHAR_BIT,
3376 0, name, (struct objfile *) NULL);
3377 TYPE_TARGET_TYPE (t) = target_type;
3382 gdbtypes_post_init (struct gdbarch *gdbarch)
3384 struct builtin_type *builtin_type
3385 = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_type);
3387 builtin_type->builtin_void =
3388 init_type (TYPE_CODE_VOID, 1,
3390 "void", (struct objfile *) NULL);
3391 builtin_type->builtin_char =
3392 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3394 | (TARGET_CHAR_SIGNED ? 0 : TYPE_FLAG_UNSIGNED)),
3395 "char", (struct objfile *) NULL);
3396 builtin_type->builtin_true_char =
3397 init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3399 "true character", (struct objfile *) NULL);
3400 builtin_type->builtin_signed_char =
3401 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3403 "signed char", (struct objfile *) NULL);
3404 builtin_type->builtin_unsigned_char =
3405 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3407 "unsigned char", (struct objfile *) NULL);
3408 builtin_type->builtin_short =
3409 init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
3411 "short", (struct objfile *) NULL);
3412 builtin_type->builtin_unsigned_short =
3413 init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
3415 "unsigned short", (struct objfile *) NULL);
3416 builtin_type->builtin_int =
3417 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
3419 "int", (struct objfile *) NULL);
3420 builtin_type->builtin_unsigned_int =
3421 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
3423 "unsigned int", (struct objfile *) NULL);
3424 builtin_type->builtin_long =
3425 init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
3427 "long", (struct objfile *) NULL);
3428 builtin_type->builtin_unsigned_long =
3429 init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
3431 "unsigned long", (struct objfile *) NULL);
3432 builtin_type->builtin_long_long =
3433 init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
3435 "long long", (struct objfile *) NULL);
3436 builtin_type->builtin_unsigned_long_long =
3437 init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
3439 "unsigned long long", (struct objfile *) NULL);
3440 builtin_type->builtin_float
3441 = build_flt (gdbarch_float_bit (gdbarch), "float",
3442 gdbarch_float_format (gdbarch));
3443 builtin_type->builtin_double
3444 = build_flt (gdbarch_double_bit (gdbarch), "double",
3445 gdbarch_double_format (gdbarch));
3446 builtin_type->builtin_long_double
3447 = build_flt (gdbarch_long_double_bit (gdbarch), "long double",
3448 gdbarch_long_double_format (gdbarch));
3449 builtin_type->builtin_complex
3450 = build_complex (gdbarch_float_bit (gdbarch), "complex",
3451 builtin_type->builtin_float);
3452 builtin_type->builtin_double_complex
3453 = build_complex (gdbarch_double_bit (gdbarch), "double complex",
3454 builtin_type->builtin_double);
3455 builtin_type->builtin_string =
3456 init_type (TYPE_CODE_STRING, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3458 "string", (struct objfile *) NULL);
3459 builtin_type->builtin_bool =
3460 init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3462 "bool", (struct objfile *) NULL);
3464 /* Pointer/Address types. */
3466 /* NOTE: on some targets, addresses and pointers are not necessarily
3467 the same --- for example, on the D10V, pointers are 16 bits long,
3468 but addresses are 32 bits long. See doc/gdbint.texinfo,
3469 ``Pointers Are Not Always Addresses''.
3472 - gdb's `struct type' always describes the target's
3474 - gdb's `struct value' objects should always hold values in
3476 - gdb's CORE_ADDR values are addresses in the unified virtual
3477 address space that the assembler and linker work with. Thus,
3478 since target_read_memory takes a CORE_ADDR as an argument, it
3479 can access any memory on the target, even if the processor has
3480 separate code and data address spaces.
3483 - If v is a value holding a D10V code pointer, its contents are
3484 in target form: a big-endian address left-shifted two bits.
3485 - If p is a D10V pointer type, TYPE_LENGTH (p) == 2, just as
3486 sizeof (void *) == 2 on the target.
3488 In this context, builtin_type->CORE_ADDR is a bit odd: it's a
3489 target type for a value the target will never see. It's only
3490 used to hold the values of (typeless) linker symbols, which are
3491 indeed in the unified virtual address space. */
3492 builtin_type->builtin_data_ptr
3493 = make_pointer_type (builtin_type->builtin_void, NULL);
3494 builtin_type->builtin_func_ptr
3495 = lookup_pointer_type (lookup_function_type (builtin_type->builtin_void));
3496 builtin_type->builtin_core_addr =
3497 init_type (TYPE_CODE_INT, TARGET_ADDR_BIT / 8,
3499 "__CORE_ADDR", (struct objfile *) NULL);
3501 return builtin_type;
3504 extern void _initialize_gdbtypes (void);
3506 _initialize_gdbtypes (void)
3508 struct cmd_list_element *c;
3511 init_type (TYPE_CODE_INT, 0 / 8,
3513 "int0_t", (struct objfile *) NULL);
3515 init_type (TYPE_CODE_INT, 8 / 8,
3517 "int8_t", (struct objfile *) NULL);
3518 builtin_type_uint8 =
3519 init_type (TYPE_CODE_INT, 8 / 8,
3521 "uint8_t", (struct objfile *) NULL);
3522 builtin_type_int16 =
3523 init_type (TYPE_CODE_INT, 16 / 8,
3525 "int16_t", (struct objfile *) NULL);
3526 builtin_type_uint16 =
3527 init_type (TYPE_CODE_INT, 16 / 8,
3529 "uint16_t", (struct objfile *) NULL);
3530 builtin_type_int32 =
3531 init_type (TYPE_CODE_INT, 32 / 8,
3533 "int32_t", (struct objfile *) NULL);
3534 builtin_type_uint32 =
3535 init_type (TYPE_CODE_INT, 32 / 8,
3537 "uint32_t", (struct objfile *) NULL);
3538 builtin_type_int64 =
3539 init_type (TYPE_CODE_INT, 64 / 8,
3541 "int64_t", (struct objfile *) NULL);
3542 builtin_type_uint64 =
3543 init_type (TYPE_CODE_INT, 64 / 8,
3545 "uint64_t", (struct objfile *) NULL);
3546 builtin_type_int128 =
3547 init_type (TYPE_CODE_INT, 128 / 8,
3549 "int128_t", (struct objfile *) NULL);
3550 builtin_type_uint128 =
3551 init_type (TYPE_CODE_INT, 128 / 8,
3553 "uint128_t", (struct objfile *) NULL);
3557 gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init);
3559 /* FIXME - For the moment, handle types by swapping them in and out.
3560 Should be using the per-architecture data-pointer and a large
3562 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void);
3563 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_char);
3564 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_short);
3565 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_int);
3566 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_long);
3567 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_long_long);
3568 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_signed_char);
3569 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_char);
3570 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_short);
3571 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_int);
3572 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_long);
3573 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_long_long);
3574 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_float);
3575 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_double);
3576 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_long_double);
3577 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_complex);
3578 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_double_complex);
3579 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_string);
3580 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4sf);
3581 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4si);
3582 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v16qi);
3583 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8qi);
3584 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8hi);
3585 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4hi);
3586 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2si);
3587 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_double);
3588 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4_float);
3589 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_int64);
3590 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4_int32);
3591 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8_int16);
3592 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v16_int8);
3593 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_float);
3594 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_int32);
3595 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8_int8);
3596 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4_int16);
3597 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_vec128);
3598 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_vec128i);
3599 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void_data_ptr);
3600 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void_func_ptr);
3601 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR);
3602 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_bfd_vma);
3603 deprecated_register_gdbarch_swap (NULL, 0, build_gdbtypes);
3605 /* Note: These types do not need to be swapped - they are target
3607 builtin_type_ieee_single_big =
3608 init_type (TYPE_CODE_FLT, floatformat_ieee_single_big.totalsize / 8,
3609 0, "builtin_type_ieee_single_big", NULL);
3610 TYPE_FLOATFORMAT (builtin_type_ieee_single_big) = &floatformat_ieee_single_big;
3611 builtin_type_ieee_single_little =
3612 init_type (TYPE_CODE_FLT, floatformat_ieee_single_little.totalsize / 8,
3613 0, "builtin_type_ieee_single_little", NULL);
3614 TYPE_FLOATFORMAT (builtin_type_ieee_single_little) = &floatformat_ieee_single_little;
3615 builtin_type_ieee_single[BFD_ENDIAN_BIG]
3616 = build_flt (floatformat_ieee_single_big.totalsize,
3617 "builtin_type_ieee_single_big",
3618 &floatformat_ieee_single_big);
3619 builtin_type_ieee_single[BFD_ENDIAN_LITTLE]
3620 = build_flt (floatformat_ieee_single_little.totalsize,
3621 "builtin_type_ieee_single_little",
3622 &floatformat_ieee_single_little);
3623 builtin_type_ieee_double_big =
3624 init_type (TYPE_CODE_FLT, floatformat_ieee_double_big.totalsize / 8,
3625 0, "builtin_type_ieee_double_big", NULL);
3626 TYPE_FLOATFORMAT (builtin_type_ieee_double_big) = &floatformat_ieee_double_big;
3627 builtin_type_ieee_double_little =
3628 init_type (TYPE_CODE_FLT, floatformat_ieee_double_little.totalsize / 8,
3629 0, "builtin_type_ieee_double_little", NULL);
3630 TYPE_FLOATFORMAT (builtin_type_ieee_double_little) = &floatformat_ieee_double_little;
3631 builtin_type_ieee_double[BFD_ENDIAN_BIG]
3632 = build_flt (floatformat_ieee_double_big.totalsize,
3633 "builtin_type_ieee_double_big",
3634 &floatformat_ieee_double_big);
3635 builtin_type_ieee_double[BFD_ENDIAN_LITTLE]
3636 = build_flt (floatformat_ieee_double_little.totalsize,
3637 "builtin_type_ieee_double_little",
3638 &floatformat_ieee_double_little);
3639 builtin_type_ieee_double_littlebyte_bigword =
3640 init_type (TYPE_CODE_FLT, floatformat_ieee_double_littlebyte_bigword.totalsize / 8,
3641 0, "builtin_type_ieee_double_littlebyte_bigword", NULL);
3642 TYPE_FLOATFORMAT (builtin_type_ieee_double_littlebyte_bigword) = &floatformat_ieee_double_littlebyte_bigword;
3643 builtin_type_i387_ext =
3644 init_type (TYPE_CODE_FLT, floatformat_i387_ext.totalsize / 8,
3645 0, "builtin_type_i387_ext", NULL);
3646 TYPE_FLOATFORMAT (builtin_type_i387_ext) = &floatformat_i387_ext;
3647 builtin_type_m68881_ext =
3648 init_type (TYPE_CODE_FLT, floatformat_m68881_ext.totalsize / 8,
3649 0, "builtin_type_m68881_ext", NULL);
3650 TYPE_FLOATFORMAT (builtin_type_m68881_ext) = &floatformat_m68881_ext;
3651 builtin_type_i960_ext =
3652 init_type (TYPE_CODE_FLT, floatformat_i960_ext.totalsize / 8,
3653 0, "builtin_type_i960_ext", NULL);
3654 TYPE_FLOATFORMAT (builtin_type_i960_ext) = &floatformat_i960_ext;
3655 builtin_type_m88110_ext =
3656 init_type (TYPE_CODE_FLT, floatformat_m88110_ext.totalsize / 8,
3657 0, "builtin_type_m88110_ext", NULL);
3658 TYPE_FLOATFORMAT (builtin_type_m88110_ext) = &floatformat_m88110_ext;
3659 builtin_type_m88110_harris_ext =
3660 init_type (TYPE_CODE_FLT, floatformat_m88110_harris_ext.totalsize / 8,
3661 0, "builtin_type_m88110_harris_ext", NULL);
3662 TYPE_FLOATFORMAT (builtin_type_m88110_harris_ext) = &floatformat_m88110_harris_ext;
3663 builtin_type_arm_ext_big =
3664 init_type (TYPE_CODE_FLT, floatformat_arm_ext_big.totalsize / 8,
3665 0, "builtin_type_arm_ext_big", NULL);
3666 TYPE_FLOATFORMAT (builtin_type_arm_ext_big) = &floatformat_arm_ext_big;
3667 builtin_type_arm_ext_littlebyte_bigword =
3668 init_type (TYPE_CODE_FLT, floatformat_arm_ext_littlebyte_bigword.totalsize / 8,
3669 0, "builtin_type_arm_ext_littlebyte_bigword", NULL);
3670 TYPE_FLOATFORMAT (builtin_type_arm_ext_littlebyte_bigword) = &floatformat_arm_ext_littlebyte_bigword;
3671 builtin_type_arm_ext[BFD_ENDIAN_BIG]
3672 = build_flt (floatformat_arm_ext_big.totalsize,
3673 "builtin_type_arm_ext_big",
3674 &floatformat_arm_ext_big);
3675 builtin_type_arm_ext[BFD_ENDIAN_LITTLE]
3676 = build_flt (floatformat_arm_ext_littlebyte_bigword.totalsize,
3677 "builtin_type_arm_ext_littlebyte_bigword",
3678 &floatformat_arm_ext_littlebyte_bigword);
3679 builtin_type_ia64_spill_big =
3680 init_type (TYPE_CODE_FLT, floatformat_ia64_spill_big.totalsize / 8,
3681 0, "builtin_type_ia64_spill_big", NULL);
3682 TYPE_FLOATFORMAT (builtin_type_ia64_spill_big) = &floatformat_ia64_spill_big;
3683 builtin_type_ia64_spill_little =
3684 init_type (TYPE_CODE_FLT, floatformat_ia64_spill_little.totalsize / 8,
3685 0, "builtin_type_ia64_spill_little", NULL);
3686 TYPE_FLOATFORMAT (builtin_type_ia64_spill_little) = &floatformat_ia64_spill_little;
3687 builtin_type_ia64_spill[BFD_ENDIAN_BIG]
3688 = build_flt (floatformat_ia64_spill_big.totalsize,
3689 "builtin_type_ia64_spill_big",
3690 &floatformat_ia64_spill_big);
3691 builtin_type_ia64_spill[BFD_ENDIAN_LITTLE]
3692 = build_flt (floatformat_ia64_spill_little.totalsize,
3693 "builtin_type_ia64_spill_little",
3694 &floatformat_ia64_spill_little);
3695 builtin_type_ia64_quad_big =
3696 init_type (TYPE_CODE_FLT, floatformat_ia64_quad_big.totalsize / 8,
3697 0, "builtin_type_ia64_quad_big", NULL);
3698 TYPE_FLOATFORMAT (builtin_type_ia64_quad_big) = &floatformat_ia64_quad_big;
3699 builtin_type_ia64_quad_little =
3700 init_type (TYPE_CODE_FLT, floatformat_ia64_quad_little.totalsize / 8,
3701 0, "builtin_type_ia64_quad_little", NULL);
3702 TYPE_FLOATFORMAT (builtin_type_ia64_quad_little) = &floatformat_ia64_quad_little;
3703 builtin_type_ia64_quad[BFD_ENDIAN_BIG]
3704 = build_flt (floatformat_ia64_quad_big.totalsize,
3705 "builtin_type_ia64_quad_big",
3706 &floatformat_ia64_quad_big);
3707 builtin_type_ia64_quad[BFD_ENDIAN_LITTLE]
3708 = build_flt (floatformat_ia64_quad_little.totalsize,
3709 "builtin_type_ia64_quad_little",
3710 &floatformat_ia64_quad_little);
3712 deprecated_add_show_from_set
3713 (add_set_cmd ("overload", no_class, var_zinteger, (char *) &overload_debug,
3714 "Set debugging of C++ overloading.\n\
3715 When enabled, ranking of the functions is displayed.", &setdebuglist),