GDB (API)
|
00001 /* Support for printing C and C++ types for GDB, the GNU debugger. 00002 Copyright (C) 1986-2013 Free Software Foundation, Inc. 00003 00004 This file is part of GDB. 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 3 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00018 00019 #include "defs.h" 00020 #include "gdb_obstack.h" 00021 #include "bfd.h" /* Binary File Description. */ 00022 #include "symtab.h" 00023 #include "gdbtypes.h" 00024 #include "expression.h" 00025 #include "value.h" 00026 #include "gdbcore.h" 00027 #include "target.h" 00028 #include "language.h" 00029 #include "demangle.h" 00030 #include "c-lang.h" 00031 #include "typeprint.h" 00032 #include "cp-abi.h" 00033 #include "jv-lang.h" 00034 #include "gdb_string.h" 00035 #include <errno.h> 00036 #include "cp-support.h" 00037 00038 static void c_type_print_varspec_prefix (struct type *, 00039 struct ui_file *, 00040 int, int, int, 00041 const struct type_print_options *); 00042 00043 /* Print "const", "volatile", or address space modifiers. */ 00044 static void c_type_print_modifier (struct type *, 00045 struct ui_file *, 00046 int, int); 00047 00048 00049 /* A callback function for cp_canonicalize_string_full that uses 00050 find_typedef_in_hash. */ 00051 00052 static const char * 00053 find_typedef_for_canonicalize (struct type *t, void *data) 00054 { 00055 return find_typedef_in_hash (data, t); 00056 } 00057 00058 /* Print NAME on STREAM. If the 'raw' field of FLAGS is not set, 00059 canonicalize NAME using the local typedefs first. */ 00060 00061 static void 00062 print_name_maybe_canonical (const char *name, 00063 const struct type_print_options *flags, 00064 struct ui_file *stream) 00065 { 00066 char *s = NULL; 00067 00068 if (!flags->raw) 00069 s = cp_canonicalize_string_full (name, 00070 find_typedef_for_canonicalize, 00071 (void *) flags); 00072 00073 fputs_filtered (s ? s : name, stream); 00074 xfree (s); 00075 } 00076 00077 00078 00079 /* LEVEL is the depth to indent lines by. */ 00080 00081 void 00082 c_print_type (struct type *type, 00083 const char *varstring, 00084 struct ui_file *stream, 00085 int show, int level, 00086 const struct type_print_options *flags) 00087 { 00088 enum type_code code; 00089 int demangled_args; 00090 int need_post_space; 00091 const char *local_name; 00092 00093 if (show > 0) 00094 CHECK_TYPEDEF (type); 00095 00096 local_name = find_typedef_in_hash (flags, type); 00097 if (local_name != NULL) 00098 { 00099 fputs_filtered (local_name, stream); 00100 if (varstring != NULL && *varstring != '\0') 00101 fputs_filtered (" ", stream); 00102 } 00103 else 00104 { 00105 c_type_print_base (type, stream, show, level, flags); 00106 code = TYPE_CODE (type); 00107 if ((varstring != NULL && *varstring != '\0') 00108 /* Need a space if going to print stars or brackets; 00109 but not if we will print just a type name. */ 00110 || ((show > 0 || TYPE_NAME (type) == 0) 00111 && (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC 00112 || code == TYPE_CODE_METHOD 00113 || (code == TYPE_CODE_ARRAY 00114 && !TYPE_VECTOR (type)) 00115 || code == TYPE_CODE_MEMBERPTR 00116 || code == TYPE_CODE_METHODPTR 00117 || code == TYPE_CODE_REF))) 00118 fputs_filtered (" ", stream); 00119 need_post_space = (varstring != NULL && strcmp (varstring, "") != 0); 00120 c_type_print_varspec_prefix (type, stream, show, 0, need_post_space, 00121 flags); 00122 } 00123 00124 if (varstring != NULL) 00125 { 00126 fputs_filtered (varstring, stream); 00127 00128 /* For demangled function names, we have the arglist as part of 00129 the name, so don't print an additional pair of ()'s. */ 00130 if (local_name == NULL) 00131 { 00132 demangled_args = strchr (varstring, '(') != NULL; 00133 c_type_print_varspec_suffix (type, stream, show, 00134 0, demangled_args, 00135 flags); 00136 } 00137 } 00138 } 00139 00140 /* Print a typedef using C syntax. TYPE is the underlying type. 00141 NEW_SYMBOL is the symbol naming the type. STREAM is the stream on 00142 which to print. */ 00143 00144 void 00145 c_print_typedef (struct type *type, 00146 struct symbol *new_symbol, 00147 struct ui_file *stream) 00148 { 00149 CHECK_TYPEDEF (type); 00150 fprintf_filtered (stream, "typedef "); 00151 type_print (type, "", stream, 0); 00152 if (TYPE_NAME ((SYMBOL_TYPE (new_symbol))) == 0 00153 || strcmp (TYPE_NAME ((SYMBOL_TYPE (new_symbol))), 00154 SYMBOL_LINKAGE_NAME (new_symbol)) != 0 00155 || TYPE_CODE (SYMBOL_TYPE (new_symbol)) == TYPE_CODE_TYPEDEF) 00156 fprintf_filtered (stream, " %s", SYMBOL_PRINT_NAME (new_symbol)); 00157 fprintf_filtered (stream, ";\n"); 00158 } 00159 00160 /* If TYPE is a derived type, then print out derivation information. 00161 Print only the actual base classes of this type, not the base 00162 classes of the base classes. I.e. for the derivation hierarchy: 00163 00164 class A { int a; }; 00165 class B : public A {int b; }; 00166 class C : public B {int c; }; 00167 00168 Print the type of class C as: 00169 00170 class C : public B { 00171 int c; 00172 } 00173 00174 Not as the following (like gdb used to), which is not legal C++ 00175 syntax for derived types and may be confused with the multiple 00176 inheritance form: 00177 00178 class C : public B : public A { 00179 int c; 00180 } 00181 00182 In general, gdb should try to print the types as closely as 00183 possible to the form that they appear in the source code. */ 00184 00185 static void 00186 cp_type_print_derivation_info (struct ui_file *stream, 00187 struct type *type, 00188 const struct type_print_options *flags) 00189 { 00190 const char *name; 00191 int i; 00192 00193 for (i = 0; i < TYPE_N_BASECLASSES (type); i++) 00194 { 00195 wrap_here (" "); 00196 fputs_filtered (i == 0 ? ": " : ", ", stream); 00197 fprintf_filtered (stream, "%s%s ", 00198 BASETYPE_VIA_PUBLIC (type, i) 00199 ? "public" : (TYPE_FIELD_PROTECTED (type, i) 00200 ? "protected" : "private"), 00201 BASETYPE_VIA_VIRTUAL (type, i) ? " virtual" : ""); 00202 name = type_name_no_tag (TYPE_BASECLASS (type, i)); 00203 if (name) 00204 print_name_maybe_canonical (name, flags, stream); 00205 else 00206 fprintf_filtered (stream, "(null)"); 00207 } 00208 if (i > 0) 00209 { 00210 fputs_filtered (" ", stream); 00211 } 00212 } 00213 00214 /* Print the C++ method arguments ARGS to the file STREAM. */ 00215 00216 static void 00217 cp_type_print_method_args (struct type *mtype, const char *prefix, 00218 const char *varstring, int staticp, 00219 struct ui_file *stream, 00220 const struct type_print_options *flags) 00221 { 00222 struct field *args = TYPE_FIELDS (mtype); 00223 int nargs = TYPE_NFIELDS (mtype); 00224 int varargs = TYPE_VARARGS (mtype); 00225 int i; 00226 00227 fprintf_symbol_filtered (stream, prefix, 00228 language_cplus, DMGL_ANSI); 00229 fprintf_symbol_filtered (stream, varstring, 00230 language_cplus, DMGL_ANSI); 00231 fputs_filtered ("(", stream); 00232 00233 /* Skip the class variable. */ 00234 i = staticp ? 0 : 1; 00235 if (nargs > i) 00236 { 00237 while (i < nargs) 00238 { 00239 c_print_type (args[i++].type, "", stream, 0, 0, flags); 00240 00241 if (i == nargs && varargs) 00242 fprintf_filtered (stream, ", ..."); 00243 else if (i < nargs) 00244 { 00245 fprintf_filtered (stream, ", "); 00246 wrap_here (" "); 00247 } 00248 } 00249 } 00250 else if (varargs) 00251 fprintf_filtered (stream, "..."); 00252 else if (current_language->la_language == language_cplus) 00253 fprintf_filtered (stream, "void"); 00254 00255 fprintf_filtered (stream, ")"); 00256 00257 /* For non-static methods, read qualifiers from the type of 00258 THIS. */ 00259 if (!staticp) 00260 { 00261 struct type *domain; 00262 00263 gdb_assert (nargs > 0); 00264 gdb_assert (TYPE_CODE (args[0].type) == TYPE_CODE_PTR); 00265 domain = TYPE_TARGET_TYPE (args[0].type); 00266 00267 if (TYPE_CONST (domain)) 00268 fprintf_filtered (stream, " const"); 00269 00270 if (TYPE_VOLATILE (domain)) 00271 fprintf_filtered (stream, " volatile"); 00272 00273 if (TYPE_RESTRICT (domain)) 00274 fprintf_filtered (stream, " restrict"); 00275 } 00276 } 00277 00278 00279 /* Print any asterisks or open-parentheses needed before the 00280 variable name (to describe its type). 00281 00282 On outermost call, pass 0 for PASSED_A_PTR. 00283 On outermost call, SHOW > 0 means should ignore 00284 any typename for TYPE and show its details. 00285 SHOW is always zero on recursive calls. 00286 00287 NEED_POST_SPACE is non-zero when a space will be be needed 00288 between a trailing qualifier and a field, variable, or function 00289 name. */ 00290 00291 static void 00292 c_type_print_varspec_prefix (struct type *type, 00293 struct ui_file *stream, 00294 int show, int passed_a_ptr, 00295 int need_post_space, 00296 const struct type_print_options *flags) 00297 { 00298 const char *name; 00299 00300 if (type == 0) 00301 return; 00302 00303 if (TYPE_NAME (type) && show <= 0) 00304 return; 00305 00306 QUIT; 00307 00308 switch (TYPE_CODE (type)) 00309 { 00310 case TYPE_CODE_PTR: 00311 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), 00312 stream, show, 1, 1, flags); 00313 fprintf_filtered (stream, "*"); 00314 c_type_print_modifier (type, stream, 1, need_post_space); 00315 break; 00316 00317 case TYPE_CODE_MEMBERPTR: 00318 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), 00319 stream, show, 0, 0, flags); 00320 name = type_name_no_tag (TYPE_DOMAIN_TYPE (type)); 00321 if (name) 00322 print_name_maybe_canonical (name, flags, stream); 00323 else 00324 c_type_print_base (TYPE_DOMAIN_TYPE (type), 00325 stream, -1, passed_a_ptr, flags); 00326 fprintf_filtered (stream, "::*"); 00327 break; 00328 00329 case TYPE_CODE_METHODPTR: 00330 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), 00331 stream, show, 0, 0, flags); 00332 fprintf_filtered (stream, "("); 00333 name = type_name_no_tag (TYPE_DOMAIN_TYPE (type)); 00334 if (name) 00335 print_name_maybe_canonical (name, flags, stream); 00336 else 00337 c_type_print_base (TYPE_DOMAIN_TYPE (type), 00338 stream, -1, passed_a_ptr, flags); 00339 fprintf_filtered (stream, "::*"); 00340 break; 00341 00342 case TYPE_CODE_REF: 00343 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), 00344 stream, show, 1, 0, flags); 00345 fprintf_filtered (stream, "&"); 00346 c_type_print_modifier (type, stream, 1, need_post_space); 00347 break; 00348 00349 case TYPE_CODE_METHOD: 00350 case TYPE_CODE_FUNC: 00351 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), 00352 stream, show, 0, 0, flags); 00353 if (passed_a_ptr) 00354 fprintf_filtered (stream, "("); 00355 break; 00356 00357 case TYPE_CODE_ARRAY: 00358 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), 00359 stream, show, 0, 0, flags); 00360 if (passed_a_ptr) 00361 fprintf_filtered (stream, "("); 00362 break; 00363 00364 case TYPE_CODE_TYPEDEF: 00365 c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), 00366 stream, show, passed_a_ptr, 0, flags); 00367 break; 00368 00369 case TYPE_CODE_UNDEF: 00370 case TYPE_CODE_STRUCT: 00371 case TYPE_CODE_UNION: 00372 case TYPE_CODE_ENUM: 00373 case TYPE_CODE_INT: 00374 case TYPE_CODE_FLT: 00375 case TYPE_CODE_VOID: 00376 case TYPE_CODE_ERROR: 00377 case TYPE_CODE_CHAR: 00378 case TYPE_CODE_BOOL: 00379 case TYPE_CODE_SET: 00380 case TYPE_CODE_RANGE: 00381 case TYPE_CODE_STRING: 00382 case TYPE_CODE_COMPLEX: 00383 case TYPE_CODE_NAMESPACE: 00384 case TYPE_CODE_DECFLOAT: 00385 /* These types need no prefix. They are listed here so that 00386 gcc -Wall will reveal any types that haven't been handled. */ 00387 break; 00388 default: 00389 error (_("type not handled in c_type_print_varspec_prefix()")); 00390 break; 00391 } 00392 } 00393 00394 /* Print out "const" and "volatile" attributes, 00395 and address space id if present. 00396 TYPE is a pointer to the type being printed out. 00397 STREAM is the output destination. 00398 NEED_PRE_SPACE = 1 indicates an initial white space is needed. 00399 NEED_POST_SPACE = 1 indicates a final white space is needed. */ 00400 00401 static void 00402 c_type_print_modifier (struct type *type, struct ui_file *stream, 00403 int need_pre_space, int need_post_space) 00404 { 00405 int did_print_modifier = 0; 00406 const char *address_space_id; 00407 00408 /* We don't print `const' qualifiers for references --- since all 00409 operators affect the thing referenced, not the reference itself, 00410 every reference is `const'. */ 00411 if (TYPE_CONST (type) 00412 && TYPE_CODE (type) != TYPE_CODE_REF) 00413 { 00414 if (need_pre_space) 00415 fprintf_filtered (stream, " "); 00416 fprintf_filtered (stream, "const"); 00417 did_print_modifier = 1; 00418 } 00419 00420 if (TYPE_VOLATILE (type)) 00421 { 00422 if (did_print_modifier || need_pre_space) 00423 fprintf_filtered (stream, " "); 00424 fprintf_filtered (stream, "volatile"); 00425 did_print_modifier = 1; 00426 } 00427 00428 if (TYPE_RESTRICT (type)) 00429 { 00430 if (did_print_modifier || need_pre_space) 00431 fprintf_filtered (stream, " "); 00432 fprintf_filtered (stream, "restrict"); 00433 did_print_modifier = 1; 00434 } 00435 00436 address_space_id = address_space_int_to_name (get_type_arch (type), 00437 TYPE_INSTANCE_FLAGS (type)); 00438 if (address_space_id) 00439 { 00440 if (did_print_modifier || need_pre_space) 00441 fprintf_filtered (stream, " "); 00442 fprintf_filtered (stream, "@%s", address_space_id); 00443 did_print_modifier = 1; 00444 } 00445 00446 if (did_print_modifier && need_post_space) 00447 fprintf_filtered (stream, " "); 00448 } 00449 00450 00451 /* Print out the arguments of TYPE, which should have TYPE_CODE_METHOD 00452 or TYPE_CODE_FUNC, to STREAM. Artificial arguments, such as "this" 00453 in non-static methods, are displayed if LINKAGE_NAME is zero. If 00454 LINKAGE_NAME is non-zero and LANGUAGE is language_cplus the topmost 00455 parameter types get removed their possible const and volatile qualifiers to 00456 match demangled linkage name parameters part of such function type. 00457 LANGUAGE is the language in which TYPE was defined. This is a necessary 00458 evil since this code is used by the C, C++, and Java backends. */ 00459 00460 void 00461 c_type_print_args (struct type *type, struct ui_file *stream, 00462 int linkage_name, enum language language, 00463 const struct type_print_options *flags) 00464 { 00465 int i; 00466 int printed_any = 0; 00467 00468 fprintf_filtered (stream, "("); 00469 00470 for (i = 0; i < TYPE_NFIELDS (type); i++) 00471 { 00472 struct type *param_type; 00473 00474 if (TYPE_FIELD_ARTIFICIAL (type, i) && linkage_name) 00475 continue; 00476 00477 if (printed_any) 00478 { 00479 fprintf_filtered (stream, ", "); 00480 wrap_here (" "); 00481 } 00482 00483 param_type = TYPE_FIELD_TYPE (type, i); 00484 00485 if (language == language_cplus && linkage_name) 00486 { 00487 /* C++ standard, 13.1 Overloadable declarations, point 3, item: 00488 - Parameter declarations that differ only in the presence or 00489 absence of const and/or volatile are equivalent. 00490 00491 And the const/volatile qualifiers are not present in the mangled 00492 names as produced by GCC. */ 00493 00494 param_type = make_cv_type (0, 0, param_type, NULL); 00495 } 00496 00497 if (language == language_java) 00498 java_print_type (param_type, "", stream, -1, 0, flags); 00499 else 00500 c_print_type (param_type, "", stream, -1, 0, flags); 00501 printed_any = 1; 00502 } 00503 00504 if (printed_any && TYPE_VARARGS (type)) 00505 { 00506 /* Print out a trailing ellipsis for varargs functions. Ignore 00507 TYPE_VARARGS if the function has no named arguments; that 00508 represents unprototyped (K&R style) C functions. */ 00509 if (printed_any && TYPE_VARARGS (type)) 00510 { 00511 fprintf_filtered (stream, ", "); 00512 wrap_here (" "); 00513 fprintf_filtered (stream, "..."); 00514 } 00515 } 00516 else if (!printed_any 00517 && ((TYPE_PROTOTYPED (type) && language != language_java) 00518 || language == language_cplus)) 00519 fprintf_filtered (stream, "void"); 00520 00521 fprintf_filtered (stream, ")"); 00522 } 00523 00524 /* Return true iff the j'th overloading of the i'th method of TYPE 00525 is a type conversion operator, like `operator int () { ... }'. 00526 When listing a class's methods, we don't print the return type of 00527 such operators. */ 00528 00529 static int 00530 is_type_conversion_operator (struct type *type, int i, int j) 00531 { 00532 /* I think the whole idea of recognizing type conversion operators 00533 by their name is pretty terrible. But I don't think our present 00534 data structure gives us any other way to tell. If you know of 00535 some other way, feel free to rewrite this function. */ 00536 const char *name = TYPE_FN_FIELDLIST_NAME (type, i); 00537 00538 if (strncmp (name, "operator", 8) != 0) 00539 return 0; 00540 00541 name += 8; 00542 if (! strchr (" \t\f\n\r", *name)) 00543 return 0; 00544 00545 while (strchr (" \t\f\n\r", *name)) 00546 name++; 00547 00548 if (!('a' <= *name && *name <= 'z') 00549 && !('A' <= *name && *name <= 'Z') 00550 && *name != '_') 00551 /* If this doesn't look like the start of an identifier, then it 00552 isn't a type conversion operator. */ 00553 return 0; 00554 else if (strncmp (name, "new", 3) == 0) 00555 name += 3; 00556 else if (strncmp (name, "delete", 6) == 0) 00557 name += 6; 00558 else 00559 /* If it doesn't look like new or delete, it's a type conversion 00560 operator. */ 00561 return 1; 00562 00563 /* Is that really the end of the name? */ 00564 if (('a' <= *name && *name <= 'z') 00565 || ('A' <= *name && *name <= 'Z') 00566 || ('0' <= *name && *name <= '9') 00567 || *name == '_') 00568 /* No, so the identifier following "operator" must be a type name, 00569 and this is a type conversion operator. */ 00570 return 1; 00571 00572 /* That was indeed the end of the name, so it was `operator new' or 00573 `operator delete', neither of which are type conversion 00574 operators. */ 00575 return 0; 00576 } 00577 00578 /* Given a C++ qualified identifier QID, strip off the qualifiers, 00579 yielding the unqualified name. The return value is a pointer into 00580 the original string. 00581 00582 It's a pity we don't have this information in some more structured 00583 form. Even the author of this function feels that writing little 00584 parsers like this everywhere is stupid. */ 00585 00586 static char * 00587 remove_qualifiers (char *qid) 00588 { 00589 int quoted = 0; /* Zero if we're not in quotes; 00590 '"' if we're in a double-quoted string; 00591 '\'' if we're in a single-quoted string. */ 00592 int depth = 0; /* Number of unclosed parens we've seen. */ 00593 char *parenstack = (char *) alloca (strlen (qid)); 00594 char *scan; 00595 char *last = 0; /* The character after the rightmost 00596 `::' token we've seen so far. */ 00597 00598 for (scan = qid; *scan; scan++) 00599 { 00600 if (quoted) 00601 { 00602 if (*scan == quoted) 00603 quoted = 0; 00604 else if (*scan == '\\' && *(scan + 1)) 00605 scan++; 00606 } 00607 else if (scan[0] == ':' && scan[1] == ':') 00608 { 00609 /* If we're inside parenthesis (i.e., an argument list) or 00610 angle brackets (i.e., a list of template arguments), then 00611 we don't record the position of this :: token, since it's 00612 not relevant to the top-level structure we're trying to 00613 operate on. */ 00614 if (depth == 0) 00615 { 00616 last = scan + 2; 00617 scan++; 00618 } 00619 } 00620 else if (*scan == '"' || *scan == '\'') 00621 quoted = *scan; 00622 else if (*scan == '(') 00623 parenstack[depth++] = ')'; 00624 else if (*scan == '[') 00625 parenstack[depth++] = ']'; 00626 /* We're going to treat <> as a pair of matching characters, 00627 since we're more likely to see those in template id's than 00628 real less-than characters. What a crock. */ 00629 else if (*scan == '<') 00630 parenstack[depth++] = '>'; 00631 else if (*scan == ')' || *scan == ']' || *scan == '>') 00632 { 00633 if (depth > 0 && parenstack[depth - 1] == *scan) 00634 depth--; 00635 else 00636 { 00637 /* We're going to do a little error recovery here. If 00638 we don't find a match for *scan on the paren stack, 00639 but there is something lower on the stack that does 00640 match, we pop the stack to that point. */ 00641 int i; 00642 00643 for (i = depth - 1; i >= 0; i--) 00644 if (parenstack[i] == *scan) 00645 { 00646 depth = i; 00647 break; 00648 } 00649 } 00650 } 00651 } 00652 00653 if (last) 00654 return last; 00655 else 00656 /* We didn't find any :: tokens at the top level, so declare the 00657 whole thing an unqualified identifier. */ 00658 return qid; 00659 } 00660 00661 /* Print any array sizes, function arguments or close parentheses 00662 needed after the variable name (to describe its type). 00663 Args work like c_type_print_varspec_prefix. */ 00664 00665 void 00666 c_type_print_varspec_suffix (struct type *type, 00667 struct ui_file *stream, 00668 int show, int passed_a_ptr, 00669 int demangled_args, 00670 const struct type_print_options *flags) 00671 { 00672 if (type == 0) 00673 return; 00674 00675 if (TYPE_NAME (type) && show <= 0) 00676 return; 00677 00678 QUIT; 00679 00680 switch (TYPE_CODE (type)) 00681 { 00682 case TYPE_CODE_ARRAY: 00683 { 00684 LONGEST low_bound, high_bound; 00685 int is_vector = TYPE_VECTOR (type); 00686 00687 if (passed_a_ptr) 00688 fprintf_filtered (stream, ")"); 00689 00690 fprintf_filtered (stream, (is_vector ? 00691 " __attribute__ ((vector_size(" : "[")); 00692 if (get_array_bounds (type, &low_bound, &high_bound)) 00693 fprintf_filtered (stream, "%s", 00694 plongest (high_bound - low_bound + 1)); 00695 fprintf_filtered (stream, (is_vector ? ")))" : "]")); 00696 00697 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 00698 show, 0, 0, flags); 00699 } 00700 break; 00701 00702 case TYPE_CODE_MEMBERPTR: 00703 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 00704 show, 0, 0, flags); 00705 break; 00706 00707 case TYPE_CODE_METHODPTR: 00708 fprintf_filtered (stream, ")"); 00709 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 00710 show, 0, 0, flags); 00711 break; 00712 00713 case TYPE_CODE_PTR: 00714 case TYPE_CODE_REF: 00715 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 00716 show, 1, 0, flags); 00717 break; 00718 00719 case TYPE_CODE_METHOD: 00720 case TYPE_CODE_FUNC: 00721 if (passed_a_ptr) 00722 fprintf_filtered (stream, ")"); 00723 if (!demangled_args) 00724 c_type_print_args (type, stream, 0, current_language->la_language, 00725 flags); 00726 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 00727 show, passed_a_ptr, 0, flags); 00728 break; 00729 00730 case TYPE_CODE_TYPEDEF: 00731 c_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 00732 show, passed_a_ptr, 0, flags); 00733 break; 00734 00735 case TYPE_CODE_UNDEF: 00736 case TYPE_CODE_STRUCT: 00737 case TYPE_CODE_UNION: 00738 case TYPE_CODE_ENUM: 00739 case TYPE_CODE_INT: 00740 case TYPE_CODE_FLT: 00741 case TYPE_CODE_VOID: 00742 case TYPE_CODE_ERROR: 00743 case TYPE_CODE_CHAR: 00744 case TYPE_CODE_BOOL: 00745 case TYPE_CODE_SET: 00746 case TYPE_CODE_RANGE: 00747 case TYPE_CODE_STRING: 00748 case TYPE_CODE_COMPLEX: 00749 case TYPE_CODE_NAMESPACE: 00750 case TYPE_CODE_DECFLOAT: 00751 /* These types do not need a suffix. They are listed so that 00752 gcc -Wall will report types that may not have been 00753 considered. */ 00754 break; 00755 default: 00756 error (_("type not handled in c_type_print_varspec_suffix()")); 00757 break; 00758 } 00759 } 00760 00761 /* A helper for c_type_print_base that displays template 00762 parameters and their bindings, if needed. 00763 00764 TABLE is the local bindings table to use. If NULL, no printing is 00765 done. Note that, at this point, TABLE won't have any useful 00766 information in it -- but it is also used as a flag to 00767 print_name_maybe_canonical to activate searching the global typedef 00768 table. 00769 00770 TYPE is the type whose template arguments are being displayed. 00771 00772 STREAM is the stream on which to print. */ 00773 00774 static void 00775 c_type_print_template_args (const struct type_print_options *flags, 00776 struct type *type, struct ui_file *stream) 00777 { 00778 int first = 1, i; 00779 00780 if (flags->raw) 00781 return; 00782 00783 for (i = 0; i < TYPE_N_TEMPLATE_ARGUMENTS (type); ++i) 00784 { 00785 struct symbol *sym = TYPE_TEMPLATE_ARGUMENT (type, i); 00786 00787 if (SYMBOL_CLASS (sym) != LOC_TYPEDEF) 00788 continue; 00789 00790 if (first) 00791 { 00792 wrap_here (" "); 00793 fprintf_filtered (stream, _("[with %s = "), 00794 SYMBOL_LINKAGE_NAME (sym)); 00795 first = 0; 00796 } 00797 else 00798 { 00799 fputs_filtered (", ", stream); 00800 wrap_here (" "); 00801 fprintf_filtered (stream, "%s = ", SYMBOL_LINKAGE_NAME (sym)); 00802 } 00803 00804 c_print_type (SYMBOL_TYPE (sym), "", stream, -1, 0, flags); 00805 } 00806 00807 if (!first) 00808 fputs_filtered (_("] "), stream); 00809 } 00810 00811 /* Print the name of the type (or the ultimate pointer target, 00812 function value or array element), or the description of a structure 00813 or union. 00814 00815 SHOW positive means print details about the type (e.g. enum 00816 values), and print structure elements passing SHOW - 1 for show. 00817 00818 SHOW negative means just print the type name or struct tag if there 00819 is one. If there is no name, print something sensible but concise 00820 like "struct {...}". 00821 00822 SHOW zero means just print the type name or struct tag if there is 00823 one. If there is no name, print something sensible but not as 00824 concise like "struct {int x; int y;}". 00825 00826 LEVEL is the number of spaces to indent by. 00827 We increase it for some recursive calls. */ 00828 00829 void 00830 c_type_print_base (struct type *type, struct ui_file *stream, 00831 int show, int level, const struct type_print_options *flags) 00832 { 00833 int i; 00834 int len, real_len; 00835 enum 00836 { 00837 s_none, s_public, s_private, s_protected 00838 } 00839 section_type; 00840 int need_access_label = 0; 00841 int j, len2; 00842 00843 QUIT; 00844 00845 if (type == NULL) 00846 { 00847 fputs_filtered (_("<type unknown>"), stream); 00848 return; 00849 } 00850 00851 /* When SHOW is zero or less, and there is a valid type name, then 00852 always just print the type name directly from the type. */ 00853 /* If we have "typedef struct foo {. . .} bar;" do we want to print 00854 it as "struct foo" or as "bar"? Pick the latter, because C++ 00855 folk tend to expect things like "class5 *foo" rather than "struct 00856 class5 *foo". */ 00857 00858 if (show <= 0 00859 && TYPE_NAME (type) != NULL) 00860 { 00861 c_type_print_modifier (type, stream, 0, 1); 00862 print_name_maybe_canonical (TYPE_NAME (type), flags, stream); 00863 return; 00864 } 00865 00866 CHECK_TYPEDEF (type); 00867 00868 switch (TYPE_CODE (type)) 00869 { 00870 case TYPE_CODE_TYPEDEF: 00871 /* If we get here, the typedef doesn't have a name, and we 00872 couldn't resolve TYPE_TARGET_TYPE. Not much we can do. */ 00873 gdb_assert (TYPE_NAME (type) == NULL); 00874 gdb_assert (TYPE_TARGET_TYPE (type) == NULL); 00875 fprintf_filtered (stream, _("<unnamed typedef>")); 00876 break; 00877 00878 case TYPE_CODE_ARRAY: 00879 case TYPE_CODE_PTR: 00880 case TYPE_CODE_MEMBERPTR: 00881 case TYPE_CODE_REF: 00882 case TYPE_CODE_FUNC: 00883 case TYPE_CODE_METHOD: 00884 case TYPE_CODE_METHODPTR: 00885 c_type_print_base (TYPE_TARGET_TYPE (type), 00886 stream, show, level, flags); 00887 break; 00888 00889 case TYPE_CODE_STRUCT: 00890 case TYPE_CODE_UNION: 00891 { 00892 struct type_print_options local_flags = *flags; 00893 struct type_print_options semi_local_flags = *flags; 00894 struct cleanup *local_cleanups = make_cleanup (null_cleanup, NULL); 00895 00896 local_flags.local_typedefs = NULL; 00897 semi_local_flags.local_typedefs = NULL; 00898 00899 if (!flags->raw) 00900 { 00901 if (flags->local_typedefs) 00902 local_flags.local_typedefs 00903 = copy_typedef_hash (flags->local_typedefs); 00904 else 00905 local_flags.local_typedefs = create_typedef_hash (); 00906 00907 make_cleanup_free_typedef_hash (local_flags.local_typedefs); 00908 } 00909 00910 c_type_print_modifier (type, stream, 0, 1); 00911 if (TYPE_CODE (type) == TYPE_CODE_UNION) 00912 fprintf_filtered (stream, "union "); 00913 else if (TYPE_DECLARED_CLASS (type)) 00914 fprintf_filtered (stream, "class "); 00915 else 00916 fprintf_filtered (stream, "struct "); 00917 00918 /* Print the tag if it exists. The HP aCC compiler emits a 00919 spurious "{unnamed struct}"/"{unnamed union}"/"{unnamed 00920 enum}" tag for unnamed struct/union/enum's, which we don't 00921 want to print. */ 00922 if (TYPE_TAG_NAME (type) != NULL 00923 && strncmp (TYPE_TAG_NAME (type), "{unnamed", 8)) 00924 { 00925 /* When printing the tag name, we are still effectively 00926 printing in the outer context, hence the use of FLAGS 00927 here. */ 00928 print_name_maybe_canonical (TYPE_TAG_NAME (type), flags, stream); 00929 if (show > 0) 00930 fputs_filtered (" ", stream); 00931 } 00932 00933 if (show < 0) 00934 { 00935 /* If we just printed a tag name, no need to print anything 00936 else. */ 00937 if (TYPE_TAG_NAME (type) == NULL) 00938 fprintf_filtered (stream, "{...}"); 00939 } 00940 else if (show > 0 || TYPE_TAG_NAME (type) == NULL) 00941 { 00942 struct type *basetype; 00943 int vptr_fieldno; 00944 00945 c_type_print_template_args (&local_flags, type, stream); 00946 00947 /* Add in template parameters when printing derivation info. */ 00948 add_template_parameters (local_flags.local_typedefs, type); 00949 cp_type_print_derivation_info (stream, type, &local_flags); 00950 00951 /* This holds just the global typedefs and the template 00952 parameters. */ 00953 semi_local_flags.local_typedefs 00954 = copy_typedef_hash (local_flags.local_typedefs); 00955 if (semi_local_flags.local_typedefs) 00956 make_cleanup_free_typedef_hash (semi_local_flags.local_typedefs); 00957 00958 /* Now add in the local typedefs. */ 00959 recursively_update_typedef_hash (local_flags.local_typedefs, type); 00960 00961 fprintf_filtered (stream, "{\n"); 00962 if (TYPE_NFIELDS (type) == 0 && TYPE_NFN_FIELDS (type) == 0 00963 && TYPE_TYPEDEF_FIELD_COUNT (type) == 0) 00964 { 00965 if (TYPE_STUB (type)) 00966 fprintfi_filtered (level + 4, stream, 00967 _("<incomplete type>\n")); 00968 else 00969 fprintfi_filtered (level + 4, stream, 00970 _("<no data fields>\n")); 00971 } 00972 00973 /* Start off with no specific section type, so we can print 00974 one for the first field we find, and use that section type 00975 thereafter until we find another type. */ 00976 00977 section_type = s_none; 00978 00979 /* For a class, if all members are private, there's no need 00980 for a "private:" label; similarly, for a struct or union 00981 masquerading as a class, if all members are public, there's 00982 no need for a "public:" label. */ 00983 00984 if (TYPE_DECLARED_CLASS (type)) 00985 { 00986 QUIT; 00987 len = TYPE_NFIELDS (type); 00988 for (i = TYPE_N_BASECLASSES (type); i < len; i++) 00989 if (!TYPE_FIELD_PRIVATE (type, i)) 00990 { 00991 need_access_label = 1; 00992 break; 00993 } 00994 QUIT; 00995 if (!need_access_label) 00996 { 00997 len2 = TYPE_NFN_FIELDS (type); 00998 for (j = 0; j < len2; j++) 00999 { 01000 len = TYPE_FN_FIELDLIST_LENGTH (type, j); 01001 for (i = 0; i < len; i++) 01002 if (!TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type, 01003 j), i)) 01004 { 01005 need_access_label = 1; 01006 break; 01007 } 01008 if (need_access_label) 01009 break; 01010 } 01011 } 01012 } 01013 else 01014 { 01015 QUIT; 01016 len = TYPE_NFIELDS (type); 01017 for (i = TYPE_N_BASECLASSES (type); i < len; i++) 01018 if (TYPE_FIELD_PRIVATE (type, i) 01019 || TYPE_FIELD_PROTECTED (type, i)) 01020 { 01021 need_access_label = 1; 01022 break; 01023 } 01024 QUIT; 01025 if (!need_access_label) 01026 { 01027 len2 = TYPE_NFN_FIELDS (type); 01028 for (j = 0; j < len2; j++) 01029 { 01030 QUIT; 01031 len = TYPE_FN_FIELDLIST_LENGTH (type, j); 01032 for (i = 0; i < len; i++) 01033 if (TYPE_FN_FIELD_PROTECTED (TYPE_FN_FIELDLIST1 (type, 01034 j), i) 01035 || TYPE_FN_FIELD_PRIVATE (TYPE_FN_FIELDLIST1 (type, 01036 j), 01037 i)) 01038 { 01039 need_access_label = 1; 01040 break; 01041 } 01042 if (need_access_label) 01043 break; 01044 } 01045 } 01046 } 01047 01048 /* If there is a base class for this type, 01049 do not print the field that it occupies. */ 01050 01051 len = TYPE_NFIELDS (type); 01052 vptr_fieldno = get_vptr_fieldno (type, &basetype); 01053 for (i = TYPE_N_BASECLASSES (type); i < len; i++) 01054 { 01055 QUIT; 01056 01057 /* If we have a virtual table pointer, omit it. Even if 01058 virtual table pointers are not specifically marked in 01059 the debug info, they should be artificial. */ 01060 if ((i == vptr_fieldno && type == basetype) 01061 || TYPE_FIELD_ARTIFICIAL (type, i)) 01062 continue; 01063 01064 if (need_access_label) 01065 { 01066 if (TYPE_FIELD_PROTECTED (type, i)) 01067 { 01068 if (section_type != s_protected) 01069 { 01070 section_type = s_protected; 01071 fprintfi_filtered (level + 2, stream, 01072 "protected:\n"); 01073 } 01074 } 01075 else if (TYPE_FIELD_PRIVATE (type, i)) 01076 { 01077 if (section_type != s_private) 01078 { 01079 section_type = s_private; 01080 fprintfi_filtered (level + 2, stream, 01081 "private:\n"); 01082 } 01083 } 01084 else 01085 { 01086 if (section_type != s_public) 01087 { 01088 section_type = s_public; 01089 fprintfi_filtered (level + 2, stream, 01090 "public:\n"); 01091 } 01092 } 01093 } 01094 01095 print_spaces_filtered (level + 4, stream); 01096 if (field_is_static (&TYPE_FIELD (type, i))) 01097 fprintf_filtered (stream, "static "); 01098 c_print_type (TYPE_FIELD_TYPE (type, i), 01099 TYPE_FIELD_NAME (type, i), 01100 stream, show - 1, level + 4, 01101 &local_flags); 01102 if (!field_is_static (&TYPE_FIELD (type, i)) 01103 && TYPE_FIELD_PACKED (type, i)) 01104 { 01105 /* It is a bitfield. This code does not attempt 01106 to look at the bitpos and reconstruct filler, 01107 unnamed fields. This would lead to misleading 01108 results if the compiler does not put out fields 01109 for such things (I don't know what it does). */ 01110 fprintf_filtered (stream, " : %d", 01111 TYPE_FIELD_BITSIZE (type, i)); 01112 } 01113 fprintf_filtered (stream, ";\n"); 01114 } 01115 01116 /* If there are both fields and methods, put a blank line 01117 between them. Make sure to count only method that we 01118 will display; artificial methods will be hidden. */ 01119 len = TYPE_NFN_FIELDS (type); 01120 if (!flags->print_methods) 01121 len = 0; 01122 real_len = 0; 01123 for (i = 0; i < len; i++) 01124 { 01125 struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); 01126 int len2 = TYPE_FN_FIELDLIST_LENGTH (type, i); 01127 int j; 01128 01129 for (j = 0; j < len2; j++) 01130 if (!TYPE_FN_FIELD_ARTIFICIAL (f, j)) 01131 real_len++; 01132 } 01133 if (real_len > 0 && section_type != s_none) 01134 fprintf_filtered (stream, "\n"); 01135 01136 /* C++: print out the methods. */ 01137 for (i = 0; i < len; i++) 01138 { 01139 struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); 01140 int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i); 01141 const char *method_name = TYPE_FN_FIELDLIST_NAME (type, i); 01142 const char *name = type_name_no_tag (type); 01143 int is_constructor = name && strcmp (method_name, 01144 name) == 0; 01145 01146 for (j = 0; j < len2; j++) 01147 { 01148 const char *mangled_name; 01149 char *demangled_name; 01150 struct cleanup *inner_cleanup; 01151 const char *physname = TYPE_FN_FIELD_PHYSNAME (f, j); 01152 int is_full_physname_constructor = 01153 TYPE_FN_FIELD_CONSTRUCTOR (f, j) 01154 || is_constructor_name (physname) 01155 || is_destructor_name (physname) 01156 || method_name[0] == '~'; 01157 01158 /* Do not print out artificial methods. */ 01159 if (TYPE_FN_FIELD_ARTIFICIAL (f, j)) 01160 continue; 01161 01162 inner_cleanup = make_cleanup (null_cleanup, NULL); 01163 01164 QUIT; 01165 if (TYPE_FN_FIELD_PROTECTED (f, j)) 01166 { 01167 if (section_type != s_protected) 01168 { 01169 section_type = s_protected; 01170 fprintfi_filtered (level + 2, stream, 01171 "protected:\n"); 01172 } 01173 } 01174 else if (TYPE_FN_FIELD_PRIVATE (f, j)) 01175 { 01176 if (section_type != s_private) 01177 { 01178 section_type = s_private; 01179 fprintfi_filtered (level + 2, stream, 01180 "private:\n"); 01181 } 01182 } 01183 else 01184 { 01185 if (section_type != s_public) 01186 { 01187 section_type = s_public; 01188 fprintfi_filtered (level + 2, stream, 01189 "public:\n"); 01190 } 01191 } 01192 01193 print_spaces_filtered (level + 4, stream); 01194 if (TYPE_FN_FIELD_VIRTUAL_P (f, j)) 01195 fprintf_filtered (stream, "virtual "); 01196 else if (TYPE_FN_FIELD_STATIC_P (f, j)) 01197 fprintf_filtered (stream, "static "); 01198 if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0) 01199 { 01200 /* Keep GDB from crashing here. */ 01201 fprintf_filtered (stream, 01202 _("<undefined type> %s;\n"), 01203 TYPE_FN_FIELD_PHYSNAME (f, j)); 01204 break; 01205 } 01206 else if (!is_constructor /* Constructors don't 01207 have declared 01208 types. */ 01209 && !is_full_physname_constructor /* " " */ 01210 && !is_type_conversion_operator (type, i, j)) 01211 { 01212 c_print_type (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)), 01213 "", stream, -1, 0, 01214 &local_flags); 01215 fputs_filtered (" ", stream); 01216 } 01217 if (TYPE_FN_FIELD_STUB (f, j)) 01218 { 01219 char *tem; 01220 01221 /* Build something we can demangle. */ 01222 tem = gdb_mangle_name (type, i, j); 01223 make_cleanup (xfree, tem); 01224 mangled_name = tem; 01225 } 01226 else 01227 mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j); 01228 01229 demangled_name = 01230 gdb_demangle (mangled_name, 01231 DMGL_ANSI | DMGL_PARAMS); 01232 if (demangled_name == NULL) 01233 { 01234 /* In some cases (for instance with the HP 01235 demangling), if a function has more than 10 01236 arguments, the demangling will fail. 01237 Let's try to reconstruct the function 01238 signature from the symbol information. */ 01239 if (!TYPE_FN_FIELD_STUB (f, j)) 01240 { 01241 int staticp = TYPE_FN_FIELD_STATIC_P (f, j); 01242 struct type *mtype = TYPE_FN_FIELD_TYPE (f, j); 01243 01244 cp_type_print_method_args (mtype, 01245 "", 01246 method_name, 01247 staticp, 01248 stream, &local_flags); 01249 } 01250 else 01251 fprintf_filtered (stream, 01252 _("<badly mangled name '%s'>"), 01253 mangled_name); 01254 } 01255 else 01256 { 01257 char *p; 01258 char *demangled_no_class 01259 = remove_qualifiers (demangled_name); 01260 01261 /* Get rid of the `static' appended by the 01262 demangler. */ 01263 p = strstr (demangled_no_class, " static"); 01264 if (p != NULL) 01265 { 01266 int length = p - demangled_no_class; 01267 char *demangled_no_static; 01268 01269 demangled_no_static 01270 = (char *) xmalloc (length + 1); 01271 strncpy (demangled_no_static, 01272 demangled_no_class, length); 01273 *(demangled_no_static + length) = '\0'; 01274 fputs_filtered (demangled_no_static, stream); 01275 xfree (demangled_no_static); 01276 } 01277 else 01278 fputs_filtered (demangled_no_class, stream); 01279 xfree (demangled_name); 01280 } 01281 01282 do_cleanups (inner_cleanup); 01283 01284 fprintf_filtered (stream, ";\n"); 01285 } 01286 } 01287 01288 /* Print typedefs defined in this class. */ 01289 01290 if (TYPE_TYPEDEF_FIELD_COUNT (type) != 0 && flags->print_typedefs) 01291 { 01292 if (TYPE_NFIELDS (type) != 0 || TYPE_NFN_FIELDS (type) != 0) 01293 fprintf_filtered (stream, "\n"); 01294 01295 for (i = 0; i < TYPE_TYPEDEF_FIELD_COUNT (type); i++) 01296 { 01297 struct type *target = TYPE_TYPEDEF_FIELD_TYPE (type, i); 01298 01299 /* Dereference the typedef declaration itself. */ 01300 gdb_assert (TYPE_CODE (target) == TYPE_CODE_TYPEDEF); 01301 target = TYPE_TARGET_TYPE (target); 01302 01303 print_spaces_filtered (level + 4, stream); 01304 fprintf_filtered (stream, "typedef "); 01305 01306 /* We want to print typedefs with substitutions 01307 from the template parameters or globally-known 01308 typedefs but not local typedefs. */ 01309 c_print_type (target, 01310 TYPE_TYPEDEF_FIELD_NAME (type, i), 01311 stream, show - 1, level + 4, 01312 &semi_local_flags); 01313 fprintf_filtered (stream, ";\n"); 01314 } 01315 } 01316 01317 fprintfi_filtered (level, stream, "}"); 01318 } 01319 01320 do_cleanups (local_cleanups); 01321 } 01322 break; 01323 01324 case TYPE_CODE_ENUM: 01325 c_type_print_modifier (type, stream, 0, 1); 01326 fprintf_filtered (stream, "enum "); 01327 /* Print the tag name if it exists. 01328 The aCC compiler emits a spurious 01329 "{unnamed struct}"/"{unnamed union}"/"{unnamed enum}" 01330 tag for unnamed struct/union/enum's, which we don't 01331 want to print. */ 01332 if (TYPE_TAG_NAME (type) != NULL 01333 && strncmp (TYPE_TAG_NAME (type), "{unnamed", 8)) 01334 { 01335 print_name_maybe_canonical (TYPE_TAG_NAME (type), flags, stream); 01336 if (show > 0) 01337 fputs_filtered (" ", stream); 01338 } 01339 01340 wrap_here (" "); 01341 if (show < 0) 01342 { 01343 /* If we just printed a tag name, no need to print anything 01344 else. */ 01345 if (TYPE_TAG_NAME (type) == NULL) 01346 fprintf_filtered (stream, "{...}"); 01347 } 01348 else if (show > 0 || TYPE_TAG_NAME (type) == NULL) 01349 { 01350 LONGEST lastval = 0; 01351 01352 fprintf_filtered (stream, "{"); 01353 len = TYPE_NFIELDS (type); 01354 for (i = 0; i < len; i++) 01355 { 01356 QUIT; 01357 if (i) 01358 fprintf_filtered (stream, ", "); 01359 wrap_here (" "); 01360 fputs_filtered (TYPE_FIELD_NAME (type, i), stream); 01361 if (lastval != TYPE_FIELD_ENUMVAL (type, i)) 01362 { 01363 fprintf_filtered (stream, " = %s", 01364 plongest (TYPE_FIELD_ENUMVAL (type, i))); 01365 lastval = TYPE_FIELD_ENUMVAL (type, i); 01366 } 01367 lastval++; 01368 } 01369 fprintf_filtered (stream, "}"); 01370 } 01371 break; 01372 01373 case TYPE_CODE_VOID: 01374 fprintf_filtered (stream, "void"); 01375 break; 01376 01377 case TYPE_CODE_UNDEF: 01378 fprintf_filtered (stream, _("struct <unknown>")); 01379 break; 01380 01381 case TYPE_CODE_ERROR: 01382 fprintf_filtered (stream, "%s", TYPE_ERROR_NAME (type)); 01383 break; 01384 01385 case TYPE_CODE_RANGE: 01386 /* This should not occur. */ 01387 fprintf_filtered (stream, _("<range type>")); 01388 break; 01389 01390 case TYPE_CODE_NAMESPACE: 01391 fputs_filtered ("namespace ", stream); 01392 fputs_filtered (TYPE_TAG_NAME (type), stream); 01393 break; 01394 01395 default: 01396 /* Handle types not explicitly handled by the other cases, such 01397 as fundamental types. For these, just print whatever the 01398 type name is, as recorded in the type itself. If there is no 01399 type name, then complain. */ 01400 if (TYPE_NAME (type) != NULL) 01401 { 01402 c_type_print_modifier (type, stream, 0, 1); 01403 print_name_maybe_canonical (TYPE_NAME (type), flags, stream); 01404 } 01405 else 01406 { 01407 /* At least for dump_symtab, it is important that this not 01408 be an error (). */ 01409 fprintf_filtered (stream, _("<invalid type code %d>"), 01410 TYPE_CODE (type)); 01411 } 01412 break; 01413 } 01414 }