1 /* Support for printing C and C++ types for GDB, the GNU debugger.
2 Copyright 1986, 1988, 1989, 1991, 1993, 1994, 1995, 1996, 1998, 1999
3 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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. */
23 #include "bfd.h" /* Binary File Description */
26 #include "expression.h"
35 #include "typeprint.h"
37 #include "gdb_string.h"
41 /* Flag indicating target was compiled by HP compiler */
42 extern int hp_som_som_object_present;
45 c_type_print_args PARAMS ((struct type *, GDB_FILE *));
48 cp_type_print_derivation_info PARAMS ((GDB_FILE *, struct type *));
51 c_type_print_varspec_prefix PARAMS ((struct type *, GDB_FILE *, int, int));
54 c_type_print_cv_qualifier PARAMS ((struct type *, GDB_FILE *, int, int));
58 /* Print a description of a type in the format of a
59 typedef for the current language.
60 NEW is the new name for a type TYPE. */
63 c_typedef_print (type, new, stream)
69 switch (current_language->la_language)
74 fprintf_filtered(stream, "typedef ");
75 type_print(type,"",stream,0);
76 if(TYPE_NAME ((SYMBOL_TYPE (new))) == 0
77 || !STREQ (TYPE_NAME ((SYMBOL_TYPE (new))), SYMBOL_NAME (new)))
78 fprintf_filtered(stream, " %s", SYMBOL_SOURCE_NAME(new));
83 fprintf_filtered(stream, "TYPE ");
84 if(!TYPE_NAME(SYMBOL_TYPE(new)) ||
85 !STREQ (TYPE_NAME(SYMBOL_TYPE(new)), SYMBOL_NAME(new)))
86 fprintf_filtered(stream, "%s = ", SYMBOL_SOURCE_NAME(new));
88 fprintf_filtered(stream, "<builtin> = ");
89 type_print(type,"",stream,0);
94 fprintf_filtered(stream, "SYNMODE ");
95 if(!TYPE_NAME(SYMBOL_TYPE(new)) ||
96 !STREQ (TYPE_NAME(SYMBOL_TYPE(new)), SYMBOL_NAME(new)))
97 fprintf_filtered(stream, "%s = ", SYMBOL_SOURCE_NAME(new));
99 fprintf_filtered(stream, "<builtin> = ");
100 type_print(type,"",stream,0);
104 error("Language not supported.");
106 fprintf_filtered(stream, ";\n");
110 /* LEVEL is the depth to indent lines by. */
113 c_print_type (type, varstring, stream, show, level)
120 register enum type_code code;
124 CHECK_TYPEDEF (type);
126 c_type_print_base (type, stream, show, level);
127 code = TYPE_CODE (type);
128 if ((varstring != NULL && *varstring != '\0')
130 /* Need a space if going to print stars or brackets;
131 but not if we will print just a type name. */
132 ((show > 0 || TYPE_NAME (type) == 0)
134 (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC
135 || code == TYPE_CODE_METHOD
136 || code == TYPE_CODE_ARRAY
137 || code == TYPE_CODE_MEMBER
138 || code == TYPE_CODE_REF)))
139 fputs_filtered (" ", stream);
140 c_type_print_varspec_prefix (type, stream, show, 0);
142 if (varstring != NULL)
144 fputs_filtered (varstring, stream);
146 /* For demangled function names, we have the arglist as part of the name,
147 so don't print an additional pair of ()'s */
149 demangled_args = strchr(varstring, '(') != NULL;
150 c_type_print_varspec_suffix (type, stream, show, 0, demangled_args);
154 /* If TYPE is a derived type, then print out derivation information.
155 Print only the actual base classes of this type, not the base classes
156 of the base classes. I.E. for the derivation hierarchy:
159 class B : public A {int b; };
160 class C : public B {int c; };
162 Print the type of class C as:
168 Not as the following (like gdb used to), which is not legal C++ syntax for
169 derived types and may be confused with the multiple inheritance form:
171 class C : public B : public A {
175 In general, gdb should try to print the types as closely as possible to
176 the form that they appear in the source code.
177 Note that in case of protected derivation gcc will not say 'protected'
178 but 'private'. The HP's aCC compiler emits specific information for
179 derivation via protected inheritance, so gdb can print it out */
182 cp_type_print_derivation_info (stream, type)
189 for (i = 0; i < TYPE_N_BASECLASSES (type); i++)
191 fputs_filtered (i == 0 ? ": " : ", ", stream);
192 fprintf_filtered (stream, "%s%s ",
193 BASETYPE_VIA_PUBLIC (type, i) ? "public"
194 : (TYPE_FIELD_PROTECTED (type, i) ? "protected" : "private"),
195 BASETYPE_VIA_VIRTUAL(type, i) ? " virtual" : "");
196 name = type_name_no_tag (TYPE_BASECLASS (type, i));
197 fprintf_filtered (stream, "%s", name ? name : "(null)");
201 fputs_filtered (" ", stream);
204 /* Print the C++ method arguments ARGS to the file STREAM. */
207 cp_type_print_method_args (args, prefix, varstring, staticp, stream)
216 fprintf_symbol_filtered (stream, prefix, language_cplus, DMGL_ANSI);
217 fprintf_symbol_filtered (stream, varstring, language_cplus, DMGL_ANSI);
218 fputs_filtered ("(", stream);
219 if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID)
221 i = !staticp; /* skip the class variable */
224 type_print (args[i++], "", stream, 0);
227 fprintf_filtered (stream, " ...");
230 else if (args[i]->code != TYPE_CODE_VOID)
232 fprintf_filtered (stream, ", ");
237 else if (current_language->la_language == language_cplus)
239 fprintf_filtered (stream, "void");
242 fprintf_filtered (stream, ")");
246 /* Print any asterisks or open-parentheses needed before the
247 variable name (to describe its type).
249 On outermost call, pass 0 for PASSED_A_PTR.
250 On outermost call, SHOW > 0 means should ignore
251 any typename for TYPE and show its details.
252 SHOW is always zero on recursive calls. */
255 c_type_print_varspec_prefix (type, stream, show, passed_a_ptr)
265 if (TYPE_NAME (type) && show <= 0)
270 switch (TYPE_CODE (type))
273 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
274 fprintf_filtered (stream, "*");
275 c_type_print_cv_qualifier (type, stream, 1, 0);
278 case TYPE_CODE_MEMBER:
280 fprintf_filtered (stream, "(");
281 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
282 fprintf_filtered (stream, " ");
283 name = type_name_no_tag (TYPE_DOMAIN_TYPE (type));
285 fputs_filtered (name, stream);
287 c_type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, passed_a_ptr);
288 fprintf_filtered (stream, "::");
291 case TYPE_CODE_METHOD:
293 fprintf_filtered (stream, "(");
294 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
297 fprintf_filtered (stream, " ");
298 c_type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, passed_a_ptr);
299 fprintf_filtered (stream, "::");
304 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
305 fprintf_filtered (stream, "&");
306 c_type_print_cv_qualifier (type, stream, 1, 0);
310 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
312 fprintf_filtered (stream, "(");
315 case TYPE_CODE_ARRAY:
316 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0);
318 fprintf_filtered (stream, "(");
321 case TYPE_CODE_UNDEF:
322 case TYPE_CODE_STRUCT:
323 case TYPE_CODE_UNION:
328 case TYPE_CODE_ERROR:
332 case TYPE_CODE_RANGE:
333 case TYPE_CODE_STRING:
334 case TYPE_CODE_BITSTRING:
335 case TYPE_CODE_COMPLEX:
336 case TYPE_CODE_TYPEDEF:
337 /* These types need no prefix. They are listed here so that
338 gcc -Wall will reveal any types that haven't been handled. */
343 /* Print out "const" and "volatile" attributes.
344 TYPE is a pointer to the type being printed out.
345 STREAM is the output destination.
346 NEED_SPACE = 1 indicates an initial white space is needed */
349 c_type_print_cv_qualifier (type, stream, need_pre_space, need_post_space)
357 if (TYPE_CONST (type))
360 fprintf_filtered (stream, " ");
361 fprintf_filtered (stream, "const");
365 if (TYPE_VOLATILE (type))
367 if (flag || need_pre_space)
368 fprintf_filtered (stream, " ");
369 fprintf_filtered (stream, "volatile");
373 if (flag && need_post_space)
374 fprintf_filtered (stream, " ");
381 c_type_print_args (type, stream)
388 fprintf_filtered (stream, "(");
389 args = TYPE_ARG_TYPES (type);
394 fprintf_filtered (stream, "...");
396 else if ((args[1]->code == TYPE_CODE_VOID) &&
397 (current_language->la_language == language_cplus))
399 fprintf_filtered (stream, "void");
404 args[i] != NULL && args[i]->code != TYPE_CODE_VOID;
407 c_print_type (args[i], "", stream, -1, 0);
408 if (args[i+1] == NULL)
410 fprintf_filtered (stream, "...");
412 else if (args[i+1]->code != TYPE_CODE_VOID)
414 fprintf_filtered (stream, ",");
420 else if (current_language->la_language == language_cplus)
422 fprintf_filtered (stream, "void");
425 fprintf_filtered (stream, ")");
428 /* Print any array sizes, function arguments or close parentheses
429 needed after the variable name (to describe its type).
430 Args work like c_type_print_varspec_prefix. */
433 c_type_print_varspec_suffix (type, stream, show, passed_a_ptr, demangled_args)
443 if (TYPE_NAME (type) && show <= 0)
448 switch (TYPE_CODE (type))
450 case TYPE_CODE_ARRAY:
452 fprintf_filtered (stream, ")");
454 fprintf_filtered (stream, "[");
455 if (TYPE_LENGTH (type) >= 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
456 && TYPE_ARRAY_UPPER_BOUND_TYPE(type) != BOUND_CANNOT_BE_DETERMINED)
457 fprintf_filtered (stream, "%d",
459 / TYPE_LENGTH (TYPE_TARGET_TYPE (type))));
460 fprintf_filtered (stream, "]");
462 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
465 case TYPE_CODE_MEMBER:
467 fprintf_filtered (stream, ")");
468 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
471 case TYPE_CODE_METHOD:
473 fprintf_filtered (stream, ")");
474 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0);
477 c_type_print_args (type, stream);
483 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0);
488 fprintf_filtered (stream, ")");
490 { int i, len = TYPE_NFIELDS (type);
491 fprintf_filtered (stream, "(");
492 if ((len == 0) && (current_language->la_language == language_cplus))
494 fprintf_filtered (stream, "void");
497 for (i = 0; i < len; i++)
501 fputs_filtered (", ", stream);
504 c_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0);
506 fprintf_filtered (stream, ")");
508 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
512 case TYPE_CODE_UNDEF:
513 case TYPE_CODE_STRUCT:
514 case TYPE_CODE_UNION:
519 case TYPE_CODE_ERROR:
523 case TYPE_CODE_RANGE:
524 case TYPE_CODE_STRING:
525 case TYPE_CODE_BITSTRING:
526 case TYPE_CODE_COMPLEX:
527 case TYPE_CODE_TYPEDEF:
528 /* These types do not need a suffix. They are listed so that
529 gcc -Wall will report types that may not have been considered. */
534 /* Print the name of the type (or the ultimate pointer target,
535 function value or array element), or the description of a
538 SHOW positive means print details about the type (e.g. enum values),
539 and print structure elements passing SHOW - 1 for show.
540 SHOW negative means just print the type name or struct tag if there is one.
541 If there is no name, print something sensible but concise like
543 SHOW zero means just print the type name or struct tag if there is one.
544 If there is no name, print something sensible but not as concise like
545 "struct {int x; int y;}".
547 LEVEL is the number of spaces to indent by.
548 We increase it for some recursive calls. */
551 c_type_print_base (type, stream, show, level)
559 register int lastval;
561 char *demangled_name;
562 char *demangled_no_static;
563 enum {s_none, s_public, s_private, s_protected} section_type;
564 int need_access_label = 0;
572 fputs_filtered ("<type unknown>", stream);
576 /* When SHOW is zero or less, and there is a valid type name, then always
577 just print the type name directly from the type. */
578 /* If we have "typedef struct foo {. . .} bar;" do we want to print it
579 as "struct foo" or as "bar"? Pick the latter, because C++ folk tend
580 to expect things like "class5 *foo" rather than "struct class5 *foo". */
583 && TYPE_NAME (type) != NULL)
585 c_type_print_cv_qualifier (type, stream, 0, 1);
586 fputs_filtered (TYPE_NAME (type), stream);
590 CHECK_TYPEDEF (type);
592 switch (TYPE_CODE (type))
594 case TYPE_CODE_TYPEDEF:
595 case TYPE_CODE_ARRAY:
597 case TYPE_CODE_MEMBER:
600 case TYPE_CODE_METHOD:
601 c_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
604 case TYPE_CODE_STRUCT:
605 c_type_print_cv_qualifier (type, stream, 0, 1);
606 /* Note TYPE_CODE_STRUCT and TYPE_CODE_CLASS have the same value,
607 * so we use another means for distinguishing them.
609 if (HAVE_CPLUS_STRUCT (type)) {
610 switch (TYPE_DECLARED_TYPE(type)) {
611 case DECLARED_TYPE_CLASS:
612 fprintf_filtered (stream, "class ");
614 case DECLARED_TYPE_UNION:
615 fprintf_filtered (stream, "union ");
617 case DECLARED_TYPE_STRUCT:
618 fprintf_filtered (stream, "struct ");
621 /* If there is a CPLUS_STRUCT, assume class if not
622 * otherwise specified in the declared_type field.
624 fprintf_filtered (stream, "class ");
628 /* If not CPLUS_STRUCT, then assume it's a C struct */
629 fprintf_filtered (stream, "struct ");
633 case TYPE_CODE_UNION:
634 c_type_print_cv_qualifier (type, stream, 0, 1);
635 fprintf_filtered (stream, "union ");
639 /* Print the tag if it exists.
640 * The HP aCC compiler emits
641 * a spurious "{unnamed struct}"/"{unnamed union}"/"{unnamed enum}"
642 * tag for unnamed struct/union/enum's, which we don't
645 if (TYPE_TAG_NAME (type) != NULL &&
646 strncmp(TYPE_TAG_NAME(type), "{unnamed", 8))
648 fputs_filtered (TYPE_TAG_NAME (type), stream);
650 fputs_filtered (" ", stream);
655 /* If we just printed a tag name, no need to print anything else. */
656 if (TYPE_TAG_NAME (type) == NULL)
657 fprintf_filtered (stream, "{...}");
659 else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
661 cp_type_print_derivation_info (stream, type);
663 fprintf_filtered (stream, "{\n");
664 if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0))
666 if (TYPE_FLAGS (type) & TYPE_FLAG_STUB)
667 fprintfi_filtered (level + 4, stream, "<incomplete type>\n");
669 fprintfi_filtered (level + 4, stream, "<no data fields>\n");
672 /* Start off with no specific section type, so we can print
673 one for the first field we find, and use that section type
674 thereafter until we find another type. */
676 section_type = s_none;
678 /* For a class, if all members are private, there's no need
679 for a "private:" label; similarly, for a struct or union
680 masquerading as a class, if all members are public, there's
681 no need for a "public:" label. */
683 if ((TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_CLASS) ||
684 (TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_TEMPLATE))
687 len = TYPE_NFIELDS (type);
688 for (i = TYPE_N_BASECLASSES (type); i < len; i++)
689 if (!TYPE_FIELD_PRIVATE (type, i))
691 need_access_label = 1;
695 if (!need_access_label)
697 len2 = TYPE_NFN_FIELDS (type);
698 for (j = 0; j < len2; j++)
700 len = TYPE_FN_FIELDLIST_LENGTH (type, j);
701 for (i = 0; i < len; i++)
702 if (!TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type, j), i))
704 need_access_label = 1;
707 if (need_access_label)
712 else if ((TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_STRUCT) ||
713 (TYPE_DECLARED_TYPE (type) == DECLARED_TYPE_UNION))
716 len = TYPE_NFIELDS (type);
717 for (i = TYPE_N_BASECLASSES (type); i < len; i++)
718 if (TYPE_FIELD_PRIVATE (type, i) || TYPE_FIELD_PROTECTED (type, i))
720 need_access_label = 1;
724 if (!need_access_label)
726 len2 = TYPE_NFN_FIELDS (type);
727 for (j = 0; j < len2; j++)
730 len = TYPE_FN_FIELDLIST_LENGTH (type, j);
731 for (i = 0; i < len; i++)
732 if (TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type, j), i) ||
733 TYPE_FN_FIELD_PROTECTED (TYPE_FN_FIELDLIST1 (type, j), i))
735 need_access_label = 1;
738 if (need_access_label)
744 /* If there is a base class for this type,
745 do not print the field that it occupies. */
747 len = TYPE_NFIELDS (type);
748 for (i = TYPE_N_BASECLASSES (type); i < len; i++)
751 /* Don't print out virtual function table. */
752 /* HP ANSI C++ case */
753 if (TYPE_HAS_VTABLE(type) && (STREQN (TYPE_FIELD_NAME (type, i), "__vfp", 5)))
755 /* Other compilers */
756 /* pai:: FIXME : check for has_vtable < 0 */
757 if (STREQN (TYPE_FIELD_NAME (type, i), "_vptr", 5)
758 && is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5]))
761 /* If this is a C++ class we can print the various C++ section
764 if (HAVE_CPLUS_STRUCT (type) && need_access_label)
766 if (TYPE_FIELD_PROTECTED (type, i))
768 if (section_type != s_protected)
770 section_type = s_protected;
771 fprintfi_filtered (level + 2, stream,
775 else if (TYPE_FIELD_PRIVATE (type, i))
777 if (section_type != s_private)
779 section_type = s_private;
780 fprintfi_filtered (level + 2, stream, "private:\n");
785 if (section_type != s_public)
787 section_type = s_public;
788 fprintfi_filtered (level + 2, stream, "public:\n");
793 print_spaces_filtered (level + 4, stream);
794 if (TYPE_FIELD_STATIC (type, i))
796 fprintf_filtered (stream, "static ");
798 c_print_type (TYPE_FIELD_TYPE (type, i),
799 TYPE_FIELD_NAME (type, i),
800 stream, show - 1, level + 4);
801 if (!TYPE_FIELD_STATIC (type, i)
802 && TYPE_FIELD_PACKED (type, i))
804 /* It is a bitfield. This code does not attempt
805 to look at the bitpos and reconstruct filler,
806 unnamed fields. This would lead to misleading
807 results if the compiler does not put out fields
808 for such things (I don't know what it does). */
809 fprintf_filtered (stream, " : %d",
810 TYPE_FIELD_BITSIZE (type, i));
812 fprintf_filtered (stream, ";\n");
815 /* If there are both fields and methods, put a space between. */
816 len = TYPE_NFN_FIELDS (type);
817 if (len && section_type != s_none)
818 fprintf_filtered (stream, "\n");
820 /* C++: print out the methods */
821 for (i = 0; i < len; i++)
823 struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
824 int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
825 char *method_name = TYPE_FN_FIELDLIST_NAME (type, i);
826 char *name = type_name_no_tag (type);
827 int is_constructor = name && STREQ(method_name, name);
828 for (j = 0; j < len2; j++)
830 char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
831 int is_full_physname_constructor =
832 ((physname[0] == '_' && physname[1] == '_'
833 && strchr ("0123456789Qt", physname[2]))
834 || STREQN (physname, "__ct__", 6)
835 || DESTRUCTOR_PREFIX_P (physname)
836 || STREQN (physname, "__dt__", 6));
839 if (TYPE_FN_FIELD_PROTECTED (f, j))
841 if (section_type != s_protected)
843 section_type = s_protected;
844 fprintfi_filtered (level + 2, stream,
848 else if (TYPE_FN_FIELD_PRIVATE (f, j))
850 if (section_type != s_private)
852 section_type = s_private;
853 fprintfi_filtered (level + 2, stream, "private:\n");
858 if (section_type != s_public)
860 section_type = s_public;
861 fprintfi_filtered (level + 2, stream, "public:\n");
865 print_spaces_filtered (level + 4, stream);
866 if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
867 fprintf_filtered (stream, "virtual ");
868 else if (TYPE_FN_FIELD_STATIC_P (f, j))
869 fprintf_filtered (stream, "static ");
870 if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0)
872 /* Keep GDB from crashing here. */
873 fprintf_filtered (stream, "<undefined type> %s;\n",
874 TYPE_FN_FIELD_PHYSNAME (f, j));
877 else if (!is_constructor && /* constructors don't have declared types */
878 !is_full_physname_constructor && /* " " */
879 !strstr (method_name, "operator ")) /* Not a type conversion operator */
880 /* (note space -- other operators don't have it) */
882 type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)),
884 fputs_filtered (" ", stream);
886 if (TYPE_FN_FIELD_STUB (f, j))
887 /* Build something we can demangle. */
888 mangled_name = gdb_mangle_name (type, i, j);
890 mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j);
893 cplus_demangle (mangled_name,
894 DMGL_ANSI | DMGL_PARAMS);
895 if (demangled_name == NULL)
897 /* in some cases (for instance with the HP demangling),
898 if a function has more than 10 arguments,
899 the demangling will fail.
900 Let's try to reconstruct the function signature from
901 the symbol information */
902 if (!TYPE_FN_FIELD_STUB (f, j))
903 cp_type_print_method_args (TYPE_FN_FIELD_ARGS (f, j), "",
905 TYPE_FN_FIELD_STATIC_P (f, j),
908 fprintf_filtered (stream, "<badly mangled name '%s'>",
914 char *demangled_no_class = demangled_name;
916 while ((p = strchr (demangled_no_class, ':')))
918 demangled_no_class = p;
919 if (*++demangled_no_class == ':')
920 ++demangled_no_class;
922 /* get rid of the static word appended by the demangler */
923 p = strstr (demangled_no_class, " static");
926 int length = p - demangled_no_class;
927 demangled_no_static = (char *) xmalloc (length + 1);
928 strncpy (demangled_no_static, demangled_no_class, length);
929 *(demangled_no_static + length) = '\0';
930 fputs_filtered (demangled_no_static, stream);
931 free (demangled_no_static);
934 fputs_filtered (demangled_no_class, stream);
935 free (demangled_name);
938 if (TYPE_FN_FIELD_STUB (f, j))
941 fprintf_filtered (stream, ";\n");
945 if (TYPE_LOCALTYPE_PTR (type) && show >= 0)
946 fprintfi_filtered (level, stream, " (Local at %s:%d)\n",
947 TYPE_LOCALTYPE_FILE (type),
948 TYPE_LOCALTYPE_LINE (type));
950 fprintfi_filtered (level, stream, "}");
952 if (TYPE_CODE(type) == TYPE_CODE_TEMPLATE)
957 c_type_print_cv_qualifier (type, stream, 0, 1);
958 /* HP C supports sized enums */
959 if (hp_som_som_object_present)
960 switch (TYPE_LENGTH (type))
963 fputs_filtered ("char ", stream);
966 fputs_filtered ("short ", stream);
971 fprintf_filtered (stream, "enum ");
972 /* Print the tag name if it exists.
973 The aCC compiler emits a spurious
974 "{unnamed struct}"/"{unnamed union}"/"{unnamed enum}"
975 tag for unnamed struct/union/enum's, which we don't
977 if (TYPE_TAG_NAME (type) != NULL &&
978 strncmp(TYPE_TAG_NAME(type), "{unnamed", 8))
980 fputs_filtered (TYPE_TAG_NAME (type), stream);
982 fputs_filtered (" ", stream);
988 /* If we just printed a tag name, no need to print anything else. */
989 if (TYPE_TAG_NAME (type) == NULL)
990 fprintf_filtered (stream, "{...}");
992 else if (show > 0 || TYPE_TAG_NAME (type) == NULL)
994 fprintf_filtered (stream, "{");
995 len = TYPE_NFIELDS (type);
997 for (i = 0; i < len; i++)
1000 if (i) fprintf_filtered (stream, ", ");
1002 fputs_filtered (TYPE_FIELD_NAME (type, i), stream);
1003 if (lastval != TYPE_FIELD_BITPOS (type, i))
1005 fprintf_filtered (stream, " = %d", TYPE_FIELD_BITPOS (type, i));
1006 lastval = TYPE_FIELD_BITPOS (type, i);
1010 fprintf_filtered (stream, "}");
1014 case TYPE_CODE_VOID:
1015 fprintf_filtered (stream, "void");
1018 case TYPE_CODE_UNDEF:
1019 fprintf_filtered (stream, "struct <unknown>");
1022 case TYPE_CODE_ERROR:
1023 fprintf_filtered (stream, "<unknown type>");
1026 case TYPE_CODE_RANGE:
1027 /* This should not occur */
1028 fprintf_filtered (stream, "<range type>");
1031 case TYPE_CODE_TEMPLATE:
1032 /* Called on "ptype t" where "t" is a template.
1033 Prints the template header (with args), e.g.:
1034 template <class T1, class T2> class "
1035 and then merges with the struct/union/class code to
1036 print the rest of the definition. */
1037 c_type_print_cv_qualifier (type, stream, 0, 1);
1038 fprintf_filtered (stream, "template <");
1039 for (i = 0; i < TYPE_NTEMPLATE_ARGS(type); i++) {
1040 struct template_arg templ_arg;
1041 templ_arg = TYPE_TEMPLATE_ARG(type, i);
1042 fprintf_filtered (stream, "class %s", templ_arg.name);
1043 if (i < TYPE_NTEMPLATE_ARGS(type)-1)
1044 fprintf_filtered (stream, ", ");
1046 fprintf_filtered (stream, "> class ");
1047 /* Yuck, factor this out to a subroutine so we can call
1048 it and return to the point marked with the "goback:" label... - RT */
1051 if (TYPE_NINSTANTIATIONS(type) > 0) {
1052 fprintf_filtered (stream, "\ntemplate instantiations:\n");
1053 for (i = 0; i < TYPE_NINSTANTIATIONS(type); i++) {
1054 fprintf_filtered(stream, " ");
1055 c_type_print_base (TYPE_INSTANTIATION(type, i), stream, 0, level);
1056 if (i < TYPE_NINSTANTIATIONS(type)-1) fprintf_filtered(stream, "\n");
1062 /* Handle types not explicitly handled by the other cases,
1063 such as fundamental types. For these, just print whatever
1064 the type name is, as recorded in the type itself. If there
1065 is no type name, then complain. */
1066 if (TYPE_NAME (type) != NULL)
1068 c_type_print_cv_qualifier (type, stream, 0, 1);
1069 fputs_filtered (TYPE_NAME (type), stream);
1073 /* At least for dump_symtab, it is important that this not be
1075 fprintf_filtered (stream, "<invalid type code %d>",