|
|
1.1 root 1: /* This file contains code written by Ron Guilmette ([email protected]) for 2: Network Computing Devices, August, September, October, November 1990. 3: 4: Output Dwarf format symbol table information from the GNU C compiler. 5: Copyright (C) 1992 Free Software Foundation, Inc. 6: 7: This file is part of GNU CC. 8: 9: GNU CC is free software; you can redistribute it and/or modify 10: it under the terms of the GNU General Public License as published by 11: the Free Software Foundation; either version 2, or (at your option) 12: any later version. 13: 14: GNU CC is distributed in the hope that it will be useful, 15: but WITHOUT ANY WARRANTY; without even the implied warranty of 16: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17: GNU General Public License for more details. 18: 19: You should have received a copy of the GNU General Public License 20: along with GNU CC; see the file COPYING. If not, write to 21: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 22: 23: #include "config.h" 24: 25: #ifdef DWARF_DEBUGGING_INFO 26: #include <stdio.h> 27: #include "dwarf.h" 28: #include "tree.h" 29: #include "flags.h" 30: #include "rtl.h" 1.1.1.4 root 31: #include "hard-reg-set.h" 1.1 root 32: #include "insn-config.h" 33: #include "reload.h" 34: #include "output.h" 1.1.1.3 root 35: #include "defaults.h" 36: 37: #ifndef DWARF_VERSION 38: #define DWARF_VERSION 1 39: #endif 1.1 root 40: 41: /* #define NDEBUG 1 */ 1.1.1.4 root 42: #include "assert.h" 1.1 root 43: 44: #if defined(DWARF_TIMESTAMPS) 45: #if defined(POSIX) 46: #include <time.h> 47: #else /* !defined(POSIX) */ 48: #include <sys/types.h> 49: #if defined(__STDC__) 50: extern time_t time (time_t *); 51: #else /* !defined(__STDC__) */ 52: extern time_t time (); 53: #endif /* !defined(__STDC__) */ 54: #endif /* !defined(POSIX) */ 55: #endif /* defined(DWARF_TIMESTAMPS) */ 56: 1.1.1.3 root 57: extern char *getpwd (); 1.1.1.2 root 58: 1.1.1.4 root 59: extern char *index (); 60: extern char *rindex (); 61: 1.1 root 62: /* IMPORTANT NOTE: Please see the file README.DWARF for important details 63: regarding the GNU implementation of Dwarf. */ 64: 65: /* NOTE: In the comments in this file, many references are made to 66: so called "Debugging Information Entries". For the sake of brevity, 67: this term is abbreviated to `DIE' throughout the remainder of this 68: file. */ 69: 70: /* Note that the implementation of C++ support herein is (as yet) unfinished. 71: If you want to try to complete it, more power to you. */ 72: 73: #if defined(__GNUC__) && (NDEBUG == 1) 74: #define inline static inline 75: #else 76: #define inline static 77: #endif 78: 79: /* How to start an assembler comment. */ 80: #ifndef ASM_COMMENT_START 81: #define ASM_COMMENT_START ";#" 82: #endif 83: 1.1.1.4 root 84: /* How to print out a register name. */ 85: #ifndef PRINT_REG 86: #define PRINT_REG(RTX, CODE, FILE) \ 87: fprintf ((FILE), "%s", reg_names[REGNO (RTX)]) 88: #endif 1.1 root 89: 90: /* Define a macro which returns non-zero for any tagged type which is 91: used (directly or indirectly) in the specification of either some 92: function's return type or some formal parameter of some function. 93: We use this macro when we are operating in "terse" mode to help us 94: know what tagged types have to be represented in Dwarf (even in 95: terse mode) and which ones don't. 96: 97: A flag bit with this meaning really should be a part of the normal 98: GCC ..._TYPE nodes, but at the moment, there is no such bit defined 99: for these nodes. For now, we have to just fake it. It it safe for 100: us to simply return zero for all complete tagged types (which will 101: get forced out anyway if they were used in the specification of some 102: formal or return type) and non-zero for all incomplete tagged types. 103: */ 104: 105: #define TYPE_USED_FOR_FUNCTION(tagged_type) (TYPE_SIZE (tagged_type) == 0) 106: 107: extern int flag_traditional; 108: extern char *version_string; 109: extern char *language_string; 110: 111: /* Maximum size (in bytes) of an artificially generated label. */ 112: 113: #define MAX_ARTIFICIAL_LABEL_BYTES 30 114: 115: /* Make sure we know the sizes of the various types dwarf can describe. 116: These are only defaults. If the sizes are different for your target, 117: you should override these values by defining the appropriate symbols 118: in your tm.h file. */ 119: 120: #ifndef CHAR_TYPE_SIZE 121: #define CHAR_TYPE_SIZE BITS_PER_UNIT 122: #endif 123: 124: #ifndef SHORT_TYPE_SIZE 125: #define SHORT_TYPE_SIZE (BITS_PER_UNIT * 2) 126: #endif 127: 128: #ifndef INT_TYPE_SIZE 129: #define INT_TYPE_SIZE BITS_PER_WORD 130: #endif 131: 132: #ifndef LONG_TYPE_SIZE 133: #define LONG_TYPE_SIZE BITS_PER_WORD 134: #endif 135: 136: #ifndef LONG_LONG_TYPE_SIZE 137: #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2) 138: #endif 139: 140: #ifndef WCHAR_TYPE_SIZE 141: #define WCHAR_TYPE_SIZE INT_TYPE_SIZE 142: #endif 143: 144: #ifndef WCHAR_UNSIGNED 145: #define WCHAR_UNSIGNED 0 146: #endif 147: 148: #ifndef FLOAT_TYPE_SIZE 149: #define FLOAT_TYPE_SIZE BITS_PER_WORD 150: #endif 151: 152: #ifndef DOUBLE_TYPE_SIZE 153: #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2) 154: #endif 155: 156: #ifndef LONG_DOUBLE_TYPE_SIZE 157: #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2) 158: #endif 159: 160: /* Structure to keep track of source filenames. */ 161: 162: struct filename_entry { 163: unsigned number; 164: char * name; 165: }; 166: 167: typedef struct filename_entry filename_entry; 168: 169: /* Pointer to an array of elements, each one having the structure above. */ 170: 171: static filename_entry *filename_table; 172: 173: /* Total number of entries in the table (i.e. array) pointed to by 174: `filename_table'. This is the *total* and includes both used and 175: unused slots. */ 176: 177: static unsigned ft_entries_allocated; 178: 179: /* Number of entries in the filename_table which are actually in use. */ 180: 181: static unsigned ft_entries; 182: 183: /* Size (in elements) of increments by which we may expand the filename 184: table. Actually, a single hunk of space of this size should be enough 185: for most typical programs. */ 186: 187: #define FT_ENTRIES_INCREMENT 64 188: 189: /* Local pointer to the name of the main input file. Initialized in 190: dwarfout_init. */ 191: 192: static char *primary_filename; 193: 194: /* Pointer to the most recent filename for which we produced some line info. */ 195: 196: static char *last_filename; 197: 198: /* For Dwarf output, we must assign lexical-blocks id numbers 199: in the order in which their beginnings are encountered. 200: We output Dwarf debugging info that refers to the beginnings 201: and ends of the ranges of code for each lexical block with 202: assembler labels ..Bn and ..Bn.e, where n is the block number. 203: The labels themselves are generated in final.c, which assigns 204: numbers to the blocks in the same way. */ 205: 206: static unsigned next_block_number = 2; 207: 208: /* Counter to generate unique names for DIEs. */ 209: 210: static unsigned next_unused_dienum = 1; 211: 212: /* Number of the DIE which is currently being generated. */ 213: 214: static unsigned current_dienum; 215: 216: /* Number to use for the special "pubname" label on the next DIE which 217: represents a function or data object defined in this compilation 218: unit which has "extern" linkage. */ 219: 220: static next_pubname_number = 0; 221: 222: #define NEXT_DIE_NUM pending_sibling_stack[pending_siblings-1] 223: 224: /* Pointer to a dynamically allocated list of pre-reserved and still 225: pending sibling DIE numbers. Note that this list will grow as needed. */ 226: 227: static unsigned *pending_sibling_stack; 228: 229: /* Counter to keep track of the number of pre-reserved and still pending 230: sibling DIE numbers. */ 231: 232: static unsigned pending_siblings; 233: 234: /* The currently allocated size of the above list (expressed in number of 235: list elements). */ 236: 237: static unsigned pending_siblings_allocated; 238: 239: /* Size (in elements) of increments by which we may expand the pending 240: sibling stack. Actually, a single hunk of space of this size should 241: be enough for most typical programs. */ 242: 243: #define PENDING_SIBLINGS_INCREMENT 64 244: 245: /* Non-zero if we are performing our file-scope finalization pass and if 1.1.1.3 root 246: we should force out Dwarf descriptions of any and all file-scope 1.1 root 247: tagged types which are still incomplete types. */ 248: 249: static int finalizing = 0; 250: 251: /* A pointer to the base of a list of pending types which we haven't 252: generated DIEs for yet, but which we will have to come back to 253: later on. */ 254: 255: static tree *pending_types_list; 256: 257: /* Number of elements currently allocated for the pending_types_list. */ 258: 259: static unsigned pending_types_allocated; 260: 261: /* Number of elements of pending_types_list currently in use. */ 262: 263: static unsigned pending_types; 264: 265: /* Size (in elements) of increments by which we may expand the pending 266: types list. Actually, a single hunk of space of this size should 267: be enough for most typical programs. */ 268: 269: #define PENDING_TYPES_INCREMENT 64 270: 1.1.1.3 root 271: /* Pointer to an artificial RECORD_TYPE which we create in dwarfout_init. 1.1 root 272: This is used in a hack to help us get the DIEs describing types of 273: formal parameters to come *after* all of the DIEs describing the formal 274: parameters themselves. That's necessary in order to be compatible 1.1.1.3 root 275: with what the brain-damaged svr4 SDB debugger requires. */ 1.1 root 276: 277: static tree fake_containing_scope; 278: 279: /* The number of the current function definition that we are generating 280: debugging information for. These numbers range from 1 up to the maximum 281: number of function definitions contained within the current compilation 282: unit. These numbers are used to create unique labels for various things 283: contained within various function definitions. */ 284: 285: static unsigned current_funcdef_number = 1; 286: 1.1.1.4 root 287: /* A pointer to the ..._DECL node which we have most recently been working 288: on. We keep this around just in case something about it looks screwy 289: and we want to tell the user what the source coordinates for the actual 290: declaration are. */ 291: 292: static tree dwarf_last_decl; 293: 1.1 root 294: /* Forward declarations for functions defined in this file. */ 295: 296: static void output_type (); 297: static void type_attribute (); 298: static void output_decls_for_scope (); 299: static void output_decl (); 300: static unsigned lookup_filename (); 301: 302: /* Definitions of defaults for assembler-dependent names of various 303: pseudo-ops and section names. 304: 305: Theses may be overridden in your tm.h file (if necessary) for your 306: particular assembler. The default values provided here correspond to 307: what is expected by "standard" AT&T System V.4 assemblers. */ 308: 309: #ifndef FILE_ASM_OP 1.1.1.2 root 310: #define FILE_ASM_OP ".file" 1.1 root 311: #endif 312: #ifndef VERSION_ASM_OP 1.1.1.2 root 313: #define VERSION_ASM_OP ".version" 1.1 root 314: #endif 315: #ifndef UNALIGNED_SHORT_ASM_OP 1.1.1.2 root 316: #define UNALIGNED_SHORT_ASM_OP ".2byte" 1.1 root 317: #endif 318: #ifndef UNALIGNED_INT_ASM_OP 1.1.1.2 root 319: #define UNALIGNED_INT_ASM_OP ".4byte" 1.1 root 320: #endif 1.1.1.3 root 321: #ifndef ASM_BYTE_OP 322: #define ASM_BYTE_OP ".byte" 323: #endif 324: #ifndef SET_ASM_OP 325: #define SET_ASM_OP ".set" 1.1 root 326: #endif 327: 1.1.1.3 root 328: /* Pseudo-ops for pushing the current section onto the section stack (and 329: simultaneously changing to a new section) and for poping back to the 330: section we were in immediately before this one. Note that most svr4 331: assemblers only maintain a one level stack... you can push all the 332: sections you want, but you can only pop out one level. (The sparc 333: svr4 assembler is an exception to this general rule.) That's 334: OK because we only use at most one level of the section stack herein. */ 335: 336: #ifndef PUSHSECTION_ASM_OP 337: #define PUSHSECTION_ASM_OP ".section" 338: #endif 339: #ifndef POPSECTION_ASM_OP 340: #define POPSECTION_ASM_OP ".previous" 341: #endif 342: 343: /* The default format used by the ASM_OUTPUT_PUSH_SECTION macro (see below) 344: to print the PUSHSECTION_ASM_OP and the section name. The default here 345: works for almost all svr4 assemblers, except for the sparc, where the 346: section name must be enclosed in double quotes. (See sparcv4.h.) */ 347: 348: #ifndef PUSHSECTION_FORMAT 349: #define PUSHSECTION_FORMAT "%s\t%s\n" 350: #endif 351: 352: #ifndef DEBUG_SECTION 353: #define DEBUG_SECTION ".debug" 354: #endif 355: #ifndef LINE_SECTION 356: #define LINE_SECTION ".line" 357: #endif 358: #ifndef SFNAMES_SECTION 359: #define SFNAMES_SECTION ".debug_sfnames" 360: #endif 361: #ifndef SRCINFO_SECTION 362: #define SRCINFO_SECTION ".debug_srcinfo" 363: #endif 364: #ifndef MACINFO_SECTION 365: #define MACINFO_SECTION ".debug_macinfo" 366: #endif 367: #ifndef PUBNAMES_SECTION 368: #define PUBNAMES_SECTION ".debug_pubnames" 369: #endif 370: #ifndef ARANGES_SECTION 371: #define ARANGES_SECTION ".debug_aranges" 372: #endif 373: #ifndef TEXT_SECTION 374: #define TEXT_SECTION ".text" 375: #endif 376: #ifndef DATA_SECTION 377: #define DATA_SECTION ".data" 378: #endif 379: #ifndef DATA1_SECTION 380: #define DATA1_SECTION ".data1" 381: #endif 382: #ifndef RODATA_SECTION 383: #define RODATA_SECTION ".rodata" 384: #endif 385: #ifndef RODATA1_SECTION 386: #define RODATA1_SECTION ".rodata1" 387: #endif 388: #ifndef BSS_SECTION 389: #define BSS_SECTION ".bss" 1.1 root 390: #endif 391: 392: /* Definitions of defaults for formats and names of various special 393: (artificial) labels which may be generated within this file (when 394: the -g options is used and DWARF_DEBUGGING_INFO is in effect. 395: 396: If necessary, these may be overridden from within your tm.h file, 1.1.1.3 root 397: but typically, you should never need to override these. 398: 399: These labels have been hacked (temporarily) so that they all begin with 400: a `.L' sequence so as to appease the stock sparc/svr4 assembler and the 401: stock m88k/svr4 assembler, both of which need to see .L at the start of 402: a label in order to prevent that label from going into the linker symbol 403: table). When I get time, I'll have to fix this the right way so that we 404: will use ASM_GENERATE_INTERNAL_LABEL and ASM_OUTPUT_INTERNAL_LABEL herein, 405: but that will require a rather massive set of changes. For the moment, 406: the following definitions out to produce the right results for all svr4 407: and svr3 assemblers. -- rfg 408: */ 1.1 root 409: 410: #ifndef TEXT_BEGIN_LABEL 1.1.1.3 root 411: #define TEXT_BEGIN_LABEL ".L_text_b" 1.1 root 412: #endif 413: #ifndef TEXT_END_LABEL 1.1.1.3 root 414: #define TEXT_END_LABEL ".L_text_e" 1.1 root 415: #endif 416: 417: #ifndef DATA_BEGIN_LABEL 1.1.1.3 root 418: #define DATA_BEGIN_LABEL ".L_data_b" 1.1 root 419: #endif 420: #ifndef DATA_END_LABEL 1.1.1.3 root 421: #define DATA_END_LABEL ".L_data_e" 1.1 root 422: #endif 423: 424: #ifndef DATA1_BEGIN_LABEL 1.1.1.3 root 425: #define DATA1_BEGIN_LABEL ".L_data1_b" 1.1 root 426: #endif 427: #ifndef DATA1_END_LABEL 1.1.1.3 root 428: #define DATA1_END_LABEL ".L_data1_e" 1.1 root 429: #endif 430: 431: #ifndef RODATA_BEGIN_LABEL 1.1.1.3 root 432: #define RODATA_BEGIN_LABEL ".L_rodata_b" 1.1 root 433: #endif 434: #ifndef RODATA_END_LABEL 1.1.1.3 root 435: #define RODATA_END_LABEL ".L_rodata_e" 1.1 root 436: #endif 437: 438: #ifndef RODATA1_BEGIN_LABEL 1.1.1.3 root 439: #define RODATA1_BEGIN_LABEL ".L_rodata1_b" 1.1 root 440: #endif 441: #ifndef RODATA1_END_LABEL 1.1.1.3 root 442: #define RODATA1_END_LABEL ".L_rodata1_e" 1.1 root 443: #endif 444: 445: #ifndef BSS_BEGIN_LABEL 1.1.1.3 root 446: #define BSS_BEGIN_LABEL ".L_bss_b" 1.1 root 447: #endif 448: #ifndef BSS_END_LABEL 1.1.1.3 root 449: #define BSS_END_LABEL ".L_bss_e" 1.1 root 450: #endif 451: 452: #ifndef LINE_BEGIN_LABEL 1.1.1.3 root 453: #define LINE_BEGIN_LABEL ".L_line_b" 1.1 root 454: #endif 455: #ifndef LINE_LAST_ENTRY_LABEL 1.1.1.3 root 456: #define LINE_LAST_ENTRY_LABEL ".L_line_last" 1.1 root 457: #endif 458: #ifndef LINE_END_LABEL 1.1.1.3 root 459: #define LINE_END_LABEL ".L_line_e" 1.1 root 460: #endif 461: 462: #ifndef DEBUG_BEGIN_LABEL 1.1.1.3 root 463: #define DEBUG_BEGIN_LABEL ".L_debug_b" 1.1 root 464: #endif 465: #ifndef SFNAMES_BEGIN_LABEL 1.1.1.3 root 466: #define SFNAMES_BEGIN_LABEL ".L_sfnames_b" 1.1 root 467: #endif 468: #ifndef SRCINFO_BEGIN_LABEL 1.1.1.3 root 469: #define SRCINFO_BEGIN_LABEL ".L_srcinfo_b" 1.1 root 470: #endif 471: #ifndef MACINFO_BEGIN_LABEL 1.1.1.3 root 472: #define MACINFO_BEGIN_LABEL ".L_macinfo_b" 1.1 root 473: #endif 474: 475: #ifndef DIE_BEGIN_LABEL_FMT 1.1.1.3 root 476: #define DIE_BEGIN_LABEL_FMT ".L_D%u" 1.1 root 477: #endif 478: #ifndef DIE_END_LABEL_FMT 1.1.1.3 root 479: #define DIE_END_LABEL_FMT ".L_D%u_e" 1.1 root 480: #endif 481: #ifndef PUB_DIE_LABEL_FMT 1.1.1.3 root 482: #define PUB_DIE_LABEL_FMT ".L_P%u" 1.1 root 483: #endif 484: #ifndef INSN_LABEL_FMT 1.1.1.3 root 485: #define INSN_LABEL_FMT ".L_I%u_%u" 1.1 root 486: #endif 487: #ifndef BLOCK_BEGIN_LABEL_FMT 1.1.1.3 root 488: #define BLOCK_BEGIN_LABEL_FMT ".L_B%u" 1.1 root 489: #endif 490: #ifndef BLOCK_END_LABEL_FMT 1.1.1.3 root 491: #define BLOCK_END_LABEL_FMT ".L_B%u_e" 1.1 root 492: #endif 493: #ifndef SS_BEGIN_LABEL_FMT 1.1.1.3 root 494: #define SS_BEGIN_LABEL_FMT ".L_s%u" 1.1 root 495: #endif 496: #ifndef SS_END_LABEL_FMT 1.1.1.3 root 497: #define SS_END_LABEL_FMT ".L_s%u_e" 1.1 root 498: #endif 499: #ifndef EE_BEGIN_LABEL_FMT 1.1.1.3 root 500: #define EE_BEGIN_LABEL_FMT ".L_e%u" 1.1 root 501: #endif 502: #ifndef EE_END_LABEL_FMT 1.1.1.3 root 503: #define EE_END_LABEL_FMT ".L_e%u_e" 1.1 root 504: #endif 505: #ifndef MT_BEGIN_LABEL_FMT 1.1.1.3 root 506: #define MT_BEGIN_LABEL_FMT ".L_t%u" 1.1 root 507: #endif 508: #ifndef MT_END_LABEL_FMT 1.1.1.3 root 509: #define MT_END_LABEL_FMT ".L_t%u_e" 1.1 root 510: #endif 511: #ifndef LOC_BEGIN_LABEL_FMT 1.1.1.3 root 512: #define LOC_BEGIN_LABEL_FMT ".L_l%u" 1.1 root 513: #endif 514: #ifndef LOC_END_LABEL_FMT 1.1.1.3 root 515: #define LOC_END_LABEL_FMT ".L_l%u_e" 1.1 root 516: #endif 517: #ifndef BOUND_BEGIN_LABEL_FMT 1.1.1.3 root 518: #define BOUND_BEGIN_LABEL_FMT ".L_b%u_%u_%c" 1.1 root 519: #endif 520: #ifndef BOUND_END_LABEL_FMT 1.1.1.3 root 521: #define BOUND_END_LABEL_FMT ".L_b%u_%u_%c_e" 1.1 root 522: #endif 523: #ifndef DERIV_BEGIN_LABEL_FMT 1.1.1.3 root 524: #define DERIV_BEGIN_LABEL_FMT ".L_d%u" 1.1 root 525: #endif 526: #ifndef DERIV_END_LABEL_FMT 1.1.1.3 root 527: #define DERIV_END_LABEL_FMT ".L_d%u_e" 1.1 root 528: #endif 529: #ifndef SL_BEGIN_LABEL_FMT 1.1.1.3 root 530: #define SL_BEGIN_LABEL_FMT ".L_sl%u" 1.1 root 531: #endif 532: #ifndef SL_END_LABEL_FMT 1.1.1.3 root 533: #define SL_END_LABEL_FMT ".L_sl%u_e" 1.1 root 534: #endif 1.1.1.4 root 535: #ifndef BODY_BEGIN_LABEL_FMT 536: #define BODY_BEGIN_LABEL_FMT ".L_b%u" 537: #endif 538: #ifndef BODY_END_LABEL_FMT 539: #define BODY_END_LABEL_FMT ".L_b%u_e" 540: #endif 1.1 root 541: #ifndef FUNC_END_LABEL_FMT 1.1.1.3 root 542: #define FUNC_END_LABEL_FMT ".L_f%u_e" 1.1 root 543: #endif 544: #ifndef TYPE_NAME_FMT 1.1.1.3 root 545: #define TYPE_NAME_FMT ".L_T%u" 1.1 root 546: #endif 1.1.1.4 root 547: #ifndef DECL_NAME_FMT 548: #define DECL_NAME_FMT ".L_E%u" 549: #endif 1.1 root 550: #ifndef LINE_CODE_LABEL_FMT 1.1.1.3 root 551: #define LINE_CODE_LABEL_FMT ".L_LC%u" 1.1 root 552: #endif 553: #ifndef SFNAMES_ENTRY_LABEL_FMT 1.1.1.3 root 554: #define SFNAMES_ENTRY_LABEL_FMT ".L_F%u" 1.1 root 555: #endif 556: #ifndef LINE_ENTRY_LABEL_FMT 1.1.1.3 root 557: #define LINE_ENTRY_LABEL_FMT ".L_LE%u" 1.1 root 558: #endif 559: 560: /* Definitions of defaults for various types of primitive assembly language 561: output operations. 562: 563: If necessary, these may be overridden from within your tm.h file, 1.1.1.3 root 564: but typically, you shouldn't need to override these. One known 565: exception is ASM_OUTPUT_DEF which has to be different for stock 566: sparc/svr4 assemblers. 567: */ 568: 569: #ifndef ASM_OUTPUT_PUSH_SECTION 570: #define ASM_OUTPUT_PUSH_SECTION(FILE, SECTION) \ 571: fprintf ((FILE), PUSHSECTION_FORMAT, PUSHSECTION_ASM_OP, SECTION) 572: #endif 573: 574: #ifndef ASM_OUTPUT_POP_SECTION 575: #define ASM_OUTPUT_POP_SECTION(FILE) \ 576: fprintf ((FILE), "\t%s\n", POPSECTION_ASM_OP) 577: #endif 1.1 root 578: 579: #ifndef ASM_OUTPUT_SOURCE_FILENAME 580: #define ASM_OUTPUT_SOURCE_FILENAME(FILE,NAME) \ 1.1.1.2 root 581: fprintf ((FILE), "\t%s\t\"%s\"\n", FILE_ASM_OP, NAME) 1.1 root 582: #endif 583: 584: #ifndef ASM_OUTPUT_DEF 585: #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \ 1.1.1.3 root 586: do { fprintf ((FILE), "\t%s\t", SET_ASM_OP); \ 1.1 root 587: assemble_name (FILE, LABEL1); \ 588: fprintf (FILE, ","); \ 589: assemble_name (FILE, LABEL2); \ 590: fprintf (FILE, "\n"); \ 591: } while (0) 592: #endif 593: 594: #ifndef ASM_OUTPUT_DWARF_DELTA2 595: #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \ 1.1.1.2 root 596: do { fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \ 1.1 root 597: assemble_name (FILE, LABEL1); \ 598: fprintf (FILE, "-"); \ 599: assemble_name (FILE, LABEL2); \ 600: fprintf (FILE, "\n"); \ 601: } while (0) 602: #endif 603: 604: #ifndef ASM_OUTPUT_DWARF_DELTA4 605: #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \ 1.1.1.2 root 606: do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \ 1.1 root 607: assemble_name (FILE, LABEL1); \ 608: fprintf (FILE, "-"); \ 609: assemble_name (FILE, LABEL2); \ 610: fprintf (FILE, "\n"); \ 611: } while (0) 612: #endif 613: 614: #ifndef ASM_OUTPUT_DWARF_TAG 615: #define ASM_OUTPUT_DWARF_TAG(FILE,TAG) \ 1.1.1.3 root 616: do { \ 617: fprintf ((FILE), "\t%s\t0x%x", \ 618: UNALIGNED_SHORT_ASM_OP, (unsigned) TAG); \ 619: if (flag_verbose_asm) \ 620: fprintf ((FILE), "\t%s %s", \ 621: ASM_COMMENT_START, dwarf_tag_name (TAG)); \ 622: fputc ('\n', (FILE)); \ 623: } while (0) 1.1 root 624: #endif 625: 626: #ifndef ASM_OUTPUT_DWARF_ATTRIBUTE 1.1.1.3 root 627: #define ASM_OUTPUT_DWARF_ATTRIBUTE(FILE,ATTR) \ 628: do { \ 629: fprintf ((FILE), "\t%s\t0x%x", \ 630: UNALIGNED_SHORT_ASM_OP, (unsigned) ATTR); \ 631: if (flag_verbose_asm) \ 632: fprintf ((FILE), "\t%s %s", \ 633: ASM_COMMENT_START, dwarf_attr_name (ATTR)); \ 634: fputc ('\n', (FILE)); \ 635: } while (0) 1.1 root 636: #endif 637: 638: #ifndef ASM_OUTPUT_DWARF_STACK_OP 639: #define ASM_OUTPUT_DWARF_STACK_OP(FILE,OP) \ 1.1.1.3 root 640: do { \ 641: fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) OP); \ 642: if (flag_verbose_asm) \ 643: fprintf ((FILE), "\t%s %s", \ 644: ASM_COMMENT_START, dwarf_stack_op_name (OP)); \ 645: fputc ('\n', (FILE)); \ 646: } while (0) 1.1 root 647: #endif 648: 649: #ifndef ASM_OUTPUT_DWARF_FUND_TYPE 650: #define ASM_OUTPUT_DWARF_FUND_TYPE(FILE,FT) \ 1.1.1.3 root 651: do { \ 652: fprintf ((FILE), "\t%s\t0x%x", \ 653: UNALIGNED_SHORT_ASM_OP, (unsigned) FT); \ 654: if (flag_verbose_asm) \ 655: fprintf ((FILE), "\t%s %s", \ 656: ASM_COMMENT_START, dwarf_fund_type_name (FT)); \ 657: fputc ('\n', (FILE)); \ 658: } while (0) 1.1 root 659: #endif 660: 661: #ifndef ASM_OUTPUT_DWARF_FMT_BYTE 662: #define ASM_OUTPUT_DWARF_FMT_BYTE(FILE,FMT) \ 1.1.1.3 root 663: do { \ 664: fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) FMT); \ 665: if (flag_verbose_asm) \ 666: fprintf ((FILE), "\t%s %s", \ 667: ASM_COMMENT_START, dwarf_fmt_byte_name (FMT)); \ 668: fputc ('\n', (FILE)); \ 669: } while (0) 1.1 root 670: #endif 671: 672: #ifndef ASM_OUTPUT_DWARF_TYPE_MODIFIER 673: #define ASM_OUTPUT_DWARF_TYPE_MODIFIER(FILE,MOD) \ 1.1.1.3 root 674: do { \ 675: fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) MOD); \ 676: if (flag_verbose_asm) \ 677: fprintf ((FILE), "\t%s %s", \ 678: ASM_COMMENT_START, dwarf_typemod_name (MOD)); \ 679: fputc ('\n', (FILE)); \ 680: } while (0) 1.1 root 681: #endif 682: 683: #ifndef ASM_OUTPUT_DWARF_ADDR 684: #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \ 1.1.1.2 root 685: do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \ 1.1 root 686: assemble_name (FILE, LABEL); \ 687: fprintf (FILE, "\n"); \ 688: } while (0) 689: #endif 690: 691: #ifndef ASM_OUTPUT_DWARF_ADDR_CONST 692: #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX) \ 1.1.1.3 root 693: do { \ 694: fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \ 695: output_addr_const ((FILE), (RTX)); \ 696: fputc ('\n', (FILE)); \ 697: } while (0) 1.1 root 698: #endif 699: 700: #ifndef ASM_OUTPUT_DWARF_REF 701: #define ASM_OUTPUT_DWARF_REF(FILE,LABEL) \ 1.1.1.2 root 702: do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \ 1.1 root 703: assemble_name (FILE, LABEL); \ 704: fprintf (FILE, "\n"); \ 705: } while (0) 706: #endif 707: 708: #ifndef ASM_OUTPUT_DWARF_DATA1 709: #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \ 1.1.1.3 root 710: fprintf ((FILE), "\t%s\t0x%x\n", ASM_BYTE_OP, VALUE) 1.1 root 711: #endif 712: 713: #ifndef ASM_OUTPUT_DWARF_DATA2 714: #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \ 1.1.1.2 root 715: fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_SHORT_ASM_OP, (unsigned) VALUE) 1.1 root 716: #endif 717: 718: #ifndef ASM_OUTPUT_DWARF_DATA4 719: #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \ 1.1.1.2 root 720: fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, (unsigned) VALUE) 1.1 root 721: #endif 722: 723: #ifndef ASM_OUTPUT_DWARF_DATA8 724: #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \ 725: do { \ 726: if (WORDS_BIG_ENDIAN) \ 727: { \ 1.1.1.2 root 728: fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \ 729: fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\ 1.1 root 730: } \ 731: else \ 732: { \ 1.1.1.2 root 733: fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\ 734: fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \ 1.1 root 735: } \ 736: } while (0) 737: #endif 738: 739: #ifndef ASM_OUTPUT_DWARF_STRING 740: #define ASM_OUTPUT_DWARF_STRING(FILE,P) \ 741: ASM_OUTPUT_ASCII ((FILE), P, strlen (P)+1) 742: #endif 743: 744: /************************ general utility functions **************************/ 745: 746: inline char * 747: xstrdup (s) 748: register char *s; 749: { 750: register char *p = (char *) xmalloc (strlen (s) + 1); 751: 752: strcpy (p, s); 753: return p; 754: } 755: 1.1.1.3 root 756: inline int 757: is_pseudo_reg (rtl) 758: register rtx rtl; 759: { 760: return (((GET_CODE (rtl) == REG) && (REGNO (rtl) >= FIRST_PSEUDO_REGISTER)) 761: || ((GET_CODE (rtl) == SUBREG) 762: && (REGNO (XEXP (rtl, 0)) >= FIRST_PSEUDO_REGISTER))); 763: } 764: 1.1.1.5 ! root 765: inline tree ! 766: type_main_variant (type) ! 767: register tree type; ! 768: { ! 769: type = TYPE_MAIN_VARIANT (type); ! 770: ! 771: /* There really should be only one main variant among any group of variants ! 772: of a given type (and all of the MAIN_VARIANT values for all members of ! 773: the group should point to that one type) but sometimes the C front-end ! 774: messes this up for array types, so we work around that bug here. */ ! 775: ! 776: if (TREE_CODE (type) == ARRAY_TYPE) ! 777: { ! 778: while (type != TYPE_MAIN_VARIANT (type)) ! 779: type = TYPE_MAIN_VARIANT (type); ! 780: } ! 781: ! 782: return type; ! 783: } ! 784: 1.1.1.4 root 785: /* Return non-zero if the given type node represents a tagged type. */ 786: 787: inline int 788: is_tagged_type (type) 789: register tree type; 790: { 791: register enum tree_code code = TREE_CODE (type); 792: 1.1.1.5 ! root 793: return (code == RECORD_TYPE || code == UNION_TYPE ! 794: || code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE); 1.1.1.4 root 795: } 796: 1.1 root 797: static char * 1.1.1.3 root 798: dwarf_tag_name (tag) 1.1 root 799: register unsigned tag; 800: { 801: switch (tag) 802: { 1.1.1.3 root 803: case TAG_padding: return "TAG_padding"; 804: case TAG_array_type: return "TAG_array_type"; 805: case TAG_class_type: return "TAG_class_type"; 806: case TAG_entry_point: return "TAG_entry_point"; 807: case TAG_enumeration_type: return "TAG_enumeration_type"; 808: case TAG_formal_parameter: return "TAG_formal_parameter"; 809: case TAG_global_subroutine: return "TAG_global_subroutine"; 810: case TAG_global_variable: return "TAG_global_variable"; 811: case TAG_label: return "TAG_label"; 812: case TAG_lexical_block: return "TAG_lexical_block"; 813: case TAG_local_variable: return "TAG_local_variable"; 814: case TAG_member: return "TAG_member"; 815: case TAG_pointer_type: return "TAG_pointer_type"; 816: case TAG_reference_type: return "TAG_reference_type"; 817: case TAG_compile_unit: return "TAG_compile_unit"; 818: case TAG_string_type: return "TAG_string_type"; 819: case TAG_structure_type: return "TAG_structure_type"; 820: case TAG_subroutine: return "TAG_subroutine"; 821: case TAG_subroutine_type: return "TAG_subroutine_type"; 822: case TAG_typedef: return "TAG_typedef"; 823: case TAG_union_type: return "TAG_union_type"; 1.1 root 824: case TAG_unspecified_parameters: return "TAG_unspecified_parameters"; 1.1.1.3 root 825: case TAG_variant: return "TAG_variant"; 826: case TAG_common_block: return "TAG_common_block"; 827: case TAG_common_inclusion: return "TAG_common_inclusion"; 828: case TAG_inheritance: return "TAG_inheritance"; 829: case TAG_inlined_subroutine: return "TAG_inlined_subroutine"; 830: case TAG_module: return "TAG_module"; 831: case TAG_ptr_to_member_type: return "TAG_ptr_to_member_type"; 832: case TAG_set_type: return "TAG_set_type"; 833: case TAG_subrange_type: return "TAG_subrange_type"; 834: case TAG_with_stmt: return "TAG_with_stmt"; 835: 836: /* GNU extensions. */ 837: 838: case TAG_format_label: return "TAG_format_label"; 839: case TAG_namelist: return "TAG_namelist"; 840: case TAG_function_template: return "TAG_function_template"; 841: case TAG_class_template: return "TAG_class_template"; 842: 1.1.1.4 root 843: default: return "TAG_<unknown>"; 1.1 root 844: } 845: } 846: 847: static char * 1.1.1.3 root 848: dwarf_attr_name (attr) 1.1 root 849: register unsigned attr; 850: { 851: switch (attr) 852: { 1.1.1.3 root 853: case AT_sibling: return "AT_sibling"; 854: case AT_location: return "AT_location"; 855: case AT_name: return "AT_name"; 856: case AT_fund_type: return "AT_fund_type"; 857: case AT_mod_fund_type: return "AT_mod_fund_type"; 858: case AT_user_def_type: return "AT_user_def_type"; 859: case AT_mod_u_d_type: return "AT_mod_u_d_type"; 860: case AT_ordering: return "AT_ordering"; 861: case AT_subscr_data: return "AT_subscr_data"; 862: case AT_byte_size: return "AT_byte_size"; 863: case AT_bit_offset: return "AT_bit_offset"; 864: case AT_bit_size: return "AT_bit_size"; 865: case AT_element_list: return "AT_element_list"; 866: case AT_stmt_list: return "AT_stmt_list"; 867: case AT_low_pc: return "AT_low_pc"; 868: case AT_high_pc: return "AT_high_pc"; 869: case AT_language: return "AT_language"; 870: case AT_member: return "AT_member"; 871: case AT_discr: return "AT_discr"; 872: case AT_discr_value: return "AT_discr_value"; 873: case AT_string_length: return "AT_string_length"; 874: case AT_common_reference: return "AT_common_reference"; 875: case AT_comp_dir: return "AT_comp_dir"; 876: case AT_const_value_string: return "AT_const_value_string"; 877: case AT_const_value_data2: return "AT_const_value_data2"; 878: case AT_const_value_data4: return "AT_const_value_data4"; 879: case AT_const_value_data8: return "AT_const_value_data8"; 880: case AT_const_value_block2: return "AT_const_value_block2"; 1.1 root 881: case AT_const_value_block4: return "AT_const_value_block4"; 1.1.1.3 root 882: case AT_containing_type: return "AT_containing_type"; 883: case AT_default_value_addr: return "AT_default_value_addr"; 884: case AT_default_value_data2: return "AT_default_value_data2"; 885: case AT_default_value_data4: return "AT_default_value_data4"; 886: case AT_default_value_data8: return "AT_default_value_data8"; 887: case AT_default_value_string: return "AT_default_value_string"; 888: case AT_friends: return "AT_friends"; 889: case AT_inline: return "AT_inline"; 890: case AT_is_optional: return "AT_is_optional"; 891: case AT_lower_bound_ref: return "AT_lower_bound_ref"; 892: case AT_lower_bound_data2: return "AT_lower_bound_data2"; 893: case AT_lower_bound_data4: return "AT_lower_bound_data4"; 894: case AT_lower_bound_data8: return "AT_lower_bound_data8"; 895: case AT_private: return "AT_private"; 896: case AT_producer: return "AT_producer"; 897: case AT_program: return "AT_program"; 898: case AT_protected: return "AT_protected"; 899: case AT_prototyped: return "AT_prototyped"; 900: case AT_public: return "AT_public"; 901: case AT_pure_virtual: return "AT_pure_virtual"; 902: case AT_return_addr: return "AT_return_addr"; 1.1.1.4 root 903: case AT_abstract_origin: return "AT_abstract_origin"; 1.1.1.3 root 904: case AT_start_scope: return "AT_start_scope"; 905: case AT_stride_size: return "AT_stride_size"; 906: case AT_upper_bound_ref: return "AT_upper_bound_ref"; 907: case AT_upper_bound_data2: return "AT_upper_bound_data2"; 908: case AT_upper_bound_data4: return "AT_upper_bound_data4"; 909: case AT_upper_bound_data8: return "AT_upper_bound_data8"; 910: case AT_virtual: return "AT_virtual"; 911: 912: /* GNU extensions */ 913: 914: case AT_sf_names: return "AT_sf_names"; 915: case AT_src_info: return "AT_src_info"; 916: case AT_mac_info: return "AT_mac_info"; 917: case AT_src_coords: return "AT_src_coords"; 1.1.1.4 root 918: case AT_body_begin: return "AT_body_begin"; 919: case AT_body_end: return "AT_body_end"; 1.1.1.3 root 920: 1.1.1.4 root 921: default: return "AT_<unknown>"; 1.1 root 922: } 923: } 924: 925: static char * 1.1.1.3 root 926: dwarf_stack_op_name (op) 1.1 root 927: register unsigned op; 928: { 929: switch (op) 930: { 931: case OP_REG: return "OP_REG"; 932: case OP_BASEREG: return "OP_BASEREG"; 933: case OP_ADDR: return "OP_ADDR"; 934: case OP_CONST: return "OP_CONST"; 935: case OP_DEREF2: return "OP_DEREF2"; 936: case OP_DEREF4: return "OP_DEREF4"; 937: case OP_ADD: return "OP_ADD"; 1.1.1.4 root 938: default: return "OP_<unknown>"; 1.1 root 939: } 940: } 941: 942: static char * 1.1.1.3 root 943: dwarf_typemod_name (mod) 1.1 root 944: register unsigned mod; 945: { 946: switch (mod) 947: { 948: case MOD_pointer_to: return "MOD_pointer_to"; 949: case MOD_reference_to: return "MOD_reference_to"; 950: case MOD_const: return "MOD_const"; 951: case MOD_volatile: return "MOD_volatile"; 1.1.1.4 root 952: default: return "MOD_<unknown>"; 1.1 root 953: } 954: } 955: 956: static char * 1.1.1.3 root 957: dwarf_fmt_byte_name (fmt) 1.1 root 958: register unsigned fmt; 959: { 960: switch (fmt) 961: { 962: case FMT_FT_C_C: return "FMT_FT_C_C"; 963: case FMT_FT_C_X: return "FMT_FT_C_X"; 964: case FMT_FT_X_C: return "FMT_FT_X_C"; 965: case FMT_FT_X_X: return "FMT_FT_X_X"; 966: case FMT_UT_C_C: return "FMT_UT_C_C"; 967: case FMT_UT_C_X: return "FMT_UT_C_X"; 968: case FMT_UT_X_C: return "FMT_UT_X_C"; 969: case FMT_UT_X_X: return "FMT_UT_X_X"; 970: case FMT_ET: return "FMT_ET"; 1.1.1.4 root 971: default: return "FMT_<unknown>"; 1.1 root 972: } 973: } 974: static char * 1.1.1.3 root 975: dwarf_fund_type_name (ft) 1.1 root 976: register unsigned ft; 977: { 978: switch (ft) 979: { 980: case FT_char: return "FT_char"; 981: case FT_signed_char: return "FT_signed_char"; 982: case FT_unsigned_char: return "FT_unsigned_char"; 983: case FT_short: return "FT_short"; 984: case FT_signed_short: return "FT_signed_short"; 985: case FT_unsigned_short: return "FT_unsigned_short"; 986: case FT_integer: return "FT_integer"; 987: case FT_signed_integer: return "FT_signed_integer"; 988: case FT_unsigned_integer: return "FT_unsigned_integer"; 989: case FT_long: return "FT_long"; 990: case FT_signed_long: return "FT_signed_long"; 991: case FT_unsigned_long: return "FT_unsigned_long"; 992: case FT_pointer: return "FT_pointer"; 993: case FT_float: return "FT_float"; 994: case FT_dbl_prec_float: return "FT_dbl_prec_float"; 995: case FT_ext_prec_float: return "FT_ext_prec_float"; 996: case FT_complex: return "FT_complex"; 997: case FT_dbl_prec_complex: return "FT_dbl_prec_complex"; 998: case FT_void: return "FT_void"; 999: case FT_boolean: return "FT_boolean"; 1.1.1.3 root 1000: case FT_ext_prec_complex: return "FT_ext_prec_complex"; 1001: case FT_label: return "FT_label"; 1002: 1003: /* GNU extensions. */ 1004: 1.1 root 1005: case FT_long_long: return "FT_long_long"; 1006: case FT_signed_long_long: return "FT_signed_long_long"; 1007: case FT_unsigned_long_long: return "FT_unsigned_long_long"; 1.1.1.3 root 1008: 1009: case FT_int8: return "FT_int8"; 1010: case FT_signed_int8: return "FT_signed_int8"; 1011: case FT_unsigned_int8: return "FT_unsigned_int8"; 1012: case FT_int16: return "FT_int16"; 1013: case FT_signed_int16: return "FT_signed_int16"; 1014: case FT_unsigned_int16: return "FT_unsigned_int16"; 1015: case FT_int32: return "FT_int32"; 1016: case FT_signed_int32: return "FT_signed_int32"; 1017: case FT_unsigned_int32: return "FT_unsigned_int32"; 1018: case FT_int64: return "FT_int64"; 1019: case FT_signed_int64: return "FT_signed_int64"; 1020: case FT_unsigned_int64: return "FT_signed_int64"; 1021: 1022: case FT_real32: return "FT_real32"; 1023: case FT_real64: return "FT_real64"; 1024: case FT_real96: return "FT_real96"; 1025: case FT_real128: return "FT_real128"; 1026: 1.1.1.4 root 1027: default: return "FT_<unknown>"; 1.1 root 1028: } 1029: } 1.1.1.4 root 1030: 1031: /* Determine the "ultimate origin" of a decl. The decl may be an 1032: inlined instance of an inlined instance of a decl which is local 1033: to an inline function, so we have to trace all of the way back 1034: through the origin chain to find out what sort of node actually 1035: served as the original seed for the given block. */ 1036: 1037: static tree 1038: decl_ultimate_origin (decl) 1039: register tree decl; 1040: { 1041: register tree immediate_origin = DECL_ABSTRACT_ORIGIN (decl); 1042: 1043: if (immediate_origin == NULL) 1044: return NULL; 1045: else 1046: { 1047: register tree ret_val; 1048: register tree lookahead = immediate_origin; 1049: 1050: do 1051: { 1052: ret_val = lookahead; 1053: lookahead = DECL_ABSTRACT_ORIGIN (ret_val); 1054: } 1055: while (lookahead != NULL && lookahead != ret_val); 1056: return ret_val; 1057: } 1058: } 1059: 1060: /* Determine the "ultimate origin" of a block. The block may be an 1061: inlined instance of an inlined instance of a block which is local 1062: to an inline function, so we have to trace all of the way back 1063: through the origin chain to find out what sort of node actually 1064: served as the original seed for the given block. */ 1065: 1066: static tree 1067: block_ultimate_origin (block) 1068: register tree block; 1069: { 1070: register tree immediate_origin = BLOCK_ABSTRACT_ORIGIN (block); 1071: 1072: if (immediate_origin == NULL) 1073: return NULL; 1074: else 1075: { 1076: register tree ret_val; 1077: register tree lookahead = immediate_origin; 1078: 1079: do 1080: { 1081: ret_val = lookahead; 1082: lookahead = (TREE_CODE (ret_val) == BLOCK) 1083: ? BLOCK_ABSTRACT_ORIGIN (ret_val) 1084: : NULL; 1085: } 1086: while (lookahead != NULL && lookahead != ret_val); 1087: return ret_val; 1088: } 1089: } 1090: 1091: static void 1092: output_unsigned_leb128 (value) 1093: register unsigned long value; 1094: { 1095: register unsigned long orig_value = value; 1096: 1097: do 1098: { 1099: register unsigned byte = (value & 0x7f); 1100: 1101: value >>= 7; 1102: if (value != 0) /* more bytes to follow */ 1103: byte |= 0x80; 1104: fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) byte); 1105: if (flag_verbose_asm && value == 0) 1106: fprintf (asm_out_file, "\t%s ULEB128 number - value = %u", 1107: ASM_COMMENT_START, orig_value); 1108: fputc ('\n', asm_out_file); 1109: } 1110: while (value != 0); 1111: } 1112: 1113: static void 1114: output_signed_leb128 (value) 1115: register long value; 1116: { 1117: register long orig_value = value; 1118: register int negative = (value < 0); 1119: register int more; 1120: 1121: do 1122: { 1123: register unsigned byte = (value & 0x7f); 1124: 1125: value >>= 7; 1126: if (negative) 1127: value |= 0xfe000000; /* manually sign extend */ 1128: if (((value == 0) && ((byte & 0x40) == 0)) 1129: || ((value == -1) && ((byte & 0x40) == 1))) 1130: more = 0; 1131: else 1132: { 1133: byte |= 0x80; 1134: more = 1; 1135: } 1136: fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) byte); 1137: if (flag_verbose_asm && more == 0) 1138: fprintf (asm_out_file, "\t%s SLEB128 number - value = %d", 1139: ASM_COMMENT_START, orig_value); 1140: fputc ('\n', asm_out_file); 1141: } 1142: while (more); 1143: } 1.1 root 1144: 1145: /**************** utility functions for attribute functions ******************/ 1146: 1.1.1.4 root 1147: /* Given a pointer to a BLOCK node return non-zero if (and only if) the 1148: node in question represents the outermost pair of curly braces (i.e. 1149: the "body block") of a function or method. 1150: 1151: For any BLOCK node representing a "body block" of a function or method, 1152: the BLOCK_SUPERCONTEXT of the node will point to another BLOCK node 1153: which represents the outermost (function) scope for the function or 1154: method (i.e. the one which includes the formal parameters). The 1155: BLOCK_SUPERCONTEXT of *that* node in turn will point to the relevant 1156: FUNCTION_DECL node. 1157: */ 1158: 1159: inline int 1160: is_body_block (stmt) 1161: register tree stmt; 1162: { 1163: if (TREE_CODE (stmt) == BLOCK) 1164: { 1165: register tree parent = BLOCK_SUPERCONTEXT (stmt); 1166: 1167: if (TREE_CODE (parent) == BLOCK) 1168: { 1169: register tree grandparent = BLOCK_SUPERCONTEXT (parent); 1170: 1171: if (TREE_CODE (grandparent) == FUNCTION_DECL) 1172: return 1; 1173: } 1174: } 1175: return 0; 1176: } 1177: 1.1 root 1178: /* Given a pointer to a tree node for some type, return a Dwarf fundamental 1179: type code for the given type. 1180: 1181: This routine must only be called for GCC type nodes that correspond to 1182: Dwarf fundamental types. 1183: 1184: The current Dwarf draft specification calls for Dwarf fundamental types 1185: to accurately reflect the fact that a given type was either a "plain" 1.1.1.4 root 1186: integral type or an explicitly "signed" integral type. Unfortunately, 1.1 root 1187: we can't always do this, because GCC may already have thrown away the 1188: information about the precise way in which the type was originally 1189: specified, as in: 1190: 1.1.1.4 root 1191: typedef signed int my_type; 1.1 root 1192: 1.1.1.4 root 1193: struct s { my_type f; }; 1.1 root 1194: 1195: Since we may be stuck here without enought information to do exactly 1196: what is called for in the Dwarf draft specification, we do the best 1197: that we can under the circumstances and always use the "plain" integral 1198: fundamental type codes for int, short, and long types. That's probably 1199: good enough. The additional accuracy called for in the current DWARF 1200: draft specification is probably never even useful in practice. */ 1201: 1202: static int 1203: fundamental_type_code (type) 1204: register tree type; 1205: { 1206: if (TREE_CODE (type) == ERROR_MARK) 1207: return 0; 1208: 1209: switch (TREE_CODE (type)) 1210: { 1211: case ERROR_MARK: 1212: return FT_void; 1213: 1214: case VOID_TYPE: 1215: return FT_void; 1216: 1217: case INTEGER_TYPE: 1218: /* Carefully distinguish all the standard types of C, 1219: without messing up if the language is not C. 1220: Note that we check only for the names that contain spaces; 1221: other names might occur by coincidence in other languages. */ 1222: if (TYPE_NAME (type) != 0 1223: && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL 1224: && DECL_NAME (TYPE_NAME (type)) != 0 1225: && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE) 1226: { 1227: char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))); 1228: 1229: if (!strcmp (name, "unsigned char")) 1230: return FT_unsigned_char; 1231: if (!strcmp (name, "signed char")) 1232: return FT_signed_char; 1233: if (!strcmp (name, "unsigned int")) 1234: return FT_unsigned_integer; 1235: if (!strcmp (name, "short int")) 1236: return FT_short; 1237: if (!strcmp (name, "short unsigned int")) 1238: return FT_unsigned_short; 1239: if (!strcmp (name, "long int")) 1240: return FT_long; 1241: if (!strcmp (name, "long unsigned int")) 1242: return FT_unsigned_long; 1243: if (!strcmp (name, "long long int")) 1244: return FT_long_long; /* Not grok'ed by svr4 SDB */ 1245: if (!strcmp (name, "long long unsigned int")) 1246: return FT_unsigned_long_long; /* Not grok'ed by svr4 SDB */ 1247: } 1248: 1249: /* Most integer types will be sorted out above, however, for the 1250: sake of special `array index' integer types, the following code 1251: is also provided. */ 1252: 1253: if (TYPE_PRECISION (type) == INT_TYPE_SIZE) 1254: return (TREE_UNSIGNED (type) ? FT_unsigned_integer : FT_integer); 1255: 1256: if (TYPE_PRECISION (type) == LONG_TYPE_SIZE) 1257: return (TREE_UNSIGNED (type) ? FT_unsigned_long : FT_long); 1258: 1259: if (TYPE_PRECISION (type) == LONG_LONG_TYPE_SIZE) 1260: return (TREE_UNSIGNED (type) ? FT_unsigned_long_long : FT_long_long); 1261: 1262: if (TYPE_PRECISION (type) == SHORT_TYPE_SIZE) 1263: return (TREE_UNSIGNED (type) ? FT_unsigned_short : FT_short); 1264: 1265: if (TYPE_PRECISION (type) == CHAR_TYPE_SIZE) 1266: return (TREE_UNSIGNED (type) ? FT_unsigned_char : FT_char); 1267: 1268: abort (); 1269: 1270: case REAL_TYPE: 1271: /* Carefully distinguish all the standard types of C, 1272: without messing up if the language is not C. */ 1273: if (TYPE_NAME (type) != 0 1274: && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL 1275: && DECL_NAME (TYPE_NAME (type)) != 0 1276: && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE) 1277: { 1278: char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))); 1279: 1280: /* Note that here we can run afowl of a serious bug in "classic" 1281: svr4 SDB debuggers. They don't seem to understand the 1282: FT_ext_prec_float type (even though they should). */ 1283: 1284: if (!strcmp (name, "long double")) 1285: return FT_ext_prec_float; 1286: } 1287: 1288: if (TYPE_PRECISION (type) == DOUBLE_TYPE_SIZE) 1289: return FT_dbl_prec_float; 1290: if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE) 1291: return FT_float; 1292: 1293: /* Note that here we can run afowl of a serious bug in "classic" 1294: svr4 SDB debuggers. They don't seem to understand the 1295: FT_ext_prec_float type (even though they should). */ 1296: 1297: if (TYPE_PRECISION (type) == LONG_DOUBLE_TYPE_SIZE) 1298: return FT_ext_prec_float; 1299: abort (); 1300: 1301: case COMPLEX_TYPE: 1302: return FT_complex; /* GNU FORTRAN COMPLEX type. */ 1303: 1304: case CHAR_TYPE: 1305: return FT_char; /* GNU Pascal CHAR type. Not used in C. */ 1306: 1307: case BOOLEAN_TYPE: 1308: return FT_boolean; /* GNU FORTRAN BOOLEAN type. */ 1309: 1310: default: 1311: abort (); /* No other TREE_CODEs are Dwarf fundamental types. */ 1312: } 1313: return 0; 1314: } 1315: 1316: /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to 1317: the Dwarf "root" type for the given input type. The Dwarf "root" type 1318: of a given type is generally the same as the given type, except that if 1319: the given type is a pointer or reference type, then the root type of 1320: the given type is the root type of the "basis" type for the pointer or 1321: reference type. (This definition of the "root" type is recursive.) 1322: Also, the root type of a `const' qualified type or a `volatile' 1323: qualified type is the root type of the given type without the 1324: qualifiers. */ 1325: 1326: static tree 1327: root_type (type) 1328: register tree type; 1329: { 1330: if (TREE_CODE (type) == ERROR_MARK) 1331: return error_mark_node; 1332: 1333: switch (TREE_CODE (type)) 1334: { 1335: case ERROR_MARK: 1336: return error_mark_node; 1337: 1338: case POINTER_TYPE: 1339: case REFERENCE_TYPE: 1.1.1.5 ! root 1340: return type_main_variant (root_type (TREE_TYPE (type))); 1.1 root 1341: 1342: default: 1.1.1.5 ! root 1343: return type_main_variant (type); 1.1 root 1344: } 1345: } 1346: 1347: /* Given a pointer to an arbitrary ..._TYPE tree node, write out a sequence 1348: of zero or more Dwarf "type-modifier" bytes applicable to the type. */ 1349: 1350: static void 1351: write_modifier_bytes (type, decl_const, decl_volatile) 1352: register tree type; 1353: register int decl_const; 1354: register int decl_volatile; 1355: { 1356: if (TREE_CODE (type) == ERROR_MARK) 1357: return; 1358: 1359: if (TYPE_READONLY (type) || decl_const) 1360: ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_const); 1361: if (TYPE_VOLATILE (type) || decl_volatile) 1362: ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_volatile); 1363: switch (TREE_CODE (type)) 1364: { 1365: case POINTER_TYPE: 1366: ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_pointer_to); 1367: write_modifier_bytes (TREE_TYPE (type), 0, 0); 1368: return; 1369: 1370: case REFERENCE_TYPE: 1371: ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_reference_to); 1372: write_modifier_bytes (TREE_TYPE (type), 0, 0); 1373: return; 1374: 1375: case ERROR_MARK: 1376: default: 1377: return; 1378: } 1379: } 1380: 1381: /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the 1382: given input type is a Dwarf "fundamental" type. Otherwise return zero. */ 1383: 1384: inline int 1385: type_is_fundamental (type) 1386: register tree type; 1387: { 1388: switch (TREE_CODE (type)) 1389: { 1390: case ERROR_MARK: 1391: case VOID_TYPE: 1392: case INTEGER_TYPE: 1393: case REAL_TYPE: 1394: case COMPLEX_TYPE: 1395: case BOOLEAN_TYPE: 1396: case CHAR_TYPE: 1397: return 1; 1398: 1399: case SET_TYPE: 1400: case ARRAY_TYPE: 1401: case RECORD_TYPE: 1402: case UNION_TYPE: 1.1.1.5 ! root 1403: case QUAL_UNION_TYPE: 1.1 root 1404: case ENUMERAL_TYPE: 1405: case FUNCTION_TYPE: 1406: case METHOD_TYPE: 1407: case POINTER_TYPE: 1408: case REFERENCE_TYPE: 1409: case STRING_TYPE: 1410: case FILE_TYPE: 1411: case OFFSET_TYPE: 1412: case LANG_TYPE: 1413: return 0; 1414: 1415: default: 1416: abort (); 1417: } 1418: return 0; 1419: } 1420: 1.1.1.4 root 1421: /* Given a pointer to some ..._DECL tree node, generate an assembly language 1422: equate directive which will associate a symbolic name with the current DIE. 1423: 1424: The name used is an artificial label generated from the DECL_UID number 1425: associated with the given decl node. The name it gets equated to is the 1426: symbolic label that we (previously) output at the start of the DIE that 1427: we are currently generating. 1428: 1429: Calling this function while generating some "decl related" form of DIE 1430: makes it possible to later refer to the DIE which represents the given 1431: decl simply by re-generating the symbolic name from the ..._DECL node's 1432: UID number. */ 1433: 1434: static void 1435: equate_decl_number_to_die_number (decl) 1436: register tree decl; 1437: { 1438: /* In the case where we are generating a DIE for some ..._DECL node 1439: which represents either some inline function declaration or some 1440: entity declared within an inline function declaration/definition, 1441: setup a symbolic name for the current DIE so that we have a name 1442: for this DIE that we can easily refer to later on within 1443: AT_abstract_origin attributes. */ 1444: 1445: char decl_label[MAX_ARTIFICIAL_LABEL_BYTES]; 1446: char die_label[MAX_ARTIFICIAL_LABEL_BYTES]; 1447: 1448: sprintf (decl_label, DECL_NAME_FMT, DECL_UID (decl)); 1449: sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum); 1450: ASM_OUTPUT_DEF (asm_out_file, decl_label, die_label); 1451: } 1452: 1.1 root 1453: /* Given a pointer to some ..._TYPE tree node, generate an assembly language 1.1.1.4 root 1454: equate directive which will associate a symbolic name with the current DIE. 1.1 root 1455: 1456: The name used is an artificial label generated from the TYPE_UID number 1457: associated with the given type node. The name it gets equated to is the 1458: symbolic label that we (previously) output at the start of the DIE that 1459: we are currently generating. 1460: 1461: Calling this function while generating some "type related" form of DIE 1462: makes it easy to later refer to the DIE which represents the given type 1463: simply by re-generating the alternative name from the ..._TYPE node's 1464: UID number. */ 1465: 1466: inline void 1467: equate_type_number_to_die_number (type) 1468: register tree type; 1469: { 1470: char type_label[MAX_ARTIFICIAL_LABEL_BYTES]; 1471: char die_label[MAX_ARTIFICIAL_LABEL_BYTES]; 1472: 1473: /* We are generating a DIE to represent the main variant of this type 1474: (i.e the type without any const or volatile qualifiers) so in order 1475: to get the equate to come out right, we need to get the main variant 1476: itself here. */ 1477: 1.1.1.5 ! root 1478: type = type_main_variant (type); 1.1 root 1479: 1480: sprintf (type_label, TYPE_NAME_FMT, TYPE_UID (type)); 1481: sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum); 1482: ASM_OUTPUT_DEF (asm_out_file, type_label, die_label); 1483: } 1484: 1.1.1.4 root 1485: static void 1486: output_reg_number (rtl) 1487: register rtx rtl; 1488: { 1489: register unsigned regno = REGNO (rtl); 1490: 1491: if (regno >= FIRST_PSEUDO_REGISTER) 1492: { 1493: warning_with_decl (dwarf_last_decl, "internal regno botch: regno = %d\n", 1494: regno); 1495: regno = 0; 1496: } 1497: fprintf (asm_out_file, "\t%s\t0x%x", 1498: UNALIGNED_INT_ASM_OP, DBX_REGISTER_NUMBER (regno)); 1499: if (flag_verbose_asm) 1500: { 1501: fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START); 1502: PRINT_REG (rtl, 0, asm_out_file); 1503: } 1504: fputc ('\n', asm_out_file); 1505: } 1506: 1.1 root 1507: /* The following routine is a nice and simple transducer. It converts the 1508: RTL for a variable or parameter (resident in memory) into an equivalent 1509: Dwarf representation of a mechanism for getting the address of that same 1510: variable onto the top of a hypothetical "address evaluation" stack. 1511: 1512: When creating memory location descriptors, we are effectively trans- 1513: forming the RTL for a memory-resident object into its Dwarf postfix 1514: expression equivalent. This routine just recursively descends an 1515: RTL tree, turning it into Dwarf postfix code as it goes. */ 1516: 1517: static void 1518: output_mem_loc_descriptor (rtl) 1519: register rtx rtl; 1520: { 1521: /* Note that for a dynamically sized array, the location we will 1522: generate a description of here will be the lowest numbered location 1523: which is actually within the array. That's *not* necessarily the 1524: same as the zeroth element of the array. */ 1525: 1526: switch (GET_CODE (rtl)) 1527: { 1528: case SUBREG: 1529: 1530: /* The case of a subreg may arise when we have a local (register) 1531: variable or a formal (register) parameter which doesn't quite 1532: fill up an entire register. For now, just assume that it is 1533: legitimate to make the Dwarf info refer to the whole register 1534: which contains the given subreg. */ 1535: 1536: rtl = XEXP (rtl, 0); 1537: /* Drop thru. */ 1538: 1539: case REG: 1540: 1541: /* Whenever a register number forms a part of the description of 1542: the method for calculating the (dynamic) address of a memory 1.1.1.4 root 1543: resident object, DWARF rules require the register number to 1.1 root 1544: be referred to as a "base register". This distinction is not 1545: based in any way upon what category of register the hardware 1546: believes the given register belongs to. This is strictly 1.1.1.4 root 1547: DWARF terminology we're dealing with here. 1548: 1549: Note that in cases where the location of a memory-resident data 1550: object could be expressed as: 1551: 1552: OP_ADD (OP_BASEREG (basereg), OP_CONST (0)) 1553: 1554: the actual DWARF location descriptor that we generate may just 1555: be OP_BASEREG (basereg). This may look deceptively like the 1556: object in question was allocated to a register (rather than 1557: in memory) so DWARF consumers need to be aware of the subtle 1558: distinction between OP_REG and OP_BASEREG. */ 1.1 root 1559: 1560: ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_BASEREG); 1.1.1.4 root 1561: output_reg_number (rtl); 1.1 root 1562: break; 1563: 1564: case MEM: 1565: output_mem_loc_descriptor (XEXP (rtl, 0)); 1566: ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_DEREF4); 1567: break; 1568: 1569: case CONST: 1570: case SYMBOL_REF: 1571: ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADDR); 1572: ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl); 1573: break; 1574: 1575: case PLUS: 1576: output_mem_loc_descriptor (XEXP (rtl, 0)); 1577: output_mem_loc_descriptor (XEXP (rtl, 1)); 1578: ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD); 1579: break; 1580: 1581: case CONST_INT: 1582: ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST); 1583: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, INTVAL (rtl)); 1584: break; 1585: 1586: default: 1587: abort (); 1588: } 1589: } 1590: 1591: /* Output a proper Dwarf location descriptor for a variable or parameter 1592: which is either allocated in a register or in a memory location. For 1593: a register, we just generate an OP_REG and the register number. For a 1594: memory location we provide a Dwarf postfix expression describing how to 1595: generate the (dynamic) address of the object onto the address stack. */ 1596: 1597: static void 1598: output_loc_descriptor (rtl) 1599: register rtx rtl; 1600: { 1601: switch (GET_CODE (rtl)) 1602: { 1603: case SUBREG: 1604: 1605: /* The case of a subreg may arise when we have a local (register) 1606: variable or a formal (register) parameter which doesn't quite 1607: fill up an entire register. For now, just assume that it is 1608: legitimate to make the Dwarf info refer to the whole register 1609: which contains the given subreg. */ 1610: 1611: rtl = XEXP (rtl, 0); 1612: /* Drop thru. */ 1613: 1614: case REG: 1615: ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_REG); 1.1.1.4 root 1616: output_reg_number (rtl); 1.1 root 1617: break; 1618: 1619: case MEM: 1620: output_mem_loc_descriptor (XEXP (rtl, 0)); 1621: break; 1622: 1623: default: 1624: abort (); /* Should never happen */ 1625: } 1626: } 1627: 1628: /* Given a tree node describing an array bound (either lower or upper) 1629: output a representation for that bound. */ 1630: 1631: static void 1632: output_bound_representation (bound, dim_num, u_or_l) 1633: register tree bound; 1634: register unsigned dim_num; /* For multi-dimensional arrays. */ 1635: register char u_or_l; /* Designates upper or lower bound. */ 1636: { 1637: switch (TREE_CODE (bound)) 1638: { 1639: 1640: case ERROR_MARK: 1641: return; 1642: 1643: /* All fixed-bounds are represented by INTEGER_CST nodes. */ 1644: 1645: case INTEGER_CST: 1646: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 1647: (unsigned) TREE_INT_CST_LOW (bound)); 1648: break; 1649: 1650: /* Dynamic bounds may be represented by NOP_EXPR nodes containing 1651: SAVE_EXPR nodes. */ 1652: 1653: case NOP_EXPR: 1654: bound = TREE_OPERAND (bound, 0); 1655: /* ... fall thru... */ 1656: 1657: case SAVE_EXPR: 1658: { 1659: char begin_label[MAX_ARTIFICIAL_LABEL_BYTES]; 1660: char end_label[MAX_ARTIFICIAL_LABEL_BYTES]; 1661: 1662: sprintf (begin_label, BOUND_BEGIN_LABEL_FMT, 1663: current_dienum, dim_num, u_or_l); 1664: 1665: sprintf (end_label, BOUND_END_LABEL_FMT, 1666: current_dienum, dim_num, u_or_l); 1667: 1668: ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label); 1669: ASM_OUTPUT_LABEL (asm_out_file, begin_label); 1670: 1671: /* If we are working on a bound for a dynamic dimension in C, 1672: the dynamic dimension in question had better have a static 1673: (zero) lower bound and a dynamic *upper* bound. */ 1674: 1675: if (u_or_l != 'u') 1676: abort (); 1677: 1678: /* If optimization is turned on, the SAVE_EXPRs that describe 1679: how to access the upper bound values are essentially bogus. 1680: They only describe (at best) how to get at these values at 1681: the points in the generated code right after they have just 1682: been computed. Worse yet, in the typical case, the upper 1683: bound values will not even *be* computed in the optimized 1684: code, so these SAVE_EXPRs are entirely bogus. 1685: 1686: In order to compensate for this fact, we check here to see 1687: if optimization is enabled, and if so, we effectively create 1688: an empty location description for the (unknown and unknowable) 1689: upper bound. 1690: 1691: This should not cause too much trouble for existing (stupid?) 1692: debuggers because they have to deal with empty upper bounds 1693: location descriptions anyway in order to be able to deal with 1694: incomplete array types. 1695: 1696: Of course an intelligent debugger (GDB?) should be able to 1697: comprehend that a missing upper bound specification in a 1698: array type used for a storage class `auto' local array variable 1699: indicates that the upper bound is both unknown (at compile- 1700: time) and unknowable (at run-time) due to optimization. 1701: */ 1702: 1703: if (! optimize) 1704: output_loc_descriptor 1.1.1.4 root 1705: (eliminate_regs (SAVE_EXPR_RTL (bound), 0, NULL_RTX)); 1.1 root 1706: 1707: ASM_OUTPUT_LABEL (asm_out_file, end_label); 1708: } 1709: break; 1710: 1711: default: 1712: abort (); 1713: } 1714: } 1715: 1716: /* Recursive function to output a sequence of value/name pairs for 1717: enumeration constants in reversed order. This is called from 1718: enumeration_type_die. */ 1719: 1720: static void 1721: output_enumeral_list (link) 1722: register tree link; 1723: { 1724: if (link) 1725: { 1726: output_enumeral_list (TREE_CHAIN (link)); 1727: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 1728: (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link))); 1729: ASM_OUTPUT_DWARF_STRING (asm_out_file, 1730: IDENTIFIER_POINTER (TREE_PURPOSE (link))); 1731: } 1732: } 1733: 1.1.1.4 root 1734: /* Given an unsigned value, round it up to the lowest multiple of `boundary' 1735: which is not less than the value itself. */ 1736: 1737: inline unsigned 1738: ceiling (value, boundary) 1739: register unsigned value; 1740: register unsigned boundary; 1741: { 1742: return (((value + boundary - 1) / boundary) * boundary); 1743: } 1744: 1745: /* Given a pointer to what is assumed to be a FIELD_DECL node, return a 1746: pointer to the declared type for the relevant field variable, or return 1747: `integer_type_node' if the given node turns out to be an ERROR_MARK node. */ 1748: 1749: inline tree 1750: field_type (decl) 1751: register tree decl; 1752: { 1753: register tree type; 1754: 1755: if (TREE_CODE (decl) == ERROR_MARK) 1756: return integer_type_node; 1757: 1758: type = DECL_BIT_FIELD_TYPE (decl); 1759: if (type == NULL) 1760: type = TREE_TYPE (decl); 1761: return type; 1762: } 1763: 1764: /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE 1765: node, return the alignment in bits for the type, or else return 1766: BITS_PER_WORD if the node actually turns out to be an ERROR_MARK node. */ 1767: 1768: inline unsigned 1769: simple_type_align_in_bits (type) 1770: register tree type; 1771: { 1772: return (TREE_CODE (type) != ERROR_MARK) ? TYPE_ALIGN (type) : BITS_PER_WORD; 1773: } 1774: 1775: /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE 1776: node, return the size in bits for the type if it is a constant, or 1777: else return the alignment for the type if the type's size is not 1778: constant, or else return BITS_PER_WORD if the type actually turns out 1779: to be an ERROR_MARK node. */ 1780: 1781: inline unsigned 1782: simple_type_size_in_bits (type) 1783: register tree type; 1784: { 1785: if (TREE_CODE (type) == ERROR_MARK) 1786: return BITS_PER_WORD; 1787: else 1788: { 1789: register tree type_size_tree = TYPE_SIZE (type); 1790: 1791: if (TREE_CODE (type_size_tree) != INTEGER_CST) 1792: return TYPE_ALIGN (type); 1793: 1794: return (unsigned) TREE_INT_CST_LOW (type_size_tree); 1795: } 1796: } 1797: 1798: /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and 1799: return the byte offset of the lowest addressed byte of the "containing 1800: object" for the given FIELD_DECL, or return 0 if we are unable to deter- 1801: mine what that offset is, either because the argument turns out to be a 1802: pointer to an ERROR_MARK node, or because the offset is actually variable. 1803: (We can't handle the latter case just yet.) */ 1804: 1805: static unsigned 1806: field_byte_offset (decl) 1807: register tree decl; 1808: { 1809: register unsigned type_align_in_bytes; 1810: register unsigned type_align_in_bits; 1811: register unsigned type_size_in_bits; 1812: register unsigned object_offset_in_align_units; 1813: register unsigned object_offset_in_bits; 1814: register unsigned object_offset_in_bytes; 1815: register tree type; 1816: register tree bitpos_tree; 1817: register tree field_size_tree; 1818: register unsigned bitpos_int; 1819: register unsigned deepest_bitpos; 1820: register unsigned field_size_in_bits; 1821: 1822: if (TREE_CODE (decl) == ERROR_MARK) 1823: return 0; 1824: 1825: if (TREE_CODE (decl) != FIELD_DECL) 1826: abort (); 1827: 1828: type = field_type (decl); 1829: 1830: bitpos_tree = DECL_FIELD_BITPOS (decl); 1831: field_size_tree = DECL_SIZE (decl); 1832: 1833: /* We cannot yet cope with fields whose positions or sizes are variable, 1834: so for now, when we see such things, we simply return 0. Someday, 1835: we may be able to handle such cases, but it will be damn difficult. */ 1836: 1837: if (TREE_CODE (bitpos_tree) != INTEGER_CST) 1838: return 0; 1839: bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree); 1840: 1841: if (TREE_CODE (field_size_tree) != INTEGER_CST) 1842: return 0; 1843: field_size_in_bits = (unsigned) TREE_INT_CST_LOW (field_size_tree); 1844: 1845: type_size_in_bits = simple_type_size_in_bits (type); 1846: 1847: type_align_in_bits = simple_type_align_in_bits (type); 1848: type_align_in_bytes = type_align_in_bits / BITS_PER_UNIT; 1849: 1850: /* Note that the GCC front-end doesn't make any attempt to keep track 1851: of the starting bit offset (relative to the start of the containing 1852: structure type) of the hypothetical "containing object" for a bit- 1853: field. Thus, when computing the byte offset value for the start of 1854: the "containing object" of a bit-field, we must deduce this infor- 1855: mation on our own. 1856: 1857: This can be rather tricky to do in some cases. For example, handling 1858: the following structure type definition when compiling for an i386/i486 1859: target (which only aligns long long's to 32-bit boundaries) can be very 1860: tricky: 1861: 1862: struct S { 1863: int field1; 1864: long long field2:31; 1865: }; 1866: 1867: Fortunately, there is a simple rule-of-thumb which can be used in such 1868: cases. When compiling for an i386/i486, GCC will allocate 8 bytes for 1869: the structure shown above. It decides to do this based upon one simple 1870: rule for bit-field allocation. Quite simply, GCC allocates each "con- 1871: taining object" for each bit-field at the first (i.e. lowest addressed) 1872: legitimate alignment boundary (based upon the required minimum alignment 1873: for the declared type of the field) which it can possibly use, subject 1874: to the condition that there is still enough available space remaining 1875: in the containing object (when allocated at the selected point) to 1.1.1.5 ! root 1876: fully accommodate all of the bits of the bit-field itself. 1.1.1.4 root 1877: 1878: This simple rule makes it obvious why GCC allocates 8 bytes for each 1879: object of the structure type shown above. When looking for a place to 1880: allocate the "containing object" for `field2', the compiler simply tries 1881: to allocate a 64-bit "containing object" at each successive 32-bit 1882: boundary (starting at zero) until it finds a place to allocate that 64- 1883: bit field such that at least 31 contiguous (and previously unallocated) 1884: bits remain within that selected 64 bit field. (As it turns out, for 1885: the example above, the compiler finds that it is OK to allocate the 1886: "containing object" 64-bit field at bit-offset zero within the 1887: structure type.) 1888: 1889: Here we attempt to work backwards from the limited set of facts we're 1890: given, and we try to deduce from those facts, where GCC must have 1891: believed that the containing object started (within the structure type). 1892: 1893: The value we deduce is then used (by the callers of this routine) to 1894: generate AT_location and AT_bit_offset attributes for fields (both 1895: bit-fields and, in the case of AT_location, regular fields as well). 1896: */ 1897: 1898: /* Figure out the bit-distance from the start of the structure to the 1899: "deepest" bit of the bit-field. */ 1900: deepest_bitpos = bitpos_int + field_size_in_bits; 1901: 1902: /* This is the tricky part. Use some fancy footwork to deduce where the 1903: lowest addressed bit of the containing object must be. */ 1904: object_offset_in_bits 1905: = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits; 1906: 1907: /* Compute the offset of the containing object in "alignment units". */ 1908: object_offset_in_align_units = object_offset_in_bits / type_align_in_bits; 1909: 1910: /* Compute the offset of the containing object in bytes. */ 1911: object_offset_in_bytes = object_offset_in_align_units * type_align_in_bytes; 1912: 1913: return object_offset_in_bytes; 1914: } 1915: 1.1 root 1916: /****************************** attributes *********************************/ 1917: 1918: /* The following routines are responsible for writing out the various types 1919: of Dwarf attributes (and any following data bytes associated with them). 1920: These routines are listed in order based on the numerical codes of their 1921: associated attributes. */ 1922: 1923: /* Generate an AT_sibling attribute. */ 1924: 1925: inline void 1926: sibling_attribute () 1927: { 1928: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 1929: 1930: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sibling); 1931: sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM); 1932: ASM_OUTPUT_DWARF_REF (asm_out_file, label); 1933: } 1934: 1935: /* Output the form of location attributes suitable for whole variables and 1936: whole parameters. Note that the location attributes for struct fields 1937: are generated by the routine `data_member_location_attribute' below. */ 1938: 1939: static void 1940: location_attribute (rtl) 1941: register rtx rtl; 1942: { 1943: char begin_label[MAX_ARTIFICIAL_LABEL_BYTES]; 1944: char end_label[MAX_ARTIFICIAL_LABEL_BYTES]; 1945: 1946: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location); 1947: sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum); 1948: sprintf (end_label, LOC_END_LABEL_FMT, current_dienum); 1949: ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label); 1950: ASM_OUTPUT_LABEL (asm_out_file, begin_label); 1951: 1952: /* Handle a special case. If we are about to output a location descriptor 1.1.1.2 root 1953: for a variable or parameter which has been optimized out of existence, 1.1 root 1954: don't do that. Instead we output a zero-length location descriptor 1.1.1.4 root 1955: value as part of the location attribute. 1956: 1.1.1.5 ! root 1957: A variable which has been optimized out of existence will have a 1.1.1.4 root 1958: DECL_RTL value which denotes a pseudo-reg. 1959: 1960: Currently, in some rare cases, variables can have DECL_RTL values 1961: which look like (MEM (REG pseudo-reg#)). These cases are due to 1962: bugs elsewhere in the compiler. We treat such cases 1.1.1.5 ! root 1963: as if the variable(s) in question had been optimized out of existence. 1.1.1.4 root 1964: 1965: Note that in all cases where we wish to express the fact that a 1.1.1.5 ! root 1966: variable has been optimized out of existence, we do not simply 1.1.1.4 root 1967: suppress the generation of the entire location attribute because 1968: the absence of a location attribute in certain kinds of DIEs is 1969: used to indicate something else entirely... i.e. that the DIE 1970: represents an object declaration, but not a definition. So sayeth 1971: the PLSIG. 1972: */ 1.1 root 1973: 1.1.1.4 root 1974: if (! is_pseudo_reg (rtl) 1975: && (GET_CODE (rtl) != MEM || ! is_pseudo_reg (XEXP (rtl, 0)))) 1976: output_loc_descriptor (eliminate_regs (rtl, 0, NULL_RTX)); 1.1 root 1977: 1978: ASM_OUTPUT_LABEL (asm_out_file, end_label); 1979: } 1980: 1981: /* Output the specialized form of location attribute used for data members 1.1.1.4 root 1982: of struct and union types. 1.1.1.3 root 1983: 1984: In the special case of a FIELD_DECL node which represents a bit-field, 1985: the "offset" part of this special location descriptor must indicate the 1986: distance in bytes from the lowest-addressed byte of the containing 1987: struct or union type to the lowest-addressed byte of the "containing 1.1.1.4 root 1988: object" for the bit-field. (See the `field_byte_offset' function above.) 1.1.1.3 root 1989: 1990: For any given bit-field, the "containing object" is a hypothetical 1991: object (of some integral or enum type) within which the given bit-field 1992: lives. The type of this hypothetical "containing object" is always the 1.1.1.4 root 1993: same as the declared type of the individual bit-field itself (for GCC 1994: anyway... the DWARF spec doesn't actually mandate this). 1.1.1.3 root 1995: 1996: Note that it is the size (in bytes) of the hypothetical "containing 1997: object" which will be given in the AT_byte_size attribute for this 1.1.1.4 root 1998: bit-field. (See the `byte_size_attribute' function below.) It is 1999: also used when calculating the value of the AT_bit_offset attribute. 2000: (See the `bit_offset_attribute' function below.) 1.1.1.3 root 2001: */ 2002: 1.1 root 2003: static void 2004: data_member_location_attribute (decl) 2005: register tree decl; 2006: { 1.1.1.4 root 2007: register unsigned object_offset_in_bytes = field_byte_offset (decl); 1.1 root 2008: char begin_label[MAX_ARTIFICIAL_LABEL_BYTES]; 2009: char end_label[MAX_ARTIFICIAL_LABEL_BYTES]; 1.1.1.3 root 2010: 1.1 root 2011: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location); 2012: sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum); 2013: sprintf (end_label, LOC_END_LABEL_FMT, current_dienum); 2014: ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label); 2015: ASM_OUTPUT_LABEL (asm_out_file, begin_label); 2016: ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST); 1.1.1.4 root 2017: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, object_offset_in_bytes); 1.1 root 2018: ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD); 2019: ASM_OUTPUT_LABEL (asm_out_file, end_label); 2020: } 2021: 2022: /* Output an AT_const_value attribute for a variable or a parameter which 2023: does not have a "location" either in memory or in a register. These 2024: things can arise in GNU C when a constant is passed as an actual 2025: parameter to an inlined function. They can also arise in C++ where 2026: declared constants do not necessarily get memory "homes". */ 2027: 2028: static void 2029: const_value_attribute (rtl) 2030: register rtx rtl; 2031: { 2032: char begin_label[MAX_ARTIFICIAL_LABEL_BYTES]; 2033: char end_label[MAX_ARTIFICIAL_LABEL_BYTES]; 2034: 2035: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_const_value_block4); 2036: sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum); 2037: sprintf (end_label, LOC_END_LABEL_FMT, current_dienum); 2038: ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label); 2039: ASM_OUTPUT_LABEL (asm_out_file, begin_label); 2040: 2041: switch (GET_CODE (rtl)) 2042: { 2043: case CONST_INT: 2044: /* Note that a CONST_INT rtx could represent either an integer or 2045: a floating-point constant. A CONST_INT is used whenever the 2046: constant will fit into a single word. In all such cases, the 2047: original mode of the constant value is wiped out, and the 2048: CONST_INT rtx is assigned VOIDmode. Since we no longer have 2049: precise mode information for these constants, we always just 2050: output them using 4 bytes. */ 2051: 2052: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, (unsigned) INTVAL (rtl)); 2053: break; 2054: 2055: case CONST_DOUBLE: 2056: /* Note that a CONST_DOUBLE rtx could represent either an integer 2057: or a floating-point constant. A CONST_DOUBLE is used whenever 2058: the constant requires more than one word in order to be adequately 2059: represented. In all such cases, the original mode of the constant 2060: value is preserved as the mode of the CONST_DOUBLE rtx, but for 2061: simplicity we always just output CONST_DOUBLEs using 8 bytes. */ 2062: 2063: ASM_OUTPUT_DWARF_DATA8 (asm_out_file, 1.1.1.4 root 2064: (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (rtl), 2065: (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (rtl)); 1.1 root 2066: break; 2067: 2068: case CONST_STRING: 2069: ASM_OUTPUT_DWARF_STRING (asm_out_file, XSTR (rtl, 0)); 2070: break; 2071: 2072: case SYMBOL_REF: 2073: case LABEL_REF: 2074: case CONST: 2075: ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl); 2076: break; 1.1.1.2 root 2077: 2078: case PLUS: 2079: /* In cases where an inlined instance of an inline function is passed 2080: the address of an `auto' variable (which is local to the caller) 2081: we can get a situation where the DECL_RTL of the artificial 2082: local variable (for the inlining) which acts as a stand-in for 2083: the corresponding formal parameter (of the inline function) 2084: will look like (plus:SI (reg:SI FRAME_PTR) (const_int ...)). 2085: This is not exactly a compile-time constant expression, but it 2086: isn't the address of the (artificial) local variable either. 2087: Rather, it represents the *value* which the artificial local 2088: variable always has during its lifetime. We currently have no 2089: way to represent such quasi-constant values in Dwarf, so for now 2090: we just punt and generate an AT_const_value attribute with form 2091: FORM_BLOCK4 and a length of zero. */ 2092: break; 1.1.1.4 root 2093: 2094: default: 2095: abort (); /* No other kinds of rtx should be possible here. */ 1.1 root 2096: } 2097: 2098: ASM_OUTPUT_LABEL (asm_out_file, end_label); 2099: } 2100: 2101: /* Generate *either* an AT_location attribute or else an AT_const_value 2102: data attribute for a variable or a parameter. We generate the 2103: AT_const_value attribute only in those cases where the given 2104: variable or parameter does not have a true "location" either in 2105: memory or in a register. This can happen (for example) when a 2106: constant is passed as an actual argument in a call to an inline 2107: function. (It's possible that these things can crop up in other 2108: ways also.) Note that one type of constant value which can be 2109: passed into an inlined function is a constant pointer. This can 2110: happen for example if an actual argument in an inlined function 2111: call evaluates to a compile-time constant address. */ 2112: 2113: static void 2114: location_or_const_value_attribute (decl) 2115: register tree decl; 2116: { 2117: register rtx rtl; 2118: 2119: if (TREE_CODE (decl) == ERROR_MARK) 2120: return; 2121: 2122: if ((TREE_CODE (decl) != VAR_DECL) && (TREE_CODE (decl) != PARM_DECL)) 1.1.1.5 ! root 2123: { ! 2124: /* Should never happen. */ ! 2125: abort (); ! 2126: return; ! 2127: } 1.1 root 2128: 1.1.1.5 ! root 2129: /* Here we have to decide where we are going to say the parameter "lives" ! 2130: (as far as the debugger is concerned). We only have a couple of choices. ! 2131: GCC provides us with DECL_RTL and with DECL_INCOMING_RTL. DECL_RTL ! 2132: normally indicates where the parameter lives during most of the activa- ! 2133: tion of the function. If optimization is enabled however, this could ! 2134: be either NULL or else a pseudo-reg. Both of those cases indicate that ! 2135: the parameter doesn't really live anywhere (as far as the code generation ! 2136: parts of GCC are concerned) during most of the function's activation. ! 2137: That will happen (for example) if the parameter is never referenced ! 2138: within the function. ! 2139: ! 2140: We could just generate a location descriptor here for all non-NULL ! 2141: non-pseudo values of DECL_RTL and ignore all of the rest, but we can ! 2142: be a little nicer than that if we also consider DECL_INCOMING_RTL in ! 2143: cases where DECL_RTL is NULL or is a pseudo-reg. ! 2144: ! 2145: Note however that we can only get away with using DECL_INCOMING_RTL as ! 2146: a backup substitute for DECL_RTL in certain limited cases. In cases ! 2147: where DECL_ARG_TYPE(decl) indicates the same type as TREE_TYPE(decl) ! 2148: we can be sure that the parameter was passed using the same type as it ! 2149: is declared to have within the function, and that its DECL_INCOMING_RTL ! 2150: points us to a place where a value of that type is passed. In cases ! 2151: where DECL_ARG_TYPE(decl) and TREE_TYPE(decl) are different types ! 2152: however, we cannot (in general) use DECL_INCOMING_RTL as a backup ! 2153: substitute for DECL_RTL because in these cases, DECL_INCOMING_RTL ! 2154: points us to a value of some type which is *different* from the type ! 2155: of the parameter itself. Thus, if we tried to use DECL_INCOMING_RTL ! 2156: to generate a location attribute in such cases, the debugger would ! 2157: end up (for example) trying to fetch a `float' from a place which ! 2158: actually contains the first part of a `double'. That would lead to ! 2159: really incorrect and confusing output at debug-time, and we don't ! 2160: want that now do we? ! 2161: ! 2162: So in general, we DO NOT use DECL_INCOMING_RTL as a backup for DECL_RTL ! 2163: in cases where DECL_ARG_TYPE(decl) != TREE_TYPE(decl). There are a ! 2164: couple of cute exceptions however. On little-endian machines we can ! 2165: get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE(decl) is ! 2166: not the same as TREE_TYPE(decl) but only when DECL_ARG_TYPE(decl) is ! 2167: an integral type which is smaller than TREE_TYPE(decl). These cases ! 2168: arise when (on a little-endian machine) a non-prototyped function has ! 2169: a parameter declared to be of type `short' or `char'. In such cases, ! 2170: TREE_TYPE(decl) will be `short' or `char', DECL_ARG_TYPE(decl) will be ! 2171: `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the ! 2172: passed `int' value. If the debugger then uses that address to fetch a ! 2173: `short' or a `char' (on a little-endian machine) the result will be the ! 2174: correct data, so we allow for such exceptional cases below. ! 2175: ! 2176: Note that our goal here is to describe the place where the given formal ! 2177: parameter lives during most of the function's activation (i.e. between ! 2178: the end of the prologue and the start of the epilogue). We'll do that ! 2179: as best as we can. Note however that if the given formal parameter is ! 2180: modified sometime during the execution of the function, then a stack ! 2181: backtrace (at debug-time) will show the function as having been called ! 2182: with the *new* value rather than the value which was originally passed ! 2183: in. This happens rarely enough that it is not a major problem, but it ! 2184: *is* a problem, and I'd like to fix it. A future version of dwarfout.c ! 2185: may generate two additional attributes for any given TAG_formal_parameter ! 2186: DIE which will describe the "passed type" and the "passed location" for ! 2187: the given formal parameter in addition to the attributes we now generate ! 2188: to indicate the "declared type" and the "active location" for each ! 2189: parameter. This additional set of attributes could be used by debuggers ! 2190: for stack backtraces. ! 2191: ! 2192: Separately, note that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL ! 2193: can be NULL also. This happens (for example) for inlined-instances of ! 2194: inline function formal parameters which are never referenced. This really ! 2195: shouldn't be happening. All PARM_DECL nodes should get valid non-NULL ! 2196: DECL_INCOMING_RTL values, but integrate.c doesn't currently generate ! 2197: these values for inlined instances of inline function parameters, so ! 2198: when we see such cases, we are just SOL (shit-out-of-luck) for the time ! 2199: being (until integrate.c gets fixed). 1.1.1.3 root 2200: */ 2201: 1.1.1.5 ! root 2202: /* Use DECL_RTL as the "location" unless we find something better. */ ! 2203: rtl = DECL_RTL (decl); ! 2204: ! 2205: if (TREE_CODE (decl) == PARM_DECL) ! 2206: if (rtl == NULL_RTX || is_pseudo_reg (rtl)) ! 2207: { ! 2208: /* This decl represents a formal parameter which was optimized out. */ ! 2209: register tree declared_type = type_main_variant (TREE_TYPE (decl)); ! 2210: register tree passed_type = type_main_variant (DECL_ARG_TYPE (decl)); ! 2211: ! 2212: /* Note that DECL_INCOMING_RTL may be NULL in here, but we handle ! 2213: *all* cases where (rtl == NULL_RTX) just below. */ ! 2214: ! 2215: if (declared_type == passed_type) ! 2216: rtl = DECL_INCOMING_RTL (decl); ! 2217: #if (BYTES_BIG_ENDIAN == 0) ! 2218: else ! 2219: if (TREE_CODE (declared_type) == INTEGER_TYPE) ! 2220: if (TYPE_SIZE (declared_type) <= TYPE_SIZE (passed_type)) ! 2221: rtl = DECL_INCOMING_RTL (decl); ! 2222: #endif /* (BYTES_BIG_ENDIAN == 0) */ ! 2223: } 1.1 root 2224: 1.1.1.5 ! root 2225: if (rtl == NULL_RTX) 1.1 root 2226: return; 2227: 2228: switch (GET_CODE (rtl)) 2229: { 2230: case CONST_INT: 2231: case CONST_DOUBLE: 2232: case CONST_STRING: 2233: case SYMBOL_REF: 2234: case LABEL_REF: 2235: case CONST: 1.1.1.2 root 2236: case PLUS: /* DECL_RTL could be (plus (reg ...) (const_int ...)) */ 1.1 root 2237: const_value_attribute (rtl); 2238: break; 2239: 2240: case MEM: 2241: case REG: 2242: case SUBREG: 2243: location_attribute (rtl); 2244: break; 2245: 2246: default: 2247: abort (); /* Should never happen. */ 2248: } 2249: } 2250: 2251: /* Generate an AT_name attribute given some string value to be included as 1.1.1.3 root 2252: the value of the attribute. */ 1.1 root 2253: 2254: inline void 2255: name_attribute (name_string) 2256: register char *name_string; 2257: { 2258: if (name_string && *name_string) 2259: { 2260: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_name); 2261: ASM_OUTPUT_DWARF_STRING (asm_out_file, name_string); 2262: } 2263: } 2264: 2265: inline void 2266: fund_type_attribute (ft_code) 2267: register unsigned ft_code; 2268: { 2269: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_fund_type); 2270: ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, ft_code); 2271: } 2272: 2273: static void 2274: mod_fund_type_attribute (type, decl_const, decl_volatile) 2275: register tree type; 2276: register int decl_const; 2277: register int decl_volatile; 2278: { 2279: char begin_label[MAX_ARTIFICIAL_LABEL_BYTES]; 2280: char end_label[MAX_ARTIFICIAL_LABEL_BYTES]; 2281: 2282: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_fund_type); 2283: sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum); 2284: sprintf (end_label, MT_END_LABEL_FMT, current_dienum); 2285: ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label); 2286: ASM_OUTPUT_LABEL (asm_out_file, begin_label); 2287: write_modifier_bytes (type, decl_const, decl_volatile); 2288: ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, 2289: fundamental_type_code (root_type (type))); 2290: ASM_OUTPUT_LABEL (asm_out_file, end_label); 2291: } 2292: 2293: inline void 2294: user_def_type_attribute (type) 2295: register tree type; 2296: { 2297: char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES]; 2298: 2299: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_user_def_type); 2300: sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (type)); 2301: ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name); 2302: } 2303: 2304: static void 2305: mod_u_d_type_attribute (type, decl_const, decl_volatile) 2306: register tree type; 2307: register int decl_const; 2308: register int decl_volatile; 2309: { 2310: char begin_label[MAX_ARTIFICIAL_LABEL_BYTES]; 2311: char end_label[MAX_ARTIFICIAL_LABEL_BYTES]; 2312: char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES]; 2313: 2314: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_u_d_type); 2315: sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum); 2316: sprintf (end_label, MT_END_LABEL_FMT, current_dienum); 2317: ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label); 2318: ASM_OUTPUT_LABEL (asm_out_file, begin_label); 2319: write_modifier_bytes (type, decl_const, decl_volatile); 2320: sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (root_type (type))); 2321: ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name); 2322: ASM_OUTPUT_LABEL (asm_out_file, end_label); 2323: } 2324: 1.1.1.4 root 2325: #ifdef USE_ORDERING_ATTRIBUTE 1.1 root 2326: inline void 2327: ordering_attribute (ordering) 2328: register unsigned ordering; 2329: { 2330: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_ordering); 2331: ASM_OUTPUT_DWARF_DATA2 (asm_out_file, ordering); 2332: } 1.1.1.4 root 2333: #endif /* defined(USE_ORDERING_ATTRIBUTE) */ 1.1 root 2334: 2335: /* Note that the block of subscript information for an array type also 2336: includes information about the element type of type given array type. */ 2337: 2338: static void 2339: subscript_data_attribute (type) 2340: register tree type; 2341: { 2342: register unsigned dimension_number; 2343: char begin_label[MAX_ARTIFICIAL_LABEL_BYTES]; 2344: char end_label[MAX_ARTIFICIAL_LABEL_BYTES]; 2345: 2346: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_subscr_data); 2347: sprintf (begin_label, SS_BEGIN_LABEL_FMT, current_dienum); 2348: sprintf (end_label, SS_END_LABEL_FMT, current_dienum); 2349: ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label); 2350: ASM_OUTPUT_LABEL (asm_out_file, begin_label); 2351: 2352: /* The GNU compilers represent multidimensional array types as sequences 2353: of one dimensional array types whose element types are themselves array 2354: types. Here we squish that down, so that each multidimensional array 2355: type gets only one array_type DIE in the Dwarf debugging info. The 2356: draft Dwarf specification say that we are allowed to do this kind 2357: of compression in C (because there is no difference between an 2358: array or arrays and a multidimensional array in C) but for other 2359: source languages (e.g. Ada) we probably shouldn't do this. */ 2360: 2361: for (dimension_number = 0; 2362: TREE_CODE (type) == ARRAY_TYPE; 2363: type = TREE_TYPE (type), dimension_number++) 2364: { 2365: register tree domain = TYPE_DOMAIN (type); 2366: 2367: /* Arrays come in three flavors. Unspecified bounds, fixed 2368: bounds, and (in GNU C only) variable bounds. Handle all 2369: three forms here. */ 2370: 2371: if (domain) 2372: { 2373: /* We have an array type with specified bounds. */ 2374: 2375: register tree lower = TYPE_MIN_VALUE (domain); 2376: register tree upper = TYPE_MAX_VALUE (domain); 2377: 2378: /* Handle only fundamental types as index types for now. */ 2379: 2380: if (! type_is_fundamental (domain)) 2381: abort (); 2382: 2383: /* Output the representation format byte for this dimension. */ 2384: 2385: ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, 2386: FMT_CODE (1, 2387: TREE_CODE (lower) == INTEGER_CST, 2388: TREE_CODE (upper) == INTEGER_CST)); 2389: 2390: /* Output the index type for this dimension. */ 2391: 2392: ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, 2393: fundamental_type_code (domain)); 2394: 2395: /* Output the representation for the lower bound. */ 2396: 2397: output_bound_representation (lower, dimension_number, 'l'); 2398: 2399: /* Output the representation for the upper bound. */ 2400: 2401: output_bound_representation (upper, dimension_number, 'u'); 2402: } 2403: else 2404: { 2405: /* We have an array type with an unspecified length. For C and 2406: C++ we can assume that this really means that (a) the index 2407: type is an integral type, and (b) the lower bound is zero. 2408: Note that Dwarf defines the representation of an unspecified 2409: (upper) bound as being a zero-length location description. */ 2410: 2411: /* Output the array-bounds format byte. */ 2412: 2413: ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_FT_C_X); 2414: 2415: /* Output the (assumed) index type. */ 2416: 2417: ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, FT_integer); 2418: 2419: /* Output the (assumed) lower bound (constant) value. */ 2420: 2421: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0); 2422: 2423: /* Output the (empty) location description for the upper bound. */ 2424: 2425: ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0); 2426: } 2427: } 2428: 2429: /* Output the prefix byte that says that the element type is comming up. */ 2430: 2431: ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_ET); 2432: 2433: /* Output a representation of the type of the elements of this array type. */ 2434: 2435: type_attribute (type, 0, 0); 2436: 2437: ASM_OUTPUT_LABEL (asm_out_file, end_label); 2438: } 2439: 2440: static void 2441: byte_size_attribute (tree_node) 2442: register tree tree_node; 2443: { 2444: register unsigned size; 2445: 2446: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_byte_size); 2447: switch (TREE_CODE (tree_node)) 2448: { 2449: case ERROR_MARK: 2450: size = 0; 2451: break; 2452: 2453: case ENUMERAL_TYPE: 2454: case RECORD_TYPE: 2455: case UNION_TYPE: 1.1.1.5 ! root 2456: case QUAL_UNION_TYPE: 1.1 root 2457: size = int_size_in_bytes (tree_node); 2458: break; 2459: 2460: case FIELD_DECL: 1.1.1.3 root 2461: /* For a data member of a struct or union, the AT_byte_size is 1.1.1.4 root 2462: generally given as the number of bytes normally allocated for 1.1.1.3 root 2463: an object of the *declared* type of the member itself. This 2464: is true even for bit-fields. */ 1.1.1.4 root 2465: size = simple_type_size_in_bits (field_type (tree_node)) 2466: / BITS_PER_UNIT; 1.1 root 2467: break; 2468: 2469: default: 2470: abort (); 2471: } 1.1.1.3 root 2472: 2473: /* Note that `size' might be -1 when we get to this point. If it 2474: is, that indicates that the byte size of the entity in question 2475: is variable. We have no good way of expressing this fact in Dwarf 2476: at the present time, so just let the -1 pass on through. */ 2477: 1.1 root 2478: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, size); 2479: } 2480: 1.1.1.3 root 2481: /* For a FIELD_DECL node which represents a bit-field, output an attribute 2482: which specifies the distance in bits from the highest order bit of the 2483: "containing object" for the bit-field to the highest order bit of the 2484: bit-field itself. 2485: 2486: For any given bit-field, the "containing object" is a hypothetical 2487: object (of some integral or enum type) within which the given bit-field 2488: lives. The type of this hypothetical "containing object" is always the 2489: same as the declared type of the individual bit-field itself. 2490: 1.1.1.4 root 2491: The determination of the exact location of the "containing object" for 2492: a bit-field is rather complicated. It's handled by the `field_byte_offset' 2493: function (above). 2494: 1.1.1.3 root 2495: Note that it is the size (in bytes) of the hypothetical "containing 2496: object" which will be given in the AT_byte_size attribute for this 2497: bit-field. (See `byte_size_attribute' above.) 2498: */ 1.1 root 2499: 2500: inline void 2501: bit_offset_attribute (decl) 2502: register tree decl; 2503: { 1.1.1.4 root 2504: register unsigned object_offset_in_bytes = field_byte_offset (decl); 1.1.1.3 root 2505: register tree type = DECL_BIT_FIELD_TYPE (decl); 2506: register tree bitpos_tree = DECL_FIELD_BITPOS (decl); 2507: register unsigned bitpos_int; 1.1.1.4 root 2508: register unsigned highest_order_object_bit_offset; 2509: register unsigned highest_order_field_bit_offset; 2510: register unsigned bit_offset; 1.1.1.3 root 2511: 1.1 root 2512: assert (TREE_CODE (decl) == FIELD_DECL); /* Must be a field. */ 1.1.1.3 root 2513: assert (type); /* Must be a bit field. */ 2514: 1.1.1.4 root 2515: /* We can't yet handle bit-fields whose offsets are variable, so if we 2516: encounter such things, just return without generating any attribute 2517: whatsoever. */ 1.1.1.3 root 2518: 2519: if (TREE_CODE (bitpos_tree) != INTEGER_CST) 2520: return; 2521: bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree); 2522: 1.1.1.4 root 2523: /* Note that the bit offset is always the distance (in bits) from the 2524: highest-order bit of the "containing object" to the highest-order 2525: bit of the bit-field itself. Since the "high-order end" of any 2526: object or field is different on big-endian and little-endian machines, 2527: the computation below must take account of these differences. */ 2528: 2529: highest_order_object_bit_offset = object_offset_in_bytes * BITS_PER_UNIT; 2530: highest_order_field_bit_offset = bitpos_int; 2531: 2532: #if (BYTES_BIG_ENDIAN == 0) 2533: highest_order_field_bit_offset 2534: += (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl)); 2535: 2536: highest_order_object_bit_offset += simple_type_size_in_bits (type); 2537: #endif /* (BYTES_BIG_ENDIAN == 0) */ 2538: 2539: bit_offset = 2540: #if (BYTES_BIG_ENDIAN == 0) 2541: highest_order_object_bit_offset - highest_order_field_bit_offset; 2542: #else /* (BYTES_BIG_ENDIAN != 0) */ 2543: highest_order_field_bit_offset - highest_order_object_bit_offset; 2544: #endif /* (BYTES_BIG_ENDIAN != 0) */ 1.1 root 2545: 2546: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_offset); 1.1.1.4 root 2547: ASM_OUTPUT_DWARF_DATA2 (asm_out_file, bit_offset); 1.1 root 2548: } 2549: 2550: /* For a FIELD_DECL node which represents a bit field, output an attribute 2551: which specifies the length in bits of the given field. */ 2552: 2553: inline void 2554: bit_size_attribute (decl) 2555: register tree decl; 2556: { 2557: assert (TREE_CODE (decl) == FIELD_DECL); /* Must be a field. */ 2558: assert (DECL_BIT_FIELD_TYPE (decl)); /* Must be a bit field. */ 2559: 2560: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_size); 2561: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 2562: (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl))); 2563: } 2564: 2565: /* The following routine outputs the `element_list' attribute for enumeration 2566: type DIEs. The element_lits attribute includes the names and values of 2567: all of the enumeration constants associated with the given enumeration 2568: type. */ 2569: 2570: inline void 2571: element_list_attribute (element) 2572: register tree element; 2573: { 2574: char begin_label[MAX_ARTIFICIAL_LABEL_BYTES]; 2575: char end_label[MAX_ARTIFICIAL_LABEL_BYTES]; 2576: 2577: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_element_list); 2578: sprintf (begin_label, EE_BEGIN_LABEL_FMT, current_dienum); 2579: sprintf (end_label, EE_END_LABEL_FMT, current_dienum); 2580: ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label); 2581: ASM_OUTPUT_LABEL (asm_out_file, begin_label); 2582: 2583: /* Here we output a list of value/name pairs for each enumeration constant 2584: defined for this enumeration type (as required), but we do it in REVERSE 2585: order. The order is the one required by the draft #5 Dwarf specification 2586: published by the UI/PLSIG. */ 2587: 2588: output_enumeral_list (element); /* Recursively output the whole list. */ 2589: 2590: ASM_OUTPUT_LABEL (asm_out_file, end_label); 2591: } 2592: 2593: /* Generate an AT_stmt_list attribute. These are normally present only in 2594: DIEs with a TAG_compile_unit tag. */ 2595: 2596: inline void 2597: stmt_list_attribute (label) 2598: register char *label; 2599: { 2600: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_stmt_list); 2601: /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */ 2602: ASM_OUTPUT_DWARF_ADDR (asm_out_file, label); 2603: } 2604: 2605: /* Generate an AT_low_pc attribute for a label DIE, a lexical_block DIE or 2606: for a subroutine DIE. */ 2607: 2608: inline void 2609: low_pc_attribute (asm_low_label) 2610: register char *asm_low_label; 2611: { 2612: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_low_pc); 2613: ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_low_label); 2614: } 2615: 2616: /* Generate an AT_high_pc attribute for a lexical_block DIE or for a 2617: subroutine DIE. */ 2618: 2619: inline void 2620: high_pc_attribute (asm_high_label) 2621: register char *asm_high_label; 2622: { 2623: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_high_pc); 2624: ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_high_label); 2625: } 2626: 1.1.1.4 root 2627: /* Generate an AT_body_begin attribute for a subroutine DIE. */ 2628: 2629: inline void 2630: body_begin_attribute (asm_begin_label) 2631: register char *asm_begin_label; 2632: { 2633: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_begin); 2634: ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_begin_label); 2635: } 2636: 2637: /* Generate an AT_body_end attribute for a subroutine DIE. */ 2638: 2639: inline void 2640: body_end_attribute (asm_end_label) 2641: register char *asm_end_label; 2642: { 2643: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_end); 2644: ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_end_label); 2645: } 2646: 1.1 root 2647: /* Generate an AT_language attribute given a LANG value. These attributes 2648: are used only within TAG_compile_unit DIEs. */ 2649: 2650: inline void 2651: language_attribute (language_code) 2652: register unsigned language_code; 2653: { 2654: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_language); 2655: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, language_code); 2656: } 2657: 2658: inline void 2659: member_attribute (context) 2660: register tree context; 2661: { 2662: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 2663: 2664: /* Generate this attribute only for members in C++. */ 2665: 1.1.1.4 root 2666: if (context != NULL && is_tagged_type (context)) 1.1 root 2667: { 2668: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_member); 2669: sprintf (label, TYPE_NAME_FMT, TYPE_UID (context)); 2670: ASM_OUTPUT_DWARF_REF (asm_out_file, label); 2671: } 2672: } 2673: 2674: inline void 2675: string_length_attribute (upper_bound) 2676: register tree upper_bound; 2677: { 2678: char begin_label[MAX_ARTIFICIAL_LABEL_BYTES]; 2679: char end_label[MAX_ARTIFICIAL_LABEL_BYTES]; 2680: 2681: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_string_length); 2682: sprintf (begin_label, SL_BEGIN_LABEL_FMT, current_dienum); 2683: sprintf (end_label, SL_END_LABEL_FMT, current_dienum); 2684: ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label); 2685: ASM_OUTPUT_LABEL (asm_out_file, begin_label); 2686: output_bound_representation (upper_bound, 0, 'u'); 2687: ASM_OUTPUT_LABEL (asm_out_file, end_label); 2688: } 2689: 2690: inline void 2691: comp_dir_attribute (dirname) 2692: register char *dirname; 2693: { 2694: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_comp_dir); 2695: ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname); 2696: } 2697: 2698: inline void 2699: sf_names_attribute (sf_names_start_label) 2700: register char *sf_names_start_label; 2701: { 2702: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sf_names); 2703: /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */ 2704: ASM_OUTPUT_DWARF_ADDR (asm_out_file, sf_names_start_label); 2705: } 2706: 2707: inline void 2708: src_info_attribute (src_info_start_label) 2709: register char *src_info_start_label; 2710: { 2711: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_info); 2712: /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */ 2713: ASM_OUTPUT_DWARF_ADDR (asm_out_file, src_info_start_label); 2714: } 2715: 2716: inline void 2717: mac_info_attribute (mac_info_start_label) 2718: register char *mac_info_start_label; 2719: { 2720: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mac_info); 2721: /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */ 2722: ASM_OUTPUT_DWARF_ADDR (asm_out_file, mac_info_start_label); 2723: } 2724: 2725: inline void 2726: prototyped_attribute (func_type) 2727: register tree func_type; 2728: { 2729: if ((strcmp (language_string, "GNU C") == 0) 2730: && (TYPE_ARG_TYPES (func_type) != NULL)) 2731: { 2732: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_prototyped); 2733: ASM_OUTPUT_DWARF_STRING (asm_out_file, ""); 2734: } 2735: } 2736: 2737: inline void 2738: producer_attribute (producer) 2739: register char *producer; 2740: { 2741: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_producer); 2742: ASM_OUTPUT_DWARF_STRING (asm_out_file, producer); 2743: } 2744: 2745: inline void 2746: inline_attribute (decl) 2747: register tree decl; 2748: { 1.1.1.4 root 2749: if (DECL_INLINE (decl)) 1.1 root 2750: { 2751: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_inline); 2752: ASM_OUTPUT_DWARF_STRING (asm_out_file, ""); 2753: } 2754: } 2755: 2756: inline void 2757: containing_type_attribute (containing_type) 2758: register tree containing_type; 2759: { 2760: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 2761: 2762: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_containing_type); 2763: sprintf (label, TYPE_NAME_FMT, TYPE_UID (containing_type)); 2764: ASM_OUTPUT_DWARF_REF (asm_out_file, label); 2765: } 2766: 1.1.1.3 root 2767: inline void 1.1.1.4 root 2768: abstract_origin_attribute (origin) 2769: register tree origin; 2770: { 2771: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 2772: 2773: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_abstract_origin); 2774: switch (TREE_CODE_CLASS (TREE_CODE (origin))) 2775: { 2776: case 'd': 2777: sprintf (label, DECL_NAME_FMT, DECL_UID (origin)); 2778: break; 2779: 2780: case 't': 2781: sprintf (label, TYPE_NAME_FMT, TYPE_UID (origin)); 2782: break; 2783: 2784: default: 2785: abort (); /* Should never happen. */ 2786: 2787: } 2788: ASM_OUTPUT_DWARF_REF (asm_out_file, label); 2789: } 2790: 2791: #ifdef DWARF_DECL_COORDINATES 2792: inline void 1.1.1.3 root 2793: src_coords_attribute (src_fileno, src_lineno) 2794: register unsigned src_fileno; 2795: register unsigned src_lineno; 2796: { 2797: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_coords); 2798: ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_fileno); 2799: ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_lineno); 2800: } 1.1.1.4 root 2801: #endif /* defined(DWARF_DECL_COORDINATES) */ 2802: 2803: inline void 2804: pure_or_virtual_attribute (func_decl) 2805: register tree func_decl; 2806: { 2807: if (DECL_VIRTUAL_P (func_decl)) 2808: { 2809: #if 0 /* DECL_ABSTRACT_VIRTUAL_P is C++-specific. */ 2810: if (DECL_ABSTRACT_VIRTUAL_P (func_decl)) 2811: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_pure_virtual); 2812: else 2813: #endif 2814: ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual); 2815: ASM_OUTPUT_DWARF_STRING (asm_out_file, ""); 2816: } 2817: } 1.1.1.3 root 2818: 1.1 root 2819: /************************* end of attributes *****************************/ 2820: 2821: /********************* utility routines for DIEs *************************/ 2822: 1.1.1.3 root 2823: /* Output an AT_name attribute and an AT_src_coords attribute for the 2824: given decl, but only if it actually has a name. */ 2825: 1.1.1.4 root 2826: static void 1.1.1.3 root 2827: name_and_src_coords_attributes (decl) 2828: register tree decl; 2829: { 2830: register tree decl_name = DECL_NAME (decl); 2831: 2832: if (decl_name && IDENTIFIER_POINTER (decl_name)) 2833: { 2834: name_attribute (IDENTIFIER_POINTER (decl_name)); 2835: #ifdef DWARF_DECL_COORDINATES 2836: { 2837: register unsigned file_index; 2838: 2839: /* This is annoying, but we have to pop out of the .debug section 2840: for a moment while we call `lookup_filename' because calling it 2841: may cause a temporary switch into the .debug_sfnames section and 2842: most svr4 assemblers are not smart enough be be able to nest 2843: section switches to any depth greater than one. Note that we 2844: also can't skirt this issue by delaying all output to the 2845: .debug_sfnames section unit the end of compilation because that 2846: would cause us to have inter-section forward references and 2847: Fred Fish sez that m68k/svr4 assemblers botch those. */ 2848: 2849: ASM_OUTPUT_POP_SECTION (asm_out_file); 2850: file_index = lookup_filename (DECL_SOURCE_FILE (decl)); 2851: ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION); 2852: 2853: src_coords_attribute (file_index, DECL_SOURCE_LINE (decl)); 2854: } 1.1.1.4 root 2855: #endif /* defined(DWARF_DECL_COORDINATES) */ 1.1.1.3 root 2856: } 2857: } 2858: 1.1 root 2859: /* Many forms of DIEs contain a "type description" part. The following 2860: routine writes out these "type descriptor" parts. */ 2861: 2862: static void 2863: type_attribute (type, decl_const, decl_volatile) 2864: register tree type; 2865: register int decl_const; 2866: register int decl_volatile; 2867: { 2868: register enum tree_code code = TREE_CODE (type); 2869: register int root_type_modified; 2870: 2871: if (TREE_CODE (type) == ERROR_MARK) 2872: return; 2873: 2874: /* Handle a special case. For functions whose return type is void, 2875: we generate *no* type attribute. (Note that no object may have 2876: type `void', so this only applies to function return types. */ 2877: 2878: if (TREE_CODE (type) == VOID_TYPE) 2879: return; 2880: 2881: root_type_modified = (code == POINTER_TYPE || code == REFERENCE_TYPE 2882: || decl_const || decl_volatile 2883: || TYPE_READONLY (type) || TYPE_VOLATILE (type)); 2884: 2885: if (type_is_fundamental (root_type (type))) 2886: if (root_type_modified) 2887: mod_fund_type_attribute (type, decl_const, decl_volatile); 2888: else 2889: fund_type_attribute (fundamental_type_code (type)); 2890: else 2891: if (root_type_modified) 2892: mod_u_d_type_attribute (type, decl_const, decl_volatile); 2893: else 1.1.1.5 ! root 2894: /* We have to get the type_main_variant here (and pass that to the ! 2895: `user_def_type_attribute' routine) because the ..._TYPE node we ! 2896: have might simply be a *copy* of some original type node (where ! 2897: the copy was created to help us keep track of typedef names) ! 2898: and that copy might have a different TYPE_UID from the original ! 2899: ..._TYPE node. (Note that when `equate_type_number_to_die_number' ! 2900: is labeling a given type DIE for future reference, it always and ! 2901: only creates labels for DIEs representing *main variants*, and it ! 2902: never even knows about non-main-variants.) */ ! 2903: user_def_type_attribute (type_main_variant (type)); 1.1 root 2904: } 2905: 2906: /* Given a tree pointer to a struct, class, union, or enum type node, return 2907: a pointer to the (string) tag name for the given type, or zero if the 2908: type was declared without a tag. */ 2909: 2910: static char * 2911: type_tag (type) 2912: register tree type; 2913: { 2914: register char *name = 0; 2915: 2916: if (TYPE_NAME (type) != 0) 2917: { 2918: register tree t = 0; 2919: 2920: /* Find the IDENTIFIER_NODE for the type name. */ 2921: if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) 2922: t = TYPE_NAME (type); 2923: #if 0 2924: /* The g++ front end makes the TYPE_NAME of *each* tagged type point 2925: to a TYPE_DECL node, regardless of whether or not a `typedef' was 2926: involved. This is distinctly different from what the gcc front-end 2927: does. It always makes the TYPE_NAME for each tagged type be either 2928: NULL (signifying an anonymous tagged type) or else a pointer to an 2929: IDENTIFIER_NODE. Obviously, we would like to generate correct Dwarf 1.1.1.3 root 2930: for both C and C++, but given this inconsistency in the TREE 1.1 root 2931: representation of tagged types for C and C++ in the GNU front-ends, 2932: we cannot support both languages correctly unless we introduce some 2933: front-end specific code here, and rms objects to that, so we can 2934: only generate correct Dwarf for one of these two languages. C is 2935: more important, so for now we'll do the right thing for C and let 2936: g++ go fish. */ 2937: 2938: else 2939: if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL) 2940: t = DECL_NAME (TYPE_NAME (type)); 2941: #endif 2942: /* Now get the name as a string, or invent one. */ 2943: if (t != 0) 2944: name = IDENTIFIER_POINTER (t); 2945: } 2946: 2947: return (name == 0 || *name == '\0') ? 0 : name; 2948: } 2949: 2950: inline void 2951: dienum_push () 2952: { 2953: /* Start by checking if the pending_sibling_stack needs to be expanded. 2954: If necessary, expand it. */ 2955: 2956: if (pending_siblings == pending_siblings_allocated) 2957: { 2958: pending_siblings_allocated += PENDING_SIBLINGS_INCREMENT; 2959: pending_sibling_stack 2960: = (unsigned *) xrealloc (pending_sibling_stack, 2961: pending_siblings_allocated * sizeof(unsigned)); 2962: } 2963: 2964: pending_siblings++; 2965: NEXT_DIE_NUM = next_unused_dienum++; 2966: } 2967: 2968: /* Pop the sibling stack so that the most recently pushed DIEnum becomes the 2969: NEXT_DIE_NUM. */ 2970: 2971: inline void 2972: dienum_pop () 2973: { 2974: pending_siblings--; 2975: } 2976: 2977: inline tree 2978: member_declared_type (member) 2979: register tree member; 2980: { 2981: return (DECL_BIT_FIELD_TYPE (member)) 2982: ? DECL_BIT_FIELD_TYPE (member) 2983: : TREE_TYPE (member); 2984: } 2985: 2986: /******************************* DIEs ************************************/ 2987: 2988: /* Output routines for individual types of DIEs. */ 2989: 2990: /* Note that every type of DIE (except a null DIE) gets a sibling. */ 2991: 2992: static void 2993: output_array_type_die (arg) 2994: register void *arg; 2995: { 2996: register tree type = arg; 2997: 2998: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_array_type); 2999: sibling_attribute (); 3000: equate_type_number_to_die_number (type); 3001: member_attribute (TYPE_CONTEXT (type)); 3002: 3003: /* I believe that we can default the array ordering. SDB will probably 3004: do the right things even if AT_ordering is not present. It's not 3005: even an issue until we start to get into multidimensional arrays 1.1.1.3 root 3006: anyway. If SDB is ever caught doing the Wrong Thing for multi- 3007: dimensional arrays, then we'll have to put the AT_ordering attribute 3008: back in. (But if and when we find out that we need to put these in, 3009: we will only do so for multidimensional arrays. After all, we don't 3010: want to waste space in the .debug section now do we?) */ 1.1 root 3011: 1.1.1.4 root 3012: #ifdef USE_ORDERING_ATTRIBUTE 1.1 root 3013: ordering_attribute (ORD_row_major); 1.1.1.4 root 3014: #endif /* defined(USE_ORDERING_ATTRIBUTE) */ 1.1 root 3015: 3016: subscript_data_attribute (type); 3017: } 3018: 3019: static void 3020: output_set_type_die (arg) 3021: register void *arg; 3022: { 3023: register tree type = arg; 3024: 3025: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_set_type); 3026: sibling_attribute (); 3027: equate_type_number_to_die_number (type); 3028: member_attribute (TYPE_CONTEXT (type)); 3029: type_attribute (TREE_TYPE (type), 0, 0); 3030: } 3031: 3032: #if 0 3033: /* Implement this when there is a GNU FORTRAN or GNU Ada front end. */ 3034: static void 3035: output_entry_point_die (arg) 3036: register void *arg; 3037: { 3038: register tree decl = arg; 1.1.1.4 root 3039: register tree origin = decl_ultimate_origin (decl); 1.1 root 3040: 3041: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_entry_point); 3042: sibling_attribute (); 3043: dienum_push (); 1.1.1.4 root 3044: if (origin != NULL) 3045: abstract_origin_attribute (origin); 3046: else 3047: { 3048: name_and_src_coords_attributes (decl); 3049: member_attribute (DECL_CONTEXT (decl)); 3050: type_attribute (TREE_TYPE (TREE_TYPE (decl)), 0, 0); 3051: } 3052: if (DECL_ABSTRACT (decl)) 3053: equate_decl_number_to_die_number (decl); 3054: else 3055: low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); 1.1 root 3056: } 3057: #endif 3058: 1.1.1.4 root 3059: /* Output a DIE to represent an inlined instance of an enumeration type. */ 3060: 3061: static void 3062: output_inlined_enumeration_type_die (arg) 3063: register void *arg; 3064: { 3065: register tree type = arg; 3066: 3067: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type); 3068: sibling_attribute (); 3069: assert (TREE_ASM_WRITTEN (type)); 3070: abstract_origin_attribute (type); 3071: } 3072: 3073: /* Output a DIE to represent an inlined instance of a structure type. */ 3074: 3075: static void 3076: output_inlined_structure_type_die (arg) 3077: register void *arg; 3078: { 3079: register tree type = arg; 3080: 3081: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type); 3082: sibling_attribute (); 3083: assert (TREE_ASM_WRITTEN (type)); 3084: abstract_origin_attribute (type); 3085: } 3086: 3087: /* Output a DIE to represent an inlined instance of a union type. */ 3088: 3089: static void 3090: output_inlined_union_type_die (arg) 3091: register void *arg; 3092: { 3093: register tree type = arg; 3094: 3095: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type); 3096: sibling_attribute (); 3097: assert (TREE_ASM_WRITTEN (type)); 3098: abstract_origin_attribute (type); 3099: } 3100: 1.1 root 3101: /* Output a DIE to represent an enumeration type. Note that these DIEs 3102: include all of the information about the enumeration values also. 3103: This information is encoded into the element_list attribute. */ 3104: 3105: static void 3106: output_enumeration_type_die (arg) 3107: register void *arg; 3108: { 3109: register tree type = arg; 3110: 3111: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type); 3112: sibling_attribute (); 3113: equate_type_number_to_die_number (type); 3114: name_attribute (type_tag (type)); 3115: member_attribute (TYPE_CONTEXT (type)); 3116: 3117: /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the 3118: given enum type is incomplete, do not generate the AT_byte_size 3119: attribute or the AT_element_list attribute. */ 3120: 3121: if (TYPE_SIZE (type)) 3122: { 3123: byte_size_attribute (type); 3124: element_list_attribute (TYPE_FIELDS (type)); 3125: } 3126: } 3127: 3128: /* Output a DIE to represent either a real live formal parameter decl or 3129: to represent just the type of some formal parameter position in some 3130: function type. 3131: 3132: Note that this routine is a bit unusual because its argument may be 1.1.1.4 root 3133: a ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which 3134: represents an inlining of some PARM_DECL) or else some sort of a 3135: ..._TYPE node. If it's the former then this function is being called 3136: to output a DIE to represent a formal parameter object (or some inlining 3137: thereof). If it's the latter, then this function is only being called 3138: to output a TAG_formal_parameter DIE to stand as a placeholder for some 3139: formal argument type of some subprogram type. */ 1.1 root 3140: 3141: static void 3142: output_formal_parameter_die (arg) 3143: register void *arg; 3144: { 1.1.1.4 root 3145: register tree node = arg; 1.1 root 3146: 3147: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_formal_parameter); 3148: sibling_attribute (); 1.1.1.4 root 3149: 3150: switch (TREE_CODE_CLASS (TREE_CODE (node))) 1.1 root 3151: { 1.1.1.4 root 3152: case 'd': /* We were called with some kind of a ..._DECL node. */ 3153: { 3154: register tree origin = decl_ultimate_origin (node); 3155: 3156: if (origin != NULL) 3157: abstract_origin_attribute (origin); 3158: else 3159: { 3160: name_and_src_coords_attributes (node); 3161: type_attribute (TREE_TYPE (node), 3162: TREE_READONLY (node), TREE_THIS_VOLATILE (node)); 3163: } 3164: if (DECL_ABSTRACT (node)) 3165: equate_decl_number_to_die_number (node); 3166: else 3167: location_or_const_value_attribute (node); 3168: } 3169: break; 3170: 3171: case 't': /* We were called with some kind of a ..._TYPE node. */ 3172: type_attribute (node, 0, 0); 3173: break; 3174: 3175: default: 3176: abort (); /* Should never happen. */ 1.1 root 3177: } 3178: } 3179: 3180: /* Output a DIE to represent a declared function (either file-scope 3181: or block-local) which has "external linkage" (according to ANSI-C). */ 3182: 3183: static void 3184: output_global_subroutine_die (arg) 3185: register void *arg; 3186: { 3187: register tree decl = arg; 1.1.1.4 root 3188: register tree origin = decl_ultimate_origin (decl); 1.1 root 3189: 3190: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_subroutine); 3191: sibling_attribute (); 3192: dienum_push (); 1.1.1.4 root 3193: if (origin != NULL) 3194: abstract_origin_attribute (origin); 3195: else 3196: { 3197: register tree type = TREE_TYPE (decl); 3198: 3199: name_and_src_coords_attributes (decl); 3200: inline_attribute (decl); 3201: prototyped_attribute (type); 3202: member_attribute (DECL_CONTEXT (decl)); 3203: type_attribute (TREE_TYPE (type), 0, 0); 3204: pure_or_virtual_attribute (decl); 3205: } 3206: if (DECL_ABSTRACT (decl)) 3207: equate_decl_number_to_die_number (decl); 3208: else 1.1 root 3209: { 1.1.1.4 root 3210: if (! DECL_EXTERNAL (decl)) 3211: { 3212: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 1.1 root 3213: 1.1.1.4 root 3214: low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); 3215: sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number); 3216: high_pc_attribute (label); 3217: sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number); 3218: body_begin_attribute (label); 3219: sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number); 3220: body_end_attribute (label); 3221: } 1.1 root 3222: } 3223: } 3224: 3225: /* Output a DIE to represent a declared data object (either file-scope 3226: or block-local) which has "external linkage" (according to ANSI-C). */ 3227: 3228: static void 3229: output_global_variable_die (arg) 3230: register void *arg; 3231: { 3232: register tree decl = arg; 1.1.1.4 root 3233: register tree origin = decl_ultimate_origin (decl); 1.1 root 3234: 3235: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_variable); 3236: sibling_attribute (); 1.1.1.4 root 3237: if (origin != NULL) 3238: abstract_origin_attribute (origin); 3239: else 1.1 root 3240: { 1.1.1.4 root 3241: name_and_src_coords_attributes (decl); 3242: member_attribute (DECL_CONTEXT (decl)); 3243: type_attribute (TREE_TYPE (decl), 3244: TREE_READONLY (decl), TREE_THIS_VOLATILE (decl)); 3245: } 3246: if (DECL_ABSTRACT (decl)) 3247: equate_decl_number_to_die_number (decl); 3248: else 3249: { 3250: if (!DECL_EXTERNAL (decl)) 3251: location_or_const_value_attribute (decl); 1.1 root 3252: } 3253: } 3254: 3255: static void 3256: output_label_die (arg) 3257: register void *arg; 3258: { 3259: register tree decl = arg; 1.1.1.4 root 3260: register tree origin = decl_ultimate_origin (decl); 1.1 root 3261: 3262: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_label); 3263: sibling_attribute (); 1.1.1.4 root 3264: if (origin != NULL) 3265: abstract_origin_attribute (origin); 3266: else 3267: name_and_src_coords_attributes (decl); 3268: if (DECL_ABSTRACT (decl)) 3269: equate_decl_number_to_die_number (decl); 3270: else 1.1 root 3271: { 1.1.1.4 root 3272: register rtx insn = DECL_RTL (decl); 1.1 root 3273: 1.1.1.4 root 3274: if (GET_CODE (insn) == CODE_LABEL) 3275: { 3276: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 3277: 3278: /* When optimization is enabled (via -O) some parts of the compiler 3279: (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which 3280: represent source-level labels which were explicitly declared by 3281: the user. This really shouldn't be happening though, so catch 3282: it if it ever does happen. */ 3283: 3284: if (INSN_DELETED_P (insn)) 3285: abort (); /* Should never happen. */ 3286: 3287: sprintf (label, INSN_LABEL_FMT, current_funcdef_number, 3288: (unsigned) INSN_UID (insn)); 3289: low_pc_attribute (label); 3290: } 1.1 root 3291: } 3292: } 3293: 3294: static void 3295: output_lexical_block_die (arg) 3296: register void *arg; 3297: { 3298: register tree stmt = arg; 3299: 3300: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_lexical_block); 3301: sibling_attribute (); 3302: dienum_push (); 1.1.1.4 root 3303: if (! BLOCK_ABSTRACT (stmt)) 3304: { 3305: char begin_label[MAX_ARTIFICIAL_LABEL_BYTES]; 3306: char end_label[MAX_ARTIFICIAL_LABEL_BYTES]; 3307: 3308: sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number); 3309: low_pc_attribute (begin_label); 3310: sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number); 3311: high_pc_attribute (end_label); 3312: } 1.1 root 3313: } 3314: 3315: static void 3316: output_inlined_subroutine_die (arg) 3317: register void *arg; 3318: { 3319: register tree stmt = arg; 3320: 3321: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inlined_subroutine); 3322: sibling_attribute (); 3323: dienum_push (); 1.1.1.4 root 3324: abstract_origin_attribute (block_ultimate_origin (stmt)); 3325: if (! BLOCK_ABSTRACT (stmt)) 3326: { 3327: char begin_label[MAX_ARTIFICIAL_LABEL_BYTES]; 3328: char end_label[MAX_ARTIFICIAL_LABEL_BYTES]; 3329: 3330: sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number); 3331: low_pc_attribute (begin_label); 3332: sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number); 3333: high_pc_attribute (end_label); 3334: } 1.1 root 3335: } 3336: 3337: /* Output a DIE to represent a declared data object (either file-scope 3338: or block-local) which has "internal linkage" (according to ANSI-C). */ 3339: 3340: static void 3341: output_local_variable_die (arg) 3342: register void *arg; 3343: { 3344: register tree decl = arg; 1.1.1.4 root 3345: register tree origin = decl_ultimate_origin (decl); 1.1 root 3346: 3347: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_local_variable); 3348: sibling_attribute (); 1.1.1.4 root 3349: if (origin != NULL) 3350: abstract_origin_attribute (origin); 3351: else 3352: { 3353: name_and_src_coords_attributes (decl); 3354: member_attribute (DECL_CONTEXT (decl)); 3355: type_attribute (TREE_TYPE (decl), 3356: TREE_READONLY (decl), TREE_THIS_VOLATILE (decl)); 3357: } 3358: if (DECL_ABSTRACT (decl)) 3359: equate_decl_number_to_die_number (decl); 3360: else 3361: location_or_const_value_attribute (decl); 1.1 root 3362: } 3363: 3364: static void 3365: output_member_die (arg) 3366: register void *arg; 3367: { 3368: register tree decl = arg; 3369: 3370: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_member); 3371: sibling_attribute (); 1.1.1.3 root 3372: name_and_src_coords_attributes (decl); 1.1 root 3373: member_attribute (DECL_CONTEXT (decl)); 3374: type_attribute (member_declared_type (decl), 3375: TREE_READONLY (decl), TREE_THIS_VOLATILE (decl)); 3376: if (DECL_BIT_FIELD_TYPE (decl)) /* If this is a bit field... */ 3377: { 3378: byte_size_attribute (decl); 3379: bit_size_attribute (decl); 3380: bit_offset_attribute (decl); 3381: } 3382: data_member_location_attribute (decl); 3383: } 3384: 3385: #if 0 1.1.1.4 root 3386: /* Don't generate either pointer_type DIEs or reference_type DIEs. Use 3387: modified types instead. 1.1 root 3388: 3389: We keep this code here just in case these types of DIEs may be needed 3390: to represent certain things in other languages (e.g. Pascal) someday. 3391: */ 3392: 3393: static void 3394: output_pointer_type_die (arg) 3395: register void *arg; 3396: { 3397: register tree type = arg; 3398: 3399: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_pointer_type); 3400: sibling_attribute (); 3401: equate_type_number_to_die_number (type); 3402: member_attribute (TYPE_CONTEXT (type)); 3403: type_attribute (TREE_TYPE (type), 0, 0); 3404: } 3405: 3406: static void 3407: output_reference_type_die (arg) 3408: register void *arg; 3409: { 3410: register tree type = arg; 3411: 3412: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_reference_type); 3413: sibling_attribute (); 3414: equate_type_number_to_die_number (type); 3415: member_attribute (TYPE_CONTEXT (type)); 3416: type_attribute (TREE_TYPE (type), 0, 0); 3417: } 3418: #endif 3419: 1.1.1.4 root 3420: static void 1.1 root 3421: output_ptr_to_mbr_type_die (arg) 3422: register void *arg; 3423: { 3424: register tree type = arg; 3425: 3426: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_ptr_to_member_type); 3427: sibling_attribute (); 3428: equate_type_number_to_die_number (type); 3429: member_attribute (TYPE_CONTEXT (type)); 3430: containing_type_attribute (TYPE_OFFSET_BASETYPE (type)); 3431: type_attribute (TREE_TYPE (type), 0, 0); 3432: } 3433: 3434: static void 3435: output_compile_unit_die (arg) 3436: register void *arg; 3437: { 3438: register char *main_input_filename = arg; 3439: 3440: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_compile_unit); 3441: sibling_attribute (); 3442: dienum_push (); 3443: name_attribute (main_input_filename); 3444: 3445: { 3446: char producer[250]; 3447: 3448: sprintf (producer, "%s %s", language_string, version_string); 3449: producer_attribute (producer); 3450: } 3451: 3452: if (strcmp (language_string, "GNU C++") == 0) 3453: language_attribute (LANG_C_PLUS_PLUS); 3454: else if (flag_traditional) 3455: language_attribute (LANG_C); 3456: else 3457: language_attribute (LANG_C89); 3458: low_pc_attribute (TEXT_BEGIN_LABEL); 3459: high_pc_attribute (TEXT_END_LABEL); 3460: if (debug_info_level >= DINFO_LEVEL_NORMAL) 3461: stmt_list_attribute (LINE_BEGIN_LABEL); 3462: last_filename = xstrdup (main_input_filename); 3463: 3464: { 1.1.1.2 root 3465: char *wd = getpwd (); 3466: if (wd) 3467: comp_dir_attribute (wd); 1.1 root 3468: } 3469: 3470: if (debug_info_level >= DINFO_LEVEL_NORMAL) 3471: { 3472: sf_names_attribute (SFNAMES_BEGIN_LABEL); 3473: src_info_attribute (SRCINFO_BEGIN_LABEL); 3474: if (debug_info_level >= DINFO_LEVEL_VERBOSE) 3475: mac_info_attribute (MACINFO_BEGIN_LABEL); 3476: } 3477: } 3478: 3479: static void 3480: output_string_type_die (arg) 3481: register void *arg; 3482: { 3483: register tree type = arg; 3484: 3485: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_string_type); 3486: sibling_attribute (); 3487: member_attribute (TYPE_CONTEXT (type)); 3488: 3489: /* Fudge the string length attribute for now. */ 3490: 1.1.1.4 root 3491: string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type))); 1.1 root 3492: } 3493: 3494: static void 3495: output_structure_type_die (arg) 3496: register void *arg; 3497: { 3498: register tree type = arg; 3499: 3500: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type); 3501: sibling_attribute (); 3502: equate_type_number_to_die_number (type); 3503: name_attribute (type_tag (type)); 3504: member_attribute (TYPE_CONTEXT (type)); 3505: 3506: /* If this type has been completed, then give it a byte_size attribute 3507: and prepare to give a list of members. Otherwise, don't do either of 3508: these things. In the latter case, we will not be generating a list 3509: of members (since we don't have any idea what they might be for an 3510: incomplete type). */ 3511: 3512: if (TYPE_SIZE (type)) 3513: { 3514: dienum_push (); 3515: byte_size_attribute (type); 3516: } 3517: } 3518: 3519: /* Output a DIE to represent a declared function (either file-scope 3520: or block-local) which has "internal linkage" (according to ANSI-C). */ 3521: 3522: static void 3523: output_local_subroutine_die (arg) 3524: register void *arg; 3525: { 3526: register tree decl = arg; 1.1.1.4 root 3527: register tree origin = decl_ultimate_origin (decl); 1.1 root 3528: 3529: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine); 3530: sibling_attribute (); 3531: dienum_push (); 1.1.1.4 root 3532: if (origin != NULL) 3533: abstract_origin_attribute (origin); 3534: else 3535: { 3536: register tree type = TREE_TYPE (decl); 1.1 root 3537: 1.1.1.4 root 3538: name_and_src_coords_attributes (decl); 3539: inline_attribute (decl); 3540: prototyped_attribute (type); 3541: member_attribute (DECL_CONTEXT (decl)); 3542: type_attribute (TREE_TYPE (type), 0, 0); 3543: pure_or_virtual_attribute (decl); 3544: } 3545: if (DECL_ABSTRACT (decl)) 3546: equate_decl_number_to_die_number (decl); 3547: else 1.1 root 3548: { 1.1.1.4 root 3549: /* Avoid getting screwed up in cases where a function was declared 3550: static but where no definition was ever given for it. */ 3551: 3552: if (TREE_ASM_WRITTEN (decl)) 3553: { 3554: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 3555: 3556: low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); 3557: sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number); 3558: high_pc_attribute (label); 3559: sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number); 3560: body_begin_attribute (label); 3561: sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number); 3562: body_end_attribute (label); 3563: } 1.1 root 3564: } 3565: } 3566: 3567: static void 3568: output_subroutine_type_die (arg) 3569: register void *arg; 3570: { 3571: register tree type = arg; 3572: register tree return_type = TREE_TYPE (type); 3573: 3574: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine_type); 3575: sibling_attribute (); 3576: dienum_push (); 3577: equate_type_number_to_die_number (type); 3578: prototyped_attribute (type); 3579: member_attribute (TYPE_CONTEXT (type)); 3580: type_attribute (return_type, 0, 0); 3581: } 3582: 3583: static void 3584: output_typedef_die (arg) 3585: register void *arg; 3586: { 3587: register tree decl = arg; 1.1.1.4 root 3588: register tree origin = decl_ultimate_origin (decl); 1.1 root 3589: 3590: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_typedef); 3591: sibling_attribute (); 1.1.1.4 root 3592: if (origin != NULL) 3593: abstract_origin_attribute (origin); 3594: else 3595: { 3596: name_and_src_coords_attributes (decl); 3597: member_attribute (DECL_CONTEXT (decl)); 3598: type_attribute (TREE_TYPE (decl), 3599: TREE_READONLY (decl), TREE_THIS_VOLATILE (decl)); 3600: } 3601: if (DECL_ABSTRACT (decl)) 3602: equate_decl_number_to_die_number (decl); 1.1 root 3603: } 3604: 3605: static void 3606: output_union_type_die (arg) 3607: register void *arg; 3608: { 3609: register tree type = arg; 3610: 3611: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type); 3612: sibling_attribute (); 3613: equate_type_number_to_die_number (type); 3614: name_attribute (type_tag (type)); 3615: member_attribute (TYPE_CONTEXT (type)); 3616: 3617: /* If this type has been completed, then give it a byte_size attribute 3618: and prepare to give a list of members. Otherwise, don't do either of 3619: these things. In the latter case, we will not be generating a list 3620: of members (since we don't have any idea what they might be for an 3621: incomplete type). */ 3622: 3623: if (TYPE_SIZE (type)) 3624: { 3625: dienum_push (); 3626: byte_size_attribute (type); 3627: } 3628: } 3629: 3630: /* Generate a special type of DIE used as a stand-in for a trailing ellipsis 3631: at the end of an (ANSI prototyped) formal parameters list. */ 3632: 3633: static void 3634: output_unspecified_parameters_die (arg) 3635: register void *arg; 3636: { 3637: register tree decl_or_type = arg; 3638: 3639: ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_unspecified_parameters); 3640: sibling_attribute (); 3641: 3642: /* This kludge is here only for the sake of being compatible with what 3643: the USL CI5 C compiler does. The specification of Dwarf Version 1 3644: doesn't say that TAG_unspecified_parameters DIEs should contain any 3645: attributes other than the AT_sibling attribute, but they are certainly 3646: allowed to contain additional attributes, and the CI5 compiler 3647: generates AT_name, AT_fund_type, and AT_location attributes within 3648: TAG_unspecified_parameters DIEs which appear in the child lists for 3649: DIEs representing function definitions, so we do likewise here. */ 3650: 3651: if (TREE_CODE (decl_or_type) == FUNCTION_DECL && DECL_INITIAL (decl_or_type)) 3652: { 3653: name_attribute ("..."); 3654: fund_type_attribute (FT_pointer); 3655: /* location_attribute (?); */ 3656: } 3657: } 3658: 3659: static void 3660: output_padded_null_die (arg) 3661: register void *arg; 3662: { 3663: ASM_OUTPUT_ALIGN (asm_out_file, 2); /* 2**2 == 4 */ 3664: } 3665: 3666: /*************************** end of DIEs *********************************/ 3667: 3668: /* Generate some type of DIE. This routine generates the generic outer 3669: wrapper stuff which goes around all types of DIE's (regardless of their 3670: TAGs. All forms of DIEs start with a DIE-specific label, followed by a 3671: DIE-length word, followed by the guts of the DIE itself. After the guts 3672: of the DIE, there must always be a terminator label for the DIE. */ 3673: 3674: static void 3675: output_die (die_specific_output_function, param) 3676: register void (*die_specific_output_function)(); 3677: register void *param; 3678: { 3679: char begin_label[MAX_ARTIFICIAL_LABEL_BYTES]; 3680: char end_label[MAX_ARTIFICIAL_LABEL_BYTES]; 3681: 3682: current_dienum = NEXT_DIE_NUM; 3683: NEXT_DIE_NUM = next_unused_dienum; 3684: 3685: sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum); 3686: sprintf (end_label, DIE_END_LABEL_FMT, current_dienum); 3687: 3688: /* Write a label which will act as the name for the start of this DIE. */ 3689: 3690: ASM_OUTPUT_LABEL (asm_out_file, begin_label); 3691: 3692: /* Write the DIE-length word. */ 3693: 3694: ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label); 3695: 3696: /* Fill in the guts of the DIE. */ 3697: 3698: next_unused_dienum++; 3699: die_specific_output_function (param); 3700: 3701: /* Write a label which will act as the name for the end of this DIE. */ 3702: 3703: ASM_OUTPUT_LABEL (asm_out_file, end_label); 3704: } 3705: 3706: static void 3707: end_sibling_chain () 3708: { 3709: char begin_label[MAX_ARTIFICIAL_LABEL_BYTES]; 3710: 3711: current_dienum = NEXT_DIE_NUM; 3712: NEXT_DIE_NUM = next_unused_dienum; 3713: 3714: sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum); 3715: 3716: /* Write a label which will act as the name for the start of this DIE. */ 3717: 3718: ASM_OUTPUT_LABEL (asm_out_file, begin_label); 3719: 3720: /* Write the DIE-length word. */ 3721: 3722: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 4); 3723: 3724: dienum_pop (); 3725: } 3726: 3727: /* Generate a list of nameless TAG_formal_parameter DIEs (and perhaps a 3728: TAG_unspecified_parameters DIE) to represent the types of the formal 3729: parameters as specified in some function type specification (except 3730: for those which appear as part of a function *definition*). 3731: 3732: Note that we must be careful here to output all of the parameter DIEs 3733: *before* we output any DIEs needed to represent the types of the formal 3734: parameters. This keeps svr4 SDB happy because it (incorrectly) thinks 3735: that the first non-parameter DIE it sees ends the formal parameter list. 3736: */ 3737: 3738: static void 3739: output_formal_types (function_or_method_type) 3740: register tree function_or_method_type; 3741: { 3742: register tree link; 1.1.1.4 root 3743: register tree formal_type = NULL; 1.1 root 3744: register tree first_parm_type = TYPE_ARG_TYPES (function_or_method_type); 3745: 3746: /* In the case where we are generating a formal types list for a C++ 3747: non-static member function type, skip over the first thing on the 3748: TYPE_ARG_TYPES list because it only represents the type of the 3749: hidden `this pointer'. The debugger should be able to figure 3750: out (without being explicitly told) that this non-static member 3751: function type takes a `this pointer' and should be able to figure 3752: what the type of that hidden parameter is from the AT_member 3753: attribute of the parent TAG_subroutine_type DIE. */ 3754: 3755: if (TREE_CODE (function_or_method_type) == METHOD_TYPE) 3756: first_parm_type = TREE_CHAIN (first_parm_type); 3757: 3758: /* Make our first pass over the list of formal parameter types and output 3759: a TAG_formal_parameter DIE for each one. */ 3760: 3761: for (link = first_parm_type; link; link = TREE_CHAIN (link)) 3762: { 3763: formal_type = TREE_VALUE (link); 3764: if (formal_type == void_type_node) 3765: break; 3766: 3767: /* Output a (nameless) DIE to represent the formal parameter itself. */ 3768: 3769: output_die (output_formal_parameter_die, formal_type); 3770: } 3771: 3772: /* If this function type has an ellipsis, add a TAG_unspecified_parameters 3773: DIE to the end of the parameter list. */ 3774: 3775: if (formal_type != void_type_node) 3776: output_die (output_unspecified_parameters_die, function_or_method_type); 3777: 3778: /* Make our second (and final) pass over the list of formal parameter types 3779: and output DIEs to represent those types (as necessary). */ 3780: 3781: for (link = TYPE_ARG_TYPES (function_or_method_type); 3782: link; 3783: link = TREE_CHAIN (link)) 3784: { 3785: formal_type = TREE_VALUE (link); 3786: if (formal_type == void_type_node) 3787: break; 3788: 3789: output_type (formal_type, function_or_method_type); 3790: } 3791: } 3792: 3793: /* Remember a type in the pending_types_list. */ 3794: 3795: static void 3796: pend_type (type) 3797: register tree type; 3798: { 3799: if (pending_types == pending_types_allocated) 3800: { 3801: pending_types_allocated += PENDING_TYPES_INCREMENT; 3802: pending_types_list 3803: = (tree *) xrealloc (pending_types_list, 3804: sizeof (tree) * pending_types_allocated); 3805: } 3806: pending_types_list[pending_types++] = type; 3807: 3808: /* Mark the pending type as having been output already (even though 3809: it hasn't been). This prevents the type from being added to the 3810: pending_types_list more than once. */ 3811: 3812: TREE_ASM_WRITTEN (type) = 1; 3813: } 3814: 3815: /* Return non-zero if it is legitimate to output DIEs to represent a 3816: given type while we are generating the list of child DIEs for some 1.1.1.4 root 3817: DIE (e.g. a function or lexical block DIE) associated with a given scope. 1.1 root 3818: 1.1.1.4 root 3819: See the comments within the function for a description of when it is 3820: considered legitimate to output DIEs for various kinds of types. 1.1 root 3821: 3822: Note that TYPE_CONTEXT(type) may be NULL (to indicate global scope) 3823: or it may point to a BLOCK node (for types local to a block), or to a 3824: FUNCTION_DECL node (for types local to the heading of some function 3825: definition), or to a FUNCTION_TYPE node (for types local to the 3826: prototyped parameter list of a function type specification), or to a 1.1.1.5 ! root 3827: RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node ! 3828: (in the case of C++ nested types). 1.1 root 3829: 3830: The `scope' parameter should likewise be NULL or should point to a 3831: BLOCK node, a FUNCTION_DECL node, a FUNCTION_TYPE node, a RECORD_TYPE 1.1.1.5 ! root 3832: node, a UNION_TYPE node, or a QUAL_UNION_TYPE node. 1.1 root 3833: 3834: This function is used only for deciding when to "pend" and when to 3835: "un-pend" types to/from the pending_types_list. 3836: 3837: Note that we sometimes make use of this "type pending" feature in a 3838: rather twisted way to temporarily delay the production of DIEs for the 3839: types of formal parameters. (We do this just to make svr4 SDB happy.) 3840: It order to delay the production of DIEs representing types of formal 3841: parameters, callers of this function supply `fake_containing_scope' as 3842: the `scope' parameter to this function. Given that fake_containing_scope 1.1.1.4 root 3843: is a tagged type which is *not* the containing scope for *any* other type, 3844: the desired effect is achieved, i.e. output of DIEs representing types 3845: is temporarily suspended, and any type DIEs which would have otherwise 3846: been output are instead placed onto the pending_types_list. Later on, 3847: we force these (temporarily pended) types to be output simply by calling 1.1 root 3848: `output_pending_types_for_scope' with an actual argument equal to the 3849: true scope of the types we temporarily pended. 3850: */ 3851: 1.1.1.4 root 3852: inline int 1.1 root 3853: type_ok_for_scope (type, scope) 3854: register tree type; 3855: register tree scope; 3856: { 1.1.1.4 root 3857: /* Tagged types (i.e. struct, union, and enum types) must always be 3858: output only in the scopes where they actually belong (or else the 3859: scoping of their own tag names and the scoping of their member 3860: names will be incorrect). Non-tagged-types on the other hand can 3861: generally be output anywhere, except that svr4 SDB really doesn't 3862: want to see them nested within struct or union types, so here we 3863: say it is always OK to immediately output any such a (non-tagged) 3864: type, so long as we are not within such a context. Note that the 3865: only kinds of non-tagged types which we will be dealing with here 3866: (for C and C++ anyway) will be array types and function types. */ 3867: 3868: return is_tagged_type (type) 3869: ? (TYPE_CONTEXT (type) == scope) 3870: : (scope == NULL_TREE || ! is_tagged_type (scope)); 1.1 root 3871: } 3872: 3873: /* Output any pending types (from the pending_types list) which we can output 1.1.1.4 root 3874: now (taking into account the scope that we are working on now). 1.1 root 3875: 3876: For each type output, remove the given type from the pending_types_list 3877: *before* we try to output it. 3878: 3879: Note that we have to process the list in beginning-to-end order, 3880: because the call made here to output_type may cause yet more types 3881: to be added to the end of the list, and we may have to output some 3882: of them too. 3883: */ 3884: 3885: static void 3886: output_pending_types_for_scope (containing_scope) 3887: register tree containing_scope; 3888: { 3889: register unsigned i; 3890: 3891: for (i = 0; i < pending_types; ) 3892: { 3893: register tree type = pending_types_list[i]; 3894: 3895: if (type_ok_for_scope (type, containing_scope)) 3896: { 3897: register tree *mover; 3898: register tree *limit; 3899: 3900: pending_types--; 3901: limit = &pending_types_list[pending_types]; 3902: for (mover = &pending_types_list[i]; mover < limit; mover++) 3903: *mover = *(mover+1); 3904: 3905: /* Un-mark the type as having been output already (because it 3906: hasn't been, really). Then call output_type to generate a 3907: Dwarf representation of it. */ 3908: 3909: TREE_ASM_WRITTEN (type) = 0; 3910: output_type (type, containing_scope); 3911: 3912: /* Don't increment the loop counter in this case because we 3913: have shifted all of the subsequent pending types down one 3914: element in the pending_types_list array. */ 3915: } 3916: else 3917: i++; 3918: } 3919: } 3920: 3921: static void 3922: output_type (type, containing_scope) 3923: register tree type; 3924: register tree containing_scope; 3925: { 3926: if (type == 0 || type == error_mark_node) 3927: return; 3928: 3929: /* We are going to output a DIE to represent the unqualified version of 3930: of this type (i.e. without any const or volatile qualifiers) so get 3931: the main variant (i.e. the unqualified version) of this type now. */ 3932: 1.1.1.5 ! root 3933: type = type_main_variant (type); 1.1 root 3934: 3935: if (TREE_ASM_WRITTEN (type)) 3936: return; 3937: 3938: /* Don't generate any DIEs for this type now unless it is OK to do so 3939: (based upon what `type_ok_for_scope' tells us). */ 3940: 3941: if (! type_ok_for_scope (type, containing_scope)) 3942: { 3943: pend_type (type); 3944: return; 3945: } 3946: 3947: switch (TREE_CODE (type)) 3948: { 3949: case ERROR_MARK: 3950: break; 3951: 3952: case POINTER_TYPE: 3953: case REFERENCE_TYPE: 3954: /* For these types, all that is required is that we output a DIE 1.1.1.4 root 3955: (or a set of DIEs) to represent the "basis" type. */ 1.1 root 3956: output_type (TREE_TYPE (type), containing_scope); 3957: break; 3958: 3959: case OFFSET_TYPE: 3960: /* This code is used for C++ pointer-to-data-member types. */ 3961: /* Output a description of the relevant class type. */ 3962: output_type (TYPE_OFFSET_BASETYPE (type), containing_scope); 3963: /* Output a description of the type of the object pointed to. */ 3964: output_type (TREE_TYPE (type), containing_scope); 3965: /* Now output a DIE to represent this pointer-to-data-member type 3966: itself. */ 3967: output_die (output_ptr_to_mbr_type_die, type); 3968: break; 3969: 3970: case SET_TYPE: 3971: output_type (TREE_TYPE (type), containing_scope); 3972: output_die (output_set_type_die, type); 3973: break; 3974: 3975: case FILE_TYPE: 3976: output_type (TREE_TYPE (type), containing_scope); 1.1.1.3 root 3977: abort (); /* No way to represent these in Dwarf yet! */ 1.1 root 3978: break; 3979: 3980: case STRING_TYPE: 3981: output_type (TREE_TYPE (type), containing_scope); 3982: output_die (output_string_type_die, type); 3983: break; 3984: 3985: case FUNCTION_TYPE: 3986: /* Force out return type (in case it wasn't forced out already). */ 3987: output_type (TREE_TYPE (type), containing_scope); 3988: output_die (output_subroutine_type_die, type); 3989: output_formal_types (type); 3990: end_sibling_chain (); 3991: break; 3992: 3993: case METHOD_TYPE: 3994: /* Force out return type (in case it wasn't forced out already). */ 3995: output_type (TREE_TYPE (type), containing_scope); 3996: output_die (output_subroutine_type_die, type); 3997: output_formal_types (type); 3998: end_sibling_chain (); 3999: break; 4000: 4001: case ARRAY_TYPE: 4002: { 4003: register tree element_type; 4004: 4005: element_type = TREE_TYPE (type); 4006: while (TREE_CODE (element_type) == ARRAY_TYPE) 4007: element_type = TREE_TYPE (element_type); 4008: 4009: output_type (element_type, containing_scope); 4010: output_die (output_array_type_die, type); 4011: } 4012: break; 4013: 4014: case ENUMERAL_TYPE: 4015: case RECORD_TYPE: 4016: case UNION_TYPE: 1.1.1.5 ! root 4017: case QUAL_UNION_TYPE: 1.1 root 4018: 4019: /* For a non-file-scope tagged type, we can always go ahead and 4020: output a Dwarf description of this type right now, even if 4021: the type in question is still incomplete, because if this 4022: local type *was* ever completed anywhere within its scope, 4023: that complete definition would already have been attached to 1.1.1.5 ! root 4024: this RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE or ENUMERAL_TYPE ! 4025: node by the time we reach this point. That's true because of the ! 4026: way the front-end does its processing of file-scope declarations (of 1.1 root 4027: functions and class types) within which other types might be 4028: nested. The C and C++ front-ends always gobble up such "local 4029: scope" things en-mass before they try to output *any* debugging 4030: information for any of the stuff contained inside them and thus, 4031: we get the benefit here of what is (in effect) a pre-resolution 4032: of forward references to tagged types in local scopes. 4033: 4034: Note however that for file-scope tagged types we cannot assume 4035: that such pre-resolution of forward references has taken place. 4036: A given file-scope tagged type may appear to be incomplete when 4037: we reach this point, but it may yet be given a full definition 4038: (at file-scope) later on during compilation. In order to avoid 4039: generating a premature (and possibly incorrect) set of Dwarf 4040: DIEs for such (as yet incomplete) file-scope tagged types, we 4041: generate nothing at all for as-yet incomplete file-scope tagged 4042: types here unless we are making our special "finalization" pass 4043: for file-scope things at the very end of compilation. At that 4044: time, we will certainly know as much about each file-scope tagged 4045: type as we are ever going to know, so at that point in time, we 4046: can safely generate correct Dwarf descriptions for these file- 4047: scope tagged types. 4048: */ 4049: 4050: if (TYPE_SIZE (type) == 0 && TYPE_CONTEXT (type) == NULL && !finalizing) 4051: return; /* EARLY EXIT! Avoid setting TREE_ASM_WRITTEN. */ 4052: 4053: /* Prevent infinite recursion in cases where the type of some 4054: member of this type is expressed in terms of this type itself. */ 4055: 4056: TREE_ASM_WRITTEN (type) = 1; 4057: 4058: /* Output a DIE to represent the tagged type itself. */ 4059: 4060: switch (TREE_CODE (type)) 4061: { 4062: case ENUMERAL_TYPE: 4063: output_die (output_enumeration_type_die, type); 4064: return; /* a special case -- nothing left to do so just return */ 4065: 4066: case RECORD_TYPE: 4067: output_die (output_structure_type_die, type); 4068: break; 4069: 4070: case UNION_TYPE: 1.1.1.5 ! root 4071: case QUAL_UNION_TYPE: 1.1 root 4072: output_die (output_union_type_die, type); 4073: break; 1.1.1.4 root 4074: 4075: default: 4076: abort (); /* Should never happen. */ 1.1 root 4077: } 4078: 4079: /* If this is not an incomplete type, output descriptions of 4080: each of its members. 4081: 4082: Note that as we output the DIEs necessary to represent the 4083: members of this record or union type, we will also be trying 4084: to output DIEs to represent the *types* of those members. 4085: However the `output_type' function (above) will specifically 4086: avoid generating type DIEs for member types *within* the list 4087: of member DIEs for this (containing) type execpt for those 4088: types (of members) which are explicitly marked as also being 4089: members of this (containing) type themselves. The g++ front- 4090: end can force any given type to be treated as a member of some 4091: other (containing) type by setting the TYPE_CONTEXT of the 4092: given (member) type to point to the TREE node representing the 4093: appropriate (containing) type. 4094: */ 4095: 4096: if (TYPE_SIZE (type)) 4097: { 1.1.1.3 root 4098: { 4099: register tree normal_member; 4100: 4101: /* First output info about the data members and type members. */ 1.1 root 4102: 1.1.1.3 root 4103: for (normal_member = TYPE_FIELDS (type); 4104: normal_member; 4105: normal_member = TREE_CHAIN (normal_member)) 4106: output_decl (normal_member, type); 4107: } 4108: 4109: { 4110: register tree vec_base; 1.1 root 4111: 1.1.1.3 root 4112: /* Now output info about the function members (if any). */ 4113: 4114: vec_base = TYPE_METHODS (type); 4115: if (vec_base) 4116: { 4117: register tree first_func_member = TREE_VEC_ELT (vec_base, 0); 4118: register tree func_member; 4119: 4120: /* This isn't documented, but the first element of the 4121: vector of member functions can be NULL in cases where 4122: the class type in question didn't have either a 4123: constructor or a destructor declared for it. We have 4124: to make allowances for that here. */ 4125: 4126: if (first_func_member == NULL) 4127: first_func_member = TREE_VEC_ELT (vec_base, 1); 4128: 4129: for (func_member = first_func_member; 4130: func_member; 4131: func_member = TREE_CHAIN (func_member)) 4132: output_decl (func_member, type); 4133: } 4134: } 1.1 root 4135: 1.1.1.5 ! root 4136: /* RECORD_TYPEs, UNION_TYPEs, and QUAL_UNION_TYPEs are themselves ! 4137: scopes (at least in C++) so we must now output any nested ! 4138: pending types which are local just to this type. */ 1.1.1.4 root 4139: 4140: output_pending_types_for_scope (type); 4141: 1.1 root 4142: end_sibling_chain (); /* Terminate member chain. */ 4143: } 4144: 4145: break; 4146: 4147: case VOID_TYPE: 4148: case INTEGER_TYPE: 4149: case REAL_TYPE: 4150: case COMPLEX_TYPE: 4151: case BOOLEAN_TYPE: 4152: case CHAR_TYPE: 4153: break; /* No DIEs needed for fundamental types. */ 4154: 4155: case LANG_TYPE: /* No Dwarf representation currently defined. */ 4156: break; 4157: 4158: default: 4159: abort (); 4160: } 4161: 4162: TREE_ASM_WRITTEN (type) = 1; 4163: } 1.1.1.4 root 4164: 4165: static void 4166: output_tagged_type_instantiation (type) 4167: register tree type; 4168: { 4169: if (type == 0 || type == error_mark_node) 4170: return; 4171: 4172: /* We are going to output a DIE to represent the unqualified version of 4173: of this type (i.e. without any const or volatile qualifiers) so make 4174: sure that we have the main variant (i.e. the unqualified version) of 4175: this type now. */ 4176: 1.1.1.5 ! root 4177: assert (type == type_main_variant (type)); 1.1.1.4 root 4178: 4179: assert (TREE_ASM_WRITTEN (type)); 4180: 4181: switch (TREE_CODE (type)) 4182: { 4183: case ERROR_MARK: 4184: break; 4185: 4186: case ENUMERAL_TYPE: 4187: output_die (output_inlined_enumeration_type_die, type); 4188: break; 4189: 4190: case RECORD_TYPE: 4191: output_die (output_inlined_structure_type_die, type); 4192: break; 4193: 4194: case UNION_TYPE: 1.1.1.5 ! root 4195: case QUAL_UNION_TYPE: 1.1.1.4 root 4196: output_die (output_inlined_union_type_die, type); 4197: break; 4198: 4199: default: 4200: abort (); /* Should never happen. */ 4201: } 4202: } 1.1 root 4203: 4204: /* Output a TAG_lexical_block DIE followed by DIEs to represent all of 4205: the things which are local to the given block. */ 4206: 4207: static void 4208: output_block (stmt) 4209: register tree stmt; 4210: { 1.1.1.4 root 4211: register int must_output_die = 0; 4212: register tree origin; 4213: register enum tree_code origin_code; 1.1 root 4214: 4215: /* Ignore blocks never really used to make RTL. */ 4216: 4217: if (! stmt || ! TREE_USED (stmt)) 4218: return; 4219: 1.1.1.4 root 4220: /* Determine the "ultimate origin" of this block. This block may be an 4221: inlined instance of an inlined instance of inline function, so we 4222: have to trace all of the way back through the origin chain to find 4223: out what sort of node actually served as the original seed for the 4224: creation of the current block. */ 4225: 4226: origin = block_ultimate_origin (stmt); 4227: origin_code = (origin != NULL) ? TREE_CODE (origin) : ERROR_MARK; 4228: 4229: /* Determine if we need to output any Dwarf DIEs at all to represent this 4230: block. */ 4231: 4232: if (origin_code == FUNCTION_DECL) 4233: /* The outer scopes for inlinings *must* always be represented. We 4234: generate TAG_inlined_subroutine DIEs for them. (See below.) */ 4235: must_output_die = 1; 1.1 root 4236: else 1.1.1.4 root 4237: { 4238: /* In the case where the current block represents an inlining of the 4239: "body block" of an inline function, we must *NOT* output any DIE 4240: for this block because we have already output a DIE to represent 4241: the whole inlined function scope and the "body block" of any 4242: function doesn't really represent a different scope according to 4243: ANSI C rules. So we check here to make sure that this block does 4244: not represent a "body block inlining" before trying to set the 4245: `must_output_die' flag. */ 4246: 4247: if (origin == NULL || ! is_body_block (origin)) 4248: { 4249: /* Determine if this block directly contains any "significant" 4250: local declarations which we will need to output DIEs for. */ 1.1 root 4251: 1.1.1.4 root 4252: if (debug_info_level > DINFO_LEVEL_TERSE) 4253: /* We are not in terse mode so *any* local declaration counts 4254: as being a "significant" one. */ 4255: must_output_die = (BLOCK_VARS (stmt) != NULL); 4256: else 1.1 root 4257: { 1.1.1.4 root 4258: register tree decl; 4259: 4260: /* We are in terse mode, so only local (nested) function 4261: definitions count as "significant" local declarations. */ 4262: 4263: for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl)) 4264: if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl)) 4265: { 4266: must_output_die = 1; 4267: break; 4268: } 1.1 root 4269: } 1.1.1.4 root 4270: } 4271: } 1.1 root 4272: 4273: /* It would be a waste of space to generate a Dwarf TAG_lexical_block 4274: DIE for any block which contains no significant local declarations 4275: at all. Rather, in such cases we just call `output_decls_for_scope' 4276: so that any needed Dwarf info for any sub-blocks will get properly 4277: generated. Note that in terse mode, our definition of what constitutes 4278: a "significant" local declaration gets restricted to include only 4279: inlined function instances and local (nested) function definitions. */ 4280: 1.1.1.4 root 4281: if (must_output_die) 1.1 root 4282: { 1.1.1.4 root 4283: output_die ((origin_code == FUNCTION_DECL) 4284: ? output_inlined_subroutine_die 4285: : output_lexical_block_die, 1.1 root 4286: stmt); 4287: output_decls_for_scope (stmt); 4288: end_sibling_chain (); 4289: } 4290: else 4291: output_decls_for_scope (stmt); 4292: } 4293: 4294: /* Output all of the decls declared within a given scope (also called 4295: a `binding contour') and (recursively) all of it's sub-blocks. */ 4296: 4297: static void 4298: output_decls_for_scope (stmt) 4299: register tree stmt; 4300: { 4301: /* Ignore blocks never really used to make RTL. */ 4302: 4303: if (! stmt || ! TREE_USED (stmt)) 4304: return; 4305: 1.1.1.4 root 4306: if (! BLOCK_ABSTRACT (stmt)) 4307: next_block_number++; 1.1 root 4308: 4309: /* Output the DIEs to represent all of the data objects, functions, 4310: typedefs, and tagged types declared directly within this block 4311: but not within any nested sub-blocks. */ 4312: 4313: { 4314: register tree decl; 4315: 4316: for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl)) 4317: output_decl (decl, stmt); 4318: } 4319: 4320: output_pending_types_for_scope (stmt); 4321: 4322: /* Output the DIEs to represent all sub-blocks (and the items declared 4323: therein) of this block. */ 4324: 4325: { 4326: register tree subblocks; 4327: 4328: for (subblocks = BLOCK_SUBBLOCKS (stmt); 4329: subblocks; 4330: subblocks = BLOCK_CHAIN (subblocks)) 4331: output_block (subblocks); 4332: } 4333: } 4334: 4335: /* Output Dwarf .debug information for a decl described by DECL. */ 4336: 4337: static void 4338: output_decl (decl, containing_scope) 4339: register tree decl; 4340: register tree containing_scope; 4341: { 1.1.1.4 root 4342: /* Make a note of the decl node we are going to be working on. We may 4343: need to give the user the source coordinates of where it appeared in 4344: case we notice (later on) that something about it looks screwy. */ 4345: 4346: dwarf_last_decl = decl; 4347: 1.1.1.3 root 4348: if (TREE_CODE (decl) == ERROR_MARK) 4349: return; 4350: 4351: /* If this ..._DECL node is marked to be ignored, then ignore it. 4352: But don't ignore a function definition, since that would screw 4353: up our count of blocks, and that it turn will completely screw up the 4354: the labels we will reference in subsequent AT_low_pc and AT_high_pc 4355: attributes (for subsequent blocks). */ 4356: 4357: if (DECL_IGNORED_P (decl) && TREE_CODE (decl) != FUNCTION_DECL) 4358: return; 4359: 1.1 root 4360: switch (TREE_CODE (decl)) 4361: { 4362: case CONST_DECL: 4363: /* The individual enumerators of an enum type get output when we 4364: output the Dwarf representation of the relevant enum type itself. */ 4365: break; 4366: 4367: case FUNCTION_DECL: 4368: /* If we are in terse mode, don't output any DIEs to represent 1.1.1.5 ! root 4369: mere function declarations. Also, if we are conforming 1.1.1.3 root 4370: to the DWARF version 1 specification, don't output DIEs for 1.1.1.5 ! root 4371: mere function declarations. */ 1.1 root 4372: 1.1.1.5 ! root 4373: if (DECL_INITIAL (decl) == NULL_TREE) 1.1.1.3 root 4374: #if (DWARF_VERSION > 1) 4375: if (debug_info_level <= DINFO_LEVEL_TERSE) 4376: #endif 4377: break; 1.1 root 4378: 4379: /* Before we describe the FUNCTION_DECL itself, make sure that we 4380: have described its return type. */ 4381: 4382: output_type (TREE_TYPE (TREE_TYPE (decl)), containing_scope); 4383: 4384: /* If the following DIE will represent a function definition for a 4385: function with "extern" linkage, output a special "pubnames" DIE 4386: label just ahead of the actual DIE. A reference to this label 4387: was already generated in the .debug_pubnames section sub-entry 4388: for this function definition. */ 4389: 4390: if (TREE_PUBLIC (decl)) 4391: { 4392: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 4393: 4394: sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++); 4395: ASM_OUTPUT_LABEL (asm_out_file, label); 4396: } 4397: 4398: /* Now output a DIE to represent the function itself. */ 4399: 1.1.1.4 root 4400: output_die (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl) 1.1 root 4401: ? output_global_subroutine_die 4402: : output_local_subroutine_die, 4403: decl); 4404: 4405: /* Now output descriptions of the arguments for this function. 4406: This gets (unnecessarily?) complex because of the fact that 4407: the DECL_ARGUMENT list for a FUNCTION_DECL doesn't indicate 4408: cases where there was a trailing `...' at the end of the formal 4409: parameter list. In order to find out if there was a trailing 4410: ellipsis or not, we must instead look at the type associated 4411: with the FUNCTION_DECL. This will be a node of type FUNCTION_TYPE. 4412: If the chain of type nodes hanging off of this FUNCTION_TYPE node 4413: ends with a void_type_node then there should *not* be an ellipsis 4414: at the end. */ 4415: 1.1.1.5 ! root 4416: /* In the case where we are describing a mere function declaration, all 1.1 root 4417: we need to do here (and all we *can* do here) is to describe 4418: the *types* of its formal parameters. */ 4419: 1.1.1.5 ! root 4420: if (DECL_INITIAL (decl) == NULL_TREE) 1.1 root 4421: output_formal_types (TREE_TYPE (decl)); 4422: else 4423: { 4424: register tree arg_decls = DECL_ARGUMENTS (decl); 4425: 4426: { 4427: register tree last_arg; 4428: 4429: last_arg = (arg_decls && TREE_CODE (arg_decls) != ERROR_MARK) 4430: ? tree_last (arg_decls) 4431: : NULL; 4432: 4433: /* Generate DIEs to represent all known formal parameters, but 4434: don't do it if this looks like a varargs function. A given 4435: function is considered to be a varargs function if (and only 4436: if) its last named argument is named `__builtin_va_alist'. */ 4437: 4438: if (! last_arg 4439: || ! DECL_NAME (last_arg) 4440: || strcmp (IDENTIFIER_POINTER (DECL_NAME (last_arg)), 4441: "__builtin_va_alist")) 4442: { 4443: register tree parm; 4444: 4445: /* WARNING! Kludge zone ahead! Here we have a special 1.1.1.2 root 4446: hack for svr4 SDB compatibility. Instead of passing the 1.1 root 4447: current FUNCTION_DECL node as the second parameter (i.e. 4448: the `containing_scope' parameter) to `output_decl' (as 4449: we ought to) we instead pass a pointer to our own private 4450: fake_containing_scope node. That node is a RECORD_TYPE 4451: node which NO OTHER TYPE may ever actually be a member of. 4452: 4453: This pointer will ultimately get passed into `output_type' 4454: as its `containing_scope' parameter. `Output_type' will 4455: then perform its part in the hack... i.e. it will pend 4456: the type of the formal parameter onto the pending_types 4457: list. Later on, when we are done generating the whole 4458: sequence of formal parameter DIEs for this function 4459: definition, we will un-pend all previously pended types 4460: of formal parameters for this function definition. 4461: 4462: This whole kludge prevents any type DIEs from being 4463: mixed in with the formal parameter DIEs. That's good 4464: because svr4 SDB believes that the list of formal 4465: parameter DIEs for a function ends wherever the first 4466: non-formal-parameter DIE appears. Thus, we have to 4467: keep the formal parameter DIEs segregated. They must 4468: all appear (consecutively) at the start of the list of 4469: children for the DIE representing the function definition. 4470: Then (and only then) may we output any additional DIEs 4471: needed to represent the types of these formal parameters. 4472: */ 4473: 4474: for (parm = arg_decls; parm; parm = TREE_CHAIN (parm)) 4475: if (TREE_CODE (parm) == PARM_DECL) 4476: output_decl (parm, fake_containing_scope); 4477: 4478: /* Now that we have finished generating all of the DIEs to 4479: represent the formal parameters themselves, force out 4480: any DIEs needed to represent their types. We do this 4481: simply by un-pending all previously pended types which 4482: can legitimately go into the chain of children DIEs for 4483: the current FUNCTION_DECL. */ 4484: 4485: output_pending_types_for_scope (decl); 4486: } 4487: } 4488: 4489: /* Now try to decide if we should put an ellipsis at the end. */ 4490: 4491: { 4492: register int has_ellipsis = TRUE; /* default assumption */ 4493: register tree fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (decl)); 4494: 4495: if (fn_arg_types) 4496: { 4497: /* This function declaration/definition was prototyped. */ 4498: 4499: /* If the list of formal argument types ends with a 4500: void_type_node, then the formals list did *not* end 4501: with an ellipsis. */ 4502: 4503: if (TREE_VALUE (tree_last (fn_arg_types)) == void_type_node) 4504: has_ellipsis = FALSE; 4505: } 4506: else 4507: { 4508: /* This function declaration/definition was not prototyped. */ 4509: 4510: /* Note that all non-prototyped function *declarations* are 4511: assumed to represent varargs functions (until proven 4512: otherwise). */ 4513: 4514: if (DECL_INITIAL (decl)) /* if this is a func definition */ 4515: { 4516: if (!arg_decls) 4517: has_ellipsis = FALSE; /* no args == (void) */ 4518: else 4519: { 4520: /* For a non-prototyped function definition which 4521: declares one or more formal parameters, if the name 4522: of the first formal parameter is *not* 4523: __builtin_va_alist then we must assume that this 4524: is *not* a varargs function. */ 4525: 4526: if (DECL_NAME (arg_decls) 4527: && strcmp (IDENTIFIER_POINTER (DECL_NAME (arg_decls)), 4528: "__builtin_va_alist")) 4529: has_ellipsis = FALSE; 4530: } 4531: } 4532: } 4533: 4534: if (has_ellipsis) 4535: output_die (output_unspecified_parameters_die, decl); 4536: } 4537: } 4538: 4539: /* Output Dwarf info for all of the stuff within the body of the 4540: function (if it has one - it may be just a declaration). */ 4541: 4542: { 4543: register tree outer_scope = DECL_INITIAL (decl); 4544: 4545: if (outer_scope && TREE_CODE (outer_scope) != ERROR_MARK) 4546: { 4547: /* Note that here, `outer_scope' is a pointer to the outermost 1.1.1.4 root 4548: BLOCK node created to represent a function. 1.1 root 4549: This outermost BLOCK actually represents the outermost 4550: binding contour for the function, i.e. the contour in which 1.1.1.4 root 4551: the function's formal parameters and labels get declared. 4552: 4553: Curiously, it appears that the front end doesn't actually 4554: put the PARM_DECL nodes for the current function onto the 4555: BLOCK_VARS list for this outer scope. (They are strung 4556: off of the DECL_ARGUMENTS list for the function instead.) 4557: The BLOCK_VARS list for the `outer_scope' does provide us 4558: with a list of the LABEL_DECL nodes for the function however, 4559: and we output DWARF info for those here. 4560: 4561: Just within the `outer_scope' there will be another BLOCK 4562: node representing the function's outermost pair of curly 4563: braces. We musn't generate a lexical_block DIE for this 4564: outermost pair of curly braces because that is not really an 1.1 root 4565: independent scope according to ANSI C rules. Rather, it is 1.1.1.4 root 4566: the same scope in which the parameters were declared. */ 1.1 root 4567: 4568: { 4569: register tree label; 4570: 4571: for (label = BLOCK_VARS (outer_scope); 4572: label; 4573: label = TREE_CHAIN (label)) 4574: output_decl (label, outer_scope); 4575: } 4576: 1.1.1.4 root 4577: /* Note here that `BLOCK_SUBBLOCKS (outer_scope)' points to a 4578: list of BLOCK nodes which is always only one element long. 4579: That one element represents the outermost pair of curley 4580: braces for the function body. */ 4581: 1.1 root 4582: output_decls_for_scope (BLOCK_SUBBLOCKS (outer_scope)); 4583: 4584: /* Finally, force out any pending types which are local to the 4585: outermost block of this function definition. These will 4586: all have a TYPE_CONTEXT which points to the FUNCTION_DECL 4587: node itself. */ 4588: 4589: output_pending_types_for_scope (decl); 4590: } 4591: } 4592: 4593: /* Generate a terminator for the list of stuff `owned' by this 4594: function. */ 4595: 4596: end_sibling_chain (); 4597: 4598: break; 4599: 4600: case TYPE_DECL: 4601: /* If we are in terse mode, don't generate any DIEs to represent 4602: any actual typedefs. Note that even when we are in terse mode, 4603: we must still output DIEs to represent those tagged types which 4604: are used (directly or indirectly) in the specification of either 4605: a return type or a formal parameter type of some function. */ 4606: 4607: if (debug_info_level <= DINFO_LEVEL_TERSE) 4608: if (DECL_NAME (decl) != NULL 4609: || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl))) 4610: return; 4611: 1.1.1.4 root 4612: /* In the special case of a null-named TYPE_DECL node (representing 4613: the declaration of some type tag), if the given TYPE_DECL is 4614: marked as having been instantiated from some other (original) 4615: TYPE_DECL node (e.g. one which was generated within the original 4616: definition of an inline function) we have to generate a special 4617: (abbreviated) TAG_structure_type, TAG_union_type, or 4618: TAG_enumeration-type DIE here. */ 4619: 4620: if (! DECL_NAME (decl) && DECL_ABSTRACT_ORIGIN (decl)) 4621: { 4622: output_tagged_type_instantiation (TREE_TYPE (decl)); 4623: return; 4624: } 4625: 1.1 root 4626: output_type (TREE_TYPE (decl), containing_scope); 4627: 4628: /* Note that unlike the gcc front end (which generates a NULL named 4629: TYPE_DECL node for each complete tagged type, each array type, 4630: and each function type node created) the g++ front end generates 4631: a *named* TYPE_DECL node for each tagged type node created. 4632: Unfortunately, these g++ TYPE_DECL nodes cause us to output many 4633: superfluous and unnecessary TAG_typedef DIEs here. When g++ is 4634: fixed to stop generating these superfluous named TYPE_DECL nodes, 4635: the superfluous TAG_typedef DIEs will likewise cease. */ 4636: 4637: if (DECL_NAME (decl)) 4638: /* Output a DIE to represent the typedef itself. */ 4639: output_die (output_typedef_die, decl); 4640: break; 4641: 4642: case LABEL_DECL: 4643: if (debug_info_level >= DINFO_LEVEL_NORMAL) 4644: output_die (output_label_die, decl); 4645: break; 4646: 4647: case VAR_DECL: 1.1.1.3 root 4648: /* If we are conforming to the DWARF version 1 specification, don't 4649: generated any DIEs to represent mere external object declarations. */ 4650: 4651: #if (DWARF_VERSION <= 1) 1.1.1.4 root 4652: if (DECL_EXTERNAL (decl) && ! TREE_PUBLIC (decl)) 1.1.1.3 root 4653: break; 4654: #endif 4655: 1.1 root 4656: /* If we are in terse mode, don't generate any DIEs to represent 4657: any variable declarations or definitions. */ 4658: 4659: if (debug_info_level <= DINFO_LEVEL_TERSE) 4660: break; 4661: 4662: /* Output any DIEs that are needed to specify the type of this data 4663: object. */ 4664: 4665: output_type (TREE_TYPE (decl), containing_scope); 4666: 4667: /* If the following DIE will represent a data object definition for a 4668: data object with "extern" linkage, output a special "pubnames" DIE 4669: label just ahead of the actual DIE. A reference to this label 4670: was already generated in the .debug_pubnames section sub-entry 4671: for this data object definition. */ 4672: 1.1.1.4 root 4673: if (TREE_PUBLIC (decl) && ! DECL_ABSTRACT (decl)) 1.1 root 4674: { 4675: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 4676: 4677: sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++); 4678: ASM_OUTPUT_LABEL (asm_out_file, label); 4679: } 4680: 1.1.1.4 root 4681: /* Now output the DIE to represent the data object itself. This gets 4682: complicated because of the possibility that the VAR_DECL really 4683: represents an inlined instance of a formal parameter for an inline 4684: function. */ 4685: 4686: { 4687: register void (*func) (); 4688: register tree origin = decl_ultimate_origin (decl); 1.1 root 4689: 1.1.1.4 root 4690: if (origin != NULL && TREE_CODE (origin) == PARM_DECL) 4691: func = output_formal_parameter_die; 4692: else 4693: { 4694: if (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)) 4695: func = output_global_variable_die; 4696: else 4697: func = output_local_variable_die; 4698: } 4699: output_die (func, decl); 4700: } 1.1 root 4701: break; 4702: 4703: case FIELD_DECL: 4704: /* Ignore the nameless fields that are used to skip bits. */ 4705: if (DECL_NAME (decl) != 0) 4706: { 4707: output_type (member_declared_type (decl), containing_scope); 4708: output_die (output_member_die, decl); 4709: } 4710: break; 4711: 4712: case PARM_DECL: 4713: /* Force out the type of this formal, if it was not forced out yet. 4714: Note that here we can run afowl of a bug in "classic" svr4 SDB. 4715: It should be able to grok the presence of type DIEs within a list 4716: of TAG_formal_parameter DIEs, but it doesn't. */ 4717: 4718: output_type (TREE_TYPE (decl), containing_scope); 4719: output_die (output_formal_parameter_die, decl); 4720: break; 4721: 4722: default: 4723: abort (); 4724: } 4725: } 4726: 4727: void 4728: dwarfout_file_scope_decl (decl, set_finalizing) 4729: register tree decl; 4730: register int set_finalizing; 4731: { 1.1.1.3 root 4732: if (TREE_CODE (decl) == ERROR_MARK) 4733: return; 4734: 4735: /* If this ..._DECL node is marked to be ignored, then ignore it. We 4736: gotta hope that the node in question doesn't represent a function 4737: definition. If it does, then totally ignoring it is bound to screw 4738: up our count of blocks, and that it turn will completely screw up the 4739: the labels we will reference in subsequent AT_low_pc and AT_high_pc 4740: attributes (for subsequent blocks). (It's too bad that BLOCK nodes 4741: don't carry their own sequence numbers with them!) */ 4742: 4743: if (DECL_IGNORED_P (decl)) 4744: { 4745: if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL) 4746: abort (); 4747: return; 4748: } 4749: 1.1 root 4750: switch (TREE_CODE (decl)) 4751: { 4752: case FUNCTION_DECL: 4753: 1.1.1.3 root 4754: /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of 4755: a builtin function. Explicit programmer-supplied declarations of 4756: these same functions should NOT be ignored however. */ 1.1 root 4757: 1.1.1.4 root 4758: if (DECL_EXTERNAL (decl) && DECL_FUNCTION_CODE (decl)) 1.1 root 4759: return; 4760: 1.1.1.5 ! root 4761: /* What we would really like to do here is to filter out all mere ! 4762: file-scope declarations of file-scope functions which are never ! 4763: referenced later within this translation unit (and keep all of ! 4764: ones that *are* referenced later on) but we aren't clarvoiant, ! 4765: so we have no idea which functions will be referenced in the ! 4766: future (i.e. later on within the current translation unit). ! 4767: So here we just ignore all file-scope function declarations ! 4768: which are not also definitions. If and when the debugger needs ! 4769: to know something about these funcstion, it wil have to hunt ! 4770: around and find the DWARF information associated with the ! 4771: *definition* of the function. ! 4772: ! 4773: Note that we can't just check `DECL_EXTERNAL' to find out which ! 4774: FUNCTION_DECL nodes represent definitions and which ones represent ! 4775: mere declarations. We have to check `DECL_INITIAL' instead. That's ! 4776: because the C front-end supports some weird semantics for "extern ! 4777: inline" function definitions. These can get inlined within the ! 4778: current translation unit (an thus, we need to generate DWARF info ! 4779: for their abstract instances so that the DWARF info for the ! 4780: concrete inlined instances can have something to refer to) but ! 4781: the compiler never generates any out-of-lines instances of such ! 4782: things (despite the fact that they *are* definitions). The ! 4783: important point is that the C front-end marks these "extern inline" ! 4784: functions as DECL_EXTERNAL, but we need to generate DWARf for them ! 4785: anyway. ! 4786: ! 4787: Note that the C++ front-end also plays some similar games for inline ! 4788: function definitions appearing within include files which also ! 4789: contain `#pragma interface' pragmas. */ 1.1 root 4790: 1.1.1.5 ! root 4791: if (DECL_INITIAL (decl) == NULL_TREE) 1.1 root 4792: return; 4793: 1.1.1.4 root 4794: if (TREE_PUBLIC (decl) 4795: && ! DECL_EXTERNAL (decl) 4796: && ! DECL_ABSTRACT (decl)) 1.1 root 4797: { 4798: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 4799: 4800: /* Output a .debug_pubnames entry for a public function 4801: defined in this compilation unit. */ 4802: 4803: fputc ('\n', asm_out_file); 1.1.1.3 root 4804: ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION); 1.1 root 4805: sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number); 4806: ASM_OUTPUT_DWARF_ADDR (asm_out_file, label); 4807: ASM_OUTPUT_DWARF_STRING (asm_out_file, 4808: IDENTIFIER_POINTER (DECL_NAME (decl))); 1.1.1.3 root 4809: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 4810: } 4811: 4812: break; 4813: 4814: case VAR_DECL: 4815: 4816: /* Ignore this VAR_DECL if it refers to a file-scope extern data 4817: object declaration and if the declaration was never even 4818: referenced from within this entire compilation unit. We 4819: suppress these DIEs in order to save space in the .debug section 4820: (by eliminating entries which are probably useless). Note that 4821: we must not suppress block-local extern declarations (whether 4822: used or not) because that would screw-up the debugger's name 4823: lookup mechanism and cause it to miss things which really ought 4824: to be in scope at a given point. */ 4825: 1.1.1.4 root 4826: if (DECL_EXTERNAL (decl) && !TREE_USED (decl)) 1.1 root 4827: return; 4828: 1.1.1.3 root 4829: if (TREE_PUBLIC (decl) 1.1.1.4 root 4830: && ! DECL_EXTERNAL (decl) 4831: && GET_CODE (DECL_RTL (decl)) == MEM 4832: && ! DECL_ABSTRACT (decl)) 1.1 root 4833: { 4834: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 4835: 4836: if (debug_info_level >= DINFO_LEVEL_NORMAL) 4837: { 4838: /* Output a .debug_pubnames entry for a public variable 4839: defined in this compilation unit. */ 4840: 4841: fputc ('\n', asm_out_file); 1.1.1.3 root 4842: ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION); 1.1 root 4843: sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number); 4844: ASM_OUTPUT_DWARF_ADDR (asm_out_file, label); 4845: ASM_OUTPUT_DWARF_STRING (asm_out_file, 4846: IDENTIFIER_POINTER (DECL_NAME (decl))); 1.1.1.3 root 4847: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 4848: } 4849: 4850: if (DECL_INITIAL (decl) == NULL) 4851: { 4852: /* Output a .debug_aranges entry for a public variable 1.1.1.3 root 4853: which is tentatively defined in this compilation unit. */ 1.1 root 4854: 4855: fputc ('\n', asm_out_file); 1.1.1.3 root 4856: ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION); 1.1 root 4857: ASM_OUTPUT_DWARF_ADDR (asm_out_file, 1.1.1.3 root 4858: IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))); 1.1 root 4859: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 4860: (unsigned) int_size_in_bytes (TREE_TYPE (decl))); 1.1.1.3 root 4861: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 4862: } 4863: } 4864: 4865: /* If we are in terse mode, don't generate any DIEs to represent 4866: any variable declarations or definitions. */ 4867: 4868: if (debug_info_level <= DINFO_LEVEL_TERSE) 4869: return; 4870: 4871: break; 4872: 4873: case TYPE_DECL: 1.1.1.4 root 4874: /* Don't bother trying to generate any DIEs to represent any of the 4875: normal built-in types for the language we are compiling, except 4876: in cases where the types in question are *not* DWARF fundamental 4877: types. We make an exception in the case of non-fundamental types 4878: for the sake of objective C (and perhaps C++) because the GNU 4879: front-ends for these languages may in fact create certain "built-in" 4880: types which are (for example) RECORD_TYPEs. In such cases, we 4881: really need to output these (non-fundamental) types because other 4882: DIEs may contain references to them. */ 1.1 root 4883: 1.1.1.4 root 4884: if (DECL_SOURCE_LINE (decl) == 0 4885: && type_is_fundamental (TREE_TYPE (decl))) 1.1 root 4886: return; 4887: 4888: /* If we are in terse mode, don't generate any DIEs to represent 4889: any actual typedefs. Note that even when we are in terse mode, 4890: we must still output DIEs to represent those tagged types which 4891: are used (directly or indirectly) in the specification of either 4892: a return type or a formal parameter type of some function. */ 4893: 4894: if (debug_info_level <= DINFO_LEVEL_TERSE) 4895: if (DECL_NAME (decl) != NULL 4896: || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl))) 4897: return; 4898: 4899: break; 4900: 4901: default: 4902: return; 4903: } 4904: 4905: fputc ('\n', asm_out_file); 1.1.1.3 root 4906: ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION); 1.1 root 4907: finalizing = set_finalizing; 1.1.1.4 root 4908: output_decl (decl, NULL_TREE); 1.1 root 4909: 4910: /* NOTE: The call above to `output_decl' may have caused one or more 4911: file-scope named types (i.e. tagged types) to be placed onto the 4912: pending_types_list. We have to get those types off of that list 4913: at some point, and this is the perfect time to do it. If we didn't 4914: take them off now, they might still be on the list when cc1 finally 4915: exits. That might be OK if it weren't for the fact that when we put 4916: types onto the pending_types_list, we set the TREE_ASM_WRITTEN flag 4917: for these types, and that causes them never to be output unless 4918: `output_pending_types_for_scope' takes them off of the list and un-sets 4919: their TREE_ASM_WRITTEN flags. */ 4920: 1.1.1.4 root 4921: output_pending_types_for_scope (NULL_TREE); 1.1 root 4922: 4923: /* The above call should have totally emptied the pending_types_list. */ 4924: 4925: assert (pending_types == 0); 4926: 1.1.1.3 root 4927: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 4928: 4929: if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL) 4930: current_funcdef_number++; 4931: } 4932: 4933: /* Output a marker (i.e. a label) for the beginning of the generated code 4934: for a lexical block. */ 4935: 4936: void 4937: dwarfout_begin_block (blocknum) 4938: register unsigned blocknum; 4939: { 4940: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 4941: 4942: text_section (); 4943: sprintf (label, BLOCK_BEGIN_LABEL_FMT, blocknum); 4944: ASM_OUTPUT_LABEL (asm_out_file, label); 4945: } 4946: 4947: /* Output a marker (i.e. a label) for the end of the generated code 4948: for a lexical block. */ 4949: 4950: void 4951: dwarfout_end_block (blocknum) 4952: register unsigned blocknum; 4953: { 4954: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 4955: 4956: text_section (); 4957: sprintf (label, BLOCK_END_LABEL_FMT, blocknum); 4958: ASM_OUTPUT_LABEL (asm_out_file, label); 4959: } 4960: 4961: /* Output a marker (i.e. a label) at a point in the assembly code which 4962: corresponds to a given source level label. */ 4963: 4964: void 4965: dwarfout_label (insn) 4966: register rtx insn; 4967: { 4968: if (debug_info_level >= DINFO_LEVEL_NORMAL) 4969: { 4970: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 4971: 4972: text_section (); 4973: sprintf (label, INSN_LABEL_FMT, current_funcdef_number, 4974: (unsigned) INSN_UID (insn)); 4975: ASM_OUTPUT_LABEL (asm_out_file, label); 4976: } 4977: } 4978: 1.1.1.4 root 4979: /* Output a marker (i.e. a label) for the point in the generated code where 4980: the real body of the function begins (after parameters have been moved 4981: to their home locations). */ 4982: 4983: void 4984: dwarfout_begin_function () 4985: { 4986: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 4987: 4988: text_section (); 4989: sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number); 4990: ASM_OUTPUT_LABEL (asm_out_file, label); 4991: } 4992: 4993: /* Output a marker (i.e. a label) for the point in the generated code where 4994: the real body of the function ends (just before the epilogue code). */ 4995: 4996: void 4997: dwarfout_end_function () 4998: { 4999: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 5000: 5001: text_section (); 5002: sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number); 5003: ASM_OUTPUT_LABEL (asm_out_file, label); 5004: } 5005: 1.1 root 5006: /* Output a marker (i.e. a label) for the absolute end of the generated code 5007: for a function definition. This gets called *after* the epilogue code 5008: has been generated. */ 5009: 5010: void 5011: dwarfout_end_epilogue () 5012: { 5013: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 5014: 5015: /* Output a label to mark the endpoint of the code generated for this 5016: function. */ 5017: 5018: sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number); 5019: ASM_OUTPUT_LABEL (asm_out_file, label); 5020: } 5021: 5022: static void 5023: shuffle_filename_entry (new_zeroth) 5024: register filename_entry *new_zeroth; 5025: { 5026: filename_entry temp_entry; 5027: register filename_entry *limit_p; 5028: register filename_entry *move_p; 5029: 5030: if (new_zeroth == &filename_table[0]) 5031: return; 5032: 5033: temp_entry = *new_zeroth; 5034: 5035: /* Shift entries up in the table to make room at [0]. */ 5036: 5037: limit_p = &filename_table[0]; 5038: for (move_p = new_zeroth; move_p > limit_p; move_p--) 5039: *move_p = *(move_p-1); 5040: 5041: /* Install the found entry at [0]. */ 5042: 5043: filename_table[0] = temp_entry; 5044: } 5045: 5046: /* Create a new (string) entry for the .debug_sfnames section. */ 5047: 5048: static void 5049: generate_new_sfname_entry () 5050: { 5051: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 5052: 5053: fputc ('\n', asm_out_file); 1.1.1.3 root 5054: ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION); 1.1 root 5055: sprintf (label, SFNAMES_ENTRY_LABEL_FMT, filename_table[0].number); 5056: ASM_OUTPUT_LABEL (asm_out_file, label); 5057: ASM_OUTPUT_DWARF_STRING (asm_out_file, 5058: filename_table[0].name 5059: ? filename_table[0].name 5060: : ""); 1.1.1.3 root 5061: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5062: } 5063: 5064: /* Lookup a filename (in the list of filenames that we know about here in 5065: dwarfout.c) and return its "index". The index of each (known) filename 5066: is just a unique number which is associated with only that one filename. 5067: We need such numbers for the sake of generating labels (in the 5068: .debug_sfnames section) and references to those unique labels (in the 5069: .debug_srcinfo and .debug_macinfo sections). 5070: 5071: If the filename given as an argument is not found in our current list, 5072: add it to the list and assign it the next available unique index number. 5073: 5074: Whatever we do (i.e. whether we find a pre-existing filename or add a new 5075: one), we shuffle the filename found (or added) up to the zeroth entry of 5076: our list of filenames (which is always searched linearly). We do this so 5077: as to optimize the most common case for these filename lookups within 5078: dwarfout.c. The most common case by far is the case where we call 5079: lookup_filename to lookup the very same filename that we did a lookup 5080: on the last time we called lookup_filename. We make sure that this 5081: common case is fast because such cases will constitute 99.9% of the 5082: lookups we ever do (in practice). 5083: 5084: If we add a new filename entry to our table, we go ahead and generate 5085: the corresponding entry in the .debug_sfnames section right away. 5086: Doing so allows us to avoid tickling an assembler bug (present in some 5087: m68k assemblers) which yields assembly-time errors in cases where the 5088: difference of two label addresses is taken and where the two labels 5089: are in a section *other* than the one where the difference is being 5090: calculated, and where at least one of the two symbol references is a 5091: forward reference. (This bug could be tickled by our .debug_srcinfo 5092: entries if we don't output their corresponding .debug_sfnames entries 5093: before them.) 5094: */ 5095: 5096: static unsigned 5097: lookup_filename (file_name) 5098: char *file_name; 5099: { 5100: register filename_entry *search_p; 5101: register filename_entry *limit_p = &filename_table[ft_entries]; 5102: 5103: for (search_p = filename_table; search_p < limit_p; search_p++) 5104: if (!strcmp (file_name, search_p->name)) 5105: { 5106: /* When we get here, we have found the filename that we were 5107: looking for in the filename_table. Now we want to make sure 5108: that it gets moved to the zero'th entry in the table (if it 5109: is not already there) so that subsequent attempts to find the 5110: same filename will find it as quickly as possible. */ 5111: 5112: shuffle_filename_entry (search_p); 5113: return filename_table[0].number; 5114: } 5115: 5116: /* We come here whenever we have a new filename which is not registered 5117: in the current table. Here we add it to the table. */ 5118: 5119: /* Prepare to add a new table entry by making sure there is enough space 5120: in the table to do so. If not, expand the current table. */ 5121: 5122: if (ft_entries == ft_entries_allocated) 5123: { 5124: ft_entries_allocated += FT_ENTRIES_INCREMENT; 5125: filename_table 5126: = (filename_entry *) 5127: xrealloc (filename_table, 5128: ft_entries_allocated * sizeof (filename_entry)); 5129: } 5130: 5131: /* Initially, add the new entry at the end of the filename table. */ 5132: 5133: filename_table[ft_entries].number = ft_entries; 5134: filename_table[ft_entries].name = xstrdup (file_name); 5135: 5136: /* Shuffle the new entry into filename_table[0]. */ 5137: 5138: shuffle_filename_entry (&filename_table[ft_entries]); 5139: 5140: if (debug_info_level >= DINFO_LEVEL_NORMAL) 5141: generate_new_sfname_entry (); 5142: 5143: ft_entries++; 5144: return filename_table[0].number; 5145: } 5146: 5147: static void 5148: generate_srcinfo_entry (line_entry_num, files_entry_num) 5149: unsigned line_entry_num; 5150: unsigned files_entry_num; 5151: { 5152: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 5153: 5154: fputc ('\n', asm_out_file); 1.1.1.3 root 5155: ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION); 1.1 root 5156: sprintf (label, LINE_ENTRY_LABEL_FMT, line_entry_num); 5157: ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, LINE_BEGIN_LABEL); 5158: sprintf (label, SFNAMES_ENTRY_LABEL_FMT, files_entry_num); 5159: ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, SFNAMES_BEGIN_LABEL); 1.1.1.3 root 5160: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5161: } 5162: 5163: void 5164: dwarfout_line (filename, line) 5165: register char *filename; 5166: register unsigned line; 5167: { 5168: if (debug_info_level >= DINFO_LEVEL_NORMAL) 5169: { 5170: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 5171: static unsigned last_line_entry_num = 0; 5172: static unsigned prev_file_entry_num = (unsigned) -1; 5173: register unsigned this_file_entry_num = lookup_filename (filename); 5174: 5175: text_section (); 5176: sprintf (label, LINE_CODE_LABEL_FMT, ++last_line_entry_num); 5177: ASM_OUTPUT_LABEL (asm_out_file, label); 5178: 5179: fputc ('\n', asm_out_file); 1.1.1.3 root 5180: ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION); 1.1 root 5181: 5182: if (this_file_entry_num != prev_file_entry_num) 5183: { 5184: char line_entry_label[MAX_ARTIFICIAL_LABEL_BYTES]; 5185: 5186: sprintf (line_entry_label, LINE_ENTRY_LABEL_FMT, last_line_entry_num); 5187: ASM_OUTPUT_LABEL (asm_out_file, line_entry_label); 5188: } 5189: 5190: { 1.1.1.4 root 5191: register char *tail = rindex (filename, '/'); 1.1 root 5192: 5193: if (tail != NULL) 5194: filename = tail; 5195: } 5196: 1.1.1.2 root 5197: fprintf (asm_out_file, "\t%s\t%u\t%s %s:%u\n", 1.1 root 5198: UNALIGNED_INT_ASM_OP, line, ASM_COMMENT_START, 5199: filename, line); 5200: ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff); 5201: ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, TEXT_BEGIN_LABEL); 1.1.1.3 root 5202: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5203: 5204: if (this_file_entry_num != prev_file_entry_num) 5205: generate_srcinfo_entry (last_line_entry_num, this_file_entry_num); 5206: prev_file_entry_num = this_file_entry_num; 5207: } 5208: } 5209: 5210: /* Generate an entry in the .debug_macinfo section. */ 5211: 5212: static void 5213: generate_macinfo_entry (type_and_offset, string) 5214: register char *type_and_offset; 5215: register char *string; 5216: { 5217: fputc ('\n', asm_out_file); 1.1.1.3 root 5218: ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION); 1.1.1.2 root 5219: fprintf (asm_out_file, "\t%s\t%s\n", UNALIGNED_INT_ASM_OP, type_and_offset); 1.1 root 5220: ASM_OUTPUT_DWARF_STRING (asm_out_file, string); 1.1.1.3 root 5221: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5222: } 5223: 5224: void 5225: dwarfout_start_new_source_file (filename) 5226: register char *filename; 5227: { 5228: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 5229: char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*3]; 5230: 5231: sprintf (label, SFNAMES_ENTRY_LABEL_FMT, lookup_filename (filename)); 5232: sprintf (type_and_offset, "0x%08x+%s-%s", 5233: ((unsigned) MACINFO_start << 24), label, SFNAMES_BEGIN_LABEL); 5234: generate_macinfo_entry (type_and_offset, ""); 5235: } 5236: 5237: void 5238: dwarfout_resume_previous_source_file (lineno) 5239: register unsigned lineno; 5240: { 5241: char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2]; 5242: 5243: sprintf (type_and_offset, "0x%08x+%u", 5244: ((unsigned) MACINFO_resume << 24), lineno); 5245: generate_macinfo_entry (type_and_offset, ""); 5246: } 5247: 5248: /* Called from check_newline in c-parse.y. The `buffer' parameter 5249: contains the tail part of the directive line, i.e. the part which 5250: is past the initial whitespace, #, whitespace, directive-name, 5251: whitespace part. */ 5252: 5253: void 5254: dwarfout_define (lineno, buffer) 5255: register unsigned lineno; 5256: register char *buffer; 5257: { 5258: static int initialized = 0; 5259: char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2]; 5260: 5261: if (!initialized) 5262: { 5263: dwarfout_start_new_source_file (primary_filename); 5264: initialized = 1; 5265: } 5266: sprintf (type_and_offset, "0x%08x+%u", 5267: ((unsigned) MACINFO_define << 24), lineno); 5268: generate_macinfo_entry (type_and_offset, buffer); 5269: } 5270: 5271: /* Called from check_newline in c-parse.y. The `buffer' parameter 5272: contains the tail part of the directive line, i.e. the part which 5273: is past the initial whitespace, #, whitespace, directive-name, 5274: whitespace part. */ 5275: 5276: void 5277: dwarfout_undef (lineno, buffer) 5278: register unsigned lineno; 5279: register char *buffer; 5280: { 5281: char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2]; 5282: 5283: sprintf (type_and_offset, "0x%08x+%u", 5284: ((unsigned) MACINFO_undef << 24), lineno); 5285: generate_macinfo_entry (type_and_offset, buffer); 5286: } 5287: 5288: /* Set up for Dwarf output at the start of compilation. */ 5289: 5290: void 5291: dwarfout_init (asm_out_file, main_input_filename) 5292: register FILE *asm_out_file; 5293: register char *main_input_filename; 5294: { 5295: /* Remember the name of the primary input file. */ 5296: 5297: primary_filename = main_input_filename; 5298: 5299: /* Allocate the initial hunk of the pending_sibling_stack. */ 5300: 5301: pending_sibling_stack 5302: = (unsigned *) 5303: xmalloc (PENDING_SIBLINGS_INCREMENT * sizeof (unsigned)); 5304: pending_siblings_allocated = PENDING_SIBLINGS_INCREMENT; 5305: pending_siblings = 1; 5306: 5307: /* Allocate the initial hunk of the filename_table. */ 5308: 5309: filename_table 5310: = (filename_entry *) 5311: xmalloc (FT_ENTRIES_INCREMENT * sizeof (filename_entry)); 5312: ft_entries_allocated = FT_ENTRIES_INCREMENT; 5313: ft_entries = 0; 5314: 5315: /* Allocate the initial hunk of the pending_types_list. */ 5316: 5317: pending_types_list 5318: = (tree *) xmalloc (PENDING_TYPES_INCREMENT * sizeof (tree)); 5319: pending_types_allocated = PENDING_TYPES_INCREMENT; 5320: pending_types = 0; 5321: 5322: /* Create an artificial RECORD_TYPE node which we can use in our hack 5323: to get the DIEs representing types of formal parameters to come out 5324: only *after* the DIEs for the formal parameters themselves. */ 5325: 5326: fake_containing_scope = make_node (RECORD_TYPE); 5327: 5328: /* Output a starting label for the .text section. */ 5329: 5330: fputc ('\n', asm_out_file); 1.1.1.3 root 5331: ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION); 1.1 root 5332: ASM_OUTPUT_LABEL (asm_out_file, TEXT_BEGIN_LABEL); 1.1.1.3 root 5333: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5334: 5335: /* Output a starting label for the .data section. */ 5336: 5337: fputc ('\n', asm_out_file); 1.1.1.3 root 5338: ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION); 1.1 root 5339: ASM_OUTPUT_LABEL (asm_out_file, DATA_BEGIN_LABEL); 1.1.1.3 root 5340: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5341: 1.1.1.4 root 5342: #if 0 /* GNU C doesn't currently use .data1. */ 1.1 root 5343: /* Output a starting label for the .data1 section. */ 5344: 5345: fputc ('\n', asm_out_file); 1.1.1.3 root 5346: ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION); 1.1 root 5347: ASM_OUTPUT_LABEL (asm_out_file, DATA1_BEGIN_LABEL); 1.1.1.3 root 5348: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1.1.4 root 5349: #endif 1.1 root 5350: 5351: /* Output a starting label for the .rodata section. */ 5352: 5353: fputc ('\n', asm_out_file); 1.1.1.3 root 5354: ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION); 1.1 root 5355: ASM_OUTPUT_LABEL (asm_out_file, RODATA_BEGIN_LABEL); 1.1.1.3 root 5356: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5357: 1.1.1.4 root 5358: #if 0 /* GNU C doesn't currently use .rodata1. */ 1.1 root 5359: /* Output a starting label for the .rodata1 section. */ 5360: 5361: fputc ('\n', asm_out_file); 1.1.1.3 root 5362: ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION); 1.1 root 5363: ASM_OUTPUT_LABEL (asm_out_file, RODATA1_BEGIN_LABEL); 1.1.1.3 root 5364: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1.1.4 root 5365: #endif 1.1 root 5366: 5367: /* Output a starting label for the .bss section. */ 5368: 5369: fputc ('\n', asm_out_file); 1.1.1.3 root 5370: ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION); 1.1 root 5371: ASM_OUTPUT_LABEL (asm_out_file, BSS_BEGIN_LABEL); 1.1.1.3 root 5372: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5373: 5374: if (debug_info_level >= DINFO_LEVEL_NORMAL) 5375: { 5376: /* Output a starting label and an initial (compilation directory) 5377: entry for the .debug_sfnames section. The starting label will be 5378: referenced by the initial entry in the .debug_srcinfo section. */ 5379: 5380: fputc ('\n', asm_out_file); 1.1.1.3 root 5381: ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION); 1.1 root 5382: ASM_OUTPUT_LABEL (asm_out_file, SFNAMES_BEGIN_LABEL); 5383: { 1.1.1.2 root 5384: register char *pwd = getpwd (); 5385: register unsigned len = strlen (pwd); 5386: register char *dirname = (char *) xmalloc (len + 2); 1.1 root 5387: 1.1.1.2 root 5388: strcpy (dirname, pwd); 5389: strcpy (dirname + len, "/"); 1.1 root 5390: ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname); 5391: free (dirname); 5392: } 1.1.1.3 root 5393: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5394: 5395: if (debug_info_level >= DINFO_LEVEL_VERBOSE) 5396: { 5397: /* Output a starting label for the .debug_macinfo section. This 5398: label will be referenced by the AT_mac_info attribute in the 5399: TAG_compile_unit DIE. */ 5400: 5401: fputc ('\n', asm_out_file); 1.1.1.3 root 5402: ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION); 1.1 root 5403: ASM_OUTPUT_LABEL (asm_out_file, MACINFO_BEGIN_LABEL); 1.1.1.3 root 5404: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5405: } 5406: 5407: /* Generate the initial entry for the .line section. */ 5408: 5409: fputc ('\n', asm_out_file); 1.1.1.3 root 5410: ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION); 1.1 root 5411: ASM_OUTPUT_LABEL (asm_out_file, LINE_BEGIN_LABEL); 5412: ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, LINE_END_LABEL, LINE_BEGIN_LABEL); 5413: ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL); 1.1.1.3 root 5414: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5415: 5416: /* Generate the initial entry for the .debug_srcinfo section. */ 5417: 5418: fputc ('\n', asm_out_file); 1.1.1.3 root 5419: ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION); 1.1 root 5420: ASM_OUTPUT_LABEL (asm_out_file, SRCINFO_BEGIN_LABEL); 5421: ASM_OUTPUT_DWARF_ADDR (asm_out_file, LINE_BEGIN_LABEL); 5422: ASM_OUTPUT_DWARF_ADDR (asm_out_file, SFNAMES_BEGIN_LABEL); 5423: ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL); 5424: ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_END_LABEL); 5425: #ifdef DWARF_TIMESTAMPS 5426: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, time (NULL)); 5427: #else 5428: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1); 5429: #endif 1.1.1.3 root 5430: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5431: 5432: /* Generate the initial entry for the .debug_pubnames section. */ 5433: 5434: fputc ('\n', asm_out_file); 1.1.1.3 root 5435: ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION); 1.1 root 5436: ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL); 1.1.1.3 root 5437: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5438: 5439: /* Generate the initial entry for the .debug_aranges section. */ 5440: 5441: fputc ('\n', asm_out_file); 1.1.1.3 root 5442: ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION); 1.1 root 5443: ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL); 1.1.1.3 root 5444: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5445: } 5446: 5447: /* Setup first DIE number == 1. */ 5448: NEXT_DIE_NUM = next_unused_dienum++; 5449: 5450: /* Generate the initial DIE for the .debug section. Note that the 5451: (string) value given in the AT_name attribute of the TAG_compile_unit 5452: DIE will (typically) be a relative pathname and that this pathname 5453: should be taken as being relative to the directory from which the 5454: compiler was invoked when the given (base) source file was compiled. */ 5455: 5456: fputc ('\n', asm_out_file); 1.1.1.3 root 5457: ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION); 1.1 root 5458: ASM_OUTPUT_LABEL (asm_out_file, DEBUG_BEGIN_LABEL); 5459: output_die (output_compile_unit_die, main_input_filename); 1.1.1.3 root 5460: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5461: 5462: fputc ('\n', asm_out_file); 5463: } 5464: 5465: /* Output stuff that dwarf requires at the end of every file. */ 5466: 5467: void 5468: dwarfout_finish () 5469: { 5470: char label[MAX_ARTIFICIAL_LABEL_BYTES]; 5471: 5472: fputc ('\n', asm_out_file); 1.1.1.3 root 5473: ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION); 1.1 root 5474: 5475: /* Mark the end of the chain of siblings which represent all file-scope 5476: declarations in this compilation unit. */ 5477: 5478: /* The (null) DIE which represents the terminator for the (sibling linked) 5479: list of file-scope items is *special*. Normally, we would just call 5480: end_sibling_chain at this point in order to output a word with the 5481: value `4' and that word would act as the terminator for the list of 5482: DIEs describing file-scope items. Unfortunately, if we were to simply 5483: do that, the label that would follow this DIE in the .debug section 5484: (i.e. `..D2') would *not* be properly aligned (as it must be on some 5485: machines) to a 4 byte boundary. 5486: 5487: In order to force the label `..D2' to get aligned to a 4 byte boundary, 5488: the trick used is to insert extra (otherwise useless) padding bytes 1.1.1.3 root 5489: into the (null) DIE that we know must precede the ..D2 label in the 1.1 root 5490: .debug section. The amount of padding required can be anywhere between 5491: 0 and 3 bytes. The length word at the start of this DIE (i.e. the one 5492: with the padding) would normally contain the value 4, but now it will 5493: also have to include the padding bytes, so it will instead have some 5494: value in the range 4..7. 5495: 5496: Fortunately, the rules of Dwarf say that any DIE whose length word 5497: contains *any* value less than 8 should be treated as a null DIE, so 5498: this trick works out nicely. Clever, eh? Don't give me any credit 5499: (or blame). I didn't think of this scheme. I just conformed to it. 5500: */ 5501: 5502: output_die (output_padded_null_die, (void *)0); 5503: dienum_pop (); 5504: 5505: sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM); 5506: ASM_OUTPUT_LABEL (asm_out_file, label); /* should be ..D2 */ 1.1.1.3 root 5507: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5508: 5509: /* Output a terminator label for the .text section. */ 5510: 5511: fputc ('\n', asm_out_file); 1.1.1.3 root 5512: ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION); 1.1 root 5513: ASM_OUTPUT_LABEL (asm_out_file, TEXT_END_LABEL); 1.1.1.3 root 5514: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5515: 5516: /* Output a terminator label for the .data section. */ 5517: 5518: fputc ('\n', asm_out_file); 1.1.1.3 root 5519: ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION); 1.1 root 5520: ASM_OUTPUT_LABEL (asm_out_file, DATA_END_LABEL); 1.1.1.3 root 5521: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5522: 1.1.1.4 root 5523: #if 0 /* GNU C doesn't currently use .data1. */ 1.1 root 5524: /* Output a terminator label for the .data1 section. */ 5525: 5526: fputc ('\n', asm_out_file); 1.1.1.3 root 5527: ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION); 1.1 root 5528: ASM_OUTPUT_LABEL (asm_out_file, DATA1_END_LABEL); 1.1.1.3 root 5529: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1.1.4 root 5530: #endif 1.1 root 5531: 5532: /* Output a terminator label for the .rodata section. */ 5533: 5534: fputc ('\n', asm_out_file); 1.1.1.3 root 5535: ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION); 1.1 root 5536: ASM_OUTPUT_LABEL (asm_out_file, RODATA_END_LABEL); 1.1.1.3 root 5537: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5538: 1.1.1.4 root 5539: #if 0 /* GNU C doesn't currently use .rodata1. */ 1.1 root 5540: /* Output a terminator label for the .rodata1 section. */ 5541: 5542: fputc ('\n', asm_out_file); 1.1.1.3 root 5543: ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION); 1.1 root 5544: ASM_OUTPUT_LABEL (asm_out_file, RODATA1_END_LABEL); 1.1.1.3 root 5545: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1.1.4 root 5546: #endif 1.1 root 5547: 5548: /* Output a terminator label for the .bss section. */ 5549: 5550: fputc ('\n', asm_out_file); 1.1.1.3 root 5551: ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION); 1.1 root 5552: ASM_OUTPUT_LABEL (asm_out_file, BSS_END_LABEL); 1.1.1.3 root 5553: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5554: 5555: if (debug_info_level >= DINFO_LEVEL_NORMAL) 5556: { 5557: /* Output a terminating entry for the .line section. */ 5558: 5559: fputc ('\n', asm_out_file); 1.1.1.3 root 5560: ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION); 1.1 root 5561: ASM_OUTPUT_LABEL (asm_out_file, LINE_LAST_ENTRY_LABEL); 5562: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0); 5563: ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff); 5564: ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL); 5565: ASM_OUTPUT_LABEL (asm_out_file, LINE_END_LABEL); 1.1.1.3 root 5566: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5567: 5568: /* Output a terminating entry for the .debug_srcinfo section. */ 5569: 5570: fputc ('\n', asm_out_file); 1.1.1.3 root 5571: ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION); 1.1 root 5572: ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, 5573: LINE_LAST_ENTRY_LABEL, LINE_BEGIN_LABEL); 5574: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1); 1.1.1.3 root 5575: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5576: 5577: if (debug_info_level >= DINFO_LEVEL_VERBOSE) 5578: { 5579: /* Output terminating entries for the .debug_macinfo section. */ 5580: 5581: dwarfout_resume_previous_source_file (0); 5582: 5583: fputc ('\n', asm_out_file); 1.1.1.3 root 5584: ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION); 1.1 root 5585: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0); 5586: ASM_OUTPUT_DWARF_STRING (asm_out_file, ""); 1.1.1.3 root 5587: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5588: } 5589: 5590: /* Generate the terminating entry for the .debug_pubnames section. */ 5591: 5592: fputc ('\n', asm_out_file); 1.1.1.3 root 5593: ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION); 1.1 root 5594: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0); 5595: ASM_OUTPUT_DWARF_STRING (asm_out_file, ""); 1.1.1.3 root 5596: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5597: 5598: /* Generate the terminating entries for the .debug_aranges section. 5599: 5600: Note that we want to do this only *after* we have output the end 5601: labels (for the various program sections) which we are going to 5602: refer to here. This allows us to work around a bug in the m68k 5603: svr4 assembler. That assembler gives bogus assembly-time errors 5604: if (within any given section) you try to take the difference of 5605: two relocatable symbols, both of which are located within some 5606: other section, and if one (or both?) of the symbols involved is 5607: being forward-referenced. By generating the .debug_aranges 5608: entries at this late point in the assembly output, we skirt the 5609: issue simply by avoiding forward-references. 5610: */ 5611: 5612: fputc ('\n', asm_out_file); 1.1.1.3 root 5613: ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION); 1.1 root 5614: 5615: ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL); 5616: ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL); 5617: 5618: ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA_BEGIN_LABEL); 5619: ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA_END_LABEL, DATA_BEGIN_LABEL); 5620: 1.1.1.4 root 5621: #if 0 /* GNU C doesn't currently use .data1. */ 1.1 root 5622: ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA1_BEGIN_LABEL); 5623: ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA1_END_LABEL, 5624: DATA1_BEGIN_LABEL); 1.1.1.4 root 5625: #endif 1.1 root 5626: 5627: ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA_BEGIN_LABEL); 5628: ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA_END_LABEL, 5629: RODATA_BEGIN_LABEL); 5630: 1.1.1.4 root 5631: #if 0 /* GNU C doesn't currently use .rodata1. */ 1.1 root 5632: ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA1_BEGIN_LABEL); 5633: ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA1_END_LABEL, 5634: RODATA1_BEGIN_LABEL); 1.1.1.4 root 5635: #endif 1.1 root 5636: 5637: ASM_OUTPUT_DWARF_ADDR (asm_out_file, BSS_BEGIN_LABEL); 5638: ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, BSS_END_LABEL, BSS_BEGIN_LABEL); 5639: 5640: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0); 5641: ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0); 5642: 1.1.1.3 root 5643: ASM_OUTPUT_POP_SECTION (asm_out_file); 1.1 root 5644: } 5645: } 5646: 5647: #endif /* DWARF_DEBUGGING_INFO */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.