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