OSDN Git Service

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