Annotation of gcc/dwarfout.c, revision 1.1.1.8

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.