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