OSDN Git Service

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