OSDN Git Service

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