1 /* This file contains code written by Ron Guilmette (rfg@ncd.com) for
2 Network Computing Devices, August, September, October, November 1990.
4 Output Dwarf format symbol table information from the GNU C compiler.
5 Copyright (C) 1992, 1993 Free Software Foundation, Inc.
7 This file is part of GNU CC.
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)
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.
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. */
25 #ifdef DWARF_DEBUGGING_INFO
31 #include "hard-reg-set.h"
32 #include "insn-config.h"
38 #define DWARF_VERSION 1
41 /* #define NDEBUG 1 */
44 #if defined(DWARF_TIMESTAMPS)
47 #else /* !defined(POSIX) */
48 #include <sys/types.h>
50 extern time_t time (time_t *);
51 #else /* !defined(__STDC__) */
52 extern time_t time ();
53 #endif /* !defined(__STDC__) */
54 #endif /* !defined(POSIX) */
55 #endif /* defined(DWARF_TIMESTAMPS) */
57 extern char *getpwd ();
59 extern char *index ();
60 extern char *rindex ();
62 /* IMPORTANT NOTE: Please see the file README.DWARF for important details
63 regarding the GNU implementation of Dwarf. */
65 /* NOTE: In the comments in this file, many references are made to
66 so called "Debugging Information Entries". For the sake of brevity,
67 this term is abbreviated to `DIE' throughout the remainder of this
70 /* Note that the implementation of C++ support herein is (as yet) unfinished.
71 If you want to try to complete it, more power to you. */
73 #if defined(__GNUC__) && (NDEBUG == 1)
74 #define inline static inline
79 /* How to start an assembler comment. */
80 #ifndef ASM_COMMENT_START
81 #define ASM_COMMENT_START ";#"
84 /* How to print out a register name. */
86 #define PRINT_REG(RTX, CODE, FILE) \
87 fprintf ((FILE), "%s", reg_names[REGNO (RTX)])
90 /* Define a macro which returns non-zero for any tagged type which is
91 used (directly or indirectly) in the specification of either some
92 function's return type or some formal parameter of some function.
93 We use this macro when we are operating in "terse" mode to help us
94 know what tagged types have to be represented in Dwarf (even in
95 terse mode) and which ones don't.
97 A flag bit with this meaning really should be a part of the normal
98 GCC ..._TYPE nodes, but at the moment, there is no such bit defined
99 for these nodes. For now, we have to just fake it. It it safe for
100 us to simply return zero for all complete tagged types (which will
101 get forced out anyway if they were used in the specification of some
102 formal or return type) and non-zero for all incomplete tagged types.
105 #define TYPE_USED_FOR_FUNCTION(tagged_type) (TYPE_SIZE (tagged_type) == 0)
107 extern int flag_traditional;
108 extern char *version_string;
109 extern char *language_string;
111 /* Maximum size (in bytes) of an artificially generated label. */
113 #define MAX_ARTIFICIAL_LABEL_BYTES 30
115 /* Make sure we know the sizes of the various types dwarf can describe.
116 These are only defaults. If the sizes are different for your target,
117 you should override these values by defining the appropriate symbols
118 in your tm.h file. */
120 #ifndef CHAR_TYPE_SIZE
121 #define CHAR_TYPE_SIZE BITS_PER_UNIT
124 #ifndef SHORT_TYPE_SIZE
125 #define SHORT_TYPE_SIZE (BITS_PER_UNIT * 2)
128 #ifndef INT_TYPE_SIZE
129 #define INT_TYPE_SIZE BITS_PER_WORD
132 #ifndef LONG_TYPE_SIZE
133 #define LONG_TYPE_SIZE BITS_PER_WORD
136 #ifndef LONG_LONG_TYPE_SIZE
137 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
140 #ifndef WCHAR_TYPE_SIZE
141 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
144 #ifndef WCHAR_UNSIGNED
145 #define WCHAR_UNSIGNED 0
148 #ifndef FLOAT_TYPE_SIZE
149 #define FLOAT_TYPE_SIZE BITS_PER_WORD
152 #ifndef DOUBLE_TYPE_SIZE
153 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
156 #ifndef LONG_DOUBLE_TYPE_SIZE
157 #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
160 /* Structure to keep track of source filenames. */
162 struct filename_entry {
167 typedef struct filename_entry filename_entry;
169 /* Pointer to an array of elements, each one having the structure above. */
171 static filename_entry *filename_table;
173 /* Total number of entries in the table (i.e. array) pointed to by
174 `filename_table'. This is the *total* and includes both used and
177 static unsigned ft_entries_allocated;
179 /* Number of entries in the filename_table which are actually in use. */
181 static unsigned ft_entries;
183 /* Size (in elements) of increments by which we may expand the filename
184 table. Actually, a single hunk of space of this size should be enough
185 for most typical programs. */
187 #define FT_ENTRIES_INCREMENT 64
189 /* Local pointer to the name of the main input file. Initialized in
192 static char *primary_filename;
194 /* Pointer to the most recent filename for which we produced some line info. */
196 static char *last_filename;
198 /* For Dwarf output, we must assign lexical-blocks id numbers
199 in the order in which their beginnings are encountered.
200 We output Dwarf debugging info that refers to the beginnings
201 and ends of the ranges of code for each lexical block with
202 assembler labels ..Bn and ..Bn.e, where n is the block number.
203 The labels themselves are generated in final.c, which assigns
204 numbers to the blocks in the same way. */
206 static unsigned next_block_number = 2;
208 /* Counter to generate unique names for DIEs. */
210 static unsigned next_unused_dienum = 1;
212 /* Number of the DIE which is currently being generated. */
214 static unsigned current_dienum;
216 /* Number to use for the special "pubname" label on the next DIE which
217 represents a function or data object defined in this compilation
218 unit which has "extern" linkage. */
220 static next_pubname_number = 0;
222 #define NEXT_DIE_NUM pending_sibling_stack[pending_siblings-1]
224 /* Pointer to a dynamically allocated list of pre-reserved and still
225 pending sibling DIE numbers. Note that this list will grow as needed. */
227 static unsigned *pending_sibling_stack;
229 /* Counter to keep track of the number of pre-reserved and still pending
230 sibling DIE numbers. */
232 static unsigned pending_siblings;
234 /* The currently allocated size of the above list (expressed in number of
237 static unsigned pending_siblings_allocated;
239 /* Size (in elements) of increments by which we may expand the pending
240 sibling stack. Actually, a single hunk of space of this size should
241 be enough for most typical programs. */
243 #define PENDING_SIBLINGS_INCREMENT 64
245 /* Non-zero if we are performing our file-scope finalization pass and if
246 we should force out Dwarf descriptions of any and all file-scope
247 tagged types which are still incomplete types. */
249 static int finalizing = 0;
251 /* A pointer to the base of a list of pending types which we haven't
252 generated DIEs for yet, but which we will have to come back to
255 static tree *pending_types_list;
257 /* Number of elements currently allocated for the pending_types_list. */
259 static unsigned pending_types_allocated;
261 /* Number of elements of pending_types_list currently in use. */
263 static unsigned pending_types;
265 /* Size (in elements) of increments by which we may expand the pending
266 types list. Actually, a single hunk of space of this size should
267 be enough for most typical programs. */
269 #define PENDING_TYPES_INCREMENT 64
271 /* Pointer to an artificial RECORD_TYPE which we create in dwarfout_init.
272 This is used in a hack to help us get the DIEs describing types of
273 formal parameters to come *after* all of the DIEs describing the formal
274 parameters themselves. That's necessary in order to be compatible
275 with what the brain-damaged svr4 SDB debugger requires. */
277 static tree fake_containing_scope;
279 /* The number of the current function definition that we are generating
280 debugging information for. These numbers range from 1 up to the maximum
281 number of function definitions contained within the current compilation
282 unit. These numbers are used to create unique labels for various things
283 contained within various function definitions. */
285 static unsigned current_funcdef_number = 1;
287 /* A pointer to the ..._DECL node which we have most recently been working
288 on. We keep this around just in case something about it looks screwy
289 and we want to tell the user what the source coordinates for the actual
292 static tree dwarf_last_decl;
294 /* Forward declarations for functions defined in this file. */
296 static void output_type ();
297 static void type_attribute ();
298 static void output_decls_for_scope ();
299 static void output_decl ();
300 static unsigned lookup_filename ();
302 /* Definitions of defaults for assembler-dependent names of various
303 pseudo-ops and section names.
305 Theses may be overridden in your tm.h file (if necessary) for your
306 particular assembler. The default values provided here correspond to
307 what is expected by "standard" AT&T System V.4 assemblers. */
310 #define FILE_ASM_OP ".file"
312 #ifndef VERSION_ASM_OP
313 #define VERSION_ASM_OP ".version"
315 #ifndef UNALIGNED_SHORT_ASM_OP
316 #define UNALIGNED_SHORT_ASM_OP ".2byte"
318 #ifndef UNALIGNED_INT_ASM_OP
319 #define UNALIGNED_INT_ASM_OP ".4byte"
322 #define ASM_BYTE_OP ".byte"
325 #define SET_ASM_OP ".set"
328 /* Pseudo-ops for pushing the current section onto the section stack (and
329 simultaneously changing to a new section) and for poping back to the
330 section we were in immediately before this one. Note that most svr4
331 assemblers only maintain a one level stack... you can push all the
332 sections you want, but you can only pop out one level. (The sparc
333 svr4 assembler is an exception to this general rule.) That's
334 OK because we only use at most one level of the section stack herein. */
336 #ifndef PUSHSECTION_ASM_OP
337 #define PUSHSECTION_ASM_OP ".section"
339 #ifndef POPSECTION_ASM_OP
340 #define POPSECTION_ASM_OP ".previous"
343 /* The default format used by the ASM_OUTPUT_PUSH_SECTION macro (see below)
344 to print the PUSHSECTION_ASM_OP and the section name. The default here
345 works for almost all svr4 assemblers, except for the sparc, where the
346 section name must be enclosed in double quotes. (See sparcv4.h.) */
348 #ifndef PUSHSECTION_FORMAT
349 #define PUSHSECTION_FORMAT "%s\t%s\n"
352 #ifndef DEBUG_SECTION
353 #define DEBUG_SECTION ".debug"
356 #define LINE_SECTION ".line"
358 #ifndef SFNAMES_SECTION
359 #define SFNAMES_SECTION ".debug_sfnames"
361 #ifndef SRCINFO_SECTION
362 #define SRCINFO_SECTION ".debug_srcinfo"
364 #ifndef MACINFO_SECTION
365 #define MACINFO_SECTION ".debug_macinfo"
367 #ifndef PUBNAMES_SECTION
368 #define PUBNAMES_SECTION ".debug_pubnames"
370 #ifndef ARANGES_SECTION
371 #define ARANGES_SECTION ".debug_aranges"
374 #define TEXT_SECTION ".text"
377 #define DATA_SECTION ".data"
379 #ifndef DATA1_SECTION
380 #define DATA1_SECTION ".data1"
382 #ifndef RODATA_SECTION
383 #define RODATA_SECTION ".rodata"
385 #ifndef RODATA1_SECTION
386 #define RODATA1_SECTION ".rodata1"
389 #define BSS_SECTION ".bss"
392 /* Definitions of defaults for formats and names of various special
393 (artificial) labels which may be generated within this file (when
394 the -g options is used and DWARF_DEBUGGING_INFO is in effect.
396 If necessary, these may be overridden from within your tm.h file,
397 but typically, you should never need to override these.
399 These labels have been hacked (temporarily) so that they all begin with
400 a `.L' sequence so as to appease the stock sparc/svr4 assembler and the
401 stock m88k/svr4 assembler, both of which need to see .L at the start of
402 a label in order to prevent that label from going into the linker symbol
403 table). When I get time, I'll have to fix this the right way so that we
404 will use ASM_GENERATE_INTERNAL_LABEL and ASM_OUTPUT_INTERNAL_LABEL herein,
405 but that will require a rather massive set of changes. For the moment,
406 the following definitions out to produce the right results for all svr4
407 and svr3 assemblers. -- rfg
410 #ifndef TEXT_BEGIN_LABEL
411 #define TEXT_BEGIN_LABEL ".L_text_b"
413 #ifndef TEXT_END_LABEL
414 #define TEXT_END_LABEL ".L_text_e"
417 #ifndef DATA_BEGIN_LABEL
418 #define DATA_BEGIN_LABEL ".L_data_b"
420 #ifndef DATA_END_LABEL
421 #define DATA_END_LABEL ".L_data_e"
424 #ifndef DATA1_BEGIN_LABEL
425 #define DATA1_BEGIN_LABEL ".L_data1_b"
427 #ifndef DATA1_END_LABEL
428 #define DATA1_END_LABEL ".L_data1_e"
431 #ifndef RODATA_BEGIN_LABEL
432 #define RODATA_BEGIN_LABEL ".L_rodata_b"
434 #ifndef RODATA_END_LABEL
435 #define RODATA_END_LABEL ".L_rodata_e"
438 #ifndef RODATA1_BEGIN_LABEL
439 #define RODATA1_BEGIN_LABEL ".L_rodata1_b"
441 #ifndef RODATA1_END_LABEL
442 #define RODATA1_END_LABEL ".L_rodata1_e"
445 #ifndef BSS_BEGIN_LABEL
446 #define BSS_BEGIN_LABEL ".L_bss_b"
448 #ifndef BSS_END_LABEL
449 #define BSS_END_LABEL ".L_bss_e"
452 #ifndef LINE_BEGIN_LABEL
453 #define LINE_BEGIN_LABEL ".L_line_b"
455 #ifndef LINE_LAST_ENTRY_LABEL
456 #define LINE_LAST_ENTRY_LABEL ".L_line_last"
458 #ifndef LINE_END_LABEL
459 #define LINE_END_LABEL ".L_line_e"
462 #ifndef DEBUG_BEGIN_LABEL
463 #define DEBUG_BEGIN_LABEL ".L_debug_b"
465 #ifndef SFNAMES_BEGIN_LABEL
466 #define SFNAMES_BEGIN_LABEL ".L_sfnames_b"
468 #ifndef SRCINFO_BEGIN_LABEL
469 #define SRCINFO_BEGIN_LABEL ".L_srcinfo_b"
471 #ifndef MACINFO_BEGIN_LABEL
472 #define MACINFO_BEGIN_LABEL ".L_macinfo_b"
475 #ifndef DIE_BEGIN_LABEL_FMT
476 #define DIE_BEGIN_LABEL_FMT ".L_D%u"
478 #ifndef DIE_END_LABEL_FMT
479 #define DIE_END_LABEL_FMT ".L_D%u_e"
481 #ifndef PUB_DIE_LABEL_FMT
482 #define PUB_DIE_LABEL_FMT ".L_P%u"
484 #ifndef INSN_LABEL_FMT
485 #define INSN_LABEL_FMT ".L_I%u_%u"
487 #ifndef BLOCK_BEGIN_LABEL_FMT
488 #define BLOCK_BEGIN_LABEL_FMT ".L_B%u"
490 #ifndef BLOCK_END_LABEL_FMT
491 #define BLOCK_END_LABEL_FMT ".L_B%u_e"
493 #ifndef SS_BEGIN_LABEL_FMT
494 #define SS_BEGIN_LABEL_FMT ".L_s%u"
496 #ifndef SS_END_LABEL_FMT
497 #define SS_END_LABEL_FMT ".L_s%u_e"
499 #ifndef EE_BEGIN_LABEL_FMT
500 #define EE_BEGIN_LABEL_FMT ".L_e%u"
502 #ifndef EE_END_LABEL_FMT
503 #define EE_END_LABEL_FMT ".L_e%u_e"
505 #ifndef MT_BEGIN_LABEL_FMT
506 #define MT_BEGIN_LABEL_FMT ".L_t%u"
508 #ifndef MT_END_LABEL_FMT
509 #define MT_END_LABEL_FMT ".L_t%u_e"
511 #ifndef LOC_BEGIN_LABEL_FMT
512 #define LOC_BEGIN_LABEL_FMT ".L_l%u"
514 #ifndef LOC_END_LABEL_FMT
515 #define LOC_END_LABEL_FMT ".L_l%u_e"
517 #ifndef BOUND_BEGIN_LABEL_FMT
518 #define BOUND_BEGIN_LABEL_FMT ".L_b%u_%u_%c"
520 #ifndef BOUND_END_LABEL_FMT
521 #define BOUND_END_LABEL_FMT ".L_b%u_%u_%c_e"
523 #ifndef DERIV_BEGIN_LABEL_FMT
524 #define DERIV_BEGIN_LABEL_FMT ".L_d%u"
526 #ifndef DERIV_END_LABEL_FMT
527 #define DERIV_END_LABEL_FMT ".L_d%u_e"
529 #ifndef SL_BEGIN_LABEL_FMT
530 #define SL_BEGIN_LABEL_FMT ".L_sl%u"
532 #ifndef SL_END_LABEL_FMT
533 #define SL_END_LABEL_FMT ".L_sl%u_e"
535 #ifndef BODY_BEGIN_LABEL_FMT
536 #define BODY_BEGIN_LABEL_FMT ".L_b%u"
538 #ifndef BODY_END_LABEL_FMT
539 #define BODY_END_LABEL_FMT ".L_b%u_e"
541 #ifndef FUNC_END_LABEL_FMT
542 #define FUNC_END_LABEL_FMT ".L_f%u_e"
544 #ifndef TYPE_NAME_FMT
545 #define TYPE_NAME_FMT ".L_T%u"
547 #ifndef DECL_NAME_FMT
548 #define DECL_NAME_FMT ".L_E%u"
550 #ifndef LINE_CODE_LABEL_FMT
551 #define LINE_CODE_LABEL_FMT ".L_LC%u"
553 #ifndef SFNAMES_ENTRY_LABEL_FMT
554 #define SFNAMES_ENTRY_LABEL_FMT ".L_F%u"
556 #ifndef LINE_ENTRY_LABEL_FMT
557 #define LINE_ENTRY_LABEL_FMT ".L_LE%u"
560 /* Definitions of defaults for various types of primitive assembly language
563 If necessary, these may be overridden from within your tm.h file,
564 but typically, you shouldn't need to override these. One known
565 exception is ASM_OUTPUT_DEF which has to be different for stock
566 sparc/svr4 assemblers.
569 #ifndef ASM_OUTPUT_PUSH_SECTION
570 #define ASM_OUTPUT_PUSH_SECTION(FILE, SECTION) \
571 fprintf ((FILE), PUSHSECTION_FORMAT, PUSHSECTION_ASM_OP, SECTION)
574 #ifndef ASM_OUTPUT_POP_SECTION
575 #define ASM_OUTPUT_POP_SECTION(FILE) \
576 fprintf ((FILE), "\t%s\n", POPSECTION_ASM_OP)
579 #ifndef ASM_OUTPUT_SOURCE_FILENAME
580 #define ASM_OUTPUT_SOURCE_FILENAME(FILE,NAME) \
581 do { fprintf (FILE, "\t%s\t", FILE_ASM_OP); \
582 output_quoted_string (FILE, NAME); \
583 fputc ('\n', FILE); \
587 #ifndef ASM_OUTPUT_DEF
588 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
589 do { fprintf ((FILE), "\t%s\t", SET_ASM_OP); \
590 assemble_name (FILE, LABEL1); \
591 fprintf (FILE, ","); \
592 assemble_name (FILE, LABEL2); \
593 fprintf (FILE, "\n"); \
597 #ifndef ASM_OUTPUT_DWARF_DELTA2
598 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
599 do { fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \
600 assemble_name (FILE, LABEL1); \
601 fprintf (FILE, "-"); \
602 assemble_name (FILE, LABEL2); \
603 fprintf (FILE, "\n"); \
607 #ifndef ASM_OUTPUT_DWARF_DELTA4
608 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
609 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
610 assemble_name (FILE, LABEL1); \
611 fprintf (FILE, "-"); \
612 assemble_name (FILE, LABEL2); \
613 fprintf (FILE, "\n"); \
617 #ifndef ASM_OUTPUT_DWARF_TAG
618 #define ASM_OUTPUT_DWARF_TAG(FILE,TAG) \
620 fprintf ((FILE), "\t%s\t0x%x", \
621 UNALIGNED_SHORT_ASM_OP, (unsigned) TAG); \
622 if (flag_verbose_asm) \
623 fprintf ((FILE), "\t%s %s", \
624 ASM_COMMENT_START, dwarf_tag_name (TAG)); \
625 fputc ('\n', (FILE)); \
629 #ifndef ASM_OUTPUT_DWARF_ATTRIBUTE
630 #define ASM_OUTPUT_DWARF_ATTRIBUTE(FILE,ATTR) \
632 fprintf ((FILE), "\t%s\t0x%x", \
633 UNALIGNED_SHORT_ASM_OP, (unsigned) ATTR); \
634 if (flag_verbose_asm) \
635 fprintf ((FILE), "\t%s %s", \
636 ASM_COMMENT_START, dwarf_attr_name (ATTR)); \
637 fputc ('\n', (FILE)); \
641 #ifndef ASM_OUTPUT_DWARF_STACK_OP
642 #define ASM_OUTPUT_DWARF_STACK_OP(FILE,OP) \
644 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) OP); \
645 if (flag_verbose_asm) \
646 fprintf ((FILE), "\t%s %s", \
647 ASM_COMMENT_START, dwarf_stack_op_name (OP)); \
648 fputc ('\n', (FILE)); \
652 #ifndef ASM_OUTPUT_DWARF_FUND_TYPE
653 #define ASM_OUTPUT_DWARF_FUND_TYPE(FILE,FT) \
655 fprintf ((FILE), "\t%s\t0x%x", \
656 UNALIGNED_SHORT_ASM_OP, (unsigned) FT); \
657 if (flag_verbose_asm) \
658 fprintf ((FILE), "\t%s %s", \
659 ASM_COMMENT_START, dwarf_fund_type_name (FT)); \
660 fputc ('\n', (FILE)); \
664 #ifndef ASM_OUTPUT_DWARF_FMT_BYTE
665 #define ASM_OUTPUT_DWARF_FMT_BYTE(FILE,FMT) \
667 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) FMT); \
668 if (flag_verbose_asm) \
669 fprintf ((FILE), "\t%s %s", \
670 ASM_COMMENT_START, dwarf_fmt_byte_name (FMT)); \
671 fputc ('\n', (FILE)); \
675 #ifndef ASM_OUTPUT_DWARF_TYPE_MODIFIER
676 #define ASM_OUTPUT_DWARF_TYPE_MODIFIER(FILE,MOD) \
678 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) MOD); \
679 if (flag_verbose_asm) \
680 fprintf ((FILE), "\t%s %s", \
681 ASM_COMMENT_START, dwarf_typemod_name (MOD)); \
682 fputc ('\n', (FILE)); \
686 #ifndef ASM_OUTPUT_DWARF_ADDR
687 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
688 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
689 assemble_name (FILE, LABEL); \
690 fprintf (FILE, "\n"); \
694 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
695 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX) \
697 fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
698 output_addr_const ((FILE), (RTX)); \
699 fputc ('\n', (FILE)); \
703 #ifndef ASM_OUTPUT_DWARF_REF
704 #define ASM_OUTPUT_DWARF_REF(FILE,LABEL) \
705 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
706 assemble_name (FILE, LABEL); \
707 fprintf (FILE, "\n"); \
711 #ifndef ASM_OUTPUT_DWARF_DATA1
712 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
713 fprintf ((FILE), "\t%s\t0x%x\n", ASM_BYTE_OP, VALUE)
716 #ifndef ASM_OUTPUT_DWARF_DATA2
717 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
718 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_SHORT_ASM_OP, (unsigned) VALUE)
721 #ifndef ASM_OUTPUT_DWARF_DATA4
722 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
723 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, (unsigned) VALUE)
726 #ifndef ASM_OUTPUT_DWARF_DATA8
727 #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \
729 if (WORDS_BIG_ENDIAN) \
731 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
732 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
736 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
737 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
742 #ifndef ASM_OUTPUT_DWARF_STRING
743 #define ASM_OUTPUT_DWARF_STRING(FILE,P) \
744 ASM_OUTPUT_ASCII ((FILE), P, strlen (P)+1)
747 /************************ general utility functions **************************/
753 register char *p = (char *) xmalloc (strlen (s) + 1);
763 return (((GET_CODE (rtl) == REG) && (REGNO (rtl) >= FIRST_PSEUDO_REGISTER))
764 || ((GET_CODE (rtl) == SUBREG)
765 && (REGNO (XEXP (rtl, 0)) >= FIRST_PSEUDO_REGISTER)));
769 type_main_variant (type)
772 type = TYPE_MAIN_VARIANT (type);
774 /* There really should be only one main variant among any group of variants
775 of a given type (and all of the MAIN_VARIANT values for all members of
776 the group should point to that one type) but sometimes the C front-end
777 messes this up for array types, so we work around that bug here. */
779 if (TREE_CODE (type) == ARRAY_TYPE)
781 while (type != TYPE_MAIN_VARIANT (type))
782 type = TYPE_MAIN_VARIANT (type);
788 /* Return non-zero if the given type node represents a tagged type. */
791 is_tagged_type (type)
794 register enum tree_code code = TREE_CODE (type);
796 return (code == RECORD_TYPE || code == UNION_TYPE
797 || code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
802 register unsigned tag;
806 case TAG_padding: return "TAG_padding";
807 case TAG_array_type: return "TAG_array_type";
808 case TAG_class_type: return "TAG_class_type";
809 case TAG_entry_point: return "TAG_entry_point";
810 case TAG_enumeration_type: return "TAG_enumeration_type";
811 case TAG_formal_parameter: return "TAG_formal_parameter";
812 case TAG_global_subroutine: return "TAG_global_subroutine";
813 case TAG_global_variable: return "TAG_global_variable";
814 case TAG_label: return "TAG_label";
815 case TAG_lexical_block: return "TAG_lexical_block";
816 case TAG_local_variable: return "TAG_local_variable";
817 case TAG_member: return "TAG_member";
818 case TAG_pointer_type: return "TAG_pointer_type";
819 case TAG_reference_type: return "TAG_reference_type";
820 case TAG_compile_unit: return "TAG_compile_unit";
821 case TAG_string_type: return "TAG_string_type";
822 case TAG_structure_type: return "TAG_structure_type";
823 case TAG_subroutine: return "TAG_subroutine";
824 case TAG_subroutine_type: return "TAG_subroutine_type";
825 case TAG_typedef: return "TAG_typedef";
826 case TAG_union_type: return "TAG_union_type";
827 case TAG_unspecified_parameters: return "TAG_unspecified_parameters";
828 case TAG_variant: return "TAG_variant";
829 case TAG_common_block: return "TAG_common_block";
830 case TAG_common_inclusion: return "TAG_common_inclusion";
831 case TAG_inheritance: return "TAG_inheritance";
832 case TAG_inlined_subroutine: return "TAG_inlined_subroutine";
833 case TAG_module: return "TAG_module";
834 case TAG_ptr_to_member_type: return "TAG_ptr_to_member_type";
835 case TAG_set_type: return "TAG_set_type";
836 case TAG_subrange_type: return "TAG_subrange_type";
837 case TAG_with_stmt: return "TAG_with_stmt";
839 /* GNU extensions. */
841 case TAG_format_label: return "TAG_format_label";
842 case TAG_namelist: return "TAG_namelist";
843 case TAG_function_template: return "TAG_function_template";
844 case TAG_class_template: return "TAG_class_template";
846 default: return "TAG_<unknown>";
851 dwarf_attr_name (attr)
852 register unsigned attr;
856 case AT_sibling: return "AT_sibling";
857 case AT_location: return "AT_location";
858 case AT_name: return "AT_name";
859 case AT_fund_type: return "AT_fund_type";
860 case AT_mod_fund_type: return "AT_mod_fund_type";
861 case AT_user_def_type: return "AT_user_def_type";
862 case AT_mod_u_d_type: return "AT_mod_u_d_type";
863 case AT_ordering: return "AT_ordering";
864 case AT_subscr_data: return "AT_subscr_data";
865 case AT_byte_size: return "AT_byte_size";
866 case AT_bit_offset: return "AT_bit_offset";
867 case AT_bit_size: return "AT_bit_size";
868 case AT_element_list: return "AT_element_list";
869 case AT_stmt_list: return "AT_stmt_list";
870 case AT_low_pc: return "AT_low_pc";
871 case AT_high_pc: return "AT_high_pc";
872 case AT_language: return "AT_language";
873 case AT_member: return "AT_member";
874 case AT_discr: return "AT_discr";
875 case AT_discr_value: return "AT_discr_value";
876 case AT_string_length: return "AT_string_length";
877 case AT_common_reference: return "AT_common_reference";
878 case AT_comp_dir: return "AT_comp_dir";
879 case AT_const_value_string: return "AT_const_value_string";
880 case AT_const_value_data2: return "AT_const_value_data2";
881 case AT_const_value_data4: return "AT_const_value_data4";
882 case AT_const_value_data8: return "AT_const_value_data8";
883 case AT_const_value_block2: return "AT_const_value_block2";
884 case AT_const_value_block4: return "AT_const_value_block4";
885 case AT_containing_type: return "AT_containing_type";
886 case AT_default_value_addr: return "AT_default_value_addr";
887 case AT_default_value_data2: return "AT_default_value_data2";
888 case AT_default_value_data4: return "AT_default_value_data4";
889 case AT_default_value_data8: return "AT_default_value_data8";
890 case AT_default_value_string: return "AT_default_value_string";
891 case AT_friends: return "AT_friends";
892 case AT_inline: return "AT_inline";
893 case AT_is_optional: return "AT_is_optional";
894 case AT_lower_bound_ref: return "AT_lower_bound_ref";
895 case AT_lower_bound_data2: return "AT_lower_bound_data2";
896 case AT_lower_bound_data4: return "AT_lower_bound_data4";
897 case AT_lower_bound_data8: return "AT_lower_bound_data8";
898 case AT_private: return "AT_private";
899 case AT_producer: return "AT_producer";
900 case AT_program: return "AT_program";
901 case AT_protected: return "AT_protected";
902 case AT_prototyped: return "AT_prototyped";
903 case AT_public: return "AT_public";
904 case AT_pure_virtual: return "AT_pure_virtual";
905 case AT_return_addr: return "AT_return_addr";
906 case AT_abstract_origin: return "AT_abstract_origin";
907 case AT_start_scope: return "AT_start_scope";
908 case AT_stride_size: return "AT_stride_size";
909 case AT_upper_bound_ref: return "AT_upper_bound_ref";
910 case AT_upper_bound_data2: return "AT_upper_bound_data2";
911 case AT_upper_bound_data4: return "AT_upper_bound_data4";
912 case AT_upper_bound_data8: return "AT_upper_bound_data8";
913 case AT_virtual: return "AT_virtual";
917 case AT_sf_names: return "AT_sf_names";
918 case AT_src_info: return "AT_src_info";
919 case AT_mac_info: return "AT_mac_info";
920 case AT_src_coords: return "AT_src_coords";
921 case AT_body_begin: return "AT_body_begin";
922 case AT_body_end: return "AT_body_end";
924 default: return "AT_<unknown>";
929 dwarf_stack_op_name (op)
930 register unsigned op;
934 case OP_REG: return "OP_REG";
935 case OP_BASEREG: return "OP_BASEREG";
936 case OP_ADDR: return "OP_ADDR";
937 case OP_CONST: return "OP_CONST";
938 case OP_DEREF2: return "OP_DEREF2";
939 case OP_DEREF4: return "OP_DEREF4";
940 case OP_ADD: return "OP_ADD";
941 default: return "OP_<unknown>";
946 dwarf_typemod_name (mod)
947 register unsigned mod;
951 case MOD_pointer_to: return "MOD_pointer_to";
952 case MOD_reference_to: return "MOD_reference_to";
953 case MOD_const: return "MOD_const";
954 case MOD_volatile: return "MOD_volatile";
955 default: return "MOD_<unknown>";
960 dwarf_fmt_byte_name (fmt)
961 register unsigned fmt;
965 case FMT_FT_C_C: return "FMT_FT_C_C";
966 case FMT_FT_C_X: return "FMT_FT_C_X";
967 case FMT_FT_X_C: return "FMT_FT_X_C";
968 case FMT_FT_X_X: return "FMT_FT_X_X";
969 case FMT_UT_C_C: return "FMT_UT_C_C";
970 case FMT_UT_C_X: return "FMT_UT_C_X";
971 case FMT_UT_X_C: return "FMT_UT_X_C";
972 case FMT_UT_X_X: return "FMT_UT_X_X";
973 case FMT_ET: return "FMT_ET";
974 default: return "FMT_<unknown>";
978 dwarf_fund_type_name (ft)
979 register unsigned ft;
983 case FT_char: return "FT_char";
984 case FT_signed_char: return "FT_signed_char";
985 case FT_unsigned_char: return "FT_unsigned_char";
986 case FT_short: return "FT_short";
987 case FT_signed_short: return "FT_signed_short";
988 case FT_unsigned_short: return "FT_unsigned_short";
989 case FT_integer: return "FT_integer";
990 case FT_signed_integer: return "FT_signed_integer";
991 case FT_unsigned_integer: return "FT_unsigned_integer";
992 case FT_long: return "FT_long";
993 case FT_signed_long: return "FT_signed_long";
994 case FT_unsigned_long: return "FT_unsigned_long";
995 case FT_pointer: return "FT_pointer";
996 case FT_float: return "FT_float";
997 case FT_dbl_prec_float: return "FT_dbl_prec_float";
998 case FT_ext_prec_float: return "FT_ext_prec_float";
999 case FT_complex: return "FT_complex";
1000 case FT_dbl_prec_complex: return "FT_dbl_prec_complex";
1001 case FT_void: return "FT_void";
1002 case FT_boolean: return "FT_boolean";
1003 case FT_ext_prec_complex: return "FT_ext_prec_complex";
1004 case FT_label: return "FT_label";
1006 /* GNU extensions. */
1008 case FT_long_long: return "FT_long_long";
1009 case FT_signed_long_long: return "FT_signed_long_long";
1010 case FT_unsigned_long_long: return "FT_unsigned_long_long";
1012 case FT_int8: return "FT_int8";
1013 case FT_signed_int8: return "FT_signed_int8";
1014 case FT_unsigned_int8: return "FT_unsigned_int8";
1015 case FT_int16: return "FT_int16";
1016 case FT_signed_int16: return "FT_signed_int16";
1017 case FT_unsigned_int16: return "FT_unsigned_int16";
1018 case FT_int32: return "FT_int32";
1019 case FT_signed_int32: return "FT_signed_int32";
1020 case FT_unsigned_int32: return "FT_unsigned_int32";
1021 case FT_int64: return "FT_int64";
1022 case FT_signed_int64: return "FT_signed_int64";
1023 case FT_unsigned_int64: return "FT_signed_int64";
1025 case FT_real32: return "FT_real32";
1026 case FT_real64: return "FT_real64";
1027 case FT_real96: return "FT_real96";
1028 case FT_real128: return "FT_real128";
1030 default: return "FT_<unknown>";
1034 /* Determine the "ultimate origin" of a decl. The decl may be an
1035 inlined instance of an inlined instance of a decl which is local
1036 to an inline function, so we have to trace all of the way back
1037 through the origin chain to find out what sort of node actually
1038 served as the original seed for the given block. */
1041 decl_ultimate_origin (decl)
1044 register tree immediate_origin = DECL_ABSTRACT_ORIGIN (decl);
1046 if (immediate_origin == NULL)
1050 register tree ret_val;
1051 register tree lookahead = immediate_origin;
1055 ret_val = lookahead;
1056 lookahead = DECL_ABSTRACT_ORIGIN (ret_val);
1058 while (lookahead != NULL && lookahead != ret_val);
1063 /* Determine the "ultimate origin" of a block. The block may be an
1064 inlined instance of an inlined instance of a block which is local
1065 to an inline function, so we have to trace all of the way back
1066 through the origin chain to find out what sort of node actually
1067 served as the original seed for the given block. */
1070 block_ultimate_origin (block)
1071 register tree block;
1073 register tree immediate_origin = BLOCK_ABSTRACT_ORIGIN (block);
1075 if (immediate_origin == NULL)
1079 register tree ret_val;
1080 register tree lookahead = immediate_origin;
1084 ret_val = lookahead;
1085 lookahead = (TREE_CODE (ret_val) == BLOCK)
1086 ? BLOCK_ABSTRACT_ORIGIN (ret_val)
1089 while (lookahead != NULL && lookahead != ret_val);
1095 output_unsigned_leb128 (value)
1096 register unsigned long value;
1098 register unsigned long orig_value = value;
1102 register unsigned byte = (value & 0x7f);
1105 if (value != 0) /* more bytes to follow */
1107 fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) byte);
1108 if (flag_verbose_asm && value == 0)
1109 fprintf (asm_out_file, "\t%s ULEB128 number - value = %u",
1110 ASM_COMMENT_START, orig_value);
1111 fputc ('\n', asm_out_file);
1117 output_signed_leb128 (value)
1118 register long value;
1120 register long orig_value = value;
1121 register int negative = (value < 0);
1126 register unsigned byte = (value & 0x7f);
1130 value |= 0xfe000000; /* manually sign extend */
1131 if (((value == 0) && ((byte & 0x40) == 0))
1132 || ((value == -1) && ((byte & 0x40) == 1)))
1139 fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) byte);
1140 if (flag_verbose_asm && more == 0)
1141 fprintf (asm_out_file, "\t%s SLEB128 number - value = %d",
1142 ASM_COMMENT_START, orig_value);
1143 fputc ('\n', asm_out_file);
1148 /**************** utility functions for attribute functions ******************/
1150 /* Given a pointer to a BLOCK node return non-zero if (and only if) the
1151 node in question represents the outermost pair of curly braces (i.e.
1152 the "body block") of a function or method.
1154 For any BLOCK node representing a "body block" of a function or method,
1155 the BLOCK_SUPERCONTEXT of the node will point to another BLOCK node
1156 which represents the outermost (function) scope for the function or
1157 method (i.e. the one which includes the formal parameters). The
1158 BLOCK_SUPERCONTEXT of *that* node in turn will point to the relevant
1163 is_body_block (stmt)
1166 if (TREE_CODE (stmt) == BLOCK)
1168 register tree parent = BLOCK_SUPERCONTEXT (stmt);
1170 if (TREE_CODE (parent) == BLOCK)
1172 register tree grandparent = BLOCK_SUPERCONTEXT (parent);
1174 if (TREE_CODE (grandparent) == FUNCTION_DECL)
1181 /* Given a pointer to a tree node for some type, return a Dwarf fundamental
1182 type code for the given type.
1184 This routine must only be called for GCC type nodes that correspond to
1185 Dwarf fundamental types.
1187 The current Dwarf draft specification calls for Dwarf fundamental types
1188 to accurately reflect the fact that a given type was either a "plain"
1189 integral type or an explicitly "signed" integral type. Unfortunately,
1190 we can't always do this, because GCC may already have thrown away the
1191 information about the precise way in which the type was originally
1194 typedef signed int my_type;
1196 struct s { my_type f; };
1198 Since we may be stuck here without enought information to do exactly
1199 what is called for in the Dwarf draft specification, we do the best
1200 that we can under the circumstances and always use the "plain" integral
1201 fundamental type codes for int, short, and long types. That's probably
1202 good enough. The additional accuracy called for in the current DWARF
1203 draft specification is probably never even useful in practice. */
1206 fundamental_type_code (type)
1209 if (TREE_CODE (type) == ERROR_MARK)
1212 switch (TREE_CODE (type))
1221 /* Carefully distinguish all the standard types of C,
1222 without messing up if the language is not C.
1223 Note that we check only for the names that contain spaces;
1224 other names might occur by coincidence in other languages. */
1225 if (TYPE_NAME (type) != 0
1226 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1227 && DECL_NAME (TYPE_NAME (type)) != 0
1228 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
1230 char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
1232 if (!strcmp (name, "unsigned char"))
1233 return FT_unsigned_char;
1234 if (!strcmp (name, "signed char"))
1235 return FT_signed_char;
1236 if (!strcmp (name, "unsigned int"))
1237 return FT_unsigned_integer;
1238 if (!strcmp (name, "short int"))
1240 if (!strcmp (name, "short unsigned int"))
1241 return FT_unsigned_short;
1242 if (!strcmp (name, "long int"))
1244 if (!strcmp (name, "long unsigned int"))
1245 return FT_unsigned_long;
1246 if (!strcmp (name, "long long int"))
1247 return FT_long_long; /* Not grok'ed by svr4 SDB */
1248 if (!strcmp (name, "long long unsigned int"))
1249 return FT_unsigned_long_long; /* Not grok'ed by svr4 SDB */
1252 /* Most integer types will be sorted out above, however, for the
1253 sake of special `array index' integer types, the following code
1254 is also provided. */
1256 if (TYPE_PRECISION (type) == INT_TYPE_SIZE)
1257 return (TREE_UNSIGNED (type) ? FT_unsigned_integer : FT_integer);
1259 if (TYPE_PRECISION (type) == LONG_TYPE_SIZE)
1260 return (TREE_UNSIGNED (type) ? FT_unsigned_long : FT_long);
1262 if (TYPE_PRECISION (type) == LONG_LONG_TYPE_SIZE)
1263 return (TREE_UNSIGNED (type) ? FT_unsigned_long_long : FT_long_long);
1265 if (TYPE_PRECISION (type) == SHORT_TYPE_SIZE)
1266 return (TREE_UNSIGNED (type) ? FT_unsigned_short : FT_short);
1268 if (TYPE_PRECISION (type) == CHAR_TYPE_SIZE)
1269 return (TREE_UNSIGNED (type) ? FT_unsigned_char : FT_char);
1274 /* Carefully distinguish all the standard types of C,
1275 without messing up if the language is not C. */
1276 if (TYPE_NAME (type) != 0
1277 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1278 && DECL_NAME (TYPE_NAME (type)) != 0
1279 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
1281 char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
1283 /* Note that here we can run afowl of a serious bug in "classic"
1284 svr4 SDB debuggers. They don't seem to understand the
1285 FT_ext_prec_float type (even though they should). */
1287 if (!strcmp (name, "long double"))
1288 return FT_ext_prec_float;
1291 if (TYPE_PRECISION (type) == DOUBLE_TYPE_SIZE)
1292 return FT_dbl_prec_float;
1293 if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE)
1296 /* Note that here we can run afowl of a serious bug in "classic"
1297 svr4 SDB debuggers. They don't seem to understand the
1298 FT_ext_prec_float type (even though they should). */
1300 if (TYPE_PRECISION (type) == LONG_DOUBLE_TYPE_SIZE)
1301 return FT_ext_prec_float;
1305 return FT_complex; /* GNU FORTRAN COMPLEX type. */
1308 return FT_char; /* GNU Pascal CHAR type. Not used in C. */
1311 return FT_boolean; /* GNU FORTRAN BOOLEAN type. */
1314 abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
1319 /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
1320 the Dwarf "root" type for the given input type. The Dwarf "root" type
1321 of a given type is generally the same as the given type, except that if
1322 the given type is a pointer or reference type, then the root type of
1323 the given type is the root type of the "basis" type for the pointer or
1324 reference type. (This definition of the "root" type is recursive.)
1325 Also, the root type of a `const' qualified type or a `volatile'
1326 qualified type is the root type of the given type without the
1333 if (TREE_CODE (type) == ERROR_MARK)
1334 return error_mark_node;
1336 switch (TREE_CODE (type))
1339 return error_mark_node;
1342 case REFERENCE_TYPE:
1343 return type_main_variant (root_type (TREE_TYPE (type)));
1346 return type_main_variant (type);
1350 /* Given a pointer to an arbitrary ..._TYPE tree node, write out a sequence
1351 of zero or more Dwarf "type-modifier" bytes applicable to the type. */
1354 write_modifier_bytes (type, decl_const, decl_volatile)
1356 register int decl_const;
1357 register int decl_volatile;
1359 if (TREE_CODE (type) == ERROR_MARK)
1362 if (TYPE_READONLY (type) || decl_const)
1363 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_const);
1364 if (TYPE_VOLATILE (type) || decl_volatile)
1365 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_volatile);
1366 switch (TREE_CODE (type))
1369 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_pointer_to);
1370 write_modifier_bytes (TREE_TYPE (type), 0, 0);
1373 case REFERENCE_TYPE:
1374 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_reference_to);
1375 write_modifier_bytes (TREE_TYPE (type), 0, 0);
1384 /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
1385 given input type is a Dwarf "fundamental" type. Otherwise return zero. */
1388 type_is_fundamental (type)
1391 switch (TREE_CODE (type))
1406 case QUAL_UNION_TYPE:
1411 case REFERENCE_TYPE:
1424 /* Given a pointer to some ..._DECL tree node, generate an assembly language
1425 equate directive which will associate a symbolic name with the current DIE.
1427 The name used is an artificial label generated from the DECL_UID number
1428 associated with the given decl node. The name it gets equated to is the
1429 symbolic label that we (previously) output at the start of the DIE that
1430 we are currently generating.
1432 Calling this function while generating some "decl related" form of DIE
1433 makes it possible to later refer to the DIE which represents the given
1434 decl simply by re-generating the symbolic name from the ..._DECL node's
1438 equate_decl_number_to_die_number (decl)
1441 /* In the case where we are generating a DIE for some ..._DECL node
1442 which represents either some inline function declaration or some
1443 entity declared within an inline function declaration/definition,
1444 setup a symbolic name for the current DIE so that we have a name
1445 for this DIE that we can easily refer to later on within
1446 AT_abstract_origin attributes. */
1448 char decl_label[MAX_ARTIFICIAL_LABEL_BYTES];
1449 char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
1451 sprintf (decl_label, DECL_NAME_FMT, DECL_UID (decl));
1452 sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
1453 ASM_OUTPUT_DEF (asm_out_file, decl_label, die_label);
1456 /* Given a pointer to some ..._TYPE tree node, generate an assembly language
1457 equate directive which will associate a symbolic name with the current DIE.
1459 The name used is an artificial label generated from the TYPE_UID number
1460 associated with the given type node. The name it gets equated to is the
1461 symbolic label that we (previously) output at the start of the DIE that
1462 we are currently generating.
1464 Calling this function while generating some "type related" form of DIE
1465 makes it easy to later refer to the DIE which represents the given type
1466 simply by re-generating the alternative name from the ..._TYPE node's
1470 equate_type_number_to_die_number (type)
1473 char type_label[MAX_ARTIFICIAL_LABEL_BYTES];
1474 char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
1476 /* We are generating a DIE to represent the main variant of this type
1477 (i.e the type without any const or volatile qualifiers) so in order
1478 to get the equate to come out right, we need to get the main variant
1481 type = type_main_variant (type);
1483 sprintf (type_label, TYPE_NAME_FMT, TYPE_UID (type));
1484 sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
1485 ASM_OUTPUT_DEF (asm_out_file, type_label, die_label);
1489 output_reg_number (rtl)
1492 register unsigned regno = REGNO (rtl);
1494 if (regno >= FIRST_PSEUDO_REGISTER)
1496 warning_with_decl (dwarf_last_decl, "internal regno botch: regno = %d\n",
1500 fprintf (asm_out_file, "\t%s\t0x%x",
1501 UNALIGNED_INT_ASM_OP, DBX_REGISTER_NUMBER (regno));
1502 if (flag_verbose_asm)
1504 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
1505 PRINT_REG (rtl, 0, asm_out_file);
1507 fputc ('\n', asm_out_file);
1510 /* The following routine is a nice and simple transducer. It converts the
1511 RTL for a variable or parameter (resident in memory) into an equivalent
1512 Dwarf representation of a mechanism for getting the address of that same
1513 variable onto the top of a hypothetical "address evaluation" stack.
1515 When creating memory location descriptors, we are effectively trans-
1516 forming the RTL for a memory-resident object into its Dwarf postfix
1517 expression equivalent. This routine just recursively descends an
1518 RTL tree, turning it into Dwarf postfix code as it goes. */
1521 output_mem_loc_descriptor (rtl)
1524 /* Note that for a dynamically sized array, the location we will
1525 generate a description of here will be the lowest numbered location
1526 which is actually within the array. That's *not* necessarily the
1527 same as the zeroth element of the array. */
1529 switch (GET_CODE (rtl))
1533 /* The case of a subreg may arise when we have a local (register)
1534 variable or a formal (register) parameter which doesn't quite
1535 fill up an entire register. For now, just assume that it is
1536 legitimate to make the Dwarf info refer to the whole register
1537 which contains the given subreg. */
1539 rtl = XEXP (rtl, 0);
1544 /* Whenever a register number forms a part of the description of
1545 the method for calculating the (dynamic) address of a memory
1546 resident object, DWARF rules require the register number to
1547 be referred to as a "base register". This distinction is not
1548 based in any way upon what category of register the hardware
1549 believes the given register belongs to. This is strictly
1550 DWARF terminology we're dealing with here.
1552 Note that in cases where the location of a memory-resident data
1553 object could be expressed as:
1555 OP_ADD (OP_BASEREG (basereg), OP_CONST (0))
1557 the actual DWARF location descriptor that we generate may just
1558 be OP_BASEREG (basereg). This may look deceptively like the
1559 object in question was allocated to a register (rather than
1560 in memory) so DWARF consumers need to be aware of the subtle
1561 distinction between OP_REG and OP_BASEREG. */
1563 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_BASEREG);
1564 output_reg_number (rtl);
1568 output_mem_loc_descriptor (XEXP (rtl, 0));
1569 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_DEREF4);
1574 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADDR);
1575 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
1579 output_mem_loc_descriptor (XEXP (rtl, 0));
1580 output_mem_loc_descriptor (XEXP (rtl, 1));
1581 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
1585 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
1586 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, INTVAL (rtl));
1594 /* Output a proper Dwarf location descriptor for a variable or parameter
1595 which is either allocated in a register or in a memory location. For
1596 a register, we just generate an OP_REG and the register number. For a
1597 memory location we provide a Dwarf postfix expression describing how to
1598 generate the (dynamic) address of the object onto the address stack. */
1601 output_loc_descriptor (rtl)
1604 switch (GET_CODE (rtl))
1608 /* The case of a subreg may arise when we have a local (register)
1609 variable or a formal (register) parameter which doesn't quite
1610 fill up an entire register. For now, just assume that it is
1611 legitimate to make the Dwarf info refer to the whole register
1612 which contains the given subreg. */
1614 rtl = XEXP (rtl, 0);
1618 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_REG);
1619 output_reg_number (rtl);
1623 output_mem_loc_descriptor (XEXP (rtl, 0));
1627 abort (); /* Should never happen */
1631 /* Given a tree node describing an array bound (either lower or upper)
1632 output a representation for that bound. */
1635 output_bound_representation (bound, dim_num, u_or_l)
1636 register tree bound;
1637 register unsigned dim_num; /* For multi-dimensional arrays. */
1638 register char u_or_l; /* Designates upper or lower bound. */
1640 switch (TREE_CODE (bound))
1646 /* All fixed-bounds are represented by INTEGER_CST nodes. */
1649 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
1650 (unsigned) TREE_INT_CST_LOW (bound));
1653 /* Dynamic bounds may be represented by NOP_EXPR nodes containing
1657 bound = TREE_OPERAND (bound, 0);
1658 /* ... fall thru... */
1662 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
1663 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
1665 sprintf (begin_label, BOUND_BEGIN_LABEL_FMT,
1666 current_dienum, dim_num, u_or_l);
1668 sprintf (end_label, BOUND_END_LABEL_FMT,
1669 current_dienum, dim_num, u_or_l);
1671 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
1672 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
1674 /* If we are working on a bound for a dynamic dimension in C,
1675 the dynamic dimension in question had better have a static
1676 (zero) lower bound and a dynamic *upper* bound. */
1681 /* If optimization is turned on, the SAVE_EXPRs that describe
1682 how to access the upper bound values are essentially bogus.
1683 They only describe (at best) how to get at these values at
1684 the points in the generated code right after they have just
1685 been computed. Worse yet, in the typical case, the upper
1686 bound values will not even *be* computed in the optimized
1687 code, so these SAVE_EXPRs are entirely bogus.
1689 In order to compensate for this fact, we check here to see
1690 if optimization is enabled, and if so, we effectively create
1691 an empty location description for the (unknown and unknowable)
1694 This should not cause too much trouble for existing (stupid?)
1695 debuggers because they have to deal with empty upper bounds
1696 location descriptions anyway in order to be able to deal with
1697 incomplete array types.
1699 Of course an intelligent debugger (GDB?) should be able to
1700 comprehend that a missing upper bound specification in a
1701 array type used for a storage class `auto' local array variable
1702 indicates that the upper bound is both unknown (at compile-
1703 time) and unknowable (at run-time) due to optimization.
1707 output_loc_descriptor
1708 (eliminate_regs (SAVE_EXPR_RTL (bound), 0, NULL_RTX));
1710 ASM_OUTPUT_LABEL (asm_out_file, end_label);
1719 /* Recursive function to output a sequence of value/name pairs for
1720 enumeration constants in reversed order. This is called from
1721 enumeration_type_die. */
1724 output_enumeral_list (link)
1729 output_enumeral_list (TREE_CHAIN (link));
1730 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
1731 (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link)));
1732 ASM_OUTPUT_DWARF_STRING (asm_out_file,
1733 IDENTIFIER_POINTER (TREE_PURPOSE (link)));
1737 /* Given an unsigned value, round it up to the lowest multiple of `boundary'
1738 which is not less than the value itself. */
1741 ceiling (value, boundary)
1742 register unsigned value;
1743 register unsigned boundary;
1745 return (((value + boundary - 1) / boundary) * boundary);
1748 /* Given a pointer to what is assumed to be a FIELD_DECL node, return a
1749 pointer to the declared type for the relevant field variable, or return
1750 `integer_type_node' if the given node turns out to be an ERROR_MARK node. */
1758 if (TREE_CODE (decl) == ERROR_MARK)
1759 return integer_type_node;
1761 type = DECL_BIT_FIELD_TYPE (decl);
1763 type = TREE_TYPE (decl);
1767 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
1768 node, return the alignment in bits for the type, or else return
1769 BITS_PER_WORD if the node actually turns out to be an ERROR_MARK node. */
1772 simple_type_align_in_bits (type)
1775 return (TREE_CODE (type) != ERROR_MARK) ? TYPE_ALIGN (type) : BITS_PER_WORD;
1778 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
1779 node, return the size in bits for the type if it is a constant, or
1780 else return the alignment for the type if the type's size is not
1781 constant, or else return BITS_PER_WORD if the type actually turns out
1782 to be an ERROR_MARK node. */
1785 simple_type_size_in_bits (type)
1788 if (TREE_CODE (type) == ERROR_MARK)
1789 return BITS_PER_WORD;
1792 register tree type_size_tree = TYPE_SIZE (type);
1794 if (TREE_CODE (type_size_tree) != INTEGER_CST)
1795 return TYPE_ALIGN (type);
1797 return (unsigned) TREE_INT_CST_LOW (type_size_tree);
1801 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
1802 return the byte offset of the lowest addressed byte of the "containing
1803 object" for the given FIELD_DECL, or return 0 if we are unable to deter-
1804 mine what that offset is, either because the argument turns out to be a
1805 pointer to an ERROR_MARK node, or because the offset is actually variable.
1806 (We can't handle the latter case just yet.) */
1809 field_byte_offset (decl)
1812 register unsigned type_align_in_bytes;
1813 register unsigned type_align_in_bits;
1814 register unsigned type_size_in_bits;
1815 register unsigned object_offset_in_align_units;
1816 register unsigned object_offset_in_bits;
1817 register unsigned object_offset_in_bytes;
1819 register tree bitpos_tree;
1820 register tree field_size_tree;
1821 register unsigned bitpos_int;
1822 register unsigned deepest_bitpos;
1823 register unsigned field_size_in_bits;
1825 if (TREE_CODE (decl) == ERROR_MARK)
1828 if (TREE_CODE (decl) != FIELD_DECL)
1831 type = field_type (decl);
1833 bitpos_tree = DECL_FIELD_BITPOS (decl);
1834 field_size_tree = DECL_SIZE (decl);
1836 /* We cannot yet cope with fields whose positions or sizes are variable,
1837 so for now, when we see such things, we simply return 0. Someday,
1838 we may be able to handle such cases, but it will be damn difficult. */
1840 if (TREE_CODE (bitpos_tree) != INTEGER_CST)
1842 bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
1844 if (TREE_CODE (field_size_tree) != INTEGER_CST)
1846 field_size_in_bits = (unsigned) TREE_INT_CST_LOW (field_size_tree);
1848 type_size_in_bits = simple_type_size_in_bits (type);
1850 type_align_in_bits = simple_type_align_in_bits (type);
1851 type_align_in_bytes = type_align_in_bits / BITS_PER_UNIT;
1853 /* Note that the GCC front-end doesn't make any attempt to keep track
1854 of the starting bit offset (relative to the start of the containing
1855 structure type) of the hypothetical "containing object" for a bit-
1856 field. Thus, when computing the byte offset value for the start of
1857 the "containing object" of a bit-field, we must deduce this infor-
1860 This can be rather tricky to do in some cases. For example, handling
1861 the following structure type definition when compiling for an i386/i486
1862 target (which only aligns long long's to 32-bit boundaries) can be very
1867 long long field2:31;
1870 Fortunately, there is a simple rule-of-thumb which can be used in such
1871 cases. When compiling for an i386/i486, GCC will allocate 8 bytes for
1872 the structure shown above. It decides to do this based upon one simple
1873 rule for bit-field allocation. Quite simply, GCC allocates each "con-
1874 taining object" for each bit-field at the first (i.e. lowest addressed)
1875 legitimate alignment boundary (based upon the required minimum alignment
1876 for the declared type of the field) which it can possibly use, subject
1877 to the condition that there is still enough available space remaining
1878 in the containing object (when allocated at the selected point) to
1879 fully accommodate all of the bits of the bit-field itself.
1881 This simple rule makes it obvious why GCC allocates 8 bytes for each
1882 object of the structure type shown above. When looking for a place to
1883 allocate the "containing object" for `field2', the compiler simply tries
1884 to allocate a 64-bit "containing object" at each successive 32-bit
1885 boundary (starting at zero) until it finds a place to allocate that 64-
1886 bit field such that at least 31 contiguous (and previously unallocated)
1887 bits remain within that selected 64 bit field. (As it turns out, for
1888 the example above, the compiler finds that it is OK to allocate the
1889 "containing object" 64-bit field at bit-offset zero within the
1892 Here we attempt to work backwards from the limited set of facts we're
1893 given, and we try to deduce from those facts, where GCC must have
1894 believed that the containing object started (within the structure type).
1896 The value we deduce is then used (by the callers of this routine) to
1897 generate AT_location and AT_bit_offset attributes for fields (both
1898 bit-fields and, in the case of AT_location, regular fields as well).
1901 /* Figure out the bit-distance from the start of the structure to the
1902 "deepest" bit of the bit-field. */
1903 deepest_bitpos = bitpos_int + field_size_in_bits;
1905 /* This is the tricky part. Use some fancy footwork to deduce where the
1906 lowest addressed bit of the containing object must be. */
1907 object_offset_in_bits
1908 = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits;
1910 /* Compute the offset of the containing object in "alignment units". */
1911 object_offset_in_align_units = object_offset_in_bits / type_align_in_bits;
1913 /* Compute the offset of the containing object in bytes. */
1914 object_offset_in_bytes = object_offset_in_align_units * type_align_in_bytes;
1916 return object_offset_in_bytes;
1919 /****************************** attributes *********************************/
1921 /* The following routines are responsible for writing out the various types
1922 of Dwarf attributes (and any following data bytes associated with them).
1923 These routines are listed in order based on the numerical codes of their
1924 associated attributes. */
1926 /* Generate an AT_sibling attribute. */
1929 sibling_attribute ()
1931 char label[MAX_ARTIFICIAL_LABEL_BYTES];
1933 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sibling);
1934 sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
1935 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
1938 /* Output the form of location attributes suitable for whole variables and
1939 whole parameters. Note that the location attributes for struct fields
1940 are generated by the routine `data_member_location_attribute' below. */
1943 location_attribute (rtl)
1946 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
1947 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
1949 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
1950 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
1951 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
1952 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
1953 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
1955 /* Handle a special case. If we are about to output a location descriptor
1956 for a variable or parameter which has been optimized out of existence,
1957 don't do that. Instead we output a zero-length location descriptor
1958 value as part of the location attribute.
1960 A variable which has been optimized out of existence will have a
1961 DECL_RTL value which denotes a pseudo-reg.
1963 Currently, in some rare cases, variables can have DECL_RTL values
1964 which look like (MEM (REG pseudo-reg#)). These cases are due to
1965 bugs elsewhere in the compiler. We treat such cases
1966 as if the variable(s) in question had been optimized out of existence.
1968 Note that in all cases where we wish to express the fact that a
1969 variable has been optimized out of existence, we do not simply
1970 suppress the generation of the entire location attribute because
1971 the absence of a location attribute in certain kinds of DIEs is
1972 used to indicate something else entirely... i.e. that the DIE
1973 represents an object declaration, but not a definition. So sayeth
1977 if (! is_pseudo_reg (rtl)
1978 && (GET_CODE (rtl) != MEM || ! is_pseudo_reg (XEXP (rtl, 0))))
1979 output_loc_descriptor (eliminate_regs (rtl, 0, NULL_RTX));
1981 ASM_OUTPUT_LABEL (asm_out_file, end_label);
1984 /* Output the specialized form of location attribute used for data members
1985 of struct and union types.
1987 In the special case of a FIELD_DECL node which represents a bit-field,
1988 the "offset" part of this special location descriptor must indicate the
1989 distance in bytes from the lowest-addressed byte of the containing
1990 struct or union type to the lowest-addressed byte of the "containing
1991 object" for the bit-field. (See the `field_byte_offset' function above.)
1993 For any given bit-field, the "containing object" is a hypothetical
1994 object (of some integral or enum type) within which the given bit-field
1995 lives. The type of this hypothetical "containing object" is always the
1996 same as the declared type of the individual bit-field itself (for GCC
1997 anyway... the DWARF spec doesn't actually mandate this).
1999 Note that it is the size (in bytes) of the hypothetical "containing
2000 object" which will be given in the AT_byte_size attribute for this
2001 bit-field. (See the `byte_size_attribute' function below.) It is
2002 also used when calculating the value of the AT_bit_offset attribute.
2003 (See the `bit_offset_attribute' function below.)
2007 data_member_location_attribute (decl)
2010 register unsigned object_offset_in_bytes = field_byte_offset (decl);
2011 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2012 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2014 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
2015 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
2016 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
2017 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2018 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2019 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
2020 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, object_offset_in_bytes);
2021 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
2022 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2025 /* Output an AT_const_value attribute for a variable or a parameter which
2026 does not have a "location" either in memory or in a register. These
2027 things can arise in GNU C when a constant is passed as an actual
2028 parameter to an inlined function. They can also arise in C++ where
2029 declared constants do not necessarily get memory "homes". */
2032 const_value_attribute (rtl)
2035 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2036 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2038 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_const_value_block4);
2039 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
2040 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
2041 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
2042 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2044 switch (GET_CODE (rtl))
2047 /* Note that a CONST_INT rtx could represent either an integer or
2048 a floating-point constant. A CONST_INT is used whenever the
2049 constant will fit into a single word. In all such cases, the
2050 original mode of the constant value is wiped out, and the
2051 CONST_INT rtx is assigned VOIDmode. Since we no longer have
2052 precise mode information for these constants, we always just
2053 output them using 4 bytes. */
2055 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, (unsigned) INTVAL (rtl));
2059 /* Note that a CONST_DOUBLE rtx could represent either an integer
2060 or a floating-point constant. A CONST_DOUBLE is used whenever
2061 the constant requires more than one word in order to be adequately
2062 represented. In all such cases, the original mode of the constant
2063 value is preserved as the mode of the CONST_DOUBLE rtx, but for
2064 simplicity we always just output CONST_DOUBLEs using 8 bytes. */
2066 ASM_OUTPUT_DWARF_DATA8 (asm_out_file,
2067 (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (rtl),
2068 (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (rtl));
2072 ASM_OUTPUT_DWARF_STRING (asm_out_file, XSTR (rtl, 0));
2078 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
2082 /* In cases where an inlined instance of an inline function is passed
2083 the address of an `auto' variable (which is local to the caller)
2084 we can get a situation where the DECL_RTL of the artificial
2085 local variable (for the inlining) which acts as a stand-in for
2086 the corresponding formal parameter (of the inline function)
2087 will look like (plus:SI (reg:SI FRAME_PTR) (const_int ...)).
2088 This is not exactly a compile-time constant expression, but it
2089 isn't the address of the (artificial) local variable either.
2090 Rather, it represents the *value* which the artificial local
2091 variable always has during its lifetime. We currently have no
2092 way to represent such quasi-constant values in Dwarf, so for now
2093 we just punt and generate an AT_const_value attribute with form
2094 FORM_BLOCK4 and a length of zero. */
2098 abort (); /* No other kinds of rtx should be possible here. */
2101 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2104 /* Generate *either* an AT_location attribute or else an AT_const_value
2105 data attribute for a variable or a parameter. We generate the
2106 AT_const_value attribute only in those cases where the given
2107 variable or parameter does not have a true "location" either in
2108 memory or in a register. This can happen (for example) when a
2109 constant is passed as an actual argument in a call to an inline
2110 function. (It's possible that these things can crop up in other
2111 ways also.) Note that one type of constant value which can be
2112 passed into an inlined function is a constant pointer. This can
2113 happen for example if an actual argument in an inlined function
2114 call evaluates to a compile-time constant address. */
2117 location_or_const_value_attribute (decl)
2122 if (TREE_CODE (decl) == ERROR_MARK)
2125 if ((TREE_CODE (decl) != VAR_DECL) && (TREE_CODE (decl) != PARM_DECL))
2127 /* Should never happen. */
2132 /* Here we have to decide where we are going to say the parameter "lives"
2133 (as far as the debugger is concerned). We only have a couple of choices.
2134 GCC provides us with DECL_RTL and with DECL_INCOMING_RTL. DECL_RTL
2135 normally indicates where the parameter lives during most of the activa-
2136 tion of the function. If optimization is enabled however, this could
2137 be either NULL or else a pseudo-reg. Both of those cases indicate that
2138 the parameter doesn't really live anywhere (as far as the code generation
2139 parts of GCC are concerned) during most of the function's activation.
2140 That will happen (for example) if the parameter is never referenced
2141 within the function.
2143 We could just generate a location descriptor here for all non-NULL
2144 non-pseudo values of DECL_RTL and ignore all of the rest, but we can
2145 be a little nicer than that if we also consider DECL_INCOMING_RTL in
2146 cases where DECL_RTL is NULL or is a pseudo-reg.
2148 Note however that we can only get away with using DECL_INCOMING_RTL as
2149 a backup substitute for DECL_RTL in certain limited cases. In cases
2150 where DECL_ARG_TYPE(decl) indicates the same type as TREE_TYPE(decl)
2151 we can be sure that the parameter was passed using the same type as it
2152 is declared to have within the function, and that its DECL_INCOMING_RTL
2153 points us to a place where a value of that type is passed. In cases
2154 where DECL_ARG_TYPE(decl) and TREE_TYPE(decl) are different types
2155 however, we cannot (in general) use DECL_INCOMING_RTL as a backup
2156 substitute for DECL_RTL because in these cases, DECL_INCOMING_RTL
2157 points us to a value of some type which is *different* from the type
2158 of the parameter itself. Thus, if we tried to use DECL_INCOMING_RTL
2159 to generate a location attribute in such cases, the debugger would
2160 end up (for example) trying to fetch a `float' from a place which
2161 actually contains the first part of a `double'. That would lead to
2162 really incorrect and confusing output at debug-time, and we don't
2163 want that now do we?
2165 So in general, we DO NOT use DECL_INCOMING_RTL as a backup for DECL_RTL
2166 in cases where DECL_ARG_TYPE(decl) != TREE_TYPE(decl). There are a
2167 couple of cute exceptions however. On little-endian machines we can
2168 get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE(decl) is
2169 not the same as TREE_TYPE(decl) but only when DECL_ARG_TYPE(decl) is
2170 an integral type which is smaller than TREE_TYPE(decl). These cases
2171 arise when (on a little-endian machine) a non-prototyped function has
2172 a parameter declared to be of type `short' or `char'. In such cases,
2173 TREE_TYPE(decl) will be `short' or `char', DECL_ARG_TYPE(decl) will be
2174 `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
2175 passed `int' value. If the debugger then uses that address to fetch a
2176 `short' or a `char' (on a little-endian machine) the result will be the
2177 correct data, so we allow for such exceptional cases below.
2179 Note that our goal here is to describe the place where the given formal
2180 parameter lives during most of the function's activation (i.e. between
2181 the end of the prologue and the start of the epilogue). We'll do that
2182 as best as we can. Note however that if the given formal parameter is
2183 modified sometime during the execution of the function, then a stack
2184 backtrace (at debug-time) will show the function as having been called
2185 with the *new* value rather than the value which was originally passed
2186 in. This happens rarely enough that it is not a major problem, but it
2187 *is* a problem, and I'd like to fix it. A future version of dwarfout.c
2188 may generate two additional attributes for any given TAG_formal_parameter
2189 DIE which will describe the "passed type" and the "passed location" for
2190 the given formal parameter in addition to the attributes we now generate
2191 to indicate the "declared type" and the "active location" for each
2192 parameter. This additional set of attributes could be used by debuggers
2193 for stack backtraces.
2195 Separately, note that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL
2196 can be NULL also. This happens (for example) for inlined-instances of
2197 inline function formal parameters which are never referenced. This really
2198 shouldn't be happening. All PARM_DECL nodes should get valid non-NULL
2199 DECL_INCOMING_RTL values, but integrate.c doesn't currently generate
2200 these values for inlined instances of inline function parameters, so
2201 when we see such cases, we are just SOL (shit-out-of-luck) for the time
2202 being (until integrate.c gets fixed).
2205 /* Use DECL_RTL as the "location" unless we find something better. */
2206 rtl = DECL_RTL (decl);
2208 if (TREE_CODE (decl) == PARM_DECL)
2209 if (rtl == NULL_RTX || is_pseudo_reg (rtl))
2211 /* This decl represents a formal parameter which was optimized out. */
2212 register tree declared_type = type_main_variant (TREE_TYPE (decl));
2213 register tree passed_type = type_main_variant (DECL_ARG_TYPE (decl));
2215 /* Note that DECL_INCOMING_RTL may be NULL in here, but we handle
2216 *all* cases where (rtl == NULL_RTX) just below. */
2218 if (declared_type == passed_type)
2219 rtl = DECL_INCOMING_RTL (decl);
2220 #if (BYTES_BIG_ENDIAN == 0)
2222 if (TREE_CODE (declared_type) == INTEGER_TYPE)
2223 if (TYPE_SIZE (declared_type) <= TYPE_SIZE (passed_type))
2224 rtl = DECL_INCOMING_RTL (decl);
2225 #endif /* (BYTES_BIG_ENDIAN == 0) */
2228 if (rtl == NULL_RTX)
2231 switch (GET_CODE (rtl))
2239 case PLUS: /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
2240 const_value_attribute (rtl);
2246 location_attribute (rtl);
2250 abort (); /* Should never happen. */
2254 /* Generate an AT_name attribute given some string value to be included as
2255 the value of the attribute. */
2258 name_attribute (name_string)
2259 register char *name_string;
2261 if (name_string && *name_string)
2263 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_name);
2264 ASM_OUTPUT_DWARF_STRING (asm_out_file, name_string);
2269 fund_type_attribute (ft_code)
2270 register unsigned ft_code;
2272 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_fund_type);
2273 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, ft_code);
2277 mod_fund_type_attribute (type, decl_const, decl_volatile)
2279 register int decl_const;
2280 register int decl_volatile;
2282 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2283 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2285 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_fund_type);
2286 sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
2287 sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
2288 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2289 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2290 write_modifier_bytes (type, decl_const, decl_volatile);
2291 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
2292 fundamental_type_code (root_type (type)));
2293 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2297 user_def_type_attribute (type)
2300 char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
2302 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_user_def_type);
2303 sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (type));
2304 ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
2308 mod_u_d_type_attribute (type, decl_const, decl_volatile)
2310 register int decl_const;
2311 register int decl_volatile;
2313 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2314 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2315 char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
2317 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_u_d_type);
2318 sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
2319 sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
2320 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2321 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2322 write_modifier_bytes (type, decl_const, decl_volatile);
2323 sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (root_type (type)));
2324 ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
2325 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2328 #ifdef USE_ORDERING_ATTRIBUTE
2330 ordering_attribute (ordering)
2331 register unsigned ordering;
2333 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_ordering);
2334 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, ordering);
2336 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
2338 /* Note that the block of subscript information for an array type also
2339 includes information about the element type of type given array type. */
2342 subscript_data_attribute (type)
2345 register unsigned dimension_number;
2346 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2347 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2349 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_subscr_data);
2350 sprintf (begin_label, SS_BEGIN_LABEL_FMT, current_dienum);
2351 sprintf (end_label, SS_END_LABEL_FMT, current_dienum);
2352 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2353 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2355 /* The GNU compilers represent multidimensional array types as sequences
2356 of one dimensional array types whose element types are themselves array
2357 types. Here we squish that down, so that each multidimensional array
2358 type gets only one array_type DIE in the Dwarf debugging info. The
2359 draft Dwarf specification say that we are allowed to do this kind
2360 of compression in C (because there is no difference between an
2361 array or arrays and a multidimensional array in C) but for other
2362 source languages (e.g. Ada) we probably shouldn't do this. */
2364 for (dimension_number = 0;
2365 TREE_CODE (type) == ARRAY_TYPE;
2366 type = TREE_TYPE (type), dimension_number++)
2368 register tree domain = TYPE_DOMAIN (type);
2370 /* Arrays come in three flavors. Unspecified bounds, fixed
2371 bounds, and (in GNU C only) variable bounds. Handle all
2372 three forms here. */
2376 /* We have an array type with specified bounds. */
2378 register tree lower = TYPE_MIN_VALUE (domain);
2379 register tree upper = TYPE_MAX_VALUE (domain);
2381 /* Handle only fundamental types as index types for now. */
2383 if (! type_is_fundamental (domain))
2386 /* Output the representation format byte for this dimension. */
2388 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file,
2390 TREE_CODE (lower) == INTEGER_CST,
2391 TREE_CODE (upper) == INTEGER_CST));
2393 /* Output the index type for this dimension. */
2395 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
2396 fundamental_type_code (domain));
2398 /* Output the representation for the lower bound. */
2400 output_bound_representation (lower, dimension_number, 'l');
2402 /* Output the representation for the upper bound. */
2404 output_bound_representation (upper, dimension_number, 'u');
2408 /* We have an array type with an unspecified length. For C and
2409 C++ we can assume that this really means that (a) the index
2410 type is an integral type, and (b) the lower bound is zero.
2411 Note that Dwarf defines the representation of an unspecified
2412 (upper) bound as being a zero-length location description. */
2414 /* Output the array-bounds format byte. */
2416 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_FT_C_X);
2418 /* Output the (assumed) index type. */
2420 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, FT_integer);
2422 /* Output the (assumed) lower bound (constant) value. */
2424 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
2426 /* Output the (empty) location description for the upper bound. */
2428 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0);
2432 /* Output the prefix byte that says that the element type is comming up. */
2434 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_ET);
2436 /* Output a representation of the type of the elements of this array type. */
2438 type_attribute (type, 0, 0);
2440 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2444 byte_size_attribute (tree_node)
2445 register tree tree_node;
2447 register unsigned size;
2449 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_byte_size);
2450 switch (TREE_CODE (tree_node))
2459 case QUAL_UNION_TYPE:
2460 size = int_size_in_bytes (tree_node);
2464 /* For a data member of a struct or union, the AT_byte_size is
2465 generally given as the number of bytes normally allocated for
2466 an object of the *declared* type of the member itself. This
2467 is true even for bit-fields. */
2468 size = simple_type_size_in_bits (field_type (tree_node))
2476 /* Note that `size' might be -1 when we get to this point. If it
2477 is, that indicates that the byte size of the entity in question
2478 is variable. We have no good way of expressing this fact in Dwarf
2479 at the present time, so just let the -1 pass on through. */
2481 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, size);
2484 /* For a FIELD_DECL node which represents a bit-field, output an attribute
2485 which specifies the distance in bits from the highest order bit of the
2486 "containing object" for the bit-field to the highest order bit of the
2489 For any given bit-field, the "containing object" is a hypothetical
2490 object (of some integral or enum type) within which the given bit-field
2491 lives. The type of this hypothetical "containing object" is always the
2492 same as the declared type of the individual bit-field itself.
2494 The determination of the exact location of the "containing object" for
2495 a bit-field is rather complicated. It's handled by the `field_byte_offset'
2498 Note that it is the size (in bytes) of the hypothetical "containing
2499 object" which will be given in the AT_byte_size attribute for this
2500 bit-field. (See `byte_size_attribute' above.)
2504 bit_offset_attribute (decl)
2507 register unsigned object_offset_in_bytes = field_byte_offset (decl);
2508 register tree type = DECL_BIT_FIELD_TYPE (decl);
2509 register tree bitpos_tree = DECL_FIELD_BITPOS (decl);
2510 register unsigned bitpos_int;
2511 register unsigned highest_order_object_bit_offset;
2512 register unsigned highest_order_field_bit_offset;
2513 register unsigned bit_offset;
2515 assert (TREE_CODE (decl) == FIELD_DECL); /* Must be a field. */
2516 assert (type); /* Must be a bit field. */
2518 /* We can't yet handle bit-fields whose offsets are variable, so if we
2519 encounter such things, just return without generating any attribute
2522 if (TREE_CODE (bitpos_tree) != INTEGER_CST)
2524 bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
2526 /* Note that the bit offset is always the distance (in bits) from the
2527 highest-order bit of the "containing object" to the highest-order
2528 bit of the bit-field itself. Since the "high-order end" of any
2529 object or field is different on big-endian and little-endian machines,
2530 the computation below must take account of these differences. */
2532 highest_order_object_bit_offset = object_offset_in_bytes * BITS_PER_UNIT;
2533 highest_order_field_bit_offset = bitpos_int;
2535 #if (BYTES_BIG_ENDIAN == 0)
2536 highest_order_field_bit_offset
2537 += (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl));
2539 highest_order_object_bit_offset += simple_type_size_in_bits (type);
2540 #endif /* (BYTES_BIG_ENDIAN == 0) */
2543 #if (BYTES_BIG_ENDIAN == 0)
2544 highest_order_object_bit_offset - highest_order_field_bit_offset;
2545 #else /* (BYTES_BIG_ENDIAN != 0) */
2546 highest_order_field_bit_offset - highest_order_object_bit_offset;
2547 #endif /* (BYTES_BIG_ENDIAN != 0) */
2549 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_offset);
2550 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, bit_offset);
2553 /* For a FIELD_DECL node which represents a bit field, output an attribute
2554 which specifies the length in bits of the given field. */
2557 bit_size_attribute (decl)
2560 assert (TREE_CODE (decl) == FIELD_DECL); /* Must be a field. */
2561 assert (DECL_BIT_FIELD_TYPE (decl)); /* Must be a bit field. */
2563 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_size);
2564 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
2565 (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl)));
2568 /* The following routine outputs the `element_list' attribute for enumeration
2569 type DIEs. The element_lits attribute includes the names and values of
2570 all of the enumeration constants associated with the given enumeration
2574 element_list_attribute (element)
2575 register tree element;
2577 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2578 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2580 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_element_list);
2581 sprintf (begin_label, EE_BEGIN_LABEL_FMT, current_dienum);
2582 sprintf (end_label, EE_END_LABEL_FMT, current_dienum);
2583 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
2584 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2586 /* Here we output a list of value/name pairs for each enumeration constant
2587 defined for this enumeration type (as required), but we do it in REVERSE
2588 order. The order is the one required by the draft #5 Dwarf specification
2589 published by the UI/PLSIG. */
2591 output_enumeral_list (element); /* Recursively output the whole list. */
2593 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2596 /* Generate an AT_stmt_list attribute. These are normally present only in
2597 DIEs with a TAG_compile_unit tag. */
2600 stmt_list_attribute (label)
2601 register char *label;
2603 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_stmt_list);
2604 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2605 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
2608 /* Generate an AT_low_pc attribute for a label DIE, a lexical_block DIE or
2609 for a subroutine DIE. */
2612 low_pc_attribute (asm_low_label)
2613 register char *asm_low_label;
2615 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_low_pc);
2616 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_low_label);
2619 /* Generate an AT_high_pc attribute for a lexical_block DIE or for a
2623 high_pc_attribute (asm_high_label)
2624 register char *asm_high_label;
2626 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_high_pc);
2627 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_high_label);
2630 /* Generate an AT_body_begin attribute for a subroutine DIE. */
2633 body_begin_attribute (asm_begin_label)
2634 register char *asm_begin_label;
2636 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_begin);
2637 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_begin_label);
2640 /* Generate an AT_body_end attribute for a subroutine DIE. */
2643 body_end_attribute (asm_end_label)
2644 register char *asm_end_label;
2646 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_end);
2647 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_end_label);
2650 /* Generate an AT_language attribute given a LANG value. These attributes
2651 are used only within TAG_compile_unit DIEs. */
2654 language_attribute (language_code)
2655 register unsigned language_code;
2657 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_language);
2658 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, language_code);
2662 member_attribute (context)
2663 register tree context;
2665 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2667 /* Generate this attribute only for members in C++. */
2669 if (context != NULL && is_tagged_type (context))
2671 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_member);
2672 sprintf (label, TYPE_NAME_FMT, TYPE_UID (context));
2673 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2678 string_length_attribute (upper_bound)
2679 register tree upper_bound;
2681 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2682 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2684 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_string_length);
2685 sprintf (begin_label, SL_BEGIN_LABEL_FMT, current_dienum);
2686 sprintf (end_label, SL_END_LABEL_FMT, current_dienum);
2687 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2688 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2689 output_bound_representation (upper_bound, 0, 'u');
2690 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2694 comp_dir_attribute (dirname)
2695 register char *dirname;
2697 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_comp_dir);
2698 ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname);
2702 sf_names_attribute (sf_names_start_label)
2703 register char *sf_names_start_label;
2705 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sf_names);
2706 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2707 ASM_OUTPUT_DWARF_ADDR (asm_out_file, sf_names_start_label);
2711 src_info_attribute (src_info_start_label)
2712 register char *src_info_start_label;
2714 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_info);
2715 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2716 ASM_OUTPUT_DWARF_ADDR (asm_out_file, src_info_start_label);
2720 mac_info_attribute (mac_info_start_label)
2721 register char *mac_info_start_label;
2723 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mac_info);
2724 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2725 ASM_OUTPUT_DWARF_ADDR (asm_out_file, mac_info_start_label);
2729 prototyped_attribute (func_type)
2730 register tree func_type;
2732 if ((strcmp (language_string, "GNU C") == 0)
2733 && (TYPE_ARG_TYPES (func_type) != NULL))
2735 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_prototyped);
2736 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
2741 producer_attribute (producer)
2742 register char *producer;
2744 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_producer);
2745 ASM_OUTPUT_DWARF_STRING (asm_out_file, producer);
2749 inline_attribute (decl)
2752 if (DECL_INLINE (decl))
2754 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_inline);
2755 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
2760 containing_type_attribute (containing_type)
2761 register tree containing_type;
2763 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2765 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_containing_type);
2766 sprintf (label, TYPE_NAME_FMT, TYPE_UID (containing_type));
2767 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2771 abstract_origin_attribute (origin)
2772 register tree origin;
2774 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2776 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_abstract_origin);
2777 switch (TREE_CODE_CLASS (TREE_CODE (origin)))
2780 sprintf (label, DECL_NAME_FMT, DECL_UID (origin));
2784 sprintf (label, TYPE_NAME_FMT, TYPE_UID (origin));
2788 abort (); /* Should never happen. */
2791 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2794 #ifdef DWARF_DECL_COORDINATES
2796 src_coords_attribute (src_fileno, src_lineno)
2797 register unsigned src_fileno;
2798 register unsigned src_lineno;
2800 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_coords);
2801 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_fileno);
2802 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_lineno);
2804 #endif /* defined(DWARF_DECL_COORDINATES) */
2807 pure_or_virtual_attribute (func_decl)
2808 register tree func_decl;
2810 if (DECL_VIRTUAL_P (func_decl))
2812 #if 0 /* DECL_ABSTRACT_VIRTUAL_P is C++-specific. */
2813 if (DECL_ABSTRACT_VIRTUAL_P (func_decl))
2814 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_pure_virtual);
2817 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
2818 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
2822 /************************* end of attributes *****************************/
2824 /********************* utility routines for DIEs *************************/
2826 /* Output an AT_name attribute and an AT_src_coords attribute for the
2827 given decl, but only if it actually has a name. */
2830 name_and_src_coords_attributes (decl)
2833 register tree decl_name = DECL_NAME (decl);
2835 if (decl_name && IDENTIFIER_POINTER (decl_name))
2837 name_attribute (IDENTIFIER_POINTER (decl_name));
2838 #ifdef DWARF_DECL_COORDINATES
2840 register unsigned file_index;
2842 /* This is annoying, but we have to pop out of the .debug section
2843 for a moment while we call `lookup_filename' because calling it
2844 may cause a temporary switch into the .debug_sfnames section and
2845 most svr4 assemblers are not smart enough be be able to nest
2846 section switches to any depth greater than one. Note that we
2847 also can't skirt this issue by delaying all output to the
2848 .debug_sfnames section unit the end of compilation because that
2849 would cause us to have inter-section forward references and
2850 Fred Fish sez that m68k/svr4 assemblers botch those. */
2852 ASM_OUTPUT_POP_SECTION (asm_out_file);
2853 file_index = lookup_filename (DECL_SOURCE_FILE (decl));
2854 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
2856 src_coords_attribute (file_index, DECL_SOURCE_LINE (decl));
2858 #endif /* defined(DWARF_DECL_COORDINATES) */
2862 /* Many forms of DIEs contain a "type description" part. The following
2863 routine writes out these "type descriptor" parts. */
2866 type_attribute (type, decl_const, decl_volatile)
2868 register int decl_const;
2869 register int decl_volatile;
2871 register enum tree_code code = TREE_CODE (type);
2872 register int root_type_modified;
2874 if (TREE_CODE (type) == ERROR_MARK)
2877 /* Handle a special case. For functions whose return type is void,
2878 we generate *no* type attribute. (Note that no object may have
2879 type `void', so this only applies to function return types. */
2881 if (TREE_CODE (type) == VOID_TYPE)
2884 root_type_modified = (code == POINTER_TYPE || code == REFERENCE_TYPE
2885 || decl_const || decl_volatile
2886 || TYPE_READONLY (type) || TYPE_VOLATILE (type));
2888 if (type_is_fundamental (root_type (type)))
2889 if (root_type_modified)
2890 mod_fund_type_attribute (type, decl_const, decl_volatile);
2892 fund_type_attribute (fundamental_type_code (type));
2894 if (root_type_modified)
2895 mod_u_d_type_attribute (type, decl_const, decl_volatile);
2897 /* We have to get the type_main_variant here (and pass that to the
2898 `user_def_type_attribute' routine) because the ..._TYPE node we
2899 have might simply be a *copy* of some original type node (where
2900 the copy was created to help us keep track of typedef names)
2901 and that copy might have a different TYPE_UID from the original
2902 ..._TYPE node. (Note that when `equate_type_number_to_die_number'
2903 is labeling a given type DIE for future reference, it always and
2904 only creates labels for DIEs representing *main variants*, and it
2905 never even knows about non-main-variants.) */
2906 user_def_type_attribute (type_main_variant (type));
2909 /* Given a tree pointer to a struct, class, union, or enum type node, return
2910 a pointer to the (string) tag name for the given type, or zero if the
2911 type was declared without a tag. */
2917 register char *name = 0;
2919 if (TYPE_NAME (type) != 0)
2921 register tree t = 0;
2923 /* Find the IDENTIFIER_NODE for the type name. */
2924 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
2925 t = TYPE_NAME (type);
2927 /* The g++ front end makes the TYPE_NAME of *each* tagged type point
2928 to a TYPE_DECL node, regardless of whether or not a `typedef' was
2929 involved. This is distinctly different from what the gcc front-end
2930 does. It always makes the TYPE_NAME for each tagged type be either
2931 NULL (signifying an anonymous tagged type) or else a pointer to an
2932 IDENTIFIER_NODE. Obviously, we would like to generate correct Dwarf
2933 for both C and C++, but given this inconsistency in the TREE
2934 representation of tagged types for C and C++ in the GNU front-ends,
2935 we cannot support both languages correctly unless we introduce some
2936 front-end specific code here, and rms objects to that, so we can
2937 only generate correct Dwarf for one of these two languages. C is
2938 more important, so for now we'll do the right thing for C and let
2942 if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
2943 t = DECL_NAME (TYPE_NAME (type));
2945 /* Now get the name as a string, or invent one. */
2947 name = IDENTIFIER_POINTER (t);
2950 return (name == 0 || *name == '\0') ? 0 : name;
2956 /* Start by checking if the pending_sibling_stack needs to be expanded.
2957 If necessary, expand it. */
2959 if (pending_siblings == pending_siblings_allocated)
2961 pending_siblings_allocated += PENDING_SIBLINGS_INCREMENT;
2962 pending_sibling_stack
2963 = (unsigned *) xrealloc (pending_sibling_stack,
2964 pending_siblings_allocated * sizeof(unsigned));
2968 NEXT_DIE_NUM = next_unused_dienum++;
2971 /* Pop the sibling stack so that the most recently pushed DIEnum becomes the
2981 member_declared_type (member)
2982 register tree member;
2984 return (DECL_BIT_FIELD_TYPE (member))
2985 ? DECL_BIT_FIELD_TYPE (member)
2986 : TREE_TYPE (member);
2989 /******************************* DIEs ************************************/
2991 /* Output routines for individual types of DIEs. */
2993 /* Note that every type of DIE (except a null DIE) gets a sibling. */
2996 output_array_type_die (arg)
2999 register tree type = arg;
3001 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_array_type);
3002 sibling_attribute ();
3003 equate_type_number_to_die_number (type);
3004 member_attribute (TYPE_CONTEXT (type));
3006 /* I believe that we can default the array ordering. SDB will probably
3007 do the right things even if AT_ordering is not present. It's not
3008 even an issue until we start to get into multidimensional arrays
3009 anyway. If SDB is ever caught doing the Wrong Thing for multi-
3010 dimensional arrays, then we'll have to put the AT_ordering attribute
3011 back in. (But if and when we find out that we need to put these in,
3012 we will only do so for multidimensional arrays. After all, we don't
3013 want to waste space in the .debug section now do we?) */
3015 #ifdef USE_ORDERING_ATTRIBUTE
3016 ordering_attribute (ORD_row_major);
3017 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
3019 subscript_data_attribute (type);
3023 output_set_type_die (arg)
3026 register tree type = arg;
3028 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_set_type);
3029 sibling_attribute ();
3030 equate_type_number_to_die_number (type);
3031 member_attribute (TYPE_CONTEXT (type));
3032 type_attribute (TREE_TYPE (type), 0, 0);
3036 /* Implement this when there is a GNU FORTRAN or GNU Ada front end. */
3038 output_entry_point_die (arg)
3041 register tree decl = arg;
3042 register tree origin = decl_ultimate_origin (decl);
3044 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_entry_point);
3045 sibling_attribute ();
3048 abstract_origin_attribute (origin);
3051 name_and_src_coords_attributes (decl);
3052 member_attribute (DECL_CONTEXT (decl));
3053 type_attribute (TREE_TYPE (TREE_TYPE (decl)), 0, 0);
3055 if (DECL_ABSTRACT (decl))
3056 equate_decl_number_to_die_number (decl);
3058 low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
3062 /* Output a DIE to represent an inlined instance of an enumeration type. */
3065 output_inlined_enumeration_type_die (arg)
3068 register tree type = arg;
3070 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
3071 sibling_attribute ();
3072 assert (TREE_ASM_WRITTEN (type));
3073 abstract_origin_attribute (type);
3076 /* Output a DIE to represent an inlined instance of a structure type. */
3079 output_inlined_structure_type_die (arg)
3082 register tree type = arg;
3084 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
3085 sibling_attribute ();
3086 assert (TREE_ASM_WRITTEN (type));
3087 abstract_origin_attribute (type);
3090 /* Output a DIE to represent an inlined instance of a union type. */
3093 output_inlined_union_type_die (arg)
3096 register tree type = arg;
3098 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
3099 sibling_attribute ();
3100 assert (TREE_ASM_WRITTEN (type));
3101 abstract_origin_attribute (type);
3104 /* Output a DIE to represent an enumeration type. Note that these DIEs
3105 include all of the information about the enumeration values also.
3106 This information is encoded into the element_list attribute. */
3109 output_enumeration_type_die (arg)
3112 register tree type = arg;
3114 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
3115 sibling_attribute ();
3116 equate_type_number_to_die_number (type);
3117 name_attribute (type_tag (type));
3118 member_attribute (TYPE_CONTEXT (type));
3120 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
3121 given enum type is incomplete, do not generate the AT_byte_size
3122 attribute or the AT_element_list attribute. */
3124 if (TYPE_SIZE (type))
3126 byte_size_attribute (type);
3127 element_list_attribute (TYPE_FIELDS (type));
3131 /* Output a DIE to represent either a real live formal parameter decl or
3132 to represent just the type of some formal parameter position in some
3135 Note that this routine is a bit unusual because its argument may be
3136 a ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
3137 represents an inlining of some PARM_DECL) or else some sort of a
3138 ..._TYPE node. If it's the former then this function is being called
3139 to output a DIE to represent a formal parameter object (or some inlining
3140 thereof). If it's the latter, then this function is only being called
3141 to output a TAG_formal_parameter DIE to stand as a placeholder for some
3142 formal argument type of some subprogram type. */
3145 output_formal_parameter_die (arg)
3148 register tree node = arg;
3150 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_formal_parameter);
3151 sibling_attribute ();
3153 switch (TREE_CODE_CLASS (TREE_CODE (node)))
3155 case 'd': /* We were called with some kind of a ..._DECL node. */
3157 register tree origin = decl_ultimate_origin (node);
3160 abstract_origin_attribute (origin);
3163 name_and_src_coords_attributes (node);
3164 type_attribute (TREE_TYPE (node),
3165 TREE_READONLY (node), TREE_THIS_VOLATILE (node));
3167 if (DECL_ABSTRACT (node))
3168 equate_decl_number_to_die_number (node);
3170 location_or_const_value_attribute (node);
3174 case 't': /* We were called with some kind of a ..._TYPE node. */
3175 type_attribute (node, 0, 0);
3179 abort (); /* Should never happen. */
3183 /* Output a DIE to represent a declared function (either file-scope
3184 or block-local) which has "external linkage" (according to ANSI-C). */
3187 output_global_subroutine_die (arg)
3190 register tree decl = arg;
3191 register tree origin = decl_ultimate_origin (decl);
3193 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_subroutine);
3194 sibling_attribute ();
3197 abstract_origin_attribute (origin);
3200 register tree type = TREE_TYPE (decl);
3202 name_and_src_coords_attributes (decl);
3203 inline_attribute (decl);
3204 prototyped_attribute (type);
3205 member_attribute (DECL_CONTEXT (decl));
3206 type_attribute (TREE_TYPE (type), 0, 0);
3207 pure_or_virtual_attribute (decl);
3209 if (DECL_ABSTRACT (decl))
3210 equate_decl_number_to_die_number (decl);
3213 if (! DECL_EXTERNAL (decl))
3215 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3217 low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
3218 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
3219 high_pc_attribute (label);
3220 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
3221 body_begin_attribute (label);
3222 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
3223 body_end_attribute (label);
3228 /* Output a DIE to represent a declared data object (either file-scope
3229 or block-local) which has "external linkage" (according to ANSI-C). */
3232 output_global_variable_die (arg)
3235 register tree decl = arg;
3236 register tree origin = decl_ultimate_origin (decl);
3238 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_variable);
3239 sibling_attribute ();
3241 abstract_origin_attribute (origin);
3244 name_and_src_coords_attributes (decl);
3245 member_attribute (DECL_CONTEXT (decl));
3246 type_attribute (TREE_TYPE (decl),
3247 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3249 if (DECL_ABSTRACT (decl))
3250 equate_decl_number_to_die_number (decl);
3253 if (!DECL_EXTERNAL (decl))
3254 location_or_const_value_attribute (decl);
3259 output_label_die (arg)
3262 register tree decl = arg;
3263 register tree origin = decl_ultimate_origin (decl);
3265 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_label);
3266 sibling_attribute ();
3268 abstract_origin_attribute (origin);
3270 name_and_src_coords_attributes (decl);
3271 if (DECL_ABSTRACT (decl))
3272 equate_decl_number_to_die_number (decl);
3275 register rtx insn = DECL_RTL (decl);
3277 if (GET_CODE (insn) == CODE_LABEL)
3279 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3281 /* When optimization is enabled (via -O) some parts of the compiler
3282 (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
3283 represent source-level labels which were explicitly declared by
3284 the user. This really shouldn't be happening though, so catch
3285 it if it ever does happen. */
3287 if (INSN_DELETED_P (insn))
3288 abort (); /* Should never happen. */
3290 sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
3291 (unsigned) INSN_UID (insn));
3292 low_pc_attribute (label);
3298 output_lexical_block_die (arg)
3301 register tree stmt = arg;
3303 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_lexical_block);
3304 sibling_attribute ();
3306 if (! BLOCK_ABSTRACT (stmt))
3308 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3309 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3311 sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
3312 low_pc_attribute (begin_label);
3313 sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
3314 high_pc_attribute (end_label);
3319 output_inlined_subroutine_die (arg)
3322 register tree stmt = arg;
3324 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inlined_subroutine);
3325 sibling_attribute ();
3327 abstract_origin_attribute (block_ultimate_origin (stmt));
3328 if (! BLOCK_ABSTRACT (stmt))
3330 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3331 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3333 sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
3334 low_pc_attribute (begin_label);
3335 sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
3336 high_pc_attribute (end_label);
3340 /* Output a DIE to represent a declared data object (either file-scope
3341 or block-local) which has "internal linkage" (according to ANSI-C). */
3344 output_local_variable_die (arg)
3347 register tree decl = arg;
3348 register tree origin = decl_ultimate_origin (decl);
3350 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_local_variable);
3351 sibling_attribute ();
3353 abstract_origin_attribute (origin);
3356 name_and_src_coords_attributes (decl);
3357 member_attribute (DECL_CONTEXT (decl));
3358 type_attribute (TREE_TYPE (decl),
3359 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3361 if (DECL_ABSTRACT (decl))
3362 equate_decl_number_to_die_number (decl);
3364 location_or_const_value_attribute (decl);
3368 output_member_die (arg)
3371 register tree decl = arg;
3373 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_member);
3374 sibling_attribute ();
3375 name_and_src_coords_attributes (decl);
3376 member_attribute (DECL_CONTEXT (decl));
3377 type_attribute (member_declared_type (decl),
3378 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3379 if (DECL_BIT_FIELD_TYPE (decl)) /* If this is a bit field... */
3381 byte_size_attribute (decl);
3382 bit_size_attribute (decl);
3383 bit_offset_attribute (decl);
3385 data_member_location_attribute (decl);
3389 /* Don't generate either pointer_type DIEs or reference_type DIEs. Use
3390 modified types instead.
3392 We keep this code here just in case these types of DIEs may be needed
3393 to represent certain things in other languages (e.g. Pascal) someday.
3397 output_pointer_type_die (arg)
3400 register tree type = arg;
3402 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_pointer_type);
3403 sibling_attribute ();
3404 equate_type_number_to_die_number (type);
3405 member_attribute (TYPE_CONTEXT (type));
3406 type_attribute (TREE_TYPE (type), 0, 0);
3410 output_reference_type_die (arg)
3413 register tree type = arg;
3415 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_reference_type);
3416 sibling_attribute ();
3417 equate_type_number_to_die_number (type);
3418 member_attribute (TYPE_CONTEXT (type));
3419 type_attribute (TREE_TYPE (type), 0, 0);
3424 output_ptr_to_mbr_type_die (arg)
3427 register tree type = arg;
3429 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_ptr_to_member_type);
3430 sibling_attribute ();
3431 equate_type_number_to_die_number (type);
3432 member_attribute (TYPE_CONTEXT (type));
3433 containing_type_attribute (TYPE_OFFSET_BASETYPE (type));
3434 type_attribute (TREE_TYPE (type), 0, 0);
3438 output_compile_unit_die (arg)
3441 register char *main_input_filename = arg;
3443 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_compile_unit);
3444 sibling_attribute ();
3446 name_attribute (main_input_filename);
3451 sprintf (producer, "%s %s", language_string, version_string);
3452 producer_attribute (producer);
3455 if (strcmp (language_string, "GNU C++") == 0)
3456 language_attribute (LANG_C_PLUS_PLUS);
3457 else if (strcmp (language_string, "GNU Ada") == 0)
3458 language_attribute (LANG_ADA83);
3459 else if (flag_traditional)
3460 language_attribute (LANG_C);
3462 language_attribute (LANG_C89);
3463 low_pc_attribute (TEXT_BEGIN_LABEL);
3464 high_pc_attribute (TEXT_END_LABEL);
3465 if (debug_info_level >= DINFO_LEVEL_NORMAL)
3466 stmt_list_attribute (LINE_BEGIN_LABEL);
3467 last_filename = xstrdup (main_input_filename);
3470 char *wd = getpwd ();
3472 comp_dir_attribute (wd);
3475 if (debug_info_level >= DINFO_LEVEL_NORMAL)
3477 sf_names_attribute (SFNAMES_BEGIN_LABEL);
3478 src_info_attribute (SRCINFO_BEGIN_LABEL);
3479 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
3480 mac_info_attribute (MACINFO_BEGIN_LABEL);
3485 output_string_type_die (arg)
3488 register tree type = arg;
3490 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_string_type);
3491 sibling_attribute ();
3492 member_attribute (TYPE_CONTEXT (type));
3494 /* Fudge the string length attribute for now. */
3496 string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
3500 output_structure_type_die (arg)
3503 register tree type = arg;
3505 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
3506 sibling_attribute ();
3507 equate_type_number_to_die_number (type);
3508 name_attribute (type_tag (type));
3509 member_attribute (TYPE_CONTEXT (type));
3511 /* If this type has been completed, then give it a byte_size attribute
3512 and prepare to give a list of members. Otherwise, don't do either of
3513 these things. In the latter case, we will not be generating a list
3514 of members (since we don't have any idea what they might be for an
3515 incomplete type). */
3517 if (TYPE_SIZE (type))
3520 byte_size_attribute (type);
3524 /* Output a DIE to represent a declared function (either file-scope
3525 or block-local) which has "internal linkage" (according to ANSI-C). */
3528 output_local_subroutine_die (arg)
3531 register tree decl = arg;
3532 register tree origin = decl_ultimate_origin (decl);
3534 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine);
3535 sibling_attribute ();
3538 abstract_origin_attribute (origin);
3541 register tree type = TREE_TYPE (decl);
3543 name_and_src_coords_attributes (decl);
3544 inline_attribute (decl);
3545 prototyped_attribute (type);
3546 member_attribute (DECL_CONTEXT (decl));
3547 type_attribute (TREE_TYPE (type), 0, 0);
3548 pure_or_virtual_attribute (decl);
3550 if (DECL_ABSTRACT (decl))
3551 equate_decl_number_to_die_number (decl);
3554 /* Avoid getting screwed up in cases where a function was declared
3555 static but where no definition was ever given for it. */
3557 if (TREE_ASM_WRITTEN (decl))
3559 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3561 low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
3562 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
3563 high_pc_attribute (label);
3564 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
3565 body_begin_attribute (label);
3566 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
3567 body_end_attribute (label);
3573 output_subroutine_type_die (arg)
3576 register tree type = arg;
3577 register tree return_type = TREE_TYPE (type);
3579 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine_type);
3580 sibling_attribute ();
3582 equate_type_number_to_die_number (type);
3583 prototyped_attribute (type);
3584 member_attribute (TYPE_CONTEXT (type));
3585 type_attribute (return_type, 0, 0);
3589 output_typedef_die (arg)
3592 register tree decl = arg;
3593 register tree origin = decl_ultimate_origin (decl);
3595 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_typedef);
3596 sibling_attribute ();
3598 abstract_origin_attribute (origin);
3601 name_and_src_coords_attributes (decl);
3602 member_attribute (DECL_CONTEXT (decl));
3603 type_attribute (TREE_TYPE (decl),
3604 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3606 if (DECL_ABSTRACT (decl))
3607 equate_decl_number_to_die_number (decl);
3611 output_union_type_die (arg)
3614 register tree type = arg;
3616 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
3617 sibling_attribute ();
3618 equate_type_number_to_die_number (type);
3619 name_attribute (type_tag (type));
3620 member_attribute (TYPE_CONTEXT (type));
3622 /* If this type has been completed, then give it a byte_size attribute
3623 and prepare to give a list of members. Otherwise, don't do either of
3624 these things. In the latter case, we will not be generating a list
3625 of members (since we don't have any idea what they might be for an
3626 incomplete type). */
3628 if (TYPE_SIZE (type))
3631 byte_size_attribute (type);
3635 /* Generate a special type of DIE used as a stand-in for a trailing ellipsis
3636 at the end of an (ANSI prototyped) formal parameters list. */
3639 output_unspecified_parameters_die (arg)
3642 register tree decl_or_type = arg;
3644 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_unspecified_parameters);
3645 sibling_attribute ();
3647 /* This kludge is here only for the sake of being compatible with what
3648 the USL CI5 C compiler does. The specification of Dwarf Version 1
3649 doesn't say that TAG_unspecified_parameters DIEs should contain any
3650 attributes other than the AT_sibling attribute, but they are certainly
3651 allowed to contain additional attributes, and the CI5 compiler
3652 generates AT_name, AT_fund_type, and AT_location attributes within
3653 TAG_unspecified_parameters DIEs which appear in the child lists for
3654 DIEs representing function definitions, so we do likewise here. */
3656 if (TREE_CODE (decl_or_type) == FUNCTION_DECL && DECL_INITIAL (decl_or_type))
3658 name_attribute ("...");
3659 fund_type_attribute (FT_pointer);
3660 /* location_attribute (?); */
3665 output_padded_null_die (arg)
3668 ASM_OUTPUT_ALIGN (asm_out_file, 2); /* 2**2 == 4 */
3671 /*************************** end of DIEs *********************************/
3673 /* Generate some type of DIE. This routine generates the generic outer
3674 wrapper stuff which goes around all types of DIE's (regardless of their
3675 TAGs. All forms of DIEs start with a DIE-specific label, followed by a
3676 DIE-length word, followed by the guts of the DIE itself. After the guts
3677 of the DIE, there must always be a terminator label for the DIE. */
3680 output_die (die_specific_output_function, param)
3681 register void (*die_specific_output_function)();
3682 register void *param;
3684 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3685 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3687 current_dienum = NEXT_DIE_NUM;
3688 NEXT_DIE_NUM = next_unused_dienum;
3690 sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
3691 sprintf (end_label, DIE_END_LABEL_FMT, current_dienum);
3693 /* Write a label which will act as the name for the start of this DIE. */
3695 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
3697 /* Write the DIE-length word. */
3699 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
3701 /* Fill in the guts of the DIE. */
3703 next_unused_dienum++;
3704 die_specific_output_function (param);
3706 /* Write a label which will act as the name for the end of this DIE. */
3708 ASM_OUTPUT_LABEL (asm_out_file, end_label);
3712 end_sibling_chain ()
3714 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3716 current_dienum = NEXT_DIE_NUM;
3717 NEXT_DIE_NUM = next_unused_dienum;
3719 sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
3721 /* Write a label which will act as the name for the start of this DIE. */
3723 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
3725 /* Write the DIE-length word. */
3727 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 4);
3732 /* Generate a list of nameless TAG_formal_parameter DIEs (and perhaps a
3733 TAG_unspecified_parameters DIE) to represent the types of the formal
3734 parameters as specified in some function type specification (except
3735 for those which appear as part of a function *definition*).
3737 Note that we must be careful here to output all of the parameter DIEs
3738 *before* we output any DIEs needed to represent the types of the formal
3739 parameters. This keeps svr4 SDB happy because it (incorrectly) thinks
3740 that the first non-parameter DIE it sees ends the formal parameter list.
3744 output_formal_types (function_or_method_type)
3745 register tree function_or_method_type;
3748 register tree formal_type = NULL;
3749 register tree first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
3751 /* In the case where we are generating a formal types list for a C++
3752 non-static member function type, skip over the first thing on the
3753 TYPE_ARG_TYPES list because it only represents the type of the
3754 hidden `this pointer'. The debugger should be able to figure
3755 out (without being explicitly told) that this non-static member
3756 function type takes a `this pointer' and should be able to figure
3757 what the type of that hidden parameter is from the AT_member
3758 attribute of the parent TAG_subroutine_type DIE. */
3760 if (TREE_CODE (function_or_method_type) == METHOD_TYPE)
3761 first_parm_type = TREE_CHAIN (first_parm_type);
3763 /* Make our first pass over the list of formal parameter types and output
3764 a TAG_formal_parameter DIE for each one. */
3766 for (link = first_parm_type; link; link = TREE_CHAIN (link))
3768 formal_type = TREE_VALUE (link);
3769 if (formal_type == void_type_node)
3772 /* Output a (nameless) DIE to represent the formal parameter itself. */
3774 output_die (output_formal_parameter_die, formal_type);
3777 /* If this function type has an ellipsis, add a TAG_unspecified_parameters
3778 DIE to the end of the parameter list. */
3780 if (formal_type != void_type_node)
3781 output_die (output_unspecified_parameters_die, function_or_method_type);
3783 /* Make our second (and final) pass over the list of formal parameter types
3784 and output DIEs to represent those types (as necessary). */
3786 for (link = TYPE_ARG_TYPES (function_or_method_type);
3788 link = TREE_CHAIN (link))
3790 formal_type = TREE_VALUE (link);
3791 if (formal_type == void_type_node)
3794 output_type (formal_type, function_or_method_type);
3798 /* Remember a type in the pending_types_list. */
3804 if (pending_types == pending_types_allocated)
3806 pending_types_allocated += PENDING_TYPES_INCREMENT;
3808 = (tree *) xrealloc (pending_types_list,
3809 sizeof (tree) * pending_types_allocated);
3811 pending_types_list[pending_types++] = type;
3813 /* Mark the pending type as having been output already (even though
3814 it hasn't been). This prevents the type from being added to the
3815 pending_types_list more than once. */
3817 TREE_ASM_WRITTEN (type) = 1;
3820 /* Return non-zero if it is legitimate to output DIEs to represent a
3821 given type while we are generating the list of child DIEs for some
3822 DIE (e.g. a function or lexical block DIE) associated with a given scope.
3824 See the comments within the function for a description of when it is
3825 considered legitimate to output DIEs for various kinds of types.
3827 Note that TYPE_CONTEXT(type) may be NULL (to indicate global scope)
3828 or it may point to a BLOCK node (for types local to a block), or to a
3829 FUNCTION_DECL node (for types local to the heading of some function
3830 definition), or to a FUNCTION_TYPE node (for types local to the
3831 prototyped parameter list of a function type specification), or to a
3832 RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node
3833 (in the case of C++ nested types).
3835 The `scope' parameter should likewise be NULL or should point to a
3836 BLOCK node, a FUNCTION_DECL node, a FUNCTION_TYPE node, a RECORD_TYPE
3837 node, a UNION_TYPE node, or a QUAL_UNION_TYPE node.
3839 This function is used only for deciding when to "pend" and when to
3840 "un-pend" types to/from the pending_types_list.
3842 Note that we sometimes make use of this "type pending" feature in a
3843 rather twisted way to temporarily delay the production of DIEs for the
3844 types of formal parameters. (We do this just to make svr4 SDB happy.)
3845 It order to delay the production of DIEs representing types of formal
3846 parameters, callers of this function supply `fake_containing_scope' as
3847 the `scope' parameter to this function. Given that fake_containing_scope
3848 is a tagged type which is *not* the containing scope for *any* other type,
3849 the desired effect is achieved, i.e. output of DIEs representing types
3850 is temporarily suspended, and any type DIEs which would have otherwise
3851 been output are instead placed onto the pending_types_list. Later on,
3852 we force these (temporarily pended) types to be output simply by calling
3853 `output_pending_types_for_scope' with an actual argument equal to the
3854 true scope of the types we temporarily pended.
3858 type_ok_for_scope (type, scope)
3860 register tree scope;
3862 /* Tagged types (i.e. struct, union, and enum types) must always be
3863 output only in the scopes where they actually belong (or else the
3864 scoping of their own tag names and the scoping of their member
3865 names will be incorrect). Non-tagged-types on the other hand can
3866 generally be output anywhere, except that svr4 SDB really doesn't
3867 want to see them nested within struct or union types, so here we
3868 say it is always OK to immediately output any such a (non-tagged)
3869 type, so long as we are not within such a context. Note that the
3870 only kinds of non-tagged types which we will be dealing with here
3871 (for C and C++ anyway) will be array types and function types. */
3873 return is_tagged_type (type)
3874 ? (TYPE_CONTEXT (type) == scope)
3875 : (scope == NULL_TREE || ! is_tagged_type (scope));
3878 /* Output any pending types (from the pending_types list) which we can output
3879 now (taking into account the scope that we are working on now).
3881 For each type output, remove the given type from the pending_types_list
3882 *before* we try to output it.
3884 Note that we have to process the list in beginning-to-end order,
3885 because the call made here to output_type may cause yet more types
3886 to be added to the end of the list, and we may have to output some
3891 output_pending_types_for_scope (containing_scope)
3892 register tree containing_scope;
3894 register unsigned i;
3896 for (i = 0; i < pending_types; )
3898 register tree type = pending_types_list[i];
3900 if (type_ok_for_scope (type, containing_scope))
3902 register tree *mover;
3903 register tree *limit;
3906 limit = &pending_types_list[pending_types];
3907 for (mover = &pending_types_list[i]; mover < limit; mover++)
3908 *mover = *(mover+1);
3910 /* Un-mark the type as having been output already (because it
3911 hasn't been, really). Then call output_type to generate a
3912 Dwarf representation of it. */
3914 TREE_ASM_WRITTEN (type) = 0;
3915 output_type (type, containing_scope);
3917 /* Don't increment the loop counter in this case because we
3918 have shifted all of the subsequent pending types down one
3919 element in the pending_types_list array. */
3927 output_type (type, containing_scope)
3929 register tree containing_scope;
3931 if (type == 0 || type == error_mark_node)
3934 /* We are going to output a DIE to represent the unqualified version of
3935 of this type (i.e. without any const or volatile qualifiers) so get
3936 the main variant (i.e. the unqualified version) of this type now. */
3938 type = type_main_variant (type);
3940 if (TREE_ASM_WRITTEN (type))
3943 /* Don't generate any DIEs for this type now unless it is OK to do so
3944 (based upon what `type_ok_for_scope' tells us). */
3946 if (! type_ok_for_scope (type, containing_scope))
3952 switch (TREE_CODE (type))
3958 case REFERENCE_TYPE:
3959 /* For these types, all that is required is that we output a DIE
3960 (or a set of DIEs) to represent the "basis" type. */
3961 output_type (TREE_TYPE (type), containing_scope);
3965 /* This code is used for C++ pointer-to-data-member types. */
3966 /* Output a description of the relevant class type. */
3967 output_type (TYPE_OFFSET_BASETYPE (type), containing_scope);
3968 /* Output a description of the type of the object pointed to. */
3969 output_type (TREE_TYPE (type), containing_scope);
3970 /* Now output a DIE to represent this pointer-to-data-member type
3972 output_die (output_ptr_to_mbr_type_die, type);
3976 output_type (TREE_TYPE (type), containing_scope);
3977 output_die (output_set_type_die, type);
3981 output_type (TREE_TYPE (type), containing_scope);
3982 abort (); /* No way to represent these in Dwarf yet! */
3986 output_type (TREE_TYPE (type), containing_scope);
3987 output_die (output_string_type_die, type);
3991 /* Force out return type (in case it wasn't forced out already). */
3992 output_type (TREE_TYPE (type), containing_scope);
3993 output_die (output_subroutine_type_die, type);
3994 output_formal_types (type);
3995 end_sibling_chain ();
3999 /* Force out return type (in case it wasn't forced out already). */
4000 output_type (TREE_TYPE (type), containing_scope);
4001 output_die (output_subroutine_type_die, type);
4002 output_formal_types (type);
4003 end_sibling_chain ();
4008 register tree element_type;
4010 element_type = TREE_TYPE (type);
4011 while (TREE_CODE (element_type) == ARRAY_TYPE)
4012 element_type = TREE_TYPE (element_type);
4014 output_type (element_type, containing_scope);
4015 output_die (output_array_type_die, type);
4022 case QUAL_UNION_TYPE:
4024 /* For a non-file-scope tagged type, we can always go ahead and
4025 output a Dwarf description of this type right now, even if
4026 the type in question is still incomplete, because if this
4027 local type *was* ever completed anywhere within its scope,
4028 that complete definition would already have been attached to
4029 this RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE or ENUMERAL_TYPE
4030 node by the time we reach this point. That's true because of the
4031 way the front-end does its processing of file-scope declarations (of
4032 functions and class types) within which other types might be
4033 nested. The C and C++ front-ends always gobble up such "local
4034 scope" things en-mass before they try to output *any* debugging
4035 information for any of the stuff contained inside them and thus,
4036 we get the benefit here of what is (in effect) a pre-resolution
4037 of forward references to tagged types in local scopes.
4039 Note however that for file-scope tagged types we cannot assume
4040 that such pre-resolution of forward references has taken place.
4041 A given file-scope tagged type may appear to be incomplete when
4042 we reach this point, but it may yet be given a full definition
4043 (at file-scope) later on during compilation. In order to avoid
4044 generating a premature (and possibly incorrect) set of Dwarf
4045 DIEs for such (as yet incomplete) file-scope tagged types, we
4046 generate nothing at all for as-yet incomplete file-scope tagged
4047 types here unless we are making our special "finalization" pass
4048 for file-scope things at the very end of compilation. At that
4049 time, we will certainly know as much about each file-scope tagged
4050 type as we are ever going to know, so at that point in time, we
4051 can safely generate correct Dwarf descriptions for these file-
4055 if (TYPE_SIZE (type) == 0 && TYPE_CONTEXT (type) == NULL && !finalizing)
4056 return; /* EARLY EXIT! Avoid setting TREE_ASM_WRITTEN. */
4058 /* Prevent infinite recursion in cases where the type of some
4059 member of this type is expressed in terms of this type itself. */
4061 TREE_ASM_WRITTEN (type) = 1;
4063 /* Output a DIE to represent the tagged type itself. */
4065 switch (TREE_CODE (type))
4068 output_die (output_enumeration_type_die, type);
4069 return; /* a special case -- nothing left to do so just return */
4072 output_die (output_structure_type_die, type);
4076 case QUAL_UNION_TYPE:
4077 output_die (output_union_type_die, type);
4081 abort (); /* Should never happen. */
4084 /* If this is not an incomplete type, output descriptions of
4085 each of its members.
4087 Note that as we output the DIEs necessary to represent the
4088 members of this record or union type, we will also be trying
4089 to output DIEs to represent the *types* of those members.
4090 However the `output_type' function (above) will specifically
4091 avoid generating type DIEs for member types *within* the list
4092 of member DIEs for this (containing) type execpt for those
4093 types (of members) which are explicitly marked as also being
4094 members of this (containing) type themselves. The g++ front-
4095 end can force any given type to be treated as a member of some
4096 other (containing) type by setting the TYPE_CONTEXT of the
4097 given (member) type to point to the TREE node representing the
4098 appropriate (containing) type.
4101 if (TYPE_SIZE (type))
4104 register tree normal_member;
4106 /* First output info about the data members and type members. */
4108 for (normal_member = TYPE_FIELDS (type);
4110 normal_member = TREE_CHAIN (normal_member))
4111 output_decl (normal_member, type);
4115 register tree vec_base;
4117 /* Now output info about the function members (if any). */
4119 vec_base = TYPE_METHODS (type);
4122 register tree first_func_member = TREE_VEC_ELT (vec_base, 0);
4123 register tree func_member;
4125 /* This isn't documented, but the first element of the
4126 vector of member functions can be NULL in cases where
4127 the class type in question didn't have either a
4128 constructor or a destructor declared for it. We have
4129 to make allowances for that here. */
4131 if (first_func_member == NULL)
4132 first_func_member = TREE_VEC_ELT (vec_base, 1);
4134 for (func_member = first_func_member;
4136 func_member = TREE_CHAIN (func_member))
4137 output_decl (func_member, type);
4141 /* RECORD_TYPEs, UNION_TYPEs, and QUAL_UNION_TYPEs are themselves
4142 scopes (at least in C++) so we must now output any nested
4143 pending types which are local just to this type. */
4145 output_pending_types_for_scope (type);
4147 end_sibling_chain (); /* Terminate member chain. */
4158 break; /* No DIEs needed for fundamental types. */
4160 case LANG_TYPE: /* No Dwarf representation currently defined. */
4167 TREE_ASM_WRITTEN (type) = 1;
4171 output_tagged_type_instantiation (type)
4174 if (type == 0 || type == error_mark_node)
4177 /* We are going to output a DIE to represent the unqualified version of
4178 of this type (i.e. without any const or volatile qualifiers) so make
4179 sure that we have the main variant (i.e. the unqualified version) of
4182 assert (type == type_main_variant (type));
4184 assert (TREE_ASM_WRITTEN (type));
4186 switch (TREE_CODE (type))
4192 output_die (output_inlined_enumeration_type_die, type);
4196 output_die (output_inlined_structure_type_die, type);
4200 case QUAL_UNION_TYPE:
4201 output_die (output_inlined_union_type_die, type);
4205 abort (); /* Should never happen. */
4209 /* Output a TAG_lexical_block DIE followed by DIEs to represent all of
4210 the things which are local to the given block. */
4216 register int must_output_die = 0;
4217 register tree origin;
4218 register enum tree_code origin_code;
4220 /* Ignore blocks never really used to make RTL. */
4222 if (! stmt || ! TREE_USED (stmt))
4225 /* Determine the "ultimate origin" of this block. This block may be an
4226 inlined instance of an inlined instance of inline function, so we
4227 have to trace all of the way back through the origin chain to find
4228 out what sort of node actually served as the original seed for the
4229 creation of the current block. */
4231 origin = block_ultimate_origin (stmt);
4232 origin_code = (origin != NULL) ? TREE_CODE (origin) : ERROR_MARK;
4234 /* Determine if we need to output any Dwarf DIEs at all to represent this
4237 if (origin_code == FUNCTION_DECL)
4238 /* The outer scopes for inlinings *must* always be represented. We
4239 generate TAG_inlined_subroutine DIEs for them. (See below.) */
4240 must_output_die = 1;
4243 /* In the case where the current block represents an inlining of the
4244 "body block" of an inline function, we must *NOT* output any DIE
4245 for this block because we have already output a DIE to represent
4246 the whole inlined function scope and the "body block" of any
4247 function doesn't really represent a different scope according to
4248 ANSI C rules. So we check here to make sure that this block does
4249 not represent a "body block inlining" before trying to set the
4250 `must_output_die' flag. */
4252 if (origin == NULL || ! is_body_block (origin))
4254 /* Determine if this block directly contains any "significant"
4255 local declarations which we will need to output DIEs for. */
4257 if (debug_info_level > DINFO_LEVEL_TERSE)
4258 /* We are not in terse mode so *any* local declaration counts
4259 as being a "significant" one. */
4260 must_output_die = (BLOCK_VARS (stmt) != NULL);
4265 /* We are in terse mode, so only local (nested) function
4266 definitions count as "significant" local declarations. */
4268 for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
4269 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
4271 must_output_die = 1;
4278 /* It would be a waste of space to generate a Dwarf TAG_lexical_block
4279 DIE for any block which contains no significant local declarations
4280 at all. Rather, in such cases we just call `output_decls_for_scope'
4281 so that any needed Dwarf info for any sub-blocks will get properly
4282 generated. Note that in terse mode, our definition of what constitutes
4283 a "significant" local declaration gets restricted to include only
4284 inlined function instances and local (nested) function definitions. */
4286 if (must_output_die)
4288 output_die ((origin_code == FUNCTION_DECL)
4289 ? output_inlined_subroutine_die
4290 : output_lexical_block_die,
4292 output_decls_for_scope (stmt);
4293 end_sibling_chain ();
4296 output_decls_for_scope (stmt);
4299 /* Output all of the decls declared within a given scope (also called
4300 a `binding contour') and (recursively) all of it's sub-blocks. */
4303 output_decls_for_scope (stmt)
4306 /* Ignore blocks never really used to make RTL. */
4308 if (! stmt || ! TREE_USED (stmt))
4311 if (! BLOCK_ABSTRACT (stmt))
4312 next_block_number++;
4314 /* Output the DIEs to represent all of the data objects, functions,
4315 typedefs, and tagged types declared directly within this block
4316 but not within any nested sub-blocks. */
4321 for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
4322 output_decl (decl, stmt);
4325 output_pending_types_for_scope (stmt);
4327 /* Output the DIEs to represent all sub-blocks (and the items declared
4328 therein) of this block. */
4331 register tree subblocks;
4333 for (subblocks = BLOCK_SUBBLOCKS (stmt);
4335 subblocks = BLOCK_CHAIN (subblocks))
4336 output_block (subblocks);
4340 /* Output Dwarf .debug information for a decl described by DECL. */
4343 output_decl (decl, containing_scope)
4345 register tree containing_scope;
4347 /* Make a note of the decl node we are going to be working on. We may
4348 need to give the user the source coordinates of where it appeared in
4349 case we notice (later on) that something about it looks screwy. */
4351 dwarf_last_decl = decl;
4353 if (TREE_CODE (decl) == ERROR_MARK)
4356 /* If this ..._DECL node is marked to be ignored, then ignore it.
4357 But don't ignore a function definition, since that would screw
4358 up our count of blocks, and that it turn will completely screw up the
4359 the labels we will reference in subsequent AT_low_pc and AT_high_pc
4360 attributes (for subsequent blocks). */
4362 if (DECL_IGNORED_P (decl) && TREE_CODE (decl) != FUNCTION_DECL)
4365 switch (TREE_CODE (decl))
4368 /* The individual enumerators of an enum type get output when we
4369 output the Dwarf representation of the relevant enum type itself. */
4373 /* If we are in terse mode, don't output any DIEs to represent
4374 mere function declarations. Also, if we are conforming
4375 to the DWARF version 1 specification, don't output DIEs for
4376 mere function declarations. */
4378 if (DECL_INITIAL (decl) == NULL_TREE)
4379 #if (DWARF_VERSION > 1)
4380 if (debug_info_level <= DINFO_LEVEL_TERSE)
4384 /* Before we describe the FUNCTION_DECL itself, make sure that we
4385 have described its return type. */
4387 output_type (TREE_TYPE (TREE_TYPE (decl)), containing_scope);
4389 /* If the following DIE will represent a function definition for a
4390 function with "extern" linkage, output a special "pubnames" DIE
4391 label just ahead of the actual DIE. A reference to this label
4392 was already generated in the .debug_pubnames section sub-entry
4393 for this function definition. */
4395 if (TREE_PUBLIC (decl))
4397 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4399 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
4400 ASM_OUTPUT_LABEL (asm_out_file, label);
4403 /* Now output a DIE to represent the function itself. */
4405 output_die (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)
4406 ? output_global_subroutine_die
4407 : output_local_subroutine_die,
4410 /* Now output descriptions of the arguments for this function.
4411 This gets (unnecessarily?) complex because of the fact that
4412 the DECL_ARGUMENT list for a FUNCTION_DECL doesn't indicate
4413 cases where there was a trailing `...' at the end of the formal
4414 parameter list. In order to find out if there was a trailing
4415 ellipsis or not, we must instead look at the type associated
4416 with the FUNCTION_DECL. This will be a node of type FUNCTION_TYPE.
4417 If the chain of type nodes hanging off of this FUNCTION_TYPE node
4418 ends with a void_type_node then there should *not* be an ellipsis
4421 /* In the case where we are describing a mere function declaration, all
4422 we need to do here (and all we *can* do here) is to describe
4423 the *types* of its formal parameters. */
4425 if (DECL_INITIAL (decl) == NULL_TREE)
4426 output_formal_types (TREE_TYPE (decl));
4429 register tree arg_decls = DECL_ARGUMENTS (decl);
4432 register tree last_arg;
4434 last_arg = (arg_decls && TREE_CODE (arg_decls) != ERROR_MARK)
4435 ? tree_last (arg_decls)
4438 /* Generate DIEs to represent all known formal parameters, but
4439 don't do it if this looks like a varargs function. A given
4440 function is considered to be a varargs function if (and only
4441 if) its last named argument is named `__builtin_va_alist'. */
4444 || ! DECL_NAME (last_arg)
4445 || strcmp (IDENTIFIER_POINTER (DECL_NAME (last_arg)),
4446 "__builtin_va_alist"))
4450 /* WARNING! Kludge zone ahead! Here we have a special
4451 hack for svr4 SDB compatibility. Instead of passing the
4452 current FUNCTION_DECL node as the second parameter (i.e.
4453 the `containing_scope' parameter) to `output_decl' (as
4454 we ought to) we instead pass a pointer to our own private
4455 fake_containing_scope node. That node is a RECORD_TYPE
4456 node which NO OTHER TYPE may ever actually be a member of.
4458 This pointer will ultimately get passed into `output_type'
4459 as its `containing_scope' parameter. `Output_type' will
4460 then perform its part in the hack... i.e. it will pend
4461 the type of the formal parameter onto the pending_types
4462 list. Later on, when we are done generating the whole
4463 sequence of formal parameter DIEs for this function
4464 definition, we will un-pend all previously pended types
4465 of formal parameters for this function definition.
4467 This whole kludge prevents any type DIEs from being
4468 mixed in with the formal parameter DIEs. That's good
4469 because svr4 SDB believes that the list of formal
4470 parameter DIEs for a function ends wherever the first
4471 non-formal-parameter DIE appears. Thus, we have to
4472 keep the formal parameter DIEs segregated. They must
4473 all appear (consecutively) at the start of the list of
4474 children for the DIE representing the function definition.
4475 Then (and only then) may we output any additional DIEs
4476 needed to represent the types of these formal parameters.
4479 for (parm = arg_decls; parm; parm = TREE_CHAIN (parm))
4480 if (TREE_CODE (parm) == PARM_DECL)
4481 output_decl (parm, fake_containing_scope);
4483 /* Now that we have finished generating all of the DIEs to
4484 represent the formal parameters themselves, force out
4485 any DIEs needed to represent their types. We do this
4486 simply by un-pending all previously pended types which
4487 can legitimately go into the chain of children DIEs for
4488 the current FUNCTION_DECL. */
4490 output_pending_types_for_scope (decl);
4494 /* Now try to decide if we should put an ellipsis at the end. */
4497 register int has_ellipsis = TRUE; /* default assumption */
4498 register tree fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (decl));
4502 /* This function declaration/definition was prototyped. */
4504 /* If the list of formal argument types ends with a
4505 void_type_node, then the formals list did *not* end
4506 with an ellipsis. */
4508 if (TREE_VALUE (tree_last (fn_arg_types)) == void_type_node)
4509 has_ellipsis = FALSE;
4513 /* This function declaration/definition was not prototyped. */
4515 /* Note that all non-prototyped function *declarations* are
4516 assumed to represent varargs functions (until proven
4519 if (DECL_INITIAL (decl)) /* if this is a func definition */
4522 has_ellipsis = FALSE; /* no args == (void) */
4525 /* For a non-prototyped function definition which
4526 declares one or more formal parameters, if the name
4527 of the first formal parameter is *not*
4528 __builtin_va_alist then we must assume that this
4529 is *not* a varargs function. */
4531 if (DECL_NAME (arg_decls)
4532 && strcmp (IDENTIFIER_POINTER (DECL_NAME (arg_decls)),
4533 "__builtin_va_alist"))
4534 has_ellipsis = FALSE;
4540 output_die (output_unspecified_parameters_die, decl);
4544 /* Output Dwarf info for all of the stuff within the body of the
4545 function (if it has one - it may be just a declaration). */
4548 register tree outer_scope = DECL_INITIAL (decl);
4550 if (outer_scope && TREE_CODE (outer_scope) != ERROR_MARK)
4552 /* Note that here, `outer_scope' is a pointer to the outermost
4553 BLOCK node created to represent a function.
4554 This outermost BLOCK actually represents the outermost
4555 binding contour for the function, i.e. the contour in which
4556 the function's formal parameters and labels get declared.
4558 Curiously, it appears that the front end doesn't actually
4559 put the PARM_DECL nodes for the current function onto the
4560 BLOCK_VARS list for this outer scope. (They are strung
4561 off of the DECL_ARGUMENTS list for the function instead.)
4562 The BLOCK_VARS list for the `outer_scope' does provide us
4563 with a list of the LABEL_DECL nodes for the function however,
4564 and we output DWARF info for those here.
4566 Just within the `outer_scope' there will be another BLOCK
4567 node representing the function's outermost pair of curly
4568 braces. We musn't generate a lexical_block DIE for this
4569 outermost pair of curly braces because that is not really an
4570 independent scope according to ANSI C rules. Rather, it is
4571 the same scope in which the parameters were declared. */
4574 register tree label;
4576 for (label = BLOCK_VARS (outer_scope);
4578 label = TREE_CHAIN (label))
4579 output_decl (label, outer_scope);
4582 /* Note here that `BLOCK_SUBBLOCKS (outer_scope)' points to a
4583 list of BLOCK nodes which is always only one element long.
4584 That one element represents the outermost pair of curley
4585 braces for the function body. */
4587 output_decls_for_scope (BLOCK_SUBBLOCKS (outer_scope));
4589 /* Finally, force out any pending types which are local to the
4590 outermost block of this function definition. These will
4591 all have a TYPE_CONTEXT which points to the FUNCTION_DECL
4594 output_pending_types_for_scope (decl);
4598 /* Generate a terminator for the list of stuff `owned' by this
4601 end_sibling_chain ();
4606 /* If we are in terse mode, don't generate any DIEs to represent
4607 any actual typedefs. Note that even when we are in terse mode,
4608 we must still output DIEs to represent those tagged types which
4609 are used (directly or indirectly) in the specification of either
4610 a return type or a formal parameter type of some function. */
4612 if (debug_info_level <= DINFO_LEVEL_TERSE)
4613 if (DECL_NAME (decl) != NULL
4614 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
4617 /* In the special case of a null-named TYPE_DECL node (representing
4618 the declaration of some type tag), if the given TYPE_DECL is
4619 marked as having been instantiated from some other (original)
4620 TYPE_DECL node (e.g. one which was generated within the original
4621 definition of an inline function) we have to generate a special
4622 (abbreviated) TAG_structure_type, TAG_union_type, or
4623 TAG_enumeration-type DIE here. */
4625 if (! DECL_NAME (decl) && DECL_ABSTRACT_ORIGIN (decl))
4627 output_tagged_type_instantiation (TREE_TYPE (decl));
4631 output_type (TREE_TYPE (decl), containing_scope);
4633 /* Note that unlike the gcc front end (which generates a NULL named
4634 TYPE_DECL node for each complete tagged type, each array type,
4635 and each function type node created) the g++ front end generates
4636 a *named* TYPE_DECL node for each tagged type node created.
4637 Unfortunately, these g++ TYPE_DECL nodes cause us to output many
4638 superfluous and unnecessary TAG_typedef DIEs here. When g++ is
4639 fixed to stop generating these superfluous named TYPE_DECL nodes,
4640 the superfluous TAG_typedef DIEs will likewise cease. */
4642 if (DECL_NAME (decl))
4643 /* Output a DIE to represent the typedef itself. */
4644 output_die (output_typedef_die, decl);
4648 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4649 output_die (output_label_die, decl);
4653 /* If we are conforming to the DWARF version 1 specification, don't
4654 generated any DIEs to represent mere external object declarations. */
4656 #if (DWARF_VERSION <= 1)
4657 if (DECL_EXTERNAL (decl) && ! TREE_PUBLIC (decl))
4661 /* If we are in terse mode, don't generate any DIEs to represent
4662 any variable declarations or definitions. */
4664 if (debug_info_level <= DINFO_LEVEL_TERSE)
4667 /* Output any DIEs that are needed to specify the type of this data
4670 output_type (TREE_TYPE (decl), containing_scope);
4672 /* If the following DIE will represent a data object definition for a
4673 data object with "extern" linkage, output a special "pubnames" DIE
4674 label just ahead of the actual DIE. A reference to this label
4675 was already generated in the .debug_pubnames section sub-entry
4676 for this data object definition. */
4678 if (TREE_PUBLIC (decl) && ! DECL_ABSTRACT (decl))
4680 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4682 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
4683 ASM_OUTPUT_LABEL (asm_out_file, label);
4686 /* Now output the DIE to represent the data object itself. This gets
4687 complicated because of the possibility that the VAR_DECL really
4688 represents an inlined instance of a formal parameter for an inline
4692 register void (*func) ();
4693 register tree origin = decl_ultimate_origin (decl);
4695 if (origin != NULL && TREE_CODE (origin) == PARM_DECL)
4696 func = output_formal_parameter_die;
4699 if (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
4700 func = output_global_variable_die;
4702 func = output_local_variable_die;
4704 output_die (func, decl);
4709 /* Ignore the nameless fields that are used to skip bits. */
4710 if (DECL_NAME (decl) != 0)
4712 output_type (member_declared_type (decl), containing_scope);
4713 output_die (output_member_die, decl);
4718 /* Force out the type of this formal, if it was not forced out yet.
4719 Note that here we can run afowl of a bug in "classic" svr4 SDB.
4720 It should be able to grok the presence of type DIEs within a list
4721 of TAG_formal_parameter DIEs, but it doesn't. */
4723 output_type (TREE_TYPE (decl), containing_scope);
4724 output_die (output_formal_parameter_die, decl);
4733 dwarfout_file_scope_decl (decl, set_finalizing)
4735 register int set_finalizing;
4737 if (TREE_CODE (decl) == ERROR_MARK)
4740 /* If this ..._DECL node is marked to be ignored, then ignore it. We
4741 gotta hope that the node in question doesn't represent a function
4742 definition. If it does, then totally ignoring it is bound to screw
4743 up our count of blocks, and that it turn will completely screw up the
4744 the labels we will reference in subsequent AT_low_pc and AT_high_pc
4745 attributes (for subsequent blocks). (It's too bad that BLOCK nodes
4746 don't carry their own sequence numbers with them!) */
4748 if (DECL_IGNORED_P (decl))
4750 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
4755 switch (TREE_CODE (decl))
4759 /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of
4760 a builtin function. Explicit programmer-supplied declarations of
4761 these same functions should NOT be ignored however. */
4763 if (DECL_EXTERNAL (decl) && DECL_FUNCTION_CODE (decl))
4766 /* What we would really like to do here is to filter out all mere
4767 file-scope declarations of file-scope functions which are never
4768 referenced later within this translation unit (and keep all of
4769 ones that *are* referenced later on) but we aren't clarvoiant,
4770 so we have no idea which functions will be referenced in the
4771 future (i.e. later on within the current translation unit).
4772 So here we just ignore all file-scope function declarations
4773 which are not also definitions. If and when the debugger needs
4774 to know something about these funcstion, it wil have to hunt
4775 around and find the DWARF information associated with the
4776 *definition* of the function.
4778 Note that we can't just check `DECL_EXTERNAL' to find out which
4779 FUNCTION_DECL nodes represent definitions and which ones represent
4780 mere declarations. We have to check `DECL_INITIAL' instead. That's
4781 because the C front-end supports some weird semantics for "extern
4782 inline" function definitions. These can get inlined within the
4783 current translation unit (an thus, we need to generate DWARF info
4784 for their abstract instances so that the DWARF info for the
4785 concrete inlined instances can have something to refer to) but
4786 the compiler never generates any out-of-lines instances of such
4787 things (despite the fact that they *are* definitions). The
4788 important point is that the C front-end marks these "extern inline"
4789 functions as DECL_EXTERNAL, but we need to generate DWARf for them
4792 Note that the C++ front-end also plays some similar games for inline
4793 function definitions appearing within include files which also
4794 contain `#pragma interface' pragmas. */
4796 if (DECL_INITIAL (decl) == NULL_TREE)
4799 if (TREE_PUBLIC (decl)
4800 && ! DECL_EXTERNAL (decl)
4801 && ! DECL_ABSTRACT (decl))
4803 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4805 /* Output a .debug_pubnames entry for a public function
4806 defined in this compilation unit. */
4808 fputc ('\n', asm_out_file);
4809 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
4810 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
4811 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
4812 ASM_OUTPUT_DWARF_STRING (asm_out_file,
4813 IDENTIFIER_POINTER (DECL_NAME (decl)));
4814 ASM_OUTPUT_POP_SECTION (asm_out_file);
4821 /* Ignore this VAR_DECL if it refers to a file-scope extern data
4822 object declaration and if the declaration was never even
4823 referenced from within this entire compilation unit. We
4824 suppress these DIEs in order to save space in the .debug section
4825 (by eliminating entries which are probably useless). Note that
4826 we must not suppress block-local extern declarations (whether
4827 used or not) because that would screw-up the debugger's name
4828 lookup mechanism and cause it to miss things which really ought
4829 to be in scope at a given point. */
4831 if (DECL_EXTERNAL (decl) && !TREE_USED (decl))
4834 if (TREE_PUBLIC (decl)
4835 && ! DECL_EXTERNAL (decl)
4836 && GET_CODE (DECL_RTL (decl)) == MEM
4837 && ! DECL_ABSTRACT (decl))
4839 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4841 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4843 /* Output a .debug_pubnames entry for a public variable
4844 defined in this compilation unit. */
4846 fputc ('\n', asm_out_file);
4847 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
4848 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
4849 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
4850 ASM_OUTPUT_DWARF_STRING (asm_out_file,
4851 IDENTIFIER_POINTER (DECL_NAME (decl)));
4852 ASM_OUTPUT_POP_SECTION (asm_out_file);
4855 if (DECL_INITIAL (decl) == NULL)
4857 /* Output a .debug_aranges entry for a public variable
4858 which is tentatively defined in this compilation unit. */
4860 fputc ('\n', asm_out_file);
4861 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
4862 ASM_OUTPUT_DWARF_ADDR (asm_out_file,
4863 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
4864 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
4865 (unsigned) int_size_in_bytes (TREE_TYPE (decl)));
4866 ASM_OUTPUT_POP_SECTION (asm_out_file);
4870 /* If we are in terse mode, don't generate any DIEs to represent
4871 any variable declarations or definitions. */
4873 if (debug_info_level <= DINFO_LEVEL_TERSE)
4879 /* Don't bother trying to generate any DIEs to represent any of the
4880 normal built-in types for the language we are compiling, except
4881 in cases where the types in question are *not* DWARF fundamental
4882 types. We make an exception in the case of non-fundamental types
4883 for the sake of objective C (and perhaps C++) because the GNU
4884 front-ends for these languages may in fact create certain "built-in"
4885 types which are (for example) RECORD_TYPEs. In such cases, we
4886 really need to output these (non-fundamental) types because other
4887 DIEs may contain references to them. */
4889 if (DECL_SOURCE_LINE (decl) == 0
4890 && type_is_fundamental (TREE_TYPE (decl)))
4893 /* If we are in terse mode, don't generate any DIEs to represent
4894 any actual typedefs. Note that even when we are in terse mode,
4895 we must still output DIEs to represent those tagged types which
4896 are used (directly or indirectly) in the specification of either
4897 a return type or a formal parameter type of some function. */
4899 if (debug_info_level <= DINFO_LEVEL_TERSE)
4900 if (DECL_NAME (decl) != NULL
4901 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
4910 fputc ('\n', asm_out_file);
4911 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
4912 finalizing = set_finalizing;
4913 output_decl (decl, NULL_TREE);
4915 /* NOTE: The call above to `output_decl' may have caused one or more
4916 file-scope named types (i.e. tagged types) to be placed onto the
4917 pending_types_list. We have to get those types off of that list
4918 at some point, and this is the perfect time to do it. If we didn't
4919 take them off now, they might still be on the list when cc1 finally
4920 exits. That might be OK if it weren't for the fact that when we put
4921 types onto the pending_types_list, we set the TREE_ASM_WRITTEN flag
4922 for these types, and that causes them never to be output unless
4923 `output_pending_types_for_scope' takes them off of the list and un-sets
4924 their TREE_ASM_WRITTEN flags. */
4926 output_pending_types_for_scope (NULL_TREE);
4928 /* The above call should have totally emptied the pending_types_list. */
4930 assert (pending_types == 0);
4932 ASM_OUTPUT_POP_SECTION (asm_out_file);
4934 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
4935 current_funcdef_number++;
4938 /* Output a marker (i.e. a label) for the beginning of the generated code
4939 for a lexical block. */
4942 dwarfout_begin_block (blocknum)
4943 register unsigned blocknum;
4945 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4948 sprintf (label, BLOCK_BEGIN_LABEL_FMT, blocknum);
4949 ASM_OUTPUT_LABEL (asm_out_file, label);
4952 /* Output a marker (i.e. a label) for the end of the generated code
4953 for a lexical block. */
4956 dwarfout_end_block (blocknum)
4957 register unsigned blocknum;
4959 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4962 sprintf (label, BLOCK_END_LABEL_FMT, blocknum);
4963 ASM_OUTPUT_LABEL (asm_out_file, label);
4966 /* Output a marker (i.e. a label) at a point in the assembly code which
4967 corresponds to a given source level label. */
4970 dwarfout_label (insn)
4973 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4975 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4978 sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
4979 (unsigned) INSN_UID (insn));
4980 ASM_OUTPUT_LABEL (asm_out_file, label);
4984 /* Output a marker (i.e. a label) for the point in the generated code where
4985 the real body of the function begins (after parameters have been moved
4986 to their home locations). */
4989 dwarfout_begin_function ()
4991 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4994 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
4995 ASM_OUTPUT_LABEL (asm_out_file, label);
4998 /* Output a marker (i.e. a label) for the point in the generated code where
4999 the real body of the function ends (just before the epilogue code). */
5002 dwarfout_end_function ()
5004 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5007 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
5008 ASM_OUTPUT_LABEL (asm_out_file, label);
5011 /* Output a marker (i.e. a label) for the absolute end of the generated code
5012 for a function definition. This gets called *after* the epilogue code
5013 has been generated. */
5016 dwarfout_end_epilogue ()
5018 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5020 /* Output a label to mark the endpoint of the code generated for this
5023 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
5024 ASM_OUTPUT_LABEL (asm_out_file, label);
5028 shuffle_filename_entry (new_zeroth)
5029 register filename_entry *new_zeroth;
5031 filename_entry temp_entry;
5032 register filename_entry *limit_p;
5033 register filename_entry *move_p;
5035 if (new_zeroth == &filename_table[0])
5038 temp_entry = *new_zeroth;
5040 /* Shift entries up in the table to make room at [0]. */
5042 limit_p = &filename_table[0];
5043 for (move_p = new_zeroth; move_p > limit_p; move_p--)
5044 *move_p = *(move_p-1);
5046 /* Install the found entry at [0]. */
5048 filename_table[0] = temp_entry;
5051 /* Create a new (string) entry for the .debug_sfnames section. */
5054 generate_new_sfname_entry ()
5056 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5058 fputc ('\n', asm_out_file);
5059 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
5060 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, filename_table[0].number);
5061 ASM_OUTPUT_LABEL (asm_out_file, label);
5062 ASM_OUTPUT_DWARF_STRING (asm_out_file,
5063 filename_table[0].name
5064 ? filename_table[0].name
5066 ASM_OUTPUT_POP_SECTION (asm_out_file);
5069 /* Lookup a filename (in the list of filenames that we know about here in
5070 dwarfout.c) and return its "index". The index of each (known) filename
5071 is just a unique number which is associated with only that one filename.
5072 We need such numbers for the sake of generating labels (in the
5073 .debug_sfnames section) and references to those unique labels (in the
5074 .debug_srcinfo and .debug_macinfo sections).
5076 If the filename given as an argument is not found in our current list,
5077 add it to the list and assign it the next available unique index number.
5079 Whatever we do (i.e. whether we find a pre-existing filename or add a new
5080 one), we shuffle the filename found (or added) up to the zeroth entry of
5081 our list of filenames (which is always searched linearly). We do this so
5082 as to optimize the most common case for these filename lookups within
5083 dwarfout.c. The most common case by far is the case where we call
5084 lookup_filename to lookup the very same filename that we did a lookup
5085 on the last time we called lookup_filename. We make sure that this
5086 common case is fast because such cases will constitute 99.9% of the
5087 lookups we ever do (in practice).
5089 If we add a new filename entry to our table, we go ahead and generate
5090 the corresponding entry in the .debug_sfnames section right away.
5091 Doing so allows us to avoid tickling an assembler bug (present in some
5092 m68k assemblers) which yields assembly-time errors in cases where the
5093 difference of two label addresses is taken and where the two labels
5094 are in a section *other* than the one where the difference is being
5095 calculated, and where at least one of the two symbol references is a
5096 forward reference. (This bug could be tickled by our .debug_srcinfo
5097 entries if we don't output their corresponding .debug_sfnames entries
5102 lookup_filename (file_name)
5105 register filename_entry *search_p;
5106 register filename_entry *limit_p = &filename_table[ft_entries];
5108 for (search_p = filename_table; search_p < limit_p; search_p++)
5109 if (!strcmp (file_name, search_p->name))
5111 /* When we get here, we have found the filename that we were
5112 looking for in the filename_table. Now we want to make sure
5113 that it gets moved to the zero'th entry in the table (if it
5114 is not already there) so that subsequent attempts to find the
5115 same filename will find it as quickly as possible. */
5117 shuffle_filename_entry (search_p);
5118 return filename_table[0].number;
5121 /* We come here whenever we have a new filename which is not registered
5122 in the current table. Here we add it to the table. */
5124 /* Prepare to add a new table entry by making sure there is enough space
5125 in the table to do so. If not, expand the current table. */
5127 if (ft_entries == ft_entries_allocated)
5129 ft_entries_allocated += FT_ENTRIES_INCREMENT;
5131 = (filename_entry *)
5132 xrealloc (filename_table,
5133 ft_entries_allocated * sizeof (filename_entry));
5136 /* Initially, add the new entry at the end of the filename table. */
5138 filename_table[ft_entries].number = ft_entries;
5139 filename_table[ft_entries].name = xstrdup (file_name);
5141 /* Shuffle the new entry into filename_table[0]. */
5143 shuffle_filename_entry (&filename_table[ft_entries]);
5145 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5146 generate_new_sfname_entry ();
5149 return filename_table[0].number;
5153 generate_srcinfo_entry (line_entry_num, files_entry_num)
5154 unsigned line_entry_num;
5155 unsigned files_entry_num;
5157 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5159 fputc ('\n', asm_out_file);
5160 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
5161 sprintf (label, LINE_ENTRY_LABEL_FMT, line_entry_num);
5162 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, LINE_BEGIN_LABEL);
5163 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, files_entry_num);
5164 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, SFNAMES_BEGIN_LABEL);
5165 ASM_OUTPUT_POP_SECTION (asm_out_file);
5169 dwarfout_line (filename, line)
5170 register char *filename;
5171 register unsigned line;
5173 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5175 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5176 static unsigned last_line_entry_num = 0;
5177 static unsigned prev_file_entry_num = (unsigned) -1;
5178 register unsigned this_file_entry_num = lookup_filename (filename);
5181 sprintf (label, LINE_CODE_LABEL_FMT, ++last_line_entry_num);
5182 ASM_OUTPUT_LABEL (asm_out_file, label);
5184 fputc ('\n', asm_out_file);
5185 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
5187 if (this_file_entry_num != prev_file_entry_num)
5189 char line_entry_label[MAX_ARTIFICIAL_LABEL_BYTES];
5191 sprintf (line_entry_label, LINE_ENTRY_LABEL_FMT, last_line_entry_num);
5192 ASM_OUTPUT_LABEL (asm_out_file, line_entry_label);
5196 register char *tail = rindex (filename, '/');
5202 fprintf (asm_out_file, "\t%s\t%u\t%s %s:%u\n",
5203 UNALIGNED_INT_ASM_OP, line, ASM_COMMENT_START,
5205 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
5206 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, TEXT_BEGIN_LABEL);
5207 ASM_OUTPUT_POP_SECTION (asm_out_file);
5209 if (this_file_entry_num != prev_file_entry_num)
5210 generate_srcinfo_entry (last_line_entry_num, this_file_entry_num);
5211 prev_file_entry_num = this_file_entry_num;
5215 /* Generate an entry in the .debug_macinfo section. */
5218 generate_macinfo_entry (type_and_offset, string)
5219 register char *type_and_offset;
5220 register char *string;
5222 fputc ('\n', asm_out_file);
5223 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
5224 fprintf (asm_out_file, "\t%s\t%s\n", UNALIGNED_INT_ASM_OP, type_and_offset);
5225 ASM_OUTPUT_DWARF_STRING (asm_out_file, string);
5226 ASM_OUTPUT_POP_SECTION (asm_out_file);
5230 dwarfout_start_new_source_file (filename)
5231 register char *filename;
5233 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5234 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*3];
5236 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, lookup_filename (filename));
5237 sprintf (type_and_offset, "0x%08x+%s-%s",
5238 ((unsigned) MACINFO_start << 24), label, SFNAMES_BEGIN_LABEL);
5239 generate_macinfo_entry (type_and_offset, "");
5243 dwarfout_resume_previous_source_file (lineno)
5244 register unsigned lineno;
5246 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
5248 sprintf (type_and_offset, "0x%08x+%u",
5249 ((unsigned) MACINFO_resume << 24), lineno);
5250 generate_macinfo_entry (type_and_offset, "");
5253 /* Called from check_newline in c-parse.y. The `buffer' parameter
5254 contains the tail part of the directive line, i.e. the part which
5255 is past the initial whitespace, #, whitespace, directive-name,
5259 dwarfout_define (lineno, buffer)
5260 register unsigned lineno;
5261 register char *buffer;
5263 static int initialized = 0;
5264 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
5268 dwarfout_start_new_source_file (primary_filename);
5271 sprintf (type_and_offset, "0x%08x+%u",
5272 ((unsigned) MACINFO_define << 24), lineno);
5273 generate_macinfo_entry (type_and_offset, buffer);
5276 /* Called from check_newline in c-parse.y. The `buffer' parameter
5277 contains the tail part of the directive line, i.e. the part which
5278 is past the initial whitespace, #, whitespace, directive-name,
5282 dwarfout_undef (lineno, buffer)
5283 register unsigned lineno;
5284 register char *buffer;
5286 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
5288 sprintf (type_and_offset, "0x%08x+%u",
5289 ((unsigned) MACINFO_undef << 24), lineno);
5290 generate_macinfo_entry (type_and_offset, buffer);
5293 /* Set up for Dwarf output at the start of compilation. */
5296 dwarfout_init (asm_out_file, main_input_filename)
5297 register FILE *asm_out_file;
5298 register char *main_input_filename;
5300 /* Remember the name of the primary input file. */
5302 primary_filename = main_input_filename;
5304 /* Allocate the initial hunk of the pending_sibling_stack. */
5306 pending_sibling_stack
5308 xmalloc (PENDING_SIBLINGS_INCREMENT * sizeof (unsigned));
5309 pending_siblings_allocated = PENDING_SIBLINGS_INCREMENT;
5310 pending_siblings = 1;
5312 /* Allocate the initial hunk of the filename_table. */
5315 = (filename_entry *)
5316 xmalloc (FT_ENTRIES_INCREMENT * sizeof (filename_entry));
5317 ft_entries_allocated = FT_ENTRIES_INCREMENT;
5320 /* Allocate the initial hunk of the pending_types_list. */
5323 = (tree *) xmalloc (PENDING_TYPES_INCREMENT * sizeof (tree));
5324 pending_types_allocated = PENDING_TYPES_INCREMENT;
5327 /* Create an artificial RECORD_TYPE node which we can use in our hack
5328 to get the DIEs representing types of formal parameters to come out
5329 only *after* the DIEs for the formal parameters themselves. */
5331 fake_containing_scope = make_node (RECORD_TYPE);
5333 /* Output a starting label for the .text section. */
5335 fputc ('\n', asm_out_file);
5336 ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
5337 ASM_OUTPUT_LABEL (asm_out_file, TEXT_BEGIN_LABEL);
5338 ASM_OUTPUT_POP_SECTION (asm_out_file);
5340 /* Output a starting label for the .data section. */
5342 fputc ('\n', asm_out_file);
5343 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
5344 ASM_OUTPUT_LABEL (asm_out_file, DATA_BEGIN_LABEL);
5345 ASM_OUTPUT_POP_SECTION (asm_out_file);
5347 #if 0 /* GNU C doesn't currently use .data1. */
5348 /* Output a starting label for the .data1 section. */
5350 fputc ('\n', asm_out_file);
5351 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
5352 ASM_OUTPUT_LABEL (asm_out_file, DATA1_BEGIN_LABEL);
5353 ASM_OUTPUT_POP_SECTION (asm_out_file);
5356 /* Output a starting label for the .rodata section. */
5358 fputc ('\n', asm_out_file);
5359 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
5360 ASM_OUTPUT_LABEL (asm_out_file, RODATA_BEGIN_LABEL);
5361 ASM_OUTPUT_POP_SECTION (asm_out_file);
5363 #if 0 /* GNU C doesn't currently use .rodata1. */
5364 /* Output a starting label for the .rodata1 section. */
5366 fputc ('\n', asm_out_file);
5367 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
5368 ASM_OUTPUT_LABEL (asm_out_file, RODATA1_BEGIN_LABEL);
5369 ASM_OUTPUT_POP_SECTION (asm_out_file);
5372 /* Output a starting label for the .bss section. */
5374 fputc ('\n', asm_out_file);
5375 ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
5376 ASM_OUTPUT_LABEL (asm_out_file, BSS_BEGIN_LABEL);
5377 ASM_OUTPUT_POP_SECTION (asm_out_file);
5379 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5381 /* Output a starting label and an initial (compilation directory)
5382 entry for the .debug_sfnames section. The starting label will be
5383 referenced by the initial entry in the .debug_srcinfo section. */
5385 fputc ('\n', asm_out_file);
5386 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
5387 ASM_OUTPUT_LABEL (asm_out_file, SFNAMES_BEGIN_LABEL);
5390 register unsigned len;
5391 register char *dirname;
5395 pfatal_with_name ("getpwd");
5397 dirname = (char *) xmalloc (len + 2);
5399 strcpy (dirname, pwd);
5400 strcpy (dirname + len, "/");
5401 ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname);
5404 ASM_OUTPUT_POP_SECTION (asm_out_file);
5406 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
5408 /* Output a starting label for the .debug_macinfo section. This
5409 label will be referenced by the AT_mac_info attribute in the
5410 TAG_compile_unit DIE. */
5412 fputc ('\n', asm_out_file);
5413 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
5414 ASM_OUTPUT_LABEL (asm_out_file, MACINFO_BEGIN_LABEL);
5415 ASM_OUTPUT_POP_SECTION (asm_out_file);
5418 /* Generate the initial entry for the .line section. */
5420 fputc ('\n', asm_out_file);
5421 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
5422 ASM_OUTPUT_LABEL (asm_out_file, LINE_BEGIN_LABEL);
5423 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, LINE_END_LABEL, LINE_BEGIN_LABEL);
5424 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
5425 ASM_OUTPUT_POP_SECTION (asm_out_file);
5427 /* Generate the initial entry for the .debug_srcinfo section. */
5429 fputc ('\n', asm_out_file);
5430 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
5431 ASM_OUTPUT_LABEL (asm_out_file, SRCINFO_BEGIN_LABEL);
5432 ASM_OUTPUT_DWARF_ADDR (asm_out_file, LINE_BEGIN_LABEL);
5433 ASM_OUTPUT_DWARF_ADDR (asm_out_file, SFNAMES_BEGIN_LABEL);
5434 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
5435 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_END_LABEL);
5436 #ifdef DWARF_TIMESTAMPS
5437 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, time (NULL));
5439 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
5441 ASM_OUTPUT_POP_SECTION (asm_out_file);
5443 /* Generate the initial entry for the .debug_pubnames section. */
5445 fputc ('\n', asm_out_file);
5446 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
5447 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
5448 ASM_OUTPUT_POP_SECTION (asm_out_file);
5450 /* Generate the initial entry for the .debug_aranges section. */
5452 fputc ('\n', asm_out_file);
5453 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
5454 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
5455 ASM_OUTPUT_POP_SECTION (asm_out_file);
5458 /* Setup first DIE number == 1. */
5459 NEXT_DIE_NUM = next_unused_dienum++;
5461 /* Generate the initial DIE for the .debug section. Note that the
5462 (string) value given in the AT_name attribute of the TAG_compile_unit
5463 DIE will (typically) be a relative pathname and that this pathname
5464 should be taken as being relative to the directory from which the
5465 compiler was invoked when the given (base) source file was compiled. */
5467 fputc ('\n', asm_out_file);
5468 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
5469 ASM_OUTPUT_LABEL (asm_out_file, DEBUG_BEGIN_LABEL);
5470 output_die (output_compile_unit_die, main_input_filename);
5471 ASM_OUTPUT_POP_SECTION (asm_out_file);
5473 fputc ('\n', asm_out_file);
5476 /* Output stuff that dwarf requires at the end of every file. */
5481 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5483 fputc ('\n', asm_out_file);
5484 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
5486 /* Mark the end of the chain of siblings which represent all file-scope
5487 declarations in this compilation unit. */
5489 /* The (null) DIE which represents the terminator for the (sibling linked)
5490 list of file-scope items is *special*. Normally, we would just call
5491 end_sibling_chain at this point in order to output a word with the
5492 value `4' and that word would act as the terminator for the list of
5493 DIEs describing file-scope items. Unfortunately, if we were to simply
5494 do that, the label that would follow this DIE in the .debug section
5495 (i.e. `..D2') would *not* be properly aligned (as it must be on some
5496 machines) to a 4 byte boundary.
5498 In order to force the label `..D2' to get aligned to a 4 byte boundary,
5499 the trick used is to insert extra (otherwise useless) padding bytes
5500 into the (null) DIE that we know must precede the ..D2 label in the
5501 .debug section. The amount of padding required can be anywhere between
5502 0 and 3 bytes. The length word at the start of this DIE (i.e. the one
5503 with the padding) would normally contain the value 4, but now it will
5504 also have to include the padding bytes, so it will instead have some
5505 value in the range 4..7.
5507 Fortunately, the rules of Dwarf say that any DIE whose length word
5508 contains *any* value less than 8 should be treated as a null DIE, so
5509 this trick works out nicely. Clever, eh? Don't give me any credit
5510 (or blame). I didn't think of this scheme. I just conformed to it.
5513 output_die (output_padded_null_die, (void *)0);
5516 sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
5517 ASM_OUTPUT_LABEL (asm_out_file, label); /* should be ..D2 */
5518 ASM_OUTPUT_POP_SECTION (asm_out_file);
5520 /* Output a terminator label for the .text section. */
5522 fputc ('\n', asm_out_file);
5523 ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
5524 ASM_OUTPUT_LABEL (asm_out_file, TEXT_END_LABEL);
5525 ASM_OUTPUT_POP_SECTION (asm_out_file);
5527 /* Output a terminator label for the .data section. */
5529 fputc ('\n', asm_out_file);
5530 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
5531 ASM_OUTPUT_LABEL (asm_out_file, DATA_END_LABEL);
5532 ASM_OUTPUT_POP_SECTION (asm_out_file);
5534 #if 0 /* GNU C doesn't currently use .data1. */
5535 /* Output a terminator label for the .data1 section. */
5537 fputc ('\n', asm_out_file);
5538 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
5539 ASM_OUTPUT_LABEL (asm_out_file, DATA1_END_LABEL);
5540 ASM_OUTPUT_POP_SECTION (asm_out_file);
5543 /* Output a terminator label for the .rodata section. */
5545 fputc ('\n', asm_out_file);
5546 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
5547 ASM_OUTPUT_LABEL (asm_out_file, RODATA_END_LABEL);
5548 ASM_OUTPUT_POP_SECTION (asm_out_file);
5550 #if 0 /* GNU C doesn't currently use .rodata1. */
5551 /* Output a terminator label for the .rodata1 section. */
5553 fputc ('\n', asm_out_file);
5554 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
5555 ASM_OUTPUT_LABEL (asm_out_file, RODATA1_END_LABEL);
5556 ASM_OUTPUT_POP_SECTION (asm_out_file);
5559 /* Output a terminator label for the .bss section. */
5561 fputc ('\n', asm_out_file);
5562 ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
5563 ASM_OUTPUT_LABEL (asm_out_file, BSS_END_LABEL);
5564 ASM_OUTPUT_POP_SECTION (asm_out_file);
5566 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5568 /* Output a terminating entry for the .line section. */
5570 fputc ('\n', asm_out_file);
5571 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
5572 ASM_OUTPUT_LABEL (asm_out_file, LINE_LAST_ENTRY_LABEL);
5573 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5574 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
5575 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
5576 ASM_OUTPUT_LABEL (asm_out_file, LINE_END_LABEL);
5577 ASM_OUTPUT_POP_SECTION (asm_out_file);
5579 /* Output a terminating entry for the .debug_srcinfo section. */
5581 fputc ('\n', asm_out_file);
5582 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
5583 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
5584 LINE_LAST_ENTRY_LABEL, LINE_BEGIN_LABEL);
5585 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
5586 ASM_OUTPUT_POP_SECTION (asm_out_file);
5588 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
5590 /* Output terminating entries for the .debug_macinfo section. */
5592 dwarfout_resume_previous_source_file (0);
5594 fputc ('\n', asm_out_file);
5595 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
5596 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5597 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
5598 ASM_OUTPUT_POP_SECTION (asm_out_file);
5601 /* Generate the terminating entry for the .debug_pubnames section. */
5603 fputc ('\n', asm_out_file);
5604 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
5605 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5606 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
5607 ASM_OUTPUT_POP_SECTION (asm_out_file);
5609 /* Generate the terminating entries for the .debug_aranges section.
5611 Note that we want to do this only *after* we have output the end
5612 labels (for the various program sections) which we are going to
5613 refer to here. This allows us to work around a bug in the m68k
5614 svr4 assembler. That assembler gives bogus assembly-time errors
5615 if (within any given section) you try to take the difference of
5616 two relocatable symbols, both of which are located within some
5617 other section, and if one (or both?) of the symbols involved is
5618 being forward-referenced. By generating the .debug_aranges
5619 entries at this late point in the assembly output, we skirt the
5620 issue simply by avoiding forward-references.
5623 fputc ('\n', asm_out_file);
5624 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
5626 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
5627 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
5629 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA_BEGIN_LABEL);
5630 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA_END_LABEL, DATA_BEGIN_LABEL);
5632 #if 0 /* GNU C doesn't currently use .data1. */
5633 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA1_BEGIN_LABEL);
5634 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA1_END_LABEL,
5638 ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA_BEGIN_LABEL);
5639 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA_END_LABEL,
5640 RODATA_BEGIN_LABEL);
5642 #if 0 /* GNU C doesn't currently use .rodata1. */
5643 ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA1_BEGIN_LABEL);
5644 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA1_END_LABEL,
5645 RODATA1_BEGIN_LABEL);
5648 ASM_OUTPUT_DWARF_ADDR (asm_out_file, BSS_BEGIN_LABEL);
5649 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, BSS_END_LABEL, BSS_BEGIN_LABEL);
5651 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5652 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5654 ASM_OUTPUT_POP_SECTION (asm_out_file);
5658 #endif /* DWARF_DEBUGGING_INFO */