OSDN Git Service

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