1/* Support for printing Ada types for GDB, the GNU debugger. 2 Copyright 1986, 1988, 1989, 1991, 1997, 2003 Free Software 3 Foundation, Inc. 4 5This file is part of GDB. 6 7This program is free software; you can redistribute it and/or modify 8it under the terms of the GNU General Public License as published by 9the Free Software Foundation; either version 2 of the License, or 10(at your option) any later version. 11 12This program is distributed in the hope that it will be useful, 13but WITHOUT ANY WARRANTY; without even the implied warranty of 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15GNU General Public License for more details. 16 17You should have received a copy of the GNU General Public License 18along with this program; if not, write to the Free Software 19Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ 20 21#include "defs.h" 22#include "gdb_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#include "ada-lang.h" 37 38#include <ctype.h> 39#include "gdb_string.h" 40#include <errno.h> 41 42static int print_record_field_types (struct type *, struct type *, 43 struct ui_file *, int, int); 44 45static void print_array_type (struct type *, struct ui_file *, int, int); 46 47static void print_choices (struct type *, int, struct ui_file *, 48 struct type *); 49 50static void print_range (struct type *, struct ui_file *); 51 52static void print_range_bound (struct type *, char *, int *, 53 struct ui_file *); 54 55static void 56print_dynamic_range_bound (struct type *, const char *, int, 57 const char *, struct ui_file *); 58 59static void print_range_type_named (char *, struct ui_file *); 60 61 62 63static char *name_buffer; 64static int name_buffer_len; 65 66/* The (demangled) Ada name of TYPE. This value persists until the 67 next call. */ 68 69static char * 70demangled_type_name (struct type *type) 71{ 72 if (ada_type_name (type) == NULL) 73 return NULL; 74 else 75 { 76 char *raw_name = ada_type_name (type); 77 char *s, *q; 78 79 if (name_buffer == NULL || name_buffer_len <= strlen (raw_name)) 80 { 81 name_buffer_len = 16 + 2 * strlen (raw_name); 82 name_buffer = xrealloc (name_buffer, name_buffer_len); 83 } 84 strcpy (name_buffer, raw_name); 85 86 s = (char *) strstr (name_buffer, "___"); 87 if (s != NULL) 88 *s = '\0'; 89 90 s = name_buffer + strlen (name_buffer) - 1; 91 while (s > name_buffer && (s[0] != '_' || s[-1] != '_')) 92 s -= 1; 93 94 if (s == name_buffer) 95 return name_buffer; 96 97 if (!islower (s[1])) 98 return NULL; 99 100 for (s = q = name_buffer; *s != '\0'; q += 1) 101 { 102 if (s[0] == '_' && s[1] == '_') 103 { 104 *q = '.'; 105 s += 2; 106 } 107 else 108 { 109 *q = *s; 110 s += 1; 111 } 112 } 113 *q = '\0'; 114 return name_buffer; 115 } 116} 117 118 119/* Print a description of a type in the format of a 120 typedef for the current language. 121 NEW is the new name for a type TYPE. */ 122 123void 124ada_typedef_print (struct type *type, struct symbol *new, 125 struct ui_file *stream) 126{ 127 fprintf_filtered (stream, "type %.*s is ", 128 ada_name_prefix_len (SYMBOL_PRINT_NAME (new)), 129 SYMBOL_PRINT_NAME (new)); 130 type_print (type, "", stream, 1); 131} 132 133/* Print range type TYPE on STREAM. */ 134 135static void 136print_range (struct type *type, struct ui_file *stream) 137{ 138 struct type *target_type; 139 target_type = TYPE_TARGET_TYPE (type); 140 if (target_type == NULL) 141 target_type = type; 142 143 switch (TYPE_CODE (target_type)) 144 { 145 case TYPE_CODE_RANGE: 146 case TYPE_CODE_INT: 147 case TYPE_CODE_BOOL: 148 case TYPE_CODE_CHAR: 149 case TYPE_CODE_ENUM: 150 break; 151 default: 152 target_type = builtin_type_ada_int; 153 break; 154 } 155 156 if (TYPE_NFIELDS (type) < 2) 157 { 158 /* A range needs at least 2 bounds to be printed. If there are less 159 than 2, just print the type name instead of the range itself. 160 This check handles cases such as characters, for example. 161 162 Note that if the name is not defined, then we don't print anything. 163 */ 164 fprintf_filtered (stream, "%.*s", 165 ada_name_prefix_len (TYPE_NAME (type)), 166 TYPE_NAME (type)); 167 } 168 else 169 { 170 /* We extract the range type bounds respectively from the first element 171 and the last element of the type->fields array */ 172 const LONGEST lower_bound = (LONGEST) TYPE_LOW_BOUND (type); 173 const LONGEST upper_bound = 174 (LONGEST) TYPE_FIELD_BITPOS (type, TYPE_NFIELDS (type) - 1); 175 176 ada_print_scalar (target_type, lower_bound, stream); 177 fprintf_filtered (stream, " .. "); 178 ada_print_scalar (target_type, upper_bound, stream); 179 } 180} 181 182/* Print the number or discriminant bound at BOUNDS+*N on STREAM, and 183 set *N past the bound and its delimiter, if any. */ 184 185static void 186print_range_bound (struct type *type, char *bounds, int *n, 187 struct ui_file *stream) 188{ 189 LONGEST B; 190 if (ada_scan_number (bounds, *n, &B, n)) 191 { 192 ada_print_scalar (type, B, stream); 193 if (bounds[*n] == '_') 194 *n += 2; 195 } 196 else 197 { 198 int bound_len; 199 char *bound = bounds + *n; 200 char *pend; 201 202 pend = strstr (bound, "__"); 203 if (pend == NULL) 204 *n += bound_len = strlen (bound); 205 else 206 { 207 bound_len = pend - bound; 208 *n += bound_len + 2; 209 } 210 fprintf_filtered (stream, "%.*s", bound_len, bound); 211 } 212} 213 214/* Assuming NAME[0 .. NAME_LEN-1] is the name of a range type, print 215 the value (if found) of the bound indicated by SUFFIX ("___L" or 216 "___U") according to the ___XD conventions. */ 217 218static void 219print_dynamic_range_bound (struct type *type, const char *name, int name_len, 220 const char *suffix, struct ui_file *stream) 221{ 222 static char *name_buf = NULL; 223 static size_t name_buf_len = 0; 224 LONGEST B; 225 int OK; 226 227 GROW_VECT (name_buf, name_buf_len, name_len + strlen (suffix) + 1); 228 strncpy (name_buf, name, name_len); 229 strcpy (name_buf + name_len, suffix); 230 231 B = get_int_var_value (name_buf, 0, &OK); 232 if (OK) 233 ada_print_scalar (type, B, stream); 234 else 235 fprintf_filtered (stream, "?"); 236} 237 238/* Print the range type named NAME. */ 239 240static void 241print_range_type_named (char *name, struct ui_file *stream) 242{ 243 struct type *raw_type = ada_find_any_type (name); 244 struct type *base_type; 245 LONGEST low, high; 246 char *subtype_info; 247 248 if (raw_type == NULL) 249 base_type = builtin_type_int; 250 else if (TYPE_CODE (raw_type) == TYPE_CODE_RANGE) 251 base_type = TYPE_TARGET_TYPE (raw_type); 252 else 253 base_type = raw_type; 254 255 subtype_info = strstr (name, "___XD"); 256 if (subtype_info == NULL && raw_type == NULL) 257 fprintf_filtered (stream, "? .. ?"); 258 else if (subtype_info == NULL) 259 print_range (raw_type, stream); 260 else 261 { 262 int prefix_len = subtype_info - name; 263 char *bounds_str; 264 int n; 265 266 subtype_info += 5; 267 bounds_str = strchr (subtype_info, '_'); 268 n = 1; 269 270 if (*subtype_info == 'L') 271 { 272 print_range_bound (raw_type, bounds_str, &n, stream); 273 subtype_info += 1; 274 } 275 else 276 print_dynamic_range_bound (raw_type, name, prefix_len, "___L", 277 stream); 278 279 fprintf_filtered (stream, " .. "); 280 281 if (*subtype_info == 'U') 282 print_range_bound (raw_type, bounds_str, &n, stream); 283 else 284 print_dynamic_range_bound (raw_type, name, prefix_len, "___U", 285 stream); 286 } 287} 288 289/* Print enumerated type TYPE on STREAM. */ 290 291static void 292print_enum_type (struct type *type, struct ui_file *stream) 293{ 294 int len = TYPE_NFIELDS (type); 295 int i, lastval; 296 297 fprintf_filtered (stream, "("); 298 wrap_here (" "); 299 300 lastval = 0; 301 for (i = 0; i < len; i++) 302 { 303 QUIT; 304 if (i) 305 fprintf_filtered (stream, ", "); 306 wrap_here (" "); 307 fputs_filtered (ada_enum_name (TYPE_FIELD_NAME (type, i)), stream); 308 if (lastval != TYPE_FIELD_BITPOS (type, i)) 309 { 310 fprintf_filtered (stream, " => %d", TYPE_FIELD_BITPOS (type, i)); 311 lastval = TYPE_FIELD_BITPOS (type, i); 312 } 313 lastval += 1; 314 } 315 fprintf_filtered (stream, ")"); 316} 317 318/* Print representation of Ada fixed-point type TYPE on STREAM. */ 319 320static void 321print_fixed_point_type (struct type *type, struct ui_file *stream) 322{ 323 DOUBLEST delta = ada_delta (type); 324 DOUBLEST small = ada_fixed_to_float (type, 1.0); 325 326 if (delta < 0.0) 327 fprintf_filtered (stream, "delta ??"); 328 else 329 { 330 fprintf_filtered (stream, "delta %g", (double) delta); 331 if (delta != small) 332 fprintf_filtered (stream, " <'small = %g>", (double) small); 333 } 334} 335 336/* Print representation of special VAX floating-point type TYPE on STREAM. */ 337 338static void 339print_vax_floating_point_type (struct type *type, struct ui_file *stream) 340{ 341 fprintf_filtered (stream, "<float format %c>", 342 ada_vax_float_type_suffix (type)); 343} 344 345/* Print simple (constrained) array type TYPE on STREAM. LEVEL is the 346 recursion (indentation) level, in case the element type itself has 347 nested structure, and SHOW is the number of levels of internal 348 structure to show (see ada_print_type). */ 349 350static void 351print_array_type (struct type *type, struct ui_file *stream, int show, 352 int level) 353{ 354 int bitsize; 355 int n_indices; 356 357 bitsize = 0; 358 fprintf_filtered (stream, "array ("); 359 360 n_indices = -1; 361 if (show < 0) 362 fprintf_filtered (stream, "..."); 363 else 364 { 365 if (ada_is_packed_array_type (type)) 366 type = ada_coerce_to_simple_array_type (type); 367 if (ada_is_simple_array (type)) 368 { 369 struct type *range_desc_type = 370 ada_find_parallel_type (type, "___XA"); 371 struct type *arr_type; 372 373 bitsize = 0; 374 if (range_desc_type == NULL) 375 { 376 for (arr_type = type; TYPE_CODE (arr_type) == TYPE_CODE_ARRAY; 377 arr_type = TYPE_TARGET_TYPE (arr_type)) 378 { 379 if (arr_type != type) 380 fprintf_filtered (stream, ", "); 381 print_range (TYPE_INDEX_TYPE (arr_type), stream); 382 if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0) 383 bitsize = TYPE_FIELD_BITSIZE (arr_type, 0); 384 } 385 } 386 else 387 { 388 int k; 389 n_indices = TYPE_NFIELDS (range_desc_type); 390 for (k = 0, arr_type = type; 391 k < n_indices; 392 k += 1, arr_type = TYPE_TARGET_TYPE (arr_type)) 393 { 394 if (k > 0) 395 fprintf_filtered (stream, ", "); 396 print_range_type_named (TYPE_FIELD_NAME 397 (range_desc_type, k), stream); 398 if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0) 399 bitsize = TYPE_FIELD_BITSIZE (arr_type, 0); 400 } 401 } 402 } 403 else 404 { 405 int i, i0; 406 for (i = i0 = ada_array_arity (type); i > 0; i -= 1) 407 fprintf_filtered (stream, "%s<>", i == i0 ? "" : ", "); 408 } 409 } 410 411 fprintf_filtered (stream, ") of "); 412 wrap_here (""); 413 ada_print_type (ada_array_element_type (type, n_indices), "", stream, 414 show == 0 ? 0 : show - 1, level + 1); 415 if (bitsize > 0) 416 fprintf_filtered (stream, " <packed: %d-bit elements>", bitsize); 417} 418 419/* Print the choices encoded by field FIELD_NUM of variant-part TYPE on 420 STREAM, assuming the VAL_TYPE is the type of the values. */ 421 422static void 423print_choices (struct type *type, int field_num, struct ui_file *stream, 424 struct type *val_type) 425{ 426 int have_output; 427 int p; 428 const char *name = TYPE_FIELD_NAME (type, field_num); 429 430 have_output = 0; 431 432 /* Skip over leading 'V': NOTE soon to be obsolete. */ 433 if (name[0] == 'V') 434 { 435 if (!ada_scan_number (name, 1, NULL, &p)) 436 goto Huh; 437 } 438 else 439 p = 0; 440 441 while (1) 442 { 443 switch (name[p]) 444 { 445 default: 446 return; 447 case 'S': 448 case 'R': 449 case 'O': 450 if (have_output) 451 fprintf_filtered (stream, " | "); 452 have_output = 1; 453 break; 454 } 455 456 switch (name[p]) 457 { 458 case 'S': 459 { 460 LONGEST W; 461 if (!ada_scan_number (name, p + 1, &W, &p)) 462 goto Huh; 463 ada_print_scalar (val_type, W, stream); 464 break; 465 } 466 case 'R': 467 { 468 LONGEST L, U; 469 if (!ada_scan_number (name, p + 1, &L, &p) 470 || name[p] != 'T' || !ada_scan_number (name, p + 1, &U, &p)) 471 goto Huh; 472 ada_print_scalar (val_type, L, stream); 473 fprintf_filtered (stream, " .. "); 474 ada_print_scalar (val_type, U, stream); 475 break; 476 } 477 case 'O': 478 fprintf_filtered (stream, "others"); 479 p += 1; 480 break; 481 } 482 } 483 484Huh: 485 fprintf_filtered (stream, "??"); 486 487} 488 489/* Assuming that field FIELD_NUM of TYPE is a VARIANTS field whose 490 discriminant is contained in OUTER_TYPE, print its variants on STREAM. 491 LEVEL is the recursion 492 (indentation) level, in case any of the fields themselves have 493 nested structure, and SHOW is the number of levels of internal structure 494 to show (see ada_print_type). For this purpose, fields nested in a 495 variant part are taken to be at the same level as the fields 496 immediately outside the variant part. */ 497 498static void 499print_variant_clauses (struct type *type, int field_num, 500 struct type *outer_type, struct ui_file *stream, 501 int show, int level) 502{ 503 int i; 504 struct type *var_type; 505 struct type *discr_type; 506 507 var_type = TYPE_FIELD_TYPE (type, field_num); 508 discr_type = ada_variant_discrim_type (var_type, outer_type); 509 510 if (TYPE_CODE (var_type) == TYPE_CODE_PTR) 511 { 512 var_type = TYPE_TARGET_TYPE (var_type); 513 if (TYPE_FLAGS (var_type) & TYPE_FLAG_STUB) 514 { 515 var_type = ada_find_parallel_type (var_type, "___XVU"); 516 if (var_type == NULL) 517 return; 518 } 519 } 520 521 for (i = 0; i < TYPE_NFIELDS (var_type); i += 1) 522 { 523 fprintf_filtered (stream, "\n%*swhen ", level + 4, ""); 524 print_choices (var_type, i, stream, discr_type); 525 fprintf_filtered (stream, " =>"); 526 if (print_record_field_types (TYPE_FIELD_TYPE (var_type, i), 527 outer_type, stream, show, level + 4) <= 0) 528 fprintf_filtered (stream, " null;"); 529 } 530} 531 532/* Assuming that field FIELD_NUM of TYPE is a variant part whose 533 discriminants are contained in OUTER_TYPE, print a description of it 534 on STREAM. LEVEL is the recursion (indentation) level, in case any of 535 the fields themselves have nested structure, and SHOW is the number of 536 levels of internal structure to show (see ada_print_type). For this 537 purpose, fields nested in a variant part are taken to be at the same 538 level as the fields immediately outside the variant part. */ 539 540static void 541print_variant_part (struct type *type, int field_num, struct type *outer_type, 542 struct ui_file *stream, int show, int level) 543{ 544 fprintf_filtered (stream, "\n%*scase %s is", level + 4, "", 545 ada_variant_discrim_name 546 (TYPE_FIELD_TYPE (type, field_num))); 547 print_variant_clauses (type, field_num, outer_type, stream, show, 548 level + 4); 549 fprintf_filtered (stream, "\n%*send case;", level + 4, ""); 550} 551 552/* Print a description on STREAM of the fields in record type TYPE, whose 553 discriminants are in OUTER_TYPE. LEVEL is the recursion (indentation) 554 level, in case any of the fields themselves have nested structure, 555 and SHOW is the number of levels of internal structure to show 556 (see ada_print_type). Does not print parent type information of TYPE. 557 Returns 0 if no fields printed, -1 for an incomplete type, else > 0. 558 Prints each field beginning on a new line, but does not put a new line at 559 end. */ 560 561static int 562print_record_field_types (struct type *type, struct type *outer_type, 563 struct ui_file *stream, int show, int level) 564{ 565 int len, i, flds; 566 567 flds = 0; 568 len = TYPE_NFIELDS (type); 569 570 if (len == 0 && (TYPE_FLAGS (type) & TYPE_FLAG_STUB) != 0) 571 return -1; 572 573 for (i = 0; i < len; i += 1) 574 { 575 QUIT; 576 577 if (ada_is_parent_field (type, i) || ada_is_ignored_field (type, i)) 578 ; 579 else if (ada_is_wrapper_field (type, i)) 580 flds += print_record_field_types (TYPE_FIELD_TYPE (type, i), type, 581 stream, show, level); 582 else if (ada_is_variant_part (type, i)) 583 { 584 print_variant_part (type, i, outer_type, stream, show, level); 585 flds = 1; 586 } 587 else 588 { 589 flds += 1; 590 fprintf_filtered (stream, "\n%*s", level + 4, ""); 591 ada_print_type (TYPE_FIELD_TYPE (type, i), 592 TYPE_FIELD_NAME (type, i), 593 stream, show - 1, level + 4); 594 fprintf_filtered (stream, ";"); 595 } 596 } 597 598 return flds; 599} 600 601/* Print record type TYPE on STREAM. LEVEL is the recursion (indentation) 602 level, in case the element type itself has nested structure, and SHOW is 603 the number of levels of internal structure to show (see ada_print_type). */ 604 605static void 606print_record_type (struct type *type0, struct ui_file *stream, int show, 607 int level) 608{ 609 struct type *parent_type; 610 struct type *type; 611 612 type = type0; 613 if (TYPE_FLAGS (type) & TYPE_FLAG_STUB) 614 { 615 struct type *type1 = ada_find_parallel_type (type, "___XVE"); 616 if (type1 != NULL) 617 type = type1; 618 } 619 620 parent_type = ada_parent_type (type); 621 if (ada_type_name (parent_type) != NULL) 622 fprintf_filtered (stream, "new %s with ", 623 demangled_type_name (parent_type)); 624 else if (parent_type == NULL && ada_is_tagged_type (type)) 625 fprintf_filtered (stream, "tagged "); 626 627 fprintf_filtered (stream, "record"); 628 629 if (show < 0) 630 fprintf_filtered (stream, " ... end record"); 631 else 632 { 633 int flds; 634 635 flds = 0; 636 if (parent_type != NULL && ada_type_name (parent_type) == NULL) 637 flds += print_record_field_types (parent_type, parent_type, 638 stream, show, level); 639 flds += print_record_field_types (type, type, stream, show, level); 640 641 if (flds > 0) 642 fprintf_filtered (stream, "\n%*send record", level, ""); 643 else if (flds < 0) 644 fprintf_filtered (stream, " <incomplete type> end record"); 645 else 646 fprintf_filtered (stream, " null; end record"); 647 } 648} 649 650/* Print the unchecked union type TYPE in something resembling Ada 651 format on STREAM. LEVEL is the recursion (indentation) level 652 in case the element type itself has nested structure, and SHOW is the 653 number of levels of internal structure to show (see ada_print_type). */ 654static void 655print_unchecked_union_type (struct type *type, struct ui_file *stream, 656 int show, int level) 657{ 658 fprintf_filtered (stream, "record (?) is"); 659 660 if (show < 0) 661 fprintf_filtered (stream, " ... end record"); 662 else if (TYPE_NFIELDS (type) == 0) 663 fprintf_filtered (stream, " null; end record"); 664 else 665 { 666 int i; 667 668 fprintf_filtered (stream, "\n%*scase ? is", level + 4, ""); 669 670 for (i = 0; i < TYPE_NFIELDS (type); i += 1) 671 { 672 fprintf_filtered (stream, "\n%*swhen ? =>\n%*s", level + 8, "", 673 level + 12, ""); 674 ada_print_type (TYPE_FIELD_TYPE (type, i), 675 TYPE_FIELD_NAME (type, i), 676 stream, show - 1, level + 12); 677 fprintf_filtered (stream, ";"); 678 } 679 680 fprintf_filtered (stream, "\n%*send case;\n%*send record", 681 level + 4, "", level, ""); 682 } 683} 684 685 686 687/* Print function or procedure type TYPE on STREAM. Make it a header 688 for function or procedure NAME if NAME is not null. */ 689 690static void 691print_func_type (struct type *type, struct ui_file *stream, char *name) 692{ 693 int i, len = TYPE_NFIELDS (type); 694 695 if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID) 696 fprintf_filtered (stream, "procedure"); 697 else 698 fprintf_filtered (stream, "function"); 699 700 if (name != NULL && name[0] != '\0') 701 fprintf_filtered (stream, " %s", name); 702 703 if (len > 0) 704 { 705 fprintf_filtered (stream, " ("); 706 for (i = 0; i < len; i += 1) 707 { 708 if (i > 0) 709 { 710 fputs_filtered ("; ", stream); 711 wrap_here (" "); 712 } 713 fprintf_filtered (stream, "a%d: ", i + 1); 714 ada_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0); 715 } 716 fprintf_filtered (stream, ")"); 717 } 718 719 if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_VOID) 720 { 721 fprintf_filtered (stream, " return "); 722 ada_print_type (TYPE_TARGET_TYPE (type), "", stream, 0, 0); 723 } 724} 725 726 727/* Print a description of a type TYPE0. 728 Output goes to STREAM (via stdio). 729 If VARSTRING is a non-empty string, print as an Ada variable/field 730 declaration. 731 SHOW+1 is the maximum number of levels of internal type structure 732 to show (this applies to record types, enumerated types, and 733 array types). 734 SHOW is the number of levels of internal type structure to show 735 when there is a type name for the SHOWth deepest level (0th is 736 outer level). 737 When SHOW<0, no inner structure is shown. 738 LEVEL indicates level of recursion (for nested definitions). */ 739 740void 741ada_print_type (struct type *type0, char *varstring, struct ui_file *stream, 742 int show, int level) 743{ 744 enum type_code code; 745 int demangled_args; 746 struct type *type = ada_completed_type (ada_get_base_type (type0)); 747 char *type_name = demangled_type_name (type); 748 int is_var_decl = (varstring != NULL && varstring[0] != '\0'); 749 750 if (type == NULL) 751 { 752 if (is_var_decl) 753 fprintf_filtered (stream, "%.*s: ", 754 ada_name_prefix_len (varstring), varstring); 755 fprintf_filtered (stream, "<null type?>"); 756 return; 757 } 758 759 if (show > 0) 760 CHECK_TYPEDEF (type); 761 762 if (is_var_decl && TYPE_CODE (type) != TYPE_CODE_FUNC) 763 fprintf_filtered (stream, "%.*s: ", 764 ada_name_prefix_len (varstring), varstring); 765 766 if (type_name != NULL && show <= 0) 767 { 768 fprintf_filtered (stream, "%.*s", 769 ada_name_prefix_len (type_name), type_name); 770 return; 771 } 772 773 if (ada_is_aligner_type (type)) 774 ada_print_type (ada_aligned_type (type), "", stream, show, level); 775 else if (ada_is_packed_array_type (type)) 776 print_array_type (type, stream, show, level); 777 else 778 switch (TYPE_CODE (type)) 779 { 780 default: 781 fprintf_filtered (stream, "<"); 782 c_print_type (type, "", stream, show, level); 783 fprintf_filtered (stream, ">"); 784 break; 785 case TYPE_CODE_PTR: 786 fprintf_filtered (stream, "access "); 787 ada_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level); 788 break; 789 case TYPE_CODE_REF: 790 fprintf_filtered (stream, "<ref> "); 791 ada_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level); 792 break; 793 case TYPE_CODE_ARRAY: 794 print_array_type (type, stream, show, level); 795 break; 796 case TYPE_CODE_INT: 797 if (ada_is_fixed_point_type (type)) 798 print_fixed_point_type (type, stream); 799 else if (ada_is_vax_floating_type (type)) 800 print_vax_floating_point_type (type, stream); 801 else 802 { 803 char *name = ada_type_name (type); 804 if (!ada_is_range_type_name (name)) 805 fprintf_filtered (stream, "<%d-byte integer>", 806 TYPE_LENGTH (type)); 807 else 808 { 809 fprintf_filtered (stream, "range "); 810 print_range_type_named (name, stream); 811 } 812 } 813 break; 814 case TYPE_CODE_RANGE: 815 if (ada_is_fixed_point_type (type)) 816 print_fixed_point_type (type, stream); 817 else if (ada_is_vax_floating_type (type)) 818 print_vax_floating_point_type (type, stream); 819 else if (ada_is_modular_type (type)) 820 fprintf_filtered (stream, "mod %ld", (long) ada_modulus (type)); 821 else 822 { 823 fprintf_filtered (stream, "range "); 824 print_range (type, stream); 825 } 826 break; 827 case TYPE_CODE_FLT: 828 fprintf_filtered (stream, "<%d-byte float>", TYPE_LENGTH (type)); 829 break; 830 case TYPE_CODE_ENUM: 831 if (show < 0) 832 fprintf_filtered (stream, "(...)"); 833 else 834 print_enum_type (type, stream); 835 break; 836 case TYPE_CODE_STRUCT: 837 if (ada_is_array_descriptor (type)) 838 print_array_type (type, stream, show, level); 839 else if (ada_is_bogus_array_descriptor (type)) 840 fprintf_filtered (stream, 841 "array (?) of ? (<mal-formed descriptor>)"); 842 else 843 print_record_type (type, stream, show, level); 844 break; 845 case TYPE_CODE_UNION: 846 print_unchecked_union_type (type, stream, show, level); 847 break; 848 case TYPE_CODE_FUNC: 849 print_func_type (type, stream, varstring); 850 break; 851 } 852} 853