]> Git Repo - binutils.git/blob - gdb/c-typeprint.c
* Added sky-sanitized --with-sim-gpu2 option to match the one given to
[binutils.git] / gdb / c-typeprint.c
1 /* Support for printing C and C++ types for GDB, the GNU debugger.
2    Copyright 1986, 1988, 1989, 1991, 1993, 1994, 1995, 1996
3    Free Software Foundation, Inc.
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 "obstack.h"
23 #include "bfd.h"                /* Binary File Description */
24 #include "symtab.h"
25 #include "gdbtypes.h"
26 #include "expression.h"
27 #include "value.h"
28 #include "gdbcore.h"
29 #include "target.h"
30 #include "command.h"
31 #include "gdbcmd.h"
32 #include "language.h"
33 #include "demangle.h"
34 #include "c-lang.h"
35 #include "typeprint.h"
36
37 #include "gdb_string.h"
38 #include <errno.h>
39 #include <ctype.h>
40
41 static void
42 c_type_print_args PARAMS ((struct type *, GDB_FILE *));
43
44 static void
45 c_type_print_varspec_suffix PARAMS ((struct type *, GDB_FILE *, int, int, int));
46
47 static void
48 cp_type_print_derivation_info PARAMS ((GDB_FILE *, struct type *));
49
50 void
51 c_type_print_varspec_prefix PARAMS ((struct type *, GDB_FILE *, int, int));
52
53 \f
54 /* Print a description of a type in the format of a 
55    typedef for the current language.
56    NEW is the new name for a type TYPE. */
57
58 void
59 c_typedef_print (type, new, stream)
60    struct type *type;
61    struct symbol *new;
62    GDB_FILE *stream;
63 {
64   CHECK_TYPEDEF (type);
65    switch (current_language->la_language)
66    {
67 #ifdef _LANG_c
68    case language_c:
69    case language_cplus:
70       fprintf_filtered(stream, "typedef ");
71       type_print(type,"",stream,0);
72       if(TYPE_NAME ((SYMBOL_TYPE (new))) == 0
73          || !STREQ (TYPE_NAME ((SYMBOL_TYPE (new))), SYMBOL_NAME (new)))
74         fprintf_filtered(stream,  " %s", SYMBOL_SOURCE_NAME(new));
75       break;
76 #endif
77 #ifdef _LANG_m2
78    case language_m2:
79       fprintf_filtered(stream, "TYPE ");
80       if(!TYPE_NAME(SYMBOL_TYPE(new)) ||
81          !STREQ (TYPE_NAME(SYMBOL_TYPE(new)), SYMBOL_NAME(new)))
82         fprintf_filtered(stream, "%s = ", SYMBOL_SOURCE_NAME(new));
83       else
84          fprintf_filtered(stream, "<builtin> = ");
85       type_print(type,"",stream,0);
86       break;
87 #endif
88 #ifdef _LANG_chill
89    case language_chill:
90       fprintf_filtered(stream, "SYNMODE ");
91       if(!TYPE_NAME(SYMBOL_TYPE(new)) ||
92          !STREQ (TYPE_NAME(SYMBOL_TYPE(new)), SYMBOL_NAME(new)))
93         fprintf_filtered(stream, "%s = ", SYMBOL_SOURCE_NAME(new));
94       else
95          fprintf_filtered(stream, "<builtin> = ");
96       type_print(type,"",stream,0);
97       break;
98 #endif
99    default:
100       error("Language not supported.");
101    }
102    fprintf_filtered(stream, ";\n");
103 }
104
105
106 /* LEVEL is the depth to indent lines by.  */
107
108 void
109 c_print_type (type, varstring, stream, show, level)
110      struct type *type;
111      char *varstring;
112      GDB_FILE *stream;
113      int show;
114      int level;
115 {
116   register enum type_code code;
117   int demangled_args;
118
119   if (show > 0)
120     CHECK_TYPEDEF (type);
121
122   c_type_print_base (type, stream, show, level);
123   code = TYPE_CODE (type);
124   if ((varstring != NULL && *varstring != '\0')
125       ||
126       /* Need a space if going to print stars or brackets;
127          but not if we will print just a type name.  */
128       ((show > 0 || TYPE_NAME (type) == 0)
129        &&
130        (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC
131         || code == TYPE_CODE_METHOD
132         || code == TYPE_CODE_ARRAY
133         || code == TYPE_CODE_MEMBER
134         || code == TYPE_CODE_REF)))
135     fputs_filtered (" ", stream);
136   c_type_print_varspec_prefix (type, stream, show, 0);
137
138   fputs_filtered (varstring, stream);
139
140   /* For demangled function names, we have the arglist as part of the name,
141      so don't print an additional pair of ()'s */
142
143   demangled_args = strchr(varstring, '(') != NULL;
144   c_type_print_varspec_suffix (type, stream, show, 0, demangled_args);
145
146 }
147   
148 /* If TYPE is a derived type, then print out derivation information.
149    Print only the actual base classes of this type, not the base classes
150    of the base classes.  I.E.  for the derivation hierarchy:
151
152         class A { int a; };
153         class B : public A {int b; };
154         class C : public B {int c; };
155
156    Print the type of class C as:
157
158         class C : public B {
159                 int c;
160         }
161
162    Not as the following (like gdb used to), which is not legal C++ syntax for
163    derived types and may be confused with the multiple inheritance form:
164
165         class C : public B : public A {
166                 int c;
167         }
168
169    In general, gdb should try to print the types as closely as possible to
170    the form that they appear in the source code. */
171
172 static void
173 cp_type_print_derivation_info (stream, type)
174      GDB_FILE *stream;
175      struct type *type;
176 {
177   char *name;
178   int i;
179
180   for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
181     {
182       fputs_filtered (i == 0 ? ": " : ", ", stream);
183       fprintf_filtered (stream, "%s%s ",
184                         BASETYPE_VIA_PUBLIC (type, i) ? "public" : "private",
185                         BASETYPE_VIA_VIRTUAL(type, i) ? " virtual" : "");
186       name = type_name_no_tag (TYPE_BASECLASS (type, i));
187       fprintf_filtered (stream, "%s", name ? name : "(null)");
188     }
189   if (i > 0)
190     {
191       fputs_filtered (" ", stream);
192     }
193 }
194
195 /* Print any asterisks or open-parentheses needed before the
196    variable name (to describe its type).
197
198    On outermost call, pass 0 for PASSED_A_PTR.
199    On outermost call, SHOW > 0 means should ignore
200    any typename for TYPE and show its details.
201    SHOW is always zero on recursive calls.  */
202
203 void
204 c_type_print_varspec_prefix (type, stream, show, passed_a_ptr)
205      struct type *type;
206      GDB_FILE *stream;
207      int show;
208      int passed_a_ptr;
209 {
210   char *name;
211   if (type == 0)
212     return;
213
214   if (TYPE_NAME (type) && show <= 0)
215     return;
216
217   QUIT;
218
219   switch (TYPE_CODE (type))
220     {
221     case TYPE_CODE_PTR:
222       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
223       fprintf_filtered (stream, "*");
224       break;
225
226     case TYPE_CODE_MEMBER:
227       if (passed_a_ptr)
228         fprintf_filtered (stream, "(");
229       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
230       fprintf_filtered (stream, " ");
231       name = type_name_no_tag (TYPE_DOMAIN_TYPE (type));
232       if (name)
233         fputs_filtered (name, stream);
234       else
235         c_type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, passed_a_ptr);
236       fprintf_filtered (stream, "::");
237       break;
238
239     case TYPE_CODE_METHOD:
240       if (passed_a_ptr)
241         fprintf_filtered (stream, "(");
242       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
243       if (passed_a_ptr)
244         {
245           fprintf_filtered (stream, " ");
246           c_type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, passed_a_ptr);
247           fprintf_filtered (stream, "::");
248         }
249       break;
250
251     case TYPE_CODE_REF:
252       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
253       fprintf_filtered (stream, "&");
254       break;
255
256     case TYPE_CODE_FUNC:
257       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
258       if (passed_a_ptr)
259         fprintf_filtered (stream, "(");
260       break;
261
262     case TYPE_CODE_ARRAY:
263       c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
264       if (passed_a_ptr)
265         fprintf_filtered (stream, "(");
266       break;
267
268     case TYPE_CODE_UNDEF:
269     case TYPE_CODE_STRUCT:
270     case TYPE_CODE_UNION:
271     case TYPE_CODE_ENUM:
272     case TYPE_CODE_INT:
273     case TYPE_CODE_FLT:
274     case TYPE_CODE_VOID:
275     case TYPE_CODE_ERROR:
276     case TYPE_CODE_CHAR:
277     case TYPE_CODE_BOOL:
278     case TYPE_CODE_SET:
279     case TYPE_CODE_RANGE:
280     case TYPE_CODE_STRING:
281     case TYPE_CODE_BITSTRING:
282     case TYPE_CODE_COMPLEX:
283     case TYPE_CODE_TYPEDEF:
284       /* These types need no prefix.  They are listed here so that
285          gcc -Wall will reveal any types that haven't been handled.  */
286       break;
287     }
288 }
289
290 static void
291 c_type_print_args (type, stream)
292      struct type *type;
293      GDB_FILE *stream;
294 {
295   int i;
296   struct type **args;
297
298   fprintf_filtered (stream, "(");
299   args = TYPE_ARG_TYPES (type);
300   if (args != NULL)
301     {
302       if (args[1] == NULL)
303         {
304           fprintf_filtered (stream, "...");
305         }
306       else
307         {
308           for (i = 1;
309                args[i] != NULL && args[i]->code != TYPE_CODE_VOID;
310                i++)
311             {
312               c_print_type (args[i], "", stream, -1, 0);
313               if (args[i+1] == NULL)
314                 {
315                   fprintf_filtered (stream, "...");
316                 }
317               else if (args[i+1]->code != TYPE_CODE_VOID)
318                 {
319                   fprintf_filtered (stream, ",");
320                   wrap_here ("    ");
321                 }
322             }
323         }
324     }
325   fprintf_filtered (stream, ")");
326 }
327
328 /* Print any array sizes, function arguments or close parentheses
329    needed after the variable name (to describe its type).
330    Args work like c_type_print_varspec_prefix.  */
331
332 static void
333 c_type_print_varspec_suffix (type, stream, show, passed_a_ptr, demangled_args)
334      struct type *type;
335      GDB_FILE *stream;
336      int show;
337      int passed_a_ptr;
338      int demangled_args;
339 {
340   if (type == 0)
341     return;
342
343   if (TYPE_NAME (type) && show <= 0)
344     return;
345
346   QUIT;
347
348   switch (TYPE_CODE (type))
349     {
350     case TYPE_CODE_ARRAY:
351       if (passed_a_ptr)
352         fprintf_filtered (stream, ")");
353       
354       fprintf_filtered (stream, "[");
355       if (TYPE_LENGTH (type) >= 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
356           && TYPE_ARRAY_UPPER_BOUND_TYPE(type) != BOUND_CANNOT_BE_DETERMINED)
357         fprintf_filtered (stream, "%d",
358                           (TYPE_LENGTH (type)
359                            / TYPE_LENGTH (TYPE_TARGET_TYPE (type))));
360       fprintf_filtered (stream, "]");
361       
362       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
363       break;
364
365     case TYPE_CODE_MEMBER:
366       if (passed_a_ptr)
367         fprintf_filtered (stream, ")");
368       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
369       break;
370
371     case TYPE_CODE_METHOD:
372       if (passed_a_ptr)
373         fprintf_filtered (stream, ")");
374       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
375       if (passed_a_ptr)
376         {
377           c_type_print_args (type, stream);
378         }
379       break;
380
381     case TYPE_CODE_PTR:
382     case TYPE_CODE_REF:
383       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0);
384       break;
385
386     case TYPE_CODE_FUNC:
387       if (passed_a_ptr)
388         fprintf_filtered (stream, ")");
389       if (!demangled_args)
390         { int i, len = TYPE_NFIELDS (type);
391           fprintf_filtered (stream, "(");
392           for (i = 0; i < len; i++)
393             {
394               if (i > 0)
395                 {
396                   fputs_filtered (", ", stream);
397                   wrap_here ("    ");
398                 }
399               c_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0);
400             }
401           fprintf_filtered (stream, ")");
402         }
403       c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
404                                    passed_a_ptr, 0);
405       break;
406
407     case TYPE_CODE_UNDEF:
408     case TYPE_CODE_STRUCT:
409     case TYPE_CODE_UNION:
410     case TYPE_CODE_ENUM:
411     case TYPE_CODE_INT:
412     case TYPE_CODE_FLT:
413     case TYPE_CODE_VOID:
414     case TYPE_CODE_ERROR:
415     case TYPE_CODE_CHAR:
416     case TYPE_CODE_BOOL:
417     case TYPE_CODE_SET:
418     case TYPE_CODE_RANGE:
419     case TYPE_CODE_STRING:
420     case TYPE_CODE_BITSTRING:
421     case TYPE_CODE_COMPLEX:
422     case TYPE_CODE_TYPEDEF:
423       /* These types do not need a suffix.  They are listed so that
424          gcc -Wall will report types that may not have been considered.  */
425       break;
426     }
427 }
428
429 /* Print the name of the type (or the ultimate pointer target,
430    function value or array element), or the description of a
431    structure or union.
432
433    SHOW positive means print details about the type (e.g. enum values),
434    and print structure elements passing SHOW - 1 for show.
435    SHOW negative means just print the type name or struct tag if there is one.
436    If there is no name, print something sensible but concise like
437    "struct {...}".
438    SHOW zero means just print the type name or struct tag if there is one.
439    If there is no name, print something sensible but not as concise like
440    "struct {int x; int y;}".
441
442    LEVEL is the number of spaces to indent by.
443    We increase it for some recursive calls.  */
444
445 void
446 c_type_print_base (type, stream, show, level)
447      struct type *type;
448      GDB_FILE *stream;
449      int show;
450      int level;
451 {
452   register int i;
453   register int len;
454   register int lastval;
455   char *mangled_name;
456   char *demangled_name;
457   enum {s_none, s_public, s_private, s_protected} section_type;
458   QUIT;
459
460   wrap_here ("    ");
461   if (type == NULL)
462     {
463       fputs_filtered ("<type unknown>", stream);
464       return;
465     }
466
467   /* When SHOW is zero or less, and there is a valid type name, then always
468      just print the type name directly from the type.  */
469   /* If we have "typedef struct foo {. . .} bar;" do we want to print it
470      as "struct foo" or as "bar"?  Pick the latter, because C++ folk tend
471      to expect things like "class5 *foo" rather than "struct class5 *foo".  */
472
473   if (show <= 0
474       && TYPE_NAME (type) != NULL)
475     {
476       fputs_filtered (TYPE_NAME (type), stream);
477       return;
478     }
479
480   CHECK_TYPEDEF (type);
481           
482   switch (TYPE_CODE (type))
483     {
484     case TYPE_CODE_TYPEDEF:
485     case TYPE_CODE_ARRAY:
486     case TYPE_CODE_PTR:
487     case TYPE_CODE_MEMBER:
488     case TYPE_CODE_REF:
489     case TYPE_CODE_FUNC:
490     case TYPE_CODE_METHOD:
491       c_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
492       break;
493
494     case TYPE_CODE_STRUCT:
495       if (HAVE_CPLUS_STRUCT (type))
496         {
497           fprintf_filtered (stream, "class ");
498         }
499       else
500         {
501           fprintf_filtered (stream, "struct ");
502         }
503       goto struct_union;
504
505     case TYPE_CODE_UNION:
506       fprintf_filtered (stream, "union ");
507
508     struct_union:
509       if (TYPE_TAG_NAME (type) != NULL)
510         {
511           fputs_filtered (TYPE_TAG_NAME (type), stream);
512           if (show > 0)
513             fputs_filtered (" ", stream);
514         }
515       wrap_here ("    ");
516       if (show < 0)
517         {
518           /* If we just printed a tag name, no need to print anything else.  */
519           if (TYPE_TAG_NAME (type) == NULL)
520             fprintf_filtered (stream, "{...}");
521         }
522       else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
523         {
524           cp_type_print_derivation_info (stream, type);
525           
526           fprintf_filtered (stream, "{\n");
527           if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0))
528             {
529               if (TYPE_FLAGS (type) & TYPE_FLAG_STUB)
530                 fprintfi_filtered (level + 4, stream, "<incomplete type>\n");
531               else
532                 fprintfi_filtered (level + 4, stream, "<no data fields>\n");
533             }
534
535           /* Start off with no specific section type, so we can print
536              one for the first field we find, and use that section type
537              thereafter until we find another type. */
538
539           section_type = s_none;
540
541           /* If there is a base class for this type,
542              do not print the field that it occupies.  */
543
544           len = TYPE_NFIELDS (type);
545           for (i = TYPE_N_BASECLASSES (type); i < len; i++)
546             {
547               QUIT;
548               /* Don't print out virtual function table.  */
549               if (STREQN (TYPE_FIELD_NAME (type, i), "_vptr", 5)
550                   && is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5]))
551                 continue;
552
553               /* If this is a C++ class we can print the various C++ section
554                  labels. */
555
556               if (HAVE_CPLUS_STRUCT (type))
557                 {
558                   if (TYPE_FIELD_PROTECTED (type, i))
559                     {
560                       if (section_type != s_protected)
561                         {
562                           section_type = s_protected;
563                           fprintfi_filtered (level + 2, stream,
564                                              "protected:\n");
565                         }
566                     }
567                   else if (TYPE_FIELD_PRIVATE (type, i))
568                     {
569                       if (section_type != s_private)
570                         {
571                           section_type = s_private;
572                           fprintfi_filtered (level + 2, stream, "private:\n");
573                         }
574                     }
575                   else
576                     {
577                       if (section_type != s_public)
578                         {
579                           section_type = s_public;
580                           fprintfi_filtered (level + 2, stream, "public:\n");
581                         }
582                     }
583                 }
584
585               print_spaces_filtered (level + 4, stream);
586               if (TYPE_FIELD_STATIC (type, i))
587                 {
588                   fprintf_filtered (stream, "static ");
589                 }
590               c_print_type (TYPE_FIELD_TYPE (type, i),
591                             TYPE_FIELD_NAME (type, i),
592                             stream, show - 1, level + 4);
593               if (!TYPE_FIELD_STATIC (type, i)
594                   && TYPE_FIELD_PACKED (type, i))
595                 {
596                   /* It is a bitfield.  This code does not attempt
597                      to look at the bitpos and reconstruct filler,
598                      unnamed fields.  This would lead to misleading
599                      results if the compiler does not put out fields
600                      for such things (I don't know what it does).  */
601                   fprintf_filtered (stream, " : %d",
602                                     TYPE_FIELD_BITSIZE (type, i));
603                 }
604               fprintf_filtered (stream, ";\n");
605             }
606
607           /* If there are both fields and methods, put a space between. */
608           len = TYPE_NFN_FIELDS (type);
609           if (len && section_type != s_none)
610              fprintf_filtered (stream, "\n");
611
612           /* C++: print out the methods */
613
614           for (i = 0; i < len; i++)
615             {
616               struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
617               int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
618               char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
619               char *name = type_name_no_tag (type);
620               int is_constructor = name && STREQ(method_name, name);
621               for (j = 0; j < len2; j++)
622                 {
623                   char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
624                   int is_full_physname_constructor = 
625                     ((physname[0] == '_' && physname[1] == '_'
626                       && strchr ("0123456789Qt", physname[2]))
627                      || STREQN (physname, "__ct__", 6)
628                      || DESTRUCTOR_PREFIX_P (physname)
629                      || STREQN (physname, "__dt__", 6));
630
631                   QUIT;
632                   if (TYPE_FN_FIELD_PROTECTED (f, j))
633                     {
634                       if (section_type != s_protected)
635                         {
636                           section_type = s_protected;
637                           fprintfi_filtered (level + 2, stream,
638                                              "protected:\n");
639                         }
640                     }
641                   else if (TYPE_FN_FIELD_PRIVATE (f, j))
642                     {
643                       if (section_type != s_private)
644                         {
645                           section_type = s_private;
646                           fprintfi_filtered (level + 2, stream, "private:\n");
647                         }
648                     }
649                   else
650                     {
651                       if (section_type != s_public)
652                         {
653                           section_type = s_public;
654                           fprintfi_filtered (level + 2, stream, "public:\n");
655                         }
656                     }
657
658                   print_spaces_filtered (level + 4, stream);
659                   if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
660                     fprintf_filtered (stream, "virtual ");
661                   else if (TYPE_FN_FIELD_STATIC_P (f, j))
662                     fprintf_filtered (stream, "static ");
663                   if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0)
664                     {
665                       /* Keep GDB from crashing here.  */
666                       fprintf_filtered (stream, "<undefined type> %s;\n",
667                                TYPE_FN_FIELD_PHYSNAME (f, j));
668                       break;
669                     }
670                   else if (!is_constructor && !is_full_physname_constructor)
671                     {
672                       type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)),
673                                   "", stream, -1);
674                       fputs_filtered (" ", stream);
675                     }
676                   if (TYPE_FN_FIELD_STUB (f, j))
677                     /* Build something we can demangle.  */
678                     mangled_name = gdb_mangle_name (type, i, j);
679                   else
680                     mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j);
681
682                   demangled_name =
683                     cplus_demangle (mangled_name,
684                                     DMGL_ANSI | DMGL_PARAMS);
685                   if (demangled_name == NULL)
686                     fprintf_filtered (stream, "<badly mangled name '%s'>",
687                                       mangled_name);
688                   else
689                     {
690                       char *demangled_no_class =
691                         strchr (demangled_name, ':');
692
693                       if (demangled_no_class == NULL)
694                         demangled_no_class = demangled_name;
695                       else
696                         {
697                           if (*++demangled_no_class == ':')
698                             ++demangled_no_class;
699                         }
700                       fputs_filtered (demangled_no_class, stream);
701                       free (demangled_name);
702                     }
703
704                   if (TYPE_FN_FIELD_STUB (f, j))
705                     free (mangled_name);
706
707                   fprintf_filtered (stream, ";\n");
708                 }
709             }
710
711           fprintfi_filtered (level, stream, "}");
712         }
713       break;
714
715     case TYPE_CODE_ENUM:
716       fprintf_filtered (stream, "enum ");
717       if (TYPE_TAG_NAME (type) != NULL)
718         {
719           fputs_filtered (TYPE_TAG_NAME (type), stream);
720           if (show > 0)
721             fputs_filtered (" ", stream);
722         }
723
724       wrap_here ("    ");
725       if (show < 0)
726         {
727           /* If we just printed a tag name, no need to print anything else.  */
728           if (TYPE_TAG_NAME (type) == NULL)
729             fprintf_filtered (stream, "{...}");
730         }
731       else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
732         {
733           fprintf_filtered (stream, "{");
734           len = TYPE_NFIELDS (type);
735           lastval = 0;
736           for (i = 0; i < len; i++)
737             {
738               QUIT;
739               if (i) fprintf_filtered (stream, ", ");
740               wrap_here ("    ");
741               fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
742               if (lastval != TYPE_FIELD_BITPOS (type, i))
743                 {
744                   fprintf_filtered (stream, " = %d", TYPE_FIELD_BITPOS (type, i));
745                   lastval = TYPE_FIELD_BITPOS (type, i);
746                 }
747               lastval++;
748             }
749           fprintf_filtered (stream, "}");
750         }
751       break;
752
753     case TYPE_CODE_VOID:
754       fprintf_filtered (stream, "void");
755       break;
756
757     case TYPE_CODE_UNDEF:
758       fprintf_filtered (stream, "struct <unknown>");
759       break;
760
761     case TYPE_CODE_ERROR:
762       fprintf_filtered (stream, "<unknown type>");
763       break;
764
765     case TYPE_CODE_RANGE:
766       /* This should not occur */
767       fprintf_filtered (stream, "<range type>");
768       break;
769
770     default:
771       /* Handle types not explicitly handled by the other cases,
772          such as fundamental types.  For these, just print whatever
773          the type name is, as recorded in the type itself.  If there
774          is no type name, then complain. */
775       if (TYPE_NAME (type) != NULL)
776         {
777           fputs_filtered (TYPE_NAME (type), stream);
778         }
779       else
780         {
781           /* At least for dump_symtab, it is important that this not be
782              an error ().  */
783           fprintf_filtered (stream, "<invalid type code %d>",
784                             TYPE_CODE (type));
785         }
786       break;
787     }
788 }
789
This page took 0.068327 seconds and 4 git commands to generate.