]> Git Repo - binutils.git/blob - gdb/gdbtypes.c
* lmode_inferior_valid, lmode_ours_valid: New static vars.
[binutils.git] / gdb / gdbtypes.c
1 /* Support routines for manipulating internal types for GDB.
2    Copyright (C) 1992 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
20
21 #include "defs.h"
22 #include <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
34 /* Alloc a new type structure and fill it with some defaults.  If
35    OBJFILE is non-NULL, then allocate the space for the type structure
36    in that objfile's type_obstack. */
37
38 struct type *
39 alloc_type (objfile)
40      struct objfile *objfile;
41 {
42   register struct type *type;
43
44   /* Alloc the structure and start off with all fields zeroed. */
45
46   if (objfile == NULL)
47     {
48       type  = (struct type *) xmalloc (sizeof (struct type));
49     }
50   else
51     {
52       type  = (struct type *) obstack_alloc (&objfile -> type_obstack,
53                                              sizeof (struct type));
54     }
55   memset ((char *)type, 0, sizeof (struct type));
56
57   /* Initialize the fields that might not be zero. */
58
59   TYPE_CODE (type) = TYPE_CODE_UNDEF;
60   TYPE_OBJFILE (type) = objfile;
61   TYPE_VPTR_FIELDNO (type) = -1;
62
63   return (type);
64 }
65
66 /* Lookup a pointer to a type TYPE.  TYPEPTR, if nonzero, points
67    to a pointer to memory where the pointer type should be stored.
68    If *TYPEPTR is zero, update it to point to the pointer type we return.
69    We allocate new memory if needed.  */
70
71 struct type *
72 make_pointer_type (type, typeptr)
73      struct type *type;
74      struct type **typeptr;
75 {
76   register struct type *ntype;          /* New type */
77   struct objfile *objfile;
78
79   ntype = TYPE_POINTER_TYPE (type);
80
81   if (ntype) 
82     if (typeptr == 0)           
83       return ntype;     /* Don't care about alloc, and have new type.  */
84     else if (*typeptr == 0)
85       {
86         *typeptr = ntype;       /* Tracking alloc, and we have new type.  */
87         return ntype;
88       }
89
90   if (typeptr == 0 || *typeptr == 0)    /* We'll need to allocate one.  */
91     {
92       ntype = alloc_type (TYPE_OBJFILE (type));
93       if (typeptr)
94         *typeptr = ntype;
95     }
96   else                          /* We have storage, but need to reset it.  */
97     {
98       ntype = *typeptr;
99       objfile = TYPE_OBJFILE (ntype);
100       memset ((char *)ntype, 0, sizeof (struct type));
101       TYPE_OBJFILE (ntype) = objfile;
102     }
103
104   TYPE_TARGET_TYPE (ntype) = type;
105   TYPE_POINTER_TYPE (type) = ntype;
106
107   /* FIXME!  Assume the machine has only one representation for pointers!  */
108
109   TYPE_LENGTH (ntype) = TARGET_PTR_BIT / TARGET_CHAR_BIT;
110   TYPE_CODE (ntype) = TYPE_CODE_PTR;
111
112   /* pointers are unsigned */
113   TYPE_FLAGS (ntype) |= TYPE_FLAG_UNSIGNED;
114   
115   if (!TYPE_POINTER_TYPE (type))        /* Remember it, if don't have one.  */
116     TYPE_POINTER_TYPE (type) = ntype;
117
118   return ntype;
119 }
120
121 /* Given a type TYPE, return a type of pointers to that type.
122    May need to construct such a type if this is the first use.  */
123
124 struct type *
125 lookup_pointer_type (type)
126      struct type *type;
127 {
128   return make_pointer_type (type, (struct type **)0);
129 }
130
131 /* Lookup a C++ `reference' to a type TYPE.  TYPEPTR, if nonzero, points
132    to a pointer to memory where the reference type should be stored.
133    If *TYPEPTR is zero, update it to point to the reference type we return.
134    We allocate new memory if needed.  */
135
136 struct type *
137 make_reference_type (type, typeptr)
138      struct type *type;
139      struct type **typeptr;
140 {
141   register struct type *ntype;          /* New type */
142   struct objfile *objfile;
143
144   ntype = TYPE_REFERENCE_TYPE (type);
145
146   if (ntype) 
147     if (typeptr == 0)           
148       return ntype;     /* Don't care about alloc, and have new type.  */
149     else if (*typeptr == 0)
150       {
151         *typeptr = ntype;       /* Tracking alloc, and we have new type.  */
152         return ntype;
153       }
154
155   if (typeptr == 0 || *typeptr == 0)    /* We'll need to allocate one.  */
156     {
157       ntype = alloc_type (TYPE_OBJFILE (type));
158       if (typeptr)
159         *typeptr = ntype;
160     }
161   else                          /* We have storage, but need to reset it.  */
162     {
163       ntype = *typeptr;
164       objfile = TYPE_OBJFILE (ntype);
165       memset ((char *)ntype, 0, sizeof (struct type));
166       TYPE_OBJFILE (ntype) = objfile;
167     }
168
169   TYPE_TARGET_TYPE (ntype) = type;
170   TYPE_REFERENCE_TYPE (type) = ntype;
171
172   /* FIXME!  Assume the machine has only one representation for references,
173      and that it matches the (only) representation for pointers!  */
174
175   TYPE_LENGTH (ntype) = TARGET_PTR_BIT / TARGET_CHAR_BIT;
176   TYPE_CODE (ntype) = TYPE_CODE_REF;
177   
178   if (!TYPE_REFERENCE_TYPE (type))      /* Remember it, if don't have one.  */
179     TYPE_REFERENCE_TYPE (type) = ntype;
180
181   return ntype;
182 }
183
184 /* Same as above, but caller doesn't care about memory allocation details.  */
185
186 struct type *
187 lookup_reference_type (type)
188      struct type *type;
189 {
190   return make_reference_type (type, (struct type **)0);
191 }
192
193 /* Lookup a function type that returns type TYPE.  TYPEPTR, if nonzero, points
194    to a pointer to memory where the function type should be stored.
195    If *TYPEPTR is zero, update it to point to the function type we return.
196    We allocate new memory if needed.  */
197
198 struct type *
199 make_function_type (type, typeptr)
200      struct type *type;
201      struct type **typeptr;
202 {
203   register struct type *ntype;          /* New type */
204   struct objfile *objfile;
205
206   ntype = TYPE_FUNCTION_TYPE (type);
207
208   if (ntype) 
209     if (typeptr == 0)           
210       return ntype;     /* Don't care about alloc, and have new type.  */
211     else if (*typeptr == 0)
212       {
213         *typeptr = ntype;       /* Tracking alloc, and we have new type.  */
214         return ntype;
215       }
216
217   if (typeptr == 0 || *typeptr == 0)    /* We'll need to allocate one.  */
218     {
219       ntype = alloc_type (TYPE_OBJFILE (type));
220       if (typeptr)
221         *typeptr = ntype;
222     }
223   else                          /* We have storage, but need to reset it.  */
224     {
225       ntype = *typeptr;
226       objfile = TYPE_OBJFILE (ntype);
227       memset ((char *)ntype, 0, sizeof (struct type));
228       TYPE_OBJFILE (ntype) = objfile;
229     }
230
231   TYPE_TARGET_TYPE (ntype) = type;
232   TYPE_FUNCTION_TYPE (type) = ntype;
233
234   TYPE_LENGTH (ntype) = 1;
235   TYPE_CODE (ntype) = TYPE_CODE_FUNC;
236   
237   if (!TYPE_FUNCTION_TYPE (type))       /* Remember it, if don't have one.  */
238     TYPE_FUNCTION_TYPE (type) = ntype;
239
240   return ntype;
241 }
242
243
244 /* Given a type TYPE, return a type of functions that return that type.
245    May need to construct such a type if this is the first use.  */
246
247 struct type *
248 lookup_function_type (type)
249      struct type *type;
250 {
251   return make_function_type (type, (struct type **)0);
252 }
253
254 /* Implement direct support for MEMBER_TYPE in GNU C++.
255    May need to construct such a type if this is the first use.
256    The TYPE is the type of the member.  The DOMAIN is the type
257    of the aggregate that the member belongs to.  */
258
259 struct type *
260 lookup_member_type (type, domain)
261      struct type *type;
262      struct type *domain;
263 {
264   register struct type *mtype;
265
266   mtype = alloc_type (TYPE_OBJFILE (type));
267   smash_to_member_type (mtype, domain, type);
268   return (mtype);
269 }
270
271 /* Allocate a stub method whose return type is TYPE.  
272    This apparently happens for speed of symbol reading, since parsing
273    out the arguments to the method is cpu-intensive, the way we are doing
274    it.  So, we will fill in arguments later.
275    This always returns a fresh type.   */
276
277 struct type *
278 allocate_stub_method (type)
279      struct type *type;
280 {
281   struct type *mtype;
282
283   mtype = alloc_type (TYPE_OBJFILE (type));
284   TYPE_TARGET_TYPE (mtype) = type;
285   /*  _DOMAIN_TYPE (mtype) = unknown yet */
286   /*  _ARG_TYPES (mtype) = unknown yet */
287   TYPE_FLAGS (mtype) = TYPE_FLAG_STUB;
288   TYPE_CODE (mtype) = TYPE_CODE_METHOD;
289   TYPE_LENGTH (mtype) = 1;
290   return (mtype);
291 }
292
293 /* Create an array type.  Elements will be of type TYPE, and there will
294    be NUM of them.
295
296    Eventually this should be extended to take two more arguments which
297    specify the bounds of the array and the type of the index.
298    It should also be changed to be a "lookup" function, with the
299    appropriate data structures added to the type field.
300    Then read array type should call here.  */
301
302 struct type *
303 create_array_type (element_type, number)
304      struct type *element_type;
305      int number;
306 {
307   struct type *result_type;
308   struct type *range_type;
309
310   result_type = alloc_type (TYPE_OBJFILE (element_type));
311
312   TYPE_CODE (result_type) = TYPE_CODE_ARRAY;
313   TYPE_TARGET_TYPE (result_type) = element_type;
314   TYPE_LENGTH (result_type) = number * TYPE_LENGTH (element_type);
315   TYPE_NFIELDS (result_type) = 1;
316   TYPE_FIELDS (result_type) = (struct field *)
317     obstack_alloc (&TYPE_OBJFILE (result_type) -> type_obstack,
318                    sizeof (struct field));
319
320   {
321     /* Create range type.  */
322     range_type = alloc_type (TYPE_OBJFILE (result_type));
323     TYPE_CODE (range_type) = TYPE_CODE_RANGE;
324     TYPE_TARGET_TYPE (range_type) = builtin_type_int;  /* FIXME */
325
326     /* This should never be needed.  */
327     TYPE_LENGTH (range_type) = sizeof (int);
328
329     TYPE_NFIELDS (range_type) = 2;
330     TYPE_FIELDS (range_type) = (struct field *)
331       obstack_alloc (&TYPE_OBJFILE (range_type) -> type_obstack,
332                      2 * sizeof (struct field));
333     TYPE_FIELD_BITPOS (range_type, 0) = 0; /* FIXME */
334     TYPE_FIELD_BITPOS (range_type, 1) = number-1; /* FIXME */
335     TYPE_FIELD_TYPE (range_type, 0) = builtin_type_int; /* FIXME */
336     TYPE_FIELD_TYPE (range_type, 1) = builtin_type_int; /* FIXME */
337   }
338   TYPE_FIELD_TYPE (result_type, 0) = range_type;
339   TYPE_VPTR_FIELDNO (result_type) = -1;
340
341   return (result_type);
342 }
343
344
345 /* Smash TYPE to be a type of members of DOMAIN with type TO_TYPE. 
346    A MEMBER is a wierd thing -- it amounts to a typed offset into
347    a struct, e.g. "an int at offset 8".  A MEMBER TYPE doesn't
348    include the offset (that's the value of the MEMBER itself), but does
349    include the structure type into which it points (for some reason).
350
351    When "smashing" the type, we preserve the objfile that the
352    old type pointed to, since we aren't changing where the type is actually
353    allocated.  */
354
355 void
356 smash_to_member_type (type, domain, to_type)
357      struct type *type;
358      struct type *domain;
359      struct type *to_type;
360 {
361   struct objfile *objfile;
362
363   objfile = TYPE_OBJFILE (type);
364
365   memset ((char *)type, 0, sizeof (struct type));
366   TYPE_OBJFILE (type) = objfile;
367   TYPE_TARGET_TYPE (type) = to_type;
368   TYPE_DOMAIN_TYPE (type) = domain;
369   TYPE_LENGTH (type) = 1;       /* In practice, this is never needed.  */
370   TYPE_CODE (type) = TYPE_CODE_MEMBER;
371 }
372
373 /* Smash TYPE to be a type of method of DOMAIN with type TO_TYPE.
374    METHOD just means `function that gets an extra "this" argument'.
375
376    When "smashing" the type, we preserve the objfile that the
377    old type pointed to, since we aren't changing where the type is actually
378    allocated.  */
379
380 void
381 smash_to_method_type (type, domain, to_type, args)
382      struct type *type;
383      struct type *domain;
384      struct type *to_type;
385      struct type **args;
386 {
387   struct objfile *objfile;
388
389   objfile = TYPE_OBJFILE (type);
390
391   memset ((char *)type, 0, sizeof (struct type));
392   TYPE_OBJFILE (type) = objfile;
393   TYPE_TARGET_TYPE (type) = to_type;
394   TYPE_DOMAIN_TYPE (type) = domain;
395   TYPE_ARG_TYPES (type) = args;
396   TYPE_LENGTH (type) = 1;       /* In practice, this is never needed.  */
397   TYPE_CODE (type) = TYPE_CODE_METHOD;
398 }
399
400 /* Return a typename for a struct/union/enum type
401    without the tag qualifier.  If the type has a NULL name,
402    NULL is returned.  */
403
404 char *
405 type_name_no_tag (type)
406      register const struct type *type;
407 {
408   register char *name;
409
410   if ((name = TYPE_NAME (type)) != NULL)
411     {
412       switch (TYPE_CODE (type))
413         {
414           case TYPE_CODE_STRUCT:
415             if(!strncmp (name, "struct ", 7))
416               {
417                 name += 7;
418               }
419             break;
420           case TYPE_CODE_UNION:
421             if(!strncmp (name, "union ", 6))
422               {
423                 name += 6;
424               }
425             break;
426           case TYPE_CODE_ENUM:
427             if(!strncmp (name, "enum ", 5))
428               {
429                 name += 5;
430               }
431             break;
432           default:              /* To avoid -Wall warnings */
433             break;
434         }
435     }
436   return (name);
437 }
438
439 /* Lookup a primitive type named NAME. 
440    Return zero if NAME is not a primitive type.*/
441
442 struct type *
443 lookup_primitive_typename (name)
444      char *name;
445 {
446    struct type ** const *p;
447
448    for (p = current_language -> la_builtin_type_vector; *p != NULL; p++)
449      {
450        if (!strcmp ((**p) -> name, name))
451          {
452            return (**p);
453          }
454      }
455    return (NULL); 
456 }
457
458 /* Lookup a typedef or primitive type named NAME,
459    visible in lexical block BLOCK.
460    If NOERR is nonzero, return zero if NAME is not suitably defined.  */
461
462 struct type *
463 lookup_typename (name, block, noerr)
464      char *name;
465      struct block *block;
466      int noerr;
467 {
468   register struct symbol *sym;
469   register struct type *tmp;
470
471   sym = lookup_symbol (name, block, VAR_NAMESPACE, 0, (struct symtab **) NULL);
472   if (sym == NULL || SYMBOL_CLASS (sym) != LOC_TYPEDEF)
473     {
474       tmp = lookup_primitive_typename (name);
475       if (tmp)
476         {
477           return (tmp);
478         }
479       else if (!tmp && noerr)
480         {
481           return (NULL);
482         }
483       else
484         {
485           error ("No type named %s.", name);
486         }
487     }
488   return (SYMBOL_TYPE (sym));
489 }
490
491 struct type *
492 lookup_unsigned_typename (name)
493      char *name;
494 {
495   char *uns = alloca (strlen (name) + 10);
496
497   strcpy (uns, "unsigned ");
498   strcpy (uns + 9, name);
499   return (lookup_typename (uns, (struct block *) NULL, 0));
500 }
501
502 struct type *
503 lookup_signed_typename (name)
504      char *name;
505 {
506   struct type *t;
507   char *uns = alloca (strlen (name) + 8);
508
509   strcpy (uns, "signed ");
510   strcpy (uns + 7, name);
511   t = lookup_typename (uns, (struct block *) NULL, 1);
512   /* If we don't find "signed FOO" just try again with plain "FOO". */
513   if (t != NULL)
514     return t;
515   return lookup_typename (name, (struct block *) NULL, 0);
516 }
517
518 /* Lookup a structure type named "struct NAME",
519    visible in lexical block BLOCK.  */
520
521 struct type *
522 lookup_struct (name, block)
523      char *name;
524      struct block *block;
525 {
526   register struct symbol *sym;
527
528   sym = lookup_symbol (name, block, STRUCT_NAMESPACE, 0,
529                        (struct symtab **) NULL);
530
531   if (sym == NULL)
532     {
533       error ("No struct type named %s.", name);
534     }
535   if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT)
536     {
537       error ("This context has class, union or enum %s, not a struct.", name);
538     }
539   return (SYMBOL_TYPE (sym));
540 }
541
542 /* Lookup a union type named "union NAME",
543    visible in lexical block BLOCK.  */
544
545 struct type *
546 lookup_union (name, block)
547      char *name;
548      struct block *block;
549 {
550   register struct symbol *sym;
551
552   sym = lookup_symbol (name, block, STRUCT_NAMESPACE, 0,
553                        (struct symtab **) NULL);
554
555   if (sym == NULL)
556     {
557       error ("No union type named %s.", name);
558     }
559   if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_UNION)
560     {
561       error ("This context has class, struct or enum %s, not a union.", name);
562     }
563   return (SYMBOL_TYPE (sym));
564 }
565
566 /* Lookup an enum type named "enum NAME",
567    visible in lexical block BLOCK.  */
568
569 struct type *
570 lookup_enum (name, block)
571      char *name;
572      struct block *block;
573 {
574   register struct symbol *sym;
575
576   sym = lookup_symbol (name, block, STRUCT_NAMESPACE, 0, 
577                        (struct symtab **) NULL);
578   if (sym == NULL)
579     {
580       error ("No enum type named %s.", name);
581     }
582   if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_ENUM)
583     {
584       error ("This context has class, struct or union %s, not an enum.", name);
585     }
586   return (SYMBOL_TYPE (sym));
587 }
588
589 /* Lookup a template type named "template NAME<TYPE>",
590    visible in lexical block BLOCK.  */
591
592 struct type *
593 lookup_template_type (name, type, block)
594      char *name;
595      struct type *type;
596      struct block *block;
597 {
598   struct symbol *sym;
599   char *nam = (char*) alloca(strlen(name) + strlen(type->name) + 4);
600   strcpy (nam, name);
601   strcat (nam, "<");
602   strcat (nam, type->name);
603   strcat (nam, " >");   /* FIXME, extra space still introduced in gcc? */
604
605   sym = lookup_symbol (nam, block, VAR_NAMESPACE, 0, (struct symtab **)NULL);
606
607   if (sym == NULL)
608     {
609       error ("No template type named %s.", name);
610     }
611   if (TYPE_CODE (SYMBOL_TYPE (sym)) != TYPE_CODE_STRUCT)
612     {
613       error ("This context has class, union or enum %s, not a struct.", name);
614     }
615   return (SYMBOL_TYPE (sym));
616 }
617
618 /* Given a type TYPE, lookup the type of the component of type named
619    NAME.  
620    If NOERR is nonzero, return zero if NAME is not suitably defined.  */
621
622 struct type *
623 lookup_struct_elt_type (type, name, noerr)
624      struct type *type;
625      char *name;
626     int noerr;
627 {
628   int i;
629
630   if (TYPE_CODE (type) == TYPE_CODE_PTR ||
631       TYPE_CODE (type) == TYPE_CODE_REF)
632       type = TYPE_TARGET_TYPE (type);
633
634   if (TYPE_CODE (type) != TYPE_CODE_STRUCT &&
635       TYPE_CODE (type) != TYPE_CODE_UNION)
636     {
637       target_terminal_ours ();
638       fflush (stdout);
639       fprintf (stderr, "Type ");
640       type_print (type, "", stderr, -1);
641       error (" is not a structure or union type.");
642     }
643
644   check_stub_type (type);
645
646   for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--)
647     {
648       char *t_field_name = TYPE_FIELD_NAME (type, i);
649
650       if (t_field_name && !strcmp (t_field_name, name))
651         {
652           return TYPE_FIELD_TYPE (type, i);
653         }
654     }
655
656   /* OK, it's not in this class.  Recursively check the baseclasses.  */
657   for (i = TYPE_N_BASECLASSES (type) - 1; i >= 0; i--)
658     {
659       struct type *t;
660
661       t = lookup_struct_elt_type (TYPE_BASECLASS (type, i), name, 0);
662       if (t != NULL)
663         {
664           return t;
665         }
666     }
667
668   if (noerr)
669     {
670       return NULL;
671     }
672   
673   target_terminal_ours ();
674   fflush (stdout);
675   fprintf (stderr, "Type ");
676   type_print (type, "", stderr, -1);
677   fprintf (stderr, " has no component named ");
678   fputs_filtered (name, stderr);
679   error (".");
680   return (struct type *)-1;     /* For lint */
681 }
682
683 /* This function is really horrible, but to avoid it, there would need
684    to be more filling in of forward references.  */
685
686 void
687 fill_in_vptr_fieldno (type)
688      struct type *type;
689 {
690   if (TYPE_VPTR_FIELDNO (type) < 0)
691     {
692       int i;
693       for (i = 1; i < TYPE_N_BASECLASSES (type); i++)
694         {
695           fill_in_vptr_fieldno (TYPE_BASECLASS (type, i));
696           if (TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, i)) >= 0)
697             {
698               TYPE_VPTR_FIELDNO (type)
699                 = TYPE_VPTR_FIELDNO (TYPE_BASECLASS (type, i));
700               TYPE_VPTR_BASETYPE (type)
701                 = TYPE_VPTR_BASETYPE (TYPE_BASECLASS (type, i));
702               break;
703             }
704         }
705     }
706 }
707
708 /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989.
709
710    If this is a stubbed struct (i.e. declared as struct foo *), see if
711    we can find a full definition in some other file. If so, copy this
712    definition, so we can use it in future.  If not, set a flag so we 
713    don't waste too much time in future.  (FIXME, this doesn't seem
714    to be happening...)
715
716    This used to be coded as a macro, but I don't think it is called 
717    often enough to merit such treatment.
718 */
719
720 struct complaint stub_noname_complaint =
721   {"stub type has NULL name", 0, 0};
722
723 void 
724 check_stub_type (type)
725      struct type *type;
726 {
727   if (TYPE_FLAGS(type) & TYPE_FLAG_STUB)
728     {
729       char* name = type_name_no_tag (type);
730       struct symbol *sym;
731       if (name == NULL)
732         {
733           complain (&stub_noname_complaint, 0);
734           return;
735         }
736       sym = lookup_symbol (name, 0, STRUCT_NAMESPACE, 0, 
737                            (struct symtab **) NULL);
738       if (sym)
739         {
740           memcpy ((char *)type, (char *)SYMBOL_TYPE(sym), sizeof (struct type));
741         }
742     }
743 }
744
745 /* Ugly hack to convert method stubs into method types.
746
747    He ain't kiddin'.  This demangles the name of the method into a string
748    including argument types, parses out each argument type, generates
749    a string casting a zero to that type, evaluates the string, and stuffs
750    the resulting type into an argtype vector!!!  Then it knows the type
751    of the whole function (including argument types for overloading),
752    which info used to be in the stab's but was removed to hack back
753    the space required for them.  */
754
755 void
756 check_stub_method (type, i, j)
757      struct type *type;
758      int i;
759      int j;
760 {
761   struct fn_field *f;
762   char *mangled_name = gdb_mangle_name (type, i, j);
763   char *demangled_name = cplus_demangle (mangled_name,
764                                          DMGL_PARAMS | DMGL_ANSI);
765   char *argtypetext, *p;
766   int depth = 0, argcount = 1;
767   struct type **argtypes;
768   struct type *mtype;
769
770   if (demangled_name == NULL)
771     {
772       error ("Internal: Cannot demangle mangled name `%s'.", mangled_name);
773     }
774
775   /* Now, read in the parameters that define this type.  */
776   argtypetext = strchr (demangled_name, '(') + 1;
777   p = argtypetext;
778   while (*p)
779     {
780       if (*p == '(')
781         {
782           depth += 1;
783         }
784       else if (*p == ')')
785         {
786           depth -= 1;
787         }
788       else if (*p == ',' && depth == 0)
789         {
790           argcount += 1;
791         }
792
793       p += 1;
794     }
795
796   /* We need two more slots: one for the THIS pointer, and one for the
797      NULL [...] or void [end of arglist].  */
798
799   argtypes = (struct type **)
800     obstack_alloc (&TYPE_OBJFILE (type) -> type_obstack,
801                    (argcount+2) * sizeof (struct type *));
802   p = argtypetext;
803   argtypes[0] = lookup_pointer_type (type);
804   argcount = 1;
805
806   if (*p != ')')                        /* () means no args, skip while */
807     {
808       depth = 0;
809       while (*p)
810         {
811           if (depth <= 0 && (*p == ',' || *p == ')'))
812             {
813               argtypes[argcount] =
814                   parse_and_eval_type (argtypetext, p - argtypetext);
815               argcount += 1;
816               argtypetext = p + 1;
817             }
818
819           if (*p == '(')
820             {
821               depth += 1;
822             }
823           else if (*p == ')')
824             {
825               depth -= 1;
826             }
827
828           p += 1;
829         }
830     }
831
832   if (p[-2] != '.')                     /* Not '...' */
833     {
834       argtypes[argcount] = builtin_type_void;   /* List terminator */
835     }
836   else
837     {
838       argtypes[argcount] = NULL;                /* Ellist terminator */
839     }
840
841   free (demangled_name);
842
843   f = TYPE_FN_FIELDLIST1 (type, i);
844   TYPE_FN_FIELD_PHYSNAME (f, j) = mangled_name;
845
846   /* Now update the old "stub" type into a real type.  */
847   mtype = TYPE_FN_FIELD_TYPE (f, j);
848   TYPE_DOMAIN_TYPE (mtype) = type;
849   TYPE_ARG_TYPES (mtype) = argtypes;
850   TYPE_FLAGS (mtype) &= ~TYPE_FLAG_STUB;
851   TYPE_FN_FIELD_STUB (f, j) = 0;
852 }
853
854 const struct cplus_struct_type cplus_struct_default;
855
856 void
857 allocate_cplus_struct_type (type)
858      struct type *type;
859 {
860   if (!HAVE_CPLUS_STRUCT (type))
861     {
862       TYPE_CPLUS_SPECIFIC (type) = (struct cplus_struct_type *)
863         obstack_alloc (&current_objfile -> type_obstack,
864                        sizeof (struct cplus_struct_type));
865       *(TYPE_CPLUS_SPECIFIC(type)) = cplus_struct_default;
866     }
867 }
868
869 /* Helper function to initialize the standard scalar types.
870
871    If NAME is non-NULL and OBJFILE is non-NULL, then we make a copy
872    of the string pointed to by name in the type_obstack for that objfile,
873    and initialize the type name to that copy.  There are places (mipsread.c
874    in particular, where init_type is called with a NULL value for NAME). */
875
876 struct type *
877 init_type (code, length, flags, name, objfile)
878      enum type_code code;
879      int length;
880      int flags;
881      char *name;
882      struct objfile *objfile;
883 {
884   register struct type *type;
885
886   type = alloc_type (objfile);
887   TYPE_CODE (type) = code;
888   TYPE_LENGTH (type) = length;
889   TYPE_FLAGS (type) |= flags;
890   if ((name != NULL) && (objfile != NULL))
891     {
892       TYPE_NAME (type) =
893         obsavestring (name, strlen (name), &objfile -> type_obstack);
894     }
895   else
896     {
897       TYPE_NAME (type) = name;
898     }
899
900   /* C++ fancies.  */
901
902   if (code == TYPE_CODE_STRUCT || code == TYPE_CODE_UNION)
903     {
904       INIT_CPLUS_SPECIFIC (type);
905     }
906   return (type);
907 }
908
909 /* Look up a fundamental type for the specified objfile.
910    May need to construct such a type if this is the first use.
911
912    Some object file formats (ELF, COFF, etc) do not define fundamental
913    types such as "int" or "double".  Others (stabs for example), do
914    define fundamental types.
915
916    For the formats which don't provide fundamental types, gdb can create
917    such types, using defaults reasonable for the current target machine.
918
919    FIXME:  Some compilers distinguish explicitly signed integral types
920    (signed short, signed int, signed long) from "regular" integral types
921    (short, int, long) in the debugging information.  There is some dis-
922    agreement as to how useful this feature is.  In particular, gcc does
923    not support this.  Also, only some debugging formats allow the
924    distinction to be passed on to a debugger.  For now, we always just
925    use "short", "int", or "long" as the type name, for both the implicit
926    and explicitly signed types.  This also makes life easier for the
927    gdb test suite since we don't have to account for the differences
928    in output depending upon what the compiler and debugging format
929    support.  We will probably have to re-examine the issue when gdb
930    starts taking it's fundamental type information directly from the
931    debugging information supplied by the compiler.  [email protected] */
932
933 struct type *
934 lookup_fundamental_type (objfile, typeid)
935      struct objfile *objfile;
936      int typeid;
937 {
938   register struct type *type = NULL;
939   register struct type **typep;
940   register int nbytes;
941
942   if (typeid < 0 || typeid >= FT_NUM_MEMBERS)
943     {
944       error ("internal error - invalid fundamental type id %d", typeid);
945     }
946   else
947     {
948       /* If this is the first time we */
949       if (objfile -> fundamental_types == NULL)
950         {
951           nbytes = FT_NUM_MEMBERS * sizeof (struct type *);
952           objfile -> fundamental_types = (struct type **)
953             obstack_alloc (&objfile -> type_obstack, nbytes);
954           memset ((char *)objfile -> fundamental_types, 0, nbytes);
955         }
956       typep = objfile -> fundamental_types + typeid;
957       if ((type = *typep) == NULL)
958         {
959           switch (typeid)
960             {
961               default:
962                 error ("internal error: unhandled type id %d", typeid);
963                 break;
964               case FT_VOID:
965                 type = init_type (TYPE_CODE_VOID,
966                                   TARGET_CHAR_BIT / TARGET_CHAR_BIT,
967                                   0,
968                                   "void", objfile);
969                 break;
970               case FT_BOOLEAN:
971                 type = init_type (TYPE_CODE_INT,
972                                   TARGET_INT_BIT / TARGET_CHAR_BIT,
973                                   TYPE_FLAG_UNSIGNED,
974                                   "boolean", objfile);
975                 break;
976               case FT_STRING:
977                 type = init_type (TYPE_CODE_PASCAL_ARRAY,
978                                   TARGET_CHAR_BIT / TARGET_CHAR_BIT,
979                                   0,
980                                   "string", objfile);
981                 break;
982               case FT_CHAR:
983                 type = init_type (TYPE_CODE_INT,
984                                   TARGET_CHAR_BIT / TARGET_CHAR_BIT,
985                                   0,
986                                   "char", objfile);
987                 break;
988               case FT_SIGNED_CHAR:
989                 type = init_type (TYPE_CODE_INT,
990                                   TARGET_CHAR_BIT / TARGET_CHAR_BIT,
991                                   TYPE_FLAG_SIGNED,
992                                   "signed char", objfile);
993                 break;
994               case FT_UNSIGNED_CHAR:
995                 type = init_type (TYPE_CODE_INT,
996                                   TARGET_CHAR_BIT / TARGET_CHAR_BIT,
997                                   TYPE_FLAG_UNSIGNED,
998                                   "unsigned char", objfile);
999                 break;
1000               case FT_SHORT:
1001                 type = init_type (TYPE_CODE_INT,
1002                                   TARGET_SHORT_BIT / TARGET_CHAR_BIT,
1003                                   0,
1004                                   "short", objfile);
1005                 break;
1006               case FT_SIGNED_SHORT:
1007                 type = init_type (TYPE_CODE_INT,
1008                                   TARGET_SHORT_BIT / TARGET_CHAR_BIT,
1009                                   TYPE_FLAG_SIGNED,
1010                                   "short", objfile);    /* FIXME -fnf */
1011                 break;
1012               case FT_UNSIGNED_SHORT:
1013                 type = init_type (TYPE_CODE_INT,
1014                                   TARGET_SHORT_BIT / TARGET_CHAR_BIT,
1015                                   TYPE_FLAG_UNSIGNED,
1016                                   "unsigned short", objfile);
1017                 break;
1018               case FT_INTEGER:
1019                 type = init_type (TYPE_CODE_INT,
1020                                   TARGET_INT_BIT / TARGET_CHAR_BIT,
1021                                   0,
1022                                   "int", objfile);
1023                 break;
1024               case FT_SIGNED_INTEGER:
1025                 type = init_type (TYPE_CODE_INT,
1026                                   TARGET_INT_BIT / TARGET_CHAR_BIT,
1027                                   TYPE_FLAG_SIGNED,
1028                                   "int", objfile);      /* FIXME -fnf */
1029                 break;
1030               case FT_UNSIGNED_INTEGER:
1031                 type = init_type (TYPE_CODE_INT,
1032                                   TARGET_INT_BIT / TARGET_CHAR_BIT,
1033                                   TYPE_FLAG_UNSIGNED,
1034                                   "unsigned int", objfile);
1035                 break;
1036               case FT_FIXED_DECIMAL:
1037                 type = init_type (TYPE_CODE_INT,
1038                                   TARGET_INT_BIT / TARGET_CHAR_BIT,
1039                                   0,
1040                                   "fixed decimal", objfile);
1041                 break;
1042               case FT_LONG:
1043                 type = init_type (TYPE_CODE_INT,
1044                                   TARGET_LONG_BIT / TARGET_CHAR_BIT,
1045                                   0,
1046                                   "long", objfile);
1047                 break;
1048               case FT_SIGNED_LONG:
1049                 type = init_type (TYPE_CODE_INT,
1050                                   TARGET_LONG_BIT / TARGET_CHAR_BIT,
1051                                   TYPE_FLAG_SIGNED,
1052                                   "long", objfile);     /* FIXME -fnf */
1053                 break;
1054               case FT_UNSIGNED_LONG:
1055                 type = init_type (TYPE_CODE_INT,
1056                                   TARGET_LONG_BIT / TARGET_CHAR_BIT,
1057                                   TYPE_FLAG_UNSIGNED,
1058                                   "unsigned long", objfile);
1059                 break;
1060               case FT_LONG_LONG:
1061                 type = init_type (TYPE_CODE_INT,
1062                                   TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
1063                                   0,
1064                                   "long long", objfile);
1065                 break;
1066               case FT_SIGNED_LONG_LONG:
1067                 type = init_type (TYPE_CODE_INT,
1068                                   TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
1069                                   TYPE_FLAG_SIGNED,
1070                                   "signed long long", objfile);
1071                 break;
1072               case FT_UNSIGNED_LONG_LONG:
1073                 type = init_type (TYPE_CODE_INT,
1074                                   TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
1075                                   TYPE_FLAG_UNSIGNED,
1076                                   "unsigned long long", objfile);
1077                 break;
1078               case FT_FLOAT:
1079                 type = init_type (TYPE_CODE_FLT,
1080                                   TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
1081                                   0,
1082                                   "float", objfile);
1083                 break;
1084               case FT_DBL_PREC_FLOAT:
1085                 type = init_type (TYPE_CODE_FLT,
1086                                   TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
1087                                   0,
1088                                   "double", objfile);
1089                 break;
1090               case FT_FLOAT_DECIMAL:
1091                 type = init_type (TYPE_CODE_FLT,
1092                                   TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
1093                                   0,
1094                                   "floating decimal", objfile);
1095                 break;
1096               case FT_EXT_PREC_FLOAT:
1097                 type = init_type (TYPE_CODE_FLT,
1098                                   TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
1099                                   0,
1100                                   "long double", objfile);
1101                 break;
1102               case FT_COMPLEX:
1103                 type = init_type (TYPE_CODE_FLT,
1104                                   TARGET_COMPLEX_BIT / TARGET_CHAR_BIT,
1105                                   0,
1106                                   "complex", objfile);
1107                 break;
1108               case FT_DBL_PREC_COMPLEX:
1109                 type = init_type (TYPE_CODE_FLT,
1110                                   TARGET_DOUBLE_COMPLEX_BIT / TARGET_CHAR_BIT,
1111                                   0,
1112                                   "double complex", objfile);
1113                 break;
1114               case FT_EXT_PREC_COMPLEX:
1115                 type = init_type (TYPE_CODE_FLT,
1116                                   TARGET_DOUBLE_COMPLEX_BIT / TARGET_CHAR_BIT,
1117                                   0,
1118                                   "long double complex", objfile);
1119                 break;
1120             }
1121           /* Install the newly created type in the objfile's fundamental_types
1122              vector. */
1123           *typep = type;
1124         }
1125     }
1126   return (type);
1127 }
1128
1129 #if MAINTENANCE_CMDS
1130
1131 static void
1132 print_bit_vector (bits, nbits)
1133      B_TYPE *bits;
1134      int nbits;
1135 {
1136   int bitno;
1137
1138   for (bitno = 0; bitno < nbits; bitno++)
1139     {
1140       if ((bitno % 8) == 0)
1141         {
1142           puts_filtered (" ");
1143         }
1144       if (B_TST (bits, bitno))
1145         {
1146           printf_filtered ("1");
1147         }
1148       else
1149         {
1150           printf_filtered ("0");
1151         }
1152     }
1153 }
1154
1155 /* The args list is a strange beast.  It is either terminated by a NULL
1156    pointer for varargs functions, or by a pointer to a TYPE_CODE_VOID
1157    type for normal fixed argcount functions.  (FIXME someday)
1158    Also note the first arg should be the "this" pointer, we may not want to
1159    include it since we may get into a infinitely recursive situation. */
1160
1161 static void
1162 print_arg_types (args, spaces)
1163      struct type **args;
1164      int spaces;
1165 {
1166   if (args != NULL)
1167     {
1168       while (*args != NULL)
1169         {
1170           recursive_dump_type (*args, spaces + 2);
1171           if ((*args++) -> code == TYPE_CODE_VOID)
1172             {
1173               break;
1174             }
1175         }
1176     }
1177 }
1178
1179 static void
1180 dump_fn_fieldlists (type, spaces)
1181      struct type *type;
1182      int spaces;
1183 {
1184   int method_idx;
1185   int overload_idx;
1186   struct fn_field *f;
1187
1188   printfi_filtered (spaces, "fn_fieldlists 0x%x\n",
1189                     TYPE_FN_FIELDLISTS (type));
1190   for (method_idx = 0; method_idx < TYPE_NFN_FIELDS (type); method_idx++)
1191     {
1192       f = TYPE_FN_FIELDLIST1 (type, method_idx);
1193       printfi_filtered (spaces + 2, "[%d] name '%s' (0x%x) length %d\n",
1194                         method_idx,
1195                         TYPE_FN_FIELDLIST_NAME (type, method_idx),
1196                         TYPE_FN_FIELDLIST_NAME (type, method_idx),
1197                         TYPE_FN_FIELDLIST_LENGTH (type, method_idx));
1198       for (overload_idx = 0;
1199            overload_idx < TYPE_FN_FIELDLIST_LENGTH (type, method_idx);
1200            overload_idx++)
1201         {
1202           printfi_filtered (spaces + 4, "[%d] physname '%s' (0x%x)\n",
1203                             overload_idx,
1204                             TYPE_FN_FIELD_PHYSNAME (f, overload_idx),
1205                             TYPE_FN_FIELD_PHYSNAME (f, overload_idx));
1206           printfi_filtered (spaces + 8, "type 0x%x\n",
1207                             TYPE_FN_FIELD_TYPE (f, overload_idx));
1208           recursive_dump_type (TYPE_FN_FIELD_TYPE (f, overload_idx),
1209                                spaces + 8 + 2);
1210           printfi_filtered (spaces + 8, "args 0x%x\n",
1211                             TYPE_FN_FIELD_ARGS (f, overload_idx));
1212           print_arg_types (TYPE_FN_FIELD_ARGS (f, overload_idx), spaces);
1213           printfi_filtered (spaces + 8, "fcontext 0x%x\n",
1214                             TYPE_FN_FIELD_FCONTEXT (f, overload_idx));
1215           printfi_filtered (spaces + 8, "is_const %d\n",
1216                             TYPE_FN_FIELD_CONST (f, overload_idx));
1217           printfi_filtered (spaces + 8, "is_volatile %d\n",
1218                             TYPE_FN_FIELD_VOLATILE (f, overload_idx));
1219           printfi_filtered (spaces + 8, "is_private %d\n",
1220                             TYPE_FN_FIELD_PRIVATE (f, overload_idx));
1221           printfi_filtered (spaces + 8, "is_protected %d\n",
1222                             TYPE_FN_FIELD_PROTECTED (f, overload_idx));
1223           printfi_filtered (spaces + 8, "is_stub %d\n",
1224                             TYPE_FN_FIELD_STUB (f, overload_idx));
1225           printfi_filtered (spaces + 8, "voffset %d\n",
1226                             TYPE_FN_FIELD_VOFFSET (f, overload_idx));
1227         }
1228     }
1229 }
1230
1231 static void
1232 print_cplus_stuff (type, spaces)
1233      struct type *type;
1234      int spaces;
1235 {
1236   int bitno;
1237
1238   printfi_filtered (spaces, "cplus_stuff 0x%x\n",
1239                     TYPE_CPLUS_SPECIFIC (type));
1240   printfi_filtered (spaces, "n_baseclasses %d\n",
1241                     TYPE_N_BASECLASSES (type));
1242   printfi_filtered (spaces, "nfn_fields %d\n",
1243                     TYPE_NFN_FIELDS (type));
1244   printfi_filtered (spaces, "nfn_fields_total %d\n",
1245                     TYPE_NFN_FIELDS_TOTAL (type));
1246   if (TYPE_N_BASECLASSES (type) > 0)
1247     {
1248       printfi_filtered (spaces, "virtual_field_bits %d 0x%x",
1249                         TYPE_N_BASECLASSES (type),
1250                         TYPE_FIELD_VIRTUAL_BITS (type));
1251       print_bit_vector (TYPE_FIELD_VIRTUAL_BITS (type),
1252                         TYPE_N_BASECLASSES (type));
1253       puts_filtered ("\n");
1254     }
1255   if (TYPE_NFIELDS (type) > 0)
1256     {
1257       if (TYPE_FIELD_PRIVATE_BITS (type) != NULL)
1258         {
1259           printfi_filtered (spaces, "private_field_bits %d 0x%x",
1260                             TYPE_NFIELDS (type),
1261                             TYPE_FIELD_PRIVATE_BITS (type));
1262           print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type),
1263                             TYPE_NFIELDS (type));
1264           puts_filtered ("\n");
1265         }
1266       if (TYPE_FIELD_PROTECTED_BITS (type) != NULL)
1267         {
1268           printfi_filtered (spaces, "protected_field_bits %d 0x%x",
1269                             TYPE_NFIELDS (type),
1270                             TYPE_FIELD_PROTECTED_BITS (type));
1271           print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type),
1272                             TYPE_NFIELDS (type));
1273           puts_filtered ("\n");
1274         }
1275     }
1276   if (TYPE_NFN_FIELDS (type) > 0)
1277     {
1278       dump_fn_fieldlists (type, spaces);
1279     }
1280 }
1281
1282 void
1283 recursive_dump_type (type, spaces)
1284      struct type *type;
1285      int spaces;
1286 {
1287   int idx;
1288
1289   printfi_filtered (spaces, "type node 0x%x\n", type);
1290   printfi_filtered (spaces, "name '%s' (0x%x)\n", TYPE_NAME (type),
1291                     TYPE_NAME (type) ? TYPE_NAME (type) : "<NULL>");
1292   printfi_filtered (spaces, "code 0x%x ", TYPE_CODE (type));
1293   switch (TYPE_CODE (type))
1294     {
1295       case TYPE_CODE_UNDEF:
1296         printf_filtered ("(TYPE_CODE_UNDEF)");
1297         break;
1298       case TYPE_CODE_PTR:
1299         printf_filtered ("(TYPE_CODE_PTR)");
1300         break;
1301       case TYPE_CODE_ARRAY:
1302         printf_filtered ("(TYPE_CODE_ARRAY)");
1303         break;
1304       case TYPE_CODE_STRUCT:
1305         printf_filtered ("(TYPE_CODE_STRUCT)");
1306         break;
1307       case TYPE_CODE_UNION:
1308         printf_filtered ("(TYPE_CODE_UNION)");
1309         break;
1310       case TYPE_CODE_ENUM:
1311         printf_filtered ("(TYPE_CODE_ENUM)");
1312         break;
1313       case TYPE_CODE_FUNC:
1314         printf_filtered ("(TYPE_CODE_FUNC)");
1315         break;
1316       case TYPE_CODE_INT:
1317         printf_filtered ("(TYPE_CODE_INT)");
1318         break;
1319       case TYPE_CODE_FLT:
1320         printf_filtered ("(TYPE_CODE_FLT)");
1321         break;
1322       case TYPE_CODE_VOID:
1323         printf_filtered ("(TYPE_CODE_VOID)");
1324         break;
1325       case TYPE_CODE_SET:
1326         printf_filtered ("(TYPE_CODE_SET)");
1327         break;
1328       case TYPE_CODE_RANGE:
1329         printf_filtered ("(TYPE_CODE_RANGE)");
1330         break;
1331       case TYPE_CODE_PASCAL_ARRAY:
1332         printf_filtered ("(TYPE_CODE_PASCAL_ARRAY)");
1333         break;
1334       case TYPE_CODE_ERROR:
1335         printf_filtered ("(TYPE_CODE_ERROR)");
1336         break;
1337       case TYPE_CODE_MEMBER:
1338         printf_filtered ("(TYPE_CODE_MEMBER)");
1339         break;
1340       case TYPE_CODE_METHOD:
1341         printf_filtered ("(TYPE_CODE_METHOD)");
1342         break;
1343       case TYPE_CODE_REF:
1344         printf_filtered ("(TYPE_CODE_REF)");
1345         break;
1346       case TYPE_CODE_CHAR:
1347         printf_filtered ("(TYPE_CODE_CHAR)");
1348         break;
1349       case TYPE_CODE_BOOL:
1350         printf_filtered ("(TYPE_CODE_BOOL)");
1351         break;
1352       default:
1353         printf_filtered ("(UNKNOWN TYPE CODE)");
1354         break;
1355     }
1356   puts_filtered ("\n");
1357   printfi_filtered (spaces, "length %d\n", TYPE_LENGTH (type));
1358   printfi_filtered (spaces, "objfile 0x%x\n", TYPE_OBJFILE (type));
1359   printfi_filtered (spaces, "target_type 0x%x\n", TYPE_TARGET_TYPE (type));
1360   if (TYPE_TARGET_TYPE (type) != NULL)
1361     {
1362       recursive_dump_type (TYPE_TARGET_TYPE (type), spaces + 2);
1363     }
1364   printfi_filtered (spaces, "pointer_type 0x%x\n",
1365                     TYPE_POINTER_TYPE (type));
1366   printfi_filtered (spaces, "reference_type 0x%x\n",
1367                     TYPE_REFERENCE_TYPE (type));
1368   printfi_filtered (spaces, "function_type 0x%x\n",
1369                     TYPE_FUNCTION_TYPE (type));
1370   printfi_filtered (spaces, "flags 0x%x", TYPE_FLAGS (type));
1371   if (TYPE_FLAGS (type) & TYPE_FLAG_UNSIGNED)
1372     {
1373       puts_filtered (" TYPE_FLAG_UNSIGNED");
1374     }
1375   if (TYPE_FLAGS (type) & TYPE_FLAG_SIGNED)
1376     {
1377       puts_filtered (" TYPE_FLAG_SIGNED");
1378     }
1379   if (TYPE_FLAGS (type) & TYPE_FLAG_STUB)
1380     {
1381       puts_filtered (" TYPE_FLAG_STUB");
1382     }
1383   puts_filtered ("\n");
1384   printfi_filtered (spaces, "nfields %d 0x%x\n", TYPE_NFIELDS (type),
1385                     TYPE_FIELDS (type));
1386   for (idx = 0; idx < TYPE_NFIELDS (type); idx++)
1387     {
1388       printfi_filtered (spaces + 2,
1389                         "[%d] bitpos %d bitsize %d type 0x%x name '%s' (0x%x)\n",
1390                         idx, TYPE_FIELD_BITPOS (type, idx),
1391                         TYPE_FIELD_BITSIZE (type, idx),
1392                         TYPE_FIELD_TYPE (type, idx),
1393                         TYPE_FIELD_NAME (type, idx),
1394                         TYPE_FIELD_NAME (type, idx) != NULL
1395                           ? TYPE_FIELD_NAME (type, idx)
1396                           : "<NULL>");
1397       if (TYPE_FIELD_TYPE (type, idx) != NULL)
1398         {
1399           recursive_dump_type (TYPE_FIELD_TYPE (type, idx), spaces + 4);
1400         }
1401     }
1402   printfi_filtered (spaces, "vptr_basetype 0x%x\n",
1403                     TYPE_VPTR_BASETYPE (type));
1404   if (TYPE_VPTR_BASETYPE (type) != NULL)
1405     {
1406       recursive_dump_type (TYPE_VPTR_BASETYPE (type), spaces + 2);
1407     }
1408   printfi_filtered (spaces, "vptr_fieldno %d\n", TYPE_VPTR_FIELDNO (type));
1409   switch (TYPE_CODE (type))
1410     {
1411       case TYPE_CODE_METHOD:
1412       case TYPE_CODE_FUNC:
1413         printfi_filtered (spaces, "arg_types 0x%x\n", TYPE_ARG_TYPES (type));
1414         print_arg_types (TYPE_ARG_TYPES (type), spaces);
1415         break;
1416
1417       case TYPE_CODE_STRUCT:
1418         print_cplus_stuff (type, spaces);
1419         break;
1420     }
1421 }
1422
1423 #endif  /* MAINTENANCE_CMDS */
This page took 0.105312 seconds and 4 git commands to generate.