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