1 /* Support routines for manipulating internal types for GDB.
2 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
4 Contributed by Cygnus Support, using pieces from other GDB modules.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
24 #include "gdb_string.h"
30 #include "expression.h"
35 #include "complaints.h"
39 #include "gdb_assert.h"
41 /* These variables point to the objects
42 representing the predefined C data types. */
44 struct type
*builtin_type_void
;
45 struct type
*builtin_type_char
;
46 struct type
*builtin_type_true_char
;
47 struct type
*builtin_type_short
;
48 struct type
*builtin_type_int
;
49 struct type
*builtin_type_long
;
50 struct type
*builtin_type_long_long
;
51 struct type
*builtin_type_signed_char
;
52 struct type
*builtin_type_unsigned_char
;
53 struct type
*builtin_type_unsigned_short
;
54 struct type
*builtin_type_unsigned_int
;
55 struct type
*builtin_type_unsigned_long
;
56 struct type
*builtin_type_unsigned_long_long
;
57 struct type
*builtin_type_float
;
58 struct type
*builtin_type_double
;
59 struct type
*builtin_type_long_double
;
60 struct type
*builtin_type_complex
;
61 struct type
*builtin_type_double_complex
;
62 struct type
*builtin_type_string
;
63 struct type
*builtin_type_int8
;
64 struct type
*builtin_type_uint8
;
65 struct type
*builtin_type_int16
;
66 struct type
*builtin_type_uint16
;
67 struct type
*builtin_type_int32
;
68 struct type
*builtin_type_uint32
;
69 struct type
*builtin_type_int64
;
70 struct type
*builtin_type_uint64
;
71 struct type
*builtin_type_int128
;
72 struct type
*builtin_type_uint128
;
73 struct type
*builtin_type_bool
;
75 /* 128 bit long vector types */
76 struct type
*builtin_type_v2_double
;
77 struct type
*builtin_type_v4_float
;
78 struct type
*builtin_type_v2_int64
;
79 struct type
*builtin_type_v4_int32
;
80 struct type
*builtin_type_v8_int16
;
81 struct type
*builtin_type_v16_int8
;
82 /* 64 bit long vector types */
83 struct type
*builtin_type_v2_float
;
84 struct type
*builtin_type_v2_int32
;
85 struct type
*builtin_type_v4_int16
;
86 struct type
*builtin_type_v8_int8
;
88 struct type
*builtin_type_v4sf
;
89 struct type
*builtin_type_v4si
;
90 struct type
*builtin_type_v16qi
;
91 struct type
*builtin_type_v8qi
;
92 struct type
*builtin_type_v8hi
;
93 struct type
*builtin_type_v4hi
;
94 struct type
*builtin_type_v2si
;
95 struct type
*builtin_type_vec128
;
96 struct type
*builtin_type_vec128i
;
97 struct type
*builtin_type_ieee_single_big
;
98 struct type
*builtin_type_ieee_single_little
;
99 struct type
*builtin_type_ieee_double_big
;
100 struct type
*builtin_type_ieee_double_little
;
101 struct type
*builtin_type_ieee_double_littlebyte_bigword
;
102 struct type
*builtin_type_i387_ext
;
103 struct type
*builtin_type_m68881_ext
;
104 struct type
*builtin_type_i960_ext
;
105 struct type
*builtin_type_m88110_ext
;
106 struct type
*builtin_type_m88110_harris_ext
;
107 struct type
*builtin_type_arm_ext_big
;
108 struct type
*builtin_type_arm_ext_littlebyte_bigword
;
109 struct type
*builtin_type_ia64_spill_big
;
110 struct type
*builtin_type_ia64_spill_little
;
111 struct type
*builtin_type_ia64_quad_big
;
112 struct type
*builtin_type_ia64_quad_little
;
113 struct type
*builtin_type_void_data_ptr
;
114 struct type
*builtin_type_void_func_ptr
;
115 struct type
*builtin_type_CORE_ADDR
;
116 struct type
*builtin_type_bfd_vma
;
118 int opaque_type_resolution
= 1;
119 int overload_debug
= 0;
125 }; /* maximum extension is 128! FIXME */
127 static void add_name (struct extra
*, char *);
128 static void add_mangled_type (struct extra
*, struct type
*);
130 static void cfront_mangle_name (struct type
*, int, int);
132 static void print_bit_vector (B_TYPE
*, int);
133 static void print_arg_types (struct type
**, int);
134 static void dump_fn_fieldlists (struct type
*, int);
135 static void print_cplus_stuff (struct type
*, int);
136 static void virtual_base_list_aux (struct type
*dclass
);
139 /* Alloc a new type structure and fill it with some defaults. If
140 OBJFILE is non-NULL, then allocate the space for the type structure
141 in that objfile's type_obstack. Otherwise allocate the new type structure
142 by xmalloc () (for permanent types). */
145 alloc_type (struct objfile
*objfile
)
147 register struct type
*type
;
149 /* Alloc the structure and start off with all fields zeroed. */
153 type
= xmalloc (sizeof (struct type
));
154 memset (type
, 0, sizeof (struct type
));
155 TYPE_MAIN_TYPE (type
) = xmalloc (sizeof (struct main_type
));
159 type
= obstack_alloc (&objfile
->type_obstack
,
160 sizeof (struct type
));
161 memset (type
, 0, sizeof (struct type
));
162 TYPE_MAIN_TYPE (type
) = obstack_alloc (&objfile
->type_obstack
,
163 sizeof (struct main_type
));
164 OBJSTAT (objfile
, n_types
++);
166 memset (TYPE_MAIN_TYPE (type
), 0, sizeof (struct main_type
));
168 /* Initialize the fields that might not be zero. */
170 TYPE_CODE (type
) = TYPE_CODE_UNDEF
;
171 TYPE_OBJFILE (type
) = objfile
;
172 TYPE_VPTR_FIELDNO (type
) = -1;
173 TYPE_CHAIN (type
) = type
; /* Chain back to itself. */
178 /* Alloc a new type instance structure, fill it with some defaults,
179 and point it at OLDTYPE. Allocate the new type instance from the
180 same place as OLDTYPE. */
183 alloc_type_instance (struct type
*oldtype
)
187 /* Allocate the structure. */
189 if (TYPE_OBJFILE (oldtype
) == NULL
)
191 type
= xmalloc (sizeof (struct type
));
192 memset (type
, 0, sizeof (struct type
));
196 type
= obstack_alloc (&TYPE_OBJFILE (oldtype
)->type_obstack
,
197 sizeof (struct type
));
198 memset (type
, 0, sizeof (struct type
));
200 TYPE_MAIN_TYPE (type
) = TYPE_MAIN_TYPE (oldtype
);
202 TYPE_CHAIN (type
) = type
; /* Chain back to itself for now. */
207 /* Clear all remnants of the previous type at TYPE, in preparation for
208 replacing it with something else. */
210 smash_type (struct type
*type
)
212 memset (TYPE_MAIN_TYPE (type
), 0, sizeof (struct main_type
));
214 /* For now, delete the rings. */
215 TYPE_CHAIN (type
) = type
;
217 /* For now, leave the pointer/reference types alone. */
220 /* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points
221 to a pointer to memory where the pointer type should be stored.
222 If *TYPEPTR is zero, update it to point to the pointer type we return.
223 We allocate new memory if needed. */
226 make_pointer_type (struct type
*type
, struct type
**typeptr
)
228 register struct type
*ntype
; /* New type */
229 struct objfile
*objfile
;
231 ntype
= TYPE_POINTER_TYPE (type
);
236 return ntype
; /* Don't care about alloc, and have new type. */
237 else if (*typeptr
== 0)
239 *typeptr
= ntype
; /* Tracking alloc, and we have new type. */
244 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
246 ntype
= alloc_type (TYPE_OBJFILE (type
));
251 /* We have storage, but need to reset it. */
254 objfile
= TYPE_OBJFILE (ntype
);
256 TYPE_OBJFILE (ntype
) = objfile
;
259 TYPE_TARGET_TYPE (ntype
) = type
;
260 TYPE_POINTER_TYPE (type
) = ntype
;
262 /* FIXME! Assume the machine has only one representation for pointers! */
264 TYPE_LENGTH (ntype
) = TARGET_PTR_BIT
/ TARGET_CHAR_BIT
;
265 TYPE_CODE (ntype
) = TYPE_CODE_PTR
;
267 /* Mark pointers as unsigned. The target converts between pointers
268 and addresses (CORE_ADDRs) using POINTER_TO_ADDRESS() and
269 ADDRESS_TO_POINTER(). */
270 TYPE_FLAGS (ntype
) |= TYPE_FLAG_UNSIGNED
;
272 if (!TYPE_POINTER_TYPE (type
)) /* Remember it, if don't have one. */
273 TYPE_POINTER_TYPE (type
) = ntype
;
278 /* Given a type TYPE, return a type of pointers to that type.
279 May need to construct such a type if this is the first use. */
282 lookup_pointer_type (struct type
*type
)
284 return make_pointer_type (type
, (struct type
**) 0);
287 /* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, points
288 to a pointer to memory where the reference type should be stored.
289 If *TYPEPTR is zero, update it to point to the reference type we return.
290 We allocate new memory if needed. */
293 make_reference_type (struct type
*type
, struct type
**typeptr
)
295 register struct type
*ntype
; /* New type */
296 struct objfile
*objfile
;
298 ntype
= TYPE_REFERENCE_TYPE (type
);
303 return ntype
; /* Don't care about alloc, and have new type. */
304 else if (*typeptr
== 0)
306 *typeptr
= ntype
; /* Tracking alloc, and we have new type. */
311 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
313 ntype
= alloc_type (TYPE_OBJFILE (type
));
318 /* We have storage, but need to reset it. */
321 objfile
= TYPE_OBJFILE (ntype
);
323 TYPE_OBJFILE (ntype
) = objfile
;
326 TYPE_TARGET_TYPE (ntype
) = type
;
327 TYPE_REFERENCE_TYPE (type
) = ntype
;
329 /* FIXME! Assume the machine has only one representation for references,
330 and that it matches the (only) representation for pointers! */
332 TYPE_LENGTH (ntype
) = TARGET_PTR_BIT
/ TARGET_CHAR_BIT
;
333 TYPE_CODE (ntype
) = TYPE_CODE_REF
;
335 if (!TYPE_REFERENCE_TYPE (type
)) /* Remember it, if don't have one. */
336 TYPE_REFERENCE_TYPE (type
) = ntype
;
341 /* Same as above, but caller doesn't care about memory allocation details. */
344 lookup_reference_type (struct type
*type
)
346 return make_reference_type (type
, (struct type
**) 0);
349 /* Lookup a function type that returns type TYPE. TYPEPTR, if nonzero, points
350 to a pointer to memory where the function type should be stored.
351 If *TYPEPTR is zero, update it to point to the function type we return.
352 We allocate new memory if needed. */
355 make_function_type (struct type
*type
, struct type
**typeptr
)
357 register struct type
*ntype
; /* New type */
358 struct objfile
*objfile
;
360 if (typeptr
== 0 || *typeptr
== 0) /* We'll need to allocate one. */
362 ntype
= alloc_type (TYPE_OBJFILE (type
));
367 /* We have storage, but need to reset it. */
370 objfile
= TYPE_OBJFILE (ntype
);
372 TYPE_OBJFILE (ntype
) = objfile
;
375 TYPE_TARGET_TYPE (ntype
) = type
;
377 TYPE_LENGTH (ntype
) = 1;
378 TYPE_CODE (ntype
) = TYPE_CODE_FUNC
;
384 /* Given a type TYPE, return a type of functions that return that type.
385 May need to construct such a type if this is the first use. */
388 lookup_function_type (struct type
*type
)
390 return make_function_type (type
, (struct type
**) 0);
393 /* Identify address space identifier by name --
394 return the integer flag defined in gdbtypes.h. */
396 address_space_name_to_int (char *space_identifier
)
398 /* Check for known address space delimiters. */
399 if (!strcmp (space_identifier
, "code"))
400 return TYPE_FLAG_CODE_SPACE
;
401 else if (!strcmp (space_identifier
, "data"))
402 return TYPE_FLAG_DATA_SPACE
;
404 error ("Unknown address space specifier: \"%s\"", space_identifier
);
407 /* Identify address space identifier by integer flag as defined in
408 gdbtypes.h -- return the string version of the adress space name. */
411 address_space_int_to_name (int space_flag
)
413 if (space_flag
& TYPE_FLAG_CODE_SPACE
)
415 else if (space_flag
& TYPE_FLAG_DATA_SPACE
)
421 /* Create a new type with instance flags NEW_FLAGS, based on TYPE.
422 If STORAGE is non-NULL, create the new type instance there. */
425 make_qualified_type (struct type
*type
, int new_flags
,
426 struct type
*storage
)
432 if (TYPE_INSTANCE_FLAGS (ntype
) == new_flags
)
434 ntype
= TYPE_CHAIN (ntype
);
435 } while (ntype
!= type
);
437 /* Create a new type instance. */
439 ntype
= alloc_type_instance (type
);
443 TYPE_MAIN_TYPE (ntype
) = TYPE_MAIN_TYPE (type
);
444 TYPE_CHAIN (ntype
) = ntype
;
447 /* Pointers or references to the original type are not relevant to
449 TYPE_POINTER_TYPE (ntype
) = (struct type
*) 0;
450 TYPE_REFERENCE_TYPE (ntype
) = (struct type
*) 0;
452 /* Chain the new qualified type to the old type. */
453 TYPE_CHAIN (ntype
) = TYPE_CHAIN (type
);
454 TYPE_CHAIN (type
) = ntype
;
456 /* Now set the instance flags and return the new type. */
457 TYPE_INSTANCE_FLAGS (ntype
) = new_flags
;
462 /* Make an address-space-delimited variant of a type -- a type that
463 is identical to the one supplied except that it has an address
464 space attribute attached to it (such as "code" or "data").
466 This is for Harvard architectures. */
469 make_type_with_address_space (struct type
*type
, int space_flag
)
472 int new_flags
= ((TYPE_INSTANCE_FLAGS (type
)
473 & ~(TYPE_FLAG_CODE_SPACE
| TYPE_FLAG_DATA_SPACE
))
476 return make_qualified_type (type
, new_flags
, NULL
);
479 /* Make a "c-v" variant of a type -- a type that is identical to the
480 one supplied except that it may have const or volatile attributes
481 CNST is a flag for setting the const attribute
482 VOLTL is a flag for setting the volatile attribute
483 TYPE is the base type whose variant we are creating.
484 TYPEPTR, if nonzero, points
485 to a pointer to memory where the reference type should be stored.
486 If *TYPEPTR is zero, update it to point to the reference type we return.
487 We allocate new memory if needed. */
490 make_cv_type (int cnst
, int voltl
, struct type
*type
, struct type
**typeptr
)
492 register struct type
*ntype
; /* New type */
493 register struct type
*tmp_type
= type
; /* tmp type */
494 struct objfile
*objfile
;
496 int new_flags
= (TYPE_INSTANCE_FLAGS (type
)
497 & ~(TYPE_FLAG_CONST
| TYPE_FLAG_VOLATILE
));
500 new_flags
|= TYPE_FLAG_CONST
;
503 new_flags
|= TYPE_FLAG_VOLATILE
;
505 if (typeptr
&& *typeptr
!= NULL
)
507 /* Objfile is per-core-type. This const-qualified type had best
508 belong to the same objfile as the type it is qualifying, unless
509 we are overwriting a stub type, in which case the safest thing
510 to do is to copy the core type into the new objfile. */
512 gdb_assert (TYPE_OBJFILE (*typeptr
) == TYPE_OBJFILE (type
)
513 || TYPE_STUB (*typeptr
));
514 if (TYPE_OBJFILE (*typeptr
) != TYPE_OBJFILE (type
))
516 TYPE_MAIN_TYPE (*typeptr
)
517 = TYPE_ALLOC (*typeptr
, sizeof (struct main_type
));
518 *TYPE_MAIN_TYPE (*typeptr
)
519 = *TYPE_MAIN_TYPE (type
);
523 ntype
= make_qualified_type (type
, new_flags
, typeptr
? *typeptr
: NULL
);
531 /* Replace the contents of ntype with the type *type. This changes the
532 contents, rather than the pointer for TYPE_MAIN_TYPE (ntype); thus
533 the changes are propogated to all types in the TYPE_CHAIN.
535 In order to build recursive types, it's inevitable that we'll need
536 to update types in place --- but this sort of indiscriminate
537 smashing is ugly, and needs to be replaced with something more
538 controlled. TYPE_MAIN_TYPE is a step in this direction; it's not
539 clear if more steps are needed. */
541 replace_type (struct type
*ntype
, struct type
*type
)
543 struct type
*cv_chain
, *as_chain
, *ptr
, *ref
;
545 *TYPE_MAIN_TYPE (ntype
) = *TYPE_MAIN_TYPE (type
);
547 /* Assert that the two types have equivalent instance qualifiers.
548 This should be true for at least all of our debug readers. */
549 gdb_assert (TYPE_INSTANCE_FLAGS (ntype
) == TYPE_INSTANCE_FLAGS (type
));
552 /* Implement direct support for MEMBER_TYPE in GNU C++.
553 May need to construct such a type if this is the first use.
554 The TYPE is the type of the member. The DOMAIN is the type
555 of the aggregate that the member belongs to. */
558 lookup_member_type (struct type
*type
, struct type
*domain
)
560 register struct type
*mtype
;
562 mtype
= alloc_type (TYPE_OBJFILE (type
));
563 smash_to_member_type (mtype
, domain
, type
);
567 /* Allocate a stub method whose return type is TYPE.
568 This apparently happens for speed of symbol reading, since parsing
569 out the arguments to the method is cpu-intensive, the way we are doing
570 it. So, we will fill in arguments later.
571 This always returns a fresh type. */
574 allocate_stub_method (struct type
*type
)
578 mtype
= init_type (TYPE_CODE_METHOD
, 1, TYPE_FLAG_STUB
, NULL
,
579 TYPE_OBJFILE (type
));
580 TYPE_TARGET_TYPE (mtype
) = type
;
581 /* _DOMAIN_TYPE (mtype) = unknown yet */
582 /* _ARG_TYPES (mtype) = unknown yet */
586 /* Create a range type using either a blank type supplied in RESULT_TYPE,
587 or creating a new type, inheriting the objfile from INDEX_TYPE.
589 Indices will be of type INDEX_TYPE, and will range from LOW_BOUND to
590 HIGH_BOUND, inclusive.
592 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
593 sure it is TYPE_CODE_UNDEF before we bash it into a range type? */
596 create_range_type (struct type
*result_type
, struct type
*index_type
,
597 int low_bound
, int high_bound
)
599 if (result_type
== NULL
)
601 result_type
= alloc_type (TYPE_OBJFILE (index_type
));
603 TYPE_CODE (result_type
) = TYPE_CODE_RANGE
;
604 TYPE_TARGET_TYPE (result_type
) = index_type
;
605 if (TYPE_STUB (index_type
))
606 TYPE_FLAGS (result_type
) |= TYPE_FLAG_TARGET_STUB
;
608 TYPE_LENGTH (result_type
) = TYPE_LENGTH (check_typedef (index_type
));
609 TYPE_NFIELDS (result_type
) = 2;
610 TYPE_FIELDS (result_type
) = (struct field
*)
611 TYPE_ALLOC (result_type
, 2 * sizeof (struct field
));
612 memset (TYPE_FIELDS (result_type
), 0, 2 * sizeof (struct field
));
613 TYPE_FIELD_BITPOS (result_type
, 0) = low_bound
;
614 TYPE_FIELD_BITPOS (result_type
, 1) = high_bound
;
615 TYPE_FIELD_TYPE (result_type
, 0) = builtin_type_int
; /* FIXME */
616 TYPE_FIELD_TYPE (result_type
, 1) = builtin_type_int
; /* FIXME */
619 TYPE_FLAGS (result_type
) |= TYPE_FLAG_UNSIGNED
;
621 return (result_type
);
624 /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type TYPE.
625 Return 1 of type is a range type, 0 if it is discrete (and bounds
626 will fit in LONGEST), or -1 otherwise. */
629 get_discrete_bounds (struct type
*type
, LONGEST
*lowp
, LONGEST
*highp
)
631 CHECK_TYPEDEF (type
);
632 switch (TYPE_CODE (type
))
634 case TYPE_CODE_RANGE
:
635 *lowp
= TYPE_LOW_BOUND (type
);
636 *highp
= TYPE_HIGH_BOUND (type
);
639 if (TYPE_NFIELDS (type
) > 0)
641 /* The enums may not be sorted by value, so search all
645 *lowp
= *highp
= TYPE_FIELD_BITPOS (type
, 0);
646 for (i
= 0; i
< TYPE_NFIELDS (type
); i
++)
648 if (TYPE_FIELD_BITPOS (type
, i
) < *lowp
)
649 *lowp
= TYPE_FIELD_BITPOS (type
, i
);
650 if (TYPE_FIELD_BITPOS (type
, i
) > *highp
)
651 *highp
= TYPE_FIELD_BITPOS (type
, i
);
654 /* Set unsigned indicator if warranted. */
657 TYPE_FLAGS (type
) |= TYPE_FLAG_UNSIGNED
;
671 if (TYPE_LENGTH (type
) > sizeof (LONGEST
)) /* Too big */
673 if (!TYPE_UNSIGNED (type
))
675 *lowp
= -(1 << (TYPE_LENGTH (type
) * TARGET_CHAR_BIT
- 1));
679 /* ... fall through for unsigned ints ... */
682 /* This round-about calculation is to avoid shifting by
683 TYPE_LENGTH (type) * TARGET_CHAR_BIT, which will not work
684 if TYPE_LENGTH (type) == sizeof (LONGEST). */
685 *highp
= 1 << (TYPE_LENGTH (type
) * TARGET_CHAR_BIT
- 1);
686 *highp
= (*highp
- 1) | *highp
;
693 /* Create an array type using either a blank type supplied in RESULT_TYPE,
694 or creating a new type, inheriting the objfile from RANGE_TYPE.
696 Elements will be of type ELEMENT_TYPE, the indices will be of type
699 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
700 sure it is TYPE_CODE_UNDEF before we bash it into an array type? */
703 create_array_type (struct type
*result_type
, struct type
*element_type
,
704 struct type
*range_type
)
706 LONGEST low_bound
, high_bound
;
708 if (result_type
== NULL
)
710 result_type
= alloc_type (TYPE_OBJFILE (range_type
));
712 TYPE_CODE (result_type
) = TYPE_CODE_ARRAY
;
713 TYPE_TARGET_TYPE (result_type
) = element_type
;
714 if (get_discrete_bounds (range_type
, &low_bound
, &high_bound
) < 0)
715 low_bound
= high_bound
= 0;
716 CHECK_TYPEDEF (element_type
);
717 TYPE_LENGTH (result_type
) =
718 TYPE_LENGTH (element_type
) * (high_bound
- low_bound
+ 1);
719 TYPE_NFIELDS (result_type
) = 1;
720 TYPE_FIELDS (result_type
) =
721 (struct field
*) TYPE_ALLOC (result_type
, sizeof (struct field
));
722 memset (TYPE_FIELDS (result_type
), 0, sizeof (struct field
));
723 TYPE_FIELD_TYPE (result_type
, 0) = range_type
;
724 TYPE_VPTR_FIELDNO (result_type
) = -1;
726 /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays */
727 if (TYPE_LENGTH (result_type
) == 0)
728 TYPE_FLAGS (result_type
) |= TYPE_FLAG_TARGET_STUB
;
730 return (result_type
);
733 /* Create a string type using either a blank type supplied in RESULT_TYPE,
734 or creating a new type. String types are similar enough to array of
735 char types that we can use create_array_type to build the basic type
736 and then bash it into a string type.
738 For fixed length strings, the range type contains 0 as the lower
739 bound and the length of the string minus one as the upper bound.
741 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
742 sure it is TYPE_CODE_UNDEF before we bash it into a string type? */
745 create_string_type (struct type
*result_type
, struct type
*range_type
)
747 result_type
= create_array_type (result_type
,
748 *current_language
->string_char_type
,
750 TYPE_CODE (result_type
) = TYPE_CODE_STRING
;
751 return (result_type
);
755 create_set_type (struct type
*result_type
, struct type
*domain_type
)
757 LONGEST low_bound
, high_bound
, bit_length
;
758 if (result_type
== NULL
)
760 result_type
= alloc_type (TYPE_OBJFILE (domain_type
));
762 TYPE_CODE (result_type
) = TYPE_CODE_SET
;
763 TYPE_NFIELDS (result_type
) = 1;
764 TYPE_FIELDS (result_type
) = (struct field
*)
765 TYPE_ALLOC (result_type
, 1 * sizeof (struct field
));
766 memset (TYPE_FIELDS (result_type
), 0, sizeof (struct field
));
768 if (!TYPE_STUB (domain_type
))
770 if (get_discrete_bounds (domain_type
, &low_bound
, &high_bound
) < 0)
771 low_bound
= high_bound
= 0;
772 bit_length
= high_bound
- low_bound
+ 1;
773 TYPE_LENGTH (result_type
)
774 = (bit_length
+ TARGET_CHAR_BIT
- 1) / TARGET_CHAR_BIT
;
776 TYPE_FIELD_TYPE (result_type
, 0) = domain_type
;
779 TYPE_FLAGS (result_type
) |= TYPE_FLAG_UNSIGNED
;
781 return (result_type
);
784 /* Construct and return a type of the form:
785 struct NAME { ELT_TYPE ELT_NAME[N]; }
786 We use these types for SIMD registers. For example, the type of
787 the SSE registers on the late x86-family processors is:
788 struct __builtin_v4sf { float f[4]; }
789 built by the function call:
790 init_simd_type ("__builtin_v4sf", builtin_type_float, "f", 4)
791 The type returned is a permanent type, allocated using malloc; it
792 doesn't live in any objfile's obstack. */
794 init_simd_type (char *name
,
795 struct type
*elt_type
,
799 struct type
*simd_type
;
800 struct type
*array_type
;
802 simd_type
= init_composite_type (name
, TYPE_CODE_STRUCT
);
803 array_type
= create_array_type (0, elt_type
,
804 create_range_type (0, builtin_type_int
,
806 append_composite_type_field (simd_type
, elt_name
, array_type
);
811 init_vector_type (struct type
*elt_type
, int n
)
813 struct type
*array_type
;
815 array_type
= create_array_type (0, elt_type
,
816 create_range_type (0, builtin_type_int
,
818 TYPE_FLAGS (array_type
) |= TYPE_FLAG_VECTOR
;
823 build_builtin_type_vec128 (void)
825 /* Construct a type for the 128 bit registers. The type we're
828 union __gdb_builtin_type_vec128
840 t
= init_composite_type ("__gdb_builtin_type_vec128", TYPE_CODE_UNION
);
841 append_composite_type_field (t
, "uint128", builtin_type_int128
);
842 append_composite_type_field (t
, "v4_float", builtin_type_v4_float
);
843 append_composite_type_field (t
, "v4_int32", builtin_type_v4_int32
);
844 append_composite_type_field (t
, "v8_int16", builtin_type_v8_int16
);
845 append_composite_type_field (t
, "v16_int8", builtin_type_v16_int8
);
851 build_builtin_type_vec128i (void)
853 /* 128-bit Intel SIMD registers */
856 t
= init_composite_type ("__gdb_builtin_type_vec128i", TYPE_CODE_UNION
);
857 append_composite_type_field (t
, "v4_float", builtin_type_v4_float
);
858 append_composite_type_field (t
, "v2_double", builtin_type_v2_double
);
859 append_composite_type_field (t
, "v16_int8", builtin_type_v16_int8
);
860 append_composite_type_field (t
, "v8_int16", builtin_type_v8_int16
);
861 append_composite_type_field (t
, "v4_int32", builtin_type_v4_int32
);
862 append_composite_type_field (t
, "v2_int64", builtin_type_v2_int64
);
863 append_composite_type_field (t
, "uint128", builtin_type_int128
);
868 /* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE.
869 A MEMBER is a wierd thing -- it amounts to a typed offset into
870 a struct, e.g. "an int at offset 8". A MEMBER TYPE doesn't
871 include the offset (that's the value of the MEMBER itself), but does
872 include the structure type into which it points (for some reason).
874 When "smashing" the type, we preserve the objfile that the
875 old type pointed to, since we aren't changing where the type is actually
879 smash_to_member_type (struct type
*type
, struct type
*domain
,
880 struct type
*to_type
)
882 struct objfile
*objfile
;
884 objfile
= TYPE_OBJFILE (type
);
887 TYPE_OBJFILE (type
) = objfile
;
888 TYPE_TARGET_TYPE (type
) = to_type
;
889 TYPE_DOMAIN_TYPE (type
) = domain
;
890 TYPE_LENGTH (type
) = 1; /* In practice, this is never needed. */
891 TYPE_CODE (type
) = TYPE_CODE_MEMBER
;
894 /* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE.
895 METHOD just means `function that gets an extra "this" argument'.
897 When "smashing" the type, we preserve the objfile that the
898 old type pointed to, since we aren't changing where the type is actually
902 smash_to_method_type (struct type
*type
, struct type
*domain
,
903 struct type
*to_type
, struct type
**args
)
905 struct objfile
*objfile
;
907 objfile
= TYPE_OBJFILE (type
);
910 TYPE_OBJFILE (type
) = objfile
;
911 TYPE_TARGET_TYPE (type
) = to_type
;
912 TYPE_DOMAIN_TYPE (type
) = domain
;
913 TYPE_ARG_TYPES (type
) = args
;
914 TYPE_LENGTH (type
) = 1; /* In practice, this is never needed. */
915 TYPE_CODE (type
) = TYPE_CODE_METHOD
;
918 /* Return a typename for a struct/union/enum type without "struct ",
919 "union ", or "enum ". If the type has a NULL name, return NULL. */
922 type_name_no_tag (register const struct type
*type
)
924 if (TYPE_TAG_NAME (type
) != NULL
)
925 return TYPE_TAG_NAME (type
);
927 /* Is there code which expects this to return the name if there is no
928 tag name? My guess is that this is mainly used for C++ in cases where
929 the two will always be the same. */
930 return TYPE_NAME (type
);
933 /* Lookup a primitive type named NAME.
934 Return zero if NAME is not a primitive type. */
937 lookup_primitive_typename (char *name
)
939 struct type
**const *p
;
941 for (p
= current_language
->la_builtin_type_vector
; *p
!= NULL
; p
++)
943 if (STREQ (TYPE_NAME (**p
), name
))
951 /* Lookup a typedef or primitive type named NAME,
952 visible in lexical block BLOCK.
953 If NOERR is nonzero, return zero if NAME is not suitably defined. */
956 lookup_typename (char *name
, struct block
*block
, int noerr
)
958 register struct symbol
*sym
;
959 register struct type
*tmp
;
961 sym
= lookup_symbol (name
, block
, VAR_NAMESPACE
, 0, (struct symtab
**) NULL
);
962 if (sym
== NULL
|| SYMBOL_CLASS (sym
) != LOC_TYPEDEF
)
964 tmp
= lookup_primitive_typename (name
);
969 else if (!tmp
&& noerr
)
975 error ("No type named %s.", name
);
978 return (SYMBOL_TYPE (sym
));
982 lookup_unsigned_typename (char *name
)
984 char *uns
= alloca (strlen (name
) + 10);
986 strcpy (uns
, "unsigned ");
987 strcpy (uns
+ 9, name
);
988 return (lookup_typename (uns
, (struct block
*) NULL
, 0));
992 lookup_signed_typename (char *name
)
995 char *uns
= alloca (strlen (name
) + 8);
997 strcpy (uns
, "signed ");
998 strcpy (uns
+ 7, name
);
999 t
= lookup_typename (uns
, (struct block
*) NULL
, 1);
1000 /* If we don't find "signed FOO" just try again with plain "FOO". */
1003 return lookup_typename (name
, (struct block
*) NULL
, 0);
1006 /* Lookup a structure type named "struct NAME",
1007 visible in lexical block BLOCK. */
1010 lookup_struct (char *name
, struct block
*block
)
1012 register struct symbol
*sym
;
1014 sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
, 0,
1015 (struct symtab
**) NULL
);
1019 error ("No struct type named %s.", name
);
1021 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_STRUCT
)
1023 error ("This context has class, union or enum %s, not a struct.", name
);
1025 return (SYMBOL_TYPE (sym
));
1028 /* Lookup a union type named "union NAME",
1029 visible in lexical block BLOCK. */
1032 lookup_union (char *name
, struct block
*block
)
1034 register struct symbol
*sym
;
1037 sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
, 0,
1038 (struct symtab
**) NULL
);
1041 error ("No union type named %s.", name
);
1043 t
= SYMBOL_TYPE (sym
);
1045 if (TYPE_CODE (t
) == TYPE_CODE_UNION
)
1048 /* C++ unions may come out with TYPE_CODE_CLASS, but we look at
1049 * a further "declared_type" field to discover it is really a union.
1051 if (HAVE_CPLUS_STRUCT (t
))
1052 if (TYPE_DECLARED_TYPE (t
) == DECLARED_TYPE_UNION
)
1055 /* If we get here, it's not a union */
1056 error ("This context has class, struct or enum %s, not a union.", name
);
1060 /* Lookup an enum type named "enum NAME",
1061 visible in lexical block BLOCK. */
1064 lookup_enum (char *name
, struct block
*block
)
1066 register struct symbol
*sym
;
1068 sym
= lookup_symbol (name
, block
, STRUCT_NAMESPACE
, 0,
1069 (struct symtab
**) NULL
);
1072 error ("No enum type named %s.", name
);
1074 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_ENUM
)
1076 error ("This context has class, struct or union %s, not an enum.", name
);
1078 return (SYMBOL_TYPE (sym
));
1081 /* Lookup a template type named "template NAME<TYPE>",
1082 visible in lexical block BLOCK. */
1085 lookup_template_type (char *name
, struct type
*type
, struct block
*block
)
1088 char *nam
= (char *) alloca (strlen (name
) + strlen (TYPE_NAME (type
)) + 4);
1091 strcat (nam
, TYPE_NAME (type
));
1092 strcat (nam
, " >"); /* FIXME, extra space still introduced in gcc? */
1094 sym
= lookup_symbol (nam
, block
, VAR_NAMESPACE
, 0, (struct symtab
**) NULL
);
1098 error ("No template type named %s.", name
);
1100 if (TYPE_CODE (SYMBOL_TYPE (sym
)) != TYPE_CODE_STRUCT
)
1102 error ("This context has class, union or enum %s, not a struct.", name
);
1104 return (SYMBOL_TYPE (sym
));
1107 /* Given a type TYPE, lookup the type of the component of type named NAME.
1109 TYPE can be either a struct or union, or a pointer or reference to a struct or
1110 union. If it is a pointer or reference, its target type is automatically used.
1111 Thus '.' and '->' are interchangable, as specified for the definitions of the
1112 expression element types STRUCTOP_STRUCT and STRUCTOP_PTR.
1114 If NOERR is nonzero, return zero if NAME is not suitably defined.
1115 If NAME is the name of a baseclass type, return that type. */
1118 lookup_struct_elt_type (struct type
*type
, char *name
, int noerr
)
1124 CHECK_TYPEDEF (type
);
1125 if (TYPE_CODE (type
) != TYPE_CODE_PTR
1126 && TYPE_CODE (type
) != TYPE_CODE_REF
)
1128 type
= TYPE_TARGET_TYPE (type
);
1131 if (TYPE_CODE (type
) != TYPE_CODE_STRUCT
&&
1132 TYPE_CODE (type
) != TYPE_CODE_UNION
)
1134 target_terminal_ours ();
1135 gdb_flush (gdb_stdout
);
1136 fprintf_unfiltered (gdb_stderr
, "Type ");
1137 type_print (type
, "", gdb_stderr
, -1);
1138 error (" is not a structure or union type.");
1142 /* FIXME: This change put in by Michael seems incorrect for the case where
1143 the structure tag name is the same as the member name. I.E. when doing
1144 "ptype bell->bar" for "struct foo { int bar; int foo; } bell;"
1149 typename
= type_name_no_tag (type
);
1150 if (typename
!= NULL
&& STREQ (typename
, name
))
1155 for (i
= TYPE_NFIELDS (type
) - 1; i
>= TYPE_N_BASECLASSES (type
); i
--)
1157 char *t_field_name
= TYPE_FIELD_NAME (type
, i
);
1159 if (t_field_name
&& (strcmp_iw (t_field_name
, name
) == 0))
1161 return TYPE_FIELD_TYPE (type
, i
);
1165 /* OK, it's not in this class. Recursively check the baseclasses. */
1166 for (i
= TYPE_N_BASECLASSES (type
) - 1; i
>= 0; i
--)
1170 t
= lookup_struct_elt_type (TYPE_BASECLASS (type
, i
), name
, noerr
);
1182 target_terminal_ours ();
1183 gdb_flush (gdb_stdout
);
1184 fprintf_unfiltered (gdb_stderr
, "Type ");
1185 type_print (type
, "", gdb_stderr
, -1);
1186 fprintf_unfiltered (gdb_stderr
, " has no component named ");
1187 fputs_filtered (name
, gdb_stderr
);
1189 return (struct type
*) -1; /* For lint */
1192 /* If possible, make the vptr_fieldno and vptr_basetype fields of TYPE
1193 valid. Callers should be aware that in some cases (for example,
1194 the type or one of its baseclasses is a stub type and we are
1195 debugging a .o file), this function will not be able to find the virtual
1196 function table pointer, and vptr_fieldno will remain -1 and vptr_basetype
1197 will remain NULL. */
1200 fill_in_vptr_fieldno (struct type
*type
)
1202 CHECK_TYPEDEF (type
);
1204 if (TYPE_VPTR_FIELDNO (type
) < 0)
1208 /* We must start at zero in case the first (and only) baseclass is
1209 virtual (and hence we cannot share the table pointer). */
1210 for (i
= 0; i
< TYPE_N_BASECLASSES (type
); i
++)
1212 fill_in_vptr_fieldno (TYPE_BASECLASS (type
, i
));
1213 if (TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type
, i
)) >= 0)
1215 TYPE_VPTR_FIELDNO (type
)
1216 = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type
, i
));
1217 TYPE_VPTR_BASETYPE (type
)
1218 = TYPE_VPTR_BASETYPE (TYPE_BASECLASS (type
, i
));
1225 /* Find the method and field indices for the destructor in class type T.
1226 Return 1 if the destructor was found, otherwise, return 0. */
1229 get_destructor_fn_field (struct type
*t
, int *method_indexp
, int *field_indexp
)
1233 for (i
= 0; i
< TYPE_NFN_FIELDS (t
); i
++)
1236 struct fn_field
*f
= TYPE_FN_FIELDLIST1 (t
, i
);
1238 for (j
= 0; j
< TYPE_FN_FIELDLIST_LENGTH (t
, i
); j
++)
1240 if (is_destructor_name (TYPE_FN_FIELD_PHYSNAME (f
, j
)) != 0)
1251 /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989.
1253 If this is a stubbed struct (i.e. declared as struct foo *), see if
1254 we can find a full definition in some other file. If so, copy this
1255 definition, so we can use it in future. There used to be a comment (but
1256 not any code) that if we don't find a full definition, we'd set a flag
1257 so we don't spend time in the future checking the same type. That would
1258 be a mistake, though--we might load in more symbols which contain a
1259 full definition for the type.
1261 This used to be coded as a macro, but I don't think it is called
1262 often enough to merit such treatment. */
1264 struct complaint stub_noname_complaint
=
1265 {"stub type has NULL name", 0, 0};
1268 check_typedef (struct type
*type
)
1270 struct type
*orig_type
= type
;
1271 int is_const
, is_volatile
;
1273 while (TYPE_CODE (type
) == TYPE_CODE_TYPEDEF
)
1275 if (!TYPE_TARGET_TYPE (type
))
1280 /* It is dangerous to call lookup_symbol if we are currently
1281 reading a symtab. Infinite recursion is one danger. */
1282 if (currently_reading_symtab
)
1285 name
= type_name_no_tag (type
);
1286 /* FIXME: shouldn't we separately check the TYPE_NAME and the
1287 TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE
1288 as appropriate? (this code was written before TYPE_NAME and
1289 TYPE_TAG_NAME were separate). */
1292 complain (&stub_noname_complaint
);
1295 sym
= lookup_symbol (name
, 0, STRUCT_NAMESPACE
, 0,
1296 (struct symtab
**) NULL
);
1298 TYPE_TARGET_TYPE (type
) = SYMBOL_TYPE (sym
);
1300 TYPE_TARGET_TYPE (type
) = alloc_type (NULL
); /* TYPE_CODE_UNDEF */
1302 type
= TYPE_TARGET_TYPE (type
);
1305 is_const
= TYPE_CONST (type
);
1306 is_volatile
= TYPE_VOLATILE (type
);
1308 /* If this is a struct/class/union with no fields, then check whether a
1309 full definition exists somewhere else. This is for systems where a
1310 type definition with no fields is issued for such types, instead of
1311 identifying them as stub types in the first place */
1313 if (TYPE_IS_OPAQUE (type
) && opaque_type_resolution
&& !currently_reading_symtab
)
1315 char *name
= type_name_no_tag (type
);
1316 struct type
*newtype
;
1319 complain (&stub_noname_complaint
);
1322 newtype
= lookup_transparent_type (name
);
1324 make_cv_type (is_const
, is_volatile
, newtype
, &type
);
1326 /* Otherwise, rely on the stub flag being set for opaque/stubbed types */
1327 else if (TYPE_STUB (type
) && !currently_reading_symtab
)
1329 char *name
= type_name_no_tag (type
);
1330 /* FIXME: shouldn't we separately check the TYPE_NAME and the
1331 TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE
1332 as appropriate? (this code was written before TYPE_NAME and
1333 TYPE_TAG_NAME were separate). */
1337 complain (&stub_noname_complaint
);
1340 sym
= lookup_symbol (name
, 0, STRUCT_NAMESPACE
, 0, (struct symtab
**) NULL
);
1342 make_cv_type (is_const
, is_volatile
, SYMBOL_TYPE (sym
), &type
);
1345 if (TYPE_TARGET_STUB (type
))
1347 struct type
*range_type
;
1348 struct type
*target_type
= check_typedef (TYPE_TARGET_TYPE (type
));
1350 if (TYPE_STUB (target_type
) || TYPE_TARGET_STUB (target_type
))
1353 else if (TYPE_CODE (type
) == TYPE_CODE_ARRAY
1354 && TYPE_NFIELDS (type
) == 1
1355 && (TYPE_CODE (range_type
= TYPE_FIELD_TYPE (type
, 0))
1356 == TYPE_CODE_RANGE
))
1358 /* Now recompute the length of the array type, based on its
1359 number of elements and the target type's length. */
1360 TYPE_LENGTH (type
) =
1361 ((TYPE_FIELD_BITPOS (range_type
, 1)
1362 - TYPE_FIELD_BITPOS (range_type
, 0)
1364 * TYPE_LENGTH (target_type
));
1365 TYPE_FLAGS (type
) &= ~TYPE_FLAG_TARGET_STUB
;
1367 else if (TYPE_CODE (type
) == TYPE_CODE_RANGE
)
1369 TYPE_LENGTH (type
) = TYPE_LENGTH (target_type
);
1370 TYPE_FLAGS (type
) &= ~TYPE_FLAG_TARGET_STUB
;
1373 /* Cache TYPE_LENGTH for future use. */
1374 TYPE_LENGTH (orig_type
) = TYPE_LENGTH (type
);
1378 /* New code added to support parsing of Cfront stabs strings */
1379 #define INIT_EXTRA { pextras->len=0; pextras->str[0]='\0'; }
1380 #define ADD_EXTRA(c) { pextras->str[pextras->len++]=c; }
1383 add_name (struct extra
*pextras
, char *n
)
1387 if ((nlen
= (n
? strlen (n
) : 0)) == 0)
1389 sprintf (pextras
->str
+ pextras
->len
, "%d%s", nlen
, n
);
1390 pextras
->len
= strlen (pextras
->str
);
1394 add_mangled_type (struct extra
*pextras
, struct type
*t
)
1396 enum type_code tcode
;
1400 tcode
= TYPE_CODE (t
);
1401 tlen
= TYPE_LENGTH (t
);
1402 tflags
= TYPE_FLAGS (t
);
1403 tname
= TYPE_NAME (t
);
1404 /* args of "..." seem to get mangled as "e" */
1422 if ((pname
= strrchr (tname
, 'l'), pname
) && !strcmp (pname
, "long"))
1435 static struct complaint msg
=
1436 {"Bad int type code length x%x\n", 0, 0};
1438 complain (&msg
, tlen
);
1457 static struct complaint msg
=
1458 {"Bad float type code length x%x\n", 0, 0};
1459 complain (&msg
, tlen
);
1465 /* followed by what it's a ref to */
1469 /* followed by what it's a ptr to */
1471 case TYPE_CODE_TYPEDEF
:
1473 static struct complaint msg
=
1474 {"Typedefs in overloaded functions not yet supported\n", 0, 0};
1477 /* followed by type bytes & name */
1479 case TYPE_CODE_FUNC
:
1481 /* followed by func's arg '_' & ret types */
1483 case TYPE_CODE_VOID
:
1486 case TYPE_CODE_METHOD
:
1488 /* followed by name of class and func's arg '_' & ret types */
1489 add_name (pextras
, tname
);
1490 ADD_EXTRA ('F'); /* then mangle function */
1492 case TYPE_CODE_STRUCT
: /* C struct */
1493 case TYPE_CODE_UNION
: /* C union */
1494 case TYPE_CODE_ENUM
: /* Enumeration type */
1495 /* followed by name of type */
1496 add_name (pextras
, tname
);
1499 /* errors possible types/not supported */
1500 case TYPE_CODE_CHAR
:
1501 case TYPE_CODE_ARRAY
: /* Array type */
1502 case TYPE_CODE_MEMBER
: /* Member type */
1503 case TYPE_CODE_BOOL
:
1504 case TYPE_CODE_COMPLEX
: /* Complex float */
1505 case TYPE_CODE_UNDEF
:
1506 case TYPE_CODE_SET
: /* Pascal sets */
1507 case TYPE_CODE_RANGE
:
1508 case TYPE_CODE_STRING
:
1509 case TYPE_CODE_BITSTRING
:
1510 case TYPE_CODE_ERROR
:
1513 static struct complaint msg
=
1514 {"Unknown type code x%x\n", 0, 0};
1515 complain (&msg
, tcode
);
1518 if (TYPE_TARGET_TYPE (t
))
1519 add_mangled_type (pextras
, TYPE_TARGET_TYPE (t
));
1524 cfront_mangle_name (struct type
*type
, int i
, int j
)
1527 char *mangled_name
= gdb_mangle_name (type
, i
, j
);
1529 f
= TYPE_FN_FIELDLIST1 (type
, i
); /* moved from below */
1531 /* kludge to support cfront methods - gdb expects to find "F" for
1532 ARM_mangled names, so when we mangle, we have to add it here */
1536 char *arm_mangled_name
;
1537 struct fn_field
*method
= &f
[j
];
1538 char *field_name
= TYPE_FN_FIELDLIST_NAME (type
, i
);
1539 char *physname
= TYPE_FN_FIELD_PHYSNAME (f
, j
);
1540 char *newname
= type_name_no_tag (type
);
1542 struct type
*ftype
= TYPE_FN_FIELD_TYPE (f
, j
);
1543 int nargs
= TYPE_NFIELDS (ftype
); /* number of args */
1544 struct extra extras
, *pextras
= &extras
;
1547 if (TYPE_FN_FIELD_STATIC_P (f
, j
)) /* j for sublist within this list */
1550 /* add args here! */
1551 if (nargs
<= 1) /* no args besides this */
1555 for (k
= 1; k
< nargs
; k
++)
1558 t
= TYPE_FIELD_TYPE (ftype
, k
);
1559 add_mangled_type (pextras
, t
);
1563 printf ("add_mangled_type: %s\n", extras
.str
); /* FIXME */
1564 xasprintf (&arm_mangled_name
, "%s%s", mangled_name
, extras
.str
);
1565 xfree (mangled_name
);
1566 mangled_name
= arm_mangled_name
;
1572 /* End of new code added to support parsing of Cfront stabs strings */
1574 /* Parse a type expression in the string [P..P+LENGTH). If an error occurs,
1575 silently return builtin_type_void. */
1578 safe_parse_type (char *p
, int length
)
1580 struct ui_file
*saved_gdb_stderr
;
1583 /* Suppress error messages. */
1584 saved_gdb_stderr
= gdb_stderr
;
1585 gdb_stderr
= ui_file_new ();
1587 /* Call parse_and_eval_type() without fear of longjmp()s. */
1588 if (!gdb_parse_and_eval_type (p
, length
, &type
))
1589 type
= builtin_type_void
;
1591 /* Stop suppressing error messages. */
1592 ui_file_delete (gdb_stderr
);
1593 gdb_stderr
= saved_gdb_stderr
;
1598 /* Ugly hack to convert method stubs into method types.
1600 He ain't kiddin'. This demangles the name of the method into a string
1601 including argument types, parses out each argument type, generates
1602 a string casting a zero to that type, evaluates the string, and stuffs
1603 the resulting type into an argtype vector!!! Then it knows the type
1604 of the whole function (including argument types for overloading),
1605 which info used to be in the stab's but was removed to hack back
1606 the space required for them. */
1609 check_stub_method (struct type
*type
, int method_id
, int signature_id
)
1612 char *mangled_name
= gdb_mangle_name (type
, method_id
, signature_id
);
1613 char *demangled_name
= cplus_demangle (mangled_name
,
1614 DMGL_PARAMS
| DMGL_ANSI
);
1615 char *argtypetext
, *p
;
1616 int depth
= 0, argcount
= 1;
1617 struct type
**argtypes
;
1620 /* Make sure we got back a function string that we can use. */
1622 p
= strchr (demangled_name
, '(');
1626 if (demangled_name
== NULL
|| p
== NULL
)
1627 error ("Internal: Cannot demangle mangled name `%s'.", mangled_name
);
1629 /* Now, read in the parameters that define this type. */
1634 if (*p
== '(' || *p
== '<')
1638 else if (*p
== ')' || *p
== '>')
1642 else if (*p
== ',' && depth
== 0)
1650 /* We need two more slots: one for the THIS pointer, and one for the
1651 NULL [...] or void [end of arglist]. */
1653 argtypes
= (struct type
**)
1654 TYPE_ALLOC (type
, (argcount
+ 2) * sizeof (struct type
*));
1657 /* Add THIS pointer for non-static methods. */
1658 f
= TYPE_FN_FIELDLIST1 (type
, method_id
);
1659 if (TYPE_FN_FIELD_STATIC_P (f
, signature_id
))
1663 argtypes
[0] = lookup_pointer_type (type
);
1667 if (*p
!= ')') /* () means no args, skip while */
1672 if (depth
<= 0 && (*p
== ',' || *p
== ')'))
1674 /* Avoid parsing of ellipsis, they will be handled below. */
1675 if (strncmp (argtypetext
, "...", p
- argtypetext
) != 0)
1677 argtypes
[argcount
] =
1678 safe_parse_type (argtypetext
, p
- argtypetext
);
1681 argtypetext
= p
+ 1;
1684 if (*p
== '(' || *p
== '<')
1688 else if (*p
== ')' || *p
== '>')
1697 if (p
[-2] != '.') /* Not '...' */
1699 argtypes
[argcount
] = builtin_type_void
; /* List terminator */
1703 argtypes
[argcount
] = NULL
; /* Ellist terminator */
1706 xfree (demangled_name
);
1708 TYPE_FN_FIELD_PHYSNAME (f
, signature_id
) = mangled_name
;
1710 /* Now update the old "stub" type into a real type. */
1711 mtype
= TYPE_FN_FIELD_TYPE (f
, signature_id
);
1712 TYPE_DOMAIN_TYPE (mtype
) = type
;
1713 TYPE_ARG_TYPES (mtype
) = argtypes
;
1714 TYPE_FLAGS (mtype
) &= ~TYPE_FLAG_STUB
;
1715 TYPE_FN_FIELD_STUB (f
, signature_id
) = 0;
1718 const struct cplus_struct_type cplus_struct_default
;
1721 allocate_cplus_struct_type (struct type
*type
)
1723 if (!HAVE_CPLUS_STRUCT (type
))
1725 TYPE_CPLUS_SPECIFIC (type
) = (struct cplus_struct_type
*)
1726 TYPE_ALLOC (type
, sizeof (struct cplus_struct_type
));
1727 *(TYPE_CPLUS_SPECIFIC (type
)) = cplus_struct_default
;
1731 /* Helper function to initialize the standard scalar types.
1733 If NAME is non-NULL and OBJFILE is non-NULL, then we make a copy
1734 of the string pointed to by name in the type_obstack for that objfile,
1735 and initialize the type name to that copy. There are places (mipsread.c
1736 in particular, where init_type is called with a NULL value for NAME). */
1739 init_type (enum type_code code
, int length
, int flags
, char *name
,
1740 struct objfile
*objfile
)
1742 register struct type
*type
;
1744 type
= alloc_type (objfile
);
1745 TYPE_CODE (type
) = code
;
1746 TYPE_LENGTH (type
) = length
;
1747 TYPE_FLAGS (type
) |= flags
;
1748 if ((name
!= NULL
) && (objfile
!= NULL
))
1751 obsavestring (name
, strlen (name
), &objfile
->type_obstack
);
1755 TYPE_NAME (type
) = name
;
1760 if (code
== TYPE_CODE_STRUCT
|| code
== TYPE_CODE_UNION
)
1762 INIT_CPLUS_SPECIFIC (type
);
1767 /* Helper function. Create an empty composite type. */
1770 init_composite_type (char *name
, enum type_code code
)
1773 gdb_assert (code
== TYPE_CODE_STRUCT
1774 || code
== TYPE_CODE_UNION
);
1775 t
= init_type (code
, 0, 0, NULL
, NULL
);
1776 TYPE_TAG_NAME (t
) = name
;
1780 /* Helper function. Append a field to a composite type. */
1783 append_composite_type_field (struct type
*t
, char *name
, struct type
*field
)
1786 TYPE_NFIELDS (t
) = TYPE_NFIELDS (t
) + 1;
1787 TYPE_FIELDS (t
) = xrealloc (TYPE_FIELDS (t
),
1788 sizeof (struct field
) * TYPE_NFIELDS (t
));
1789 f
= &(TYPE_FIELDS (t
)[TYPE_NFIELDS (t
) - 1]);
1790 memset (f
, 0, sizeof f
[0]);
1791 FIELD_TYPE (f
[0]) = field
;
1792 FIELD_NAME (f
[0]) = name
;
1793 if (TYPE_CODE (t
) == TYPE_CODE_UNION
)
1795 if (TYPE_LENGTH (t
) < TYPE_LENGTH (field
))
1796 TYPE_LENGTH (t
) = TYPE_LENGTH (field
);
1798 else if (TYPE_CODE (t
) == TYPE_CODE_STRUCT
)
1800 TYPE_LENGTH (t
) = TYPE_LENGTH (t
) + TYPE_LENGTH (field
);
1801 if (TYPE_NFIELDS (t
) > 1)
1803 FIELD_BITPOS (f
[0]) = (FIELD_BITPOS (f
[-1])
1804 + TYPE_LENGTH (field
) * TARGET_CHAR_BIT
);
1809 /* Look up a fundamental type for the specified objfile.
1810 May need to construct such a type if this is the first use.
1812 Some object file formats (ELF, COFF, etc) do not define fundamental
1813 types such as "int" or "double". Others (stabs for example), do
1814 define fundamental types.
1816 For the formats which don't provide fundamental types, gdb can create
1817 such types, using defaults reasonable for the current language and
1818 the current target machine.
1820 NOTE: This routine is obsolescent. Each debugging format reader
1821 should manage it's own fundamental types, either creating them from
1822 suitable defaults or reading them from the debugging information,
1823 whichever is appropriate. The DWARF reader has already been
1824 fixed to do this. Once the other readers are fixed, this routine
1825 will go away. Also note that fundamental types should be managed
1826 on a compilation unit basis in a multi-language environment, not
1827 on a linkage unit basis as is done here. */
1831 lookup_fundamental_type (struct objfile
*objfile
, int typeid)
1833 register struct type
**typep
;
1834 register int nbytes
;
1836 if (typeid < 0 || typeid >= FT_NUM_MEMBERS
)
1838 error ("internal error - invalid fundamental type id %d", typeid);
1841 /* If this is the first time we need a fundamental type for this objfile
1842 then we need to initialize the vector of type pointers. */
1844 if (objfile
->fundamental_types
== NULL
)
1846 nbytes
= FT_NUM_MEMBERS
* sizeof (struct type
*);
1847 objfile
->fundamental_types
= (struct type
**)
1848 obstack_alloc (&objfile
->type_obstack
, nbytes
);
1849 memset ((char *) objfile
->fundamental_types
, 0, nbytes
);
1850 OBJSTAT (objfile
, n_types
+= FT_NUM_MEMBERS
);
1853 /* Look for this particular type in the fundamental type vector. If one is
1854 not found, create and install one appropriate for the current language. */
1856 typep
= objfile
->fundamental_types
+ typeid;
1859 *typep
= create_fundamental_type (objfile
, typeid);
1866 can_dereference (struct type
*t
)
1868 /* FIXME: Should we return true for references as well as pointers? */
1872 && TYPE_CODE (t
) == TYPE_CODE_PTR
1873 && TYPE_CODE (TYPE_TARGET_TYPE (t
)) != TYPE_CODE_VOID
);
1877 is_integral_type (struct type
*t
)
1882 && ((TYPE_CODE (t
) == TYPE_CODE_INT
)
1883 || (TYPE_CODE (t
) == TYPE_CODE_ENUM
)
1884 || (TYPE_CODE (t
) == TYPE_CODE_CHAR
)
1885 || (TYPE_CODE (t
) == TYPE_CODE_RANGE
)
1886 || (TYPE_CODE (t
) == TYPE_CODE_BOOL
)));
1889 /* Chill varying string and arrays are represented as follows:
1891 struct { int __var_length; ELEMENT_TYPE[MAX_SIZE] __var_data};
1893 Return true if TYPE is such a Chill varying type. */
1896 chill_varying_type (struct type
*type
)
1898 if (TYPE_CODE (type
) != TYPE_CODE_STRUCT
1899 || TYPE_NFIELDS (type
) != 2
1900 || strcmp (TYPE_FIELD_NAME (type
, 0), "__var_length") != 0)
1905 /* Check whether BASE is an ancestor or base class or DCLASS
1906 Return 1 if so, and 0 if not.
1907 Note: callers may want to check for identity of the types before
1908 calling this function -- identical types are considered to satisfy
1909 the ancestor relationship even if they're identical */
1912 is_ancestor (struct type
*base
, struct type
*dclass
)
1916 CHECK_TYPEDEF (base
);
1917 CHECK_TYPEDEF (dclass
);
1921 if (TYPE_NAME (base
) && TYPE_NAME (dclass
) &&
1922 !strcmp (TYPE_NAME (base
), TYPE_NAME (dclass
)))
1925 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1926 if (is_ancestor (base
, TYPE_BASECLASS (dclass
, i
)))
1934 /* See whether DCLASS has a virtual table. This routine is aimed at
1935 the HP/Taligent ANSI C++ runtime model, and may not work with other
1936 runtime models. Return 1 => Yes, 0 => No. */
1939 has_vtable (struct type
*dclass
)
1941 /* In the HP ANSI C++ runtime model, a class has a vtable only if it
1942 has virtual functions or virtual bases. */
1946 if (TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
1949 /* First check for the presence of virtual bases */
1950 if (TYPE_FIELD_VIRTUAL_BITS (dclass
))
1951 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1952 if (B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass
), i
))
1955 /* Next check for virtual functions */
1956 if (TYPE_FN_FIELDLISTS (dclass
))
1957 for (i
= 0; i
< TYPE_NFN_FIELDS (dclass
); i
++)
1958 if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass
, i
), 0))
1961 /* Recurse on non-virtual bases to see if any of them needs a vtable */
1962 if (TYPE_FIELD_VIRTUAL_BITS (dclass
))
1963 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1964 if ((!B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass
), i
)) &&
1965 (has_vtable (TYPE_FIELD_TYPE (dclass
, i
))))
1968 /* Well, maybe we don't need a virtual table */
1972 /* Return a pointer to the "primary base class" of DCLASS.
1974 A NULL return indicates that DCLASS has no primary base, or that it
1975 couldn't be found (insufficient information).
1977 This routine is aimed at the HP/Taligent ANSI C++ runtime model,
1978 and may not work with other runtime models. */
1981 primary_base_class (struct type
*dclass
)
1983 /* In HP ANSI C++'s runtime model, a "primary base class" of a class
1984 is the first directly inherited, non-virtual base class that
1985 requires a virtual table */
1989 if (TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
1992 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
1993 if (!TYPE_FIELD_VIRTUAL (dclass
, i
) &&
1994 has_vtable (TYPE_FIELD_TYPE (dclass
, i
)))
1995 return TYPE_FIELD_TYPE (dclass
, i
);
2000 /* Global manipulated by virtual_base_list[_aux]() */
2002 static struct vbase
*current_vbase_list
= NULL
;
2004 /* Return a pointer to a null-terminated list of struct vbase
2005 items. The vbasetype pointer of each item in the list points to the
2006 type information for a virtual base of the argument DCLASS.
2008 Helper function for virtual_base_list().
2009 Note: the list goes backward, right-to-left. virtual_base_list()
2010 copies the items out in reverse order. */
2013 virtual_base_list_aux (struct type
*dclass
)
2015 struct vbase
*tmp_vbase
;
2018 if (TYPE_CODE (dclass
) != TYPE_CODE_CLASS
)
2021 for (i
= 0; i
< TYPE_N_BASECLASSES (dclass
); i
++)
2023 /* Recurse on this ancestor, first */
2024 virtual_base_list_aux (TYPE_FIELD_TYPE (dclass
, i
));
2026 /* If this current base is itself virtual, add it to the list */
2027 if (BASETYPE_VIA_VIRTUAL (dclass
, i
))
2029 struct type
*basetype
= TYPE_FIELD_TYPE (dclass
, i
);
2031 /* Check if base already recorded */
2032 tmp_vbase
= current_vbase_list
;
2035 if (tmp_vbase
->vbasetype
== basetype
)
2036 break; /* found it */
2037 tmp_vbase
= tmp_vbase
->next
;
2040 if (!tmp_vbase
) /* normal exit from loop */
2042 /* Allocate new item for this virtual base */
2043 tmp_vbase
= (struct vbase
*) xmalloc (sizeof (struct vbase
));
2045 /* Stick it on at the end of the list */
2046 tmp_vbase
->vbasetype
= basetype
;
2047 tmp_vbase
->next
= current_vbase_list
;
2048 current_vbase_list
= tmp_vbase
;
2051 } /* for loop over bases */
2055 /* Compute the list of virtual bases in the right order. Virtual
2056 bases are laid out in the object's memory area in order of their
2057 occurrence in a depth-first, left-to-right search through the
2060 Argument DCLASS is the type whose virtual bases are required.
2061 Return value is the address of a null-terminated array of pointers
2062 to struct type items.
2064 This routine is aimed at the HP/Taligent ANSI C++ runtime model,
2065 and may not work with other runtime models.
2067 This routine merely hands off the argument to virtual_base_list_aux()
2068 and then copies the result into an array to save space. */
2071 virtual_base_list (struct type
*dclass
)
2073 register struct vbase
*tmp_vbase
;
2074 register struct vbase
*tmp_vbase_2
;
2077 struct type
**vbase_array
;
2079 current_vbase_list
= NULL
;
2080 virtual_base_list_aux (dclass
);
2082 for (i
= 0, tmp_vbase
= current_vbase_list
; tmp_vbase
!= NULL
; i
++, tmp_vbase
= tmp_vbase
->next
)
2087 vbase_array
= (struct type
**) xmalloc ((count
+ 1) * sizeof (struct type
*));
2089 for (i
= count
- 1, tmp_vbase
= current_vbase_list
; i
>= 0; i
--, tmp_vbase
= tmp_vbase
->next
)
2090 vbase_array
[i
] = tmp_vbase
->vbasetype
;
2092 /* Get rid of constructed chain */
2093 tmp_vbase_2
= tmp_vbase
= current_vbase_list
;
2096 tmp_vbase
= tmp_vbase
->next
;
2097 xfree (tmp_vbase_2
);
2098 tmp_vbase_2
= tmp_vbase
;
2101 vbase_array
[count
] = NULL
;
2105 /* Return the length of the virtual base list of the type DCLASS. */
2108 virtual_base_list_length (struct type
*dclass
)
2111 register struct vbase
*tmp_vbase
;
2113 current_vbase_list
= NULL
;
2114 virtual_base_list_aux (dclass
);
2116 for (i
= 0, tmp_vbase
= current_vbase_list
; tmp_vbase
!= NULL
; i
++, tmp_vbase
= tmp_vbase
->next
)
2121 /* Return the number of elements of the virtual base list of the type
2122 DCLASS, ignoring those appearing in the primary base (and its
2123 primary base, recursively). */
2126 virtual_base_list_length_skip_primaries (struct type
*dclass
)
2129 register struct vbase
*tmp_vbase
;
2130 struct type
*primary
;
2132 primary
= TYPE_RUNTIME_PTR (dclass
) ? TYPE_PRIMARY_BASE (dclass
) : NULL
;
2135 return virtual_base_list_length (dclass
);
2137 current_vbase_list
= NULL
;
2138 virtual_base_list_aux (dclass
);
2140 for (i
= 0, tmp_vbase
= current_vbase_list
; tmp_vbase
!= NULL
; tmp_vbase
= tmp_vbase
->next
)
2142 if (virtual_base_index (tmp_vbase
->vbasetype
, primary
) >= 0)
2150 /* Return the index (position) of type BASE, which is a virtual base
2151 class of DCLASS, in the latter's virtual base list. A return of -1
2152 indicates "not found" or a problem. */
2155 virtual_base_index (struct type
*base
, struct type
*dclass
)
2157 register struct type
*vbase
;
2160 if ((TYPE_CODE (dclass
) != TYPE_CODE_CLASS
) ||
2161 (TYPE_CODE (base
) != TYPE_CODE_CLASS
))
2165 vbase
= virtual_base_list (dclass
)[0];
2170 vbase
= virtual_base_list (dclass
)[++i
];
2173 return vbase
? i
: -1;
2178 /* Return the index (position) of type BASE, which is a virtual base
2179 class of DCLASS, in the latter's virtual base list. Skip over all
2180 bases that may appear in the virtual base list of the primary base
2181 class of DCLASS (recursively). A return of -1 indicates "not
2182 found" or a problem. */
2185 virtual_base_index_skip_primaries (struct type
*base
, struct type
*dclass
)
2187 register struct type
*vbase
;
2189 struct type
*primary
;
2191 if ((TYPE_CODE (dclass
) != TYPE_CODE_CLASS
) ||
2192 (TYPE_CODE (base
) != TYPE_CODE_CLASS
))
2195 primary
= TYPE_RUNTIME_PTR (dclass
) ? TYPE_PRIMARY_BASE (dclass
) : NULL
;
2199 vbase
= virtual_base_list (dclass
)[0];
2202 if (!primary
|| (virtual_base_index_skip_primaries (vbase
, primary
) < 0))
2206 vbase
= virtual_base_list (dclass
)[++i
];
2209 return vbase
? j
: -1;
2212 /* Return position of a derived class DCLASS in the list of
2213 * primary bases starting with the remotest ancestor.
2214 * Position returned is 0-based. */
2217 class_index_in_primary_list (struct type
*dclass
)
2219 struct type
*pbc
; /* primary base class */
2221 /* Simply recurse on primary base */
2222 pbc
= TYPE_PRIMARY_BASE (dclass
);
2224 return 1 + class_index_in_primary_list (pbc
);
2229 /* Return a count of the number of virtual functions a type has.
2230 * This includes all the virtual functions it inherits from its
2234 /* pai: FIXME This doesn't do the right thing: count redefined virtual
2235 * functions only once (latest redefinition)
2239 count_virtual_fns (struct type
*dclass
)
2241 int fn
, oi
; /* function and overloaded instance indices */
2242 int vfuncs
; /* count to return */
2244 /* recurse on bases that can share virtual table */
2245 struct type
*pbc
= primary_base_class (dclass
);
2247 vfuncs
= count_virtual_fns (pbc
);
2251 for (fn
= 0; fn
< TYPE_NFN_FIELDS (dclass
); fn
++)
2252 for (oi
= 0; oi
< TYPE_FN_FIELDLIST_LENGTH (dclass
, fn
); oi
++)
2253 if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass
, fn
), oi
))
2261 /* Functions for overload resolution begin here */
2263 /* Compare two badness vectors A and B and return the result.
2264 * 0 => A and B are identical
2265 * 1 => A and B are incomparable
2266 * 2 => A is better than B
2267 * 3 => A is worse than B */
2270 compare_badness (struct badness_vector
*a
, struct badness_vector
*b
)
2274 short found_pos
= 0; /* any positives in c? */
2275 short found_neg
= 0; /* any negatives in c? */
2277 /* differing lengths => incomparable */
2278 if (a
->length
!= b
->length
)
2281 /* Subtract b from a */
2282 for (i
= 0; i
< a
->length
; i
++)
2284 tmp
= a
->rank
[i
] - b
->rank
[i
];
2294 return 1; /* incomparable */
2296 return 3; /* A > B */
2302 return 2; /* A < B */
2304 return 0; /* A == B */
2308 /* Rank a function by comparing its parameter types (PARMS, length NPARMS),
2309 * to the types of an argument list (ARGS, length NARGS).
2310 * Return a pointer to a badness vector. This has NARGS + 1 entries. */
2312 struct badness_vector
*
2313 rank_function (struct type
**parms
, int nparms
, struct type
**args
, int nargs
)
2316 struct badness_vector
*bv
;
2317 int min_len
= nparms
< nargs
? nparms
: nargs
;
2319 bv
= xmalloc (sizeof (struct badness_vector
));
2320 bv
->length
= nargs
+ 1; /* add 1 for the length-match rank */
2321 bv
->rank
= xmalloc ((nargs
+ 1) * sizeof (int));
2323 /* First compare the lengths of the supplied lists.
2324 * If there is a mismatch, set it to a high value. */
2326 /* pai/1997-06-03 FIXME: when we have debug info about default
2327 * arguments and ellipsis parameter lists, we should consider those
2328 * and rank the length-match more finely. */
2330 LENGTH_MATCH (bv
) = (nargs
!= nparms
) ? LENGTH_MISMATCH_BADNESS
: 0;
2332 /* Now rank all the parameters of the candidate function */
2333 for (i
= 1; i
<= min_len
; i
++)
2334 bv
->rank
[i
] = rank_one_type (parms
[i
-1], args
[i
-1]);
2336 /* If more arguments than parameters, add dummy entries */
2337 for (i
= min_len
+ 1; i
<= nargs
; i
++)
2338 bv
->rank
[i
] = TOO_FEW_PARAMS_BADNESS
;
2343 /* Compare one type (PARM) for compatibility with another (ARG).
2344 * PARM is intended to be the parameter type of a function; and
2345 * ARG is the supplied argument's type. This function tests if
2346 * the latter can be converted to the former.
2348 * Return 0 if they are identical types;
2349 * Otherwise, return an integer which corresponds to how compatible
2350 * PARM is to ARG. The higher the return value, the worse the match.
2351 * Generally the "bad" conversions are all uniformly assigned a 100 */
2354 rank_one_type (struct type
*parm
, struct type
*arg
)
2356 /* Identical type pointers */
2357 /* However, this still doesn't catch all cases of same type for arg
2358 * and param. The reason is that builtin types are different from
2359 * the same ones constructed from the object. */
2363 /* Resolve typedefs */
2364 if (TYPE_CODE (parm
) == TYPE_CODE_TYPEDEF
)
2365 parm
= check_typedef (parm
);
2366 if (TYPE_CODE (arg
) == TYPE_CODE_TYPEDEF
)
2367 arg
= check_typedef (arg
);
2370 Well, damnit, if the names are exactly the same,
2371 i'll say they are exactly the same. This happens when we generate
2372 method stubs. The types won't point to the same address, but they
2373 really are the same.
2376 if (TYPE_NAME (parm
) && TYPE_NAME (arg
) &&
2377 !strcmp (TYPE_NAME (parm
), TYPE_NAME (arg
)))
2380 /* Check if identical after resolving typedefs */
2384 /* See through references, since we can almost make non-references
2386 if (TYPE_CODE (arg
) == TYPE_CODE_REF
)
2387 return (rank_one_type (parm
, TYPE_TARGET_TYPE (arg
))
2388 + REFERENCE_CONVERSION_BADNESS
);
2389 if (TYPE_CODE (parm
) == TYPE_CODE_REF
)
2390 return (rank_one_type (TYPE_TARGET_TYPE (parm
), arg
)
2391 + REFERENCE_CONVERSION_BADNESS
);
2393 /* Debugging only. */
2394 fprintf_filtered (gdb_stderr
,"------ Arg is %s [%d], parm is %s [%d]\n",
2395 TYPE_NAME (arg
), TYPE_CODE (arg
), TYPE_NAME (parm
), TYPE_CODE (parm
));
2397 /* x -> y means arg of type x being supplied for parameter of type y */
2399 switch (TYPE_CODE (parm
))
2402 switch (TYPE_CODE (arg
))
2405 if (TYPE_CODE (TYPE_TARGET_TYPE (parm
)) == TYPE_CODE_VOID
)
2406 return VOID_PTR_CONVERSION_BADNESS
;
2408 return rank_one_type (TYPE_TARGET_TYPE (parm
), TYPE_TARGET_TYPE (arg
));
2409 case TYPE_CODE_ARRAY
:
2410 return rank_one_type (TYPE_TARGET_TYPE (parm
), TYPE_TARGET_TYPE (arg
));
2411 case TYPE_CODE_FUNC
:
2412 return rank_one_type (TYPE_TARGET_TYPE (parm
), arg
);
2414 case TYPE_CODE_ENUM
:
2415 case TYPE_CODE_CHAR
:
2416 case TYPE_CODE_RANGE
:
2417 case TYPE_CODE_BOOL
:
2418 return POINTER_CONVERSION_BADNESS
;
2420 return INCOMPATIBLE_TYPE_BADNESS
;
2422 case TYPE_CODE_ARRAY
:
2423 switch (TYPE_CODE (arg
))
2426 case TYPE_CODE_ARRAY
:
2427 return rank_one_type (TYPE_TARGET_TYPE (parm
), TYPE_TARGET_TYPE (arg
));
2429 return INCOMPATIBLE_TYPE_BADNESS
;
2431 case TYPE_CODE_FUNC
:
2432 switch (TYPE_CODE (arg
))
2434 case TYPE_CODE_PTR
: /* funcptr -> func */
2435 return rank_one_type (parm
, TYPE_TARGET_TYPE (arg
));
2437 return INCOMPATIBLE_TYPE_BADNESS
;
2440 switch (TYPE_CODE (arg
))
2443 if (TYPE_LENGTH (arg
) == TYPE_LENGTH (parm
))
2445 /* Deal with signed, unsigned, and plain chars and
2446 signed and unsigned ints */
2447 if (TYPE_NOSIGN (parm
))
2449 /* This case only for character types */
2450 if (TYPE_NOSIGN (arg
)) /* plain char -> plain char */
2453 return INTEGER_COERCION_BADNESS
; /* signed/unsigned char -> plain char */
2455 else if (TYPE_UNSIGNED (parm
))
2457 if (TYPE_UNSIGNED (arg
))
2459 if (!strcmp_iw (TYPE_NAME (parm
), TYPE_NAME (arg
)))
2460 return 0; /* unsigned int -> unsigned int, or unsigned long -> unsigned long */
2461 else if (!strcmp_iw (TYPE_NAME (arg
), "int") && !strcmp_iw (TYPE_NAME (parm
), "long"))
2462 return INTEGER_PROMOTION_BADNESS
; /* unsigned int -> unsigned long */
2464 return INTEGER_COERCION_BADNESS
; /* unsigned long -> unsigned int */
2468 if (!strcmp_iw (TYPE_NAME (arg
), "long") && !strcmp_iw (TYPE_NAME (parm
), "int"))
2469 return INTEGER_COERCION_BADNESS
; /* signed long -> unsigned int */
2471 return INTEGER_CONVERSION_BADNESS
; /* signed int/long -> unsigned int/long */
2474 else if (!TYPE_NOSIGN (arg
) && !TYPE_UNSIGNED (arg
))
2476 if (!strcmp_iw (TYPE_NAME (parm
), TYPE_NAME (arg
)))
2478 else if (!strcmp_iw (TYPE_NAME (arg
), "int") && !strcmp_iw (TYPE_NAME (parm
), "long"))
2479 return INTEGER_PROMOTION_BADNESS
;
2481 return INTEGER_COERCION_BADNESS
;
2484 return INTEGER_COERCION_BADNESS
;
2486 else if (TYPE_LENGTH (arg
) < TYPE_LENGTH (parm
))
2487 return INTEGER_PROMOTION_BADNESS
;
2489 return INTEGER_COERCION_BADNESS
;
2490 case TYPE_CODE_ENUM
:
2491 case TYPE_CODE_CHAR
:
2492 case TYPE_CODE_RANGE
:
2493 case TYPE_CODE_BOOL
:
2494 return INTEGER_PROMOTION_BADNESS
;
2496 return INT_FLOAT_CONVERSION_BADNESS
;
2498 return NS_POINTER_CONVERSION_BADNESS
;
2500 return INCOMPATIBLE_TYPE_BADNESS
;
2503 case TYPE_CODE_ENUM
:
2504 switch (TYPE_CODE (arg
))
2507 case TYPE_CODE_CHAR
:
2508 case TYPE_CODE_RANGE
:
2509 case TYPE_CODE_BOOL
:
2510 case TYPE_CODE_ENUM
:
2511 return INTEGER_COERCION_BADNESS
;
2513 return INT_FLOAT_CONVERSION_BADNESS
;
2515 return INCOMPATIBLE_TYPE_BADNESS
;
2518 case TYPE_CODE_CHAR
:
2519 switch (TYPE_CODE (arg
))
2521 case TYPE_CODE_RANGE
:
2522 case TYPE_CODE_BOOL
:
2523 case TYPE_CODE_ENUM
:
2524 return INTEGER_COERCION_BADNESS
;
2526 return INT_FLOAT_CONVERSION_BADNESS
;
2528 if (TYPE_LENGTH (arg
) > TYPE_LENGTH (parm
))
2529 return INTEGER_COERCION_BADNESS
;
2530 else if (TYPE_LENGTH (arg
) < TYPE_LENGTH (parm
))
2531 return INTEGER_PROMOTION_BADNESS
;
2532 /* >>> !! else fall through !! <<< */
2533 case TYPE_CODE_CHAR
:
2534 /* Deal with signed, unsigned, and plain chars for C++
2535 and with int cases falling through from previous case */
2536 if (TYPE_NOSIGN (parm
))
2538 if (TYPE_NOSIGN (arg
))
2541 return INTEGER_COERCION_BADNESS
;
2543 else if (TYPE_UNSIGNED (parm
))
2545 if (TYPE_UNSIGNED (arg
))
2548 return INTEGER_PROMOTION_BADNESS
;
2550 else if (!TYPE_NOSIGN (arg
) && !TYPE_UNSIGNED (arg
))
2553 return INTEGER_COERCION_BADNESS
;
2555 return INCOMPATIBLE_TYPE_BADNESS
;
2558 case TYPE_CODE_RANGE
:
2559 switch (TYPE_CODE (arg
))
2562 case TYPE_CODE_CHAR
:
2563 case TYPE_CODE_RANGE
:
2564 case TYPE_CODE_BOOL
:
2565 case TYPE_CODE_ENUM
:
2566 return INTEGER_COERCION_BADNESS
;
2568 return INT_FLOAT_CONVERSION_BADNESS
;
2570 return INCOMPATIBLE_TYPE_BADNESS
;
2573 case TYPE_CODE_BOOL
:
2574 switch (TYPE_CODE (arg
))
2577 case TYPE_CODE_CHAR
:
2578 case TYPE_CODE_RANGE
:
2579 case TYPE_CODE_ENUM
:
2582 return BOOLEAN_CONVERSION_BADNESS
;
2583 case TYPE_CODE_BOOL
:
2586 return INCOMPATIBLE_TYPE_BADNESS
;
2590 switch (TYPE_CODE (arg
))
2593 if (TYPE_LENGTH (arg
) < TYPE_LENGTH (parm
))
2594 return FLOAT_PROMOTION_BADNESS
;
2595 else if (TYPE_LENGTH (arg
) == TYPE_LENGTH (parm
))
2598 return FLOAT_CONVERSION_BADNESS
;
2600 case TYPE_CODE_BOOL
:
2601 case TYPE_CODE_ENUM
:
2602 case TYPE_CODE_RANGE
:
2603 case TYPE_CODE_CHAR
:
2604 return INT_FLOAT_CONVERSION_BADNESS
;
2606 return INCOMPATIBLE_TYPE_BADNESS
;
2609 case TYPE_CODE_COMPLEX
:
2610 switch (TYPE_CODE (arg
))
2611 { /* Strictly not needed for C++, but... */
2613 return FLOAT_PROMOTION_BADNESS
;
2614 case TYPE_CODE_COMPLEX
:
2617 return INCOMPATIBLE_TYPE_BADNESS
;
2620 case TYPE_CODE_STRUCT
:
2621 /* currently same as TYPE_CODE_CLASS */
2622 switch (TYPE_CODE (arg
))
2624 case TYPE_CODE_STRUCT
:
2625 /* Check for derivation */
2626 if (is_ancestor (parm
, arg
))
2627 return BASE_CONVERSION_BADNESS
;
2628 /* else fall through */
2630 return INCOMPATIBLE_TYPE_BADNESS
;
2633 case TYPE_CODE_UNION
:
2634 switch (TYPE_CODE (arg
))
2636 case TYPE_CODE_UNION
:
2638 return INCOMPATIBLE_TYPE_BADNESS
;
2641 case TYPE_CODE_MEMBER
:
2642 switch (TYPE_CODE (arg
))
2645 return INCOMPATIBLE_TYPE_BADNESS
;
2648 case TYPE_CODE_METHOD
:
2649 switch (TYPE_CODE (arg
))
2653 return INCOMPATIBLE_TYPE_BADNESS
;
2657 switch (TYPE_CODE (arg
))
2661 return INCOMPATIBLE_TYPE_BADNESS
;
2666 switch (TYPE_CODE (arg
))
2670 return rank_one_type (TYPE_FIELD_TYPE (parm
, 0), TYPE_FIELD_TYPE (arg
, 0));
2672 return INCOMPATIBLE_TYPE_BADNESS
;
2675 case TYPE_CODE_VOID
:
2677 return INCOMPATIBLE_TYPE_BADNESS
;
2678 } /* switch (TYPE_CODE (arg)) */
2682 /* End of functions for overload resolution */
2685 print_bit_vector (B_TYPE
*bits
, int nbits
)
2689 for (bitno
= 0; bitno
< nbits
; bitno
++)
2691 if ((bitno
% 8) == 0)
2693 puts_filtered (" ");
2695 if (B_TST (bits
, bitno
))
2697 printf_filtered ("1");
2701 printf_filtered ("0");
2706 /* The args list is a strange beast. It is either terminated by a NULL
2707 pointer for varargs functions, or by a pointer to a TYPE_CODE_VOID
2708 type for normal fixed argcount functions. (FIXME someday)
2709 Also note the first arg should be the "this" pointer, we may not want to
2710 include it since we may get into a infinitely recursive situation. */
2713 print_arg_types (struct type
**args
, int spaces
)
2717 while (*args
!= NULL
)
2719 recursive_dump_type (*args
, spaces
+ 2);
2720 if (TYPE_CODE (*args
++) == TYPE_CODE_VOID
)
2729 dump_fn_fieldlists (struct type
*type
, int spaces
)
2735 printfi_filtered (spaces
, "fn_fieldlists ");
2736 gdb_print_host_address (TYPE_FN_FIELDLISTS (type
), gdb_stdout
);
2737 printf_filtered ("\n");
2738 for (method_idx
= 0; method_idx
< TYPE_NFN_FIELDS (type
); method_idx
++)
2740 f
= TYPE_FN_FIELDLIST1 (type
, method_idx
);
2741 printfi_filtered (spaces
+ 2, "[%d] name '%s' (",
2743 TYPE_FN_FIELDLIST_NAME (type
, method_idx
));
2744 gdb_print_host_address (TYPE_FN_FIELDLIST_NAME (type
, method_idx
),
2746 printf_filtered (") length %d\n",
2747 TYPE_FN_FIELDLIST_LENGTH (type
, method_idx
));
2748 for (overload_idx
= 0;
2749 overload_idx
< TYPE_FN_FIELDLIST_LENGTH (type
, method_idx
);
2752 printfi_filtered (spaces
+ 4, "[%d] physname '%s' (",
2754 TYPE_FN_FIELD_PHYSNAME (f
, overload_idx
));
2755 gdb_print_host_address (TYPE_FN_FIELD_PHYSNAME (f
, overload_idx
),
2757 printf_filtered (")\n");
2758 printfi_filtered (spaces
+ 8, "type ");
2759 gdb_print_host_address (TYPE_FN_FIELD_TYPE (f
, overload_idx
), gdb_stdout
);
2760 printf_filtered ("\n");
2762 recursive_dump_type (TYPE_FN_FIELD_TYPE (f
, overload_idx
),
2765 printfi_filtered (spaces
+ 8, "args ");
2766 gdb_print_host_address (TYPE_FN_FIELD_ARGS (f
, overload_idx
), gdb_stdout
);
2767 printf_filtered ("\n");
2769 print_arg_types (TYPE_FN_FIELD_ARGS (f
, overload_idx
), spaces
);
2770 printfi_filtered (spaces
+ 8, "fcontext ");
2771 gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f
, overload_idx
),
2773 printf_filtered ("\n");
2775 printfi_filtered (spaces
+ 8, "is_const %d\n",
2776 TYPE_FN_FIELD_CONST (f
, overload_idx
));
2777 printfi_filtered (spaces
+ 8, "is_volatile %d\n",
2778 TYPE_FN_FIELD_VOLATILE (f
, overload_idx
));
2779 printfi_filtered (spaces
+ 8, "is_private %d\n",
2780 TYPE_FN_FIELD_PRIVATE (f
, overload_idx
));
2781 printfi_filtered (spaces
+ 8, "is_protected %d\n",
2782 TYPE_FN_FIELD_PROTECTED (f
, overload_idx
));
2783 printfi_filtered (spaces
+ 8, "is_stub %d\n",
2784 TYPE_FN_FIELD_STUB (f
, overload_idx
));
2785 printfi_filtered (spaces
+ 8, "voffset %u\n",
2786 TYPE_FN_FIELD_VOFFSET (f
, overload_idx
));
2792 print_cplus_stuff (struct type
*type
, int spaces
)
2794 printfi_filtered (spaces
, "n_baseclasses %d\n",
2795 TYPE_N_BASECLASSES (type
));
2796 printfi_filtered (spaces
, "nfn_fields %d\n",
2797 TYPE_NFN_FIELDS (type
));
2798 printfi_filtered (spaces
, "nfn_fields_total %d\n",
2799 TYPE_NFN_FIELDS_TOTAL (type
));
2800 if (TYPE_N_BASECLASSES (type
) > 0)
2802 printfi_filtered (spaces
, "virtual_field_bits (%d bits at *",
2803 TYPE_N_BASECLASSES (type
));
2804 gdb_print_host_address (TYPE_FIELD_VIRTUAL_BITS (type
), gdb_stdout
);
2805 printf_filtered (")");
2807 print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type
),
2808 TYPE_N_BASECLASSES (type
));
2809 puts_filtered ("\n");
2811 if (TYPE_NFIELDS (type
) > 0)
2813 if (TYPE_FIELD_PRIVATE_BITS (type
) != NULL
)
2815 printfi_filtered (spaces
, "private_field_bits (%d bits at *",
2816 TYPE_NFIELDS (type
));
2817 gdb_print_host_address (TYPE_FIELD_PRIVATE_BITS (type
), gdb_stdout
);
2818 printf_filtered (")");
2819 print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type
),
2820 TYPE_NFIELDS (type
));
2821 puts_filtered ("\n");
2823 if (TYPE_FIELD_PROTECTED_BITS (type
) != NULL
)
2825 printfi_filtered (spaces
, "protected_field_bits (%d bits at *",
2826 TYPE_NFIELDS (type
));
2827 gdb_print_host_address (TYPE_FIELD_PROTECTED_BITS (type
), gdb_stdout
);
2828 printf_filtered (")");
2829 print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type
),
2830 TYPE_NFIELDS (type
));
2831 puts_filtered ("\n");
2834 if (TYPE_NFN_FIELDS (type
) > 0)
2836 dump_fn_fieldlists (type
, spaces
);
2841 print_bound_type (int bt
)
2845 case BOUND_CANNOT_BE_DETERMINED
:
2846 printf_filtered ("(BOUND_CANNOT_BE_DETERMINED)");
2848 case BOUND_BY_REF_ON_STACK
:
2849 printf_filtered ("(BOUND_BY_REF_ON_STACK)");
2851 case BOUND_BY_VALUE_ON_STACK
:
2852 printf_filtered ("(BOUND_BY_VALUE_ON_STACK)");
2854 case BOUND_BY_REF_IN_REG
:
2855 printf_filtered ("(BOUND_BY_REF_IN_REG)");
2857 case BOUND_BY_VALUE_IN_REG
:
2858 printf_filtered ("(BOUND_BY_VALUE_IN_REG)");
2861 printf_filtered ("(BOUND_SIMPLE)");
2864 printf_filtered ("(unknown bound type)");
2869 static struct obstack dont_print_type_obstack
;
2872 recursive_dump_type (struct type
*type
, int spaces
)
2877 obstack_begin (&dont_print_type_obstack
, 0);
2879 if (TYPE_NFIELDS (type
) > 0
2880 || (TYPE_CPLUS_SPECIFIC (type
) && TYPE_NFN_FIELDS (type
) > 0))
2882 struct type
**first_dont_print
2883 = (struct type
**) obstack_base (&dont_print_type_obstack
);
2885 int i
= (struct type
**) obstack_next_free (&dont_print_type_obstack
)
2890 if (type
== first_dont_print
[i
])
2892 printfi_filtered (spaces
, "type node ");
2893 gdb_print_host_address (type
, gdb_stdout
);
2894 printf_filtered (" <same as already seen type>\n");
2899 obstack_ptr_grow (&dont_print_type_obstack
, type
);
2902 printfi_filtered (spaces
, "type node ");
2903 gdb_print_host_address (type
, gdb_stdout
);
2904 printf_filtered ("\n");
2905 printfi_filtered (spaces
, "name '%s' (",
2906 TYPE_NAME (type
) ? TYPE_NAME (type
) : "<NULL>");
2907 gdb_print_host_address (TYPE_NAME (type
), gdb_stdout
);
2908 printf_filtered (")\n");
2909 printfi_filtered (spaces
, "tagname '%s' (",
2910 TYPE_TAG_NAME (type
) ? TYPE_TAG_NAME (type
) : "<NULL>");
2911 gdb_print_host_address (TYPE_TAG_NAME (type
), gdb_stdout
);
2912 printf_filtered (")\n");
2913 printfi_filtered (spaces
, "code 0x%x ", TYPE_CODE (type
));
2914 switch (TYPE_CODE (type
))
2916 case TYPE_CODE_UNDEF
:
2917 printf_filtered ("(TYPE_CODE_UNDEF)");
2920 printf_filtered ("(TYPE_CODE_PTR)");
2922 case TYPE_CODE_ARRAY
:
2923 printf_filtered ("(TYPE_CODE_ARRAY)");
2925 case TYPE_CODE_STRUCT
:
2926 printf_filtered ("(TYPE_CODE_STRUCT)");
2928 case TYPE_CODE_UNION
:
2929 printf_filtered ("(TYPE_CODE_UNION)");
2931 case TYPE_CODE_ENUM
:
2932 printf_filtered ("(TYPE_CODE_ENUM)");
2934 case TYPE_CODE_FUNC
:
2935 printf_filtered ("(TYPE_CODE_FUNC)");
2938 printf_filtered ("(TYPE_CODE_INT)");
2941 printf_filtered ("(TYPE_CODE_FLT)");
2943 case TYPE_CODE_VOID
:
2944 printf_filtered ("(TYPE_CODE_VOID)");
2947 printf_filtered ("(TYPE_CODE_SET)");
2949 case TYPE_CODE_RANGE
:
2950 printf_filtered ("(TYPE_CODE_RANGE)");
2952 case TYPE_CODE_STRING
:
2953 printf_filtered ("(TYPE_CODE_STRING)");
2955 case TYPE_CODE_BITSTRING
:
2956 printf_filtered ("(TYPE_CODE_BITSTRING)");
2958 case TYPE_CODE_ERROR
:
2959 printf_filtered ("(TYPE_CODE_ERROR)");
2961 case TYPE_CODE_MEMBER
:
2962 printf_filtered ("(TYPE_CODE_MEMBER)");
2964 case TYPE_CODE_METHOD
:
2965 printf_filtered ("(TYPE_CODE_METHOD)");
2968 printf_filtered ("(TYPE_CODE_REF)");
2970 case TYPE_CODE_CHAR
:
2971 printf_filtered ("(TYPE_CODE_CHAR)");
2973 case TYPE_CODE_BOOL
:
2974 printf_filtered ("(TYPE_CODE_BOOL)");
2976 case TYPE_CODE_COMPLEX
:
2977 printf_filtered ("(TYPE_CODE_COMPLEX)");
2979 case TYPE_CODE_TYPEDEF
:
2980 printf_filtered ("(TYPE_CODE_TYPEDEF)");
2982 case TYPE_CODE_TEMPLATE
:
2983 printf_filtered ("(TYPE_CODE_TEMPLATE)");
2985 case TYPE_CODE_TEMPLATE_ARG
:
2986 printf_filtered ("(TYPE_CODE_TEMPLATE_ARG)");
2989 printf_filtered ("(UNKNOWN TYPE CODE)");
2992 puts_filtered ("\n");
2993 printfi_filtered (spaces
, "length %d\n", TYPE_LENGTH (type
));
2994 printfi_filtered (spaces
, "upper_bound_type 0x%x ",
2995 TYPE_ARRAY_UPPER_BOUND_TYPE (type
));
2996 print_bound_type (TYPE_ARRAY_UPPER_BOUND_TYPE (type
));
2997 puts_filtered ("\n");
2998 printfi_filtered (spaces
, "lower_bound_type 0x%x ",
2999 TYPE_ARRAY_LOWER_BOUND_TYPE (type
));
3000 print_bound_type (TYPE_ARRAY_LOWER_BOUND_TYPE (type
));
3001 puts_filtered ("\n");
3002 printfi_filtered (spaces
, "objfile ");
3003 gdb_print_host_address (TYPE_OBJFILE (type
), gdb_stdout
);
3004 printf_filtered ("\n");
3005 printfi_filtered (spaces
, "target_type ");
3006 gdb_print_host_address (TYPE_TARGET_TYPE (type
), gdb_stdout
);
3007 printf_filtered ("\n");
3008 if (TYPE_TARGET_TYPE (type
) != NULL
)
3010 recursive_dump_type (TYPE_TARGET_TYPE (type
), spaces
+ 2);
3012 printfi_filtered (spaces
, "pointer_type ");
3013 gdb_print_host_address (TYPE_POINTER_TYPE (type
), gdb_stdout
);
3014 printf_filtered ("\n");
3015 printfi_filtered (spaces
, "reference_type ");
3016 gdb_print_host_address (TYPE_REFERENCE_TYPE (type
), gdb_stdout
);
3017 printf_filtered ("\n");
3018 printfi_filtered (spaces
, "type_chain ");
3019 gdb_print_host_address (TYPE_CHAIN (type
), gdb_stdout
);
3020 printf_filtered ("\n");
3021 printfi_filtered (spaces
, "instance_flags 0x%x", TYPE_INSTANCE_FLAGS (type
));
3022 if (TYPE_CONST (type
))
3024 puts_filtered (" TYPE_FLAG_CONST");
3026 if (TYPE_VOLATILE (type
))
3028 puts_filtered (" TYPE_FLAG_VOLATILE");
3030 if (TYPE_CODE_SPACE (type
))
3032 puts_filtered (" TYPE_FLAG_CODE_SPACE");
3034 if (TYPE_DATA_SPACE (type
))
3036 puts_filtered (" TYPE_FLAG_DATA_SPACE");
3038 puts_filtered ("\n");
3039 printfi_filtered (spaces
, "flags 0x%x", TYPE_FLAGS (type
));
3040 if (TYPE_UNSIGNED (type
))
3042 puts_filtered (" TYPE_FLAG_UNSIGNED");
3044 if (TYPE_NOSIGN (type
))
3046 puts_filtered (" TYPE_FLAG_NOSIGN");
3048 if (TYPE_STUB (type
))
3050 puts_filtered (" TYPE_FLAG_STUB");
3052 if (TYPE_TARGET_STUB (type
))
3054 puts_filtered (" TYPE_FLAG_TARGET_STUB");
3056 if (TYPE_STATIC (type
))
3058 puts_filtered (" TYPE_FLAG_STATIC");
3060 if (TYPE_PROTOTYPED (type
))
3062 puts_filtered (" TYPE_FLAG_PROTOTYPED");
3064 if (TYPE_INCOMPLETE (type
))
3066 puts_filtered (" TYPE_FLAG_INCOMPLETE");
3068 if (TYPE_VARARGS (type
))
3070 puts_filtered (" TYPE_FLAG_VARARGS");
3072 /* This is used for things like AltiVec registers on ppc. Gcc emits
3073 an attribute for the array type, which tells whether or not we
3074 have a vector, instead of a regular array. */
3075 if (TYPE_VECTOR (type
))
3077 puts_filtered (" TYPE_FLAG_VECTOR");
3079 puts_filtered ("\n");
3080 printfi_filtered (spaces
, "nfields %d ", TYPE_NFIELDS (type
));
3081 gdb_print_host_address (TYPE_FIELDS (type
), gdb_stdout
);
3082 puts_filtered ("\n");
3083 for (idx
= 0; idx
< TYPE_NFIELDS (type
); idx
++)
3085 printfi_filtered (spaces
+ 2,
3086 "[%d] bitpos %d bitsize %d type ",
3087 idx
, TYPE_FIELD_BITPOS (type
, idx
),
3088 TYPE_FIELD_BITSIZE (type
, idx
));
3089 gdb_print_host_address (TYPE_FIELD_TYPE (type
, idx
), gdb_stdout
);
3090 printf_filtered (" name '%s' (",
3091 TYPE_FIELD_NAME (type
, idx
) != NULL
3092 ? TYPE_FIELD_NAME (type
, idx
)
3094 gdb_print_host_address (TYPE_FIELD_NAME (type
, idx
), gdb_stdout
);
3095 printf_filtered (")\n");
3096 if (TYPE_FIELD_TYPE (type
, idx
) != NULL
)
3098 recursive_dump_type (TYPE_FIELD_TYPE (type
, idx
), spaces
+ 4);
3101 printfi_filtered (spaces
, "vptr_basetype ");
3102 gdb_print_host_address (TYPE_VPTR_BASETYPE (type
), gdb_stdout
);
3103 puts_filtered ("\n");
3104 if (TYPE_VPTR_BASETYPE (type
) != NULL
)
3106 recursive_dump_type (TYPE_VPTR_BASETYPE (type
), spaces
+ 2);
3108 printfi_filtered (spaces
, "vptr_fieldno %d\n", TYPE_VPTR_FIELDNO (type
));
3109 switch (TYPE_CODE (type
))
3111 case TYPE_CODE_METHOD
:
3112 case TYPE_CODE_FUNC
:
3113 printfi_filtered (spaces
, "arg_types ");
3114 gdb_print_host_address (TYPE_ARG_TYPES (type
), gdb_stdout
);
3115 puts_filtered ("\n");
3116 print_arg_types (TYPE_ARG_TYPES (type
), spaces
);
3119 case TYPE_CODE_STRUCT
:
3120 printfi_filtered (spaces
, "cplus_stuff ");
3121 gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type
), gdb_stdout
);
3122 puts_filtered ("\n");
3123 print_cplus_stuff (type
, spaces
);
3127 printfi_filtered (spaces
, "floatformat ");
3128 if (TYPE_FLOATFORMAT (type
) == NULL
3129 || TYPE_FLOATFORMAT (type
)->name
== NULL
)
3130 puts_filtered ("(null)");
3132 puts_filtered (TYPE_FLOATFORMAT (type
)->name
);
3133 puts_filtered ("\n");
3137 /* We have to pick one of the union types to be able print and test
3138 the value. Pick cplus_struct_type, even though we know it isn't
3139 any particular one. */
3140 printfi_filtered (spaces
, "type_specific ");
3141 gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type
), gdb_stdout
);
3142 if (TYPE_CPLUS_SPECIFIC (type
) != NULL
)
3144 printf_filtered (" (unknown data form)");
3146 printf_filtered ("\n");
3151 obstack_free (&dont_print_type_obstack
, NULL
);
3154 static void build_gdbtypes (void);
3156 build_gdbtypes (void)
3159 init_type (TYPE_CODE_VOID
, 1,
3161 "void", (struct objfile
*) NULL
);
3163 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3165 | (TARGET_CHAR_SIGNED
? 0 : TYPE_FLAG_UNSIGNED
)),
3166 "char", (struct objfile
*) NULL
);
3167 builtin_type_true_char
=
3168 init_type (TYPE_CODE_CHAR
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3170 "true character", (struct objfile
*) NULL
);
3171 builtin_type_signed_char
=
3172 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3174 "signed char", (struct objfile
*) NULL
);
3175 builtin_type_unsigned_char
=
3176 init_type (TYPE_CODE_INT
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3178 "unsigned char", (struct objfile
*) NULL
);
3179 builtin_type_short
=
3180 init_type (TYPE_CODE_INT
, TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
3182 "short", (struct objfile
*) NULL
);
3183 builtin_type_unsigned_short
=
3184 init_type (TYPE_CODE_INT
, TARGET_SHORT_BIT
/ TARGET_CHAR_BIT
,
3186 "unsigned short", (struct objfile
*) NULL
);
3188 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
3190 "int", (struct objfile
*) NULL
);
3191 builtin_type_unsigned_int
=
3192 init_type (TYPE_CODE_INT
, TARGET_INT_BIT
/ TARGET_CHAR_BIT
,
3194 "unsigned int", (struct objfile
*) NULL
);
3196 init_type (TYPE_CODE_INT
, TARGET_LONG_BIT
/ TARGET_CHAR_BIT
,
3198 "long", (struct objfile
*) NULL
);
3199 builtin_type_unsigned_long
=
3200 init_type (TYPE_CODE_INT
, TARGET_LONG_BIT
/ TARGET_CHAR_BIT
,
3202 "unsigned long", (struct objfile
*) NULL
);
3203 builtin_type_long_long
=
3204 init_type (TYPE_CODE_INT
, TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
,
3206 "long long", (struct objfile
*) NULL
);
3207 builtin_type_unsigned_long_long
=
3208 init_type (TYPE_CODE_INT
, TARGET_LONG_LONG_BIT
/ TARGET_CHAR_BIT
,
3210 "unsigned long long", (struct objfile
*) NULL
);
3211 builtin_type_float
=
3212 init_type (TYPE_CODE_FLT
, TARGET_FLOAT_BIT
/ TARGET_CHAR_BIT
,
3214 "float", (struct objfile
*) NULL
);
3215 /* vinschen@redhat.com 2002-02-08:
3216 The below lines are disabled since they are doing the wrong
3217 thing for non-multiarch targets. They are setting the correct
3218 type of floats for the target but while on multiarch targets
3219 this is done everytime the architecture changes, it's done on
3220 non-multiarch targets only on startup, leaving the wrong values
3221 in even if the architecture changes (eg. from big-endian to
3224 TYPE_FLOATFORMAT (builtin_type_float
) = TARGET_FLOAT_FORMAT
;
3226 builtin_type_double
=
3227 init_type (TYPE_CODE_FLT
, TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
3229 "double", (struct objfile
*) NULL
);
3231 TYPE_FLOATFORMAT (builtin_type_double
) = TARGET_DOUBLE_FORMAT
;
3233 builtin_type_long_double
=
3234 init_type (TYPE_CODE_FLT
, TARGET_LONG_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
3236 "long double", (struct objfile
*) NULL
);
3238 TYPE_FLOATFORMAT (builtin_type_long_double
) = TARGET_LONG_DOUBLE_FORMAT
;
3240 builtin_type_complex
=
3241 init_type (TYPE_CODE_COMPLEX
, 2 * TARGET_FLOAT_BIT
/ TARGET_CHAR_BIT
,
3243 "complex", (struct objfile
*) NULL
);
3244 TYPE_TARGET_TYPE (builtin_type_complex
) = builtin_type_float
;
3245 builtin_type_double_complex
=
3246 init_type (TYPE_CODE_COMPLEX
, 2 * TARGET_DOUBLE_BIT
/ TARGET_CHAR_BIT
,
3248 "double complex", (struct objfile
*) NULL
);
3249 TYPE_TARGET_TYPE (builtin_type_double_complex
) = builtin_type_double
;
3250 builtin_type_string
=
3251 init_type (TYPE_CODE_STRING
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3253 "string", (struct objfile
*) NULL
);
3255 init_type (TYPE_CODE_INT
, 8 / 8,
3257 "int8_t", (struct objfile
*) NULL
);
3258 builtin_type_uint8
=
3259 init_type (TYPE_CODE_INT
, 8 / 8,
3261 "uint8_t", (struct objfile
*) NULL
);
3262 builtin_type_int16
=
3263 init_type (TYPE_CODE_INT
, 16 / 8,
3265 "int16_t", (struct objfile
*) NULL
);
3266 builtin_type_uint16
=
3267 init_type (TYPE_CODE_INT
, 16 / 8,
3269 "uint16_t", (struct objfile
*) NULL
);
3270 builtin_type_int32
=
3271 init_type (TYPE_CODE_INT
, 32 / 8,
3273 "int32_t", (struct objfile
*) NULL
);
3274 builtin_type_uint32
=
3275 init_type (TYPE_CODE_INT
, 32 / 8,
3277 "uint32_t", (struct objfile
*) NULL
);
3278 builtin_type_int64
=
3279 init_type (TYPE_CODE_INT
, 64 / 8,
3281 "int64_t", (struct objfile
*) NULL
);
3282 builtin_type_uint64
=
3283 init_type (TYPE_CODE_INT
, 64 / 8,
3285 "uint64_t", (struct objfile
*) NULL
);
3286 builtin_type_int128
=
3287 init_type (TYPE_CODE_INT
, 128 / 8,
3289 "int128_t", (struct objfile
*) NULL
);
3290 builtin_type_uint128
=
3291 init_type (TYPE_CODE_INT
, 128 / 8,
3293 "uint128_t", (struct objfile
*) NULL
);
3295 init_type (TYPE_CODE_BOOL
, TARGET_CHAR_BIT
/ TARGET_CHAR_BIT
,
3297 "bool", (struct objfile
*) NULL
);
3299 /* Add user knob for controlling resolution of opaque types */
3301 (add_set_cmd ("opaque-type-resolution", class_support
, var_boolean
, (char *) &opaque_type_resolution
,
3302 "Set resolution of opaque struct/class/union types (if set before loading symbols).",
3305 opaque_type_resolution
= 1;
3307 /* Build SIMD types. */
3309 = init_simd_type ("__builtin_v4sf", builtin_type_float
, "f", 4);
3311 = init_simd_type ("__builtin_v4si", builtin_type_int32
, "f", 4);
3313 = init_simd_type ("__builtin_v16qi", builtin_type_int8
, "f", 16);
3315 = init_simd_type ("__builtin_v8qi", builtin_type_int8
, "f", 8);
3317 = init_simd_type ("__builtin_v8hi", builtin_type_int16
, "f", 8);
3319 = init_simd_type ("__builtin_v4hi", builtin_type_int16
, "f", 4);
3321 = init_simd_type ("__builtin_v2si", builtin_type_int32
, "f", 2);
3323 /* 128 bit vectors. */
3324 builtin_type_v2_double
= init_vector_type (builtin_type_double
, 2);
3325 builtin_type_v4_float
= init_vector_type (builtin_type_float
, 4);
3326 builtin_type_v2_int64
= init_vector_type (builtin_type_int64
, 2);
3327 builtin_type_v4_int32
= init_vector_type (builtin_type_int32
, 4);
3328 builtin_type_v8_int16
= init_vector_type (builtin_type_int16
, 8);
3329 builtin_type_v16_int8
= init_vector_type (builtin_type_int8
, 16);
3330 /* 64 bit vectors. */
3331 builtin_type_v2_float
= init_vector_type (builtin_type_float
, 2);
3332 builtin_type_v2_int32
= init_vector_type (builtin_type_int32
, 2);
3333 builtin_type_v4_int16
= init_vector_type (builtin_type_int16
, 4);
3334 builtin_type_v8_int8
= init_vector_type (builtin_type_int8
, 8);
3337 builtin_type_vec128
= build_builtin_type_vec128 ();
3338 builtin_type_vec128i
= build_builtin_type_vec128i ();
3340 /* Pointer/Address types. */
3342 /* NOTE: on some targets, addresses and pointers are not necessarily
3343 the same --- for example, on the D10V, pointers are 16 bits long,
3344 but addresses are 32 bits long. See doc/gdbint.texinfo,
3345 ``Pointers Are Not Always Addresses''.
3348 - gdb's `struct type' always describes the target's
3350 - gdb's `struct value' objects should always hold values in
3352 - gdb's CORE_ADDR values are addresses in the unified virtual
3353 address space that the assembler and linker work with. Thus,
3354 since target_read_memory takes a CORE_ADDR as an argument, it
3355 can access any memory on the target, even if the processor has
3356 separate code and data address spaces.
3359 - If v is a value holding a D10V code pointer, its contents are
3360 in target form: a big-endian address left-shifted two bits.
3361 - If p is a D10V pointer type, TYPE_LENGTH (p) == 2, just as
3362 sizeof (void *) == 2 on the target.
3364 In this context, builtin_type_CORE_ADDR is a bit odd: it's a
3365 target type for a value the target will never see. It's only
3366 used to hold the values of (typeless) linker symbols, which are
3367 indeed in the unified virtual address space. */
3368 builtin_type_void_data_ptr
= make_pointer_type (builtin_type_void
, NULL
);
3369 builtin_type_void_func_ptr
3370 = lookup_pointer_type (lookup_function_type (builtin_type_void
));
3371 builtin_type_CORE_ADDR
=
3372 init_type (TYPE_CODE_INT
, TARGET_ADDR_BIT
/ 8,
3374 "__CORE_ADDR", (struct objfile
*) NULL
);
3375 builtin_type_bfd_vma
=
3376 init_type (TYPE_CODE_INT
, TARGET_BFD_VMA_BIT
/ 8,
3378 "__bfd_vma", (struct objfile
*) NULL
);
3382 extern void _initialize_gdbtypes (void);
3384 _initialize_gdbtypes (void)
3386 struct cmd_list_element
*c
;
3389 /* FIXME - For the moment, handle types by swapping them in and out.
3390 Should be using the per-architecture data-pointer and a large
3392 register_gdbarch_swap (&builtin_type_void
, sizeof (struct type
*), NULL
);
3393 register_gdbarch_swap (&builtin_type_char
, sizeof (struct type
*), NULL
);
3394 register_gdbarch_swap (&builtin_type_short
, sizeof (struct type
*), NULL
);
3395 register_gdbarch_swap (&builtin_type_int
, sizeof (struct type
*), NULL
);
3396 register_gdbarch_swap (&builtin_type_long
, sizeof (struct type
*), NULL
);
3397 register_gdbarch_swap (&builtin_type_long_long
, sizeof (struct type
*), NULL
);
3398 register_gdbarch_swap (&builtin_type_signed_char
, sizeof (struct type
*), NULL
);
3399 register_gdbarch_swap (&builtin_type_unsigned_char
, sizeof (struct type
*), NULL
);
3400 register_gdbarch_swap (&builtin_type_unsigned_short
, sizeof (struct type
*), NULL
);
3401 register_gdbarch_swap (&builtin_type_unsigned_int
, sizeof (struct type
*), NULL
);
3402 register_gdbarch_swap (&builtin_type_unsigned_long
, sizeof (struct type
*), NULL
);
3403 register_gdbarch_swap (&builtin_type_unsigned_long_long
, sizeof (struct type
*), NULL
);
3404 register_gdbarch_swap (&builtin_type_float
, sizeof (struct type
*), NULL
);
3405 register_gdbarch_swap (&builtin_type_double
, sizeof (struct type
*), NULL
);
3406 register_gdbarch_swap (&builtin_type_long_double
, sizeof (struct type
*), NULL
);
3407 register_gdbarch_swap (&builtin_type_complex
, sizeof (struct type
*), NULL
);
3408 register_gdbarch_swap (&builtin_type_double_complex
, sizeof (struct type
*), NULL
);
3409 register_gdbarch_swap (&builtin_type_string
, sizeof (struct type
*), NULL
);
3410 register_gdbarch_swap (&builtin_type_int8
, sizeof (struct type
*), NULL
);
3411 register_gdbarch_swap (&builtin_type_uint8
, sizeof (struct type
*), NULL
);
3412 register_gdbarch_swap (&builtin_type_int16
, sizeof (struct type
*), NULL
);
3413 register_gdbarch_swap (&builtin_type_uint16
, sizeof (struct type
*), NULL
);
3414 register_gdbarch_swap (&builtin_type_int32
, sizeof (struct type
*), NULL
);
3415 register_gdbarch_swap (&builtin_type_uint32
, sizeof (struct type
*), NULL
);
3416 register_gdbarch_swap (&builtin_type_int64
, sizeof (struct type
*), NULL
);
3417 register_gdbarch_swap (&builtin_type_uint64
, sizeof (struct type
*), NULL
);
3418 register_gdbarch_swap (&builtin_type_int128
, sizeof (struct type
*), NULL
);
3419 register_gdbarch_swap (&builtin_type_uint128
, sizeof (struct type
*), NULL
);
3420 register_gdbarch_swap (&builtin_type_v4sf
, sizeof (struct type
*), NULL
);
3421 register_gdbarch_swap (&builtin_type_v4si
, sizeof (struct type
*), NULL
);
3422 register_gdbarch_swap (&builtin_type_v16qi
, sizeof (struct type
*), NULL
);
3423 register_gdbarch_swap (&builtin_type_v8qi
, sizeof (struct type
*), NULL
);
3424 register_gdbarch_swap (&builtin_type_v8hi
, sizeof (struct type
*), NULL
);
3425 register_gdbarch_swap (&builtin_type_v4hi
, sizeof (struct type
*), NULL
);
3426 register_gdbarch_swap (&builtin_type_v2si
, sizeof (struct type
*), NULL
);
3427 register_gdbarch_swap (&builtin_type_v2_double
, sizeof (struct type
*), NULL
);
3428 register_gdbarch_swap (&builtin_type_v4_float
, sizeof (struct type
*), NULL
);
3429 register_gdbarch_swap (&builtin_type_v2_int64
, sizeof (struct type
*), NULL
);
3430 register_gdbarch_swap (&builtin_type_v4_int32
, sizeof (struct type
*), NULL
);
3431 register_gdbarch_swap (&builtin_type_v8_int16
, sizeof (struct type
*), NULL
);
3432 register_gdbarch_swap (&builtin_type_v16_int8
, sizeof (struct type
*), NULL
);
3433 register_gdbarch_swap (&builtin_type_v2_float
, sizeof (struct type
*), NULL
);
3434 register_gdbarch_swap (&builtin_type_v2_int32
, sizeof (struct type
*), NULL
);
3435 register_gdbarch_swap (&builtin_type_v8_int8
, sizeof (struct type
*), NULL
);
3436 register_gdbarch_swap (&builtin_type_v4_int16
, sizeof (struct type
*), NULL
);
3437 register_gdbarch_swap (&builtin_type_vec128
, sizeof (struct type
*), NULL
);
3438 register_gdbarch_swap (&builtin_type_vec128i
, sizeof (struct type
*), NULL
);
3439 REGISTER_GDBARCH_SWAP (builtin_type_void_data_ptr
);
3440 REGISTER_GDBARCH_SWAP (builtin_type_void_func_ptr
);
3441 REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR
);
3442 REGISTER_GDBARCH_SWAP (builtin_type_bfd_vma
);
3443 register_gdbarch_swap (NULL
, 0, build_gdbtypes
);
3445 /* Note: These types do not need to be swapped - they are target
3447 builtin_type_ieee_single_big
=
3448 init_type (TYPE_CODE_FLT
, floatformat_ieee_single_big
.totalsize
/ 8,
3449 0, "builtin_type_ieee_single_big", NULL
);
3450 TYPE_FLOATFORMAT (builtin_type_ieee_single_big
) = &floatformat_ieee_single_big
;
3451 builtin_type_ieee_single_little
=
3452 init_type (TYPE_CODE_FLT
, floatformat_ieee_single_little
.totalsize
/ 8,
3453 0, "builtin_type_ieee_single_little", NULL
);
3454 TYPE_FLOATFORMAT (builtin_type_ieee_single_little
) = &floatformat_ieee_single_little
;
3455 builtin_type_ieee_double_big
=
3456 init_type (TYPE_CODE_FLT
, floatformat_ieee_double_big
.totalsize
/ 8,
3457 0, "builtin_type_ieee_double_big", NULL
);
3458 TYPE_FLOATFORMAT (builtin_type_ieee_double_big
) = &floatformat_ieee_double_big
;
3459 builtin_type_ieee_double_little
=
3460 init_type (TYPE_CODE_FLT
, floatformat_ieee_double_little
.totalsize
/ 8,
3461 0, "builtin_type_ieee_double_little", NULL
);
3462 TYPE_FLOATFORMAT (builtin_type_ieee_double_little
) = &floatformat_ieee_double_little
;
3463 builtin_type_ieee_double_littlebyte_bigword
=
3464 init_type (TYPE_CODE_FLT
, floatformat_ieee_double_littlebyte_bigword
.totalsize
/ 8,
3465 0, "builtin_type_ieee_double_littlebyte_bigword", NULL
);
3466 TYPE_FLOATFORMAT (builtin_type_ieee_double_littlebyte_bigword
) = &floatformat_ieee_double_littlebyte_bigword
;
3467 builtin_type_i387_ext
=
3468 init_type (TYPE_CODE_FLT
, floatformat_i387_ext
.totalsize
/ 8,
3469 0, "builtin_type_i387_ext", NULL
);
3470 TYPE_FLOATFORMAT (builtin_type_i387_ext
) = &floatformat_i387_ext
;
3471 builtin_type_m68881_ext
=
3472 init_type (TYPE_CODE_FLT
, floatformat_m68881_ext
.totalsize
/ 8,
3473 0, "builtin_type_m68881_ext", NULL
);
3474 TYPE_FLOATFORMAT (builtin_type_m68881_ext
) = &floatformat_m68881_ext
;
3475 builtin_type_i960_ext
=
3476 init_type (TYPE_CODE_FLT
, floatformat_i960_ext
.totalsize
/ 8,
3477 0, "builtin_type_i960_ext", NULL
);
3478 TYPE_FLOATFORMAT (builtin_type_i960_ext
) = &floatformat_i960_ext
;
3479 builtin_type_m88110_ext
=
3480 init_type (TYPE_CODE_FLT
, floatformat_m88110_ext
.totalsize
/ 8,
3481 0, "builtin_type_m88110_ext", NULL
);
3482 TYPE_FLOATFORMAT (builtin_type_m88110_ext
) = &floatformat_m88110_ext
;
3483 builtin_type_m88110_harris_ext
=
3484 init_type (TYPE_CODE_FLT
, floatformat_m88110_harris_ext
.totalsize
/ 8,
3485 0, "builtin_type_m88110_harris_ext", NULL
);
3486 TYPE_FLOATFORMAT (builtin_type_m88110_harris_ext
) = &floatformat_m88110_harris_ext
;
3487 builtin_type_arm_ext_big
=
3488 init_type (TYPE_CODE_FLT
, floatformat_arm_ext_big
.totalsize
/ 8,
3489 0, "builtin_type_arm_ext_big", NULL
);
3490 TYPE_FLOATFORMAT (builtin_type_arm_ext_big
) = &floatformat_arm_ext_big
;
3491 builtin_type_arm_ext_littlebyte_bigword
=
3492 init_type (TYPE_CODE_FLT
, floatformat_arm_ext_littlebyte_bigword
.totalsize
/ 8,
3493 0, "builtin_type_arm_ext_littlebyte_bigword", NULL
);
3494 TYPE_FLOATFORMAT (builtin_type_arm_ext_littlebyte_bigword
) = &floatformat_arm_ext_littlebyte_bigword
;
3495 builtin_type_ia64_spill_big
=
3496 init_type (TYPE_CODE_FLT
, floatformat_ia64_spill_big
.totalsize
/ 8,
3497 0, "builtin_type_ia64_spill_big", NULL
);
3498 TYPE_FLOATFORMAT (builtin_type_ia64_spill_big
) = &floatformat_ia64_spill_big
;
3499 builtin_type_ia64_spill_little
=
3500 init_type (TYPE_CODE_FLT
, floatformat_ia64_spill_little
.totalsize
/ 8,
3501 0, "builtin_type_ia64_spill_little", NULL
);
3502 TYPE_FLOATFORMAT (builtin_type_ia64_spill_little
) = &floatformat_ia64_spill_little
;
3503 builtin_type_ia64_quad_big
=
3504 init_type (TYPE_CODE_FLT
, floatformat_ia64_quad_big
.totalsize
/ 8,
3505 0, "builtin_type_ia64_quad_big", NULL
);
3506 TYPE_FLOATFORMAT (builtin_type_ia64_quad_big
) = &floatformat_ia64_quad_big
;
3507 builtin_type_ia64_quad_little
=
3508 init_type (TYPE_CODE_FLT
, floatformat_ia64_quad_little
.totalsize
/ 8,
3509 0, "builtin_type_ia64_quad_little", NULL
);
3510 TYPE_FLOATFORMAT (builtin_type_ia64_quad_little
) = &floatformat_ia64_quad_little
;
3513 add_set_cmd ("overload", no_class
, var_zinteger
, (char *) &overload_debug
,
3514 "Set debugging of C++ overloading.\n\
3515 When enabled, ranking of the functions\n\
3516 is displayed.", &setdebuglist
),