dbxout.c revision 50495
1/* Output dbx-format symbol table information from GNU compiler. 2 Copyright (C) 1987, 88, 92-97, 1998 Free Software Foundation, Inc. 3 4This file is part of GNU CC. 5 6GNU CC is free software; you can redistribute it and/or modify 7it under the terms of the GNU General Public License as published by 8the Free Software Foundation; either version 2, or (at your option) 9any later version. 10 11GNU CC is distributed in the hope that it will be useful, 12but WITHOUT ANY WARRANTY; without even the implied warranty of 13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14GNU General Public License for more details. 15 16You should have received a copy of the GNU General Public License 17along with GNU CC; see the file COPYING. If not, write to 18the Free Software Foundation, 59 Temple Place - Suite 330, 19Boston, MA 02111-1307, USA. */ 20 21 22/* Output dbx-format symbol table data. 23 This consists of many symbol table entries, each of them 24 a .stabs assembler pseudo-op with four operands: 25 a "name" which is really a description of one symbol and its type, 26 a "code", which is a symbol defined in stab.h whose name starts with N_, 27 an unused operand always 0, 28 and a "value" which is an address or an offset. 29 The name is enclosed in doublequote characters. 30 31 Each function, variable, typedef, and structure tag 32 has a symbol table entry to define it. 33 The beginning and end of each level of name scoping within 34 a function are also marked by special symbol table entries. 35 36 The "name" consists of the symbol name, a colon, a kind-of-symbol letter, 37 and a data type number. The data type number may be followed by 38 "=" and a type definition; normally this will happen the first time 39 the type number is mentioned. The type definition may refer to 40 other types by number, and those type numbers may be followed 41 by "=" and nested definitions. 42 43 This can make the "name" quite long. 44 When a name is more than 80 characters, we split the .stabs pseudo-op 45 into two .stabs pseudo-ops, both sharing the same "code" and "value". 46 The first one is marked as continued with a double-backslash at the 47 end of its "name". 48 49 The kind-of-symbol letter distinguished function names from global 50 variables from file-scope variables from parameters from auto 51 variables in memory from typedef names from register variables. 52 See `dbxout_symbol'. 53 54 The "code" is mostly redundant with the kind-of-symbol letter 55 that goes in the "name", but not entirely: for symbols located 56 in static storage, the "code" says which segment the address is in, 57 which controls how it is relocated. 58 59 The "value" for a symbol in static storage 60 is the core address of the symbol (actually, the assembler 61 label for the symbol). For a symbol located in a stack slot 62 it is the stack offset; for one in a register, the register number. 63 For a typedef symbol, it is zero. 64 65 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be 66 output while in the text section. 67 68 For more on data type definitions, see `dbxout_type'. */ 69 70#include "config.h" 71#include "system.h" 72 73#include "tree.h" 74#include "rtl.h" 75#include "flags.h" 76#include "regs.h" 77#include "insn-config.h" 78#include "reload.h" 79#include "defaults.h" 80#include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */ 81#include "dbxout.h" 82#include "toplev.h" 83 84#ifdef XCOFF_DEBUGGING_INFO 85#include "xcoffout.h" 86#endif 87 88#ifndef ASM_STABS_OP 89#define ASM_STABS_OP ".stabs" 90#endif 91 92#ifndef ASM_STABN_OP 93#define ASM_STABN_OP ".stabn" 94#endif 95 96#ifndef DBX_TYPE_DECL_STABS_CODE 97#define DBX_TYPE_DECL_STABS_CODE N_LSYM 98#endif 99 100#ifndef DBX_STATIC_CONST_VAR_CODE 101#define DBX_STATIC_CONST_VAR_CODE N_FUN 102#endif 103 104#ifndef DBX_REGPARM_STABS_CODE 105#define DBX_REGPARM_STABS_CODE N_RSYM 106#endif 107 108#ifndef DBX_REGPARM_STABS_LETTER 109#define DBX_REGPARM_STABS_LETTER 'P' 110#endif 111 112/* This is used for parameters passed by invisible reference in a register. */ 113#ifndef GDB_INV_REF_REGPARM_STABS_LETTER 114#define GDB_INV_REF_REGPARM_STABS_LETTER 'a' 115#endif 116 117#ifndef DBX_MEMPARM_STABS_LETTER 118#define DBX_MEMPARM_STABS_LETTER 'p' 119#endif 120 121#ifndef FILE_NAME_JOINER 122#define FILE_NAME_JOINER "/" 123#endif 124 125/* Nonzero means if the type has methods, only output debugging 126 information if methods are actually written to the asm file. This 127 optimization only works if the debugger can detect the special C++ 128 marker. */ 129 130#define MINIMAL_DEBUG 1 131 132#ifdef NO_DOLLAR_IN_LABEL 133#ifdef NO_DOT_IN_LABEL 134#undef MINIMAL_DEBUG 135#define MINIMAL_DEBUG 0 136#endif 137#endif 138 139char *getpwd (); 140 141/* Typical USG systems don't have stab.h, and they also have 142 no use for DBX-format debugging info. */ 143 144#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) 145 146static int flag_minimal_debug = MINIMAL_DEBUG; 147 148/* Nonzero if we have actually used any of the GDB extensions 149 to the debugging format. The idea is that we use them for the 150 first time only if there's a strong reason, but once we have done that, 151 we use them whenever convenient. */ 152 153static int have_used_extensions = 0; 154 155/* Number for the next N_SOL filename stabs label. The number 0 is reserved 156 for the N_SO filename stabs label. */ 157 158static int source_label_number = 1; 159 160#ifdef DEBUG_SYMS_TEXT 161#define FORCE_TEXT text_section (); 162#else 163#define FORCE_TEXT 164#endif 165 166/* If there is a system stabs.h, use it. Otherwise, use our own. */ 167 168#ifndef HAVE_STABS_H 169#include "gstab.h" 170#else 171#include <stab.h> 172 173/* This is a GNU extension we need to reference in this file. */ 174#ifndef N_CATCH 175#define N_CATCH 0x54 176#endif 177#endif 178 179#ifdef __GNU_STAB__ 180#define STAB_CODE_TYPE enum __stab_debug_code 181#else 182#define STAB_CODE_TYPE int 183#endif 184 185/* 1 if PARM is passed to this function in memory. */ 186 187#define PARM_PASSED_IN_MEMORY(PARM) \ 188 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM) 189 190/* A C expression for the integer offset value of an automatic variable 191 (N_LSYM) having address X (an RTX). */ 192#ifndef DEBUGGER_AUTO_OFFSET 193#define DEBUGGER_AUTO_OFFSET(X) \ 194 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0) 195#endif 196 197/* A C expression for the integer offset value of an argument (N_PSYM) 198 having address X (an RTX). The nominal offset is OFFSET. */ 199#ifndef DEBUGGER_ARG_OFFSET 200#define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET) 201#endif 202 203/* Stream for writing to assembler file. */ 204 205static FILE *asmfile; 206 207/* Last source file name mentioned in a NOTE insn. */ 208 209static char *lastfile; 210 211/* Current working directory. */ 212 213static char *cwd; 214 215enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED}; 216 217/* Structure recording information about a C data type. 218 The status element says whether we have yet output 219 the definition of the type. TYPE_XREF says we have 220 output it as a cross-reference only. 221 The file_number and type_number elements are used if DBX_USE_BINCL 222 is defined. */ 223 224struct typeinfo 225{ 226 enum typestatus status; 227#ifdef DBX_USE_BINCL 228 int file_number; 229 int type_number; 230#endif 231}; 232 233/* Vector recording information about C data types. 234 When we first notice a data type (a tree node), 235 we assign it a number using next_type_number. 236 That is its index in this vector. */ 237 238struct typeinfo *typevec; 239 240/* Number of elements of space allocated in `typevec'. */ 241 242static int typevec_len; 243 244/* In dbx output, each type gets a unique number. 245 This is the number for the next type output. 246 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */ 247 248static int next_type_number; 249 250#ifdef DBX_USE_BINCL 251 252/* When using N_BINCL in dbx output, each type number is actually a 253 pair of the file number and the type number within the file. 254 This is a stack of input files. */ 255 256struct dbx_file 257{ 258 struct dbx_file *next; 259 int file_number; 260 int next_type_number; 261}; 262 263/* This is the top of the stack. */ 264 265static struct dbx_file *current_file; 266 267/* This is the next file number to use. */ 268 269static int next_file_number; 270 271#endif /* DBX_USE_BINCL */ 272 273/* In dbx output, we must assign symbol-blocks id numbers 274 in the order in which their beginnings are encountered. 275 We output debugging info that refers to the beginning and 276 end of the ranges of code in each block 277 with assembler labels LBBn and LBEn, where n is the block number. 278 The labels are generated in final, which assigns numbers to the 279 blocks in the same way. */ 280 281static int next_block_number; 282 283/* These variables are for dbxout_symbol to communicate to 284 dbxout_finish_symbol. 285 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h. 286 current_sym_value and current_sym_addr are two ways to address the 287 value to store in the symtab entry. 288 current_sym_addr if nonzero represents the value as an rtx. 289 If that is zero, current_sym_value is used. This is used 290 when the value is an offset (such as for auto variables, 291 register variables and parms). */ 292 293static STAB_CODE_TYPE current_sym_code; 294static int current_sym_value; 295static rtx current_sym_addr; 296 297/* Number of chars of symbol-description generated so far for the 298 current symbol. Used by CHARS and CONTIN. */ 299 300static int current_sym_nchars; 301 302/* Report having output N chars of the current symbol-description. */ 303 304#define CHARS(N) (current_sym_nchars += (N)) 305 306/* Break the current symbol-description, generating a continuation, 307 if it has become long. */ 308 309#ifndef DBX_CONTIN_LENGTH 310#define DBX_CONTIN_LENGTH 80 311#endif 312 313#if DBX_CONTIN_LENGTH > 0 314#define CONTIN \ 315 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0) 316#else 317#define CONTIN 318#endif 319 320void dbxout_types (); 321void dbxout_args (); 322void dbxout_symbol (); 323 324#if defined(ASM_OUTPUT_SECTION_NAME) 325static void dbxout_function_end PROTO((void)); 326#endif 327static void dbxout_typedefs PROTO((tree)); 328static void dbxout_type_index PROTO((tree)); 329#if DBX_CONTIN_LENGTH > 0 330static void dbxout_continue PROTO((void)); 331#endif 332static void dbxout_type_fields PROTO((tree)); 333static void dbxout_type_method_1 PROTO((tree, char *)); 334static void dbxout_type_methods PROTO((tree)); 335static void dbxout_range_type PROTO((tree)); 336static void dbxout_type PROTO((tree, int, int)); 337static void print_int_cst_octal PROTO((tree)); 338static void print_octal PROTO((unsigned HOST_WIDE_INT, int)); 339static void dbxout_type_name PROTO((tree)); 340static void dbxout_symbol_location PROTO((tree, tree, char *, rtx)); 341static void dbxout_symbol_name PROTO((tree, char *, int)); 342static void dbxout_prepare_symbol PROTO((tree)); 343static void dbxout_finish_symbol PROTO((tree)); 344static void dbxout_block PROTO((tree, int, tree)); 345static void dbxout_really_begin_function PROTO((tree)); 346 347#if defined(ASM_OUTPUT_SECTION_NAME) 348static void 349dbxout_function_end () 350{ 351 static int scope_labelno = 0; 352 char lscope_label_name[100]; 353 /* Convert Ltext into the appropriate format for local labels in case 354 the system doesn't insert underscores in front of user generated 355 labels. */ 356 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno); 357 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Lscope", scope_labelno); 358 scope_labelno++; 359 360 /* By convention, GCC will mark the end of a function with an N_FUN 361 symbol and an empty string. */ 362 fprintf (asmfile, "%s \"\",%d,0,0,", ASM_STABS_OP, N_FUN); 363 assemble_name (asmfile, lscope_label_name); 364 fputc ('-', asmfile); 365 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); 366 fprintf (asmfile, "\n"); 367} 368#endif /* ! NO_DBX_FUNCTION_END */ 369 370/* At the beginning of compilation, start writing the symbol table. 371 Initialize `typevec' and output the standard data types of C. */ 372 373void 374dbxout_init (asm_file, input_file_name, syms) 375 FILE *asm_file; 376 char *input_file_name; 377 tree syms; 378{ 379 char ltext_label_name[100]; 380 381 asmfile = asm_file; 382 383 typevec_len = 100; 384 typevec = (struct typeinfo *) xmalloc (typevec_len * sizeof typevec[0]); 385 bzero ((char *) typevec, typevec_len * sizeof typevec[0]); 386 387 /* Convert Ltext into the appropriate format for local labels in case 388 the system doesn't insert underscores in front of user generated 389 labels. */ 390 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0); 391 392 /* Put the current working directory in an N_SO symbol. */ 393#ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this, 394 but GDB always does. */ 395 if (use_gnu_debug_info_extensions) 396#endif 397 { 398 if (!cwd && (cwd = getpwd ()) && (!*cwd || cwd[strlen (cwd) - 1] != '/')) 399 { 400 char *wdslash = xmalloc (strlen (cwd) + sizeof (FILE_NAME_JOINER)); 401 sprintf (wdslash, "%s%s", cwd, FILE_NAME_JOINER); 402 cwd = wdslash; 403 } 404 if (cwd) 405 { 406#ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY 407 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd); 408#else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */ 409 fprintf (asmfile, "%s ", ASM_STABS_OP); 410 output_quoted_string (asmfile, cwd); 411 fprintf (asmfile, ",%d,0,0,%s\n", N_SO, <ext_label_name[1]); 412#endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */ 413 } 414 } 415 416#ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME 417 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That 418 would give us an N_SOL, and we want an N_SO. */ 419 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name); 420#else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */ 421 /* We include outputting `Ltext:' here, 422 because that gives you a way to override it. */ 423 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */ 424 fprintf (asmfile, "%s ", ASM_STABS_OP); 425 output_quoted_string (asmfile, input_file_name); 426 fprintf (asmfile, ",%d,0,0,%s\n", 427 N_SO, <ext_label_name[1]); 428 text_section (); 429 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Ltext", 0); 430#endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */ 431 432 /* Possibly output something to inform GDB that this compilation was by 433 GCC. It's easier for GDB to parse it when after the N_SO's. This 434 is used in Solaris 2. */ 435#ifdef ASM_IDENTIFY_GCC_AFTER_SOURCE 436 ASM_IDENTIFY_GCC_AFTER_SOURCE (asmfile); 437#endif 438 439 lastfile = input_file_name; 440 441 next_type_number = 1; 442 next_block_number = 2; 443 444#ifdef DBX_USE_BINCL 445 current_file = (struct dbx_file *) xmalloc (sizeof *current_file); 446 current_file->next = NULL; 447 current_file->file_number = 0; 448 current_file->next_type_number = 1; 449 next_file_number = 1; 450#endif 451 452 /* Make sure that types `int' and `char' have numbers 1 and 2. 453 Definitions of other integer types will refer to those numbers. 454 (Actually it should no longer matter what their numbers are. 455 Also, if any types with tags have been defined, dbxout_symbol 456 will output them first, so the numbers won't be 1 and 2. That 457 happens in C++. So it's a good thing it should no longer matter). */ 458 459#ifdef DBX_OUTPUT_STANDARD_TYPES 460 DBX_OUTPUT_STANDARD_TYPES (syms); 461#else 462 dbxout_symbol (TYPE_NAME (integer_type_node), 0); 463 dbxout_symbol (TYPE_NAME (char_type_node), 0); 464#endif 465 466 /* Get all permanent types that have typedef names, 467 and output them all, except for those already output. */ 468 469 dbxout_typedefs (syms); 470} 471 472/* Output any typedef names for types described by TYPE_DECLs in SYMS, 473 in the reverse order from that which is found in SYMS. */ 474 475static void 476dbxout_typedefs (syms) 477 tree syms; 478{ 479 if (syms) 480 { 481 dbxout_typedefs (TREE_CHAIN (syms)); 482 if (TREE_CODE (syms) == TYPE_DECL) 483 { 484 tree type = TREE_TYPE (syms); 485 if (TYPE_NAME (type) 486 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL 487 && TYPE_SIZE (type) != NULL_TREE 488 && ! TREE_ASM_WRITTEN (TYPE_NAME (type))) 489 dbxout_symbol (TYPE_NAME (type), 0); 490 } 491 } 492} 493 494/* Change to reading from a new source file. Generate a N_BINCL stab. */ 495 496void 497dbxout_start_new_source_file (filename) 498 char *filename; 499{ 500#ifdef DBX_USE_BINCL 501 struct dbx_file *n = (struct dbx_file *) xmalloc (sizeof *n); 502 503 n->next = current_file; 504 n->file_number = next_file_number++; 505 n->next_type_number = 1; 506 current_file = n; 507 fprintf (asmfile, "%s ", ASM_STABS_OP); 508 output_quoted_string (asmfile, filename); 509 fprintf (asmfile, ",%d,0,0,0\n", N_BINCL); 510#endif 511} 512 513/* Revert to reading a previous source file. Generate a N_EINCL stab. */ 514 515void 516dbxout_resume_previous_source_file () 517{ 518#ifdef DBX_USE_BINCL 519 struct dbx_file *next; 520 521 fprintf (asmfile, "%s %d,0,0,0\n", ASM_STABN_OP, N_EINCL); 522 next = current_file->next; 523 free (current_file); 524 current_file = next; 525#endif 526} 527 528/* Output debugging info to FILE to switch to sourcefile FILENAME. */ 529 530void 531dbxout_source_file (file, filename) 532 FILE *file; 533 char *filename; 534{ 535 char ltext_label_name[100]; 536 537 if (filename && (lastfile == 0 || strcmp (filename, lastfile))) 538 { 539#ifdef DBX_OUTPUT_SOURCE_FILENAME 540 DBX_OUTPUT_SOURCE_FILENAME (file, filename); 541#else 542 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 543 source_label_number); 544 fprintf (file, "%s ", ASM_STABS_OP); 545 output_quoted_string (file, filename); 546 fprintf (file, ",%d,0,0,%s\n", N_SOL, <ext_label_name[1]); 547 if (current_function_decl != NULL_TREE 548 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE) 549 ; /* Don't change section amid function. */ 550 else 551 text_section (); 552 ASM_OUTPUT_INTERNAL_LABEL (file, "Ltext", source_label_number); 553 source_label_number++; 554#endif 555 lastfile = filename; 556 } 557} 558 559/* Output a line number symbol entry into output stream FILE, 560 for source file FILENAME and line number LINENO. */ 561 562void 563dbxout_source_line (file, filename, lineno) 564 FILE *file; 565 char *filename; 566 int lineno; 567{ 568 dbxout_source_file (file, filename); 569 570#ifdef ASM_OUTPUT_SOURCE_LINE 571 ASM_OUTPUT_SOURCE_LINE (file, lineno); 572#else 573 fprintf (file, "\t%s %d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno); 574#endif 575} 576 577/* At the end of compilation, finish writing the symbol table. 578 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is 579 to do nothing. */ 580 581void 582dbxout_finish (file, filename) 583 FILE *file; 584 char *filename; 585{ 586#ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END 587 DBX_OUTPUT_MAIN_SOURCE_FILE_END (file, filename); 588#endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */ 589} 590 591/* Output the index of a type. */ 592 593static void 594dbxout_type_index (type) 595 tree type; 596{ 597#ifndef DBX_USE_BINCL 598 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type)); 599 CHARS (3); 600#else 601 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)]; 602 fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number); 603 CHARS (7); 604#endif 605} 606 607#if DBX_CONTIN_LENGTH > 0 608/* Continue a symbol-description that gets too big. 609 End one symbol table entry with a double-backslash 610 and start a new one, eventually producing something like 611 .stabs "start......\\",code,0,value 612 .stabs "...rest",code,0,value */ 613 614static void 615dbxout_continue () 616{ 617#ifdef DBX_CONTIN_CHAR 618 fprintf (asmfile, "%c", DBX_CONTIN_CHAR); 619#else 620 fprintf (asmfile, "\\\\"); 621#endif 622 dbxout_finish_symbol (NULL_TREE); 623 fprintf (asmfile, "%s \"", ASM_STABS_OP); 624 current_sym_nchars = 0; 625} 626#endif /* DBX_CONTIN_LENGTH > 0 */ 627 628/* Subroutine of `dbxout_type'. Output the type fields of TYPE. 629 This must be a separate function because anonymous unions require 630 recursive calls. */ 631 632static void 633dbxout_type_fields (type) 634 tree type; 635{ 636 tree tem; 637 /* Output the name, type, position (in bits), size (in bits) of each 638 field. */ 639 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem)) 640 { 641 /* Omit here local type decls until we know how to support them. */ 642 if (TREE_CODE (tem) == TYPE_DECL) 643 continue; 644 /* Omit fields whose position or size are variable. */ 645 else if (TREE_CODE (tem) == FIELD_DECL 646 && (TREE_CODE (DECL_FIELD_BITPOS (tem)) != INTEGER_CST 647 || TREE_CODE (DECL_SIZE (tem)) != INTEGER_CST)) 648 continue; 649 /* Omit here the nameless fields that are used to skip bits. */ 650 else if (DECL_IGNORED_P (tem)) 651 continue; 652 else if (TREE_CODE (tem) != CONST_DECL) 653 { 654 /* Continue the line if necessary, 655 but not before the first field. */ 656 if (tem != TYPE_FIELDS (type)) 657 { 658 CONTIN; 659 } 660 661 if (use_gnu_debug_info_extensions 662 && flag_minimal_debug 663 && TREE_CODE (tem) == FIELD_DECL 664 && DECL_VIRTUAL_P (tem) 665 && DECL_ASSEMBLER_NAME (tem)) 666 { 667 have_used_extensions = 1; 668 CHARS (3 + IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (tem))); 669 fputs (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem)), asmfile); 670 dbxout_type (DECL_FCONTEXT (tem), 0, 0); 671 fprintf (asmfile, ":"); 672 dbxout_type (TREE_TYPE (tem), 0, 0); 673 fputc (',', asmfile); 674 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 675 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem))); 676 fputc (';', asmfile); 677 continue; 678 } 679 680 if (DECL_NAME (tem)) 681 { 682 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem))); 683 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem))); 684 } 685 else 686 { 687 fprintf (asmfile, ":"); 688 CHARS (2); 689 } 690 691 if (use_gnu_debug_info_extensions 692 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem) 693 || TREE_CODE (tem) != FIELD_DECL)) 694 { 695 have_used_extensions = 1; 696 putc ('/', asmfile); 697 putc ((TREE_PRIVATE (tem) ? '0' 698 : TREE_PROTECTED (tem) ? '1' : '2'), 699 asmfile); 700 CHARS (2); 701 } 702 703 dbxout_type ((TREE_CODE (tem) == FIELD_DECL 704 && DECL_BIT_FIELD_TYPE (tem)) 705 ? DECL_BIT_FIELD_TYPE (tem) 706 : TREE_TYPE (tem), 0, 0); 707 708 if (TREE_CODE (tem) == VAR_DECL) 709 { 710 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions) 711 { 712 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem)); 713 have_used_extensions = 1; 714 fprintf (asmfile, ":%s;", name); 715 CHARS (strlen (name)); 716 } 717 else 718 { 719 /* If TEM is non-static, GDB won't understand it. */ 720 fprintf (asmfile, ",0,0;"); 721 } 722 } 723 else if (TREE_CODE (DECL_FIELD_BITPOS (tem)) == INTEGER_CST) 724 { 725 fputc (',', asmfile); 726 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 727 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem))); 728 fputc (',', asmfile); 729 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 730 TREE_INT_CST_LOW (DECL_SIZE (tem))); 731 fputc (';', asmfile); 732 } 733 CHARS (23); 734 } 735 } 736} 737 738/* Subroutine of `dbxout_type_methods'. Output debug info about the 739 method described DECL. DEBUG_NAME is an encoding of the method's 740 type signature. ??? We may be able to do without DEBUG_NAME altogether 741 now. */ 742 743static void 744dbxout_type_method_1 (decl, debug_name) 745 tree decl; 746 char *debug_name; 747{ 748 char c1 = 'A', c2; 749 750 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE) 751 c2 = '?'; 752 else /* it's a METHOD_TYPE. */ 753 { 754 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl))); 755 /* A for normal functions. 756 B for `const' member functions. 757 C for `volatile' member functions. 758 D for `const volatile' member functions. */ 759 if (TYPE_READONLY (TREE_TYPE (firstarg))) 760 c1 += 1; 761 if (TYPE_VOLATILE (TREE_TYPE (firstarg))) 762 c1 += 2; 763 764 if (DECL_VINDEX (decl)) 765 c2 = '*'; 766 else 767 c2 = '.'; 768 } 769 770 fprintf (asmfile, ":%s;%c%c%c", debug_name, 771 TREE_PRIVATE (decl) ? '0' : TREE_PROTECTED (decl) ? '1' : '2', c1, c2); 772 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6 773 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)))); 774 if (DECL_VINDEX (decl)) 775 { 776 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 777 TREE_INT_CST_LOW (DECL_VINDEX (decl))); 778 fputc (';', asmfile); 779 dbxout_type (DECL_CONTEXT (decl), 0, 0); 780 fprintf (asmfile, ";"); 781 CHARS (8); 782 } 783} 784 785/* Subroutine of `dbxout_type'. Output debug info about the methods defined 786 in TYPE. */ 787 788static void 789dbxout_type_methods (type) 790 register tree type; 791{ 792 /* C++: put out the method names and their parameter lists */ 793 tree methods = TYPE_METHODS (type); 794 tree type_encoding; 795 register tree fndecl; 796 register tree last; 797 char formatted_type_identifier_length[16]; 798 register int type_identifier_length; 799 800 if (methods == NULL_TREE) 801 return; 802 803 type_encoding = DECL_NAME (TYPE_NAME (type)); 804 805#if 0 806 /* C++: Template classes break some assumptions made by this code about 807 the class names, constructor names, and encodings for assembler 808 label names. For now, disable output of dbx info for them. */ 809 { 810 char *ptr = IDENTIFIER_POINTER (type_encoding); 811 /* This should use index. (mrs) */ 812 while (*ptr && *ptr != '<') ptr++; 813 if (*ptr != 0) 814 { 815 static int warned; 816 if (!warned) 817 warned = 1; 818 return; 819 } 820 } 821#endif 822 823 type_identifier_length = IDENTIFIER_LENGTH (type_encoding); 824 825 sprintf(formatted_type_identifier_length, "%d", type_identifier_length); 826 827 if (TREE_CODE (methods) != TREE_VEC) 828 fndecl = methods; 829 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE) 830 fndecl = TREE_VEC_ELT (methods, 0); 831 else 832 fndecl = TREE_VEC_ELT (methods, 1); 833 834 while (fndecl) 835 { 836 tree name = DECL_NAME (fndecl); 837 int need_prefix = 1; 838 839 /* Group together all the methods for the same operation. 840 These differ in the types of the arguments. */ 841 for (last = NULL_TREE; 842 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last)); 843 fndecl = TREE_CHAIN (fndecl)) 844 /* Output the name of the field (after overloading), as 845 well as the name of the field before overloading, along 846 with its parameter list */ 847 { 848 /* This is the "mangled" name of the method. 849 It encodes the argument types. */ 850 char *debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl)); 851 int show_arg_types = 0; 852 853 CONTIN; 854 855 last = fndecl; 856 857 if (DECL_IGNORED_P (fndecl)) 858 continue; 859 860 if (flag_minimal_debug) 861 { 862 char marker; 863 864 /* We can't optimize a method which uses an anonymous 865 class, because the debugger will not be able to 866 associate the arbitrary class name with the actual 867 class. */ 868#ifndef NO_DOLLAR_IN_LABEL 869 marker = '$'; 870#else 871 marker = '.'; 872#endif 873 if (strchr (debug_name, marker)) 874 show_arg_types = 1; 875 /* Detect ordinary methods because their mangled names 876 start with the operation name. */ 877 else if (!strncmp (IDENTIFIER_POINTER (name), debug_name, 878 IDENTIFIER_LENGTH (name))) 879 { 880 debug_name += IDENTIFIER_LENGTH (name); 881 if (debug_name[0] == '_' && debug_name[1] == '_') 882 { 883 char *method_name = debug_name + 2; 884 char *length_ptr = formatted_type_identifier_length; 885 /* Get past const and volatile qualifiers. */ 886 while (*method_name == 'C' || *method_name == 'V') 887 method_name++; 888 /* Skip digits for length of type_encoding. */ 889 while (*method_name == *length_ptr && *length_ptr) 890 length_ptr++, method_name++; 891 if (! strncmp (method_name, 892 IDENTIFIER_POINTER (type_encoding), 893 type_identifier_length)) 894 method_name += type_identifier_length; 895 debug_name = method_name; 896 } 897 } 898 /* Detect constructors by their style of name mangling. */ 899 else if (debug_name[0] == '_' && debug_name[1] == '_') 900 { 901 char *ctor_name = debug_name + 2; 902 char *length_ptr = formatted_type_identifier_length; 903 while (*ctor_name == 'C' || *ctor_name == 'V') 904 ctor_name++; 905 /* Skip digits for length of type_encoding. */ 906 while (*ctor_name == *length_ptr && *length_ptr) 907 length_ptr++, ctor_name++; 908 if (!strncmp (IDENTIFIER_POINTER (type_encoding), ctor_name, 909 type_identifier_length)) 910 debug_name = ctor_name + type_identifier_length; 911 } 912 /* The other alternative is a destructor. */ 913 else 914 show_arg_types = 1; 915 916 /* Output the operation name just once, for the first method 917 that we output. */ 918 if (need_prefix) 919 { 920 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name)); 921 CHARS (IDENTIFIER_LENGTH (name) + 2); 922 need_prefix = 0; 923 } 924 } 925 926 dbxout_type (TREE_TYPE (fndecl), 0, show_arg_types); 927 928 dbxout_type_method_1 (fndecl, debug_name); 929 } 930 if (!need_prefix) 931 { 932 putc (';', asmfile); 933 CHARS (1); 934 } 935 } 936} 937 938/* Emit a "range" type specification, which has the form: 939 "r<index type>;<lower bound>;<upper bound>;". 940 TYPE is an INTEGER_TYPE. */ 941 942static void 943dbxout_range_type (type) 944 tree type; 945{ 946 fprintf (asmfile, "r"); 947 if (TREE_TYPE (type)) 948 dbxout_type (TREE_TYPE (type), 0, 0); 949 else if (TREE_CODE (type) != INTEGER_TYPE) 950 dbxout_type (type, 0, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */ 951 else 952 { 953 /* Traditionally, we made sure 'int' was type 1, and builtin types 954 were defined to be sub-ranges of int. Unfortunately, this 955 does not allow us to distinguish true sub-ranges from integer 956 types. So, instead we define integer (non-sub-range) types as 957 sub-ranges of themselves. This matters for Chill. If this isn't 958 a subrange type, then we want to define it in terms of itself. 959 However, in C, this may be an anonymous integer type, and we don't 960 want to emit debug info referring to it. Just calling 961 dbxout_type_index won't work anyways, because the type hasn't been 962 defined yet. We make this work for both cases by checked to see 963 whether this is a defined type, referring to it if it is, and using 964 'int' otherwise. */ 965 if (TYPE_SYMTAB_ADDRESS (type) != 0) 966 dbxout_type_index (type); 967 else 968 dbxout_type_index (integer_type_node); 969 } 970 if (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST) 971 { 972 fputc (';', asmfile); 973 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 974 TREE_INT_CST_LOW (TYPE_MIN_VALUE (type))); 975 } 976 else 977 fprintf (asmfile, ";0"); 978 if (TYPE_MAX_VALUE (type) 979 && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST) 980 { 981 fputc (';', asmfile); 982 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 983 TREE_INT_CST_LOW (TYPE_MAX_VALUE (type))); 984 fputc (';', asmfile); 985 } 986 else 987 fprintf (asmfile, ";-1;"); 988} 989 990/* Output a reference to a type. If the type has not yet been 991 described in the dbx output, output its definition now. 992 For a type already defined, just refer to its definition 993 using the type number. 994 995 If FULL is nonzero, and the type has been described only with 996 a forward-reference, output the definition now. 997 If FULL is zero in this case, just refer to the forward-reference 998 using the number previously allocated. 999 1000 If SHOW_ARG_TYPES is nonzero, we output a description of the argument 1001 types for a METHOD_TYPE. */ 1002 1003static void 1004dbxout_type (type, full, show_arg_types) 1005 tree type; 1006 int full; 1007 int show_arg_types; 1008{ 1009 register tree tem; 1010 static int anonymous_type_number = 0; 1011 1012 /* If there was an input error and we don't really have a type, 1013 avoid crashing and write something that is at least valid 1014 by assuming `int'. */ 1015 if (type == error_mark_node) 1016 type = integer_type_node; 1017 else 1018 { 1019 /* Try to find the "main variant" with the same name but not const 1020 or volatile. (Since stabs does not distinguish const and volatile, 1021 there is no need to make them separate types. But types with 1022 different names are usefully distinguished.) */ 1023 1024 for (tem = TYPE_MAIN_VARIANT (type); tem; tem = TYPE_NEXT_VARIANT (tem)) 1025 if (!TYPE_READONLY (tem) && !TYPE_VOLATILE (tem) 1026 && TYPE_NAME (tem) == TYPE_NAME (type)) 1027 { 1028 type = tem; 1029 break; 1030 } 1031 if (TYPE_NAME (type) 1032 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL 1033 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type))) 1034 full = 0; 1035 } 1036 1037 if (TYPE_SYMTAB_ADDRESS (type) == 0) 1038 { 1039 /* Type has no dbx number assigned. Assign next available number. */ 1040 TYPE_SYMTAB_ADDRESS (type) = next_type_number++; 1041 1042 /* Make sure type vector is long enough to record about this type. */ 1043 1044 if (next_type_number == typevec_len) 1045 { 1046 typevec 1047 = (struct typeinfo *) xrealloc (typevec, 1048 typevec_len * 2 * sizeof typevec[0]); 1049 bzero ((char *) (typevec + typevec_len), 1050 typevec_len * sizeof typevec[0]); 1051 typevec_len *= 2; 1052 } 1053 1054#ifdef DBX_USE_BINCL 1055 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number 1056 = current_file->file_number; 1057 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number 1058 = current_file->next_type_number++; 1059#endif 1060 } 1061 1062 /* Output the number of this type, to refer to it. */ 1063 dbxout_type_index (type); 1064 1065#ifdef DBX_TYPE_DEFINED 1066 if (DBX_TYPE_DEFINED (type)) 1067 return; 1068#endif 1069 1070 /* If this type's definition has been output or is now being output, 1071 that is all. */ 1072 1073 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status) 1074 { 1075 case TYPE_UNSEEN: 1076 break; 1077 case TYPE_XREF: 1078 /* If we have already had a cross reference, 1079 and either that's all we want or that's the best we could do, 1080 don't repeat the cross reference. 1081 Sun dbx crashes if we do. */ 1082 if (! full || TYPE_SIZE (type) == 0 1083 /* No way in DBX fmt to describe a variable size. */ 1084 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) 1085 return; 1086 break; 1087 case TYPE_DEFINED: 1088 return; 1089 } 1090 1091#ifdef DBX_NO_XREFS 1092 /* For systems where dbx output does not allow the `=xsNAME:' syntax, 1093 leave the type-number completely undefined rather than output 1094 a cross-reference. If we have already used GNU debug info extensions, 1095 then it is OK to output a cross reference. This is necessary to get 1096 proper C++ debug output. */ 1097 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE 1098 || TREE_CODE (type) == QUAL_UNION_TYPE 1099 || TREE_CODE (type) == ENUMERAL_TYPE) 1100 && ! use_gnu_debug_info_extensions) 1101 /* We must use the same test here as we use twice below when deciding 1102 whether to emit a cross-reference. */ 1103 if ((TYPE_NAME (type) != 0 1104 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL 1105 && DECL_IGNORED_P (TYPE_NAME (type))) 1106 && !full) 1107 || TYPE_SIZE (type) == 0 1108 /* No way in DBX fmt to describe a variable size. */ 1109 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) 1110 { 1111 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF; 1112 return; 1113 } 1114#endif 1115 1116 /* Output a definition now. */ 1117 1118 fprintf (asmfile, "="); 1119 CHARS (1); 1120 1121 /* Mark it as defined, so that if it is self-referent 1122 we will not get into an infinite recursion of definitions. */ 1123 1124 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED; 1125 1126 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL 1127 && DECL_ORIGINAL_TYPE (TYPE_NAME (type))) 1128 { 1129 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0, 0); 1130 return; 1131 } 1132 1133 switch (TREE_CODE (type)) 1134 { 1135 case VOID_TYPE: 1136 case LANG_TYPE: 1137 /* For a void type, just define it as itself; ie, "5=5". 1138 This makes us consider it defined 1139 without saying what it is. The debugger will make it 1140 a void type when the reference is seen, and nothing will 1141 ever override that default. */ 1142 dbxout_type_index (type); 1143 break; 1144 1145 case INTEGER_TYPE: 1146 if (type == char_type_node && ! TREE_UNSIGNED (type)) 1147 { 1148 /* Output the type `char' as a subrange of itself! 1149 I don't understand this definition, just copied it 1150 from the output of pcc. 1151 This used to use `r2' explicitly and we used to 1152 take care to make sure that `char' was type number 2. */ 1153 fprintf (asmfile, "r"); 1154 dbxout_type_index (type); 1155 fprintf (asmfile, ";0;127;"); 1156 } 1157 /* This used to check if the type's precision was more than 1158 HOST_BITS_PER_WIDE_INT. That is wrong since gdb uses a 1159 long (it has no concept of HOST_BITS_PER_WIDE_INT). */ 1160 else if (use_gnu_debug_info_extensions 1161 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node) 1162 || TYPE_PRECISION (type) >= HOST_BITS_PER_LONG)) 1163 { 1164 /* This used to say `r1' and we used to take care 1165 to make sure that `int' was type number 1. */ 1166 fprintf (asmfile, "r"); 1167 dbxout_type_index (integer_type_node); 1168 fprintf (asmfile, ";"); 1169 print_int_cst_octal (TYPE_MIN_VALUE (type)); 1170 fprintf (asmfile, ";"); 1171 print_int_cst_octal (TYPE_MAX_VALUE (type)); 1172 fprintf (asmfile, ";"); 1173 } 1174 else /* Output other integer types as subranges of `int'. */ 1175 dbxout_range_type (type); 1176 CHARS (22); 1177 break; 1178 1179 case REAL_TYPE: 1180 /* This used to say `r1' and we used to take care 1181 to make sure that `int' was type number 1. */ 1182 fprintf (asmfile, "r"); 1183 dbxout_type_index (integer_type_node); 1184 fputc (';', asmfile); 1185 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, int_size_in_bytes (type)); 1186 fputs (";0;", asmfile); 1187 CHARS (13); 1188 break; 1189 1190 case CHAR_TYPE: 1191 if (use_gnu_debug_info_extensions) 1192 { 1193 fputs ("@s", asmfile); 1194 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 1195 BITS_PER_UNIT * int_size_in_bytes (type)); 1196 fputs (";-20;", asmfile); 1197 } 1198 else 1199 { 1200 /* Output the type `char' as a subrange of itself. 1201 That is what pcc seems to do. */ 1202 fprintf (asmfile, "r"); 1203 dbxout_type_index (char_type_node); 1204 fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127); 1205 } 1206 CHARS (9); 1207 break; 1208 1209 case BOOLEAN_TYPE: 1210 if (use_gnu_debug_info_extensions) 1211 { 1212 fputs ("@s", asmfile); 1213 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 1214 BITS_PER_UNIT * int_size_in_bytes (type)); 1215 fputs (";-16;", asmfile); 1216 } 1217 else /* Define as enumeral type (False, True) */ 1218 fprintf (asmfile, "eFalse:0,True:1,;"); 1219 CHARS (17); 1220 break; 1221 1222 case FILE_TYPE: 1223 putc ('d', asmfile); 1224 CHARS (1); 1225 dbxout_type (TREE_TYPE (type), 0, 0); 1226 break; 1227 1228 case COMPLEX_TYPE: 1229 /* Differs from the REAL_TYPE by its new data type number */ 1230 1231 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE) 1232 { 1233 fprintf (asmfile, "r"); 1234 dbxout_type_index (type); 1235 fputc (';', asmfile); 1236 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 1237 int_size_in_bytes (TREE_TYPE (type))); 1238 fputs (";0;", asmfile); 1239 CHARS (12); /* The number is probably incorrect here. */ 1240 } 1241 else 1242 { 1243 /* Output a complex integer type as a structure, 1244 pending some other way to do it. */ 1245 fputc ('s', asmfile); 1246 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, int_size_in_bytes (type)); 1247 1248 fprintf (asmfile, "real:"); 1249 CHARS (10); 1250 dbxout_type (TREE_TYPE (type), 0, 0); 1251 fprintf (asmfile, ",%d,%d;", 1252 0, TYPE_PRECISION (TREE_TYPE (type))); 1253 CHARS (8); 1254 fprintf (asmfile, "imag:"); 1255 CHARS (5); 1256 dbxout_type (TREE_TYPE (type), 0, 0); 1257 fprintf (asmfile, ",%d,%d;;", 1258 TYPE_PRECISION (TREE_TYPE (type)), 1259 TYPE_PRECISION (TREE_TYPE (type))); 1260 CHARS (9); 1261 } 1262 break; 1263 1264 case SET_TYPE: 1265 if (use_gnu_debug_info_extensions) 1266 { 1267 have_used_extensions = 1; 1268 fputs ("@s", asmfile); 1269 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 1270 BITS_PER_UNIT * int_size_in_bytes (type)); 1271 fputc (';', asmfile); 1272 /* Check if a bitstring type, which in Chill is 1273 different from a [power]set. */ 1274 if (TYPE_STRING_FLAG (type)) 1275 fprintf (asmfile, "@S;"); 1276 } 1277 putc ('S', asmfile); 1278 CHARS (1); 1279 dbxout_type (TYPE_DOMAIN (type), 0, 0); 1280 break; 1281 1282 case ARRAY_TYPE: 1283 /* Make arrays of packed bits look like bitstrings for chill. */ 1284 if (TYPE_PACKED (type) && use_gnu_debug_info_extensions) 1285 { 1286 have_used_extensions = 1; 1287 fputs ("@s", asmfile); 1288 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 1289 BITS_PER_UNIT * int_size_in_bytes (type)); 1290 fputc (';', asmfile); 1291 fprintf (asmfile, "@S;"); 1292 putc ('S', asmfile); 1293 CHARS (1); 1294 dbxout_type (TYPE_DOMAIN (type), 0, 0); 1295 break; 1296 } 1297 /* Output "a" followed by a range type definition 1298 for the index type of the array 1299 followed by a reference to the target-type. 1300 ar1;0;N;M for a C array of type M and size N+1. */ 1301 /* Check if a character string type, which in Chill is 1302 different from an array of characters. */ 1303 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions) 1304 { 1305 have_used_extensions = 1; 1306 fprintf (asmfile, "@S;"); 1307 } 1308 tem = TYPE_DOMAIN (type); 1309 if (tem == NULL) 1310 { 1311 fprintf (asmfile, "ar"); 1312 dbxout_type_index (integer_type_node); 1313 fprintf (asmfile, ";0;-1;"); 1314 } 1315 else 1316 { 1317 fprintf (asmfile, "a"); 1318 dbxout_range_type (tem); 1319 } 1320 CHARS (14); 1321 dbxout_type (TREE_TYPE (type), 0, 0); 1322 break; 1323 1324 case RECORD_TYPE: 1325 case UNION_TYPE: 1326 case QUAL_UNION_TYPE: 1327 { 1328 int i, n_baseclasses = 0; 1329 1330 if (TYPE_BINFO (type) != 0 1331 && TREE_CODE (TYPE_BINFO (type)) == TREE_VEC 1332 && TYPE_BINFO_BASETYPES (type) != 0) 1333 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type)); 1334 1335 /* Output a structure type. We must use the same test here as we 1336 use in the DBX_NO_XREFS case above. */ 1337 if ((TYPE_NAME (type) != 0 1338 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL 1339 && DECL_IGNORED_P (TYPE_NAME (type))) 1340 && !full) 1341 || TYPE_SIZE (type) == 0 1342 /* No way in DBX fmt to describe a variable size. */ 1343 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST) 1344 { 1345 /* If the type is just a cross reference, output one 1346 and mark the type as partially described. 1347 If it later becomes defined, we will output 1348 its real definition. 1349 If the type has a name, don't nest its definition within 1350 another type's definition; instead, output an xref 1351 and let the definition come when the name is defined. */ 1352 fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu"); 1353 CHARS (3); 1354#if 0 /* This assertion is legitimately false in C++. */ 1355 /* We shouldn't be outputting a reference to a type before its 1356 definition unless the type has a tag name. 1357 A typedef name without a tag name should be impossible. */ 1358 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE) 1359 abort (); 1360#endif 1361 if (TYPE_NAME (type) != 0) 1362 dbxout_type_name (type); 1363 else 1364 fprintf (asmfile, "$$%d", anonymous_type_number++); 1365 fprintf (asmfile, ":"); 1366 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF; 1367 break; 1368 } 1369 1370 /* Identify record or union, and print its size. */ 1371 fputc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asmfile); 1372 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 1373 int_size_in_bytes (type)); 1374 1375 if (use_gnu_debug_info_extensions) 1376 { 1377 if (n_baseclasses) 1378 { 1379 have_used_extensions = 1; 1380 fprintf (asmfile, "!%d,", n_baseclasses); 1381 CHARS (8); 1382 } 1383 } 1384 for (i = 0; i < n_baseclasses; i++) 1385 { 1386 tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i); 1387 if (use_gnu_debug_info_extensions) 1388 { 1389 have_used_extensions = 1; 1390 putc (TREE_VIA_VIRTUAL (child) ? '1' 1391 : '0', 1392 asmfile); 1393 putc (TREE_VIA_PUBLIC (child) ? '2' 1394 : '0', 1395 asmfile); 1396 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 1397 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT); 1398 fputc (',', asmfile); 1399 CHARS (15); 1400 dbxout_type (BINFO_TYPE (child), 0, 0); 1401 putc (';', asmfile); 1402 } 1403 else 1404 { 1405 /* Print out the base class information with fields 1406 which have the same names at the types they hold. */ 1407 dbxout_type_name (BINFO_TYPE (child)); 1408 putc (':', asmfile); 1409 dbxout_type (BINFO_TYPE (child), full, 0); 1410 fputc (',', asmfile); 1411 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 1412 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT); 1413 fputc (',', asmfile); 1414 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 1415 TREE_INT_CST_LOW (DECL_SIZE (TYPE_NAME (BINFO_TYPE (child)))) * BITS_PER_UNIT); 1416 fputc (';', asmfile); 1417 CHARS (20); 1418 } 1419 } 1420 } 1421 1422 CHARS (11); 1423 1424 /* Write out the field declarations. */ 1425 dbxout_type_fields (type); 1426 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE) 1427 { 1428 have_used_extensions = 1; 1429 dbxout_type_methods (type); 1430 } 1431 putc (';', asmfile); 1432 1433 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE 1434 /* Avoid the ~ if we don't really need it--it confuses dbx. */ 1435 && TYPE_VFIELD (type)) 1436 { 1437 have_used_extensions = 1; 1438 1439 /* Tell GDB+ that it may keep reading. */ 1440 putc ('~', asmfile); 1441 1442 /* We need to write out info about what field this class 1443 uses as its "main" vtable pointer field, because if this 1444 field is inherited from a base class, GDB cannot necessarily 1445 figure out which field it's using in time. */ 1446 if (TYPE_VFIELD (type)) 1447 { 1448 putc ('%', asmfile); 1449 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0, 0); 1450 } 1451 putc (';', asmfile); 1452 CHARS (3); 1453 } 1454 break; 1455 1456 case ENUMERAL_TYPE: 1457 /* We must use the same test here as we use in the DBX_NO_XREFS case 1458 above. We simplify it a bit since an enum will never have a variable 1459 size. */ 1460 if ((TYPE_NAME (type) != 0 1461 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL 1462 && DECL_IGNORED_P (TYPE_NAME (type))) 1463 && !full) 1464 || TYPE_SIZE (type) == 0) 1465 { 1466 fprintf (asmfile, "xe"); 1467 CHARS (3); 1468 dbxout_type_name (type); 1469 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF; 1470 fprintf (asmfile, ":"); 1471 return; 1472 } 1473#ifdef DBX_OUTPUT_ENUM 1474 DBX_OUTPUT_ENUM (asmfile, type); 1475#else 1476 if (use_gnu_debug_info_extensions 1477 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node)) 1478 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type)); 1479 putc ('e', asmfile); 1480 CHARS (1); 1481 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem)) 1482 { 1483 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem))); 1484 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0) 1485 fprintf (asmfile, HOST_WIDE_INT_PRINT_UNSIGNED, 1486 TREE_INT_CST_LOW (TREE_VALUE (tem))); 1487 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1 1488 && TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0) 1489 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, 1490 TREE_INT_CST_LOW (TREE_VALUE (tem))); 1491 else 1492 print_int_cst_octal (TREE_VALUE (tem)); 1493 fprintf (asmfile, ","); 1494 CHARS (20 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem))); 1495 if (TREE_CHAIN (tem) != 0) 1496 { 1497 CONTIN; 1498 } 1499 } 1500 putc (';', asmfile); 1501 CHARS (1); 1502#endif 1503 break; 1504 1505 case POINTER_TYPE: 1506 putc ('*', asmfile); 1507 CHARS (1); 1508 dbxout_type (TREE_TYPE (type), 0, 0); 1509 break; 1510 1511 case METHOD_TYPE: 1512 if (use_gnu_debug_info_extensions) 1513 { 1514 have_used_extensions = 1; 1515 putc ('#', asmfile); 1516 CHARS (1); 1517 if (flag_minimal_debug && !show_arg_types) 1518 { 1519 /* Normally, just output the return type. 1520 The argument types are encoded in the method name. */ 1521 putc ('#', asmfile); 1522 CHARS (1); 1523 dbxout_type (TREE_TYPE (type), 0, 0); 1524 putc (';', asmfile); 1525 CHARS (1); 1526 } 1527 else 1528 { 1529 /* When outputting destructors, we need to write 1530 the argument types out longhand. */ 1531 dbxout_type (TYPE_METHOD_BASETYPE (type), 0, 0); 1532 putc (',', asmfile); 1533 CHARS (1); 1534 dbxout_type (TREE_TYPE (type), 0, 0); 1535 dbxout_args (TYPE_ARG_TYPES (type)); 1536 putc (';', asmfile); 1537 CHARS (1); 1538 } 1539 } 1540 else 1541 { 1542 /* Treat it as a function type. */ 1543 dbxout_type (TREE_TYPE (type), 0, 0); 1544 } 1545 break; 1546 1547 case OFFSET_TYPE: 1548 if (use_gnu_debug_info_extensions) 1549 { 1550 have_used_extensions = 1; 1551 putc ('@', asmfile); 1552 CHARS (1); 1553 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0, 0); 1554 putc (',', asmfile); 1555 CHARS (1); 1556 dbxout_type (TREE_TYPE (type), 0, 0); 1557 } 1558 else 1559 { 1560 /* Should print as an int, because it is really 1561 just an offset. */ 1562 dbxout_type (integer_type_node, 0, 0); 1563 } 1564 break; 1565 1566 case REFERENCE_TYPE: 1567 if (use_gnu_debug_info_extensions) 1568 have_used_extensions = 1; 1569 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile); 1570 CHARS (1); 1571 dbxout_type (TREE_TYPE (type), 0, 0); 1572 break; 1573 1574 case FUNCTION_TYPE: 1575 putc ('f', asmfile); 1576 CHARS (1); 1577 dbxout_type (TREE_TYPE (type), 0, 0); 1578 break; 1579 1580 default: 1581 abort (); 1582 } 1583} 1584 1585/* Print the value of integer constant C, in octal, 1586 handling double precision. */ 1587 1588static void 1589print_int_cst_octal (c) 1590 tree c; 1591{ 1592 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c); 1593 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c); 1594 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3)); 1595 int width = TYPE_PRECISION (TREE_TYPE (c)); 1596 1597 /* GDB wants constants with no extra leading "1" bits, so 1598 we need to remove any sign-extension that might be 1599 present. */ 1600 if (width == HOST_BITS_PER_WIDE_INT * 2) 1601 ; 1602 else if (width > HOST_BITS_PER_WIDE_INT) 1603 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1); 1604 else if (width == HOST_BITS_PER_WIDE_INT) 1605 high = 0; 1606 else 1607 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1); 1608 1609 fprintf (asmfile, "0"); 1610 1611 if (excess == 3) 1612 { 1613 print_octal (high, HOST_BITS_PER_WIDE_INT / 3); 1614 print_octal (low, HOST_BITS_PER_WIDE_INT / 3); 1615 } 1616 else 1617 { 1618 unsigned HOST_WIDE_INT beg = high >> excess; 1619 unsigned HOST_WIDE_INT middle 1620 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess) 1621 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3))); 1622 unsigned HOST_WIDE_INT end 1623 = low & (((unsigned HOST_WIDE_INT) 1 1624 << (HOST_BITS_PER_WIDE_INT / 3 * 3)) 1625 - 1); 1626 1627 fprintf (asmfile, "%o%01o", (int)beg, (int)middle); 1628 print_octal (end, HOST_BITS_PER_WIDE_INT / 3); 1629 } 1630} 1631 1632static void 1633print_octal (value, digits) 1634 unsigned HOST_WIDE_INT value; 1635 int digits; 1636{ 1637 int i; 1638 1639 for (i = digits - 1; i >= 0; i--) 1640 fprintf (asmfile, "%01o", (int)((value >> (3 * i)) & 7)); 1641} 1642 1643/* Output the name of type TYPE, with no punctuation. 1644 Such names can be set up either by typedef declarations 1645 or by struct, enum and union tags. */ 1646 1647static void 1648dbxout_type_name (type) 1649 register tree type; 1650{ 1651 tree t; 1652 if (TYPE_NAME (type) == 0) 1653 abort (); 1654 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) 1655 { 1656 t = TYPE_NAME (type); 1657 } 1658 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL) 1659 { 1660 t = DECL_NAME (TYPE_NAME (type)); 1661 } 1662 else 1663 abort (); 1664 1665 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t)); 1666 CHARS (IDENTIFIER_LENGTH (t)); 1667} 1668 1669/* Output a .stabs for the symbol defined by DECL, 1670 which must be a ..._DECL node in the normal namespace. 1671 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL. 1672 LOCAL is nonzero if the scope is less than the entire file. */ 1673 1674void 1675dbxout_symbol (decl, local) 1676 tree decl; 1677 int local; 1678{ 1679 tree type = TREE_TYPE (decl); 1680 tree context = NULL_TREE; 1681 1682 /* Cast avoids warning in old compilers. */ 1683 current_sym_code = (STAB_CODE_TYPE) 0; 1684 current_sym_value = 0; 1685 current_sym_addr = 0; 1686 1687 /* Ignore nameless syms, but don't ignore type tags. */ 1688 1689 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL) 1690 || DECL_IGNORED_P (decl)) 1691 return; 1692 1693 dbxout_prepare_symbol (decl); 1694 1695 /* The output will always start with the symbol name, 1696 so always count that in the length-output-so-far. */ 1697 1698 if (DECL_NAME (decl) != 0) 1699 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl)); 1700 1701 switch (TREE_CODE (decl)) 1702 { 1703 case CONST_DECL: 1704 /* Enum values are defined by defining the enum type. */ 1705 break; 1706 1707 case FUNCTION_DECL: 1708 if (DECL_RTL (decl) == 0) 1709 return; 1710 if (DECL_EXTERNAL (decl)) 1711 break; 1712 /* Don't mention a nested function under its parent. */ 1713 context = decl_function_context (decl); 1714 if (context == current_function_decl) 1715 break; 1716 if (GET_CODE (DECL_RTL (decl)) != MEM 1717 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF) 1718 break; 1719 FORCE_TEXT; 1720 1721 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP, 1722 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), 1723 TREE_PUBLIC (decl) ? 'F' : 'f'); 1724 1725 current_sym_code = N_FUN; 1726 current_sym_addr = XEXP (DECL_RTL (decl), 0); 1727 1728 if (TREE_TYPE (type)) 1729 dbxout_type (TREE_TYPE (type), 0, 0); 1730 else 1731 dbxout_type (void_type_node, 0, 0); 1732 1733 /* For a nested function, when that function is compiled, 1734 mention the containing function name 1735 as well as (since dbx wants it) our own assembler-name. */ 1736 if (context != 0) 1737 fprintf (asmfile, ",%s,%s", 1738 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), 1739 IDENTIFIER_POINTER (DECL_NAME (context))); 1740 1741 dbxout_finish_symbol (decl); 1742 break; 1743 1744 case TYPE_DECL: 1745#if 0 1746 /* This seems all wrong. Outputting most kinds of types gives no name 1747 at all. A true definition gives no name; a cross-ref for a 1748 structure can give the tag name, but not a type name. 1749 It seems that no typedef name is defined by outputting a type. */ 1750 1751 /* If this typedef name was defined by outputting the type, 1752 don't duplicate it. */ 1753 if (typevec[TYPE_SYMTAB_ADDRESS (type)].status == TYPE_DEFINED 1754 && TYPE_NAME (TREE_TYPE (decl)) == decl) 1755 return; 1756#endif 1757 /* Don't output the same typedef twice. 1758 And don't output what language-specific stuff doesn't want output. */ 1759 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl)) 1760 return; 1761 1762 FORCE_TEXT; 1763 1764 { 1765 int tag_needed = 1; 1766 int did_output = 0; 1767 1768 if (DECL_NAME (decl)) 1769 { 1770 /* Nonzero means we must output a tag as well as a typedef. */ 1771 tag_needed = 0; 1772 1773 /* Handle the case of a C++ structure or union 1774 where the TYPE_NAME is a TYPE_DECL 1775 which gives both a typedef name and a tag. */ 1776 /* dbx requires the tag first and the typedef second. */ 1777 if ((TREE_CODE (type) == RECORD_TYPE 1778 || TREE_CODE (type) == UNION_TYPE 1779 || TREE_CODE (type) == QUAL_UNION_TYPE) 1780 && TYPE_NAME (type) == decl 1781 && !(use_gnu_debug_info_extensions && have_used_extensions) 1782 && !TREE_ASM_WRITTEN (TYPE_NAME (type)) 1783 /* Distinguish the implicit typedefs of C++ 1784 from explicit ones that might be found in C. */ 1785 && DECL_ARTIFICIAL (decl)) 1786 { 1787 tree name = TYPE_NAME (type); 1788 if (TREE_CODE (name) == TYPE_DECL) 1789 name = DECL_NAME (name); 1790 1791 current_sym_code = DBX_TYPE_DECL_STABS_CODE; 1792 current_sym_value = 0; 1793 current_sym_addr = 0; 1794 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name); 1795 1796 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP, 1797 IDENTIFIER_POINTER (name)); 1798 dbxout_type (type, 1, 0); 1799 dbxout_finish_symbol (NULL_TREE); 1800 } 1801 1802 /* Output typedef name. */ 1803 fprintf (asmfile, "%s \"%s:", ASM_STABS_OP, 1804 IDENTIFIER_POINTER (DECL_NAME (decl))); 1805 1806 /* Short cut way to output a tag also. */ 1807 if ((TREE_CODE (type) == RECORD_TYPE 1808 || TREE_CODE (type) == UNION_TYPE 1809 || TREE_CODE (type) == QUAL_UNION_TYPE) 1810 && TYPE_NAME (type) == decl 1811 /* Distinguish the implicit typedefs of C++ 1812 from explicit ones that might be found in C. */ 1813 && DECL_ARTIFICIAL (decl)) 1814 { 1815 if (use_gnu_debug_info_extensions && have_used_extensions) 1816 { 1817 putc ('T', asmfile); 1818 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1; 1819 } 1820#if 0 /* Now we generate the tag for this case up above. */ 1821 else 1822 tag_needed = 1; 1823#endif 1824 } 1825 1826 putc ('t', asmfile); 1827 current_sym_code = DBX_TYPE_DECL_STABS_CODE; 1828 1829 dbxout_type (type, 1, 0); 1830 dbxout_finish_symbol (decl); 1831 did_output = 1; 1832 } 1833 1834 /* Don't output a tag if this is an incomplete type (TYPE_SIZE is 1835 zero). This prevents the sun4 Sun OS 4.x dbx from crashing. */ 1836 1837 if (tag_needed && TYPE_NAME (type) != 0 1838 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE 1839 || (DECL_NAME (TYPE_NAME (type)) != 0)) 1840 && TYPE_SIZE (type) != 0 1841 && !TREE_ASM_WRITTEN (TYPE_NAME (type))) 1842 { 1843 /* For a TYPE_DECL with no name, but the type has a name, 1844 output a tag. 1845 This is what represents `struct foo' with no typedef. */ 1846 /* In C++, the name of a type is the corresponding typedef. 1847 In C, it is an IDENTIFIER_NODE. */ 1848 tree name = TYPE_NAME (type); 1849 if (TREE_CODE (name) == TYPE_DECL) 1850 name = DECL_NAME (name); 1851 1852 current_sym_code = DBX_TYPE_DECL_STABS_CODE; 1853 current_sym_value = 0; 1854 current_sym_addr = 0; 1855 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name); 1856 1857 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP, 1858 IDENTIFIER_POINTER (name)); 1859 dbxout_type (type, 1, 0); 1860 dbxout_finish_symbol (NULL_TREE); 1861 did_output = 1; 1862 } 1863 1864 /* If an enum type has no name, it cannot be referred to, 1865 but we must output it anyway, since the enumeration constants 1866 can be referred to. */ 1867 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE) 1868 { 1869 current_sym_code = DBX_TYPE_DECL_STABS_CODE; 1870 current_sym_value = 0; 1871 current_sym_addr = 0; 1872 current_sym_nchars = 2; 1873 1874 /* Some debuggers fail when given NULL names, so give this a 1875 harmless name of ` '. */ 1876 fprintf (asmfile, "%s \" :T", ASM_STABS_OP); 1877 dbxout_type (type, 1, 0); 1878 dbxout_finish_symbol (NULL_TREE); 1879 } 1880 1881 /* Prevent duplicate output of a typedef. */ 1882 TREE_ASM_WRITTEN (decl) = 1; 1883 break; 1884 } 1885 1886 case PARM_DECL: 1887 /* Parm decls go in their own separate chains 1888 and are output by dbxout_reg_parms and dbxout_parms. */ 1889 abort (); 1890 1891 case RESULT_DECL: 1892 /* Named return value, treat like a VAR_DECL. */ 1893 case VAR_DECL: 1894 if (DECL_RTL (decl) == 0) 1895 return; 1896 /* Don't mention a variable that is external. 1897 Let the file that defines it describe it. */ 1898 if (DECL_EXTERNAL (decl)) 1899 break; 1900 1901 /* If the variable is really a constant 1902 and not written in memory, inform the debugger. */ 1903 if (TREE_STATIC (decl) && TREE_READONLY (decl) 1904 && DECL_INITIAL (decl) != 0 1905 && ! TREE_ASM_WRITTEN (decl) 1906 && (DECL_FIELD_CONTEXT (decl) == NULL_TREE 1907 || TREE_CODE (DECL_FIELD_CONTEXT (decl)) == BLOCK)) 1908 { 1909 if (TREE_PUBLIC (decl) == 0) 1910 { 1911 /* The sun4 assembler does not grok this. */ 1912 char *name = IDENTIFIER_POINTER (DECL_NAME (decl)); 1913 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE 1914 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE) 1915 { 1916 HOST_WIDE_INT ival = TREE_INT_CST_LOW (DECL_INITIAL (decl)); 1917#ifdef DBX_OUTPUT_CONSTANT_SYMBOL 1918 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile, name, ival); 1919#else 1920 fprintf (asmfile, "%s \"%s:c=i", ASM_STABS_OP, name); 1921 1922 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, ival); 1923 fprintf (asmfile, "\",0x%x,0,0,0\n", N_LSYM); 1924#endif 1925 return; 1926 } 1927 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE) 1928 { 1929 /* don't know how to do this yet. */ 1930 } 1931 break; 1932 } 1933 /* else it is something we handle like a normal variable. */ 1934 } 1935 1936 DECL_RTL (decl) = eliminate_regs (DECL_RTL (decl), 0, NULL_RTX); 1937#ifdef LEAF_REG_REMAP 1938 if (leaf_function) 1939 leaf_renumber_regs_insn (DECL_RTL (decl)); 1940#endif 1941 1942 dbxout_symbol_location (decl, type, 0, DECL_RTL (decl)); 1943 break; 1944 1945 default: 1946 break; 1947 } 1948} 1949 1950/* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL. 1951 Add SUFFIX to its name, if SUFFIX is not 0. 1952 Describe the variable as residing in HOME 1953 (usually HOME is DECL_RTL (DECL), but not always). */ 1954 1955static void 1956dbxout_symbol_location (decl, type, suffix, home) 1957 tree decl, type; 1958 char *suffix; 1959 rtx home; 1960{ 1961 int letter = 0; 1962 int regno = -1; 1963 1964 /* Don't mention a variable at all 1965 if it was completely optimized into nothingness. 1966 1967 If the decl was from an inline function, then its rtl 1968 is not identically the rtl that was used in this 1969 particular compilation. */ 1970 if (GET_CODE (home) == REG) 1971 { 1972 regno = REGNO (home); 1973 if (regno >= FIRST_PSEUDO_REGISTER) 1974 return; 1975 } 1976 else if (GET_CODE (home) == SUBREG) 1977 { 1978 rtx value = home; 1979 int offset = 0; 1980 while (GET_CODE (value) == SUBREG) 1981 { 1982 offset += SUBREG_WORD (value); 1983 value = SUBREG_REG (value); 1984 } 1985 if (GET_CODE (value) == REG) 1986 { 1987 regno = REGNO (value); 1988 if (regno >= FIRST_PSEUDO_REGISTER) 1989 return; 1990 regno += offset; 1991 } 1992 alter_subreg (home); 1993 } 1994 1995 /* The kind-of-variable letter depends on where 1996 the variable is and on the scope of its name: 1997 G and N_GSYM for static storage and global scope, 1998 S for static storage and file scope, 1999 V for static storage and local scope, 2000 for those two, use N_LCSYM if data is in bss segment, 2001 N_STSYM if in data segment, N_FUN otherwise. 2002 (We used N_FUN originally, then changed to N_STSYM 2003 to please GDB. However, it seems that confused ld. 2004 Now GDB has been fixed to like N_FUN, says Kingdon.) 2005 no letter at all, and N_LSYM, for auto variable, 2006 r and N_RSYM for register variable. */ 2007 2008 if (GET_CODE (home) == MEM 2009 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF) 2010 { 2011 if (TREE_PUBLIC (decl)) 2012 { 2013 letter = 'G'; 2014 current_sym_code = N_GSYM; 2015 } 2016 else 2017 { 2018 current_sym_addr = XEXP (home, 0); 2019 2020 letter = decl_function_context (decl) ? 'V' : 'S'; 2021 2022 /* This should be the same condition as in assemble_variable, but 2023 we don't have access to dont_output_data here. So, instead, 2024 we rely on the fact that error_mark_node initializers always 2025 end up in bss for C++ and never end up in bss for C. */ 2026 if (DECL_INITIAL (decl) == 0 2027 || (!strcmp (lang_identify (), "cplusplus") 2028 && DECL_INITIAL (decl) == error_mark_node)) 2029 current_sym_code = N_LCSYM; 2030 else if (DECL_IN_TEXT_SECTION (decl)) 2031 /* This is not quite right, but it's the closest 2032 of all the codes that Unix defines. */ 2033 current_sym_code = DBX_STATIC_CONST_VAR_CODE; 2034 else 2035 { 2036 /* Ultrix `as' seems to need this. */ 2037#ifdef DBX_STATIC_STAB_DATA_SECTION 2038 data_section (); 2039#endif 2040 current_sym_code = N_STSYM; 2041 } 2042 } 2043 } 2044 else if (regno >= 0) 2045 { 2046 letter = 'r'; 2047 current_sym_code = N_RSYM; 2048 current_sym_value = DBX_REGISTER_NUMBER (regno); 2049 } 2050 else if (GET_CODE (home) == MEM 2051 && (GET_CODE (XEXP (home, 0)) == MEM 2052 || (GET_CODE (XEXP (home, 0)) == REG 2053 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM 2054 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM 2055#if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM 2056 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM 2057#endif 2058 ))) 2059 /* If the value is indirect by memory or by a register 2060 that isn't the frame pointer 2061 then it means the object is variable-sized and address through 2062 that register or stack slot. DBX has no way to represent this 2063 so all we can do is output the variable as a pointer. 2064 If it's not a parameter, ignore it. 2065 (VAR_DECLs like this can be made by integrate.c.) */ 2066 { 2067 if (GET_CODE (XEXP (home, 0)) == REG) 2068 { 2069 letter = 'r'; 2070 current_sym_code = N_RSYM; 2071 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0))); 2072 } 2073 else 2074 { 2075 current_sym_code = N_LSYM; 2076 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))). 2077 We want the value of that CONST_INT. */ 2078 current_sym_value 2079 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0)); 2080 } 2081 2082 /* Effectively do build_pointer_type, but don't cache this type, 2083 since it might be temporary whereas the type it points to 2084 might have been saved for inlining. */ 2085 /* Don't use REFERENCE_TYPE because dbx can't handle that. */ 2086 type = make_node (POINTER_TYPE); 2087 TREE_TYPE (type) = TREE_TYPE (decl); 2088 } 2089 else if (GET_CODE (home) == MEM 2090 && GET_CODE (XEXP (home, 0)) == REG) 2091 { 2092 current_sym_code = N_LSYM; 2093 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0)); 2094 } 2095 else if (GET_CODE (home) == MEM 2096 && GET_CODE (XEXP (home, 0)) == PLUS 2097 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT) 2098 { 2099 current_sym_code = N_LSYM; 2100 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...))) 2101 We want the value of that CONST_INT. */ 2102 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0)); 2103 } 2104 else if (GET_CODE (home) == MEM 2105 && GET_CODE (XEXP (home, 0)) == CONST) 2106 { 2107 /* Handle an obscure case which can arise when optimizing and 2108 when there are few available registers. (This is *always* 2109 the case for i386/i486 targets). The RTL looks like 2110 (MEM (CONST ...)) even though this variable is a local `auto' 2111 or a local `register' variable. In effect, what has happened 2112 is that the reload pass has seen that all assignments and 2113 references for one such a local variable can be replaced by 2114 equivalent assignments and references to some static storage 2115 variable, thereby avoiding the need for a register. In such 2116 cases we're forced to lie to debuggers and tell them that 2117 this variable was itself `static'. */ 2118 current_sym_code = N_LCSYM; 2119 letter = 'V'; 2120 current_sym_addr = XEXP (XEXP (home, 0), 0); 2121 } 2122 else if (GET_CODE (home) == CONCAT) 2123 { 2124 tree subtype = TREE_TYPE (type); 2125 2126 /* If the variable's storage is in two parts, 2127 output each as a separate stab with a modified name. */ 2128 if (WORDS_BIG_ENDIAN) 2129 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0)); 2130 else 2131 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0)); 2132 2133 /* Cast avoids warning in old compilers. */ 2134 current_sym_code = (STAB_CODE_TYPE) 0; 2135 current_sym_value = 0; 2136 current_sym_addr = 0; 2137 dbxout_prepare_symbol (decl); 2138 2139 if (WORDS_BIG_ENDIAN) 2140 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1)); 2141 else 2142 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1)); 2143 return; 2144 } 2145 else 2146 /* Address might be a MEM, when DECL is a variable-sized object. 2147 Or it might be const0_rtx, meaning previous passes 2148 want us to ignore this variable. */ 2149 return; 2150 2151 /* Ok, start a symtab entry and output the variable name. */ 2152 FORCE_TEXT; 2153 2154#ifdef DBX_STATIC_BLOCK_START 2155 DBX_STATIC_BLOCK_START (asmfile, current_sym_code); 2156#endif 2157 2158 dbxout_symbol_name (decl, suffix, letter); 2159 dbxout_type (type, 0, 0); 2160 dbxout_finish_symbol (decl); 2161 2162#ifdef DBX_STATIC_BLOCK_END 2163 DBX_STATIC_BLOCK_END (asmfile, current_sym_code); 2164#endif 2165} 2166 2167/* Output the symbol name of DECL for a stabs, with suffix SUFFIX. 2168 Then output LETTER to indicate the kind of location the symbol has. */ 2169 2170static void 2171dbxout_symbol_name (decl, suffix, letter) 2172 tree decl; 2173 char *suffix; 2174 int letter; 2175{ 2176 /* One slight hitch: if this is a VAR_DECL which is a static 2177 class member, we must put out the mangled name instead of the 2178 DECL_NAME. Note also that static member (variable) names DO NOT begin 2179 with underscores in .stabs directives. */ 2180 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)); 2181 if (name == 0) 2182 name = "(anon)"; 2183 fprintf (asmfile, "%s \"%s%s:", ASM_STABS_OP, name, 2184 (suffix ? suffix : "")); 2185 2186 if (letter) putc (letter, asmfile); 2187} 2188 2189static void 2190dbxout_prepare_symbol (decl) 2191 tree decl; 2192{ 2193#ifdef WINNING_GDB 2194 char *filename = DECL_SOURCE_FILE (decl); 2195 2196 dbxout_source_file (asmfile, filename); 2197#endif 2198} 2199 2200static void 2201dbxout_finish_symbol (sym) 2202 tree sym; 2203{ 2204#ifdef DBX_FINISH_SYMBOL 2205 DBX_FINISH_SYMBOL (sym); 2206#else 2207 int line = 0; 2208 if (use_gnu_debug_info_extensions && sym != 0) 2209 line = DECL_SOURCE_LINE (sym); 2210 2211 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line); 2212 if (current_sym_addr) 2213 output_addr_const (asmfile, current_sym_addr); 2214 else 2215 fprintf (asmfile, "%d", current_sym_value); 2216 putc ('\n', asmfile); 2217#endif 2218} 2219 2220/* Output definitions of all the decls in a chain. */ 2221 2222void 2223dbxout_syms (syms) 2224 tree syms; 2225{ 2226 while (syms) 2227 { 2228 dbxout_symbol (syms, 1); 2229 syms = TREE_CHAIN (syms); 2230 } 2231} 2232 2233/* The following two functions output definitions of function parameters. 2234 Each parameter gets a definition locating it in the parameter list. 2235 Each parameter that is a register variable gets a second definition 2236 locating it in the register. 2237 2238 Printing or argument lists in gdb uses the definitions that 2239 locate in the parameter list. But reference to the variable in 2240 expressions uses preferentially the definition as a register. */ 2241 2242/* Output definitions, referring to storage in the parmlist, 2243 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */ 2244 2245void 2246dbxout_parms (parms) 2247 tree parms; 2248{ 2249 for (; parms; parms = TREE_CHAIN (parms)) 2250 if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node) 2251 { 2252 dbxout_prepare_symbol (parms); 2253 2254 /* Perform any necessary register eliminations on the parameter's rtl, 2255 so that the debugging output will be accurate. */ 2256 DECL_INCOMING_RTL (parms) 2257 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX); 2258 DECL_RTL (parms) = eliminate_regs (DECL_RTL (parms), 0, NULL_RTX); 2259#ifdef LEAF_REG_REMAP 2260 if (leaf_function) 2261 { 2262 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms)); 2263 leaf_renumber_regs_insn (DECL_RTL (parms)); 2264 } 2265#endif 2266 2267 if (PARM_PASSED_IN_MEMORY (parms)) 2268 { 2269 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0); 2270 2271 /* ??? Here we assume that the parm address is indexed 2272 off the frame pointer or arg pointer. 2273 If that is not true, we produce meaningless results, 2274 but do not crash. */ 2275 if (GET_CODE (addr) == PLUS 2276 && GET_CODE (XEXP (addr, 1)) == CONST_INT) 2277 current_sym_value = INTVAL (XEXP (addr, 1)); 2278 else 2279 current_sym_value = 0; 2280 2281 current_sym_code = N_PSYM; 2282 current_sym_addr = 0; 2283 2284 FORCE_TEXT; 2285 if (DECL_NAME (parms)) 2286 { 2287 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms)); 2288 2289 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP, 2290 IDENTIFIER_POINTER (DECL_NAME (parms)), 2291 DBX_MEMPARM_STABS_LETTER); 2292 } 2293 else 2294 { 2295 current_sym_nchars = 8; 2296 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP, 2297 DBX_MEMPARM_STABS_LETTER); 2298 } 2299 2300 /* It is quite tempting to use: 2301 2302 dbxout_type (TREE_TYPE (parms), 0, 0); 2303 2304 as the next statement, rather than using DECL_ARG_TYPE(), so 2305 that gcc reports the actual type of the parameter, rather 2306 than the promoted type. This certainly makes GDB's life 2307 easier, at least for some ports. The change is a bad idea 2308 however, since GDB expects to be able access the type without 2309 performing any conversions. So for example, if we were 2310 passing a float to an unprototyped function, gcc will store a 2311 double on the stack, but if we emit a stab saying the type is a 2312 float, then gdb will only read in a single value, and this will 2313 produce an erropneous value. */ 2314 dbxout_type (DECL_ARG_TYPE (parms), 0, 0); 2315 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr); 2316 dbxout_finish_symbol (parms); 2317 } 2318 else if (GET_CODE (DECL_RTL (parms)) == REG) 2319 { 2320 rtx best_rtl; 2321 char regparm_letter; 2322 tree parm_type; 2323 /* Parm passed in registers and lives in registers or nowhere. */ 2324 2325 current_sym_code = DBX_REGPARM_STABS_CODE; 2326 regparm_letter = DBX_REGPARM_STABS_LETTER; 2327 current_sym_addr = 0; 2328 2329 /* If parm lives in a register, use that register; 2330 pretend the parm was passed there. It would be more consistent 2331 to describe the register where the parm was passed, 2332 but in practice that register usually holds something else. 2333 2334 If we use DECL_RTL, then we must use the declared type of 2335 the variable, not the type that it arrived in. */ 2336 if (REGNO (DECL_RTL (parms)) >= 0 2337 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER) 2338 { 2339 best_rtl = DECL_RTL (parms); 2340 parm_type = TREE_TYPE (parms); 2341 } 2342 /* If the parm lives nowhere, use the register where it was 2343 passed. It is also better to use the declared type here. */ 2344 else 2345 { 2346 best_rtl = DECL_INCOMING_RTL (parms); 2347 parm_type = TREE_TYPE (parms); 2348 } 2349 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl)); 2350 2351 FORCE_TEXT; 2352 if (DECL_NAME (parms)) 2353 { 2354 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms)); 2355 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP, 2356 IDENTIFIER_POINTER (DECL_NAME (parms)), 2357 regparm_letter); 2358 } 2359 else 2360 { 2361 current_sym_nchars = 8; 2362 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP, 2363 regparm_letter); 2364 } 2365 2366 dbxout_type (parm_type, 0, 0); 2367 dbxout_finish_symbol (parms); 2368 } 2369 else if (GET_CODE (DECL_RTL (parms)) == MEM 2370 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG 2371 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM 2372 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM 2373#if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM 2374 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM 2375#endif 2376 ) 2377 { 2378 /* Parm was passed via invisible reference. 2379 That is, its address was passed in a register. 2380 Output it as if it lived in that register. 2381 The debugger will know from the type 2382 that it was actually passed by invisible reference. */ 2383 2384 char regparm_letter; 2385 /* Parm passed in registers and lives in registers or nowhere. */ 2386 2387 current_sym_code = DBX_REGPARM_STABS_CODE; 2388 if (use_gnu_debug_info_extensions) 2389 regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER; 2390 else 2391 regparm_letter = DBX_REGPARM_STABS_LETTER; 2392 2393 /* DECL_RTL looks like (MEM (REG...). Get the register number. 2394 If it is an unallocated pseudo-reg, then use the register where 2395 it was passed instead. */ 2396 if (REGNO (XEXP (DECL_RTL (parms), 0)) >= 0 2397 && REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER) 2398 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0)); 2399 else 2400 current_sym_value = REGNO (DECL_INCOMING_RTL (parms)); 2401 2402 current_sym_addr = 0; 2403 2404 FORCE_TEXT; 2405 if (DECL_NAME (parms)) 2406 { 2407 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms))); 2408 2409 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP, 2410 IDENTIFIER_POINTER (DECL_NAME (parms)), 2411 regparm_letter); 2412 } 2413 else 2414 { 2415 current_sym_nchars = 8; 2416 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP, 2417 regparm_letter); 2418 } 2419 2420 dbxout_type (TREE_TYPE (parms), 0, 0); 2421 dbxout_finish_symbol (parms); 2422 } 2423 else if (GET_CODE (DECL_RTL (parms)) == MEM 2424 && XEXP (DECL_RTL (parms), 0) != const0_rtx 2425 /* ??? A constant address for a parm can happen 2426 when the reg it lives in is equiv to a constant in memory. 2427 Should make this not happen, after 2.4. */ 2428 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0))) 2429 { 2430 /* Parm was passed in registers but lives on the stack. */ 2431 2432 current_sym_code = N_PSYM; 2433 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))), 2434 in which case we want the value of that CONST_INT, 2435 or (MEM (REG ...)) or (MEM (MEM ...)), 2436 in which case we use a value of zero. */ 2437 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG 2438 || GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM) 2439 current_sym_value = 0; 2440 else 2441 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)); 2442 current_sym_addr = 0; 2443 2444 /* Make a big endian correction if the mode of the type of the 2445 parameter is not the same as the mode of the rtl. */ 2446 if (BYTES_BIG_ENDIAN 2447 && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms)) 2448 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD) 2449 { 2450 current_sym_value += UNITS_PER_WORD - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))); 2451 } 2452 2453 FORCE_TEXT; 2454 if (DECL_NAME (parms)) 2455 { 2456 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms))); 2457 2458 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP, 2459 IDENTIFIER_POINTER (DECL_NAME (parms)), 2460 DBX_MEMPARM_STABS_LETTER); 2461 } 2462 else 2463 { 2464 current_sym_nchars = 8; 2465 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP, 2466 DBX_MEMPARM_STABS_LETTER); 2467 } 2468 2469 current_sym_value 2470 = DEBUGGER_ARG_OFFSET (current_sym_value, 2471 XEXP (DECL_RTL (parms), 0)); 2472 dbxout_type (TREE_TYPE (parms), 0, 0); 2473 dbxout_finish_symbol (parms); 2474 } 2475 } 2476} 2477 2478/* Output definitions for the places where parms live during the function, 2479 when different from where they were passed, when the parms were passed 2480 in memory. 2481 2482 It is not useful to do this for parms passed in registers 2483 that live during the function in different registers, because it is 2484 impossible to look in the passed register for the passed value, 2485 so we use the within-the-function register to begin with. 2486 2487 PARMS is a chain of PARM_DECL nodes. */ 2488 2489void 2490dbxout_reg_parms (parms) 2491 tree parms; 2492{ 2493 for (; parms; parms = TREE_CHAIN (parms)) 2494 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms)) 2495 { 2496 dbxout_prepare_symbol (parms); 2497 2498 /* Report parms that live in registers during the function 2499 but were passed in memory. */ 2500 if (GET_CODE (DECL_RTL (parms)) == REG 2501 && REGNO (DECL_RTL (parms)) >= 0 2502 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER) 2503 dbxout_symbol_location (parms, TREE_TYPE (parms), 2504 0, DECL_RTL (parms)); 2505 else if (GET_CODE (DECL_RTL (parms)) == CONCAT) 2506 dbxout_symbol_location (parms, TREE_TYPE (parms), 2507 0, DECL_RTL (parms)); 2508 /* Report parms that live in memory but not where they were passed. */ 2509 else if (GET_CODE (DECL_RTL (parms)) == MEM 2510 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms))) 2511 dbxout_symbol_location (parms, TREE_TYPE (parms), 2512 0, DECL_RTL (parms)); 2513 } 2514} 2515 2516/* Given a chain of ..._TYPE nodes (as come in a parameter list), 2517 output definitions of those names, in raw form */ 2518 2519void 2520dbxout_args (args) 2521 tree args; 2522{ 2523 while (args) 2524 { 2525 putc (',', asmfile); 2526 dbxout_type (TREE_VALUE (args), 0, 0); 2527 CHARS (1); 2528 args = TREE_CHAIN (args); 2529 } 2530} 2531 2532/* Given a chain of ..._TYPE nodes, 2533 find those which have typedef names and output those names. 2534 This is to ensure those types get output. */ 2535 2536void 2537dbxout_types (types) 2538 register tree types; 2539{ 2540 while (types) 2541 { 2542 if (TYPE_NAME (types) 2543 && TREE_CODE (TYPE_NAME (types)) == TYPE_DECL 2544 && ! TREE_ASM_WRITTEN (TYPE_NAME (types))) 2545 dbxout_symbol (TYPE_NAME (types), 1); 2546 types = TREE_CHAIN (types); 2547 } 2548} 2549 2550/* Output everything about a symbol block (a BLOCK node 2551 that represents a scope level), 2552 including recursive output of contained blocks. 2553 2554 BLOCK is the BLOCK node. 2555 DEPTH is its depth within containing symbol blocks. 2556 ARGS is usually zero; but for the outermost block of the 2557 body of a function, it is a chain of PARM_DECLs for the function parameters. 2558 We output definitions of all the register parms 2559 as if they were local variables of that block. 2560 2561 If -g1 was used, we count blocks just the same, but output nothing 2562 except for the outermost block. 2563 2564 Actually, BLOCK may be several blocks chained together. 2565 We handle them all in sequence. */ 2566 2567static void 2568dbxout_block (block, depth, args) 2569 register tree block; 2570 int depth; 2571 tree args; 2572{ 2573 int blocknum; 2574 2575 while (block) 2576 { 2577 /* Ignore blocks never expanded or otherwise marked as real. */ 2578 if (TREE_USED (block)) 2579 { 2580#ifndef DBX_LBRAC_FIRST 2581 /* In dbx format, the syms of a block come before the N_LBRAC. */ 2582 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0) 2583 dbxout_syms (BLOCK_VARS (block)); 2584 if (args) 2585 dbxout_reg_parms (args); 2586#endif 2587 2588 /* Now output an N_LBRAC symbol to represent the beginning of 2589 the block. Use the block's tree-walk order to generate 2590 the assembler symbols LBBn and LBEn 2591 that final will define around the code in this block. */ 2592 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE) 2593 { 2594 char buf[20]; 2595 blocknum = next_block_number++; 2596 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum); 2597 2598 if (BLOCK_HANDLER_BLOCK (block)) 2599 { 2600 /* A catch block. Must precede N_LBRAC. */ 2601 tree decl = BLOCK_VARS (block); 2602 while (decl) 2603 { 2604#ifdef DBX_OUTPUT_CATCH 2605 DBX_OUTPUT_CATCH (asmfile, decl, buf); 2606#else 2607 fprintf (asmfile, "%s \"%s:C1\",%d,0,0,", ASM_STABS_OP, 2608 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH); 2609 assemble_name (asmfile, buf); 2610 fprintf (asmfile, "\n"); 2611#endif 2612 decl = TREE_CHAIN (decl); 2613 } 2614 } 2615 2616#ifdef DBX_OUTPUT_LBRAC 2617 DBX_OUTPUT_LBRAC (asmfile, buf); 2618#else 2619 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC); 2620 assemble_name (asmfile, buf); 2621#if DBX_BLOCKS_FUNCTION_RELATIVE 2622 fputc ('-', asmfile); 2623 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); 2624#endif 2625 fprintf (asmfile, "\n"); 2626#endif 2627 } 2628 else if (depth > 0) 2629 /* Count blocks the same way regardless of debug_info_level. */ 2630 next_block_number++; 2631 2632#ifdef DBX_LBRAC_FIRST 2633 /* On some weird machines, the syms of a block 2634 come after the N_LBRAC. */ 2635 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0) 2636 dbxout_syms (BLOCK_VARS (block)); 2637 if (args) 2638 dbxout_reg_parms (args); 2639#endif 2640 2641 /* Output the subblocks. */ 2642 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE); 2643 2644 /* Refer to the marker for the end of the block. */ 2645 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE) 2646 { 2647 char buf[20]; 2648 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum); 2649#ifdef DBX_OUTPUT_RBRAC 2650 DBX_OUTPUT_RBRAC (asmfile, buf); 2651#else 2652 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC); 2653 assemble_name (asmfile, buf); 2654#if DBX_BLOCKS_FUNCTION_RELATIVE 2655 fputc ('-', asmfile); 2656 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); 2657#endif 2658 fprintf (asmfile, "\n"); 2659#endif 2660 } 2661 } 2662 block = BLOCK_CHAIN (block); 2663 } 2664} 2665 2666/* Output the information about a function and its arguments and result. 2667 Usually this follows the function's code, 2668 but on some systems, it comes before. */ 2669 2670static void 2671dbxout_really_begin_function (decl) 2672 tree decl; 2673{ 2674 dbxout_symbol (decl, 0); 2675 dbxout_parms (DECL_ARGUMENTS (decl)); 2676 if (DECL_NAME (DECL_RESULT (decl)) != 0) 2677 dbxout_symbol (DECL_RESULT (decl), 1); 2678} 2679 2680/* Called at beginning of output of function definition. */ 2681 2682void 2683dbxout_begin_function (decl) 2684 tree decl; 2685{ 2686#ifdef DBX_FUNCTION_FIRST 2687 dbxout_really_begin_function (decl); 2688#else 2689#ifdef DBX_CHECK_FUNCTION_FIRST 2690 if (DBX_CHECK_FUNCTION_FIRST) 2691 dbxout_really_begin_function (decl); 2692#endif 2693#endif 2694} 2695 2696/* Output dbx data for a function definition. 2697 This includes a definition of the function name itself (a symbol), 2698 definitions of the parameters (locating them in the parameter list) 2699 and then output the block that makes up the function's body 2700 (including all the auto variables of the function). */ 2701 2702void 2703dbxout_function (decl) 2704 tree decl; 2705{ 2706#ifndef DBX_FUNCTION_FIRST 2707 dbxout_really_begin_function (decl); 2708#else 2709#ifdef DBX_CHECK_FUNCTION_FIRST 2710 if (!(DBX_CHECK_FUNCTION_FIRST)) 2711 dbxout_really_begin_function (decl); 2712#endif 2713#endif 2714 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl)); 2715#ifdef DBX_OUTPUT_FUNCTION_END 2716 DBX_OUTPUT_FUNCTION_END (asmfile, decl); 2717#endif 2718#if defined(ASM_OUTPUT_SECTION_NAME) 2719 if (use_gnu_debug_info_extensions 2720#if defined(NO_DBX_FUNCTION_END) 2721 && ! NO_DBX_FUNCTION_END 2722#endif 2723 ) 2724 dbxout_function_end (); 2725#endif 2726} 2727#endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */ 2728