]>
Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Support routines for manipulating internal types for GDB. |
b99607ea EZ |
2 | Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, |
3 | 2004 Free Software Foundation, Inc. | |
c906108c SS |
4 | Contributed by Cygnus Support, using pieces from other GDB modules. |
5 | ||
c5aa993b | 6 | This file is part of GDB. |
c906108c | 7 | |
c5aa993b JM |
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. | |
c906108c | 12 | |
c5aa993b JM |
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. | |
c906108c | 17 | |
c5aa993b JM |
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. */ | |
c906108c SS |
22 | |
23 | #include "defs.h" | |
24 | #include "gdb_string.h" | |
25 | #include "bfd.h" | |
26 | #include "symtab.h" | |
27 | #include "symfile.h" | |
28 | #include "objfiles.h" | |
29 | #include "gdbtypes.h" | |
30 | #include "expression.h" | |
31 | #include "language.h" | |
32 | #include "target.h" | |
33 | #include "value.h" | |
34 | #include "demangle.h" | |
35 | #include "complaints.h" | |
36 | #include "gdbcmd.h" | |
c91ecb25 | 37 | #include "wrapper.h" |
015a42b4 | 38 | #include "cp-abi.h" |
a02fd225 | 39 | #include "gdb_assert.h" |
c906108c SS |
40 | |
41 | /* These variables point to the objects | |
42 | representing the predefined C data types. */ | |
43 | ||
44 | struct type *builtin_type_void; | |
45 | struct type *builtin_type_char; | |
9e0b60a8 | 46 | struct type *builtin_type_true_char; |
c906108c SS |
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; | |
449a5da4 | 63 | struct type *builtin_type_int0; |
c906108c SS |
64 | struct type *builtin_type_int8; |
65 | struct type *builtin_type_uint8; | |
66 | struct type *builtin_type_int16; | |
67 | struct type *builtin_type_uint16; | |
68 | struct type *builtin_type_int32; | |
69 | struct type *builtin_type_uint32; | |
70 | struct type *builtin_type_int64; | |
71 | struct type *builtin_type_uint64; | |
8b982acf EZ |
72 | struct type *builtin_type_int128; |
73 | struct type *builtin_type_uint128; | |
c906108c | 74 | struct type *builtin_type_bool; |
ac3aafc7 EZ |
75 | |
76 | /* 128 bit long vector types */ | |
3139facc | 77 | struct type *builtin_type_v2_double; |
ac3aafc7 | 78 | struct type *builtin_type_v4_float; |
3139facc | 79 | struct type *builtin_type_v2_int64; |
ac3aafc7 EZ |
80 | struct type *builtin_type_v4_int32; |
81 | struct type *builtin_type_v8_int16; | |
82 | struct type *builtin_type_v16_int8; | |
83 | /* 64 bit long vector types */ | |
6599f021 | 84 | struct type *builtin_type_v2_float; |
ac3aafc7 EZ |
85 | struct type *builtin_type_v2_int32; |
86 | struct type *builtin_type_v4_int16; | |
87 | struct type *builtin_type_v8_int8; | |
88 | ||
917317f4 | 89 | struct type *builtin_type_v4sf; |
c2d11a7d | 90 | struct type *builtin_type_v4si; |
08cf96df | 91 | struct type *builtin_type_v16qi; |
c2d11a7d | 92 | struct type *builtin_type_v8qi; |
08cf96df | 93 | struct type *builtin_type_v8hi; |
c2d11a7d JM |
94 | struct type *builtin_type_v4hi; |
95 | struct type *builtin_type_v2si; | |
b063e7a2 AC |
96 | struct type *builtin_type_vec64; |
97 | struct type *builtin_type_vec64i; | |
08cf96df | 98 | struct type *builtin_type_vec128; |
3139facc | 99 | struct type *builtin_type_vec128i; |
5ef2d0aa | 100 | struct type *builtin_type_ieee_single[BFD_ENDIAN_UNKNOWN]; |
598f52df AC |
101 | struct type *builtin_type_ieee_single_big; |
102 | struct type *builtin_type_ieee_single_little; | |
5ef2d0aa | 103 | struct type *builtin_type_ieee_double[BFD_ENDIAN_UNKNOWN]; |
598f52df AC |
104 | struct type *builtin_type_ieee_double_big; |
105 | struct type *builtin_type_ieee_double_little; | |
106 | struct type *builtin_type_ieee_double_littlebyte_bigword; | |
107 | struct type *builtin_type_i387_ext; | |
108 | struct type *builtin_type_m68881_ext; | |
109 | struct type *builtin_type_i960_ext; | |
110 | struct type *builtin_type_m88110_ext; | |
111 | struct type *builtin_type_m88110_harris_ext; | |
5ef2d0aa | 112 | struct type *builtin_type_arm_ext[BFD_ENDIAN_UNKNOWN]; |
598f52df AC |
113 | struct type *builtin_type_arm_ext_big; |
114 | struct type *builtin_type_arm_ext_littlebyte_bigword; | |
5ef2d0aa | 115 | struct type *builtin_type_ia64_spill[BFD_ENDIAN_UNKNOWN]; |
598f52df AC |
116 | struct type *builtin_type_ia64_spill_big; |
117 | struct type *builtin_type_ia64_spill_little; | |
5ef2d0aa | 118 | struct type *builtin_type_ia64_quad[BFD_ENDIAN_UNKNOWN]; |
598f52df AC |
119 | struct type *builtin_type_ia64_quad_big; |
120 | struct type *builtin_type_ia64_quad_little; | |
090a2205 | 121 | struct type *builtin_type_void_data_ptr; |
ee3a7b7f | 122 | struct type *builtin_type_void_func_ptr; |
c4093a6a JM |
123 | struct type *builtin_type_CORE_ADDR; |
124 | struct type *builtin_type_bfd_vma; | |
c906108c SS |
125 | |
126 | int opaque_type_resolution = 1; | |
5d161b24 | 127 | int overload_debug = 0; |
c906108c | 128 | |
c5aa993b JM |
129 | struct extra |
130 | { | |
131 | char str[128]; | |
132 | int len; | |
8c990f3c | 133 | }; /* maximum extension is 128! FIXME */ |
c906108c | 134 | |
a14ed312 | 135 | static void print_bit_vector (B_TYPE *, int); |
ad2f7632 | 136 | static void print_arg_types (struct field *, int, int); |
a14ed312 KB |
137 | static void dump_fn_fieldlists (struct type *, int); |
138 | static void print_cplus_stuff (struct type *, int); | |
139 | static void virtual_base_list_aux (struct type *dclass); | |
7a292a7a | 140 | |
c906108c SS |
141 | |
142 | /* Alloc a new type structure and fill it with some defaults. If | |
143 | OBJFILE is non-NULL, then allocate the space for the type structure | |
b99607ea | 144 | in that objfile's objfile_obstack. Otherwise allocate the new type structure |
2fdde8f8 | 145 | by xmalloc () (for permanent types). */ |
c906108c SS |
146 | |
147 | struct type * | |
fba45db2 | 148 | alloc_type (struct objfile *objfile) |
c906108c | 149 | { |
52f0bd74 | 150 | struct type *type; |
c906108c SS |
151 | |
152 | /* Alloc the structure and start off with all fields zeroed. */ | |
153 | ||
154 | if (objfile == NULL) | |
155 | { | |
2fdde8f8 DJ |
156 | type = xmalloc (sizeof (struct type)); |
157 | memset (type, 0, sizeof (struct type)); | |
158 | TYPE_MAIN_TYPE (type) = xmalloc (sizeof (struct main_type)); | |
c906108c SS |
159 | } |
160 | else | |
161 | { | |
b99607ea | 162 | type = obstack_alloc (&objfile->objfile_obstack, |
2fdde8f8 DJ |
163 | sizeof (struct type)); |
164 | memset (type, 0, sizeof (struct type)); | |
b99607ea | 165 | TYPE_MAIN_TYPE (type) = obstack_alloc (&objfile->objfile_obstack, |
2fdde8f8 | 166 | sizeof (struct main_type)); |
c906108c SS |
167 | OBJSTAT (objfile, n_types++); |
168 | } | |
2fdde8f8 | 169 | memset (TYPE_MAIN_TYPE (type), 0, sizeof (struct main_type)); |
c906108c SS |
170 | |
171 | /* Initialize the fields that might not be zero. */ | |
172 | ||
173 | TYPE_CODE (type) = TYPE_CODE_UNDEF; | |
174 | TYPE_OBJFILE (type) = objfile; | |
175 | TYPE_VPTR_FIELDNO (type) = -1; | |
2fdde8f8 | 176 | TYPE_CHAIN (type) = type; /* Chain back to itself. */ |
c906108c SS |
177 | |
178 | return (type); | |
179 | } | |
180 | ||
2fdde8f8 DJ |
181 | /* Alloc a new type instance structure, fill it with some defaults, |
182 | and point it at OLDTYPE. Allocate the new type instance from the | |
183 | same place as OLDTYPE. */ | |
184 | ||
185 | static struct type * | |
186 | alloc_type_instance (struct type *oldtype) | |
187 | { | |
188 | struct type *type; | |
189 | ||
190 | /* Allocate the structure. */ | |
191 | ||
192 | if (TYPE_OBJFILE (oldtype) == NULL) | |
193 | { | |
194 | type = xmalloc (sizeof (struct type)); | |
195 | memset (type, 0, sizeof (struct type)); | |
196 | } | |
197 | else | |
198 | { | |
b99607ea | 199 | type = obstack_alloc (&TYPE_OBJFILE (oldtype)->objfile_obstack, |
2fdde8f8 DJ |
200 | sizeof (struct type)); |
201 | memset (type, 0, sizeof (struct type)); | |
202 | } | |
203 | TYPE_MAIN_TYPE (type) = TYPE_MAIN_TYPE (oldtype); | |
204 | ||
205 | TYPE_CHAIN (type) = type; /* Chain back to itself for now. */ | |
206 | ||
207 | return (type); | |
208 | } | |
209 | ||
210 | /* Clear all remnants of the previous type at TYPE, in preparation for | |
211 | replacing it with something else. */ | |
212 | static void | |
213 | smash_type (struct type *type) | |
214 | { | |
215 | memset (TYPE_MAIN_TYPE (type), 0, sizeof (struct main_type)); | |
216 | ||
217 | /* For now, delete the rings. */ | |
218 | TYPE_CHAIN (type) = type; | |
219 | ||
220 | /* For now, leave the pointer/reference types alone. */ | |
221 | } | |
222 | ||
c906108c SS |
223 | /* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points |
224 | to a pointer to memory where the pointer type should be stored. | |
225 | If *TYPEPTR is zero, update it to point to the pointer type we return. | |
226 | We allocate new memory if needed. */ | |
227 | ||
228 | struct type * | |
fba45db2 | 229 | make_pointer_type (struct type *type, struct type **typeptr) |
c906108c | 230 | { |
52f0bd74 | 231 | struct type *ntype; /* New type */ |
c906108c SS |
232 | struct objfile *objfile; |
233 | ||
234 | ntype = TYPE_POINTER_TYPE (type); | |
235 | ||
c5aa993b | 236 | if (ntype) |
c906108c | 237 | { |
c5aa993b JM |
238 | if (typeptr == 0) |
239 | return ntype; /* Don't care about alloc, and have new type. */ | |
c906108c | 240 | else if (*typeptr == 0) |
c5aa993b | 241 | { |
c906108c SS |
242 | *typeptr = ntype; /* Tracking alloc, and we have new type. */ |
243 | return ntype; | |
c5aa993b | 244 | } |
c906108c SS |
245 | } |
246 | ||
247 | if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ | |
248 | { | |
249 | ntype = alloc_type (TYPE_OBJFILE (type)); | |
250 | if (typeptr) | |
251 | *typeptr = ntype; | |
252 | } | |
c5aa993b JM |
253 | else |
254 | /* We have storage, but need to reset it. */ | |
c906108c SS |
255 | { |
256 | ntype = *typeptr; | |
257 | objfile = TYPE_OBJFILE (ntype); | |
2fdde8f8 | 258 | smash_type (ntype); |
c906108c SS |
259 | TYPE_OBJFILE (ntype) = objfile; |
260 | } | |
261 | ||
262 | TYPE_TARGET_TYPE (ntype) = type; | |
263 | TYPE_POINTER_TYPE (type) = ntype; | |
264 | ||
265 | /* FIXME! Assume the machine has only one representation for pointers! */ | |
266 | ||
267 | TYPE_LENGTH (ntype) = TARGET_PTR_BIT / TARGET_CHAR_BIT; | |
268 | TYPE_CODE (ntype) = TYPE_CODE_PTR; | |
269 | ||
67b2adb2 AC |
270 | /* Mark pointers as unsigned. The target converts between pointers |
271 | and addresses (CORE_ADDRs) using POINTER_TO_ADDRESS() and | |
272 | ADDRESS_TO_POINTER(). */ | |
c906108c | 273 | TYPE_FLAGS (ntype) |= TYPE_FLAG_UNSIGNED; |
c5aa993b | 274 | |
c906108c SS |
275 | if (!TYPE_POINTER_TYPE (type)) /* Remember it, if don't have one. */ |
276 | TYPE_POINTER_TYPE (type) = ntype; | |
277 | ||
278 | return ntype; | |
279 | } | |
280 | ||
281 | /* Given a type TYPE, return a type of pointers to that type. | |
282 | May need to construct such a type if this is the first use. */ | |
283 | ||
284 | struct type * | |
fba45db2 | 285 | lookup_pointer_type (struct type *type) |
c906108c | 286 | { |
c5aa993b | 287 | return make_pointer_type (type, (struct type **) 0); |
c906108c SS |
288 | } |
289 | ||
290 | /* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, points | |
291 | to a pointer to memory where the reference type should be stored. | |
292 | If *TYPEPTR is zero, update it to point to the reference type we return. | |
293 | We allocate new memory if needed. */ | |
294 | ||
295 | struct type * | |
fba45db2 | 296 | make_reference_type (struct type *type, struct type **typeptr) |
c906108c | 297 | { |
52f0bd74 | 298 | struct type *ntype; /* New type */ |
c906108c SS |
299 | struct objfile *objfile; |
300 | ||
301 | ntype = TYPE_REFERENCE_TYPE (type); | |
302 | ||
c5aa993b | 303 | if (ntype) |
c906108c | 304 | { |
c5aa993b JM |
305 | if (typeptr == 0) |
306 | return ntype; /* Don't care about alloc, and have new type. */ | |
c906108c | 307 | else if (*typeptr == 0) |
c5aa993b | 308 | { |
c906108c SS |
309 | *typeptr = ntype; /* Tracking alloc, and we have new type. */ |
310 | return ntype; | |
c5aa993b | 311 | } |
c906108c SS |
312 | } |
313 | ||
314 | if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ | |
315 | { | |
316 | ntype = alloc_type (TYPE_OBJFILE (type)); | |
317 | if (typeptr) | |
318 | *typeptr = ntype; | |
319 | } | |
c5aa993b JM |
320 | else |
321 | /* We have storage, but need to reset it. */ | |
c906108c SS |
322 | { |
323 | ntype = *typeptr; | |
324 | objfile = TYPE_OBJFILE (ntype); | |
2fdde8f8 | 325 | smash_type (ntype); |
c906108c SS |
326 | TYPE_OBJFILE (ntype) = objfile; |
327 | } | |
328 | ||
329 | TYPE_TARGET_TYPE (ntype) = type; | |
330 | TYPE_REFERENCE_TYPE (type) = ntype; | |
331 | ||
332 | /* FIXME! Assume the machine has only one representation for references, | |
333 | and that it matches the (only) representation for pointers! */ | |
334 | ||
335 | TYPE_LENGTH (ntype) = TARGET_PTR_BIT / TARGET_CHAR_BIT; | |
336 | TYPE_CODE (ntype) = TYPE_CODE_REF; | |
c5aa993b | 337 | |
c906108c SS |
338 | if (!TYPE_REFERENCE_TYPE (type)) /* Remember it, if don't have one. */ |
339 | TYPE_REFERENCE_TYPE (type) = ntype; | |
340 | ||
341 | return ntype; | |
342 | } | |
343 | ||
344 | /* Same as above, but caller doesn't care about memory allocation details. */ | |
345 | ||
346 | struct type * | |
fba45db2 | 347 | lookup_reference_type (struct type *type) |
c906108c | 348 | { |
c5aa993b | 349 | return make_reference_type (type, (struct type **) 0); |
c906108c SS |
350 | } |
351 | ||
352 | /* Lookup a function type that returns type TYPE. TYPEPTR, if nonzero, points | |
353 | to a pointer to memory where the function type should be stored. | |
354 | If *TYPEPTR is zero, update it to point to the function type we return. | |
355 | We allocate new memory if needed. */ | |
356 | ||
357 | struct type * | |
fba45db2 | 358 | make_function_type (struct type *type, struct type **typeptr) |
c906108c | 359 | { |
52f0bd74 | 360 | struct type *ntype; /* New type */ |
c906108c SS |
361 | struct objfile *objfile; |
362 | ||
363 | if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ | |
364 | { | |
365 | ntype = alloc_type (TYPE_OBJFILE (type)); | |
366 | if (typeptr) | |
367 | *typeptr = ntype; | |
368 | } | |
c5aa993b JM |
369 | else |
370 | /* We have storage, but need to reset it. */ | |
c906108c SS |
371 | { |
372 | ntype = *typeptr; | |
373 | objfile = TYPE_OBJFILE (ntype); | |
2fdde8f8 | 374 | smash_type (ntype); |
c906108c SS |
375 | TYPE_OBJFILE (ntype) = objfile; |
376 | } | |
377 | ||
378 | TYPE_TARGET_TYPE (ntype) = type; | |
379 | ||
380 | TYPE_LENGTH (ntype) = 1; | |
381 | TYPE_CODE (ntype) = TYPE_CODE_FUNC; | |
c5aa993b | 382 | |
c906108c SS |
383 | return ntype; |
384 | } | |
385 | ||
386 | ||
387 | /* Given a type TYPE, return a type of functions that return that type. | |
388 | May need to construct such a type if this is the first use. */ | |
389 | ||
390 | struct type * | |
fba45db2 | 391 | lookup_function_type (struct type *type) |
c906108c | 392 | { |
c5aa993b | 393 | return make_function_type (type, (struct type **) 0); |
c906108c SS |
394 | } |
395 | ||
47663de5 MS |
396 | /* Identify address space identifier by name -- |
397 | return the integer flag defined in gdbtypes.h. */ | |
398 | extern int | |
399 | address_space_name_to_int (char *space_identifier) | |
400 | { | |
5f11f355 | 401 | struct gdbarch *gdbarch = current_gdbarch; |
8b2dbe47 | 402 | int type_flags; |
47663de5 MS |
403 | /* Check for known address space delimiters. */ |
404 | if (!strcmp (space_identifier, "code")) | |
405 | return TYPE_FLAG_CODE_SPACE; | |
406 | else if (!strcmp (space_identifier, "data")) | |
407 | return TYPE_FLAG_DATA_SPACE; | |
5f11f355 AC |
408 | else if (gdbarch_address_class_name_to_type_flags_p (gdbarch) |
409 | && gdbarch_address_class_name_to_type_flags (gdbarch, | |
410 | space_identifier, | |
411 | &type_flags)) | |
8b2dbe47 | 412 | return type_flags; |
47663de5 MS |
413 | else |
414 | error ("Unknown address space specifier: \"%s\"", space_identifier); | |
415 | } | |
416 | ||
417 | /* Identify address space identifier by integer flag as defined in | |
418 | gdbtypes.h -- return the string version of the adress space name. */ | |
419 | ||
321432c0 | 420 | const char * |
47663de5 MS |
421 | address_space_int_to_name (int space_flag) |
422 | { | |
5f11f355 | 423 | struct gdbarch *gdbarch = current_gdbarch; |
47663de5 MS |
424 | if (space_flag & TYPE_FLAG_CODE_SPACE) |
425 | return "code"; | |
426 | else if (space_flag & TYPE_FLAG_DATA_SPACE) | |
427 | return "data"; | |
8b2dbe47 | 428 | else if ((space_flag & TYPE_FLAG_ADDRESS_CLASS_ALL) |
5f11f355 AC |
429 | && gdbarch_address_class_type_flags_to_name_p (gdbarch)) |
430 | return gdbarch_address_class_type_flags_to_name (gdbarch, space_flag); | |
47663de5 MS |
431 | else |
432 | return NULL; | |
433 | } | |
434 | ||
2fdde8f8 | 435 | /* Create a new type with instance flags NEW_FLAGS, based on TYPE. |
ad766c0a JB |
436 | |
437 | If STORAGE is non-NULL, create the new type instance there. | |
438 | STORAGE must be in the same obstack as TYPE. */ | |
47663de5 | 439 | |
b9362cc7 | 440 | static struct type * |
2fdde8f8 DJ |
441 | make_qualified_type (struct type *type, int new_flags, |
442 | struct type *storage) | |
47663de5 MS |
443 | { |
444 | struct type *ntype; | |
445 | ||
446 | ntype = type; | |
447 | do { | |
2fdde8f8 | 448 | if (TYPE_INSTANCE_FLAGS (ntype) == new_flags) |
47663de5 | 449 | return ntype; |
2fdde8f8 | 450 | ntype = TYPE_CHAIN (ntype); |
47663de5 MS |
451 | } while (ntype != type); |
452 | ||
2fdde8f8 DJ |
453 | /* Create a new type instance. */ |
454 | if (storage == NULL) | |
455 | ntype = alloc_type_instance (type); | |
456 | else | |
457 | { | |
ad766c0a JB |
458 | /* If STORAGE was provided, it had better be in the same objfile as |
459 | TYPE. Otherwise, we can't link it into TYPE's cv chain: if one | |
460 | objfile is freed and the other kept, we'd have dangling | |
461 | pointers. */ | |
462 | gdb_assert (TYPE_OBJFILE (type) == TYPE_OBJFILE (storage)); | |
463 | ||
2fdde8f8 DJ |
464 | ntype = storage; |
465 | TYPE_MAIN_TYPE (ntype) = TYPE_MAIN_TYPE (type); | |
466 | TYPE_CHAIN (ntype) = ntype; | |
467 | } | |
47663de5 MS |
468 | |
469 | /* Pointers or references to the original type are not relevant to | |
2fdde8f8 | 470 | the new type. */ |
47663de5 MS |
471 | TYPE_POINTER_TYPE (ntype) = (struct type *) 0; |
472 | TYPE_REFERENCE_TYPE (ntype) = (struct type *) 0; | |
47663de5 | 473 | |
2fdde8f8 DJ |
474 | /* Chain the new qualified type to the old type. */ |
475 | TYPE_CHAIN (ntype) = TYPE_CHAIN (type); | |
476 | TYPE_CHAIN (type) = ntype; | |
477 | ||
478 | /* Now set the instance flags and return the new type. */ | |
479 | TYPE_INSTANCE_FLAGS (ntype) = new_flags; | |
47663de5 | 480 | |
ab5d3da6 KB |
481 | /* Set length of new type to that of the original type. */ |
482 | TYPE_LENGTH (ntype) = TYPE_LENGTH (type); | |
483 | ||
47663de5 MS |
484 | return ntype; |
485 | } | |
486 | ||
2fdde8f8 DJ |
487 | /* Make an address-space-delimited variant of a type -- a type that |
488 | is identical to the one supplied except that it has an address | |
489 | space attribute attached to it (such as "code" or "data"). | |
490 | ||
8b2dbe47 KB |
491 | The space attributes "code" and "data" are for Harvard architectures. |
492 | The address space attributes are for architectures which have | |
493 | alternately sized pointers or pointers with alternate representations. */ | |
2fdde8f8 DJ |
494 | |
495 | struct type * | |
496 | make_type_with_address_space (struct type *type, int space_flag) | |
497 | { | |
498 | struct type *ntype; | |
499 | int new_flags = ((TYPE_INSTANCE_FLAGS (type) | |
8b2dbe47 KB |
500 | & ~(TYPE_FLAG_CODE_SPACE | TYPE_FLAG_DATA_SPACE |
501 | | TYPE_FLAG_ADDRESS_CLASS_ALL)) | |
2fdde8f8 DJ |
502 | | space_flag); |
503 | ||
504 | return make_qualified_type (type, new_flags, NULL); | |
505 | } | |
c906108c SS |
506 | |
507 | /* Make a "c-v" variant of a type -- a type that is identical to the | |
508 | one supplied except that it may have const or volatile attributes | |
509 | CNST is a flag for setting the const attribute | |
510 | VOLTL is a flag for setting the volatile attribute | |
511 | TYPE is the base type whose variant we are creating. | |
c906108c | 512 | |
ad766c0a JB |
513 | If TYPEPTR and *TYPEPTR are non-zero, then *TYPEPTR points to |
514 | storage to hold the new qualified type; *TYPEPTR and TYPE must be | |
515 | in the same objfile. Otherwise, allocate fresh memory for the new | |
516 | type whereever TYPE lives. If TYPEPTR is non-zero, set it to the | |
517 | new type we construct. */ | |
c906108c | 518 | struct type * |
fba45db2 | 519 | make_cv_type (int cnst, int voltl, struct type *type, struct type **typeptr) |
c906108c | 520 | { |
52f0bd74 AC |
521 | struct type *ntype; /* New type */ |
522 | struct type *tmp_type = type; /* tmp type */ | |
c906108c SS |
523 | struct objfile *objfile; |
524 | ||
2fdde8f8 DJ |
525 | int new_flags = (TYPE_INSTANCE_FLAGS (type) |
526 | & ~(TYPE_FLAG_CONST | TYPE_FLAG_VOLATILE)); | |
c906108c | 527 | |
c906108c | 528 | if (cnst) |
2fdde8f8 | 529 | new_flags |= TYPE_FLAG_CONST; |
c906108c SS |
530 | |
531 | if (voltl) | |
2fdde8f8 | 532 | new_flags |= TYPE_FLAG_VOLATILE; |
a02fd225 | 533 | |
2fdde8f8 | 534 | if (typeptr && *typeptr != NULL) |
a02fd225 | 535 | { |
ad766c0a JB |
536 | /* TYPE and *TYPEPTR must be in the same objfile. We can't have |
537 | a C-V variant chain that threads across objfiles: if one | |
538 | objfile gets freed, then the other has a broken C-V chain. | |
539 | ||
540 | This code used to try to copy over the main type from TYPE to | |
541 | *TYPEPTR if they were in different objfiles, but that's | |
542 | wrong, too: TYPE may have a field list or member function | |
543 | lists, which refer to types of their own, etc. etc. The | |
544 | whole shebang would need to be copied over recursively; you | |
545 | can't have inter-objfile pointers. The only thing to do is | |
546 | to leave stub types as stub types, and look them up afresh by | |
547 | name each time you encounter them. */ | |
548 | gdb_assert (TYPE_OBJFILE (*typeptr) == TYPE_OBJFILE (type)); | |
2fdde8f8 DJ |
549 | } |
550 | ||
551 | ntype = make_qualified_type (type, new_flags, typeptr ? *typeptr : NULL); | |
c906108c | 552 | |
2fdde8f8 DJ |
553 | if (typeptr != NULL) |
554 | *typeptr = ntype; | |
a02fd225 | 555 | |
2fdde8f8 | 556 | return ntype; |
a02fd225 | 557 | } |
c906108c | 558 | |
2fdde8f8 DJ |
559 | /* Replace the contents of ntype with the type *type. This changes the |
560 | contents, rather than the pointer for TYPE_MAIN_TYPE (ntype); thus | |
561 | the changes are propogated to all types in the TYPE_CHAIN. | |
dd6bda65 | 562 | |
cda6c68a JB |
563 | In order to build recursive types, it's inevitable that we'll need |
564 | to update types in place --- but this sort of indiscriminate | |
565 | smashing is ugly, and needs to be replaced with something more | |
2fdde8f8 DJ |
566 | controlled. TYPE_MAIN_TYPE is a step in this direction; it's not |
567 | clear if more steps are needed. */ | |
dd6bda65 DJ |
568 | void |
569 | replace_type (struct type *ntype, struct type *type) | |
570 | { | |
ab5d3da6 | 571 | struct type *chain; |
dd6bda65 | 572 | |
ad766c0a JB |
573 | /* These two types had better be in the same objfile. Otherwise, |
574 | the assignment of one type's main type structure to the other | |
575 | will produce a type with references to objects (names; field | |
576 | lists; etc.) allocated on an objfile other than its own. */ | |
577 | gdb_assert (TYPE_OBJFILE (ntype) == TYPE_OBJFILE (ntype)); | |
578 | ||
2fdde8f8 | 579 | *TYPE_MAIN_TYPE (ntype) = *TYPE_MAIN_TYPE (type); |
dd6bda65 | 580 | |
ab5d3da6 KB |
581 | /* The type length is not a part of the main type. Update it for each |
582 | type on the variant chain. */ | |
583 | chain = ntype; | |
584 | do { | |
585 | /* Assert that this element of the chain has no address-class bits | |
586 | set in its flags. Such type variants might have type lengths | |
587 | which are supposed to be different from the non-address-class | |
588 | variants. This assertion shouldn't ever be triggered because | |
589 | symbol readers which do construct address-class variants don't | |
590 | call replace_type(). */ | |
591 | gdb_assert (TYPE_ADDRESS_CLASS_ALL (chain) == 0); | |
592 | ||
593 | TYPE_LENGTH (ntype) = TYPE_LENGTH (type); | |
594 | chain = TYPE_CHAIN (chain); | |
595 | } while (ntype != chain); | |
596 | ||
2fdde8f8 DJ |
597 | /* Assert that the two types have equivalent instance qualifiers. |
598 | This should be true for at least all of our debug readers. */ | |
599 | gdb_assert (TYPE_INSTANCE_FLAGS (ntype) == TYPE_INSTANCE_FLAGS (type)); | |
dd6bda65 DJ |
600 | } |
601 | ||
c906108c SS |
602 | /* Implement direct support for MEMBER_TYPE in GNU C++. |
603 | May need to construct such a type if this is the first use. | |
604 | The TYPE is the type of the member. The DOMAIN is the type | |
605 | of the aggregate that the member belongs to. */ | |
606 | ||
607 | struct type * | |
fba45db2 | 608 | lookup_member_type (struct type *type, struct type *domain) |
c906108c | 609 | { |
52f0bd74 | 610 | struct type *mtype; |
c906108c SS |
611 | |
612 | mtype = alloc_type (TYPE_OBJFILE (type)); | |
613 | smash_to_member_type (mtype, domain, type); | |
614 | return (mtype); | |
615 | } | |
616 | ||
7b83ea04 | 617 | /* Allocate a stub method whose return type is TYPE. |
c906108c SS |
618 | This apparently happens for speed of symbol reading, since parsing |
619 | out the arguments to the method is cpu-intensive, the way we are doing | |
620 | it. So, we will fill in arguments later. | |
621 | This always returns a fresh type. */ | |
622 | ||
623 | struct type * | |
fba45db2 | 624 | allocate_stub_method (struct type *type) |
c906108c SS |
625 | { |
626 | struct type *mtype; | |
627 | ||
7e956337 FF |
628 | mtype = init_type (TYPE_CODE_METHOD, 1, TYPE_FLAG_STUB, NULL, |
629 | TYPE_OBJFILE (type)); | |
c906108c SS |
630 | TYPE_TARGET_TYPE (mtype) = type; |
631 | /* _DOMAIN_TYPE (mtype) = unknown yet */ | |
c906108c SS |
632 | return (mtype); |
633 | } | |
634 | ||
635 | /* Create a range type using either a blank type supplied in RESULT_TYPE, | |
636 | or creating a new type, inheriting the objfile from INDEX_TYPE. | |
637 | ||
638 | Indices will be of type INDEX_TYPE, and will range from LOW_BOUND to | |
639 | HIGH_BOUND, inclusive. | |
640 | ||
641 | FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make | |
642 | sure it is TYPE_CODE_UNDEF before we bash it into a range type? */ | |
643 | ||
644 | struct type * | |
fba45db2 KB |
645 | create_range_type (struct type *result_type, struct type *index_type, |
646 | int low_bound, int high_bound) | |
c906108c SS |
647 | { |
648 | if (result_type == NULL) | |
649 | { | |
650 | result_type = alloc_type (TYPE_OBJFILE (index_type)); | |
651 | } | |
652 | TYPE_CODE (result_type) = TYPE_CODE_RANGE; | |
653 | TYPE_TARGET_TYPE (result_type) = index_type; | |
74a9bb82 | 654 | if (TYPE_STUB (index_type)) |
c906108c SS |
655 | TYPE_FLAGS (result_type) |= TYPE_FLAG_TARGET_STUB; |
656 | else | |
657 | TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type)); | |
658 | TYPE_NFIELDS (result_type) = 2; | |
659 | TYPE_FIELDS (result_type) = (struct field *) | |
660 | TYPE_ALLOC (result_type, 2 * sizeof (struct field)); | |
661 | memset (TYPE_FIELDS (result_type), 0, 2 * sizeof (struct field)); | |
662 | TYPE_FIELD_BITPOS (result_type, 0) = low_bound; | |
663 | TYPE_FIELD_BITPOS (result_type, 1) = high_bound; | |
c5aa993b JM |
664 | TYPE_FIELD_TYPE (result_type, 0) = builtin_type_int; /* FIXME */ |
665 | TYPE_FIELD_TYPE (result_type, 1) = builtin_type_int; /* FIXME */ | |
c906108c | 666 | |
c5aa993b | 667 | if (low_bound >= 0) |
c906108c SS |
668 | TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED; |
669 | ||
670 | return (result_type); | |
671 | } | |
672 | ||
673 | /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type TYPE. | |
674 | Return 1 of type is a range type, 0 if it is discrete (and bounds | |
675 | will fit in LONGEST), or -1 otherwise. */ | |
676 | ||
677 | int | |
fba45db2 | 678 | get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp) |
c906108c SS |
679 | { |
680 | CHECK_TYPEDEF (type); | |
681 | switch (TYPE_CODE (type)) | |
682 | { | |
683 | case TYPE_CODE_RANGE: | |
684 | *lowp = TYPE_LOW_BOUND (type); | |
685 | *highp = TYPE_HIGH_BOUND (type); | |
686 | return 1; | |
687 | case TYPE_CODE_ENUM: | |
688 | if (TYPE_NFIELDS (type) > 0) | |
689 | { | |
690 | /* The enums may not be sorted by value, so search all | |
691 | entries */ | |
692 | int i; | |
693 | ||
694 | *lowp = *highp = TYPE_FIELD_BITPOS (type, 0); | |
695 | for (i = 0; i < TYPE_NFIELDS (type); i++) | |
696 | { | |
697 | if (TYPE_FIELD_BITPOS (type, i) < *lowp) | |
698 | *lowp = TYPE_FIELD_BITPOS (type, i); | |
699 | if (TYPE_FIELD_BITPOS (type, i) > *highp) | |
700 | *highp = TYPE_FIELD_BITPOS (type, i); | |
701 | } | |
702 | ||
703 | /* Set unsigned indicator if warranted. */ | |
c5aa993b | 704 | if (*lowp >= 0) |
c906108c SS |
705 | { |
706 | TYPE_FLAGS (type) |= TYPE_FLAG_UNSIGNED; | |
707 | } | |
708 | } | |
709 | else | |
710 | { | |
711 | *lowp = 0; | |
712 | *highp = -1; | |
713 | } | |
714 | return 0; | |
715 | case TYPE_CODE_BOOL: | |
716 | *lowp = 0; | |
717 | *highp = 1; | |
718 | return 0; | |
719 | case TYPE_CODE_INT: | |
c5aa993b | 720 | if (TYPE_LENGTH (type) > sizeof (LONGEST)) /* Too big */ |
c906108c SS |
721 | return -1; |
722 | if (!TYPE_UNSIGNED (type)) | |
723 | { | |
c5aa993b | 724 | *lowp = -(1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1)); |
c906108c SS |
725 | *highp = -*lowp - 1; |
726 | return 0; | |
727 | } | |
728 | /* ... fall through for unsigned ints ... */ | |
729 | case TYPE_CODE_CHAR: | |
730 | *lowp = 0; | |
731 | /* This round-about calculation is to avoid shifting by | |
7b83ea04 AC |
732 | TYPE_LENGTH (type) * TARGET_CHAR_BIT, which will not work |
733 | if TYPE_LENGTH (type) == sizeof (LONGEST). */ | |
c906108c SS |
734 | *highp = 1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1); |
735 | *highp = (*highp - 1) | *highp; | |
736 | return 0; | |
737 | default: | |
738 | return -1; | |
739 | } | |
740 | } | |
741 | ||
742 | /* Create an array type using either a blank type supplied in RESULT_TYPE, | |
743 | or creating a new type, inheriting the objfile from RANGE_TYPE. | |
744 | ||
745 | Elements will be of type ELEMENT_TYPE, the indices will be of type | |
746 | RANGE_TYPE. | |
747 | ||
748 | FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make | |
749 | sure it is TYPE_CODE_UNDEF before we bash it into an array type? */ | |
750 | ||
751 | struct type * | |
fba45db2 KB |
752 | create_array_type (struct type *result_type, struct type *element_type, |
753 | struct type *range_type) | |
c906108c SS |
754 | { |
755 | LONGEST low_bound, high_bound; | |
756 | ||
757 | if (result_type == NULL) | |
758 | { | |
759 | result_type = alloc_type (TYPE_OBJFILE (range_type)); | |
760 | } | |
761 | TYPE_CODE (result_type) = TYPE_CODE_ARRAY; | |
762 | TYPE_TARGET_TYPE (result_type) = element_type; | |
763 | if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0) | |
764 | low_bound = high_bound = 0; | |
765 | CHECK_TYPEDEF (element_type); | |
766 | TYPE_LENGTH (result_type) = | |
767 | TYPE_LENGTH (element_type) * (high_bound - low_bound + 1); | |
768 | TYPE_NFIELDS (result_type) = 1; | |
769 | TYPE_FIELDS (result_type) = | |
770 | (struct field *) TYPE_ALLOC (result_type, sizeof (struct field)); | |
771 | memset (TYPE_FIELDS (result_type), 0, sizeof (struct field)); | |
772 | TYPE_FIELD_TYPE (result_type, 0) = range_type; | |
773 | TYPE_VPTR_FIELDNO (result_type) = -1; | |
774 | ||
775 | /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays */ | |
776 | if (TYPE_LENGTH (result_type) == 0) | |
777 | TYPE_FLAGS (result_type) |= TYPE_FLAG_TARGET_STUB; | |
778 | ||
779 | return (result_type); | |
780 | } | |
781 | ||
782 | /* Create a string type using either a blank type supplied in RESULT_TYPE, | |
783 | or creating a new type. String types are similar enough to array of | |
784 | char types that we can use create_array_type to build the basic type | |
785 | and then bash it into a string type. | |
786 | ||
787 | For fixed length strings, the range type contains 0 as the lower | |
788 | bound and the length of the string minus one as the upper bound. | |
789 | ||
790 | FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make | |
791 | sure it is TYPE_CODE_UNDEF before we bash it into a string type? */ | |
792 | ||
793 | struct type * | |
fba45db2 | 794 | create_string_type (struct type *result_type, struct type *range_type) |
c906108c | 795 | { |
f290d38e AC |
796 | struct type *string_char_type; |
797 | ||
798 | string_char_type = language_string_char_type (current_language, | |
799 | current_gdbarch); | |
c906108c | 800 | result_type = create_array_type (result_type, |
f290d38e | 801 | string_char_type, |
c906108c SS |
802 | range_type); |
803 | TYPE_CODE (result_type) = TYPE_CODE_STRING; | |
804 | return (result_type); | |
805 | } | |
806 | ||
807 | struct type * | |
fba45db2 | 808 | create_set_type (struct type *result_type, struct type *domain_type) |
c906108c SS |
809 | { |
810 | LONGEST low_bound, high_bound, bit_length; | |
811 | if (result_type == NULL) | |
812 | { | |
813 | result_type = alloc_type (TYPE_OBJFILE (domain_type)); | |
814 | } | |
815 | TYPE_CODE (result_type) = TYPE_CODE_SET; | |
816 | TYPE_NFIELDS (result_type) = 1; | |
817 | TYPE_FIELDS (result_type) = (struct field *) | |
818 | TYPE_ALLOC (result_type, 1 * sizeof (struct field)); | |
819 | memset (TYPE_FIELDS (result_type), 0, sizeof (struct field)); | |
820 | ||
74a9bb82 | 821 | if (!TYPE_STUB (domain_type)) |
c906108c SS |
822 | { |
823 | if (get_discrete_bounds (domain_type, &low_bound, &high_bound) < 0) | |
824 | low_bound = high_bound = 0; | |
825 | bit_length = high_bound - low_bound + 1; | |
826 | TYPE_LENGTH (result_type) | |
827 | = (bit_length + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT; | |
828 | } | |
829 | TYPE_FIELD_TYPE (result_type, 0) = domain_type; | |
830 | ||
c5aa993b | 831 | if (low_bound >= 0) |
c906108c SS |
832 | TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED; |
833 | ||
834 | return (result_type); | |
835 | } | |
836 | ||
917317f4 JM |
837 | /* Construct and return a type of the form: |
838 | struct NAME { ELT_TYPE ELT_NAME[N]; } | |
839 | We use these types for SIMD registers. For example, the type of | |
840 | the SSE registers on the late x86-family processors is: | |
841 | struct __builtin_v4sf { float f[4]; } | |
842 | built by the function call: | |
843 | init_simd_type ("__builtin_v4sf", builtin_type_float, "f", 4) | |
844 | The type returned is a permanent type, allocated using malloc; it | |
845 | doesn't live in any objfile's obstack. */ | |
c2d11a7d | 846 | static struct type * |
917317f4 JM |
847 | init_simd_type (char *name, |
848 | struct type *elt_type, | |
849 | char *elt_name, | |
850 | int n) | |
851 | { | |
73d322b1 EZ |
852 | struct type *simd_type; |
853 | struct type *array_type; | |
854 | ||
855 | simd_type = init_composite_type (name, TYPE_CODE_STRUCT); | |
856 | array_type = create_array_type (0, elt_type, | |
857 | create_range_type (0, builtin_type_int, | |
858 | 0, n-1)); | |
859 | append_composite_type_field (simd_type, elt_name, array_type); | |
860 | return simd_type; | |
917317f4 JM |
861 | } |
862 | ||
ac3aafc7 EZ |
863 | static struct type * |
864 | init_vector_type (struct type *elt_type, int n) | |
865 | { | |
866 | struct type *array_type; | |
867 | ||
868 | array_type = create_array_type (0, elt_type, | |
869 | create_range_type (0, builtin_type_int, | |
870 | 0, n-1)); | |
871 | TYPE_FLAGS (array_type) |= TYPE_FLAG_VECTOR; | |
872 | return array_type; | |
873 | } | |
874 | ||
b063e7a2 AC |
875 | static struct type * |
876 | build_builtin_type_vec64 (void) | |
877 | { | |
878 | /* Construct a type for the 64 bit registers. The type we're | |
879 | building is this: */ | |
880 | #if 0 | |
881 | union __gdb_builtin_type_vec64 | |
882 | { | |
883 | int64_t uint64; | |
884 | float v2_float[2]; | |
885 | int32_t v2_int32[2]; | |
886 | int16_t v4_int16[4]; | |
887 | int8_t v8_int8[8]; | |
888 | }; | |
889 | #endif | |
890 | ||
891 | struct type *t; | |
892 | ||
893 | t = init_composite_type ("__gdb_builtin_type_vec64", TYPE_CODE_UNION); | |
894 | append_composite_type_field (t, "uint64", builtin_type_int64); | |
895 | append_composite_type_field (t, "v2_float", builtin_type_v2_float); | |
896 | append_composite_type_field (t, "v2_int32", builtin_type_v2_int32); | |
897 | append_composite_type_field (t, "v4_int16", builtin_type_v4_int16); | |
898 | append_composite_type_field (t, "v8_int8", builtin_type_v8_int8); | |
899 | ||
900 | TYPE_FLAGS (t) |= TYPE_FLAG_VECTOR; | |
216b504f | 901 | TYPE_NAME (t) = "builtin_type_vec64"; |
b063e7a2 AC |
902 | return t; |
903 | } | |
904 | ||
905 | static struct type * | |
906 | build_builtin_type_vec64i (void) | |
907 | { | |
908 | /* Construct a type for the 64 bit registers. The type we're | |
909 | building is this: */ | |
910 | #if 0 | |
911 | union __gdb_builtin_type_vec64i | |
912 | { | |
913 | int64_t uint64; | |
914 | int32_t v2_int32[2]; | |
915 | int16_t v4_int16[4]; | |
916 | int8_t v8_int8[8]; | |
917 | }; | |
918 | #endif | |
919 | ||
920 | struct type *t; | |
921 | ||
922 | t = init_composite_type ("__gdb_builtin_type_vec64i", TYPE_CODE_UNION); | |
923 | append_composite_type_field (t, "uint64", builtin_type_int64); | |
924 | append_composite_type_field (t, "v2_int32", builtin_type_v2_int32); | |
925 | append_composite_type_field (t, "v4_int16", builtin_type_v4_int16); | |
926 | append_composite_type_field (t, "v8_int8", builtin_type_v8_int8); | |
927 | ||
928 | TYPE_FLAGS (t) |= TYPE_FLAG_VECTOR; | |
216b504f | 929 | TYPE_NAME (t) = "builtin_type_vec64i"; |
b063e7a2 AC |
930 | return t; |
931 | } | |
932 | ||
08cf96df EZ |
933 | static struct type * |
934 | build_builtin_type_vec128 (void) | |
935 | { | |
936 | /* Construct a type for the 128 bit registers. The type we're | |
937 | building is this: */ | |
938 | #if 0 | |
ac3aafc7 | 939 | union __gdb_builtin_type_vec128 |
08cf96df | 940 | { |
ac3aafc7 EZ |
941 | int128_t uint128; |
942 | float v4_float[4]; | |
943 | int32_t v4_int32[4]; | |
944 | int16_t v8_int16[8]; | |
945 | int8_t v16_int8[16]; | |
08cf96df EZ |
946 | }; |
947 | #endif | |
948 | ||
949 | struct type *t; | |
08cf96df | 950 | |
73d322b1 EZ |
951 | t = init_composite_type ("__gdb_builtin_type_vec128", TYPE_CODE_UNION); |
952 | append_composite_type_field (t, "uint128", builtin_type_int128); | |
ac3aafc7 EZ |
953 | append_composite_type_field (t, "v4_float", builtin_type_v4_float); |
954 | append_composite_type_field (t, "v4_int32", builtin_type_v4_int32); | |
955 | append_composite_type_field (t, "v8_int16", builtin_type_v8_int16); | |
956 | append_composite_type_field (t, "v16_int8", builtin_type_v16_int8); | |
08cf96df | 957 | |
b063e7a2 | 958 | TYPE_FLAGS (t) |= TYPE_FLAG_VECTOR; |
216b504f | 959 | TYPE_NAME (t) = "builtin_type_vec128"; |
08cf96df EZ |
960 | return t; |
961 | } | |
917317f4 | 962 | |
3139facc MH |
963 | static struct type * |
964 | build_builtin_type_vec128i (void) | |
965 | { | |
966 | /* 128-bit Intel SIMD registers */ | |
967 | struct type *t; | |
968 | ||
969 | t = init_composite_type ("__gdb_builtin_type_vec128i", TYPE_CODE_UNION); | |
970 | append_composite_type_field (t, "v4_float", builtin_type_v4_float); | |
971 | append_composite_type_field (t, "v2_double", builtin_type_v2_double); | |
972 | append_composite_type_field (t, "v16_int8", builtin_type_v16_int8); | |
973 | append_composite_type_field (t, "v8_int16", builtin_type_v8_int16); | |
974 | append_composite_type_field (t, "v4_int32", builtin_type_v4_int32); | |
975 | append_composite_type_field (t, "v2_int64", builtin_type_v2_int64); | |
976 | append_composite_type_field (t, "uint128", builtin_type_int128); | |
977 | ||
b063e7a2 | 978 | TYPE_FLAGS (t) |= TYPE_FLAG_VECTOR; |
216b504f | 979 | TYPE_NAME (t) = "builtin_type_vec128i"; |
3139facc MH |
980 | return t; |
981 | } | |
982 | ||
7b83ea04 | 983 | /* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE. |
c906108c SS |
984 | A MEMBER is a wierd thing -- it amounts to a typed offset into |
985 | a struct, e.g. "an int at offset 8". A MEMBER TYPE doesn't | |
986 | include the offset (that's the value of the MEMBER itself), but does | |
987 | include the structure type into which it points (for some reason). | |
988 | ||
989 | When "smashing" the type, we preserve the objfile that the | |
990 | old type pointed to, since we aren't changing where the type is actually | |
991 | allocated. */ | |
992 | ||
993 | void | |
fba45db2 KB |
994 | smash_to_member_type (struct type *type, struct type *domain, |
995 | struct type *to_type) | |
c906108c SS |
996 | { |
997 | struct objfile *objfile; | |
998 | ||
999 | objfile = TYPE_OBJFILE (type); | |
1000 | ||
2fdde8f8 | 1001 | smash_type (type); |
c906108c SS |
1002 | TYPE_OBJFILE (type) = objfile; |
1003 | TYPE_TARGET_TYPE (type) = to_type; | |
1004 | TYPE_DOMAIN_TYPE (type) = domain; | |
1005 | TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */ | |
1006 | TYPE_CODE (type) = TYPE_CODE_MEMBER; | |
1007 | } | |
1008 | ||
1009 | /* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE. | |
1010 | METHOD just means `function that gets an extra "this" argument'. | |
1011 | ||
1012 | When "smashing" the type, we preserve the objfile that the | |
1013 | old type pointed to, since we aren't changing where the type is actually | |
1014 | allocated. */ | |
1015 | ||
1016 | void | |
fba45db2 | 1017 | smash_to_method_type (struct type *type, struct type *domain, |
ad2f7632 DJ |
1018 | struct type *to_type, struct field *args, |
1019 | int nargs, int varargs) | |
c906108c SS |
1020 | { |
1021 | struct objfile *objfile; | |
1022 | ||
1023 | objfile = TYPE_OBJFILE (type); | |
1024 | ||
2fdde8f8 | 1025 | smash_type (type); |
c906108c SS |
1026 | TYPE_OBJFILE (type) = objfile; |
1027 | TYPE_TARGET_TYPE (type) = to_type; | |
1028 | TYPE_DOMAIN_TYPE (type) = domain; | |
ad2f7632 DJ |
1029 | TYPE_FIELDS (type) = args; |
1030 | TYPE_NFIELDS (type) = nargs; | |
1031 | if (varargs) | |
1032 | TYPE_FLAGS (type) |= TYPE_FLAG_VARARGS; | |
c906108c SS |
1033 | TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */ |
1034 | TYPE_CODE (type) = TYPE_CODE_METHOD; | |
1035 | } | |
1036 | ||
1037 | /* Return a typename for a struct/union/enum type without "struct ", | |
1038 | "union ", or "enum ". If the type has a NULL name, return NULL. */ | |
1039 | ||
1040 | char * | |
aa1ee363 | 1041 | type_name_no_tag (const struct type *type) |
c906108c SS |
1042 | { |
1043 | if (TYPE_TAG_NAME (type) != NULL) | |
1044 | return TYPE_TAG_NAME (type); | |
1045 | ||
1046 | /* Is there code which expects this to return the name if there is no | |
1047 | tag name? My guess is that this is mainly used for C++ in cases where | |
1048 | the two will always be the same. */ | |
1049 | return TYPE_NAME (type); | |
1050 | } | |
1051 | ||
c906108c SS |
1052 | /* Lookup a typedef or primitive type named NAME, |
1053 | visible in lexical block BLOCK. | |
1054 | If NOERR is nonzero, return zero if NAME is not suitably defined. */ | |
1055 | ||
1056 | struct type * | |
fba45db2 | 1057 | lookup_typename (char *name, struct block *block, int noerr) |
c906108c | 1058 | { |
52f0bd74 AC |
1059 | struct symbol *sym; |
1060 | struct type *tmp; | |
c906108c | 1061 | |
176620f1 | 1062 | sym = lookup_symbol (name, block, VAR_DOMAIN, 0, (struct symtab **) NULL); |
c906108c SS |
1063 | if (sym == NULL || SYMBOL_CLASS (sym) != LOC_TYPEDEF) |
1064 | { | |
54a5b07d AC |
1065 | tmp = language_lookup_primitive_type_by_name (current_language, |
1066 | current_gdbarch, | |
1067 | name); | |
c906108c SS |
1068 | if (tmp) |
1069 | { | |
1070 | return (tmp); | |
1071 | } | |
1072 | else if (!tmp && noerr) | |
1073 | { | |
1074 | return (NULL); | |
1075 | } | |
1076 | else | |
1077 | { | |
1078 | error ("No type named %s.", name); | |
1079 | } | |
1080 | } | |
1081 | return (SYMBOL_TYPE (sym)); | |
1082 | } | |
1083 | ||
1084 | struct type * | |
fba45db2 | 1085 | lookup_unsigned_typename (char *name) |
c906108c SS |
1086 | { |
1087 | char *uns = alloca (strlen (name) + 10); | |
1088 | ||
1089 | strcpy (uns, "unsigned "); | |
1090 | strcpy (uns + 9, name); | |
1091 | return (lookup_typename (uns, (struct block *) NULL, 0)); | |
1092 | } | |
1093 | ||
1094 | struct type * | |
fba45db2 | 1095 | lookup_signed_typename (char *name) |
c906108c SS |
1096 | { |
1097 | struct type *t; | |
1098 | char *uns = alloca (strlen (name) + 8); | |
1099 | ||
1100 | strcpy (uns, "signed "); | |
1101 | strcpy (uns + 7, name); | |
1102 | t = lookup_typename (uns, (struct block *) NULL, 1); | |
1103 | /* If we don't find "signed FOO" just try again with plain "FOO". */ | |
1104 | if (t != NULL) | |
1105 | return t; | |
1106 | return lookup_typename (name, (struct block *) NULL, 0); | |
1107 | } | |
1108 | ||
1109 | /* Lookup a structure type named "struct NAME", | |
1110 | visible in lexical block BLOCK. */ | |
1111 | ||
1112 | struct type * | |
fba45db2 | 1113 | lookup_struct (char *name, struct block *block) |
c906108c | 1114 | { |
52f0bd74 | 1115 | struct symbol *sym; |
c906108c | 1116 | |
176620f1 | 1117 | sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0, |
c906108c SS |
1118 | (struct symtab **) NULL); |
1119 | ||
1120 | if (sym == NULL) | |
1121 | { | |
1122 | error ("No struct type named %s.", name); | |
1123 | } | |
1124 | if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT) | |
1125 | { | |
1126 | error ("This context has class, union or enum %s, not a struct.", name); | |
1127 | } | |
1128 | return (SYMBOL_TYPE (sym)); | |
1129 | } | |
1130 | ||
1131 | /* Lookup a union type named "union NAME", | |
1132 | visible in lexical block BLOCK. */ | |
1133 | ||
1134 | struct type * | |
fba45db2 | 1135 | lookup_union (char *name, struct block *block) |
c906108c | 1136 | { |
52f0bd74 | 1137 | struct symbol *sym; |
c5aa993b | 1138 | struct type *t; |
c906108c | 1139 | |
176620f1 | 1140 | sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0, |
c906108c SS |
1141 | (struct symtab **) NULL); |
1142 | ||
1143 | if (sym == NULL) | |
1144 | error ("No union type named %s.", name); | |
1145 | ||
c5aa993b | 1146 | t = SYMBOL_TYPE (sym); |
c906108c SS |
1147 | |
1148 | if (TYPE_CODE (t) == TYPE_CODE_UNION) | |
1149 | return (t); | |
1150 | ||
1151 | /* C++ unions may come out with TYPE_CODE_CLASS, but we look at | |
1152 | * a further "declared_type" field to discover it is really a union. | |
1153 | */ | |
c5aa993b JM |
1154 | if (HAVE_CPLUS_STRUCT (t)) |
1155 | if (TYPE_DECLARED_TYPE (t) == DECLARED_TYPE_UNION) | |
c906108c SS |
1156 | return (t); |
1157 | ||
1158 | /* If we get here, it's not a union */ | |
1159 | error ("This context has class, struct or enum %s, not a union.", name); | |
1160 | } | |
1161 | ||
1162 | ||
1163 | /* Lookup an enum type named "enum NAME", | |
1164 | visible in lexical block BLOCK. */ | |
1165 | ||
1166 | struct type * | |
fba45db2 | 1167 | lookup_enum (char *name, struct block *block) |
c906108c | 1168 | { |
52f0bd74 | 1169 | struct symbol *sym; |
c906108c | 1170 | |
176620f1 | 1171 | sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0, |
c906108c SS |
1172 | (struct symtab **) NULL); |
1173 | if (sym == NULL) | |
1174 | { | |
1175 | error ("No enum type named %s.", name); | |
1176 | } | |
1177 | if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_ENUM) | |
1178 | { | |
1179 | error ("This context has class, struct or union %s, not an enum.", name); | |
1180 | } | |
1181 | return (SYMBOL_TYPE (sym)); | |
1182 | } | |
1183 | ||
1184 | /* Lookup a template type named "template NAME<TYPE>", | |
1185 | visible in lexical block BLOCK. */ | |
1186 | ||
1187 | struct type * | |
fba45db2 | 1188 | lookup_template_type (char *name, struct type *type, struct block *block) |
c906108c SS |
1189 | { |
1190 | struct symbol *sym; | |
0004e5a2 | 1191 | char *nam = (char *) alloca (strlen (name) + strlen (TYPE_NAME (type)) + 4); |
c906108c SS |
1192 | strcpy (nam, name); |
1193 | strcat (nam, "<"); | |
0004e5a2 | 1194 | strcat (nam, TYPE_NAME (type)); |
c5aa993b | 1195 | strcat (nam, " >"); /* FIXME, extra space still introduced in gcc? */ |
c906108c | 1196 | |
176620f1 | 1197 | sym = lookup_symbol (nam, block, VAR_DOMAIN, 0, (struct symtab **) NULL); |
c906108c SS |
1198 | |
1199 | if (sym == NULL) | |
1200 | { | |
1201 | error ("No template type named %s.", name); | |
1202 | } | |
1203 | if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT) | |
1204 | { | |
1205 | error ("This context has class, union or enum %s, not a struct.", name); | |
1206 | } | |
1207 | return (SYMBOL_TYPE (sym)); | |
1208 | } | |
1209 | ||
7b83ea04 | 1210 | /* Given a type TYPE, lookup the type of the component of type named NAME. |
c906108c SS |
1211 | |
1212 | TYPE can be either a struct or union, or a pointer or reference to a struct or | |
1213 | union. If it is a pointer or reference, its target type is automatically used. | |
1214 | Thus '.' and '->' are interchangable, as specified for the definitions of the | |
1215 | expression element types STRUCTOP_STRUCT and STRUCTOP_PTR. | |
1216 | ||
1217 | If NOERR is nonzero, return zero if NAME is not suitably defined. | |
1218 | If NAME is the name of a baseclass type, return that type. */ | |
1219 | ||
1220 | struct type * | |
fba45db2 | 1221 | lookup_struct_elt_type (struct type *type, char *name, int noerr) |
c906108c SS |
1222 | { |
1223 | int i; | |
1224 | ||
1225 | for (;;) | |
1226 | { | |
1227 | CHECK_TYPEDEF (type); | |
1228 | if (TYPE_CODE (type) != TYPE_CODE_PTR | |
1229 | && TYPE_CODE (type) != TYPE_CODE_REF) | |
1230 | break; | |
1231 | type = TYPE_TARGET_TYPE (type); | |
1232 | } | |
1233 | ||
1234 | if (TYPE_CODE (type) != TYPE_CODE_STRUCT && | |
1235 | TYPE_CODE (type) != TYPE_CODE_UNION) | |
1236 | { | |
1237 | target_terminal_ours (); | |
1238 | gdb_flush (gdb_stdout); | |
1239 | fprintf_unfiltered (gdb_stderr, "Type "); | |
1240 | type_print (type, "", gdb_stderr, -1); | |
1241 | error (" is not a structure or union type."); | |
1242 | } | |
1243 | ||
1244 | #if 0 | |
1245 | /* FIXME: This change put in by Michael seems incorrect for the case where | |
1246 | the structure tag name is the same as the member name. I.E. when doing | |
1247 | "ptype bell->bar" for "struct foo { int bar; int foo; } bell;" | |
1248 | Disabled by fnf. */ | |
1249 | { | |
1250 | char *typename; | |
1251 | ||
1252 | typename = type_name_no_tag (type); | |
762f08a3 | 1253 | if (typename != NULL && strcmp (typename, name) == 0) |
c906108c SS |
1254 | return type; |
1255 | } | |
1256 | #endif | |
1257 | ||
1258 | for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--) | |
1259 | { | |
1260 | char *t_field_name = TYPE_FIELD_NAME (type, i); | |
1261 | ||
db577aea | 1262 | if (t_field_name && (strcmp_iw (t_field_name, name) == 0)) |
c906108c SS |
1263 | { |
1264 | return TYPE_FIELD_TYPE (type, i); | |
1265 | } | |
1266 | } | |
1267 | ||
1268 | /* OK, it's not in this class. Recursively check the baseclasses. */ | |
1269 | for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--) | |
1270 | { | |
1271 | struct type *t; | |
1272 | ||
1273 | t = lookup_struct_elt_type (TYPE_BASECLASS (type, i), name, noerr); | |
1274 | if (t != NULL) | |
1275 | { | |
1276 | return t; | |
1277 | } | |
1278 | } | |
1279 | ||
1280 | if (noerr) | |
1281 | { | |
1282 | return NULL; | |
1283 | } | |
c5aa993b | 1284 | |
c906108c SS |
1285 | target_terminal_ours (); |
1286 | gdb_flush (gdb_stdout); | |
1287 | fprintf_unfiltered (gdb_stderr, "Type "); | |
1288 | type_print (type, "", gdb_stderr, -1); | |
1289 | fprintf_unfiltered (gdb_stderr, " has no component named "); | |
1290 | fputs_filtered (name, gdb_stderr); | |
1291 | error ("."); | |
c5aa993b | 1292 | return (struct type *) -1; /* For lint */ |
c906108c SS |
1293 | } |
1294 | ||
1295 | /* If possible, make the vptr_fieldno and vptr_basetype fields of TYPE | |
1296 | valid. Callers should be aware that in some cases (for example, | |
1297 | the type or one of its baseclasses is a stub type and we are | |
1298 | debugging a .o file), this function will not be able to find the virtual | |
1299 | function table pointer, and vptr_fieldno will remain -1 and vptr_basetype | |
1300 | will remain NULL. */ | |
1301 | ||
1302 | void | |
fba45db2 | 1303 | fill_in_vptr_fieldno (struct type *type) |
c906108c SS |
1304 | { |
1305 | CHECK_TYPEDEF (type); | |
1306 | ||
1307 | if (TYPE_VPTR_FIELDNO (type) < 0) | |
1308 | { | |
1309 | int i; | |
1310 | ||
1311 | /* We must start at zero in case the first (and only) baseclass is | |
7b83ea04 | 1312 | virtual (and hence we cannot share the table pointer). */ |
c906108c SS |
1313 | for (i = 0; i < TYPE_N_BASECLASSES (type); i++) |
1314 | { | |
cef4f5dd DJ |
1315 | struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i)); |
1316 | fill_in_vptr_fieldno (baseclass); | |
1317 | if (TYPE_VPTR_FIELDNO (baseclass) >= 0) | |
c906108c | 1318 | { |
cef4f5dd DJ |
1319 | TYPE_VPTR_FIELDNO (type) = TYPE_VPTR_FIELDNO (baseclass); |
1320 | TYPE_VPTR_BASETYPE (type) = TYPE_VPTR_BASETYPE (baseclass); | |
c906108c SS |
1321 | break; |
1322 | } | |
1323 | } | |
1324 | } | |
1325 | } | |
1326 | ||
1327 | /* Find the method and field indices for the destructor in class type T. | |
1328 | Return 1 if the destructor was found, otherwise, return 0. */ | |
1329 | ||
1330 | int | |
fba45db2 | 1331 | get_destructor_fn_field (struct type *t, int *method_indexp, int *field_indexp) |
c906108c SS |
1332 | { |
1333 | int i; | |
1334 | ||
1335 | for (i = 0; i < TYPE_NFN_FIELDS (t); i++) | |
1336 | { | |
1337 | int j; | |
1338 | struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i); | |
1339 | ||
1340 | for (j = 0; j < TYPE_FN_FIELDLIST_LENGTH (t, i); j++) | |
1341 | { | |
015a42b4 | 1342 | if (is_destructor_name (TYPE_FN_FIELD_PHYSNAME (f, j)) != 0) |
c906108c SS |
1343 | { |
1344 | *method_indexp = i; | |
1345 | *field_indexp = j; | |
1346 | return 1; | |
1347 | } | |
1348 | } | |
1349 | } | |
1350 | return 0; | |
1351 | } | |
1352 | ||
44e1a9eb DJ |
1353 | static void |
1354 | stub_noname_complaint (void) | |
1355 | { | |
1356 | complaint (&symfile_complaints, "stub type has NULL name"); | |
1357 | } | |
1358 | ||
c906108c SS |
1359 | /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989. |
1360 | ||
1361 | If this is a stubbed struct (i.e. declared as struct foo *), see if | |
1362 | we can find a full definition in some other file. If so, copy this | |
1363 | definition, so we can use it in future. There used to be a comment (but | |
1364 | not any code) that if we don't find a full definition, we'd set a flag | |
1365 | so we don't spend time in the future checking the same type. That would | |
1366 | be a mistake, though--we might load in more symbols which contain a | |
1367 | full definition for the type. | |
1368 | ||
7b83ea04 | 1369 | This used to be coded as a macro, but I don't think it is called |
c906108c SS |
1370 | often enough to merit such treatment. */ |
1371 | ||
44e1a9eb DJ |
1372 | /* Find the real type of TYPE. This function returns the real type, after |
1373 | removing all layers of typedefs and completing opaque or stub types. | |
1374 | Completion changes the TYPE argument, but stripping of typedefs does | |
1375 | not. */ | |
c906108c SS |
1376 | |
1377 | struct type * | |
a02fd225 | 1378 | check_typedef (struct type *type) |
c906108c SS |
1379 | { |
1380 | struct type *orig_type = type; | |
a02fd225 DJ |
1381 | int is_const, is_volatile; |
1382 | ||
c906108c SS |
1383 | while (TYPE_CODE (type) == TYPE_CODE_TYPEDEF) |
1384 | { | |
1385 | if (!TYPE_TARGET_TYPE (type)) | |
1386 | { | |
c5aa993b | 1387 | char *name; |
c906108c SS |
1388 | struct symbol *sym; |
1389 | ||
1390 | /* It is dangerous to call lookup_symbol if we are currently | |
1391 | reading a symtab. Infinite recursion is one danger. */ | |
1392 | if (currently_reading_symtab) | |
1393 | return type; | |
1394 | ||
1395 | name = type_name_no_tag (type); | |
1396 | /* FIXME: shouldn't we separately check the TYPE_NAME and the | |
176620f1 | 1397 | TYPE_TAG_NAME, and look in STRUCT_DOMAIN and/or VAR_DOMAIN |
c906108c SS |
1398 | as appropriate? (this code was written before TYPE_NAME and |
1399 | TYPE_TAG_NAME were separate). */ | |
1400 | if (name == NULL) | |
1401 | { | |
23136709 | 1402 | stub_noname_complaint (); |
c906108c SS |
1403 | return type; |
1404 | } | |
176620f1 | 1405 | sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0, |
c906108c SS |
1406 | (struct symtab **) NULL); |
1407 | if (sym) | |
1408 | TYPE_TARGET_TYPE (type) = SYMBOL_TYPE (sym); | |
1409 | else | |
c5aa993b | 1410 | TYPE_TARGET_TYPE (type) = alloc_type (NULL); /* TYPE_CODE_UNDEF */ |
c906108c SS |
1411 | } |
1412 | type = TYPE_TARGET_TYPE (type); | |
1413 | } | |
1414 | ||
a02fd225 DJ |
1415 | is_const = TYPE_CONST (type); |
1416 | is_volatile = TYPE_VOLATILE (type); | |
1417 | ||
c906108c SS |
1418 | /* If this is a struct/class/union with no fields, then check whether a |
1419 | full definition exists somewhere else. This is for systems where a | |
1420 | type definition with no fields is issued for such types, instead of | |
c5aa993b JM |
1421 | identifying them as stub types in the first place */ |
1422 | ||
c906108c SS |
1423 | if (TYPE_IS_OPAQUE (type) && opaque_type_resolution && !currently_reading_symtab) |
1424 | { | |
c5aa993b JM |
1425 | char *name = type_name_no_tag (type); |
1426 | struct type *newtype; | |
c906108c SS |
1427 | if (name == NULL) |
1428 | { | |
23136709 | 1429 | stub_noname_complaint (); |
c906108c SS |
1430 | return type; |
1431 | } | |
1432 | newtype = lookup_transparent_type (name); | |
ad766c0a | 1433 | |
c906108c | 1434 | if (newtype) |
ad766c0a JB |
1435 | { |
1436 | /* If the resolved type and the stub are in the same objfile, | |
1437 | then replace the stub type with the real deal. But if | |
1438 | they're in separate objfiles, leave the stub alone; we'll | |
1439 | just look up the transparent type every time we call | |
1440 | check_typedef. We can't create pointers between types | |
1441 | allocated to different objfiles, since they may have | |
1442 | different lifetimes. Trying to copy NEWTYPE over to TYPE's | |
1443 | objfile is pointless, too, since you'll have to move over any | |
1444 | other types NEWTYPE refers to, which could be an unbounded | |
1445 | amount of stuff. */ | |
1446 | if (TYPE_OBJFILE (newtype) == TYPE_OBJFILE (type)) | |
1447 | make_cv_type (is_const, is_volatile, newtype, &type); | |
1448 | else | |
1449 | type = newtype; | |
1450 | } | |
c906108c SS |
1451 | } |
1452 | /* Otherwise, rely on the stub flag being set for opaque/stubbed types */ | |
74a9bb82 | 1453 | else if (TYPE_STUB (type) && !currently_reading_symtab) |
c906108c | 1454 | { |
c5aa993b | 1455 | char *name = type_name_no_tag (type); |
c906108c | 1456 | /* FIXME: shouldn't we separately check the TYPE_NAME and the |
176620f1 | 1457 | TYPE_TAG_NAME, and look in STRUCT_DOMAIN and/or VAR_DOMAIN |
7b83ea04 AC |
1458 | as appropriate? (this code was written before TYPE_NAME and |
1459 | TYPE_TAG_NAME were separate). */ | |
c906108c SS |
1460 | struct symbol *sym; |
1461 | if (name == NULL) | |
1462 | { | |
23136709 | 1463 | stub_noname_complaint (); |
c906108c SS |
1464 | return type; |
1465 | } | |
176620f1 | 1466 | sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0, (struct symtab **) NULL); |
c906108c | 1467 | if (sym) |
a02fd225 | 1468 | make_cv_type (is_const, is_volatile, SYMBOL_TYPE (sym), &type); |
c906108c SS |
1469 | } |
1470 | ||
74a9bb82 | 1471 | if (TYPE_TARGET_STUB (type)) |
c906108c SS |
1472 | { |
1473 | struct type *range_type; | |
1474 | struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type)); | |
1475 | ||
74a9bb82 | 1476 | if (TYPE_STUB (target_type) || TYPE_TARGET_STUB (target_type)) |
c5aa993b JM |
1477 | { |
1478 | } | |
c906108c SS |
1479 | else if (TYPE_CODE (type) == TYPE_CODE_ARRAY |
1480 | && TYPE_NFIELDS (type) == 1 | |
1481 | && (TYPE_CODE (range_type = TYPE_FIELD_TYPE (type, 0)) | |
1482 | == TYPE_CODE_RANGE)) | |
1483 | { | |
1484 | /* Now recompute the length of the array type, based on its | |
1485 | number of elements and the target type's length. */ | |
1486 | TYPE_LENGTH (type) = | |
1487 | ((TYPE_FIELD_BITPOS (range_type, 1) | |
1488 | - TYPE_FIELD_BITPOS (range_type, 0) | |
1489 | + 1) | |
1490 | * TYPE_LENGTH (target_type)); | |
1491 | TYPE_FLAGS (type) &= ~TYPE_FLAG_TARGET_STUB; | |
1492 | } | |
1493 | else if (TYPE_CODE (type) == TYPE_CODE_RANGE) | |
1494 | { | |
1495 | TYPE_LENGTH (type) = TYPE_LENGTH (target_type); | |
1496 | TYPE_FLAGS (type) &= ~TYPE_FLAG_TARGET_STUB; | |
1497 | } | |
1498 | } | |
1499 | /* Cache TYPE_LENGTH for future use. */ | |
1500 | TYPE_LENGTH (orig_type) = TYPE_LENGTH (type); | |
1501 | return type; | |
1502 | } | |
1503 | ||
c91ecb25 ND |
1504 | /* Parse a type expression in the string [P..P+LENGTH). If an error occurs, |
1505 | silently return builtin_type_void. */ | |
1506 | ||
b9362cc7 | 1507 | static struct type * |
c91ecb25 ND |
1508 | safe_parse_type (char *p, int length) |
1509 | { | |
1510 | struct ui_file *saved_gdb_stderr; | |
1511 | struct type *type; | |
1512 | ||
1513 | /* Suppress error messages. */ | |
1514 | saved_gdb_stderr = gdb_stderr; | |
1515 | gdb_stderr = ui_file_new (); | |
1516 | ||
1517 | /* Call parse_and_eval_type() without fear of longjmp()s. */ | |
1518 | if (!gdb_parse_and_eval_type (p, length, &type)) | |
1519 | type = builtin_type_void; | |
1520 | ||
1521 | /* Stop suppressing error messages. */ | |
1522 | ui_file_delete (gdb_stderr); | |
1523 | gdb_stderr = saved_gdb_stderr; | |
1524 | ||
1525 | return type; | |
1526 | } | |
1527 | ||
c906108c SS |
1528 | /* Ugly hack to convert method stubs into method types. |
1529 | ||
1530 | He ain't kiddin'. This demangles the name of the method into a string | |
1531 | including argument types, parses out each argument type, generates | |
1532 | a string casting a zero to that type, evaluates the string, and stuffs | |
1533 | the resulting type into an argtype vector!!! Then it knows the type | |
1534 | of the whole function (including argument types for overloading), | |
1535 | which info used to be in the stab's but was removed to hack back | |
1536 | the space required for them. */ | |
1537 | ||
de17c821 | 1538 | static void |
fba45db2 | 1539 | check_stub_method (struct type *type, int method_id, int signature_id) |
c906108c SS |
1540 | { |
1541 | struct fn_field *f; | |
1542 | char *mangled_name = gdb_mangle_name (type, method_id, signature_id); | |
1543 | char *demangled_name = cplus_demangle (mangled_name, | |
1544 | DMGL_PARAMS | DMGL_ANSI); | |
1545 | char *argtypetext, *p; | |
1546 | int depth = 0, argcount = 1; | |
ad2f7632 | 1547 | struct field *argtypes; |
c906108c SS |
1548 | struct type *mtype; |
1549 | ||
1550 | /* Make sure we got back a function string that we can use. */ | |
1551 | if (demangled_name) | |
1552 | p = strchr (demangled_name, '('); | |
502dcf4e AC |
1553 | else |
1554 | p = NULL; | |
c906108c SS |
1555 | |
1556 | if (demangled_name == NULL || p == NULL) | |
1557 | error ("Internal: Cannot demangle mangled name `%s'.", mangled_name); | |
1558 | ||
1559 | /* Now, read in the parameters that define this type. */ | |
1560 | p += 1; | |
1561 | argtypetext = p; | |
1562 | while (*p) | |
1563 | { | |
070ad9f0 | 1564 | if (*p == '(' || *p == '<') |
c906108c SS |
1565 | { |
1566 | depth += 1; | |
1567 | } | |
070ad9f0 | 1568 | else if (*p == ')' || *p == '>') |
c906108c SS |
1569 | { |
1570 | depth -= 1; | |
1571 | } | |
1572 | else if (*p == ',' && depth == 0) | |
1573 | { | |
1574 | argcount += 1; | |
1575 | } | |
1576 | ||
1577 | p += 1; | |
1578 | } | |
1579 | ||
ad2f7632 DJ |
1580 | /* If we read one argument and it was ``void'', don't count it. */ |
1581 | if (strncmp (argtypetext, "(void)", 6) == 0) | |
1582 | argcount -= 1; | |
c906108c | 1583 | |
ad2f7632 DJ |
1584 | /* We need one extra slot, for the THIS pointer. */ |
1585 | ||
1586 | argtypes = (struct field *) | |
1587 | TYPE_ALLOC (type, (argcount + 1) * sizeof (struct field)); | |
c906108c | 1588 | p = argtypetext; |
4a1970e4 DJ |
1589 | |
1590 | /* Add THIS pointer for non-static methods. */ | |
1591 | f = TYPE_FN_FIELDLIST1 (type, method_id); | |
1592 | if (TYPE_FN_FIELD_STATIC_P (f, signature_id)) | |
1593 | argcount = 0; | |
1594 | else | |
1595 | { | |
ad2f7632 | 1596 | argtypes[0].type = lookup_pointer_type (type); |
4a1970e4 DJ |
1597 | argcount = 1; |
1598 | } | |
c906108c | 1599 | |
c5aa993b | 1600 | if (*p != ')') /* () means no args, skip while */ |
c906108c SS |
1601 | { |
1602 | depth = 0; | |
1603 | while (*p) | |
1604 | { | |
1605 | if (depth <= 0 && (*p == ',' || *p == ')')) | |
1606 | { | |
ad2f7632 DJ |
1607 | /* Avoid parsing of ellipsis, they will be handled below. |
1608 | Also avoid ``void'' as above. */ | |
1609 | if (strncmp (argtypetext, "...", p - argtypetext) != 0 | |
1610 | && strncmp (argtypetext, "void", p - argtypetext) != 0) | |
c906108c | 1611 | { |
ad2f7632 | 1612 | argtypes[argcount].type = |
c91ecb25 | 1613 | safe_parse_type (argtypetext, p - argtypetext); |
c906108c SS |
1614 | argcount += 1; |
1615 | } | |
1616 | argtypetext = p + 1; | |
1617 | } | |
1618 | ||
070ad9f0 | 1619 | if (*p == '(' || *p == '<') |
c906108c SS |
1620 | { |
1621 | depth += 1; | |
1622 | } | |
070ad9f0 | 1623 | else if (*p == ')' || *p == '>') |
c906108c SS |
1624 | { |
1625 | depth -= 1; | |
1626 | } | |
1627 | ||
1628 | p += 1; | |
1629 | } | |
1630 | } | |
1631 | ||
c906108c SS |
1632 | TYPE_FN_FIELD_PHYSNAME (f, signature_id) = mangled_name; |
1633 | ||
1634 | /* Now update the old "stub" type into a real type. */ | |
1635 | mtype = TYPE_FN_FIELD_TYPE (f, signature_id); | |
1636 | TYPE_DOMAIN_TYPE (mtype) = type; | |
ad2f7632 DJ |
1637 | TYPE_FIELDS (mtype) = argtypes; |
1638 | TYPE_NFIELDS (mtype) = argcount; | |
c906108c SS |
1639 | TYPE_FLAGS (mtype) &= ~TYPE_FLAG_STUB; |
1640 | TYPE_FN_FIELD_STUB (f, signature_id) = 0; | |
ad2f7632 DJ |
1641 | if (p[-2] == '.') |
1642 | TYPE_FLAGS (mtype) |= TYPE_FLAG_VARARGS; | |
1643 | ||
1644 | xfree (demangled_name); | |
c906108c SS |
1645 | } |
1646 | ||
de17c821 DJ |
1647 | /* This is the external interface to check_stub_method, above. This function |
1648 | unstubs all of the signatures for TYPE's METHOD_ID method name. After | |
1649 | calling this function TYPE_FN_FIELD_STUB will be cleared for each signature | |
1650 | and TYPE_FN_FIELDLIST_NAME will be correct. | |
1651 | ||
1652 | This function unfortunately can not die until stabs do. */ | |
1653 | ||
1654 | void | |
1655 | check_stub_method_group (struct type *type, int method_id) | |
1656 | { | |
1657 | int len = TYPE_FN_FIELDLIST_LENGTH (type, method_id); | |
1658 | struct fn_field *f = TYPE_FN_FIELDLIST1 (type, method_id); | |
f710f4fc | 1659 | int j, found_stub = 0; |
de17c821 DJ |
1660 | |
1661 | for (j = 0; j < len; j++) | |
1662 | if (TYPE_FN_FIELD_STUB (f, j)) | |
1663 | { | |
1664 | found_stub = 1; | |
1665 | check_stub_method (type, method_id, j); | |
1666 | } | |
1667 | ||
1668 | /* GNU v3 methods with incorrect names were corrected when we read in | |
1669 | type information, because it was cheaper to do it then. The only GNU v2 | |
1670 | methods with incorrect method names are operators and destructors; | |
1671 | destructors were also corrected when we read in type information. | |
1672 | ||
1673 | Therefore the only thing we need to handle here are v2 operator | |
1674 | names. */ | |
1675 | if (found_stub && strncmp (TYPE_FN_FIELD_PHYSNAME (f, 0), "_Z", 2) != 0) | |
1676 | { | |
1677 | int ret; | |
1678 | char dem_opname[256]; | |
1679 | ||
1680 | ret = cplus_demangle_opname (TYPE_FN_FIELDLIST_NAME (type, method_id), | |
1681 | dem_opname, DMGL_ANSI); | |
1682 | if (!ret) | |
1683 | ret = cplus_demangle_opname (TYPE_FN_FIELDLIST_NAME (type, method_id), | |
1684 | dem_opname, 0); | |
1685 | if (ret) | |
1686 | TYPE_FN_FIELDLIST_NAME (type, method_id) = xstrdup (dem_opname); | |
1687 | } | |
1688 | } | |
1689 | ||
c906108c SS |
1690 | const struct cplus_struct_type cplus_struct_default; |
1691 | ||
1692 | void | |
fba45db2 | 1693 | allocate_cplus_struct_type (struct type *type) |
c906108c SS |
1694 | { |
1695 | if (!HAVE_CPLUS_STRUCT (type)) | |
1696 | { | |
1697 | TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *) | |
1698 | TYPE_ALLOC (type, sizeof (struct cplus_struct_type)); | |
c5aa993b | 1699 | *(TYPE_CPLUS_SPECIFIC (type)) = cplus_struct_default; |
c906108c SS |
1700 | } |
1701 | } | |
1702 | ||
1703 | /* Helper function to initialize the standard scalar types. | |
1704 | ||
1705 | If NAME is non-NULL and OBJFILE is non-NULL, then we make a copy | |
b99607ea | 1706 | of the string pointed to by name in the objfile_obstack for that objfile, |
c906108c SS |
1707 | and initialize the type name to that copy. There are places (mipsread.c |
1708 | in particular, where init_type is called with a NULL value for NAME). */ | |
1709 | ||
1710 | struct type * | |
fba45db2 KB |
1711 | init_type (enum type_code code, int length, int flags, char *name, |
1712 | struct objfile *objfile) | |
c906108c | 1713 | { |
52f0bd74 | 1714 | struct type *type; |
c906108c SS |
1715 | |
1716 | type = alloc_type (objfile); | |
1717 | TYPE_CODE (type) = code; | |
1718 | TYPE_LENGTH (type) = length; | |
1719 | TYPE_FLAGS (type) |= flags; | |
1720 | if ((name != NULL) && (objfile != NULL)) | |
1721 | { | |
1722 | TYPE_NAME (type) = | |
b99607ea | 1723 | obsavestring (name, strlen (name), &objfile->objfile_obstack); |
c906108c SS |
1724 | } |
1725 | else | |
1726 | { | |
1727 | TYPE_NAME (type) = name; | |
1728 | } | |
1729 | ||
1730 | /* C++ fancies. */ | |
1731 | ||
973ccf8b DJ |
1732 | if (name && strcmp (name, "char") == 0) |
1733 | TYPE_FLAGS (type) |= TYPE_FLAG_NOSIGN; | |
1734 | ||
5c4e30ca DC |
1735 | if (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION |
1736 | || code == TYPE_CODE_NAMESPACE) | |
c906108c SS |
1737 | { |
1738 | INIT_CPLUS_SPECIFIC (type); | |
1739 | } | |
1740 | return (type); | |
1741 | } | |
1742 | ||
0e101458 AC |
1743 | /* Helper function. Create an empty composite type. */ |
1744 | ||
1745 | struct type * | |
1746 | init_composite_type (char *name, enum type_code code) | |
1747 | { | |
1748 | struct type *t; | |
1749 | gdb_assert (code == TYPE_CODE_STRUCT | |
1750 | || code == TYPE_CODE_UNION); | |
1751 | t = init_type (code, 0, 0, NULL, NULL); | |
1752 | TYPE_TAG_NAME (t) = name; | |
1753 | return t; | |
1754 | } | |
1755 | ||
1756 | /* Helper function. Append a field to a composite type. */ | |
1757 | ||
1758 | void | |
1759 | append_composite_type_field (struct type *t, char *name, struct type *field) | |
1760 | { | |
1761 | struct field *f; | |
1762 | TYPE_NFIELDS (t) = TYPE_NFIELDS (t) + 1; | |
1763 | TYPE_FIELDS (t) = xrealloc (TYPE_FIELDS (t), | |
1764 | sizeof (struct field) * TYPE_NFIELDS (t)); | |
1765 | f = &(TYPE_FIELDS (t)[TYPE_NFIELDS (t) - 1]); | |
1766 | memset (f, 0, sizeof f[0]); | |
1767 | FIELD_TYPE (f[0]) = field; | |
1768 | FIELD_NAME (f[0]) = name; | |
1769 | if (TYPE_CODE (t) == TYPE_CODE_UNION) | |
1770 | { | |
73d322b1 | 1771 | if (TYPE_LENGTH (t) < TYPE_LENGTH (field)) |
0e101458 AC |
1772 | TYPE_LENGTH (t) = TYPE_LENGTH (field); |
1773 | } | |
1774 | else if (TYPE_CODE (t) == TYPE_CODE_STRUCT) | |
1775 | { | |
1776 | TYPE_LENGTH (t) = TYPE_LENGTH (t) + TYPE_LENGTH (field); | |
1777 | if (TYPE_NFIELDS (t) > 1) | |
1778 | { | |
1779 | FIELD_BITPOS (f[0]) = (FIELD_BITPOS (f[-1]) | |
1780 | + TYPE_LENGTH (field) * TARGET_CHAR_BIT); | |
1781 | } | |
1782 | } | |
1783 | } | |
1784 | ||
c906108c SS |
1785 | /* Look up a fundamental type for the specified objfile. |
1786 | May need to construct such a type if this is the first use. | |
1787 | ||
1788 | Some object file formats (ELF, COFF, etc) do not define fundamental | |
1789 | types such as "int" or "double". Others (stabs for example), do | |
1790 | define fundamental types. | |
1791 | ||
1792 | For the formats which don't provide fundamental types, gdb can create | |
1793 | such types, using defaults reasonable for the current language and | |
1794 | the current target machine. | |
1795 | ||
1796 | NOTE: This routine is obsolescent. Each debugging format reader | |
1797 | should manage it's own fundamental types, either creating them from | |
1798 | suitable defaults or reading them from the debugging information, | |
1799 | whichever is appropriate. The DWARF reader has already been | |
1800 | fixed to do this. Once the other readers are fixed, this routine | |
1801 | will go away. Also note that fundamental types should be managed | |
1802 | on a compilation unit basis in a multi-language environment, not | |
1803 | on a linkage unit basis as is done here. */ | |
1804 | ||
1805 | ||
1806 | struct type * | |
fba45db2 | 1807 | lookup_fundamental_type (struct objfile *objfile, int typeid) |
c906108c | 1808 | { |
52f0bd74 AC |
1809 | struct type **typep; |
1810 | int nbytes; | |
c906108c SS |
1811 | |
1812 | if (typeid < 0 || typeid >= FT_NUM_MEMBERS) | |
1813 | { | |
1814 | error ("internal error - invalid fundamental type id %d", typeid); | |
1815 | } | |
1816 | ||
1817 | /* If this is the first time we need a fundamental type for this objfile | |
1818 | then we need to initialize the vector of type pointers. */ | |
c5aa993b JM |
1819 | |
1820 | if (objfile->fundamental_types == NULL) | |
c906108c SS |
1821 | { |
1822 | nbytes = FT_NUM_MEMBERS * sizeof (struct type *); | |
c5aa993b | 1823 | objfile->fundamental_types = (struct type **) |
b99607ea | 1824 | obstack_alloc (&objfile->objfile_obstack, nbytes); |
c5aa993b | 1825 | memset ((char *) objfile->fundamental_types, 0, nbytes); |
c906108c SS |
1826 | OBJSTAT (objfile, n_types += FT_NUM_MEMBERS); |
1827 | } | |
1828 | ||
1829 | /* Look for this particular type in the fundamental type vector. If one is | |
1830 | not found, create and install one appropriate for the current language. */ | |
1831 | ||
c5aa993b | 1832 | typep = objfile->fundamental_types + typeid; |
c906108c SS |
1833 | if (*typep == NULL) |
1834 | { | |
1835 | *typep = create_fundamental_type (objfile, typeid); | |
1836 | } | |
1837 | ||
1838 | return (*typep); | |
1839 | } | |
1840 | ||
1841 | int | |
fba45db2 | 1842 | can_dereference (struct type *t) |
c906108c SS |
1843 | { |
1844 | /* FIXME: Should we return true for references as well as pointers? */ | |
1845 | CHECK_TYPEDEF (t); | |
1846 | return | |
1847 | (t != NULL | |
1848 | && TYPE_CODE (t) == TYPE_CODE_PTR | |
1849 | && TYPE_CODE (TYPE_TARGET_TYPE (t)) != TYPE_CODE_VOID); | |
1850 | } | |
1851 | ||
adf40b2e | 1852 | int |
fba45db2 | 1853 | is_integral_type (struct type *t) |
adf40b2e JM |
1854 | { |
1855 | CHECK_TYPEDEF (t); | |
1856 | return | |
1857 | ((t != NULL) | |
d4f3574e SS |
1858 | && ((TYPE_CODE (t) == TYPE_CODE_INT) |
1859 | || (TYPE_CODE (t) == TYPE_CODE_ENUM) | |
1860 | || (TYPE_CODE (t) == TYPE_CODE_CHAR) | |
1861 | || (TYPE_CODE (t) == TYPE_CODE_RANGE) | |
1862 | || (TYPE_CODE (t) == TYPE_CODE_BOOL))); | |
adf40b2e JM |
1863 | } |
1864 | ||
7b83ea04 | 1865 | /* Check whether BASE is an ancestor or base class or DCLASS |
c906108c SS |
1866 | Return 1 if so, and 0 if not. |
1867 | Note: callers may want to check for identity of the types before | |
1868 | calling this function -- identical types are considered to satisfy | |
1869 | the ancestor relationship even if they're identical */ | |
1870 | ||
1871 | int | |
fba45db2 | 1872 | is_ancestor (struct type *base, struct type *dclass) |
c906108c SS |
1873 | { |
1874 | int i; | |
c5aa993b | 1875 | |
c906108c SS |
1876 | CHECK_TYPEDEF (base); |
1877 | CHECK_TYPEDEF (dclass); | |
1878 | ||
1879 | if (base == dclass) | |
1880 | return 1; | |
6b1ba9a0 ND |
1881 | if (TYPE_NAME (base) && TYPE_NAME (dclass) && |
1882 | !strcmp (TYPE_NAME (base), TYPE_NAME (dclass))) | |
1883 | return 1; | |
c906108c SS |
1884 | |
1885 | for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++) | |
1886 | if (is_ancestor (base, TYPE_BASECLASS (dclass, i))) | |
1887 | return 1; | |
1888 | ||
1889 | return 0; | |
1890 | } | |
1891 | ||
1892 | ||
1893 | ||
1894 | /* See whether DCLASS has a virtual table. This routine is aimed at | |
1895 | the HP/Taligent ANSI C++ runtime model, and may not work with other | |
1896 | runtime models. Return 1 => Yes, 0 => No. */ | |
1897 | ||
1898 | int | |
fba45db2 | 1899 | has_vtable (struct type *dclass) |
c906108c SS |
1900 | { |
1901 | /* In the HP ANSI C++ runtime model, a class has a vtable only if it | |
1902 | has virtual functions or virtual bases. */ | |
1903 | ||
52f0bd74 | 1904 | int i; |
c906108c | 1905 | |
c5aa993b | 1906 | if (TYPE_CODE (dclass) != TYPE_CODE_CLASS) |
c906108c | 1907 | return 0; |
c5aa993b | 1908 | |
c906108c | 1909 | /* First check for the presence of virtual bases */ |
c5aa993b JM |
1910 | if (TYPE_FIELD_VIRTUAL_BITS (dclass)) |
1911 | for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++) | |
1912 | if (B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass), i)) | |
1913 | return 1; | |
1914 | ||
c906108c | 1915 | /* Next check for virtual functions */ |
c5aa993b JM |
1916 | if (TYPE_FN_FIELDLISTS (dclass)) |
1917 | for (i = 0; i < TYPE_NFN_FIELDS (dclass); i++) | |
1918 | if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass, i), 0)) | |
c906108c | 1919 | return 1; |
c5aa993b JM |
1920 | |
1921 | /* Recurse on non-virtual bases to see if any of them needs a vtable */ | |
1922 | if (TYPE_FIELD_VIRTUAL_BITS (dclass)) | |
1923 | for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++) | |
1924 | if ((!B_TST (TYPE_FIELD_VIRTUAL_BITS (dclass), i)) && | |
1925 | (has_vtable (TYPE_FIELD_TYPE (dclass, i)))) | |
1926 | return 1; | |
1927 | ||
1928 | /* Well, maybe we don't need a virtual table */ | |
c906108c SS |
1929 | return 0; |
1930 | } | |
1931 | ||
1932 | /* Return a pointer to the "primary base class" of DCLASS. | |
c5aa993b | 1933 | |
c906108c SS |
1934 | A NULL return indicates that DCLASS has no primary base, or that it |
1935 | couldn't be found (insufficient information). | |
c5aa993b | 1936 | |
c906108c SS |
1937 | This routine is aimed at the HP/Taligent ANSI C++ runtime model, |
1938 | and may not work with other runtime models. */ | |
1939 | ||
1940 | struct type * | |
fba45db2 | 1941 | primary_base_class (struct type *dclass) |
c906108c SS |
1942 | { |
1943 | /* In HP ANSI C++'s runtime model, a "primary base class" of a class | |
1944 | is the first directly inherited, non-virtual base class that | |
1945 | requires a virtual table */ | |
1946 | ||
52f0bd74 | 1947 | int i; |
c906108c | 1948 | |
c5aa993b | 1949 | if (TYPE_CODE (dclass) != TYPE_CODE_CLASS) |
c906108c SS |
1950 | return NULL; |
1951 | ||
c5aa993b JM |
1952 | for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++) |
1953 | if (!TYPE_FIELD_VIRTUAL (dclass, i) && | |
1954 | has_vtable (TYPE_FIELD_TYPE (dclass, i))) | |
1955 | return TYPE_FIELD_TYPE (dclass, i); | |
c906108c SS |
1956 | |
1957 | return NULL; | |
1958 | } | |
1959 | ||
1960 | /* Global manipulated by virtual_base_list[_aux]() */ | |
1961 | ||
c5aa993b | 1962 | static struct vbase *current_vbase_list = NULL; |
c906108c SS |
1963 | |
1964 | /* Return a pointer to a null-terminated list of struct vbase | |
1965 | items. The vbasetype pointer of each item in the list points to the | |
1966 | type information for a virtual base of the argument DCLASS. | |
c5aa993b | 1967 | |
7b83ea04 | 1968 | Helper function for virtual_base_list(). |
c906108c SS |
1969 | Note: the list goes backward, right-to-left. virtual_base_list() |
1970 | copies the items out in reverse order. */ | |
1971 | ||
7a292a7a | 1972 | static void |
fba45db2 | 1973 | virtual_base_list_aux (struct type *dclass) |
c906108c | 1974 | { |
c5aa993b | 1975 | struct vbase *tmp_vbase; |
52f0bd74 | 1976 | int i; |
c906108c | 1977 | |
c5aa993b | 1978 | if (TYPE_CODE (dclass) != TYPE_CODE_CLASS) |
7a292a7a | 1979 | return; |
c906108c SS |
1980 | |
1981 | for (i = 0; i < TYPE_N_BASECLASSES (dclass); i++) | |
1982 | { | |
1983 | /* Recurse on this ancestor, first */ | |
c5aa993b | 1984 | virtual_base_list_aux (TYPE_FIELD_TYPE (dclass, i)); |
c906108c SS |
1985 | |
1986 | /* If this current base is itself virtual, add it to the list */ | |
c5aa993b JM |
1987 | if (BASETYPE_VIA_VIRTUAL (dclass, i)) |
1988 | { | |
1989 | struct type *basetype = TYPE_FIELD_TYPE (dclass, i); | |
1990 | ||
1991 | /* Check if base already recorded */ | |
1992 | tmp_vbase = current_vbase_list; | |
1993 | while (tmp_vbase) | |
1994 | { | |
1995 | if (tmp_vbase->vbasetype == basetype) | |
1996 | break; /* found it */ | |
1997 | tmp_vbase = tmp_vbase->next; | |
1998 | } | |
1999 | ||
2000 | if (!tmp_vbase) /* normal exit from loop */ | |
2001 | { | |
2002 | /* Allocate new item for this virtual base */ | |
2003 | tmp_vbase = (struct vbase *) xmalloc (sizeof (struct vbase)); | |
2004 | ||
2005 | /* Stick it on at the end of the list */ | |
2006 | tmp_vbase->vbasetype = basetype; | |
2007 | tmp_vbase->next = current_vbase_list; | |
2008 | current_vbase_list = tmp_vbase; | |
2009 | } | |
2010 | } /* if virtual */ | |
2011 | } /* for loop over bases */ | |
c906108c SS |
2012 | } |
2013 | ||
2014 | ||
2015 | /* Compute the list of virtual bases in the right order. Virtual | |
2016 | bases are laid out in the object's memory area in order of their | |
2017 | occurrence in a depth-first, left-to-right search through the | |
2018 | ancestors. | |
c5aa993b | 2019 | |
c906108c SS |
2020 | Argument DCLASS is the type whose virtual bases are required. |
2021 | Return value is the address of a null-terminated array of pointers | |
2022 | to struct type items. | |
c5aa993b | 2023 | |
c906108c SS |
2024 | This routine is aimed at the HP/Taligent ANSI C++ runtime model, |
2025 | and may not work with other runtime models. | |
c5aa993b | 2026 | |
c906108c SS |
2027 | This routine merely hands off the argument to virtual_base_list_aux() |
2028 | and then copies the result into an array to save space. */ | |
2029 | ||
2030 | struct type ** | |
fba45db2 | 2031 | virtual_base_list (struct type *dclass) |
c906108c | 2032 | { |
52f0bd74 AC |
2033 | struct vbase *tmp_vbase; |
2034 | struct vbase *tmp_vbase_2; | |
2035 | int i; | |
c906108c | 2036 | int count; |
c5aa993b | 2037 | struct type **vbase_array; |
c906108c SS |
2038 | |
2039 | current_vbase_list = NULL; | |
c5aa993b | 2040 | virtual_base_list_aux (dclass); |
c906108c | 2041 | |
c5aa993b | 2042 | for (i = 0, tmp_vbase = current_vbase_list; tmp_vbase != NULL; i++, tmp_vbase = tmp_vbase->next) |
c906108c SS |
2043 | /* no body */ ; |
2044 | ||
2045 | count = i; | |
2046 | ||
c5aa993b | 2047 | vbase_array = (struct type **) xmalloc ((count + 1) * sizeof (struct type *)); |
c906108c | 2048 | |
c5aa993b | 2049 | for (i = count - 1, tmp_vbase = current_vbase_list; i >= 0; i--, tmp_vbase = tmp_vbase->next) |
c906108c SS |
2050 | vbase_array[i] = tmp_vbase->vbasetype; |
2051 | ||
2052 | /* Get rid of constructed chain */ | |
2053 | tmp_vbase_2 = tmp_vbase = current_vbase_list; | |
2054 | while (tmp_vbase) | |
2055 | { | |
2056 | tmp_vbase = tmp_vbase->next; | |
b8c9b27d | 2057 | xfree (tmp_vbase_2); |
c906108c SS |
2058 | tmp_vbase_2 = tmp_vbase; |
2059 | } | |
c5aa993b | 2060 | |
c906108c SS |
2061 | vbase_array[count] = NULL; |
2062 | return vbase_array; | |
2063 | } | |
2064 | ||
2065 | /* Return the length of the virtual base list of the type DCLASS. */ | |
2066 | ||
2067 | int | |
fba45db2 | 2068 | virtual_base_list_length (struct type *dclass) |
c906108c | 2069 | { |
52f0bd74 AC |
2070 | int i; |
2071 | struct vbase *tmp_vbase; | |
c5aa993b | 2072 | |
c906108c | 2073 | current_vbase_list = NULL; |
c5aa993b | 2074 | virtual_base_list_aux (dclass); |
c906108c | 2075 | |
c5aa993b | 2076 | for (i = 0, tmp_vbase = current_vbase_list; tmp_vbase != NULL; i++, tmp_vbase = tmp_vbase->next) |
c906108c SS |
2077 | /* no body */ ; |
2078 | return i; | |
2079 | } | |
2080 | ||
2081 | /* Return the number of elements of the virtual base list of the type | |
2082 | DCLASS, ignoring those appearing in the primary base (and its | |
2083 | primary base, recursively). */ | |
2084 | ||
2085 | int | |
fba45db2 | 2086 | virtual_base_list_length_skip_primaries (struct type *dclass) |
c906108c | 2087 | { |
52f0bd74 AC |
2088 | int i; |
2089 | struct vbase *tmp_vbase; | |
c5aa993b | 2090 | struct type *primary; |
c906108c SS |
2091 | |
2092 | primary = TYPE_RUNTIME_PTR (dclass) ? TYPE_PRIMARY_BASE (dclass) : NULL; | |
2093 | ||
2094 | if (!primary) | |
2095 | return virtual_base_list_length (dclass); | |
2096 | ||
2097 | current_vbase_list = NULL; | |
c5aa993b | 2098 | virtual_base_list_aux (dclass); |
c906108c | 2099 | |
c5aa993b | 2100 | for (i = 0, tmp_vbase = current_vbase_list; tmp_vbase != NULL; tmp_vbase = tmp_vbase->next) |
c906108c SS |
2101 | { |
2102 | if (virtual_base_index (tmp_vbase->vbasetype, primary) >= 0) | |
c5aa993b | 2103 | continue; |
c906108c SS |
2104 | i++; |
2105 | } | |
2106 | return i; | |
2107 | } | |
2108 | ||
2109 | ||
2110 | /* Return the index (position) of type BASE, which is a virtual base | |
2111 | class of DCLASS, in the latter's virtual base list. A return of -1 | |
2112 | indicates "not found" or a problem. */ | |
2113 | ||
2114 | int | |
fba45db2 | 2115 | virtual_base_index (struct type *base, struct type *dclass) |
c906108c | 2116 | { |
52f0bd74 AC |
2117 | struct type *vbase; |
2118 | int i; | |
c906108c | 2119 | |
c5aa993b JM |
2120 | if ((TYPE_CODE (dclass) != TYPE_CODE_CLASS) || |
2121 | (TYPE_CODE (base) != TYPE_CODE_CLASS)) | |
c906108c SS |
2122 | return -1; |
2123 | ||
2124 | i = 0; | |
015a42b4 | 2125 | vbase = virtual_base_list (dclass)[0]; |
c906108c SS |
2126 | while (vbase) |
2127 | { | |
2128 | if (vbase == base) | |
c5aa993b | 2129 | break; |
015a42b4 | 2130 | vbase = virtual_base_list (dclass)[++i]; |
c906108c SS |
2131 | } |
2132 | ||
2133 | return vbase ? i : -1; | |
2134 | } | |
2135 | ||
2136 | ||
2137 | ||
2138 | /* Return the index (position) of type BASE, which is a virtual base | |
2139 | class of DCLASS, in the latter's virtual base list. Skip over all | |
2140 | bases that may appear in the virtual base list of the primary base | |
2141 | class of DCLASS (recursively). A return of -1 indicates "not | |
2142 | found" or a problem. */ | |
2143 | ||
2144 | int | |
fba45db2 | 2145 | virtual_base_index_skip_primaries (struct type *base, struct type *dclass) |
c906108c | 2146 | { |
52f0bd74 AC |
2147 | struct type *vbase; |
2148 | int i, j; | |
c5aa993b | 2149 | struct type *primary; |
c906108c | 2150 | |
c5aa993b JM |
2151 | if ((TYPE_CODE (dclass) != TYPE_CODE_CLASS) || |
2152 | (TYPE_CODE (base) != TYPE_CODE_CLASS)) | |
c906108c SS |
2153 | return -1; |
2154 | ||
c5aa993b | 2155 | primary = TYPE_RUNTIME_PTR (dclass) ? TYPE_PRIMARY_BASE (dclass) : NULL; |
c906108c SS |
2156 | |
2157 | j = -1; | |
2158 | i = 0; | |
015a42b4 | 2159 | vbase = virtual_base_list (dclass)[0]; |
c906108c SS |
2160 | while (vbase) |
2161 | { | |
c5aa993b JM |
2162 | if (!primary || (virtual_base_index_skip_primaries (vbase, primary) < 0)) |
2163 | j++; | |
c906108c | 2164 | if (vbase == base) |
c5aa993b | 2165 | break; |
015a42b4 | 2166 | vbase = virtual_base_list (dclass)[++i]; |
c906108c SS |
2167 | } |
2168 | ||
2169 | return vbase ? j : -1; | |
2170 | } | |
2171 | ||
2172 | /* Return position of a derived class DCLASS in the list of | |
2173 | * primary bases starting with the remotest ancestor. | |
2174 | * Position returned is 0-based. */ | |
2175 | ||
2176 | int | |
fba45db2 | 2177 | class_index_in_primary_list (struct type *dclass) |
c906108c | 2178 | { |
c5aa993b | 2179 | struct type *pbc; /* primary base class */ |
c906108c | 2180 | |
c5aa993b | 2181 | /* Simply recurse on primary base */ |
c906108c SS |
2182 | pbc = TYPE_PRIMARY_BASE (dclass); |
2183 | if (pbc) | |
2184 | return 1 + class_index_in_primary_list (pbc); | |
2185 | else | |
2186 | return 0; | |
2187 | } | |
2188 | ||
2189 | /* Return a count of the number of virtual functions a type has. | |
2190 | * This includes all the virtual functions it inherits from its | |
2191 | * base classes too. | |
2192 | */ | |
2193 | ||
2194 | /* pai: FIXME This doesn't do the right thing: count redefined virtual | |
2195 | * functions only once (latest redefinition) | |
2196 | */ | |
2197 | ||
2198 | int | |
fba45db2 | 2199 | count_virtual_fns (struct type *dclass) |
c906108c | 2200 | { |
c5aa993b | 2201 | int fn, oi; /* function and overloaded instance indices */ |
c5aa993b JM |
2202 | int vfuncs; /* count to return */ |
2203 | ||
2204 | /* recurse on bases that can share virtual table */ | |
2205 | struct type *pbc = primary_base_class (dclass); | |
c906108c SS |
2206 | if (pbc) |
2207 | vfuncs = count_virtual_fns (pbc); | |
7f7e9482 AC |
2208 | else |
2209 | vfuncs = 0; | |
c5aa993b | 2210 | |
c906108c SS |
2211 | for (fn = 0; fn < TYPE_NFN_FIELDS (dclass); fn++) |
2212 | for (oi = 0; oi < TYPE_FN_FIELDLIST_LENGTH (dclass, fn); oi++) | |
2213 | if (TYPE_FN_FIELD_VIRTUAL_P (TYPE_FN_FIELDLIST1 (dclass, fn), oi)) | |
c5aa993b | 2214 | vfuncs++; |
c906108c SS |
2215 | |
2216 | return vfuncs; | |
2217 | } | |
c906108c SS |
2218 | \f |
2219 | ||
c5aa993b | 2220 | |
c906108c SS |
2221 | /* Functions for overload resolution begin here */ |
2222 | ||
2223 | /* Compare two badness vectors A and B and return the result. | |
2224 | * 0 => A and B are identical | |
2225 | * 1 => A and B are incomparable | |
2226 | * 2 => A is better than B | |
2227 | * 3 => A is worse than B */ | |
2228 | ||
2229 | int | |
fba45db2 | 2230 | compare_badness (struct badness_vector *a, struct badness_vector *b) |
c906108c SS |
2231 | { |
2232 | int i; | |
2233 | int tmp; | |
c5aa993b JM |
2234 | short found_pos = 0; /* any positives in c? */ |
2235 | short found_neg = 0; /* any negatives in c? */ | |
2236 | ||
2237 | /* differing lengths => incomparable */ | |
c906108c SS |
2238 | if (a->length != b->length) |
2239 | return 1; | |
2240 | ||
c5aa993b JM |
2241 | /* Subtract b from a */ |
2242 | for (i = 0; i < a->length; i++) | |
c906108c SS |
2243 | { |
2244 | tmp = a->rank[i] - b->rank[i]; | |
2245 | if (tmp > 0) | |
c5aa993b | 2246 | found_pos = 1; |
c906108c | 2247 | else if (tmp < 0) |
c5aa993b | 2248 | found_neg = 1; |
c906108c SS |
2249 | } |
2250 | ||
2251 | if (found_pos) | |
2252 | { | |
2253 | if (found_neg) | |
c5aa993b | 2254 | return 1; /* incomparable */ |
c906108c | 2255 | else |
c5aa993b | 2256 | return 3; /* A > B */ |
c906108c | 2257 | } |
c5aa993b JM |
2258 | else |
2259 | /* no positives */ | |
c906108c SS |
2260 | { |
2261 | if (found_neg) | |
c5aa993b | 2262 | return 2; /* A < B */ |
c906108c | 2263 | else |
c5aa993b | 2264 | return 0; /* A == B */ |
c906108c SS |
2265 | } |
2266 | } | |
2267 | ||
2268 | /* Rank a function by comparing its parameter types (PARMS, length NPARMS), | |
2269 | * to the types of an argument list (ARGS, length NARGS). | |
2270 | * Return a pointer to a badness vector. This has NARGS + 1 entries. */ | |
2271 | ||
2272 | struct badness_vector * | |
fba45db2 | 2273 | rank_function (struct type **parms, int nparms, struct type **args, int nargs) |
c906108c SS |
2274 | { |
2275 | int i; | |
c5aa993b | 2276 | struct badness_vector *bv; |
c906108c SS |
2277 | int min_len = nparms < nargs ? nparms : nargs; |
2278 | ||
2279 | bv = xmalloc (sizeof (struct badness_vector)); | |
c5aa993b | 2280 | bv->length = nargs + 1; /* add 1 for the length-match rank */ |
c906108c SS |
2281 | bv->rank = xmalloc ((nargs + 1) * sizeof (int)); |
2282 | ||
2283 | /* First compare the lengths of the supplied lists. | |
2284 | * If there is a mismatch, set it to a high value. */ | |
c5aa993b | 2285 | |
c906108c SS |
2286 | /* pai/1997-06-03 FIXME: when we have debug info about default |
2287 | * arguments and ellipsis parameter lists, we should consider those | |
2288 | * and rank the length-match more finely. */ | |
2289 | ||
2290 | LENGTH_MATCH (bv) = (nargs != nparms) ? LENGTH_MISMATCH_BADNESS : 0; | |
2291 | ||
2292 | /* Now rank all the parameters of the candidate function */ | |
74cc24b0 DB |
2293 | for (i = 1; i <= min_len; i++) |
2294 | bv->rank[i] = rank_one_type (parms[i-1], args[i-1]); | |
c906108c | 2295 | |
c5aa993b JM |
2296 | /* If more arguments than parameters, add dummy entries */ |
2297 | for (i = min_len + 1; i <= nargs; i++) | |
c906108c SS |
2298 | bv->rank[i] = TOO_FEW_PARAMS_BADNESS; |
2299 | ||
2300 | return bv; | |
2301 | } | |
2302 | ||
973ccf8b DJ |
2303 | /* Compare the names of two integer types, assuming that any sign |
2304 | qualifiers have been checked already. We do it this way because | |
2305 | there may be an "int" in the name of one of the types. */ | |
2306 | ||
2307 | static int | |
2308 | integer_types_same_name_p (const char *first, const char *second) | |
2309 | { | |
2310 | int first_p, second_p; | |
2311 | ||
2312 | /* If both are shorts, return 1; if neither is a short, keep checking. */ | |
2313 | first_p = (strstr (first, "short") != NULL); | |
2314 | second_p = (strstr (second, "short") != NULL); | |
2315 | if (first_p && second_p) | |
2316 | return 1; | |
2317 | if (first_p || second_p) | |
2318 | return 0; | |
2319 | ||
2320 | /* Likewise for long. */ | |
2321 | first_p = (strstr (first, "long") != NULL); | |
2322 | second_p = (strstr (second, "long") != NULL); | |
2323 | if (first_p && second_p) | |
2324 | return 1; | |
2325 | if (first_p || second_p) | |
2326 | return 0; | |
2327 | ||
2328 | /* Likewise for char. */ | |
2329 | first_p = (strstr (first, "char") != NULL); | |
2330 | second_p = (strstr (second, "char") != NULL); | |
2331 | if (first_p && second_p) | |
2332 | return 1; | |
2333 | if (first_p || second_p) | |
2334 | return 0; | |
2335 | ||
2336 | /* They must both be ints. */ | |
2337 | return 1; | |
2338 | } | |
2339 | ||
c906108c SS |
2340 | /* Compare one type (PARM) for compatibility with another (ARG). |
2341 | * PARM is intended to be the parameter type of a function; and | |
2342 | * ARG is the supplied argument's type. This function tests if | |
2343 | * the latter can be converted to the former. | |
2344 | * | |
2345 | * Return 0 if they are identical types; | |
2346 | * Otherwise, return an integer which corresponds to how compatible | |
2347 | * PARM is to ARG. The higher the return value, the worse the match. | |
2348 | * Generally the "bad" conversions are all uniformly assigned a 100 */ | |
2349 | ||
2350 | int | |
fba45db2 | 2351 | rank_one_type (struct type *parm, struct type *arg) |
c906108c SS |
2352 | { |
2353 | /* Identical type pointers */ | |
2354 | /* However, this still doesn't catch all cases of same type for arg | |
2355 | * and param. The reason is that builtin types are different from | |
2356 | * the same ones constructed from the object. */ | |
2357 | if (parm == arg) | |
2358 | return 0; | |
2359 | ||
2360 | /* Resolve typedefs */ | |
2361 | if (TYPE_CODE (parm) == TYPE_CODE_TYPEDEF) | |
2362 | parm = check_typedef (parm); | |
2363 | if (TYPE_CODE (arg) == TYPE_CODE_TYPEDEF) | |
2364 | arg = check_typedef (arg); | |
2365 | ||
070ad9f0 DB |
2366 | /* |
2367 | Well, damnit, if the names are exactly the same, | |
2368 | i'll say they are exactly the same. This happens when we generate | |
2369 | method stubs. The types won't point to the same address, but they | |
2370 | really are the same. | |
2371 | */ | |
2372 | ||
6b1ba9a0 ND |
2373 | if (TYPE_NAME (parm) && TYPE_NAME (arg) && |
2374 | !strcmp (TYPE_NAME (parm), TYPE_NAME (arg))) | |
070ad9f0 DB |
2375 | return 0; |
2376 | ||
c906108c SS |
2377 | /* Check if identical after resolving typedefs */ |
2378 | if (parm == arg) | |
2379 | return 0; | |
2380 | ||
db577aea AC |
2381 | /* See through references, since we can almost make non-references |
2382 | references. */ | |
2383 | if (TYPE_CODE (arg) == TYPE_CODE_REF) | |
6b1ba9a0 | 2384 | return (rank_one_type (parm, TYPE_TARGET_TYPE (arg)) |
db577aea AC |
2385 | + REFERENCE_CONVERSION_BADNESS); |
2386 | if (TYPE_CODE (parm) == TYPE_CODE_REF) | |
6b1ba9a0 | 2387 | return (rank_one_type (TYPE_TARGET_TYPE (parm), arg) |
db577aea | 2388 | + REFERENCE_CONVERSION_BADNESS); |
5d161b24 | 2389 | if (overload_debug) |
db577aea | 2390 | /* Debugging only. */ |
5d161b24 DB |
2391 | fprintf_filtered (gdb_stderr,"------ Arg is %s [%d], parm is %s [%d]\n", |
2392 | TYPE_NAME (arg), TYPE_CODE (arg), TYPE_NAME (parm), TYPE_CODE (parm)); | |
c906108c SS |
2393 | |
2394 | /* x -> y means arg of type x being supplied for parameter of type y */ | |
2395 | ||
2396 | switch (TYPE_CODE (parm)) | |
2397 | { | |
c5aa993b JM |
2398 | case TYPE_CODE_PTR: |
2399 | switch (TYPE_CODE (arg)) | |
2400 | { | |
2401 | case TYPE_CODE_PTR: | |
2402 | if (TYPE_CODE (TYPE_TARGET_TYPE (parm)) == TYPE_CODE_VOID) | |
2403 | return VOID_PTR_CONVERSION_BADNESS; | |
2404 | else | |
2405 | return rank_one_type (TYPE_TARGET_TYPE (parm), TYPE_TARGET_TYPE (arg)); | |
2406 | case TYPE_CODE_ARRAY: | |
2407 | return rank_one_type (TYPE_TARGET_TYPE (parm), TYPE_TARGET_TYPE (arg)); | |
2408 | case TYPE_CODE_FUNC: | |
2409 | return rank_one_type (TYPE_TARGET_TYPE (parm), arg); | |
2410 | case TYPE_CODE_INT: | |
2411 | case TYPE_CODE_ENUM: | |
2412 | case TYPE_CODE_CHAR: | |
2413 | case TYPE_CODE_RANGE: | |
2414 | case TYPE_CODE_BOOL: | |
2415 | return POINTER_CONVERSION_BADNESS; | |
2416 | default: | |
2417 | return INCOMPATIBLE_TYPE_BADNESS; | |
2418 | } | |
2419 | case TYPE_CODE_ARRAY: | |
2420 | switch (TYPE_CODE (arg)) | |
2421 | { | |
2422 | case TYPE_CODE_PTR: | |
2423 | case TYPE_CODE_ARRAY: | |
2424 | return rank_one_type (TYPE_TARGET_TYPE (parm), TYPE_TARGET_TYPE (arg)); | |
2425 | default: | |
2426 | return INCOMPATIBLE_TYPE_BADNESS; | |
2427 | } | |
2428 | case TYPE_CODE_FUNC: | |
2429 | switch (TYPE_CODE (arg)) | |
2430 | { | |
2431 | case TYPE_CODE_PTR: /* funcptr -> func */ | |
2432 | return rank_one_type (parm, TYPE_TARGET_TYPE (arg)); | |
2433 | default: | |
2434 | return INCOMPATIBLE_TYPE_BADNESS; | |
2435 | } | |
2436 | case TYPE_CODE_INT: | |
2437 | switch (TYPE_CODE (arg)) | |
2438 | { | |
2439 | case TYPE_CODE_INT: | |
2440 | if (TYPE_LENGTH (arg) == TYPE_LENGTH (parm)) | |
2441 | { | |
2442 | /* Deal with signed, unsigned, and plain chars and | |
7b83ea04 | 2443 | signed and unsigned ints */ |
c5aa993b JM |
2444 | if (TYPE_NOSIGN (parm)) |
2445 | { | |
2446 | /* This case only for character types */ | |
2447 | if (TYPE_NOSIGN (arg)) /* plain char -> plain char */ | |
2448 | return 0; | |
2449 | else | |
1c5cb38e | 2450 | return INTEGER_CONVERSION_BADNESS; /* signed/unsigned char -> plain char */ |
c5aa993b JM |
2451 | } |
2452 | else if (TYPE_UNSIGNED (parm)) | |
2453 | { | |
2454 | if (TYPE_UNSIGNED (arg)) | |
2455 | { | |
973ccf8b DJ |
2456 | /* unsigned int -> unsigned int, or unsigned long -> unsigned long */ |
2457 | if (integer_types_same_name_p (TYPE_NAME (parm), TYPE_NAME (arg))) | |
2458 | return 0; | |
2459 | else if (integer_types_same_name_p (TYPE_NAME (arg), "int") | |
2460 | && integer_types_same_name_p (TYPE_NAME (parm), "long")) | |
c5aa993b JM |
2461 | return INTEGER_PROMOTION_BADNESS; /* unsigned int -> unsigned long */ |
2462 | else | |
1c5cb38e | 2463 | return INTEGER_CONVERSION_BADNESS; /* unsigned long -> unsigned int */ |
c5aa993b JM |
2464 | } |
2465 | else | |
2466 | { | |
973ccf8b DJ |
2467 | if (integer_types_same_name_p (TYPE_NAME (arg), "long") |
2468 | && integer_types_same_name_p (TYPE_NAME (parm), "int")) | |
1c5cb38e | 2469 | return INTEGER_CONVERSION_BADNESS; /* signed long -> unsigned int */ |
c5aa993b JM |
2470 | else |
2471 | return INTEGER_CONVERSION_BADNESS; /* signed int/long -> unsigned int/long */ | |
2472 | } | |
2473 | } | |
2474 | else if (!TYPE_NOSIGN (arg) && !TYPE_UNSIGNED (arg)) | |
2475 | { | |
973ccf8b | 2476 | if (integer_types_same_name_p (TYPE_NAME (parm), TYPE_NAME (arg))) |
c5aa993b | 2477 | return 0; |
973ccf8b DJ |
2478 | else if (integer_types_same_name_p (TYPE_NAME (arg), "int") |
2479 | && integer_types_same_name_p (TYPE_NAME (parm), "long")) | |
c5aa993b JM |
2480 | return INTEGER_PROMOTION_BADNESS; |
2481 | else | |
1c5cb38e | 2482 | return INTEGER_CONVERSION_BADNESS; |
c5aa993b JM |
2483 | } |
2484 | else | |
1c5cb38e | 2485 | return INTEGER_CONVERSION_BADNESS; |
c5aa993b JM |
2486 | } |
2487 | else if (TYPE_LENGTH (arg) < TYPE_LENGTH (parm)) | |
2488 | return INTEGER_PROMOTION_BADNESS; | |
2489 | else | |
1c5cb38e | 2490 | return INTEGER_CONVERSION_BADNESS; |
c5aa993b JM |
2491 | case TYPE_CODE_ENUM: |
2492 | case TYPE_CODE_CHAR: | |
2493 | case TYPE_CODE_RANGE: | |
2494 | case TYPE_CODE_BOOL: | |
2495 | return INTEGER_PROMOTION_BADNESS; | |
2496 | case TYPE_CODE_FLT: | |
2497 | return INT_FLOAT_CONVERSION_BADNESS; | |
2498 | case TYPE_CODE_PTR: | |
2499 | return NS_POINTER_CONVERSION_BADNESS; | |
2500 | default: | |
2501 | return INCOMPATIBLE_TYPE_BADNESS; | |
2502 | } | |
2503 | break; | |
2504 | case TYPE_CODE_ENUM: | |
2505 | switch (TYPE_CODE (arg)) | |
2506 | { | |
2507 | case TYPE_CODE_INT: | |
2508 | case TYPE_CODE_CHAR: | |
2509 | case TYPE_CODE_RANGE: | |
2510 | case TYPE_CODE_BOOL: | |
2511 | case TYPE_CODE_ENUM: | |
1c5cb38e | 2512 | return INTEGER_CONVERSION_BADNESS; |
c5aa993b JM |
2513 | case TYPE_CODE_FLT: |
2514 | return INT_FLOAT_CONVERSION_BADNESS; | |
2515 | default: | |
2516 | return INCOMPATIBLE_TYPE_BADNESS; | |
2517 | } | |
2518 | break; | |
2519 | case TYPE_CODE_CHAR: | |
2520 | switch (TYPE_CODE (arg)) | |
2521 | { | |
2522 | case TYPE_CODE_RANGE: | |
2523 | case TYPE_CODE_BOOL: | |
2524 | case TYPE_CODE_ENUM: | |
1c5cb38e | 2525 | return INTEGER_CONVERSION_BADNESS; |
c5aa993b JM |
2526 | case TYPE_CODE_FLT: |
2527 | return INT_FLOAT_CONVERSION_BADNESS; | |
2528 | case TYPE_CODE_INT: | |
2529 | if (TYPE_LENGTH (arg) > TYPE_LENGTH (parm)) | |
1c5cb38e | 2530 | return INTEGER_CONVERSION_BADNESS; |
c5aa993b JM |
2531 | else if (TYPE_LENGTH (arg) < TYPE_LENGTH (parm)) |
2532 | return INTEGER_PROMOTION_BADNESS; | |
2533 | /* >>> !! else fall through !! <<< */ | |
2534 | case TYPE_CODE_CHAR: | |
2535 | /* Deal with signed, unsigned, and plain chars for C++ | |
2536 | and with int cases falling through from previous case */ | |
2537 | if (TYPE_NOSIGN (parm)) | |
2538 | { | |
2539 | if (TYPE_NOSIGN (arg)) | |
2540 | return 0; | |
2541 | else | |
1c5cb38e | 2542 | return INTEGER_CONVERSION_BADNESS; |
c5aa993b JM |
2543 | } |
2544 | else if (TYPE_UNSIGNED (parm)) | |
2545 | { | |
2546 | if (TYPE_UNSIGNED (arg)) | |
2547 | return 0; | |
2548 | else | |
2549 | return INTEGER_PROMOTION_BADNESS; | |
2550 | } | |
2551 | else if (!TYPE_NOSIGN (arg) && !TYPE_UNSIGNED (arg)) | |
2552 | return 0; | |
2553 | else | |
1c5cb38e | 2554 | return INTEGER_CONVERSION_BADNESS; |
c5aa993b JM |
2555 | default: |
2556 | return INCOMPATIBLE_TYPE_BADNESS; | |
2557 | } | |
2558 | break; | |
2559 | case TYPE_CODE_RANGE: | |
2560 | switch (TYPE_CODE (arg)) | |
2561 | { | |
2562 | case TYPE_CODE_INT: | |
2563 | case TYPE_CODE_CHAR: | |
2564 | case TYPE_CODE_RANGE: | |
2565 | case TYPE_CODE_BOOL: | |
2566 | case TYPE_CODE_ENUM: | |
1c5cb38e | 2567 | return INTEGER_CONVERSION_BADNESS; |
c5aa993b JM |
2568 | case TYPE_CODE_FLT: |
2569 | return INT_FLOAT_CONVERSION_BADNESS; | |
2570 | default: | |
2571 | return INCOMPATIBLE_TYPE_BADNESS; | |
2572 | } | |
2573 | break; | |
2574 | case TYPE_CODE_BOOL: | |
2575 | switch (TYPE_CODE (arg)) | |
2576 | { | |
2577 | case TYPE_CODE_INT: | |
2578 | case TYPE_CODE_CHAR: | |
2579 | case TYPE_CODE_RANGE: | |
2580 | case TYPE_CODE_ENUM: | |
2581 | case TYPE_CODE_FLT: | |
2582 | case TYPE_CODE_PTR: | |
2583 | return BOOLEAN_CONVERSION_BADNESS; | |
2584 | case TYPE_CODE_BOOL: | |
2585 | return 0; | |
2586 | default: | |
2587 | return INCOMPATIBLE_TYPE_BADNESS; | |
2588 | } | |
2589 | break; | |
2590 | case TYPE_CODE_FLT: | |
2591 | switch (TYPE_CODE (arg)) | |
2592 | { | |
2593 | case TYPE_CODE_FLT: | |
2594 | if (TYPE_LENGTH (arg) < TYPE_LENGTH (parm)) | |
2595 | return FLOAT_PROMOTION_BADNESS; | |
2596 | else if (TYPE_LENGTH (arg) == TYPE_LENGTH (parm)) | |
2597 | return 0; | |
2598 | else | |
2599 | return FLOAT_CONVERSION_BADNESS; | |
2600 | case TYPE_CODE_INT: | |
2601 | case TYPE_CODE_BOOL: | |
2602 | case TYPE_CODE_ENUM: | |
2603 | case TYPE_CODE_RANGE: | |
2604 | case TYPE_CODE_CHAR: | |
2605 | return INT_FLOAT_CONVERSION_BADNESS; | |
2606 | default: | |
2607 | return INCOMPATIBLE_TYPE_BADNESS; | |
2608 | } | |
2609 | break; | |
2610 | case TYPE_CODE_COMPLEX: | |
2611 | switch (TYPE_CODE (arg)) | |
2612 | { /* Strictly not needed for C++, but... */ | |
2613 | case TYPE_CODE_FLT: | |
2614 | return FLOAT_PROMOTION_BADNESS; | |
2615 | case TYPE_CODE_COMPLEX: | |
2616 | return 0; | |
2617 | default: | |
2618 | return INCOMPATIBLE_TYPE_BADNESS; | |
2619 | } | |
2620 | break; | |
2621 | case TYPE_CODE_STRUCT: | |
c906108c | 2622 | /* currently same as TYPE_CODE_CLASS */ |
c5aa993b JM |
2623 | switch (TYPE_CODE (arg)) |
2624 | { | |
2625 | case TYPE_CODE_STRUCT: | |
2626 | /* Check for derivation */ | |
2627 | if (is_ancestor (parm, arg)) | |
2628 | return BASE_CONVERSION_BADNESS; | |
2629 | /* else fall through */ | |
2630 | default: | |
2631 | return INCOMPATIBLE_TYPE_BADNESS; | |
2632 | } | |
2633 | break; | |
2634 | case TYPE_CODE_UNION: | |
2635 | switch (TYPE_CODE (arg)) | |
2636 | { | |
2637 | case TYPE_CODE_UNION: | |
2638 | default: | |
2639 | return INCOMPATIBLE_TYPE_BADNESS; | |
2640 | } | |
2641 | break; | |
2642 | case TYPE_CODE_MEMBER: | |
2643 | switch (TYPE_CODE (arg)) | |
2644 | { | |
2645 | default: | |
2646 | return INCOMPATIBLE_TYPE_BADNESS; | |
2647 | } | |
2648 | break; | |
2649 | case TYPE_CODE_METHOD: | |
2650 | switch (TYPE_CODE (arg)) | |
2651 | { | |
2652 | ||
2653 | default: | |
2654 | return INCOMPATIBLE_TYPE_BADNESS; | |
2655 | } | |
2656 | break; | |
2657 | case TYPE_CODE_REF: | |
2658 | switch (TYPE_CODE (arg)) | |
2659 | { | |
2660 | ||
2661 | default: | |
2662 | return INCOMPATIBLE_TYPE_BADNESS; | |
2663 | } | |
2664 | ||
2665 | break; | |
2666 | case TYPE_CODE_SET: | |
2667 | switch (TYPE_CODE (arg)) | |
2668 | { | |
2669 | /* Not in C++ */ | |
2670 | case TYPE_CODE_SET: | |
2671 | return rank_one_type (TYPE_FIELD_TYPE (parm, 0), TYPE_FIELD_TYPE (arg, 0)); | |
2672 | default: | |
2673 | return INCOMPATIBLE_TYPE_BADNESS; | |
2674 | } | |
2675 | break; | |
2676 | case TYPE_CODE_VOID: | |
2677 | default: | |
2678 | return INCOMPATIBLE_TYPE_BADNESS; | |
2679 | } /* switch (TYPE_CODE (arg)) */ | |
c906108c SS |
2680 | } |
2681 | ||
c5aa993b JM |
2682 | |
2683 | /* End of functions for overload resolution */ | |
c906108c | 2684 | |
c906108c | 2685 | static void |
fba45db2 | 2686 | print_bit_vector (B_TYPE *bits, int nbits) |
c906108c SS |
2687 | { |
2688 | int bitno; | |
2689 | ||
2690 | for (bitno = 0; bitno < nbits; bitno++) | |
2691 | { | |
2692 | if ((bitno % 8) == 0) | |
2693 | { | |
2694 | puts_filtered (" "); | |
2695 | } | |
2696 | if (B_TST (bits, bitno)) | |
2697 | { | |
2698 | printf_filtered ("1"); | |
2699 | } | |
2700 | else | |
2701 | { | |
2702 | printf_filtered ("0"); | |
2703 | } | |
2704 | } | |
2705 | } | |
2706 | ||
ad2f7632 DJ |
2707 | /* Note the first arg should be the "this" pointer, we may not want to |
2708 | include it since we may get into a infinitely recursive situation. */ | |
c906108c SS |
2709 | |
2710 | static void | |
ad2f7632 | 2711 | print_arg_types (struct field *args, int nargs, int spaces) |
c906108c SS |
2712 | { |
2713 | if (args != NULL) | |
2714 | { | |
ad2f7632 DJ |
2715 | int i; |
2716 | ||
2717 | for (i = 0; i < nargs; i++) | |
2718 | recursive_dump_type (args[i].type, spaces + 2); | |
c906108c SS |
2719 | } |
2720 | } | |
2721 | ||
2722 | static void | |
fba45db2 | 2723 | dump_fn_fieldlists (struct type *type, int spaces) |
c906108c SS |
2724 | { |
2725 | int method_idx; | |
2726 | int overload_idx; | |
2727 | struct fn_field *f; | |
2728 | ||
2729 | printfi_filtered (spaces, "fn_fieldlists "); | |
d4f3574e | 2730 | gdb_print_host_address (TYPE_FN_FIELDLISTS (type), gdb_stdout); |
c906108c SS |
2731 | printf_filtered ("\n"); |
2732 | for (method_idx = 0; method_idx < TYPE_NFN_FIELDS (type); method_idx++) | |
2733 | { | |
2734 | f = TYPE_FN_FIELDLIST1 (type, method_idx); | |
2735 | printfi_filtered (spaces + 2, "[%d] name '%s' (", | |
2736 | method_idx, | |
2737 | TYPE_FN_FIELDLIST_NAME (type, method_idx)); | |
d4f3574e SS |
2738 | gdb_print_host_address (TYPE_FN_FIELDLIST_NAME (type, method_idx), |
2739 | gdb_stdout); | |
c906108c SS |
2740 | printf_filtered (") length %d\n", |
2741 | TYPE_FN_FIELDLIST_LENGTH (type, method_idx)); | |
2742 | for (overload_idx = 0; | |
2743 | overload_idx < TYPE_FN_FIELDLIST_LENGTH (type, method_idx); | |
2744 | overload_idx++) | |
2745 | { | |
2746 | printfi_filtered (spaces + 4, "[%d] physname '%s' (", | |
2747 | overload_idx, | |
2748 | TYPE_FN_FIELD_PHYSNAME (f, overload_idx)); | |
d4f3574e SS |
2749 | gdb_print_host_address (TYPE_FN_FIELD_PHYSNAME (f, overload_idx), |
2750 | gdb_stdout); | |
c906108c SS |
2751 | printf_filtered (")\n"); |
2752 | printfi_filtered (spaces + 8, "type "); | |
d4f3574e | 2753 | gdb_print_host_address (TYPE_FN_FIELD_TYPE (f, overload_idx), gdb_stdout); |
c906108c SS |
2754 | printf_filtered ("\n"); |
2755 | ||
2756 | recursive_dump_type (TYPE_FN_FIELD_TYPE (f, overload_idx), | |
2757 | spaces + 8 + 2); | |
2758 | ||
2759 | printfi_filtered (spaces + 8, "args "); | |
d4f3574e | 2760 | gdb_print_host_address (TYPE_FN_FIELD_ARGS (f, overload_idx), gdb_stdout); |
c906108c SS |
2761 | printf_filtered ("\n"); |
2762 | ||
ad2f7632 DJ |
2763 | print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), |
2764 | TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (f, overload_idx)), | |
2765 | spaces); | |
c906108c | 2766 | printfi_filtered (spaces + 8, "fcontext "); |
d4f3574e SS |
2767 | gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx), |
2768 | gdb_stdout); | |
c906108c SS |
2769 | printf_filtered ("\n"); |
2770 | ||
2771 | printfi_filtered (spaces + 8, "is_const %d\n", | |
2772 | TYPE_FN_FIELD_CONST (f, overload_idx)); | |
2773 | printfi_filtered (spaces + 8, "is_volatile %d\n", | |
2774 | TYPE_FN_FIELD_VOLATILE (f, overload_idx)); | |
2775 | printfi_filtered (spaces + 8, "is_private %d\n", | |
2776 | TYPE_FN_FIELD_PRIVATE (f, overload_idx)); | |
2777 | printfi_filtered (spaces + 8, "is_protected %d\n", | |
2778 | TYPE_FN_FIELD_PROTECTED (f, overload_idx)); | |
2779 | printfi_filtered (spaces + 8, "is_stub %d\n", | |
2780 | TYPE_FN_FIELD_STUB (f, overload_idx)); | |
2781 | printfi_filtered (spaces + 8, "voffset %u\n", | |
2782 | TYPE_FN_FIELD_VOFFSET (f, overload_idx)); | |
2783 | } | |
2784 | } | |
2785 | } | |
2786 | ||
2787 | static void | |
fba45db2 | 2788 | print_cplus_stuff (struct type *type, int spaces) |
c906108c SS |
2789 | { |
2790 | printfi_filtered (spaces, "n_baseclasses %d\n", | |
2791 | TYPE_N_BASECLASSES (type)); | |
2792 | printfi_filtered (spaces, "nfn_fields %d\n", | |
2793 | TYPE_NFN_FIELDS (type)); | |
2794 | printfi_filtered (spaces, "nfn_fields_total %d\n", | |
2795 | TYPE_NFN_FIELDS_TOTAL (type)); | |
2796 | if (TYPE_N_BASECLASSES (type) > 0) | |
2797 | { | |
2798 | printfi_filtered (spaces, "virtual_field_bits (%d bits at *", | |
2799 | TYPE_N_BASECLASSES (type)); | |
d4f3574e | 2800 | gdb_print_host_address (TYPE_FIELD_VIRTUAL_BITS (type), gdb_stdout); |
c906108c SS |
2801 | printf_filtered (")"); |
2802 | ||
2803 | print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type), | |
2804 | TYPE_N_BASECLASSES (type)); | |
2805 | puts_filtered ("\n"); | |
2806 | } | |
2807 | if (TYPE_NFIELDS (type) > 0) | |
2808 | { | |
2809 | if (TYPE_FIELD_PRIVATE_BITS (type) != NULL) | |
2810 | { | |
2811 | printfi_filtered (spaces, "private_field_bits (%d bits at *", | |
2812 | TYPE_NFIELDS (type)); | |
d4f3574e | 2813 | gdb_print_host_address (TYPE_FIELD_PRIVATE_BITS (type), gdb_stdout); |
c906108c SS |
2814 | printf_filtered (")"); |
2815 | print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type), | |
2816 | TYPE_NFIELDS (type)); | |
2817 | puts_filtered ("\n"); | |
2818 | } | |
2819 | if (TYPE_FIELD_PROTECTED_BITS (type) != NULL) | |
2820 | { | |
2821 | printfi_filtered (spaces, "protected_field_bits (%d bits at *", | |
2822 | TYPE_NFIELDS (type)); | |
d4f3574e | 2823 | gdb_print_host_address (TYPE_FIELD_PROTECTED_BITS (type), gdb_stdout); |
c906108c SS |
2824 | printf_filtered (")"); |
2825 | print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type), | |
2826 | TYPE_NFIELDS (type)); | |
2827 | puts_filtered ("\n"); | |
2828 | } | |
2829 | } | |
2830 | if (TYPE_NFN_FIELDS (type) > 0) | |
2831 | { | |
2832 | dump_fn_fieldlists (type, spaces); | |
2833 | } | |
2834 | } | |
2835 | ||
e9e79dd9 FF |
2836 | static void |
2837 | print_bound_type (int bt) | |
2838 | { | |
2839 | switch (bt) | |
2840 | { | |
2841 | case BOUND_CANNOT_BE_DETERMINED: | |
2842 | printf_filtered ("(BOUND_CANNOT_BE_DETERMINED)"); | |
2843 | break; | |
2844 | case BOUND_BY_REF_ON_STACK: | |
2845 | printf_filtered ("(BOUND_BY_REF_ON_STACK)"); | |
2846 | break; | |
2847 | case BOUND_BY_VALUE_ON_STACK: | |
2848 | printf_filtered ("(BOUND_BY_VALUE_ON_STACK)"); | |
2849 | break; | |
2850 | case BOUND_BY_REF_IN_REG: | |
2851 | printf_filtered ("(BOUND_BY_REF_IN_REG)"); | |
2852 | break; | |
2853 | case BOUND_BY_VALUE_IN_REG: | |
2854 | printf_filtered ("(BOUND_BY_VALUE_IN_REG)"); | |
2855 | break; | |
2856 | case BOUND_SIMPLE: | |
2857 | printf_filtered ("(BOUND_SIMPLE)"); | |
2858 | break; | |
2859 | default: | |
2860 | printf_filtered ("(unknown bound type)"); | |
2861 | break; | |
2862 | } | |
2863 | } | |
2864 | ||
c906108c SS |
2865 | static struct obstack dont_print_type_obstack; |
2866 | ||
2867 | void | |
fba45db2 | 2868 | recursive_dump_type (struct type *type, int spaces) |
c906108c SS |
2869 | { |
2870 | int idx; | |
2871 | ||
2872 | if (spaces == 0) | |
2873 | obstack_begin (&dont_print_type_obstack, 0); | |
2874 | ||
2875 | if (TYPE_NFIELDS (type) > 0 | |
2876 | || (TYPE_CPLUS_SPECIFIC (type) && TYPE_NFN_FIELDS (type) > 0)) | |
2877 | { | |
2878 | struct type **first_dont_print | |
c5aa993b | 2879 | = (struct type **) obstack_base (&dont_print_type_obstack); |
c906108c | 2880 | |
c5aa993b JM |
2881 | int i = (struct type **) obstack_next_free (&dont_print_type_obstack) |
2882 | - first_dont_print; | |
c906108c SS |
2883 | |
2884 | while (--i >= 0) | |
2885 | { | |
2886 | if (type == first_dont_print[i]) | |
2887 | { | |
2888 | printfi_filtered (spaces, "type node "); | |
d4f3574e | 2889 | gdb_print_host_address (type, gdb_stdout); |
c906108c SS |
2890 | printf_filtered (" <same as already seen type>\n"); |
2891 | return; | |
2892 | } | |
2893 | } | |
2894 | ||
2895 | obstack_ptr_grow (&dont_print_type_obstack, type); | |
2896 | } | |
2897 | ||
2898 | printfi_filtered (spaces, "type node "); | |
d4f3574e | 2899 | gdb_print_host_address (type, gdb_stdout); |
c906108c SS |
2900 | printf_filtered ("\n"); |
2901 | printfi_filtered (spaces, "name '%s' (", | |
2902 | TYPE_NAME (type) ? TYPE_NAME (type) : "<NULL>"); | |
d4f3574e | 2903 | gdb_print_host_address (TYPE_NAME (type), gdb_stdout); |
c906108c | 2904 | printf_filtered (")\n"); |
e9e79dd9 FF |
2905 | printfi_filtered (spaces, "tagname '%s' (", |
2906 | TYPE_TAG_NAME (type) ? TYPE_TAG_NAME (type) : "<NULL>"); | |
2907 | gdb_print_host_address (TYPE_TAG_NAME (type), gdb_stdout); | |
2908 | printf_filtered (")\n"); | |
c906108c SS |
2909 | printfi_filtered (spaces, "code 0x%x ", TYPE_CODE (type)); |
2910 | switch (TYPE_CODE (type)) | |
2911 | { | |
c5aa993b JM |
2912 | case TYPE_CODE_UNDEF: |
2913 | printf_filtered ("(TYPE_CODE_UNDEF)"); | |
2914 | break; | |
2915 | case TYPE_CODE_PTR: | |
2916 | printf_filtered ("(TYPE_CODE_PTR)"); | |
2917 | break; | |
2918 | case TYPE_CODE_ARRAY: | |
2919 | printf_filtered ("(TYPE_CODE_ARRAY)"); | |
2920 | break; | |
2921 | case TYPE_CODE_STRUCT: | |
2922 | printf_filtered ("(TYPE_CODE_STRUCT)"); | |
2923 | break; | |
2924 | case TYPE_CODE_UNION: | |
2925 | printf_filtered ("(TYPE_CODE_UNION)"); | |
2926 | break; | |
2927 | case TYPE_CODE_ENUM: | |
2928 | printf_filtered ("(TYPE_CODE_ENUM)"); | |
2929 | break; | |
2930 | case TYPE_CODE_FUNC: | |
2931 | printf_filtered ("(TYPE_CODE_FUNC)"); | |
2932 | break; | |
2933 | case TYPE_CODE_INT: | |
2934 | printf_filtered ("(TYPE_CODE_INT)"); | |
2935 | break; | |
2936 | case TYPE_CODE_FLT: | |
2937 | printf_filtered ("(TYPE_CODE_FLT)"); | |
2938 | break; | |
2939 | case TYPE_CODE_VOID: | |
2940 | printf_filtered ("(TYPE_CODE_VOID)"); | |
2941 | break; | |
2942 | case TYPE_CODE_SET: | |
2943 | printf_filtered ("(TYPE_CODE_SET)"); | |
2944 | break; | |
2945 | case TYPE_CODE_RANGE: | |
2946 | printf_filtered ("(TYPE_CODE_RANGE)"); | |
2947 | break; | |
2948 | case TYPE_CODE_STRING: | |
2949 | printf_filtered ("(TYPE_CODE_STRING)"); | |
2950 | break; | |
e9e79dd9 FF |
2951 | case TYPE_CODE_BITSTRING: |
2952 | printf_filtered ("(TYPE_CODE_BITSTRING)"); | |
2953 | break; | |
c5aa993b JM |
2954 | case TYPE_CODE_ERROR: |
2955 | printf_filtered ("(TYPE_CODE_ERROR)"); | |
2956 | break; | |
2957 | case TYPE_CODE_MEMBER: | |
2958 | printf_filtered ("(TYPE_CODE_MEMBER)"); | |
2959 | break; | |
2960 | case TYPE_CODE_METHOD: | |
2961 | printf_filtered ("(TYPE_CODE_METHOD)"); | |
2962 | break; | |
2963 | case TYPE_CODE_REF: | |
2964 | printf_filtered ("(TYPE_CODE_REF)"); | |
2965 | break; | |
2966 | case TYPE_CODE_CHAR: | |
2967 | printf_filtered ("(TYPE_CODE_CHAR)"); | |
2968 | break; | |
2969 | case TYPE_CODE_BOOL: | |
2970 | printf_filtered ("(TYPE_CODE_BOOL)"); | |
2971 | break; | |
e9e79dd9 FF |
2972 | case TYPE_CODE_COMPLEX: |
2973 | printf_filtered ("(TYPE_CODE_COMPLEX)"); | |
2974 | break; | |
c5aa993b JM |
2975 | case TYPE_CODE_TYPEDEF: |
2976 | printf_filtered ("(TYPE_CODE_TYPEDEF)"); | |
2977 | break; | |
e9e79dd9 FF |
2978 | case TYPE_CODE_TEMPLATE: |
2979 | printf_filtered ("(TYPE_CODE_TEMPLATE)"); | |
2980 | break; | |
2981 | case TYPE_CODE_TEMPLATE_ARG: | |
2982 | printf_filtered ("(TYPE_CODE_TEMPLATE_ARG)"); | |
2983 | break; | |
5c4e30ca DC |
2984 | case TYPE_CODE_NAMESPACE: |
2985 | printf_filtered ("(TYPE_CODE_NAMESPACE)"); | |
2986 | break; | |
c5aa993b JM |
2987 | default: |
2988 | printf_filtered ("(UNKNOWN TYPE CODE)"); | |
2989 | break; | |
c906108c SS |
2990 | } |
2991 | puts_filtered ("\n"); | |
2992 | printfi_filtered (spaces, "length %d\n", TYPE_LENGTH (type)); | |
e9e79dd9 FF |
2993 | printfi_filtered (spaces, "upper_bound_type 0x%x ", |
2994 | TYPE_ARRAY_UPPER_BOUND_TYPE (type)); | |
2995 | print_bound_type (TYPE_ARRAY_UPPER_BOUND_TYPE (type)); | |
2996 | puts_filtered ("\n"); | |
2997 | printfi_filtered (spaces, "lower_bound_type 0x%x ", | |
2998 | TYPE_ARRAY_LOWER_BOUND_TYPE (type)); | |
2999 | print_bound_type (TYPE_ARRAY_LOWER_BOUND_TYPE (type)); | |
3000 | puts_filtered ("\n"); | |
c906108c | 3001 | printfi_filtered (spaces, "objfile "); |
d4f3574e | 3002 | gdb_print_host_address (TYPE_OBJFILE (type), gdb_stdout); |
c906108c SS |
3003 | printf_filtered ("\n"); |
3004 | printfi_filtered (spaces, "target_type "); | |
d4f3574e | 3005 | gdb_print_host_address (TYPE_TARGET_TYPE (type), gdb_stdout); |
c906108c SS |
3006 | printf_filtered ("\n"); |
3007 | if (TYPE_TARGET_TYPE (type) != NULL) | |
3008 | { | |
3009 | recursive_dump_type (TYPE_TARGET_TYPE (type), spaces + 2); | |
3010 | } | |
3011 | printfi_filtered (spaces, "pointer_type "); | |
d4f3574e | 3012 | gdb_print_host_address (TYPE_POINTER_TYPE (type), gdb_stdout); |
c906108c SS |
3013 | printf_filtered ("\n"); |
3014 | printfi_filtered (spaces, "reference_type "); | |
d4f3574e | 3015 | gdb_print_host_address (TYPE_REFERENCE_TYPE (type), gdb_stdout); |
c906108c | 3016 | printf_filtered ("\n"); |
2fdde8f8 DJ |
3017 | printfi_filtered (spaces, "type_chain "); |
3018 | gdb_print_host_address (TYPE_CHAIN (type), gdb_stdout); | |
e9e79dd9 | 3019 | printf_filtered ("\n"); |
2fdde8f8 DJ |
3020 | printfi_filtered (spaces, "instance_flags 0x%x", TYPE_INSTANCE_FLAGS (type)); |
3021 | if (TYPE_CONST (type)) | |
3022 | { | |
3023 | puts_filtered (" TYPE_FLAG_CONST"); | |
3024 | } | |
3025 | if (TYPE_VOLATILE (type)) | |
3026 | { | |
3027 | puts_filtered (" TYPE_FLAG_VOLATILE"); | |
3028 | } | |
3029 | if (TYPE_CODE_SPACE (type)) | |
3030 | { | |
3031 | puts_filtered (" TYPE_FLAG_CODE_SPACE"); | |
3032 | } | |
3033 | if (TYPE_DATA_SPACE (type)) | |
3034 | { | |
3035 | puts_filtered (" TYPE_FLAG_DATA_SPACE"); | |
3036 | } | |
8b2dbe47 KB |
3037 | if (TYPE_ADDRESS_CLASS_1 (type)) |
3038 | { | |
3039 | puts_filtered (" TYPE_FLAG_ADDRESS_CLASS_1"); | |
3040 | } | |
3041 | if (TYPE_ADDRESS_CLASS_2 (type)) | |
3042 | { | |
3043 | puts_filtered (" TYPE_FLAG_ADDRESS_CLASS_2"); | |
3044 | } | |
2fdde8f8 | 3045 | puts_filtered ("\n"); |
c906108c | 3046 | printfi_filtered (spaces, "flags 0x%x", TYPE_FLAGS (type)); |
762a036f | 3047 | if (TYPE_UNSIGNED (type)) |
c906108c SS |
3048 | { |
3049 | puts_filtered (" TYPE_FLAG_UNSIGNED"); | |
3050 | } | |
762a036f FF |
3051 | if (TYPE_NOSIGN (type)) |
3052 | { | |
3053 | puts_filtered (" TYPE_FLAG_NOSIGN"); | |
3054 | } | |
3055 | if (TYPE_STUB (type)) | |
c906108c SS |
3056 | { |
3057 | puts_filtered (" TYPE_FLAG_STUB"); | |
3058 | } | |
762a036f FF |
3059 | if (TYPE_TARGET_STUB (type)) |
3060 | { | |
3061 | puts_filtered (" TYPE_FLAG_TARGET_STUB"); | |
3062 | } | |
3063 | if (TYPE_STATIC (type)) | |
3064 | { | |
3065 | puts_filtered (" TYPE_FLAG_STATIC"); | |
3066 | } | |
762a036f FF |
3067 | if (TYPE_PROTOTYPED (type)) |
3068 | { | |
3069 | puts_filtered (" TYPE_FLAG_PROTOTYPED"); | |
3070 | } | |
3071 | if (TYPE_INCOMPLETE (type)) | |
3072 | { | |
3073 | puts_filtered (" TYPE_FLAG_INCOMPLETE"); | |
3074 | } | |
762a036f FF |
3075 | if (TYPE_VARARGS (type)) |
3076 | { | |
3077 | puts_filtered (" TYPE_FLAG_VARARGS"); | |
3078 | } | |
f5f8a009 EZ |
3079 | /* This is used for things like AltiVec registers on ppc. Gcc emits |
3080 | an attribute for the array type, which tells whether or not we | |
3081 | have a vector, instead of a regular array. */ | |
3082 | if (TYPE_VECTOR (type)) | |
3083 | { | |
3084 | puts_filtered (" TYPE_FLAG_VECTOR"); | |
3085 | } | |
c906108c SS |
3086 | puts_filtered ("\n"); |
3087 | printfi_filtered (spaces, "nfields %d ", TYPE_NFIELDS (type)); | |
d4f3574e | 3088 | gdb_print_host_address (TYPE_FIELDS (type), gdb_stdout); |
c906108c SS |
3089 | puts_filtered ("\n"); |
3090 | for (idx = 0; idx < TYPE_NFIELDS (type); idx++) | |
3091 | { | |
3092 | printfi_filtered (spaces + 2, | |
3093 | "[%d] bitpos %d bitsize %d type ", | |
3094 | idx, TYPE_FIELD_BITPOS (type, idx), | |
3095 | TYPE_FIELD_BITSIZE (type, idx)); | |
d4f3574e | 3096 | gdb_print_host_address (TYPE_FIELD_TYPE (type, idx), gdb_stdout); |
c906108c SS |
3097 | printf_filtered (" name '%s' (", |
3098 | TYPE_FIELD_NAME (type, idx) != NULL | |
3099 | ? TYPE_FIELD_NAME (type, idx) | |
3100 | : "<NULL>"); | |
d4f3574e | 3101 | gdb_print_host_address (TYPE_FIELD_NAME (type, idx), gdb_stdout); |
c906108c SS |
3102 | printf_filtered (")\n"); |
3103 | if (TYPE_FIELD_TYPE (type, idx) != NULL) | |
3104 | { | |
3105 | recursive_dump_type (TYPE_FIELD_TYPE (type, idx), spaces + 4); | |
3106 | } | |
3107 | } | |
3108 | printfi_filtered (spaces, "vptr_basetype "); | |
d4f3574e | 3109 | gdb_print_host_address (TYPE_VPTR_BASETYPE (type), gdb_stdout); |
c906108c SS |
3110 | puts_filtered ("\n"); |
3111 | if (TYPE_VPTR_BASETYPE (type) != NULL) | |
3112 | { | |
3113 | recursive_dump_type (TYPE_VPTR_BASETYPE (type), spaces + 2); | |
3114 | } | |
3115 | printfi_filtered (spaces, "vptr_fieldno %d\n", TYPE_VPTR_FIELDNO (type)); | |
3116 | switch (TYPE_CODE (type)) | |
3117 | { | |
c5aa993b JM |
3118 | case TYPE_CODE_STRUCT: |
3119 | printfi_filtered (spaces, "cplus_stuff "); | |
d4f3574e | 3120 | gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout); |
c5aa993b JM |
3121 | puts_filtered ("\n"); |
3122 | print_cplus_stuff (type, spaces); | |
3123 | break; | |
c906108c | 3124 | |
701c159d AC |
3125 | case TYPE_CODE_FLT: |
3126 | printfi_filtered (spaces, "floatformat "); | |
3127 | if (TYPE_FLOATFORMAT (type) == NULL | |
3128 | || TYPE_FLOATFORMAT (type)->name == NULL) | |
3129 | puts_filtered ("(null)"); | |
3130 | else | |
3131 | puts_filtered (TYPE_FLOATFORMAT (type)->name); | |
3132 | puts_filtered ("\n"); | |
3133 | break; | |
3134 | ||
c5aa993b JM |
3135 | default: |
3136 | /* We have to pick one of the union types to be able print and test | |
7b83ea04 AC |
3137 | the value. Pick cplus_struct_type, even though we know it isn't |
3138 | any particular one. */ | |
c5aa993b | 3139 | printfi_filtered (spaces, "type_specific "); |
d4f3574e | 3140 | gdb_print_host_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout); |
c5aa993b JM |
3141 | if (TYPE_CPLUS_SPECIFIC (type) != NULL) |
3142 | { | |
3143 | printf_filtered (" (unknown data form)"); | |
3144 | } | |
3145 | printf_filtered ("\n"); | |
3146 | break; | |
c906108c SS |
3147 | |
3148 | } | |
3149 | if (spaces == 0) | |
3150 | obstack_free (&dont_print_type_obstack, NULL); | |
3151 | } | |
3152 | ||
a14ed312 | 3153 | static void build_gdbtypes (void); |
c906108c | 3154 | static void |
fba45db2 | 3155 | build_gdbtypes (void) |
c906108c SS |
3156 | { |
3157 | builtin_type_void = | |
3158 | init_type (TYPE_CODE_VOID, 1, | |
3159 | 0, | |
3160 | "void", (struct objfile *) NULL); | |
3161 | builtin_type_char = | |
3162 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
4e409299 JB |
3163 | (TYPE_FLAG_NOSIGN |
3164 | | (TARGET_CHAR_SIGNED ? 0 : TYPE_FLAG_UNSIGNED)), | |
c906108c | 3165 | "char", (struct objfile *) NULL); |
c5aa993b | 3166 | builtin_type_true_char = |
9e0b60a8 JM |
3167 | init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT, |
3168 | 0, | |
3169 | "true character", (struct objfile *) NULL); | |
c906108c SS |
3170 | builtin_type_signed_char = |
3171 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
3172 | 0, | |
3173 | "signed char", (struct objfile *) NULL); | |
3174 | builtin_type_unsigned_char = | |
3175 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
3176 | TYPE_FLAG_UNSIGNED, | |
3177 | "unsigned char", (struct objfile *) NULL); | |
3178 | builtin_type_short = | |
3179 | init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, | |
3180 | 0, | |
3181 | "short", (struct objfile *) NULL); | |
3182 | builtin_type_unsigned_short = | |
3183 | init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, | |
3184 | TYPE_FLAG_UNSIGNED, | |
3185 | "unsigned short", (struct objfile *) NULL); | |
3186 | builtin_type_int = | |
3187 | init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, | |
3188 | 0, | |
3189 | "int", (struct objfile *) NULL); | |
3190 | builtin_type_unsigned_int = | |
3191 | init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, | |
3192 | TYPE_FLAG_UNSIGNED, | |
3193 | "unsigned int", (struct objfile *) NULL); | |
3194 | builtin_type_long = | |
3195 | init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, | |
3196 | 0, | |
3197 | "long", (struct objfile *) NULL); | |
3198 | builtin_type_unsigned_long = | |
3199 | init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, | |
3200 | TYPE_FLAG_UNSIGNED, | |
3201 | "unsigned long", (struct objfile *) NULL); | |
3202 | builtin_type_long_long = | |
3203 | init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, | |
3204 | 0, | |
3205 | "long long", (struct objfile *) NULL); | |
c5aa993b | 3206 | builtin_type_unsigned_long_long = |
c906108c SS |
3207 | init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, |
3208 | TYPE_FLAG_UNSIGNED, | |
3209 | "unsigned long long", (struct objfile *) NULL); | |
3210 | builtin_type_float = | |
3211 | init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT, | |
3212 | 0, | |
3213 | "float", (struct objfile *) NULL); | |
9c9532c9 CV |
3214 | /* [email protected] 2002-02-08: |
3215 | The below lines are disabled since they are doing the wrong | |
3216 | thing for non-multiarch targets. They are setting the correct | |
3217 | type of floats for the target but while on multiarch targets | |
3218 | this is done everytime the architecture changes, it's done on | |
3219 | non-multiarch targets only on startup, leaving the wrong values | |
3220 | in even if the architecture changes (eg. from big-endian to | |
3221 | little-endian). */ | |
3222 | #if 0 | |
701c159d | 3223 | TYPE_FLOATFORMAT (builtin_type_float) = TARGET_FLOAT_FORMAT; |
9c9532c9 | 3224 | #endif |
c906108c SS |
3225 | builtin_type_double = |
3226 | init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, | |
3227 | 0, | |
3228 | "double", (struct objfile *) NULL); | |
9c9532c9 | 3229 | #if 0 |
701c159d | 3230 | TYPE_FLOATFORMAT (builtin_type_double) = TARGET_DOUBLE_FORMAT; |
9c9532c9 | 3231 | #endif |
c906108c SS |
3232 | builtin_type_long_double = |
3233 | init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT, | |
3234 | 0, | |
3235 | "long double", (struct objfile *) NULL); | |
9c9532c9 | 3236 | #if 0 |
701c159d | 3237 | TYPE_FLOATFORMAT (builtin_type_long_double) = TARGET_LONG_DOUBLE_FORMAT; |
9c9532c9 | 3238 | #endif |
c906108c SS |
3239 | builtin_type_complex = |
3240 | init_type (TYPE_CODE_COMPLEX, 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT, | |
3241 | 0, | |
3242 | "complex", (struct objfile *) NULL); | |
3243 | TYPE_TARGET_TYPE (builtin_type_complex) = builtin_type_float; | |
3244 | builtin_type_double_complex = | |
3245 | init_type (TYPE_CODE_COMPLEX, 2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, | |
3246 | 0, | |
3247 | "double complex", (struct objfile *) NULL); | |
3248 | TYPE_TARGET_TYPE (builtin_type_double_complex) = builtin_type_double; | |
3249 | builtin_type_string = | |
3250 | init_type (TYPE_CODE_STRING, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
3251 | 0, | |
3252 | "string", (struct objfile *) NULL); | |
c906108c SS |
3253 | builtin_type_bool = |
3254 | init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
3255 | 0, | |
3256 | "bool", (struct objfile *) NULL); | |
3257 | ||
c5aa993b | 3258 | /* Add user knob for controlling resolution of opaque types */ |
cb1a6d5f | 3259 | deprecated_add_show_from_set |
c5aa993b | 3260 | (add_set_cmd ("opaque-type-resolution", class_support, var_boolean, (char *) &opaque_type_resolution, |
c906108c SS |
3261 | "Set resolution of opaque struct/class/union types (if set before loading symbols).", |
3262 | &setlist), | |
3263 | &showlist); | |
3264 | opaque_type_resolution = 1; | |
3265 | ||
917317f4 JM |
3266 | /* Build SIMD types. */ |
3267 | builtin_type_v4sf | |
3268 | = init_simd_type ("__builtin_v4sf", builtin_type_float, "f", 4); | |
c2d11a7d JM |
3269 | builtin_type_v4si |
3270 | = init_simd_type ("__builtin_v4si", builtin_type_int32, "f", 4); | |
08cf96df EZ |
3271 | builtin_type_v16qi |
3272 | = init_simd_type ("__builtin_v16qi", builtin_type_int8, "f", 16); | |
c2d11a7d JM |
3273 | builtin_type_v8qi |
3274 | = init_simd_type ("__builtin_v8qi", builtin_type_int8, "f", 8); | |
08cf96df EZ |
3275 | builtin_type_v8hi |
3276 | = init_simd_type ("__builtin_v8hi", builtin_type_int16, "f", 8); | |
c2d11a7d JM |
3277 | builtin_type_v4hi |
3278 | = init_simd_type ("__builtin_v4hi", builtin_type_int16, "f", 4); | |
3279 | builtin_type_v2si | |
3280 | = init_simd_type ("__builtin_v2si", builtin_type_int32, "f", 2); | |
c4093a6a | 3281 | |
ac3aafc7 | 3282 | /* 128 bit vectors. */ |
3139facc | 3283 | builtin_type_v2_double = init_vector_type (builtin_type_double, 2); |
ac3aafc7 | 3284 | builtin_type_v4_float = init_vector_type (builtin_type_float, 4); |
3139facc | 3285 | builtin_type_v2_int64 = init_vector_type (builtin_type_int64, 2); |
ac3aafc7 EZ |
3286 | builtin_type_v4_int32 = init_vector_type (builtin_type_int32, 4); |
3287 | builtin_type_v8_int16 = init_vector_type (builtin_type_int16, 8); | |
3288 | builtin_type_v16_int8 = init_vector_type (builtin_type_int8, 16); | |
3289 | /* 64 bit vectors. */ | |
6599f021 | 3290 | builtin_type_v2_float = init_vector_type (builtin_type_float, 2); |
ac3aafc7 EZ |
3291 | builtin_type_v2_int32 = init_vector_type (builtin_type_int32, 2); |
3292 | builtin_type_v4_int16 = init_vector_type (builtin_type_int16, 4); | |
3293 | builtin_type_v8_int8 = init_vector_type (builtin_type_int8, 8); | |
3294 | ||
b063e7a2 AC |
3295 | /* Vector types. */ |
3296 | builtin_type_vec64 = build_builtin_type_vec64 (); | |
3297 | builtin_type_vec64i = build_builtin_type_vec64i (); | |
ac3aafc7 | 3298 | builtin_type_vec128 = build_builtin_type_vec128 (); |
3139facc | 3299 | builtin_type_vec128i = build_builtin_type_vec128i (); |
08cf96df | 3300 | |
c4093a6a | 3301 | /* Pointer/Address types. */ |
ee3a7b7f JB |
3302 | |
3303 | /* NOTE: on some targets, addresses and pointers are not necessarily | |
3304 | the same --- for example, on the D10V, pointers are 16 bits long, | |
3305 | but addresses are 32 bits long. See doc/gdbint.texinfo, | |
3306 | ``Pointers Are Not Always Addresses''. | |
3307 | ||
3308 | The upshot is: | |
3309 | - gdb's `struct type' always describes the target's | |
3310 | representation. | |
3311 | - gdb's `struct value' objects should always hold values in | |
3312 | target form. | |
3313 | - gdb's CORE_ADDR values are addresses in the unified virtual | |
3314 | address space that the assembler and linker work with. Thus, | |
3315 | since target_read_memory takes a CORE_ADDR as an argument, it | |
3316 | can access any memory on the target, even if the processor has | |
3317 | separate code and data address spaces. | |
3318 | ||
3319 | So, for example: | |
3320 | - If v is a value holding a D10V code pointer, its contents are | |
3321 | in target form: a big-endian address left-shifted two bits. | |
3322 | - If p is a D10V pointer type, TYPE_LENGTH (p) == 2, just as | |
3323 | sizeof (void *) == 2 on the target. | |
3324 | ||
3325 | In this context, builtin_type_CORE_ADDR is a bit odd: it's a | |
3326 | target type for a value the target will never see. It's only | |
3327 | used to hold the values of (typeless) linker symbols, which are | |
3328 | indeed in the unified virtual address space. */ | |
090a2205 | 3329 | builtin_type_void_data_ptr = make_pointer_type (builtin_type_void, NULL); |
ee3a7b7f JB |
3330 | builtin_type_void_func_ptr |
3331 | = lookup_pointer_type (lookup_function_type (builtin_type_void)); | |
c4093a6a | 3332 | builtin_type_CORE_ADDR = |
52204a0b | 3333 | init_type (TYPE_CODE_INT, TARGET_ADDR_BIT / 8, |
c4093a6a JM |
3334 | TYPE_FLAG_UNSIGNED, |
3335 | "__CORE_ADDR", (struct objfile *) NULL); | |
3336 | builtin_type_bfd_vma = | |
3337 | init_type (TYPE_CODE_INT, TARGET_BFD_VMA_BIT / 8, | |
3338 | TYPE_FLAG_UNSIGNED, | |
3339 | "__bfd_vma", (struct objfile *) NULL); | |
c906108c SS |
3340 | } |
3341 | ||
000177f0 AC |
3342 | static struct gdbarch_data *gdbtypes_data; |
3343 | ||
3344 | const struct builtin_type * | |
3345 | builtin_type (struct gdbarch *gdbarch) | |
3346 | { | |
3347 | return gdbarch_data (gdbarch, gdbtypes_data); | |
3348 | } | |
3349 | ||
70bd8e24 AC |
3350 | |
3351 | static struct type * | |
3352 | build_flt (int bit, char *name, const struct floatformat *floatformat) | |
3353 | { | |
3354 | struct type *t; | |
3355 | if (bit <= 0 || floatformat == NULL) | |
3356 | { | |
3357 | gdb_assert (builtin_type_error != NULL); | |
3358 | return builtin_type_error; | |
3359 | } | |
3360 | t = init_type (TYPE_CODE_FLT, bit / TARGET_CHAR_BIT, | |
3361 | 0, name, (struct objfile *) NULL); | |
3362 | TYPE_FLOATFORMAT (t) = floatformat; | |
3363 | return t; | |
3364 | } | |
3365 | ||
3366 | static struct type * | |
3367 | build_complex (int bit, char *name, struct type *target_type) | |
3368 | { | |
3369 | struct type *t; | |
3370 | if (bit <= 0 || target_type == builtin_type_error) | |
3371 | { | |
3372 | gdb_assert (builtin_type_error != NULL); | |
3373 | return builtin_type_error; | |
3374 | } | |
3375 | t = init_type (TYPE_CODE_COMPLEX, 2 * bit / TARGET_CHAR_BIT, | |
3376 | 0, name, (struct objfile *) NULL); | |
3377 | TYPE_TARGET_TYPE (t) = target_type; | |
3378 | return t; | |
3379 | } | |
3380 | ||
000177f0 AC |
3381 | static void * |
3382 | gdbtypes_post_init (struct gdbarch *gdbarch) | |
3383 | { | |
3384 | struct builtin_type *builtin_type | |
3385 | = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_type); | |
3386 | ||
3387 | builtin_type->builtin_void = | |
3388 | init_type (TYPE_CODE_VOID, 1, | |
3389 | 0, | |
3390 | "void", (struct objfile *) NULL); | |
3391 | builtin_type->builtin_char = | |
3392 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
3393 | (TYPE_FLAG_NOSIGN | |
3394 | | (TARGET_CHAR_SIGNED ? 0 : TYPE_FLAG_UNSIGNED)), | |
3395 | "char", (struct objfile *) NULL); | |
685419e2 | 3396 | builtin_type->builtin_true_char = |
000177f0 AC |
3397 | init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT, |
3398 | 0, | |
3399 | "true character", (struct objfile *) NULL); | |
3400 | builtin_type->builtin_signed_char = | |
3401 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
3402 | 0, | |
3403 | "signed char", (struct objfile *) NULL); | |
3404 | builtin_type->builtin_unsigned_char = | |
3405 | init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
3406 | TYPE_FLAG_UNSIGNED, | |
3407 | "unsigned char", (struct objfile *) NULL); | |
3408 | builtin_type->builtin_short = | |
3409 | init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, | |
3410 | 0, | |
3411 | "short", (struct objfile *) NULL); | |
3412 | builtin_type->builtin_unsigned_short = | |
3413 | init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, | |
3414 | TYPE_FLAG_UNSIGNED, | |
3415 | "unsigned short", (struct objfile *) NULL); | |
3416 | builtin_type->builtin_int = | |
3417 | init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, | |
3418 | 0, | |
3419 | "int", (struct objfile *) NULL); | |
3420 | builtin_type->builtin_unsigned_int = | |
3421 | init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, | |
3422 | TYPE_FLAG_UNSIGNED, | |
3423 | "unsigned int", (struct objfile *) NULL); | |
3424 | builtin_type->builtin_long = | |
3425 | init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, | |
3426 | 0, | |
3427 | "long", (struct objfile *) NULL); | |
3428 | builtin_type->builtin_unsigned_long = | |
3429 | init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, | |
3430 | TYPE_FLAG_UNSIGNED, | |
3431 | "unsigned long", (struct objfile *) NULL); | |
3432 | builtin_type->builtin_long_long = | |
3433 | init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, | |
3434 | 0, | |
3435 | "long long", (struct objfile *) NULL); | |
3436 | builtin_type->builtin_unsigned_long_long = | |
3437 | init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, | |
3438 | TYPE_FLAG_UNSIGNED, | |
3439 | "unsigned long long", (struct objfile *) NULL); | |
70bd8e24 AC |
3440 | builtin_type->builtin_float |
3441 | = build_flt (gdbarch_float_bit (gdbarch), "float", | |
3442 | gdbarch_float_format (gdbarch)); | |
3443 | builtin_type->builtin_double | |
3444 | = build_flt (gdbarch_double_bit (gdbarch), "double", | |
3445 | gdbarch_double_format (gdbarch)); | |
3446 | builtin_type->builtin_long_double | |
3447 | = build_flt (gdbarch_long_double_bit (gdbarch), "long double", | |
3448 | gdbarch_long_double_format (gdbarch)); | |
3449 | builtin_type->builtin_complex | |
3450 | = build_complex (gdbarch_float_bit (gdbarch), "complex", | |
3451 | builtin_type->builtin_float); | |
3452 | builtin_type->builtin_double_complex | |
3453 | = build_complex (gdbarch_double_bit (gdbarch), "double complex", | |
3454 | builtin_type->builtin_double); | |
000177f0 AC |
3455 | builtin_type->builtin_string = |
3456 | init_type (TYPE_CODE_STRING, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
3457 | 0, | |
3458 | "string", (struct objfile *) NULL); | |
000177f0 AC |
3459 | builtin_type->builtin_bool = |
3460 | init_type (TYPE_CODE_BOOL, TARGET_CHAR_BIT / TARGET_CHAR_BIT, | |
3461 | 0, | |
3462 | "bool", (struct objfile *) NULL); | |
3463 | ||
3464 | /* Pointer/Address types. */ | |
3465 | ||
3466 | /* NOTE: on some targets, addresses and pointers are not necessarily | |
3467 | the same --- for example, on the D10V, pointers are 16 bits long, | |
3468 | but addresses are 32 bits long. See doc/gdbint.texinfo, | |
3469 | ``Pointers Are Not Always Addresses''. | |
3470 | ||
3471 | The upshot is: | |
3472 | - gdb's `struct type' always describes the target's | |
3473 | representation. | |
3474 | - gdb's `struct value' objects should always hold values in | |
3475 | target form. | |
3476 | - gdb's CORE_ADDR values are addresses in the unified virtual | |
3477 | address space that the assembler and linker work with. Thus, | |
3478 | since target_read_memory takes a CORE_ADDR as an argument, it | |
3479 | can access any memory on the target, even if the processor has | |
3480 | separate code and data address spaces. | |
3481 | ||
3482 | So, for example: | |
3483 | - If v is a value holding a D10V code pointer, its contents are | |
3484 | in target form: a big-endian address left-shifted two bits. | |
3485 | - If p is a D10V pointer type, TYPE_LENGTH (p) == 2, just as | |
3486 | sizeof (void *) == 2 on the target. | |
3487 | ||
3488 | In this context, builtin_type->CORE_ADDR is a bit odd: it's a | |
3489 | target type for a value the target will never see. It's only | |
3490 | used to hold the values of (typeless) linker symbols, which are | |
3491 | indeed in the unified virtual address space. */ | |
3492 | builtin_type->builtin_data_ptr | |
3493 | = make_pointer_type (builtin_type->builtin_void, NULL); | |
3494 | builtin_type->builtin_func_ptr | |
3495 | = lookup_pointer_type (lookup_function_type (builtin_type->builtin_void)); | |
3496 | builtin_type->builtin_core_addr = | |
3497 | init_type (TYPE_CODE_INT, TARGET_ADDR_BIT / 8, | |
3498 | TYPE_FLAG_UNSIGNED, | |
3499 | "__CORE_ADDR", (struct objfile *) NULL); | |
3500 | ||
3501 | return builtin_type; | |
3502 | } | |
3503 | ||
a14ed312 | 3504 | extern void _initialize_gdbtypes (void); |
c906108c | 3505 | void |
fba45db2 | 3506 | _initialize_gdbtypes (void) |
c906108c | 3507 | { |
5d161b24 | 3508 | struct cmd_list_element *c; |
7ad6570d AC |
3509 | |
3510 | builtin_type_int0 = | |
3511 | init_type (TYPE_CODE_INT, 0 / 8, | |
3512 | 0, | |
3513 | "int0_t", (struct objfile *) NULL); | |
3514 | builtin_type_int8 = | |
3515 | init_type (TYPE_CODE_INT, 8 / 8, | |
3516 | 0, | |
3517 | "int8_t", (struct objfile *) NULL); | |
3518 | builtin_type_uint8 = | |
3519 | init_type (TYPE_CODE_INT, 8 / 8, | |
3520 | TYPE_FLAG_UNSIGNED, | |
3521 | "uint8_t", (struct objfile *) NULL); | |
3522 | builtin_type_int16 = | |
3523 | init_type (TYPE_CODE_INT, 16 / 8, | |
3524 | 0, | |
3525 | "int16_t", (struct objfile *) NULL); | |
3526 | builtin_type_uint16 = | |
3527 | init_type (TYPE_CODE_INT, 16 / 8, | |
3528 | TYPE_FLAG_UNSIGNED, | |
3529 | "uint16_t", (struct objfile *) NULL); | |
3530 | builtin_type_int32 = | |
3531 | init_type (TYPE_CODE_INT, 32 / 8, | |
3532 | 0, | |
3533 | "int32_t", (struct objfile *) NULL); | |
3534 | builtin_type_uint32 = | |
3535 | init_type (TYPE_CODE_INT, 32 / 8, | |
3536 | TYPE_FLAG_UNSIGNED, | |
3537 | "uint32_t", (struct objfile *) NULL); | |
3538 | builtin_type_int64 = | |
3539 | init_type (TYPE_CODE_INT, 64 / 8, | |
3540 | 0, | |
3541 | "int64_t", (struct objfile *) NULL); | |
3542 | builtin_type_uint64 = | |
3543 | init_type (TYPE_CODE_INT, 64 / 8, | |
3544 | TYPE_FLAG_UNSIGNED, | |
3545 | "uint64_t", (struct objfile *) NULL); | |
3546 | builtin_type_int128 = | |
3547 | init_type (TYPE_CODE_INT, 128 / 8, | |
3548 | 0, | |
3549 | "int128_t", (struct objfile *) NULL); | |
3550 | builtin_type_uint128 = | |
3551 | init_type (TYPE_CODE_INT, 128 / 8, | |
3552 | TYPE_FLAG_UNSIGNED, | |
3553 | "uint128_t", (struct objfile *) NULL); | |
3554 | ||
c906108c | 3555 | build_gdbtypes (); |
0f71a2f6 | 3556 | |
000177f0 AC |
3557 | gdbtypes_data = gdbarch_data_register_post_init (gdbtypes_post_init); |
3558 | ||
0f71a2f6 JM |
3559 | /* FIXME - For the moment, handle types by swapping them in and out. |
3560 | Should be using the per-architecture data-pointer and a large | |
3561 | struct. */ | |
046a4708 AC |
3562 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void); |
3563 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_char); | |
3564 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_short); | |
3565 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_int); | |
3566 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_long); | |
3567 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_long_long); | |
3568 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_signed_char); | |
3569 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_char); | |
3570 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_short); | |
3571 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_int); | |
3572 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_long); | |
3573 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_unsigned_long_long); | |
3574 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_float); | |
3575 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_double); | |
3576 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_long_double); | |
3577 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_complex); | |
3578 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_double_complex); | |
3579 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_string); | |
046a4708 AC |
3580 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4sf); |
3581 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4si); | |
3582 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v16qi); | |
3583 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8qi); | |
3584 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8hi); | |
3585 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4hi); | |
3586 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2si); | |
3587 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_double); | |
3588 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4_float); | |
3589 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_int64); | |
3590 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4_int32); | |
3591 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8_int16); | |
3592 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v16_int8); | |
3593 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_float); | |
3594 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v2_int32); | |
3595 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v8_int8); | |
3596 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_v4_int16); | |
3597 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_vec128); | |
3598 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_vec128i); | |
3599 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void_data_ptr); | |
3600 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_void_func_ptr); | |
3601 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_CORE_ADDR); | |
3602 | DEPRECATED_REGISTER_GDBARCH_SWAP (builtin_type_bfd_vma); | |
3603 | deprecated_register_gdbarch_swap (NULL, 0, build_gdbtypes); | |
5d161b24 | 3604 | |
598f52df AC |
3605 | /* Note: These types do not need to be swapped - they are target |
3606 | neutral. */ | |
3607 | builtin_type_ieee_single_big = | |
3608 | init_type (TYPE_CODE_FLT, floatformat_ieee_single_big.totalsize / 8, | |
3609 | 0, "builtin_type_ieee_single_big", NULL); | |
3610 | TYPE_FLOATFORMAT (builtin_type_ieee_single_big) = &floatformat_ieee_single_big; | |
3611 | builtin_type_ieee_single_little = | |
3612 | init_type (TYPE_CODE_FLT, floatformat_ieee_single_little.totalsize / 8, | |
3613 | 0, "builtin_type_ieee_single_little", NULL); | |
069e84fd | 3614 | TYPE_FLOATFORMAT (builtin_type_ieee_single_little) = &floatformat_ieee_single_little; |
5ef2d0aa AC |
3615 | builtin_type_ieee_single[BFD_ENDIAN_BIG] |
3616 | = build_flt (floatformat_ieee_single_big.totalsize, | |
3617 | "builtin_type_ieee_single_big", | |
3618 | &floatformat_ieee_single_big); | |
3619 | builtin_type_ieee_single[BFD_ENDIAN_LITTLE] | |
3620 | = build_flt (floatformat_ieee_single_little.totalsize, | |
3621 | "builtin_type_ieee_single_little", | |
3622 | &floatformat_ieee_single_little); | |
598f52df AC |
3623 | builtin_type_ieee_double_big = |
3624 | init_type (TYPE_CODE_FLT, floatformat_ieee_double_big.totalsize / 8, | |
3625 | 0, "builtin_type_ieee_double_big", NULL); | |
069e84fd | 3626 | TYPE_FLOATFORMAT (builtin_type_ieee_double_big) = &floatformat_ieee_double_big; |
598f52df AC |
3627 | builtin_type_ieee_double_little = |
3628 | init_type (TYPE_CODE_FLT, floatformat_ieee_double_little.totalsize / 8, | |
3629 | 0, "builtin_type_ieee_double_little", NULL); | |
069e84fd | 3630 | TYPE_FLOATFORMAT (builtin_type_ieee_double_little) = &floatformat_ieee_double_little; |
5ef2d0aa AC |
3631 | builtin_type_ieee_double[BFD_ENDIAN_BIG] |
3632 | = build_flt (floatformat_ieee_double_big.totalsize, | |
3633 | "builtin_type_ieee_double_big", | |
3634 | &floatformat_ieee_double_big); | |
3635 | builtin_type_ieee_double[BFD_ENDIAN_LITTLE] | |
3636 | = build_flt (floatformat_ieee_double_little.totalsize, | |
3637 | "builtin_type_ieee_double_little", | |
3638 | &floatformat_ieee_double_little); | |
598f52df AC |
3639 | builtin_type_ieee_double_littlebyte_bigword = |
3640 | init_type (TYPE_CODE_FLT, floatformat_ieee_double_littlebyte_bigword.totalsize / 8, | |
3641 | 0, "builtin_type_ieee_double_littlebyte_bigword", NULL); | |
069e84fd | 3642 | TYPE_FLOATFORMAT (builtin_type_ieee_double_littlebyte_bigword) = &floatformat_ieee_double_littlebyte_bigword; |
598f52df AC |
3643 | builtin_type_i387_ext = |
3644 | init_type (TYPE_CODE_FLT, floatformat_i387_ext.totalsize / 8, | |
3645 | 0, "builtin_type_i387_ext", NULL); | |
e371b258 | 3646 | TYPE_FLOATFORMAT (builtin_type_i387_ext) = &floatformat_i387_ext; |
598f52df AC |
3647 | builtin_type_m68881_ext = |
3648 | init_type (TYPE_CODE_FLT, floatformat_m68881_ext.totalsize / 8, | |
3649 | 0, "builtin_type_m68881_ext", NULL); | |
069e84fd | 3650 | TYPE_FLOATFORMAT (builtin_type_m68881_ext) = &floatformat_m68881_ext; |
598f52df AC |
3651 | builtin_type_i960_ext = |
3652 | init_type (TYPE_CODE_FLT, floatformat_i960_ext.totalsize / 8, | |
3653 | 0, "builtin_type_i960_ext", NULL); | |
069e84fd | 3654 | TYPE_FLOATFORMAT (builtin_type_i960_ext) = &floatformat_i960_ext; |
598f52df AC |
3655 | builtin_type_m88110_ext = |
3656 | init_type (TYPE_CODE_FLT, floatformat_m88110_ext.totalsize / 8, | |
3657 | 0, "builtin_type_m88110_ext", NULL); | |
069e84fd | 3658 | TYPE_FLOATFORMAT (builtin_type_m88110_ext) = &floatformat_m88110_ext; |
598f52df AC |
3659 | builtin_type_m88110_harris_ext = |
3660 | init_type (TYPE_CODE_FLT, floatformat_m88110_harris_ext.totalsize / 8, | |
3661 | 0, "builtin_type_m88110_harris_ext", NULL); | |
069e84fd | 3662 | TYPE_FLOATFORMAT (builtin_type_m88110_harris_ext) = &floatformat_m88110_harris_ext; |
598f52df AC |
3663 | builtin_type_arm_ext_big = |
3664 | init_type (TYPE_CODE_FLT, floatformat_arm_ext_big.totalsize / 8, | |
3665 | 0, "builtin_type_arm_ext_big", NULL); | |
069e84fd | 3666 | TYPE_FLOATFORMAT (builtin_type_arm_ext_big) = &floatformat_arm_ext_big; |
598f52df AC |
3667 | builtin_type_arm_ext_littlebyte_bigword = |
3668 | init_type (TYPE_CODE_FLT, floatformat_arm_ext_littlebyte_bigword.totalsize / 8, | |
3669 | 0, "builtin_type_arm_ext_littlebyte_bigword", NULL); | |
069e84fd | 3670 | TYPE_FLOATFORMAT (builtin_type_arm_ext_littlebyte_bigword) = &floatformat_arm_ext_littlebyte_bigword; |
5ef2d0aa AC |
3671 | builtin_type_arm_ext[BFD_ENDIAN_BIG] |
3672 | = build_flt (floatformat_arm_ext_big.totalsize, | |
3673 | "builtin_type_arm_ext_big", | |
3674 | &floatformat_arm_ext_big); | |
3675 | builtin_type_arm_ext[BFD_ENDIAN_LITTLE] | |
3676 | = build_flt (floatformat_arm_ext_littlebyte_bigword.totalsize, | |
3677 | "builtin_type_arm_ext_littlebyte_bigword", | |
3678 | &floatformat_arm_ext_littlebyte_bigword); | |
598f52df AC |
3679 | builtin_type_ia64_spill_big = |
3680 | init_type (TYPE_CODE_FLT, floatformat_ia64_spill_big.totalsize / 8, | |
3681 | 0, "builtin_type_ia64_spill_big", NULL); | |
069e84fd | 3682 | TYPE_FLOATFORMAT (builtin_type_ia64_spill_big) = &floatformat_ia64_spill_big; |
598f52df AC |
3683 | builtin_type_ia64_spill_little = |
3684 | init_type (TYPE_CODE_FLT, floatformat_ia64_spill_little.totalsize / 8, | |
3685 | 0, "builtin_type_ia64_spill_little", NULL); | |
069e84fd | 3686 | TYPE_FLOATFORMAT (builtin_type_ia64_spill_little) = &floatformat_ia64_spill_little; |
5ef2d0aa AC |
3687 | builtin_type_ia64_spill[BFD_ENDIAN_BIG] |
3688 | = build_flt (floatformat_ia64_spill_big.totalsize, | |
3689 | "builtin_type_ia64_spill_big", | |
3690 | &floatformat_ia64_spill_big); | |
3691 | builtin_type_ia64_spill[BFD_ENDIAN_LITTLE] | |
3692 | = build_flt (floatformat_ia64_spill_little.totalsize, | |
3693 | "builtin_type_ia64_spill_little", | |
3694 | &floatformat_ia64_spill_little); | |
598f52df AC |
3695 | builtin_type_ia64_quad_big = |
3696 | init_type (TYPE_CODE_FLT, floatformat_ia64_quad_big.totalsize / 8, | |
3697 | 0, "builtin_type_ia64_quad_big", NULL); | |
069e84fd | 3698 | TYPE_FLOATFORMAT (builtin_type_ia64_quad_big) = &floatformat_ia64_quad_big; |
598f52df AC |
3699 | builtin_type_ia64_quad_little = |
3700 | init_type (TYPE_CODE_FLT, floatformat_ia64_quad_little.totalsize / 8, | |
3701 | 0, "builtin_type_ia64_quad_little", NULL); | |
069e84fd | 3702 | TYPE_FLOATFORMAT (builtin_type_ia64_quad_little) = &floatformat_ia64_quad_little; |
5ef2d0aa AC |
3703 | builtin_type_ia64_quad[BFD_ENDIAN_BIG] |
3704 | = build_flt (floatformat_ia64_quad_big.totalsize, | |
3705 | "builtin_type_ia64_quad_big", | |
3706 | &floatformat_ia64_quad_big); | |
3707 | builtin_type_ia64_quad[BFD_ENDIAN_LITTLE] | |
3708 | = build_flt (floatformat_ia64_quad_little.totalsize, | |
3709 | "builtin_type_ia64_quad_little", | |
3710 | &floatformat_ia64_quad_little); | |
598f52df | 3711 | |
cb1a6d5f AC |
3712 | deprecated_add_show_from_set |
3713 | (add_set_cmd ("overload", no_class, var_zinteger, (char *) &overload_debug, | |
3714 | "Set debugging of C++ overloading.\n\ | |
3715 | When enabled, ranking of the functions is displayed.", &setdebuglist), | |
3716 | &showdebuglist); | |
c906108c | 3717 | } |