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 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 "insn-config.h"
37 #define DWARF_VERSION 1
40 /* #define NDEBUG 1 */
43 #if defined(DWARF_TIMESTAMPS)
46 #else /* !defined(POSIX) */
47 #include <sys/types.h>
49 extern time_t time (time_t *);
50 #else /* !defined(__STDC__) */
51 extern time_t time ();
52 #endif /* !defined(__STDC__) */
53 #endif /* !defined(POSIX) */
54 #endif /* defined(DWARF_TIMESTAMPS) */
56 extern char *getpwd ();
58 extern char *index ();
59 extern char *rindex ();
61 /* IMPORTANT NOTE: Please see the file README.DWARF for important details
62 regarding the GNU implementation of Dwarf. */
64 /* NOTE: In the comments in this file, many references are made to
65 so called "Debugging Information Entries". For the sake of brevity,
66 this term is abbreviated to `DIE' throughout the remainder of this
69 /* Note that the implementation of C++ support herein is (as yet) unfinished.
70 If you want to try to complete it, more power to you. */
72 #if defined(__GNUC__) && (NDEBUG == 1)
73 #define inline static inline
78 /* How to start an assembler comment. */
79 #ifndef ASM_COMMENT_START
80 #define ASM_COMMENT_START ";#"
83 /* Define a macro which, when given a pointer to some BLOCK node, returns
84 a pointer to the FUNCTION_DECL node from which the given BLOCK node
85 was instantiated (as an inline expansion). This macro needs to be
86 defined properly in tree.h, however for the moment, we just fake it. */
88 #define BLOCK_INLINE_FUNCTION(block) 0
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 /* Forward declarations for functions defined in this file. */
289 static void output_type ();
290 static void type_attribute ();
291 static void output_decls_for_scope ();
292 static void output_decl ();
293 static unsigned lookup_filename ();
295 /* Definitions of defaults for assembler-dependent names of various
296 pseudo-ops and section names.
298 Theses may be overridden in your tm.h file (if necessary) for your
299 particular assembler. The default values provided here correspond to
300 what is expected by "standard" AT&T System V.4 assemblers. */
303 #define FILE_ASM_OP ".file"
305 #ifndef VERSION_ASM_OP
306 #define VERSION_ASM_OP ".version"
308 #ifndef UNALIGNED_SHORT_ASM_OP
309 #define UNALIGNED_SHORT_ASM_OP ".2byte"
311 #ifndef UNALIGNED_INT_ASM_OP
312 #define UNALIGNED_INT_ASM_OP ".4byte"
315 #define ASM_BYTE_OP ".byte"
318 #define SET_ASM_OP ".set"
321 /* Pseudo-ops for pushing the current section onto the section stack (and
322 simultaneously changing to a new section) and for poping back to the
323 section we were in immediately before this one. Note that most svr4
324 assemblers only maintain a one level stack... you can push all the
325 sections you want, but you can only pop out one level. (The sparc
326 svr4 assembler is an exception to this general rule.) That's
327 OK because we only use at most one level of the section stack herein. */
329 #ifndef PUSHSECTION_ASM_OP
330 #define PUSHSECTION_ASM_OP ".section"
332 #ifndef POPSECTION_ASM_OP
333 #define POPSECTION_ASM_OP ".previous"
336 /* The default format used by the ASM_OUTPUT_PUSH_SECTION macro (see below)
337 to print the PUSHSECTION_ASM_OP and the section name. The default here
338 works for almost all svr4 assemblers, except for the sparc, where the
339 section name must be enclosed in double quotes. (See sparcv4.h.) */
341 #ifndef PUSHSECTION_FORMAT
342 #define PUSHSECTION_FORMAT "%s\t%s\n"
345 #ifndef DEBUG_SECTION
346 #define DEBUG_SECTION ".debug"
349 #define LINE_SECTION ".line"
351 #ifndef SFNAMES_SECTION
352 #define SFNAMES_SECTION ".debug_sfnames"
354 #ifndef SRCINFO_SECTION
355 #define SRCINFO_SECTION ".debug_srcinfo"
357 #ifndef MACINFO_SECTION
358 #define MACINFO_SECTION ".debug_macinfo"
360 #ifndef PUBNAMES_SECTION
361 #define PUBNAMES_SECTION ".debug_pubnames"
363 #ifndef ARANGES_SECTION
364 #define ARANGES_SECTION ".debug_aranges"
367 #define TEXT_SECTION ".text"
370 #define DATA_SECTION ".data"
372 #ifndef DATA1_SECTION
373 #define DATA1_SECTION ".data1"
375 #ifndef RODATA_SECTION
376 #define RODATA_SECTION ".rodata"
378 #ifndef RODATA1_SECTION
379 #define RODATA1_SECTION ".rodata1"
382 #define BSS_SECTION ".bss"
385 /* Definitions of defaults for formats and names of various special
386 (artificial) labels which may be generated within this file (when
387 the -g options is used and DWARF_DEBUGGING_INFO is in effect.
389 If necessary, these may be overridden from within your tm.h file,
390 but typically, you should never need to override these.
392 These labels have been hacked (temporarily) so that they all begin with
393 a `.L' sequence so as to appease the stock sparc/svr4 assembler and the
394 stock m88k/svr4 assembler, both of which need to see .L at the start of
395 a label in order to prevent that label from going into the linker symbol
396 table). When I get time, I'll have to fix this the right way so that we
397 will use ASM_GENERATE_INTERNAL_LABEL and ASM_OUTPUT_INTERNAL_LABEL herein,
398 but that will require a rather massive set of changes. For the moment,
399 the following definitions out to produce the right results for all svr4
400 and svr3 assemblers. -- rfg
403 #ifndef TEXT_BEGIN_LABEL
404 #define TEXT_BEGIN_LABEL ".L_text_b"
406 #ifndef TEXT_END_LABEL
407 #define TEXT_END_LABEL ".L_text_e"
410 #ifndef DATA_BEGIN_LABEL
411 #define DATA_BEGIN_LABEL ".L_data_b"
413 #ifndef DATA_END_LABEL
414 #define DATA_END_LABEL ".L_data_e"
417 #ifndef DATA1_BEGIN_LABEL
418 #define DATA1_BEGIN_LABEL ".L_data1_b"
420 #ifndef DATA1_END_LABEL
421 #define DATA1_END_LABEL ".L_data1_e"
424 #ifndef RODATA_BEGIN_LABEL
425 #define RODATA_BEGIN_LABEL ".L_rodata_b"
427 #ifndef RODATA_END_LABEL
428 #define RODATA_END_LABEL ".L_rodata_e"
431 #ifndef RODATA1_BEGIN_LABEL
432 #define RODATA1_BEGIN_LABEL ".L_rodata1_b"
434 #ifndef RODATA1_END_LABEL
435 #define RODATA1_END_LABEL ".L_rodata1_e"
438 #ifndef BSS_BEGIN_LABEL
439 #define BSS_BEGIN_LABEL ".L_bss_b"
441 #ifndef BSS_END_LABEL
442 #define BSS_END_LABEL ".L_bss_e"
445 #ifndef LINE_BEGIN_LABEL
446 #define LINE_BEGIN_LABEL ".L_line_b"
448 #ifndef LINE_LAST_ENTRY_LABEL
449 #define LINE_LAST_ENTRY_LABEL ".L_line_last"
451 #ifndef LINE_END_LABEL
452 #define LINE_END_LABEL ".L_line_e"
455 #ifndef DEBUG_BEGIN_LABEL
456 #define DEBUG_BEGIN_LABEL ".L_debug_b"
458 #ifndef SFNAMES_BEGIN_LABEL
459 #define SFNAMES_BEGIN_LABEL ".L_sfnames_b"
461 #ifndef SRCINFO_BEGIN_LABEL
462 #define SRCINFO_BEGIN_LABEL ".L_srcinfo_b"
464 #ifndef MACINFO_BEGIN_LABEL
465 #define MACINFO_BEGIN_LABEL ".L_macinfo_b"
468 #ifndef DIE_BEGIN_LABEL_FMT
469 #define DIE_BEGIN_LABEL_FMT ".L_D%u"
471 #ifndef DIE_END_LABEL_FMT
472 #define DIE_END_LABEL_FMT ".L_D%u_e"
474 #ifndef PUB_DIE_LABEL_FMT
475 #define PUB_DIE_LABEL_FMT ".L_P%u"
477 #ifndef INSN_LABEL_FMT
478 #define INSN_LABEL_FMT ".L_I%u_%u"
480 #ifndef BLOCK_BEGIN_LABEL_FMT
481 #define BLOCK_BEGIN_LABEL_FMT ".L_B%u"
483 #ifndef BLOCK_END_LABEL_FMT
484 #define BLOCK_END_LABEL_FMT ".L_B%u_e"
486 #ifndef SS_BEGIN_LABEL_FMT
487 #define SS_BEGIN_LABEL_FMT ".L_s%u"
489 #ifndef SS_END_LABEL_FMT
490 #define SS_END_LABEL_FMT ".L_s%u_e"
492 #ifndef EE_BEGIN_LABEL_FMT
493 #define EE_BEGIN_LABEL_FMT ".L_e%u"
495 #ifndef EE_END_LABEL_FMT
496 #define EE_END_LABEL_FMT ".L_e%u_e"
498 #ifndef MT_BEGIN_LABEL_FMT
499 #define MT_BEGIN_LABEL_FMT ".L_t%u"
501 #ifndef MT_END_LABEL_FMT
502 #define MT_END_LABEL_FMT ".L_t%u_e"
504 #ifndef LOC_BEGIN_LABEL_FMT
505 #define LOC_BEGIN_LABEL_FMT ".L_l%u"
507 #ifndef LOC_END_LABEL_FMT
508 #define LOC_END_LABEL_FMT ".L_l%u_e"
510 #ifndef BOUND_BEGIN_LABEL_FMT
511 #define BOUND_BEGIN_LABEL_FMT ".L_b%u_%u_%c"
513 #ifndef BOUND_END_LABEL_FMT
514 #define BOUND_END_LABEL_FMT ".L_b%u_%u_%c_e"
516 #ifndef DERIV_BEGIN_LABEL_FMT
517 #define DERIV_BEGIN_LABEL_FMT ".L_d%u"
519 #ifndef DERIV_END_LABEL_FMT
520 #define DERIV_END_LABEL_FMT ".L_d%u_e"
522 #ifndef SL_BEGIN_LABEL_FMT
523 #define SL_BEGIN_LABEL_FMT ".L_sl%u"
525 #ifndef SL_END_LABEL_FMT
526 #define SL_END_LABEL_FMT ".L_sl%u_e"
528 #ifndef FUNC_END_LABEL_FMT
529 #define FUNC_END_LABEL_FMT ".L_f%u_e"
531 #ifndef TYPE_NAME_FMT
532 #define TYPE_NAME_FMT ".L_T%u"
534 #ifndef DECL_NAME_FMT
535 #define DECL_NAME_FMT ".L_E%u"
537 #ifndef LINE_CODE_LABEL_FMT
538 #define LINE_CODE_LABEL_FMT ".L_LC%u"
540 #ifndef SFNAMES_ENTRY_LABEL_FMT
541 #define SFNAMES_ENTRY_LABEL_FMT ".L_F%u"
543 #ifndef LINE_ENTRY_LABEL_FMT
544 #define LINE_ENTRY_LABEL_FMT ".L_LE%u"
547 /* Definitions of defaults for various types of primitive assembly language
550 If necessary, these may be overridden from within your tm.h file,
551 but typically, you shouldn't need to override these. One known
552 exception is ASM_OUTPUT_DEF which has to be different for stock
553 sparc/svr4 assemblers.
556 #ifndef ASM_OUTPUT_PUSH_SECTION
557 #define ASM_OUTPUT_PUSH_SECTION(FILE, SECTION) \
558 fprintf ((FILE), PUSHSECTION_FORMAT, PUSHSECTION_ASM_OP, SECTION)
561 #ifndef ASM_OUTPUT_POP_SECTION
562 #define ASM_OUTPUT_POP_SECTION(FILE) \
563 fprintf ((FILE), "\t%s\n", POPSECTION_ASM_OP)
566 #ifndef ASM_OUTPUT_SOURCE_FILENAME
567 #define ASM_OUTPUT_SOURCE_FILENAME(FILE,NAME) \
568 fprintf ((FILE), "\t%s\t\"%s\"\n", FILE_ASM_OP, NAME)
571 #ifndef ASM_OUTPUT_DEF
572 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
573 do { fprintf ((FILE), "\t%s\t", SET_ASM_OP); \
574 assemble_name (FILE, LABEL1); \
575 fprintf (FILE, ","); \
576 assemble_name (FILE, LABEL2); \
577 fprintf (FILE, "\n"); \
581 #ifndef ASM_OUTPUT_DWARF_DELTA2
582 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
583 do { fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \
584 assemble_name (FILE, LABEL1); \
585 fprintf (FILE, "-"); \
586 assemble_name (FILE, LABEL2); \
587 fprintf (FILE, "\n"); \
591 #ifndef ASM_OUTPUT_DWARF_DELTA4
592 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
593 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
594 assemble_name (FILE, LABEL1); \
595 fprintf (FILE, "-"); \
596 assemble_name (FILE, LABEL2); \
597 fprintf (FILE, "\n"); \
601 #ifndef ASM_OUTPUT_DWARF_TAG
602 #define ASM_OUTPUT_DWARF_TAG(FILE,TAG) \
604 fprintf ((FILE), "\t%s\t0x%x", \
605 UNALIGNED_SHORT_ASM_OP, (unsigned) TAG); \
606 if (flag_verbose_asm) \
607 fprintf ((FILE), "\t%s %s", \
608 ASM_COMMENT_START, dwarf_tag_name (TAG)); \
609 fputc ('\n', (FILE)); \
613 #ifndef ASM_OUTPUT_DWARF_ATTRIBUTE
614 #define ASM_OUTPUT_DWARF_ATTRIBUTE(FILE,ATTR) \
616 fprintf ((FILE), "\t%s\t0x%x", \
617 UNALIGNED_SHORT_ASM_OP, (unsigned) ATTR); \
618 if (flag_verbose_asm) \
619 fprintf ((FILE), "\t%s %s", \
620 ASM_COMMENT_START, dwarf_attr_name (ATTR)); \
621 fputc ('\n', (FILE)); \
625 #ifndef ASM_OUTPUT_DWARF_STACK_OP
626 #define ASM_OUTPUT_DWARF_STACK_OP(FILE,OP) \
628 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) OP); \
629 if (flag_verbose_asm) \
630 fprintf ((FILE), "\t%s %s", \
631 ASM_COMMENT_START, dwarf_stack_op_name (OP)); \
632 fputc ('\n', (FILE)); \
636 #ifndef ASM_OUTPUT_DWARF_FUND_TYPE
637 #define ASM_OUTPUT_DWARF_FUND_TYPE(FILE,FT) \
639 fprintf ((FILE), "\t%s\t0x%x", \
640 UNALIGNED_SHORT_ASM_OP, (unsigned) FT); \
641 if (flag_verbose_asm) \
642 fprintf ((FILE), "\t%s %s", \
643 ASM_COMMENT_START, dwarf_fund_type_name (FT)); \
644 fputc ('\n', (FILE)); \
648 #ifndef ASM_OUTPUT_DWARF_FMT_BYTE
649 #define ASM_OUTPUT_DWARF_FMT_BYTE(FILE,FMT) \
651 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) FMT); \
652 if (flag_verbose_asm) \
653 fprintf ((FILE), "\t%s %s", \
654 ASM_COMMENT_START, dwarf_fmt_byte_name (FMT)); \
655 fputc ('\n', (FILE)); \
659 #ifndef ASM_OUTPUT_DWARF_TYPE_MODIFIER
660 #define ASM_OUTPUT_DWARF_TYPE_MODIFIER(FILE,MOD) \
662 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) MOD); \
663 if (flag_verbose_asm) \
664 fprintf ((FILE), "\t%s %s", \
665 ASM_COMMENT_START, dwarf_typemod_name (MOD)); \
666 fputc ('\n', (FILE)); \
670 #ifndef ASM_OUTPUT_DWARF_ADDR
671 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
672 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
673 assemble_name (FILE, LABEL); \
674 fprintf (FILE, "\n"); \
678 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
679 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX) \
681 fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
682 output_addr_const ((FILE), (RTX)); \
683 fputc ('\n', (FILE)); \
687 #ifndef ASM_OUTPUT_DWARF_REF
688 #define ASM_OUTPUT_DWARF_REF(FILE,LABEL) \
689 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
690 assemble_name (FILE, LABEL); \
691 fprintf (FILE, "\n"); \
695 #ifndef ASM_OUTPUT_DWARF_DATA1
696 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
697 fprintf ((FILE), "\t%s\t0x%x\n", ASM_BYTE_OP, VALUE)
700 #ifndef ASM_OUTPUT_DWARF_DATA2
701 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
702 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_SHORT_ASM_OP, (unsigned) VALUE)
705 #ifndef ASM_OUTPUT_DWARF_DATA4
706 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
707 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, (unsigned) VALUE)
710 #ifndef ASM_OUTPUT_DWARF_DATA8
711 #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \
713 if (WORDS_BIG_ENDIAN) \
715 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
716 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
720 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
721 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
726 #ifndef ASM_OUTPUT_DWARF_STRING
727 #define ASM_OUTPUT_DWARF_STRING(FILE,P) \
728 ASM_OUTPUT_ASCII ((FILE), P, strlen (P)+1)
731 /************************ general utility functions **************************/
737 register char *p = (char *) xmalloc (strlen (s) + 1);
747 return (((GET_CODE (rtl) == REG) && (REGNO (rtl) >= FIRST_PSEUDO_REGISTER))
748 || ((GET_CODE (rtl) == SUBREG)
749 && (REGNO (XEXP (rtl, 0)) >= FIRST_PSEUDO_REGISTER)));
754 register unsigned tag;
758 case TAG_padding: return "TAG_padding";
759 case TAG_array_type: return "TAG_array_type";
760 case TAG_class_type: return "TAG_class_type";
761 case TAG_entry_point: return "TAG_entry_point";
762 case TAG_enumeration_type: return "TAG_enumeration_type";
763 case TAG_formal_parameter: return "TAG_formal_parameter";
764 case TAG_global_subroutine: return "TAG_global_subroutine";
765 case TAG_global_variable: return "TAG_global_variable";
766 case TAG_label: return "TAG_label";
767 case TAG_lexical_block: return "TAG_lexical_block";
768 case TAG_local_variable: return "TAG_local_variable";
769 case TAG_member: return "TAG_member";
770 case TAG_pointer_type: return "TAG_pointer_type";
771 case TAG_reference_type: return "TAG_reference_type";
772 case TAG_compile_unit: return "TAG_compile_unit";
773 case TAG_string_type: return "TAG_string_type";
774 case TAG_structure_type: return "TAG_structure_type";
775 case TAG_subroutine: return "TAG_subroutine";
776 case TAG_subroutine_type: return "TAG_subroutine_type";
777 case TAG_typedef: return "TAG_typedef";
778 case TAG_union_type: return "TAG_union_type";
779 case TAG_unspecified_parameters: return "TAG_unspecified_parameters";
780 case TAG_variant: return "TAG_variant";
781 case TAG_common_block: return "TAG_common_block";
782 case TAG_common_inclusion: return "TAG_common_inclusion";
783 case TAG_inheritance: return "TAG_inheritance";
784 case TAG_inlined_subroutine: return "TAG_inlined_subroutine";
785 case TAG_module: return "TAG_module";
786 case TAG_ptr_to_member_type: return "TAG_ptr_to_member_type";
787 case TAG_set_type: return "TAG_set_type";
788 case TAG_subrange_type: return "TAG_subrange_type";
789 case TAG_with_stmt: return "TAG_with_stmt";
791 /* GNU extensions. */
793 case TAG_format_label: return "TAG_format_label";
794 case TAG_namelist: return "TAG_namelist";
795 case TAG_function_template: return "TAG_function_template";
796 case TAG_class_template: return "TAG_class_template";
798 default: return "TAG_<unknown>";
803 dwarf_attr_name (attr)
804 register unsigned attr;
808 case AT_sibling: return "AT_sibling";
809 case AT_location: return "AT_location";
810 case AT_name: return "AT_name";
811 case AT_fund_type: return "AT_fund_type";
812 case AT_mod_fund_type: return "AT_mod_fund_type";
813 case AT_user_def_type: return "AT_user_def_type";
814 case AT_mod_u_d_type: return "AT_mod_u_d_type";
815 case AT_ordering: return "AT_ordering";
816 case AT_subscr_data: return "AT_subscr_data";
817 case AT_byte_size: return "AT_byte_size";
818 case AT_bit_offset: return "AT_bit_offset";
819 case AT_bit_size: return "AT_bit_size";
820 case AT_element_list: return "AT_element_list";
821 case AT_stmt_list: return "AT_stmt_list";
822 case AT_low_pc: return "AT_low_pc";
823 case AT_high_pc: return "AT_high_pc";
824 case AT_language: return "AT_language";
825 case AT_member: return "AT_member";
826 case AT_discr: return "AT_discr";
827 case AT_discr_value: return "AT_discr_value";
828 case AT_string_length: return "AT_string_length";
829 case AT_common_reference: return "AT_common_reference";
830 case AT_comp_dir: return "AT_comp_dir";
831 case AT_const_value_string: return "AT_const_value_string";
832 case AT_const_value_data2: return "AT_const_value_data2";
833 case AT_const_value_data4: return "AT_const_value_data4";
834 case AT_const_value_data8: return "AT_const_value_data8";
835 case AT_const_value_block2: return "AT_const_value_block2";
836 case AT_const_value_block4: return "AT_const_value_block4";
837 case AT_containing_type: return "AT_containing_type";
838 case AT_default_value_addr: return "AT_default_value_addr";
839 case AT_default_value_data2: return "AT_default_value_data2";
840 case AT_default_value_data4: return "AT_default_value_data4";
841 case AT_default_value_data8: return "AT_default_value_data8";
842 case AT_default_value_string: return "AT_default_value_string";
843 case AT_friends: return "AT_friends";
844 case AT_inline: return "AT_inline";
845 case AT_is_optional: return "AT_is_optional";
846 case AT_lower_bound_ref: return "AT_lower_bound_ref";
847 case AT_lower_bound_data2: return "AT_lower_bound_data2";
848 case AT_lower_bound_data4: return "AT_lower_bound_data4";
849 case AT_lower_bound_data8: return "AT_lower_bound_data8";
850 case AT_private: return "AT_private";
851 case AT_producer: return "AT_producer";
852 case AT_program: return "AT_program";
853 case AT_protected: return "AT_protected";
854 case AT_prototyped: return "AT_prototyped";
855 case AT_public: return "AT_public";
856 case AT_pure_virtual: return "AT_pure_virtual";
857 case AT_return_addr: return "AT_return_addr";
858 case AT_abstract_origin: return "AT_abstract_origin";
859 case AT_start_scope: return "AT_start_scope";
860 case AT_stride_size: return "AT_stride_size";
861 case AT_upper_bound_ref: return "AT_upper_bound_ref";
862 case AT_upper_bound_data2: return "AT_upper_bound_data2";
863 case AT_upper_bound_data4: return "AT_upper_bound_data4";
864 case AT_upper_bound_data8: return "AT_upper_bound_data8";
865 case AT_virtual: return "AT_virtual";
869 case AT_sf_names: return "AT_sf_names";
870 case AT_src_info: return "AT_src_info";
871 case AT_mac_info: return "AT_mac_info";
872 case AT_src_coords: return "AT_src_coords";
874 default: return "AT_<unknown>";
879 dwarf_stack_op_name (op)
880 register unsigned op;
884 case OP_REG: return "OP_REG";
885 case OP_BASEREG: return "OP_BASEREG";
886 case OP_ADDR: return "OP_ADDR";
887 case OP_CONST: return "OP_CONST";
888 case OP_DEREF2: return "OP_DEREF2";
889 case OP_DEREF4: return "OP_DEREF4";
890 case OP_ADD: return "OP_ADD";
891 default: return "OP_<unknown>";
896 dwarf_typemod_name (mod)
897 register unsigned mod;
901 case MOD_pointer_to: return "MOD_pointer_to";
902 case MOD_reference_to: return "MOD_reference_to";
903 case MOD_const: return "MOD_const";
904 case MOD_volatile: return "MOD_volatile";
905 default: return "MOD_<unknown>";
910 dwarf_fmt_byte_name (fmt)
911 register unsigned fmt;
915 case FMT_FT_C_C: return "FMT_FT_C_C";
916 case FMT_FT_C_X: return "FMT_FT_C_X";
917 case FMT_FT_X_C: return "FMT_FT_X_C";
918 case FMT_FT_X_X: return "FMT_FT_X_X";
919 case FMT_UT_C_C: return "FMT_UT_C_C";
920 case FMT_UT_C_X: return "FMT_UT_C_X";
921 case FMT_UT_X_C: return "FMT_UT_X_C";
922 case FMT_UT_X_X: return "FMT_UT_X_X";
923 case FMT_ET: return "FMT_ET";
924 default: return "FMT_<unknown>";
928 dwarf_fund_type_name (ft)
929 register unsigned ft;
933 case FT_char: return "FT_char";
934 case FT_signed_char: return "FT_signed_char";
935 case FT_unsigned_char: return "FT_unsigned_char";
936 case FT_short: return "FT_short";
937 case FT_signed_short: return "FT_signed_short";
938 case FT_unsigned_short: return "FT_unsigned_short";
939 case FT_integer: return "FT_integer";
940 case FT_signed_integer: return "FT_signed_integer";
941 case FT_unsigned_integer: return "FT_unsigned_integer";
942 case FT_long: return "FT_long";
943 case FT_signed_long: return "FT_signed_long";
944 case FT_unsigned_long: return "FT_unsigned_long";
945 case FT_pointer: return "FT_pointer";
946 case FT_float: return "FT_float";
947 case FT_dbl_prec_float: return "FT_dbl_prec_float";
948 case FT_ext_prec_float: return "FT_ext_prec_float";
949 case FT_complex: return "FT_complex";
950 case FT_dbl_prec_complex: return "FT_dbl_prec_complex";
951 case FT_void: return "FT_void";
952 case FT_boolean: return "FT_boolean";
953 case FT_ext_prec_complex: return "FT_ext_prec_complex";
954 case FT_label: return "FT_label";
956 /* GNU extensions. */
958 case FT_long_long: return "FT_long_long";
959 case FT_signed_long_long: return "FT_signed_long_long";
960 case FT_unsigned_long_long: return "FT_unsigned_long_long";
962 case FT_int8: return "FT_int8";
963 case FT_signed_int8: return "FT_signed_int8";
964 case FT_unsigned_int8: return "FT_unsigned_int8";
965 case FT_int16: return "FT_int16";
966 case FT_signed_int16: return "FT_signed_int16";
967 case FT_unsigned_int16: return "FT_unsigned_int16";
968 case FT_int32: return "FT_int32";
969 case FT_signed_int32: return "FT_signed_int32";
970 case FT_unsigned_int32: return "FT_unsigned_int32";
971 case FT_int64: return "FT_int64";
972 case FT_signed_int64: return "FT_signed_int64";
973 case FT_unsigned_int64: return "FT_signed_int64";
975 case FT_real32: return "FT_real32";
976 case FT_real64: return "FT_real64";
977 case FT_real96: return "FT_real96";
978 case FT_real128: return "FT_real128";
980 default: return "<unknown fundamental type>";
984 /**************** utility functions for attribute functions ******************/
986 /* Given a pointer to a BLOCK node return non-zero if (and only if) the
987 node in question represents the outermost block (i.e. the "body block")
988 of a function or method.
990 For any BLOCK node representing a "body block", the BLOCK_SUPERCONTEXT
991 of the node will point to another BLOCK node which represents the outer-
992 most (function) scope for the function or method. The BLOCK_SUPERCONTEXT
993 of that node in turn will point to the relevant FUNCTION_DECL node.
1000 register enum tree_code code
1001 = TREE_CODE (BLOCK_SUPERCONTEXT (BLOCK_SUPERCONTEXT (stmt)));
1003 return (code == FUNCTION_DECL);
1006 /* Given a pointer to a tree node for some type, return a Dwarf fundamental
1007 type code for the given type.
1009 This routine must only be called for GCC type nodes that correspond to
1010 Dwarf fundamental types.
1012 The current Dwarf draft specification calls for Dwarf fundamental types
1013 to accurately reflect the fact that a given type was either a "plain"
1014 integral type or an explicitly "signed" integral type. Unfortunately,
1015 we can't always do this, because GCC may already have thrown away the
1016 information about the precise way in which the type was originally
1019 typedef signed int field_type;
1021 struct s { field_type f; };
1023 Since we may be stuck here without enought information to do exactly
1024 what is called for in the Dwarf draft specification, we do the best
1025 that we can under the circumstances and always use the "plain" integral
1026 fundamental type codes for int, short, and long types. That's probably
1027 good enough. The additional accuracy called for in the current DWARF
1028 draft specification is probably never even useful in practice. */
1031 fundamental_type_code (type)
1034 if (TREE_CODE (type) == ERROR_MARK)
1037 switch (TREE_CODE (type))
1046 /* Carefully distinguish all the standard types of C,
1047 without messing up if the language is not C.
1048 Note that we check only for the names that contain spaces;
1049 other names might occur by coincidence in other languages. */
1050 if (TYPE_NAME (type) != 0
1051 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1052 && DECL_NAME (TYPE_NAME (type)) != 0
1053 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
1055 char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
1057 if (!strcmp (name, "unsigned char"))
1058 return FT_unsigned_char;
1059 if (!strcmp (name, "signed char"))
1060 return FT_signed_char;
1061 if (!strcmp (name, "unsigned int"))
1062 return FT_unsigned_integer;
1063 if (!strcmp (name, "short int"))
1065 if (!strcmp (name, "short unsigned int"))
1066 return FT_unsigned_short;
1067 if (!strcmp (name, "long int"))
1069 if (!strcmp (name, "long unsigned int"))
1070 return FT_unsigned_long;
1071 if (!strcmp (name, "long long int"))
1072 return FT_long_long; /* Not grok'ed by svr4 SDB */
1073 if (!strcmp (name, "long long unsigned int"))
1074 return FT_unsigned_long_long; /* Not grok'ed by svr4 SDB */
1077 /* Most integer types will be sorted out above, however, for the
1078 sake of special `array index' integer types, the following code
1079 is also provided. */
1081 if (TYPE_PRECISION (type) == INT_TYPE_SIZE)
1082 return (TREE_UNSIGNED (type) ? FT_unsigned_integer : FT_integer);
1084 if (TYPE_PRECISION (type) == LONG_TYPE_SIZE)
1085 return (TREE_UNSIGNED (type) ? FT_unsigned_long : FT_long);
1087 if (TYPE_PRECISION (type) == LONG_LONG_TYPE_SIZE)
1088 return (TREE_UNSIGNED (type) ? FT_unsigned_long_long : FT_long_long);
1090 if (TYPE_PRECISION (type) == SHORT_TYPE_SIZE)
1091 return (TREE_UNSIGNED (type) ? FT_unsigned_short : FT_short);
1093 if (TYPE_PRECISION (type) == CHAR_TYPE_SIZE)
1094 return (TREE_UNSIGNED (type) ? FT_unsigned_char : FT_char);
1099 /* Carefully distinguish all the standard types of C,
1100 without messing up if the language is not C. */
1101 if (TYPE_NAME (type) != 0
1102 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1103 && DECL_NAME (TYPE_NAME (type)) != 0
1104 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
1106 char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
1108 /* Note that here we can run afowl of a serious bug in "classic"
1109 svr4 SDB debuggers. They don't seem to understand the
1110 FT_ext_prec_float type (even though they should). */
1112 if (!strcmp (name, "long double"))
1113 return FT_ext_prec_float;
1116 if (TYPE_PRECISION (type) == DOUBLE_TYPE_SIZE)
1117 return FT_dbl_prec_float;
1118 if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE)
1121 /* Note that here we can run afowl of a serious bug in "classic"
1122 svr4 SDB debuggers. They don't seem to understand the
1123 FT_ext_prec_float type (even though they should). */
1125 if (TYPE_PRECISION (type) == LONG_DOUBLE_TYPE_SIZE)
1126 return FT_ext_prec_float;
1130 return FT_complex; /* GNU FORTRAN COMPLEX type. */
1133 return FT_char; /* GNU Pascal CHAR type. Not used in C. */
1136 return FT_boolean; /* GNU FORTRAN BOOLEAN type. */
1139 abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
1144 /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
1145 the Dwarf "root" type for the given input type. The Dwarf "root" type
1146 of a given type is generally the same as the given type, except that if
1147 the given type is a pointer or reference type, then the root type of
1148 the given type is the root type of the "basis" type for the pointer or
1149 reference type. (This definition of the "root" type is recursive.)
1150 Also, the root type of a `const' qualified type or a `volatile'
1151 qualified type is the root type of the given type without the
1158 if (TREE_CODE (type) == ERROR_MARK)
1159 return error_mark_node;
1161 switch (TREE_CODE (type))
1164 return error_mark_node;
1167 case REFERENCE_TYPE:
1168 return TYPE_MAIN_VARIANT (root_type (TREE_TYPE (type)));
1171 return TYPE_MAIN_VARIANT (type);
1175 /* Given a pointer to an arbitrary ..._TYPE tree node, write out a sequence
1176 of zero or more Dwarf "type-modifier" bytes applicable to the type. */
1179 write_modifier_bytes (type, decl_const, decl_volatile)
1181 register int decl_const;
1182 register int decl_volatile;
1184 if (TREE_CODE (type) == ERROR_MARK)
1187 if (TYPE_READONLY (type) || decl_const)
1188 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_const);
1189 if (TYPE_VOLATILE (type) || decl_volatile)
1190 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_volatile);
1191 switch (TREE_CODE (type))
1194 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_pointer_to);
1195 write_modifier_bytes (TREE_TYPE (type), 0, 0);
1198 case REFERENCE_TYPE:
1199 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_reference_to);
1200 write_modifier_bytes (TREE_TYPE (type), 0, 0);
1209 /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
1210 given input type is a Dwarf "fundamental" type. Otherwise return zero. */
1213 type_is_fundamental (type)
1216 switch (TREE_CODE (type))
1235 case REFERENCE_TYPE:
1248 /* Given a pointer to some ..._DECL tree node, generate an assembly language
1249 equate directive which will associate a symbolic name with the current DIE.
1251 The name used is an artificial label generated from the DECL_UID number
1252 associated with the given decl node. The name it gets equated to is the
1253 symbolic label that we (previously) output at the start of the DIE that
1254 we are currently generating.
1256 Calling this function while generating some "decl related" form of DIE
1257 makes it possible to later refer to the DIE which represents the given
1258 decl simply by re-generating the symbolic name from the ..._DECL node's
1262 equate_decl_number_to_die_number (decl)
1265 /* In the case where we are generating a DIE for some ..._DECL node
1266 which represents either some inline function declaration or some
1267 entity declared within an inline function declaration/definition,
1268 setup a symbolic name for the current DIE so that we have a name
1269 for this DIE that we can easily refer to later on within
1270 AT_abstract_origin attributes. */
1272 char decl_label[MAX_ARTIFICIAL_LABEL_BYTES];
1273 char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
1275 sprintf (decl_label, DECL_NAME_FMT, DECL_UID (decl));
1276 sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
1277 ASM_OUTPUT_DEF (asm_out_file, decl_label, die_label);
1280 /* Given a pointer to some ..._TYPE tree node, generate an assembly language
1281 equate directive which will associate a symbolic name with the current DIE.
1283 The name used is an artificial label generated from the TYPE_UID number
1284 associated with the given type node. The name it gets equated to is the
1285 symbolic label that we (previously) output at the start of the DIE that
1286 we are currently generating.
1288 Calling this function while generating some "type related" form of DIE
1289 makes it easy to later refer to the DIE which represents the given type
1290 simply by re-generating the alternative name from the ..._TYPE node's
1294 equate_type_number_to_die_number (type)
1297 char type_label[MAX_ARTIFICIAL_LABEL_BYTES];
1298 char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
1300 /* We are generating a DIE to represent the main variant of this type
1301 (i.e the type without any const or volatile qualifiers) so in order
1302 to get the equate to come out right, we need to get the main variant
1305 type = TYPE_MAIN_VARIANT (type);
1307 sprintf (type_label, TYPE_NAME_FMT, TYPE_UID (type));
1308 sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
1309 ASM_OUTPUT_DEF (asm_out_file, type_label, die_label);
1312 /* The following routine is a nice and simple transducer. It converts the
1313 RTL for a variable or parameter (resident in memory) into an equivalent
1314 Dwarf representation of a mechanism for getting the address of that same
1315 variable onto the top of a hypothetical "address evaluation" stack.
1317 When creating memory location descriptors, we are effectively trans-
1318 forming the RTL for a memory-resident object into its Dwarf postfix
1319 expression equivalent. This routine just recursively descends an
1320 RTL tree, turning it into Dwarf postfix code as it goes. */
1323 output_mem_loc_descriptor (rtl)
1326 /* Note that for a dynamically sized array, the location we will
1327 generate a description of here will be the lowest numbered location
1328 which is actually within the array. That's *not* necessarily the
1329 same as the zeroth element of the array. */
1331 switch (GET_CODE (rtl))
1335 /* The case of a subreg may arise when we have a local (register)
1336 variable or a formal (register) parameter which doesn't quite
1337 fill up an entire register. For now, just assume that it is
1338 legitimate to make the Dwarf info refer to the whole register
1339 which contains the given subreg. */
1341 rtl = XEXP (rtl, 0);
1346 /* Whenever a register number forms a part of the description of
1347 the method for calculating the (dynamic) address of a memory
1348 resident object, Dwarf rules require the register number to
1349 be referred to as a "base register". This distinction is not
1350 based in any way upon what category of register the hardware
1351 believes the given register belongs to. This is strictly
1352 Dwarf terminology we're dealing with here. */
1354 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_BASEREG);
1355 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
1356 DBX_REGISTER_NUMBER (REGNO (rtl)));
1360 output_mem_loc_descriptor (XEXP (rtl, 0));
1361 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_DEREF4);
1366 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADDR);
1367 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
1371 output_mem_loc_descriptor (XEXP (rtl, 0));
1372 output_mem_loc_descriptor (XEXP (rtl, 1));
1373 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
1377 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
1378 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, INTVAL (rtl));
1386 /* Output a proper Dwarf location descriptor for a variable or parameter
1387 which is either allocated in a register or in a memory location. For
1388 a register, we just generate an OP_REG and the register number. For a
1389 memory location we provide a Dwarf postfix expression describing how to
1390 generate the (dynamic) address of the object onto the address stack. */
1393 output_loc_descriptor (rtl)
1396 switch (GET_CODE (rtl))
1400 /* The case of a subreg may arise when we have a local (register)
1401 variable or a formal (register) parameter which doesn't quite
1402 fill up an entire register. For now, just assume that it is
1403 legitimate to make the Dwarf info refer to the whole register
1404 which contains the given subreg. */
1406 rtl = XEXP (rtl, 0);
1410 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_REG);
1411 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
1412 DBX_REGISTER_NUMBER (REGNO (rtl)));
1416 output_mem_loc_descriptor (XEXP (rtl, 0));
1420 abort (); /* Should never happen */
1424 /* Given a tree node describing an array bound (either lower or upper)
1425 output a representation for that bound. */
1428 output_bound_representation (bound, dim_num, u_or_l)
1429 register tree bound;
1430 register unsigned dim_num; /* For multi-dimensional arrays. */
1431 register char u_or_l; /* Designates upper or lower bound. */
1433 switch (TREE_CODE (bound))
1439 /* All fixed-bounds are represented by INTEGER_CST nodes. */
1442 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
1443 (unsigned) TREE_INT_CST_LOW (bound));
1446 /* Dynamic bounds may be represented by NOP_EXPR nodes containing
1450 bound = TREE_OPERAND (bound, 0);
1451 /* ... fall thru... */
1455 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
1456 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
1458 sprintf (begin_label, BOUND_BEGIN_LABEL_FMT,
1459 current_dienum, dim_num, u_or_l);
1461 sprintf (end_label, BOUND_END_LABEL_FMT,
1462 current_dienum, dim_num, u_or_l);
1464 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
1465 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
1467 /* If we are working on a bound for a dynamic dimension in C,
1468 the dynamic dimension in question had better have a static
1469 (zero) lower bound and a dynamic *upper* bound. */
1474 /* If optimization is turned on, the SAVE_EXPRs that describe
1475 how to access the upper bound values are essentially bogus.
1476 They only describe (at best) how to get at these values at
1477 the points in the generated code right after they have just
1478 been computed. Worse yet, in the typical case, the upper
1479 bound values will not even *be* computed in the optimized
1480 code, so these SAVE_EXPRs are entirely bogus.
1482 In order to compensate for this fact, we check here to see
1483 if optimization is enabled, and if so, we effectively create
1484 an empty location description for the (unknown and unknowable)
1487 This should not cause too much trouble for existing (stupid?)
1488 debuggers because they have to deal with empty upper bounds
1489 location descriptions anyway in order to be able to deal with
1490 incomplete array types.
1492 Of course an intelligent debugger (GDB?) should be able to
1493 comprehend that a missing upper bound specification in a
1494 array type used for a storage class `auto' local array variable
1495 indicates that the upper bound is both unknown (at compile-
1496 time) and unknowable (at run-time) due to optimization.
1500 output_loc_descriptor
1501 (eliminate_regs (SAVE_EXPR_RTL (bound), 0, NULL_RTX));
1503 ASM_OUTPUT_LABEL (asm_out_file, end_label);
1512 /* Recursive function to output a sequence of value/name pairs for
1513 enumeration constants in reversed order. This is called from
1514 enumeration_type_die. */
1517 output_enumeral_list (link)
1522 output_enumeral_list (TREE_CHAIN (link));
1523 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
1524 (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link)));
1525 ASM_OUTPUT_DWARF_STRING (asm_out_file,
1526 IDENTIFIER_POINTER (TREE_PURPOSE (link)));
1530 /****************************** attributes *********************************/
1532 /* The following routines are responsible for writing out the various types
1533 of Dwarf attributes (and any following data bytes associated with them).
1534 These routines are listed in order based on the numerical codes of their
1535 associated attributes. */
1537 /* Generate an AT_sibling attribute. */
1540 sibling_attribute ()
1542 char label[MAX_ARTIFICIAL_LABEL_BYTES];
1544 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sibling);
1545 sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
1546 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
1549 /* Output the form of location attributes suitable for whole variables and
1550 whole parameters. Note that the location attributes for struct fields
1551 are generated by the routine `data_member_location_attribute' below. */
1554 location_attribute (rtl)
1557 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
1558 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
1560 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
1561 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
1562 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
1563 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
1564 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
1566 /* Handle a special case. If we are about to output a location descriptor
1567 for a variable or parameter which has been optimized out of existence,
1568 don't do that. Instead we output a zero-length location descriptor
1569 value as part of the location attribute. Note that we cannot simply
1570 suppress the entire location attribute, because the absence of a
1571 location attribute in certain kinds of DIEs is used to indicate some-
1572 thing entirely different... i.e. that the DIE represents an object
1573 declaration, but not a definition. So sayeth the PLSIG. */
1575 if (! is_pseudo_reg (rtl))
1576 output_loc_descriptor (eliminate_regs (rtl, 0, NULL_RTX));
1578 ASM_OUTPUT_LABEL (asm_out_file, end_label);
1581 /* Output the specialized form of location attribute used for data members
1584 In the special case of a FIELD_DECL node which represents a bit-field,
1585 the "offset" part of this special location descriptor must indicate the
1586 distance in bytes from the lowest-addressed byte of the containing
1587 struct or union type to the lowest-addressed byte of the "containing
1588 object" for the bit-field.
1590 For any given bit-field, the "containing object" is a hypothetical
1591 object (of some integral or enum type) within which the given bit-field
1592 lives. The type of this hypothetical "containing object" is always the
1593 same as the declared type of the individual bit-field itself.
1595 Note that it is the size (in bytes) of the hypothetical "containing
1596 object" which will be given in the AT_byte_size attribute for this
1597 bit-field. (See the `byte_size_attribute' function below.)
1602 data_member_location_attribute (decl)
1605 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
1606 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
1607 register unsigned type_align_in_bytes;
1608 register unsigned type_align_in_bits;
1609 register unsigned offset_in_align_units;
1610 register unsigned offset_in_bytes;
1612 register tree bitpos_tree = DECL_FIELD_BITPOS (decl);
1613 register unsigned bitpos_int;
1615 if (TREE_CODE (decl) == ERROR_MARK)
1618 if (TREE_CODE (decl) != FIELD_DECL)
1621 /* The bit position given by DECL_FIELD_BITPOS could be non-constant
1622 in the case where one or more variable sized members preceded this
1623 member in the containing struct type. We could probably correctly
1624 handle this case someday, by it's too complicated to deal with at
1625 the moment (and probably too rare to worry about), so just punt on
1626 the whole AT_location attribute for now. Eventually, we'll have
1627 to analyze the expression given as the DECL_FIELD_BITPOS and turn
1628 it into a member-style AT_location descriptor, but that'll be
1629 tough to do. -- rfg */
1631 if (TREE_CODE (bitpos_tree) != INTEGER_CST)
1633 bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
1635 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
1636 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
1637 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
1638 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
1639 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
1640 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
1642 type = DECL_BIT_FIELD_TYPE (decl);
1644 type = TREE_TYPE (decl);
1646 type_align_in_bits = TYPE_ALIGN (type);
1647 type_align_in_bytes = type_align_in_bits / BITS_PER_UNIT;
1649 /* WARNING! Note that the GCC front-end doesn't make any attempt to
1650 keep track of the starting bit offset (relative to the start of
1651 the containing structure type) of the hypothetical "containing
1652 object" for a bit-field. (See the comments at the start of this
1653 function.) Thus, when computing the byte offset value for a
1654 bit-field, all we can do is to divide the starting bit offset of
1655 the bit-field by the alignment of the hypothetical "containing
1656 object" (which we can easily find) and then multiply by the number
1657 of bytes of that alignment.
1659 This solution only yields an unambiguously correct result when
1660 the size of the bit-field is strictly larger than the size of the
1661 declared type minus the alignment of the declared type. When this
1662 condition is not satisfied, it means that there is at least an
1663 "alignment unit's" worth of other slop which co-resides within the
1664 hypothetical "containing object" with the bit field, and this other
1665 slop could be either to the left of the bit-field or to the right
1666 of the bit-field. (We have no way of knowing which.)
1668 It also means that we cannot unambiguously tell exactly where the
1669 hypothetical "containing object" begins within the containing struct
1670 type. We only know the precise position of the bit-field which is
1671 contained therein, and that the hypothetical containing object must
1672 be aligned as required for its type. But when there is at least an
1673 alignment unit's worth of slop co-resident in the containing object
1674 with the actual bit-field, the actual start of the containing object
1675 is ambiguous and thus, we cannot unambiguously determine the "correct"
1676 byte offset to put into the AT_location attribute for the bit-field
1679 This whole thing is a non-issue for the majority of targets, because
1680 (for most GCC targets) the alignment of each supported integral type
1681 is the same as the size of that type, and thus (size - alignment) for
1682 the declared type of any bit-field yields zero, and the size (in bits)
1683 of any bit-field must be bigger than zero, so there is never any
1684 ambiguity about the starting positions of the containing objects of
1685 bit-fields for most GCC targets.
1687 An exception arises however for some machines (e.g. i386) which have
1688 BIGGEST_ALIGNMENT set to something less than the size of type `long
1689 long' (i.e. 64) and when we are confronted with something like:
1693 long long field2:31;
1696 Here it is ambiguous (going by DWARF rules anyway) whether the con-
1697 taining `long long' object for `field2' should be said to occupy the
1698 first and second (32-bit) words of the containing struct type, or
1699 whether it should be said to occupy the second and third words of
1702 Currently, GCC allocates 8 bytes (for an i386 target) for each object
1703 of the above type. This is probably a bug however, and GCC should
1704 probably be allocating 12 bytes for each such structure (for the i386
1707 Assuming this bug gets fixed, one would have a strong case for saying
1708 that the containing `long long' object for `field2' occupies the second
1709 and third words of the above structure type, and that `field2' itself
1710 occupies the first 31 bits of that containing object. However consider:
1714 long long field2:31;
1716 long long field4:31;
1719 Even if the current "member allocation" bug in GCC is fixed, this ex-
1720 ample would still illustrate a case in which the starting point of the
1721 containing `long long' object for `field4' would be ambiguous, even
1722 though we know the exact starting bit offset (within the structure) of
1723 the `field4' bit-field itself.
1725 We essentially just ignore this whole issue here and always act as if
1726 most of the slop which co-resides in a containing object along with a
1727 bit-field appears in that containing object *AFTER* the bit field.
1728 Thus, for the above example, we say that the containing object for
1729 `field4' occupies the third and fourth words of the structure type,
1730 even though objects of the type only occupy three words. As long
1731 as the debugger understands that the compiler uses this disambiguation
1732 rule, the debugger should easily be able to do the Right Thing in all
1736 offset_in_align_units = bitpos_int / type_align_in_bits;
1737 offset_in_bytes = offset_in_align_units * type_align_in_bytes;
1739 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, offset_in_bytes);
1740 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
1741 ASM_OUTPUT_LABEL (asm_out_file, end_label);
1744 /* Output an AT_const_value attribute for a variable or a parameter which
1745 does not have a "location" either in memory or in a register. These
1746 things can arise in GNU C when a constant is passed as an actual
1747 parameter to an inlined function. They can also arise in C++ where
1748 declared constants do not necessarily get memory "homes". */
1751 const_value_attribute (rtl)
1754 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
1755 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
1757 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_const_value_block4);
1758 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
1759 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
1760 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
1761 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
1763 switch (GET_CODE (rtl))
1766 /* Note that a CONST_INT rtx could represent either an integer or
1767 a floating-point constant. A CONST_INT is used whenever the
1768 constant will fit into a single word. In all such cases, the
1769 original mode of the constant value is wiped out, and the
1770 CONST_INT rtx is assigned VOIDmode. Since we no longer have
1771 precise mode information for these constants, we always just
1772 output them using 4 bytes. */
1774 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, (unsigned) INTVAL (rtl));
1778 /* Note that a CONST_DOUBLE rtx could represent either an integer
1779 or a floating-point constant. A CONST_DOUBLE is used whenever
1780 the constant requires more than one word in order to be adequately
1781 represented. In all such cases, the original mode of the constant
1782 value is preserved as the mode of the CONST_DOUBLE rtx, but for
1783 simplicity we always just output CONST_DOUBLEs using 8 bytes. */
1785 ASM_OUTPUT_DWARF_DATA8 (asm_out_file,
1786 (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (rtl),
1787 (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (rtl));
1791 ASM_OUTPUT_DWARF_STRING (asm_out_file, XSTR (rtl, 0));
1797 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
1801 /* In cases where an inlined instance of an inline function is passed
1802 the address of an `auto' variable (which is local to the caller)
1803 we can get a situation where the DECL_RTL of the artificial
1804 local variable (for the inlining) which acts as a stand-in for
1805 the corresponding formal parameter (of the inline function)
1806 will look like (plus:SI (reg:SI FRAME_PTR) (const_int ...)).
1807 This is not exactly a compile-time constant expression, but it
1808 isn't the address of the (artificial) local variable either.
1809 Rather, it represents the *value* which the artificial local
1810 variable always has during its lifetime. We currently have no
1811 way to represent such quasi-constant values in Dwarf, so for now
1812 we just punt and generate an AT_const_value attribute with form
1813 FORM_BLOCK4 and a length of zero. */
1817 ASM_OUTPUT_LABEL (asm_out_file, end_label);
1820 /* Generate *either* an AT_location attribute or else an AT_const_value
1821 data attribute for a variable or a parameter. We generate the
1822 AT_const_value attribute only in those cases where the given
1823 variable or parameter does not have a true "location" either in
1824 memory or in a register. This can happen (for example) when a
1825 constant is passed as an actual argument in a call to an inline
1826 function. (It's possible that these things can crop up in other
1827 ways also.) Note that one type of constant value which can be
1828 passed into an inlined function is a constant pointer. This can
1829 happen for example if an actual argument in an inlined function
1830 call evaluates to a compile-time constant address. */
1833 location_or_const_value_attribute (decl)
1838 if (TREE_CODE (decl) == ERROR_MARK)
1841 if ((TREE_CODE (decl) != VAR_DECL) && (TREE_CODE (decl) != PARM_DECL))
1844 /* Existing Dwarf debuggers need and expect the location descriptors for
1845 formal parameters to reflect either the place where the parameters get
1846 passed (if they are passed on the stack and in memory) or else the
1847 (preserved) registers which the parameters get copied to during the
1850 At least this is the way things are for most common CISC machines
1851 (e.g. x86 and m68k) where parameters are passed in the stack, and for
1852 most common RISC machines (e.g. i860 and m88k) where parameters are
1853 passed in registers.
1855 The rules for Sparc are a little weird for some reason. The DWARF
1856 generated by the USL C compiler for the Sparc/svr4 reference port says
1857 that the parameters are passed in the stack. I haven't figured out
1858 how to duplicate that behavior here (for the Sparc) yet, or even if
1861 Note that none of this is clearly spelled out in the current Dwarf
1862 version 1 specification, but it's obvious if you look at the output of
1863 the CI5 compiler, or if you try to use the svr4 SDB debugger. Hopefully,
1864 a later version of the Dwarf specification will clarify this. For now,
1865 we just need to generate the right thing. Note that Dwarf version 2
1866 will provide us with a means to describe *all* of the locations in which
1867 a given variable or parameter resides (and the PC ranges over which it
1868 occupies each one), but for now we can only describe one "location"
1869 for each formal parameter passed, and so we just try to mimic existing
1870 practice as much as possible.
1873 if (TREE_CODE (decl) != PARM_DECL)
1874 /* If this decl is not a formal parameter, just use DECL_RTL. */
1875 rtl = DECL_RTL (decl);
1878 if (GET_CODE (DECL_INCOMING_RTL (decl)) == MEM)
1879 /* Parameter was passed in memory, so say that's where it lives. */
1880 rtl = DECL_INCOMING_RTL (decl);
1883 /* Parameter was passed in a register, so say it lives in the
1884 register it will be copied to during the prologue. */
1885 rtl = DECL_RTL (decl);
1887 /* Note that in cases where the formal parameter is never used
1888 and where this compilation is done with -O, the copying of
1889 of an incoming register parameter to another register (in
1890 the prologue) can be totally optimized away. (In such cases
1891 the DECL_RTL will indicate a pseudo-register.) We could just
1892 use the DECL_RTL (as we normally do for register parameters)
1893 in these cases, but if we did that, we would end up generating
1894 a null location descriptor. (See `location_attribute' above.)
1895 That would be acceptable (according to the DWARF spec) but it
1896 is probably more useful to say that the formal resides where
1897 it was passed instead of saying that it resides nowhere. */
1898 if (is_pseudo_reg (rtl))
1899 rtl = DECL_INCOMING_RTL (decl);
1906 switch (GET_CODE (rtl))
1914 case PLUS: /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
1915 const_value_attribute (rtl);
1921 location_attribute (rtl);
1925 abort (); /* Should never happen. */
1929 /* Generate an AT_name attribute given some string value to be included as
1930 the value of the attribute. */
1933 name_attribute (name_string)
1934 register char *name_string;
1936 if (name_string && *name_string)
1938 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_name);
1939 ASM_OUTPUT_DWARF_STRING (asm_out_file, name_string);
1944 fund_type_attribute (ft_code)
1945 register unsigned ft_code;
1947 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_fund_type);
1948 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, ft_code);
1952 mod_fund_type_attribute (type, decl_const, decl_volatile)
1954 register int decl_const;
1955 register int decl_volatile;
1957 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
1958 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
1960 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_fund_type);
1961 sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
1962 sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
1963 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
1964 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
1965 write_modifier_bytes (type, decl_const, decl_volatile);
1966 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
1967 fundamental_type_code (root_type (type)));
1968 ASM_OUTPUT_LABEL (asm_out_file, end_label);
1972 user_def_type_attribute (type)
1975 char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
1977 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_user_def_type);
1978 sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (type));
1979 ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
1983 mod_u_d_type_attribute (type, decl_const, decl_volatile)
1985 register int decl_const;
1986 register int decl_volatile;
1988 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
1989 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
1990 char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
1992 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_u_d_type);
1993 sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
1994 sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
1995 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
1996 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
1997 write_modifier_bytes (type, decl_const, decl_volatile);
1998 sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (root_type (type)));
1999 ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
2000 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2004 ordering_attribute (ordering)
2005 register unsigned ordering;
2007 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_ordering);
2008 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, ordering);
2011 /* Note that the block of subscript information for an array type also
2012 includes information about the element type of type given array type. */
2015 subscript_data_attribute (type)
2018 register unsigned dimension_number;
2019 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2020 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2022 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_subscr_data);
2023 sprintf (begin_label, SS_BEGIN_LABEL_FMT, current_dienum);
2024 sprintf (end_label, SS_END_LABEL_FMT, current_dienum);
2025 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2026 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2028 /* The GNU compilers represent multidimensional array types as sequences
2029 of one dimensional array types whose element types are themselves array
2030 types. Here we squish that down, so that each multidimensional array
2031 type gets only one array_type DIE in the Dwarf debugging info. The
2032 draft Dwarf specification say that we are allowed to do this kind
2033 of compression in C (because there is no difference between an
2034 array or arrays and a multidimensional array in C) but for other
2035 source languages (e.g. Ada) we probably shouldn't do this. */
2037 for (dimension_number = 0;
2038 TREE_CODE (type) == ARRAY_TYPE;
2039 type = TREE_TYPE (type), dimension_number++)
2041 register tree domain = TYPE_DOMAIN (type);
2043 /* Arrays come in three flavors. Unspecified bounds, fixed
2044 bounds, and (in GNU C only) variable bounds. Handle all
2045 three forms here. */
2049 /* We have an array type with specified bounds. */
2051 register tree lower = TYPE_MIN_VALUE (domain);
2052 register tree upper = TYPE_MAX_VALUE (domain);
2054 /* Handle only fundamental types as index types for now. */
2056 if (! type_is_fundamental (domain))
2059 /* Output the representation format byte for this dimension. */
2061 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file,
2063 TREE_CODE (lower) == INTEGER_CST,
2064 TREE_CODE (upper) == INTEGER_CST));
2066 /* Output the index type for this dimension. */
2068 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
2069 fundamental_type_code (domain));
2071 /* Output the representation for the lower bound. */
2073 output_bound_representation (lower, dimension_number, 'l');
2075 /* Output the representation for the upper bound. */
2077 output_bound_representation (upper, dimension_number, 'u');
2081 /* We have an array type with an unspecified length. For C and
2082 C++ we can assume that this really means that (a) the index
2083 type is an integral type, and (b) the lower bound is zero.
2084 Note that Dwarf defines the representation of an unspecified
2085 (upper) bound as being a zero-length location description. */
2087 /* Output the array-bounds format byte. */
2089 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_FT_C_X);
2091 /* Output the (assumed) index type. */
2093 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, FT_integer);
2095 /* Output the (assumed) lower bound (constant) value. */
2097 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
2099 /* Output the (empty) location description for the upper bound. */
2101 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0);
2105 /* Output the prefix byte that says that the element type is comming up. */
2107 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_ET);
2109 /* Output a representation of the type of the elements of this array type. */
2111 type_attribute (type, 0, 0);
2113 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2117 byte_size_attribute (tree_node)
2118 register tree tree_node;
2120 register unsigned size;
2122 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_byte_size);
2123 switch (TREE_CODE (tree_node))
2132 size = int_size_in_bytes (tree_node);
2136 /* For a data member of a struct or union, the AT_byte_size is
2137 always given as the number of bytes normally allocated for
2138 an object of the *declared* type of the member itself. This
2139 is true even for bit-fields. */
2140 size = int_size_in_bytes (DECL_BIT_FIELD_TYPE (tree_node)
2141 ? DECL_BIT_FIELD_TYPE (tree_node)
2142 : TREE_TYPE (tree_node));
2149 /* Note that `size' might be -1 when we get to this point. If it
2150 is, that indicates that the byte size of the entity in question
2151 is variable. We have no good way of expressing this fact in Dwarf
2152 at the present time, so just let the -1 pass on through. */
2154 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, size);
2157 /* For a FIELD_DECL node which represents a bit-field, output an attribute
2158 which specifies the distance in bits from the highest order bit of the
2159 "containing object" for the bit-field to the highest order bit of the
2162 For any given bit-field, the "containing object" is a hypothetical
2163 object (of some integral or enum type) within which the given bit-field
2164 lives. The type of this hypothetical "containing object" is always the
2165 same as the declared type of the individual bit-field itself.
2167 Note that it is the size (in bytes) of the hypothetical "containing
2168 object" which will be given in the AT_byte_size attribute for this
2169 bit-field. (See `byte_size_attribute' above.)
2173 bit_offset_attribute (decl)
2176 register tree type = DECL_BIT_FIELD_TYPE (decl);
2177 register unsigned dwarf_bit_offset;
2178 register tree bitpos_tree = DECL_FIELD_BITPOS (decl);
2179 register unsigned bitpos_int;
2181 assert (TREE_CODE (decl) == FIELD_DECL); /* Must be a field. */
2182 assert (type); /* Must be a bit field. */
2184 /* The bit position given by DECL_FIELD_BITPOS could be non-constant
2185 in the case where one or more variable sized members preceded this
2186 member in the containing struct type. We could probably correctly
2187 handle this case someday, by it's too complicated to deal with at
2188 the moment, so just punt on the whole AT_bit_offset attribute for
2189 now. Eventually, we'll have to analyze the (variable) expression
2190 given as the DECL_FIELD_BITPOS and see if we can factor out just
2191 the (constant) bit offset part of that expression. -- rfg */
2193 if (TREE_CODE (bitpos_tree) != INTEGER_CST)
2195 bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
2197 /* For a detailed description of how the AT_bit_offset attribute value
2198 is calculated, see the comments in `data_member_location_attribute'
2201 #if (BYTES_BIG_ENDIAN == 1)
2202 dwarf_bit_offset = bitpos_int % TYPE_ALIGN (type);
2205 register unsigned high_order_bitpos
2206 = bitpos_int + (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl));
2207 register tree type_size_tree = TYPE_SIZE (type);
2208 register unsigned type_size_in_bits;
2210 if (TREE_CODE (type_size_tree) != INTEGER_CST)
2212 type_size_in_bits = (unsigned) TREE_INT_CST_LOW (type_size_tree);
2214 dwarf_bit_offset = type_size_in_bits
2215 - (high_order_bitpos % TYPE_ALIGN (type));
2219 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_offset);
2220 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, dwarf_bit_offset);
2223 /* For a FIELD_DECL node which represents a bit field, output an attribute
2224 which specifies the length in bits of the given field. */
2227 bit_size_attribute (decl)
2230 assert (TREE_CODE (decl) == FIELD_DECL); /* Must be a field. */
2231 assert (DECL_BIT_FIELD_TYPE (decl)); /* Must be a bit field. */
2233 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_size);
2234 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
2235 (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl)));
2238 /* The following routine outputs the `element_list' attribute for enumeration
2239 type DIEs. The element_lits attribute includes the names and values of
2240 all of the enumeration constants associated with the given enumeration
2244 element_list_attribute (element)
2245 register tree element;
2247 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2248 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2250 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_element_list);
2251 sprintf (begin_label, EE_BEGIN_LABEL_FMT, current_dienum);
2252 sprintf (end_label, EE_END_LABEL_FMT, current_dienum);
2253 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
2254 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2256 /* Here we output a list of value/name pairs for each enumeration constant
2257 defined for this enumeration type (as required), but we do it in REVERSE
2258 order. The order is the one required by the draft #5 Dwarf specification
2259 published by the UI/PLSIG. */
2261 output_enumeral_list (element); /* Recursively output the whole list. */
2263 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2266 /* Generate an AT_stmt_list attribute. These are normally present only in
2267 DIEs with a TAG_compile_unit tag. */
2270 stmt_list_attribute (label)
2271 register char *label;
2273 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_stmt_list);
2274 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2275 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
2278 /* Generate an AT_low_pc attribute for a label DIE, a lexical_block DIE or
2279 for a subroutine DIE. */
2282 low_pc_attribute (asm_low_label)
2283 register char *asm_low_label;
2285 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_low_pc);
2286 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_low_label);
2289 /* Generate an AT_high_pc attribute for a lexical_block DIE or for a
2293 high_pc_attribute (asm_high_label)
2294 register char *asm_high_label;
2296 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_high_pc);
2297 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_high_label);
2300 /* Generate an AT_language attribute given a LANG value. These attributes
2301 are used only within TAG_compile_unit DIEs. */
2304 language_attribute (language_code)
2305 register unsigned language_code;
2307 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_language);
2308 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, language_code);
2312 member_attribute (context)
2313 register tree context;
2315 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2317 /* Generate this attribute only for members in C++. */
2320 && (TREE_CODE (context) == RECORD_TYPE
2321 || TREE_CODE (context) == UNION_TYPE))
2323 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_member);
2324 sprintf (label, TYPE_NAME_FMT, TYPE_UID (context));
2325 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2330 string_length_attribute (upper_bound)
2331 register tree upper_bound;
2333 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2334 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2336 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_string_length);
2337 sprintf (begin_label, SL_BEGIN_LABEL_FMT, current_dienum);
2338 sprintf (end_label, SL_END_LABEL_FMT, current_dienum);
2339 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2340 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2341 output_bound_representation (upper_bound, 0, 'u');
2342 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2346 comp_dir_attribute (dirname)
2347 register char *dirname;
2349 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_comp_dir);
2350 ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname);
2354 sf_names_attribute (sf_names_start_label)
2355 register char *sf_names_start_label;
2357 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sf_names);
2358 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2359 ASM_OUTPUT_DWARF_ADDR (asm_out_file, sf_names_start_label);
2363 src_info_attribute (src_info_start_label)
2364 register char *src_info_start_label;
2366 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_info);
2367 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2368 ASM_OUTPUT_DWARF_ADDR (asm_out_file, src_info_start_label);
2372 mac_info_attribute (mac_info_start_label)
2373 register char *mac_info_start_label;
2375 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mac_info);
2376 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2377 ASM_OUTPUT_DWARF_ADDR (asm_out_file, mac_info_start_label);
2381 prototyped_attribute (func_type)
2382 register tree func_type;
2384 if ((strcmp (language_string, "GNU C") == 0)
2385 && (TYPE_ARG_TYPES (func_type) != NULL))
2387 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_prototyped);
2388 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
2393 producer_attribute (producer)
2394 register char *producer;
2396 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_producer);
2397 ASM_OUTPUT_DWARF_STRING (asm_out_file, producer);
2401 inline_attribute (decl)
2404 if (TREE_INLINE (decl))
2406 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_inline);
2407 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
2412 containing_type_attribute (containing_type)
2413 register tree containing_type;
2415 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2417 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_containing_type);
2418 sprintf (label, TYPE_NAME_FMT, TYPE_UID (containing_type));
2419 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2423 abstract_origin_attribute (origin)
2424 register tree origin;
2426 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2428 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_abstract_origin);
2429 switch (TREE_CODE_CLASS (TREE_CODE (origin)))
2432 sprintf (label, DECL_NAME_FMT, DECL_UID (origin));
2436 sprintf (label, TYPE_NAME_FMT, TYPE_UID (origin));
2440 abort (); /* Should never happen. */
2443 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2446 #ifdef DWARF_DECL_COORDINATES
2448 src_coords_attribute (src_fileno, src_lineno)
2449 register unsigned src_fileno;
2450 register unsigned src_lineno;
2452 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_coords);
2453 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_fileno);
2454 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_lineno);
2456 #endif /* defined(DWARF_DECL_COORDINATES) */
2459 pure_or_virtual_attribute (func_decl)
2460 register tree func_decl;
2462 if (DECL_VIRTUAL_P (func_decl))
2464 if (DECL_ABSTRACT_VIRTUAL_P (func_decl))
2465 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_pure_virtual);
2467 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
2468 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
2472 /************************* end of attributes *****************************/
2474 /********************* utility routines for DIEs *************************/
2476 /* Output an AT_name attribute and an AT_src_coords attribute for the
2477 given decl, but only if it actually has a name. */
2480 name_and_src_coords_attributes (decl)
2483 register tree decl_name = DECL_NAME (decl);
2485 if (decl_name && IDENTIFIER_POINTER (decl_name))
2487 name_attribute (IDENTIFIER_POINTER (decl_name));
2488 #ifdef DWARF_DECL_COORDINATES
2490 register unsigned file_index;
2492 /* This is annoying, but we have to pop out of the .debug section
2493 for a moment while we call `lookup_filename' because calling it
2494 may cause a temporary switch into the .debug_sfnames section and
2495 most svr4 assemblers are not smart enough be be able to nest
2496 section switches to any depth greater than one. Note that we
2497 also can't skirt this issue by delaying all output to the
2498 .debug_sfnames section unit the end of compilation because that
2499 would cause us to have inter-section forward references and
2500 Fred Fish sez that m68k/svr4 assemblers botch those. */
2502 ASM_OUTPUT_POP_SECTION (asm_out_file);
2503 file_index = lookup_filename (DECL_SOURCE_FILE (decl));
2504 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
2506 src_coords_attribute (file_index, DECL_SOURCE_LINE (decl));
2512 /* Many forms of DIEs contain a "type description" part. The following
2513 routine writes out these "type descriptor" parts. */
2516 type_attribute (type, decl_const, decl_volatile)
2518 register int decl_const;
2519 register int decl_volatile;
2521 register enum tree_code code = TREE_CODE (type);
2522 register int root_type_modified;
2524 if (TREE_CODE (type) == ERROR_MARK)
2527 /* Handle a special case. For functions whose return type is void,
2528 we generate *no* type attribute. (Note that no object may have
2529 type `void', so this only applies to function return types. */
2531 if (TREE_CODE (type) == VOID_TYPE)
2534 root_type_modified = (code == POINTER_TYPE || code == REFERENCE_TYPE
2535 || decl_const || decl_volatile
2536 || TYPE_READONLY (type) || TYPE_VOLATILE (type));
2538 if (type_is_fundamental (root_type (type)))
2539 if (root_type_modified)
2540 mod_fund_type_attribute (type, decl_const, decl_volatile);
2542 fund_type_attribute (fundamental_type_code (type));
2544 if (root_type_modified)
2545 mod_u_d_type_attribute (type, decl_const, decl_volatile);
2547 user_def_type_attribute (type);
2550 /* Given a tree pointer to a struct, class, union, or enum type node, return
2551 a pointer to the (string) tag name for the given type, or zero if the
2552 type was declared without a tag. */
2558 register char *name = 0;
2560 if (TYPE_NAME (type) != 0)
2562 register tree t = 0;
2564 /* Find the IDENTIFIER_NODE for the type name. */
2565 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
2566 t = TYPE_NAME (type);
2568 /* The g++ front end makes the TYPE_NAME of *each* tagged type point
2569 to a TYPE_DECL node, regardless of whether or not a `typedef' was
2570 involved. This is distinctly different from what the gcc front-end
2571 does. It always makes the TYPE_NAME for each tagged type be either
2572 NULL (signifying an anonymous tagged type) or else a pointer to an
2573 IDENTIFIER_NODE. Obviously, we would like to generate correct Dwarf
2574 for both C and C++, but given this inconsistency in the TREE
2575 representation of tagged types for C and C++ in the GNU front-ends,
2576 we cannot support both languages correctly unless we introduce some
2577 front-end specific code here, and rms objects to that, so we can
2578 only generate correct Dwarf for one of these two languages. C is
2579 more important, so for now we'll do the right thing for C and let
2583 if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
2584 t = DECL_NAME (TYPE_NAME (type));
2586 /* Now get the name as a string, or invent one. */
2588 name = IDENTIFIER_POINTER (t);
2591 return (name == 0 || *name == '\0') ? 0 : name;
2597 /* Start by checking if the pending_sibling_stack needs to be expanded.
2598 If necessary, expand it. */
2600 if (pending_siblings == pending_siblings_allocated)
2602 pending_siblings_allocated += PENDING_SIBLINGS_INCREMENT;
2603 pending_sibling_stack
2604 = (unsigned *) xrealloc (pending_sibling_stack,
2605 pending_siblings_allocated * sizeof(unsigned));
2609 NEXT_DIE_NUM = next_unused_dienum++;
2612 /* Pop the sibling stack so that the most recently pushed DIEnum becomes the
2622 member_declared_type (member)
2623 register tree member;
2625 return (DECL_BIT_FIELD_TYPE (member))
2626 ? DECL_BIT_FIELD_TYPE (member)
2627 : TREE_TYPE (member);
2630 /******************************* DIEs ************************************/
2632 /* Output routines for individual types of DIEs. */
2634 /* Note that every type of DIE (except a null DIE) gets a sibling. */
2637 output_array_type_die (arg)
2640 register tree type = arg;
2642 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_array_type);
2643 sibling_attribute ();
2644 equate_type_number_to_die_number (type);
2645 member_attribute (TYPE_CONTEXT (type));
2647 /* I believe that we can default the array ordering. SDB will probably
2648 do the right things even if AT_ordering is not present. It's not
2649 even an issue until we start to get into multidimensional arrays
2650 anyway. If SDB is ever caught doing the Wrong Thing for multi-
2651 dimensional arrays, then we'll have to put the AT_ordering attribute
2652 back in. (But if and when we find out that we need to put these in,
2653 we will only do so for multidimensional arrays. After all, we don't
2654 want to waste space in the .debug section now do we?) */
2657 ordering_attribute (ORD_row_major);
2660 subscript_data_attribute (type);
2664 output_set_type_die (arg)
2667 register tree type = arg;
2669 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_set_type);
2670 sibling_attribute ();
2671 equate_type_number_to_die_number (type);
2672 member_attribute (TYPE_CONTEXT (type));
2673 type_attribute (TREE_TYPE (type), 0, 0);
2677 /* Implement this when there is a GNU FORTRAN or GNU Ada front end. */
2679 output_entry_point_die (arg)
2682 register tree decl = arg;
2683 register tree type = TREE_TYPE (decl);
2684 register tree return_type = TREE_TYPE (type);
2686 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_entry_point);
2687 sibling_attribute ();
2689 name_and_src_coords_attributes (decl);
2690 member_attribute (DECL_CONTEXT (decl));
2691 type_attribute (return_type, 0, 0);
2695 /* Output a DIE to represent an enumeration type. Note that these DIEs
2696 include all of the information about the enumeration values also.
2697 This information is encoded into the element_list attribute. */
2700 output_enumeration_type_die (arg)
2703 register tree type = arg;
2705 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
2706 sibling_attribute ();
2707 equate_type_number_to_die_number (type);
2708 name_attribute (type_tag (type));
2709 member_attribute (TYPE_CONTEXT (type));
2711 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
2712 given enum type is incomplete, do not generate the AT_byte_size
2713 attribute or the AT_element_list attribute. */
2715 if (TYPE_SIZE (type))
2717 byte_size_attribute (type);
2718 element_list_attribute (TYPE_FIELDS (type));
2722 /* Output a DIE to represent either a real live formal parameter decl or
2723 to represent just the type of some formal parameter position in some
2726 Note that this routine is a bit unusual because its argument may be
2727 either a PARM_DECL node or else some sort of a ..._TYPE node. If it's
2728 the formar then this function is being called to output a real live
2729 formal parameter declaration. If it's the latter, then this function
2730 is only being called to output a TAG_formal_parameter DIE to stand as
2731 a placeholder for some formal argument type of some subprogram type. */
2734 output_formal_parameter_die (arg)
2737 register tree decl = arg;
2740 if (TREE_CODE (decl) == PARM_DECL)
2741 type = TREE_TYPE (decl);
2744 type = decl; /* we were called with a type, not a decl */
2748 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_formal_parameter);
2749 sibling_attribute ();
2752 name_and_src_coords_attributes (decl);
2753 type_attribute (type, TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
2754 location_or_const_value_attribute (decl);
2757 type_attribute (type, 0, 0);
2760 /* Output a DIE to represent a declared function (either file-scope
2761 or block-local) which has "external linkage" (according to ANSI-C). */
2764 output_global_subroutine_die (arg)
2767 register tree decl = arg;
2768 register tree type = TREE_TYPE (decl);
2769 register tree return_type = TREE_TYPE (type);
2771 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_subroutine);
2772 sibling_attribute ();
2774 name_and_src_coords_attributes (decl);
2775 inline_attribute (decl);
2776 prototyped_attribute (type);
2777 member_attribute (DECL_CONTEXT (decl));
2778 type_attribute (return_type, 0, 0);
2779 if (!TREE_EXTERNAL (decl))
2781 char func_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2783 low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
2784 sprintf (func_end_label, FUNC_END_LABEL_FMT, current_funcdef_number);
2785 high_pc_attribute (func_end_label);
2789 /* Output a DIE to represent a declared data object (either file-scope
2790 or block-local) which has "external linkage" (according to ANSI-C). */
2793 output_global_variable_die (arg)
2796 register tree decl = arg;
2797 register tree type = TREE_TYPE (decl);
2799 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_variable);
2800 sibling_attribute ();
2801 name_and_src_coords_attributes (decl);
2802 member_attribute (DECL_CONTEXT (decl));
2803 type_attribute (type, TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
2804 if (!TREE_EXTERNAL (decl))
2805 location_or_const_value_attribute (decl);
2809 /* TAG_inline_subroutine has been retired by the UI/PLSIG. We're
2810 now supposed to use either TAG_subroutine or TAG_global_subroutine
2811 (depending on whether or not the function in question has internal
2812 or external linkage) and we're supposed to just put in an AT_inline
2815 output_inline_subroutine_die (arg)
2818 register tree decl = arg;
2819 register tree type = TREE_TYPE (decl);
2820 register tree return_type = TREE_TYPE (type);
2822 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inline_subroutine);
2823 sibling_attribute ();
2825 name_and_src_coords_attributes (decl);
2826 prototyped_attribute (type);
2827 member_attribute (DECL_CONTEXT (decl));
2828 type_attribute (return_type, 0, 0);
2830 /* Note: For each inline function which gets an out-of-line body
2831 generated for it, we want to generate AT_low_pc and AT_high_pc
2832 attributes here for the function's out-of-line body.
2834 Unfortunately, the decision as to whether or not to generate an
2835 out-of-line body for any given inline function may not be made
2836 until we reach the end of the containing scope for the given
2837 inline function (because only then will it be known if the
2838 function was ever even called).
2840 For this reason, the output of DIEs representing file-scope inline
2841 functions gets delayed until a special post-pass which happens only
2842 after we have reached the end of the compilation unit. Because of
2843 this mechanism, we can always be sure (by the time we reach here)
2844 that TREE_ASM_WRITTEN(decl) will correctly indicate whether or not
2845 there was an out-of-line body generated for this inline function.
2848 if (!TREE_EXTERNAL (decl))
2850 if (TREE_ASM_WRITTEN (decl))
2852 char func_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2854 low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
2855 sprintf (func_end_label, FUNC_END_LABEL_FMT, current_funcdef_number);
2856 high_pc_attribute (func_end_label);
2863 output_label_die (arg)
2866 register tree decl = arg;
2867 register rtx insn = DECL_RTL (decl);
2869 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_label);
2870 sibling_attribute ();
2871 name_and_src_coords_attributes (decl);
2873 /* When optimization is enabled (with -O) the code in jump.c and in flow.c
2874 may cause insns representing one of more of the user's own labels to
2875 be deleted. This happens whenever it is determined that a given label
2878 In such cases, we here generate an abbreviated form of a label DIE.
2879 This abbreviated version does *not* have a low_pc attribute. This
2880 should signify to the debugger that the label has been optimized away.
2882 Note that a CODE_LABEL can get deleted either by begin converted into
2883 a NOTE_INSN_DELETED note, or by simply having its INSN_DELETED_P flag
2884 set to true. We handle both cases here.
2887 if (GET_CODE (insn) == CODE_LABEL && ! INSN_DELETED_P (insn))
2889 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2891 sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
2892 (unsigned) INSN_UID (insn));
2893 low_pc_attribute (label);
2898 output_lexical_block_die (arg)
2901 register tree stmt = arg;
2902 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2903 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2905 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_lexical_block);
2906 sibling_attribute ();
2908 sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
2909 low_pc_attribute (begin_label);
2910 sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
2911 high_pc_attribute (end_label);
2915 output_inlined_subroutine_die (arg)
2918 register tree stmt = arg;
2919 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2920 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2922 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inlined_subroutine);
2923 sibling_attribute ();
2925 sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
2926 low_pc_attribute (begin_label);
2927 sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
2928 high_pc_attribute (end_label);
2931 /* Output a DIE to represent a declared data object (either file-scope
2932 or block-local) which has "internal linkage" (according to ANSI-C). */
2935 output_local_variable_die (arg)
2938 register tree decl = arg;
2939 register tree type = TREE_TYPE (decl);
2941 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_local_variable);
2942 sibling_attribute ();
2943 name_and_src_coords_attributes (decl);
2944 member_attribute (DECL_CONTEXT (decl));
2945 type_attribute (type, TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
2946 location_or_const_value_attribute (decl);
2950 output_member_die (arg)
2953 register tree decl = arg;
2955 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_member);
2956 sibling_attribute ();
2957 name_and_src_coords_attributes (decl);
2958 member_attribute (DECL_CONTEXT (decl));
2959 type_attribute (member_declared_type (decl),
2960 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
2961 if (DECL_BIT_FIELD_TYPE (decl)) /* If this is a bit field... */
2963 byte_size_attribute (decl);
2964 bit_size_attribute (decl);
2965 bit_offset_attribute (decl);
2967 data_member_location_attribute (decl);
2971 /* Don't generate either pointer_type DIEs or reference_type DIEs. According
2972 to the 4-4-90 Dwarf draft spec (just after requirement #47):
2974 These two type entries are not currently generated by any compiler.
2975 Since the only way to name a pointer (or reference) type is C or C++
2976 is via a "typedef", an entry with the "typedef" tag is generated
2979 We keep this code here just in case these types of DIEs may be needed
2980 to represent certain things in other languages (e.g. Pascal) someday.
2984 output_pointer_type_die (arg)
2987 register tree type = arg;
2989 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_pointer_type);
2990 sibling_attribute ();
2991 equate_type_number_to_die_number (type);
2992 member_attribute (TYPE_CONTEXT (type));
2993 type_attribute (TREE_TYPE (type), 0, 0);
2997 output_reference_type_die (arg)
3000 register tree type = arg;
3002 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_reference_type);
3003 sibling_attribute ();
3004 equate_type_number_to_die_number (type);
3005 member_attribute (TYPE_CONTEXT (type));
3006 type_attribute (TREE_TYPE (type), 0, 0);
3010 output_ptr_to_mbr_type_die (arg)
3013 register tree type = arg;
3015 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_ptr_to_member_type);
3016 sibling_attribute ();
3017 equate_type_number_to_die_number (type);
3018 member_attribute (TYPE_CONTEXT (type));
3019 containing_type_attribute (TYPE_OFFSET_BASETYPE (type));
3020 type_attribute (TREE_TYPE (type), 0, 0);
3024 output_compile_unit_die (arg)
3027 register char *main_input_filename = arg;
3029 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_compile_unit);
3030 sibling_attribute ();
3032 name_attribute (main_input_filename);
3037 sprintf (producer, "%s %s", language_string, version_string);
3038 producer_attribute (producer);
3041 if (strcmp (language_string, "GNU C++") == 0)
3042 language_attribute (LANG_C_PLUS_PLUS);
3043 else if (flag_traditional)
3044 language_attribute (LANG_C);
3046 language_attribute (LANG_C89);
3047 low_pc_attribute (TEXT_BEGIN_LABEL);
3048 high_pc_attribute (TEXT_END_LABEL);
3049 if (debug_info_level >= DINFO_LEVEL_NORMAL)
3050 stmt_list_attribute (LINE_BEGIN_LABEL);
3051 last_filename = xstrdup (main_input_filename);
3054 char *wd = getpwd ();
3056 comp_dir_attribute (wd);
3059 if (debug_info_level >= DINFO_LEVEL_NORMAL)
3061 sf_names_attribute (SFNAMES_BEGIN_LABEL);
3062 src_info_attribute (SRCINFO_BEGIN_LABEL);
3063 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
3064 mac_info_attribute (MACINFO_BEGIN_LABEL);
3069 output_string_type_die (arg)
3072 register tree type = arg;
3074 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_string_type);
3075 sibling_attribute ();
3076 member_attribute (TYPE_CONTEXT (type));
3078 /* Fudge the string length attribute for now. */
3080 string_length_attribute (
3081 TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
3085 output_structure_type_die (arg)
3088 register tree type = arg;
3090 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
3091 sibling_attribute ();
3092 equate_type_number_to_die_number (type);
3093 name_attribute (type_tag (type));
3094 member_attribute (TYPE_CONTEXT (type));
3096 /* If this type has been completed, then give it a byte_size attribute
3097 and prepare to give a list of members. Otherwise, don't do either of
3098 these things. In the latter case, we will not be generating a list
3099 of members (since we don't have any idea what they might be for an
3100 incomplete type). */
3102 if (TYPE_SIZE (type))
3105 byte_size_attribute (type);
3109 /* Output a DIE to represent a declared function (either file-scope
3110 or block-local) which has "internal linkage" (according to ANSI-C). */
3113 output_local_subroutine_die (arg)
3116 register tree decl = arg;
3117 register tree type = TREE_TYPE (decl);
3118 register tree return_type = TREE_TYPE (type);
3119 char func_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3121 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine);
3122 sibling_attribute ();
3124 name_and_src_coords_attributes (decl);
3125 inline_attribute (decl);
3126 prototyped_attribute (type);
3127 member_attribute (DECL_CONTEXT (decl));
3128 type_attribute (return_type, 0, 0);
3130 /* Avoid getting screwed up in cases where a function was declared static
3131 but where no definition was ever given for it. */
3133 if (TREE_ASM_WRITTEN (decl))
3135 low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
3136 sprintf (func_end_label, FUNC_END_LABEL_FMT, current_funcdef_number);
3137 high_pc_attribute (func_end_label);
3142 output_subroutine_type_die (arg)
3145 register tree type = arg;
3146 register tree return_type = TREE_TYPE (type);
3148 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine_type);
3149 sibling_attribute ();
3151 equate_type_number_to_die_number (type);
3152 prototyped_attribute (type);
3153 member_attribute (TYPE_CONTEXT (type));
3154 type_attribute (return_type, 0, 0);
3158 output_typedef_die (arg)
3161 register tree decl = arg;
3162 register tree type = TREE_TYPE (decl);
3164 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_typedef);
3165 sibling_attribute ();
3166 name_and_src_coords_attributes (decl);
3167 member_attribute (DECL_CONTEXT (decl));
3168 type_attribute (type, TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3172 output_union_type_die (arg)
3175 register tree type = arg;
3177 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
3178 sibling_attribute ();
3179 equate_type_number_to_die_number (type);
3180 name_attribute (type_tag (type));
3181 member_attribute (TYPE_CONTEXT (type));
3183 /* If this type has been completed, then give it a byte_size attribute
3184 and prepare to give a list of members. Otherwise, don't do either of
3185 these things. In the latter case, we will not be generating a list
3186 of members (since we don't have any idea what they might be for an
3187 incomplete type). */
3189 if (TYPE_SIZE (type))
3192 byte_size_attribute (type);
3196 /* Generate a special type of DIE used as a stand-in for a trailing ellipsis
3197 at the end of an (ANSI prototyped) formal parameters list. */
3200 output_unspecified_parameters_die (arg)
3203 register tree decl_or_type = arg;
3205 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_unspecified_parameters);
3206 sibling_attribute ();
3208 /* This kludge is here only for the sake of being compatible with what
3209 the USL CI5 C compiler does. The specification of Dwarf Version 1
3210 doesn't say that TAG_unspecified_parameters DIEs should contain any
3211 attributes other than the AT_sibling attribute, but they are certainly
3212 allowed to contain additional attributes, and the CI5 compiler
3213 generates AT_name, AT_fund_type, and AT_location attributes within
3214 TAG_unspecified_parameters DIEs which appear in the child lists for
3215 DIEs representing function definitions, so we do likewise here. */
3217 if (TREE_CODE (decl_or_type) == FUNCTION_DECL && DECL_INITIAL (decl_or_type))
3219 name_attribute ("...");
3220 fund_type_attribute (FT_pointer);
3221 /* location_attribute (?); */
3226 output_padded_null_die (arg)
3229 ASM_OUTPUT_ALIGN (asm_out_file, 2); /* 2**2 == 4 */
3232 /*************************** end of DIEs *********************************/
3234 /* Generate some type of DIE. This routine generates the generic outer
3235 wrapper stuff which goes around all types of DIE's (regardless of their
3236 TAGs. All forms of DIEs start with a DIE-specific label, followed by a
3237 DIE-length word, followed by the guts of the DIE itself. After the guts
3238 of the DIE, there must always be a terminator label for the DIE. */
3241 output_die (die_specific_output_function, param)
3242 register void (*die_specific_output_function)();
3243 register void *param;
3245 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3246 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3248 current_dienum = NEXT_DIE_NUM;
3249 NEXT_DIE_NUM = next_unused_dienum;
3251 sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
3252 sprintf (end_label, DIE_END_LABEL_FMT, current_dienum);
3254 /* Write a label which will act as the name for the start of this DIE. */
3256 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
3258 /* Write the DIE-length word. */
3260 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
3262 /* Fill in the guts of the DIE. */
3264 next_unused_dienum++;
3265 die_specific_output_function (param);
3267 /* Write a label which will act as the name for the end of this DIE. */
3269 ASM_OUTPUT_LABEL (asm_out_file, end_label);
3273 end_sibling_chain ()
3275 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3277 current_dienum = NEXT_DIE_NUM;
3278 NEXT_DIE_NUM = next_unused_dienum;
3280 sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
3282 /* Write a label which will act as the name for the start of this DIE. */
3284 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
3286 /* Write the DIE-length word. */
3288 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 4);
3293 /* Generate a list of nameless TAG_formal_parameter DIEs (and perhaps a
3294 TAG_unspecified_parameters DIE) to represent the types of the formal
3295 parameters as specified in some function type specification (except
3296 for those which appear as part of a function *definition*).
3298 Note that we must be careful here to output all of the parameter DIEs
3299 *before* we output any DIEs needed to represent the types of the formal
3300 parameters. This keeps svr4 SDB happy because it (incorrectly) thinks
3301 that the first non-parameter DIE it sees ends the formal parameter list.
3305 output_formal_types (function_or_method_type)
3306 register tree function_or_method_type;
3309 register tree formal_type;
3310 register tree first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
3312 /* In the case where we are generating a formal types list for a C++
3313 non-static member function type, skip over the first thing on the
3314 TYPE_ARG_TYPES list because it only represents the type of the
3315 hidden `this pointer'. The debugger should be able to figure
3316 out (without being explicitly told) that this non-static member
3317 function type takes a `this pointer' and should be able to figure
3318 what the type of that hidden parameter is from the AT_member
3319 attribute of the parent TAG_subroutine_type DIE. */
3321 if (TREE_CODE (function_or_method_type) == METHOD_TYPE)
3322 first_parm_type = TREE_CHAIN (first_parm_type);
3324 /* Make our first pass over the list of formal parameter types and output
3325 a TAG_formal_parameter DIE for each one. */
3327 for (link = first_parm_type; link; link = TREE_CHAIN (link))
3329 formal_type = TREE_VALUE (link);
3330 if (formal_type == void_type_node)
3333 /* Output a (nameless) DIE to represent the formal parameter itself. */
3335 output_die (output_formal_parameter_die, formal_type);
3338 /* If this function type has an ellipsis, add a TAG_unspecified_parameters
3339 DIE to the end of the parameter list. */
3341 if (formal_type != void_type_node)
3342 output_die (output_unspecified_parameters_die, function_or_method_type);
3344 /* Make our second (and final) pass over the list of formal parameter types
3345 and output DIEs to represent those types (as necessary). */
3347 for (link = TYPE_ARG_TYPES (function_or_method_type);
3349 link = TREE_CHAIN (link))
3351 formal_type = TREE_VALUE (link);
3352 if (formal_type == void_type_node)
3355 output_type (formal_type, function_or_method_type);
3359 /* Remember a type in the pending_types_list. */
3365 if (pending_types == pending_types_allocated)
3367 pending_types_allocated += PENDING_TYPES_INCREMENT;
3369 = (tree *) xrealloc (pending_types_list,
3370 sizeof (tree) * pending_types_allocated);
3372 pending_types_list[pending_types++] = type;
3374 /* Mark the pending type as having been output already (even though
3375 it hasn't been). This prevents the type from being added to the
3376 pending_types_list more than once. */
3378 TREE_ASM_WRITTEN (type) = 1;
3381 /* Return non-zero if it is legitimate to output DIEs to represent a
3382 given type while we are generating the list of child DIEs for some
3383 DIE associated with a given scope.
3385 This function returns non-zero if *either* of the following two conditions
3388 o the type actually belongs to the given scope (as evidenced
3389 by its TYPE_CONTEXT value), or
3391 o the type is anonymous, and the `scope' in question is *not*
3392 a RECORD_TYPE or UNION_TYPE.
3394 In theory, we should be able to generate DIEs for anonymous types
3395 *anywhere* (since the scope of an anonymous type is irrelevant)
3396 however svr4 SDB doesn't want to see other type DIEs within the
3397 lists of child DIEs for a TAG_structure_type or TAG_union_type DIE.
3399 Note that TYPE_CONTEXT(type) may be NULL (to indicate global scope)
3400 or it may point to a BLOCK node (for types local to a block), or to a
3401 FUNCTION_DECL node (for types local to the heading of some function
3402 definition), or to a FUNCTION_TYPE node (for types local to the
3403 prototyped parameter list of a function type specification), or to a
3404 RECORD_TYPE or UNION_TYPE node (in the case of C++ nested types).
3406 The `scope' parameter should likewise be NULL or should point to a
3407 BLOCK node, a FUNCTION_DECL node, a FUNCTION_TYPE node, a RECORD_TYPE
3408 node, or a UNION_TYPE node.
3410 This function is used only for deciding when to "pend" and when to
3411 "un-pend" types to/from the pending_types_list.
3413 Note that we sometimes make use of this "type pending" feature in a
3414 rather twisted way to temporarily delay the production of DIEs for the
3415 types of formal parameters. (We do this just to make svr4 SDB happy.)
3416 It order to delay the production of DIEs representing types of formal
3417 parameters, callers of this function supply `fake_containing_scope' as
3418 the `scope' parameter to this function. Given that fake_containing_scope
3419 is *not* the containing scope for *any* other type, the desired effect
3420 is achieved, i.e. output of DIEs representing types is temporarily
3421 suspended, and any type DIEs which would have been output otherwise
3422 are instead placed onto the pending_types_list. Later on, we can force
3423 these (temporarily pended) types to be output simply by calling
3424 `output_pending_types_for_scope' with an actual argument equal to the
3425 true scope of the types we temporarily pended.
3429 type_ok_for_scope (type, scope)
3431 register tree scope;
3433 return (TYPE_CONTEXT (type) == scope
3434 || (TYPE_NAME (type) == NULL
3435 && TREE_CODE (scope) != RECORD_TYPE
3436 && TREE_CODE (scope) != UNION_TYPE));
3439 /* Output any pending types (from the pending_types list) which we can output
3440 now (given the limitations of the scope that we are working on now).
3442 For each type output, remove the given type from the pending_types_list
3443 *before* we try to output it.
3445 Note that we have to process the list in beginning-to-end order,
3446 because the call made here to output_type may cause yet more types
3447 to be added to the end of the list, and we may have to output some
3452 output_pending_types_for_scope (containing_scope)
3453 register tree containing_scope;
3455 register unsigned i;
3457 for (i = 0; i < pending_types; )
3459 register tree type = pending_types_list[i];
3461 if (type_ok_for_scope (type, containing_scope))
3463 register tree *mover;
3464 register tree *limit;
3467 limit = &pending_types_list[pending_types];
3468 for (mover = &pending_types_list[i]; mover < limit; mover++)
3469 *mover = *(mover+1);
3471 /* Un-mark the type as having been output already (because it
3472 hasn't been, really). Then call output_type to generate a
3473 Dwarf representation of it. */
3475 TREE_ASM_WRITTEN (type) = 0;
3476 output_type (type, containing_scope);
3478 /* Don't increment the loop counter in this case because we
3479 have shifted all of the subsequent pending types down one
3480 element in the pending_types_list array. */
3488 output_type (type, containing_scope)
3490 register tree containing_scope;
3492 if (type == 0 || type == error_mark_node)
3495 /* We are going to output a DIE to represent the unqualified version of
3496 of this type (i.e. without any const or volatile qualifiers) so get
3497 the main variant (i.e. the unqualified version) of this type now. */
3499 type = TYPE_MAIN_VARIANT (type);
3501 if (TREE_ASM_WRITTEN (type))
3504 /* Don't generate any DIEs for this type now unless it is OK to do so
3505 (based upon what `type_ok_for_scope' tells us). */
3507 if (! type_ok_for_scope (type, containing_scope))
3513 switch (TREE_CODE (type))
3519 case REFERENCE_TYPE:
3520 /* For these types, all that is required is that we output a DIE
3521 (or a set of DIEs) to represent that "basis" type. */
3522 output_type (TREE_TYPE (type), containing_scope);
3526 /* This code is used for C++ pointer-to-data-member types. */
3527 /* Output a description of the relevant class type. */
3528 output_type (TYPE_OFFSET_BASETYPE (type), containing_scope);
3529 /* Output a description of the type of the object pointed to. */
3530 output_type (TREE_TYPE (type), containing_scope);
3531 /* Now output a DIE to represent this pointer-to-data-member type
3533 output_die (output_ptr_to_mbr_type_die, type);
3537 output_type (TREE_TYPE (type), containing_scope);
3538 output_die (output_set_type_die, type);
3542 output_type (TREE_TYPE (type), containing_scope);
3543 abort (); /* No way to represent these in Dwarf yet! */
3547 output_type (TREE_TYPE (type), containing_scope);
3548 output_die (output_string_type_die, type);
3552 /* Force out return type (in case it wasn't forced out already). */
3553 output_type (TREE_TYPE (type), containing_scope);
3554 output_die (output_subroutine_type_die, type);
3555 output_formal_types (type);
3556 end_sibling_chain ();
3560 /* Force out return type (in case it wasn't forced out already). */
3561 output_type (TREE_TYPE (type), containing_scope);
3562 output_die (output_subroutine_type_die, type);
3563 output_formal_types (type);
3564 end_sibling_chain ();
3569 register tree element_type;
3571 element_type = TREE_TYPE (type);
3572 while (TREE_CODE (element_type) == ARRAY_TYPE)
3573 element_type = TREE_TYPE (element_type);
3575 output_type (element_type, containing_scope);
3576 output_die (output_array_type_die, type);
3584 /* For a non-file-scope tagged type, we can always go ahead and
3585 output a Dwarf description of this type right now, even if
3586 the type in question is still incomplete, because if this
3587 local type *was* ever completed anywhere within its scope,
3588 that complete definition would already have been attached to
3589 this RECORD_TYPE, UNION_TYPE or ENUMERAL_TYPE node by the
3590 time we reach this point. That's true because of the way the
3591 front-end does its processing of file-scope declarations (of
3592 functions and class types) within which other types might be
3593 nested. The C and C++ front-ends always gobble up such "local
3594 scope" things en-mass before they try to output *any* debugging
3595 information for any of the stuff contained inside them and thus,
3596 we get the benefit here of what is (in effect) a pre-resolution
3597 of forward references to tagged types in local scopes.
3599 Note however that for file-scope tagged types we cannot assume
3600 that such pre-resolution of forward references has taken place.
3601 A given file-scope tagged type may appear to be incomplete when
3602 we reach this point, but it may yet be given a full definition
3603 (at file-scope) later on during compilation. In order to avoid
3604 generating a premature (and possibly incorrect) set of Dwarf
3605 DIEs for such (as yet incomplete) file-scope tagged types, we
3606 generate nothing at all for as-yet incomplete file-scope tagged
3607 types here unless we are making our special "finalization" pass
3608 for file-scope things at the very end of compilation. At that
3609 time, we will certainly know as much about each file-scope tagged
3610 type as we are ever going to know, so at that point in time, we
3611 can safely generate correct Dwarf descriptions for these file-
3615 if (TYPE_SIZE (type) == 0 && TYPE_CONTEXT (type) == NULL && !finalizing)
3616 return; /* EARLY EXIT! Avoid setting TREE_ASM_WRITTEN. */
3618 /* Prevent infinite recursion in cases where the type of some
3619 member of this type is expressed in terms of this type itself. */
3621 TREE_ASM_WRITTEN (type) = 1;
3623 /* Output a DIE to represent the tagged type itself. */
3625 switch (TREE_CODE (type))
3628 output_die (output_enumeration_type_die, type);
3629 return; /* a special case -- nothing left to do so just return */
3632 output_die (output_structure_type_die, type);
3636 output_die (output_union_type_die, type);
3640 /* If this is not an incomplete type, output descriptions of
3641 each of its members.
3643 Note that as we output the DIEs necessary to represent the
3644 members of this record or union type, we will also be trying
3645 to output DIEs to represent the *types* of those members.
3646 However the `output_type' function (above) will specifically
3647 avoid generating type DIEs for member types *within* the list
3648 of member DIEs for this (containing) type execpt for those
3649 types (of members) which are explicitly marked as also being
3650 members of this (containing) type themselves. The g++ front-
3651 end can force any given type to be treated as a member of some
3652 other (containing) type by setting the TYPE_CONTEXT of the
3653 given (member) type to point to the TREE node representing the
3654 appropriate (containing) type.
3657 if (TYPE_SIZE (type))
3660 register tree normal_member;
3662 /* First output info about the data members and type members. */
3664 for (normal_member = TYPE_FIELDS (type);
3666 normal_member = TREE_CHAIN (normal_member))
3667 output_decl (normal_member, type);
3671 register tree vec_base;
3673 /* Now output info about the function members (if any). */
3675 vec_base = TYPE_METHODS (type);
3678 register tree first_func_member = TREE_VEC_ELT (vec_base, 0);
3679 register tree func_member;
3681 /* This isn't documented, but the first element of the
3682 vector of member functions can be NULL in cases where
3683 the class type in question didn't have either a
3684 constructor or a destructor declared for it. We have
3685 to make allowances for that here. */
3687 if (first_func_member == NULL)
3688 first_func_member = TREE_VEC_ELT (vec_base, 1);
3690 for (func_member = first_func_member;
3692 func_member = TREE_CHAIN (func_member))
3693 output_decl (func_member, type);
3697 end_sibling_chain (); /* Terminate member chain. */
3708 break; /* No DIEs needed for fundamental types. */
3710 case LANG_TYPE: /* No Dwarf representation currently defined. */
3717 TREE_ASM_WRITTEN (type) = 1;
3720 /* Output a TAG_lexical_block DIE followed by DIEs to represent all of
3721 the things which are local to the given block. */
3727 register int have_significant_locals = 0;
3729 /* Ignore blocks never really used to make RTL. */
3731 if (! stmt || ! TREE_USED (stmt))
3734 /* Determine if this block contains any "significant" local declarations
3735 which we need to output DIEs for. */
3737 if (BLOCK_INLINE_FUNCTION (stmt))
3738 /* The outer scopes for inlinings *must* always be represented. */
3739 have_significant_locals = 1;
3741 if (debug_info_level > DINFO_LEVEL_TERSE)
3742 have_significant_locals = (BLOCK_VARS (stmt) != NULL);
3747 for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
3748 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
3750 have_significant_locals = 1;
3755 /* It would be a waste of space to generate a Dwarf TAG_lexical_block
3756 DIE for any block which contains no significant local declarations
3757 at all. Rather, in such cases we just call `output_decls_for_scope'
3758 so that any needed Dwarf info for any sub-blocks will get properly
3759 generated. Note that in terse mode, our definition of what constitutes
3760 a "significant" local declaration gets restricted to include only
3761 inlined function instances and local (nested) function definitions. */
3763 if (have_significant_locals)
3765 output_die (BLOCK_INLINE_FUNCTION (stmt)
3766 ? output_inlined_subroutine_die
3767 : output_lexical_block_die,
3769 output_decls_for_scope (stmt);
3770 end_sibling_chain ();
3773 output_decls_for_scope (stmt);
3776 /* Output all of the decls declared within a given scope (also called
3777 a `binding contour') and (recursively) all of it's sub-blocks. */
3780 output_decls_for_scope (stmt)
3783 /* Ignore blocks never really used to make RTL. */
3785 if (! stmt || ! TREE_USED (stmt))
3788 next_block_number++;
3790 /* Output the DIEs to represent all of the data objects, functions,
3791 typedefs, and tagged types declared directly within this block
3792 but not within any nested sub-blocks. */
3797 for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
3798 output_decl (decl, stmt);
3801 output_pending_types_for_scope (stmt);
3803 /* Output the DIEs to represent all sub-blocks (and the items declared
3804 therein) of this block. */
3807 register tree subblocks;
3809 for (subblocks = BLOCK_SUBBLOCKS (stmt);
3811 subblocks = BLOCK_CHAIN (subblocks))
3812 output_block (subblocks);
3816 /* Output Dwarf .debug information for a decl described by DECL. */
3819 output_decl (decl, containing_scope)
3821 register tree containing_scope;
3823 if (TREE_CODE (decl) == ERROR_MARK)
3826 /* If this ..._DECL node is marked to be ignored, then ignore it.
3827 But don't ignore a function definition, since that would screw
3828 up our count of blocks, and that it turn will completely screw up the
3829 the labels we will reference in subsequent AT_low_pc and AT_high_pc
3830 attributes (for subsequent blocks). */
3832 if (DECL_IGNORED_P (decl) && TREE_CODE (decl) != FUNCTION_DECL)
3835 switch (TREE_CODE (decl))
3838 /* The individual enumerators of an enum type get output when we
3839 output the Dwarf representation of the relevant enum type itself. */
3843 /* If we are in terse mode, don't output any DIEs to represent
3844 mere external function declarations. Also, if we are conforming
3845 to the DWARF version 1 specification, don't output DIEs for
3846 mere external function declarations. */
3848 if (TREE_EXTERNAL (decl))
3849 #if (DWARF_VERSION > 1)
3850 if (debug_info_level <= DINFO_LEVEL_TERSE)
3854 /* Before we describe the FUNCTION_DECL itself, make sure that we
3855 have described its return type. */
3857 output_type (TREE_TYPE (TREE_TYPE (decl)), containing_scope);
3859 /* If the following DIE will represent a function definition for a
3860 function with "extern" linkage, output a special "pubnames" DIE
3861 label just ahead of the actual DIE. A reference to this label
3862 was already generated in the .debug_pubnames section sub-entry
3863 for this function definition. */
3865 if (TREE_PUBLIC (decl))
3867 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3869 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
3870 ASM_OUTPUT_LABEL (asm_out_file, label);
3873 /* Now output a DIE to represent the function itself. */
3875 output_die (TREE_PUBLIC (decl) || TREE_EXTERNAL (decl)
3876 ? output_global_subroutine_die
3877 : output_local_subroutine_die,
3880 /* Now output descriptions of the arguments for this function.
3881 This gets (unnecessarily?) complex because of the fact that
3882 the DECL_ARGUMENT list for a FUNCTION_DECL doesn't indicate
3883 cases where there was a trailing `...' at the end of the formal
3884 parameter list. In order to find out if there was a trailing
3885 ellipsis or not, we must instead look at the type associated
3886 with the FUNCTION_DECL. This will be a node of type FUNCTION_TYPE.
3887 If the chain of type nodes hanging off of this FUNCTION_TYPE node
3888 ends with a void_type_node then there should *not* be an ellipsis
3891 /* In the case where we are describing an external function, all
3892 we need to do here (and all we *can* do here) is to describe
3893 the *types* of its formal parameters. */
3895 if (TREE_EXTERNAL (decl))
3896 output_formal_types (TREE_TYPE (decl));
3899 register tree arg_decls = DECL_ARGUMENTS (decl);
3901 /* In the case where the FUNCTION_DECL represents a C++ non-static
3902 member function, skip over the first thing on the DECL_ARGUMENTS
3903 chain. It only represents the hidden `this pointer' parameter
3904 and the debugger should know implicitly that non-static member
3905 functions have such a thing, and should be able to figure out
3906 exactly what the type of each `this pointer' is (from the
3907 AT_member attribute of the parent TAG_subroutine DIE) without
3908 being explicitly told. */
3910 if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
3911 arg_decls = TREE_CHAIN (arg_decls);
3914 register tree last_arg;
3916 last_arg = (arg_decls && TREE_CODE (arg_decls) != ERROR_MARK)
3917 ? tree_last (arg_decls)
3920 /* Generate DIEs to represent all known formal parameters, but
3921 don't do it if this looks like a varargs function. A given
3922 function is considered to be a varargs function if (and only
3923 if) its last named argument is named `__builtin_va_alist'. */
3926 || ! DECL_NAME (last_arg)
3927 || strcmp (IDENTIFIER_POINTER (DECL_NAME (last_arg)),
3928 "__builtin_va_alist"))
3932 /* WARNING! Kludge zone ahead! Here we have a special
3933 hack for svr4 SDB compatibility. Instead of passing the
3934 current FUNCTION_DECL node as the second parameter (i.e.
3935 the `containing_scope' parameter) to `output_decl' (as
3936 we ought to) we instead pass a pointer to our own private
3937 fake_containing_scope node. That node is a RECORD_TYPE
3938 node which NO OTHER TYPE may ever actually be a member of.
3940 This pointer will ultimately get passed into `output_type'
3941 as its `containing_scope' parameter. `Output_type' will
3942 then perform its part in the hack... i.e. it will pend
3943 the type of the formal parameter onto the pending_types
3944 list. Later on, when we are done generating the whole
3945 sequence of formal parameter DIEs for this function
3946 definition, we will un-pend all previously pended types
3947 of formal parameters for this function definition.
3949 This whole kludge prevents any type DIEs from being
3950 mixed in with the formal parameter DIEs. That's good
3951 because svr4 SDB believes that the list of formal
3952 parameter DIEs for a function ends wherever the first
3953 non-formal-parameter DIE appears. Thus, we have to
3954 keep the formal parameter DIEs segregated. They must
3955 all appear (consecutively) at the start of the list of
3956 children for the DIE representing the function definition.
3957 Then (and only then) may we output any additional DIEs
3958 needed to represent the types of these formal parameters.
3961 for (parm = arg_decls; parm; parm = TREE_CHAIN (parm))
3962 if (TREE_CODE (parm) == PARM_DECL)
3963 output_decl (parm, fake_containing_scope);
3965 /* Now that we have finished generating all of the DIEs to
3966 represent the formal parameters themselves, force out
3967 any DIEs needed to represent their types. We do this
3968 simply by un-pending all previously pended types which
3969 can legitimately go into the chain of children DIEs for
3970 the current FUNCTION_DECL. */
3972 output_pending_types_for_scope (decl);
3976 /* Now try to decide if we should put an ellipsis at the end. */
3979 register int has_ellipsis = TRUE; /* default assumption */
3980 register tree fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (decl));
3984 /* This function declaration/definition was prototyped. */
3986 /* If the list of formal argument types ends with a
3987 void_type_node, then the formals list did *not* end
3988 with an ellipsis. */
3990 if (TREE_VALUE (tree_last (fn_arg_types)) == void_type_node)
3991 has_ellipsis = FALSE;
3995 /* This function declaration/definition was not prototyped. */
3997 /* Note that all non-prototyped function *declarations* are
3998 assumed to represent varargs functions (until proven
4001 if (DECL_INITIAL (decl)) /* if this is a func definition */
4004 has_ellipsis = FALSE; /* no args == (void) */
4007 /* For a non-prototyped function definition which
4008 declares one or more formal parameters, if the name
4009 of the first formal parameter is *not*
4010 __builtin_va_alist then we must assume that this
4011 is *not* a varargs function. */
4013 if (DECL_NAME (arg_decls)
4014 && strcmp (IDENTIFIER_POINTER (DECL_NAME (arg_decls)),
4015 "__builtin_va_alist"))
4016 has_ellipsis = FALSE;
4022 output_die (output_unspecified_parameters_die, decl);
4026 /* Output Dwarf info for all of the stuff within the body of the
4027 function (if it has one - it may be just a declaration). */
4030 register tree outer_scope = DECL_INITIAL (decl);
4032 if (outer_scope && TREE_CODE (outer_scope) != ERROR_MARK)
4034 /* Note that here, `outer_scope' is a pointer to the outermost
4035 BLOCK node created to represent the body of a function.
4036 This outermost BLOCK actually represents the outermost
4037 binding contour for the function, i.e. the contour in which
4038 the function's formal parameters get declared. Just within
4039 this contour, there will be another (nested) BLOCK which
4040 represents the function's outermost block. We don't want
4041 to generate a lexical_block DIE to represent the outermost
4042 block of a function body, because that is not really an
4043 independent scope according to ANSI C rules. Rather, it is
4044 the same scope in which the parameters were declared and
4045 for Dwarf, we do not generate a TAG_lexical_block DIE for
4046 that scope. We must however see to it that the LABEL_DECLs
4047 associated with `outer_scope' get DIEs generated for them. */
4050 register tree label;
4052 for (label = BLOCK_VARS (outer_scope);
4054 label = TREE_CHAIN (label))
4055 output_decl (label, outer_scope);
4058 output_decls_for_scope (BLOCK_SUBBLOCKS (outer_scope));
4060 /* Finally, force out any pending types which are local to the
4061 outermost block of this function definition. These will
4062 all have a TYPE_CONTEXT which points to the FUNCTION_DECL
4065 output_pending_types_for_scope (decl);
4069 /* Generate a terminator for the list of stuff `owned' by this
4072 end_sibling_chain ();
4077 /* If we are in terse mode, don't generate any DIEs to represent
4078 any actual typedefs. Note that even when we are in terse mode,
4079 we must still output DIEs to represent those tagged types which
4080 are used (directly or indirectly) in the specification of either
4081 a return type or a formal parameter type of some function. */
4083 if (debug_info_level <= DINFO_LEVEL_TERSE)
4084 if (DECL_NAME (decl) != NULL
4085 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
4088 output_type (TREE_TYPE (decl), containing_scope);
4090 /* Note that unlike the gcc front end (which generates a NULL named
4091 TYPE_DECL node for each complete tagged type, each array type,
4092 and each function type node created) the g++ front end generates
4093 a *named* TYPE_DECL node for each tagged type node created.
4094 Unfortunately, these g++ TYPE_DECL nodes cause us to output many
4095 superfluous and unnecessary TAG_typedef DIEs here. When g++ is
4096 fixed to stop generating these superfluous named TYPE_DECL nodes,
4097 the superfluous TAG_typedef DIEs will likewise cease. */
4099 if (DECL_NAME (decl))
4100 /* Output a DIE to represent the typedef itself. */
4101 output_die (output_typedef_die, decl);
4105 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4106 output_die (output_label_die, decl);
4110 /* If we are conforming to the DWARF version 1 specification, don't
4111 generated any DIEs to represent mere external object declarations. */
4113 #if (DWARF_VERSION <= 1)
4114 if (TREE_EXTERNAL (decl) && ! TREE_PUBLIC (decl))
4118 /* If we are in terse mode, don't generate any DIEs to represent
4119 any variable declarations or definitions. */
4121 if (debug_info_level <= DINFO_LEVEL_TERSE)
4124 /* Output any DIEs that are needed to specify the type of this data
4127 output_type (TREE_TYPE (decl), containing_scope);
4129 /* If the following DIE will represent a data object definition for a
4130 data object with "extern" linkage, output a special "pubnames" DIE
4131 label just ahead of the actual DIE. A reference to this label
4132 was already generated in the .debug_pubnames section sub-entry
4133 for this data object definition. */
4135 if (TREE_PUBLIC (decl))
4137 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4139 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
4140 ASM_OUTPUT_LABEL (asm_out_file, label);
4143 /* Now output the DIE to represent the data object itself. */
4145 output_die (TREE_PUBLIC (decl) || TREE_EXTERNAL (decl)
4146 ? output_global_variable_die : output_local_variable_die,
4151 /* Ignore the nameless fields that are used to skip bits. */
4152 if (DECL_NAME (decl) != 0)
4154 output_type (member_declared_type (decl), containing_scope);
4155 output_die (output_member_die, decl);
4160 /* Force out the type of this formal, if it was not forced out yet.
4161 Note that here we can run afowl of a bug in "classic" svr4 SDB.
4162 It should be able to grok the presence of type DIEs within a list
4163 of TAG_formal_parameter DIEs, but it doesn't. */
4165 output_type (TREE_TYPE (decl), containing_scope);
4166 output_die (output_formal_parameter_die, decl);
4175 dwarfout_file_scope_decl (decl, set_finalizing)
4177 register int set_finalizing;
4179 if (TREE_CODE (decl) == ERROR_MARK)
4182 /* If this ..._DECL node is marked to be ignored, then ignore it. We
4183 gotta hope that the node in question doesn't represent a function
4184 definition. If it does, then totally ignoring it is bound to screw
4185 up our count of blocks, and that it turn will completely screw up the
4186 the labels we will reference in subsequent AT_low_pc and AT_high_pc
4187 attributes (for subsequent blocks). (It's too bad that BLOCK nodes
4188 don't carry their own sequence numbers with them!) */
4190 if (DECL_IGNORED_P (decl))
4192 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
4197 switch (TREE_CODE (decl))
4201 /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of
4202 a builtin function. Explicit programmer-supplied declarations of
4203 these same functions should NOT be ignored however. */
4205 if (TREE_EXTERNAL (decl) && DECL_FUNCTION_CODE (decl))
4208 /* Ignore this FUNCTION_DECL if it refers to a file-scope extern
4209 function declaration and if the declaration was never even
4210 referenced from within this entire compilation unit. We
4211 suppress these DIEs in order to save space in the .debug section
4212 (by eliminating entries which are probably useless). Note that
4213 we must not suppress block-local extern declarations (whether
4214 used or not) because that would screw-up the debugger's name
4215 lookup mechanism and cause it to miss things which really ought
4216 to be in scope at a given point. */
4218 if (TREE_EXTERNAL (decl) && !TREE_USED (decl))
4221 if (TREE_PUBLIC (decl) && ! TREE_EXTERNAL (decl))
4223 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4225 /* Output a .debug_pubnames entry for a public function
4226 defined in this compilation unit. */
4228 fputc ('\n', asm_out_file);
4229 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
4230 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
4231 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
4232 ASM_OUTPUT_DWARF_STRING (asm_out_file,
4233 IDENTIFIER_POINTER (DECL_NAME (decl)));
4234 ASM_OUTPUT_POP_SECTION (asm_out_file);
4241 /* Ignore this VAR_DECL if it refers to a file-scope extern data
4242 object declaration and if the declaration was never even
4243 referenced from within this entire compilation unit. We
4244 suppress these DIEs in order to save space in the .debug section
4245 (by eliminating entries which are probably useless). Note that
4246 we must not suppress block-local extern declarations (whether
4247 used or not) because that would screw-up the debugger's name
4248 lookup mechanism and cause it to miss things which really ought
4249 to be in scope at a given point. */
4251 if (TREE_EXTERNAL (decl) && !TREE_USED (decl))
4254 if (TREE_PUBLIC (decl)
4255 && ! TREE_EXTERNAL (decl)
4256 && GET_CODE (DECL_RTL (decl)) == MEM)
4258 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4260 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4262 /* Output a .debug_pubnames entry for a public variable
4263 defined in this compilation unit. */
4265 fputc ('\n', asm_out_file);
4266 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
4267 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
4268 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
4269 ASM_OUTPUT_DWARF_STRING (asm_out_file,
4270 IDENTIFIER_POINTER (DECL_NAME (decl)));
4271 ASM_OUTPUT_POP_SECTION (asm_out_file);
4274 if (DECL_INITIAL (decl) == NULL)
4276 /* Output a .debug_aranges entry for a public variable
4277 which is tentatively defined in this compilation unit. */
4279 fputc ('\n', asm_out_file);
4280 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
4281 ASM_OUTPUT_DWARF_ADDR (asm_out_file,
4282 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
4283 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
4284 (unsigned) int_size_in_bytes (TREE_TYPE (decl)));
4285 ASM_OUTPUT_POP_SECTION (asm_out_file);
4289 /* If we are in terse mode, don't generate any DIEs to represent
4290 any variable declarations or definitions. */
4292 if (debug_info_level <= DINFO_LEVEL_TERSE)
4298 /* Don't generate any DIEs to represent the standard built-in types. */
4300 if (DECL_SOURCE_LINE (decl) == 0)
4303 /* If we are in terse mode, don't generate any DIEs to represent
4304 any actual typedefs. Note that even when we are in terse mode,
4305 we must still output DIEs to represent those tagged types which
4306 are used (directly or indirectly) in the specification of either
4307 a return type or a formal parameter type of some function. */
4309 if (debug_info_level <= DINFO_LEVEL_TERSE)
4310 if (DECL_NAME (decl) != NULL
4311 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
4320 fputc ('\n', asm_out_file);
4321 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
4322 finalizing = set_finalizing;
4323 output_decl (decl, NULL_TREE);
4325 /* NOTE: The call above to `output_decl' may have caused one or more
4326 file-scope named types (i.e. tagged types) to be placed onto the
4327 pending_types_list. We have to get those types off of that list
4328 at some point, and this is the perfect time to do it. If we didn't
4329 take them off now, they might still be on the list when cc1 finally
4330 exits. That might be OK if it weren't for the fact that when we put
4331 types onto the pending_types_list, we set the TREE_ASM_WRITTEN flag
4332 for these types, and that causes them never to be output unless
4333 `output_pending_types_for_scope' takes them off of the list and un-sets
4334 their TREE_ASM_WRITTEN flags. */
4336 output_pending_types_for_scope (NULL_TREE);
4338 /* The above call should have totally emptied the pending_types_list. */
4340 assert (pending_types == 0);
4342 ASM_OUTPUT_POP_SECTION (asm_out_file);
4344 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
4345 current_funcdef_number++;
4348 /* Output a marker (i.e. a label) for the beginning of the generated code
4349 for a lexical block. */
4352 dwarfout_begin_block (blocknum)
4353 register unsigned blocknum;
4355 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4358 sprintf (label, BLOCK_BEGIN_LABEL_FMT, blocknum);
4359 ASM_OUTPUT_LABEL (asm_out_file, label);
4362 /* Output a marker (i.e. a label) for the end of the generated code
4363 for a lexical block. */
4366 dwarfout_end_block (blocknum)
4367 register unsigned blocknum;
4369 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4372 sprintf (label, BLOCK_END_LABEL_FMT, blocknum);
4373 ASM_OUTPUT_LABEL (asm_out_file, label);
4376 /* Output a marker (i.e. a label) at a point in the assembly code which
4377 corresponds to a given source level label. */
4380 dwarfout_label (insn)
4383 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4385 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4388 sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
4389 (unsigned) INSN_UID (insn));
4390 ASM_OUTPUT_LABEL (asm_out_file, label);
4394 /* Output a marker (i.e. a label) for the absolute end of the generated code
4395 for a function definition. This gets called *after* the epilogue code
4396 has been generated. */
4399 dwarfout_end_epilogue ()
4401 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4403 /* Output a label to mark the endpoint of the code generated for this
4406 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
4407 ASM_OUTPUT_LABEL (asm_out_file, label);
4411 shuffle_filename_entry (new_zeroth)
4412 register filename_entry *new_zeroth;
4414 filename_entry temp_entry;
4415 register filename_entry *limit_p;
4416 register filename_entry *move_p;
4418 if (new_zeroth == &filename_table[0])
4421 temp_entry = *new_zeroth;
4423 /* Shift entries up in the table to make room at [0]. */
4425 limit_p = &filename_table[0];
4426 for (move_p = new_zeroth; move_p > limit_p; move_p--)
4427 *move_p = *(move_p-1);
4429 /* Install the found entry at [0]. */
4431 filename_table[0] = temp_entry;
4434 /* Create a new (string) entry for the .debug_sfnames section. */
4437 generate_new_sfname_entry ()
4439 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4441 fputc ('\n', asm_out_file);
4442 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
4443 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, filename_table[0].number);
4444 ASM_OUTPUT_LABEL (asm_out_file, label);
4445 ASM_OUTPUT_DWARF_STRING (asm_out_file,
4446 filename_table[0].name
4447 ? filename_table[0].name
4449 ASM_OUTPUT_POP_SECTION (asm_out_file);
4452 /* Lookup a filename (in the list of filenames that we know about here in
4453 dwarfout.c) and return its "index". The index of each (known) filename
4454 is just a unique number which is associated with only that one filename.
4455 We need such numbers for the sake of generating labels (in the
4456 .debug_sfnames section) and references to those unique labels (in the
4457 .debug_srcinfo and .debug_macinfo sections).
4459 If the filename given as an argument is not found in our current list,
4460 add it to the list and assign it the next available unique index number.
4462 Whatever we do (i.e. whether we find a pre-existing filename or add a new
4463 one), we shuffle the filename found (or added) up to the zeroth entry of
4464 our list of filenames (which is always searched linearly). We do this so
4465 as to optimize the most common case for these filename lookups within
4466 dwarfout.c. The most common case by far is the case where we call
4467 lookup_filename to lookup the very same filename that we did a lookup
4468 on the last time we called lookup_filename. We make sure that this
4469 common case is fast because such cases will constitute 99.9% of the
4470 lookups we ever do (in practice).
4472 If we add a new filename entry to our table, we go ahead and generate
4473 the corresponding entry in the .debug_sfnames section right away.
4474 Doing so allows us to avoid tickling an assembler bug (present in some
4475 m68k assemblers) which yields assembly-time errors in cases where the
4476 difference of two label addresses is taken and where the two labels
4477 are in a section *other* than the one where the difference is being
4478 calculated, and where at least one of the two symbol references is a
4479 forward reference. (This bug could be tickled by our .debug_srcinfo
4480 entries if we don't output their corresponding .debug_sfnames entries
4485 lookup_filename (file_name)
4488 register filename_entry *search_p;
4489 register filename_entry *limit_p = &filename_table[ft_entries];
4491 for (search_p = filename_table; search_p < limit_p; search_p++)
4492 if (!strcmp (file_name, search_p->name))
4494 /* When we get here, we have found the filename that we were
4495 looking for in the filename_table. Now we want to make sure
4496 that it gets moved to the zero'th entry in the table (if it
4497 is not already there) so that subsequent attempts to find the
4498 same filename will find it as quickly as possible. */
4500 shuffle_filename_entry (search_p);
4501 return filename_table[0].number;
4504 /* We come here whenever we have a new filename which is not registered
4505 in the current table. Here we add it to the table. */
4507 /* Prepare to add a new table entry by making sure there is enough space
4508 in the table to do so. If not, expand the current table. */
4510 if (ft_entries == ft_entries_allocated)
4512 ft_entries_allocated += FT_ENTRIES_INCREMENT;
4514 = (filename_entry *)
4515 xrealloc (filename_table,
4516 ft_entries_allocated * sizeof (filename_entry));
4519 /* Initially, add the new entry at the end of the filename table. */
4521 filename_table[ft_entries].number = ft_entries;
4522 filename_table[ft_entries].name = xstrdup (file_name);
4524 /* Shuffle the new entry into filename_table[0]. */
4526 shuffle_filename_entry (&filename_table[ft_entries]);
4528 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4529 generate_new_sfname_entry ();
4532 return filename_table[0].number;
4536 generate_srcinfo_entry (line_entry_num, files_entry_num)
4537 unsigned line_entry_num;
4538 unsigned files_entry_num;
4540 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4542 fputc ('\n', asm_out_file);
4543 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
4544 sprintf (label, LINE_ENTRY_LABEL_FMT, line_entry_num);
4545 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, LINE_BEGIN_LABEL);
4546 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, files_entry_num);
4547 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, SFNAMES_BEGIN_LABEL);
4548 ASM_OUTPUT_POP_SECTION (asm_out_file);
4552 dwarfout_line (filename, line)
4553 register char *filename;
4554 register unsigned line;
4556 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4558 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4559 static unsigned last_line_entry_num = 0;
4560 static unsigned prev_file_entry_num = (unsigned) -1;
4561 register unsigned this_file_entry_num = lookup_filename (filename);
4564 sprintf (label, LINE_CODE_LABEL_FMT, ++last_line_entry_num);
4565 ASM_OUTPUT_LABEL (asm_out_file, label);
4567 fputc ('\n', asm_out_file);
4568 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
4570 if (this_file_entry_num != prev_file_entry_num)
4572 char line_entry_label[MAX_ARTIFICIAL_LABEL_BYTES];
4574 sprintf (line_entry_label, LINE_ENTRY_LABEL_FMT, last_line_entry_num);
4575 ASM_OUTPUT_LABEL (asm_out_file, line_entry_label);
4579 register char *tail = rindex (filename, '/');
4585 fprintf (asm_out_file, "\t%s\t%u\t%s %s:%u\n",
4586 UNALIGNED_INT_ASM_OP, line, ASM_COMMENT_START,
4588 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
4589 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, TEXT_BEGIN_LABEL);
4590 ASM_OUTPUT_POP_SECTION (asm_out_file);
4592 if (this_file_entry_num != prev_file_entry_num)
4593 generate_srcinfo_entry (last_line_entry_num, this_file_entry_num);
4594 prev_file_entry_num = this_file_entry_num;
4598 /* Generate an entry in the .debug_macinfo section. */
4601 generate_macinfo_entry (type_and_offset, string)
4602 register char *type_and_offset;
4603 register char *string;
4605 fputc ('\n', asm_out_file);
4606 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
4607 fprintf (asm_out_file, "\t%s\t%s\n", UNALIGNED_INT_ASM_OP, type_and_offset);
4608 ASM_OUTPUT_DWARF_STRING (asm_out_file, string);
4609 ASM_OUTPUT_POP_SECTION (asm_out_file);
4613 dwarfout_start_new_source_file (filename)
4614 register char *filename;
4616 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4617 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*3];
4619 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, lookup_filename (filename));
4620 sprintf (type_and_offset, "0x%08x+%s-%s",
4621 ((unsigned) MACINFO_start << 24), label, SFNAMES_BEGIN_LABEL);
4622 generate_macinfo_entry (type_and_offset, "");
4626 dwarfout_resume_previous_source_file (lineno)
4627 register unsigned lineno;
4629 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
4631 sprintf (type_and_offset, "0x%08x+%u",
4632 ((unsigned) MACINFO_resume << 24), lineno);
4633 generate_macinfo_entry (type_and_offset, "");
4636 /* Called from check_newline in c-parse.y. The `buffer' parameter
4637 contains the tail part of the directive line, i.e. the part which
4638 is past the initial whitespace, #, whitespace, directive-name,
4642 dwarfout_define (lineno, buffer)
4643 register unsigned lineno;
4644 register char *buffer;
4646 static int initialized = 0;
4647 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
4651 dwarfout_start_new_source_file (primary_filename);
4654 sprintf (type_and_offset, "0x%08x+%u",
4655 ((unsigned) MACINFO_define << 24), lineno);
4656 generate_macinfo_entry (type_and_offset, buffer);
4659 /* Called from check_newline in c-parse.y. The `buffer' parameter
4660 contains the tail part of the directive line, i.e. the part which
4661 is past the initial whitespace, #, whitespace, directive-name,
4665 dwarfout_undef (lineno, buffer)
4666 register unsigned lineno;
4667 register char *buffer;
4669 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
4671 sprintf (type_and_offset, "0x%08x+%u",
4672 ((unsigned) MACINFO_undef << 24), lineno);
4673 generate_macinfo_entry (type_and_offset, buffer);
4676 /* Set up for Dwarf output at the start of compilation. */
4679 dwarfout_init (asm_out_file, main_input_filename)
4680 register FILE *asm_out_file;
4681 register char *main_input_filename;
4683 /* Remember the name of the primary input file. */
4685 primary_filename = main_input_filename;
4687 /* Allocate the initial hunk of the pending_sibling_stack. */
4689 pending_sibling_stack
4691 xmalloc (PENDING_SIBLINGS_INCREMENT * sizeof (unsigned));
4692 pending_siblings_allocated = PENDING_SIBLINGS_INCREMENT;
4693 pending_siblings = 1;
4695 /* Allocate the initial hunk of the filename_table. */
4698 = (filename_entry *)
4699 xmalloc (FT_ENTRIES_INCREMENT * sizeof (filename_entry));
4700 ft_entries_allocated = FT_ENTRIES_INCREMENT;
4703 /* Allocate the initial hunk of the pending_types_list. */
4706 = (tree *) xmalloc (PENDING_TYPES_INCREMENT * sizeof (tree));
4707 pending_types_allocated = PENDING_TYPES_INCREMENT;
4710 /* Create an artificial RECORD_TYPE node which we can use in our hack
4711 to get the DIEs representing types of formal parameters to come out
4712 only *after* the DIEs for the formal parameters themselves. */
4714 fake_containing_scope = make_node (RECORD_TYPE);
4716 /* Output a starting label for the .text section. */
4718 fputc ('\n', asm_out_file);
4719 ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
4720 ASM_OUTPUT_LABEL (asm_out_file, TEXT_BEGIN_LABEL);
4721 ASM_OUTPUT_POP_SECTION (asm_out_file);
4723 /* Output a starting label for the .data section. */
4725 fputc ('\n', asm_out_file);
4726 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
4727 ASM_OUTPUT_LABEL (asm_out_file, DATA_BEGIN_LABEL);
4728 ASM_OUTPUT_POP_SECTION (asm_out_file);
4730 /* Output a starting label for the .data1 section. */
4732 fputc ('\n', asm_out_file);
4733 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
4734 ASM_OUTPUT_LABEL (asm_out_file, DATA1_BEGIN_LABEL);
4735 ASM_OUTPUT_POP_SECTION (asm_out_file);
4737 /* Output a starting label for the .rodata section. */
4739 fputc ('\n', asm_out_file);
4740 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
4741 ASM_OUTPUT_LABEL (asm_out_file, RODATA_BEGIN_LABEL);
4742 ASM_OUTPUT_POP_SECTION (asm_out_file);
4744 /* Output a starting label for the .rodata1 section. */
4746 fputc ('\n', asm_out_file);
4747 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
4748 ASM_OUTPUT_LABEL (asm_out_file, RODATA1_BEGIN_LABEL);
4749 ASM_OUTPUT_POP_SECTION (asm_out_file);
4751 /* Output a starting label for the .bss section. */
4753 fputc ('\n', asm_out_file);
4754 ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
4755 ASM_OUTPUT_LABEL (asm_out_file, BSS_BEGIN_LABEL);
4756 ASM_OUTPUT_POP_SECTION (asm_out_file);
4758 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4760 /* Output a starting label and an initial (compilation directory)
4761 entry for the .debug_sfnames section. The starting label will be
4762 referenced by the initial entry in the .debug_srcinfo section. */
4764 fputc ('\n', asm_out_file);
4765 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
4766 ASM_OUTPUT_LABEL (asm_out_file, SFNAMES_BEGIN_LABEL);
4768 register char *pwd = getpwd ();
4769 register unsigned len = strlen (pwd);
4770 register char *dirname = (char *) xmalloc (len + 2);
4772 strcpy (dirname, pwd);
4773 strcpy (dirname + len, "/");
4774 ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname);
4777 ASM_OUTPUT_POP_SECTION (asm_out_file);
4779 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
4781 /* Output a starting label for the .debug_macinfo section. This
4782 label will be referenced by the AT_mac_info attribute in the
4783 TAG_compile_unit DIE. */
4785 fputc ('\n', asm_out_file);
4786 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
4787 ASM_OUTPUT_LABEL (asm_out_file, MACINFO_BEGIN_LABEL);
4788 ASM_OUTPUT_POP_SECTION (asm_out_file);
4791 /* Generate the initial entry for the .line section. */
4793 fputc ('\n', asm_out_file);
4794 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
4795 ASM_OUTPUT_LABEL (asm_out_file, LINE_BEGIN_LABEL);
4796 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, LINE_END_LABEL, LINE_BEGIN_LABEL);
4797 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
4798 ASM_OUTPUT_POP_SECTION (asm_out_file);
4800 /* Generate the initial entry for the .debug_srcinfo section. */
4802 fputc ('\n', asm_out_file);
4803 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
4804 ASM_OUTPUT_LABEL (asm_out_file, SRCINFO_BEGIN_LABEL);
4805 ASM_OUTPUT_DWARF_ADDR (asm_out_file, LINE_BEGIN_LABEL);
4806 ASM_OUTPUT_DWARF_ADDR (asm_out_file, SFNAMES_BEGIN_LABEL);
4807 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
4808 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_END_LABEL);
4809 #ifdef DWARF_TIMESTAMPS
4810 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, time (NULL));
4812 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
4814 ASM_OUTPUT_POP_SECTION (asm_out_file);
4816 /* Generate the initial entry for the .debug_pubnames section. */
4818 fputc ('\n', asm_out_file);
4819 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
4820 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
4821 ASM_OUTPUT_POP_SECTION (asm_out_file);
4823 /* Generate the initial entry for the .debug_aranges section. */
4825 fputc ('\n', asm_out_file);
4826 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
4827 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
4828 ASM_OUTPUT_POP_SECTION (asm_out_file);
4831 /* Setup first DIE number == 1. */
4832 NEXT_DIE_NUM = next_unused_dienum++;
4834 /* Generate the initial DIE for the .debug section. Note that the
4835 (string) value given in the AT_name attribute of the TAG_compile_unit
4836 DIE will (typically) be a relative pathname and that this pathname
4837 should be taken as being relative to the directory from which the
4838 compiler was invoked when the given (base) source file was compiled. */
4840 fputc ('\n', asm_out_file);
4841 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
4842 ASM_OUTPUT_LABEL (asm_out_file, DEBUG_BEGIN_LABEL);
4843 output_die (output_compile_unit_die, main_input_filename);
4844 ASM_OUTPUT_POP_SECTION (asm_out_file);
4846 fputc ('\n', asm_out_file);
4849 /* Output stuff that dwarf requires at the end of every file. */
4854 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4856 fputc ('\n', asm_out_file);
4857 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
4859 /* Mark the end of the chain of siblings which represent all file-scope
4860 declarations in this compilation unit. */
4862 /* The (null) DIE which represents the terminator for the (sibling linked)
4863 list of file-scope items is *special*. Normally, we would just call
4864 end_sibling_chain at this point in order to output a word with the
4865 value `4' and that word would act as the terminator for the list of
4866 DIEs describing file-scope items. Unfortunately, if we were to simply
4867 do that, the label that would follow this DIE in the .debug section
4868 (i.e. `..D2') would *not* be properly aligned (as it must be on some
4869 machines) to a 4 byte boundary.
4871 In order to force the label `..D2' to get aligned to a 4 byte boundary,
4872 the trick used is to insert extra (otherwise useless) padding bytes
4873 into the (null) DIE that we know must precede the ..D2 label in the
4874 .debug section. The amount of padding required can be anywhere between
4875 0 and 3 bytes. The length word at the start of this DIE (i.e. the one
4876 with the padding) would normally contain the value 4, but now it will
4877 also have to include the padding bytes, so it will instead have some
4878 value in the range 4..7.
4880 Fortunately, the rules of Dwarf say that any DIE whose length word
4881 contains *any* value less than 8 should be treated as a null DIE, so
4882 this trick works out nicely. Clever, eh? Don't give me any credit
4883 (or blame). I didn't think of this scheme. I just conformed to it.
4886 output_die (output_padded_null_die, (void *)0);
4889 sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
4890 ASM_OUTPUT_LABEL (asm_out_file, label); /* should be ..D2 */
4891 ASM_OUTPUT_POP_SECTION (asm_out_file);
4893 /* Output a terminator label for the .text section. */
4895 fputc ('\n', asm_out_file);
4896 ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
4897 ASM_OUTPUT_LABEL (asm_out_file, TEXT_END_LABEL);
4898 ASM_OUTPUT_POP_SECTION (asm_out_file);
4900 /* Output a terminator label for the .data section. */
4902 fputc ('\n', asm_out_file);
4903 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
4904 ASM_OUTPUT_LABEL (asm_out_file, DATA_END_LABEL);
4905 ASM_OUTPUT_POP_SECTION (asm_out_file);
4907 /* Output a terminator label for the .data1 section. */
4909 fputc ('\n', asm_out_file);
4910 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
4911 ASM_OUTPUT_LABEL (asm_out_file, DATA1_END_LABEL);
4912 ASM_OUTPUT_POP_SECTION (asm_out_file);
4914 /* Output a terminator label for the .rodata section. */
4916 fputc ('\n', asm_out_file);
4917 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
4918 ASM_OUTPUT_LABEL (asm_out_file, RODATA_END_LABEL);
4919 ASM_OUTPUT_POP_SECTION (asm_out_file);
4921 /* Output a terminator label for the .rodata1 section. */
4923 fputc ('\n', asm_out_file);
4924 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
4925 ASM_OUTPUT_LABEL (asm_out_file, RODATA1_END_LABEL);
4926 ASM_OUTPUT_POP_SECTION (asm_out_file);
4928 /* Output a terminator label for the .bss section. */
4930 fputc ('\n', asm_out_file);
4931 ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
4932 ASM_OUTPUT_LABEL (asm_out_file, BSS_END_LABEL);
4933 ASM_OUTPUT_POP_SECTION (asm_out_file);
4935 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4937 /* Output a terminating entry for the .line section. */
4939 fputc ('\n', asm_out_file);
4940 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
4941 ASM_OUTPUT_LABEL (asm_out_file, LINE_LAST_ENTRY_LABEL);
4942 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
4943 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
4944 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
4945 ASM_OUTPUT_LABEL (asm_out_file, LINE_END_LABEL);
4946 ASM_OUTPUT_POP_SECTION (asm_out_file);
4948 /* Output a terminating entry for the .debug_srcinfo section. */
4950 fputc ('\n', asm_out_file);
4951 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
4952 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
4953 LINE_LAST_ENTRY_LABEL, LINE_BEGIN_LABEL);
4954 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
4955 ASM_OUTPUT_POP_SECTION (asm_out_file);
4957 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
4959 /* Output terminating entries for the .debug_macinfo section. */
4961 dwarfout_resume_previous_source_file (0);
4963 fputc ('\n', asm_out_file);
4964 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
4965 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
4966 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
4967 ASM_OUTPUT_POP_SECTION (asm_out_file);
4970 /* Generate the terminating entry for the .debug_pubnames section. */
4972 fputc ('\n', asm_out_file);
4973 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
4974 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
4975 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
4976 ASM_OUTPUT_POP_SECTION (asm_out_file);
4978 /* Generate the terminating entries for the .debug_aranges section.
4980 Note that we want to do this only *after* we have output the end
4981 labels (for the various program sections) which we are going to
4982 refer to here. This allows us to work around a bug in the m68k
4983 svr4 assembler. That assembler gives bogus assembly-time errors
4984 if (within any given section) you try to take the difference of
4985 two relocatable symbols, both of which are located within some
4986 other section, and if one (or both?) of the symbols involved is
4987 being forward-referenced. By generating the .debug_aranges
4988 entries at this late point in the assembly output, we skirt the
4989 issue simply by avoiding forward-references.
4992 fputc ('\n', asm_out_file);
4993 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
4995 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
4996 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
4998 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA_BEGIN_LABEL);
4999 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA_END_LABEL, DATA_BEGIN_LABEL);
5001 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA1_BEGIN_LABEL);
5002 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA1_END_LABEL,
5005 ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA_BEGIN_LABEL);
5006 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA_END_LABEL,
5007 RODATA_BEGIN_LABEL);
5009 ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA1_BEGIN_LABEL);
5010 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA1_END_LABEL,
5011 RODATA1_BEGIN_LABEL);
5013 ASM_OUTPUT_DWARF_ADDR (asm_out_file, BSS_BEGIN_LABEL);
5014 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, BSS_END_LABEL, BSS_BEGIN_LABEL);
5016 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5017 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5019 ASM_OUTPUT_POP_SECTION (asm_out_file);
5023 #endif /* DWARF_DEBUGGING_INFO */