1 /* Support routines for manipulating internal types for GDB.
3 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
4 2002, 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_int0
;
48 struct type
*builtin_type_int8
;
49 struct type
*builtin_type_uint8
;
50 struct type
*builtin_type_int16
;
51 struct type
*builtin_type_uint16
;
52 struct type
*builtin_type_int32
;
53 struct type
*builtin_type_uint32
;
54 struct type
*builtin_type_int64
;
55 struct type
*builtin_type_uint64
;
56 struct type
*builtin_type_int128
;
57 struct type
*builtin_type_uint128
;
59 /* Floatformat pairs. */
60 const struct floatformat
*floatformats_ieee_single
[BFD_ENDIAN_UNKNOWN
] = {
61 &floatformat_ieee_single_big
,
62 &floatformat_ieee_single_little
64 const struct floatformat
*floatformats_ieee_double
[BFD_ENDIAN_UNKNOWN
] = {
65 &floatformat_ieee_double_big
,
66 &floatformat_ieee_double_little
68 const struct floatformat
*floatformats_ieee_double_littlebyte_bigword
[BFD_ENDIAN_UNKNOWN
] = {
69 &floatformat_ieee_double_big
,
70 &floatformat_ieee_double_littlebyte_bigword
72 const struct floatformat
*floatformats_i387_ext
[BFD_ENDIAN_UNKNOWN
] = {
73 &floatformat_i387_ext
,
76 const struct floatformat
*floatformats_m68881_ext
[BFD_ENDIAN_UNKNOWN
] = {
77 &floatformat_m68881_ext
,
78 &floatformat_m68881_ext
80 const struct floatformat
*floatformats_arm_ext
[BFD_ENDIAN_UNKNOWN
] = {
81 &floatformat_arm_ext_big
,
82 &floatformat_arm_ext_littlebyte_bigword
84 const struct floatformat
*floatformats_ia64_spill
[BFD_ENDIAN_UNKNOWN
] = {
85 &floatformat_ia64_spill_big
,
86 &floatformat_ia64_spill_little
88 const struct floatformat
*floatformats_ia64_quad
[BFD_ENDIAN_UNKNOWN
] = {
89 &floatformat_ia64_quad_big
,
90 &floatformat_ia64_quad_little
92 const struct floatformat
*floatformats_vax_f
[BFD_ENDIAN_UNKNOWN
] = {
96 const struct floatformat
*floatformats_vax_d
[BFD_ENDIAN_UNKNOWN
] = {
101 struct type
*builtin_type_ieee_single
;
102 struct type
*builtin_type_ieee_double
;
103 struct type
*builtin_type_i387_ext
;
104 struct type
*builtin_type_m68881_ext
;
105 struct type
*builtin_type_arm_ext
;
106 struct type
*builtin_type_ia64_spill
;
107 struct type
*builtin_type_ia64_quad
;
110 int opaque_type_resolution
= 1;
112 show_opaque_type_resolution (struct ui_file
*file
, int from_tty
,
113 struct cmd_list_element
*c
,
116 fprintf_filtered (file
, _("\
117 Resolution of opaque struct/class/union types (if set before loading symbols) is %s.\n"),
121 int overload_debug
= 0;
123 show_overload_debug (struct ui_file
*file
, int from_tty
,
124 struct cmd_list_element
*c
, const char *value
)
126 fprintf_filtered (file
, _("Debugging of C++ overloading is %s.\n"),
134 }; /* Maximum extension is 128! FIXME */
136 static void print_bit_vector (B_TYPE
*, int);
137 static void print_arg_types (struct field
*, int, int);
138 static void dump_fn_fieldlists (struct type
*, int);
139 static void print_cplus_stuff (struct type
*, int);
140 static void virtual_base_list_aux (struct type
*dclass
);
143 /* Alloc a new type structure and fill it with some defaults. If
144 OBJFILE is non-NULL, then allocate the space for the type structure
145 in that objfile's objfile_obstack. Otherwise allocate the new type
146 structure by xmalloc () (for permanent types). */
149 alloc_type (struct objfile
*objfile
)
153 /* Alloc the structure and start off with all fields zeroed. */
157 type
= xmalloc (sizeof (struct type
));
158 memset (type
, 0, sizeof (struct type
));
159 TYPE_MAIN_TYPE (type
) = xmalloc (sizeof (struct main_type
));
163 type
= obstack_alloc (&objfile
->objfile_obstack
,
164 sizeof (struct type
));
165 memset (type
, 0, sizeof (struct type
));
166 TYPE_MAIN_TYPE (type
) = obstack_alloc (&objfile
->objfile_obstack
,
167 sizeof (struct main_type
));
168 OBJSTAT (objfile
, n_types
++);
170 memset (TYPE_MAIN_TYPE (type
), 0, sizeof (struct main_type
));
172 /* Initialize the fields that might not be zero. */
174 TYPE_CODE (type
) = TYPE_CODE_UNDEF
;
175 TYPE_OBJFILE (type
) = objfile
;
176 TYPE_VPTR_FIELDNO (type
) = -1;
177 TYPE_CHAIN (type
) = type
; /* Chain back to itself. */
182 /* Alloc a new type instance structure, fill it with some defaults,
183 and point it at OLDTYPE. Allocate the new type instance from the
184 same place as OLDTYPE. */
187 alloc_type_instance (struct type
*oldtype
)
191 /* Allocate the structure. */
193 if (TYPE_OBJFILE (oldtype
) == NULL
)
195 type
= xmalloc (sizeof (struct type
));
196 memset (type
, 0, sizeof (struct type
));
200 type
= obstack_alloc (&TYPE_OBJFILE (oldtype
)->objfile_obstack
,
201 sizeof (struct type
));
202 memset (type
, 0, sizeof (struct type
));
204 TYPE_MAIN_TYPE (type
) = TYPE_MAIN_TYPE (oldtype
);
206 TYPE_CHAIN (type
) = type
; /* Chain back to itself for now. */
211 /* Clear all remnants of the previous type at TYPE, in preparation for
212 replacing it with something else. */
214 smash_type (struct type
*type
)
216 memset (TYPE_MAIN_TYPE (type
), 0, sizeof (struct main_type
));
218 /* For now, delete the rings. */
219 TYPE_CHAIN (type
) = type
;
221 /* For now, leave the pointer/reference types alone. */
224 /* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points
225 to a pointer to memory where the pointer type should be stored.
226 If *TYPEPTR is zero, update it to point to the pointer type we return.
227 We allocate new memory if needed. */
230 make_pointer_type (struct type
*type
, struct type
**typeptr
)
232 struct type
*ntype
; /* New type */
233 struct objfile
*objfile
;
236 ntype
= TYPE_POINTER_TYPE (type
);
241 return ntype
; /* Don't care about alloc,
242 and have new type. */
243 else if (*typeptr
== 0)
245 *typeptr
= ntype
; /* Tracking alloc, and have new type. */
250 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
252 ntype
= alloc_type (TYPE_OBJFILE (type
));
256 else /* We have storage, but need to reset it. */
259 objfile
= TYPE_OBJFILE (ntype
);
260 chain
= TYPE_CHAIN (ntype
);
262 TYPE_CHAIN (ntype
) = chain
;
263 TYPE_OBJFILE (ntype
) = objfile
;
266 TYPE_TARGET_TYPE (ntype
) = type
;
267 TYPE_POINTER_TYPE (type
) = ntype
;
269 /* FIXME! Assume the machine has only one representation for
272 TYPE_LENGTH (ntype
) =
273 gdbarch_ptr_bit (current_gdbarch
) / TARGET_CHAR_BIT
;
274 TYPE_CODE (ntype
) = TYPE_CODE_PTR
;
276 /* Mark pointers as unsigned. The target converts between pointers
277 and addresses (CORE_ADDRs) using gdbarch_pointer_to_address and
278 gdbarch_address_to_pointer. */
279 TYPE_FLAGS (ntype
) |= TYPE_FLAG_UNSIGNED
;
281 if (!TYPE_POINTER_TYPE (type
)) /* Remember it, if don't have one. */
282 TYPE_POINTER_TYPE (type
) = ntype
;
284 /* Update the length of all the other variants of this type. */
285 chain
= TYPE_CHAIN (ntype
);
286 while (chain
!= ntype
)
288 TYPE_LENGTH (chain
) = TYPE_LENGTH (ntype
);
289 chain
= TYPE_CHAIN (chain
);
295 /* Given a type TYPE, return a type of pointers to that type.
296 May need to construct such a type if this is the first use. */
299 lookup_pointer_type (struct type
*type
)
301 return make_pointer_type (type
, (struct type
**) 0);
304 /* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero,
305 points to a pointer to memory where the reference type should be
306 stored. If *TYPEPTR is zero, update it to point to the reference
307 type we return. We allocate new memory if needed. */
310 make_reference_type (struct type
*type
, struct type
**typeptr
)
312 struct type
*ntype
; /* New type */
313 struct objfile
*objfile
;
316 ntype
= TYPE_REFERENCE_TYPE (type
);
321 return ntype
; /* Don't care about alloc,
322 and have new type. */
323 else if (*typeptr
== 0)
325 *typeptr
= ntype
; /* Tracking alloc, and have new type. */
330 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
332 ntype
= alloc_type (TYPE_OBJFILE (type
));
336 else /* We have storage, but need to reset it. */
339 objfile
= TYPE_OBJFILE (ntype
);
340 chain
= TYPE_CHAIN (ntype
);
342 TYPE_CHAIN (ntype
) = chain
;
343 TYPE_OBJFILE (ntype
) = objfile
;
346 TYPE_TARGET_TYPE (ntype
) = type
;
347 TYPE_REFERENCE_TYPE (type
) = ntype
;
349 /* FIXME! Assume the machine has only one representation for
350 references, and that it matches the (only) representation for
353 TYPE_LENGTH (ntype
) = gdbarch_ptr_bit (current_gdbarch
) / TARGET_CHAR_BIT
;
354 TYPE_CODE (ntype
) = TYPE_CODE_REF
;
356 if (!TYPE_REFERENCE_TYPE (type
)) /* Remember it, if don't have one. */
357 TYPE_REFERENCE_TYPE (type
) = ntype
;
359 /* Update the length of all the other variants of this type. */
360 chain
= TYPE_CHAIN (ntype
);
361 while (chain
!= ntype
)
363 TYPE_LENGTH (chain
) = TYPE_LENGTH (ntype
);
364 chain
= TYPE_CHAIN (chain
);
370 /* Same as above, but caller doesn't care about memory allocation
374 lookup_reference_type (struct type
*type
)
376 return make_reference_type (type
, (struct type
**) 0);
379 /* Lookup a function type that returns type TYPE. TYPEPTR, if
380 nonzero, points to a pointer to memory where the function type
381 should be stored. If *TYPEPTR is zero, update it to point to the
382 function type we return. We allocate new memory if needed. */
385 make_function_type (struct type
*type
, struct type
**typeptr
)
387 struct type
*ntype
; /* New type */
388 struct objfile
*objfile
;
390 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
392 ntype
= alloc_type (TYPE_OBJFILE (type
));
396 else /* We have storage, but need to reset it. */
399 objfile
= TYPE_OBJFILE (ntype
);
401 TYPE_OBJFILE (ntype
) = objfile
;
404 TYPE_TARGET_TYPE (ntype
) = type
;
406 TYPE_LENGTH (ntype
) = 1;
407 TYPE_CODE (ntype
) = TYPE_CODE_FUNC
;
413 /* Given a type TYPE, return a type of functions that return that type.
414 May need to construct such a type if this is the first use. */
417 lookup_function_type (struct type
*type
)
419 return make_function_type (type
, (struct type
**) 0);
422 /* Identify address space identifier by name --
423 return the integer flag defined in gdbtypes.h. */
425 address_space_name_to_int (char *space_identifier
)
427 struct gdbarch
*gdbarch
= current_gdbarch
;
429 /* Check for known address space delimiters. */
430 if (!strcmp (space_identifier
, "code"))
431 return TYPE_FLAG_CODE_SPACE
;
432 else if (!strcmp (space_identifier
, "data"))
433 return TYPE_FLAG_DATA_SPACE
;
434 else if (gdbarch_address_class_name_to_type_flags_p (gdbarch
)
435 && gdbarch_address_class_name_to_type_flags (gdbarch
,
440 error (_("Unknown address space specifier: \"%s\""), space_identifier
);
443 /* Identify address space identifier by integer flag as defined in
444 gdbtypes.h -- return the string version of the adress space name. */
447 address_space_int_to_name (int space_flag
)
449 struct gdbarch
*gdbarch
= current_gdbarch
;
450 if (space_flag
& TYPE_FLAG_CODE_SPACE
)
452 else if (space_flag
& TYPE_FLAG_DATA_SPACE
)
454 else if ((space_flag
& TYPE_FLAG_ADDRESS_CLASS_ALL
)
455 && gdbarch_address_class_type_flags_to_name_p (gdbarch
))
456 return gdbarch_address_class_type_flags_to_name (gdbarch
, space_flag
);
461 /* Create a new type with instance flags NEW_FLAGS, based on TYPE.
463 If STORAGE is non-NULL, create the new type instance there.
464 STORAGE must be in the same obstack as TYPE. */
467 make_qualified_type (struct type
*type
, int new_flags
,
468 struct type
*storage
)
474 if (TYPE_INSTANCE_FLAGS (ntype
) == new_flags
)
476 ntype
= TYPE_CHAIN (ntype
);
477 } while (ntype
!= type
);
479 /* Create a new type instance. */
481 ntype
= alloc_type_instance (type
);
484 /* If STORAGE was provided, it had better be in the same objfile
485 as TYPE. Otherwise, we can't link it into TYPE's cv chain:
486 if one objfile is freed and the other kept, we'd have
487 dangling pointers. */
488 gdb_assert (TYPE_OBJFILE (type
) == TYPE_OBJFILE (storage
));
491 TYPE_MAIN_TYPE (ntype
) = TYPE_MAIN_TYPE (type
);
492 TYPE_CHAIN (ntype
) = ntype
;
495 /* Pointers or references to the original type are not relevant to
497 TYPE_POINTER_TYPE (ntype
) = (struct type
*) 0;
498 TYPE_REFERENCE_TYPE (ntype
) = (struct type
*) 0;
500 /* Chain the new qualified type to the old type. */
501 TYPE_CHAIN (ntype
) = TYPE_CHAIN (type
);
502 TYPE_CHAIN (type
) = ntype
;
504 /* Now set the instance flags and return the new type. */
505 TYPE_INSTANCE_FLAGS (ntype
) = new_flags
;
507 /* Set length of new type to that of the original type. */
508 TYPE_LENGTH (ntype
) = TYPE_LENGTH (type
);
513 /* Make an address-space-delimited variant of a type -- a type that
514 is identical to the one supplied except that it has an address
515 space attribute attached to it (such as "code" or "data").
517 The space attributes "code" and "data" are for Harvard
518 architectures. The address space attributes are for architectures
519 which have alternately sized pointers or pointers with alternate
523 make_type_with_address_space (struct type
*type
, int space_flag
)
526 int new_flags
= ((TYPE_INSTANCE_FLAGS (type
)
527 & ~(TYPE_FLAG_CODE_SPACE
| TYPE_FLAG_DATA_SPACE
528 | TYPE_FLAG_ADDRESS_CLASS_ALL
))
531 return make_qualified_type (type
, new_flags
, NULL
);
534 /* Make a "c-v" variant of a type -- a type that is identical to the
535 one supplied except that it may have const or volatile attributes
536 CNST is a flag for setting the const attribute
537 VOLTL is a flag for setting the volatile attribute
538 TYPE is the base type whose variant we are creating.
540 If TYPEPTR and *TYPEPTR are non-zero, then *TYPEPTR points to
541 storage to hold the new qualified type; *TYPEPTR and TYPE must be
542 in the same objfile. Otherwise, allocate fresh memory for the new
543 type whereever TYPE lives. If TYPEPTR is non-zero, set it to the
544 new type we construct. */
546 make_cv_type (int cnst
, int voltl
,
548 struct type
**typeptr
)
550 struct type
*ntype
; /* New type */
551 struct type
*tmp_type
= type
; /* tmp type */
552 struct objfile
*objfile
;
554 int new_flags
= (TYPE_INSTANCE_FLAGS (type
)
555 & ~(TYPE_FLAG_CONST
| TYPE_FLAG_VOLATILE
));
558 new_flags
|= TYPE_FLAG_CONST
;
561 new_flags
|= TYPE_FLAG_VOLATILE
;
563 if (typeptr
&& *typeptr
!= NULL
)
565 /* TYPE and *TYPEPTR must be in the same objfile. We can't have
566 a C-V variant chain that threads across objfiles: if one
567 objfile gets freed, then the other has a broken C-V chain.
569 This code used to try to copy over the main type from TYPE to
570 *TYPEPTR if they were in different objfiles, but that's
571 wrong, too: TYPE may have a field list or member function
572 lists, which refer to types of their own, etc. etc. The
573 whole shebang would need to be copied over recursively; you
574 can't have inter-objfile pointers. The only thing to do is
575 to leave stub types as stub types, and look them up afresh by
576 name each time you encounter them. */
577 gdb_assert (TYPE_OBJFILE (*typeptr
) == TYPE_OBJFILE (type
));
580 ntype
= make_qualified_type (type
, new_flags
,
581 typeptr
? *typeptr
: NULL
);
589 /* Replace the contents of ntype with the type *type. This changes the
590 contents, rather than the pointer for TYPE_MAIN_TYPE (ntype); thus
591 the changes are propogated to all types in the TYPE_CHAIN.
593 In order to build recursive types, it's inevitable that we'll need
594 to update types in place --- but this sort of indiscriminate
595 smashing is ugly, and needs to be replaced with something more
596 controlled. TYPE_MAIN_TYPE is a step in this direction; it's not
597 clear if more steps are needed. */
599 replace_type (struct type
*ntype
, struct type
*type
)
603 /* These two types had better be in the same objfile. Otherwise,
604 the assignment of one type's main type structure to the other
605 will produce a type with references to objects (names; field
606 lists; etc.) allocated on an objfile other than its own. */
607 gdb_assert (TYPE_OBJFILE (ntype
) == TYPE_OBJFILE (ntype
));
609 *TYPE_MAIN_TYPE (ntype
) = *TYPE_MAIN_TYPE (type
);
611 /* The type length is not a part of the main type. Update it for
612 each type on the variant chain. */
615 /* Assert that this element of the chain has no address-class bits
616 set in its flags. Such type variants might have type lengths
617 which are supposed to be different from the non-address-class
618 variants. This assertion shouldn't ever be triggered because
619 symbol readers which do construct address-class variants don't
620 call replace_type(). */
621 gdb_assert (TYPE_ADDRESS_CLASS_ALL (chain
) == 0);
623 TYPE_LENGTH (chain
) = TYPE_LENGTH (type
);
624 chain
= TYPE_CHAIN (chain
);
625 } while (ntype
!= chain
);
627 /* Assert that the two types have equivalent instance qualifiers.
628 This should be true for at least all of our debug readers. */
629 gdb_assert (TYPE_INSTANCE_FLAGS (ntype
) == TYPE_INSTANCE_FLAGS (type
));
632 /* Implement direct support for MEMBER_TYPE in GNU C++.
633 May need to construct such a type if this is the first use.
634 The TYPE is the type of the member. The DOMAIN is the type
635 of the aggregate that the member belongs to. */
638 lookup_memberptr_type (struct type
*type
, struct type
*domain
)
642 mtype
= alloc_type (TYPE_OBJFILE (type
));
643 smash_to_memberptr_type (mtype
, domain
, type
);
647 /* Return a pointer-to-method type, for a method of type TO_TYPE. */
650 lookup_methodptr_type (struct type
*to_type
)
654 mtype
= alloc_type (TYPE_OBJFILE (to_type
));
655 TYPE_TARGET_TYPE (mtype
) = to_type
;
656 TYPE_DOMAIN_TYPE (mtype
) = TYPE_DOMAIN_TYPE (to_type
);
657 TYPE_LENGTH (mtype
) = cplus_method_ptr_size ();
658 TYPE_CODE (mtype
) = TYPE_CODE_METHODPTR
;
662 /* Allocate a stub method whose return type is TYPE. This apparently
663 happens for speed of symbol reading, since parsing out the
664 arguments to the method is cpu-intensive, the way we are doing it.
665 So, we will fill in arguments later. This always returns a fresh
669 allocate_stub_method (struct type
*type
)
673 mtype
= init_type (TYPE_CODE_METHOD
, 1, TYPE_FLAG_STUB
, NULL
,
674 TYPE_OBJFILE (type
));
675 TYPE_TARGET_TYPE (mtype
) = type
;
676 /* _DOMAIN_TYPE (mtype) = unknown yet */
680 /* Create a range type using either a blank type supplied in
681 RESULT_TYPE, or creating a new type, inheriting the objfile from
684 Indices will be of type INDEX_TYPE, and will range from LOW_BOUND
685 to HIGH_BOUND, inclusive.
687 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
688 sure it is TYPE_CODE_UNDEF before we bash it into a range type? */
691 create_range_type (struct type
*result_type
, struct type
*index_type
,
692 int low_bound
, int high_bound
)
694 if (result_type
== NULL
)
696 result_type
= alloc_type (TYPE_OBJFILE (index_type
));
698 TYPE_CODE (result_type
) = TYPE_CODE_RANGE
;
699 TYPE_TARGET_TYPE (result_type
) = index_type
;
700 if (TYPE_STUB (index_type
))
701 TYPE_FLAGS (result_type
) |= TYPE_FLAG_TARGET_STUB
;
703 TYPE_LENGTH (result_type
) = TYPE_LENGTH (check_typedef (index_type
));
704 TYPE_NFIELDS (result_type
) = 2;
705 TYPE_FIELDS (result_type
) = (struct field
*)
706 TYPE_ALLOC (result_type
, 2 * sizeof (struct field
));
707 memset (TYPE_FIELDS (result_type
), 0, 2 * sizeof (struct field
));
708 TYPE_FIELD_BITPOS (result_type
, 0) = low_bound
;
709 TYPE_FIELD_BITPOS (result_type
, 1) = high_bound
;
710 TYPE_FIELD_TYPE (result_type
, 0) = builtin_type_int
; /* FIXME */
711 TYPE_FIELD_TYPE (result_type
, 1) = builtin_type_int
; /* FIXME */
714 TYPE_FLAGS (result_type
) |= TYPE_FLAG_UNSIGNED
;
716 return (result_type
);
719 /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type
720 TYPE. Return 1 if type is a range type, 0 if it is discrete (and
721 bounds will fit in LONGEST), or -1 otherwise. */
724 get_discrete_bounds (struct type
*type
, LONGEST
*lowp
, LONGEST
*highp
)
726 CHECK_TYPEDEF (type
);
727 switch (TYPE_CODE (type
))
729 case TYPE_CODE_RANGE
:
730 *lowp
= TYPE_LOW_BOUND (type
);
731 *highp
= TYPE_HIGH_BOUND (type
);
734 if (TYPE_NFIELDS (type
) > 0)
736 /* The enums may not be sorted by value, so search all
740 *lowp
= *highp
= TYPE_FIELD_BITPOS (type
, 0);
741 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
743 if (TYPE_FIELD_BITPOS (type
, i
) < *lowp
)
744 *lowp
= TYPE_FIELD_BITPOS (type
, i
);
745 if (TYPE_FIELD_BITPOS (type
, i
) > *highp
)
746 *highp
= TYPE_FIELD_BITPOS (type
, i
);
749 /* Set unsigned indicator if warranted. */
752 TYPE_FLAGS (type
) |= TYPE_FLAG_UNSIGNED
;
766 if (TYPE_LENGTH (type
) > sizeof (LONGEST
)) /* Too big */
768 if (!TYPE_UNSIGNED (type
))
770 *lowp
= -(1 << (TYPE_LENGTH (type
) * TARGET_CHAR_BIT
- 1));
774 /* ... fall through for unsigned ints ... */
777 /* This round-about calculation is to avoid shifting by
778 TYPE_LENGTH (type) * TARGET_CHAR_BIT, which will not work
779 if TYPE_LENGTH (type) == sizeof (LONGEST). */
780 *highp
= 1 << (TYPE_LENGTH (type
) * TARGET_CHAR_BIT
- 1);
781 *highp
= (*highp
- 1) | *highp
;
788 /* Create an array type using either a blank type supplied in
789 RESULT_TYPE, or creating a new type, inheriting the objfile from
792 Elements will be of type ELEMENT_TYPE, the indices will be of type
795 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
796 sure it is TYPE_CODE_UNDEF before we bash it into an array
800 create_array_type (struct type
*result_type
,
801 struct type
*element_type
,
802 struct type
*range_type
)
804 LONGEST low_bound
, high_bound
;
806 if (result_type
== NULL
)
808 result_type
= alloc_type (TYPE_OBJFILE (range_type
));
810 TYPE_CODE (result_type
) = TYPE_CODE_ARRAY
;
811 TYPE_TARGET_TYPE (result_type
) = element_type
;
812 if (get_discrete_bounds (range_type
, &low_bound
, &high_bound
) < 0)
813 low_bound
= high_bound
= 0;
814 CHECK_TYPEDEF (element_type
);
815 TYPE_LENGTH (result_type
) =
816 TYPE_LENGTH (element_type
) * (high_bound
- low_bound
+ 1);
817 TYPE_NFIELDS (result_type
) = 1;
818 TYPE_FIELDS (result_type
) =
819 (struct field
*) TYPE_ALLOC (result_type
, sizeof (struct field
));
820 memset (TYPE_FIELDS (result_type
), 0, sizeof (struct field
));
821 TYPE_FIELD_TYPE (result_type
, 0) = range_type
;
822 TYPE_VPTR_FIELDNO (result_type
) = -1;
824 /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays */
825 if (TYPE_LENGTH (result_type
) == 0)
826 TYPE_FLAGS (result_type
) |= TYPE_FLAG_TARGET_STUB
;
828 return (result_type
);
831 /* Create a string type using either a blank type supplied in
832 RESULT_TYPE, or creating a new type. String types are similar
833 enough to array of char types that we can use create_array_type to
834 build the basic type and then bash it into a string type.
836 For fixed length strings, the range type contains 0 as the lower
837 bound and the length of the string minus one as the upper bound.
839 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
840 sure it is TYPE_CODE_UNDEF before we bash it into a string
844 create_string_type (struct type
*result_type
,
845 struct type
*range_type
)
847 struct type
*string_char_type
;
849 string_char_type
= language_string_char_type (current_language
,
851 result_type
= create_array_type (result_type
,
854 TYPE_CODE (result_type
) = TYPE_CODE_STRING
;
855 return (result_type
);
859 create_set_type (struct type
*result_type
, struct type
*domain_type
)
861 if (result_type
== NULL
)
863 result_type
= alloc_type (TYPE_OBJFILE (domain_type
));
865 TYPE_CODE (result_type
) = TYPE_CODE_SET
;
866 TYPE_NFIELDS (result_type
) = 1;
867 TYPE_FIELDS (result_type
) = (struct field
*)
868 TYPE_ALLOC (result_type
, 1 * sizeof (struct field
));
869 memset (TYPE_FIELDS (result_type
), 0, sizeof (struct field
));
871 if (!TYPE_STUB (domain_type
))
873 LONGEST low_bound
, high_bound
, bit_length
;
874 if (get_discrete_bounds (domain_type
, &low_bound
, &high_bound
) < 0)
875 low_bound
= high_bound
= 0;
876 bit_length
= high_bound
- low_bound
+ 1;
877 TYPE_LENGTH (result_type
)
878 = (bit_length
+ TARGET_CHAR_BIT
- 1) / TARGET_CHAR_BIT
;
880 TYPE_FLAGS (result_type
) |= TYPE_FLAG_UNSIGNED
;
882 TYPE_FIELD_TYPE (result_type
, 0) = domain_type
;
884 return (result_type
);
888 append_flags_type_flag (struct type
*type
, int bitpos
, char *name
)
890 gdb_assert (TYPE_CODE (type
) == TYPE_CODE_FLAGS
);
891 gdb_assert (bitpos
< TYPE_NFIELDS (type
));
892 gdb_assert (bitpos
>= 0);
896 TYPE_FIELD_NAME (type
, bitpos
) = xstrdup (name
);
897 TYPE_FIELD_BITPOS (type
, bitpos
) = bitpos
;
901 /* Don't show this field to the user. */
902 TYPE_FIELD_BITPOS (type
, bitpos
) = -1;
907 init_flags_type (char *name
, int length
)
909 int nfields
= length
* TARGET_CHAR_BIT
;
912 type
= init_type (TYPE_CODE_FLAGS
, length
,
913 TYPE_FLAG_UNSIGNED
, name
, NULL
);
914 TYPE_NFIELDS (type
) = nfields
;
915 TYPE_FIELDS (type
) = TYPE_ALLOC (type
,
916 nfields
* sizeof (struct field
));
917 memset (TYPE_FIELDS (type
), 0, nfields
* sizeof (struct field
));
923 init_vector_type (struct type
*elt_type
, int n
)
925 struct type
*array_type
;
927 array_type
= create_array_type (0, elt_type
,
928 create_range_type (0,
931 TYPE_FLAGS (array_type
) |= TYPE_FLAG_VECTOR
;
935 /* Smash TYPE to be a type of pointers to members of DOMAIN with type
936 TO_TYPE. A member pointer is a wierd thing -- it amounts to a
937 typed offset into a struct, e.g. "an int at offset 8". A MEMBER
938 TYPE doesn't include the offset (that's the value of the MEMBER
939 itself), but does include the structure type into which it points
942 When "smashing" the type, we preserve the objfile that the old type
943 pointed to, since we aren't changing where the type is actually
947 smash_to_memberptr_type (struct type
*type
, struct type
*domain
,
948 struct type
*to_type
)
950 struct objfile
*objfile
;
952 objfile
= TYPE_OBJFILE (type
);
955 TYPE_OBJFILE (type
) = objfile
;
956 TYPE_TARGET_TYPE (type
) = to_type
;
957 TYPE_DOMAIN_TYPE (type
) = domain
;
958 /* Assume that a data member pointer is the same size as a normal
960 TYPE_LENGTH (type
) = gdbarch_ptr_bit (current_gdbarch
) / TARGET_CHAR_BIT
;
961 TYPE_CODE (type
) = TYPE_CODE_MEMBERPTR
;
964 /* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE.
965 METHOD just means `function that gets an extra "this" argument'.
967 When "smashing" the type, we preserve the objfile that the old type
968 pointed to, since we aren't changing where the type is actually
972 smash_to_method_type (struct type
*type
, struct type
*domain
,
973 struct type
*to_type
, struct field
*args
,
974 int nargs
, int varargs
)
976 struct objfile
*objfile
;
978 objfile
= TYPE_OBJFILE (type
);
981 TYPE_OBJFILE (type
) = objfile
;
982 TYPE_TARGET_TYPE (type
) = to_type
;
983 TYPE_DOMAIN_TYPE (type
) = domain
;
984 TYPE_FIELDS (type
) = args
;
985 TYPE_NFIELDS (type
) = nargs
;
987 TYPE_FLAGS (type
) |= TYPE_FLAG_VARARGS
;
988 TYPE_LENGTH (type
) = 1; /* In practice, this is never needed. */
989 TYPE_CODE (type
) = TYPE_CODE_METHOD
;
992 /* Return a typename for a struct/union/enum type without "struct ",
993 "union ", or "enum ". If the type has a NULL name, return NULL. */
996 type_name_no_tag (const struct type
*type
)
998 if (TYPE_TAG_NAME (type
) != NULL
)
999 return TYPE_TAG_NAME (type
);
1001 /* Is there code which expects this to return the name if there is
1002 no tag name? My guess is that this is mainly used for C++ in
1003 cases where the two will always be the same. */
1004 return TYPE_NAME (type
);
1007 /* Lookup a typedef or primitive type named NAME, visible in lexical
1008 block BLOCK. If NOERR is nonzero, return zero if NAME is not
1009 suitably defined. */
1012 lookup_typename (char *name
, struct block
*block
, int noerr
)
1017 sym
= lookup_symbol (name
, block
, VAR_DOMAIN
, 0,
1018 (struct symtab
**) NULL
);
1019 if (sym
== NULL
|| SYMBOL_CLASS (sym
) != LOC_TYPEDEF
)
1021 tmp
= language_lookup_primitive_type_by_name (current_language
,
1028 else if (!tmp
&& noerr
)
1034 error (_("No type named %s."), name
);
1037 return (SYMBOL_TYPE (sym
));
1041 lookup_unsigned_typename (char *name
)
1043 char *uns
= alloca (strlen (name
) + 10);
1045 strcpy (uns
, "unsigned ");
1046 strcpy (uns
+ 9, name
);
1047 return (lookup_typename (uns
, (struct block
*) NULL
, 0));
1051 lookup_signed_typename (char *name
)
1054 char *uns
= alloca (strlen (name
) + 8);
1056 strcpy (uns
, "signed ");
1057 strcpy (uns
+ 7, name
);
1058 t
= lookup_typename (uns
, (struct block
*) NULL
, 1);
1059 /* If we don't find "signed FOO" just try again with plain "FOO". */
1062 return lookup_typename (name
, (struct block
*) NULL
, 0);
1065 /* Lookup a structure type named "struct NAME",
1066 visible in lexical block BLOCK. */
1069 lookup_struct (char *name
, struct block
*block
)
1073 sym
= lookup_symbol (name
, block
, STRUCT_DOMAIN
, 0,
1074 (struct symtab
**) NULL
);
1078 error (_("No struct type named %s."), name
);
1080 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_STRUCT
)
1082 error (_("This context has class, union or enum %s, not a struct."),
1085 return (SYMBOL_TYPE (sym
));
1088 /* Lookup a union type named "union NAME",
1089 visible in lexical block BLOCK. */
1092 lookup_union (char *name
, struct block
*block
)
1097 sym
= lookup_symbol (name
, block
, STRUCT_DOMAIN
, 0,
1098 (struct symtab
**) NULL
);
1101 error (_("No union type named %s."), name
);
1103 t
= SYMBOL_TYPE (sym
);
1105 if (TYPE_CODE (t
) == TYPE_CODE_UNION
)
1108 /* C++ unions may come out with TYPE_CODE_CLASS, but we look at
1109 * a further "declared_type" field to discover it is really a union.
1111 if (HAVE_CPLUS_STRUCT (t
))
1112 if (TYPE_DECLARED_TYPE (t
) == DECLARED_TYPE_UNION
)
1115 /* If we get here, it's not a union. */
1116 error (_("This context has class, struct or enum %s, not a union."),
1121 /* Lookup an enum type named "enum NAME",
1122 visible in lexical block BLOCK. */
1125 lookup_enum (char *name
, struct block
*block
)
1129 sym
= lookup_symbol (name
, block
, STRUCT_DOMAIN
, 0,
1130 (struct symtab
**) NULL
);
1133 error (_("No enum type named %s."), name
);
1135 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_ENUM
)
1137 error (_("This context has class, struct or union %s, not an enum."),
1140 return (SYMBOL_TYPE (sym
));
1143 /* Lookup a template type named "template NAME<TYPE>",
1144 visible in lexical block BLOCK. */
1147 lookup_template_type (char *name
, struct type
*type
,
1148 struct block
*block
)
1151 char *nam
= (char *)
1152 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,
1159 (struct symtab
**) NULL
);
1163 error (_("No template type named %s."), name
);
1165 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_STRUCT
)
1167 error (_("This context has class, union or enum %s, not a struct."),
1170 return (SYMBOL_TYPE (sym
));
1173 /* Given a type TYPE, lookup the type of the component of type named
1176 TYPE can be either a struct or union, or a pointer or reference to
1177 a struct or union. If it is a pointer or reference, its target
1178 type is automatically used. Thus '.' and '->' are interchangable,
1179 as specified for the definitions of the expression element types
1180 STRUCTOP_STRUCT and STRUCTOP_PTR.
1182 If NOERR is nonzero, return zero if NAME is not suitably defined.
1183 If NAME is the name of a baseclass type, return that type. */
1186 lookup_struct_elt_type (struct type
*type
, char *name
, int noerr
)
1192 CHECK_TYPEDEF (type
);
1193 if (TYPE_CODE (type
) != TYPE_CODE_PTR
1194 && TYPE_CODE (type
) != TYPE_CODE_REF
)
1196 type
= TYPE_TARGET_TYPE (type
);
1199 if (TYPE_CODE (type
) != TYPE_CODE_STRUCT
1200 && TYPE_CODE (type
) != TYPE_CODE_UNION
)
1202 target_terminal_ours ();
1203 gdb_flush (gdb_stdout
);
1204 fprintf_unfiltered (gdb_stderr
, "Type ");
1205 type_print (type
, "", gdb_stderr
, -1);
1206 error (_(" is not a structure or union type."));
1210 /* FIXME: This change put in by Michael seems incorrect for the case
1211 where the structure tag name is the same as the member name.
1212 I.E. when doing "ptype bell->bar" for "struct foo { int bar; int
1213 foo; } bell;" Disabled by fnf. */
1217 typename
= type_name_no_tag (type
);
1218 if (typename
!= NULL
&& strcmp (typename
, name
) == 0)
1223 for (i
= TYPE_NFIELDS (type
) - 1; i
>= TYPE_N_BASECLASSES (type
); i
--)
1225 char *t_field_name
= TYPE_FIELD_NAME (type
, i
);
1227 if (t_field_name
&& (strcmp_iw (t_field_name
, name
) == 0))
1229 return TYPE_FIELD_TYPE (type
, i
);
1233 /* OK, it's not in this class. Recursively check the baseclasses. */
1234 for (i
= TYPE_N_BASECLASSES (type
) - 1; i
>= 0; i
--)
1238 t
= lookup_struct_elt_type (TYPE_BASECLASS (type
, i
), name
, 1);
1250 target_terminal_ours ();
1251 gdb_flush (gdb_stdout
);
1252 fprintf_unfiltered (gdb_stderr
, "Type ");
1253 type_print (type
, "", gdb_stderr
, -1);
1254 fprintf_unfiltered (gdb_stderr
, " has no component named ");
1255 fputs_filtered (name
, gdb_stderr
);
1257 return (struct type
*) -1; /* For lint */
1260 /* If possible, make the vptr_fieldno and vptr_basetype fields of TYPE
1261 valid. Callers should be aware that in some cases (for example,
1262 the type or one of its baseclasses is a stub type and we are
1263 debugging a .o file), this function will not be able to find the
1264 virtual function table pointer, and vptr_fieldno will remain -1 and
1265 vptr_basetype will remain NULL. */
1268 fill_in_vptr_fieldno (struct type
*type
)
1270 CHECK_TYPEDEF (type
);
1272 if (TYPE_VPTR_FIELDNO (type
) < 0)
1276 /* We must start at zero in case the first (and only) baseclass
1277 is virtual (and hence we cannot share the table pointer). */
1278 for (i
= 0; i
< TYPE_N_BASECLASSES (type
); i
++)
1280 struct type
*baseclass
= check_typedef (TYPE_BASECLASS (type
,
1282 fill_in_vptr_fieldno (baseclass
);
1283 if (TYPE_VPTR_FIELDNO (baseclass
) >= 0)
1285 TYPE_VPTR_FIELDNO (type
) = TYPE_VPTR_FIELDNO (baseclass
);
1286 TYPE_VPTR_BASETYPE (type
) = TYPE_VPTR_BASETYPE (baseclass
);
1293 /* Find the method and field indices for the destructor in class type T.
1294 Return 1 if the destructor was found, otherwise, return 0. */
1297 get_destructor_fn_field (struct type
*t
,
1303 for (i
= 0; i
< TYPE_NFN_FIELDS (t
); i
++)
1306 struct fn_field
*f
= TYPE_FN_FIELDLIST1 (t
, i
);
1308 for (j
= 0; j
< TYPE_FN_FIELDLIST_LENGTH (t
, i
); j
++)
1310 if (is_destructor_name (TYPE_FN_FIELD_PHYSNAME (f
, j
)) != 0)
1322 stub_noname_complaint (void)
1324 complaint (&symfile_complaints
, _("stub type has NULL name"));
1327 /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989.
1329 If this is a stubbed struct (i.e. declared as struct foo *), see if
1330 we can find a full definition in some other file. If so, copy this
1331 definition, so we can use it in future. There used to be a comment
1332 (but not any code) that if we don't find a full definition, we'd
1333 set a flag so we don't spend time in the future checking the same
1334 type. That would be a mistake, though--we might load in more
1335 symbols which contain a full definition for the type.
1337 This used to be coded as a macro, but I don't think it is called
1338 often enough to merit such treatment. */
1340 /* Find the real type of TYPE. This function returns the real type,
1341 after removing all layers of typedefs and completing opaque or stub
1342 types. Completion changes the TYPE argument, but stripping of
1343 typedefs does not. */
1346 check_typedef (struct type
*type
)
1348 struct type
*orig_type
= type
;
1349 int is_const
, is_volatile
;
1353 while (TYPE_CODE (type
) == TYPE_CODE_TYPEDEF
)
1355 if (!TYPE_TARGET_TYPE (type
))
1360 /* It is dangerous to call lookup_symbol if we are currently
1361 reading a symtab. Infinite recursion is one danger. */
1362 if (currently_reading_symtab
)
1365 name
= type_name_no_tag (type
);
1366 /* FIXME: shouldn't we separately check the TYPE_NAME and
1367 the TYPE_TAG_NAME, and look in STRUCT_DOMAIN and/or
1368 VAR_DOMAIN as appropriate? (this code was written before
1369 TYPE_NAME and TYPE_TAG_NAME were separate). */
1372 stub_noname_complaint ();
1375 sym
= lookup_symbol (name
, 0, STRUCT_DOMAIN
, 0,
1376 (struct symtab
**) NULL
);
1378 TYPE_TARGET_TYPE (type
) = SYMBOL_TYPE (sym
);
1379 else /* TYPE_CODE_UNDEF */
1380 TYPE_TARGET_TYPE (type
) = alloc_type (NULL
);
1382 type
= TYPE_TARGET_TYPE (type
);
1385 is_const
= TYPE_CONST (type
);
1386 is_volatile
= TYPE_VOLATILE (type
);
1388 /* If this is a struct/class/union with no fields, then check
1389 whether a full definition exists somewhere else. This is for
1390 systems where a type definition with no fields is issued for such
1391 types, instead of identifying them as stub types in the first
1394 if (TYPE_IS_OPAQUE (type
)
1395 && opaque_type_resolution
1396 && !currently_reading_symtab
)
1398 char *name
= type_name_no_tag (type
);
1399 struct type
*newtype
;
1402 stub_noname_complaint ();
1405 newtype
= lookup_transparent_type (name
);
1409 /* If the resolved type and the stub are in the same
1410 objfile, then replace the stub type with the real deal.
1411 But if they're in separate objfiles, leave the stub
1412 alone; we'll just look up the transparent type every time
1413 we call check_typedef. We can't create pointers between
1414 types allocated to different objfiles, since they may
1415 have different lifetimes. Trying to copy NEWTYPE over to
1416 TYPE's objfile is pointless, too, since you'll have to
1417 move over any other types NEWTYPE refers to, which could
1418 be an unbounded amount of stuff. */
1419 if (TYPE_OBJFILE (newtype
) == TYPE_OBJFILE (type
))
1420 make_cv_type (is_const
, is_volatile
, newtype
, &type
);
1425 /* Otherwise, rely on the stub flag being set for opaque/stubbed
1427 else if (TYPE_STUB (type
) && !currently_reading_symtab
)
1429 char *name
= type_name_no_tag (type
);
1430 /* FIXME: shouldn't we separately check the TYPE_NAME and the
1431 TYPE_TAG_NAME, and look in STRUCT_DOMAIN and/or VAR_DOMAIN
1432 as appropriate? (this code was written before TYPE_NAME and
1433 TYPE_TAG_NAME were separate). */
1437 stub_noname_complaint ();
1440 sym
= lookup_symbol (name
, 0, STRUCT_DOMAIN
,
1441 0, (struct symtab
**) NULL
);
1444 /* Same as above for opaque types, we can replace the stub
1445 with the complete type only if they are int the same
1447 if (TYPE_OBJFILE (SYMBOL_TYPE(sym
)) == TYPE_OBJFILE (type
))
1448 make_cv_type (is_const
, is_volatile
,
1449 SYMBOL_TYPE (sym
), &type
);
1451 type
= SYMBOL_TYPE (sym
);
1455 if (TYPE_TARGET_STUB (type
))
1457 struct type
*range_type
;
1458 struct type
*target_type
= check_typedef (TYPE_TARGET_TYPE (type
));
1460 if (TYPE_STUB (target_type
) || TYPE_TARGET_STUB (target_type
))
1464 else if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
1465 && TYPE_NFIELDS (type
) == 1
1466 && (TYPE_CODE (range_type
= TYPE_FIELD_TYPE (type
, 0))
1467 == TYPE_CODE_RANGE
))
1469 /* Now recompute the length of the array type, based on its
1470 number of elements and the target type's length. */
1471 TYPE_LENGTH (type
) =
1472 ((TYPE_FIELD_BITPOS (range_type
, 1)
1473 - TYPE_FIELD_BITPOS (range_type
, 0) + 1)
1474 * TYPE_LENGTH (target_type
));
1475 TYPE_FLAGS (type
) &= ~TYPE_FLAG_TARGET_STUB
;
1477 else if (TYPE_CODE (type
) == TYPE_CODE_RANGE
)
1479 TYPE_LENGTH (type
) = TYPE_LENGTH (target_type
);
1480 TYPE_FLAGS (type
) &= ~TYPE_FLAG_TARGET_STUB
;
1483 /* Cache TYPE_LENGTH for future use. */
1484 TYPE_LENGTH (orig_type
) = TYPE_LENGTH (type
);
1488 /* Parse a type expression in the string [P..P+LENGTH). If an error
1489 occurs, silently return builtin_type_void. */
1491 static struct type
*
1492 safe_parse_type (char *p
, int length
)
1494 struct ui_file
*saved_gdb_stderr
;
1497 /* Suppress error messages. */
1498 saved_gdb_stderr
= gdb_stderr
;
1499 gdb_stderr
= ui_file_new ();
1501 /* Call parse_and_eval_type() without fear of longjmp()s. */
1502 if (!gdb_parse_and_eval_type (p
, length
, &type
))
1503 type
= builtin_type_void
;
1505 /* Stop suppressing error messages. */
1506 ui_file_delete (gdb_stderr
);
1507 gdb_stderr
= saved_gdb_stderr
;
1512 /* Ugly hack to convert method stubs into method types.
1514 He ain't kiddin'. This demangles the name of the method into a
1515 string including argument types, parses out each argument type,
1516 generates a string casting a zero to that type, evaluates the
1517 string, and stuffs the resulting type into an argtype vector!!!
1518 Then it knows the type of the whole function (including argument
1519 types for overloading), which info used to be in the stab's but was
1520 removed to hack back the space required for them. */
1523 check_stub_method (struct type
*type
, int method_id
, int signature_id
)
1526 char *mangled_name
= gdb_mangle_name (type
, method_id
, signature_id
);
1527 char *demangled_name
= cplus_demangle (mangled_name
,
1528 DMGL_PARAMS
| DMGL_ANSI
);
1529 char *argtypetext
, *p
;
1530 int depth
= 0, argcount
= 1;
1531 struct field
*argtypes
;
1534 /* Make sure we got back a function string that we can use. */
1536 p
= strchr (demangled_name
, '(');
1540 if (demangled_name
== NULL
|| p
== NULL
)
1541 error (_("Internal: Cannot demangle mangled name `%s'."),
1544 /* Now, read in the parameters that define this type. */
1549 if (*p
== '(' || *p
== '<')
1553 else if (*p
== ')' || *p
== '>')
1557 else if (*p
== ',' && depth
== 0)
1565 /* If we read one argument and it was ``void'', don't count it. */
1566 if (strncmp (argtypetext
, "(void)", 6) == 0)
1569 /* We need one extra slot, for the THIS pointer. */
1571 argtypes
= (struct field
*)
1572 TYPE_ALLOC (type
, (argcount
+ 1) * sizeof (struct field
));
1575 /* Add THIS pointer for non-static methods. */
1576 f
= TYPE_FN_FIELDLIST1 (type
, method_id
);
1577 if (TYPE_FN_FIELD_STATIC_P (f
, signature_id
))
1581 argtypes
[0].type
= lookup_pointer_type (type
);
1585 if (*p
!= ')') /* () means no args, skip while */
1590 if (depth
<= 0 && (*p
== ',' || *p
== ')'))
1592 /* Avoid parsing of ellipsis, they will be handled below.
1593 Also avoid ``void'' as above. */
1594 if (strncmp (argtypetext
, "...", p
- argtypetext
) != 0
1595 && strncmp (argtypetext
, "void", p
- argtypetext
) != 0)
1597 argtypes
[argcount
].type
=
1598 safe_parse_type (argtypetext
, p
- argtypetext
);
1601 argtypetext
= p
+ 1;
1604 if (*p
== '(' || *p
== '<')
1608 else if (*p
== ')' || *p
== '>')
1617 TYPE_FN_FIELD_PHYSNAME (f
, signature_id
) = mangled_name
;
1619 /* Now update the old "stub" type into a real type. */
1620 mtype
= TYPE_FN_FIELD_TYPE (f
, signature_id
);
1621 TYPE_DOMAIN_TYPE (mtype
) = type
;
1622 TYPE_FIELDS (mtype
) = argtypes
;
1623 TYPE_NFIELDS (mtype
) = argcount
;
1624 TYPE_FLAGS (mtype
) &= ~TYPE_FLAG_STUB
;
1625 TYPE_FN_FIELD_STUB (f
, signature_id
) = 0;
1627 TYPE_FLAGS (mtype
) |= TYPE_FLAG_VARARGS
;
1629 xfree (demangled_name
);
1632 /* This is the external interface to check_stub_method, above. This
1633 function unstubs all of the signatures for TYPE's METHOD_ID method
1634 name. After calling this function TYPE_FN_FIELD_STUB will be
1635 cleared for each signature and TYPE_FN_FIELDLIST_NAME will be
1638 This function unfortunately can not die until stabs do. */
1641 check_stub_method_group (struct type
*type
, int method_id
)
1643 int len
= TYPE_FN_FIELDLIST_LENGTH (type
, method_id
);
1644 struct fn_field
*f
= TYPE_FN_FIELDLIST1 (type
, method_id
);
1645 int j
, found_stub
= 0;
1647 for (j
= 0; j
< len
; j
++)
1648 if (TYPE_FN_FIELD_STUB (f
, j
))
1651 check_stub_method (type
, method_id
, j
);
1654 /* GNU v3 methods with incorrect names were corrected when we read
1655 in type information, because it was cheaper to do it then. The
1656 only GNU v2 methods with incorrect method names are operators and
1657 destructors; destructors were also corrected when we read in type
1660 Therefore the only thing we need to handle here are v2 operator
1662 if (found_stub
&& strncmp (TYPE_FN_FIELD_PHYSNAME (f
, 0), "_Z", 2) != 0)
1665 char dem_opname
[256];
1667 ret
= cplus_demangle_opname (TYPE_FN_FIELDLIST_NAME (type
,
1669 dem_opname
, DMGL_ANSI
);
1671 ret
= cplus_demangle_opname (TYPE_FN_FIELDLIST_NAME (type
,
1675 TYPE_FN_FIELDLIST_NAME (type
, method_id
) = xstrdup (dem_opname
);
1679 const struct cplus_struct_type cplus_struct_default
;
1682 allocate_cplus_struct_type (struct type
*type
)
1684 if (!HAVE_CPLUS_STRUCT (type
))
1686 TYPE_CPLUS_SPECIFIC (type
) = (struct cplus_struct_type
*)
1687 TYPE_ALLOC (type
, sizeof (struct cplus_struct_type
));
1688 *(TYPE_CPLUS_SPECIFIC (type
)) = cplus_struct_default
;
1692 /* Helper function to initialize the standard scalar types.
1694 If NAME is non-NULL and OBJFILE is non-NULL, then we make a copy of
1695 the string pointed to by name in the objfile_obstack for that
1696 objfile, and initialize the type name to that copy. There are
1697 places (mipsread.c in particular, where init_type is called with a
1698 NULL value for NAME). */
1701 init_type (enum type_code code
, int length
, int flags
,
1702 char *name
, struct objfile
*objfile
)
1706 type
= alloc_type (objfile
);
1707 TYPE_CODE (type
) = code
;
1708 TYPE_LENGTH (type
) = length
;
1709 TYPE_FLAGS (type
) |= flags
;
1710 if ((name
!= NULL
) && (objfile
!= NULL
))
1712 TYPE_NAME (type
) = obsavestring (name
, strlen (name
),
1713 &objfile
->objfile_obstack
);
1717 TYPE_NAME (type
) = name
;
1722 if (name
&& strcmp (name
, "char") == 0)
1723 TYPE_FLAGS (type
) |= TYPE_FLAG_NOSIGN
;
1725 if (code
== TYPE_CODE_STRUCT
|| code
== TYPE_CODE_UNION
1726 || code
== TYPE_CODE_NAMESPACE
)
1728 INIT_CPLUS_SPECIFIC (type
);
1733 /* Helper function. Create an empty composite type. */
1736 init_composite_type (char *name
, enum type_code code
)
1739 gdb_assert (code
== TYPE_CODE_STRUCT
1740 || code
== TYPE_CODE_UNION
);
1741 t
= init_type (code
, 0, 0, NULL
, NULL
);
1742 TYPE_TAG_NAME (t
) = name
;
1746 /* Helper function. Append a field to a composite type. */
1749 append_composite_type_field (struct type
*t
, char *name
,
1753 TYPE_NFIELDS (t
) = TYPE_NFIELDS (t
) + 1;
1754 TYPE_FIELDS (t
) = xrealloc (TYPE_FIELDS (t
),
1755 sizeof (struct field
) * TYPE_NFIELDS (t
));
1756 f
= &(TYPE_FIELDS (t
)[TYPE_NFIELDS (t
) - 1]);
1757 memset (f
, 0, sizeof f
[0]);
1758 FIELD_TYPE (f
[0]) = field
;
1759 FIELD_NAME (f
[0]) = name
;
1760 if (TYPE_CODE (t
) == TYPE_CODE_UNION
)
1762 if (TYPE_LENGTH (t
) < TYPE_LENGTH (field
))
1763 TYPE_LENGTH (t
) = TYPE_LENGTH (field
);
1765 else if (TYPE_CODE (t
) == TYPE_CODE_STRUCT
)
1767 TYPE_LENGTH (t
) = TYPE_LENGTH (t
) + TYPE_LENGTH (field
);
1768 if (TYPE_NFIELDS (t
) > 1)
1770 FIELD_BITPOS (f
[0]) = (FIELD_BITPOS (f
[-1])
1771 + TYPE_LENGTH (field
) * TARGET_CHAR_BIT
);
1776 /* Look up a fundamental type for the specified objfile.
1777 May need to construct such a type if this is the first use.
1779 Some object file formats (ELF, COFF, etc) do not define fundamental
1780 types such as "int" or "double". Others (stabs for example), do
1781 define fundamental types.
1783 For the formats which don't provide fundamental types, gdb can
1784 create such types, using defaults reasonable for the current
1785 language and the current target machine.
1787 NOTE: This routine is obsolescent. Each debugging format reader
1788 should manage it's own fundamental types, either creating them from
1789 suitable defaults or reading them from the debugging information,
1790 whichever is appropriate. The DWARF reader has already been fixed
1791 to do this. Once the other readers are fixed, this routine will go
1792 away. Also note that fundamental types should be managed on a
1793 compilation unit basis in a multi-language environment, not on a
1794 linkage unit basis as is done here. */
1798 lookup_fundamental_type (struct objfile
*objfile
, int typeid)
1800 struct type
**typep
;
1803 if (typeid < 0 || typeid >= FT_NUM_MEMBERS
)
1805 error (_("internal error - invalid fundamental type id %d"),
1809 /* If this is the first time we need a fundamental type for this
1810 objfile then we need to initialize the vector of type
1813 if (objfile
->fundamental_types
== NULL
)
1815 nbytes
= FT_NUM_MEMBERS
* sizeof (struct type
*);
1816 objfile
->fundamental_types
= (struct type
**)
1817 obstack_alloc (&objfile
->objfile_obstack
, nbytes
);
1818 memset ((char *) objfile
->fundamental_types
, 0, nbytes
);
1819 OBJSTAT (objfile
, n_types
+= FT_NUM_MEMBERS
);
1822 /* Look for this particular type in the fundamental type vector. If
1823 one is not found, create and install one appropriate for the
1824 current language. */
1826 typep
= objfile
->fundamental_types
+ typeid;
1829 *typep
= create_fundamental_type (objfile
, typeid);
1836 can_dereference (struct type
*t
)
1838 /* FIXME: Should we return true for references as well as
1843 && TYPE_CODE (t
) == TYPE_CODE_PTR
1844 && TYPE_CODE (TYPE_TARGET_TYPE (t
)) != TYPE_CODE_VOID
);
1848 is_integral_type (struct type
*t
)
1853 && ((TYPE_CODE (t
) == TYPE_CODE_INT
)
1854 || (TYPE_CODE (t
) == TYPE_CODE_ENUM
)
1855 || (TYPE_CODE (t
) == TYPE_CODE_FLAGS
)
1856 || (TYPE_CODE (t
) == TYPE_CODE_CHAR
)
1857 || (TYPE_CODE (t
) == TYPE_CODE_RANGE
)
1858 || (TYPE_CODE (t
) == TYPE_CODE_BOOL
)));
1861 /* Check whether BASE is an ancestor or base class or DCLASS
1862 Return 1 if so, and 0 if not.
1863 Note: callers may want to check for identity of the types before
1864 calling this function -- identical types are considered to satisfy
1865 the ancestor relationship even if they're identical. */
1868 is_ancestor (struct type
*base
, struct type
*dclass
)
1872 CHECK_TYPEDEF (base
);
1873 CHECK_TYPEDEF (dclass
);
1877 if (TYPE_NAME (base
) && TYPE_NAME (dclass
)
1878 && !strcmp (TYPE_NAME (base
), TYPE_NAME (dclass
)))
1881 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1882 if (is_ancestor (base
, TYPE_BASECLASS (dclass
, i
)))
1890 /* See whether DCLASS has a virtual table. This routine is aimed at
1891 the HP/Taligent ANSI C++ runtime model, and may not work with other
1892 runtime models. Return 1 => Yes, 0 => No. */
1895 has_vtable (struct type
*dclass
)
1897 /* In the HP ANSI C++ runtime model, a class has a vtable only if it
1898 has virtual functions or virtual bases. */
1902 if (TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
1905 /* First check for the presence of virtual bases. */
1906 if (TYPE_FIELD_VIRTUAL_BITS (dclass
))
1907 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1908 if (B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass
), i
))
1911 /* Next check for virtual functions. */
1912 if (TYPE_FN_FIELDLISTS (dclass
))
1913 for (i
= 0; i
< TYPE_NFN_FIELDS (dclass
); i
++)
1914 if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass
, i
), 0))
1917 /* Recurse on non-virtual bases to see if any of them needs a
1919 if (TYPE_FIELD_VIRTUAL_BITS (dclass
))
1920 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1921 if ((!B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass
), i
))
1922 && (has_vtable (TYPE_FIELD_TYPE (dclass
, i
))))
1925 /* Well, maybe we don't need a virtual table. */
1929 /* Return a pointer to the "primary base class" of DCLASS.
1931 A NULL return indicates that DCLASS has no primary base, or that it
1932 couldn't be found (insufficient information).
1934 This routine is aimed at the HP/Taligent ANSI C++ runtime model,
1935 and may not work with other runtime models. */
1938 primary_base_class (struct type
*dclass
)
1940 /* In HP ANSI C++'s runtime model, a "primary base class" of a class
1941 is the first directly inherited, non-virtual base class that
1942 requires a virtual table. */
1946 if (TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
1949 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1950 if (!TYPE_FIELD_VIRTUAL (dclass
, i
)
1951 && has_vtable (TYPE_FIELD_TYPE (dclass
, i
)))
1952 return TYPE_FIELD_TYPE (dclass
, i
);
1957 /* Global manipulated by virtual_base_list[_aux](). */
1959 static struct vbase
*current_vbase_list
= NULL
;
1961 /* Return a pointer to a null-terminated list of struct vbase items.
1962 The vbasetype pointer of each item in the list points to the type
1963 information for a virtual base of the argument DCLASS.
1965 Helper function for virtual_base_list().
1966 Note: the list goes backward, right-to-left.
1967 virtual_base_list() copies the items out in reverse order. */
1970 virtual_base_list_aux (struct type
*dclass
)
1972 struct vbase
*tmp_vbase
;
1975 if (TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
1978 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1980 /* Recurse on this ancestor, first */
1981 virtual_base_list_aux (TYPE_FIELD_TYPE (dclass
, i
));
1983 /* If this current base is itself virtual, add it to the list */
1984 if (BASETYPE_VIA_VIRTUAL (dclass
, i
))
1986 struct type
*basetype
= TYPE_FIELD_TYPE (dclass
, i
);
1988 /* Check if base already recorded */
1989 tmp_vbase
= current_vbase_list
;
1992 if (tmp_vbase
->vbasetype
== basetype
)
1993 break; /* found it */
1994 tmp_vbase
= tmp_vbase
->next
;
1997 if (!tmp_vbase
) /* normal exit from loop */
1999 /* Allocate new item for this virtual base */
2000 tmp_vbase
= (struct vbase
*) xmalloc (sizeof (struct vbase
));
2002 /* Stick it on at the end of the list */
2003 tmp_vbase
->vbasetype
= basetype
;
2004 tmp_vbase
->next
= current_vbase_list
;
2005 current_vbase_list
= tmp_vbase
;
2008 } /* for loop over bases */
2012 /* Compute the list of virtual bases in the right order. Virtual
2013 bases are laid out in the object's memory area in order of their
2014 occurrence in a depth-first, left-to-right search through the
2017 Argument DCLASS is the type whose virtual bases are required.
2018 Return value is the address of a null-terminated array of pointers
2019 to struct type items.
2021 This routine is aimed at the HP/Taligent ANSI C++ runtime model,
2022 and may not work with other runtime models.
2024 This routine merely hands off the argument to virtual_base_list_aux()
2025 and then copies the result into an array to save space. */
2027 static struct type
**
2028 virtual_base_list (struct type
*dclass
)
2030 struct vbase
*tmp_vbase
;
2031 struct vbase
*tmp_vbase_2
;
2034 struct type
**vbase_array
;
2036 current_vbase_list
= NULL
;
2037 virtual_base_list_aux (dclass
);
2039 for (i
= 0, tmp_vbase
= current_vbase_list
;
2041 i
++, tmp_vbase
= tmp_vbase
->next
)
2046 vbase_array
= (struct type
**)
2047 xmalloc ((count
+ 1) * sizeof (struct type
*));
2049 for (i
= count
- 1, tmp_vbase
= current_vbase_list
;
2051 tmp_vbase
= tmp_vbase
->next
)
2052 vbase_array
[i
] = tmp_vbase
->vbasetype
;
2054 /* Get rid of constructed chain. */
2055 tmp_vbase_2
= tmp_vbase
= current_vbase_list
;
2058 tmp_vbase
= tmp_vbase
->next
;
2059 xfree (tmp_vbase_2
);
2060 tmp_vbase_2
= tmp_vbase
;
2063 vbase_array
[count
] = NULL
;
2067 /* Return the length of the virtual base list of the type DCLASS. */
2070 virtual_base_list_length (struct type
*dclass
)
2073 struct vbase
*tmp_vbase
;
2075 current_vbase_list
= NULL
;
2076 virtual_base_list_aux (dclass
);
2078 for (i
= 0, tmp_vbase
= current_vbase_list
;
2080 i
++, tmp_vbase
= tmp_vbase
->next
)
2085 /* Return the number of elements of the virtual base list of the type
2086 DCLASS, ignoring those appearing in the primary base (and its
2087 primary base, recursively). */
2090 virtual_base_list_length_skip_primaries (struct type
*dclass
)
2093 struct vbase
*tmp_vbase
;
2094 struct type
*primary
;
2096 primary
= TYPE_RUNTIME_PTR (dclass
) ? TYPE_PRIMARY_BASE (dclass
) : NULL
;
2099 return virtual_base_list_length (dclass
);
2101 current_vbase_list
= NULL
;
2102 virtual_base_list_aux (dclass
);
2104 for (i
= 0, tmp_vbase
= current_vbase_list
;
2106 tmp_vbase
= tmp_vbase
->next
)
2108 if (virtual_base_index (tmp_vbase
->vbasetype
, primary
) >= 0)
2115 /* Return the index (position) of type BASE, which is a virtual base
2116 class of DCLASS, in the latter's virtual base list. A return of -1
2117 indicates "not found" or a problem. */
2120 virtual_base_index (struct type
*base
, struct type
*dclass
)
2122 struct type
*vbase
, **vbase_list
;
2125 if ((TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
2126 || (TYPE_CODE (base
) != TYPE_CODE_CLASS
))
2129 vbase_list
= virtual_base_list (dclass
);
2130 for (i
= 0, vbase
= vbase_list
[0];
2132 vbase
= vbase_list
[++i
])
2137 return vbase
? i
: -1;
2140 /* Return the index (position) of type BASE, which is a virtual base
2141 class of DCLASS, in the latter's virtual base list. Skip over all
2142 bases that may appear in the virtual base list of the primary base
2143 class of DCLASS (recursively). A return of -1 indicates "not
2144 found" or a problem. */
2147 virtual_base_index_skip_primaries (struct type
*base
,
2148 struct type
*dclass
)
2150 struct type
*vbase
, **vbase_list
;
2152 struct type
*primary
;
2154 if ((TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
2155 || (TYPE_CODE (base
) != TYPE_CODE_CLASS
))
2158 primary
= TYPE_RUNTIME_PTR (dclass
) ? TYPE_PRIMARY_BASE (dclass
) : NULL
;
2160 vbase_list
= virtual_base_list (dclass
);
2161 for (i
= 0, j
= -1, vbase
= vbase_list
[0];
2163 vbase
= vbase_list
[++i
])
2166 || (virtual_base_index_skip_primaries (vbase
, primary
) < 0))
2172 return vbase
? j
: -1;
2175 /* Return position of a derived class DCLASS in the list of primary
2176 bases starting with the remotest ancestor. Position returned is
2180 class_index_in_primary_list (struct type
*dclass
)
2182 struct type
*pbc
; /* primary base class */
2184 /* Simply recurse on primary base */
2185 pbc
= TYPE_PRIMARY_BASE (dclass
);
2187 return 1 + class_index_in_primary_list (pbc
);
2192 /* Return a count of the number of virtual functions a type has. This
2193 includes all the virtual functions it inherits from its base
2196 /* pai: FIXME This doesn't do the right thing: count redefined virtual
2197 functions only once (latest redefinition). */
2200 count_virtual_fns (struct type
*dclass
)
2202 int fn
, oi
; /* function and overloaded instance indices */
2203 int vfuncs
; /* count to return */
2205 /* recurse on bases that can share virtual table */
2206 struct type
*pbc
= primary_base_class (dclass
);
2208 vfuncs
= count_virtual_fns (pbc
);
2212 for (fn
= 0; fn
< TYPE_NFN_FIELDS (dclass
); fn
++)
2213 for (oi
= 0; oi
< TYPE_FN_FIELDLIST_LENGTH (dclass
, fn
); oi
++)
2214 if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass
, fn
), oi
))
2222 /* Functions for overload resolution begin here */
2224 /* Compare two badness vectors A and B and return the result.
2225 0 => A and B are identical
2226 1 => A and B are incomparable
2227 2 => A is better than B
2228 3 => A is worse than B */
2231 compare_badness (struct badness_vector
*a
, struct badness_vector
*b
)
2235 short found_pos
= 0; /* any positives in c? */
2236 short found_neg
= 0; /* any negatives in c? */
2238 /* differing lengths => incomparable */
2239 if (a
->length
!= b
->length
)
2242 /* Subtract b from a */
2243 for (i
= 0; i
< a
->length
; i
++)
2245 tmp
= a
->rank
[i
] - b
->rank
[i
];
2255 return 1; /* incomparable */
2257 return 3; /* A > B */
2263 return 2; /* A < B */
2265 return 0; /* A == B */
2269 /* Rank a function by comparing its parameter types (PARMS, length
2270 NPARMS), to the types of an argument list (ARGS, length NARGS).
2271 Return a pointer to a badness vector. This has NARGS + 1
2274 struct badness_vector
*
2275 rank_function (struct type
**parms
, int nparms
,
2276 struct type
**args
, int nargs
)
2279 struct badness_vector
*bv
;
2280 int min_len
= nparms
< nargs
? nparms
: nargs
;
2282 bv
= xmalloc (sizeof (struct badness_vector
));
2283 bv
->length
= nargs
+ 1; /* add 1 for the length-match rank */
2284 bv
->rank
= xmalloc ((nargs
+ 1) * sizeof (int));
2286 /* First compare the lengths of the supplied lists.
2287 If there is a mismatch, set it to a high value. */
2289 /* pai/1997-06-03 FIXME: when we have debug info about default
2290 arguments and ellipsis parameter lists, we should consider those
2291 and rank the length-match more finely. */
2293 LENGTH_MATCH (bv
) = (nargs
!= nparms
) ? LENGTH_MISMATCH_BADNESS
: 0;
2295 /* Now rank all the parameters of the candidate function */
2296 for (i
= 1; i
<= min_len
; i
++)
2297 bv
->rank
[i
] = rank_one_type (parms
[i
-1], args
[i
-1]);
2299 /* If more arguments than parameters, add dummy entries */
2300 for (i
= min_len
+ 1; i
<= nargs
; i
++)
2301 bv
->rank
[i
] = TOO_FEW_PARAMS_BADNESS
;
2306 /* Compare the names of two integer types, assuming that any sign
2307 qualifiers have been checked already. We do it this way because
2308 there may be an "int" in the name of one of the types. */
2311 integer_types_same_name_p (const char *first
, const char *second
)
2313 int first_p
, second_p
;
2315 /* If both are shorts, return 1; if neither is a short, keep
2317 first_p
= (strstr (first
, "short") != NULL
);
2318 second_p
= (strstr (second
, "short") != NULL
);
2319 if (first_p
&& second_p
)
2321 if (first_p
|| second_p
)
2324 /* Likewise for long. */
2325 first_p
= (strstr (first
, "long") != NULL
);
2326 second_p
= (strstr (second
, "long") != NULL
);
2327 if (first_p
&& second_p
)
2329 if (first_p
|| second_p
)
2332 /* Likewise for char. */
2333 first_p
= (strstr (first
, "char") != NULL
);
2334 second_p
= (strstr (second
, "char") != NULL
);
2335 if (first_p
&& second_p
)
2337 if (first_p
|| second_p
)
2340 /* They must both be ints. */
2344 /* Compare one type (PARM) for compatibility with another (ARG).
2345 * PARM is intended to be the parameter type of a function; and
2346 * ARG is the supplied argument's type. This function tests if
2347 * the latter can be converted to the former.
2349 * Return 0 if they are identical types;
2350 * Otherwise, return an integer which corresponds to how compatible
2351 * PARM is to ARG. The higher the return value, the worse the match.
2352 * Generally the "bad" conversions are all uniformly assigned a 100. */
2355 rank_one_type (struct type
*parm
, struct type
*arg
)
2357 /* Identical type pointers. */
2358 /* However, this still doesn't catch all cases of same type for arg
2359 and param. The reason is that builtin types are different from
2360 the same ones constructed from the object. */
2364 /* Resolve typedefs */
2365 if (TYPE_CODE (parm
) == TYPE_CODE_TYPEDEF
)
2366 parm
= check_typedef (parm
);
2367 if (TYPE_CODE (arg
) == TYPE_CODE_TYPEDEF
)
2368 arg
= check_typedef (arg
);
2371 Well, damnit, if the names are exactly the same, I'll say they
2372 are exactly the same. This happens when we generate method
2373 stubs. The types won't point to the same address, but they
2374 really are the same.
2377 if (TYPE_NAME (parm
) && TYPE_NAME (arg
)
2378 && !strcmp (TYPE_NAME (parm
), TYPE_NAME (arg
)))
2381 /* Check if identical after resolving typedefs. */
2385 /* See through references, since we can almost make non-references
2387 if (TYPE_CODE (arg
) == TYPE_CODE_REF
)
2388 return (rank_one_type (parm
, TYPE_TARGET_TYPE (arg
))
2389 + REFERENCE_CONVERSION_BADNESS
);
2390 if (TYPE_CODE (parm
) == TYPE_CODE_REF
)
2391 return (rank_one_type (TYPE_TARGET_TYPE (parm
), arg
)
2392 + REFERENCE_CONVERSION_BADNESS
);
2394 /* Debugging only. */
2395 fprintf_filtered (gdb_stderr
,
2396 "------ Arg is %s [%d], parm is %s [%d]\n",
2397 TYPE_NAME (arg
), TYPE_CODE (arg
),
2398 TYPE_NAME (parm
), TYPE_CODE (parm
));
2400 /* x -> y means arg of type x being supplied for parameter of type y */
2402 switch (TYPE_CODE (parm
))
2405 switch (TYPE_CODE (arg
))
2408 if (TYPE_CODE (TYPE_TARGET_TYPE (parm
)) == TYPE_CODE_VOID
)
2409 return VOID_PTR_CONVERSION_BADNESS
;
2411 return rank_one_type (TYPE_TARGET_TYPE (parm
),
2412 TYPE_TARGET_TYPE (arg
));
2413 case TYPE_CODE_ARRAY
:
2414 return rank_one_type (TYPE_TARGET_TYPE (parm
),
2415 TYPE_TARGET_TYPE (arg
));
2416 case TYPE_CODE_FUNC
:
2417 return rank_one_type (TYPE_TARGET_TYPE (parm
), arg
);
2419 case TYPE_CODE_ENUM
:
2420 case TYPE_CODE_FLAGS
:
2421 case TYPE_CODE_CHAR
:
2422 case TYPE_CODE_RANGE
:
2423 case TYPE_CODE_BOOL
:
2424 return POINTER_CONVERSION_BADNESS
;
2426 return INCOMPATIBLE_TYPE_BADNESS
;
2428 case TYPE_CODE_ARRAY
:
2429 switch (TYPE_CODE (arg
))
2432 case TYPE_CODE_ARRAY
:
2433 return rank_one_type (TYPE_TARGET_TYPE (parm
),
2434 TYPE_TARGET_TYPE (arg
));
2436 return INCOMPATIBLE_TYPE_BADNESS
;
2438 case TYPE_CODE_FUNC
:
2439 switch (TYPE_CODE (arg
))
2441 case TYPE_CODE_PTR
: /* funcptr -> func */
2442 return rank_one_type (parm
, TYPE_TARGET_TYPE (arg
));
2444 return INCOMPATIBLE_TYPE_BADNESS
;
2447 switch (TYPE_CODE (arg
))
2450 if (TYPE_LENGTH (arg
) == TYPE_LENGTH (parm
))
2452 /* Deal with signed, unsigned, and plain chars and
2453 signed and unsigned ints. */
2454 if (TYPE_NOSIGN (parm
))
2456 /* This case only for character types */
2457 if (TYPE_NOSIGN (arg
))
2458 return 0; /* plain char -> plain char */
2459 else /* signed/unsigned char -> plain char */
2460 return INTEGER_CONVERSION_BADNESS
;
2462 else if (TYPE_UNSIGNED (parm
))
2464 if (TYPE_UNSIGNED (arg
))
2466 /* unsigned int -> unsigned int, or
2467 unsigned long -> unsigned long */
2468 if (integer_types_same_name_p (TYPE_NAME (parm
),
2471 else if (integer_types_same_name_p (TYPE_NAME (arg
),
2473 && integer_types_same_name_p (TYPE_NAME (parm
),
2475 return INTEGER_PROMOTION_BADNESS
; /* unsigned int -> unsigned long */
2477 return INTEGER_CONVERSION_BADNESS
; /* unsigned long -> unsigned int */
2481 if (integer_types_same_name_p (TYPE_NAME (arg
),
2483 && integer_types_same_name_p (TYPE_NAME (parm
),
2485 return INTEGER_CONVERSION_BADNESS
; /* signed long -> unsigned int */
2487 return INTEGER_CONVERSION_BADNESS
; /* signed int/long -> unsigned int/long */
2490 else if (!TYPE_NOSIGN (arg
) && !TYPE_UNSIGNED (arg
))
2492 if (integer_types_same_name_p (TYPE_NAME (parm
),
2495 else if (integer_types_same_name_p (TYPE_NAME (arg
),
2497 && integer_types_same_name_p (TYPE_NAME (parm
),
2499 return INTEGER_PROMOTION_BADNESS
;
2501 return INTEGER_CONVERSION_BADNESS
;
2504 return INTEGER_CONVERSION_BADNESS
;
2506 else if (TYPE_LENGTH (arg
) < TYPE_LENGTH (parm
))
2507 return INTEGER_PROMOTION_BADNESS
;
2509 return INTEGER_CONVERSION_BADNESS
;
2510 case TYPE_CODE_ENUM
:
2511 case TYPE_CODE_FLAGS
:
2512 case TYPE_CODE_CHAR
:
2513 case TYPE_CODE_RANGE
:
2514 case TYPE_CODE_BOOL
:
2515 return INTEGER_PROMOTION_BADNESS
;
2517 return INT_FLOAT_CONVERSION_BADNESS
;
2519 return NS_POINTER_CONVERSION_BADNESS
;
2521 return INCOMPATIBLE_TYPE_BADNESS
;
2524 case TYPE_CODE_ENUM
:
2525 switch (TYPE_CODE (arg
))
2528 case TYPE_CODE_CHAR
:
2529 case TYPE_CODE_RANGE
:
2530 case TYPE_CODE_BOOL
:
2531 case TYPE_CODE_ENUM
:
2532 return INTEGER_CONVERSION_BADNESS
;
2534 return INT_FLOAT_CONVERSION_BADNESS
;
2536 return INCOMPATIBLE_TYPE_BADNESS
;
2539 case TYPE_CODE_CHAR
:
2540 switch (TYPE_CODE (arg
))
2542 case TYPE_CODE_RANGE
:
2543 case TYPE_CODE_BOOL
:
2544 case TYPE_CODE_ENUM
:
2545 return INTEGER_CONVERSION_BADNESS
;
2547 return INT_FLOAT_CONVERSION_BADNESS
;
2549 if (TYPE_LENGTH (arg
) > TYPE_LENGTH (parm
))
2550 return INTEGER_CONVERSION_BADNESS
;
2551 else if (TYPE_LENGTH (arg
) < TYPE_LENGTH (parm
))
2552 return INTEGER_PROMOTION_BADNESS
;
2553 /* >>> !! else fall through !! <<< */
2554 case TYPE_CODE_CHAR
:
2555 /* Deal with signed, unsigned, and plain chars for C++ and
2556 with int cases falling through from previous case. */
2557 if (TYPE_NOSIGN (parm
))
2559 if (TYPE_NOSIGN (arg
))
2562 return INTEGER_CONVERSION_BADNESS
;
2564 else if (TYPE_UNSIGNED (parm
))
2566 if (TYPE_UNSIGNED (arg
))
2569 return INTEGER_PROMOTION_BADNESS
;
2571 else if (!TYPE_NOSIGN (arg
) && !TYPE_UNSIGNED (arg
))
2574 return INTEGER_CONVERSION_BADNESS
;
2576 return INCOMPATIBLE_TYPE_BADNESS
;
2579 case TYPE_CODE_RANGE
:
2580 switch (TYPE_CODE (arg
))
2583 case TYPE_CODE_CHAR
:
2584 case TYPE_CODE_RANGE
:
2585 case TYPE_CODE_BOOL
:
2586 case TYPE_CODE_ENUM
:
2587 return INTEGER_CONVERSION_BADNESS
;
2589 return INT_FLOAT_CONVERSION_BADNESS
;
2591 return INCOMPATIBLE_TYPE_BADNESS
;
2594 case TYPE_CODE_BOOL
:
2595 switch (TYPE_CODE (arg
))
2598 case TYPE_CODE_CHAR
:
2599 case TYPE_CODE_RANGE
:
2600 case TYPE_CODE_ENUM
:
2603 return BOOLEAN_CONVERSION_BADNESS
;
2604 case TYPE_CODE_BOOL
:
2607 return INCOMPATIBLE_TYPE_BADNESS
;
2611 switch (TYPE_CODE (arg
))
2614 if (TYPE_LENGTH (arg
) < TYPE_LENGTH (parm
))
2615 return FLOAT_PROMOTION_BADNESS
;
2616 else if (TYPE_LENGTH (arg
) == TYPE_LENGTH (parm
))
2619 return FLOAT_CONVERSION_BADNESS
;
2621 case TYPE_CODE_BOOL
:
2622 case TYPE_CODE_ENUM
:
2623 case TYPE_CODE_RANGE
:
2624 case TYPE_CODE_CHAR
:
2625 return INT_FLOAT_CONVERSION_BADNESS
;
2627 return INCOMPATIBLE_TYPE_BADNESS
;
2630 case TYPE_CODE_COMPLEX
:
2631 switch (TYPE_CODE (arg
))
2632 { /* Strictly not needed for C++, but... */
2634 return FLOAT_PROMOTION_BADNESS
;
2635 case TYPE_CODE_COMPLEX
:
2638 return INCOMPATIBLE_TYPE_BADNESS
;
2641 case TYPE_CODE_STRUCT
:
2642 /* currently same as TYPE_CODE_CLASS */
2643 switch (TYPE_CODE (arg
))
2645 case TYPE_CODE_STRUCT
:
2646 /* Check for derivation */
2647 if (is_ancestor (parm
, arg
))
2648 return BASE_CONVERSION_BADNESS
;
2649 /* else fall through */
2651 return INCOMPATIBLE_TYPE_BADNESS
;
2654 case TYPE_CODE_UNION
:
2655 switch (TYPE_CODE (arg
))
2657 case TYPE_CODE_UNION
:
2659 return INCOMPATIBLE_TYPE_BADNESS
;
2662 case TYPE_CODE_MEMBERPTR
:
2663 switch (TYPE_CODE (arg
))
2666 return INCOMPATIBLE_TYPE_BADNESS
;
2669 case TYPE_CODE_METHOD
:
2670 switch (TYPE_CODE (arg
))
2674 return INCOMPATIBLE_TYPE_BADNESS
;
2678 switch (TYPE_CODE (arg
))
2682 return INCOMPATIBLE_TYPE_BADNESS
;
2687 switch (TYPE_CODE (arg
))
2691 return rank_one_type (TYPE_FIELD_TYPE (parm
, 0),
2692 TYPE_FIELD_TYPE (arg
, 0));
2694 return INCOMPATIBLE_TYPE_BADNESS
;
2697 case TYPE_CODE_VOID
:
2699 return INCOMPATIBLE_TYPE_BADNESS
;
2700 } /* switch (TYPE_CODE (arg)) */
2704 /* End of functions for overload resolution */
2707 print_bit_vector (B_TYPE
*bits
, int nbits
)
2711 for (bitno
= 0; bitno
< nbits
; bitno
++)
2713 if ((bitno
% 8) == 0)
2715 puts_filtered (" ");
2717 if (B_TST (bits
, bitno
))
2718 printf_filtered (("1"));
2720 printf_filtered (("0"));
2724 /* Note the first arg should be the "this" pointer, we may not want to
2725 include it since we may get into a infinitely recursive
2729 print_arg_types (struct field
*args
, int nargs
, int spaces
)
2735 for (i
= 0; i
< nargs
; i
++)
2736 recursive_dump_type (args
[i
].type
, spaces
+ 2);
2741 dump_fn_fieldlists (struct type
*type
, int spaces
)
2747 printfi_filtered (spaces
, "fn_fieldlists ");
2748 gdb_print_host_address (TYPE_FN_FIELDLISTS (type
), gdb_stdout
);
2749 printf_filtered ("\n");
2750 for (method_idx
= 0; method_idx
< TYPE_NFN_FIELDS (type
); method_idx
++)
2752 f
= TYPE_FN_FIELDLIST1 (type
, method_idx
);
2753 printfi_filtered (spaces
+ 2, "[%d] name '%s' (",
2755 TYPE_FN_FIELDLIST_NAME (type
, method_idx
));
2756 gdb_print_host_address (TYPE_FN_FIELDLIST_NAME (type
, method_idx
),
2758 printf_filtered (_(") length %d\n"),
2759 TYPE_FN_FIELDLIST_LENGTH (type
, method_idx
));
2760 for (overload_idx
= 0;
2761 overload_idx
< TYPE_FN_FIELDLIST_LENGTH (type
, method_idx
);
2764 printfi_filtered (spaces
+ 4, "[%d] physname '%s' (",
2766 TYPE_FN_FIELD_PHYSNAME (f
, overload_idx
));
2767 gdb_print_host_address (TYPE_FN_FIELD_PHYSNAME (f
, overload_idx
),
2769 printf_filtered (")\n");
2770 printfi_filtered (spaces
+ 8, "type ");
2771 gdb_print_host_address (TYPE_FN_FIELD_TYPE (f
, overload_idx
),
2773 printf_filtered ("\n");
2775 recursive_dump_type (TYPE_FN_FIELD_TYPE (f
, overload_idx
),
2778 printfi_filtered (spaces
+ 8, "args ");
2779 gdb_print_host_address (TYPE_FN_FIELD_ARGS (f
, overload_idx
),
2781 printf_filtered ("\n");
2783 print_arg_types (TYPE_FN_FIELD_ARGS (f
, overload_idx
),
2784 TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (f
,
2787 printfi_filtered (spaces
+ 8, "fcontext ");
2788 gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f
, overload_idx
),
2790 printf_filtered ("\n");
2792 printfi_filtered (spaces
+ 8, "is_const %d\n",
2793 TYPE_FN_FIELD_CONST (f
, overload_idx
));
2794 printfi_filtered (spaces
+ 8, "is_volatile %d\n",
2795 TYPE_FN_FIELD_VOLATILE (f
, overload_idx
));
2796 printfi_filtered (spaces
+ 8, "is_private %d\n",
2797 TYPE_FN_FIELD_PRIVATE (f
, overload_idx
));
2798 printfi_filtered (spaces
+ 8, "is_protected %d\n",
2799 TYPE_FN_FIELD_PROTECTED (f
, overload_idx
));
2800 printfi_filtered (spaces
+ 8, "is_stub %d\n",
2801 TYPE_FN_FIELD_STUB (f
, overload_idx
));
2802 printfi_filtered (spaces
+ 8, "voffset %u\n",
2803 TYPE_FN_FIELD_VOFFSET (f
, overload_idx
));
2809 print_cplus_stuff (struct type
*type
, int spaces
)
2811 printfi_filtered (spaces
, "n_baseclasses %d\n",
2812 TYPE_N_BASECLASSES (type
));
2813 printfi_filtered (spaces
, "nfn_fields %d\n",
2814 TYPE_NFN_FIELDS (type
));
2815 printfi_filtered (spaces
, "nfn_fields_total %d\n",
2816 TYPE_NFN_FIELDS_TOTAL (type
));
2817 if (TYPE_N_BASECLASSES (type
) > 0)
2819 printfi_filtered (spaces
, "virtual_field_bits (%d bits at *",
2820 TYPE_N_BASECLASSES (type
));
2821 gdb_print_host_address (TYPE_FIELD_VIRTUAL_BITS (type
),
2823 printf_filtered (")");
2825 print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type
),
2826 TYPE_N_BASECLASSES (type
));
2827 puts_filtered ("\n");
2829 if (TYPE_NFIELDS (type
) > 0)
2831 if (TYPE_FIELD_PRIVATE_BITS (type
) != NULL
)
2833 printfi_filtered (spaces
,
2834 "private_field_bits (%d bits at *",
2835 TYPE_NFIELDS (type
));
2836 gdb_print_host_address (TYPE_FIELD_PRIVATE_BITS (type
),
2838 printf_filtered (")");
2839 print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type
),
2840 TYPE_NFIELDS (type
));
2841 puts_filtered ("\n");
2843 if (TYPE_FIELD_PROTECTED_BITS (type
) != NULL
)
2845 printfi_filtered (spaces
,
2846 "protected_field_bits (%d bits at *",
2847 TYPE_NFIELDS (type
));
2848 gdb_print_host_address (TYPE_FIELD_PROTECTED_BITS (type
),
2850 printf_filtered (")");
2851 print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type
),
2852 TYPE_NFIELDS (type
));
2853 puts_filtered ("\n");
2856 if (TYPE_NFN_FIELDS (type
) > 0)
2858 dump_fn_fieldlists (type
, spaces
);
2863 print_bound_type (int bt
)
2867 case BOUND_CANNOT_BE_DETERMINED
:
2868 printf_filtered ("(BOUND_CANNOT_BE_DETERMINED)");
2870 case BOUND_BY_REF_ON_STACK
:
2871 printf_filtered ("(BOUND_BY_REF_ON_STACK)");
2873 case BOUND_BY_VALUE_ON_STACK
:
2874 printf_filtered ("(BOUND_BY_VALUE_ON_STACK)");
2876 case BOUND_BY_REF_IN_REG
:
2877 printf_filtered ("(BOUND_BY_REF_IN_REG)");
2879 case BOUND_BY_VALUE_IN_REG
:
2880 printf_filtered ("(BOUND_BY_VALUE_IN_REG)");
2883 printf_filtered ("(BOUND_SIMPLE)");
2886 printf_filtered (_("(unknown bound type)"));
2891 static struct obstack dont_print_type_obstack
;
2894 recursive_dump_type (struct type
*type
, int spaces
)
2899 obstack_begin (&dont_print_type_obstack
, 0);
2901 if (TYPE_NFIELDS (type
) > 0
2902 || (TYPE_CPLUS_SPECIFIC (type
) && TYPE_NFN_FIELDS (type
) > 0))
2904 struct type
**first_dont_print
2905 = (struct type
**) obstack_base (&dont_print_type_obstack
);
2907 int i
= (struct type
**)
2908 obstack_next_free (&dont_print_type_obstack
) - first_dont_print
;
2912 if (type
== first_dont_print
[i
])
2914 printfi_filtered (spaces
, "type node ");
2915 gdb_print_host_address (type
, gdb_stdout
);
2916 printf_filtered (_(" <same as already seen type>\n"));
2921 obstack_ptr_grow (&dont_print_type_obstack
, type
);
2924 printfi_filtered (spaces
, "type node ");
2925 gdb_print_host_address (type
, gdb_stdout
);
2926 printf_filtered ("\n");
2927 printfi_filtered (spaces
, "name '%s' (",
2928 TYPE_NAME (type
) ? TYPE_NAME (type
) : "<NULL>");
2929 gdb_print_host_address (TYPE_NAME (type
), gdb_stdout
);
2930 printf_filtered (")\n");
2931 printfi_filtered (spaces
, "tagname '%s' (",
2932 TYPE_TAG_NAME (type
) ? TYPE_TAG_NAME (type
) : "<NULL>");
2933 gdb_print_host_address (TYPE_TAG_NAME (type
), gdb_stdout
);
2934 printf_filtered (")\n");
2935 printfi_filtered (spaces
, "code 0x%x ", TYPE_CODE (type
));
2936 switch (TYPE_CODE (type
))
2938 case TYPE_CODE_UNDEF
:
2939 printf_filtered ("(TYPE_CODE_UNDEF)");
2942 printf_filtered ("(TYPE_CODE_PTR)");
2944 case TYPE_CODE_ARRAY
:
2945 printf_filtered ("(TYPE_CODE_ARRAY)");
2947 case TYPE_CODE_STRUCT
:
2948 printf_filtered ("(TYPE_CODE_STRUCT)");
2950 case TYPE_CODE_UNION
:
2951 printf_filtered ("(TYPE_CODE_UNION)");
2953 case TYPE_CODE_ENUM
:
2954 printf_filtered ("(TYPE_CODE_ENUM)");
2956 case TYPE_CODE_FLAGS
:
2957 printf_filtered ("(TYPE_CODE_FLAGS)");
2959 case TYPE_CODE_FUNC
:
2960 printf_filtered ("(TYPE_CODE_FUNC)");
2963 printf_filtered ("(TYPE_CODE_INT)");
2966 printf_filtered ("(TYPE_CODE_FLT)");
2968 case TYPE_CODE_VOID
:
2969 printf_filtered ("(TYPE_CODE_VOID)");
2972 printf_filtered ("(TYPE_CODE_SET)");
2974 case TYPE_CODE_RANGE
:
2975 printf_filtered ("(TYPE_CODE_RANGE)");
2977 case TYPE_CODE_STRING
:
2978 printf_filtered ("(TYPE_CODE_STRING)");
2980 case TYPE_CODE_BITSTRING
:
2981 printf_filtered ("(TYPE_CODE_BITSTRING)");
2983 case TYPE_CODE_ERROR
:
2984 printf_filtered ("(TYPE_CODE_ERROR)");
2986 case TYPE_CODE_MEMBERPTR
:
2987 printf_filtered ("(TYPE_CODE_MEMBERPTR)");
2989 case TYPE_CODE_METHODPTR
:
2990 printf_filtered ("(TYPE_CODE_METHODPTR)");
2992 case TYPE_CODE_METHOD
:
2993 printf_filtered ("(TYPE_CODE_METHOD)");
2996 printf_filtered ("(TYPE_CODE_REF)");
2998 case TYPE_CODE_CHAR
:
2999 printf_filtered ("(TYPE_CODE_CHAR)");
3001 case TYPE_CODE_BOOL
:
3002 printf_filtered ("(TYPE_CODE_BOOL)");
3004 case TYPE_CODE_COMPLEX
:
3005 printf_filtered ("(TYPE_CODE_COMPLEX)");
3007 case TYPE_CODE_TYPEDEF
:
3008 printf_filtered ("(TYPE_CODE_TYPEDEF)");
3010 case TYPE_CODE_TEMPLATE
:
3011 printf_filtered ("(TYPE_CODE_TEMPLATE)");
3013 case TYPE_CODE_TEMPLATE_ARG
:
3014 printf_filtered ("(TYPE_CODE_TEMPLATE_ARG)");
3016 case TYPE_CODE_NAMESPACE
:
3017 printf_filtered ("(TYPE_CODE_NAMESPACE)");
3020 printf_filtered ("(UNKNOWN TYPE CODE)");
3023 puts_filtered ("\n");
3024 printfi_filtered (spaces
, "length %d\n", TYPE_LENGTH (type
));
3025 printfi_filtered (spaces
, "upper_bound_type 0x%x ",
3026 TYPE_ARRAY_UPPER_BOUND_TYPE (type
));
3027 print_bound_type (TYPE_ARRAY_UPPER_BOUND_TYPE (type
));
3028 puts_filtered ("\n");
3029 printfi_filtered (spaces
, "lower_bound_type 0x%x ",
3030 TYPE_ARRAY_LOWER_BOUND_TYPE (type
));
3031 print_bound_type (TYPE_ARRAY_LOWER_BOUND_TYPE (type
));
3032 puts_filtered ("\n");
3033 printfi_filtered (spaces
, "objfile ");
3034 gdb_print_host_address (TYPE_OBJFILE (type
), gdb_stdout
);
3035 printf_filtered ("\n");
3036 printfi_filtered (spaces
, "target_type ");
3037 gdb_print_host_address (TYPE_TARGET_TYPE (type
), gdb_stdout
);
3038 printf_filtered ("\n");
3039 if (TYPE_TARGET_TYPE (type
) != NULL
)
3041 recursive_dump_type (TYPE_TARGET_TYPE (type
), spaces
+ 2);
3043 printfi_filtered (spaces
, "pointer_type ");
3044 gdb_print_host_address (TYPE_POINTER_TYPE (type
), gdb_stdout
);
3045 printf_filtered ("\n");
3046 printfi_filtered (spaces
, "reference_type ");
3047 gdb_print_host_address (TYPE_REFERENCE_TYPE (type
), gdb_stdout
);
3048 printf_filtered ("\n");
3049 printfi_filtered (spaces
, "type_chain ");
3050 gdb_print_host_address (TYPE_CHAIN (type
), gdb_stdout
);
3051 printf_filtered ("\n");
3052 printfi_filtered (spaces
, "instance_flags 0x%x",
3053 TYPE_INSTANCE_FLAGS (type
));
3054 if (TYPE_CONST (type
))
3056 puts_filtered (" TYPE_FLAG_CONST");
3058 if (TYPE_VOLATILE (type
))
3060 puts_filtered (" TYPE_FLAG_VOLATILE");
3062 if (TYPE_CODE_SPACE (type
))
3064 puts_filtered (" TYPE_FLAG_CODE_SPACE");
3066 if (TYPE_DATA_SPACE (type
))
3068 puts_filtered (" TYPE_FLAG_DATA_SPACE");
3070 if (TYPE_ADDRESS_CLASS_1 (type
))
3072 puts_filtered (" TYPE_FLAG_ADDRESS_CLASS_1");
3074 if (TYPE_ADDRESS_CLASS_2 (type
))
3076 puts_filtered (" TYPE_FLAG_ADDRESS_CLASS_2");
3078 puts_filtered ("\n");
3079 printfi_filtered (spaces
, "flags 0x%x", TYPE_FLAGS (type
));
3080 if (TYPE_UNSIGNED (type
))
3082 puts_filtered (" TYPE_FLAG_UNSIGNED");
3084 if (TYPE_NOSIGN (type
))
3086 puts_filtered (" TYPE_FLAG_NOSIGN");
3088 if (TYPE_STUB (type
))
3090 puts_filtered (" TYPE_FLAG_STUB");
3092 if (TYPE_TARGET_STUB (type
))
3094 puts_filtered (" TYPE_FLAG_TARGET_STUB");
3096 if (TYPE_STATIC (type
))
3098 puts_filtered (" TYPE_FLAG_STATIC");
3100 if (TYPE_PROTOTYPED (type
))
3102 puts_filtered (" TYPE_FLAG_PROTOTYPED");
3104 if (TYPE_INCOMPLETE (type
))
3106 puts_filtered (" TYPE_FLAG_INCOMPLETE");
3108 if (TYPE_VARARGS (type
))
3110 puts_filtered (" TYPE_FLAG_VARARGS");
3112 /* This is used for things like AltiVec registers on ppc. Gcc emits
3113 an attribute for the array type, which tells whether or not we
3114 have a vector, instead of a regular array. */
3115 if (TYPE_VECTOR (type
))
3117 puts_filtered (" TYPE_FLAG_VECTOR");
3119 puts_filtered ("\n");
3120 printfi_filtered (spaces
, "nfields %d ", TYPE_NFIELDS (type
));
3121 gdb_print_host_address (TYPE_FIELDS (type
), gdb_stdout
);
3122 puts_filtered ("\n");
3123 for (idx
= 0; idx
< TYPE_NFIELDS (type
); idx
++)
3125 printfi_filtered (spaces
+ 2,
3126 "[%d] bitpos %d bitsize %d type ",
3127 idx
, TYPE_FIELD_BITPOS (type
, idx
),
3128 TYPE_FIELD_BITSIZE (type
, idx
));
3129 gdb_print_host_address (TYPE_FIELD_TYPE (type
, idx
), gdb_stdout
);
3130 printf_filtered (" name '%s' (",
3131 TYPE_FIELD_NAME (type
, idx
) != NULL
3132 ? TYPE_FIELD_NAME (type
, idx
)
3134 gdb_print_host_address (TYPE_FIELD_NAME (type
, idx
), gdb_stdout
);
3135 printf_filtered (")\n");
3136 if (TYPE_FIELD_TYPE (type
, idx
) != NULL
)
3138 recursive_dump_type (TYPE_FIELD_TYPE (type
, idx
), spaces
+ 4);
3141 printfi_filtered (spaces
, "vptr_basetype ");
3142 gdb_print_host_address (TYPE_VPTR_BASETYPE (type
), gdb_stdout
);
3143 puts_filtered ("\n");
3144 if (TYPE_VPTR_BASETYPE (type
) != NULL
)
3146 recursive_dump_type (TYPE_VPTR_BASETYPE (type
), spaces
+ 2);
3148 printfi_filtered (spaces
, "vptr_fieldno %d\n",
3149 TYPE_VPTR_FIELDNO (type
));
3150 switch (TYPE_CODE (type
))
3152 case TYPE_CODE_STRUCT
:
3153 printfi_filtered (spaces
, "cplus_stuff ");
3154 gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type
),
3156 puts_filtered ("\n");
3157 print_cplus_stuff (type
, spaces
);
3161 printfi_filtered (spaces
, "floatformat ");
3162 if (TYPE_FLOATFORMAT (type
) == NULL
)
3163 puts_filtered ("(null)");
3166 puts_filtered ("{ ");
3167 if (TYPE_FLOATFORMAT (type
)[0] == NULL
3168 || TYPE_FLOATFORMAT (type
)[0]->name
== NULL
)
3169 puts_filtered ("(null)");
3171 puts_filtered (TYPE_FLOATFORMAT (type
)[0]->name
);
3173 puts_filtered (", ");
3174 if (TYPE_FLOATFORMAT (type
)[1] == NULL
3175 || TYPE_FLOATFORMAT (type
)[1]->name
== NULL
)
3176 puts_filtered ("(null)");
3178 puts_filtered (TYPE_FLOATFORMAT (type
)[1]->name
);
3180 puts_filtered (" }");
3182 puts_filtered ("\n");
3186 /* We have to pick one of the union types to be able print and
3187 test the value. Pick cplus_struct_type, even though we know
3188 it isn't any particular one. */
3189 printfi_filtered (spaces
, "type_specific ");
3190 gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type
), gdb_stdout
);
3191 if (TYPE_CPLUS_SPECIFIC (type
) != NULL
)
3193 printf_filtered (_(" (unknown data form)"));
3195 printf_filtered ("\n");
3200 obstack_free (&dont_print_type_obstack
, NULL
);
3203 /* Trivial helpers for the libiberty hash table, for mapping one
3208 struct type
*old
, *new;
3212 type_pair_hash (const void *item
)
3214 const struct type_pair
*pair
= item
;
3215 return htab_hash_pointer (pair
->old
);
3219 type_pair_eq (const void *item_lhs
, const void *item_rhs
)
3221 const struct type_pair
*lhs
= item_lhs
, *rhs
= item_rhs
;
3222 return lhs
->old
== rhs
->old
;
3225 /* Allocate the hash table used by copy_type_recursive to walk
3226 types without duplicates. We use OBJFILE's obstack, because
3227 OBJFILE is about to be deleted. */
3230 create_copied_types_hash (struct objfile
*objfile
)
3232 return htab_create_alloc_ex (1, type_pair_hash
, type_pair_eq
,
3233 NULL
, &objfile
->objfile_obstack
,
3234 hashtab_obstack_allocate
,
3235 dummy_obstack_deallocate
);
3238 /* Recursively copy (deep copy) TYPE, if it is associated with
3239 OBJFILE. Return a new type allocated using malloc, a saved type if
3240 we have already visited TYPE (using COPIED_TYPES), or TYPE if it is
3241 not associated with OBJFILE. */
3244 copy_type_recursive (struct objfile
*objfile
,
3246 htab_t copied_types
)
3248 struct type_pair
*stored
, pair
;
3250 struct type
*new_type
;
3252 if (TYPE_OBJFILE (type
) == NULL
)
3255 /* This type shouldn't be pointing to any types in other objfiles;
3256 if it did, the type might disappear unexpectedly. */
3257 gdb_assert (TYPE_OBJFILE (type
) == objfile
);
3260 slot
= htab_find_slot (copied_types
, &pair
, INSERT
);
3262 return ((struct type_pair
*) *slot
)->new;
3264 new_type
= alloc_type (NULL
);
3266 /* We must add the new type to the hash table immediately, in case
3267 we encounter this type again during a recursive call below. */
3268 stored
= xmalloc (sizeof (struct type_pair
));
3270 stored
->new = new_type
;
3273 /* Copy the common fields of types. */
3274 TYPE_CODE (new_type
) = TYPE_CODE (type
);
3275 TYPE_ARRAY_UPPER_BOUND_TYPE (new_type
) =
3276 TYPE_ARRAY_UPPER_BOUND_TYPE (type
);
3277 TYPE_ARRAY_LOWER_BOUND_TYPE (new_type
) =
3278 TYPE_ARRAY_LOWER_BOUND_TYPE (type
);
3279 if (TYPE_NAME (type
))
3280 TYPE_NAME (new_type
) = xstrdup (TYPE_NAME (type
));
3281 if (TYPE_TAG_NAME (type
))
3282 TYPE_TAG_NAME (new_type
) = xstrdup (TYPE_TAG_NAME (type
));
3283 TYPE_FLAGS (new_type
) = TYPE_FLAGS (type
);
3284 TYPE_VPTR_FIELDNO (new_type
) = TYPE_VPTR_FIELDNO (type
);
3286 TYPE_INSTANCE_FLAGS (new_type
) = TYPE_INSTANCE_FLAGS (type
);
3287 TYPE_LENGTH (new_type
) = TYPE_LENGTH (type
);
3289 /* Copy the fields. */
3290 TYPE_NFIELDS (new_type
) = TYPE_NFIELDS (type
);
3291 if (TYPE_NFIELDS (type
))
3295 nfields
= TYPE_NFIELDS (type
);
3296 TYPE_FIELDS (new_type
) = xmalloc (sizeof (struct field
) * nfields
);
3297 for (i
= 0; i
< nfields
; i
++)
3299 TYPE_FIELD_ARTIFICIAL (new_type
, i
) =
3300 TYPE_FIELD_ARTIFICIAL (type
, i
);
3301 TYPE_FIELD_BITSIZE (new_type
, i
) = TYPE_FIELD_BITSIZE (type
, i
);
3302 if (TYPE_FIELD_TYPE (type
, i
))
3303 TYPE_FIELD_TYPE (new_type
, i
)
3304 = copy_type_recursive (objfile
, TYPE_FIELD_TYPE (type
, i
),
3306 if (TYPE_FIELD_NAME (type
, i
))
3307 TYPE_FIELD_NAME (new_type
, i
) =
3308 xstrdup (TYPE_FIELD_NAME (type
, i
));
3309 if (TYPE_FIELD_STATIC_HAS_ADDR (type
, i
))
3310 SET_FIELD_PHYSADDR (TYPE_FIELD (new_type
, i
),
3311 TYPE_FIELD_STATIC_PHYSADDR (type
, i
));
3312 else if (TYPE_FIELD_STATIC (type
, i
))
3313 SET_FIELD_PHYSNAME (TYPE_FIELD (new_type
, i
),
3314 xstrdup (TYPE_FIELD_STATIC_PHYSNAME (type
,
3318 TYPE_FIELD_BITPOS (new_type
, i
) =
3319 TYPE_FIELD_BITPOS (type
, i
);
3320 TYPE_FIELD_STATIC_KIND (new_type
, i
) = 0;
3325 /* Copy pointers to other types. */
3326 if (TYPE_TARGET_TYPE (type
))
3327 TYPE_TARGET_TYPE (new_type
) =
3328 copy_type_recursive (objfile
,
3329 TYPE_TARGET_TYPE (type
),
3331 if (TYPE_VPTR_BASETYPE (type
))
3332 TYPE_VPTR_BASETYPE (new_type
) =
3333 copy_type_recursive (objfile
,
3334 TYPE_VPTR_BASETYPE (type
),
3336 /* Maybe copy the type_specific bits.
3338 NOTE drow/2005-12-09: We do not copy the C++-specific bits like
3339 base classes and methods. There's no fundamental reason why we
3340 can't, but at the moment it is not needed. */
3342 if (TYPE_CODE (type
) == TYPE_CODE_FLT
)
3343 TYPE_FLOATFORMAT (new_type
) = TYPE_FLOATFORMAT (type
);
3344 else if (TYPE_CODE (type
) == TYPE_CODE_STRUCT
3345 || TYPE_CODE (type
) == TYPE_CODE_UNION
3346 || TYPE_CODE (type
) == TYPE_CODE_TEMPLATE
3347 || TYPE_CODE (type
) == TYPE_CODE_NAMESPACE
)
3348 INIT_CPLUS_SPECIFIC (new_type
);
3353 static struct type
*
3354 build_flt (int bit
, char *name
, const struct floatformat
**floatformats
)
3360 gdb_assert (floatformats
!= NULL
);
3361 gdb_assert (floatformats
[0] != NULL
&& floatformats
[1] != NULL
);
3362 bit
= floatformats
[0]->totalsize
;
3364 gdb_assert (bit
>= 0);
3366 t
= init_type (TYPE_CODE_FLT
, bit
/ TARGET_CHAR_BIT
, 0, name
, NULL
);
3367 TYPE_FLOATFORMAT (t
) = floatformats
;
3371 static struct gdbarch_data
*gdbtypes_data
;
3373 const struct builtin_type
*
3374 builtin_type (struct gdbarch
*gdbarch
)
3376 return gdbarch_data (gdbarch
, gdbtypes_data
);
3380 static struct type
*
3381 build_complex (int bit
, char *name
, struct type
*target_type
)
3384 if (bit
<= 0 || target_type
== builtin_type_error
)
3386 gdb_assert (builtin_type_error
!= NULL
);
3387 return builtin_type_error
;
3389 t
= init_type (TYPE_CODE_COMPLEX
, 2 * bit
/ TARGET_CHAR_BIT
,
3390 0, name
, (struct objfile
*) NULL
);
3391 TYPE_TARGET_TYPE (t
) = target_type
;
3396 gdbtypes_post_init (struct gdbarch
*gdbarch
)
3398 struct builtin_type
*builtin_type
3399 = GDBARCH_OBSTACK_ZALLOC (gdbarch
, struct builtin_type
);
3401 builtin_type
->builtin_void
=
3402 init_type (TYPE_CODE_VOID
, 1,
3404 "void", (struct objfile
*) NULL
);
3405 builtin_type
->builtin_char
=
3406 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3408 | (gdbarch_char_signed (current_gdbarch
) ?
3409 0 : TYPE_FLAG_UNSIGNED
)),
3410 "char", (struct objfile
*) NULL
);
3411 builtin_type
->builtin_true_char
=
3412 init_type (TYPE_CODE_CHAR
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3414 "true character", (struct objfile
*) NULL
);
3415 builtin_type
->builtin_signed_char
=
3416 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3418 "signed char", (struct objfile
*) NULL
);
3419 builtin_type
->builtin_unsigned_char
=
3420 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3422 "unsigned char", (struct objfile
*) NULL
);
3423 builtin_type
->builtin_short
=
3424 init_type (TYPE_CODE_INT
,
3425 gdbarch_short_bit (current_gdbarch
) / TARGET_CHAR_BIT
,
3426 0, "short", (struct objfile
*) NULL
);
3427 builtin_type
->builtin_unsigned_short
=
3428 init_type (TYPE_CODE_INT
,
3429 gdbarch_short_bit (current_gdbarch
) / TARGET_CHAR_BIT
,
3430 TYPE_FLAG_UNSIGNED
, "unsigned short",
3431 (struct objfile
*) NULL
);
3432 builtin_type
->builtin_int
=
3433 init_type (TYPE_CODE_INT
,
3434 gdbarch_int_bit (current_gdbarch
) / TARGET_CHAR_BIT
,
3435 0, "int", (struct objfile
*) NULL
);
3436 builtin_type
->builtin_unsigned_int
=
3437 init_type (TYPE_CODE_INT
,
3438 gdbarch_int_bit (current_gdbarch
) / TARGET_CHAR_BIT
,
3439 TYPE_FLAG_UNSIGNED
, "unsigned int",
3440 (struct objfile
*) NULL
);
3441 builtin_type
->builtin_long
=
3442 init_type (TYPE_CODE_INT
,
3443 gdbarch_long_bit (current_gdbarch
) / TARGET_CHAR_BIT
,
3444 0, "long", (struct objfile
*) NULL
);
3445 builtin_type
->builtin_unsigned_long
=
3446 init_type (TYPE_CODE_INT
,
3447 gdbarch_long_bit (current_gdbarch
) / TARGET_CHAR_BIT
,
3448 TYPE_FLAG_UNSIGNED
, "unsigned long",
3449 (struct objfile
*) NULL
);
3450 builtin_type
->builtin_long_long
=
3451 init_type (TYPE_CODE_INT
,
3452 gdbarch_long_long_bit (current_gdbarch
) / TARGET_CHAR_BIT
,
3453 0, "long long", (struct objfile
*) NULL
);
3454 builtin_type
->builtin_unsigned_long_long
=
3455 init_type (TYPE_CODE_INT
,
3456 gdbarch_long_long_bit (current_gdbarch
) / TARGET_CHAR_BIT
,
3457 TYPE_FLAG_UNSIGNED
, "unsigned long long",
3458 (struct objfile
*) NULL
);
3459 builtin_type
->builtin_float
3460 = build_flt (gdbarch_float_bit (gdbarch
), "float",
3461 gdbarch_float_format (gdbarch
));
3462 builtin_type
->builtin_double
3463 = build_flt (gdbarch_double_bit (gdbarch
), "double",
3464 gdbarch_double_format (gdbarch
));
3465 builtin_type
->builtin_long_double
3466 = build_flt (gdbarch_long_double_bit (gdbarch
), "long double",
3467 gdbarch_long_double_format (gdbarch
));
3468 builtin_type
->builtin_complex
3469 = build_complex (gdbarch_float_bit (gdbarch
), "complex",
3470 builtin_type
->builtin_float
);
3471 builtin_type
->builtin_double_complex
3472 = build_complex (gdbarch_double_bit (gdbarch
), "double complex",
3473 builtin_type
->builtin_double
);
3474 builtin_type
->builtin_string
=
3475 init_type (TYPE_CODE_STRING
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3477 "string", (struct objfile
*) NULL
);
3478 builtin_type
->builtin_bool
=
3479 init_type (TYPE_CODE_BOOL
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3481 "bool", (struct objfile
*) NULL
);
3483 /* Pointer/Address types. */
3485 /* NOTE: on some targets, addresses and pointers are not necessarily
3486 the same --- for example, on the D10V, pointers are 16 bits long,
3487 but addresses are 32 bits long. See doc/gdbint.texinfo,
3488 ``Pointers Are Not Always Addresses''.
3491 - gdb's `struct type' always describes the target's
3493 - gdb's `struct value' objects should always hold values in
3495 - gdb's CORE_ADDR values are addresses in the unified virtual
3496 address space that the assembler and linker work with. Thus,
3497 since target_read_memory takes a CORE_ADDR as an argument, it
3498 can access any memory on the target, even if the processor has
3499 separate code and data address spaces.
3502 - If v is a value holding a D10V code pointer, its contents are
3503 in target form: a big-endian address left-shifted two bits.
3504 - If p is a D10V pointer type, TYPE_LENGTH (p) == 2, just as
3505 sizeof (void *) == 2 on the target.
3507 In this context, builtin_type->CORE_ADDR is a bit odd: it's a
3508 target type for a value the target will never see. It's only
3509 used to hold the values of (typeless) linker symbols, which are
3510 indeed in the unified virtual address space. */
3512 builtin_type
->builtin_data_ptr
=
3513 make_pointer_type (builtin_type
->builtin_void
, NULL
);
3514 builtin_type
->builtin_func_ptr
=
3515 lookup_pointer_type (lookup_function_type (builtin_type
->builtin_void
));
3516 builtin_type
->builtin_core_addr
=
3517 init_type (TYPE_CODE_INT
,
3518 gdbarch_addr_bit (current_gdbarch
) / 8,
3520 "__CORE_ADDR", (struct objfile
*) NULL
);
3523 /* The following set of types is used for symbols with no
3524 debug information. */
3525 builtin_type
->nodebug_text_symbol
=
3526 init_type (TYPE_CODE_FUNC
, 1, 0,
3527 "<text variable, no debug info>", NULL
);
3528 TYPE_TARGET_TYPE (builtin_type
->nodebug_text_symbol
) =
3529 builtin_type
->builtin_int
;
3530 builtin_type
->nodebug_data_symbol
=
3531 init_type (TYPE_CODE_INT
,
3532 gdbarch_int_bit (gdbarch
) / HOST_CHAR_BIT
, 0,
3533 "<data variable, no debug info>", NULL
);
3534 builtin_type
->nodebug_unknown_symbol
=
3535 init_type (TYPE_CODE_INT
, 1, 0,
3536 "<variable (not text or data), no debug info>", NULL
);
3537 builtin_type
->nodebug_tls_symbol
=
3538 init_type (TYPE_CODE_INT
,
3539 gdbarch_int_bit (gdbarch
) / HOST_CHAR_BIT
, 0,
3540 "<thread local variable, no debug info>", NULL
);
3542 return builtin_type
;
3545 extern void _initialize_gdbtypes (void);
3547 _initialize_gdbtypes (void)
3549 gdbtypes_data
= gdbarch_data_register_post_init (gdbtypes_post_init
);
3551 /* FIXME: The following types are architecture-neutral. However,
3552 they contain pointer_type and reference_type fields potentially
3553 caching pointer or reference types that *are* architecture
3557 init_type (TYPE_CODE_INT
, 0 / 8,
3559 "int0_t", (struct objfile
*) NULL
);
3561 init_type (TYPE_CODE_INT
, 8 / 8,
3563 "int8_t", (struct objfile
*) NULL
);
3564 builtin_type_uint8
=
3565 init_type (TYPE_CODE_INT
, 8 / 8,
3567 "uint8_t", (struct objfile
*) NULL
);
3568 builtin_type_int16
=
3569 init_type (TYPE_CODE_INT
, 16 / 8,
3571 "int16_t", (struct objfile
*) NULL
);
3572 builtin_type_uint16
=
3573 init_type (TYPE_CODE_INT
, 16 / 8,
3575 "uint16_t", (struct objfile
*) NULL
);
3576 builtin_type_int32
=
3577 init_type (TYPE_CODE_INT
, 32 / 8,
3579 "int32_t", (struct objfile
*) NULL
);
3580 builtin_type_uint32
=
3581 init_type (TYPE_CODE_INT
, 32 / 8,
3583 "uint32_t", (struct objfile
*) NULL
);
3584 builtin_type_int64
=
3585 init_type (TYPE_CODE_INT
, 64 / 8,
3587 "int64_t", (struct objfile
*) NULL
);
3588 builtin_type_uint64
=
3589 init_type (TYPE_CODE_INT
, 64 / 8,
3591 "uint64_t", (struct objfile
*) NULL
);
3592 builtin_type_int128
=
3593 init_type (TYPE_CODE_INT
, 128 / 8,
3595 "int128_t", (struct objfile
*) NULL
);
3596 builtin_type_uint128
=
3597 init_type (TYPE_CODE_INT
, 128 / 8,
3599 "uint128_t", (struct objfile
*) NULL
);
3601 builtin_type_ieee_single
=
3602 build_flt (-1, "builtin_type_ieee_single", floatformats_ieee_single
);
3603 builtin_type_ieee_double
=
3604 build_flt (-1, "builtin_type_ieee_double", floatformats_ieee_double
);
3605 builtin_type_i387_ext
=
3606 build_flt (-1, "builtin_type_i387_ext", floatformats_i387_ext
);
3607 builtin_type_m68881_ext
=
3608 build_flt (-1, "builtin_type_m68881_ext", floatformats_m68881_ext
);
3609 builtin_type_arm_ext
=
3610 build_flt (-1, "builtin_type_arm_ext", floatformats_arm_ext
);
3611 builtin_type_ia64_spill
=
3612 build_flt (-1, "builtin_type_ia64_spill", floatformats_ia64_spill
);
3613 builtin_type_ia64_quad
=
3614 build_flt (-1, "builtin_type_ia64_quad", floatformats_ia64_quad
);
3616 add_setshow_zinteger_cmd ("overload", no_class
, &overload_debug
, _("\
3617 Set debugging of C++ overloading."), _("\
3618 Show debugging of C++ overloading."), _("\
3619 When enabled, ranking of the functions is displayed."),
3621 show_overload_debug
,
3622 &setdebuglist
, &showdebuglist
);
3624 /* Add user knob for controlling resolution of opaque types. */
3625 add_setshow_boolean_cmd ("opaque-type-resolution", class_support
,
3626 &opaque_type_resolution
, _("\
3627 Set resolution of opaque struct/class/union types (if set before loading symbols)."), _("\
3628 Show resolution of opaque struct/class/union types (if set before loading symbols)."), NULL
,
3630 show_opaque_type_resolution
,
3631 &setlist
, &showlist
);