* ser-unix.c (wait_for): Do not reset timeout_remaining for cygwin32 so
[deliverable/binutils-gdb.git] / gdb / gdbtypes.c
1 /* Support routines for manipulating internal types for GDB.
2 Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
3 Contributed by Cygnus Support, using pieces from other GDB modules.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21 #include "defs.h"
22 #include "gdb_string.h"
23 #include "bfd.h"
24 #include "symtab.h"
25 #include "symfile.h"
26 #include "objfiles.h"
27 #include "gdbtypes.h"
28 #include "expression.h"
29 #include "language.h"
30 #include "target.h"
31 #include "value.h"
32 #include "demangle.h"
33 #include "complaints.h"
34
35 /* These variables point to the objects
36 representing the predefined C data types. */
37
38 struct type *builtin_type_void;
39 struct type *builtin_type_char;
40 struct type *builtin_type_short;
41 struct type *builtin_type_int;
42 struct type *builtin_type_long;
43 struct type *builtin_type_long_long;
44 struct type *builtin_type_signed_char;
45 struct type *builtin_type_unsigned_char;
46 struct type *builtin_type_unsigned_short;
47 struct type *builtin_type_unsigned_int;
48 struct type *builtin_type_unsigned_long;
49 struct type *builtin_type_unsigned_long_long;
50 struct type *builtin_type_float;
51 struct type *builtin_type_double;
52 struct type *builtin_type_long_double;
53 struct type *builtin_type_complex;
54 struct type *builtin_type_double_complex;
55 struct type *builtin_type_string;
56 struct type *builtin_type_int8;
57 struct type *builtin_type_uint8;
58 struct type *builtin_type_int16;
59 struct type *builtin_type_uint16;
60 struct type *builtin_type_int32;
61 struct type *builtin_type_uint32;
62 struct type *builtin_type_int64;
63 struct type *builtin_type_uint64;
64 /* start-sanitize-r5900 */
65 struct type *builtin_type_int128;
66 struct type *builtin_type_uint128;
67 /* end-sanitize-r5900 */
68
69 struct extra { char str[128]; int len; }; /* maximum extention is 128! FIXME */
70
71 static void add_name PARAMS ((struct extra *, char *));
72 static void add_mangled_type PARAMS ((struct extra *, struct type *));
73 #if 0
74 static void cfront_mangle_name PARAMS ((struct type *, int, int));
75 #endif
76 static void print_bit_vector PARAMS ((B_TYPE *, int));
77 static void print_arg_types PARAMS ((struct type **, int));
78 static void dump_fn_fieldlists PARAMS ((struct type *, int));
79 static void print_cplus_stuff PARAMS ((struct type *, int));
80
81 /* Alloc a new type structure and fill it with some defaults. If
82 OBJFILE is non-NULL, then allocate the space for the type structure
83 in that objfile's type_obstack. */
84
85 struct type *
86 alloc_type (objfile)
87 struct objfile *objfile;
88 {
89 register struct type *type;
90
91 /* Alloc the structure and start off with all fields zeroed. */
92
93 if (objfile == NULL)
94 {
95 type = (struct type *) xmalloc (sizeof (struct type));
96 }
97 else
98 {
99 type = (struct type *) obstack_alloc (&objfile -> type_obstack,
100 sizeof (struct type));
101 OBJSTAT (objfile, n_types++);
102 }
103 memset ((char *) type, 0, sizeof (struct type));
104
105 /* Initialize the fields that might not be zero. */
106
107 TYPE_CODE (type) = TYPE_CODE_UNDEF;
108 TYPE_OBJFILE (type) = objfile;
109 TYPE_VPTR_FIELDNO (type) = -1;
110
111 return (type);
112 }
113
114 /* Lookup a pointer to a type TYPE. TYPEPTR, if nonzero, points
115 to a pointer to memory where the pointer type should be stored.
116 If *TYPEPTR is zero, update it to point to the pointer type we return.
117 We allocate new memory if needed. */
118
119 struct type *
120 make_pointer_type (type, typeptr)
121 struct type *type;
122 struct type **typeptr;
123 {
124 register struct type *ntype; /* New type */
125 struct objfile *objfile;
126
127 ntype = TYPE_POINTER_TYPE (type);
128
129 if (ntype)
130 if (typeptr == 0)
131 return ntype; /* Don't care about alloc, and have new type. */
132 else if (*typeptr == 0)
133 {
134 *typeptr = ntype; /* Tracking alloc, and we have new type. */
135 return ntype;
136 }
137
138 if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
139 {
140 ntype = alloc_type (TYPE_OBJFILE (type));
141 if (typeptr)
142 *typeptr = ntype;
143 }
144 else /* We have storage, but need to reset it. */
145 {
146 ntype = *typeptr;
147 objfile = TYPE_OBJFILE (ntype);
148 memset ((char *) ntype, 0, sizeof (struct type));
149 TYPE_OBJFILE (ntype) = objfile;
150 }
151
152 TYPE_TARGET_TYPE (ntype) = type;
153 TYPE_POINTER_TYPE (type) = ntype;
154
155 /* FIXME! Assume the machine has only one representation for pointers! */
156
157 TYPE_LENGTH (ntype) = TARGET_PTR_BIT / TARGET_CHAR_BIT;
158 TYPE_CODE (ntype) = TYPE_CODE_PTR;
159
160 /* pointers are unsigned */
161 TYPE_FLAGS (ntype) |= TYPE_FLAG_UNSIGNED;
162
163 if (!TYPE_POINTER_TYPE (type)) /* Remember it, if don't have one. */
164 TYPE_POINTER_TYPE (type) = ntype;
165
166 return ntype;
167 }
168
169 /* Given a type TYPE, return a type of pointers to that type.
170 May need to construct such a type if this is the first use. */
171
172 struct type *
173 lookup_pointer_type (type)
174 struct type *type;
175 {
176 return make_pointer_type (type, (struct type **)0);
177 }
178
179 /* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, points
180 to a pointer to memory where the reference type should be stored.
181 If *TYPEPTR is zero, update it to point to the reference type we return.
182 We allocate new memory if needed. */
183
184 struct type *
185 make_reference_type (type, typeptr)
186 struct type *type;
187 struct type **typeptr;
188 {
189 register struct type *ntype; /* New type */
190 struct objfile *objfile;
191
192 ntype = TYPE_REFERENCE_TYPE (type);
193
194 if (ntype)
195 if (typeptr == 0)
196 return ntype; /* Don't care about alloc, and have new type. */
197 else if (*typeptr == 0)
198 {
199 *typeptr = ntype; /* Tracking alloc, and we have new type. */
200 return ntype;
201 }
202
203 if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
204 {
205 ntype = alloc_type (TYPE_OBJFILE (type));
206 if (typeptr)
207 *typeptr = ntype;
208 }
209 else /* We have storage, but need to reset it. */
210 {
211 ntype = *typeptr;
212 objfile = TYPE_OBJFILE (ntype);
213 memset ((char *) ntype, 0, sizeof (struct type));
214 TYPE_OBJFILE (ntype) = objfile;
215 }
216
217 TYPE_TARGET_TYPE (ntype) = type;
218 TYPE_REFERENCE_TYPE (type) = ntype;
219
220 /* FIXME! Assume the machine has only one representation for references,
221 and that it matches the (only) representation for pointers! */
222
223 TYPE_LENGTH (ntype) = TARGET_PTR_BIT / TARGET_CHAR_BIT;
224 TYPE_CODE (ntype) = TYPE_CODE_REF;
225
226 if (!TYPE_REFERENCE_TYPE (type)) /* Remember it, if don't have one. */
227 TYPE_REFERENCE_TYPE (type) = ntype;
228
229 return ntype;
230 }
231
232 /* Same as above, but caller doesn't care about memory allocation details. */
233
234 struct type *
235 lookup_reference_type (type)
236 struct type *type;
237 {
238 return make_reference_type (type, (struct type **)0);
239 }
240
241 /* Lookup a function type that returns type TYPE. TYPEPTR, if nonzero, points
242 to a pointer to memory where the function type should be stored.
243 If *TYPEPTR is zero, update it to point to the function type we return.
244 We allocate new memory if needed. */
245
246 struct type *
247 make_function_type (type, typeptr)
248 struct type *type;
249 struct type **typeptr;
250 {
251 register struct type *ntype; /* New type */
252 struct objfile *objfile;
253
254 if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */
255 {
256 ntype = alloc_type (TYPE_OBJFILE (type));
257 if (typeptr)
258 *typeptr = ntype;
259 }
260 else /* We have storage, but need to reset it. */
261 {
262 ntype = *typeptr;
263 objfile = TYPE_OBJFILE (ntype);
264 memset ((char *) ntype, 0, sizeof (struct type));
265 TYPE_OBJFILE (ntype) = objfile;
266 }
267
268 TYPE_TARGET_TYPE (ntype) = type;
269
270 TYPE_LENGTH (ntype) = 1;
271 TYPE_CODE (ntype) = TYPE_CODE_FUNC;
272
273 return ntype;
274 }
275
276
277 /* Given a type TYPE, return a type of functions that return that type.
278 May need to construct such a type if this is the first use. */
279
280 struct type *
281 lookup_function_type (type)
282 struct type *type;
283 {
284 return make_function_type (type, (struct type **)0);
285 }
286
287 /* Implement direct support for MEMBER_TYPE in GNU C++.
288 May need to construct such a type if this is the first use.
289 The TYPE is the type of the member. The DOMAIN is the type
290 of the aggregate that the member belongs to. */
291
292 struct type *
293 lookup_member_type (type, domain)
294 struct type *type;
295 struct type *domain;
296 {
297 register struct type *mtype;
298
299 mtype = alloc_type (TYPE_OBJFILE (type));
300 smash_to_member_type (mtype, domain, type);
301 return (mtype);
302 }
303
304 /* Allocate a stub method whose return type is TYPE.
305 This apparently happens for speed of symbol reading, since parsing
306 out the arguments to the method is cpu-intensive, the way we are doing
307 it. So, we will fill in arguments later.
308 This always returns a fresh type. */
309
310 struct type *
311 allocate_stub_method (type)
312 struct type *type;
313 {
314 struct type *mtype;
315
316 mtype = alloc_type (TYPE_OBJFILE (type));
317 TYPE_TARGET_TYPE (mtype) = type;
318 /* _DOMAIN_TYPE (mtype) = unknown yet */
319 /* _ARG_TYPES (mtype) = unknown yet */
320 TYPE_FLAGS (mtype) = TYPE_FLAG_STUB;
321 TYPE_CODE (mtype) = TYPE_CODE_METHOD;
322 TYPE_LENGTH (mtype) = 1;
323 return (mtype);
324 }
325
326 /* Create a range type using either a blank type supplied in RESULT_TYPE,
327 or creating a new type, inheriting the objfile from INDEX_TYPE.
328
329 Indices will be of type INDEX_TYPE, and will range from LOW_BOUND to
330 HIGH_BOUND, inclusive.
331
332 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
333 sure it is TYPE_CODE_UNDEF before we bash it into a range type? */
334
335 struct type *
336 create_range_type (result_type, index_type, low_bound, high_bound)
337 struct type *result_type;
338 struct type *index_type;
339 int low_bound;
340 int high_bound;
341 {
342 if (result_type == NULL)
343 {
344 result_type = alloc_type (TYPE_OBJFILE (index_type));
345 }
346 TYPE_CODE (result_type) = TYPE_CODE_RANGE;
347 TYPE_TARGET_TYPE (result_type) = index_type;
348 if (TYPE_FLAGS (index_type) & TYPE_FLAG_STUB)
349 TYPE_FLAGS (result_type) |= TYPE_FLAG_TARGET_STUB;
350 else
351 TYPE_LENGTH (result_type) = TYPE_LENGTH (check_typedef (index_type));
352 TYPE_NFIELDS (result_type) = 2;
353 TYPE_FIELDS (result_type) = (struct field *)
354 TYPE_ALLOC (result_type, 2 * sizeof (struct field));
355 memset (TYPE_FIELDS (result_type), 0, 2 * sizeof (struct field));
356 TYPE_FIELD_BITPOS (result_type, 0) = low_bound;
357 TYPE_FIELD_BITPOS (result_type, 1) = high_bound;
358 TYPE_FIELD_TYPE (result_type, 0) = builtin_type_int; /* FIXME */
359 TYPE_FIELD_TYPE (result_type, 1) = builtin_type_int; /* FIXME */
360
361 if(low_bound >= 0)
362 TYPE_FLAGS (result_type) |= TYPE_FLAG_UNSIGNED;
363
364 return (result_type);
365 }
366
367 /* Set *LOWP and *HIGHP to the lower and upper bounds of discrete type TYPE.
368 Return 1 of type is a range type, 0 if it is discrete (and bounds
369 will fit in LONGEST), or -1 otherwise. */
370
371 int
372 get_discrete_bounds (type, lowp, highp)
373 struct type *type;
374 LONGEST *lowp, *highp;
375 {
376 CHECK_TYPEDEF (type);
377 switch (TYPE_CODE (type))
378 {
379 case TYPE_CODE_RANGE:
380 *lowp = TYPE_LOW_BOUND (type);
381 *highp = TYPE_HIGH_BOUND (type);
382 return 1;
383 case TYPE_CODE_ENUM:
384 if (TYPE_NFIELDS (type) > 0)
385 {
386 /* The enums may not be sorted by value, so search all
387 entries */
388 int i;
389
390 *lowp = *highp = TYPE_FIELD_BITPOS (type, 0);
391 for (i = 0; i < TYPE_NFIELDS (type); i++)
392 {
393 if (TYPE_FIELD_BITPOS (type, i) < *lowp)
394 *lowp = TYPE_FIELD_BITPOS (type, i);
395 if (TYPE_FIELD_BITPOS (type, i) > *highp)
396 *highp = TYPE_FIELD_BITPOS (type, i);
397 }
398 }
399 else
400 {
401 *lowp = 0;
402 *highp = -1;
403 }
404 return 0;
405 case TYPE_CODE_BOOL:
406 *lowp = 0;
407 *highp = 1;
408 return 0;
409 case TYPE_CODE_INT:
410 if (TYPE_LENGTH (type) > sizeof (LONGEST)) /* Too big */
411 return -1;
412 if (!TYPE_UNSIGNED (type))
413 {
414 *lowp = - (1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1));
415 *highp = -*lowp - 1;
416 return 0;
417 }
418 /* ... fall through for unsigned ints ... */
419 case TYPE_CODE_CHAR:
420 *lowp = 0;
421 /* This round-about calculation is to avoid shifting by
422 TYPE_LENGTH (type) * TARGET_CHAR_BIT, which will not work
423 if TYPE_LENGTH (type) == sizeof (LONGEST). */
424 *highp = 1 << (TYPE_LENGTH (type) * TARGET_CHAR_BIT - 1);
425 *highp = (*highp - 1) | *highp;
426 return 0;
427 default:
428 return -1;
429 }
430 }
431
432 /* Create an array type using either a blank type supplied in RESULT_TYPE,
433 or creating a new type, inheriting the objfile from RANGE_TYPE.
434
435 Elements will be of type ELEMENT_TYPE, the indices will be of type
436 RANGE_TYPE.
437
438 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
439 sure it is TYPE_CODE_UNDEF before we bash it into an array type? */
440
441 struct type *
442 create_array_type (result_type, element_type, range_type)
443 struct type *result_type;
444 struct type *element_type;
445 struct type *range_type;
446 {
447 LONGEST low_bound, high_bound;
448
449 if (result_type == NULL)
450 {
451 result_type = alloc_type (TYPE_OBJFILE (range_type));
452 }
453 TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
454 TYPE_TARGET_TYPE (result_type) = element_type;
455 if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0)
456 low_bound = high_bound = 0;
457 CHECK_TYPEDEF (element_type);
458 TYPE_LENGTH (result_type) =
459 TYPE_LENGTH (element_type) * (high_bound - low_bound + 1);
460 TYPE_NFIELDS (result_type) = 1;
461 TYPE_FIELDS (result_type) =
462 (struct field *) TYPE_ALLOC (result_type, sizeof (struct field));
463 memset (TYPE_FIELDS (result_type), 0, sizeof (struct field));
464 TYPE_FIELD_TYPE (result_type, 0) = range_type;
465 TYPE_VPTR_FIELDNO (result_type) = -1;
466
467 /* TYPE_FLAG_TARGET_STUB will take care of zero length arrays */
468 if (TYPE_LENGTH (result_type) == 0)
469 TYPE_FLAGS (result_type) |= TYPE_FLAG_TARGET_STUB;
470
471 return (result_type);
472 }
473
474 /* Create a string type using either a blank type supplied in RESULT_TYPE,
475 or creating a new type. String types are similar enough to array of
476 char types that we can use create_array_type to build the basic type
477 and then bash it into a string type.
478
479 For fixed length strings, the range type contains 0 as the lower
480 bound and the length of the string minus one as the upper bound.
481
482 FIXME: Maybe we should check the TYPE_CODE of RESULT_TYPE to make
483 sure it is TYPE_CODE_UNDEF before we bash it into a string type? */
484
485 struct type *
486 create_string_type (result_type, range_type)
487 struct type *result_type;
488 struct type *range_type;
489 {
490 result_type = create_array_type (result_type,
491 *current_language->string_char_type,
492 range_type);
493 TYPE_CODE (result_type) = TYPE_CODE_STRING;
494 return (result_type);
495 }
496
497 struct type *
498 create_set_type (result_type, domain_type)
499 struct type *result_type;
500 struct type *domain_type;
501 {
502 LONGEST low_bound, high_bound, bit_length;
503 if (result_type == NULL)
504 {
505 result_type = alloc_type (TYPE_OBJFILE (domain_type));
506 }
507 TYPE_CODE (result_type) = TYPE_CODE_SET;
508 TYPE_NFIELDS (result_type) = 1;
509 TYPE_FIELDS (result_type) = (struct field *)
510 TYPE_ALLOC (result_type, 1 * sizeof (struct field));
511 memset (TYPE_FIELDS (result_type), 0, sizeof (struct field));
512
513 if (! (TYPE_FLAGS (domain_type) & TYPE_FLAG_STUB))
514 {
515 if (get_discrete_bounds (domain_type, &low_bound, &high_bound) < 0)
516 low_bound = high_bound = 0;
517 bit_length = high_bound - low_bound + 1;
518 TYPE_LENGTH (result_type)
519 = (bit_length + TARGET_CHAR_BIT - 1) / TARGET_CHAR_BIT;
520 }
521 TYPE_FIELD_TYPE (result_type, 0) = domain_type;
522 return (result_type);
523 }
524
525 /* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE.
526 A MEMBER is a wierd thing -- it amounts to a typed offset into
527 a struct, e.g. "an int at offset 8". A MEMBER TYPE doesn't
528 include the offset (that's the value of the MEMBER itself), but does
529 include the structure type into which it points (for some reason).
530
531 When "smashing" the type, we preserve the objfile that the
532 old type pointed to, since we aren't changing where the type is actually
533 allocated. */
534
535 void
536 smash_to_member_type (type, domain, to_type)
537 struct type *type;
538 struct type *domain;
539 struct type *to_type;
540 {
541 struct objfile *objfile;
542
543 objfile = TYPE_OBJFILE (type);
544
545 memset ((char *) type, 0, sizeof (struct type));
546 TYPE_OBJFILE (type) = objfile;
547 TYPE_TARGET_TYPE (type) = to_type;
548 TYPE_DOMAIN_TYPE (type) = domain;
549 TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */
550 TYPE_CODE (type) = TYPE_CODE_MEMBER;
551 }
552
553 /* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE.
554 METHOD just means `function that gets an extra "this" argument'.
555
556 When "smashing" the type, we preserve the objfile that the
557 old type pointed to, since we aren't changing where the type is actually
558 allocated. */
559
560 void
561 smash_to_method_type (type, domain, to_type, args)
562 struct type *type;
563 struct type *domain;
564 struct type *to_type;
565 struct type **args;
566 {
567 struct objfile *objfile;
568
569 objfile = TYPE_OBJFILE (type);
570
571 memset ((char *) type, 0, sizeof (struct type));
572 TYPE_OBJFILE (type) = objfile;
573 TYPE_TARGET_TYPE (type) = to_type;
574 TYPE_DOMAIN_TYPE (type) = domain;
575 TYPE_ARG_TYPES (type) = args;
576 TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */
577 TYPE_CODE (type) = TYPE_CODE_METHOD;
578 }
579
580 /* Return a typename for a struct/union/enum type without "struct ",
581 "union ", or "enum ". If the type has a NULL name, return NULL. */
582
583 char *
584 type_name_no_tag (type)
585 register const struct type *type;
586 {
587 if (TYPE_TAG_NAME (type) != NULL)
588 return TYPE_TAG_NAME (type);
589
590 /* Is there code which expects this to return the name if there is no
591 tag name? My guess is that this is mainly used for C++ in cases where
592 the two will always be the same. */
593 return TYPE_NAME (type);
594 }
595
596 /* Lookup a primitive type named NAME.
597 Return zero if NAME is not a primitive type.*/
598
599 struct type *
600 lookup_primitive_typename (name)
601 char *name;
602 {
603 struct type ** const *p;
604
605 for (p = current_language -> la_builtin_type_vector; *p != NULL; p++)
606 {
607 if (STREQ ((**p) -> name, name))
608 {
609 return (**p);
610 }
611 }
612 return (NULL);
613 }
614
615 /* Lookup a typedef or primitive type named NAME,
616 visible in lexical block BLOCK.
617 If NOERR is nonzero, return zero if NAME is not suitably defined. */
618
619 struct type *
620 lookup_typename (name, block, noerr)
621 char *name;
622 struct block *block;
623 int noerr;
624 {
625 register struct symbol *sym;
626 register struct type *tmp;
627
628 sym = lookup_symbol (name, block, VAR_NAMESPACE, 0, (struct symtab **) NULL);
629 if (sym == NULL || SYMBOL_CLASS (sym) != LOC_TYPEDEF)
630 {
631 tmp = lookup_primitive_typename (name);
632 if (tmp)
633 {
634 return (tmp);
635 }
636 else if (!tmp && noerr)
637 {
638 return (NULL);
639 }
640 else
641 {
642 error ("No type named %s.", name);
643 }
644 }
645 return (SYMBOL_TYPE (sym));
646 }
647
648 struct type *
649 lookup_unsigned_typename (name)
650 char *name;
651 {
652 char *uns = alloca (strlen (name) + 10);
653
654 strcpy (uns, "unsigned ");
655 strcpy (uns + 9, name);
656 return (lookup_typename (uns, (struct block *) NULL, 0));
657 }
658
659 struct type *
660 lookup_signed_typename (name)
661 char *name;
662 {
663 struct type *t;
664 char *uns = alloca (strlen (name) + 8);
665
666 strcpy (uns, "signed ");
667 strcpy (uns + 7, name);
668 t = lookup_typename (uns, (struct block *) NULL, 1);
669 /* If we don't find "signed FOO" just try again with plain "FOO". */
670 if (t != NULL)
671 return t;
672 return lookup_typename (name, (struct block *) NULL, 0);
673 }
674
675 /* Lookup a structure type named "struct NAME",
676 visible in lexical block BLOCK. */
677
678 struct type *
679 lookup_struct (name, block)
680 char *name;
681 struct block *block;
682 {
683 register struct symbol *sym;
684
685 sym = lookup_symbol (name, block, STRUCT_NAMESPACE, 0,
686 (struct symtab **) NULL);
687
688 if (sym == NULL)
689 {
690 error ("No struct type named %s.", name);
691 }
692 if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT)
693 {
694 error ("This context has class, union or enum %s, not a struct.", name);
695 }
696 return (SYMBOL_TYPE (sym));
697 }
698
699 /* Lookup a union type named "union NAME",
700 visible in lexical block BLOCK. */
701
702 struct type *
703 lookup_union (name, block)
704 char *name;
705 struct block *block;
706 {
707 register struct symbol *sym;
708
709 sym = lookup_symbol (name, block, STRUCT_NAMESPACE, 0,
710 (struct symtab **) NULL);
711
712 if (sym == NULL)
713 {
714 error ("No union type named %s.", name);
715 }
716 if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_UNION)
717 {
718 error ("This context has class, struct or enum %s, not a union.", name);
719 }
720 return (SYMBOL_TYPE (sym));
721 }
722
723 /* Lookup an enum type named "enum NAME",
724 visible in lexical block BLOCK. */
725
726 struct type *
727 lookup_enum (name, block)
728 char *name;
729 struct block *block;
730 {
731 register struct symbol *sym;
732
733 sym = lookup_symbol (name, block, STRUCT_NAMESPACE, 0,
734 (struct symtab **) NULL);
735 if (sym == NULL)
736 {
737 error ("No enum type named %s.", name);
738 }
739 if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_ENUM)
740 {
741 error ("This context has class, struct or union %s, not an enum.", name);
742 }
743 return (SYMBOL_TYPE (sym));
744 }
745
746 /* Lookup a template type named "template NAME<TYPE>",
747 visible in lexical block BLOCK. */
748
749 struct type *
750 lookup_template_type (name, type, block)
751 char *name;
752 struct type *type;
753 struct block *block;
754 {
755 struct symbol *sym;
756 char *nam = (char*) alloca(strlen(name) + strlen(type->name) + 4);
757 strcpy (nam, name);
758 strcat (nam, "<");
759 strcat (nam, type->name);
760 strcat (nam, " >"); /* FIXME, extra space still introduced in gcc? */
761
762 sym = lookup_symbol (nam, block, VAR_NAMESPACE, 0, (struct symtab **)NULL);
763
764 if (sym == NULL)
765 {
766 error ("No template type named %s.", name);
767 }
768 if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT)
769 {
770 error ("This context has class, union or enum %s, not a struct.", name);
771 }
772 return (SYMBOL_TYPE (sym));
773 }
774
775 /* Given a type TYPE, lookup the type of the component of type named NAME.
776
777 TYPE can be either a struct or union, or a pointer or reference to a struct or
778 union. If it is a pointer or reference, its target type is automatically used.
779 Thus '.' and '->' are interchangable, as specified for the definitions of the
780 expression element types STRUCTOP_STRUCT and STRUCTOP_PTR.
781
782 If NOERR is nonzero, return zero if NAME is not suitably defined.
783 If NAME is the name of a baseclass type, return that type. */
784
785 struct type *
786 lookup_struct_elt_type (type, name, noerr)
787 struct type *type;
788 char *name;
789 int noerr;
790 {
791 int i;
792
793 for (;;)
794 {
795 CHECK_TYPEDEF (type);
796 if (TYPE_CODE (type) != TYPE_CODE_PTR
797 && TYPE_CODE (type) != TYPE_CODE_REF)
798 break;
799 type = TYPE_TARGET_TYPE (type);
800 }
801
802 if (TYPE_CODE (type) != TYPE_CODE_STRUCT &&
803 TYPE_CODE (type) != TYPE_CODE_UNION)
804 {
805 target_terminal_ours ();
806 gdb_flush (gdb_stdout);
807 fprintf_unfiltered (gdb_stderr, "Type ");
808 type_print (type, "", gdb_stderr, -1);
809 error (" is not a structure or union type.");
810 }
811
812 #if 0
813 /* FIXME: This change put in by Michael seems incorrect for the case where
814 the structure tag name is the same as the member name. I.E. when doing
815 "ptype bell->bar" for "struct foo { int bar; int foo; } bell;"
816 Disabled by fnf. */
817 {
818 char *typename;
819
820 typename = type_name_no_tag (type);
821 if (typename != NULL && STREQ (typename, name))
822 return type;
823 }
824 #endif
825
826 for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--)
827 {
828 char *t_field_name = TYPE_FIELD_NAME (type, i);
829
830 if (t_field_name && STREQ (t_field_name, name))
831 {
832 return TYPE_FIELD_TYPE (type, i);
833 }
834 }
835
836 /* OK, it's not in this class. Recursively check the baseclasses. */
837 for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
838 {
839 struct type *t;
840
841 t = lookup_struct_elt_type (TYPE_BASECLASS (type, i), name, noerr);
842 if (t != NULL)
843 {
844 return t;
845 }
846 }
847
848 if (noerr)
849 {
850 return NULL;
851 }
852
853 target_terminal_ours ();
854 gdb_flush (gdb_stdout);
855 fprintf_unfiltered (gdb_stderr, "Type ");
856 type_print (type, "", gdb_stderr, -1);
857 fprintf_unfiltered (gdb_stderr, " has no component named ");
858 fputs_filtered (name, gdb_stderr);
859 error (".");
860 return (struct type *)-1; /* For lint */
861 }
862
863 /* If possible, make the vptr_fieldno and vptr_basetype fields of TYPE
864 valid. Callers should be aware that in some cases (for example,
865 the type or one of its baseclasses is a stub type and we are
866 debugging a .o file), this function will not be able to find the virtual
867 function table pointer, and vptr_fieldno will remain -1 and vptr_basetype
868 will remain NULL. */
869
870 void
871 fill_in_vptr_fieldno (type)
872 struct type *type;
873 {
874 CHECK_TYPEDEF (type);
875
876 if (TYPE_VPTR_FIELDNO (type) < 0)
877 {
878 int i;
879
880 /* We must start at zero in case the first (and only) baseclass is
881 virtual (and hence we cannot share the table pointer). */
882 for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
883 {
884 fill_in_vptr_fieldno (TYPE_BASECLASS (type, i));
885 if (TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, i)) >= 0)
886 {
887 TYPE_VPTR_FIELDNO (type)
888 = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, i));
889 TYPE_VPTR_BASETYPE (type)
890 = TYPE_VPTR_BASETYPE (TYPE_BASECLASS (type, i));
891 break;
892 }
893 }
894 }
895 }
896
897 /* Find the method and field indices for the destructor in class type T.
898 Return 1 if the destructor was found, otherwise, return 0. */
899
900 int
901 get_destructor_fn_field (t, method_indexp, field_indexp)
902 struct type *t;
903 int *method_indexp;
904 int *field_indexp;
905 {
906 int i;
907
908 for (i = 0; i < TYPE_NFN_FIELDS (t); i++)
909 {
910 int j;
911 struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i);
912
913 for (j = 0; j < TYPE_FN_FIELDLIST_LENGTH (t, i); j++)
914 {
915 if (DESTRUCTOR_PREFIX_P (TYPE_FN_FIELD_PHYSNAME (f, j)))
916 {
917 *method_indexp = i;
918 *field_indexp = j;
919 return 1;
920 }
921 }
922 }
923 return 0;
924 }
925
926 /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989.
927
928 If this is a stubbed struct (i.e. declared as struct foo *), see if
929 we can find a full definition in some other file. If so, copy this
930 definition, so we can use it in future. There used to be a comment (but
931 not any code) that if we don't find a full definition, we'd set a flag
932 so we don't spend time in the future checking the same type. That would
933 be a mistake, though--we might load in more symbols which contain a
934 full definition for the type.
935
936 This used to be coded as a macro, but I don't think it is called
937 often enough to merit such treatment. */
938
939 struct complaint stub_noname_complaint =
940 {"stub type has NULL name", 0, 0};
941
942 struct type *
943 check_typedef (type)
944 register struct type *type;
945 {
946 struct type *orig_type = type;
947 while (TYPE_CODE (type) == TYPE_CODE_TYPEDEF)
948 {
949 if (!TYPE_TARGET_TYPE (type))
950 {
951 char* name;
952 struct symbol *sym;
953
954 /* It is dangerous to call lookup_symbol if we are currently
955 reading a symtab. Infinite recursion is one danger. */
956 if (currently_reading_symtab)
957 return type;
958
959 name = type_name_no_tag (type);
960 /* FIXME: shouldn't we separately check the TYPE_NAME and the
961 TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE
962 as appropriate? (this code was written before TYPE_NAME and
963 TYPE_TAG_NAME were separate). */
964 if (name == NULL)
965 {
966 complain (&stub_noname_complaint);
967 return type;
968 }
969 sym = lookup_symbol (name, 0, STRUCT_NAMESPACE, 0,
970 (struct symtab **) NULL);
971 if (sym)
972 TYPE_TARGET_TYPE (type) = SYMBOL_TYPE (sym);
973 else
974 TYPE_TARGET_TYPE (type) = alloc_type (NULL); /* TYPE_CODE_UNDEF */
975 }
976 type = TYPE_TARGET_TYPE (type);
977 }
978
979 if ((TYPE_FLAGS(type) & TYPE_FLAG_STUB) && ! currently_reading_symtab)
980 {
981 char* name = type_name_no_tag (type);
982 /* FIXME: shouldn't we separately check the TYPE_NAME and the
983 TYPE_TAG_NAME, and look in STRUCT_NAMESPACE and/or VAR_NAMESPACE
984 as appropriate? (this code was written before TYPE_NAME and
985 TYPE_TAG_NAME were separate). */
986 struct symbol *sym;
987 if (name == NULL)
988 {
989 complain (&stub_noname_complaint);
990 return type;
991 }
992 sym = lookup_symbol (name, 0, STRUCT_NAMESPACE, 0,
993 (struct symtab **) NULL);
994 if (sym)
995 {
996 memcpy ((char *)type,
997 (char *)SYMBOL_TYPE(sym),
998 sizeof (struct type));
999 }
1000 }
1001
1002 if (TYPE_FLAGS (type) & TYPE_FLAG_TARGET_STUB)
1003 {
1004 struct type *range_type;
1005 struct type *target_type = check_typedef (TYPE_TARGET_TYPE (type));
1006
1007 if (TYPE_FLAGS (target_type) & (TYPE_FLAG_STUB | TYPE_FLAG_TARGET_STUB))
1008 { }
1009 else if (TYPE_CODE (type) == TYPE_CODE_ARRAY
1010 && TYPE_NFIELDS (type) == 1
1011 && (TYPE_CODE (range_type = TYPE_FIELD_TYPE (type, 0))
1012 == TYPE_CODE_RANGE))
1013 {
1014 /* Now recompute the length of the array type, based on its
1015 number of elements and the target type's length. */
1016 TYPE_LENGTH (type) =
1017 ((TYPE_FIELD_BITPOS (range_type, 1)
1018 - TYPE_FIELD_BITPOS (range_type, 0)
1019 + 1)
1020 * TYPE_LENGTH (target_type));
1021 TYPE_FLAGS (type) &= ~TYPE_FLAG_TARGET_STUB;
1022 }
1023 else if (TYPE_CODE (type) == TYPE_CODE_RANGE)
1024 {
1025 TYPE_LENGTH (type) = TYPE_LENGTH (target_type);
1026 TYPE_FLAGS (type) &= ~TYPE_FLAG_TARGET_STUB;
1027 }
1028 }
1029 /* Cache TYPE_LENGTH for future use. */
1030 TYPE_LENGTH (orig_type) = TYPE_LENGTH (type);
1031 return type;
1032 }
1033
1034 /* New code added to support parsing of Cfront stabs strings */
1035 #include <ctype.h>
1036 #define INIT_EXTRA { pextras->len=0; pextras->str[0]='\0'; }
1037 #define ADD_EXTRA(c) { pextras->str[pextras->len++]=c; }
1038
1039 static void
1040 add_name(pextras,n)
1041 struct extra * pextras;
1042 char * n;
1043 {
1044 int nlen;
1045
1046 if ((nlen = (n ? strlen(n) : 0))==0)
1047 return;
1048 sprintf(pextras->str+pextras->len,"%d%s",nlen,n);
1049 pextras->len=strlen(pextras->str);
1050 }
1051
1052 static void
1053 add_mangled_type(pextras,t)
1054 struct extra * pextras;
1055 struct type * t;
1056 {
1057 enum type_code tcode;
1058 int tlen, tflags;
1059 char * tname;
1060
1061 tcode = TYPE_CODE(t);
1062 tlen = TYPE_LENGTH(t);
1063 tflags = TYPE_FLAGS(t);
1064 tname = TYPE_NAME(t);
1065 /* args of "..." seem to get mangled as "e" */
1066
1067 switch (tcode)
1068 {
1069 case TYPE_CODE_INT:
1070 if (tflags==1)
1071 ADD_EXTRA('U');
1072 switch (tlen)
1073 {
1074 case 1:
1075 ADD_EXTRA('c');
1076 break;
1077 case 2:
1078 ADD_EXTRA('s');
1079 break;
1080 case 4:
1081 {
1082 char* pname;
1083 if ((pname=strrchr(tname,'l'),pname) && !strcmp(pname,"long"))
1084 ADD_EXTRA('l')
1085 else
1086 ADD_EXTRA('i')
1087 }
1088 break;
1089 default:
1090 {
1091
1092 static struct complaint msg = {"Bad int type code length x%x\n",0,0};
1093
1094 complain (&msg, tlen);
1095
1096 }
1097 }
1098 break;
1099 case TYPE_CODE_FLT:
1100 switch (tlen)
1101 {
1102 case 4:
1103 ADD_EXTRA('f');
1104 break;
1105 case 8:
1106 ADD_EXTRA('d');
1107 break;
1108 case 16:
1109 ADD_EXTRA('r');
1110 break;
1111 default:
1112 {
1113 static struct complaint msg = {"Bad float type code length x%x\n",0,0};
1114 complain (&msg, tlen);
1115 }
1116 }
1117 break;
1118 case TYPE_CODE_REF:
1119 ADD_EXTRA('R');
1120 /* followed by what it's a ref to */
1121 break;
1122 case TYPE_CODE_PTR:
1123 ADD_EXTRA('P');
1124 /* followed by what it's a ptr to */
1125 break;
1126 case TYPE_CODE_TYPEDEF:
1127 {
1128 static struct complaint msg = {"Typedefs in overloaded functions not yet supported\n",0,0};
1129 complain (&msg);
1130 }
1131 /* followed by type bytes & name */
1132 break;
1133 case TYPE_CODE_FUNC:
1134 ADD_EXTRA('F');
1135 /* followed by func's arg '_' & ret types */
1136 break;
1137 case TYPE_CODE_VOID:
1138 ADD_EXTRA('v');
1139 break;
1140 case TYPE_CODE_METHOD:
1141 ADD_EXTRA('M');
1142 /* followed by name of class and func's arg '_' & ret types */
1143 add_name(pextras,tname);
1144 ADD_EXTRA('F'); /* then mangle function */
1145 break;
1146 case TYPE_CODE_STRUCT: /* C struct */
1147 case TYPE_CODE_UNION: /* C union */
1148 case TYPE_CODE_ENUM: /* Enumeration type */
1149 /* followed by name of type */
1150 add_name(pextras,tname);
1151 break;
1152
1153 /* errors possible types/not supported */
1154 case TYPE_CODE_CHAR:
1155 case TYPE_CODE_ARRAY: /* Array type */
1156 case TYPE_CODE_MEMBER: /* Member type */
1157 case TYPE_CODE_BOOL:
1158 case TYPE_CODE_COMPLEX: /* Complex float */
1159 case TYPE_CODE_UNDEF:
1160 case TYPE_CODE_SET: /* Pascal sets */
1161 case TYPE_CODE_RANGE:
1162 case TYPE_CODE_STRING:
1163 case TYPE_CODE_BITSTRING:
1164 case TYPE_CODE_ERROR:
1165 default:
1166 {
1167 static struct complaint msg = {"Unknown type code x%x\n",0,0};
1168 complain (&msg, tcode);
1169 }
1170 }
1171 if (t->target_type)
1172 add_mangled_type(pextras,t->target_type);
1173 }
1174
1175 #if 0
1176 void
1177 cfront_mangle_name(type, i, j)
1178 struct type *type;
1179 int i;
1180 int j;
1181 {
1182 struct fn_field *f;
1183 char *mangled_name = gdb_mangle_name (type, i, j);
1184
1185 f = TYPE_FN_FIELDLIST1 (type, i); /* moved from below */
1186
1187 /* kludge to support cfront methods - gdb expects to find "F" for
1188 ARM_mangled names, so when we mangle, we have to add it here */
1189 if (ARM_DEMANGLING)
1190 {
1191 int k;
1192 char * arm_mangled_name;
1193 struct fn_field *method = &f[j];
1194 char *field_name = TYPE_FN_FIELDLIST_NAME (type, i);
1195 char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
1196 char *newname = type_name_no_tag (type);
1197
1198 struct type *ftype = TYPE_FN_FIELD_TYPE (f, j);
1199 int nargs = TYPE_NFIELDS(ftype); /* number of args */
1200 struct extra extras, * pextras = &extras;
1201 INIT_EXTRA
1202
1203 if (TYPE_FN_FIELD_STATIC_P (f, j)) /* j for sublist within this list */
1204 ADD_EXTRA('S')
1205 ADD_EXTRA('F')
1206 /* add args here! */
1207 if (nargs <= 1) /* no args besides this */
1208 ADD_EXTRA('v')
1209 else {
1210 for (k=1; k<nargs; k++)
1211 {
1212 struct type * t;
1213 t = TYPE_FIELD_TYPE(ftype,k);
1214 add_mangled_type(pextras,t);
1215 }
1216 }
1217 ADD_EXTRA('\0')
1218 printf("add_mangled_type: %s\n",extras.str); /* FIXME */
1219 arm_mangled_name = malloc(strlen(mangled_name)+extras.len);
1220 sprintf(arm_mangled_name,"%s%s",mangled_name,extras.str);
1221 free(mangled_name);
1222 mangled_name = arm_mangled_name;
1223 }
1224 }
1225 #endif /* 0 */
1226
1227 #undef ADD_EXTRA
1228 /* End of new code added to support parsing of Cfront stabs strings */
1229
1230 /* Ugly hack to convert method stubs into method types.
1231
1232 He ain't kiddin'. This demangles the name of the method into a string
1233 including argument types, parses out each argument type, generates
1234 a string casting a zero to that type, evaluates the string, and stuffs
1235 the resulting type into an argtype vector!!! Then it knows the type
1236 of the whole function (including argument types for overloading),
1237 which info used to be in the stab's but was removed to hack back
1238 the space required for them. */
1239
1240 void
1241 check_stub_method (type, i, j)
1242 struct type *type;
1243 int i;
1244 int j;
1245 {
1246 struct fn_field *f;
1247 char *mangled_name = gdb_mangle_name (type, i, j);
1248 char *demangled_name = cplus_demangle (mangled_name,
1249 DMGL_PARAMS | DMGL_ANSI);
1250 char *argtypetext, *p;
1251 int depth = 0, argcount = 1;
1252 struct type **argtypes;
1253 struct type *mtype;
1254
1255 /* Make sure we got back a function string that we can use. */
1256 if (demangled_name)
1257 p = strchr (demangled_name, '(');
1258
1259 if (demangled_name == NULL || p == NULL)
1260 error ("Internal: Cannot demangle mangled name `%s'.", mangled_name);
1261
1262 /* Now, read in the parameters that define this type. */
1263 p += 1;
1264 argtypetext = p;
1265 while (*p)
1266 {
1267 if (*p == '(')
1268 {
1269 depth += 1;
1270 }
1271 else if (*p == ')')
1272 {
1273 depth -= 1;
1274 }
1275 else if (*p == ',' && depth == 0)
1276 {
1277 argcount += 1;
1278 }
1279
1280 p += 1;
1281 }
1282
1283 /* We need two more slots: one for the THIS pointer, and one for the
1284 NULL [...] or void [end of arglist]. */
1285
1286 argtypes = (struct type **)
1287 TYPE_ALLOC (type, (argcount + 2) * sizeof (struct type *));
1288 p = argtypetext;
1289 /* FIXME: This is wrong for static member functions. */
1290 argtypes[0] = lookup_pointer_type (type);
1291 argcount = 1;
1292
1293 if (*p != ')') /* () means no args, skip while */
1294 {
1295 depth = 0;
1296 while (*p)
1297 {
1298 if (depth <= 0 && (*p == ',' || *p == ')'))
1299 {
1300 /* Avoid parsing of ellipsis, they will be handled below. */
1301 if (strncmp (argtypetext, "...", p - argtypetext) != 0)
1302 {
1303 argtypes[argcount] =
1304 parse_and_eval_type (argtypetext, p - argtypetext);
1305 argcount += 1;
1306 }
1307 argtypetext = p + 1;
1308 }
1309
1310 if (*p == '(')
1311 {
1312 depth += 1;
1313 }
1314 else if (*p == ')')
1315 {
1316 depth -= 1;
1317 }
1318
1319 p += 1;
1320 }
1321 }
1322
1323 if (p[-2] != '.') /* Not '...' */
1324 {
1325 argtypes[argcount] = builtin_type_void; /* List terminator */
1326 }
1327 else
1328 {
1329 argtypes[argcount] = NULL; /* Ellist terminator */
1330 }
1331
1332 free (demangled_name);
1333
1334 f = TYPE_FN_FIELDLIST1 (type, i);
1335
1336 TYPE_FN_FIELD_PHYSNAME (f, j) = mangled_name;
1337
1338 /* Now update the old "stub" type into a real type. */
1339 mtype = TYPE_FN_FIELD_TYPE (f, j);
1340 TYPE_DOMAIN_TYPE (mtype) = type;
1341 TYPE_ARG_TYPES (mtype) = argtypes;
1342 TYPE_FLAGS (mtype) &= ~TYPE_FLAG_STUB;
1343 TYPE_FN_FIELD_STUB (f, j) = 0;
1344 }
1345
1346 const struct cplus_struct_type cplus_struct_default;
1347
1348 void
1349 allocate_cplus_struct_type (type)
1350 struct type *type;
1351 {
1352 if (!HAVE_CPLUS_STRUCT (type))
1353 {
1354 TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *)
1355 TYPE_ALLOC (type, sizeof (struct cplus_struct_type));
1356 *(TYPE_CPLUS_SPECIFIC(type)) = cplus_struct_default;
1357 }
1358 }
1359
1360 /* Helper function to initialize the standard scalar types.
1361
1362 If NAME is non-NULL and OBJFILE is non-NULL, then we make a copy
1363 of the string pointed to by name in the type_obstack for that objfile,
1364 and initialize the type name to that copy. There are places (mipsread.c
1365 in particular, where init_type is called with a NULL value for NAME). */
1366
1367 struct type *
1368 init_type (code, length, flags, name, objfile)
1369 enum type_code code;
1370 int length;
1371 int flags;
1372 char *name;
1373 struct objfile *objfile;
1374 {
1375 register struct type *type;
1376
1377 type = alloc_type (objfile);
1378 TYPE_CODE (type) = code;
1379 TYPE_LENGTH (type) = length;
1380 TYPE_FLAGS (type) |= flags;
1381 if ((name != NULL) && (objfile != NULL))
1382 {
1383 TYPE_NAME (type) =
1384 obsavestring (name, strlen (name), &objfile -> type_obstack);
1385 }
1386 else
1387 {
1388 TYPE_NAME (type) = name;
1389 }
1390
1391 /* C++ fancies. */
1392
1393 if (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
1394 {
1395 INIT_CPLUS_SPECIFIC (type);
1396 }
1397 return (type);
1398 }
1399
1400 /* Look up a fundamental type for the specified objfile.
1401 May need to construct such a type if this is the first use.
1402
1403 Some object file formats (ELF, COFF, etc) do not define fundamental
1404 types such as "int" or "double". Others (stabs for example), do
1405 define fundamental types.
1406
1407 For the formats which don't provide fundamental types, gdb can create
1408 such types, using defaults reasonable for the current language and
1409 the current target machine.
1410
1411 NOTE: This routine is obsolescent. Each debugging format reader
1412 should manage it's own fundamental types, either creating them from
1413 suitable defaults or reading them from the debugging information,
1414 whichever is appropriate. The DWARF reader has already been
1415 fixed to do this. Once the other readers are fixed, this routine
1416 will go away. Also note that fundamental types should be managed
1417 on a compilation unit basis in a multi-language environment, not
1418 on a linkage unit basis as is done here. */
1419
1420
1421 struct type *
1422 lookup_fundamental_type (objfile, typeid)
1423 struct objfile *objfile;
1424 int typeid;
1425 {
1426 register struct type **typep;
1427 register int nbytes;
1428
1429 if (typeid < 0 || typeid >= FT_NUM_MEMBERS)
1430 {
1431 error ("internal error - invalid fundamental type id %d", typeid);
1432 }
1433
1434 /* If this is the first time we need a fundamental type for this objfile
1435 then we need to initialize the vector of type pointers. */
1436
1437 if (objfile -> fundamental_types == NULL)
1438 {
1439 nbytes = FT_NUM_MEMBERS * sizeof (struct type *);
1440 objfile -> fundamental_types = (struct type **)
1441 obstack_alloc (&objfile -> type_obstack, nbytes);
1442 memset ((char *) objfile -> fundamental_types, 0, nbytes);
1443 OBJSTAT (objfile, n_types += FT_NUM_MEMBERS);
1444 }
1445
1446 /* Look for this particular type in the fundamental type vector. If one is
1447 not found, create and install one appropriate for the current language. */
1448
1449 typep = objfile -> fundamental_types + typeid;
1450 if (*typep == NULL)
1451 {
1452 *typep = create_fundamental_type (objfile, typeid);
1453 }
1454
1455 return (*typep);
1456 }
1457
1458 int
1459 can_dereference (t)
1460 struct type *t;
1461 {
1462 /* FIXME: Should we return true for references as well as pointers? */
1463 CHECK_TYPEDEF (t);
1464 return
1465 (t != NULL
1466 && TYPE_CODE (t) == TYPE_CODE_PTR
1467 && TYPE_CODE (TYPE_TARGET_TYPE (t)) != TYPE_CODE_VOID);
1468 }
1469
1470 /* Chill varying string and arrays are represented as follows:
1471
1472 struct { int __var_length; ELEMENT_TYPE[MAX_SIZE] __var_data};
1473
1474 Return true if TYPE is such a Chill varying type. */
1475
1476 int
1477 chill_varying_type (type)
1478 struct type *type;
1479 {
1480 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
1481 || TYPE_NFIELDS (type) != 2
1482 || strcmp (TYPE_FIELD_NAME (type, 0), "__var_length") != 0)
1483 return 0;
1484 return 1;
1485 }
1486
1487 #if MAINTENANCE_CMDS
1488
1489 static void
1490 print_bit_vector (bits, nbits)
1491 B_TYPE *bits;
1492 int nbits;
1493 {
1494 int bitno;
1495
1496 for (bitno = 0; bitno < nbits; bitno++)
1497 {
1498 if ((bitno % 8) == 0)
1499 {
1500 puts_filtered (" ");
1501 }
1502 if (B_TST (bits, bitno))
1503 {
1504 printf_filtered ("1");
1505 }
1506 else
1507 {
1508 printf_filtered ("0");
1509 }
1510 }
1511 }
1512
1513 /* The args list is a strange beast. It is either terminated by a NULL
1514 pointer for varargs functions, or by a pointer to a TYPE_CODE_VOID
1515 type for normal fixed argcount functions. (FIXME someday)
1516 Also note the first arg should be the "this" pointer, we may not want to
1517 include it since we may get into a infinitely recursive situation. */
1518
1519 static void
1520 print_arg_types (args, spaces)
1521 struct type **args;
1522 int spaces;
1523 {
1524 if (args != NULL)
1525 {
1526 while (*args != NULL)
1527 {
1528 recursive_dump_type (*args, spaces + 2);
1529 if ((*args++) -> code == TYPE_CODE_VOID)
1530 {
1531 break;
1532 }
1533 }
1534 }
1535 }
1536
1537 static void
1538 dump_fn_fieldlists (type, spaces)
1539 struct type *type;
1540 int spaces;
1541 {
1542 int method_idx;
1543 int overload_idx;
1544 struct fn_field *f;
1545
1546 printfi_filtered (spaces, "fn_fieldlists ");
1547 gdb_print_address (TYPE_FN_FIELDLISTS (type), gdb_stdout);
1548 printf_filtered ("\n");
1549 for (method_idx = 0; method_idx < TYPE_NFN_FIELDS (type); method_idx++)
1550 {
1551 f = TYPE_FN_FIELDLIST1 (type, method_idx);
1552 printfi_filtered (spaces + 2, "[%d] name '%s' (",
1553 method_idx,
1554 TYPE_FN_FIELDLIST_NAME (type, method_idx));
1555 gdb_print_address (TYPE_FN_FIELDLIST_NAME (type, method_idx),
1556 gdb_stdout);
1557 printf_filtered (") length %d\n",
1558 TYPE_FN_FIELDLIST_LENGTH (type, method_idx));
1559 for (overload_idx = 0;
1560 overload_idx < TYPE_FN_FIELDLIST_LENGTH (type, method_idx);
1561 overload_idx++)
1562 {
1563 printfi_filtered (spaces + 4, "[%d] physname '%s' (",
1564 overload_idx,
1565 TYPE_FN_FIELD_PHYSNAME (f, overload_idx));
1566 gdb_print_address (TYPE_FN_FIELD_PHYSNAME (f, overload_idx),
1567 gdb_stdout);
1568 printf_filtered (")\n");
1569 printfi_filtered (spaces + 8, "type ");
1570 gdb_print_address (TYPE_FN_FIELD_TYPE (f, overload_idx), gdb_stdout);
1571 printf_filtered ("\n");
1572
1573 recursive_dump_type (TYPE_FN_FIELD_TYPE (f, overload_idx),
1574 spaces + 8 + 2);
1575
1576 printfi_filtered (spaces + 8, "args ");
1577 gdb_print_address (TYPE_FN_FIELD_ARGS (f, overload_idx), gdb_stdout);
1578 printf_filtered ("\n");
1579
1580 print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), spaces);
1581 printfi_filtered (spaces + 8, "fcontext ");
1582 gdb_print_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx),
1583 gdb_stdout);
1584 printf_filtered ("\n");
1585
1586 printfi_filtered (spaces + 8, "is_const %d\n",
1587 TYPE_FN_FIELD_CONST (f, overload_idx));
1588 printfi_filtered (spaces + 8, "is_volatile %d\n",
1589 TYPE_FN_FIELD_VOLATILE (f, overload_idx));
1590 printfi_filtered (spaces + 8, "is_private %d\n",
1591 TYPE_FN_FIELD_PRIVATE (f, overload_idx));
1592 printfi_filtered (spaces + 8, "is_protected %d\n",
1593 TYPE_FN_FIELD_PROTECTED (f, overload_idx));
1594 printfi_filtered (spaces + 8, "is_stub %d\n",
1595 TYPE_FN_FIELD_STUB (f, overload_idx));
1596 printfi_filtered (spaces + 8, "voffset %u\n",
1597 TYPE_FN_FIELD_VOFFSET (f, overload_idx));
1598 }
1599 }
1600 }
1601
1602 static void
1603 print_cplus_stuff (type, spaces)
1604 struct type *type;
1605 int spaces;
1606 {
1607 printfi_filtered (spaces, "n_baseclasses %d\n",
1608 TYPE_N_BASECLASSES (type));
1609 printfi_filtered (spaces, "nfn_fields %d\n",
1610 TYPE_NFN_FIELDS (type));
1611 printfi_filtered (spaces, "nfn_fields_total %d\n",
1612 TYPE_NFN_FIELDS_TOTAL (type));
1613 if (TYPE_N_BASECLASSES (type) > 0)
1614 {
1615 printfi_filtered (spaces, "virtual_field_bits (%d bits at *",
1616 TYPE_N_BASECLASSES (type));
1617 gdb_print_address (TYPE_FIELD_VIRTUAL_BITS (type), gdb_stdout);
1618 printf_filtered (")");
1619
1620 print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type),
1621 TYPE_N_BASECLASSES (type));
1622 puts_filtered ("\n");
1623 }
1624 if (TYPE_NFIELDS (type) > 0)
1625 {
1626 if (TYPE_FIELD_PRIVATE_BITS (type) != NULL)
1627 {
1628 printfi_filtered (spaces, "private_field_bits (%d bits at *",
1629 TYPE_NFIELDS (type));
1630 gdb_print_address (TYPE_FIELD_PRIVATE_BITS (type), gdb_stdout);
1631 printf_filtered (")");
1632 print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type),
1633 TYPE_NFIELDS (type));
1634 puts_filtered ("\n");
1635 }
1636 if (TYPE_FIELD_PROTECTED_BITS (type) != NULL)
1637 {
1638 printfi_filtered (spaces, "protected_field_bits (%d bits at *",
1639 TYPE_NFIELDS (type));
1640 gdb_print_address (TYPE_FIELD_PROTECTED_BITS (type), gdb_stdout);
1641 printf_filtered (")");
1642 print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type),
1643 TYPE_NFIELDS (type));
1644 puts_filtered ("\n");
1645 }
1646 }
1647 if (TYPE_NFN_FIELDS (type) > 0)
1648 {
1649 dump_fn_fieldlists (type, spaces);
1650 }
1651 }
1652
1653 static struct obstack dont_print_type_obstack;
1654
1655 void
1656 recursive_dump_type (type, spaces)
1657 struct type *type;
1658 int spaces;
1659 {
1660 int idx;
1661
1662 if (spaces == 0)
1663 obstack_begin (&dont_print_type_obstack, 0);
1664
1665 if (TYPE_NFIELDS (type) > 0
1666 || (TYPE_CPLUS_SPECIFIC (type) && TYPE_NFN_FIELDS (type) > 0))
1667 {
1668 struct type **first_dont_print
1669 = (struct type **)obstack_base (&dont_print_type_obstack);
1670
1671 int i = (struct type **)obstack_next_free (&dont_print_type_obstack)
1672 - first_dont_print;
1673
1674 while (--i >= 0)
1675 {
1676 if (type == first_dont_print[i])
1677 {
1678 printfi_filtered (spaces, "type node ");
1679 gdb_print_address (type, gdb_stdout);
1680 printf_filtered (" <same as already seen type>\n");
1681 return;
1682 }
1683 }
1684
1685 obstack_ptr_grow (&dont_print_type_obstack, type);
1686 }
1687
1688 printfi_filtered (spaces, "type node ");
1689 gdb_print_address (type, gdb_stdout);
1690 printf_filtered ("\n");
1691 printfi_filtered (spaces, "name '%s' (",
1692 TYPE_NAME (type) ? TYPE_NAME (type) : "<NULL>");
1693 gdb_print_address (TYPE_NAME (type), gdb_stdout);
1694 printf_filtered (")\n");
1695 if (TYPE_TAG_NAME (type) != NULL)
1696 {
1697 printfi_filtered (spaces, "tagname '%s' (",
1698 TYPE_TAG_NAME (type));
1699 gdb_print_address (TYPE_TAG_NAME (type), gdb_stdout);
1700 printf_filtered (")\n");
1701 }
1702 printfi_filtered (spaces, "code 0x%x ", TYPE_CODE (type));
1703 switch (TYPE_CODE (type))
1704 {
1705 case TYPE_CODE_UNDEF:
1706 printf_filtered ("(TYPE_CODE_UNDEF)");
1707 break;
1708 case TYPE_CODE_PTR:
1709 printf_filtered ("(TYPE_CODE_PTR)");
1710 break;
1711 case TYPE_CODE_ARRAY:
1712 printf_filtered ("(TYPE_CODE_ARRAY)");
1713 break;
1714 case TYPE_CODE_STRUCT:
1715 printf_filtered ("(TYPE_CODE_STRUCT)");
1716 break;
1717 case TYPE_CODE_UNION:
1718 printf_filtered ("(TYPE_CODE_UNION)");
1719 break;
1720 case TYPE_CODE_ENUM:
1721 printf_filtered ("(TYPE_CODE_ENUM)");
1722 break;
1723 case TYPE_CODE_FUNC:
1724 printf_filtered ("(TYPE_CODE_FUNC)");
1725 break;
1726 case TYPE_CODE_INT:
1727 printf_filtered ("(TYPE_CODE_INT)");
1728 break;
1729 case TYPE_CODE_FLT:
1730 printf_filtered ("(TYPE_CODE_FLT)");
1731 break;
1732 case TYPE_CODE_VOID:
1733 printf_filtered ("(TYPE_CODE_VOID)");
1734 break;
1735 case TYPE_CODE_SET:
1736 printf_filtered ("(TYPE_CODE_SET)");
1737 break;
1738 case TYPE_CODE_RANGE:
1739 printf_filtered ("(TYPE_CODE_RANGE)");
1740 break;
1741 case TYPE_CODE_STRING:
1742 printf_filtered ("(TYPE_CODE_STRING)");
1743 break;
1744 case TYPE_CODE_ERROR:
1745 printf_filtered ("(TYPE_CODE_ERROR)");
1746 break;
1747 case TYPE_CODE_MEMBER:
1748 printf_filtered ("(TYPE_CODE_MEMBER)");
1749 break;
1750 case TYPE_CODE_METHOD:
1751 printf_filtered ("(TYPE_CODE_METHOD)");
1752 break;
1753 case TYPE_CODE_REF:
1754 printf_filtered ("(TYPE_CODE_REF)");
1755 break;
1756 case TYPE_CODE_CHAR:
1757 printf_filtered ("(TYPE_CODE_CHAR)");
1758 break;
1759 case TYPE_CODE_BOOL:
1760 printf_filtered ("(TYPE_CODE_BOOL)");
1761 break;
1762 case TYPE_CODE_TYPEDEF:
1763 printf_filtered ("(TYPE_CODE_TYPEDEF)");
1764 break;
1765 default:
1766 printf_filtered ("(UNKNOWN TYPE CODE)");
1767 break;
1768 }
1769 puts_filtered ("\n");
1770 printfi_filtered (spaces, "length %d\n", TYPE_LENGTH (type));
1771 printfi_filtered (spaces, "objfile ");
1772 gdb_print_address (TYPE_OBJFILE (type), gdb_stdout);
1773 printf_filtered ("\n");
1774 printfi_filtered (spaces, "target_type ");
1775 gdb_print_address (TYPE_TARGET_TYPE (type), gdb_stdout);
1776 printf_filtered ("\n");
1777 if (TYPE_TARGET_TYPE (type) != NULL)
1778 {
1779 recursive_dump_type (TYPE_TARGET_TYPE (type), spaces + 2);
1780 }
1781 printfi_filtered (spaces, "pointer_type ");
1782 gdb_print_address (TYPE_POINTER_TYPE (type), gdb_stdout);
1783 printf_filtered ("\n");
1784 printfi_filtered (spaces, "reference_type ");
1785 gdb_print_address (TYPE_REFERENCE_TYPE (type), gdb_stdout);
1786 printf_filtered ("\n");
1787 printfi_filtered (spaces, "flags 0x%x", TYPE_FLAGS (type));
1788 if (TYPE_FLAGS (type) & TYPE_FLAG_UNSIGNED)
1789 {
1790 puts_filtered (" TYPE_FLAG_UNSIGNED");
1791 }
1792 if (TYPE_FLAGS (type) & TYPE_FLAG_STUB)
1793 {
1794 puts_filtered (" TYPE_FLAG_STUB");
1795 }
1796 puts_filtered ("\n");
1797 printfi_filtered (spaces, "nfields %d ", TYPE_NFIELDS (type));
1798 gdb_print_address (TYPE_FIELDS (type), gdb_stdout);
1799 puts_filtered ("\n");
1800 for (idx = 0; idx < TYPE_NFIELDS (type); idx++)
1801 {
1802 printfi_filtered (spaces + 2,
1803 "[%d] bitpos %d bitsize %d type ",
1804 idx, TYPE_FIELD_BITPOS (type, idx),
1805 TYPE_FIELD_BITSIZE (type, idx));
1806 gdb_print_address (TYPE_FIELD_TYPE (type, idx), gdb_stdout);
1807 printf_filtered (" name '%s' (",
1808 TYPE_FIELD_NAME (type, idx) != NULL
1809 ? TYPE_FIELD_NAME (type, idx)
1810 : "<NULL>");
1811 gdb_print_address (TYPE_FIELD_NAME (type, idx), gdb_stdout);
1812 printf_filtered (")\n");
1813 if (TYPE_FIELD_TYPE (type, idx) != NULL)
1814 {
1815 recursive_dump_type (TYPE_FIELD_TYPE (type, idx), spaces + 4);
1816 }
1817 }
1818 printfi_filtered (spaces, "vptr_basetype ");
1819 gdb_print_address (TYPE_VPTR_BASETYPE (type), gdb_stdout);
1820 puts_filtered ("\n");
1821 if (TYPE_VPTR_BASETYPE (type) != NULL)
1822 {
1823 recursive_dump_type (TYPE_VPTR_BASETYPE (type), spaces + 2);
1824 }
1825 printfi_filtered (spaces, "vptr_fieldno %d\n", TYPE_VPTR_FIELDNO (type));
1826 switch (TYPE_CODE (type))
1827 {
1828 case TYPE_CODE_METHOD:
1829 case TYPE_CODE_FUNC:
1830 printfi_filtered (spaces, "arg_types ");
1831 gdb_print_address (TYPE_ARG_TYPES (type), gdb_stdout);
1832 puts_filtered ("\n");
1833 print_arg_types (TYPE_ARG_TYPES (type), spaces);
1834 break;
1835
1836 case TYPE_CODE_STRUCT:
1837 printfi_filtered (spaces, "cplus_stuff ");
1838 gdb_print_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout);
1839 puts_filtered ("\n");
1840 print_cplus_stuff (type, spaces);
1841 break;
1842
1843 default:
1844 /* We have to pick one of the union types to be able print and test
1845 the value. Pick cplus_struct_type, even though we know it isn't
1846 any particular one. */
1847 printfi_filtered (spaces, "type_specific ");
1848 gdb_print_address (TYPE_CPLUS_SPECIFIC (type), gdb_stdout);
1849 if (TYPE_CPLUS_SPECIFIC (type) != NULL)
1850 {
1851 printf_filtered (" (unknown data form)");
1852 }
1853 printf_filtered ("\n");
1854 break;
1855
1856 }
1857 if (spaces == 0)
1858 obstack_free (&dont_print_type_obstack, NULL);
1859 }
1860
1861 #endif /* MAINTENANCE_CMDS */
1862
1863 void
1864 _initialize_gdbtypes ()
1865 {
1866 builtin_type_void =
1867 init_type (TYPE_CODE_VOID, 1,
1868 0,
1869 "void", (struct objfile *) NULL);
1870 builtin_type_char =
1871 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1872 0,
1873 "char", (struct objfile *) NULL);
1874 builtin_type_signed_char =
1875 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1876 0,
1877 "signed char", (struct objfile *) NULL);
1878 builtin_type_unsigned_char =
1879 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1880 TYPE_FLAG_UNSIGNED,
1881 "unsigned char", (struct objfile *) NULL);
1882 builtin_type_short =
1883 init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
1884 0,
1885 "short", (struct objfile *) NULL);
1886 builtin_type_unsigned_short =
1887 init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
1888 TYPE_FLAG_UNSIGNED,
1889 "unsigned short", (struct objfile *) NULL);
1890 builtin_type_int =
1891 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
1892 0,
1893 "int", (struct objfile *) NULL);
1894 builtin_type_unsigned_int =
1895 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
1896 TYPE_FLAG_UNSIGNED,
1897 "unsigned int", (struct objfile *) NULL);
1898 builtin_type_long =
1899 init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
1900 0,
1901 "long", (struct objfile *) NULL);
1902 builtin_type_unsigned_long =
1903 init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
1904 TYPE_FLAG_UNSIGNED,
1905 "unsigned long", (struct objfile *) NULL);
1906 builtin_type_long_long =
1907 init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
1908 0,
1909 "long long", (struct objfile *) NULL);
1910 builtin_type_unsigned_long_long =
1911 init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
1912 TYPE_FLAG_UNSIGNED,
1913 "unsigned long long", (struct objfile *) NULL);
1914 builtin_type_float =
1915 init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
1916 0,
1917 "float", (struct objfile *) NULL);
1918 builtin_type_double =
1919 init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
1920 0,
1921 "double", (struct objfile *) NULL);
1922 builtin_type_long_double =
1923 init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
1924 0,
1925 "long double", (struct objfile *) NULL);
1926 builtin_type_complex =
1927 init_type (TYPE_CODE_COMPLEX, 2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
1928 0,
1929 "complex", (struct objfile *) NULL);
1930 TYPE_TARGET_TYPE (builtin_type_complex) = builtin_type_float;
1931 builtin_type_double_complex =
1932 init_type (TYPE_CODE_COMPLEX, 2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
1933 0,
1934 "double complex", (struct objfile *) NULL);
1935 TYPE_TARGET_TYPE (builtin_type_double_complex) = builtin_type_double;
1936 builtin_type_string =
1937 init_type (TYPE_CODE_STRING, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1938 0,
1939 "string", (struct objfile *) NULL);
1940 builtin_type_int8 =
1941 init_type (TYPE_CODE_INT, 8 / 8,
1942 0,
1943 "int8_t", (struct objfile *) NULL);
1944 builtin_type_uint8 =
1945 init_type (TYPE_CODE_INT, 8 / 8,
1946 TYPE_FLAG_UNSIGNED,
1947 "uint8_t", (struct objfile *) NULL);
1948 builtin_type_int16 =
1949 init_type (TYPE_CODE_INT, 16 / 8,
1950 0,
1951 "int16_t", (struct objfile *) NULL);
1952 builtin_type_uint16 =
1953 init_type (TYPE_CODE_INT, 16 / 8,
1954 TYPE_FLAG_UNSIGNED,
1955 "uint16_t", (struct objfile *) NULL);
1956 builtin_type_int32 =
1957 init_type (TYPE_CODE_INT, 32 / 8,
1958 0,
1959 "int32_t", (struct objfile *) NULL);
1960 builtin_type_uint32 =
1961 init_type (TYPE_CODE_INT, 32 / 8,
1962 TYPE_FLAG_UNSIGNED,
1963 "uint32_t", (struct objfile *) NULL);
1964 builtin_type_int64 =
1965 init_type (TYPE_CODE_INT, 64 / 8,
1966 0,
1967 "int64_t", (struct objfile *) NULL);
1968 builtin_type_uint64 =
1969 init_type (TYPE_CODE_INT, 64 / 8,
1970 TYPE_FLAG_UNSIGNED,
1971 "uint64_t", (struct objfile *) NULL);
1972 /* start-sanitize-r5900 */
1973 builtin_type_int128 =
1974 init_type (TYPE_CODE_INT, 128 / 8,
1975 0,
1976 "int128_t", (struct objfile *) NULL);
1977 builtin_type_uint128 =
1978 init_type (TYPE_CODE_INT, 128 / 8,
1979 TYPE_FLAG_UNSIGNED,
1980 "uint128_t", (struct objfile *) NULL);
1981 /* end-sanitize-r5900 */
1982 }
This page took 0.071125 seconds and 4 git commands to generate.