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