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