1 /* Support routines for manipulating internal types for GDB.
3 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002,
4 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
6 Contributed by Cygnus Support, using pieces from other GDB modules.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA. */
26 #include "gdb_string.h"
32 #include "expression.h"
37 #include "complaints.h"
41 #include "gdb_assert.h"
44 /* These variables point to the objects
45 representing the predefined C data types. */
47 struct type *builtin_type_void;
48 struct type *builtin_type_char;
49 struct type *builtin_type_true_char;
50 struct type *builtin_type_short;
51 struct type *builtin_type_int;
52 struct type *builtin_type_long;
53 struct type *builtin_type_long_long;
54 struct type *builtin_type_signed_char;
55 struct type *builtin_type_unsigned_char;
56 struct type *builtin_type_unsigned_short;
57 struct type *builtin_type_unsigned_int;
58 struct type *builtin_type_unsigned_long;
59 struct type *builtin_type_unsigned_long_long;
60 struct type *builtin_type_float;
61 struct type *builtin_type_double;
62 struct type *builtin_type_long_double;
63 struct type *builtin_type_complex;
64 struct type *builtin_type_double_complex;
65 struct type *builtin_type_string;
66 struct type *builtin_type_int0;
67 struct type *builtin_type_int8;
68 struct type *builtin_type_uint8;
69 struct type *builtin_type_int16;
70 struct type *builtin_type_uint16;
71 struct type *builtin_type_int32;
72 struct type *builtin_type_uint32;
73 struct type *builtin_type_int64;
74 struct type *builtin_type_uint64;
75 struct type *builtin_type_int128;
76 struct type *builtin_type_uint128;
77 struct type *builtin_type_bool;
79 /* Floatformat pairs. */
80 const struct floatformat *floatformats_ieee_single[BFD_ENDIAN_UNKNOWN] = {
81 &floatformat_ieee_single_big,
82 &floatformat_ieee_single_little
84 const struct floatformat *floatformats_ieee_double[BFD_ENDIAN_UNKNOWN] = {
85 &floatformat_ieee_double_big,
86 &floatformat_ieee_double_little
88 const struct floatformat *floatformats_ieee_double_littlebyte_bigword[BFD_ENDIAN_UNKNOWN] = {
89 &floatformat_ieee_double_big,
90 &floatformat_ieee_double_littlebyte_bigword
92 const struct floatformat *floatformats_i387_ext[BFD_ENDIAN_UNKNOWN] = {
93 &floatformat_i387_ext,
96 const struct floatformat *floatformats_m68881_ext[BFD_ENDIAN_UNKNOWN] = {
97 &floatformat_m68881_ext,
98 &floatformat_m68881_ext
100 const struct floatformat *floatformats_arm_ext[BFD_ENDIAN_UNKNOWN] = {
101 &floatformat_arm_ext_big,
102 &floatformat_arm_ext_littlebyte_bigword
104 const struct floatformat *floatformats_ia64_spill[BFD_ENDIAN_UNKNOWN] = {
105 &floatformat_ia64_spill_big,
106 &floatformat_ia64_spill_little
108 const struct floatformat *floatformats_ia64_quad[BFD_ENDIAN_UNKNOWN] = {
109 &floatformat_ia64_quad_big,
110 &floatformat_ia64_quad_little
112 const struct floatformat *floatformats_vax_f[BFD_ENDIAN_UNKNOWN] = {
116 const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN] = {
121 struct type *builtin_type_ieee_single;
122 struct type *builtin_type_ieee_double;
123 struct type *builtin_type_i387_ext;
124 struct type *builtin_type_m68881_ext;
125 struct type *builtin_type_arm_ext;
126 struct type *builtin_type_ia64_spill;
127 struct type *builtin_type_ia64_quad;
129 struct type *builtin_type_void_data_ptr;
130 struct type *builtin_type_void_func_ptr;
131 struct type *builtin_type_CORE_ADDR;
133 int opaque_type_resolution = 1;
135 show_opaque_type_resolution (struct ui_file *file, int from_tty,
136 struct cmd_list_element *c, const char *value)
138 fprintf_filtered (file, _("\
139 Resolution of opaque struct/class/union types (if set before loading symbols) is %s.\n"),
143 int overload_debug = 0;
145 show_overload_debug (struct ui_file *file, int from_tty,
146 struct cmd_list_element *c, const char *value)
148 fprintf_filtered (file, _("Debugging of C++ overloading is %s.\n"), value);
155 }; /* maximum extension is 128! FIXME */
157 static void print_bit_vector (B_TYPE *, int);
158 static void print_arg_types (struct field *, int, int);
159 static void dump_fn_fieldlists (struct type *, int);
160 static void print_cplus_stuff (struct type *, int);
161 static void virtual_base_list_aux (struct type *dclass);
164 /* Alloc a new type structure and fill it with some defaults. If
165 OBJFILE is non-NULL, then allocate the space for the type structure
166 in that objfile's objfile_obstack. Otherwise allocate the new type structure
167 by xmalloc () (for permanent types). */
170 alloc_type (struct objfile *objfile)
174 /* Alloc the structure and start off with all fields zeroed. */
178 type = xmalloc (sizeof (struct type));
179 memset (type, 0, sizeof (struct type));
180 TYPE_MAIN_TYPE (type) = xmalloc (sizeof (struct main_type));
184 type = obstack_alloc (&objfile->objfile_obstack,
185 sizeof (struct type));
186 memset (type, 0, sizeof (struct type));
187 TYPE_MAIN_TYPE (type) = obstack_alloc (&objfile->objfile_obstack,
188 sizeof (struct main_type));
189 OBJSTAT (objfile, n_types++);
191 memset (TYPE_MAIN_TYPE (type), 0, sizeof (struct main_type));
193 /* Initialize the fields that might not be zero. */
195 TYPE_CODE (type) = TYPE_CODE_UNDEF;
196 TYPE_OBJFILE (type) = objfile;
197 TYPE_VPTR_FIELDNO (type) = -1;
198 TYPE_CHAIN (type) = type; /* Chain back to itself. */
203 /* Alloc a new type instance structure, fill it with some defaults,
204 and point it at OLDTYPE. Allocate the new type instance from the
205 same place as OLDTYPE. */
208 alloc_type_instance (struct type *oldtype)
212 /* Allocate the structure. */
214 if (TYPE_OBJFILE (oldtype) == NULL)
216 type = xmalloc (sizeof (struct type));
217 memset (type, 0, sizeof (struct type));
221 type = obstack_alloc (&TYPE_OBJFILE (oldtype)->objfile_obstack,
222 sizeof (struct type));
223 memset (type, 0, sizeof (struct type));
225 TYPE_MAIN_TYPE (type) = TYPE_MAIN_TYPE (oldtype);
227 TYPE_CHAIN (type) = type; /* Chain back to itself for now. */
232 /* Clear all remnants of the previous type at TYPE, in preparation for
233 replacing it with something else. */
235 smash_type (struct type *type)
237 memset (TYPE_MAIN_TYPE (type), 0, sizeof (struct main_type));
239 /* For now, delete the rings. */
240 TYPE_CHAIN (type) = type;
242 /* For now, leave the pointer/reference types alone. */
245 /* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points
246 to a pointer to memory where the pointer type should be stored.
247 If *TYPEPTR is zero, update it to point to the pointer type we return.
248 We allocate new memory if needed. */
251 make_pointer_type (struct type *type, struct type **typeptr)
253 struct type *ntype; /* New type */
254 struct objfile *objfile;
257 ntype = TYPE_POINTER_TYPE (type);
262 return ntype; /* Don't care about alloc, and have new type. */
263 else if (*typeptr == 0)
265 *typeptr = ntype; /* Tracking alloc, and we have new type. */
270 if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
272 ntype = alloc_type (TYPE_OBJFILE (type));
277 /* We have storage, but need to reset it. */
280 objfile = TYPE_OBJFILE (ntype);
281 chain = TYPE_CHAIN (ntype);
283 TYPE_CHAIN (ntype) = chain;
284 TYPE_OBJFILE (ntype) = objfile;
287 TYPE_TARGET_TYPE (ntype) = type;
288 TYPE_POINTER_TYPE (type) = ntype;
290 /* FIXME! Assume the machine has only one representation for pointers! */
292 TYPE_LENGTH (ntype) = gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT;
293 TYPE_CODE (ntype) = TYPE_CODE_PTR;
295 /* Mark pointers as unsigned. The target converts between pointers
296 and addresses (CORE_ADDRs) using gdbarch_pointer_to_address and
297 gdbarch_address_to_pointer. */
298 TYPE_FLAGS (ntype) |= TYPE_FLAG_UNSIGNED;
300 if (!TYPE_POINTER_TYPE (type)) /* Remember it, if don't have one. */
301 TYPE_POINTER_TYPE (type) = ntype;
303 /* Update the length of all the other variants of this type. */
304 chain = TYPE_CHAIN (ntype);
305 while (chain != ntype)
307 TYPE_LENGTH (chain) = TYPE_LENGTH (ntype);
308 chain = TYPE_CHAIN (chain);
314 /* Given a type TYPE, return a type of pointers to that type.
315 May need to construct such a type if this is the first use. */
318 lookup_pointer_type (struct type *type)
320 return make_pointer_type (type, (struct type **) 0);
323 /* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, points
324 to a pointer to memory where the reference type should be stored.
325 If *TYPEPTR is zero, update it to point to the reference type we return.
326 We allocate new memory if needed. */
329 make_reference_type (struct type *type, struct type **typeptr)
331 struct type *ntype; /* New type */
332 struct objfile *objfile;
335 ntype = TYPE_REFERENCE_TYPE (type);
340 return ntype; /* Don't care about alloc, and have new type. */
341 else if (*typeptr == 0)
343 *typeptr = ntype; /* Tracking alloc, and we have new type. */
348 if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
350 ntype = alloc_type (TYPE_OBJFILE (type));
355 /* We have storage, but need to reset it. */
358 objfile = TYPE_OBJFILE (ntype);
359 chain = TYPE_CHAIN (ntype);
361 TYPE_CHAIN (ntype) = chain;
362 TYPE_OBJFILE (ntype) = objfile;
365 TYPE_TARGET_TYPE (ntype) = type;
366 TYPE_REFERENCE_TYPE (type) = ntype;
368 /* FIXME! Assume the machine has only one representation for references,
369 and that it matches the (only) representation for pointers! */
371 TYPE_LENGTH (ntype) = gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT;
372 TYPE_CODE (ntype) = TYPE_CODE_REF;
374 if (!TYPE_REFERENCE_TYPE (type)) /* Remember it, if don't have one. */
375 TYPE_REFERENCE_TYPE (type) = ntype;
377 /* Update the length of all the other variants of this type. */
378 chain = TYPE_CHAIN (ntype);
379 while (chain != ntype)
381 TYPE_LENGTH (chain) = TYPE_LENGTH (ntype);
382 chain = TYPE_CHAIN (chain);
388 /* Same as above, but caller doesn't care about memory allocation details. */
391 lookup_reference_type (struct type *type)
393 return make_reference_type (type, (struct type **) 0);
396 /* Lookup a function type that returns type TYPE. TYPEPTR, if nonzero, points
397 to a pointer to memory where the function type should be stored.
398 If *TYPEPTR is zero, update it to point to the function type we return.
399 We allocate new memory if needed. */
402 make_function_type (struct type *type, struct type **typeptr)
404 struct type *ntype; /* New type */
405 struct objfile *objfile;
407 if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
409 ntype = alloc_type (TYPE_OBJFILE (type));
414 /* We have storage, but need to reset it. */
417 objfile = TYPE_OBJFILE (ntype);
419 TYPE_OBJFILE (ntype) = objfile;
422 TYPE_TARGET_TYPE (ntype) = type;
424 TYPE_LENGTH (ntype) = 1;
425 TYPE_CODE (ntype) = TYPE_CODE_FUNC;
431 /* Given a type TYPE, return a type of functions that return that type.
432 May need to construct such a type if this is the first use. */
435 lookup_function_type (struct type *type)
437 return make_function_type (type, (struct type **) 0);
440 /* Identify address space identifier by name --
441 return the integer flag defined in gdbtypes.h. */
443 address_space_name_to_int (char *space_identifier)
445 struct gdbarch *gdbarch = current_gdbarch;
447 /* Check for known address space delimiters. */
448 if (!strcmp (space_identifier, "code"))
449 return TYPE_FLAG_CODE_SPACE;
450 else if (!strcmp (space_identifier, "data"))
451 return TYPE_FLAG_DATA_SPACE;
452 else if (gdbarch_address_class_name_to_type_flags_p (gdbarch)
453 && gdbarch_address_class_name_to_type_flags (gdbarch,
458 error (_("Unknown address space specifier: \"%s\""), space_identifier);
461 /* Identify address space identifier by integer flag as defined in
462 gdbtypes.h -- return the string version of the adress space name. */
465 address_space_int_to_name (int space_flag)
467 struct gdbarch *gdbarch = current_gdbarch;
468 if (space_flag & TYPE_FLAG_CODE_SPACE)
470 else if (space_flag & TYPE_FLAG_DATA_SPACE)
472 else if ((space_flag & TYPE_FLAG_ADDRESS_CLASS_ALL)
473 && gdbarch_address_class_type_flags_to_name_p (gdbarch))
474 return gdbarch_address_class_type_flags_to_name (gdbarch, space_flag);
479 /* Create a new type with instance flags NEW_FLAGS, based on TYPE.
481 If STORAGE is non-NULL, create the new type instance there.
482 STORAGE must be in the same obstack as TYPE. */
485 make_qualified_type (struct type *type, int new_flags,
486 struct type *storage)
492 if (TYPE_INSTANCE_FLAGS (ntype) == new_flags)
494 ntype = TYPE_CHAIN (ntype);
495 } while (ntype != type);
497 /* Create a new type instance. */
499 ntype = alloc_type_instance (type);
502 /* If STORAGE was provided, it had better be in the same objfile as
503 TYPE. Otherwise, we can't link it into TYPE's cv chain: if one
504 objfile is freed and the other kept, we'd have dangling
506 gdb_assert (TYPE_OBJFILE (type) == TYPE_OBJFILE (storage));
509 TYPE_MAIN_TYPE (ntype) = TYPE_MAIN_TYPE (type);
510 TYPE_CHAIN (ntype) = ntype;
513 /* Pointers or references to the original type are not relevant to
515 TYPE_POINTER_TYPE (ntype) = (struct type *) 0;
516 TYPE_REFERENCE_TYPE (ntype) = (struct type *) 0;
518 /* Chain the new qualified type to the old type. */
519 TYPE_CHAIN (ntype) = TYPE_CHAIN (type);
520 TYPE_CHAIN (type) = ntype;
522 /* Now set the instance flags and return the new type. */
523 TYPE_INSTANCE_FLAGS (ntype) = new_flags;
525 /* Set length of new type to that of the original type. */
526 TYPE_LENGTH (ntype) = TYPE_LENGTH (type);
531 /* Make an address-space-delimited variant of a type -- a type that
532 is identical to the one supplied except that it has an address
533 space attribute attached to it (such as "code" or "data").
535 The space attributes "code" and "data" are for Harvard architectures.
536 The address space attributes are for architectures which have
537 alternately sized pointers or pointers with alternate representations. */
540 make_type_with_address_space (struct type *type, int space_flag)
543 int new_flags = ((TYPE_INSTANCE_FLAGS (type)
544 & ~(TYPE_FLAG_CODE_SPACE | TYPE_FLAG_DATA_SPACE
545 | TYPE_FLAG_ADDRESS_CLASS_ALL))
548 return make_qualified_type (type, new_flags, NULL);
551 /* Make a "c-v" variant of a type -- a type that is identical to the
552 one supplied except that it may have const or volatile attributes
553 CNST is a flag for setting the const attribute
554 VOLTL is a flag for setting the volatile attribute
555 TYPE is the base type whose variant we are creating.
557 If TYPEPTR and *TYPEPTR are non-zero, then *TYPEPTR points to
558 storage to hold the new qualified type; *TYPEPTR and TYPE must be
559 in the same objfile. Otherwise, allocate fresh memory for the new
560 type whereever TYPE lives. If TYPEPTR is non-zero, set it to the
561 new type we construct. */
563 make_cv_type (int cnst, int voltl, struct type *type, struct type **typeptr)
565 struct type *ntype; /* New type */
566 struct type *tmp_type = type; /* tmp type */
567 struct objfile *objfile;
569 int new_flags = (TYPE_INSTANCE_FLAGS (type)
570 & ~(TYPE_FLAG_CONST | TYPE_FLAG_VOLATILE));
573 new_flags |= TYPE_FLAG_CONST;
576 new_flags |= TYPE_FLAG_VOLATILE;
578 if (typeptr && *typeptr != NULL)
580 /* TYPE and *TYPEPTR must be in the same objfile. We can't have
581 a C-V variant chain that threads across objfiles: if one
582 objfile gets freed, then the other has a broken C-V chain.
584 This code used to try to copy over the main type from TYPE to
585 *TYPEPTR if they were in different objfiles, but that's
586 wrong, too: TYPE may have a field list or member function
587 lists, which refer to types of their own, etc. etc. The
588 whole shebang would need to be copied over recursively; you
589 can't have inter-objfile pointers. The only thing to do is
590 to leave stub types as stub types, and look them up afresh by
591 name each time you encounter them. */
592 gdb_assert (TYPE_OBJFILE (*typeptr) == TYPE_OBJFILE (type));
595 ntype = make_qualified_type (type, new_flags, typeptr ? *typeptr : NULL);
603 /* Replace the contents of ntype with the type *type. This changes the
604 contents, rather than the pointer for TYPE_MAIN_TYPE (ntype); thus
605 the changes are propogated to all types in the TYPE_CHAIN.
607 In order to build recursive types, it's inevitable that we'll need
608 to update types in place --- but this sort of indiscriminate
609 smashing is ugly, and needs to be replaced with something more
610 controlled. TYPE_MAIN_TYPE is a step in this direction; it's not
611 clear if more steps are needed. */
613 replace_type (struct type *ntype, struct type *type)
617 /* These two types had better be in the same objfile. Otherwise,
618 the assignment of one type's main type structure to the other
619 will produce a type with references to objects (names; field
620 lists; etc.) allocated on an objfile other than its own. */
621 gdb_assert (TYPE_OBJFILE (ntype) == TYPE_OBJFILE (ntype));
623 *TYPE_MAIN_TYPE (ntype) = *TYPE_MAIN_TYPE (type);
625 /* The type length is not a part of the main type. Update it for each
626 type on the variant chain. */
629 /* Assert that this element of the chain has no address-class bits
630 set in its flags. Such type variants might have type lengths
631 which are supposed to be different from the non-address-class
632 variants. This assertion shouldn't ever be triggered because
633 symbol readers which do construct address-class variants don't
634 call replace_type(). */
635 gdb_assert (TYPE_ADDRESS_CLASS_ALL (chain) == 0);
637 TYPE_LENGTH (chain) = TYPE_LENGTH (type);
638 chain = TYPE_CHAIN (chain);
639 } while (ntype != chain);
641 /* Assert that the two types have equivalent instance qualifiers.
642 This should be true for at least all of our debug readers. */
643 gdb_assert (TYPE_INSTANCE_FLAGS (ntype) == TYPE_INSTANCE_FLAGS (type));
646 /* Implement direct support for MEMBER_TYPE in GNU C++.
647 May need to construct such a type if this is the first use.
648 The TYPE is the type of the member. The DOMAIN is the type
649 of the aggregate that the member belongs to. */
652 lookup_memberptr_type (struct type *type, struct type *domain)
656 mtype = alloc_type (TYPE_OBJFILE (type));
657 smash_to_memberptr_type (mtype, domain, type);
661 /* Return a pointer-to-method type, for a method of type TO_TYPE. */
664 lookup_methodptr_type (struct type *to_type)
668 mtype = alloc_type (TYPE_OBJFILE (to_type));
669 TYPE_TARGET_TYPE (mtype) = to_type;
670 TYPE_DOMAIN_TYPE (mtype) = TYPE_DOMAIN_TYPE (to_type);
671 TYPE_LENGTH (mtype) = cplus_method_ptr_size ();
672 TYPE_CODE (mtype) = TYPE_CODE_METHODPTR;
676 /* Allocate a stub method whose return type is TYPE.
677 This apparently happens for speed of symbol reading, since parsing
678 out the arguments to the method is cpu-intensive, the way we are doing
679 it. So, we will fill in arguments later.
680 This always returns a fresh type. */
683 allocate_stub_method (struct type *type)
687 mtype = init_type (TYPE_CODE_METHOD, 1, TYPE_FLAG_STUB, NULL,
688 TYPE_OBJFILE (type));
689 TYPE_TARGET_TYPE (mtype) = type;
690 /* _DOMAIN_TYPE (mtype) = unknown yet */
694 /* Create a range type using either a blank type supplied in RESULT_TYPE,
695 or creating a new type, inheriting the objfile from INDEX_TYPE.
697 Indices will be of type INDEX_TYPE, and will range from LOW_BOUND to
698 HIGH_BOUND, inclusive.
700 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
701 sure it is TYPE_CODE_UNDEF before we bash it into a range type? */
704 create_range_type (struct type *result_type, struct type *index_type,
705 int low_bound, int high_bound)
707 if (result_type == NULL)
709 result_type = alloc_type (TYPE_OBJFILE (index_type));
711 TYPE_CODE (result_type) = TYPE_CODE_RANGE;
712 TYPE_TARGET_TYPE (result_type) = index_type;
713 if (TYPE_STUB (index_type))
714 TYPE_FLAGS (result_type) |= TYPE_FLAG_TARGET_STUB;
716 TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type));
717 TYPE_NFIELDS (result_type) = 2;
718 TYPE_FIELDS (result_type) = (struct field *)
719 TYPE_ALLOC (result_type, 2 * sizeof (struct field));
720 memset (TYPE_FIELDS (result_type), 0, 2 * sizeof (struct field));
721 TYPE_FIELD_BITPOS (result_type, 0) = low_bound;
722 TYPE_FIELD_BITPOS (result_type, 1) = high_bound;
723 TYPE_FIELD_TYPE (result_type, 0) = builtin_type_int; /* FIXME */
724 TYPE_FIELD_TYPE (result_type, 1) = builtin_type_int; /* FIXME */
727 TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED;
729 return (result_type);
732 /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type TYPE.
733 Return 1 if type is a range type, 0 if it is discrete (and bounds
734 will fit in LONGEST), or -1 otherwise. */
737 get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp)
739 CHECK_TYPEDEF (type);
740 switch (TYPE_CODE (type))
742 case TYPE_CODE_RANGE:
743 *lowp = TYPE_LOW_BOUND (type);
744 *highp = TYPE_HIGH_BOUND (type);
747 if (TYPE_NFIELDS (type) > 0)
749 /* The enums may not be sorted by value, so search all
753 *lowp = *highp = TYPE_FIELD_BITPOS (type, 0);
754 for (i = 0; i < TYPE_NFIELDS (type); i++)
756 if (TYPE_FIELD_BITPOS (type, i) < *lowp)
757 *lowp = TYPE_FIELD_BITPOS (type, i);
758 if (TYPE_FIELD_BITPOS (type, i) > *highp)
759 *highp = TYPE_FIELD_BITPOS (type, i);
762 /* Set unsigned indicator if warranted. */
765 TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED;
779 if (TYPE_LENGTH (type) > sizeof (LONGEST)) /* Too big */
781 if (!TYPE_UNSIGNED (type))
783 *lowp = -(1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1));
787 /* ... fall through for unsigned ints ... */
790 /* This round-about calculation is to avoid shifting by
791 TYPE_LENGTH (type) * TARGET_CHAR_BIT, which will not work
792 if TYPE_LENGTH (type) == sizeof (LONGEST). */
793 *highp = 1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1);
794 *highp = (*highp - 1) | *highp;
801 /* Create an array type using either a blank type supplied in RESULT_TYPE,
802 or creating a new type, inheriting the objfile from RANGE_TYPE.
804 Elements will be of type ELEMENT_TYPE, the indices will be of type
807 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
808 sure it is TYPE_CODE_UNDEF before we bash it into an array type? */
811 create_array_type (struct type *result_type, struct type *element_type,
812 struct type *range_type)
814 LONGEST low_bound, high_bound;
816 if (result_type == NULL)
818 result_type = alloc_type (TYPE_OBJFILE (range_type));
820 TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
821 TYPE_TARGET_TYPE (result_type) = element_type;
822 if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
823 low_bound = high_bound = 0;
824 CHECK_TYPEDEF (element_type);
825 TYPE_LENGTH (result_type) =
826 TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
827 TYPE_NFIELDS (result_type) = 1;
828 TYPE_FIELDS (result_type) =
829 (struct field *) TYPE_ALLOC (result_type, sizeof (struct field));
830 memset (TYPE_FIELDS (result_type), 0, sizeof (struct field));
831 TYPE_FIELD_TYPE (result_type, 0) = range_type;
832 TYPE_VPTR_FIELDNO (result_type) = -1;
834 /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays */
835 if (TYPE_LENGTH (result_type) == 0)
836 TYPE_FLAGS (result_type) |= TYPE_FLAG_TARGET_STUB;
838 return (result_type);
841 /* Create a string type using either a blank type supplied in RESULT_TYPE,
842 or creating a new type. String types are similar enough to array of
843 char types that we can use create_array_type to build the basic type
844 and then bash it into a string type.
846 For fixed length strings, the range type contains 0 as the lower
847 bound and the length of the string minus one as the upper bound.
849 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
850 sure it is TYPE_CODE_UNDEF before we bash it into a string type? */
853 create_string_type (struct type *result_type, struct type *range_type)
855 struct type *string_char_type;
857 string_char_type = language_string_char_type (current_language,
859 result_type = create_array_type (result_type,
862 TYPE_CODE (result_type) = TYPE_CODE_STRING;
863 return (result_type);
867 create_set_type (struct type *result_type, struct type *domain_type)
869 LONGEST low_bound, high_bound, bit_length;
870 if (result_type == NULL)
872 result_type = alloc_type (TYPE_OBJFILE (domain_type));
874 TYPE_CODE (result_type) = TYPE_CODE_SET;
875 TYPE_NFIELDS (result_type) = 1;
876 TYPE_FIELDS (result_type) = (struct field *)
877 TYPE_ALLOC (result_type, 1 * sizeof (struct field));
878 memset (TYPE_FIELDS (result_type), 0, sizeof (struct field));
880 if (!TYPE_STUB (domain_type))
882 if (get_discrete_bounds (domain_type, &low_bound, &high_bound) < 0)
883 low_bound = high_bound = 0;
884 bit_length = high_bound - low_bound + 1;
885 TYPE_LENGTH (result_type)
886 = (bit_length + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
888 TYPE_FIELD_TYPE (result_type, 0) = domain_type;
891 TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED;
893 return (result_type);
897 append_flags_type_flag (struct type *type, int bitpos, char *name)
899 gdb_assert (TYPE_CODE (type) == TYPE_CODE_FLAGS);
900 gdb_assert (bitpos < TYPE_NFIELDS (type));
901 gdb_assert (bitpos >= 0);
905 TYPE_FIELD_NAME (type, bitpos) = xstrdup (name);
906 TYPE_FIELD_BITPOS (type, bitpos) = bitpos;
910 /* Don't show this field to the user. */
911 TYPE_FIELD_BITPOS (type, bitpos) = -1;
916 init_flags_type (char *name, int length)
918 int nfields = length * TARGET_CHAR_BIT;
921 type = init_type (TYPE_CODE_FLAGS, length, TYPE_FLAG_UNSIGNED, name, NULL);
922 TYPE_NFIELDS (type) = nfields;
923 TYPE_FIELDS (type) = TYPE_ALLOC (type, nfields * sizeof (struct field));
924 memset (TYPE_FIELDS (type), 0, nfields * sizeof (struct field));
930 init_vector_type (struct type *elt_type, int n)
932 struct type *array_type;
934 array_type = create_array_type (0, elt_type,
935 create_range_type (0, builtin_type_int,
937 TYPE_FLAGS (array_type) |= TYPE_FLAG_VECTOR;
941 /* Smash TYPE to be a type of pointers to members of DOMAIN with type
942 TO_TYPE. A member pointer is a wierd thing -- it amounts to a
943 typed offset into a struct, e.g. "an int at offset 8". A MEMBER
944 TYPE doesn't include the offset (that's the value of the MEMBER
945 itself), but does include the structure type into which it points
948 When "smashing" the type, we preserve the objfile that the
949 old type pointed to, since we aren't changing where the type is actually
953 smash_to_memberptr_type (struct type *type, struct type *domain,
954 struct type *to_type)
956 struct objfile *objfile;
958 objfile = TYPE_OBJFILE (type);
961 TYPE_OBJFILE (type) = objfile;
962 TYPE_TARGET_TYPE (type) = to_type;
963 TYPE_DOMAIN_TYPE (type) = domain;
964 /* Assume that a data member pointer is the same size as a normal
966 TYPE_LENGTH (type) = gdbarch_ptr_bit (current_gdbarch) / TARGET_CHAR_BIT;
967 TYPE_CODE (type) = TYPE_CODE_MEMBERPTR;
970 /* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE.
971 METHOD just means `function that gets an extra "this" argument'.
973 When "smashing" the type, we preserve the objfile that the
974 old type pointed to, since we aren't changing where the type is actually
978 smash_to_method_type (struct type *type, struct type *domain,
979 struct type *to_type, struct field *args,
980 int nargs, int varargs)
982 struct objfile *objfile;
984 objfile = TYPE_OBJFILE (type);
987 TYPE_OBJFILE (type) = objfile;
988 TYPE_TARGET_TYPE (type) = to_type;
989 TYPE_DOMAIN_TYPE (type) = domain;
990 TYPE_FIELDS (type) = args;
991 TYPE_NFIELDS (type) = nargs;
993 TYPE_FLAGS (type) |= TYPE_FLAG_VARARGS;
994 TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */
995 TYPE_CODE (type) = TYPE_CODE_METHOD;
998 /* Return a typename for a struct/union/enum type without "struct ",
999 "union ", or "enum ". If the type has a NULL name, return NULL. */
1002 type_name_no_tag (const struct type *type)
1004 if (TYPE_TAG_NAME (type) != NULL)
1005 return TYPE_TAG_NAME (type);
1007 /* Is there code which expects this to return the name if there is no
1008 tag name? My guess is that this is mainly used for C++ in cases where
1009 the two will always be the same. */
1010 return TYPE_NAME (type);
1013 /* Lookup a typedef or primitive type named NAME,
1014 visible in lexical block BLOCK.
1015 If NOERR is nonzero, return zero if NAME is not suitably defined. */
1018 lookup_typename (char *name, struct block *block, int noerr)
1023 sym = lookup_symbol (name, block, VAR_DOMAIN, 0, (struct symtab **) NULL);
1024 if (sym == NULL || SYMBOL_CLASS (sym) != LOC_TYPEDEF)
1026 tmp = language_lookup_primitive_type_by_name (current_language,
1033 else if (!tmp && noerr)
1039 error (_("No type named %s."), name);
1042 return (SYMBOL_TYPE (sym));
1046 lookup_unsigned_typename (char *name)
1048 char *uns = alloca (strlen (name) + 10);
1050 strcpy (uns, "unsigned ");
1051 strcpy (uns + 9, name);
1052 return (lookup_typename (uns, (struct block *) NULL, 0));
1056 lookup_signed_typename (char *name)
1059 char *uns = alloca (strlen (name) + 8);
1061 strcpy (uns, "signed ");
1062 strcpy (uns + 7, name);
1063 t = lookup_typename (uns, (struct block *) NULL, 1);
1064 /* If we don't find "signed FOO" just try again with plain "FOO". */
1067 return lookup_typename (name, (struct block *) NULL, 0);
1070 /* Lookup a structure type named "struct NAME",
1071 visible in lexical block BLOCK. */
1074 lookup_struct (char *name, struct block *block)
1078 sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0,
1079 (struct symtab **) NULL);
1083 error (_("No struct type named %s."), name);
1085 if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT)
1087 error (_("This context has class, union or enum %s, not a struct."), name);
1089 return (SYMBOL_TYPE (sym));
1092 /* Lookup a union type named "union NAME",
1093 visible in lexical block BLOCK. */
1096 lookup_union (char *name, struct block *block)
1101 sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0,
1102 (struct symtab **) NULL);
1105 error (_("No union type named %s."), name);
1107 t = SYMBOL_TYPE (sym);
1109 if (TYPE_CODE (t) == TYPE_CODE_UNION)
1112 /* C++ unions may come out with TYPE_CODE_CLASS, but we look at
1113 * a further "declared_type" field to discover it is really a union.
1115 if (HAVE_CPLUS_STRUCT (t))
1116 if (TYPE_DECLARED_TYPE (t) == DECLARED_TYPE_UNION)
1119 /* If we get here, it's not a union */
1120 error (_("This context has class, struct or enum %s, not a union."), name);
1124 /* Lookup an enum type named "enum NAME",
1125 visible in lexical block BLOCK. */
1128 lookup_enum (char *name, struct block *block)
1132 sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0,
1133 (struct symtab **) NULL);
1136 error (_("No enum type named %s."), name);
1138 if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_ENUM)
1140 error (_("This context has class, struct or union %s, not an enum."), name);
1142 return (SYMBOL_TYPE (sym));
1145 /* Lookup a template type named "template NAME<TYPE>",
1146 visible in lexical block BLOCK. */
1149 lookup_template_type (char *name, struct type *type, struct block *block)
1152 char *nam = (char *) alloca (strlen (name) + strlen (TYPE_NAME (type)) + 4);
1155 strcat (nam, TYPE_NAME (type));
1156 strcat (nam, " >"); /* FIXME, extra space still introduced in gcc? */
1158 sym = lookup_symbol (nam, block, VAR_DOMAIN, 0, (struct symtab **) NULL);
1162 error (_("No template type named %s."), name);
1164 if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT)
1166 error (_("This context has class, union or enum %s, not a struct."), name);
1168 return (SYMBOL_TYPE (sym));
1171 /* Given a type TYPE, lookup the type of the component of type named NAME.
1173 TYPE can be either a struct or union, or a pointer or reference to a struct or
1174 union. If it is a pointer or reference, its target type is automatically used.
1175 Thus '.' and '->' are interchangable, as specified for the definitions of the
1176 expression element types STRUCTOP_STRUCT and STRUCTOP_PTR.
1178 If NOERR is nonzero, return zero if NAME is not suitably defined.
1179 If NAME is the name of a baseclass type, return that type. */
1182 lookup_struct_elt_type (struct type *type, char *name, int noerr)
1188 CHECK_TYPEDEF (type);
1189 if (TYPE_CODE (type) != TYPE_CODE_PTR
1190 && TYPE_CODE (type) != TYPE_CODE_REF)
1192 type = TYPE_TARGET_TYPE (type);
1195 if (TYPE_CODE (type) != TYPE_CODE_STRUCT &&
1196 TYPE_CODE (type) != TYPE_CODE_UNION)
1198 target_terminal_ours ();
1199 gdb_flush (gdb_stdout);
1200 fprintf_unfiltered (gdb_stderr, "Type ");
1201 type_print (type, "", gdb_stderr, -1);
1202 error (_(" is not a structure or union type."));
1206 /* FIXME: This change put in by Michael seems incorrect for the case where
1207 the structure tag name is the same as the member name. I.E. when doing
1208 "ptype bell->bar" for "struct foo { int bar; int foo; } bell;"
1213 typename = type_name_no_tag (type);
1214 if (typename != NULL && strcmp (typename, name) == 0)
1219 for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--)
1221 char *t_field_name = TYPE_FIELD_NAME (type, i);
1223 if (t_field_name && (strcmp_iw (t_field_name, name) == 0))
1225 return TYPE_FIELD_TYPE (type, i);
1229 /* OK, it's not in this class. Recursively check the baseclasses. */
1230 for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
1234 t = lookup_struct_elt_type (TYPE_BASECLASS (type, i), name, 1);
1246 target_terminal_ours ();
1247 gdb_flush (gdb_stdout);
1248 fprintf_unfiltered (gdb_stderr, "Type ");
1249 type_print (type, "", gdb_stderr, -1);
1250 fprintf_unfiltered (gdb_stderr, " has no component named ");
1251 fputs_filtered (name, gdb_stderr);
1253 return (struct type *) -1; /* For lint */
1256 /* If possible, make the vptr_fieldno and vptr_basetype fields of TYPE
1257 valid. Callers should be aware that in some cases (for example,
1258 the type or one of its baseclasses is a stub type and we are
1259 debugging a .o file), this function will not be able to find the virtual
1260 function table pointer, and vptr_fieldno will remain -1 and vptr_basetype
1261 will remain NULL. */
1264 fill_in_vptr_fieldno (struct type *type)
1266 CHECK_TYPEDEF (type);
1268 if (TYPE_VPTR_FIELDNO (type) < 0)
1272 /* We must start at zero in case the first (and only) baseclass is
1273 virtual (and hence we cannot share the table pointer). */
1274 for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
1276 struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
1277 fill_in_vptr_fieldno (baseclass);
1278 if (TYPE_VPTR_FIELDNO (baseclass) >= 0)
1280 TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (baseclass);
1281 TYPE_VPTR_BASETYPE (type) = TYPE_VPTR_BASETYPE (baseclass);
1288 /* Find the method and field indices for the destructor in class type T.
1289 Return 1 if the destructor was found, otherwise, return 0. */
1292 get_destructor_fn_field (struct type *t, int *method_indexp, int *field_indexp)
1296 for (i = 0; i < TYPE_NFN_FIELDS (t); i++)
1299 struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i);
1301 for (j = 0; j < TYPE_FN_FIELDLIST_LENGTH (t, i); j++)
1303 if (is_destructor_name (TYPE_FN_FIELD_PHYSNAME (f, j)) != 0)
1315 stub_noname_complaint (void)
1317 complaint (&symfile_complaints, _("stub type has NULL name"));
1320 /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989.
1322 If this is a stubbed struct (i.e. declared as struct foo *), see if
1323 we can find a full definition in some other file. If so, copy this
1324 definition, so we can use it in future. There used to be a comment (but
1325 not any code) that if we don't find a full definition, we'd set a flag
1326 so we don't spend time in the future checking the same type. That would
1327 be a mistake, though--we might load in more symbols which contain a
1328 full definition for the type.
1330 This used to be coded as a macro, but I don't think it is called
1331 often enough to merit such treatment. */
1333 /* Find the real type of TYPE. This function returns the real type, after
1334 removing all layers of typedefs and completing opaque or stub types.
1335 Completion changes the TYPE argument, but stripping of typedefs does
1339 check_typedef (struct type *type)
1341 struct type *orig_type = type;
1342 int is_const, is_volatile;
1344 while (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
1346 if (!TYPE_TARGET_TYPE (type))
1351 /* It is dangerous to call lookup_symbol if we are currently
1352 reading a symtab. Infinite recursion is one danger. */
1353 if (currently_reading_symtab)
1356 name = type_name_no_tag (type);
1357 /* FIXME: shouldn't we separately check the TYPE_NAME and the
1358 TYPE_TAG_NAME, and look in STRUCT_DOMAIN and/or VAR_DOMAIN
1359 as appropriate? (this code was written before TYPE_NAME and
1360 TYPE_TAG_NAME were separate). */
1363 stub_noname_complaint ();
1366 sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0,
1367 (struct symtab **) NULL);
1369 TYPE_TARGET_TYPE (type) = SYMBOL_TYPE (sym);
1371 TYPE_TARGET_TYPE (type) = alloc_type (NULL); /* TYPE_CODE_UNDEF */
1373 type = TYPE_TARGET_TYPE (type);
1376 is_const = TYPE_CONST (type);
1377 is_volatile = TYPE_VOLATILE (type);
1379 /* If this is a struct/class/union with no fields, then check whether a
1380 full definition exists somewhere else. This is for systems where a
1381 type definition with no fields is issued for such types, instead of
1382 identifying them as stub types in the first place */
1384 if (TYPE_IS_OPAQUE (type) && opaque_type_resolution && !currently_reading_symtab)
1386 char *name = type_name_no_tag (type);
1387 struct type *newtype;
1390 stub_noname_complaint ();
1393 newtype = lookup_transparent_type (name);
1397 /* If the resolved type and the stub are in the same objfile,
1398 then replace the stub type with the real deal. But if
1399 they're in separate objfiles, leave the stub alone; we'll
1400 just look up the transparent type every time we call
1401 check_typedef. We can't create pointers between types
1402 allocated to different objfiles, since they may have
1403 different lifetimes. Trying to copy NEWTYPE over to TYPE's
1404 objfile is pointless, too, since you'll have to move over any
1405 other types NEWTYPE refers to, which could be an unbounded
1407 if (TYPE_OBJFILE (newtype) == TYPE_OBJFILE (type))
1408 make_cv_type (is_const, is_volatile, newtype, &type);
1413 /* Otherwise, rely on the stub flag being set for opaque/stubbed types */
1414 else if (TYPE_STUB (type) && !currently_reading_symtab)
1416 char *name = type_name_no_tag (type);
1417 /* FIXME: shouldn't we separately check the TYPE_NAME and the
1418 TYPE_TAG_NAME, and look in STRUCT_DOMAIN and/or VAR_DOMAIN
1419 as appropriate? (this code was written before TYPE_NAME and
1420 TYPE_TAG_NAME were separate). */
1424 stub_noname_complaint ();
1427 sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL);
1430 /* Same as above for opaque types, we can replace the stub
1431 with the complete type only if they are int the same
1433 if (TYPE_OBJFILE (SYMBOL_TYPE(sym)) == TYPE_OBJFILE (type))
1434 make_cv_type (is_const, is_volatile, SYMBOL_TYPE (sym), &type);
1436 type = SYMBOL_TYPE (sym);
1440 if (TYPE_TARGET_STUB (type))
1442 struct type *range_type;
1443 struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type));
1445 if (TYPE_STUB (target_type) || TYPE_TARGET_STUB (target_type))
1448 else if (TYPE_CODE (type) == TYPE_CODE_ARRAY
1449 && TYPE_NFIELDS (type) == 1
1450 && (TYPE_CODE (range_type = TYPE_FIELD_TYPE (type, 0))
1451 == TYPE_CODE_RANGE))
1453 /* Now recompute the length of the array type, based on its
1454 number of elements and the target type's length. */
1455 TYPE_LENGTH (type) =
1456 ((TYPE_FIELD_BITPOS (range_type, 1)
1457 - TYPE_FIELD_BITPOS (range_type, 0)
1459 * TYPE_LENGTH (target_type));
1460 TYPE_FLAGS (type) &= ~TYPE_FLAG_TARGET_STUB;
1462 else if (TYPE_CODE (type) == TYPE_CODE_RANGE)
1464 TYPE_LENGTH (type) = TYPE_LENGTH (target_type);
1465 TYPE_FLAGS (type) &= ~TYPE_FLAG_TARGET_STUB;
1468 /* Cache TYPE_LENGTH for future use. */
1469 TYPE_LENGTH (orig_type) = TYPE_LENGTH (type);
1473 /* Parse a type expression in the string [P..P+LENGTH). If an error occurs,
1474 silently return builtin_type_void. */
1476 static struct type *
1477 safe_parse_type (char *p, int length)
1479 struct ui_file *saved_gdb_stderr;
1482 /* Suppress error messages. */
1483 saved_gdb_stderr = gdb_stderr;
1484 gdb_stderr = ui_file_new ();
1486 /* Call parse_and_eval_type() without fear of longjmp()s. */
1487 if (!gdb_parse_and_eval_type (p, length, &type))
1488 type = builtin_type_void;
1490 /* Stop suppressing error messages. */
1491 ui_file_delete (gdb_stderr);
1492 gdb_stderr = saved_gdb_stderr;
1497 /* Ugly hack to convert method stubs into method types.
1499 He ain't kiddin'. This demangles the name of the method into a string
1500 including argument types, parses out each argument type, generates
1501 a string casting a zero to that type, evaluates the string, and stuffs
1502 the resulting type into an argtype vector!!! Then it knows the type
1503 of the whole function (including argument types for overloading),
1504 which info used to be in the stab's but was removed to hack back
1505 the space required for them. */
1508 check_stub_method (struct type *type, int method_id, int signature_id)
1511 char *mangled_name = gdb_mangle_name (type, method_id, signature_id);
1512 char *demangled_name = cplus_demangle (mangled_name,
1513 DMGL_PARAMS | DMGL_ANSI);
1514 char *argtypetext, *p;
1515 int depth = 0, argcount = 1;
1516 struct field *argtypes;
1519 /* Make sure we got back a function string that we can use. */
1521 p = strchr (demangled_name, '(');
1525 if (demangled_name == NULL || p == NULL)
1526 error (_("Internal: Cannot demangle mangled name `%s'."), mangled_name);
1528 /* Now, read in the parameters that define this type. */
1533 if (*p == '(' || *p == '<')
1537 else if (*p == ')' || *p == '>')
1541 else if (*p == ',' && depth == 0)
1549 /* If we read one argument and it was ``void'', don't count it. */
1550 if (strncmp (argtypetext, "(void)", 6) == 0)
1553 /* We need one extra slot, for the THIS pointer. */
1555 argtypes = (struct field *)
1556 TYPE_ALLOC (type, (argcount + 1) * sizeof (struct field));
1559 /* Add THIS pointer for non-static methods. */
1560 f = TYPE_FN_FIELDLIST1 (type, method_id);
1561 if (TYPE_FN_FIELD_STATIC_P (f, signature_id))
1565 argtypes[0].type = lookup_pointer_type (type);
1569 if (*p != ')') /* () means no args, skip while */
1574 if (depth <= 0 && (*p == ',' || *p == ')'))
1576 /* Avoid parsing of ellipsis, they will be handled below.
1577 Also avoid ``void'' as above. */
1578 if (strncmp (argtypetext, "...", p - argtypetext) != 0
1579 && strncmp (argtypetext, "void", p - argtypetext) != 0)
1581 argtypes[argcount].type =
1582 safe_parse_type (argtypetext, p - argtypetext);
1585 argtypetext = p + 1;
1588 if (*p == '(' || *p == '<')
1592 else if (*p == ')' || *p == '>')
1601 TYPE_FN_FIELD_PHYSNAME (f, signature_id) = mangled_name;
1603 /* Now update the old "stub" type into a real type. */
1604 mtype = TYPE_FN_FIELD_TYPE (f, signature_id);
1605 TYPE_DOMAIN_TYPE (mtype) = type;
1606 TYPE_FIELDS (mtype) = argtypes;
1607 TYPE_NFIELDS (mtype) = argcount;
1608 TYPE_FLAGS (mtype) &= ~TYPE_FLAG_STUB;
1609 TYPE_FN_FIELD_STUB (f, signature_id) = 0;
1611 TYPE_FLAGS (mtype) |= TYPE_FLAG_VARARGS;
1613 xfree (demangled_name);
1616 /* This is the external interface to check_stub_method, above. This function
1617 unstubs all of the signatures for TYPE's METHOD_ID method name. After
1618 calling this function TYPE_FN_FIELD_STUB will be cleared for each signature
1619 and TYPE_FN_FIELDLIST_NAME will be correct.
1621 This function unfortunately can not die until stabs do. */
1624 check_stub_method_group (struct type *type, int method_id)
1626 int len = TYPE_FN_FIELDLIST_LENGTH (type, method_id);
1627 struct fn_field *f = TYPE_FN_FIELDLIST1 (type, method_id);
1628 int j, found_stub = 0;
1630 for (j = 0; j < len; j++)
1631 if (TYPE_FN_FIELD_STUB (f, j))
1634 check_stub_method (type, method_id, j);
1637 /* GNU v3 methods with incorrect names were corrected when we read in
1638 type information, because it was cheaper to do it then. The only GNU v2
1639 methods with incorrect method names are operators and destructors;
1640 destructors were also corrected when we read in type information.
1642 Therefore the only thing we need to handle here are v2 operator
1644 if (found_stub && strncmp (TYPE_FN_FIELD_PHYSNAME (f, 0), "_Z", 2) != 0)
1647 char dem_opname[256];
1649 ret = cplus_demangle_opname (TYPE_FN_FIELDLIST_NAME (type, method_id),
1650 dem_opname, DMGL_ANSI);
1652 ret = cplus_demangle_opname (TYPE_FN_FIELDLIST_NAME (type, method_id),
1655 TYPE_FN_FIELDLIST_NAME (type, method_id) = xstrdup (dem_opname);
1659 const struct cplus_struct_type cplus_struct_default;
1662 allocate_cplus_struct_type (struct type *type)
1664 if (!HAVE_CPLUS_STRUCT (type))
1666 TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *)
1667 TYPE_ALLOC (type, sizeof (struct cplus_struct_type));
1668 *(TYPE_CPLUS_SPECIFIC (type)) = cplus_struct_default;
1672 /* Helper function to initialize the standard scalar types.
1674 If NAME is non-NULL and OBJFILE is non-NULL, then we make a copy
1675 of the string pointed to by name in the objfile_obstack for that objfile,
1676 and initialize the type name to that copy. There are places (mipsread.c
1677 in particular, where init_type is called with a NULL value for NAME). */
1680 init_type (enum type_code code, int length, int flags, char *name,
1681 struct objfile *objfile)
1685 type = alloc_type (objfile);
1686 TYPE_CODE (type) = code;
1687 TYPE_LENGTH (type) = length;
1688 TYPE_FLAGS (type) |= flags;
1689 if ((name != NULL) && (objfile != NULL))
1692 obsavestring (name, strlen (name), &objfile->objfile_obstack);
1696 TYPE_NAME (type) = name;
1701 if (name && strcmp (name, "char") == 0)
1702 TYPE_FLAGS (type) |= TYPE_FLAG_NOSIGN;
1704 if (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION
1705 || code == TYPE_CODE_NAMESPACE)
1707 INIT_CPLUS_SPECIFIC (type);
1712 /* Helper function. Create an empty composite type. */
1715 init_composite_type (char *name, enum type_code code)
1718 gdb_assert (code == TYPE_CODE_STRUCT
1719 || code == TYPE_CODE_UNION);
1720 t = init_type (code, 0, 0, NULL, NULL);
1721 TYPE_TAG_NAME (t) = name;
1725 /* Helper function. Append a field to a composite type. */
1728 append_composite_type_field (struct type *t, char *name, struct type *field)
1731 TYPE_NFIELDS (t) = TYPE_NFIELDS (t) + 1;
1732 TYPE_FIELDS (t) = xrealloc (TYPE_FIELDS (t),
1733 sizeof (struct field) * TYPE_NFIELDS (t));
1734 f = &(TYPE_FIELDS (t)[TYPE_NFIELDS (t) - 1]);
1735 memset (f, 0, sizeof f[0]);
1736 FIELD_TYPE (f[0]) = field;
1737 FIELD_NAME (f[0]) = name;
1738 if (TYPE_CODE (t) == TYPE_CODE_UNION)
1740 if (TYPE_LENGTH (t) < TYPE_LENGTH (field))
1741 TYPE_LENGTH (t) = TYPE_LENGTH (field);
1743 else if (TYPE_CODE (t) == TYPE_CODE_STRUCT)
1745 TYPE_LENGTH (t) = TYPE_LENGTH (t) + TYPE_LENGTH (field);
1746 if (TYPE_NFIELDS (t) > 1)
1748 FIELD_BITPOS (f[0]) = (FIELD_BITPOS (f[-1])
1749 + TYPE_LENGTH (field) * TARGET_CHAR_BIT);
1754 /* Look up a fundamental type for the specified objfile.
1755 May need to construct such a type if this is the first use.
1757 Some object file formats (ELF, COFF, etc) do not define fundamental
1758 types such as "int" or "double". Others (stabs for example), do
1759 define fundamental types.
1761 For the formats which don't provide fundamental types, gdb can create
1762 such types, using defaults reasonable for the current language and
1763 the current target machine.
1765 NOTE: This routine is obsolescent. Each debugging format reader
1766 should manage it's own fundamental types, either creating them from
1767 suitable defaults or reading them from the debugging information,
1768 whichever is appropriate. The DWARF reader has already been
1769 fixed to do this. Once the other readers are fixed, this routine
1770 will go away. Also note that fundamental types should be managed
1771 on a compilation unit basis in a multi-language environment, not
1772 on a linkage unit basis as is done here. */
1776 lookup_fundamental_type (struct objfile *objfile, int typeid)
1778 struct type **typep;
1781 if (typeid < 0 || typeid >= FT_NUM_MEMBERS)
1783 error (_("internal error - invalid fundamental type id %d"), typeid);
1786 /* If this is the first time we need a fundamental type for this objfile
1787 then we need to initialize the vector of type pointers. */
1789 if (objfile->fundamental_types == NULL)
1791 nbytes = FT_NUM_MEMBERS * sizeof (struct type *);
1792 objfile->fundamental_types = (struct type **)
1793 obstack_alloc (&objfile->objfile_obstack, nbytes);
1794 memset ((char *) objfile->fundamental_types, 0, nbytes);
1795 OBJSTAT (objfile, n_types += FT_NUM_MEMBERS);
1798 /* Look for this particular type in the fundamental type vector. If one is
1799 not found, create and install one appropriate for the current language. */
1801 typep = objfile->fundamental_types + typeid;
1804 *typep = create_fundamental_type (objfile, typeid);
1811 can_dereference (struct type *t)
1813 /* FIXME: Should we return true for references as well as pointers? */
1817 && TYPE_CODE (t) == TYPE_CODE_PTR
1818 && TYPE_CODE (TYPE_TARGET_TYPE (t)) != TYPE_CODE_VOID);
1822 is_integral_type (struct type *t)
1827 && ((TYPE_CODE (t) == TYPE_CODE_INT)
1828 || (TYPE_CODE (t) == TYPE_CODE_ENUM)
1829 || (TYPE_CODE (t) == TYPE_CODE_FLAGS)
1830 || (TYPE_CODE (t) == TYPE_CODE_CHAR)
1831 || (TYPE_CODE (t) == TYPE_CODE_RANGE)
1832 || (TYPE_CODE (t) == TYPE_CODE_BOOL)));
1835 /* Check whether BASE is an ancestor or base class or DCLASS
1836 Return 1 if so, and 0 if not.
1837 Note: callers may want to check for identity of the types before
1838 calling this function -- identical types are considered to satisfy
1839 the ancestor relationship even if they're identical */
1842 is_ancestor (struct type *base, struct type *dclass)
1846 CHECK_TYPEDEF (base);
1847 CHECK_TYPEDEF (dclass);
1851 if (TYPE_NAME (base) && TYPE_NAME (dclass) &&
1852 !strcmp (TYPE_NAME (base), TYPE_NAME (dclass)))
1855 for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++)
1856 if (is_ancestor (base, TYPE_BASECLASS (dclass, i)))
1864 /* See whether DCLASS has a virtual table. This routine is aimed at
1865 the HP/Taligent ANSI C++ runtime model, and may not work with other
1866 runtime models. Return 1 => Yes, 0 => No. */
1869 has_vtable (struct type *dclass)
1871 /* In the HP ANSI C++ runtime model, a class has a vtable only if it
1872 has virtual functions or virtual bases. */
1876 if (TYPE_CODE (dclass) != TYPE_CODE_CLASS)
1879 /* First check for the presence of virtual bases */
1880 if (TYPE_FIELD_VIRTUAL_BITS (dclass))
1881 for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++)
1882 if (B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass), i))
1885 /* Next check for virtual functions */
1886 if (TYPE_FN_FIELDLISTS (dclass))
1887 for (i = 0; i < TYPE_NFN_FIELDS (dclass); i++)
1888 if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass, i), 0))
1891 /* Recurse on non-virtual bases to see if any of them needs a vtable */
1892 if (TYPE_FIELD_VIRTUAL_BITS (dclass))
1893 for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++)
1894 if ((!B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass), i)) &&
1895 (has_vtable (TYPE_FIELD_TYPE (dclass, i))))
1898 /* Well, maybe we don't need a virtual table */
1902 /* Return a pointer to the "primary base class" of DCLASS.
1904 A NULL return indicates that DCLASS has no primary base, or that it
1905 couldn't be found (insufficient information).
1907 This routine is aimed at the HP/Taligent ANSI C++ runtime model,
1908 and may not work with other runtime models. */
1911 primary_base_class (struct type *dclass)
1913 /* In HP ANSI C++'s runtime model, a "primary base class" of a class
1914 is the first directly inherited, non-virtual base class that
1915 requires a virtual table */
1919 if (TYPE_CODE (dclass) != TYPE_CODE_CLASS)
1922 for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++)
1923 if (!TYPE_FIELD_VIRTUAL (dclass, i) &&
1924 has_vtable (TYPE_FIELD_TYPE (dclass, i)))
1925 return TYPE_FIELD_TYPE (dclass, i);
1930 /* Global manipulated by virtual_base_list[_aux]() */
1932 static struct vbase *current_vbase_list = NULL;
1934 /* Return a pointer to a null-terminated list of struct vbase
1935 items. The vbasetype pointer of each item in the list points to the
1936 type information for a virtual base of the argument DCLASS.
1938 Helper function for virtual_base_list().
1939 Note: the list goes backward, right-to-left. virtual_base_list()
1940 copies the items out in reverse order. */
1943 virtual_base_list_aux (struct type *dclass)
1945 struct vbase *tmp_vbase;
1948 if (TYPE_CODE (dclass) != TYPE_CODE_CLASS)
1951 for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++)
1953 /* Recurse on this ancestor, first */
1954 virtual_base_list_aux (TYPE_FIELD_TYPE (dclass, i));
1956 /* If this current base is itself virtual, add it to the list */
1957 if (BASETYPE_VIA_VIRTUAL (dclass, i))
1959 struct type *basetype = TYPE_FIELD_TYPE (dclass, i);
1961 /* Check if base already recorded */
1962 tmp_vbase = current_vbase_list;
1965 if (tmp_vbase->vbasetype == basetype)
1966 break; /* found it */
1967 tmp_vbase = tmp_vbase->next;
1970 if (!tmp_vbase) /* normal exit from loop */
1972 /* Allocate new item for this virtual base */
1973 tmp_vbase = (struct vbase *) xmalloc (sizeof (struct vbase));
1975 /* Stick it on at the end of the list */
1976 tmp_vbase->vbasetype = basetype;
1977 tmp_vbase->next = current_vbase_list;
1978 current_vbase_list = tmp_vbase;
1981 } /* for loop over bases */
1985 /* Compute the list of virtual bases in the right order. Virtual
1986 bases are laid out in the object's memory area in order of their
1987 occurrence in a depth-first, left-to-right search through the
1990 Argument DCLASS is the type whose virtual bases are required.
1991 Return value is the address of a null-terminated array of pointers
1992 to struct type items.
1994 This routine is aimed at the HP/Taligent ANSI C++ runtime model,
1995 and may not work with other runtime models.
1997 This routine merely hands off the argument to virtual_base_list_aux()
1998 and then copies the result into an array to save space. */
2001 virtual_base_list (struct type *dclass)
2003 struct vbase *tmp_vbase;
2004 struct vbase *tmp_vbase_2;
2007 struct type **vbase_array;
2009 current_vbase_list = NULL;
2010 virtual_base_list_aux (dclass);
2012 for (i = 0, tmp_vbase = current_vbase_list; tmp_vbase != NULL; i++, tmp_vbase = tmp_vbase->next)
2017 vbase_array = (struct type **) xmalloc ((count + 1) * sizeof (struct type *));
2019 for (i = count - 1, tmp_vbase = current_vbase_list; i >= 0; i--, tmp_vbase = tmp_vbase->next)
2020 vbase_array[i] = tmp_vbase->vbasetype;
2022 /* Get rid of constructed chain */
2023 tmp_vbase_2 = tmp_vbase = current_vbase_list;
2026 tmp_vbase = tmp_vbase->next;
2027 xfree (tmp_vbase_2);
2028 tmp_vbase_2 = tmp_vbase;
2031 vbase_array[count] = NULL;
2035 /* Return the length of the virtual base list of the type DCLASS. */
2038 virtual_base_list_length (struct type *dclass)
2041 struct vbase *tmp_vbase;
2043 current_vbase_list = NULL;
2044 virtual_base_list_aux (dclass);
2046 for (i = 0, tmp_vbase = current_vbase_list; tmp_vbase != NULL; i++, tmp_vbase = tmp_vbase->next)
2051 /* Return the number of elements of the virtual base list of the type
2052 DCLASS, ignoring those appearing in the primary base (and its
2053 primary base, recursively). */
2056 virtual_base_list_length_skip_primaries (struct type *dclass)
2059 struct vbase *tmp_vbase;
2060 struct type *primary;
2062 primary = TYPE_RUNTIME_PTR (dclass) ? TYPE_PRIMARY_BASE (dclass) : NULL;
2065 return virtual_base_list_length (dclass);
2067 current_vbase_list = NULL;
2068 virtual_base_list_aux (dclass);
2070 for (i = 0, tmp_vbase = current_vbase_list; tmp_vbase != NULL; tmp_vbase = tmp_vbase->next)
2072 if (virtual_base_index (tmp_vbase->vbasetype, primary) >= 0)
2080 /* Return the index (position) of type BASE, which is a virtual base
2081 class of DCLASS, in the latter's virtual base list. A return of -1
2082 indicates "not found" or a problem. */
2085 virtual_base_index (struct type *base, struct type *dclass)
2090 if ((TYPE_CODE (dclass) != TYPE_CODE_CLASS) ||
2091 (TYPE_CODE (base) != TYPE_CODE_CLASS))
2095 vbase = virtual_base_list (dclass)[0];
2100 vbase = virtual_base_list (dclass)[++i];
2103 return vbase ? i : -1;
2108 /* Return the index (position) of type BASE, which is a virtual base
2109 class of DCLASS, in the latter's virtual base list. Skip over all
2110 bases that may appear in the virtual base list of the primary base
2111 class of DCLASS (recursively). A return of -1 indicates "not
2112 found" or a problem. */
2115 virtual_base_index_skip_primaries (struct type *base, struct type *dclass)
2119 struct type *primary;
2121 if ((TYPE_CODE (dclass) != TYPE_CODE_CLASS) ||
2122 (TYPE_CODE (base) != TYPE_CODE_CLASS))
2125 primary = TYPE_RUNTIME_PTR (dclass) ? TYPE_PRIMARY_BASE (dclass) : NULL;
2129 vbase = virtual_base_list (dclass)[0];
2132 if (!primary || (virtual_base_index_skip_primaries (vbase, primary) < 0))
2136 vbase = virtual_base_list (dclass)[++i];
2139 return vbase ? j : -1;
2142 /* Return position of a derived class DCLASS in the list of
2143 * primary bases starting with the remotest ancestor.
2144 * Position returned is 0-based. */
2147 class_index_in_primary_list (struct type *dclass)
2149 struct type *pbc; /* primary base class */
2151 /* Simply recurse on primary base */
2152 pbc = TYPE_PRIMARY_BASE (dclass);
2154 return 1 + class_index_in_primary_list (pbc);
2159 /* Return a count of the number of virtual functions a type has.
2160 * This includes all the virtual functions it inherits from its
2164 /* pai: FIXME This doesn't do the right thing: count redefined virtual
2165 * functions only once (latest redefinition)
2169 count_virtual_fns (struct type *dclass)
2171 int fn, oi; /* function and overloaded instance indices */
2172 int vfuncs; /* count to return */
2174 /* recurse on bases that can share virtual table */
2175 struct type *pbc = primary_base_class (dclass);
2177 vfuncs = count_virtual_fns (pbc);
2181 for (fn = 0; fn < TYPE_NFN_FIELDS (dclass); fn++)
2182 for (oi = 0; oi < TYPE_FN_FIELDLIST_LENGTH (dclass, fn); oi++)
2183 if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass, fn), oi))
2191 /* Functions for overload resolution begin here */
2193 /* Compare two badness vectors A and B and return the result.
2194 * 0 => A and B are identical
2195 * 1 => A and B are incomparable
2196 * 2 => A is better than B
2197 * 3 => A is worse than B */
2200 compare_badness (struct badness_vector *a, struct badness_vector *b)
2204 short found_pos = 0; /* any positives in c? */
2205 short found_neg = 0; /* any negatives in c? */
2207 /* differing lengths => incomparable */
2208 if (a->length != b->length)
2211 /* Subtract b from a */
2212 for (i = 0; i < a->length; i++)
2214 tmp = a->rank[i] - b->rank[i];
2224 return 1; /* incomparable */
2226 return 3; /* A > B */
2232 return 2; /* A < B */
2234 return 0; /* A == B */
2238 /* Rank a function by comparing its parameter types (PARMS, length NPARMS),
2239 * to the types of an argument list (ARGS, length NARGS).
2240 * Return a pointer to a badness vector. This has NARGS + 1 entries. */
2242 struct badness_vector *
2243 rank_function (struct type **parms, int nparms, struct type **args, int nargs)
2246 struct badness_vector *bv;
2247 int min_len = nparms < nargs ? nparms : nargs;
2249 bv = xmalloc (sizeof (struct badness_vector));
2250 bv->length = nargs + 1; /* add 1 for the length-match rank */
2251 bv->rank = xmalloc ((nargs + 1) * sizeof (int));
2253 /* First compare the lengths of the supplied lists.
2254 * If there is a mismatch, set it to a high value. */
2256 /* pai/1997-06-03 FIXME: when we have debug info about default
2257 * arguments and ellipsis parameter lists, we should consider those
2258 * and rank the length-match more finely. */
2260 LENGTH_MATCH (bv) = (nargs != nparms) ? LENGTH_MISMATCH_BADNESS : 0;
2262 /* Now rank all the parameters of the candidate function */
2263 for (i = 1; i <= min_len; i++)
2264 bv->rank[i] = rank_one_type (parms[i-1], args[i-1]);
2266 /* If more arguments than parameters, add dummy entries */
2267 for (i = min_len + 1; i <= nargs; i++)
2268 bv->rank[i] = TOO_FEW_PARAMS_BADNESS;
2273 /* Compare the names of two integer types, assuming that any sign
2274 qualifiers have been checked already. We do it this way because
2275 there may be an "int" in the name of one of the types. */
2278 integer_types_same_name_p (const char *first, const char *second)
2280 int first_p, second_p;
2282 /* If both are shorts, return 1; if neither is a short, keep checking. */
2283 first_p = (strstr (first, "short") != NULL);
2284 second_p = (strstr (second, "short") != NULL);
2285 if (first_p && second_p)
2287 if (first_p || second_p)
2290 /* Likewise for long. */
2291 first_p = (strstr (first, "long") != NULL);
2292 second_p = (strstr (second, "long") != NULL);
2293 if (first_p && second_p)
2295 if (first_p || second_p)
2298 /* Likewise for char. */
2299 first_p = (strstr (first, "char") != NULL);
2300 second_p = (strstr (second, "char") != NULL);
2301 if (first_p && second_p)
2303 if (first_p || second_p)
2306 /* They must both be ints. */
2310 /* Compare one type (PARM) for compatibility with another (ARG).
2311 * PARM is intended to be the parameter type of a function; and
2312 * ARG is the supplied argument's type. This function tests if
2313 * the latter can be converted to the former.
2315 * Return 0 if they are identical types;
2316 * Otherwise, return an integer which corresponds to how compatible
2317 * PARM is to ARG. The higher the return value, the worse the match.
2318 * Generally the "bad" conversions are all uniformly assigned a 100 */
2321 rank_one_type (struct type *parm, struct type *arg)
2323 /* Identical type pointers */
2324 /* However, this still doesn't catch all cases of same type for arg
2325 * and param. The reason is that builtin types are different from
2326 * the same ones constructed from the object. */
2330 /* Resolve typedefs */
2331 if (TYPE_CODE (parm) == TYPE_CODE_TYPEDEF)
2332 parm = check_typedef (parm);
2333 if (TYPE_CODE (arg) == TYPE_CODE_TYPEDEF)
2334 arg = check_typedef (arg);
2337 Well, damnit, if the names are exactly the same,
2338 i'll say they are exactly the same. This happens when we generate
2339 method stubs. The types won't point to the same address, but they
2340 really are the same.
2343 if (TYPE_NAME (parm) && TYPE_NAME (arg) &&
2344 !strcmp (TYPE_NAME (parm), TYPE_NAME (arg)))
2347 /* Check if identical after resolving typedefs */
2351 /* See through references, since we can almost make non-references
2353 if (TYPE_CODE (arg) == TYPE_CODE_REF)
2354 return (rank_one_type (parm, TYPE_TARGET_TYPE (arg))
2355 + REFERENCE_CONVERSION_BADNESS);
2356 if (TYPE_CODE (parm) == TYPE_CODE_REF)
2357 return (rank_one_type (TYPE_TARGET_TYPE (parm), arg)
2358 + REFERENCE_CONVERSION_BADNESS);
2360 /* Debugging only. */
2361 fprintf_filtered (gdb_stderr,"------ Arg is %s [%d], parm is %s [%d]\n",
2362 TYPE_NAME (arg), TYPE_CODE (arg), TYPE_NAME (parm), TYPE_CODE (parm));
2364 /* x -> y means arg of type x being supplied for parameter of type y */
2366 switch (TYPE_CODE (parm))
2369 switch (TYPE_CODE (arg))
2372 if (TYPE_CODE (TYPE_TARGET_TYPE (parm)) == TYPE_CODE_VOID)
2373 return VOID_PTR_CONVERSION_BADNESS;
2375 return rank_one_type (TYPE_TARGET_TYPE (parm), TYPE_TARGET_TYPE (arg));
2376 case TYPE_CODE_ARRAY:
2377 return rank_one_type (TYPE_TARGET_TYPE (parm), TYPE_TARGET_TYPE (arg));
2378 case TYPE_CODE_FUNC:
2379 return rank_one_type (TYPE_TARGET_TYPE (parm), arg);
2381 case TYPE_CODE_ENUM:
2382 case TYPE_CODE_FLAGS:
2383 case TYPE_CODE_CHAR:
2384 case TYPE_CODE_RANGE:
2385 case TYPE_CODE_BOOL:
2386 return POINTER_CONVERSION_BADNESS;
2388 return INCOMPATIBLE_TYPE_BADNESS;
2390 case TYPE_CODE_ARRAY:
2391 switch (TYPE_CODE (arg))
2394 case TYPE_CODE_ARRAY:
2395 return rank_one_type (TYPE_TARGET_TYPE (parm), TYPE_TARGET_TYPE (arg));
2397 return INCOMPATIBLE_TYPE_BADNESS;
2399 case TYPE_CODE_FUNC:
2400 switch (TYPE_CODE (arg))
2402 case TYPE_CODE_PTR: /* funcptr -> func */
2403 return rank_one_type (parm, TYPE_TARGET_TYPE (arg));
2405 return INCOMPATIBLE_TYPE_BADNESS;
2408 switch (TYPE_CODE (arg))
2411 if (TYPE_LENGTH (arg) == TYPE_LENGTH (parm))
2413 /* Deal with signed, unsigned, and plain chars and
2414 signed and unsigned ints */
2415 if (TYPE_NOSIGN (parm))
2417 /* This case only for character types */
2418 if (TYPE_NOSIGN (arg)) /* plain char -> plain char */
2421 return INTEGER_CONVERSION_BADNESS; /* signed/unsigned char -> plain char */
2423 else if (TYPE_UNSIGNED (parm))
2425 if (TYPE_UNSIGNED (arg))
2427 /* unsigned int -> unsigned int, or unsigned long -> unsigned long */
2428 if (integer_types_same_name_p (TYPE_NAME (parm), TYPE_NAME (arg)))
2430 else if (integer_types_same_name_p (TYPE_NAME (arg), "int")
2431 && integer_types_same_name_p (TYPE_NAME (parm), "long"))
2432 return INTEGER_PROMOTION_BADNESS; /* unsigned int -> unsigned long */
2434 return INTEGER_CONVERSION_BADNESS; /* unsigned long -> unsigned int */
2438 if (integer_types_same_name_p (TYPE_NAME (arg), "long")
2439 && integer_types_same_name_p (TYPE_NAME (parm), "int"))
2440 return INTEGER_CONVERSION_BADNESS; /* signed long -> unsigned int */
2442 return INTEGER_CONVERSION_BADNESS; /* signed int/long -> unsigned int/long */
2445 else if (!TYPE_NOSIGN (arg) && !TYPE_UNSIGNED (arg))
2447 if (integer_types_same_name_p (TYPE_NAME (parm), TYPE_NAME (arg)))
2449 else if (integer_types_same_name_p (TYPE_NAME (arg), "int")
2450 && integer_types_same_name_p (TYPE_NAME (parm), "long"))
2451 return INTEGER_PROMOTION_BADNESS;
2453 return INTEGER_CONVERSION_BADNESS;
2456 return INTEGER_CONVERSION_BADNESS;
2458 else if (TYPE_LENGTH (arg) < TYPE_LENGTH (parm))
2459 return INTEGER_PROMOTION_BADNESS;
2461 return INTEGER_CONVERSION_BADNESS;
2462 case TYPE_CODE_ENUM:
2463 case TYPE_CODE_FLAGS:
2464 case TYPE_CODE_CHAR:
2465 case TYPE_CODE_RANGE:
2466 case TYPE_CODE_BOOL:
2467 return INTEGER_PROMOTION_BADNESS;
2469 return INT_FLOAT_CONVERSION_BADNESS;
2471 return NS_POINTER_CONVERSION_BADNESS;
2473 return INCOMPATIBLE_TYPE_BADNESS;
2476 case TYPE_CODE_ENUM:
2477 switch (TYPE_CODE (arg))
2480 case TYPE_CODE_CHAR:
2481 case TYPE_CODE_RANGE:
2482 case TYPE_CODE_BOOL:
2483 case TYPE_CODE_ENUM:
2484 return INTEGER_CONVERSION_BADNESS;
2486 return INT_FLOAT_CONVERSION_BADNESS;
2488 return INCOMPATIBLE_TYPE_BADNESS;
2491 case TYPE_CODE_CHAR:
2492 switch (TYPE_CODE (arg))
2494 case TYPE_CODE_RANGE:
2495 case TYPE_CODE_BOOL:
2496 case TYPE_CODE_ENUM:
2497 return INTEGER_CONVERSION_BADNESS;
2499 return INT_FLOAT_CONVERSION_BADNESS;
2501 if (TYPE_LENGTH (arg) > TYPE_LENGTH (parm))
2502 return INTEGER_CONVERSION_BADNESS;
2503 else if (TYPE_LENGTH (arg) < TYPE_LENGTH (parm))
2504 return INTEGER_PROMOTION_BADNESS;
2505 /* >>> !! else fall through !! <<< */
2506 case TYPE_CODE_CHAR:
2507 /* Deal with signed, unsigned, and plain chars for C++
2508 and with int cases falling through from previous case */
2509 if (TYPE_NOSIGN (parm))
2511 if (TYPE_NOSIGN (arg))
2514 return INTEGER_CONVERSION_BADNESS;
2516 else if (TYPE_UNSIGNED (parm))
2518 if (TYPE_UNSIGNED (arg))
2521 return INTEGER_PROMOTION_BADNESS;
2523 else if (!TYPE_NOSIGN (arg) && !TYPE_UNSIGNED (arg))
2526 return INTEGER_CONVERSION_BADNESS;
2528 return INCOMPATIBLE_TYPE_BADNESS;
2531 case TYPE_CODE_RANGE:
2532 switch (TYPE_CODE (arg))
2535 case TYPE_CODE_CHAR:
2536 case TYPE_CODE_RANGE:
2537 case TYPE_CODE_BOOL:
2538 case TYPE_CODE_ENUM:
2539 return INTEGER_CONVERSION_BADNESS;
2541 return INT_FLOAT_CONVERSION_BADNESS;
2543 return INCOMPATIBLE_TYPE_BADNESS;
2546 case TYPE_CODE_BOOL:
2547 switch (TYPE_CODE (arg))
2550 case TYPE_CODE_CHAR:
2551 case TYPE_CODE_RANGE:
2552 case TYPE_CODE_ENUM:
2555 return BOOLEAN_CONVERSION_BADNESS;
2556 case TYPE_CODE_BOOL:
2559 return INCOMPATIBLE_TYPE_BADNESS;
2563 switch (TYPE_CODE (arg))
2566 if (TYPE_LENGTH (arg) < TYPE_LENGTH (parm))
2567 return FLOAT_PROMOTION_BADNESS;
2568 else if (TYPE_LENGTH (arg) == TYPE_LENGTH (parm))
2571 return FLOAT_CONVERSION_BADNESS;
2573 case TYPE_CODE_BOOL:
2574 case TYPE_CODE_ENUM:
2575 case TYPE_CODE_RANGE:
2576 case TYPE_CODE_CHAR:
2577 return INT_FLOAT_CONVERSION_BADNESS;
2579 return INCOMPATIBLE_TYPE_BADNESS;
2582 case TYPE_CODE_COMPLEX:
2583 switch (TYPE_CODE (arg))
2584 { /* Strictly not needed for C++, but... */
2586 return FLOAT_PROMOTION_BADNESS;
2587 case TYPE_CODE_COMPLEX:
2590 return INCOMPATIBLE_TYPE_BADNESS;
2593 case TYPE_CODE_STRUCT:
2594 /* currently same as TYPE_CODE_CLASS */
2595 switch (TYPE_CODE (arg))
2597 case TYPE_CODE_STRUCT:
2598 /* Check for derivation */
2599 if (is_ancestor (parm, arg))
2600 return BASE_CONVERSION_BADNESS;
2601 /* else fall through */
2603 return INCOMPATIBLE_TYPE_BADNESS;
2606 case TYPE_CODE_UNION:
2607 switch (TYPE_CODE (arg))
2609 case TYPE_CODE_UNION:
2611 return INCOMPATIBLE_TYPE_BADNESS;
2614 case TYPE_CODE_MEMBERPTR:
2615 switch (TYPE_CODE (arg))
2618 return INCOMPATIBLE_TYPE_BADNESS;
2621 case TYPE_CODE_METHOD:
2622 switch (TYPE_CODE (arg))
2626 return INCOMPATIBLE_TYPE_BADNESS;
2630 switch (TYPE_CODE (arg))
2634 return INCOMPATIBLE_TYPE_BADNESS;
2639 switch (TYPE_CODE (arg))
2643 return rank_one_type (TYPE_FIELD_TYPE (parm, 0), TYPE_FIELD_TYPE (arg, 0));
2645 return INCOMPATIBLE_TYPE_BADNESS;
2648 case TYPE_CODE_VOID:
2650 return INCOMPATIBLE_TYPE_BADNESS;
2651 } /* switch (TYPE_CODE (arg)) */
2655 /* End of functions for overload resolution */
2658 print_bit_vector (B_TYPE *bits, int nbits)
2662 for (bitno = 0; bitno < nbits; bitno++)
2664 if ((bitno % 8) == 0)
2666 puts_filtered (" ");
2668 if (B_TST (bits, bitno))
2669 printf_filtered (("1"));
2671 printf_filtered (("0"));
2675 /* Note the first arg should be the "this" pointer, we may not want to
2676 include it since we may get into a infinitely recursive situation. */
2679 print_arg_types (struct field *args, int nargs, int spaces)
2685 for (i = 0; i < nargs; i++)
2686 recursive_dump_type (args[i].type, spaces + 2);
2691 dump_fn_fieldlists (struct type *type, int spaces)
2697 printfi_filtered (spaces, "fn_fieldlists ");
2698 gdb_print_host_address (TYPE_FN_FIELDLISTS (type), gdb_stdout);
2699 printf_filtered ("\n");
2700 for (method_idx = 0; method_idx < TYPE_NFN_FIELDS (type); method_idx++)
2702 f = TYPE_FN_FIELDLIST1 (type, method_idx);
2703 printfi_filtered (spaces + 2, "[%d] name '%s' (",
2705 TYPE_FN_FIELDLIST_NAME (type, method_idx));
2706 gdb_print_host_address (TYPE_FN_FIELDLIST_NAME (type, method_idx),
2708 printf_filtered (_(") length %d\n"),
2709 TYPE_FN_FIELDLIST_LENGTH (type, method_idx));
2710 for (overload_idx = 0;
2711 overload_idx < TYPE_FN_FIELDLIST_LENGTH (type, method_idx);
2714 printfi_filtered (spaces + 4, "[%d] physname '%s' (",
2716 TYPE_FN_FIELD_PHYSNAME (f, overload_idx));
2717 gdb_print_host_address (TYPE_FN_FIELD_PHYSNAME (f, overload_idx),
2719 printf_filtered (")\n");
2720 printfi_filtered (spaces + 8, "type ");
2721 gdb_print_host_address (TYPE_FN_FIELD_TYPE (f, overload_idx), gdb_stdout);
2722 printf_filtered ("\n");
2724 recursive_dump_type (TYPE_FN_FIELD_TYPE (f, overload_idx),
2727 printfi_filtered (spaces + 8, "args ");
2728 gdb_print_host_address (TYPE_FN_FIELD_ARGS (f, overload_idx), gdb_stdout);
2729 printf_filtered ("\n");
2731 print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx),
2732 TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (f, overload_idx)),
2734 printfi_filtered (spaces + 8, "fcontext ");
2735 gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx),
2737 printf_filtered ("\n");
2739 printfi_filtered (spaces + 8, "is_const %d\n",
2740 TYPE_FN_FIELD_CONST (f, overload_idx));
2741 printfi_filtered (spaces + 8, "is_volatile %d\n",
2742 TYPE_FN_FIELD_VOLATILE (f, overload_idx));
2743 printfi_filtered (spaces + 8, "is_private %d\n",
2744 TYPE_FN_FIELD_PRIVATE (f, overload_idx));
2745 printfi_filtered (spaces + 8, "is_protected %d\n",
2746 TYPE_FN_FIELD_PROTECTED (f, overload_idx));
2747 printfi_filtered (spaces + 8, "is_stub %d\n",
2748 TYPE_FN_FIELD_STUB (f, overload_idx));
2749 printfi_filtered (spaces + 8, "voffset %u\n",
2750 TYPE_FN_FIELD_VOFFSET (f, overload_idx));
2756 print_cplus_stuff (struct type *type, int spaces)
2758 printfi_filtered (spaces, "n_baseclasses %d\n",
2759 TYPE_N_BASECLASSES (type));
2760 printfi_filtered (spaces, "nfn_fields %d\n",
2761 TYPE_NFN_FIELDS (type));
2762 printfi_filtered (spaces, "nfn_fields_total %d\n",
2763 TYPE_NFN_FIELDS_TOTAL (type));
2764 if (TYPE_N_BASECLASSES (type) > 0)
2766 printfi_filtered (spaces, "virtual_field_bits (%d bits at *",
2767 TYPE_N_BASECLASSES (type));
2768 gdb_print_host_address (TYPE_FIELD_VIRTUAL_BITS (type), gdb_stdout);
2769 printf_filtered (")");
2771 print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type),
2772 TYPE_N_BASECLASSES (type));
2773 puts_filtered ("\n");
2775 if (TYPE_NFIELDS (type) > 0)
2777 if (TYPE_FIELD_PRIVATE_BITS (type) != NULL)
2779 printfi_filtered (spaces, "private_field_bits (%d bits at *",
2780 TYPE_NFIELDS (type));
2781 gdb_print_host_address (TYPE_FIELD_PRIVATE_BITS (type), gdb_stdout);
2782 printf_filtered (")");
2783 print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type),
2784 TYPE_NFIELDS (type));
2785 puts_filtered ("\n");
2787 if (TYPE_FIELD_PROTECTED_BITS (type) != NULL)
2789 printfi_filtered (spaces, "protected_field_bits (%d bits at *",
2790 TYPE_NFIELDS (type));
2791 gdb_print_host_address (TYPE_FIELD_PROTECTED_BITS (type), gdb_stdout);
2792 printf_filtered (")");
2793 print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type),
2794 TYPE_NFIELDS (type));
2795 puts_filtered ("\n");
2798 if (TYPE_NFN_FIELDS (type) > 0)
2800 dump_fn_fieldlists (type, spaces);
2805 print_bound_type (int bt)
2809 case BOUND_CANNOT_BE_DETERMINED:
2810 printf_filtered ("(BOUND_CANNOT_BE_DETERMINED)");
2812 case BOUND_BY_REF_ON_STACK:
2813 printf_filtered ("(BOUND_BY_REF_ON_STACK)");
2815 case BOUND_BY_VALUE_ON_STACK:
2816 printf_filtered ("(BOUND_BY_VALUE_ON_STACK)");
2818 case BOUND_BY_REF_IN_REG:
2819 printf_filtered ("(BOUND_BY_REF_IN_REG)");
2821 case BOUND_BY_VALUE_IN_REG:
2822 printf_filtered ("(BOUND_BY_VALUE_IN_REG)");
2825 printf_filtered ("(BOUND_SIMPLE)");
2828 printf_filtered (_("(unknown bound type)"));
2833 static struct obstack dont_print_type_obstack;
2836 recursive_dump_type (struct type *type, int spaces)
2841 obstack_begin (&dont_print_type_obstack, 0);
2843 if (TYPE_NFIELDS (type) > 0
2844 || (TYPE_CPLUS_SPECIFIC (type) && TYPE_NFN_FIELDS (type) > 0))
2846 struct type **first_dont_print
2847 = (struct type **) obstack_base (&dont_print_type_obstack);
2849 int i = (struct type **) obstack_next_free (&dont_print_type_obstack)
2854 if (type == first_dont_print[i])
2856 printfi_filtered (spaces, "type node ");
2857 gdb_print_host_address (type, gdb_stdout);
2858 printf_filtered (_(" <same as already seen type>\n"));
2863 obstack_ptr_grow (&dont_print_type_obstack, type);
2866 printfi_filtered (spaces, "type node ");
2867 gdb_print_host_address (type, gdb_stdout);
2868 printf_filtered ("\n");
2869 printfi_filtered (spaces, "name '%s' (",
2870 TYPE_NAME (type) ? TYPE_NAME (type) : "<NULL>");
2871 gdb_print_host_address (TYPE_NAME (type), gdb_stdout);
2872 printf_filtered (")\n");
2873 printfi_filtered (spaces, "tagname '%s' (",
2874 TYPE_TAG_NAME (type) ? TYPE_TAG_NAME (type) : "<NULL>");
2875 gdb_print_host_address (TYPE_TAG_NAME (type), gdb_stdout);
2876 printf_filtered (")\n");
2877 printfi_filtered (spaces, "code 0x%x ", TYPE_CODE (type));
2878 switch (TYPE_CODE (type))
2880 case TYPE_CODE_UNDEF:
2881 printf_filtered ("(TYPE_CODE_UNDEF)");
2884 printf_filtered ("(TYPE_CODE_PTR)");
2886 case TYPE_CODE_ARRAY:
2887 printf_filtered ("(TYPE_CODE_ARRAY)");
2889 case TYPE_CODE_STRUCT:
2890 printf_filtered ("(TYPE_CODE_STRUCT)");
2892 case TYPE_CODE_UNION:
2893 printf_filtered ("(TYPE_CODE_UNION)");
2895 case TYPE_CODE_ENUM:
2896 printf_filtered ("(TYPE_CODE_ENUM)");
2898 case TYPE_CODE_FLAGS:
2899 printf_filtered ("(TYPE_CODE_FLAGS)");
2901 case TYPE_CODE_FUNC:
2902 printf_filtered ("(TYPE_CODE_FUNC)");
2905 printf_filtered ("(TYPE_CODE_INT)");
2908 printf_filtered ("(TYPE_CODE_FLT)");
2910 case TYPE_CODE_VOID:
2911 printf_filtered ("(TYPE_CODE_VOID)");
2914 printf_filtered ("(TYPE_CODE_SET)");
2916 case TYPE_CODE_RANGE:
2917 printf_filtered ("(TYPE_CODE_RANGE)");
2919 case TYPE_CODE_STRING:
2920 printf_filtered ("(TYPE_CODE_STRING)");
2922 case TYPE_CODE_BITSTRING:
2923 printf_filtered ("(TYPE_CODE_BITSTRING)");
2925 case TYPE_CODE_ERROR:
2926 printf_filtered ("(TYPE_CODE_ERROR)");
2928 case TYPE_CODE_MEMBERPTR:
2929 printf_filtered ("(TYPE_CODE_MEMBERPTR)");
2931 case TYPE_CODE_METHODPTR:
2932 printf_filtered ("(TYPE_CODE_METHODPTR)");
2934 case TYPE_CODE_METHOD:
2935 printf_filtered ("(TYPE_CODE_METHOD)");
2938 printf_filtered ("(TYPE_CODE_REF)");
2940 case TYPE_CODE_CHAR:
2941 printf_filtered ("(TYPE_CODE_CHAR)");
2943 case TYPE_CODE_BOOL:
2944 printf_filtered ("(TYPE_CODE_BOOL)");
2946 case TYPE_CODE_COMPLEX:
2947 printf_filtered ("(TYPE_CODE_COMPLEX)");
2949 case TYPE_CODE_TYPEDEF:
2950 printf_filtered ("(TYPE_CODE_TYPEDEF)");
2952 case TYPE_CODE_TEMPLATE:
2953 printf_filtered ("(TYPE_CODE_TEMPLATE)");
2955 case TYPE_CODE_TEMPLATE_ARG:
2956 printf_filtered ("(TYPE_CODE_TEMPLATE_ARG)");
2958 case TYPE_CODE_NAMESPACE:
2959 printf_filtered ("(TYPE_CODE_NAMESPACE)");
2962 printf_filtered ("(UNKNOWN TYPE CODE)");
2965 puts_filtered ("\n");
2966 printfi_filtered (spaces, "length %d\n", TYPE_LENGTH (type));
2967 printfi_filtered (spaces, "upper_bound_type 0x%x ",
2968 TYPE_ARRAY_UPPER_BOUND_TYPE (type));
2969 print_bound_type (TYPE_ARRAY_UPPER_BOUND_TYPE (type));
2970 puts_filtered ("\n");
2971 printfi_filtered (spaces, "lower_bound_type 0x%x ",
2972 TYPE_ARRAY_LOWER_BOUND_TYPE (type));
2973 print_bound_type (TYPE_ARRAY_LOWER_BOUND_TYPE (type));
2974 puts_filtered ("\n");
2975 printfi_filtered (spaces, "objfile ");
2976 gdb_print_host_address (TYPE_OBJFILE (type), gdb_stdout);
2977 printf_filtered ("\n");
2978 printfi_filtered (spaces, "target_type ");
2979 gdb_print_host_address (TYPE_TARGET_TYPE (type), gdb_stdout);
2980 printf_filtered ("\n");
2981 if (TYPE_TARGET_TYPE (type) != NULL)
2983 recursive_dump_type (TYPE_TARGET_TYPE (type), spaces + 2);
2985 printfi_filtered (spaces, "pointer_type ");
2986 gdb_print_host_address (TYPE_POINTER_TYPE (type), gdb_stdout);
2987 printf_filtered ("\n");
2988 printfi_filtered (spaces, "reference_type ");
2989 gdb_print_host_address (TYPE_REFERENCE_TYPE (type), gdb_stdout);
2990 printf_filtered ("\n");
2991 printfi_filtered (spaces, "type_chain ");
2992 gdb_print_host_address (TYPE_CHAIN (type), gdb_stdout);
2993 printf_filtered ("\n");
2994 printfi_filtered (spaces, "instance_flags 0x%x", TYPE_INSTANCE_FLAGS (type));
2995 if (TYPE_CONST (type))
2997 puts_filtered (" TYPE_FLAG_CONST");
2999 if (TYPE_VOLATILE (type))
3001 puts_filtered (" TYPE_FLAG_VOLATILE");
3003 if (TYPE_CODE_SPACE (type))
3005 puts_filtered (" TYPE_FLAG_CODE_SPACE");
3007 if (TYPE_DATA_SPACE (type))
3009 puts_filtered (" TYPE_FLAG_DATA_SPACE");
3011 if (TYPE_ADDRESS_CLASS_1 (type))
3013 puts_filtered (" TYPE_FLAG_ADDRESS_CLASS_1");
3015 if (TYPE_ADDRESS_CLASS_2 (type))
3017 puts_filtered (" TYPE_FLAG_ADDRESS_CLASS_2");
3019 puts_filtered ("\n");
3020 printfi_filtered (spaces, "flags 0x%x", TYPE_FLAGS (type));
3021 if (TYPE_UNSIGNED (type))
3023 puts_filtered (" TYPE_FLAG_UNSIGNED");
3025 if (TYPE_NOSIGN (type))
3027 puts_filtered (" TYPE_FLAG_NOSIGN");
3029 if (TYPE_STUB (type))
3031 puts_filtered (" TYPE_FLAG_STUB");
3033 if (TYPE_TARGET_STUB (type))
3035 puts_filtered (" TYPE_FLAG_TARGET_STUB");
3037 if (TYPE_STATIC (type))
3039 puts_filtered (" TYPE_FLAG_STATIC");
3041 if (TYPE_PROTOTYPED (type))
3043 puts_filtered (" TYPE_FLAG_PROTOTYPED");
3045 if (TYPE_INCOMPLETE (type))
3047 puts_filtered (" TYPE_FLAG_INCOMPLETE");
3049 if (TYPE_VARARGS (type))
3051 puts_filtered (" TYPE_FLAG_VARARGS");
3053 /* This is used for things like AltiVec registers on ppc. Gcc emits
3054 an attribute for the array type, which tells whether or not we
3055 have a vector, instead of a regular array. */
3056 if (TYPE_VECTOR (type))
3058 puts_filtered (" TYPE_FLAG_VECTOR");
3060 puts_filtered ("\n");
3061 printfi_filtered (spaces, "nfields %d ", TYPE_NFIELDS (type));
3062 gdb_print_host_address (TYPE_FIELDS (type), gdb_stdout);
3063 puts_filtered ("\n");
3064 for (idx = 0; idx < TYPE_NFIELDS (type); idx++)
3066 printfi_filtered (spaces + 2,
3067 "[%d] bitpos %d bitsize %d type ",
3068 idx, TYPE_FIELD_BITPOS (type, idx),
3069 TYPE_FIELD_BITSIZE (type, idx));
3070 gdb_print_host_address (TYPE_FIELD_TYPE (type, idx), gdb_stdout);
3071 printf_filtered (" name '%s' (",
3072 TYPE_FIELD_NAME (type, idx) != NULL
3073 ? TYPE_FIELD_NAME (type, idx)
3075 gdb_print_host_address (TYPE_FIELD_NAME (type, idx), gdb_stdout);
3076 printf_filtered (")\n");
3077 if (TYPE_FIELD_TYPE (type, idx) != NULL)
3079 recursive_dump_type (TYPE_FIELD_TYPE (type, idx), spaces + 4);
3082 printfi_filtered (spaces, "vptr_basetype ");
3083 gdb_print_host_address (TYPE_VPTR_BASETYPE (type), gdb_stdout);
3084 puts_filtered ("\n");
3085 if (TYPE_VPTR_BASETYPE (type) != NULL)
3087 recursive_dump_type (TYPE_VPTR_BASETYPE (type), spaces + 2);
3089 printfi_filtered (spaces, "vptr_fieldno %d\n", TYPE_VPTR_FIELDNO (type));
3090 switch (TYPE_CODE (type))
3092 case TYPE_CODE_STRUCT:
3093 printfi_filtered (spaces, "cplus_stuff ");
3094 gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout);
3095 puts_filtered ("\n");
3096 print_cplus_stuff (type, spaces);
3100 printfi_filtered (spaces, "floatformat ");
3101 if (TYPE_FLOATFORMAT (type) == NULL)
3102 puts_filtered ("(null)");
3105 puts_filtered ("{ ");
3106 if (TYPE_FLOATFORMAT (type)[0] == NULL
3107 || TYPE_FLOATFORMAT (type)[0]->name == NULL)
3108 puts_filtered ("(null)");
3110 puts_filtered (TYPE_FLOATFORMAT (type)[0]->name);
3112 puts_filtered (", ");
3113 if (TYPE_FLOATFORMAT (type)[1] == NULL
3114 || TYPE_FLOATFORMAT (type)[1]->name == NULL)
3115 puts_filtered ("(null)");
3117 puts_filtered (TYPE_FLOATFORMAT (type)[1]->name);
3119 puts_filtered (" }");
3121 puts_filtered ("\n");
3125 /* We have to pick one of the union types to be able print and test
3126 the value. Pick cplus_struct_type, even though we know it isn't
3127 any particular one. */
3128 printfi_filtered (spaces, "type_specific ");
3129 gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout);
3130 if (TYPE_CPLUS_SPECIFIC (type) != NULL)
3132 printf_filtered (_(" (unknown data form)"));
3134 printf_filtered ("\n");
3139 obstack_free (&dont_print_type_obstack, NULL);
3142 /* Trivial helpers for the libiberty hash table, for mapping one
3147 struct type *old, *new;
3151 type_pair_hash (const void *item)
3153 const struct type_pair *pair = item;
3154 return htab_hash_pointer (pair->old);
3158 type_pair_eq (const void *item_lhs, const void *item_rhs)
3160 const struct type_pair *lhs = item_lhs, *rhs = item_rhs;
3161 return lhs->old == rhs->old;
3164 /* Allocate the hash table used by copy_type_recursive to walk
3165 types without duplicates. We use OBJFILE's obstack, because
3166 OBJFILE is about to be deleted. */
3169 create_copied_types_hash (struct objfile *objfile)
3171 return htab_create_alloc_ex (1, type_pair_hash, type_pair_eq,
3172 NULL, &objfile->objfile_obstack,
3173 hashtab_obstack_allocate,
3174 dummy_obstack_deallocate);
3177 /* Recursively copy (deep copy) TYPE, if it is associated with OBJFILE.
3178 Return a new type allocated using malloc, a saved type if we have already
3179 visited TYPE (using COPIED_TYPES), or TYPE if it is not associated with
3183 copy_type_recursive (struct objfile *objfile, struct type *type,
3184 htab_t copied_types)
3186 struct type_pair *stored, pair;
3188 struct type *new_type;
3190 if (TYPE_OBJFILE (type) == NULL)
3193 /* This type shouldn't be pointing to any types in other objfiles; if
3194 it did, the type might disappear unexpectedly. */
3195 gdb_assert (TYPE_OBJFILE (type) == objfile);
3198 slot = htab_find_slot (copied_types, &pair, INSERT);
3200 return ((struct type_pair *) *slot)->new;
3202 new_type = alloc_type (NULL);
3204 /* We must add the new type to the hash table immediately, in case
3205 we encounter this type again during a recursive call below. */
3206 stored = xmalloc (sizeof (struct type_pair));
3208 stored->new = new_type;
3211 /* Copy the common fields of types. */
3212 TYPE_CODE (new_type) = TYPE_CODE (type);
3213 TYPE_ARRAY_UPPER_BOUND_TYPE (new_type) = TYPE_ARRAY_UPPER_BOUND_TYPE (type);
3214 TYPE_ARRAY_LOWER_BOUND_TYPE (new_type) = TYPE_ARRAY_LOWER_BOUND_TYPE (type);
3215 if (TYPE_NAME (type))
3216 TYPE_NAME (new_type) = xstrdup (TYPE_NAME (type));
3217 if (TYPE_TAG_NAME (type))
3218 TYPE_TAG_NAME (new_type) = xstrdup (TYPE_TAG_NAME (type));
3219 TYPE_FLAGS (new_type) = TYPE_FLAGS (type);
3220 TYPE_VPTR_FIELDNO (new_type) = TYPE_VPTR_FIELDNO (type);
3222 TYPE_INSTANCE_FLAGS (new_type) = TYPE_INSTANCE_FLAGS (type);
3223 TYPE_LENGTH (new_type) = TYPE_LENGTH (type);
3225 /* Copy the fields. */
3226 TYPE_NFIELDS (new_type) = TYPE_NFIELDS (type);
3227 if (TYPE_NFIELDS (type))
3231 nfields = TYPE_NFIELDS (type);
3232 TYPE_FIELDS (new_type) = xmalloc (sizeof (struct field) * nfields);
3233 for (i = 0; i < nfields; i++)
3235 TYPE_FIELD_ARTIFICIAL (new_type, i) = TYPE_FIELD_ARTIFICIAL (type, i);
3236 TYPE_FIELD_BITSIZE (new_type, i) = TYPE_FIELD_BITSIZE (type, i);
3237 if (TYPE_FIELD_TYPE (type, i))
3238 TYPE_FIELD_TYPE (new_type, i)
3239 = copy_type_recursive (objfile, TYPE_FIELD_TYPE (type, i),
3241 if (TYPE_FIELD_NAME (type, i))
3242 TYPE_FIELD_NAME (new_type, i) = xstrdup (TYPE_FIELD_NAME (type, i));
3243 if (TYPE_FIELD_STATIC_HAS_ADDR (type, i))
3244 SET_FIELD_PHYSADDR (TYPE_FIELD (new_type, i),
3245 TYPE_FIELD_STATIC_PHYSADDR (type, i));
3246 else if (TYPE_FIELD_STATIC (type, i))
3247 SET_FIELD_PHYSNAME (TYPE_FIELD (new_type, i),
3248 xstrdup (TYPE_FIELD_STATIC_PHYSNAME (type, i)));
3251 TYPE_FIELD_BITPOS (new_type, i) = TYPE_FIELD_BITPOS (type, i);
3252 TYPE_FIELD_STATIC_KIND (new_type, i) = 0;
3257 /* Copy pointers to other types. */
3258 if (TYPE_TARGET_TYPE (type))
3259 TYPE_TARGET_TYPE (new_type) = copy_type_recursive (objfile,
3260 TYPE_TARGET_TYPE (type),
3262 if (TYPE_VPTR_BASETYPE (type))
3263 TYPE_VPTR_BASETYPE (new_type) = copy_type_recursive (objfile,
3264 TYPE_VPTR_BASETYPE (type),
3266 /* Maybe copy the type_specific bits.
3268 NOTE drow/2005-12-09: We do not copy the C++-specific bits like
3269 base classes and methods. There's no fundamental reason why we
3270 can't, but at the moment it is not needed. */
3272 if (TYPE_CODE (type) == TYPE_CODE_FLT)
3273 TYPE_FLOATFORMAT (new_type) = TYPE_FLOATFORMAT (type);
3274 else if (TYPE_CODE (type) == TYPE_CODE_STRUCT
3275 || TYPE_CODE (type) == TYPE_CODE_UNION
3276 || TYPE_CODE (type) == TYPE_CODE_TEMPLATE
3277 || TYPE_CODE (type) == TYPE_CODE_NAMESPACE)
3278 INIT_CPLUS_SPECIFIC (new_type);
3283 static struct type *
3284 build_flt (int bit, char *name, const struct floatformat **floatformats)
3290 gdb_assert (floatformats != NULL);
3291 gdb_assert (floatformats[0] != NULL && floatformats[1] != NULL);
3292 bit = floatformats[0]->totalsize;
3294 gdb_assert (bit >= 0);
3296 t = init_type (TYPE_CODE_FLT, bit / TARGET_CHAR_BIT, 0, name, NULL);
3297 TYPE_FLOATFORMAT (t) = floatformats;
3302 build_gdbtypes (void)
3305 init_type (TYPE_CODE_VOID, 1,
3307 "void", (struct objfile *) NULL);
3309 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3311 | (gdbarch_char_signed (current_gdbarch) ?
3312 0 : TYPE_FLAG_UNSIGNED)),
3313 "char", (struct objfile *) NULL);
3314 builtin_type_true_char =
3315 init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3317 "true character", (struct objfile *) NULL);
3318 builtin_type_signed_char =
3319 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3321 "signed char", (struct objfile *) NULL);
3322 builtin_type_unsigned_char =
3323 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3325 "unsigned char", (struct objfile *) NULL);
3326 builtin_type_short =
3327 init_type (TYPE_CODE_INT,
3328 gdbarch_short_bit (current_gdbarch) / TARGET_CHAR_BIT,
3329 0, "short", (struct objfile *) NULL);
3330 builtin_type_unsigned_short =
3331 init_type (TYPE_CODE_INT,
3332 gdbarch_short_bit (current_gdbarch) / TARGET_CHAR_BIT,
3333 TYPE_FLAG_UNSIGNED, "unsigned short", (struct objfile *) NULL);
3335 init_type (TYPE_CODE_INT,
3336 gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT,
3337 0, "int", (struct objfile *) NULL);
3338 builtin_type_unsigned_int =
3339 init_type (TYPE_CODE_INT,
3340 gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT,
3341 TYPE_FLAG_UNSIGNED, "unsigned int", (struct objfile *) NULL);
3343 init_type (TYPE_CODE_INT,
3344 gdbarch_long_bit (current_gdbarch) / TARGET_CHAR_BIT,
3345 0, "long", (struct objfile *) NULL);
3346 builtin_type_unsigned_long =
3347 init_type (TYPE_CODE_INT,
3348 gdbarch_long_bit (current_gdbarch) / TARGET_CHAR_BIT,
3349 TYPE_FLAG_UNSIGNED, "unsigned long", (struct objfile *) NULL);
3350 builtin_type_long_long =
3351 init_type (TYPE_CODE_INT,
3352 gdbarch_long_long_bit (current_gdbarch) / TARGET_CHAR_BIT,
3353 0, "long long", (struct objfile *) NULL);
3354 builtin_type_unsigned_long_long =
3355 init_type (TYPE_CODE_INT,
3356 gdbarch_long_long_bit (current_gdbarch) / TARGET_CHAR_BIT,
3358 "unsigned long long", (struct objfile *) NULL);
3361 = build_flt (gdbarch_float_bit (current_gdbarch), "float",
3362 gdbarch_float_format (current_gdbarch));
3364 = build_flt (gdbarch_double_bit (current_gdbarch), "double",
3365 gdbarch_double_format (current_gdbarch));
3366 builtin_type_long_double
3367 = build_flt (gdbarch_long_double_bit (current_gdbarch), "long double",
3368 gdbarch_long_double_format
3371 builtin_type_complex =
3372 init_type (TYPE_CODE_COMPLEX,
3373 2 * gdbarch_float_bit (current_gdbarch) / TARGET_CHAR_BIT,
3375 "complex", (struct objfile *) NULL);
3376 TYPE_TARGET_TYPE (builtin_type_complex) = builtin_type_float;
3377 builtin_type_double_complex =
3378 init_type (TYPE_CODE_COMPLEX,
3379 2 * gdbarch_double_bit (current_gdbarch) / TARGET_CHAR_BIT,
3381 "double complex", (struct objfile *) NULL);
3382 TYPE_TARGET_TYPE (builtin_type_double_complex) = builtin_type_double;
3383 builtin_type_string =
3384 init_type (TYPE_CODE_STRING, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3386 "string", (struct objfile *) NULL);
3388 init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3390 "bool", (struct objfile *) NULL);
3392 /* Add user knob for controlling resolution of opaque types */
3393 add_setshow_boolean_cmd ("opaque-type-resolution", class_support,
3394 &opaque_type_resolution, _("\
3395 Set resolution of opaque struct/class/union types (if set before loading symbols)."), _("\
3396 Show resolution of opaque struct/class/union types (if set before loading symbols)."), NULL,
3398 show_opaque_type_resolution,
3399 &setlist, &showlist);
3400 opaque_type_resolution = 1;
3402 /* Pointer/Address types. */
3404 /* NOTE: on some targets, addresses and pointers are not necessarily
3405 the same --- for example, on the D10V, pointers are 16 bits long,
3406 but addresses are 32 bits long. See doc/gdbint.texinfo,
3407 ``Pointers Are Not Always Addresses''.
3410 - gdb's `struct type' always describes the target's
3412 - gdb's `struct value' objects should always hold values in
3414 - gdb's CORE_ADDR values are addresses in the unified virtual
3415 address space that the assembler and linker work with. Thus,
3416 since target_read_memory takes a CORE_ADDR as an argument, it
3417 can access any memory on the target, even if the processor has
3418 separate code and data address spaces.
3421 - If v is a value holding a D10V code pointer, its contents are
3422 in target form: a big-endian address left-shifted two bits.
3423 - If p is a D10V pointer type, TYPE_LENGTH (p) == 2, just as
3424 sizeof (void *) == 2 on the target.
3426 In this context, builtin_type_CORE_ADDR is a bit odd: it's a
3427 target type for a value the target will never see. It's only
3428 used to hold the values of (typeless) linker symbols, which are
3429 indeed in the unified virtual address space. */
3430 builtin_type_void_data_ptr = make_pointer_type (builtin_type_void, NULL);
3431 builtin_type_void_func_ptr
3432 = lookup_pointer_type (lookup_function_type (builtin_type_void));
3433 builtin_type_CORE_ADDR =
3434 init_type (TYPE_CODE_INT, gdbarch_addr_bit (current_gdbarch) / 8,
3436 "__CORE_ADDR", (struct objfile *) NULL);
3439 static struct gdbarch_data *gdbtypes_data;
3441 const struct builtin_type *
3442 builtin_type (struct gdbarch *gdbarch)
3444 return gdbarch_data (gdbarch, gdbtypes_data);
3448 static struct type *
3449 build_complex (int bit, char *name, struct type *target_type)
3452 if (bit <= 0 || target_type == builtin_type_error)
3454 gdb_assert (builtin_type_error != NULL);
3455 return builtin_type_error;
3457 t = init_type (TYPE_CODE_COMPLEX, 2 * bit / TARGET_CHAR_BIT,
3458 0, name, (struct objfile *) NULL);
3459 TYPE_TARGET_TYPE (t) = target_type;
3464 gdbtypes_post_init (struct gdbarch *gdbarch)
3466 struct builtin_type *builtin_type
3467 = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_type);
3469 builtin_type->builtin_void =
3470 init_type (TYPE_CODE_VOID, 1,
3472 "void", (struct objfile *) NULL);
3473 builtin_type->builtin_char =
3474 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3476 | (gdbarch_char_signed (current_gdbarch) ?
3477 0 : TYPE_FLAG_UNSIGNED)),
3478 "char", (struct objfile *) NULL);
3479 builtin_type->builtin_true_char =
3480 init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3482 "true character", (struct objfile *) NULL);
3483 builtin_type->builtin_signed_char =
3484 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3486 "signed char", (struct objfile *) NULL);
3487 builtin_type->builtin_unsigned_char =
3488 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3490 "unsigned char", (struct objfile *) NULL);
3491 builtin_type->builtin_short =
3493 (TYPE_CODE_INT, gdbarch_short_bit (current_gdbarch) / TARGET_CHAR_BIT,
3494 0, "short", (struct objfile *) NULL);
3495 builtin_type->builtin_unsigned_short =
3497 (TYPE_CODE_INT, gdbarch_short_bit (current_gdbarch) / TARGET_CHAR_BIT,
3498 TYPE_FLAG_UNSIGNED, "unsigned short", (struct objfile *) NULL);
3499 builtin_type->builtin_int =
3501 (TYPE_CODE_INT, gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT,
3502 0, "int", (struct objfile *) NULL);
3503 builtin_type->builtin_unsigned_int =
3505 (TYPE_CODE_INT, gdbarch_int_bit (current_gdbarch) / TARGET_CHAR_BIT,
3506 TYPE_FLAG_UNSIGNED, "unsigned int", (struct objfile *) NULL);
3507 builtin_type->builtin_long =
3509 (TYPE_CODE_INT, gdbarch_long_bit (current_gdbarch) / TARGET_CHAR_BIT,
3510 0, "long", (struct objfile *) NULL);
3511 builtin_type->builtin_unsigned_long =
3513 (TYPE_CODE_INT, gdbarch_long_bit (current_gdbarch) / TARGET_CHAR_BIT,
3514 TYPE_FLAG_UNSIGNED, "unsigned long", (struct objfile *) NULL);
3515 builtin_type->builtin_long_long =
3516 init_type (TYPE_CODE_INT,
3517 gdbarch_long_long_bit (current_gdbarch) / TARGET_CHAR_BIT,
3518 0, "long long", (struct objfile *) NULL);
3519 builtin_type->builtin_unsigned_long_long =
3520 init_type (TYPE_CODE_INT,
3521 gdbarch_long_long_bit (current_gdbarch) / TARGET_CHAR_BIT,
3522 TYPE_FLAG_UNSIGNED, "unsigned long long",
3523 (struct objfile *) NULL);
3524 builtin_type->builtin_float
3525 = build_flt (gdbarch_float_bit (gdbarch), "float",
3526 gdbarch_float_format (gdbarch));
3527 builtin_type->builtin_double
3528 = build_flt (gdbarch_double_bit (gdbarch), "double",
3529 gdbarch_double_format (gdbarch));
3530 builtin_type->builtin_long_double
3531 = build_flt (gdbarch_long_double_bit (gdbarch), "long double",
3532 gdbarch_long_double_format (gdbarch));
3533 builtin_type->builtin_complex
3534 = build_complex (gdbarch_float_bit (gdbarch), "complex",
3535 builtin_type->builtin_float);
3536 builtin_type->builtin_double_complex
3537 = build_complex (gdbarch_double_bit (gdbarch), "double complex",
3538 builtin_type->builtin_double);
3539 builtin_type->builtin_string =
3540 init_type (TYPE_CODE_STRING, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3542 "string", (struct objfile *) NULL);
3543 builtin_type->builtin_bool =
3544 init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
3546 "bool", (struct objfile *) NULL);
3548 /* Pointer/Address types. */
3550 /* NOTE: on some targets, addresses and pointers are not necessarily
3551 the same --- for example, on the D10V, pointers are 16 bits long,
3552 but addresses are 32 bits long. See doc/gdbint.texinfo,
3553 ``Pointers Are Not Always Addresses''.
3556 - gdb's `struct type' always describes the target's
3558 - gdb's `struct value' objects should always hold values in
3560 - gdb's CORE_ADDR values are addresses in the unified virtual
3561 address space that the assembler and linker work with. Thus,
3562 since target_read_memory takes a CORE_ADDR as an argument, it
3563 can access any memory on the target, even if the processor has
3564 separate code and data address spaces.
3567 - If v is a value holding a D10V code pointer, its contents are
3568 in target form: a big-endian address left-shifted two bits.
3569 - If p is a D10V pointer type, TYPE_LENGTH (p) == 2, just as
3570 sizeof (void *) == 2 on the target.
3572 In this context, builtin_type->CORE_ADDR is a bit odd: it's a
3573 target type for a value the target will never see. It's only
3574 used to hold the values of (typeless) linker symbols, which are
3575 indeed in the unified virtual address space. */
3576 builtin_type->builtin_data_ptr
3577 = make_pointer_type (builtin_type->builtin_void, NULL);
3578 builtin_type->builtin_func_ptr
3579 = lookup_pointer_type (lookup_function_type (builtin_type->builtin_void));
3580 builtin_type->builtin_core_addr =
3581 init_type (TYPE_CODE_INT, gdbarch_addr_bit (current_gdbarch) / 8,
3583 "__CORE_ADDR", (struct objfile *) NULL);
3585 return builtin_type;
3588 extern void _initialize_gdbtypes (void);
3590 _initialize_gdbtypes (void)
3592 struct cmd_list_element *c;
3594 /* FIXME: Why don't the following types need to be arch-swapped?
3595 See the comment at the top of the calls to
3596 DEPRECATED_REGISTER_GDBARCH_SWAP below. */
3598 init_type (TYPE_CODE_INT, 0 / 8,
3600 "int0_t", (struct objfile *) NULL);
3602 init_type (TYPE_CODE_INT, 8 / 8,
3604 "int8_t", (struct objfile *) NULL);
3605 builtin_type_uint8 =
3606 init_type (TYPE_CODE_INT, 8 / 8,
3608 "uint8_t", (struct objfile *) NULL);
3609 builtin_type_int16 =
3610 init_type (TYPE_CODE_INT, 16 / 8,
3612 "int16_t", (struct objfile *) NULL);
3613 builtin_type_uint16 =
3614 init_type (TYPE_CODE_INT, 16 / 8,
3616 "uint16_t", (struct objfile *) NULL);
3617 builtin_type_int32 =
3618 init_type (TYPE_CODE_INT, 32 / 8,
3620 "int32_t", (struct objfile *) NULL);
3621 builtin_type_uint32 =
3622 init_type (TYPE_CODE_INT, 32 / 8,
3624 "uint32_t", (struct objfile *) NULL);
3625 builtin_type_int64 =
3626 init_type (TYPE_CODE_INT, 64 / 8,
3628 "int64_t", (struct objfile *) NULL);
3629 builtin_type_uint64 =
3630 init_type (TYPE_CODE_INT, 64 / 8,
3632 "uint64_t", (struct objfile *) NULL);
3633 builtin_type_int128 =
3634 init_type (TYPE_CODE_INT, 128 / 8,
3636 "int128_t", (struct objfile *) NULL);
3637 builtin_type_uint128 =
3638 init_type (TYPE_CODE_INT, 128 / 8,
3640 "uint128_t", (struct objfile *) NULL);
3644 gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init);
3646 /* FIXME - For the moment, handle types by swapping them in and out.
3647 Should be using the per-architecture data-pointer and a large
3650 Note that any type T that we might create a 'T *' type for must
3651 be arch-swapped: we cache a type's 'T *' type in the pointer_type
3652 field, so if we change architectures but don't swap T, then
3653 lookup_pointer_type will start handing out pointer types made for
3654 a different architecture. */
3655 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void);
3656 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_char);
3657 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_short);
3658 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_int);
3659 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_long);
3660 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_long_long);
3661 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_signed_char);
3662 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_char);
3663 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_short);
3664 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_int);
3665 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_long);
3666 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_long_long);
3667 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_float);
3668 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_double);
3669 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_long_double);
3670 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_complex);
3671 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_double_complex);
3672 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_string);
3673 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void_data_ptr);
3674 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void_func_ptr);
3675 DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR);
3676 deprecated_register_gdbarch_swap (NULL, 0, build_gdbtypes);
3678 /* Note: These types do not need to be swapped - they are target
3679 neutral. FIXME: Are you sure? See the comment above the calls
3680 to DEPRECATED_REGISTER_GDBARCH_SWAP above. */
3681 builtin_type_ieee_single
3682 = build_flt (-1, "builtin_type_ieee_single", floatformats_ieee_single);
3683 builtin_type_ieee_double
3684 = build_flt (-1, "builtin_type_ieee_double", floatformats_ieee_double);
3685 builtin_type_i387_ext
3686 = build_flt (-1, "builtin_type_i387_ext", floatformats_i387_ext);
3687 builtin_type_m68881_ext
3688 = build_flt (-1, "builtin_type_m68881_ext", floatformats_m68881_ext);
3689 builtin_type_arm_ext
3690 = build_flt (-1, "builtin_type_arm_ext", floatformats_arm_ext);
3691 builtin_type_ia64_spill
3692 = build_flt (-1, "builtin_type_ia64_spill", floatformats_ia64_spill);
3693 builtin_type_ia64_quad
3694 = build_flt (-1, "builtin_type_ia64_quad", floatformats_ia64_quad);
3696 add_setshow_zinteger_cmd ("overload", no_class, &overload_debug, _("\
3697 Set debugging of C++ overloading."), _("\
3698 Show debugging of C++ overloading."), _("\
3699 When enabled, ranking of the functions is displayed."),
3701 show_overload_debug,
3702 &setdebuglist, &showdebuglist);