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"
36 /* #define NDEBUG 1 */
39 #if defined(DWARF_TIMESTAMPS)
42 #else /* !defined(POSIX) */
43 #include <sys/types.h>
45 extern time_t time (time_t *);
46 #else /* !defined(__STDC__) */
47 extern time_t time ();
48 #endif /* !defined(__STDC__) */
49 #endif /* !defined(POSIX) */
50 #endif /* defined(DWARF_TIMESTAMPS) */
52 #if defined(USG) || defined(POSIX)
56 #define strrchr rindex
59 extern char *getpwd ();
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 DEF_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 might be 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 sparc/svr4 assmebler (which needs
394 to see .L at the start of a label in order to prevent that label from
395 going into the linker symbol table). When I get time, I'll have to
396 fix this the right way so that we use ASM_GENERATE_INTERNAL_LABEL and
397 ASM_OUTPUT_INTERNAL_LABEL throughout dwarfout.c, but that will require
398 a rather massive set of changes. For the moment, the following definitions
399 out to produce the right results for all svr4 and svr3 assemblers. -- rfg
402 #ifndef TEXT_BEGIN_LABEL
403 #define TEXT_BEGIN_LABEL ".L_text_b"
405 #ifndef TEXT_END_LABEL
406 #define TEXT_END_LABEL ".L_text_e"
409 #ifndef DATA_BEGIN_LABEL
410 #define DATA_BEGIN_LABEL ".L_data_b"
412 #ifndef DATA_END_LABEL
413 #define DATA_END_LABEL ".L_data_e"
416 #ifndef DATA1_BEGIN_LABEL
417 #define DATA1_BEGIN_LABEL ".L_data1_b"
419 #ifndef DATA1_END_LABEL
420 #define DATA1_END_LABEL ".L_data1_e"
423 #ifndef RODATA_BEGIN_LABEL
424 #define RODATA_BEGIN_LABEL ".L_rodata_b"
426 #ifndef RODATA_END_LABEL
427 #define RODATA_END_LABEL ".L_rodata_e"
430 #ifndef RODATA1_BEGIN_LABEL
431 #define RODATA1_BEGIN_LABEL ".L_rodata1_b"
433 #ifndef RODATA1_END_LABEL
434 #define RODATA1_END_LABEL ".L_rodata1_e"
437 #ifndef BSS_BEGIN_LABEL
438 #define BSS_BEGIN_LABEL ".L_bss_b"
440 #ifndef BSS_END_LABEL
441 #define BSS_END_LABEL ".L_bss_e"
444 #ifndef LINE_BEGIN_LABEL
445 #define LINE_BEGIN_LABEL ".L_line_b"
447 #ifndef LINE_LAST_ENTRY_LABEL
448 #define LINE_LAST_ENTRY_LABEL ".L_line_last"
450 #ifndef LINE_END_LABEL
451 #define LINE_END_LABEL ".L_line_e"
454 #ifndef DEBUG_BEGIN_LABEL
455 #define DEBUG_BEGIN_LABEL ".L_debug_b"
457 #ifndef SFNAMES_BEGIN_LABEL
458 #define SFNAMES_BEGIN_LABEL ".L_sfnames_b"
460 #ifndef SRCINFO_BEGIN_LABEL
461 #define SRCINFO_BEGIN_LABEL ".L_srcinfo_b"
463 #ifndef MACINFO_BEGIN_LABEL
464 #define MACINFO_BEGIN_LABEL ".L_macinfo_b"
467 #ifndef DIE_BEGIN_LABEL_FMT
468 #define DIE_BEGIN_LABEL_FMT ".L_D%u"
470 #ifndef DIE_END_LABEL_FMT
471 #define DIE_END_LABEL_FMT ".L_D%u_e"
473 #ifndef PUB_DIE_LABEL_FMT
474 #define PUB_DIE_LABEL_FMT ".L_P%u"
476 #ifndef INSN_LABEL_FMT
477 #define INSN_LABEL_FMT ".L_I%u_%u"
479 #ifndef BLOCK_BEGIN_LABEL_FMT
480 #define BLOCK_BEGIN_LABEL_FMT ".L_B%u"
482 #ifndef BLOCK_END_LABEL_FMT
483 #define BLOCK_END_LABEL_FMT ".L_B%u_e"
485 #ifndef SS_BEGIN_LABEL_FMT
486 #define SS_BEGIN_LABEL_FMT ".L_s%u"
488 #ifndef SS_END_LABEL_FMT
489 #define SS_END_LABEL_FMT ".L_s%u_e"
491 #ifndef EE_BEGIN_LABEL_FMT
492 #define EE_BEGIN_LABEL_FMT ".L_e%u"
494 #ifndef EE_END_LABEL_FMT
495 #define EE_END_LABEL_FMT ".L_e%u_e"
497 #ifndef MT_BEGIN_LABEL_FMT
498 #define MT_BEGIN_LABEL_FMT ".L_t%u"
500 #ifndef MT_END_LABEL_FMT
501 #define MT_END_LABEL_FMT ".L_t%u_e"
503 #ifndef LOC_BEGIN_LABEL_FMT
504 #define LOC_BEGIN_LABEL_FMT ".L_l%u"
506 #ifndef LOC_END_LABEL_FMT
507 #define LOC_END_LABEL_FMT ".L_l%u_e"
509 #ifndef BOUND_BEGIN_LABEL_FMT
510 #define BOUND_BEGIN_LABEL_FMT ".L_b%u_%u_%c"
512 #ifndef BOUND_END_LABEL_FMT
513 #define BOUND_END_LABEL_FMT ".L_b%u_%u_%c_e"
515 #ifndef DERIV_BEGIN_LABEL_FMT
516 #define DERIV_BEGIN_LABEL_FMT ".L_d%u"
518 #ifndef DERIV_END_LABEL_FMT
519 #define DERIV_END_LABEL_FMT ".L_d%u_e"
521 #ifndef SL_BEGIN_LABEL_FMT
522 #define SL_BEGIN_LABEL_FMT ".L_sl%u"
524 #ifndef SL_END_LABEL_FMT
525 #define SL_END_LABEL_FMT ".L_sl%u_e"
527 #ifndef FUNC_END_LABEL_FMT
528 #define FUNC_END_LABEL_FMT ".L_f%u_e"
530 #ifndef TYPE_NAME_FMT
531 #define TYPE_NAME_FMT ".L_T%u"
533 #ifndef LINE_CODE_LABEL_FMT
534 #define LINE_CODE_LABEL_FMT ".L_LC%u"
536 #ifndef SFNAMES_ENTRY_LABEL_FMT
537 #define SFNAMES_ENTRY_LABEL_FMT ".L_F%u"
539 #ifndef LINE_ENTRY_LABEL_FMT
540 #define LINE_ENTRY_LABEL_FMT ".L_LE%u"
543 /* Definitions of defaults for various types of primitive assembly language
546 If necessary, these may be overridden from within your tm.h file,
547 but typically, you shouldn't need to override these. Two known
548 exceptions are the ASM_OUTPUT_PUSH_SECTION and ASM_OUTPUT_POP_SECTION
549 definitions, which need to be somewhat special for a sparc running svr4.
552 #ifndef ASM_OUTPUT_PUSH_SECTION
553 #define ASM_OUTPUT_PUSH_SECTION(FILE, SECTION) \
554 fprintf ((FILE), PUSHSECTION_FORMAT, PUSHSECTION_ASM_OP, SECTION)
557 #ifndef ASM_OUTPUT_POP_SECTION
558 #define ASM_OUTPUT_POP_SECTION(FILE) \
559 fprintf ((FILE), "\t%s\n", POPSECTION_ASM_OP)
562 #ifndef ASM_OUTPUT_SOURCE_FILENAME
563 #define ASM_OUTPUT_SOURCE_FILENAME(FILE,NAME) \
564 fprintf ((FILE), "\t%s\t\"%s\"\n", FILE_ASM_OP, NAME)
567 #ifndef ASM_OUTPUT_DEF
568 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2) \
569 do { fprintf ((FILE), "\t%s\t", DEF_ASM_OP); \
570 assemble_name (FILE, LABEL1); \
571 fprintf (FILE, ","); \
572 assemble_name (FILE, LABEL2); \
573 fprintf (FILE, "\n"); \
577 #ifndef ASM_OUTPUT_DWARF_DELTA2
578 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
579 do { fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \
580 assemble_name (FILE, LABEL1); \
581 fprintf (FILE, "-"); \
582 assemble_name (FILE, LABEL2); \
583 fprintf (FILE, "\n"); \
587 #ifndef ASM_OUTPUT_DWARF_DELTA4
588 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
589 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
590 assemble_name (FILE, LABEL1); \
591 fprintf (FILE, "-"); \
592 assemble_name (FILE, LABEL2); \
593 fprintf (FILE, "\n"); \
597 #ifndef ASM_OUTPUT_DWARF_TAG
598 #define ASM_OUTPUT_DWARF_TAG(FILE,TAG) \
600 fprintf ((FILE), "\t%s\t0x%x", \
601 UNALIGNED_SHORT_ASM_OP, (unsigned) TAG); \
602 if (flag_verbose_asm) \
603 fprintf ((FILE), "\t%s %s", \
604 ASM_COMMENT_START, dwarf_tag_name (TAG)); \
605 fputc ('\n', (FILE)); \
609 #ifndef ASM_OUTPUT_DWARF_ATTRIBUTE
610 #define ASM_OUTPUT_DWARF_ATTRIBUTE(FILE,ATTR) \
612 fprintf ((FILE), "\t%s\t0x%x", \
613 UNALIGNED_SHORT_ASM_OP, (unsigned) ATTR); \
614 if (flag_verbose_asm) \
615 fprintf ((FILE), "\t%s %s", \
616 ASM_COMMENT_START, dwarf_attr_name (ATTR)); \
617 fputc ('\n', (FILE)); \
621 #ifndef ASM_OUTPUT_DWARF_STACK_OP
622 #define ASM_OUTPUT_DWARF_STACK_OP(FILE,OP) \
624 fprintf ((FILE), "%s\t0x%x", ASM_BYTE_OP, (unsigned) OP); \
625 if (flag_verbose_asm) \
626 fprintf ((FILE), "\t%s %s", \
627 ASM_COMMENT_START, dwarf_stack_op_name (OP)); \
628 fputc ('\n', (FILE)); \
632 #ifndef ASM_OUTPUT_DWARF_FUND_TYPE
633 #define ASM_OUTPUT_DWARF_FUND_TYPE(FILE,FT) \
635 fprintf ((FILE), "\t%s\t0x%x", \
636 UNALIGNED_SHORT_ASM_OP, (unsigned) FT); \
637 if (flag_verbose_asm) \
638 fprintf ((FILE), "\t%s %s", \
639 ASM_COMMENT_START, dwarf_fund_type_name (FT)); \
640 fputc ('\n', (FILE)); \
644 #ifndef ASM_OUTPUT_DWARF_FMT_BYTE
645 #define ASM_OUTPUT_DWARF_FMT_BYTE(FILE,FMT) \
647 fprintf ((FILE), "%s\t0x%x", ASM_BYTE_OP, (unsigned) FMT); \
648 if (flag_verbose_asm) \
649 fprintf ((FILE), "\t%s %s", \
650 ASM_COMMENT_START, dwarf_fmt_byte_name (FMT)); \
651 fputc ('\n', (FILE)); \
655 #ifndef ASM_OUTPUT_DWARF_TYPE_MODIFIER
656 #define ASM_OUTPUT_DWARF_TYPE_MODIFIER(FILE,MOD) \
658 fprintf ((FILE), "%s\t0x%x", ASM_BYTE_OP, (unsigned) MOD); \
659 if (flag_verbose_asm) \
660 fprintf ((FILE), "\t%s %s", \
661 ASM_COMMENT_START, dwarf_typemod_name (MOD)); \
662 fputc ('\n', (FILE)); \
666 #ifndef ASM_OUTPUT_DWARF_ADDR
667 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
668 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
669 assemble_name (FILE, LABEL); \
670 fprintf (FILE, "\n"); \
674 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
675 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX) \
676 fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
677 output_addr_const ((FILE), (RTX)); \
681 #ifndef ASM_OUTPUT_DWARF_REF
682 #define ASM_OUTPUT_DWARF_REF(FILE,LABEL) \
683 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
684 assemble_name (FILE, LABEL); \
685 fprintf (FILE, "\n"); \
689 #ifndef ASM_OUTPUT_DWARF_DATA1
690 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
691 fprintf ((FILE), "%s\t0x%x\n", ASM_BYTE_OP, VALUE)
694 #ifndef ASM_OUTPUT_DWARF_DATA2
695 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
696 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_SHORT_ASM_OP, (unsigned) VALUE)
699 #ifndef ASM_OUTPUT_DWARF_DATA4
700 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
701 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, (unsigned) VALUE)
704 #ifndef ASM_OUTPUT_DWARF_DATA8
705 #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \
707 if (WORDS_BIG_ENDIAN) \
709 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
710 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
714 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
715 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
720 #ifndef ASM_OUTPUT_DWARF_STRING
721 #define ASM_OUTPUT_DWARF_STRING(FILE,P) \
722 ASM_OUTPUT_ASCII ((FILE), P, strlen (P)+1)
725 /************************ general utility functions **************************/
731 register char *p
= (char *) xmalloc (strlen (s
) + 1);
739 register unsigned tag
;
743 case TAG_padding
: return "TAG_padding";
744 case TAG_array_type
: return "TAG_array_type";
745 case TAG_class_type
: return "TAG_class_type";
746 case TAG_entry_point
: return "TAG_entry_point";
747 case TAG_enumeration_type
: return "TAG_enumeration_type";
748 case TAG_formal_parameter
: return "TAG_formal_parameter";
749 case TAG_global_subroutine
: return "TAG_global_subroutine";
750 case TAG_global_variable
: return "TAG_global_variable";
751 case TAG_label
: return "TAG_label";
752 case TAG_lexical_block
: return "TAG_lexical_block";
753 case TAG_local_variable
: return "TAG_local_variable";
754 case TAG_member
: return "TAG_member";
755 case TAG_pointer_type
: return "TAG_pointer_type";
756 case TAG_reference_type
: return "TAG_reference_type";
757 case TAG_compile_unit
: return "TAG_compile_unit";
758 case TAG_string_type
: return "TAG_string_type";
759 case TAG_structure_type
: return "TAG_structure_type";
760 case TAG_subroutine
: return "TAG_subroutine";
761 case TAG_subroutine_type
: return "TAG_subroutine_type";
762 case TAG_typedef
: return "TAG_typedef";
763 case TAG_union_type
: return "TAG_union_type";
764 case TAG_unspecified_parameters
: return "TAG_unspecified_parameters";
765 case TAG_variant
: return "TAG_variant";
766 case TAG_common_block
: return "TAG_common_block";
767 case TAG_common_inclusion
: return "TAG_common_inclusion";
768 case TAG_inheritance
: return "TAG_inheritance";
769 case TAG_inlined_subroutine
: return "TAG_inlined_subroutine";
770 case TAG_module
: return "TAG_module";
771 case TAG_ptr_to_member_type
: return "TAG_ptr_to_member_type";
772 case TAG_set_type
: return "TAG_set_type";
773 case TAG_subrange_type
: return "TAG_subrange_type";
774 case TAG_with_stmt
: return "TAG_with_stmt";
776 /* GNU extensions. */
778 case TAG_format_label
: return "TAG_format_label";
779 case TAG_namelist
: return "TAG_namelist";
780 case TAG_function_template
: return "TAG_function_template";
781 case TAG_class_template
: return "TAG_class_template";
783 default: return "<unknown tag>";
788 dwarf_attr_name (attr
)
789 register unsigned attr
;
793 case AT_sibling
: return "AT_sibling";
794 case AT_location
: return "AT_location";
795 case AT_name
: return "AT_name";
796 case AT_fund_type
: return "AT_fund_type";
797 case AT_mod_fund_type
: return "AT_mod_fund_type";
798 case AT_user_def_type
: return "AT_user_def_type";
799 case AT_mod_u_d_type
: return "AT_mod_u_d_type";
800 case AT_ordering
: return "AT_ordering";
801 case AT_subscr_data
: return "AT_subscr_data";
802 case AT_byte_size
: return "AT_byte_size";
803 case AT_bit_offset
: return "AT_bit_offset";
804 case AT_bit_size
: return "AT_bit_size";
805 case AT_element_list
: return "AT_element_list";
806 case AT_stmt_list
: return "AT_stmt_list";
807 case AT_low_pc
: return "AT_low_pc";
808 case AT_high_pc
: return "AT_high_pc";
809 case AT_language
: return "AT_language";
810 case AT_member
: return "AT_member";
811 case AT_discr
: return "AT_discr";
812 case AT_discr_value
: return "AT_discr_value";
813 case AT_string_length
: return "AT_string_length";
814 case AT_common_reference
: return "AT_common_reference";
815 case AT_comp_dir
: return "AT_comp_dir";
816 case AT_const_value_string
: return "AT_const_value_string";
817 case AT_const_value_data2
: return "AT_const_value_data2";
818 case AT_const_value_data4
: return "AT_const_value_data4";
819 case AT_const_value_data8
: return "AT_const_value_data8";
820 case AT_const_value_block2
: return "AT_const_value_block2";
821 case AT_const_value_block4
: return "AT_const_value_block4";
822 case AT_containing_type
: return "AT_containing_type";
823 case AT_default_value_addr
: return "AT_default_value_addr";
824 case AT_default_value_data2
: return "AT_default_value_data2";
825 case AT_default_value_data4
: return "AT_default_value_data4";
826 case AT_default_value_data8
: return "AT_default_value_data8";
827 case AT_default_value_string
: return "AT_default_value_string";
828 case AT_friends
: return "AT_friends";
829 case AT_inline
: return "AT_inline";
830 case AT_is_optional
: return "AT_is_optional";
831 case AT_lower_bound_ref
: return "AT_lower_bound_ref";
832 case AT_lower_bound_data2
: return "AT_lower_bound_data2";
833 case AT_lower_bound_data4
: return "AT_lower_bound_data4";
834 case AT_lower_bound_data8
: return "AT_lower_bound_data8";
835 case AT_private
: return "AT_private";
836 case AT_producer
: return "AT_producer";
837 case AT_program
: return "AT_program";
838 case AT_protected
: return "AT_protected";
839 case AT_prototyped
: return "AT_prototyped";
840 case AT_public
: return "AT_public";
841 case AT_pure_virtual
: return "AT_pure_virtual";
842 case AT_return_addr
: return "AT_return_addr";
843 case AT_specification
: return "AT_specification";
844 case AT_start_scope
: return "AT_start_scope";
845 case AT_stride_size
: return "AT_stride_size";
846 case AT_upper_bound_ref
: return "AT_upper_bound_ref";
847 case AT_upper_bound_data2
: return "AT_upper_bound_data2";
848 case AT_upper_bound_data4
: return "AT_upper_bound_data4";
849 case AT_upper_bound_data8
: return "AT_upper_bound_data8";
850 case AT_virtual
: return "AT_virtual";
854 case AT_sf_names
: return "AT_sf_names";
855 case AT_src_info
: return "AT_src_info";
856 case AT_mac_info
: return "AT_mac_info";
857 case AT_src_coords
: return "AT_src_coords";
859 default: return "<unknown attribute>";
864 dwarf_stack_op_name (op
)
865 register unsigned op
;
869 case OP_REG
: return "OP_REG";
870 case OP_BASEREG
: return "OP_BASEREG";
871 case OP_ADDR
: return "OP_ADDR";
872 case OP_CONST
: return "OP_CONST";
873 case OP_DEREF2
: return "OP_DEREF2";
874 case OP_DEREF4
: return "OP_DEREF4";
875 case OP_ADD
: return "OP_ADD";
876 default: return "<unknown stack operator>";
881 dwarf_typemod_name (mod
)
882 register unsigned mod
;
886 case MOD_pointer_to
: return "MOD_pointer_to";
887 case MOD_reference_to
: return "MOD_reference_to";
888 case MOD_const
: return "MOD_const";
889 case MOD_volatile
: return "MOD_volatile";
890 default: return "<unknown modifier>";
895 dwarf_fmt_byte_name (fmt
)
896 register unsigned fmt
;
900 case FMT_FT_C_C
: return "FMT_FT_C_C";
901 case FMT_FT_C_X
: return "FMT_FT_C_X";
902 case FMT_FT_X_C
: return "FMT_FT_X_C";
903 case FMT_FT_X_X
: return "FMT_FT_X_X";
904 case FMT_UT_C_C
: return "FMT_UT_C_C";
905 case FMT_UT_C_X
: return "FMT_UT_C_X";
906 case FMT_UT_X_C
: return "FMT_UT_X_C";
907 case FMT_UT_X_X
: return "FMT_UT_X_X";
908 case FMT_ET
: return "FMT_ET";
909 default: return "<unknown array bound format byte>";
913 dwarf_fund_type_name (ft
)
914 register unsigned ft
;
918 case FT_char
: return "FT_char";
919 case FT_signed_char
: return "FT_signed_char";
920 case FT_unsigned_char
: return "FT_unsigned_char";
921 case FT_short
: return "FT_short";
922 case FT_signed_short
: return "FT_signed_short";
923 case FT_unsigned_short
: return "FT_unsigned_short";
924 case FT_integer
: return "FT_integer";
925 case FT_signed_integer
: return "FT_signed_integer";
926 case FT_unsigned_integer
: return "FT_unsigned_integer";
927 case FT_long
: return "FT_long";
928 case FT_signed_long
: return "FT_signed_long";
929 case FT_unsigned_long
: return "FT_unsigned_long";
930 case FT_pointer
: return "FT_pointer";
931 case FT_float
: return "FT_float";
932 case FT_dbl_prec_float
: return "FT_dbl_prec_float";
933 case FT_ext_prec_float
: return "FT_ext_prec_float";
934 case FT_complex
: return "FT_complex";
935 case FT_dbl_prec_complex
: return "FT_dbl_prec_complex";
936 case FT_void
: return "FT_void";
937 case FT_boolean
: return "FT_boolean";
938 case FT_ext_prec_complex
: return "FT_ext_prec_complex";
939 case FT_label
: return "FT_label";
941 /* GNU extensions. */
943 case FT_long_long
: return "FT_long_long";
944 case FT_signed_long_long
: return "FT_signed_long_long";
945 case FT_unsigned_long_long
: return "FT_unsigned_long_long";
947 case FT_int8
: return "FT_int8";
948 case FT_signed_int8
: return "FT_signed_int8";
949 case FT_unsigned_int8
: return "FT_unsigned_int8";
950 case FT_int16
: return "FT_int16";
951 case FT_signed_int16
: return "FT_signed_int16";
952 case FT_unsigned_int16
: return "FT_unsigned_int16";
953 case FT_int32
: return "FT_int32";
954 case FT_signed_int32
: return "FT_signed_int32";
955 case FT_unsigned_int32
: return "FT_unsigned_int32";
956 case FT_int64
: return "FT_int64";
957 case FT_signed_int64
: return "FT_signed_int64";
958 case FT_unsigned_int64
: return "FT_signed_int64";
960 case FT_real32
: return "FT_real32";
961 case FT_real64
: return "FT_real64";
962 case FT_real96
: return "FT_real96";
963 case FT_real128
: return "FT_real128";
965 default: return "<unknown fundamental type>";
969 /**************** utility functions for attribute functions ******************/
971 /* Given a pointer to a tree node for some type, return a Dwarf fundamental
972 type code for the given type.
974 This routine must only be called for GCC type nodes that correspond to
975 Dwarf fundamental types.
977 The current Dwarf draft specification calls for Dwarf fundamental types
978 to accurately reflect the fact that a given type was either a "plain"
979 integral type or an explicitly "signed" integral type. Unfortuantely,
980 we can't always do this, because GCC may already have thrown away the
981 information about the precise way in which the type was originally
984 typedef signed int field_type;
986 struct s { field_type f; };
988 Since we may be stuck here without enought information to do exactly
989 what is called for in the Dwarf draft specification, we do the best
990 that we can under the circumstances and always use the "plain" integral
991 fundamental type codes for int, short, and long types. That's probably
992 good enough. The additional accuracy called for in the current DWARF
993 draft specification is probably never even useful in practice. */
996 fundamental_type_code (type
)
999 if (TREE_CODE (type
) == ERROR_MARK
)
1002 switch (TREE_CODE (type
))
1011 /* Carefully distinguish all the standard types of C,
1012 without messing up if the language is not C.
1013 Note that we check only for the names that contain spaces;
1014 other names might occur by coincidence in other languages. */
1015 if (TYPE_NAME (type
) != 0
1016 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1017 && DECL_NAME (TYPE_NAME (type
)) != 0
1018 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
1020 char *name
= IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
1022 if (!strcmp (name
, "unsigned char"))
1023 return FT_unsigned_char
;
1024 if (!strcmp (name
, "signed char"))
1025 return FT_signed_char
;
1026 if (!strcmp (name
, "unsigned int"))
1027 return FT_unsigned_integer
;
1028 if (!strcmp (name
, "short int"))
1030 if (!strcmp (name
, "short unsigned int"))
1031 return FT_unsigned_short
;
1032 if (!strcmp (name
, "long int"))
1034 if (!strcmp (name
, "long unsigned int"))
1035 return FT_unsigned_long
;
1036 if (!strcmp (name
, "long long int"))
1037 return FT_long_long
; /* Not grok'ed by svr4 SDB */
1038 if (!strcmp (name
, "long long unsigned int"))
1039 return FT_unsigned_long_long
; /* Not grok'ed by svr4 SDB */
1042 /* Most integer types will be sorted out above, however, for the
1043 sake of special `array index' integer types, the following code
1044 is also provided. */
1046 if (TYPE_PRECISION (type
) == INT_TYPE_SIZE
)
1047 return (TREE_UNSIGNED (type
) ? FT_unsigned_integer
: FT_integer
);
1049 if (TYPE_PRECISION (type
) == LONG_TYPE_SIZE
)
1050 return (TREE_UNSIGNED (type
) ? FT_unsigned_long
: FT_long
);
1052 if (TYPE_PRECISION (type
) == LONG_LONG_TYPE_SIZE
)
1053 return (TREE_UNSIGNED (type
) ? FT_unsigned_long_long
: FT_long_long
);
1055 if (TYPE_PRECISION (type
) == SHORT_TYPE_SIZE
)
1056 return (TREE_UNSIGNED (type
) ? FT_unsigned_short
: FT_short
);
1058 if (TYPE_PRECISION (type
) == CHAR_TYPE_SIZE
)
1059 return (TREE_UNSIGNED (type
) ? FT_unsigned_char
: FT_char
);
1064 /* Carefully distinguish all the standard types of C,
1065 without messing up if the language is not C. */
1066 if (TYPE_NAME (type
) != 0
1067 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1068 && DECL_NAME (TYPE_NAME (type
)) != 0
1069 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
1071 char *name
= IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
1073 /* Note that here we can run afowl of a serious bug in "classic"
1074 svr4 SDB debuggers. They don't seem to understand the
1075 FT_ext_prec_float type (even though they should). */
1077 if (!strcmp (name
, "long double"))
1078 return FT_ext_prec_float
;
1081 if (TYPE_PRECISION (type
) == DOUBLE_TYPE_SIZE
)
1082 return FT_dbl_prec_float
;
1083 if (TYPE_PRECISION (type
) == FLOAT_TYPE_SIZE
)
1086 /* Note that here we can run afowl of a serious bug in "classic"
1087 svr4 SDB debuggers. They don't seem to understand the
1088 FT_ext_prec_float type (even though they should). */
1090 if (TYPE_PRECISION (type
) == LONG_DOUBLE_TYPE_SIZE
)
1091 return FT_ext_prec_float
;
1095 return FT_complex
; /* GNU FORTRAN COMPLEX type. */
1098 return FT_char
; /* GNU Pascal CHAR type. Not used in C. */
1101 return FT_boolean
; /* GNU FORTRAN BOOLEAN type. */
1104 abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
1109 /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
1110 the Dwarf "root" type for the given input type. The Dwarf "root" type
1111 of a given type is generally the same as the given type, except that if
1112 the given type is a pointer or reference type, then the root type of
1113 the given type is the root type of the "basis" type for the pointer or
1114 reference type. (This definition of the "root" type is recursive.)
1115 Also, the root type of a `const' qualified type or a `volatile'
1116 qualified type is the root type of the given type without the
1123 if (TREE_CODE (type
) == ERROR_MARK
)
1124 return error_mark_node
;
1126 switch (TREE_CODE (type
))
1129 return error_mark_node
;
1132 case REFERENCE_TYPE
:
1133 return TYPE_MAIN_VARIANT (root_type (TREE_TYPE (type
)));
1136 return TYPE_MAIN_VARIANT (type
);
1140 /* Given a pointer to an arbitrary ..._TYPE tree node, write out a sequence
1141 of zero or more Dwarf "type-modifier" bytes applicable to the type. */
1144 write_modifier_bytes (type
, decl_const
, decl_volatile
)
1146 register int decl_const
;
1147 register int decl_volatile
;
1149 if (TREE_CODE (type
) == ERROR_MARK
)
1152 if (TYPE_READONLY (type
) || decl_const
)
1153 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file
, MOD_const
);
1154 if (TYPE_VOLATILE (type
) || decl_volatile
)
1155 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file
, MOD_volatile
);
1156 switch (TREE_CODE (type
))
1159 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file
, MOD_pointer_to
);
1160 write_modifier_bytes (TREE_TYPE (type
), 0, 0);
1163 case REFERENCE_TYPE
:
1164 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file
, MOD_reference_to
);
1165 write_modifier_bytes (TREE_TYPE (type
), 0, 0);
1174 /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
1175 given input type is a Dwarf "fundamental" type. Otherwise return zero. */
1178 type_is_fundamental (type
)
1181 switch (TREE_CODE (type
))
1200 case REFERENCE_TYPE
:
1213 /* Given a pointer to some ..._TYPE tree node, generate an assembly language
1214 equate directive which will associate an easily remembered symbolic name
1215 with the current DIE.
1217 The name used is an artificial label generated from the TYPE_UID number
1218 associated with the given type node. The name it gets equated to is the
1219 symbolic label that we (previously) output at the start of the DIE that
1220 we are currently generating.
1222 Calling this function while generating some "type related" form of DIE
1223 makes it easy to later refer to the DIE which represents the given type
1224 simply by re-generating the alternative name from the ..._TYPE node's
1228 equate_type_number_to_die_number (type
)
1231 char type_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1232 char die_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1234 /* We are generating a DIE to represent the main variant of this type
1235 (i.e the type without any const or volatile qualifiers) so in order
1236 to get the equate to come out right, we need to get the main variant
1239 type
= TYPE_MAIN_VARIANT (type
);
1241 sprintf (type_label
, TYPE_NAME_FMT
, TYPE_UID (type
));
1242 sprintf (die_label
, DIE_BEGIN_LABEL_FMT
, current_dienum
);
1243 ASM_OUTPUT_DEF (asm_out_file
, type_label
, die_label
);
1246 /* The following routine is a nice and simple transducer. It converts the
1247 RTL for a variable or parameter (resident in memory) into an equivalent
1248 Dwarf representation of a mechanism for getting the address of that same
1249 variable onto the top of a hypothetical "address evaluation" stack.
1251 When creating memory location descriptors, we are effectively trans-
1252 forming the RTL for a memory-resident object into its Dwarf postfix
1253 expression equivalent. This routine just recursively descends an
1254 RTL tree, turning it into Dwarf postfix code as it goes. */
1257 output_mem_loc_descriptor (rtl
)
1260 /* Note that for a dynamically sized array, the location we will
1261 generate a description of here will be the lowest numbered location
1262 which is actually within the array. That's *not* necessarily the
1263 same as the zeroth element of the array. */
1265 switch (GET_CODE (rtl
))
1269 /* The case of a subreg may arise when we have a local (register)
1270 variable or a formal (register) parameter which doesn't quite
1271 fill up an entire register. For now, just assume that it is
1272 legitimate to make the Dwarf info refer to the whole register
1273 which contains the given subreg. */
1275 rtl
= XEXP (rtl
, 0);
1280 /* Whenever a register number forms a part of the description of
1281 the method for calculating the (dynamic) address of a memory
1282 resident object, Dwarf rules require the register number to
1283 be referred to as a "base register". This distinction is not
1284 based in any way upon what category of register the hardware
1285 believes the given register belongs to. This is strictly
1286 Dwarf terminology we're dealing with here. */
1288 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_BASEREG
);
1289 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
1290 DBX_REGISTER_NUMBER (REGNO (rtl
)));
1294 output_mem_loc_descriptor (XEXP (rtl
, 0));
1295 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_DEREF4
);
1300 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_ADDR
);
1301 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file
, rtl
);
1305 output_mem_loc_descriptor (XEXP (rtl
, 0));
1306 output_mem_loc_descriptor (XEXP (rtl
, 1));
1307 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_ADD
);
1311 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_CONST
);
1312 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, INTVAL (rtl
));
1320 /* Output a proper Dwarf location descriptor for a variable or parameter
1321 which is either allocated in a register or in a memory location. For
1322 a register, we just generate an OP_REG and the register number. For a
1323 memory location we provide a Dwarf postfix expression describing how to
1324 generate the (dynamic) address of the object onto the address stack. */
1327 output_loc_descriptor (rtl
)
1330 switch (GET_CODE (rtl
))
1334 /* The case of a subreg may arise when we have a local (register)
1335 variable or a formal (register) parameter which doesn't quite
1336 fill up an entire register. For now, just assume that it is
1337 legitimate to make the Dwarf info refer to the whole register
1338 which contains the given subreg. */
1340 rtl
= XEXP (rtl
, 0);
1344 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_REG
);
1345 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
1346 DBX_REGISTER_NUMBER (REGNO (rtl
)));
1350 output_mem_loc_descriptor (XEXP (rtl
, 0));
1354 abort (); /* Should never happen */
1358 /* Given a tree node describing an array bound (either lower or upper)
1359 output a representation for that bound. */
1362 output_bound_representation (bound
, dim_num
, u_or_l
)
1363 register tree bound
;
1364 register unsigned dim_num
; /* For multi-dimensional arrays. */
1365 register char u_or_l
; /* Designates upper or lower bound. */
1367 switch (TREE_CODE (bound
))
1373 /* All fixed-bounds are represented by INTEGER_CST nodes. */
1376 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
1377 (unsigned) TREE_INT_CST_LOW (bound
));
1380 /* Dynamic bounds may be represented by NOP_EXPR nodes containing
1384 bound
= TREE_OPERAND (bound
, 0);
1385 /* ... fall thru... */
1389 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1390 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1392 sprintf (begin_label
, BOUND_BEGIN_LABEL_FMT
,
1393 current_dienum
, dim_num
, u_or_l
);
1395 sprintf (end_label
, BOUND_END_LABEL_FMT
,
1396 current_dienum
, dim_num
, u_or_l
);
1398 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
1399 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
1401 /* If we are working on a bound for a dynamic dimension in C,
1402 the dynamic dimension in question had better have a static
1403 (zero) lower bound and a dynamic *upper* bound. */
1408 /* If optimization is turned on, the SAVE_EXPRs that describe
1409 how to access the upper bound values are essentially bogus.
1410 They only describe (at best) how to get at these values at
1411 the points in the generated code right after they have just
1412 been computed. Worse yet, in the typical case, the upper
1413 bound values will not even *be* computed in the optimized
1414 code, so these SAVE_EXPRs are entirely bogus.
1416 In order to compensate for this fact, we check here to see
1417 if optimization is enabled, and if so, we effectively create
1418 an empty location description for the (unknown and unknowable)
1421 This should not cause too much trouble for existing (stupid?)
1422 debuggers because they have to deal with empty upper bounds
1423 location descriptions anyway in order to be able to deal with
1424 incomplete array types.
1426 Of course an intelligent debugger (GDB?) should be able to
1427 comprehend that a missing upper bound specification in a
1428 array type used for a storage class `auto' local array variable
1429 indicates that the upper bound is both unknown (at compile-
1430 time) and unknowable (at run-time) due to optimization.
1434 output_loc_descriptor
1435 (eliminate_regs (SAVE_EXPR_RTL (bound
), 0, 0));
1437 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
1446 /* Recursive function to output a sequence of value/name pairs for
1447 enumeration constants in reversed order. This is called from
1448 enumeration_type_die. */
1451 output_enumeral_list (link
)
1456 output_enumeral_list (TREE_CHAIN (link
));
1457 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
1458 (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link
)));
1459 ASM_OUTPUT_DWARF_STRING (asm_out_file
,
1460 IDENTIFIER_POINTER (TREE_PURPOSE (link
)));
1464 /****************************** attributes *********************************/
1466 /* The following routines are responsible for writing out the various types
1467 of Dwarf attributes (and any following data bytes associated with them).
1468 These routines are listed in order based on the numerical codes of their
1469 associated attributes. */
1471 /* Generate an AT_sibling attribute. */
1474 sibling_attribute ()
1476 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1478 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_sibling
);
1479 sprintf (label
, DIE_BEGIN_LABEL_FMT
, NEXT_DIE_NUM
);
1480 ASM_OUTPUT_DWARF_REF (asm_out_file
, label
);
1483 /* Output the form of location attributes suitable for whole variables and
1484 whole parameters. Note that the location attributes for struct fields
1485 are generated by the routine `data_member_location_attribute' below. */
1488 location_attribute (rtl
)
1491 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1492 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1494 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_location
);
1495 sprintf (begin_label
, LOC_BEGIN_LABEL_FMT
, current_dienum
);
1496 sprintf (end_label
, LOC_END_LABEL_FMT
, current_dienum
);
1497 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
1498 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
1500 /* Handle a special case. If we are about to output a location descriptor
1501 for a variable or parameter which has been optimized out of existence,
1502 don't do that. Instead we output a zero-length location descriptor
1503 value as part of the location attribute. Note that we cannot simply
1504 suppress the entire location attribute, because the absence of a
1505 location attribute in certain kinds of DIEs is used to indicate some-
1506 thing entirely different... i.e. that the DIE represents an object
1507 declaration, but not a definition. So sayeth the PLSIG. */
1509 if (((GET_CODE (rtl
) != REG
) || (REGNO (rtl
) < FIRST_PSEUDO_REGISTER
))
1510 && ((GET_CODE (rtl
) != SUBREG
)
1511 || (REGNO (XEXP (rtl
, 0)) < FIRST_PSEUDO_REGISTER
)))
1512 output_loc_descriptor (eliminate_regs (rtl
, 0, 0));
1514 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
1517 /* Output the specialized form of location attribute used for data members
1520 In the special case of a FIELD_DECL node which represents a bit-field,
1521 the "offset" part of this special location descriptor must indicate the
1522 distance in bytes from the lowest-addressed byte of the containing
1523 struct or union type to the lowest-addressed byte of the "containing
1524 object" for the bit-field.
1526 For any given bit-field, the "containing object" is a hypothetical
1527 object (of some integral or enum type) within which the given bit-field
1528 lives. The type of this hypothetical "containing object" is always the
1529 same as the declared type of the individual bit-field itself.
1531 Note that it is the size (in bytes) of the hypothetical "containing
1532 object" which will be given in the AT_byte_size attribute for this
1533 bit-field. (See the `byte_size_attribute' function below.)
1538 data_member_location_attribute (decl
)
1541 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1542 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1543 register unsigned containing_object_size_in_bytes
;
1544 register unsigned containing_object_size_in_bits
;
1545 register unsigned member_offset_in_objects
;
1546 register unsigned member_offset_in_bytes
;
1548 register tree bitpos
= DECL_FIELD_BITPOS (decl
);
1550 if (TREE_CODE (decl
) == ERROR_MARK
)
1553 if (TREE_CODE (decl
) != FIELD_DECL
)
1556 /* The bit position given by DECL_FIELD_BITPOS could be non-constant
1557 in the case where one or more variable sized members preceeded this
1558 member in the containing struct type. We could probably correctly
1559 handle this case someday, by it's too complicated to deal with at
1560 the moment (and probably too rare to worry about), so just punt on
1561 the whole AT_location attribute for now. Eventually, we'll have
1562 to analyze the expression given as the DECL_FIELD_BITPOS and turn
1563 it into a member-style AT_location descriptor, but that'll be
1564 tough to do. -- rfg */
1566 if (TREE_CODE (bitpos
) != INTEGER_CST
)
1569 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_location
);
1570 sprintf (begin_label
, LOC_BEGIN_LABEL_FMT
, current_dienum
);
1571 sprintf (end_label
, LOC_END_LABEL_FMT
, current_dienum
);
1572 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
1573 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
1574 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_CONST
);
1576 type
= DECL_BIT_FIELD_TYPE (decl
);
1578 type
= TREE_TYPE (decl
);
1580 containing_object_size_in_bytes
= int_size_in_bytes (type
);
1581 containing_object_size_in_bits
1582 = containing_object_size_in_bytes
* BITS_PER_UNIT
;
1584 /* WARNING! Note that the GCC front-end doesn't make any attempt to
1585 keep track of the starting bit offset (relative to the start of
1586 the containing structure type) of the hypothetical "containing
1587 object" for a bit-field. (See the comments at the start of this
1588 function.) Thus, when computing the byte offset value for a
1589 bit-field, all we can do is to divide the starting bit offset of
1590 the bit-field by the size of the hypothetical "containing object"
1591 (which we can easily find).
1593 This solution only works right as long as the alignment used by the
1594 compiler for the declared type of the bit-field is the same as the
1597 Since GCC allows type `long long' to be the declared type for a
1598 bit-field, and since some target configurations only align
1599 `long longs' to 4-byte boundaries, we have to check here to see
1600 that the alignment of the containing object is the same as the
1601 size of that object. If it isn't, and if the field in question
1602 is a bit-field, then we may be about to generate bogus Dwarf
1603 output, so we need to warn the user about that.
1605 Of course it would be nice to actually solve this problem, but
1606 that would require a lot of changes elsewhere in the compiler
1607 which could be quite painful, so for now we'll just live with
1608 this minor annoyance.
1611 if ((GET_MODE_ALIGNMENT (TYPE_MODE (type
)) != containing_object_size_in_bits
)
1612 && (DECL_BIT_FIELD_TYPE (type
) != NULL
))
1613 warning_with_decl (decl
, "debugging info won't necessarily be reliable");
1615 member_offset_in_objects
1616 = (unsigned) TREE_INT_CST_LOW (bitpos
) / containing_object_size_in_bits
;
1617 member_offset_in_bytes
1618 = member_offset_in_objects
* containing_object_size_in_bytes
;
1620 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, member_offset_in_bytes
);
1621 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_ADD
);
1622 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
1625 /* Output an AT_const_value attribute for a variable or a parameter which
1626 does not have a "location" either in memory or in a register. These
1627 things can arise in GNU C when a constant is passed as an actual
1628 parameter to an inlined function. They can also arise in C++ where
1629 declared constants do not necessarily get memory "homes". */
1632 const_value_attribute (rtl
)
1635 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1636 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1638 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_const_value_block4
);
1639 sprintf (begin_label
, LOC_BEGIN_LABEL_FMT
, current_dienum
);
1640 sprintf (end_label
, LOC_END_LABEL_FMT
, current_dienum
);
1641 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, end_label
, begin_label
);
1642 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
1644 switch (GET_CODE (rtl
))
1647 /* Note that a CONST_INT rtx could represent either an integer or
1648 a floating-point constant. A CONST_INT is used whenever the
1649 constant will fit into a single word. In all such cases, the
1650 original mode of the constant value is wiped out, and the
1651 CONST_INT rtx is assigned VOIDmode. Since we no longer have
1652 precise mode information for these constants, we always just
1653 output them using 4 bytes. */
1655 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, (unsigned) INTVAL (rtl
));
1659 /* Note that a CONST_DOUBLE rtx could represent either an integer
1660 or a floating-point constant. A CONST_DOUBLE is used whenever
1661 the constant requires more than one word in order to be adequately
1662 represented. In all such cases, the original mode of the constant
1663 value is preserved as the mode of the CONST_DOUBLE rtx, but for
1664 simplicity we always just output CONST_DOUBLEs using 8 bytes. */
1666 ASM_OUTPUT_DWARF_DATA8 (asm_out_file
,
1667 (unsigned) CONST_DOUBLE_HIGH (rtl
),
1668 (unsigned) CONST_DOUBLE_LOW (rtl
));
1672 ASM_OUTPUT_DWARF_STRING (asm_out_file
, XSTR (rtl
, 0));
1678 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file
, rtl
);
1682 /* In cases where an inlined instance of an inline function is passed
1683 the address of an `auto' variable (which is local to the caller)
1684 we can get a situation where the DECL_RTL of the artificial
1685 local variable (for the inlining) which acts as a stand-in for
1686 the corresponding formal parameter (of the inline function)
1687 will look like (plus:SI (reg:SI FRAME_PTR) (const_int ...)).
1688 This is not exactly a compile-time constant expression, but it
1689 isn't the address of the (artificial) local variable either.
1690 Rather, it represents the *value* which the artificial local
1691 variable always has during its lifetime. We currently have no
1692 way to represent such quasi-constant values in Dwarf, so for now
1693 we just punt and generate an AT_const_value attribute with form
1694 FORM_BLOCK4 and a length of zero. */
1698 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
1701 /* Generate *either* an AT_location attribute or else an AT_const_value
1702 data attribute for a variable or a parameter. We generate the
1703 AT_const_value attribute only in those cases where the given
1704 variable or parameter does not have a true "location" either in
1705 memory or in a register. This can happen (for example) when a
1706 constant is passed as an actual argument in a call to an inline
1707 function. (It's possible that these things can crop up in other
1708 ways also.) Note that one type of constant value which can be
1709 passed into an inlined function is a constant pointer. This can
1710 happen for example if an actual argument in an inlined function
1711 call evaluates to a compile-time constant address. */
1714 location_or_const_value_attribute (decl
)
1719 if (TREE_CODE (decl
) == ERROR_MARK
)
1722 if ((TREE_CODE (decl
) != VAR_DECL
) && (TREE_CODE (decl
) != PARM_DECL
))
1725 /* Existing Dwarf debuggers need and expect the location descriptors for
1726 formal parameters to reflect the place where the parameter are passed,
1727 as opposed to the places where they might reside during the execution
1728 of the function. This isn't clearly spelled out in the current Dwarf
1729 version 1 specification, but it's obvious if you look at the output of
1730 the CI5 compiler, or if you try to use the svr4 SDB debugger. Hopefully,
1731 a later version of the Dwarf specification will clarify this. For now,
1732 we just need to generate the right thing. Note that Dwarf version 2
1733 will provide us with a means to describe *all* of the locations in which
1734 a given variable or parameter resides (and the PC ranges over which it
1735 occupies each one), but for now we can only describe the "passing"
1738 rtl
= (TREE_CODE (decl
) == PARM_DECL
)
1739 ? DECL_INCOMING_RTL (decl
)
1745 switch (GET_CODE (rtl
))
1753 case PLUS
: /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
1754 const_value_attribute (rtl
);
1760 location_attribute (rtl
);
1764 abort (); /* Should never happen. */
1768 /* Generate an AT_name attribute given some string value to be included as
1769 the value of the attribute. */
1772 name_attribute (name_string
)
1773 register char *name_string
;
1775 if (name_string
&& *name_string
)
1777 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_name
);
1778 ASM_OUTPUT_DWARF_STRING (asm_out_file
, name_string
);
1783 fund_type_attribute (ft_code
)
1784 register unsigned ft_code
;
1786 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_fund_type
);
1787 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file
, ft_code
);
1791 mod_fund_type_attribute (type
, decl_const
, decl_volatile
)
1793 register int decl_const
;
1794 register int decl_volatile
;
1796 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1797 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1799 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_mod_fund_type
);
1800 sprintf (begin_label
, MT_BEGIN_LABEL_FMT
, current_dienum
);
1801 sprintf (end_label
, MT_END_LABEL_FMT
, current_dienum
);
1802 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
1803 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
1804 write_modifier_bytes (type
, decl_const
, decl_volatile
);
1805 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file
,
1806 fundamental_type_code (root_type (type
)));
1807 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
1811 user_def_type_attribute (type
)
1814 char ud_type_name
[MAX_ARTIFICIAL_LABEL_BYTES
];
1816 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_user_def_type
);
1817 sprintf (ud_type_name
, TYPE_NAME_FMT
, TYPE_UID (type
));
1818 ASM_OUTPUT_DWARF_REF (asm_out_file
, ud_type_name
);
1822 mod_u_d_type_attribute (type
, decl_const
, decl_volatile
)
1824 register int decl_const
;
1825 register int decl_volatile
;
1827 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1828 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1829 char ud_type_name
[MAX_ARTIFICIAL_LABEL_BYTES
];
1831 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_mod_u_d_type
);
1832 sprintf (begin_label
, MT_BEGIN_LABEL_FMT
, current_dienum
);
1833 sprintf (end_label
, MT_END_LABEL_FMT
, current_dienum
);
1834 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
1835 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
1836 write_modifier_bytes (type
, decl_const
, decl_volatile
);
1837 sprintf (ud_type_name
, TYPE_NAME_FMT
, TYPE_UID (root_type (type
)));
1838 ASM_OUTPUT_DWARF_REF (asm_out_file
, ud_type_name
);
1839 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
1843 ordering_attribute (ordering
)
1844 register unsigned ordering
;
1846 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_ordering
);
1847 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, ordering
);
1850 /* Note that the block of subscript information for an array type also
1851 includes information about the element type of type given array type. */
1854 subscript_data_attribute (type
)
1857 register unsigned dimension_number
;
1858 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1859 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1861 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_subscr_data
);
1862 sprintf (begin_label
, SS_BEGIN_LABEL_FMT
, current_dienum
);
1863 sprintf (end_label
, SS_END_LABEL_FMT
, current_dienum
);
1864 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
1865 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
1867 /* The GNU compilers represent multidimensional array types as sequences
1868 of one dimensional array types whose element types are themselves array
1869 types. Here we squish that down, so that each multidimensional array
1870 type gets only one array_type DIE in the Dwarf debugging info. The
1871 draft Dwarf specification say that we are allowed to do this kind
1872 of compression in C (because there is no difference between an
1873 array or arrays and a multidimensional array in C) but for other
1874 source languages (e.g. Ada) we probably shouldn't do this. */
1876 for (dimension_number
= 0;
1877 TREE_CODE (type
) == ARRAY_TYPE
;
1878 type
= TREE_TYPE (type
), dimension_number
++)
1880 register tree domain
= TYPE_DOMAIN (type
);
1882 /* Arrays come in three flavors. Unspecified bounds, fixed
1883 bounds, and (in GNU C only) variable bounds. Handle all
1884 three forms here. */
1888 /* We have an array type with specified bounds. */
1890 register tree lower
= TYPE_MIN_VALUE (domain
);
1891 register tree upper
= TYPE_MAX_VALUE (domain
);
1893 /* Handle only fundamental types as index types for now. */
1895 if (! type_is_fundamental (domain
))
1898 /* Output the representation format byte for this dimension. */
1900 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file
,
1902 TREE_CODE (lower
) == INTEGER_CST
,
1903 TREE_CODE (upper
) == INTEGER_CST
));
1905 /* Output the index type for this dimension. */
1907 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file
,
1908 fundamental_type_code (domain
));
1910 /* Output the representation for the lower bound. */
1912 output_bound_representation (lower
, dimension_number
, 'l');
1914 /* Output the representation for the upper bound. */
1916 output_bound_representation (upper
, dimension_number
, 'u');
1920 /* We have an array type with an unspecified length. For C and
1921 C++ we can assume that this really means that (a) the index
1922 type is an integral type, and (b) the lower bound is zero.
1923 Note that Dwarf defines the representation of an unspecified
1924 (upper) bound as being a zero-length location description. */
1926 /* Output the array-bounds format byte. */
1928 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file
, FMT_FT_C_X
);
1930 /* Output the (assumed) index type. */
1932 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file
, FT_integer
);
1934 /* Output the (assumed) lower bound (constant) value. */
1936 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
1938 /* Output the (empty) location description for the upper bound. */
1940 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, 0);
1944 /* Output the prefix byte that says that the element type is comming up. */
1946 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file
, FMT_ET
);
1948 /* Output a representation of the type of the elements of this array type. */
1950 type_attribute (type
, 0, 0);
1952 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
1956 byte_size_attribute (tree_node
)
1957 register tree tree_node
;
1959 register unsigned size
;
1961 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_byte_size
);
1962 switch (TREE_CODE (tree_node
))
1971 size
= int_size_in_bytes (tree_node
);
1975 /* For a data member of a struct or union, the AT_byte_size is
1976 always given as the number of bytes normally allocated for
1977 an object of the *declared* type of the member itself. This
1978 is true even for bit-fields. */
1979 size
= int_size_in_bytes (DECL_BIT_FIELD_TYPE (tree_node
)
1980 ? DECL_BIT_FIELD_TYPE (tree_node
)
1981 : TREE_TYPE (tree_node
));
1988 /* Note that `size' might be -1 when we get to this point. If it
1989 is, that indicates that the byte size of the entity in question
1990 is variable. We have no good way of expressing this fact in Dwarf
1991 at the present time, so just let the -1 pass on through. */
1993 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, size
);
1996 /* For a FIELD_DECL node which represents a bit-field, output an attribute
1997 which specifies the distance in bits from the highest order bit of the
1998 "containing object" for the bit-field to the highest order bit of the
2001 For any given bit-field, the "containing object" is a hypothetical
2002 object (of some integral or enum type) within which the given bit-field
2003 lives. The type of this hypothetical "containing object" is always the
2004 same as the declared type of the individual bit-field itself.
2006 Note that it is the size (in bytes) of the hypothetical "containing
2007 object" which will be given in the AT_byte_size attribute for this
2008 bit-field. (See `byte_size_attribute' above.)
2012 bit_offset_attribute (decl
)
2015 register tree type
= DECL_BIT_FIELD_TYPE (decl
);
2016 register unsigned containing_object_size_in_bits
;
2017 register unsigned dwarf_bit_offset
;
2018 register tree bitpos_tree
= DECL_FIELD_BITPOS (decl
);
2019 register unsigned bitpos
;
2021 assert (TREE_CODE (decl
) == FIELD_DECL
); /* Must be a field. */
2022 assert (type
); /* Must be a bit field. */
2024 /* The bit position given by DECL_FIELD_BITPOS could be non-constant
2025 in the case where one or more variable sized members preceeded this
2026 member in the containing struct type. We could probably correctly
2027 handle this case someday, by it's too complicated to deal with at
2028 the moment, so just punt on the whole AT_bit_offset attribute for
2029 now. Eventually, we'll have to analyze the (variable) expression
2030 given as the DECL_FIELD_BITPOS and see if we can factor out just
2031 the (constant) bit offset part of that expression. -- rfg */
2033 if (TREE_CODE (bitpos_tree
) != CONST_INT
)
2036 containing_object_size_in_bits
= int_size_in_bytes (type
) * BITS_PER_UNIT
;
2038 /* WARNING! Note that the GCC front-end doesn't make any attempt to
2039 keep track of the starting bit offset (relative to the start of
2040 the containing structure type) of the hypothetical "containing
2041 object" for a bit-field. (See the comments at the start of this
2042 function.) Thus, when computing the AT_bit_offset value for a
2043 bit-field, all we can do is to divide the starting bit offset of
2044 the bit-field by the size of the hypothetical "containing object"
2045 (which we can easily find) and then get the remainder.
2047 This solution only works right as long as the alignment used by the
2048 compiler for the declared type of the bit-field is the same as the
2051 Since GCC allows type `long long' to be the declared type for a
2052 bit-field, and since some target configurations only align
2053 `long longs' to 4-byte boundaries, we really should check here
2054 to see that the alignment of the containing object is the same
2055 as the size of that object and issue a warning if it isn't but
2056 since we will also be generating an AT_location attribute for
2057 the bit-field, and sinec it will generat a warning for this
2058 condition we do not need to do it again here. That would just
2059 cause the user to see two redundant warnings for the same single
2060 bit-field declaration.
2062 Of course it would be nice to actually solve this problem, but
2063 that would require a lot of changes elsewhere in the compiler
2064 which could be quite painful, so for now we'll just live with
2065 this minor annoyance.
2069 if (GET_MODE_ALIGNMENT (TYPE_MODE (type
)) != containing_object_size_in_bits
)
2070 warning_with_decl (decl
, "debugging info won't necessarily be reliable");
2073 bitpos
= (unsigned) TREE_INT_CST_LOW (bitpos_tree
);
2075 #if (BYTES_BIG_ENDIAN == 1)
2077 register unsigned high_order_bitpos
= bitpos
;
2079 dwarf_bit_offset
= high_order_bitpos
% containing_object_size_in_bits
;
2083 register unsigned low_order_bitpos
= bitpos
;
2084 register unsigned field_width
2085 = (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl
));
2086 register unsigned high_order_bitpos
= low_order_bitpos
+ field_width
;
2088 dwarf_bit_offset
= containing_object_size_in_bits
2089 - (high_order_bitpos
% containing_object_size_in_bits
);
2093 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_bit_offset
);
2094 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, dwarf_bit_offset
);
2097 /* For a FIELD_DECL node which represents a bit field, output an attribute
2098 which specifies the length in bits of the given field. */
2101 bit_size_attribute (decl
)
2104 assert (TREE_CODE (decl
) == FIELD_DECL
); /* Must be a field. */
2105 assert (DECL_BIT_FIELD_TYPE (decl
)); /* Must be a bit field. */
2107 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_bit_size
);
2108 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
2109 (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl
)));
2112 /* The following routine outputs the `element_list' attribute for enumeration
2113 type DIEs. The element_lits attribute includes the names and values of
2114 all of the enumeration constants associated with the given enumeration
2118 element_list_attribute (element
)
2119 register tree element
;
2121 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2122 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2124 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_element_list
);
2125 sprintf (begin_label
, EE_BEGIN_LABEL_FMT
, current_dienum
);
2126 sprintf (end_label
, EE_END_LABEL_FMT
, current_dienum
);
2127 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, end_label
, begin_label
);
2128 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2130 /* Here we output a list of value/name pairs for each enumeration constant
2131 defined for this enumeration type (as required), but we do it in REVERSE
2132 order. The order is the one required by the draft #5 Dwarf specification
2133 published by the UI/PLSIG. */
2135 output_enumeral_list (element
); /* Recursively output the whole list. */
2137 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2140 /* Generate an AT_stmt_list attribute. These are normally present only in
2141 DIEs with a TAG_compile_unit tag. */
2144 stmt_list_attribute (label
)
2145 register char *label
;
2147 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_stmt_list
);
2148 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2149 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, label
);
2152 /* Generate an AT_low_pc attribute for a label DIE, a lexical_block DIE or
2153 for a subroutine DIE. */
2156 low_pc_attribute (asm_low_label
)
2157 register char *asm_low_label
;
2159 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_low_pc
);
2160 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, asm_low_label
);
2163 /* Generate an AT_high_pc attribute for a lexical_block DIE or for a
2167 high_pc_attribute (asm_high_label
)
2168 register char *asm_high_label
;
2170 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_high_pc
);
2171 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, asm_high_label
);
2174 /* Generate an AT_language attribute given a LANG value. These attributes
2175 are used only within TAG_compile_unit DIEs. */
2178 language_attribute (language_code
)
2179 register unsigned language_code
;
2181 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_language
);
2182 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, language_code
);
2186 member_attribute (context
)
2187 register tree context
;
2189 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2191 /* Generate this attribute only for members in C++. */
2194 && (TREE_CODE (context
) == RECORD_TYPE
2195 || TREE_CODE (context
) == UNION_TYPE
))
2197 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_member
);
2198 sprintf (label
, TYPE_NAME_FMT
, TYPE_UID (context
));
2199 ASM_OUTPUT_DWARF_REF (asm_out_file
, label
);
2204 string_length_attribute (upper_bound
)
2205 register tree upper_bound
;
2207 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2208 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2210 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_string_length
);
2211 sprintf (begin_label
, SL_BEGIN_LABEL_FMT
, current_dienum
);
2212 sprintf (end_label
, SL_END_LABEL_FMT
, current_dienum
);
2213 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
2214 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2215 output_bound_representation (upper_bound
, 0, 'u');
2216 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2220 comp_dir_attribute (dirname
)
2221 register char *dirname
;
2223 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_comp_dir
);
2224 ASM_OUTPUT_DWARF_STRING (asm_out_file
, dirname
);
2228 sf_names_attribute (sf_names_start_label
)
2229 register char *sf_names_start_label
;
2231 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_sf_names
);
2232 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2233 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, sf_names_start_label
);
2237 src_info_attribute (src_info_start_label
)
2238 register char *src_info_start_label
;
2240 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_src_info
);
2241 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2242 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, src_info_start_label
);
2246 mac_info_attribute (mac_info_start_label
)
2247 register char *mac_info_start_label
;
2249 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_mac_info
);
2250 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2251 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, mac_info_start_label
);
2255 prototyped_attribute (func_type
)
2256 register tree func_type
;
2258 if ((strcmp (language_string
, "GNU C") == 0)
2259 && (TYPE_ARG_TYPES (func_type
) != NULL
))
2261 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_prototyped
);
2262 ASM_OUTPUT_DWARF_STRING (asm_out_file
, "");
2267 producer_attribute (producer
)
2268 register char *producer
;
2270 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_producer
);
2271 ASM_OUTPUT_DWARF_STRING (asm_out_file
, producer
);
2275 inline_attribute (decl
)
2278 if (TREE_INLINE (decl
))
2280 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_inline
);
2281 ASM_OUTPUT_DWARF_STRING (asm_out_file
, "");
2286 containing_type_attribute (containing_type
)
2287 register tree containing_type
;
2289 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2291 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_containing_type
);
2292 sprintf (label
, TYPE_NAME_FMT
, TYPE_UID (containing_type
));
2293 ASM_OUTPUT_DWARF_REF (asm_out_file
, label
);
2297 src_coords_attribute (src_fileno
, src_lineno
)
2298 register unsigned src_fileno
;
2299 register unsigned src_lineno
;
2301 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_src_coords
);
2302 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, src_fileno
);
2303 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, src_lineno
);
2306 /************************* end of attributes *****************************/
2308 /********************* utility routines for DIEs *************************/
2310 /* Output an AT_name attribute and an AT_src_coords attribute for the
2311 given decl, but only if it actually has a name. */
2314 name_and_src_coords_attributes (decl
)
2317 register tree decl_name
= DECL_NAME (decl
);
2319 if (decl_name
&& IDENTIFIER_POINTER (decl_name
))
2321 name_attribute (IDENTIFIER_POINTER (decl_name
));
2322 #ifdef DWARF_DECL_COORDINATES
2324 register unsigned file_index
;
2326 /* This is annoying, but we have to pop out of the .debug section
2327 for a moment while we call `lookup_filename' because calling it
2328 may cause a temporary switch into the .debug_sfnames section and
2329 most svr4 assemblers are not smart enough be be able to nest
2330 section switches to any depth greater than one. Note that we
2331 also can't skirt this issue by delaying all output to the
2332 .debug_sfnames section unit the end of compilation because that
2333 would cause us to have inter-section forward references and
2334 Fred Fish sez that m68k/svr4 assemblers botch those. */
2336 ASM_OUTPUT_POP_SECTION (asm_out_file
);
2337 file_index
= lookup_filename (DECL_SOURCE_FILE (decl
));
2338 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DEBUG_SECTION
);
2340 src_coords_attribute (file_index
, DECL_SOURCE_LINE (decl
));
2346 /* Many forms of DIEs contain a "type description" part. The following
2347 routine writes out these "type descriptor" parts. */
2350 type_attribute (type
, decl_const
, decl_volatile
)
2352 register int decl_const
;
2353 register int decl_volatile
;
2355 register enum tree_code code
= TREE_CODE (type
);
2356 register int root_type_modified
;
2358 if (TREE_CODE (type
) == ERROR_MARK
)
2361 /* Handle a special case. For functions whose return type is void,
2362 we generate *no* type attribute. (Note that no object may have
2363 type `void', so this only applies to function return types. */
2365 if (TREE_CODE (type
) == VOID_TYPE
)
2368 root_type_modified
= (code
== POINTER_TYPE
|| code
== REFERENCE_TYPE
2369 || decl_const
|| decl_volatile
2370 || TYPE_READONLY (type
) || TYPE_VOLATILE (type
));
2372 if (type_is_fundamental (root_type (type
)))
2373 if (root_type_modified
)
2374 mod_fund_type_attribute (type
, decl_const
, decl_volatile
);
2376 fund_type_attribute (fundamental_type_code (type
));
2378 if (root_type_modified
)
2379 mod_u_d_type_attribute (type
, decl_const
, decl_volatile
);
2381 user_def_type_attribute (type
);
2384 /* Given a tree pointer to a struct, class, union, or enum type node, return
2385 a pointer to the (string) tag name for the given type, or zero if the
2386 type was declared without a tag. */
2392 register char *name
= 0;
2394 if (TYPE_NAME (type
) != 0)
2396 register tree t
= 0;
2398 /* Find the IDENTIFIER_NODE for the type name. */
2399 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
2400 t
= TYPE_NAME (type
);
2402 /* The g++ front end makes the TYPE_NAME of *each* tagged type point
2403 to a TYPE_DECL node, regardless of whether or not a `typedef' was
2404 involved. This is distinctly different from what the gcc front-end
2405 does. It always makes the TYPE_NAME for each tagged type be either
2406 NULL (signifying an anonymous tagged type) or else a pointer to an
2407 IDENTIFIER_NODE. Obviously, we would like to generate correct Dwarf
2408 for both C and C++, but given this inconsistency in the TREE
2409 representation of tagged types for C and C++ in the GNU front-ends,
2410 we cannot support both languages correctly unless we introduce some
2411 front-end specific code here, and rms objects to that, so we can
2412 only generate correct Dwarf for one of these two languages. C is
2413 more important, so for now we'll do the right thing for C and let
2417 if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
2418 t
= DECL_NAME (TYPE_NAME (type
));
2420 /* Now get the name as a string, or invent one. */
2422 name
= IDENTIFIER_POINTER (t
);
2425 return (name
== 0 || *name
== '\0') ? 0 : name
;
2431 /* Start by checking if the pending_sibling_stack needs to be expanded.
2432 If necessary, expand it. */
2434 if (pending_siblings
== pending_siblings_allocated
)
2436 pending_siblings_allocated
+= PENDING_SIBLINGS_INCREMENT
;
2437 pending_sibling_stack
2438 = (unsigned *) xrealloc (pending_sibling_stack
,
2439 pending_siblings_allocated
* sizeof(unsigned));
2443 NEXT_DIE_NUM
= next_unused_dienum
++;
2446 /* Pop the sibling stack so that the most recently pushed DIEnum becomes the
2456 member_declared_type (member
)
2457 register tree member
;
2459 return (DECL_BIT_FIELD_TYPE (member
))
2460 ? DECL_BIT_FIELD_TYPE (member
)
2461 : TREE_TYPE (member
);
2464 /******************************* DIEs ************************************/
2466 /* Output routines for individual types of DIEs. */
2468 /* Note that every type of DIE (except a null DIE) gets a sibling. */
2471 output_array_type_die (arg
)
2474 register tree type
= arg
;
2476 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_array_type
);
2477 sibling_attribute ();
2478 equate_type_number_to_die_number (type
);
2479 member_attribute (TYPE_CONTEXT (type
));
2481 /* I believe that we can default the array ordering. SDB will probably
2482 do the right things even if AT_ordering is not present. It's not
2483 even an issue until we start to get into multidimensional arrays
2484 anyway. If SDB is ever caught doing the Wrong Thing for multi-
2485 dimensional arrays, then we'll have to put the AT_ordering attribute
2486 back in. (But if and when we find out that we need to put these in,
2487 we will only do so for multidimensional arrays. After all, we don't
2488 want to waste space in the .debug section now do we?) */
2491 ordering_attribute (ORD_row_major
);
2494 subscript_data_attribute (type
);
2498 output_set_type_die (arg
)
2501 register tree type
= arg
;
2503 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_set_type
);
2504 sibling_attribute ();
2505 equate_type_number_to_die_number (type
);
2506 member_attribute (TYPE_CONTEXT (type
));
2507 type_attribute (TREE_TYPE (type
), 0, 0);
2511 /* Implement this when there is a GNU FORTRAN or GNU Ada front end. */
2513 output_entry_point_die (arg
)
2516 register tree decl
= arg
;
2517 register tree type
= TREE_TYPE (decl
);
2518 register tree return_type
= TREE_TYPE (type
);
2520 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_entry_point
);
2521 sibling_attribute ();
2523 name_and_src_coords_attributes (decl
);
2524 member_attribute (DECL_CONTEXT (decl
));
2525 type_attribute (return_type
, 0, 0);
2529 /* Output a DIE to represent an enumeration type. Note that these DIEs
2530 include all of the information about the enumeration values also.
2531 This information is encoded into the element_list attribute. */
2534 output_enumeration_type_die (arg
)
2537 register tree type
= arg
;
2539 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_enumeration_type
);
2540 sibling_attribute ();
2541 equate_type_number_to_die_number (type
);
2542 name_attribute (type_tag (type
));
2543 member_attribute (TYPE_CONTEXT (type
));
2545 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
2546 given enum type is incomplete, do not generate the AT_byte_size
2547 attribute or the AT_element_list attribute. */
2549 if (TYPE_SIZE (type
))
2551 byte_size_attribute (type
);
2552 element_list_attribute (TYPE_FIELDS (type
));
2556 /* Output a DIE to represent either a real live formal parameter decl or
2557 to represent just the type of some formal parameter position in some
2560 Note that this routine is a bit unusual because its argument may be
2561 either a PARM_DECL node or else some sort of a ..._TYPE node. If it's
2562 the formar then this function is being called to output a real live
2563 formal parameter declaration. If it's the latter, then this function
2564 is only being called to output a TAG_formal_parameter DIE to stand as
2565 a placeholder for some formal argument type of some subprogram type. */
2568 output_formal_parameter_die (arg
)
2571 register tree decl
= arg
;
2574 if (TREE_CODE (decl
) == PARM_DECL
)
2575 type
= TREE_TYPE (decl
);
2578 type
= decl
; /* we were called with a type, not a decl */
2582 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_formal_parameter
);
2583 sibling_attribute ();
2586 name_and_src_coords_attributes (decl
);
2587 type_attribute (type
, TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
));
2588 location_or_const_value_attribute (decl
);
2591 type_attribute (type
, 0, 0);
2594 /* Output a DIE to represent a declared function (either file-scope
2595 or block-local) which has "external linkage" (according to ANSI-C). */
2598 output_global_subroutine_die (arg
)
2601 register tree decl
= arg
;
2602 register tree type
= TREE_TYPE (decl
);
2603 register tree return_type
= TREE_TYPE (type
);
2605 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_global_subroutine
);
2606 sibling_attribute ();
2608 name_and_src_coords_attributes (decl
);
2609 inline_attribute (decl
);
2610 prototyped_attribute (type
);
2611 member_attribute (DECL_CONTEXT (decl
));
2612 type_attribute (return_type
, 0, 0);
2613 if (!TREE_EXTERNAL (decl
))
2615 char func_end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2617 low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
2618 sprintf (func_end_label
, FUNC_END_LABEL_FMT
, current_funcdef_number
);
2619 high_pc_attribute (func_end_label
);
2623 /* Output a DIE to represent a declared data object (either file-scope
2624 or block-local) which has "external linkage" (according to ANSI-C). */
2627 output_global_variable_die (arg
)
2630 register tree decl
= arg
;
2631 register tree type
= TREE_TYPE (decl
);
2633 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_global_variable
);
2634 sibling_attribute ();
2635 name_and_src_coords_attributes (decl
);
2636 member_attribute (DECL_CONTEXT (decl
));
2637 type_attribute (type
, TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
));
2638 if (!TREE_EXTERNAL (decl
))
2639 location_or_const_value_attribute (decl
);
2643 /* TAG_inline_subroutine has been retired by the UI/PLSIG. We're
2644 now supposed to use either TAG_subroutine or TAG_global_subroutine
2645 (depending on whether or not the function in question has internal
2646 or external linkage) and we're supposed to just put in an AT_inline
2649 output_inline_subroutine_die (arg
)
2652 register tree decl
= arg
;
2653 register tree type
= TREE_TYPE (decl
);
2654 register tree return_type
= TREE_TYPE (type
);
2656 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_inline_subroutine
);
2657 sibling_attribute ();
2659 name_and_src_coords_attributes (decl
);
2660 prototyped_attribute (type
);
2661 member_attribute (DECL_CONTEXT (decl
));
2662 type_attribute (return_type
, 0, 0);
2664 /* Note: For each inline function which gets an out-of-line body
2665 generated for it, we want to generate AT_low_pc and AT_high_pc
2666 attributes here for the function's out-of-line body.
2668 Unfortunately, the decision as to whether or not to generate an
2669 out-of-line body for any given inline function may not be made
2670 until we reach the end of the containing scope for the given
2671 inline function (because only then will it be known if the
2672 function was ever even called).
2674 For this reason, the output of DIEs representing file-scope inline
2675 functions gets delayed until a special post-pass which happens only
2676 after we have reached the end of the compilation unit. Because of
2677 this mechanism, we can always be sure (by the time we reach here)
2678 that TREE_ASM_WRITTEN(decl) will correctly indicate whether or not
2679 there was an out-of-line body generated for this inline function.
2682 if (!TREE_EXTERNAL (decl
))
2684 if (TREE_ASM_WRITTEN (decl
))
2686 char func_end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2688 low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
2689 sprintf (func_end_label
, FUNC_END_LABEL_FMT
, current_funcdef_number
);
2690 high_pc_attribute (func_end_label
);
2697 output_label_die (arg
)
2700 register tree decl
= arg
;
2701 register rtx insn
= DECL_RTL (decl
);
2703 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_label
);
2704 sibling_attribute ();
2705 name_and_src_coords_attributes (decl
);
2707 /* When optimization is enabled (with -O) the code in jump.c and in flow.c
2708 may cause insns representing one of more of the user's own labels to
2709 be deleted. This happens whenever it is determined that a given label
2712 In such cases, we here generate an abbreviated form of a label DIE.
2713 This abbreviated version does *not* have a low_pc attribute. This
2714 should signify to the debugger that the label has been optimized away.
2716 Note that a CODE_LABEL can get deleted either by begin converted into
2717 a NOTE_INSN_DELETED note, or by simply having its INSN_DELETED_P flag
2718 set to true. We handle both cases here.
2721 if (GET_CODE (insn
) == CODE_LABEL
&& ! INSN_DELETED_P (insn
))
2723 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2725 sprintf (label
, INSN_LABEL_FMT
, current_funcdef_number
,
2726 (unsigned) INSN_UID (insn
));
2727 low_pc_attribute (label
);
2732 output_lexical_block_die (arg
)
2735 register tree stmt
= arg
;
2736 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2737 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2739 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_lexical_block
);
2740 sibling_attribute ();
2742 sprintf (begin_label
, BLOCK_BEGIN_LABEL_FMT
, next_block_number
);
2743 low_pc_attribute (begin_label
);
2744 sprintf (end_label
, BLOCK_END_LABEL_FMT
, next_block_number
);
2745 high_pc_attribute (end_label
);
2749 output_inlined_subroutine_die (arg
)
2752 register tree stmt
= arg
;
2753 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2754 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2756 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_inlined_subroutine
);
2757 sibling_attribute ();
2759 sprintf (begin_label
, BLOCK_BEGIN_LABEL_FMT
, next_block_number
);
2760 low_pc_attribute (begin_label
);
2761 sprintf (end_label
, BLOCK_END_LABEL_FMT
, next_block_number
);
2762 high_pc_attribute (end_label
);
2765 /* Output a DIE to represent a declared data object (either file-scope
2766 or block-local) which has "internal linkage" (according to ANSI-C). */
2769 output_local_variable_die (arg
)
2772 register tree decl
= arg
;
2773 register tree type
= TREE_TYPE (decl
);
2775 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_local_variable
);
2776 sibling_attribute ();
2777 name_and_src_coords_attributes (decl
);
2778 member_attribute (DECL_CONTEXT (decl
));
2779 type_attribute (type
, TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
));
2780 location_or_const_value_attribute (decl
);
2784 output_member_die (arg
)
2787 register tree decl
= arg
;
2789 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_member
);
2790 sibling_attribute ();
2791 name_and_src_coords_attributes (decl
);
2792 member_attribute (DECL_CONTEXT (decl
));
2793 type_attribute (member_declared_type (decl
),
2794 TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
));
2795 if (DECL_BIT_FIELD_TYPE (decl
)) /* If this is a bit field... */
2797 byte_size_attribute (decl
);
2798 bit_size_attribute (decl
);
2799 bit_offset_attribute (decl
);
2801 data_member_location_attribute (decl
);
2805 /* Don't generate either pointer_type DIEs or reference_type DIEs. According
2806 to the 4-4-90 Dwarf draft spec (just after requirement #47):
2808 These two type entries are not currently generated by any compiler.
2809 Since the only way to name a pointer (or reference) type is C or C++
2810 is via a "typedef", an entry with the "typedef" tag is generated
2813 We keep this code here just in case these types of DIEs may be needed
2814 to represent certain things in other languages (e.g. Pascal) someday.
2818 output_pointer_type_die (arg
)
2821 register tree type
= arg
;
2823 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_pointer_type
);
2824 sibling_attribute ();
2825 equate_type_number_to_die_number (type
);
2826 member_attribute (TYPE_CONTEXT (type
));
2827 type_attribute (TREE_TYPE (type
), 0, 0);
2831 output_reference_type_die (arg
)
2834 register tree type
= arg
;
2836 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_reference_type
);
2837 sibling_attribute ();
2838 equate_type_number_to_die_number (type
);
2839 member_attribute (TYPE_CONTEXT (type
));
2840 type_attribute (TREE_TYPE (type
), 0, 0);
2844 output_ptr_to_mbr_type_die (arg
)
2847 register tree type
= arg
;
2849 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_ptr_to_member_type
);
2850 sibling_attribute ();
2851 equate_type_number_to_die_number (type
);
2852 member_attribute (TYPE_CONTEXT (type
));
2853 containing_type_attribute (TYPE_OFFSET_BASETYPE (type
));
2854 type_attribute (TREE_TYPE (type
), 0, 0);
2858 output_compile_unit_die (arg
)
2861 register char *main_input_filename
= arg
;
2863 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_compile_unit
);
2864 sibling_attribute ();
2866 name_attribute (main_input_filename
);
2871 sprintf (producer
, "%s %s", language_string
, version_string
);
2872 producer_attribute (producer
);
2875 if (strcmp (language_string
, "GNU C++") == 0)
2876 language_attribute (LANG_C_PLUS_PLUS
);
2877 else if (flag_traditional
)
2878 language_attribute (LANG_C
);
2880 language_attribute (LANG_C89
);
2881 low_pc_attribute (TEXT_BEGIN_LABEL
);
2882 high_pc_attribute (TEXT_END_LABEL
);
2883 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
2884 stmt_list_attribute (LINE_BEGIN_LABEL
);
2885 last_filename
= xstrdup (main_input_filename
);
2888 char *wd
= getpwd ();
2890 comp_dir_attribute (wd
);
2893 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
2895 sf_names_attribute (SFNAMES_BEGIN_LABEL
);
2896 src_info_attribute (SRCINFO_BEGIN_LABEL
);
2897 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
2898 mac_info_attribute (MACINFO_BEGIN_LABEL
);
2903 output_string_type_die (arg
)
2906 register tree type
= arg
;
2908 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_string_type
);
2909 sibling_attribute ();
2910 member_attribute (TYPE_CONTEXT (type
));
2912 /* Fudge the string length attribute for now. */
2914 string_length_attribute (
2915 TYPE_MAX_VALUE (TYPE_DOMAIN (type
)));
2919 output_structure_type_die (arg
)
2922 register tree type
= arg
;
2924 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_structure_type
);
2925 sibling_attribute ();
2926 equate_type_number_to_die_number (type
);
2927 name_attribute (type_tag (type
));
2928 member_attribute (TYPE_CONTEXT (type
));
2930 /* If this type has been completed, then give it a byte_size attribute
2931 and prepare to give a list of members. Otherwise, don't do either of
2932 these things. In the latter case, we will not be generating a list
2933 of members (since we don't have any idea what they might be for an
2934 incomplete type). */
2936 if (TYPE_SIZE (type
))
2939 byte_size_attribute (type
);
2943 /* Output a DIE to represent a declared function (either file-scope
2944 or block-local) which has "internal linkage" (according to ANSI-C). */
2947 output_local_subroutine_die (arg
)
2950 register tree decl
= arg
;
2951 register tree type
= TREE_TYPE (decl
);
2952 register tree return_type
= TREE_TYPE (type
);
2953 char func_end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2955 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_subroutine
);
2956 sibling_attribute ();
2958 name_and_src_coords_attributes (decl
);
2959 inline_attribute (decl
);
2960 prototyped_attribute (type
);
2961 member_attribute (DECL_CONTEXT (decl
));
2962 type_attribute (return_type
, 0, 0);
2964 /* Avoid getting screwed up in cases where a function was declared static
2965 but where no definition was ever given for it. */
2967 if (TREE_ASM_WRITTEN (decl
))
2969 low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
2970 sprintf (func_end_label
, FUNC_END_LABEL_FMT
, current_funcdef_number
);
2971 high_pc_attribute (func_end_label
);
2976 output_subroutine_type_die (arg
)
2979 register tree type
= arg
;
2980 register tree return_type
= TREE_TYPE (type
);
2982 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_subroutine_type
);
2983 sibling_attribute ();
2985 equate_type_number_to_die_number (type
);
2986 prototyped_attribute (type
);
2987 member_attribute (TYPE_CONTEXT (type
));
2988 type_attribute (return_type
, 0, 0);
2992 output_typedef_die (arg
)
2995 register tree decl
= arg
;
2996 register tree type
= TREE_TYPE (decl
);
2998 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_typedef
);
2999 sibling_attribute ();
3000 name_and_src_coords_attributes (decl
);
3001 member_attribute (DECL_CONTEXT (decl
));
3002 type_attribute (type
, TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
));
3006 output_union_type_die (arg
)
3009 register tree type
= arg
;
3011 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_union_type
);
3012 sibling_attribute ();
3013 equate_type_number_to_die_number (type
);
3014 name_attribute (type_tag (type
));
3015 member_attribute (TYPE_CONTEXT (type
));
3017 /* If this type has been completed, then give it a byte_size attribute
3018 and prepare to give a list of members. Otherwise, don't do either of
3019 these things. In the latter case, we will not be generating a list
3020 of members (since we don't have any idea what they might be for an
3021 incomplete type). */
3023 if (TYPE_SIZE (type
))
3026 byte_size_attribute (type
);
3030 /* Generate a special type of DIE used as a stand-in for a trailing ellipsis
3031 at the end of an (ANSI prototyped) formal parameters list. */
3034 output_unspecified_parameters_die (arg
)
3037 register tree decl_or_type
= arg
;
3039 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_unspecified_parameters
);
3040 sibling_attribute ();
3042 /* This kludge is here only for the sake of being compatible with what
3043 the USL CI5 C compiler does. The specification of Dwarf Version 1
3044 doesn't say that TAG_unspecified_parameters DIEs should contain any
3045 attributes other than the AT_sibling attribute, but they are certainly
3046 allowed to contain additional attributes, and the CI5 compiler
3047 generates AT_name, AT_fund_type, and AT_location attributes within
3048 TAG_unspecified_parameters DIEs which appear in the child lists for
3049 DIEs representing function definitions, so we do likewise here. */
3051 if (TREE_CODE (decl_or_type
) == FUNCTION_DECL
&& DECL_INITIAL (decl_or_type
))
3053 name_attribute ("...");
3054 fund_type_attribute (FT_pointer
);
3055 /* location_attribute (?); */
3060 output_padded_null_die (arg
)
3063 ASM_OUTPUT_ALIGN (asm_out_file
, 2); /* 2**2 == 4 */
3066 /*************************** end of DIEs *********************************/
3068 /* Generate some type of DIE. This routine generates the generic outer
3069 wrapper stuff which goes around all types of DIE's (regardless of their
3070 TAGs. All forms of DIEs start with a DIE-specific label, followed by a
3071 DIE-length word, followed by the guts of the DIE itself. After the guts
3072 of the DIE, there must always be a terminator label for the DIE. */
3075 output_die (die_specific_output_function
, param
)
3076 register void (*die_specific_output_function
)();
3077 register void *param
;
3079 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3080 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3082 current_dienum
= NEXT_DIE_NUM
;
3083 NEXT_DIE_NUM
= next_unused_dienum
;
3085 sprintf (begin_label
, DIE_BEGIN_LABEL_FMT
, current_dienum
);
3086 sprintf (end_label
, DIE_END_LABEL_FMT
, current_dienum
);
3088 /* Write a label which will act as the name for the start of this DIE. */
3090 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
3092 /* Write the DIE-length word. */
3094 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, end_label
, begin_label
);
3096 /* Fill in the guts of the DIE. */
3098 next_unused_dienum
++;
3099 die_specific_output_function (param
);
3101 /* Write a label which will act as the name for the end of this DIE. */
3103 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
3107 end_sibling_chain ()
3109 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3111 current_dienum
= NEXT_DIE_NUM
;
3112 NEXT_DIE_NUM
= next_unused_dienum
;
3114 sprintf (begin_label
, DIE_BEGIN_LABEL_FMT
, current_dienum
);
3116 /* Write a label which will act as the name for the start of this DIE. */
3118 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
3120 /* Write the DIE-length word. */
3122 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 4);
3127 /* Generate a list of nameless TAG_formal_parameter DIEs (and perhaps a
3128 TAG_unspecified_parameters DIE) to represent the types of the formal
3129 parameters as specified in some function type specification (except
3130 for those which appear as part of a function *definition*).
3132 Note that we must be careful here to output all of the parameter DIEs
3133 *before* we output any DIEs needed to represent the types of the formal
3134 parameters. This keeps svr4 SDB happy because it (incorrectly) thinks
3135 that the first non-parameter DIE it sees ends the formal parameter list.
3139 output_formal_types (function_or_method_type
)
3140 register tree function_or_method_type
;
3143 register tree formal_type
;
3144 register tree first_parm_type
= TYPE_ARG_TYPES (function_or_method_type
);
3146 /* In the case where we are generating a formal types list for a C++
3147 non-static member function type, skip over the first thing on the
3148 TYPE_ARG_TYPES list because it only represents the type of the
3149 hidden `this pointer'. The debugger should be able to figure
3150 out (without being explicitly told) that this non-static member
3151 function type takes a `this pointer' and should be able to figure
3152 what the type of that hidden parameter is from the AT_member
3153 attribute of the parent TAG_subroutine_type DIE. */
3155 if (TREE_CODE (function_or_method_type
) == METHOD_TYPE
)
3156 first_parm_type
= TREE_CHAIN (first_parm_type
);
3158 /* Make our first pass over the list of formal parameter types and output
3159 a TAG_formal_parameter DIE for each one. */
3161 for (link
= first_parm_type
; link
; link
= TREE_CHAIN (link
))
3163 formal_type
= TREE_VALUE (link
);
3164 if (formal_type
== void_type_node
)
3167 /* Output a (nameless) DIE to represent the formal parameter itself. */
3169 output_die (output_formal_parameter_die
, formal_type
);
3172 /* If this function type has an ellipsis, add a TAG_unspecified_parameters
3173 DIE to the end of the parameter list. */
3175 if (formal_type
!= void_type_node
)
3176 output_die (output_unspecified_parameters_die
, function_or_method_type
);
3178 /* Make our second (and final) pass over the list of formal parameter types
3179 and output DIEs to represent those types (as necessary). */
3181 for (link
= TYPE_ARG_TYPES (function_or_method_type
);
3183 link
= TREE_CHAIN (link
))
3185 formal_type
= TREE_VALUE (link
);
3186 if (formal_type
== void_type_node
)
3189 output_type (formal_type
, function_or_method_type
);
3193 /* Remember a type in the pending_types_list. */
3199 if (pending_types
== pending_types_allocated
)
3201 pending_types_allocated
+= PENDING_TYPES_INCREMENT
;
3203 = (tree
*) xrealloc (pending_types_list
,
3204 sizeof (tree
) * pending_types_allocated
);
3206 pending_types_list
[pending_types
++] = type
;
3208 /* Mark the pending type as having been output already (even though
3209 it hasn't been). This prevents the type from being added to the
3210 pending_types_list more than once. */
3212 TREE_ASM_WRITTEN (type
) = 1;
3215 /* Return non-zero if it is legitimate to output DIEs to represent a
3216 given type while we are generating the list of child DIEs for some
3217 DIE associated with a given scope.
3219 This function returns non-zero if *either* of the following two conditions
3222 o the type actually belongs to the given scope (as evidenced
3223 by its TYPE_CONTEXT value), or
3225 o the type is anonymous, and the `scope' in question is *not*
3226 a RECORD_TYPE or UNION_TYPE.
3228 In theory, we should be able to generate DIEs for anonymous types
3229 *anywhere* (since the scope of an anonymous type is irrelevant)
3230 however svr4 SDB doesn't want to see other type DIEs within the
3231 lists of child DIEs for a TAG_structure_type or TAG_union_type DIE.
3233 Note that TYPE_CONTEXT(type) may be NULL (to indicate global scope)
3234 or it may point to a BLOCK node (for types local to a block), or to a
3235 FUNCTION_DECL node (for types local to the heading of some function
3236 definition), or to a FUNCTION_TYPE node (for types local to the
3237 prototyped parameter list of a function type specification), or to a
3238 RECORD_TYPE or UNION_TYPE node (in the case of C++ nested types).
3240 The `scope' parameter should likewise be NULL or should point to a
3241 BLOCK node, a FUNCTION_DECL node, a FUNCTION_TYPE node, a RECORD_TYPE
3242 node, or a UNION_TYPE node.
3244 This function is used only for deciding when to "pend" and when to
3245 "un-pend" types to/from the pending_types_list.
3247 Note that we sometimes make use of this "type pending" feature in a
3248 rather twisted way to temporarily delay the production of DIEs for the
3249 types of formal parameters. (We do this just to make svr4 SDB happy.)
3250 It order to delay the production of DIEs representing types of formal
3251 parameters, callers of this function supply `fake_containing_scope' as
3252 the `scope' parameter to this function. Given that fake_containing_scope
3253 is *not* the containing scope for *any* other type, the desired effect
3254 is achieved, i.e. output of DIEs representing types is temporarily
3255 suspended, and any type DIEs which would have been output otherwise
3256 are instead placed onto the pending_types_list. Later on, we can force
3257 these (temporarily pended) types to be output simply by calling
3258 `output_pending_types_for_scope' with an actual argument equal to the
3259 true scope of the types we temporarily pended.
3263 type_ok_for_scope (type
, scope
)
3265 register tree scope
;
3267 return (TYPE_CONTEXT (type
) == scope
3268 || (TYPE_NAME (type
) == NULL
3269 && TREE_CODE (scope
) != RECORD_TYPE
3270 && TREE_CODE (scope
) != UNION_TYPE
));
3273 /* Output any pending types (from the pending_types list) which we can output
3274 now (given the limitations of the scope that we are working on now).
3276 For each type output, remove the given type from the pending_types_list
3277 *before* we try to output it.
3279 Note that we have to process the list in beginning-to-end order,
3280 because the call made here to output_type may cause yet more types
3281 to be added to the end of the list, and we may have to output some
3286 output_pending_types_for_scope (containing_scope
)
3287 register tree containing_scope
;
3289 register unsigned i
;
3291 for (i
= 0; i
< pending_types
; )
3293 register tree type
= pending_types_list
[i
];
3295 if (type_ok_for_scope (type
, containing_scope
))
3297 register tree
*mover
;
3298 register tree
*limit
;
3301 limit
= &pending_types_list
[pending_types
];
3302 for (mover
= &pending_types_list
[i
]; mover
< limit
; mover
++)
3303 *mover
= *(mover
+1);
3305 /* Un-mark the type as having been output already (because it
3306 hasn't been, really). Then call output_type to generate a
3307 Dwarf representation of it. */
3309 TREE_ASM_WRITTEN (type
) = 0;
3310 output_type (type
, containing_scope
);
3312 /* Don't increment the loop counter in this case because we
3313 have shifted all of the subsequent pending types down one
3314 element in the pending_types_list array. */
3322 output_type (type
, containing_scope
)
3324 register tree containing_scope
;
3326 if (type
== 0 || type
== error_mark_node
)
3329 /* We are going to output a DIE to represent the unqualified version of
3330 of this type (i.e. without any const or volatile qualifiers) so get
3331 the main variant (i.e. the unqualified version) of this type now. */
3333 type
= TYPE_MAIN_VARIANT (type
);
3335 if (TREE_ASM_WRITTEN (type
))
3338 /* Don't generate any DIEs for this type now unless it is OK to do so
3339 (based upon what `type_ok_for_scope' tells us). */
3341 if (! type_ok_for_scope (type
, containing_scope
))
3347 switch (TREE_CODE (type
))
3353 case REFERENCE_TYPE
:
3354 /* For these types, all that is required is that we output a DIE
3355 (or a set of DIEs) to represent that "basis" type. */
3356 output_type (TREE_TYPE (type
), containing_scope
);
3360 /* This code is used for C++ pointer-to-data-member types. */
3361 /* Output a description of the relevant class type. */
3362 output_type (TYPE_OFFSET_BASETYPE (type
), containing_scope
);
3363 /* Output a description of the type of the object pointed to. */
3364 output_type (TREE_TYPE (type
), containing_scope
);
3365 /* Now output a DIE to represent this pointer-to-data-member type
3367 output_die (output_ptr_to_mbr_type_die
, type
);
3371 output_type (TREE_TYPE (type
), containing_scope
);
3372 output_die (output_set_type_die
, type
);
3376 output_type (TREE_TYPE (type
), containing_scope
);
3377 abort (); /* No way to represent these in Dwarf yet! */
3381 output_type (TREE_TYPE (type
), containing_scope
);
3382 output_die (output_string_type_die
, type
);
3386 /* Force out return type (in case it wasn't forced out already). */
3387 output_type (TREE_TYPE (type
), containing_scope
);
3388 output_die (output_subroutine_type_die
, type
);
3389 output_formal_types (type
);
3390 end_sibling_chain ();
3394 /* Force out return type (in case it wasn't forced out already). */
3395 output_type (TREE_TYPE (type
), containing_scope
);
3396 output_die (output_subroutine_type_die
, type
);
3397 output_formal_types (type
);
3398 end_sibling_chain ();
3403 register tree element_type
;
3405 element_type
= TREE_TYPE (type
);
3406 while (TREE_CODE (element_type
) == ARRAY_TYPE
)
3407 element_type
= TREE_TYPE (element_type
);
3409 output_type (element_type
, containing_scope
);
3410 output_die (output_array_type_die
, type
);
3418 /* For a non-file-scope tagged type, we can always go ahead and
3419 output a Dwarf description of this type right now, even if
3420 the type in question is still incomplete, because if this
3421 local type *was* ever completed anywhere within its scope,
3422 that complete definition would already have been attached to
3423 this RECORD_TYPE, UNION_TYPE or ENUMERAL_TYPE node by the
3424 time we reach this point. That's true because of the way the
3425 front-end does its processing of file-scope declarations (of
3426 functions and class types) within which other types might be
3427 nested. The C and C++ front-ends always gobble up such "local
3428 scope" things en-mass before they try to output *any* debugging
3429 information for any of the stuff contained inside them and thus,
3430 we get the benefit here of what is (in effect) a pre-resolution
3431 of forward references to tagged types in local scopes.
3433 Note however that for file-scope tagged types we cannot assume
3434 that such pre-resolution of forward references has taken place.
3435 A given file-scope tagged type may appear to be incomplete when
3436 we reach this point, but it may yet be given a full definition
3437 (at file-scope) later on during compilation. In order to avoid
3438 generating a premature (and possibly incorrect) set of Dwarf
3439 DIEs for such (as yet incomplete) file-scope tagged types, we
3440 generate nothing at all for as-yet incomplete file-scope tagged
3441 types here unless we are making our special "finalization" pass
3442 for file-scope things at the very end of compilation. At that
3443 time, we will certainly know as much about each file-scope tagged
3444 type as we are ever going to know, so at that point in time, we
3445 can safely generate correct Dwarf descriptions for these file-
3449 if (TYPE_SIZE (type
) == 0 && TYPE_CONTEXT (type
) == NULL
&& !finalizing
)
3450 return; /* EARLY EXIT! Avoid setting TREE_ASM_WRITTEN. */
3452 /* Prevent infinite recursion in cases where the type of some
3453 member of this type is expressed in terms of this type itself. */
3455 TREE_ASM_WRITTEN (type
) = 1;
3457 /* Output a DIE to represent the tagged type itself. */
3459 switch (TREE_CODE (type
))
3462 output_die (output_enumeration_type_die
, type
);
3463 return; /* a special case -- nothing left to do so just return */
3466 output_die (output_structure_type_die
, type
);
3470 output_die (output_union_type_die
, type
);
3474 /* If this is not an incomplete type, output descriptions of
3475 each of its members.
3477 Note that as we output the DIEs necessary to represent the
3478 members of this record or union type, we will also be trying
3479 to output DIEs to represent the *types* of those members.
3480 However the `output_type' function (above) will specifically
3481 avoid generating type DIEs for member types *within* the list
3482 of member DIEs for this (containing) type execpt for those
3483 types (of members) which are explicitly marked as also being
3484 members of this (containing) type themselves. The g++ front-
3485 end can force any given type to be treated as a member of some
3486 other (containing) type by setting the TYPE_CONTEXT of the
3487 given (member) type to point to the TREE node representing the
3488 appropriate (containing) type.
3491 if (TYPE_SIZE (type
))
3494 register tree normal_member
;
3496 /* First output info about the data members and type members. */
3498 for (normal_member
= TYPE_FIELDS (type
);
3500 normal_member
= TREE_CHAIN (normal_member
))
3501 output_decl (normal_member
, type
);
3505 register tree vec_base
;
3507 /* Now output info about the function members (if any). */
3509 vec_base
= TYPE_METHODS (type
);
3512 register tree first_func_member
= TREE_VEC_ELT (vec_base
, 0);
3513 register tree func_member
;
3515 /* This isn't documented, but the first element of the
3516 vector of member functions can be NULL in cases where
3517 the class type in question didn't have either a
3518 constructor or a destructor declared for it. We have
3519 to make allowances for that here. */
3521 if (first_func_member
== NULL
)
3522 first_func_member
= TREE_VEC_ELT (vec_base
, 1);
3524 for (func_member
= first_func_member
;
3526 func_member
= TREE_CHAIN (func_member
))
3527 output_decl (func_member
, type
);
3531 end_sibling_chain (); /* Terminate member chain. */
3542 break; /* No DIEs needed for fundamental types. */
3544 case LANG_TYPE
: /* No Dwarf representation currently defined. */
3551 TREE_ASM_WRITTEN (type
) = 1;
3554 /* Output a TAG_lexical_block DIE followed by DIEs to represent all of
3555 the things which are local to the given block. */
3561 register int have_significant_locals
= 0;
3563 /* Ignore blocks never really used to make RTL. */
3565 if (! stmt
|| ! TREE_USED (stmt
))
3568 /* Determine if this block contains any "significant" local declarations
3569 which we need to output DIEs for. */
3571 if (BLOCK_INLINE_FUNCTION (stmt
))
3572 /* The outer scopes for inlinings *must* always be represented. */
3573 have_significant_locals
= 1;
3575 if (debug_info_level
> DINFO_LEVEL_TERSE
)
3576 have_significant_locals
= (BLOCK_VARS (stmt
) != NULL
);
3581 for (decl
= BLOCK_VARS (stmt
); decl
; decl
= TREE_CHAIN (decl
))
3582 if (TREE_CODE (decl
) == FUNCTION_DECL
&& DECL_INITIAL (decl
))
3584 have_significant_locals
= 1;
3589 /* It would be a waste of space to generate a Dwarf TAG_lexical_block
3590 DIE for any block which contains no significant local declarations
3591 at all. Rather, in such cases we just call `output_decls_for_scope'
3592 so that any needed Dwarf info for any sub-blocks will get properly
3593 generated. Note that in terse mode, our definition of what constitutes
3594 a "significant" local declaration gets restricted to include only
3595 inlined function instances and local (nested) function definitions. */
3597 if (have_significant_locals
)
3599 output_die (BLOCK_INLINE_FUNCTION (stmt
)
3600 ? output_inlined_subroutine_die
3601 : output_lexical_block_die
,
3603 output_decls_for_scope (stmt
);
3604 end_sibling_chain ();
3607 output_decls_for_scope (stmt
);
3610 /* Output all of the decls declared within a given scope (also called
3611 a `binding contour') and (recursively) all of it's sub-blocks. */
3614 output_decls_for_scope (stmt
)
3617 /* Ignore blocks never really used to make RTL. */
3619 if (! stmt
|| ! TREE_USED (stmt
))
3622 next_block_number
++;
3624 /* Output the DIEs to represent all of the data objects, functions,
3625 typedefs, and tagged types declared directly within this block
3626 but not within any nested sub-blocks. */
3631 for (decl
= BLOCK_VARS (stmt
); decl
; decl
= TREE_CHAIN (decl
))
3632 output_decl (decl
, stmt
);
3635 output_pending_types_for_scope (stmt
);
3637 /* Output the DIEs to represent all sub-blocks (and the items declared
3638 therein) of this block. */
3641 register tree subblocks
;
3643 for (subblocks
= BLOCK_SUBBLOCKS (stmt
);
3645 subblocks
= BLOCK_CHAIN (subblocks
))
3646 output_block (subblocks
);
3650 /* Output Dwarf .debug information for a decl described by DECL. */
3653 output_decl (decl
, containing_scope
)
3655 register tree containing_scope
;
3657 switch (TREE_CODE (decl
))
3663 /* The individual enumerators of an enum type get output when we
3664 output the Dwarf representation of the relevant enum type itself. */
3668 /* If we are in terse mode, don't output any DIEs to represent
3669 mere external function declarations. */
3671 if (TREE_EXTERNAL (decl
) && debug_info_level
<= DINFO_LEVEL_TERSE
)
3674 /* Before we describe the FUNCTION_DECL itself, make sure that we
3675 have described its return type. */
3677 output_type (TREE_TYPE (TREE_TYPE (decl
)), containing_scope
);
3679 /* If the following DIE will represent a function definition for a
3680 function with "extern" linkage, output a special "pubnames" DIE
3681 label just ahead of the actual DIE. A reference to this label
3682 was already generated in the .debug_pubnames section sub-entry
3683 for this function definition. */
3685 if (TREE_PUBLIC (decl
))
3687 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3689 sprintf (label
, PUB_DIE_LABEL_FMT
, next_pubname_number
++);
3690 ASM_OUTPUT_LABEL (asm_out_file
, label
);
3693 /* Now output a DIE to represent the function itself. */
3695 output_die (TREE_PUBLIC (decl
) || TREE_EXTERNAL (decl
)
3696 ? output_global_subroutine_die
3697 : output_local_subroutine_die
,
3700 /* Now output descriptions of the arguments for this function.
3701 This gets (unnecessarily?) complex because of the fact that
3702 the DECL_ARGUMENT list for a FUNCTION_DECL doesn't indicate
3703 cases where there was a trailing `...' at the end of the formal
3704 parameter list. In order to find out if there was a trailing
3705 ellipsis or not, we must instead look at the type associated
3706 with the FUNCTION_DECL. This will be a node of type FUNCTION_TYPE.
3707 If the chain of type nodes hanging off of this FUNCTION_TYPE node
3708 ends with a void_type_node then there should *not* be an ellipsis
3711 /* In the case where we are describing an external function, all
3712 we need to do here (and all we *can* do here) is to describe
3713 the *types* of its formal parameters. */
3715 if (TREE_EXTERNAL (decl
))
3716 output_formal_types (TREE_TYPE (decl
));
3719 register tree arg_decls
= DECL_ARGUMENTS (decl
);
3721 /* In the case where the FUNCTION_DECL represents a C++ non-static
3722 member function, skip over the first thing on the DECL_ARGUMENTS
3723 chain. It only represents the hidden `this pointer' parameter
3724 and the debugger should know implicitly that non-static member
3725 functions have such a thing, and should be able to figure out
3726 exactly what the type of each `this pointer' is (from the
3727 AT_member attribute of the parent TAG_subroutine DIE) without
3728 being explicitly told. */
3730 if (TREE_CODE (TREE_TYPE (decl
)) == METHOD_TYPE
)
3731 arg_decls
= TREE_CHAIN (arg_decls
);
3734 register tree last_arg
;
3736 last_arg
= (arg_decls
&& TREE_CODE (arg_decls
) != ERROR_MARK
)
3737 ? tree_last (arg_decls
)
3740 /* Generate DIEs to represent all known formal parameters, but
3741 don't do it if this looks like a varargs function. A given
3742 function is considered to be a varargs function if (and only
3743 if) its last named argument is named `__builtin_va_alist'. */
3746 || ! DECL_NAME (last_arg
)
3747 || strcmp (IDENTIFIER_POINTER (DECL_NAME (last_arg
)),
3748 "__builtin_va_alist"))
3752 /* WARNING! Kludge zone ahead! Here we have a special
3753 hack for svr4 SDB compatibility. Instead of passing the
3754 current FUNCTION_DECL node as the second parameter (i.e.
3755 the `containing_scope' parameter) to `output_decl' (as
3756 we ought to) we instead pass a pointer to our own private
3757 fake_containing_scope node. That node is a RECORD_TYPE
3758 node which NO OTHER TYPE may ever actually be a member of.
3760 This pointer will ultimately get passed into `output_type'
3761 as its `containing_scope' parameter. `Output_type' will
3762 then perform its part in the hack... i.e. it will pend
3763 the type of the formal parameter onto the pending_types
3764 list. Later on, when we are done generating the whole
3765 sequence of formal parameter DIEs for this function
3766 definition, we will un-pend all previously pended types
3767 of formal parameters for this function definition.
3769 This whole kludge prevents any type DIEs from being
3770 mixed in with the formal parameter DIEs. That's good
3771 because svr4 SDB believes that the list of formal
3772 parameter DIEs for a function ends wherever the first
3773 non-formal-parameter DIE appears. Thus, we have to
3774 keep the formal parameter DIEs segregated. They must
3775 all appear (consecutively) at the start of the list of
3776 children for the DIE representing the function definition.
3777 Then (and only then) may we output any additional DIEs
3778 needed to represent the types of these formal parameters.
3781 for (parm
= arg_decls
; parm
; parm
= TREE_CHAIN (parm
))
3782 if (TREE_CODE (parm
) == PARM_DECL
)
3783 output_decl (parm
, fake_containing_scope
);
3785 /* Now that we have finished generating all of the DIEs to
3786 represent the formal parameters themselves, force out
3787 any DIEs needed to represent their types. We do this
3788 simply by un-pending all previously pended types which
3789 can legitimately go into the chain of children DIEs for
3790 the current FUNCTION_DECL. */
3792 output_pending_types_for_scope (decl
);
3796 /* Now try to decide if we should put an ellipsis at the end. */
3799 register int has_ellipsis
= TRUE
; /* default assumption */
3800 register tree fn_arg_types
= TYPE_ARG_TYPES (TREE_TYPE (decl
));
3804 /* This function declaration/definition was prototyped. */
3806 /* If the list of formal argument types ends with a
3807 void_type_node, then the formals list did *not* end
3808 with an ellipsis. */
3810 if (TREE_VALUE (tree_last (fn_arg_types
)) == void_type_node
)
3811 has_ellipsis
= FALSE
;
3815 /* This function declaration/definition was not prototyped. */
3817 /* Note that all non-prototyped function *declarations* are
3818 assumed to represent varargs functions (until proven
3821 if (DECL_INITIAL (decl
)) /* if this is a func definition */
3824 has_ellipsis
= FALSE
; /* no args == (void) */
3827 /* For a non-prototyped function definition which
3828 declares one or more formal parameters, if the name
3829 of the first formal parameter is *not*
3830 __builtin_va_alist then we must assume that this
3831 is *not* a varargs function. */
3833 if (DECL_NAME (arg_decls
)
3834 && strcmp (IDENTIFIER_POINTER (DECL_NAME (arg_decls
)),
3835 "__builtin_va_alist"))
3836 has_ellipsis
= FALSE
;
3842 output_die (output_unspecified_parameters_die
, decl
);
3846 /* Output Dwarf info for all of the stuff within the body of the
3847 function (if it has one - it may be just a declaration). */
3850 register tree outer_scope
= DECL_INITIAL (decl
);
3852 if (outer_scope
&& TREE_CODE (outer_scope
) != ERROR_MARK
)
3854 /* Note that here, `outer_scope' is a pointer to the outermost
3855 BLOCK node created to represent the body of a function.
3856 This outermost BLOCK actually represents the outermost
3857 binding contour for the function, i.e. the contour in which
3858 the function's formal parameters get declared. Just within
3859 this contour, there will be another (nested) BLOCK which
3860 represents the function's outermost block. We don't want
3861 to generate a lexical_block DIE to represent the outermost
3862 block of a function body, because that is not really an
3863 independent scope according to ANSI C rules. Rather, it is
3864 the same scope in which the parameters were declared and
3865 for Dwarf, we do not generate a TAG_lexical_block DIE for
3866 that scope. We must however see to it that the LABEL_DECLs
3867 associated with `outer_scope' get DIEs generated for them. */
3870 register tree label
;
3872 for (label
= BLOCK_VARS (outer_scope
);
3874 label
= TREE_CHAIN (label
))
3875 output_decl (label
, outer_scope
);
3878 output_decls_for_scope (BLOCK_SUBBLOCKS (outer_scope
));
3880 /* Finally, force out any pending types which are local to the
3881 outermost block of this function definition. These will
3882 all have a TYPE_CONTEXT which points to the FUNCTION_DECL
3885 output_pending_types_for_scope (decl
);
3889 /* Generate a terminator for the list of stuff `owned' by this
3892 end_sibling_chain ();
3897 /* If we are in terse mode, don't generate any DIEs to represent
3898 any actual typedefs. Note that even when we are in terse mode,
3899 we must still output DIEs to represent those tagged types which
3900 are used (directly or indirectly) in the specification of either
3901 a return type or a formal parameter type of some function. */
3903 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
3904 if (DECL_NAME (decl
) != NULL
3905 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl
)))
3908 output_type (TREE_TYPE (decl
), containing_scope
);
3910 /* Note that unlike the gcc front end (which generates a NULL named
3911 TYPE_DECL node for each complete tagged type, each array type,
3912 and each function type node created) the g++ front end generates
3913 a *named* TYPE_DECL node for each tagged type node created.
3914 Unfortunately, these g++ TYPE_DECL nodes cause us to output many
3915 superfluous and unnecessary TAG_typedef DIEs here. When g++ is
3916 fixed to stop generating these superfluous named TYPE_DECL nodes,
3917 the superfluous TAG_typedef DIEs will likewise cease. */
3919 if (DECL_NAME (decl
))
3920 /* Output a DIE to represent the typedef itself. */
3921 output_die (output_typedef_die
, decl
);
3925 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
3926 output_die (output_label_die
, decl
);
3930 /* If we are in terse mode, don't generate any DIEs to represent
3931 any variable declarations or definitions. */
3933 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
3936 /* Output any DIEs that are needed to specify the type of this data
3939 output_type (TREE_TYPE (decl
), containing_scope
);
3941 /* If the following DIE will represent a data object definition for a
3942 data object with "extern" linkage, output a special "pubnames" DIE
3943 label just ahead of the actual DIE. A reference to this label
3944 was already generated in the .debug_pubnames section sub-entry
3945 for this data object definition. */
3947 if (TREE_PUBLIC (decl
))
3949 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3951 sprintf (label
, PUB_DIE_LABEL_FMT
, next_pubname_number
++);
3952 ASM_OUTPUT_LABEL (asm_out_file
, label
);
3955 /* Now output the DIE to represent the data object itself. */
3957 output_die (TREE_PUBLIC (decl
) || TREE_EXTERNAL (decl
)
3958 ? output_global_variable_die
: output_local_variable_die
,
3963 /* Ignore the nameless fields that are used to skip bits. */
3964 if (DECL_NAME (decl
) != 0)
3966 output_type (member_declared_type (decl
), containing_scope
);
3967 output_die (output_member_die
, decl
);
3972 /* Force out the type of this formal, if it was not forced out yet.
3973 Note that here we can run afowl of a bug in "classic" svr4 SDB.
3974 It should be able to grok the presence of type DIEs within a list
3975 of TAG_formal_parameter DIEs, but it doesn't. */
3977 output_type (TREE_TYPE (decl
), containing_scope
);
3978 output_die (output_formal_parameter_die
, decl
);
3987 dwarfout_file_scope_decl (decl
, set_finalizing
)
3989 register int set_finalizing
;
3991 switch (TREE_CODE (decl
))
3995 /* Ignore this FUNCTION_DECL if it refers to a builtin function. */
3997 if (TREE_EXTERNAL (decl
) && DECL_FUNCTION_CODE (decl
))
4000 /* Ignore this FUNCTION_DECL if it refers to a file-scope extern
4001 function declaration and if the declaration was never even
4002 referenced from within this entire compilation unit. We
4003 suppress these DIEs in order to save space in the .debug section
4004 (by eliminating entries which are probably useless). Note that
4005 we must not suppress block-local extern declarations (whether
4006 used or not) because that would screw-up the debugger's name
4007 lookup mechanism and cause it to miss things which really ought
4008 to be in scope at a given point. */
4010 if (TREE_EXTERNAL (decl
) && !TREE_USED (decl
))
4013 if (TREE_PUBLIC (decl
) && ! TREE_EXTERNAL (decl
))
4015 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4017 /* Output a .debug_pubnames entry for a public function
4018 defined in this compilation unit. */
4020 fputc ('\n', asm_out_file
);
4021 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, PUBNAMES_SECTION
);
4022 sprintf (label
, PUB_DIE_LABEL_FMT
, next_pubname_number
);
4023 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, label
);
4024 ASM_OUTPUT_DWARF_STRING (asm_out_file
,
4025 IDENTIFIER_POINTER (DECL_NAME (decl
)));
4026 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4033 /* Ignore this VAR_DECL if it refers to a file-scope extern data
4034 object declaration and if the declaration was never even
4035 referenced from within this entire compilation unit. We
4036 suppress these DIEs in order to save space in the .debug section
4037 (by eliminating entries which are probably useless). Note that
4038 we must not suppress block-local extern declarations (whether
4039 used or not) because that would screw-up the debugger's name
4040 lookup mechanism and cause it to miss things which really ought
4041 to be in scope at a given point. */
4043 if (TREE_EXTERNAL (decl
) && !TREE_USED (decl
))
4046 if (TREE_PUBLIC (decl
)
4047 && ! TREE_EXTERNAL (decl
)
4048 && GET_CODE (DECL_RTL (decl
)) == MEM
)
4050 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4052 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
4054 /* Output a .debug_pubnames entry for a public variable
4055 defined in this compilation unit. */
4057 fputc ('\n', asm_out_file
);
4058 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, PUBNAMES_SECTION
);
4059 sprintf (label
, PUB_DIE_LABEL_FMT
, next_pubname_number
);
4060 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, label
);
4061 ASM_OUTPUT_DWARF_STRING (asm_out_file
,
4062 IDENTIFIER_POINTER (DECL_NAME (decl
)));
4063 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4066 if (DECL_INITIAL (decl
) == NULL
)
4068 /* Output a .debug_aranges entry for a public variable
4069 which is tentatively defined in this compilation unit. */
4071 fputc ('\n', asm_out_file
);
4072 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, ARANGES_SECTION
);
4073 ASM_OUTPUT_DWARF_ADDR (asm_out_file
,
4074 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
4075 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
4076 (unsigned) int_size_in_bytes (TREE_TYPE (decl
)));
4077 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4081 /* If we are in terse mode, don't generate any DIEs to represent
4082 any variable declarations or definitions. */
4084 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
4090 /* Don't generate any DIEs to represent the standard built-in types. */
4092 if (DECL_SOURCE_LINE (decl
) == 0)
4095 /* If we are in terse mode, don't generate any DIEs to represent
4096 any actual typedefs. Note that even when we are in terse mode,
4097 we must still output DIEs to represent those tagged types which
4098 are used (directly or indirectly) in the specification of either
4099 a return type or a formal parameter type of some function. */
4101 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
4102 if (DECL_NAME (decl
) != NULL
4103 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl
)))
4112 fputc ('\n', asm_out_file
);
4113 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DEBUG_SECTION
);
4114 finalizing
= set_finalizing
;
4115 output_decl (decl
, NULL
);
4117 /* NOTE: The call above to `output_decl' may have caused one or more
4118 file-scope named types (i.e. tagged types) to be placed onto the
4119 pending_types_list. We have to get those types off of that list
4120 at some point, and this is the perfect time to do it. If we didn't
4121 take them off now, they might still be on the list when cc1 finally
4122 exits. That might be OK if it weren't for the fact that when we put
4123 types onto the pending_types_list, we set the TREE_ASM_WRITTEN flag
4124 for these types, and that causes them never to be output unless
4125 `output_pending_types_for_scope' takes them off of the list and un-sets
4126 their TREE_ASM_WRITTEN flags. */
4128 output_pending_types_for_scope (NULL
);
4130 /* The above call should have totally emptied the pending_types_list. */
4132 assert (pending_types
== 0);
4134 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4136 if (TREE_CODE (decl
) == FUNCTION_DECL
&& DECL_INITIAL (decl
) != NULL
)
4137 current_funcdef_number
++;
4140 /* Output a marker (i.e. a label) for the beginning of the generated code
4141 for a lexical block. */
4144 dwarfout_begin_block (blocknum
)
4145 register unsigned blocknum
;
4147 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4150 sprintf (label
, BLOCK_BEGIN_LABEL_FMT
, blocknum
);
4151 ASM_OUTPUT_LABEL (asm_out_file
, label
);
4154 /* Output a marker (i.e. a label) for the end of the generated code
4155 for a lexical block. */
4158 dwarfout_end_block (blocknum
)
4159 register unsigned blocknum
;
4161 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4164 sprintf (label
, BLOCK_END_LABEL_FMT
, blocknum
);
4165 ASM_OUTPUT_LABEL (asm_out_file
, label
);
4168 /* Output a marker (i.e. a label) at a point in the assembly code which
4169 corresponds to a given source level label. */
4172 dwarfout_label (insn
)
4175 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
4177 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4180 sprintf (label
, INSN_LABEL_FMT
, current_funcdef_number
,
4181 (unsigned) INSN_UID (insn
));
4182 ASM_OUTPUT_LABEL (asm_out_file
, label
);
4186 /* Output a marker (i.e. a label) for the absolute end of the generated code
4187 for a function definition. This gets called *after* the epilogue code
4188 has been generated. */
4191 dwarfout_end_epilogue ()
4193 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4195 /* Output a label to mark the endpoint of the code generated for this
4198 sprintf (label
, FUNC_END_LABEL_FMT
, current_funcdef_number
);
4199 ASM_OUTPUT_LABEL (asm_out_file
, label
);
4203 shuffle_filename_entry (new_zeroth
)
4204 register filename_entry
*new_zeroth
;
4206 filename_entry temp_entry
;
4207 register filename_entry
*limit_p
;
4208 register filename_entry
*move_p
;
4210 if (new_zeroth
== &filename_table
[0])
4213 temp_entry
= *new_zeroth
;
4215 /* Shift entries up in the table to make room at [0]. */
4217 limit_p
= &filename_table
[0];
4218 for (move_p
= new_zeroth
; move_p
> limit_p
; move_p
--)
4219 *move_p
= *(move_p
-1);
4221 /* Install the found entry at [0]. */
4223 filename_table
[0] = temp_entry
;
4226 /* Create a new (string) entry for the .debug_sfnames section. */
4229 generate_new_sfname_entry ()
4231 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4233 fputc ('\n', asm_out_file
);
4234 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, SFNAMES_SECTION
);
4235 sprintf (label
, SFNAMES_ENTRY_LABEL_FMT
, filename_table
[0].number
);
4236 ASM_OUTPUT_LABEL (asm_out_file
, label
);
4237 ASM_OUTPUT_DWARF_STRING (asm_out_file
,
4238 filename_table
[0].name
4239 ? filename_table
[0].name
4241 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4244 /* Lookup a filename (in the list of filenames that we know about here in
4245 dwarfout.c) and return its "index". The index of each (known) filename
4246 is just a unique number which is associated with only that one filename.
4247 We need such numbers for the sake of generating labels (in the
4248 .debug_sfnames section) and references to those unique labels (in the
4249 .debug_srcinfo and .debug_macinfo sections).
4251 If the filename given as an argument is not found in our current list,
4252 add it to the list and assign it the next available unique index number.
4254 Whatever we do (i.e. whether we find a pre-existing filename or add a new
4255 one), we shuffle the filename found (or added) up to the zeroth entry of
4256 our list of filenames (which is always searched linearly). We do this so
4257 as to optimize the most common case for these filename lookups within
4258 dwarfout.c. The most common case by far is the case where we call
4259 lookup_filename to lookup the very same filename that we did a lookup
4260 on the last time we called lookup_filename. We make sure that this
4261 common case is fast because such cases will constitute 99.9% of the
4262 lookups we ever do (in practice).
4264 If we add a new filename entry to our table, we go ahead and generate
4265 the corresponding entry in the .debug_sfnames section right away.
4266 Doing so allows us to avoid tickling an assembler bug (present in some
4267 m68k assemblers) which yields assembly-time errors in cases where the
4268 difference of two label addresses is taken and where the two labels
4269 are in a section *other* than the one where the difference is being
4270 calculated, and where at least one of the two symbol references is a
4271 forward reference. (This bug could be tickled by our .debug_srcinfo
4272 entries if we don't output their corresponding .debug_sfnames entries
4277 lookup_filename (file_name
)
4280 register filename_entry
*search_p
;
4281 register filename_entry
*limit_p
= &filename_table
[ft_entries
];
4283 for (search_p
= filename_table
; search_p
< limit_p
; search_p
++)
4284 if (!strcmp (file_name
, search_p
->name
))
4286 /* When we get here, we have found the filename that we were
4287 looking for in the filename_table. Now we want to make sure
4288 that it gets moved to the zero'th entry in the table (if it
4289 is not already there) so that subsequent attempts to find the
4290 same filename will find it as quickly as possible. */
4292 shuffle_filename_entry (search_p
);
4293 return filename_table
[0].number
;
4296 /* We come here whenever we have a new filename which is not registered
4297 in the current table. Here we add it to the table. */
4299 /* Prepare to add a new table entry by making sure there is enough space
4300 in the table to do so. If not, expand the current table. */
4302 if (ft_entries
== ft_entries_allocated
)
4304 ft_entries_allocated
+= FT_ENTRIES_INCREMENT
;
4306 = (filename_entry
*)
4307 xrealloc (filename_table
,
4308 ft_entries_allocated
* sizeof (filename_entry
));
4311 /* Initially, add the new entry at the end of the filename table. */
4313 filename_table
[ft_entries
].number
= ft_entries
;
4314 filename_table
[ft_entries
].name
= xstrdup (file_name
);
4316 /* Shuffle the new entry into filename_table[0]. */
4318 shuffle_filename_entry (&filename_table
[ft_entries
]);
4320 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
4321 generate_new_sfname_entry ();
4324 return filename_table
[0].number
;
4328 generate_srcinfo_entry (line_entry_num
, files_entry_num
)
4329 unsigned line_entry_num
;
4330 unsigned files_entry_num
;
4332 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4334 fputc ('\n', asm_out_file
);
4335 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, SRCINFO_SECTION
);
4336 sprintf (label
, LINE_ENTRY_LABEL_FMT
, line_entry_num
);
4337 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, label
, LINE_BEGIN_LABEL
);
4338 sprintf (label
, SFNAMES_ENTRY_LABEL_FMT
, files_entry_num
);
4339 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, label
, SFNAMES_BEGIN_LABEL
);
4340 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4344 dwarfout_line (filename
, line
)
4345 register char *filename
;
4346 register unsigned line
;
4348 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
4350 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4351 static unsigned last_line_entry_num
= 0;
4352 static unsigned prev_file_entry_num
= (unsigned) -1;
4353 register unsigned this_file_entry_num
= lookup_filename (filename
);
4356 sprintf (label
, LINE_CODE_LABEL_FMT
, ++last_line_entry_num
);
4357 ASM_OUTPUT_LABEL (asm_out_file
, label
);
4359 fputc ('\n', asm_out_file
);
4360 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, LINE_SECTION
);
4362 if (this_file_entry_num
!= prev_file_entry_num
)
4364 char line_entry_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4366 sprintf (line_entry_label
, LINE_ENTRY_LABEL_FMT
, last_line_entry_num
);
4367 ASM_OUTPUT_LABEL (asm_out_file
, line_entry_label
);
4371 register char *tail
= strrchr (filename
, '/');
4377 fprintf (asm_out_file
, "\t%s\t%u\t%s %s:%u\n",
4378 UNALIGNED_INT_ASM_OP
, line
, ASM_COMMENT_START
,
4380 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, 0xffff);
4381 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, label
, TEXT_BEGIN_LABEL
);
4382 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4384 if (this_file_entry_num
!= prev_file_entry_num
)
4385 generate_srcinfo_entry (last_line_entry_num
, this_file_entry_num
);
4386 prev_file_entry_num
= this_file_entry_num
;
4390 /* Generate an entry in the .debug_macinfo section. */
4393 generate_macinfo_entry (type_and_offset
, string
)
4394 register char *type_and_offset
;
4395 register char *string
;
4397 fputc ('\n', asm_out_file
);
4398 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, MACINFO_SECTION
);
4399 fprintf (asm_out_file
, "\t%s\t%s\n", UNALIGNED_INT_ASM_OP
, type_and_offset
);
4400 ASM_OUTPUT_DWARF_STRING (asm_out_file
, string
);
4401 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4405 dwarfout_start_new_source_file (filename
)
4406 register char *filename
;
4408 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4409 char type_and_offset
[MAX_ARTIFICIAL_LABEL_BYTES
*3];
4411 sprintf (label
, SFNAMES_ENTRY_LABEL_FMT
, lookup_filename (filename
));
4412 sprintf (type_and_offset
, "0x%08x+%s-%s",
4413 ((unsigned) MACINFO_start
<< 24), label
, SFNAMES_BEGIN_LABEL
);
4414 generate_macinfo_entry (type_and_offset
, "");
4418 dwarfout_resume_previous_source_file (lineno
)
4419 register unsigned lineno
;
4421 char type_and_offset
[MAX_ARTIFICIAL_LABEL_BYTES
*2];
4423 sprintf (type_and_offset
, "0x%08x+%u",
4424 ((unsigned) MACINFO_resume
<< 24), lineno
);
4425 generate_macinfo_entry (type_and_offset
, "");
4428 /* Called from check_newline in c-parse.y. The `buffer' parameter
4429 contains the tail part of the directive line, i.e. the part which
4430 is past the initial whitespace, #, whitespace, directive-name,
4434 dwarfout_define (lineno
, buffer
)
4435 register unsigned lineno
;
4436 register char *buffer
;
4438 static int initialized
= 0;
4439 char type_and_offset
[MAX_ARTIFICIAL_LABEL_BYTES
*2];
4443 dwarfout_start_new_source_file (primary_filename
);
4446 sprintf (type_and_offset
, "0x%08x+%u",
4447 ((unsigned) MACINFO_define
<< 24), lineno
);
4448 generate_macinfo_entry (type_and_offset
, buffer
);
4451 /* Called from check_newline in c-parse.y. The `buffer' parameter
4452 contains the tail part of the directive line, i.e. the part which
4453 is past the initial whitespace, #, whitespace, directive-name,
4457 dwarfout_undef (lineno
, buffer
)
4458 register unsigned lineno
;
4459 register char *buffer
;
4461 char type_and_offset
[MAX_ARTIFICIAL_LABEL_BYTES
*2];
4463 sprintf (type_and_offset
, "0x%08x+%u",
4464 ((unsigned) MACINFO_undef
<< 24), lineno
);
4465 generate_macinfo_entry (type_and_offset
, buffer
);
4468 /* Set up for Dwarf output at the start of compilation. */
4471 dwarfout_init (asm_out_file
, main_input_filename
)
4472 register FILE *asm_out_file
;
4473 register char *main_input_filename
;
4475 /* Remember the name of the primary input file. */
4477 primary_filename
= main_input_filename
;
4479 /* Allocate the initial hunk of the pending_sibling_stack. */
4481 pending_sibling_stack
4483 xmalloc (PENDING_SIBLINGS_INCREMENT
* sizeof (unsigned));
4484 pending_siblings_allocated
= PENDING_SIBLINGS_INCREMENT
;
4485 pending_siblings
= 1;
4487 /* Allocate the initial hunk of the filename_table. */
4490 = (filename_entry
*)
4491 xmalloc (FT_ENTRIES_INCREMENT
* sizeof (filename_entry
));
4492 ft_entries_allocated
= FT_ENTRIES_INCREMENT
;
4495 /* Allocate the initial hunk of the pending_types_list. */
4498 = (tree
*) xmalloc (PENDING_TYPES_INCREMENT
* sizeof (tree
));
4499 pending_types_allocated
= PENDING_TYPES_INCREMENT
;
4502 /* Create an artificial RECORD_TYPE node which we can use in our hack
4503 to get the DIEs representing types of formal parameters to come out
4504 only *after* the DIEs for the formal parameters themselves. */
4506 fake_containing_scope
= make_node (RECORD_TYPE
);
4508 /* Output a starting label for the .text section. */
4510 fputc ('\n', asm_out_file
);
4511 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, TEXT_SECTION
);
4512 ASM_OUTPUT_LABEL (asm_out_file
, TEXT_BEGIN_LABEL
);
4513 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4515 /* Output a starting label for the .data section. */
4517 fputc ('\n', asm_out_file
);
4518 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DATA_SECTION
);
4519 ASM_OUTPUT_LABEL (asm_out_file
, DATA_BEGIN_LABEL
);
4520 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4522 /* Output a starting label for the .data1 section. */
4524 fputc ('\n', asm_out_file
);
4525 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DATA1_SECTION
);
4526 ASM_OUTPUT_LABEL (asm_out_file
, DATA1_BEGIN_LABEL
);
4527 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4529 /* Output a starting label for the .rodata section. */
4531 fputc ('\n', asm_out_file
);
4532 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, RODATA_SECTION
);
4533 ASM_OUTPUT_LABEL (asm_out_file
, RODATA_BEGIN_LABEL
);
4534 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4536 /* Output a starting label for the .rodata1 section. */
4538 fputc ('\n', asm_out_file
);
4539 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, RODATA1_SECTION
);
4540 ASM_OUTPUT_LABEL (asm_out_file
, RODATA1_BEGIN_LABEL
);
4541 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4543 /* Output a starting label for the .bss section. */
4545 fputc ('\n', asm_out_file
);
4546 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, BSS_SECTION
);
4547 ASM_OUTPUT_LABEL (asm_out_file
, BSS_BEGIN_LABEL
);
4548 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4550 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
4552 /* Output a starting label and an initial (compilation directory)
4553 entry for the .debug_sfnames section. The starting label will be
4554 referenced by the initial entry in the .debug_srcinfo section. */
4556 fputc ('\n', asm_out_file
);
4557 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, SFNAMES_SECTION
);
4558 ASM_OUTPUT_LABEL (asm_out_file
, SFNAMES_BEGIN_LABEL
);
4560 register char *pwd
= getpwd ();
4561 register unsigned len
= strlen (pwd
);
4562 register char *dirname
= (char *) xmalloc (len
+ 2);
4564 strcpy (dirname
, pwd
);
4565 strcpy (dirname
+ len
, "/");
4566 ASM_OUTPUT_DWARF_STRING (asm_out_file
, dirname
);
4569 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4571 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
4573 /* Output a starting label for the .debug_macinfo section. This
4574 label will be referenced by the AT_mac_info attribute in the
4575 TAG_compile_unit DIE. */
4577 fputc ('\n', asm_out_file
);
4578 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, MACINFO_SECTION
);
4579 ASM_OUTPUT_LABEL (asm_out_file
, MACINFO_BEGIN_LABEL
);
4580 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4583 /* Generate the initial entry for the .line section. */
4585 fputc ('\n', asm_out_file
);
4586 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, LINE_SECTION
);
4587 ASM_OUTPUT_LABEL (asm_out_file
, LINE_BEGIN_LABEL
);
4588 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, LINE_END_LABEL
, LINE_BEGIN_LABEL
);
4589 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_BEGIN_LABEL
);
4590 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4592 /* Generate the initial entry for the .debug_srcinfo section. */
4594 fputc ('\n', asm_out_file
);
4595 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, SRCINFO_SECTION
);
4596 ASM_OUTPUT_LABEL (asm_out_file
, SRCINFO_BEGIN_LABEL
);
4597 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, LINE_BEGIN_LABEL
);
4598 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, SFNAMES_BEGIN_LABEL
);
4599 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_BEGIN_LABEL
);
4600 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_END_LABEL
);
4601 #ifdef DWARF_TIMESTAMPS
4602 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, time (NULL
));
4604 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, -1);
4606 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4608 /* Generate the initial entry for the .debug_pubnames section. */
4610 fputc ('\n', asm_out_file
);
4611 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, PUBNAMES_SECTION
);
4612 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, DEBUG_BEGIN_LABEL
);
4613 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4615 /* Generate the initial entry for the .debug_aranges section. */
4617 fputc ('\n', asm_out_file
);
4618 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, ARANGES_SECTION
);
4619 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, DEBUG_BEGIN_LABEL
);
4620 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4623 /* Setup first DIE number == 1. */
4624 NEXT_DIE_NUM
= next_unused_dienum
++;
4626 /* Generate the initial DIE for the .debug section. Note that the
4627 (string) value given in the AT_name attribute of the TAG_compile_unit
4628 DIE will (typically) be a relative pathname and that this pathname
4629 should be taken as being relative to the directory from which the
4630 compiler was invoked when the given (base) source file was compiled. */
4632 fputc ('\n', asm_out_file
);
4633 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DEBUG_SECTION
);
4634 ASM_OUTPUT_LABEL (asm_out_file
, DEBUG_BEGIN_LABEL
);
4635 output_die (output_compile_unit_die
, main_input_filename
);
4636 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4638 fputc ('\n', asm_out_file
);
4641 /* Output stuff that dwarf requires at the end of every file. */
4646 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4648 fputc ('\n', asm_out_file
);
4649 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DEBUG_SECTION
);
4651 /* Mark the end of the chain of siblings which represent all file-scope
4652 declarations in this compilation unit. */
4654 /* The (null) DIE which represents the terminator for the (sibling linked)
4655 list of file-scope items is *special*. Normally, we would just call
4656 end_sibling_chain at this point in order to output a word with the
4657 value `4' and that word would act as the terminator for the list of
4658 DIEs describing file-scope items. Unfortunately, if we were to simply
4659 do that, the label that would follow this DIE in the .debug section
4660 (i.e. `..D2') would *not* be properly aligned (as it must be on some
4661 machines) to a 4 byte boundary.
4663 In order to force the label `..D2' to get aligned to a 4 byte boundary,
4664 the trick used is to insert extra (otherwise useless) padding bytes
4665 into the (null) DIE that we know must precede the ..D2 label in the
4666 .debug section. The amount of padding required can be anywhere between
4667 0 and 3 bytes. The length word at the start of this DIE (i.e. the one
4668 with the padding) would normally contain the value 4, but now it will
4669 also have to include the padding bytes, so it will instead have some
4670 value in the range 4..7.
4672 Fortunately, the rules of Dwarf say that any DIE whose length word
4673 contains *any* value less than 8 should be treated as a null DIE, so
4674 this trick works out nicely. Clever, eh? Don't give me any credit
4675 (or blame). I didn't think of this scheme. I just conformed to it.
4678 output_die (output_padded_null_die
, (void *)0);
4681 sprintf (label
, DIE_BEGIN_LABEL_FMT
, NEXT_DIE_NUM
);
4682 ASM_OUTPUT_LABEL (asm_out_file
, label
); /* should be ..D2 */
4683 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4685 /* Output a terminator label for the .text section. */
4687 fputc ('\n', asm_out_file
);
4688 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, TEXT_SECTION
);
4689 ASM_OUTPUT_LABEL (asm_out_file
, TEXT_END_LABEL
);
4690 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4692 /* Output a terminator label for the .data section. */
4694 fputc ('\n', asm_out_file
);
4695 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DATA_SECTION
);
4696 ASM_OUTPUT_LABEL (asm_out_file
, DATA_END_LABEL
);
4697 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4699 /* Output a terminator label for the .data1 section. */
4701 fputc ('\n', asm_out_file
);
4702 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DATA1_SECTION
);
4703 ASM_OUTPUT_LABEL (asm_out_file
, DATA1_END_LABEL
);
4704 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4706 /* Output a terminator label for the .rodata section. */
4708 fputc ('\n', asm_out_file
);
4709 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, RODATA_SECTION
);
4710 ASM_OUTPUT_LABEL (asm_out_file
, RODATA_END_LABEL
);
4711 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4713 /* Output a terminator label for the .rodata1 section. */
4715 fputc ('\n', asm_out_file
);
4716 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, RODATA1_SECTION
);
4717 ASM_OUTPUT_LABEL (asm_out_file
, RODATA1_END_LABEL
);
4718 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4720 /* Output a terminator label for the .bss section. */
4722 fputc ('\n', asm_out_file
);
4723 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, BSS_SECTION
);
4724 ASM_OUTPUT_LABEL (asm_out_file
, BSS_END_LABEL
);
4725 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4727 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
4729 /* Output a terminating entry for the .line section. */
4731 fputc ('\n', asm_out_file
);
4732 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, LINE_SECTION
);
4733 ASM_OUTPUT_LABEL (asm_out_file
, LINE_LAST_ENTRY_LABEL
);
4734 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
4735 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, 0xffff);
4736 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, TEXT_END_LABEL
, TEXT_BEGIN_LABEL
);
4737 ASM_OUTPUT_LABEL (asm_out_file
, LINE_END_LABEL
);
4738 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4740 /* Output a terminating entry for the .debug_srcinfo section. */
4742 fputc ('\n', asm_out_file
);
4743 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, SRCINFO_SECTION
);
4744 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
,
4745 LINE_LAST_ENTRY_LABEL
, LINE_BEGIN_LABEL
);
4746 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, -1);
4747 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4749 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
4751 /* Output terminating entries for the .debug_macinfo section. */
4753 dwarfout_resume_previous_source_file (0);
4755 fputc ('\n', asm_out_file
);
4756 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, MACINFO_SECTION
);
4757 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
4758 ASM_OUTPUT_DWARF_STRING (asm_out_file
, "");
4759 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4762 /* Generate the terminating entry for the .debug_pubnames section. */
4764 fputc ('\n', asm_out_file
);
4765 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, PUBNAMES_SECTION
);
4766 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
4767 ASM_OUTPUT_DWARF_STRING (asm_out_file
, "");
4768 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4770 /* Generate the terminating entries for the .debug_aranges section.
4772 Note that we want to do this only *after* we have output the end
4773 labels (for the various program sections) which we are going to
4774 refer to here. This allows us to work around a bug in the m68k
4775 svr4 assembler. That assembler gives bogus assembly-time errors
4776 if (within any given section) you try to take the difference of
4777 two relocatable symbols, both of which are located within some
4778 other section, and if one (or both?) of the symbols involved is
4779 being forward-referenced. By generating the .debug_aranges
4780 entries at this late point in the assembly output, we skirt the
4781 issue simply by avoiding forward-references.
4784 fputc ('\n', asm_out_file
);
4785 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, ARANGES_SECTION
);
4787 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_BEGIN_LABEL
);
4788 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, TEXT_END_LABEL
, TEXT_BEGIN_LABEL
);
4790 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, DATA_BEGIN_LABEL
);
4791 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, DATA_END_LABEL
, DATA_BEGIN_LABEL
);
4793 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, DATA1_BEGIN_LABEL
);
4794 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, DATA1_END_LABEL
,
4797 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, RODATA_BEGIN_LABEL
);
4798 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, RODATA_END_LABEL
,
4799 RODATA_BEGIN_LABEL
);
4801 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, RODATA1_BEGIN_LABEL
);
4802 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, RODATA1_END_LABEL
,
4803 RODATA1_BEGIN_LABEL
);
4805 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, BSS_BEGIN_LABEL
);
4806 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, BSS_END_LABEL
, BSS_BEGIN_LABEL
);
4808 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
4809 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
4811 ASM_OUTPUT_POP_SECTION (asm_out_file
);
4815 #endif /* DWARF_DEBUGGING_INFO */