1 /* Output Dwarf format symbol table information from the GNU C compiler.
2 Copyright (C) 1992, 1993, 1995, 1996 Free Software Foundation, Inc.
4 Written by Ron Guilmette (rfg@netcom.com) for
5 Network Computing Devices, August, September, October, November 1990.
6 Generously contributed by NCD to the Free Software Foundation.
8 This file is part of GNU CC.
10 GNU CC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
15 GNU CC is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with GNU CC; see the file COPYING. If not, write to
22 the Free Software Foundation, 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
27 #ifdef DWARF_DEBUGGING_INFO
33 #include "hard-reg-set.h"
34 #include "insn-config.h"
40 #define DWARF_VERSION 1
43 /* #define NDEBUG 1 */
46 #if defined(DWARF_TIMESTAMPS)
49 #else /* !defined(POSIX) */
50 #include <sys/types.h>
52 extern time_t time (time_t *);
53 #else /* !defined(__STDC__) */
54 extern time_t time ();
55 #endif /* !defined(__STDC__) */
56 #endif /* !defined(POSIX) */
57 #endif /* defined(DWARF_TIMESTAMPS) */
59 extern char *getpwd ();
61 extern char *index ();
62 extern char *rindex ();
64 /* IMPORTANT NOTE: Please see the file README.DWARF for important details
65 regarding the GNU implementation of Dwarf. */
67 /* NOTE: In the comments in this file, many references are made to
68 so called "Debugging Information Entries". For the sake of brevity,
69 this term is abbreviated to `DIE' throughout the remainder of this
72 /* Note that the implementation of C++ support herein is (as yet) unfinished.
73 If you want to try to complete it, more power to you. */
75 #if defined(__GNUC__) && (NDEBUG == 1)
76 #define inline static inline
81 /* How to start an assembler comment. */
82 #ifndef ASM_COMMENT_START
83 #define ASM_COMMENT_START ";#"
86 /* How to print out a register name. */
88 #define PRINT_REG(RTX, CODE, FILE) \
89 fprintf ((FILE), "%s", reg_names[REGNO (RTX)])
92 /* Define a macro which returns non-zero for any tagged type which is
93 used (directly or indirectly) in the specification of either some
94 function's return type or some formal parameter of some function.
95 We use this macro when we are operating in "terse" mode to help us
96 know what tagged types have to be represented in Dwarf (even in
97 terse mode) and which ones don't.
99 A flag bit with this meaning really should be a part of the normal
100 GCC ..._TYPE nodes, but at the moment, there is no such bit defined
101 for these nodes. For now, we have to just fake it. It it safe for
102 us to simply return zero for all complete tagged types (which will
103 get forced out anyway if they were used in the specification of some
104 formal or return type) and non-zero for all incomplete tagged types.
107 #define TYPE_USED_FOR_FUNCTION(tagged_type) (TYPE_SIZE (tagged_type) == 0)
109 extern int flag_traditional;
110 extern char *version_string;
111 extern char *language_string;
113 /* Maximum size (in bytes) of an artificially generated label. */
115 #define MAX_ARTIFICIAL_LABEL_BYTES 30
117 /* Make sure we know the sizes of the various types dwarf can describe.
118 These are only defaults. If the sizes are different for your target,
119 you should override these values by defining the appropriate symbols
120 in your tm.h file. */
122 #ifndef CHAR_TYPE_SIZE
123 #define CHAR_TYPE_SIZE BITS_PER_UNIT
126 #ifndef SHORT_TYPE_SIZE
127 #define SHORT_TYPE_SIZE (BITS_PER_UNIT * 2)
130 #ifndef INT_TYPE_SIZE
131 #define INT_TYPE_SIZE BITS_PER_WORD
134 #ifndef LONG_TYPE_SIZE
135 #define LONG_TYPE_SIZE BITS_PER_WORD
138 #ifndef LONG_LONG_TYPE_SIZE
139 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
142 #ifndef WCHAR_TYPE_SIZE
143 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
146 #ifndef WCHAR_UNSIGNED
147 #define WCHAR_UNSIGNED 0
150 #ifndef FLOAT_TYPE_SIZE
151 #define FLOAT_TYPE_SIZE BITS_PER_WORD
154 #ifndef DOUBLE_TYPE_SIZE
155 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
158 #ifndef LONG_DOUBLE_TYPE_SIZE
159 #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
162 /* Structure to keep track of source filenames. */
164 struct filename_entry {
169 typedef struct filename_entry filename_entry;
171 /* Pointer to an array of elements, each one having the structure above. */
173 static filename_entry *filename_table;
175 /* Total number of entries in the table (i.e. array) pointed to by
176 `filename_table'. This is the *total* and includes both used and
179 static unsigned ft_entries_allocated;
181 /* Number of entries in the filename_table which are actually in use. */
183 static unsigned ft_entries;
185 /* Size (in elements) of increments by which we may expand the filename
186 table. Actually, a single hunk of space of this size should be enough
187 for most typical programs. */
189 #define FT_ENTRIES_INCREMENT 64
191 /* Local pointer to the name of the main input file. Initialized in
194 static char *primary_filename;
196 /* Pointer to the most recent filename for which we produced some line info. */
198 static char *last_filename;
200 /* For Dwarf output, we must assign lexical-blocks id numbers
201 in the order in which their beginnings are encountered.
202 We output Dwarf debugging info that refers to the beginnings
203 and ends of the ranges of code for each lexical block with
204 assembler labels ..Bn and ..Bn.e, where n is the block number.
205 The labels themselves are generated in final.c, which assigns
206 numbers to the blocks in the same way. */
208 static unsigned next_block_number = 2;
210 /* Counter to generate unique names for DIEs. */
212 static unsigned next_unused_dienum = 1;
214 /* Number of the DIE which is currently being generated. */
216 static unsigned current_dienum;
218 /* Number to use for the special "pubname" label on the next DIE which
219 represents a function or data object defined in this compilation
220 unit which has "extern" linkage. */
222 static next_pubname_number = 0;
224 #define NEXT_DIE_NUM pending_sibling_stack[pending_siblings-1]
226 /* Pointer to a dynamically allocated list of pre-reserved and still
227 pending sibling DIE numbers. Note that this list will grow as needed. */
229 static unsigned *pending_sibling_stack;
231 /* Counter to keep track of the number of pre-reserved and still pending
232 sibling DIE numbers. */
234 static unsigned pending_siblings;
236 /* The currently allocated size of the above list (expressed in number of
239 static unsigned pending_siblings_allocated;
241 /* Size (in elements) of increments by which we may expand the pending
242 sibling stack. Actually, a single hunk of space of this size should
243 be enough for most typical programs. */
245 #define PENDING_SIBLINGS_INCREMENT 64
247 /* Non-zero if we are performing our file-scope finalization pass and if
248 we should force out Dwarf descriptions of any and all file-scope
249 tagged types which are still incomplete types. */
251 static int finalizing = 0;
253 /* A pointer to the base of a list of pending types which we haven't
254 generated DIEs for yet, but which we will have to come back to
257 static tree *pending_types_list;
259 /* Number of elements currently allocated for the pending_types_list. */
261 static unsigned pending_types_allocated;
263 /* Number of elements of pending_types_list currently in use. */
265 static unsigned pending_types;
267 /* Size (in elements) of increments by which we may expand the pending
268 types list. Actually, a single hunk of space of this size should
269 be enough for most typical programs. */
271 #define PENDING_TYPES_INCREMENT 64
273 /* Pointer to an artificial RECORD_TYPE which we create in dwarfout_init.
274 This is used in a hack to help us get the DIEs describing types of
275 formal parameters to come *after* all of the DIEs describing the formal
276 parameters themselves. That's necessary in order to be compatible
277 with what the brain-damaged svr4 SDB debugger requires. */
279 static tree fake_containing_scope;
281 /* The number of the current function definition that we are generating
282 debugging information for. These numbers range from 1 up to the maximum
283 number of function definitions contained within the current compilation
284 unit. These numbers are used to create unique labels for various things
285 contained within various function definitions. */
287 static unsigned current_funcdef_number = 1;
289 /* A pointer to the ..._DECL node which we have most recently been working
290 on. We keep this around just in case something about it looks screwy
291 and we want to tell the user what the source coordinates for the actual
294 static tree dwarf_last_decl;
296 /* Forward declarations for functions defined in this file. */
298 static void output_type ();
299 static void type_attribute ();
300 static void output_decls_for_scope ();
301 static void output_decl ();
302 static unsigned lookup_filename ();
304 /* Definitions of defaults for assembler-dependent names of various
305 pseudo-ops and section names.
307 Theses may be overridden in your tm.h file (if necessary) for your
308 particular assembler. The default values provided here correspond to
309 what is expected by "standard" AT&T System V.4 assemblers. */
312 #define FILE_ASM_OP ".file"
314 #ifndef VERSION_ASM_OP
315 #define VERSION_ASM_OP ".version"
317 #ifndef UNALIGNED_SHORT_ASM_OP
318 #define UNALIGNED_SHORT_ASM_OP ".2byte"
320 #ifndef UNALIGNED_INT_ASM_OP
321 #define UNALIGNED_INT_ASM_OP ".4byte"
324 #define ASM_BYTE_OP ".byte"
327 #define SET_ASM_OP ".set"
330 /* Pseudo-ops for pushing the current section onto the section stack (and
331 simultaneously changing to a new section) and for poping back to the
332 section we were in immediately before this one. Note that most svr4
333 assemblers only maintain a one level stack... you can push all the
334 sections you want, but you can only pop out one level. (The sparc
335 svr4 assembler is an exception to this general rule.) That's
336 OK because we only use at most one level of the section stack herein. */
338 #ifndef PUSHSECTION_ASM_OP
339 #define PUSHSECTION_ASM_OP ".section"
341 #ifndef POPSECTION_ASM_OP
342 #define POPSECTION_ASM_OP ".previous"
345 /* The default format used by the ASM_OUTPUT_PUSH_SECTION macro (see below)
346 to print the PUSHSECTION_ASM_OP and the section name. The default here
347 works for almost all svr4 assemblers, except for the sparc, where the
348 section name must be enclosed in double quotes. (See sparcv4.h.) */
350 #ifndef PUSHSECTION_FORMAT
351 #define PUSHSECTION_FORMAT "\t%s\t%s\n"
354 #ifndef DEBUG_SECTION
355 #define DEBUG_SECTION ".debug"
358 #define LINE_SECTION ".line"
360 #ifndef SFNAMES_SECTION
361 #define SFNAMES_SECTION ".debug_sfnames"
363 #ifndef SRCINFO_SECTION
364 #define SRCINFO_SECTION ".debug_srcinfo"
366 #ifndef MACINFO_SECTION
367 #define MACINFO_SECTION ".debug_macinfo"
369 #ifndef PUBNAMES_SECTION
370 #define PUBNAMES_SECTION ".debug_pubnames"
372 #ifndef ARANGES_SECTION
373 #define ARANGES_SECTION ".debug_aranges"
376 #define TEXT_SECTION ".text"
379 #define DATA_SECTION ".data"
381 #ifndef DATA1_SECTION
382 #define DATA1_SECTION ".data1"
384 #ifndef RODATA_SECTION
385 #define RODATA_SECTION ".rodata"
387 #ifndef RODATA1_SECTION
388 #define RODATA1_SECTION ".rodata1"
391 #define BSS_SECTION ".bss"
394 /* Definitions of defaults for formats and names of various special
395 (artificial) labels which may be generated within this file (when
396 the -g options is used and DWARF_DEBUGGING_INFO is in effect.
398 If necessary, these may be overridden from within your tm.h file,
399 but typically, you should never need to override these.
401 These labels have been hacked (temporarily) so that they all begin with
402 a `.L' sequence so as to appease the stock sparc/svr4 assembler and the
403 stock m88k/svr4 assembler, both of which need to see .L at the start of
404 a label in order to prevent that label from going into the linker symbol
405 table). When I get time, I'll have to fix this the right way so that we
406 will use ASM_GENERATE_INTERNAL_LABEL and ASM_OUTPUT_INTERNAL_LABEL herein,
407 but that will require a rather massive set of changes. For the moment,
408 the following definitions out to produce the right results for all svr4
409 and svr3 assemblers. -- rfg
412 #ifndef TEXT_BEGIN_LABEL
413 #define TEXT_BEGIN_LABEL ".L_text_b"
415 #ifndef TEXT_END_LABEL
416 #define TEXT_END_LABEL ".L_text_e"
419 #ifndef DATA_BEGIN_LABEL
420 #define DATA_BEGIN_LABEL ".L_data_b"
422 #ifndef DATA_END_LABEL
423 #define DATA_END_LABEL ".L_data_e"
426 #ifndef DATA1_BEGIN_LABEL
427 #define DATA1_BEGIN_LABEL ".L_data1_b"
429 #ifndef DATA1_END_LABEL
430 #define DATA1_END_LABEL ".L_data1_e"
433 #ifndef RODATA_BEGIN_LABEL
434 #define RODATA_BEGIN_LABEL ".L_rodata_b"
436 #ifndef RODATA_END_LABEL
437 #define RODATA_END_LABEL ".L_rodata_e"
440 #ifndef RODATA1_BEGIN_LABEL
441 #define RODATA1_BEGIN_LABEL ".L_rodata1_b"
443 #ifndef RODATA1_END_LABEL
444 #define RODATA1_END_LABEL ".L_rodata1_e"
447 #ifndef BSS_BEGIN_LABEL
448 #define BSS_BEGIN_LABEL ".L_bss_b"
450 #ifndef BSS_END_LABEL
451 #define BSS_END_LABEL ".L_bss_e"
454 #ifndef LINE_BEGIN_LABEL
455 #define LINE_BEGIN_LABEL ".L_line_b"
457 #ifndef LINE_LAST_ENTRY_LABEL
458 #define LINE_LAST_ENTRY_LABEL ".L_line_last"
460 #ifndef LINE_END_LABEL
461 #define LINE_END_LABEL ".L_line_e"
464 #ifndef DEBUG_BEGIN_LABEL
465 #define DEBUG_BEGIN_LABEL ".L_debug_b"
467 #ifndef SFNAMES_BEGIN_LABEL
468 #define SFNAMES_BEGIN_LABEL ".L_sfnames_b"
470 #ifndef SRCINFO_BEGIN_LABEL
471 #define SRCINFO_BEGIN_LABEL ".L_srcinfo_b"
473 #ifndef MACINFO_BEGIN_LABEL
474 #define MACINFO_BEGIN_LABEL ".L_macinfo_b"
477 #ifndef DIE_BEGIN_LABEL_FMT
478 #define DIE_BEGIN_LABEL_FMT ".L_D%u"
480 #ifndef DIE_END_LABEL_FMT
481 #define DIE_END_LABEL_FMT ".L_D%u_e"
483 #ifndef PUB_DIE_LABEL_FMT
484 #define PUB_DIE_LABEL_FMT ".L_P%u"
486 #ifndef INSN_LABEL_FMT
487 #define INSN_LABEL_FMT ".L_I%u_%u"
489 #ifndef BLOCK_BEGIN_LABEL_FMT
490 #define BLOCK_BEGIN_LABEL_FMT ".L_B%u"
492 #ifndef BLOCK_END_LABEL_FMT
493 #define BLOCK_END_LABEL_FMT ".L_B%u_e"
495 #ifndef SS_BEGIN_LABEL_FMT
496 #define SS_BEGIN_LABEL_FMT ".L_s%u"
498 #ifndef SS_END_LABEL_FMT
499 #define SS_END_LABEL_FMT ".L_s%u_e"
501 #ifndef EE_BEGIN_LABEL_FMT
502 #define EE_BEGIN_LABEL_FMT ".L_e%u"
504 #ifndef EE_END_LABEL_FMT
505 #define EE_END_LABEL_FMT ".L_e%u_e"
507 #ifndef MT_BEGIN_LABEL_FMT
508 #define MT_BEGIN_LABEL_FMT ".L_t%u"
510 #ifndef MT_END_LABEL_FMT
511 #define MT_END_LABEL_FMT ".L_t%u_e"
513 #ifndef LOC_BEGIN_LABEL_FMT
514 #define LOC_BEGIN_LABEL_FMT ".L_l%u"
516 #ifndef LOC_END_LABEL_FMT
517 #define LOC_END_LABEL_FMT ".L_l%u_e"
519 #ifndef BOUND_BEGIN_LABEL_FMT
520 #define BOUND_BEGIN_LABEL_FMT ".L_b%u_%u_%c"
522 #ifndef BOUND_END_LABEL_FMT
523 #define BOUND_END_LABEL_FMT ".L_b%u_%u_%c_e"
525 #ifndef DERIV_BEGIN_LABEL_FMT
526 #define DERIV_BEGIN_LABEL_FMT ".L_d%u"
528 #ifndef DERIV_END_LABEL_FMT
529 #define DERIV_END_LABEL_FMT ".L_d%u_e"
531 #ifndef SL_BEGIN_LABEL_FMT
532 #define SL_BEGIN_LABEL_FMT ".L_sl%u"
534 #ifndef SL_END_LABEL_FMT
535 #define SL_END_LABEL_FMT ".L_sl%u_e"
537 #ifndef BODY_BEGIN_LABEL_FMT
538 #define BODY_BEGIN_LABEL_FMT ".L_b%u"
540 #ifndef BODY_END_LABEL_FMT
541 #define BODY_END_LABEL_FMT ".L_b%u_e"
543 #ifndef FUNC_END_LABEL_FMT
544 #define FUNC_END_LABEL_FMT ".L_f%u_e"
546 #ifndef TYPE_NAME_FMT
547 #define TYPE_NAME_FMT ".L_T%u"
549 #ifndef DECL_NAME_FMT
550 #define DECL_NAME_FMT ".L_E%u"
552 #ifndef LINE_CODE_LABEL_FMT
553 #define LINE_CODE_LABEL_FMT ".L_LC%u"
555 #ifndef SFNAMES_ENTRY_LABEL_FMT
556 #define SFNAMES_ENTRY_LABEL_FMT ".L_F%u"
558 #ifndef LINE_ENTRY_LABEL_FMT
559 #define LINE_ENTRY_LABEL_FMT ".L_LE%u"
562 /* Definitions of defaults for various types of primitive assembly language
565 If necessary, these may be overridden from within your tm.h file,
566 but typically, you shouldn't need to override these. */
568 #ifndef ASM_OUTPUT_PUSH_SECTION
569 #define ASM_OUTPUT_PUSH_SECTION(FILE, SECTION) \
570 fprintf ((FILE), PUSHSECTION_FORMAT, PUSHSECTION_ASM_OP, SECTION)
573 #ifndef ASM_OUTPUT_POP_SECTION
574 #define ASM_OUTPUT_POP_SECTION(FILE) \
575 fprintf ((FILE), "\t%s\n", POPSECTION_ASM_OP)
578 #ifndef ASM_OUTPUT_SOURCE_FILENAME
579 #define ASM_OUTPUT_SOURCE_FILENAME(FILE,NAME) \
580 do { fprintf (FILE, "\t%s\t", FILE_ASM_OP); \
581 output_quoted_string (FILE, NAME); \
582 fputc ('\n', FILE); \
586 #ifndef ASM_OUTPUT_DWARF_DELTA2
587 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
588 do { fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \
589 assemble_name (FILE, LABEL1); \
590 fprintf (FILE, "-"); \
591 assemble_name (FILE, LABEL2); \
592 fprintf (FILE, "\n"); \
596 #ifndef ASM_OUTPUT_DWARF_DELTA4
597 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
598 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
599 assemble_name (FILE, LABEL1); \
600 fprintf (FILE, "-"); \
601 assemble_name (FILE, LABEL2); \
602 fprintf (FILE, "\n"); \
606 #ifndef ASM_OUTPUT_DWARF_TAG
607 #define ASM_OUTPUT_DWARF_TAG(FILE,TAG) \
609 fprintf ((FILE), "\t%s\t0x%x", \
610 UNALIGNED_SHORT_ASM_OP, (unsigned) TAG); \
611 if (flag_verbose_asm) \
612 fprintf ((FILE), "\t%s %s", \
613 ASM_COMMENT_START, dwarf_tag_name (TAG)); \
614 fputc ('\n', (FILE)); \
618 #ifndef ASM_OUTPUT_DWARF_ATTRIBUTE
619 #define ASM_OUTPUT_DWARF_ATTRIBUTE(FILE,ATTR) \
621 fprintf ((FILE), "\t%s\t0x%x", \
622 UNALIGNED_SHORT_ASM_OP, (unsigned) ATTR); \
623 if (flag_verbose_asm) \
624 fprintf ((FILE), "\t%s %s", \
625 ASM_COMMENT_START, dwarf_attr_name (ATTR)); \
626 fputc ('\n', (FILE)); \
630 #ifndef ASM_OUTPUT_DWARF_STACK_OP
631 #define ASM_OUTPUT_DWARF_STACK_OP(FILE,OP) \
633 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) OP); \
634 if (flag_verbose_asm) \
635 fprintf ((FILE), "\t%s %s", \
636 ASM_COMMENT_START, dwarf_stack_op_name (OP)); \
637 fputc ('\n', (FILE)); \
641 #ifndef ASM_OUTPUT_DWARF_FUND_TYPE
642 #define ASM_OUTPUT_DWARF_FUND_TYPE(FILE,FT) \
644 fprintf ((FILE), "\t%s\t0x%x", \
645 UNALIGNED_SHORT_ASM_OP, (unsigned) FT); \
646 if (flag_verbose_asm) \
647 fprintf ((FILE), "\t%s %s", \
648 ASM_COMMENT_START, dwarf_fund_type_name (FT)); \
649 fputc ('\n', (FILE)); \
653 #ifndef ASM_OUTPUT_DWARF_FMT_BYTE
654 #define ASM_OUTPUT_DWARF_FMT_BYTE(FILE,FMT) \
656 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) FMT); \
657 if (flag_verbose_asm) \
658 fprintf ((FILE), "\t%s %s", \
659 ASM_COMMENT_START, dwarf_fmt_byte_name (FMT)); \
660 fputc ('\n', (FILE)); \
664 #ifndef ASM_OUTPUT_DWARF_TYPE_MODIFIER
665 #define ASM_OUTPUT_DWARF_TYPE_MODIFIER(FILE,MOD) \
667 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) MOD); \
668 if (flag_verbose_asm) \
669 fprintf ((FILE), "\t%s %s", \
670 ASM_COMMENT_START, dwarf_typemod_name (MOD)); \
671 fputc ('\n', (FILE)); \
675 #ifndef ASM_OUTPUT_DWARF_ADDR
676 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
677 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
678 assemble_name (FILE, LABEL); \
679 fprintf (FILE, "\n"); \
683 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
684 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX) \
686 fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
687 output_addr_const ((FILE), (RTX)); \
688 fputc ('\n', (FILE)); \
692 #ifndef ASM_OUTPUT_DWARF_REF
693 #define ASM_OUTPUT_DWARF_REF(FILE,LABEL) \
694 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
695 assemble_name (FILE, LABEL); \
696 fprintf (FILE, "\n"); \
700 #ifndef ASM_OUTPUT_DWARF_DATA1
701 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
702 fprintf ((FILE), "\t%s\t0x%x\n", ASM_BYTE_OP, VALUE)
705 #ifndef ASM_OUTPUT_DWARF_DATA2
706 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
707 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_SHORT_ASM_OP, (unsigned) VALUE)
710 #ifndef ASM_OUTPUT_DWARF_DATA4
711 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
712 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, (unsigned) VALUE)
715 #ifndef ASM_OUTPUT_DWARF_DATA8
716 #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \
718 if (WORDS_BIG_ENDIAN) \
720 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
721 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
725 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
726 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
731 #ifndef ASM_OUTPUT_DWARF_STRING
732 #define ASM_OUTPUT_DWARF_STRING(FILE,P) \
733 ASM_OUTPUT_ASCII ((FILE), P, strlen (P)+1)
736 /************************ general utility functions **************************/
742 return (((GET_CODE (rtl) == REG) && (REGNO (rtl) >= FIRST_PSEUDO_REGISTER))
743 || ((GET_CODE (rtl) == SUBREG)
744 && (REGNO (XEXP (rtl, 0)) >= FIRST_PSEUDO_REGISTER)));
748 type_main_variant (type)
751 type = TYPE_MAIN_VARIANT (type);
753 /* There really should be only one main variant among any group of variants
754 of a given type (and all of the MAIN_VARIANT values for all members of
755 the group should point to that one type) but sometimes the C front-end
756 messes this up for array types, so we work around that bug here. */
758 if (TREE_CODE (type) == ARRAY_TYPE)
760 while (type != TYPE_MAIN_VARIANT (type))
761 type = TYPE_MAIN_VARIANT (type);
767 /* Return non-zero if the given type node represents a tagged type. */
770 is_tagged_type (type)
773 register enum tree_code code = TREE_CODE (type);
775 return (code == RECORD_TYPE || code == UNION_TYPE
776 || code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
781 register unsigned tag;
785 case TAG_padding: return "TAG_padding";
786 case TAG_array_type: return "TAG_array_type";
787 case TAG_class_type: return "TAG_class_type";
788 case TAG_entry_point: return "TAG_entry_point";
789 case TAG_enumeration_type: return "TAG_enumeration_type";
790 case TAG_formal_parameter: return "TAG_formal_parameter";
791 case TAG_global_subroutine: return "TAG_global_subroutine";
792 case TAG_global_variable: return "TAG_global_variable";
793 case TAG_label: return "TAG_label";
794 case TAG_lexical_block: return "TAG_lexical_block";
795 case TAG_local_variable: return "TAG_local_variable";
796 case TAG_member: return "TAG_member";
797 case TAG_pointer_type: return "TAG_pointer_type";
798 case TAG_reference_type: return "TAG_reference_type";
799 case TAG_compile_unit: return "TAG_compile_unit";
800 case TAG_string_type: return "TAG_string_type";
801 case TAG_structure_type: return "TAG_structure_type";
802 case TAG_subroutine: return "TAG_subroutine";
803 case TAG_subroutine_type: return "TAG_subroutine_type";
804 case TAG_typedef: return "TAG_typedef";
805 case TAG_union_type: return "TAG_union_type";
806 case TAG_unspecified_parameters: return "TAG_unspecified_parameters";
807 case TAG_variant: return "TAG_variant";
808 case TAG_common_block: return "TAG_common_block";
809 case TAG_common_inclusion: return "TAG_common_inclusion";
810 case TAG_inheritance: return "TAG_inheritance";
811 case TAG_inlined_subroutine: return "TAG_inlined_subroutine";
812 case TAG_module: return "TAG_module";
813 case TAG_ptr_to_member_type: return "TAG_ptr_to_member_type";
814 case TAG_set_type: return "TAG_set_type";
815 case TAG_subrange_type: return "TAG_subrange_type";
816 case TAG_with_stmt: return "TAG_with_stmt";
818 /* GNU extensions. */
820 case TAG_format_label: return "TAG_format_label";
821 case TAG_namelist: return "TAG_namelist";
822 case TAG_function_template: return "TAG_function_template";
823 case TAG_class_template: return "TAG_class_template";
825 default: return "TAG_<unknown>";
830 dwarf_attr_name (attr)
831 register unsigned attr;
835 case AT_sibling: return "AT_sibling";
836 case AT_location: return "AT_location";
837 case AT_name: return "AT_name";
838 case AT_fund_type: return "AT_fund_type";
839 case AT_mod_fund_type: return "AT_mod_fund_type";
840 case AT_user_def_type: return "AT_user_def_type";
841 case AT_mod_u_d_type: return "AT_mod_u_d_type";
842 case AT_ordering: return "AT_ordering";
843 case AT_subscr_data: return "AT_subscr_data";
844 case AT_byte_size: return "AT_byte_size";
845 case AT_bit_offset: return "AT_bit_offset";
846 case AT_bit_size: return "AT_bit_size";
847 case AT_element_list: return "AT_element_list";
848 case AT_stmt_list: return "AT_stmt_list";
849 case AT_low_pc: return "AT_low_pc";
850 case AT_high_pc: return "AT_high_pc";
851 case AT_language: return "AT_language";
852 case AT_member: return "AT_member";
853 case AT_discr: return "AT_discr";
854 case AT_discr_value: return "AT_discr_value";
855 case AT_string_length: return "AT_string_length";
856 case AT_common_reference: return "AT_common_reference";
857 case AT_comp_dir: return "AT_comp_dir";
858 case AT_const_value_string: return "AT_const_value_string";
859 case AT_const_value_data2: return "AT_const_value_data2";
860 case AT_const_value_data4: return "AT_const_value_data4";
861 case AT_const_value_data8: return "AT_const_value_data8";
862 case AT_const_value_block2: return "AT_const_value_block2";
863 case AT_const_value_block4: return "AT_const_value_block4";
864 case AT_containing_type: return "AT_containing_type";
865 case AT_default_value_addr: return "AT_default_value_addr";
866 case AT_default_value_data2: return "AT_default_value_data2";
867 case AT_default_value_data4: return "AT_default_value_data4";
868 case AT_default_value_data8: return "AT_default_value_data8";
869 case AT_default_value_string: return "AT_default_value_string";
870 case AT_friends: return "AT_friends";
871 case AT_inline: return "AT_inline";
872 case AT_is_optional: return "AT_is_optional";
873 case AT_lower_bound_ref: return "AT_lower_bound_ref";
874 case AT_lower_bound_data2: return "AT_lower_bound_data2";
875 case AT_lower_bound_data4: return "AT_lower_bound_data4";
876 case AT_lower_bound_data8: return "AT_lower_bound_data8";
877 case AT_private: return "AT_private";
878 case AT_producer: return "AT_producer";
879 case AT_program: return "AT_program";
880 case AT_protected: return "AT_protected";
881 case AT_prototyped: return "AT_prototyped";
882 case AT_public: return "AT_public";
883 case AT_pure_virtual: return "AT_pure_virtual";
884 case AT_return_addr: return "AT_return_addr";
885 case AT_abstract_origin: return "AT_abstract_origin";
886 case AT_start_scope: return "AT_start_scope";
887 case AT_stride_size: return "AT_stride_size";
888 case AT_upper_bound_ref: return "AT_upper_bound_ref";
889 case AT_upper_bound_data2: return "AT_upper_bound_data2";
890 case AT_upper_bound_data4: return "AT_upper_bound_data4";
891 case AT_upper_bound_data8: return "AT_upper_bound_data8";
892 case AT_virtual: return "AT_virtual";
896 case AT_sf_names: return "AT_sf_names";
897 case AT_src_info: return "AT_src_info";
898 case AT_mac_info: return "AT_mac_info";
899 case AT_src_coords: return "AT_src_coords";
900 case AT_body_begin: return "AT_body_begin";
901 case AT_body_end: return "AT_body_end";
903 default: return "AT_<unknown>";
908 dwarf_stack_op_name (op)
909 register unsigned op;
913 case OP_REG: return "OP_REG";
914 case OP_BASEREG: return "OP_BASEREG";
915 case OP_ADDR: return "OP_ADDR";
916 case OP_CONST: return "OP_CONST";
917 case OP_DEREF2: return "OP_DEREF2";
918 case OP_DEREF4: return "OP_DEREF4";
919 case OP_ADD: return "OP_ADD";
920 default: return "OP_<unknown>";
925 dwarf_typemod_name (mod)
926 register unsigned mod;
930 case MOD_pointer_to: return "MOD_pointer_to";
931 case MOD_reference_to: return "MOD_reference_to";
932 case MOD_const: return "MOD_const";
933 case MOD_volatile: return "MOD_volatile";
934 default: return "MOD_<unknown>";
939 dwarf_fmt_byte_name (fmt)
940 register unsigned fmt;
944 case FMT_FT_C_C: return "FMT_FT_C_C";
945 case FMT_FT_C_X: return "FMT_FT_C_X";
946 case FMT_FT_X_C: return "FMT_FT_X_C";
947 case FMT_FT_X_X: return "FMT_FT_X_X";
948 case FMT_UT_C_C: return "FMT_UT_C_C";
949 case FMT_UT_C_X: return "FMT_UT_C_X";
950 case FMT_UT_X_C: return "FMT_UT_X_C";
951 case FMT_UT_X_X: return "FMT_UT_X_X";
952 case FMT_ET: return "FMT_ET";
953 default: return "FMT_<unknown>";
957 dwarf_fund_type_name (ft)
958 register unsigned ft;
962 case FT_char: return "FT_char";
963 case FT_signed_char: return "FT_signed_char";
964 case FT_unsigned_char: return "FT_unsigned_char";
965 case FT_short: return "FT_short";
966 case FT_signed_short: return "FT_signed_short";
967 case FT_unsigned_short: return "FT_unsigned_short";
968 case FT_integer: return "FT_integer";
969 case FT_signed_integer: return "FT_signed_integer";
970 case FT_unsigned_integer: return "FT_unsigned_integer";
971 case FT_long: return "FT_long";
972 case FT_signed_long: return "FT_signed_long";
973 case FT_unsigned_long: return "FT_unsigned_long";
974 case FT_pointer: return "FT_pointer";
975 case FT_float: return "FT_float";
976 case FT_dbl_prec_float: return "FT_dbl_prec_float";
977 case FT_ext_prec_float: return "FT_ext_prec_float";
978 case FT_complex: return "FT_complex";
979 case FT_dbl_prec_complex: return "FT_dbl_prec_complex";
980 case FT_void: return "FT_void";
981 case FT_boolean: return "FT_boolean";
982 case FT_ext_prec_complex: return "FT_ext_prec_complex";
983 case FT_label: return "FT_label";
985 /* GNU extensions. */
987 case FT_long_long: return "FT_long_long";
988 case FT_signed_long_long: return "FT_signed_long_long";
989 case FT_unsigned_long_long: return "FT_unsigned_long_long";
991 case FT_int8: return "FT_int8";
992 case FT_signed_int8: return "FT_signed_int8";
993 case FT_unsigned_int8: return "FT_unsigned_int8";
994 case FT_int16: return "FT_int16";
995 case FT_signed_int16: return "FT_signed_int16";
996 case FT_unsigned_int16: return "FT_unsigned_int16";
997 case FT_int32: return "FT_int32";
998 case FT_signed_int32: return "FT_signed_int32";
999 case FT_unsigned_int32: return "FT_unsigned_int32";
1000 case FT_int64: return "FT_int64";
1001 case FT_signed_int64: return "FT_signed_int64";
1002 case FT_unsigned_int64: return "FT_signed_int64";
1004 case FT_real32: return "FT_real32";
1005 case FT_real64: return "FT_real64";
1006 case FT_real96: return "FT_real96";
1007 case FT_real128: return "FT_real128";
1009 default: return "FT_<unknown>";
1013 /* Determine the "ultimate origin" of a decl. The decl may be an
1014 inlined instance of an inlined instance of a decl which is local
1015 to an inline function, so we have to trace all of the way back
1016 through the origin chain to find out what sort of node actually
1017 served as the original seed for the given block. */
1020 decl_ultimate_origin (decl)
1023 register tree immediate_origin = DECL_ABSTRACT_ORIGIN (decl);
1025 if (immediate_origin == NULL)
1029 register tree ret_val;
1030 register tree lookahead = immediate_origin;
1034 ret_val = lookahead;
1035 lookahead = DECL_ABSTRACT_ORIGIN (ret_val);
1037 while (lookahead != NULL && lookahead != ret_val);
1042 /* Determine the "ultimate origin" of a block. The block may be an
1043 inlined instance of an inlined instance of a block which is local
1044 to an inline function, so we have to trace all of the way back
1045 through the origin chain to find out what sort of node actually
1046 served as the original seed for the given block. */
1049 block_ultimate_origin (block)
1050 register tree block;
1052 register tree immediate_origin = BLOCK_ABSTRACT_ORIGIN (block);
1054 if (immediate_origin == NULL)
1058 register tree ret_val;
1059 register tree lookahead = immediate_origin;
1063 ret_val = lookahead;
1064 lookahead = (TREE_CODE (ret_val) == BLOCK)
1065 ? BLOCK_ABSTRACT_ORIGIN (ret_val)
1068 while (lookahead != NULL && lookahead != ret_val);
1074 output_unsigned_leb128 (value)
1075 register unsigned long value;
1077 register unsigned long orig_value = value;
1081 register unsigned byte = (value & 0x7f);
1084 if (value != 0) /* more bytes to follow */
1086 fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) byte);
1087 if (flag_verbose_asm && value == 0)
1088 fprintf (asm_out_file, "\t%s ULEB128 number - value = %u",
1089 ASM_COMMENT_START, orig_value);
1090 fputc ('\n', asm_out_file);
1096 output_signed_leb128 (value)
1097 register long value;
1099 register long orig_value = value;
1100 register int negative = (value < 0);
1105 register unsigned byte = (value & 0x7f);
1109 value |= 0xfe000000; /* manually sign extend */
1110 if (((value == 0) && ((byte & 0x40) == 0))
1111 || ((value == -1) && ((byte & 0x40) == 1)))
1118 fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) byte);
1119 if (flag_verbose_asm && more == 0)
1120 fprintf (asm_out_file, "\t%s SLEB128 number - value = %d",
1121 ASM_COMMENT_START, orig_value);
1122 fputc ('\n', asm_out_file);
1127 /**************** utility functions for attribute functions ******************/
1129 /* Given a pointer to a BLOCK node return non-zero if (and only if) the
1130 node in question represents the outermost pair of curly braces (i.e.
1131 the "body block") of a function or method.
1133 For any BLOCK node representing a "body block" of a function or method,
1134 the BLOCK_SUPERCONTEXT of the node will point to another BLOCK node
1135 which represents the outermost (function) scope for the function or
1136 method (i.e. the one which includes the formal parameters). The
1137 BLOCK_SUPERCONTEXT of *that* node in turn will point to the relevant
1142 is_body_block (stmt)
1145 if (TREE_CODE (stmt) == BLOCK)
1147 register tree parent = BLOCK_SUPERCONTEXT (stmt);
1149 if (TREE_CODE (parent) == BLOCK)
1151 register tree grandparent = BLOCK_SUPERCONTEXT (parent);
1153 if (TREE_CODE (grandparent) == FUNCTION_DECL)
1160 /* Given a pointer to a tree node for some type, return a Dwarf fundamental
1161 type code for the given type.
1163 This routine must only be called for GCC type nodes that correspond to
1164 Dwarf fundamental types.
1166 The current Dwarf draft specification calls for Dwarf fundamental types
1167 to accurately reflect the fact that a given type was either a "plain"
1168 integral type or an explicitly "signed" integral type. Unfortunately,
1169 we can't always do this, because GCC may already have thrown away the
1170 information about the precise way in which the type was originally
1173 typedef signed int my_type;
1175 struct s { my_type f; };
1177 Since we may be stuck here without enought information to do exactly
1178 what is called for in the Dwarf draft specification, we do the best
1179 that we can under the circumstances and always use the "plain" integral
1180 fundamental type codes for int, short, and long types. That's probably
1181 good enough. The additional accuracy called for in the current DWARF
1182 draft specification is probably never even useful in practice. */
1185 fundamental_type_code (type)
1188 if (TREE_CODE (type) == ERROR_MARK)
1191 switch (TREE_CODE (type))
1200 /* Carefully distinguish all the standard types of C,
1201 without messing up if the language is not C.
1202 Note that we check only for the names that contain spaces;
1203 other names might occur by coincidence in other languages. */
1204 if (TYPE_NAME (type) != 0
1205 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1206 && DECL_NAME (TYPE_NAME (type)) != 0
1207 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
1209 char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
1211 if (!strcmp (name, "unsigned char"))
1212 return FT_unsigned_char;
1213 if (!strcmp (name, "signed char"))
1214 return FT_signed_char;
1215 if (!strcmp (name, "unsigned int"))
1216 return FT_unsigned_integer;
1217 if (!strcmp (name, "short int"))
1219 if (!strcmp (name, "short unsigned int"))
1220 return FT_unsigned_short;
1221 if (!strcmp (name, "long int"))
1223 if (!strcmp (name, "long unsigned int"))
1224 return FT_unsigned_long;
1225 if (!strcmp (name, "long long int"))
1226 return FT_long_long; /* Not grok'ed by svr4 SDB */
1227 if (!strcmp (name, "long long unsigned int"))
1228 return FT_unsigned_long_long; /* Not grok'ed by svr4 SDB */
1231 /* Most integer types will be sorted out above, however, for the
1232 sake of special `array index' integer types, the following code
1233 is also provided. */
1235 if (TYPE_PRECISION (type) == INT_TYPE_SIZE)
1236 return (TREE_UNSIGNED (type) ? FT_unsigned_integer : FT_integer);
1238 if (TYPE_PRECISION (type) == LONG_TYPE_SIZE)
1239 return (TREE_UNSIGNED (type) ? FT_unsigned_long : FT_long);
1241 if (TYPE_PRECISION (type) == LONG_LONG_TYPE_SIZE)
1242 return (TREE_UNSIGNED (type) ? FT_unsigned_long_long : FT_long_long);
1244 if (TYPE_PRECISION (type) == SHORT_TYPE_SIZE)
1245 return (TREE_UNSIGNED (type) ? FT_unsigned_short : FT_short);
1247 if (TYPE_PRECISION (type) == CHAR_TYPE_SIZE)
1248 return (TREE_UNSIGNED (type) ? FT_unsigned_char : FT_char);
1253 /* Carefully distinguish all the standard types of C,
1254 without messing up if the language is not C. */
1255 if (TYPE_NAME (type) != 0
1256 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1257 && DECL_NAME (TYPE_NAME (type)) != 0
1258 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
1260 char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
1262 /* Note that here we can run afowl of a serious bug in "classic"
1263 svr4 SDB debuggers. They don't seem to understand the
1264 FT_ext_prec_float type (even though they should). */
1266 if (!strcmp (name, "long double"))
1267 return FT_ext_prec_float;
1270 if (TYPE_PRECISION (type) == DOUBLE_TYPE_SIZE)
1271 return FT_dbl_prec_float;
1272 if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE)
1275 /* Note that here we can run afowl of a serious bug in "classic"
1276 svr4 SDB debuggers. They don't seem to understand the
1277 FT_ext_prec_float type (even though they should). */
1279 if (TYPE_PRECISION (type) == LONG_DOUBLE_TYPE_SIZE)
1280 return FT_ext_prec_float;
1284 return FT_complex; /* GNU FORTRAN COMPLEX type. */
1287 return FT_char; /* GNU Pascal CHAR type. Not used in C. */
1290 return FT_boolean; /* GNU FORTRAN BOOLEAN type. */
1293 abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
1298 /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
1299 the Dwarf "root" type for the given input type. The Dwarf "root" type
1300 of a given type is generally the same as the given type, except that if
1301 the given type is a pointer or reference type, then the root type of
1302 the given type is the root type of the "basis" type for the pointer or
1303 reference type. (This definition of the "root" type is recursive.)
1304 Also, the root type of a `const' qualified type or a `volatile'
1305 qualified type is the root type of the given type without the
1312 if (TREE_CODE (type) == ERROR_MARK)
1313 return error_mark_node;
1315 switch (TREE_CODE (type))
1318 return error_mark_node;
1321 case REFERENCE_TYPE:
1322 return type_main_variant (root_type (TREE_TYPE (type)));
1325 return type_main_variant (type);
1329 /* Given a pointer to an arbitrary ..._TYPE tree node, write out a sequence
1330 of zero or more Dwarf "type-modifier" bytes applicable to the type. */
1333 write_modifier_bytes (type, decl_const, decl_volatile)
1335 register int decl_const;
1336 register int decl_volatile;
1338 if (TREE_CODE (type) == ERROR_MARK)
1341 if (TYPE_READONLY (type) || decl_const)
1342 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_const);
1343 if (TYPE_VOLATILE (type) || decl_volatile)
1344 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_volatile);
1345 switch (TREE_CODE (type))
1348 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_pointer_to);
1349 write_modifier_bytes (TREE_TYPE (type), 0, 0);
1352 case REFERENCE_TYPE:
1353 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_reference_to);
1354 write_modifier_bytes (TREE_TYPE (type), 0, 0);
1363 /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
1364 given input type is a Dwarf "fundamental" type. Otherwise return zero. */
1367 type_is_fundamental (type)
1370 switch (TREE_CODE (type))
1385 case QUAL_UNION_TYPE:
1390 case REFERENCE_TYPE:
1402 /* Given a pointer to some ..._DECL tree node, generate an assembly language
1403 equate directive which will associate a symbolic name with the current DIE.
1405 The name used is an artificial label generated from the DECL_UID number
1406 associated with the given decl node. The name it gets equated to is the
1407 symbolic label that we (previously) output at the start of the DIE that
1408 we are currently generating.
1410 Calling this function while generating some "decl related" form of DIE
1411 makes it possible to later refer to the DIE which represents the given
1412 decl simply by re-generating the symbolic name from the ..._DECL node's
1416 equate_decl_number_to_die_number (decl)
1419 /* In the case where we are generating a DIE for some ..._DECL node
1420 which represents either some inline function declaration or some
1421 entity declared within an inline function declaration/definition,
1422 setup a symbolic name for the current DIE so that we have a name
1423 for this DIE that we can easily refer to later on within
1424 AT_abstract_origin attributes. */
1426 char decl_label[MAX_ARTIFICIAL_LABEL_BYTES];
1427 char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
1429 sprintf (decl_label, DECL_NAME_FMT, DECL_UID (decl));
1430 sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
1431 ASM_OUTPUT_DEF (asm_out_file, decl_label, die_label);
1434 /* Given a pointer to some ..._TYPE tree node, generate an assembly language
1435 equate directive which will associate a symbolic name with the current DIE.
1437 The name used is an artificial label generated from the TYPE_UID number
1438 associated with the given type node. The name it gets equated to is the
1439 symbolic label that we (previously) output at the start of the DIE that
1440 we are currently generating.
1442 Calling this function while generating some "type related" form of DIE
1443 makes it easy to later refer to the DIE which represents the given type
1444 simply by re-generating the alternative name from the ..._TYPE node's
1448 equate_type_number_to_die_number (type)
1451 char type_label[MAX_ARTIFICIAL_LABEL_BYTES];
1452 char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
1454 /* We are generating a DIE to represent the main variant of this type
1455 (i.e the type without any const or volatile qualifiers) so in order
1456 to get the equate to come out right, we need to get the main variant
1459 type = type_main_variant (type);
1461 sprintf (type_label, TYPE_NAME_FMT, TYPE_UID (type));
1462 sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
1463 ASM_OUTPUT_DEF (asm_out_file, type_label, die_label);
1467 output_reg_number (rtl)
1470 register unsigned regno = REGNO (rtl);
1472 if (regno >= FIRST_PSEUDO_REGISTER)
1474 warning_with_decl (dwarf_last_decl, "internal regno botch: regno = %d\n",
1478 fprintf (asm_out_file, "\t%s\t0x%x",
1479 UNALIGNED_INT_ASM_OP, DBX_REGISTER_NUMBER (regno));
1480 if (flag_verbose_asm)
1482 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
1483 PRINT_REG (rtl, 0, asm_out_file);
1485 fputc ('\n', asm_out_file);
1488 /* The following routine is a nice and simple transducer. It converts the
1489 RTL for a variable or parameter (resident in memory) into an equivalent
1490 Dwarf representation of a mechanism for getting the address of that same
1491 variable onto the top of a hypothetical "address evaluation" stack.
1493 When creating memory location descriptors, we are effectively trans-
1494 forming the RTL for a memory-resident object into its Dwarf postfix
1495 expression equivalent. This routine just recursively descends an
1496 RTL tree, turning it into Dwarf postfix code as it goes. */
1499 output_mem_loc_descriptor (rtl)
1502 /* Note that for a dynamically sized array, the location we will
1503 generate a description of here will be the lowest numbered location
1504 which is actually within the array. That's *not* necessarily the
1505 same as the zeroth element of the array. */
1507 switch (GET_CODE (rtl))
1511 /* The case of a subreg may arise when we have a local (register)
1512 variable or a formal (register) parameter which doesn't quite
1513 fill up an entire register. For now, just assume that it is
1514 legitimate to make the Dwarf info refer to the whole register
1515 which contains the given subreg. */
1517 rtl = XEXP (rtl, 0);
1522 /* Whenever a register number forms a part of the description of
1523 the method for calculating the (dynamic) address of a memory
1524 resident object, DWARF rules require the register number to
1525 be referred to as a "base register". This distinction is not
1526 based in any way upon what category of register the hardware
1527 believes the given register belongs to. This is strictly
1528 DWARF terminology we're dealing with here.
1530 Note that in cases where the location of a memory-resident data
1531 object could be expressed as:
1533 OP_ADD (OP_BASEREG (basereg), OP_CONST (0))
1535 the actual DWARF location descriptor that we generate may just
1536 be OP_BASEREG (basereg). This may look deceptively like the
1537 object in question was allocated to a register (rather than
1538 in memory) so DWARF consumers need to be aware of the subtle
1539 distinction between OP_REG and OP_BASEREG. */
1541 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_BASEREG);
1542 output_reg_number (rtl);
1546 output_mem_loc_descriptor (XEXP (rtl, 0));
1547 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_DEREF4);
1552 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADDR);
1553 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
1557 output_mem_loc_descriptor (XEXP (rtl, 0));
1558 output_mem_loc_descriptor (XEXP (rtl, 1));
1559 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
1563 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
1564 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, INTVAL (rtl));
1572 /* Output a proper Dwarf location descriptor for a variable or parameter
1573 which is either allocated in a register or in a memory location. For
1574 a register, we just generate an OP_REG and the register number. For a
1575 memory location we provide a Dwarf postfix expression describing how to
1576 generate the (dynamic) address of the object onto the address stack. */
1579 output_loc_descriptor (rtl)
1582 switch (GET_CODE (rtl))
1586 /* The case of a subreg may arise when we have a local (register)
1587 variable or a formal (register) parameter which doesn't quite
1588 fill up an entire register. For now, just assume that it is
1589 legitimate to make the Dwarf info refer to the whole register
1590 which contains the given subreg. */
1592 rtl = XEXP (rtl, 0);
1596 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_REG);
1597 output_reg_number (rtl);
1601 output_mem_loc_descriptor (XEXP (rtl, 0));
1605 abort (); /* Should never happen */
1609 /* Given a tree node describing an array bound (either lower or upper)
1610 output a representation for that bound. */
1613 output_bound_representation (bound, dim_num, u_or_l)
1614 register tree bound;
1615 register unsigned dim_num; /* For multi-dimensional arrays. */
1616 register char u_or_l; /* Designates upper or lower bound. */
1618 switch (TREE_CODE (bound))
1624 /* All fixed-bounds are represented by INTEGER_CST nodes. */
1627 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
1628 (unsigned) TREE_INT_CST_LOW (bound));
1631 /* Dynamic bounds may be represented by NOP_EXPR nodes containing
1635 bound = TREE_OPERAND (bound, 0);
1636 /* ... fall thru... */
1640 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
1641 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
1643 sprintf (begin_label, BOUND_BEGIN_LABEL_FMT,
1644 current_dienum, dim_num, u_or_l);
1646 sprintf (end_label, BOUND_END_LABEL_FMT,
1647 current_dienum, dim_num, u_or_l);
1649 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
1650 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
1652 /* If we are working on a bound for a dynamic dimension in C,
1653 the dynamic dimension in question had better have a static
1654 (zero) lower bound and a dynamic *upper* bound. */
1659 /* If optimization is turned on, the SAVE_EXPRs that describe
1660 how to access the upper bound values are essentially bogus.
1661 They only describe (at best) how to get at these values at
1662 the points in the generated code right after they have just
1663 been computed. Worse yet, in the typical case, the upper
1664 bound values will not even *be* computed in the optimized
1665 code, so these SAVE_EXPRs are entirely bogus.
1667 In order to compensate for this fact, we check here to see
1668 if optimization is enabled, and if so, we effectively create
1669 an empty location description for the (unknown and unknowable)
1672 This should not cause too much trouble for existing (stupid?)
1673 debuggers because they have to deal with empty upper bounds
1674 location descriptions anyway in order to be able to deal with
1675 incomplete array types.
1677 Of course an intelligent debugger (GDB?) should be able to
1678 comprehend that a missing upper bound specification in a
1679 array type used for a storage class `auto' local array variable
1680 indicates that the upper bound is both unknown (at compile-
1681 time) and unknowable (at run-time) due to optimization.
1685 output_loc_descriptor
1686 (eliminate_regs (SAVE_EXPR_RTL (bound), 0, NULL_RTX));
1688 ASM_OUTPUT_LABEL (asm_out_file, end_label);
1697 /* Recursive function to output a sequence of value/name pairs for
1698 enumeration constants in reversed order. This is called from
1699 enumeration_type_die. */
1702 output_enumeral_list (link)
1707 output_enumeral_list (TREE_CHAIN (link));
1708 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
1709 (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link)));
1710 ASM_OUTPUT_DWARF_STRING (asm_out_file,
1711 IDENTIFIER_POINTER (TREE_PURPOSE (link)));
1715 /* Given an unsigned value, round it up to the lowest multiple of `boundary'
1716 which is not less than the value itself. */
1719 ceiling (value, boundary)
1720 register unsigned value;
1721 register unsigned boundary;
1723 return (((value + boundary - 1) / boundary) * boundary);
1726 /* Given a pointer to what is assumed to be a FIELD_DECL node, return a
1727 pointer to the declared type for the relevant field variable, or return
1728 `integer_type_node' if the given node turns out to be an ERROR_MARK node. */
1736 if (TREE_CODE (decl) == ERROR_MARK)
1737 return integer_type_node;
1739 type = DECL_BIT_FIELD_TYPE (decl);
1741 type = TREE_TYPE (decl);
1745 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
1746 node, return the alignment in bits for the type, or else return
1747 BITS_PER_WORD if the node actually turns out to be an ERROR_MARK node. */
1750 simple_type_align_in_bits (type)
1753 return (TREE_CODE (type) != ERROR_MARK) ? TYPE_ALIGN (type) : BITS_PER_WORD;
1756 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
1757 node, return the size in bits for the type if it is a constant, or
1758 else return the alignment for the type if the type's size is not
1759 constant, or else return BITS_PER_WORD if the type actually turns out
1760 to be an ERROR_MARK node. */
1763 simple_type_size_in_bits (type)
1766 if (TREE_CODE (type) == ERROR_MARK)
1767 return BITS_PER_WORD;
1770 register tree type_size_tree = TYPE_SIZE (type);
1772 if (TREE_CODE (type_size_tree) != INTEGER_CST)
1773 return TYPE_ALIGN (type);
1775 return (unsigned) TREE_INT_CST_LOW (type_size_tree);
1779 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
1780 return the byte offset of the lowest addressed byte of the "containing
1781 object" for the given FIELD_DECL, or return 0 if we are unable to deter-
1782 mine what that offset is, either because the argument turns out to be a
1783 pointer to an ERROR_MARK node, or because the offset is actually variable.
1784 (We can't handle the latter case just yet.) */
1787 field_byte_offset (decl)
1790 register unsigned type_align_in_bytes;
1791 register unsigned type_align_in_bits;
1792 register unsigned type_size_in_bits;
1793 register unsigned object_offset_in_align_units;
1794 register unsigned object_offset_in_bits;
1795 register unsigned object_offset_in_bytes;
1797 register tree bitpos_tree;
1798 register tree field_size_tree;
1799 register unsigned bitpos_int;
1800 register unsigned deepest_bitpos;
1801 register unsigned field_size_in_bits;
1803 if (TREE_CODE (decl) == ERROR_MARK)
1806 if (TREE_CODE (decl) != FIELD_DECL)
1809 type = field_type (decl);
1811 bitpos_tree = DECL_FIELD_BITPOS (decl);
1812 field_size_tree = DECL_SIZE (decl);
1814 /* We cannot yet cope with fields whose positions or sizes are variable,
1815 so for now, when we see such things, we simply return 0. Someday,
1816 we may be able to handle such cases, but it will be damn difficult. */
1818 if (TREE_CODE (bitpos_tree) != INTEGER_CST)
1820 bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
1822 if (TREE_CODE (field_size_tree) != INTEGER_CST)
1824 field_size_in_bits = (unsigned) TREE_INT_CST_LOW (field_size_tree);
1826 type_size_in_bits = simple_type_size_in_bits (type);
1828 type_align_in_bits = simple_type_align_in_bits (type);
1829 type_align_in_bytes = type_align_in_bits / BITS_PER_UNIT;
1831 /* Note that the GCC front-end doesn't make any attempt to keep track
1832 of the starting bit offset (relative to the start of the containing
1833 structure type) of the hypothetical "containing object" for a bit-
1834 field. Thus, when computing the byte offset value for the start of
1835 the "containing object" of a bit-field, we must deduce this infor-
1838 This can be rather tricky to do in some cases. For example, handling
1839 the following structure type definition when compiling for an i386/i486
1840 target (which only aligns long long's to 32-bit boundaries) can be very
1845 long long field2:31;
1848 Fortunately, there is a simple rule-of-thumb which can be used in such
1849 cases. When compiling for an i386/i486, GCC will allocate 8 bytes for
1850 the structure shown above. It decides to do this based upon one simple
1851 rule for bit-field allocation. Quite simply, GCC allocates each "con-
1852 taining object" for each bit-field at the first (i.e. lowest addressed)
1853 legitimate alignment boundary (based upon the required minimum alignment
1854 for the declared type of the field) which it can possibly use, subject
1855 to the condition that there is still enough available space remaining
1856 in the containing object (when allocated at the selected point) to
1857 fully accommodate all of the bits of the bit-field itself.
1859 This simple rule makes it obvious why GCC allocates 8 bytes for each
1860 object of the structure type shown above. When looking for a place to
1861 allocate the "containing object" for `field2', the compiler simply tries
1862 to allocate a 64-bit "containing object" at each successive 32-bit
1863 boundary (starting at zero) until it finds a place to allocate that 64-
1864 bit field such that at least 31 contiguous (and previously unallocated)
1865 bits remain within that selected 64 bit field. (As it turns out, for
1866 the example above, the compiler finds that it is OK to allocate the
1867 "containing object" 64-bit field at bit-offset zero within the
1870 Here we attempt to work backwards from the limited set of facts we're
1871 given, and we try to deduce from those facts, where GCC must have
1872 believed that the containing object started (within the structure type).
1874 The value we deduce is then used (by the callers of this routine) to
1875 generate AT_location and AT_bit_offset attributes for fields (both
1876 bit-fields and, in the case of AT_location, regular fields as well).
1879 /* Figure out the bit-distance from the start of the structure to the
1880 "deepest" bit of the bit-field. */
1881 deepest_bitpos = bitpos_int + field_size_in_bits;
1883 /* This is the tricky part. Use some fancy footwork to deduce where the
1884 lowest addressed bit of the containing object must be. */
1885 object_offset_in_bits
1886 = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits;
1888 /* Compute the offset of the containing object in "alignment units". */
1889 object_offset_in_align_units = object_offset_in_bits / type_align_in_bits;
1891 /* Compute the offset of the containing object in bytes. */
1892 object_offset_in_bytes = object_offset_in_align_units * type_align_in_bytes;
1894 return object_offset_in_bytes;
1897 /****************************** attributes *********************************/
1899 /* The following routines are responsible for writing out the various types
1900 of Dwarf attributes (and any following data bytes associated with them).
1901 These routines are listed in order based on the numerical codes of their
1902 associated attributes. */
1904 /* Generate an AT_sibling attribute. */
1907 sibling_attribute ()
1909 char label[MAX_ARTIFICIAL_LABEL_BYTES];
1911 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sibling);
1912 sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
1913 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
1916 /* Output the form of location attributes suitable for whole variables and
1917 whole parameters. Note that the location attributes for struct fields
1918 are generated by the routine `data_member_location_attribute' below. */
1921 location_attribute (rtl)
1924 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
1925 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
1927 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
1928 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
1929 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
1930 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
1931 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
1933 /* Handle a special case. If we are about to output a location descriptor
1934 for a variable or parameter which has been optimized out of existence,
1935 don't do that. Instead we output a zero-length location descriptor
1936 value as part of the location attribute.
1938 A variable which has been optimized out of existence will have a
1939 DECL_RTL value which denotes a pseudo-reg.
1941 Currently, in some rare cases, variables can have DECL_RTL values
1942 which look like (MEM (REG pseudo-reg#)). These cases are due to
1943 bugs elsewhere in the compiler. We treat such cases
1944 as if the variable(s) in question had been optimized out of existence.
1946 Note that in all cases where we wish to express the fact that a
1947 variable has been optimized out of existence, we do not simply
1948 suppress the generation of the entire location attribute because
1949 the absence of a location attribute in certain kinds of DIEs is
1950 used to indicate something else entirely... i.e. that the DIE
1951 represents an object declaration, but not a definition. So saith
1955 if (! is_pseudo_reg (rtl)
1956 && (GET_CODE (rtl) != MEM || ! is_pseudo_reg (XEXP (rtl, 0))))
1957 output_loc_descriptor (eliminate_regs (rtl, 0, NULL_RTX));
1959 ASM_OUTPUT_LABEL (asm_out_file, end_label);
1962 /* Output the specialized form of location attribute used for data members
1963 of struct and union types.
1965 In the special case of a FIELD_DECL node which represents a bit-field,
1966 the "offset" part of this special location descriptor must indicate the
1967 distance in bytes from the lowest-addressed byte of the containing
1968 struct or union type to the lowest-addressed byte of the "containing
1969 object" for the bit-field. (See the `field_byte_offset' function above.)
1971 For any given bit-field, the "containing object" is a hypothetical
1972 object (of some integral or enum type) within which the given bit-field
1973 lives. The type of this hypothetical "containing object" is always the
1974 same as the declared type of the individual bit-field itself (for GCC
1975 anyway... the DWARF spec doesn't actually mandate this).
1977 Note that it is the size (in bytes) of the hypothetical "containing
1978 object" which will be given in the AT_byte_size attribute for this
1979 bit-field. (See the `byte_size_attribute' function below.) It is
1980 also used when calculating the value of the AT_bit_offset attribute.
1981 (See the `bit_offset_attribute' function below.)
1985 data_member_location_attribute (decl)
1988 register unsigned object_offset_in_bytes = field_byte_offset (decl);
1989 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
1990 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
1992 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
1993 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
1994 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
1995 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
1996 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
1997 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
1998 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, object_offset_in_bytes);
1999 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
2000 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2003 /* Output an AT_const_value attribute for a variable or a parameter which
2004 does not have a "location" either in memory or in a register. These
2005 things can arise in GNU C when a constant is passed as an actual
2006 parameter to an inlined function. They can also arise in C++ where
2007 declared constants do not necessarily get memory "homes". */
2010 const_value_attribute (rtl)
2013 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2014 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2016 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_const_value_block4);
2017 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
2018 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
2019 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
2020 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2022 switch (GET_CODE (rtl))
2025 /* Note that a CONST_INT rtx could represent either an integer or
2026 a floating-point constant. A CONST_INT is used whenever the
2027 constant will fit into a single word. In all such cases, the
2028 original mode of the constant value is wiped out, and the
2029 CONST_INT rtx is assigned VOIDmode. Since we no longer have
2030 precise mode information for these constants, we always just
2031 output them using 4 bytes. */
2033 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, (unsigned) INTVAL (rtl));
2037 /* Note that a CONST_DOUBLE rtx could represent either an integer
2038 or a floating-point constant. A CONST_DOUBLE is used whenever
2039 the constant requires more than one word in order to be adequately
2040 represented. In all such cases, the original mode of the constant
2041 value is preserved as the mode of the CONST_DOUBLE rtx, but for
2042 simplicity we always just output CONST_DOUBLEs using 8 bytes. */
2044 ASM_OUTPUT_DWARF_DATA8 (asm_out_file,
2045 (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (rtl),
2046 (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (rtl));
2050 ASM_OUTPUT_DWARF_STRING (asm_out_file, XSTR (rtl, 0));
2056 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
2060 /* In cases where an inlined instance of an inline function is passed
2061 the address of an `auto' variable (which is local to the caller)
2062 we can get a situation where the DECL_RTL of the artificial
2063 local variable (for the inlining) which acts as a stand-in for
2064 the corresponding formal parameter (of the inline function)
2065 will look like (plus:SI (reg:SI FRAME_PTR) (const_int ...)).
2066 This is not exactly a compile-time constant expression, but it
2067 isn't the address of the (artificial) local variable either.
2068 Rather, it represents the *value* which the artificial local
2069 variable always has during its lifetime. We currently have no
2070 way to represent such quasi-constant values in Dwarf, so for now
2071 we just punt and generate an AT_const_value attribute with form
2072 FORM_BLOCK4 and a length of zero. */
2076 abort (); /* No other kinds of rtx should be possible here. */
2079 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2082 /* Generate *either* an AT_location attribute or else an AT_const_value
2083 data attribute for a variable or a parameter. We generate the
2084 AT_const_value attribute only in those cases where the given
2085 variable or parameter does not have a true "location" either in
2086 memory or in a register. This can happen (for example) when a
2087 constant is passed as an actual argument in a call to an inline
2088 function. (It's possible that these things can crop up in other
2089 ways also.) Note that one type of constant value which can be
2090 passed into an inlined function is a constant pointer. This can
2091 happen for example if an actual argument in an inlined function
2092 call evaluates to a compile-time constant address. */
2095 location_or_const_value_attribute (decl)
2100 if (TREE_CODE (decl) == ERROR_MARK)
2103 if ((TREE_CODE (decl) != VAR_DECL) && (TREE_CODE (decl) != PARM_DECL))
2105 /* Should never happen. */
2110 /* Here we have to decide where we are going to say the parameter "lives"
2111 (as far as the debugger is concerned). We only have a couple of choices.
2112 GCC provides us with DECL_RTL and with DECL_INCOMING_RTL. DECL_RTL
2113 normally indicates where the parameter lives during most of the activa-
2114 tion of the function. If optimization is enabled however, this could
2115 be either NULL or else a pseudo-reg. Both of those cases indicate that
2116 the parameter doesn't really live anywhere (as far as the code generation
2117 parts of GCC are concerned) during most of the function's activation.
2118 That will happen (for example) if the parameter is never referenced
2119 within the function.
2121 We could just generate a location descriptor here for all non-NULL
2122 non-pseudo values of DECL_RTL and ignore all of the rest, but we can
2123 be a little nicer than that if we also consider DECL_INCOMING_RTL in
2124 cases where DECL_RTL is NULL or is a pseudo-reg.
2126 Note however that we can only get away with using DECL_INCOMING_RTL as
2127 a backup substitute for DECL_RTL in certain limited cases. In cases
2128 where DECL_ARG_TYPE(decl) indicates the same type as TREE_TYPE(decl)
2129 we can be sure that the parameter was passed using the same type as it
2130 is declared to have within the function, and that its DECL_INCOMING_RTL
2131 points us to a place where a value of that type is passed. In cases
2132 where DECL_ARG_TYPE(decl) and TREE_TYPE(decl) are different types
2133 however, we cannot (in general) use DECL_INCOMING_RTL as a backup
2134 substitute for DECL_RTL because in these cases, DECL_INCOMING_RTL
2135 points us to a value of some type which is *different* from the type
2136 of the parameter itself. Thus, if we tried to use DECL_INCOMING_RTL
2137 to generate a location attribute in such cases, the debugger would
2138 end up (for example) trying to fetch a `float' from a place which
2139 actually contains the first part of a `double'. That would lead to
2140 really incorrect and confusing output at debug-time, and we don't
2141 want that now do we?
2143 So in general, we DO NOT use DECL_INCOMING_RTL as a backup for DECL_RTL
2144 in cases where DECL_ARG_TYPE(decl) != TREE_TYPE(decl). There are a
2145 couple of cute exceptions however. On little-endian machines we can
2146 get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE(decl) is
2147 not the same as TREE_TYPE(decl) but only when DECL_ARG_TYPE(decl) is
2148 an integral type which is smaller than TREE_TYPE(decl). These cases
2149 arise when (on a little-endian machine) a non-prototyped function has
2150 a parameter declared to be of type `short' or `char'. In such cases,
2151 TREE_TYPE(decl) will be `short' or `char', DECL_ARG_TYPE(decl) will be
2152 `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
2153 passed `int' value. If the debugger then uses that address to fetch a
2154 `short' or a `char' (on a little-endian machine) the result will be the
2155 correct data, so we allow for such exceptional cases below.
2157 Note that our goal here is to describe the place where the given formal
2158 parameter lives during most of the function's activation (i.e. between
2159 the end of the prologue and the start of the epilogue). We'll do that
2160 as best as we can. Note however that if the given formal parameter is
2161 modified sometime during the execution of the function, then a stack
2162 backtrace (at debug-time) will show the function as having been called
2163 with the *new* value rather than the value which was originally passed
2164 in. This happens rarely enough that it is not a major problem, but it
2165 *is* a problem, and I'd like to fix it. A future version of dwarfout.c
2166 may generate two additional attributes for any given TAG_formal_parameter
2167 DIE which will describe the "passed type" and the "passed location" for
2168 the given formal parameter in addition to the attributes we now generate
2169 to indicate the "declared type" and the "active location" for each
2170 parameter. This additional set of attributes could be used by debuggers
2171 for stack backtraces.
2173 Separately, note that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL
2174 can be NULL also. This happens (for example) for inlined-instances of
2175 inline function formal parameters which are never referenced. This really
2176 shouldn't be happening. All PARM_DECL nodes should get valid non-NULL
2177 DECL_INCOMING_RTL values, but integrate.c doesn't currently generate
2178 these values for inlined instances of inline function parameters, so
2179 when we see such cases, we are just SOL (shit-out-of-luck) for the time
2180 being (until integrate.c gets fixed).
2183 /* Use DECL_RTL as the "location" unless we find something better. */
2184 rtl = DECL_RTL (decl);
2186 if (TREE_CODE (decl) == PARM_DECL)
2187 if (rtl == NULL_RTX || is_pseudo_reg (rtl))
2189 /* This decl represents a formal parameter which was optimized out. */
2190 register tree declared_type = type_main_variant (TREE_TYPE (decl));
2191 register tree passed_type = type_main_variant (DECL_ARG_TYPE (decl));
2193 /* Note that DECL_INCOMING_RTL may be NULL in here, but we handle
2194 *all* cases where (rtl == NULL_RTX) just below. */
2196 if (declared_type == passed_type)
2197 rtl = DECL_INCOMING_RTL (decl);
2198 else if (! BYTES_BIG_ENDIAN)
2199 if (TREE_CODE (declared_type) == INTEGER_TYPE)
2200 if (TYPE_SIZE (declared_type) <= TYPE_SIZE (passed_type))
2201 rtl = DECL_INCOMING_RTL (decl);
2204 if (rtl == NULL_RTX)
2207 switch (GET_CODE (rtl))
2215 case PLUS: /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
2216 const_value_attribute (rtl);
2222 location_attribute (rtl);
2226 abort (); /* Should never happen. */
2230 /* Generate an AT_name attribute given some string value to be included as
2231 the value of the attribute. */
2234 name_attribute (name_string)
2235 register char *name_string;
2237 if (name_string && *name_string)
2239 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_name);
2240 ASM_OUTPUT_DWARF_STRING (asm_out_file, name_string);
2245 fund_type_attribute (ft_code)
2246 register unsigned ft_code;
2248 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_fund_type);
2249 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, ft_code);
2253 mod_fund_type_attribute (type, decl_const, decl_volatile)
2255 register int decl_const;
2256 register int decl_volatile;
2258 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2259 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2261 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_fund_type);
2262 sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
2263 sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
2264 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2265 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2266 write_modifier_bytes (type, decl_const, decl_volatile);
2267 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
2268 fundamental_type_code (root_type (type)));
2269 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2273 user_def_type_attribute (type)
2276 char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
2278 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_user_def_type);
2279 sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (type));
2280 ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
2284 mod_u_d_type_attribute (type, decl_const, decl_volatile)
2286 register int decl_const;
2287 register int decl_volatile;
2289 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2290 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2291 char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
2293 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_u_d_type);
2294 sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
2295 sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
2296 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2297 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2298 write_modifier_bytes (type, decl_const, decl_volatile);
2299 sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (root_type (type)));
2300 ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
2301 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2304 #ifdef USE_ORDERING_ATTRIBUTE
2306 ordering_attribute (ordering)
2307 register unsigned ordering;
2309 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_ordering);
2310 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, ordering);
2312 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
2314 /* Note that the block of subscript information for an array type also
2315 includes information about the element type of type given array type. */
2318 subscript_data_attribute (type)
2321 register unsigned dimension_number;
2322 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2323 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2325 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_subscr_data);
2326 sprintf (begin_label, SS_BEGIN_LABEL_FMT, current_dienum);
2327 sprintf (end_label, SS_END_LABEL_FMT, current_dienum);
2328 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2329 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2331 /* The GNU compilers represent multidimensional array types as sequences
2332 of one dimensional array types whose element types are themselves array
2333 types. Here we squish that down, so that each multidimensional array
2334 type gets only one array_type DIE in the Dwarf debugging info. The
2335 draft Dwarf specification say that we are allowed to do this kind
2336 of compression in C (because there is no difference between an
2337 array or arrays and a multidimensional array in C) but for other
2338 source languages (e.g. Ada) we probably shouldn't do this. */
2340 for (dimension_number = 0;
2341 TREE_CODE (type) == ARRAY_TYPE;
2342 type = TREE_TYPE (type), dimension_number++)
2344 register tree domain = TYPE_DOMAIN (type);
2346 /* Arrays come in three flavors. Unspecified bounds, fixed
2347 bounds, and (in GNU C only) variable bounds. Handle all
2348 three forms here. */
2352 /* We have an array type with specified bounds. */
2354 register tree lower = TYPE_MIN_VALUE (domain);
2355 register tree upper = TYPE_MAX_VALUE (domain);
2357 /* Handle only fundamental types as index types for now. */
2359 if (! type_is_fundamental (domain))
2362 /* Output the representation format byte for this dimension. */
2364 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file,
2366 TREE_CODE (lower) == INTEGER_CST,
2367 TREE_CODE (upper) == INTEGER_CST));
2369 /* Output the index type for this dimension. */
2371 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
2372 fundamental_type_code (domain));
2374 /* Output the representation for the lower bound. */
2376 output_bound_representation (lower, dimension_number, 'l');
2378 /* Output the representation for the upper bound. */
2380 output_bound_representation (upper, dimension_number, 'u');
2384 /* We have an array type with an unspecified length. For C and
2385 C++ we can assume that this really means that (a) the index
2386 type is an integral type, and (b) the lower bound is zero.
2387 Note that Dwarf defines the representation of an unspecified
2388 (upper) bound as being a zero-length location description. */
2390 /* Output the array-bounds format byte. */
2392 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_FT_C_X);
2394 /* Output the (assumed) index type. */
2396 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, FT_integer);
2398 /* Output the (assumed) lower bound (constant) value. */
2400 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
2402 /* Output the (empty) location description for the upper bound. */
2404 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0);
2408 /* Output the prefix byte that says that the element type is coming up. */
2410 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_ET);
2412 /* Output a representation of the type of the elements of this array type. */
2414 type_attribute (type, 0, 0);
2416 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2420 byte_size_attribute (tree_node)
2421 register tree tree_node;
2423 register unsigned size;
2425 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_byte_size);
2426 switch (TREE_CODE (tree_node))
2435 case QUAL_UNION_TYPE:
2436 size = int_size_in_bytes (tree_node);
2440 /* For a data member of a struct or union, the AT_byte_size is
2441 generally given as the number of bytes normally allocated for
2442 an object of the *declared* type of the member itself. This
2443 is true even for bit-fields. */
2444 size = simple_type_size_in_bits (field_type (tree_node))
2452 /* Note that `size' might be -1 when we get to this point. If it
2453 is, that indicates that the byte size of the entity in question
2454 is variable. We have no good way of expressing this fact in Dwarf
2455 at the present time, so just let the -1 pass on through. */
2457 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, size);
2460 /* For a FIELD_DECL node which represents a bit-field, output an attribute
2461 which specifies the distance in bits from the highest order bit of the
2462 "containing object" for the bit-field to the highest order bit of the
2465 For any given bit-field, the "containing object" is a hypothetical
2466 object (of some integral or enum type) within which the given bit-field
2467 lives. The type of this hypothetical "containing object" is always the
2468 same as the declared type of the individual bit-field itself.
2470 The determination of the exact location of the "containing object" for
2471 a bit-field is rather complicated. It's handled by the `field_byte_offset'
2474 Note that it is the size (in bytes) of the hypothetical "containing
2475 object" which will be given in the AT_byte_size attribute for this
2476 bit-field. (See `byte_size_attribute' above.)
2480 bit_offset_attribute (decl)
2483 register unsigned object_offset_in_bytes = field_byte_offset (decl);
2484 register tree type = DECL_BIT_FIELD_TYPE (decl);
2485 register tree bitpos_tree = DECL_FIELD_BITPOS (decl);
2486 register unsigned bitpos_int;
2487 register unsigned highest_order_object_bit_offset;
2488 register unsigned highest_order_field_bit_offset;
2489 register unsigned bit_offset;
2491 assert (TREE_CODE (decl) == FIELD_DECL); /* Must be a field. */
2492 assert (type); /* Must be a bit field. */
2494 /* We can't yet handle bit-fields whose offsets are variable, so if we
2495 encounter such things, just return without generating any attribute
2498 if (TREE_CODE (bitpos_tree) != INTEGER_CST)
2500 bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
2502 /* Note that the bit offset is always the distance (in bits) from the
2503 highest-order bit of the "containing object" to the highest-order
2504 bit of the bit-field itself. Since the "high-order end" of any
2505 object or field is different on big-endian and little-endian machines,
2506 the computation below must take account of these differences. */
2508 highest_order_object_bit_offset = object_offset_in_bytes * BITS_PER_UNIT;
2509 highest_order_field_bit_offset = bitpos_int;
2511 if (! BYTES_BIG_ENDIAN)
2513 highest_order_field_bit_offset
2514 += (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl));
2516 highest_order_object_bit_offset += simple_type_size_in_bits (type);
2521 ? highest_order_object_bit_offset - highest_order_field_bit_offset
2522 : highest_order_field_bit_offset - highest_order_object_bit_offset);
2524 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_offset);
2525 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, bit_offset);
2528 /* For a FIELD_DECL node which represents a bit field, output an attribute
2529 which specifies the length in bits of the given field. */
2532 bit_size_attribute (decl)
2535 assert (TREE_CODE (decl) == FIELD_DECL); /* Must be a field. */
2536 assert (DECL_BIT_FIELD_TYPE (decl)); /* Must be a bit field. */
2538 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_size);
2539 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
2540 (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl)));
2543 /* The following routine outputs the `element_list' attribute for enumeration
2544 type DIEs. The element_lits attribute includes the names and values of
2545 all of the enumeration constants associated with the given enumeration
2549 element_list_attribute (element)
2550 register tree element;
2552 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2553 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2555 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_element_list);
2556 sprintf (begin_label, EE_BEGIN_LABEL_FMT, current_dienum);
2557 sprintf (end_label, EE_END_LABEL_FMT, current_dienum);
2558 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
2559 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2561 /* Here we output a list of value/name pairs for each enumeration constant
2562 defined for this enumeration type (as required), but we do it in REVERSE
2563 order. The order is the one required by the draft #5 Dwarf specification
2564 published by the UI/PLSIG. */
2566 output_enumeral_list (element); /* Recursively output the whole list. */
2568 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2571 /* Generate an AT_stmt_list attribute. These are normally present only in
2572 DIEs with a TAG_compile_unit tag. */
2575 stmt_list_attribute (label)
2576 register char *label;
2578 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_stmt_list);
2579 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2580 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
2583 /* Generate an AT_low_pc attribute for a label DIE, a lexical_block DIE or
2584 for a subroutine DIE. */
2587 low_pc_attribute (asm_low_label)
2588 register char *asm_low_label;
2590 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_low_pc);
2591 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_low_label);
2594 /* Generate an AT_high_pc attribute for a lexical_block DIE or for a
2598 high_pc_attribute (asm_high_label)
2599 register char *asm_high_label;
2601 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_high_pc);
2602 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_high_label);
2605 /* Generate an AT_body_begin attribute for a subroutine DIE. */
2608 body_begin_attribute (asm_begin_label)
2609 register char *asm_begin_label;
2611 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_begin);
2612 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_begin_label);
2615 /* Generate an AT_body_end attribute for a subroutine DIE. */
2618 body_end_attribute (asm_end_label)
2619 register char *asm_end_label;
2621 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_end);
2622 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_end_label);
2625 /* Generate an AT_language attribute given a LANG value. These attributes
2626 are used only within TAG_compile_unit DIEs. */
2629 language_attribute (language_code)
2630 register unsigned language_code;
2632 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_language);
2633 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, language_code);
2637 member_attribute (context)
2638 register tree context;
2640 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2642 /* Generate this attribute only for members in C++. */
2644 if (context != NULL && is_tagged_type (context))
2646 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_member);
2647 sprintf (label, TYPE_NAME_FMT, TYPE_UID (context));
2648 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2653 string_length_attribute (upper_bound)
2654 register tree upper_bound;
2656 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2657 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2659 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_string_length);
2660 sprintf (begin_label, SL_BEGIN_LABEL_FMT, current_dienum);
2661 sprintf (end_label, SL_END_LABEL_FMT, current_dienum);
2662 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2663 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2664 output_bound_representation (upper_bound, 0, 'u');
2665 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2669 comp_dir_attribute (dirname)
2670 register char *dirname;
2672 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_comp_dir);
2673 ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname);
2677 sf_names_attribute (sf_names_start_label)
2678 register char *sf_names_start_label;
2680 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sf_names);
2681 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2682 ASM_OUTPUT_DWARF_ADDR (asm_out_file, sf_names_start_label);
2686 src_info_attribute (src_info_start_label)
2687 register char *src_info_start_label;
2689 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_info);
2690 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2691 ASM_OUTPUT_DWARF_ADDR (asm_out_file, src_info_start_label);
2695 mac_info_attribute (mac_info_start_label)
2696 register char *mac_info_start_label;
2698 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mac_info);
2699 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2700 ASM_OUTPUT_DWARF_ADDR (asm_out_file, mac_info_start_label);
2704 prototyped_attribute (func_type)
2705 register tree func_type;
2707 if ((strcmp (language_string, "GNU C") == 0)
2708 && (TYPE_ARG_TYPES (func_type) != NULL))
2710 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_prototyped);
2711 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
2716 producer_attribute (producer)
2717 register char *producer;
2719 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_producer);
2720 ASM_OUTPUT_DWARF_STRING (asm_out_file, producer);
2724 inline_attribute (decl)
2727 if (DECL_INLINE (decl))
2729 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_inline);
2730 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
2735 containing_type_attribute (containing_type)
2736 register tree containing_type;
2738 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2740 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_containing_type);
2741 sprintf (label, TYPE_NAME_FMT, TYPE_UID (containing_type));
2742 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2746 abstract_origin_attribute (origin)
2747 register tree origin;
2749 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2751 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_abstract_origin);
2752 switch (TREE_CODE_CLASS (TREE_CODE (origin)))
2755 sprintf (label, DECL_NAME_FMT, DECL_UID (origin));
2759 sprintf (label, TYPE_NAME_FMT, TYPE_UID (origin));
2763 abort (); /* Should never happen. */
2766 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2769 #ifdef DWARF_DECL_COORDINATES
2771 src_coords_attribute (src_fileno, src_lineno)
2772 register unsigned src_fileno;
2773 register unsigned src_lineno;
2775 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_coords);
2776 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_fileno);
2777 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_lineno);
2779 #endif /* defined(DWARF_DECL_COORDINATES) */
2782 pure_or_virtual_attribute (func_decl)
2783 register tree func_decl;
2785 if (DECL_VIRTUAL_P (func_decl))
2787 #if 0 /* DECL_ABSTRACT_VIRTUAL_P is C++-specific. */
2788 if (DECL_ABSTRACT_VIRTUAL_P (func_decl))
2789 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_pure_virtual);
2792 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
2793 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
2797 /************************* end of attributes *****************************/
2799 /********************* utility routines for DIEs *************************/
2801 /* Output an AT_name attribute and an AT_src_coords attribute for the
2802 given decl, but only if it actually has a name. */
2805 name_and_src_coords_attributes (decl)
2808 register tree decl_name = DECL_NAME (decl);
2810 if (decl_name && IDENTIFIER_POINTER (decl_name))
2812 name_attribute (IDENTIFIER_POINTER (decl_name));
2813 #ifdef DWARF_DECL_COORDINATES
2815 register unsigned file_index;
2817 /* This is annoying, but we have to pop out of the .debug section
2818 for a moment while we call `lookup_filename' because calling it
2819 may cause a temporary switch into the .debug_sfnames section and
2820 most svr4 assemblers are not smart enough be be able to nest
2821 section switches to any depth greater than one. Note that we
2822 also can't skirt this issue by delaying all output to the
2823 .debug_sfnames section unit the end of compilation because that
2824 would cause us to have inter-section forward references and
2825 Fred Fish sez that m68k/svr4 assemblers botch those. */
2827 ASM_OUTPUT_POP_SECTION (asm_out_file);
2828 file_index = lookup_filename (DECL_SOURCE_FILE (decl));
2829 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
2831 src_coords_attribute (file_index, DECL_SOURCE_LINE (decl));
2833 #endif /* defined(DWARF_DECL_COORDINATES) */
2837 /* Many forms of DIEs contain a "type description" part. The following
2838 routine writes out these "type descriptor" parts. */
2841 type_attribute (type, decl_const, decl_volatile)
2843 register int decl_const;
2844 register int decl_volatile;
2846 register enum tree_code code = TREE_CODE (type);
2847 register int root_type_modified;
2849 if (TREE_CODE (type) == ERROR_MARK)
2852 /* Handle a special case. For functions whose return type is void,
2853 we generate *no* type attribute. (Note that no object may have
2854 type `void', so this only applies to function return types. */
2856 if (TREE_CODE (type) == VOID_TYPE)
2859 root_type_modified = (code == POINTER_TYPE || code == REFERENCE_TYPE
2860 || decl_const || decl_volatile
2861 || TYPE_READONLY (type) || TYPE_VOLATILE (type));
2863 if (type_is_fundamental (root_type (type)))
2864 if (root_type_modified)
2865 mod_fund_type_attribute (type, decl_const, decl_volatile);
2867 fund_type_attribute (fundamental_type_code (type));
2869 if (root_type_modified)
2870 mod_u_d_type_attribute (type, decl_const, decl_volatile);
2872 /* We have to get the type_main_variant here (and pass that to the
2873 `user_def_type_attribute' routine) because the ..._TYPE node we
2874 have might simply be a *copy* of some original type node (where
2875 the copy was created to help us keep track of typedef names)
2876 and that copy might have a different TYPE_UID from the original
2877 ..._TYPE node. (Note that when `equate_type_number_to_die_number'
2878 is labeling a given type DIE for future reference, it always and
2879 only creates labels for DIEs representing *main variants*, and it
2880 never even knows about non-main-variants.) */
2881 user_def_type_attribute (type_main_variant (type));
2884 /* Given a tree pointer to a struct, class, union, or enum type node, return
2885 a pointer to the (string) tag name for the given type, or zero if the
2886 type was declared without a tag. */
2892 register char *name = 0;
2894 if (TYPE_NAME (type) != 0)
2896 register tree t = 0;
2898 /* Find the IDENTIFIER_NODE for the type name. */
2899 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
2900 t = TYPE_NAME (type);
2902 /* The g++ front end makes the TYPE_NAME of *each* tagged type point
2903 to a TYPE_DECL node, regardless of whether or not a `typedef' was
2904 involved. This is distinctly different from what the gcc front-end
2905 does. It always makes the TYPE_NAME for each tagged type be either
2906 NULL (signifying an anonymous tagged type) or else a pointer to an
2907 IDENTIFIER_NODE. Obviously, we would like to generate correct Dwarf
2908 for both C and C++, but given this inconsistency in the TREE
2909 representation of tagged types for C and C++ in the GNU front-ends,
2910 we cannot support both languages correctly unless we introduce some
2911 front-end specific code here, and rms objects to that, so we can
2912 only generate correct Dwarf for one of these two languages. C is
2913 more important, so for now we'll do the right thing for C and let
2917 if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
2918 t = DECL_NAME (TYPE_NAME (type));
2920 /* Now get the name as a string, or invent one. */
2922 name = IDENTIFIER_POINTER (t);
2925 return (name == 0 || *name == '\0') ? 0 : name;
2931 /* Start by checking if the pending_sibling_stack needs to be expanded.
2932 If necessary, expand it. */
2934 if (pending_siblings == pending_siblings_allocated)
2936 pending_siblings_allocated += PENDING_SIBLINGS_INCREMENT;
2937 pending_sibling_stack
2938 = (unsigned *) xrealloc (pending_sibling_stack,
2939 pending_siblings_allocated * sizeof(unsigned));
2943 NEXT_DIE_NUM = next_unused_dienum++;
2946 /* Pop the sibling stack so that the most recently pushed DIEnum becomes the
2956 member_declared_type (member)
2957 register tree member;
2959 return (DECL_BIT_FIELD_TYPE (member))
2960 ? DECL_BIT_FIELD_TYPE (member)
2961 : TREE_TYPE (member);
2964 /* Get the function's label, as described by its RTL.
2965 This may be different from the DECL_NAME name used
2966 in the source file. */
2969 function_start_label (decl)
2975 x = DECL_RTL (decl);
2976 if (GET_CODE (x) != MEM)
2979 if (GET_CODE (x) != SYMBOL_REF)
2981 fnname = XSTR (x, 0);
2986 /******************************* DIEs ************************************/
2988 /* Output routines for individual types of DIEs. */
2990 /* Note that every type of DIE (except a null DIE) gets a sibling. */
2993 output_array_type_die (arg)
2996 register tree type = arg;
2998 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_array_type);
2999 sibling_attribute ();
3000 equate_type_number_to_die_number (type);
3001 member_attribute (TYPE_CONTEXT (type));
3003 /* I believe that we can default the array ordering. SDB will probably
3004 do the right things even if AT_ordering is not present. It's not
3005 even an issue until we start to get into multidimensional arrays
3006 anyway. If SDB is ever caught doing the Wrong Thing for multi-
3007 dimensional arrays, then we'll have to put the AT_ordering attribute
3008 back in. (But if and when we find out that we need to put these in,
3009 we will only do so for multidimensional arrays. After all, we don't
3010 want to waste space in the .debug section now do we?) */
3012 #ifdef USE_ORDERING_ATTRIBUTE
3013 ordering_attribute (ORD_row_major);
3014 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
3016 subscript_data_attribute (type);
3020 output_set_type_die (arg)
3023 register tree type = arg;
3025 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_set_type);
3026 sibling_attribute ();
3027 equate_type_number_to_die_number (type);
3028 member_attribute (TYPE_CONTEXT (type));
3029 type_attribute (TREE_TYPE (type), 0, 0);
3033 /* Implement this when there is a GNU FORTRAN or GNU Ada front end. */
3035 output_entry_point_die (arg)
3038 register tree decl = arg;
3039 register tree origin = decl_ultimate_origin (decl);
3041 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_entry_point);
3042 sibling_attribute ();
3045 abstract_origin_attribute (origin);
3048 name_and_src_coords_attributes (decl);
3049 member_attribute (DECL_CONTEXT (decl));
3050 type_attribute (TREE_TYPE (TREE_TYPE (decl)), 0, 0);
3052 if (DECL_ABSTRACT (decl))
3053 equate_decl_number_to_die_number (decl);
3055 low_pc_attribute (function_start_label (decl));
3059 /* Output a DIE to represent an inlined instance of an enumeration type. */
3062 output_inlined_enumeration_type_die (arg)
3065 register tree type = arg;
3067 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
3068 sibling_attribute ();
3069 assert (TREE_ASM_WRITTEN (type));
3070 abstract_origin_attribute (type);
3073 /* Output a DIE to represent an inlined instance of a structure type. */
3076 output_inlined_structure_type_die (arg)
3079 register tree type = arg;
3081 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
3082 sibling_attribute ();
3083 assert (TREE_ASM_WRITTEN (type));
3084 abstract_origin_attribute (type);
3087 /* Output a DIE to represent an inlined instance of a union type. */
3090 output_inlined_union_type_die (arg)
3093 register tree type = arg;
3095 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
3096 sibling_attribute ();
3097 assert (TREE_ASM_WRITTEN (type));
3098 abstract_origin_attribute (type);
3101 /* Output a DIE to represent an enumeration type. Note that these DIEs
3102 include all of the information about the enumeration values also.
3103 This information is encoded into the element_list attribute. */
3106 output_enumeration_type_die (arg)
3109 register tree type = arg;
3111 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
3112 sibling_attribute ();
3113 equate_type_number_to_die_number (type);
3114 name_attribute (type_tag (type));
3115 member_attribute (TYPE_CONTEXT (type));
3117 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
3118 given enum type is incomplete, do not generate the AT_byte_size
3119 attribute or the AT_element_list attribute. */
3121 if (TYPE_SIZE (type))
3123 byte_size_attribute (type);
3124 element_list_attribute (TYPE_FIELDS (type));
3128 /* Output a DIE to represent either a real live formal parameter decl or
3129 to represent just the type of some formal parameter position in some
3132 Note that this routine is a bit unusual because its argument may be
3133 a ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
3134 represents an inlining of some PARM_DECL) or else some sort of a
3135 ..._TYPE node. If it's the former then this function is being called
3136 to output a DIE to represent a formal parameter object (or some inlining
3137 thereof). If it's the latter, then this function is only being called
3138 to output a TAG_formal_parameter DIE to stand as a placeholder for some
3139 formal argument type of some subprogram type. */
3142 output_formal_parameter_die (arg)
3145 register tree node = arg;
3147 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_formal_parameter);
3148 sibling_attribute ();
3150 switch (TREE_CODE_CLASS (TREE_CODE (node)))
3152 case 'd': /* We were called with some kind of a ..._DECL node. */
3154 register tree origin = decl_ultimate_origin (node);
3157 abstract_origin_attribute (origin);
3160 name_and_src_coords_attributes (node);
3161 type_attribute (TREE_TYPE (node),
3162 TREE_READONLY (node), TREE_THIS_VOLATILE (node));
3164 if (DECL_ABSTRACT (node))
3165 equate_decl_number_to_die_number (node);
3167 location_or_const_value_attribute (node);
3171 case 't': /* We were called with some kind of a ..._TYPE node. */
3172 type_attribute (node, 0, 0);
3176 abort (); /* Should never happen. */
3180 /* Output a DIE to represent a declared function (either file-scope
3181 or block-local) which has "external linkage" (according to ANSI-C). */
3184 output_global_subroutine_die (arg)
3187 register tree decl = arg;
3188 register tree origin = decl_ultimate_origin (decl);
3190 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_subroutine);
3191 sibling_attribute ();
3194 abstract_origin_attribute (origin);
3197 register tree type = TREE_TYPE (decl);
3199 name_and_src_coords_attributes (decl);
3200 inline_attribute (decl);
3201 prototyped_attribute (type);
3202 member_attribute (DECL_CONTEXT (decl));
3203 type_attribute (TREE_TYPE (type), 0, 0);
3204 pure_or_virtual_attribute (decl);
3206 if (DECL_ABSTRACT (decl))
3207 equate_decl_number_to_die_number (decl);
3210 if (! DECL_EXTERNAL (decl))
3212 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3214 low_pc_attribute (function_start_label (decl));
3215 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
3216 high_pc_attribute (label);
3217 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
3218 body_begin_attribute (label);
3219 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
3220 body_end_attribute (label);
3225 /* Output a DIE to represent a declared data object (either file-scope
3226 or block-local) which has "external linkage" (according to ANSI-C). */
3229 output_global_variable_die (arg)
3232 register tree decl = arg;
3233 register tree origin = decl_ultimate_origin (decl);
3235 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_variable);
3236 sibling_attribute ();
3238 abstract_origin_attribute (origin);
3241 name_and_src_coords_attributes (decl);
3242 member_attribute (DECL_CONTEXT (decl));
3243 type_attribute (TREE_TYPE (decl),
3244 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3246 if (DECL_ABSTRACT (decl))
3247 equate_decl_number_to_die_number (decl);
3250 if (!DECL_EXTERNAL (decl))
3251 location_or_const_value_attribute (decl);
3256 output_label_die (arg)
3259 register tree decl = arg;
3260 register tree origin = decl_ultimate_origin (decl);
3262 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_label);
3263 sibling_attribute ();
3265 abstract_origin_attribute (origin);
3267 name_and_src_coords_attributes (decl);
3268 if (DECL_ABSTRACT (decl))
3269 equate_decl_number_to_die_number (decl);
3272 register rtx insn = DECL_RTL (decl);
3274 if (GET_CODE (insn) == CODE_LABEL)
3276 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3278 /* When optimization is enabled (via -O) some parts of the compiler
3279 (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
3280 represent source-level labels which were explicitly declared by
3281 the user. This really shouldn't be happening though, so catch
3282 it if it ever does happen. */
3284 if (INSN_DELETED_P (insn))
3285 abort (); /* Should never happen. */
3287 sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
3288 (unsigned) INSN_UID (insn));
3289 low_pc_attribute (label);
3295 output_lexical_block_die (arg)
3298 register tree stmt = arg;
3300 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_lexical_block);
3301 sibling_attribute ();
3303 if (! BLOCK_ABSTRACT (stmt))
3305 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3306 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3308 sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
3309 low_pc_attribute (begin_label);
3310 sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
3311 high_pc_attribute (end_label);
3316 output_inlined_subroutine_die (arg)
3319 register tree stmt = arg;
3321 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inlined_subroutine);
3322 sibling_attribute ();
3324 abstract_origin_attribute (block_ultimate_origin (stmt));
3325 if (! BLOCK_ABSTRACT (stmt))
3327 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3328 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3330 sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
3331 low_pc_attribute (begin_label);
3332 sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
3333 high_pc_attribute (end_label);
3337 /* Output a DIE to represent a declared data object (either file-scope
3338 or block-local) which has "internal linkage" (according to ANSI-C). */
3341 output_local_variable_die (arg)
3344 register tree decl = arg;
3345 register tree origin = decl_ultimate_origin (decl);
3347 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_local_variable);
3348 sibling_attribute ();
3350 abstract_origin_attribute (origin);
3353 name_and_src_coords_attributes (decl);
3354 member_attribute (DECL_CONTEXT (decl));
3355 type_attribute (TREE_TYPE (decl),
3356 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3358 if (DECL_ABSTRACT (decl))
3359 equate_decl_number_to_die_number (decl);
3361 location_or_const_value_attribute (decl);
3365 output_member_die (arg)
3368 register tree decl = arg;
3370 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_member);
3371 sibling_attribute ();
3372 name_and_src_coords_attributes (decl);
3373 member_attribute (DECL_CONTEXT (decl));
3374 type_attribute (member_declared_type (decl),
3375 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3376 if (DECL_BIT_FIELD_TYPE (decl)) /* If this is a bit field... */
3378 byte_size_attribute (decl);
3379 bit_size_attribute (decl);
3380 bit_offset_attribute (decl);
3382 data_member_location_attribute (decl);
3386 /* Don't generate either pointer_type DIEs or reference_type DIEs. Use
3387 modified types instead.
3389 We keep this code here just in case these types of DIEs may be needed
3390 to represent certain things in other languages (e.g. Pascal) someday.
3394 output_pointer_type_die (arg)
3397 register tree type = arg;
3399 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_pointer_type);
3400 sibling_attribute ();
3401 equate_type_number_to_die_number (type);
3402 member_attribute (TYPE_CONTEXT (type));
3403 type_attribute (TREE_TYPE (type), 0, 0);
3407 output_reference_type_die (arg)
3410 register tree type = arg;
3412 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_reference_type);
3413 sibling_attribute ();
3414 equate_type_number_to_die_number (type);
3415 member_attribute (TYPE_CONTEXT (type));
3416 type_attribute (TREE_TYPE (type), 0, 0);
3421 output_ptr_to_mbr_type_die (arg)
3424 register tree type = arg;
3426 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_ptr_to_member_type);
3427 sibling_attribute ();
3428 equate_type_number_to_die_number (type);
3429 member_attribute (TYPE_CONTEXT (type));
3430 containing_type_attribute (TYPE_OFFSET_BASETYPE (type));
3431 type_attribute (TREE_TYPE (type), 0, 0);
3435 output_compile_unit_die (arg)
3438 register char *main_input_filename = arg;
3440 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_compile_unit);
3441 sibling_attribute ();
3443 name_attribute (main_input_filename);
3448 sprintf (producer, "%s %s", language_string, version_string);
3449 producer_attribute (producer);
3452 if (strcmp (language_string, "GNU C++") == 0)
3453 language_attribute (LANG_C_PLUS_PLUS);
3454 else if (strcmp (language_string, "GNU Ada") == 0)
3455 language_attribute (LANG_ADA83);
3456 else if (strcmp (language_string, "GNU F77") == 0)
3457 language_attribute (LANG_FORTRAN77);
3458 else if (flag_traditional)
3459 language_attribute (LANG_C);
3461 language_attribute (LANG_C89);
3462 low_pc_attribute (TEXT_BEGIN_LABEL);
3463 high_pc_attribute (TEXT_END_LABEL);
3464 if (debug_info_level >= DINFO_LEVEL_NORMAL)
3465 stmt_list_attribute (LINE_BEGIN_LABEL);
3466 last_filename = xstrdup (main_input_filename);
3469 char *wd = getpwd ();
3471 comp_dir_attribute (wd);
3474 if (debug_info_level >= DINFO_LEVEL_NORMAL)
3476 sf_names_attribute (SFNAMES_BEGIN_LABEL);
3477 src_info_attribute (SRCINFO_BEGIN_LABEL);
3478 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
3479 mac_info_attribute (MACINFO_BEGIN_LABEL);
3484 output_string_type_die (arg)
3487 register tree type = arg;
3489 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_string_type);
3490 sibling_attribute ();
3491 member_attribute (TYPE_CONTEXT (type));
3493 /* Fudge the string length attribute for now. */
3495 string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
3499 output_structure_type_die (arg)
3502 register tree type = arg;
3504 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
3505 sibling_attribute ();
3506 equate_type_number_to_die_number (type);
3507 name_attribute (type_tag (type));
3508 member_attribute (TYPE_CONTEXT (type));
3510 /* If this type has been completed, then give it a byte_size attribute
3511 and prepare to give a list of members. Otherwise, don't do either of
3512 these things. In the latter case, we will not be generating a list
3513 of members (since we don't have any idea what they might be for an
3514 incomplete type). */
3516 if (TYPE_SIZE (type))
3519 byte_size_attribute (type);
3523 /* Output a DIE to represent a declared function (either file-scope
3524 or block-local) which has "internal linkage" (according to ANSI-C). */
3527 output_local_subroutine_die (arg)
3530 register tree decl = arg;
3531 register tree origin = decl_ultimate_origin (decl);
3533 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine);
3534 sibling_attribute ();
3537 abstract_origin_attribute (origin);
3540 register tree type = TREE_TYPE (decl);
3542 name_and_src_coords_attributes (decl);
3543 inline_attribute (decl);
3544 prototyped_attribute (type);
3545 member_attribute (DECL_CONTEXT (decl));
3546 type_attribute (TREE_TYPE (type), 0, 0);
3547 pure_or_virtual_attribute (decl);
3549 if (DECL_ABSTRACT (decl))
3550 equate_decl_number_to_die_number (decl);
3553 /* Avoid getting screwed up in cases where a function was declared
3554 static but where no definition was ever given for it. */
3556 if (TREE_ASM_WRITTEN (decl))
3558 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3559 low_pc_attribute (function_start_label (decl));
3560 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
3561 high_pc_attribute (label);
3562 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
3563 body_begin_attribute (label);
3564 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
3565 body_end_attribute (label);
3571 output_subroutine_type_die (arg)
3574 register tree type = arg;
3575 register tree return_type = TREE_TYPE (type);
3577 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine_type);
3578 sibling_attribute ();
3580 equate_type_number_to_die_number (type);
3581 prototyped_attribute (type);
3582 member_attribute (TYPE_CONTEXT (type));
3583 type_attribute (return_type, 0, 0);
3587 output_typedef_die (arg)
3590 register tree decl = arg;
3591 register tree origin = decl_ultimate_origin (decl);
3593 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_typedef);
3594 sibling_attribute ();
3596 abstract_origin_attribute (origin);
3599 name_and_src_coords_attributes (decl);
3600 member_attribute (DECL_CONTEXT (decl));
3601 type_attribute (TREE_TYPE (decl),
3602 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3604 if (DECL_ABSTRACT (decl))
3605 equate_decl_number_to_die_number (decl);
3609 output_union_type_die (arg)
3612 register tree type = arg;
3614 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
3615 sibling_attribute ();
3616 equate_type_number_to_die_number (type);
3617 name_attribute (type_tag (type));
3618 member_attribute (TYPE_CONTEXT (type));
3620 /* If this type has been completed, then give it a byte_size attribute
3621 and prepare to give a list of members. Otherwise, don't do either of
3622 these things. In the latter case, we will not be generating a list
3623 of members (since we don't have any idea what they might be for an
3624 incomplete type). */
3626 if (TYPE_SIZE (type))
3629 byte_size_attribute (type);
3633 /* Generate a special type of DIE used as a stand-in for a trailing ellipsis
3634 at the end of an (ANSI prototyped) formal parameters list. */
3637 output_unspecified_parameters_die (arg)
3640 register tree decl_or_type = arg;
3642 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_unspecified_parameters);
3643 sibling_attribute ();
3645 /* This kludge is here only for the sake of being compatible with what
3646 the USL CI5 C compiler does. The specification of Dwarf Version 1
3647 doesn't say that TAG_unspecified_parameters DIEs should contain any
3648 attributes other than the AT_sibling attribute, but they are certainly
3649 allowed to contain additional attributes, and the CI5 compiler
3650 generates AT_name, AT_fund_type, and AT_location attributes within
3651 TAG_unspecified_parameters DIEs which appear in the child lists for
3652 DIEs representing function definitions, so we do likewise here. */
3654 if (TREE_CODE (decl_or_type) == FUNCTION_DECL && DECL_INITIAL (decl_or_type))
3656 name_attribute ("...");
3657 fund_type_attribute (FT_pointer);
3658 /* location_attribute (?); */
3663 output_padded_null_die (arg)
3666 ASM_OUTPUT_ALIGN (asm_out_file, 2); /* 2**2 == 4 */
3669 /*************************** end of DIEs *********************************/
3671 /* Generate some type of DIE. This routine generates the generic outer
3672 wrapper stuff which goes around all types of DIE's (regardless of their
3673 TAGs. All forms of DIEs start with a DIE-specific label, followed by a
3674 DIE-length word, followed by the guts of the DIE itself. After the guts
3675 of the DIE, there must always be a terminator label for the DIE. */
3678 output_die (die_specific_output_function, param)
3679 register void (*die_specific_output_function)();
3680 register void *param;
3682 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3683 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3685 current_dienum = NEXT_DIE_NUM;
3686 NEXT_DIE_NUM = next_unused_dienum;
3688 sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
3689 sprintf (end_label, DIE_END_LABEL_FMT, current_dienum);
3691 /* Write a label which will act as the name for the start of this DIE. */
3693 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
3695 /* Write the DIE-length word. */
3697 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
3699 /* Fill in the guts of the DIE. */
3701 next_unused_dienum++;
3702 die_specific_output_function (param);
3704 /* Write a label which will act as the name for the end of this DIE. */
3706 ASM_OUTPUT_LABEL (asm_out_file, end_label);
3710 end_sibling_chain ()
3712 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3714 current_dienum = NEXT_DIE_NUM;
3715 NEXT_DIE_NUM = next_unused_dienum;
3717 sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
3719 /* Write a label which will act as the name for the start of this DIE. */
3721 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
3723 /* Write the DIE-length word. */
3725 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 4);
3730 /* Generate a list of nameless TAG_formal_parameter DIEs (and perhaps a
3731 TAG_unspecified_parameters DIE) to represent the types of the formal
3732 parameters as specified in some function type specification (except
3733 for those which appear as part of a function *definition*).
3735 Note that we must be careful here to output all of the parameter DIEs
3736 *before* we output any DIEs needed to represent the types of the formal
3737 parameters. This keeps svr4 SDB happy because it (incorrectly) thinks
3738 that the first non-parameter DIE it sees ends the formal parameter list.
3742 output_formal_types (function_or_method_type)
3743 register tree function_or_method_type;
3746 register tree formal_type = NULL;
3747 register tree first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
3749 /* In the case where we are generating a formal types list for a C++
3750 non-static member function type, skip over the first thing on the
3751 TYPE_ARG_TYPES list because it only represents the type of the
3752 hidden `this pointer'. The debugger should be able to figure
3753 out (without being explicitly told) that this non-static member
3754 function type takes a `this pointer' and should be able to figure
3755 what the type of that hidden parameter is from the AT_member
3756 attribute of the parent TAG_subroutine_type DIE. */
3758 if (TREE_CODE (function_or_method_type) == METHOD_TYPE)
3759 first_parm_type = TREE_CHAIN (first_parm_type);
3761 /* Make our first pass over the list of formal parameter types and output
3762 a TAG_formal_parameter DIE for each one. */
3764 for (link = first_parm_type; link; link = TREE_CHAIN (link))
3766 formal_type = TREE_VALUE (link);
3767 if (formal_type == void_type_node)
3770 /* Output a (nameless) DIE to represent the formal parameter itself. */
3772 output_die (output_formal_parameter_die, formal_type);
3775 /* If this function type has an ellipsis, add a TAG_unspecified_parameters
3776 DIE to the end of the parameter list. */
3778 if (formal_type != void_type_node)
3779 output_die (output_unspecified_parameters_die, function_or_method_type);
3781 /* Make our second (and final) pass over the list of formal parameter types
3782 and output DIEs to represent those types (as necessary). */
3784 for (link = TYPE_ARG_TYPES (function_or_method_type);
3786 link = TREE_CHAIN (link))
3788 formal_type = TREE_VALUE (link);
3789 if (formal_type == void_type_node)
3792 output_type (formal_type, function_or_method_type);
3796 /* Remember a type in the pending_types_list. */
3802 if (pending_types == pending_types_allocated)
3804 pending_types_allocated += PENDING_TYPES_INCREMENT;
3806 = (tree *) xrealloc (pending_types_list,
3807 sizeof (tree) * pending_types_allocated);
3809 pending_types_list[pending_types++] = type;
3811 /* Mark the pending type as having been output already (even though
3812 it hasn't been). This prevents the type from being added to the
3813 pending_types_list more than once. */
3815 TREE_ASM_WRITTEN (type) = 1;
3818 /* Return non-zero if it is legitimate to output DIEs to represent a
3819 given type while we are generating the list of child DIEs for some
3820 DIE (e.g. a function or lexical block DIE) associated with a given scope.
3822 See the comments within the function for a description of when it is
3823 considered legitimate to output DIEs for various kinds of types.
3825 Note that TYPE_CONTEXT(type) may be NULL (to indicate global scope)
3826 or it may point to a BLOCK node (for types local to a block), or to a
3827 FUNCTION_DECL node (for types local to the heading of some function
3828 definition), or to a FUNCTION_TYPE node (for types local to the
3829 prototyped parameter list of a function type specification), or to a
3830 RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node
3831 (in the case of C++ nested types).
3833 The `scope' parameter should likewise be NULL or should point to a
3834 BLOCK node, a FUNCTION_DECL node, a FUNCTION_TYPE node, a RECORD_TYPE
3835 node, a UNION_TYPE node, or a QUAL_UNION_TYPE node.
3837 This function is used only for deciding when to "pend" and when to
3838 "un-pend" types to/from the pending_types_list.
3840 Note that we sometimes make use of this "type pending" feature in a
3841 rather twisted way to temporarily delay the production of DIEs for the
3842 types of formal parameters. (We do this just to make svr4 SDB happy.)
3843 It order to delay the production of DIEs representing types of formal
3844 parameters, callers of this function supply `fake_containing_scope' as
3845 the `scope' parameter to this function. Given that fake_containing_scope
3846 is a tagged type which is *not* the containing scope for *any* other type,
3847 the desired effect is achieved, i.e. output of DIEs representing types
3848 is temporarily suspended, and any type DIEs which would have otherwise
3849 been output are instead placed onto the pending_types_list. Later on,
3850 we force these (temporarily pended) types to be output simply by calling
3851 `output_pending_types_for_scope' with an actual argument equal to the
3852 true scope of the types we temporarily pended.
3856 type_ok_for_scope (type, scope)
3858 register tree scope;
3860 /* Tagged types (i.e. struct, union, and enum types) must always be
3861 output only in the scopes where they actually belong (or else the
3862 scoping of their own tag names and the scoping of their member
3863 names will be incorrect). Non-tagged-types on the other hand can
3864 generally be output anywhere, except that svr4 SDB really doesn't
3865 want to see them nested within struct or union types, so here we
3866 say it is always OK to immediately output any such a (non-tagged)
3867 type, so long as we are not within such a context. Note that the
3868 only kinds of non-tagged types which we will be dealing with here
3869 (for C and C++ anyway) will be array types and function types. */
3871 return is_tagged_type (type)
3872 ? (TYPE_CONTEXT (type) == scope)
3873 : (scope == NULL_TREE || ! is_tagged_type (scope));
3876 /* Output any pending types (from the pending_types list) which we can output
3877 now (taking into account the scope that we are working on now).
3879 For each type output, remove the given type from the pending_types_list
3880 *before* we try to output it.
3882 Note that we have to process the list in beginning-to-end order,
3883 because the call made here to output_type may cause yet more types
3884 to be added to the end of the list, and we may have to output some
3889 output_pending_types_for_scope (containing_scope)
3890 register tree containing_scope;
3892 register unsigned i;
3894 for (i = 0; i < pending_types; )
3896 register tree type = pending_types_list[i];
3898 if (type_ok_for_scope (type, containing_scope))
3900 register tree *mover;
3901 register tree *limit;
3904 limit = &pending_types_list[pending_types];
3905 for (mover = &pending_types_list[i]; mover < limit; mover++)
3906 *mover = *(mover+1);
3908 /* Un-mark the type as having been output already (because it
3909 hasn't been, really). Then call output_type to generate a
3910 Dwarf representation of it. */
3912 TREE_ASM_WRITTEN (type) = 0;
3913 output_type (type, containing_scope);
3915 /* Don't increment the loop counter in this case because we
3916 have shifted all of the subsequent pending types down one
3917 element in the pending_types_list array. */
3925 output_type (type, containing_scope)
3927 register tree containing_scope;
3929 if (type == 0 || type == error_mark_node)
3932 /* We are going to output a DIE to represent the unqualified version of
3933 of this type (i.e. without any const or volatile qualifiers) so get
3934 the main variant (i.e. the unqualified version) of this type now. */
3936 type = type_main_variant (type);
3938 if (TREE_ASM_WRITTEN (type))
3941 /* Don't generate any DIEs for this type now unless it is OK to do so
3942 (based upon what `type_ok_for_scope' tells us). */
3944 if (! type_ok_for_scope (type, containing_scope))
3950 switch (TREE_CODE (type))
3956 case REFERENCE_TYPE:
3957 /* For these types, all that is required is that we output a DIE
3958 (or a set of DIEs) to represent the "basis" type. */
3959 output_type (TREE_TYPE (type), containing_scope);
3963 /* This code is used for C++ pointer-to-data-member types. */
3964 /* Output a description of the relevant class type. */
3965 output_type (TYPE_OFFSET_BASETYPE (type), containing_scope);
3966 /* Output a description of the type of the object pointed to. */
3967 output_type (TREE_TYPE (type), containing_scope);
3968 /* Now output a DIE to represent this pointer-to-data-member type
3970 output_die (output_ptr_to_mbr_type_die, type);
3974 output_type (TYPE_DOMAIN (type), containing_scope);
3975 output_die (output_set_type_die, type);
3979 output_type (TREE_TYPE (type), containing_scope);
3980 abort (); /* No way to represent these in Dwarf yet! */
3984 /* Force out return type (in case it wasn't forced out already). */
3985 output_type (TREE_TYPE (type), containing_scope);
3986 output_die (output_subroutine_type_die, type);
3987 output_formal_types (type);
3988 end_sibling_chain ();
3992 /* Force out return type (in case it wasn't forced out already). */
3993 output_type (TREE_TYPE (type), containing_scope);
3994 output_die (output_subroutine_type_die, type);
3995 output_formal_types (type);
3996 end_sibling_chain ();
4000 if (TYPE_STRING_FLAG (type) && TREE_CODE(TREE_TYPE(type)) == CHAR_TYPE)
4002 output_type (TREE_TYPE (type), containing_scope);
4003 output_die (output_string_type_die, type);
4007 register tree element_type;
4009 element_type = TREE_TYPE (type);
4010 while (TREE_CODE (element_type) == ARRAY_TYPE)
4011 element_type = TREE_TYPE (element_type);
4013 output_type (element_type, containing_scope);
4014 output_die (output_array_type_die, type);
4021 case QUAL_UNION_TYPE:
4023 /* For a non-file-scope tagged type, we can always go ahead and
4024 output a Dwarf description of this type right now, even if
4025 the type in question is still incomplete, because if this
4026 local type *was* ever completed anywhere within its scope,
4027 that complete definition would already have been attached to
4028 this RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE or ENUMERAL_TYPE
4029 node by the time we reach this point. That's true because of the
4030 way the front-end does its processing of file-scope declarations (of
4031 functions and class types) within which other types might be
4032 nested. The C and C++ front-ends always gobble up such "local
4033 scope" things en-mass before they try to output *any* debugging
4034 information for any of the stuff contained inside them and thus,
4035 we get the benefit here of what is (in effect) a pre-resolution
4036 of forward references to tagged types in local scopes.
4038 Note however that for file-scope tagged types we cannot assume
4039 that such pre-resolution of forward references has taken place.
4040 A given file-scope tagged type may appear to be incomplete when
4041 we reach this point, but it may yet be given a full definition
4042 (at file-scope) later on during compilation. In order to avoid
4043 generating a premature (and possibly incorrect) set of Dwarf
4044 DIEs for such (as yet incomplete) file-scope tagged types, we
4045 generate nothing at all for as-yet incomplete file-scope tagged
4046 types here unless we are making our special "finalization" pass
4047 for file-scope things at the very end of compilation. At that
4048 time, we will certainly know as much about each file-scope tagged
4049 type as we are ever going to know, so at that point in time, we
4050 can safely generate correct Dwarf descriptions for these file-
4054 if (TYPE_SIZE (type) == 0 && TYPE_CONTEXT (type) == NULL && !finalizing)
4055 return; /* EARLY EXIT! Avoid setting TREE_ASM_WRITTEN. */
4057 /* Prevent infinite recursion in cases where the type of some
4058 member of this type is expressed in terms of this type itself. */
4060 TREE_ASM_WRITTEN (type) = 1;
4062 /* Output a DIE to represent the tagged type itself. */
4064 switch (TREE_CODE (type))
4067 output_die (output_enumeration_type_die, type);
4068 return; /* a special case -- nothing left to do so just return */
4071 output_die (output_structure_type_die, type);
4075 case QUAL_UNION_TYPE:
4076 output_die (output_union_type_die, type);
4080 abort (); /* Should never happen. */
4083 /* If this is not an incomplete type, output descriptions of
4084 each of its members.
4086 Note that as we output the DIEs necessary to represent the
4087 members of this record or union type, we will also be trying
4088 to output DIEs to represent the *types* of those members.
4089 However the `output_type' function (above) will specifically
4090 avoid generating type DIEs for member types *within* the list
4091 of member DIEs for this (containing) type execpt for those
4092 types (of members) which are explicitly marked as also being
4093 members of this (containing) type themselves. The g++ front-
4094 end can force any given type to be treated as a member of some
4095 other (containing) type by setting the TYPE_CONTEXT of the
4096 given (member) type to point to the TREE node representing the
4097 appropriate (containing) type.
4100 if (TYPE_SIZE (type))
4103 register tree normal_member;
4105 /* First output info about the data members and type members. */
4107 for (normal_member = TYPE_FIELDS (type);
4109 normal_member = TREE_CHAIN (normal_member))
4110 output_decl (normal_member, type);
4114 register tree vec_base;
4116 /* Now output info about the function members (if any). */
4118 vec_base = TYPE_METHODS (type);
4121 register tree first_func_member = TREE_VEC_ELT (vec_base, 0);
4122 register tree func_member;
4124 /* This isn't documented, but the first element of the
4125 vector of member functions can be NULL in cases where
4126 the class type in question didn't have either a
4127 constructor or a destructor declared for it. We have
4128 to make allowances for that here. */
4130 if (first_func_member == NULL)
4131 first_func_member = TREE_VEC_ELT (vec_base, 1);
4133 for (func_member = first_func_member;
4135 func_member = TREE_CHAIN (func_member))
4136 output_decl (func_member, type);
4140 /* RECORD_TYPEs, UNION_TYPEs, and QUAL_UNION_TYPEs are themselves
4141 scopes (at least in C++) so we must now output any nested
4142 pending types which are local just to this type. */
4144 output_pending_types_for_scope (type);
4146 end_sibling_chain (); /* Terminate member chain. */
4157 break; /* No DIEs needed for fundamental types. */
4159 case LANG_TYPE: /* No Dwarf representation currently defined. */
4166 TREE_ASM_WRITTEN (type) = 1;
4170 output_tagged_type_instantiation (type)
4173 if (type == 0 || type == error_mark_node)
4176 /* We are going to output a DIE to represent the unqualified version of
4177 of this type (i.e. without any const or volatile qualifiers) so make
4178 sure that we have the main variant (i.e. the unqualified version) of
4181 assert (type == type_main_variant (type));
4183 assert (TREE_ASM_WRITTEN (type));
4185 switch (TREE_CODE (type))
4191 output_die (output_inlined_enumeration_type_die, type);
4195 output_die (output_inlined_structure_type_die, type);
4199 case QUAL_UNION_TYPE:
4200 output_die (output_inlined_union_type_die, type);
4204 abort (); /* Should never happen. */
4208 /* Output a TAG_lexical_block DIE followed by DIEs to represent all of
4209 the things which are local to the given block. */
4215 register int must_output_die = 0;
4216 register tree origin;
4217 register enum tree_code origin_code;
4219 /* Ignore blocks never really used to make RTL. */
4221 if (! stmt || ! TREE_USED (stmt))
4224 /* Determine the "ultimate origin" of this block. This block may be an
4225 inlined instance of an inlined instance of inline function, so we
4226 have to trace all of the way back through the origin chain to find
4227 out what sort of node actually served as the original seed for the
4228 creation of the current block. */
4230 origin = block_ultimate_origin (stmt);
4231 origin_code = (origin != NULL) ? TREE_CODE (origin) : ERROR_MARK;
4233 /* Determine if we need to output any Dwarf DIEs at all to represent this
4236 if (origin_code == FUNCTION_DECL)
4237 /* The outer scopes for inlinings *must* always be represented. We
4238 generate TAG_inlined_subroutine DIEs for them. (See below.) */
4239 must_output_die = 1;
4242 /* In the case where the current block represents an inlining of the
4243 "body block" of an inline function, we must *NOT* output any DIE
4244 for this block because we have already output a DIE to represent
4245 the whole inlined function scope and the "body block" of any
4246 function doesn't really represent a different scope according to
4247 ANSI C rules. So we check here to make sure that this block does
4248 not represent a "body block inlining" before trying to set the
4249 `must_output_die' flag. */
4251 if (origin == NULL || ! is_body_block (origin))
4253 /* Determine if this block directly contains any "significant"
4254 local declarations which we will need to output DIEs for. */
4256 if (debug_info_level > DINFO_LEVEL_TERSE)
4257 /* We are not in terse mode so *any* local declaration counts
4258 as being a "significant" one. */
4259 must_output_die = (BLOCK_VARS (stmt) != NULL);
4264 /* We are in terse mode, so only local (nested) function
4265 definitions count as "significant" local declarations. */
4267 for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
4268 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
4270 must_output_die = 1;
4277 /* It would be a waste of space to generate a Dwarf TAG_lexical_block
4278 DIE for any block which contains no significant local declarations
4279 at all. Rather, in such cases we just call `output_decls_for_scope'
4280 so that any needed Dwarf info for any sub-blocks will get properly
4281 generated. Note that in terse mode, our definition of what constitutes
4282 a "significant" local declaration gets restricted to include only
4283 inlined function instances and local (nested) function definitions. */
4285 if (must_output_die)
4287 output_die ((origin_code == FUNCTION_DECL)
4288 ? output_inlined_subroutine_die
4289 : output_lexical_block_die,
4291 output_decls_for_scope (stmt);
4292 end_sibling_chain ();
4295 output_decls_for_scope (stmt);
4298 /* Output all of the decls declared within a given scope (also called
4299 a `binding contour') and (recursively) all of it's sub-blocks. */
4302 output_decls_for_scope (stmt)
4305 /* Ignore blocks never really used to make RTL. */
4307 if (! stmt || ! TREE_USED (stmt))
4310 if (! BLOCK_ABSTRACT (stmt))
4311 next_block_number++;
4313 /* Output the DIEs to represent all of the data objects, functions,
4314 typedefs, and tagged types declared directly within this block
4315 but not within any nested sub-blocks. */
4320 for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
4321 output_decl (decl, stmt);
4324 output_pending_types_for_scope (stmt);
4326 /* Output the DIEs to represent all sub-blocks (and the items declared
4327 therein) of this block. */
4330 register tree subblocks;
4332 for (subblocks = BLOCK_SUBBLOCKS (stmt);
4334 subblocks = BLOCK_CHAIN (subblocks))
4335 output_block (subblocks);
4339 /* Output Dwarf .debug information for a decl described by DECL. */
4342 output_decl (decl, containing_scope)
4344 register tree containing_scope;
4346 /* Make a note of the decl node we are going to be working on. We may
4347 need to give the user the source coordinates of where it appeared in
4348 case we notice (later on) that something about it looks screwy. */
4350 dwarf_last_decl = decl;
4352 if (TREE_CODE (decl) == ERROR_MARK)
4355 /* If a structure is declared within an initialization, e.g. as the
4356 operand of a sizeof, then it will not have a name. We don't want
4357 to output a DIE for it, as the tree nodes are in the temporary obstack */
4359 if ((TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
4360 || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE)
4361 && ((DECL_NAME (decl) == 0 && TYPE_NAME (TREE_TYPE (decl)) == 0)
4362 || (TYPE_FIELDS (TREE_TYPE (decl))
4363 && (TREE_CODE (TYPE_FIELDS (TREE_TYPE (decl))) == ERROR_MARK))))
4366 /* If this ..._DECL node is marked to be ignored, then ignore it.
4367 But don't ignore a function definition, since that would screw
4368 up our count of blocks, and that it turn will completely screw up the
4369 the labels we will reference in subsequent AT_low_pc and AT_high_pc
4370 attributes (for subsequent blocks). */
4372 if (DECL_IGNORED_P (decl) && TREE_CODE (decl) != FUNCTION_DECL)
4375 switch (TREE_CODE (decl))
4378 /* The individual enumerators of an enum type get output when we
4379 output the Dwarf representation of the relevant enum type itself. */
4383 /* If we are in terse mode, don't output any DIEs to represent
4384 mere function declarations. Also, if we are conforming
4385 to the DWARF version 1 specification, don't output DIEs for
4386 mere function declarations. */
4388 if (DECL_INITIAL (decl) == NULL_TREE)
4389 #if (DWARF_VERSION > 1)
4390 if (debug_info_level <= DINFO_LEVEL_TERSE)
4394 /* Before we describe the FUNCTION_DECL itself, make sure that we
4395 have described its return type. */
4397 output_type (TREE_TYPE (TREE_TYPE (decl)), containing_scope);
4399 /* If the following DIE will represent a function definition for a
4400 function with "extern" linkage, output a special "pubnames" DIE
4401 label just ahead of the actual DIE. A reference to this label
4402 was already generated in the .debug_pubnames section sub-entry
4403 for this function definition. */
4405 if (TREE_PUBLIC (decl))
4407 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4409 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
4410 ASM_OUTPUT_LABEL (asm_out_file, label);
4413 /* Now output a DIE to represent the function itself. */
4415 output_die (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)
4416 ? output_global_subroutine_die
4417 : output_local_subroutine_die,
4420 /* Now output descriptions of the arguments for this function.
4421 This gets (unnecessarily?) complex because of the fact that
4422 the DECL_ARGUMENT list for a FUNCTION_DECL doesn't indicate
4423 cases where there was a trailing `...' at the end of the formal
4424 parameter list. In order to find out if there was a trailing
4425 ellipsis or not, we must instead look at the type associated
4426 with the FUNCTION_DECL. This will be a node of type FUNCTION_TYPE.
4427 If the chain of type nodes hanging off of this FUNCTION_TYPE node
4428 ends with a void_type_node then there should *not* be an ellipsis
4431 /* In the case where we are describing a mere function declaration, all
4432 we need to do here (and all we *can* do here) is to describe
4433 the *types* of its formal parameters. */
4435 if (DECL_INITIAL (decl) == NULL_TREE)
4436 output_formal_types (TREE_TYPE (decl));
4439 /* Generate DIEs to represent all known formal parameters */
4441 register tree arg_decls = DECL_ARGUMENTS (decl);
4444 /* WARNING! Kludge zone ahead! Here we have a special
4445 hack for svr4 SDB compatibility. Instead of passing the
4446 current FUNCTION_DECL node as the second parameter (i.e.
4447 the `containing_scope' parameter) to `output_decl' (as
4448 we ought to) we instead pass a pointer to our own private
4449 fake_containing_scope node. That node is a RECORD_TYPE
4450 node which NO OTHER TYPE may ever actually be a member of.
4452 This pointer will ultimately get passed into `output_type'
4453 as its `containing_scope' parameter. `Output_type' will
4454 then perform its part in the hack... i.e. it will pend
4455 the type of the formal parameter onto the pending_types
4456 list. Later on, when we are done generating the whole
4457 sequence of formal parameter DIEs for this function
4458 definition, we will un-pend all previously pended types
4459 of formal parameters for this function definition.
4461 This whole kludge prevents any type DIEs from being
4462 mixed in with the formal parameter DIEs. That's good
4463 because svr4 SDB believes that the list of formal
4464 parameter DIEs for a function ends wherever the first
4465 non-formal-parameter DIE appears. Thus, we have to
4466 keep the formal parameter DIEs segregated. They must
4467 all appear (consecutively) at the start of the list of
4468 children for the DIE representing the function definition.
4469 Then (and only then) may we output any additional DIEs
4470 needed to represent the types of these formal parameters.
4474 When generating DIEs, generate the unspecified_parameters
4475 DIE instead if we come across the arg "__builtin_va_alist"
4478 for (parm = arg_decls; parm; parm = TREE_CHAIN (parm))
4479 if (TREE_CODE (parm) == PARM_DECL)
4481 if (DECL_NAME(parm) &&
4482 !strcmp(IDENTIFIER_POINTER(DECL_NAME(parm)),
4483 "__builtin_va_alist") )
4484 output_die (output_unspecified_parameters_die, decl);
4486 output_decl (parm, fake_containing_scope);
4490 Now that we have finished generating all of the DIEs to
4491 represent the formal parameters themselves, force out
4492 any DIEs needed to represent their types. We do this
4493 simply by un-pending all previously pended types which
4494 can legitimately go into the chain of children DIEs for
4495 the current FUNCTION_DECL.
4498 output_pending_types_for_scope (decl);
4501 Decide whether we need a unspecified_parameters DIE at the end.
4502 There are 2 more cases to do this for:
4503 1) the ansi ... declaration - this is detectable when the end
4504 of the arg list is not a void_type_node
4505 2) an unprototyped function declaration (not a definition). This
4506 just means that we have no info about the parameters at all.
4510 register tree fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (decl));
4514 /* this is the prototyped case, check for ... */
4515 if (TREE_VALUE (tree_last (fn_arg_types)) != void_type_node)
4516 output_die (output_unspecified_parameters_die, decl);
4520 /* this is unprototyped, check for undefined (just declaration) */
4521 if (!DECL_INITIAL (decl))
4522 output_die (output_unspecified_parameters_die, decl);
4527 /* Output Dwarf info for all of the stuff within the body of the
4528 function (if it has one - it may be just a declaration). */
4531 register tree outer_scope = DECL_INITIAL (decl);
4533 if (outer_scope && TREE_CODE (outer_scope) != ERROR_MARK)
4535 /* Note that here, `outer_scope' is a pointer to the outermost
4536 BLOCK node created to represent a function.
4537 This outermost BLOCK actually represents the outermost
4538 binding contour for the function, i.e. the contour in which
4539 the function's formal parameters and labels get declared.
4541 Curiously, it appears that the front end doesn't actually
4542 put the PARM_DECL nodes for the current function onto the
4543 BLOCK_VARS list for this outer scope. (They are strung
4544 off of the DECL_ARGUMENTS list for the function instead.)
4545 The BLOCK_VARS list for the `outer_scope' does provide us
4546 with a list of the LABEL_DECL nodes for the function however,
4547 and we output DWARF info for those here.
4549 Just within the `outer_scope' there will be another BLOCK
4550 node representing the function's outermost pair of curly
4551 braces. We mustn't generate a lexical_block DIE for this
4552 outermost pair of curly braces because that is not really an
4553 independent scope according to ANSI C rules. Rather, it is
4554 the same scope in which the parameters were declared. */
4557 register tree label;
4559 for (label = BLOCK_VARS (outer_scope);
4561 label = TREE_CHAIN (label))
4562 output_decl (label, outer_scope);
4565 /* Note here that `BLOCK_SUBBLOCKS (outer_scope)' points to a
4566 list of BLOCK nodes which is always only one element long.
4567 That one element represents the outermost pair of curley
4568 braces for the function body. */
4570 output_decls_for_scope (BLOCK_SUBBLOCKS (outer_scope));
4572 /* Finally, force out any pending types which are local to the
4573 outermost block of this function definition. These will
4574 all have a TYPE_CONTEXT which points to the FUNCTION_DECL
4577 output_pending_types_for_scope (decl);
4581 /* Generate a terminator for the list of stuff `owned' by this
4584 end_sibling_chain ();
4589 /* If we are in terse mode, don't generate any DIEs to represent
4590 any actual typedefs. Note that even when we are in terse mode,
4591 we must still output DIEs to represent those tagged types which
4592 are used (directly or indirectly) in the specification of either
4593 a return type or a formal parameter type of some function. */
4595 if (debug_info_level <= DINFO_LEVEL_TERSE)
4596 if (DECL_NAME (decl) != NULL
4597 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
4600 /* In the special case of a null-named TYPE_DECL node (representing
4601 the declaration of some type tag), if the given TYPE_DECL is
4602 marked as having been instantiated from some other (original)
4603 TYPE_DECL node (e.g. one which was generated within the original
4604 definition of an inline function) we have to generate a special
4605 (abbreviated) TAG_structure_type, TAG_union_type, or
4606 TAG_enumeration-type DIE here. */
4608 if (! DECL_NAME (decl) && DECL_ABSTRACT_ORIGIN (decl))
4610 output_tagged_type_instantiation (TREE_TYPE (decl));
4614 output_type (TREE_TYPE (decl), containing_scope);
4616 /* Note that unlike the gcc front end (which generates a NULL named
4617 TYPE_DECL node for each complete tagged type, each array type,
4618 and each function type node created) the g++ front end generates
4619 a *named* TYPE_DECL node for each tagged type node created.
4620 Unfortunately, these g++ TYPE_DECL nodes cause us to output many
4621 superfluous and unnecessary TAG_typedef DIEs here. When g++ is
4622 fixed to stop generating these superfluous named TYPE_DECL nodes,
4623 the superfluous TAG_typedef DIEs will likewise cease. */
4625 if (DECL_NAME (decl))
4626 /* Output a DIE to represent the typedef itself. */
4627 output_die (output_typedef_die, decl);
4631 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4632 output_die (output_label_die, decl);
4636 /* If we are conforming to the DWARF version 1 specification, don't
4637 generated any DIEs to represent mere external object declarations. */
4639 #if (DWARF_VERSION <= 1)
4640 if (DECL_EXTERNAL (decl) && ! TREE_PUBLIC (decl))
4644 /* If we are in terse mode, don't generate any DIEs to represent
4645 any variable declarations or definitions. */
4647 if (debug_info_level <= DINFO_LEVEL_TERSE)
4650 /* Output any DIEs that are needed to specify the type of this data
4653 output_type (TREE_TYPE (decl), containing_scope);
4655 /* If the following DIE will represent a data object definition for a
4656 data object with "extern" linkage, output a special "pubnames" DIE
4657 label just ahead of the actual DIE. A reference to this label
4658 was already generated in the .debug_pubnames section sub-entry
4659 for this data object definition. */
4661 if (TREE_PUBLIC (decl) && ! DECL_ABSTRACT (decl))
4663 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4665 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
4666 ASM_OUTPUT_LABEL (asm_out_file, label);
4669 /* Now output the DIE to represent the data object itself. This gets
4670 complicated because of the possibility that the VAR_DECL really
4671 represents an inlined instance of a formal parameter for an inline
4675 register void (*func) ();
4676 register tree origin = decl_ultimate_origin (decl);
4678 if (origin != NULL && TREE_CODE (origin) == PARM_DECL)
4679 func = output_formal_parameter_die;
4682 if (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
4683 func = output_global_variable_die;
4685 func = output_local_variable_die;
4687 output_die (func, decl);
4692 /* Ignore the nameless fields that are used to skip bits. */
4693 if (DECL_NAME (decl) != 0)
4695 output_type (member_declared_type (decl), containing_scope);
4696 output_die (output_member_die, decl);
4701 /* Force out the type of this formal, if it was not forced out yet.
4702 Note that here we can run afowl of a bug in "classic" svr4 SDB.
4703 It should be able to grok the presence of type DIEs within a list
4704 of TAG_formal_parameter DIEs, but it doesn't. */
4706 output_type (TREE_TYPE (decl), containing_scope);
4707 output_die (output_formal_parameter_die, decl);
4716 dwarfout_file_scope_decl (decl, set_finalizing)
4718 register int set_finalizing;
4720 if (TREE_CODE (decl) == ERROR_MARK)
4723 /* If this ..._DECL node is marked to be ignored, then ignore it. We
4724 gotta hope that the node in question doesn't represent a function
4725 definition. If it does, then totally ignoring it is bound to screw
4726 up our count of blocks, and that it turn will completely screw up the
4727 the labels we will reference in subsequent AT_low_pc and AT_high_pc
4728 attributes (for subsequent blocks). (It's too bad that BLOCK nodes
4729 don't carry their own sequence numbers with them!) */
4731 if (DECL_IGNORED_P (decl))
4733 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
4738 switch (TREE_CODE (decl))
4742 /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of
4743 a builtin function. Explicit programmer-supplied declarations of
4744 these same functions should NOT be ignored however. */
4746 if (DECL_EXTERNAL (decl) && DECL_FUNCTION_CODE (decl))
4749 /* What we would really like to do here is to filter out all mere
4750 file-scope declarations of file-scope functions which are never
4751 referenced later within this translation unit (and keep all of
4752 ones that *are* referenced later on) but we aren't clairvoyant,
4753 so we have no idea which functions will be referenced in the
4754 future (i.e. later on within the current translation unit).
4755 So here we just ignore all file-scope function declarations
4756 which are not also definitions. If and when the debugger needs
4757 to know something about these functions, it wil have to hunt
4758 around and find the DWARF information associated with the
4759 *definition* of the function.
4761 Note that we can't just check `DECL_EXTERNAL' to find out which
4762 FUNCTION_DECL nodes represent definitions and which ones represent
4763 mere declarations. We have to check `DECL_INITIAL' instead. That's
4764 because the C front-end supports some weird semantics for "extern
4765 inline" function definitions. These can get inlined within the
4766 current translation unit (an thus, we need to generate DWARF info
4767 for their abstract instances so that the DWARF info for the
4768 concrete inlined instances can have something to refer to) but
4769 the compiler never generates any out-of-lines instances of such
4770 things (despite the fact that they *are* definitions). The
4771 important point is that the C front-end marks these "extern inline"
4772 functions as DECL_EXTERNAL, but we need to generate DWARf for them
4775 Note that the C++ front-end also plays some similar games for inline
4776 function definitions appearing within include files which also
4777 contain `#pragma interface' pragmas. */
4779 if (DECL_INITIAL (decl) == NULL_TREE)
4782 if (TREE_PUBLIC (decl)
4783 && ! DECL_EXTERNAL (decl)
4784 && ! DECL_ABSTRACT (decl))
4786 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4788 /* Output a .debug_pubnames entry for a public function
4789 defined in this compilation unit. */
4791 fputc ('\n', asm_out_file);
4792 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
4793 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
4794 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
4795 ASM_OUTPUT_DWARF_STRING (asm_out_file,
4796 IDENTIFIER_POINTER (DECL_NAME (decl)));
4797 ASM_OUTPUT_POP_SECTION (asm_out_file);
4804 /* Ignore this VAR_DECL if it refers to a file-scope extern data
4805 object declaration and if the declaration was never even
4806 referenced from within this entire compilation unit. We
4807 suppress these DIEs in order to save space in the .debug section
4808 (by eliminating entries which are probably useless). Note that
4809 we must not suppress block-local extern declarations (whether
4810 used or not) because that would screw-up the debugger's name
4811 lookup mechanism and cause it to miss things which really ought
4812 to be in scope at a given point. */
4814 if (DECL_EXTERNAL (decl) && !TREE_USED (decl))
4817 if (TREE_PUBLIC (decl)
4818 && ! DECL_EXTERNAL (decl)
4819 && GET_CODE (DECL_RTL (decl)) == MEM
4820 && ! DECL_ABSTRACT (decl))
4822 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4824 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4826 /* Output a .debug_pubnames entry for a public variable
4827 defined in this compilation unit. */
4829 fputc ('\n', asm_out_file);
4830 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
4831 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
4832 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
4833 ASM_OUTPUT_DWARF_STRING (asm_out_file,
4834 IDENTIFIER_POINTER (DECL_NAME (decl)));
4835 ASM_OUTPUT_POP_SECTION (asm_out_file);
4838 if (DECL_INITIAL (decl) == NULL)
4840 /* Output a .debug_aranges entry for a public variable
4841 which is tentatively defined in this compilation unit. */
4843 fputc ('\n', asm_out_file);
4844 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
4845 ASM_OUTPUT_DWARF_ADDR (asm_out_file,
4846 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
4847 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
4848 (unsigned) int_size_in_bytes (TREE_TYPE (decl)));
4849 ASM_OUTPUT_POP_SECTION (asm_out_file);
4853 /* If we are in terse mode, don't generate any DIEs to represent
4854 any variable declarations or definitions. */
4856 if (debug_info_level <= DINFO_LEVEL_TERSE)
4862 /* Don't bother trying to generate any DIEs to represent any of the
4863 normal built-in types for the language we are compiling, except
4864 in cases where the types in question are *not* DWARF fundamental
4865 types. We make an exception in the case of non-fundamental types
4866 for the sake of objective C (and perhaps C++) because the GNU
4867 front-ends for these languages may in fact create certain "built-in"
4868 types which are (for example) RECORD_TYPEs. In such cases, we
4869 really need to output these (non-fundamental) types because other
4870 DIEs may contain references to them. */
4872 if (DECL_SOURCE_LINE (decl) == 0
4873 && type_is_fundamental (TREE_TYPE (decl)))
4876 /* If we are in terse mode, don't generate any DIEs to represent
4877 any actual typedefs. Note that even when we are in terse mode,
4878 we must still output DIEs to represent those tagged types which
4879 are used (directly or indirectly) in the specification of either
4880 a return type or a formal parameter type of some function. */
4882 if (debug_info_level <= DINFO_LEVEL_TERSE)
4883 if (DECL_NAME (decl) != NULL
4884 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
4893 fputc ('\n', asm_out_file);
4894 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
4895 finalizing = set_finalizing;
4896 output_decl (decl, NULL_TREE);
4898 /* NOTE: The call above to `output_decl' may have caused one or more
4899 file-scope named types (i.e. tagged types) to be placed onto the
4900 pending_types_list. We have to get those types off of that list
4901 at some point, and this is the perfect time to do it. If we didn't
4902 take them off now, they might still be on the list when cc1 finally
4903 exits. That might be OK if it weren't for the fact that when we put
4904 types onto the pending_types_list, we set the TREE_ASM_WRITTEN flag
4905 for these types, and that causes them never to be output unless
4906 `output_pending_types_for_scope' takes them off of the list and un-sets
4907 their TREE_ASM_WRITTEN flags. */
4909 output_pending_types_for_scope (NULL_TREE);
4911 /* The above call should have totally emptied the pending_types_list. */
4913 assert (pending_types == 0);
4915 ASM_OUTPUT_POP_SECTION (asm_out_file);
4917 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
4918 current_funcdef_number++;
4921 /* Output a marker (i.e. a label) for the beginning of the generated code
4922 for a lexical block. */
4925 dwarfout_begin_block (blocknum)
4926 register unsigned blocknum;
4928 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4930 function_section (current_function_decl);
4931 sprintf (label, BLOCK_BEGIN_LABEL_FMT, blocknum);
4932 ASM_OUTPUT_LABEL (asm_out_file, label);
4935 /* Output a marker (i.e. a label) for the end of the generated code
4936 for a lexical block. */
4939 dwarfout_end_block (blocknum)
4940 register unsigned blocknum;
4942 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4944 function_section (current_function_decl);
4945 sprintf (label, BLOCK_END_LABEL_FMT, blocknum);
4946 ASM_OUTPUT_LABEL (asm_out_file, label);
4949 /* Output a marker (i.e. a label) at a point in the assembly code which
4950 corresponds to a given source level label. */
4953 dwarfout_label (insn)
4956 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4958 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4960 function_section (current_function_decl);
4961 sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
4962 (unsigned) INSN_UID (insn));
4963 ASM_OUTPUT_LABEL (asm_out_file, label);
4967 /* Output a marker (i.e. a label) for the point in the generated code where
4968 the real body of the function begins (after parameters have been moved
4969 to their home locations). */
4972 dwarfout_begin_function ()
4974 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4976 function_section (current_function_decl);
4977 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
4978 ASM_OUTPUT_LABEL (asm_out_file, label);
4981 /* Output a marker (i.e. a label) for the point in the generated code where
4982 the real body of the function ends (just before the epilogue code). */
4985 dwarfout_end_function ()
4987 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4989 function_section (current_function_decl);
4990 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
4991 ASM_OUTPUT_LABEL (asm_out_file, label);
4994 /* Output a marker (i.e. a label) for the absolute end of the generated code
4995 for a function definition. This gets called *after* the epilogue code
4996 has been generated. */
4999 dwarfout_end_epilogue ()
5001 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5003 /* Output a label to mark the endpoint of the code generated for this
5006 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
5007 ASM_OUTPUT_LABEL (asm_out_file, label);
5011 shuffle_filename_entry (new_zeroth)
5012 register filename_entry *new_zeroth;
5014 filename_entry temp_entry;
5015 register filename_entry *limit_p;
5016 register filename_entry *move_p;
5018 if (new_zeroth == &filename_table[0])
5021 temp_entry = *new_zeroth;
5023 /* Shift entries up in the table to make room at [0]. */
5025 limit_p = &filename_table[0];
5026 for (move_p = new_zeroth; move_p > limit_p; move_p--)
5027 *move_p = *(move_p-1);
5029 /* Install the found entry at [0]. */
5031 filename_table[0] = temp_entry;
5034 /* Create a new (string) entry for the .debug_sfnames section. */
5037 generate_new_sfname_entry ()
5039 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5041 fputc ('\n', asm_out_file);
5042 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
5043 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, filename_table[0].number);
5044 ASM_OUTPUT_LABEL (asm_out_file, label);
5045 ASM_OUTPUT_DWARF_STRING (asm_out_file,
5046 filename_table[0].name
5047 ? filename_table[0].name
5049 ASM_OUTPUT_POP_SECTION (asm_out_file);
5052 /* Lookup a filename (in the list of filenames that we know about here in
5053 dwarfout.c) and return its "index". The index of each (known) filename
5054 is just a unique number which is associated with only that one filename.
5055 We need such numbers for the sake of generating labels (in the
5056 .debug_sfnames section) and references to those unique labels (in the
5057 .debug_srcinfo and .debug_macinfo sections).
5059 If the filename given as an argument is not found in our current list,
5060 add it to the list and assign it the next available unique index number.
5062 Whatever we do (i.e. whether we find a pre-existing filename or add a new
5063 one), we shuffle the filename found (or added) up to the zeroth entry of
5064 our list of filenames (which is always searched linearly). We do this so
5065 as to optimize the most common case for these filename lookups within
5066 dwarfout.c. The most common case by far is the case where we call
5067 lookup_filename to lookup the very same filename that we did a lookup
5068 on the last time we called lookup_filename. We make sure that this
5069 common case is fast because such cases will constitute 99.9% of the
5070 lookups we ever do (in practice).
5072 If we add a new filename entry to our table, we go ahead and generate
5073 the corresponding entry in the .debug_sfnames section right away.
5074 Doing so allows us to avoid tickling an assembler bug (present in some
5075 m68k assemblers) which yields assembly-time errors in cases where the
5076 difference of two label addresses is taken and where the two labels
5077 are in a section *other* than the one where the difference is being
5078 calculated, and where at least one of the two symbol references is a
5079 forward reference. (This bug could be tickled by our .debug_srcinfo
5080 entries if we don't output their corresponding .debug_sfnames entries
5085 lookup_filename (file_name)
5088 register filename_entry *search_p;
5089 register filename_entry *limit_p = &filename_table[ft_entries];
5091 for (search_p = filename_table; search_p < limit_p; search_p++)
5092 if (!strcmp (file_name, search_p->name))
5094 /* When we get here, we have found the filename that we were
5095 looking for in the filename_table. Now we want to make sure
5096 that it gets moved to the zero'th entry in the table (if it
5097 is not already there) so that subsequent attempts to find the
5098 same filename will find it as quickly as possible. */
5100 shuffle_filename_entry (search_p);
5101 return filename_table[0].number;
5104 /* We come here whenever we have a new filename which is not registered
5105 in the current table. Here we add it to the table. */
5107 /* Prepare to add a new table entry by making sure there is enough space
5108 in the table to do so. If not, expand the current table. */
5110 if (ft_entries == ft_entries_allocated)
5112 ft_entries_allocated += FT_ENTRIES_INCREMENT;
5114 = (filename_entry *)
5115 xrealloc (filename_table,
5116 ft_entries_allocated * sizeof (filename_entry));
5119 /* Initially, add the new entry at the end of the filename table. */
5121 filename_table[ft_entries].number = ft_entries;
5122 filename_table[ft_entries].name = xstrdup (file_name);
5124 /* Shuffle the new entry into filename_table[0]. */
5126 shuffle_filename_entry (&filename_table[ft_entries]);
5128 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5129 generate_new_sfname_entry ();
5132 return filename_table[0].number;
5136 generate_srcinfo_entry (line_entry_num, files_entry_num)
5137 unsigned line_entry_num;
5138 unsigned files_entry_num;
5140 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5142 fputc ('\n', asm_out_file);
5143 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
5144 sprintf (label, LINE_ENTRY_LABEL_FMT, line_entry_num);
5145 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, LINE_BEGIN_LABEL);
5146 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, files_entry_num);
5147 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, SFNAMES_BEGIN_LABEL);
5148 ASM_OUTPUT_POP_SECTION (asm_out_file);
5152 dwarfout_line (filename, line)
5153 register char *filename;
5154 register unsigned line;
5156 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5158 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5159 static unsigned last_line_entry_num = 0;
5160 static unsigned prev_file_entry_num = (unsigned) -1;
5161 register unsigned this_file_entry_num = lookup_filename (filename);
5163 function_section (current_function_decl);
5164 sprintf (label, LINE_CODE_LABEL_FMT, ++last_line_entry_num);
5165 ASM_OUTPUT_LABEL (asm_out_file, label);
5167 fputc ('\n', asm_out_file);
5168 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
5170 if (this_file_entry_num != prev_file_entry_num)
5172 char line_entry_label[MAX_ARTIFICIAL_LABEL_BYTES];
5174 sprintf (line_entry_label, LINE_ENTRY_LABEL_FMT, last_line_entry_num);
5175 ASM_OUTPUT_LABEL (asm_out_file, line_entry_label);
5179 register char *tail = rindex (filename, '/');
5185 fprintf (asm_out_file, "\t%s\t%u\t%s %s:%u\n",
5186 UNALIGNED_INT_ASM_OP, line, ASM_COMMENT_START,
5188 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
5189 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, TEXT_BEGIN_LABEL);
5190 ASM_OUTPUT_POP_SECTION (asm_out_file);
5192 if (this_file_entry_num != prev_file_entry_num)
5193 generate_srcinfo_entry (last_line_entry_num, this_file_entry_num);
5194 prev_file_entry_num = this_file_entry_num;
5198 /* Generate an entry in the .debug_macinfo section. */
5201 generate_macinfo_entry (type_and_offset, string)
5202 register char *type_and_offset;
5203 register char *string;
5205 fputc ('\n', asm_out_file);
5206 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
5207 fprintf (asm_out_file, "\t%s\t%s\n", UNALIGNED_INT_ASM_OP, type_and_offset);
5208 ASM_OUTPUT_DWARF_STRING (asm_out_file, string);
5209 ASM_OUTPUT_POP_SECTION (asm_out_file);
5213 dwarfout_start_new_source_file (filename)
5214 register char *filename;
5216 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5217 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*3];
5219 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, lookup_filename (filename));
5220 sprintf (type_and_offset, "0x%08x+%s-%s",
5221 ((unsigned) MACINFO_start << 24), label, SFNAMES_BEGIN_LABEL);
5222 generate_macinfo_entry (type_and_offset, "");
5226 dwarfout_resume_previous_source_file (lineno)
5227 register unsigned lineno;
5229 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
5231 sprintf (type_and_offset, "0x%08x+%u",
5232 ((unsigned) MACINFO_resume << 24), lineno);
5233 generate_macinfo_entry (type_and_offset, "");
5236 /* Called from check_newline in c-parse.y. The `buffer' parameter
5237 contains the tail part of the directive line, i.e. the part which
5238 is past the initial whitespace, #, whitespace, directive-name,
5242 dwarfout_define (lineno, buffer)
5243 register unsigned lineno;
5244 register char *buffer;
5246 static int initialized = 0;
5247 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
5251 dwarfout_start_new_source_file (primary_filename);
5254 sprintf (type_and_offset, "0x%08x+%u",
5255 ((unsigned) MACINFO_define << 24), lineno);
5256 generate_macinfo_entry (type_and_offset, buffer);
5259 /* Called from check_newline in c-parse.y. The `buffer' parameter
5260 contains the tail part of the directive line, i.e. the part which
5261 is past the initial whitespace, #, whitespace, directive-name,
5265 dwarfout_undef (lineno, buffer)
5266 register unsigned lineno;
5267 register char *buffer;
5269 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
5271 sprintf (type_and_offset, "0x%08x+%u",
5272 ((unsigned) MACINFO_undef << 24), lineno);
5273 generate_macinfo_entry (type_and_offset, buffer);
5276 /* Set up for Dwarf output at the start of compilation. */
5279 dwarfout_init (asm_out_file, main_input_filename)
5280 register FILE *asm_out_file;
5281 register char *main_input_filename;
5283 /* Remember the name of the primary input file. */
5285 primary_filename = main_input_filename;
5287 /* Allocate the initial hunk of the pending_sibling_stack. */
5289 pending_sibling_stack
5291 xmalloc (PENDING_SIBLINGS_INCREMENT * sizeof (unsigned));
5292 pending_siblings_allocated = PENDING_SIBLINGS_INCREMENT;
5293 pending_siblings = 1;
5295 /* Allocate the initial hunk of the filename_table. */
5298 = (filename_entry *)
5299 xmalloc (FT_ENTRIES_INCREMENT * sizeof (filename_entry));
5300 ft_entries_allocated = FT_ENTRIES_INCREMENT;
5303 /* Allocate the initial hunk of the pending_types_list. */
5306 = (tree *) xmalloc (PENDING_TYPES_INCREMENT * sizeof (tree));
5307 pending_types_allocated = PENDING_TYPES_INCREMENT;
5310 /* Create an artificial RECORD_TYPE node which we can use in our hack
5311 to get the DIEs representing types of formal parameters to come out
5312 only *after* the DIEs for the formal parameters themselves. */
5314 fake_containing_scope = make_node (RECORD_TYPE);
5316 /* Output a starting label for the .text section. */
5318 fputc ('\n', asm_out_file);
5319 ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
5320 ASM_OUTPUT_LABEL (asm_out_file, TEXT_BEGIN_LABEL);
5321 ASM_OUTPUT_POP_SECTION (asm_out_file);
5323 /* Output a starting label for the .data section. */
5325 fputc ('\n', asm_out_file);
5326 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
5327 ASM_OUTPUT_LABEL (asm_out_file, DATA_BEGIN_LABEL);
5328 ASM_OUTPUT_POP_SECTION (asm_out_file);
5330 #if 0 /* GNU C doesn't currently use .data1. */
5331 /* Output a starting label for the .data1 section. */
5333 fputc ('\n', asm_out_file);
5334 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
5335 ASM_OUTPUT_LABEL (asm_out_file, DATA1_BEGIN_LABEL);
5336 ASM_OUTPUT_POP_SECTION (asm_out_file);
5339 /* Output a starting label for the .rodata section. */
5341 fputc ('\n', asm_out_file);
5342 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
5343 ASM_OUTPUT_LABEL (asm_out_file, RODATA_BEGIN_LABEL);
5344 ASM_OUTPUT_POP_SECTION (asm_out_file);
5346 #if 0 /* GNU C doesn't currently use .rodata1. */
5347 /* Output a starting label for the .rodata1 section. */
5349 fputc ('\n', asm_out_file);
5350 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
5351 ASM_OUTPUT_LABEL (asm_out_file, RODATA1_BEGIN_LABEL);
5352 ASM_OUTPUT_POP_SECTION (asm_out_file);
5355 /* Output a starting label for the .bss section. */
5357 fputc ('\n', asm_out_file);
5358 ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
5359 ASM_OUTPUT_LABEL (asm_out_file, BSS_BEGIN_LABEL);
5360 ASM_OUTPUT_POP_SECTION (asm_out_file);
5362 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5364 /* Output a starting label and an initial (compilation directory)
5365 entry for the .debug_sfnames section. The starting label will be
5366 referenced by the initial entry in the .debug_srcinfo section. */
5368 fputc ('\n', asm_out_file);
5369 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
5370 ASM_OUTPUT_LABEL (asm_out_file, SFNAMES_BEGIN_LABEL);
5373 register unsigned len;
5374 register char *dirname;
5378 pfatal_with_name ("getpwd");
5380 dirname = (char *) xmalloc (len + 2);
5382 strcpy (dirname, pwd);
5383 strcpy (dirname + len, "/");
5384 ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname);
5387 ASM_OUTPUT_POP_SECTION (asm_out_file);
5389 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
5391 /* Output a starting label for the .debug_macinfo section. This
5392 label will be referenced by the AT_mac_info attribute in the
5393 TAG_compile_unit DIE. */
5395 fputc ('\n', asm_out_file);
5396 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
5397 ASM_OUTPUT_LABEL (asm_out_file, MACINFO_BEGIN_LABEL);
5398 ASM_OUTPUT_POP_SECTION (asm_out_file);
5401 /* Generate the initial entry for the .line section. */
5403 fputc ('\n', asm_out_file);
5404 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
5405 ASM_OUTPUT_LABEL (asm_out_file, LINE_BEGIN_LABEL);
5406 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, LINE_END_LABEL, LINE_BEGIN_LABEL);
5407 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
5408 ASM_OUTPUT_POP_SECTION (asm_out_file);
5410 /* Generate the initial entry for the .debug_srcinfo section. */
5412 fputc ('\n', asm_out_file);
5413 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
5414 ASM_OUTPUT_LABEL (asm_out_file, SRCINFO_BEGIN_LABEL);
5415 ASM_OUTPUT_DWARF_ADDR (asm_out_file, LINE_BEGIN_LABEL);
5416 ASM_OUTPUT_DWARF_ADDR (asm_out_file, SFNAMES_BEGIN_LABEL);
5417 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
5418 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_END_LABEL);
5419 #ifdef DWARF_TIMESTAMPS
5420 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, time (NULL));
5422 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
5424 ASM_OUTPUT_POP_SECTION (asm_out_file);
5426 /* Generate the initial entry for the .debug_pubnames section. */
5428 fputc ('\n', asm_out_file);
5429 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
5430 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
5431 ASM_OUTPUT_POP_SECTION (asm_out_file);
5433 /* Generate the initial entry for the .debug_aranges section. */
5435 fputc ('\n', asm_out_file);
5436 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
5437 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
5438 ASM_OUTPUT_POP_SECTION (asm_out_file);
5441 /* Setup first DIE number == 1. */
5442 NEXT_DIE_NUM = next_unused_dienum++;
5444 /* Generate the initial DIE for the .debug section. Note that the
5445 (string) value given in the AT_name attribute of the TAG_compile_unit
5446 DIE will (typically) be a relative pathname and that this pathname
5447 should be taken as being relative to the directory from which the
5448 compiler was invoked when the given (base) source file was compiled. */
5450 fputc ('\n', asm_out_file);
5451 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
5452 ASM_OUTPUT_LABEL (asm_out_file, DEBUG_BEGIN_LABEL);
5453 output_die (output_compile_unit_die, main_input_filename);
5454 ASM_OUTPUT_POP_SECTION (asm_out_file);
5456 fputc ('\n', asm_out_file);
5459 /* Output stuff that dwarf requires at the end of every file. */
5464 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5466 fputc ('\n', asm_out_file);
5467 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
5469 /* Mark the end of the chain of siblings which represent all file-scope
5470 declarations in this compilation unit. */
5472 /* The (null) DIE which represents the terminator for the (sibling linked)
5473 list of file-scope items is *special*. Normally, we would just call
5474 end_sibling_chain at this point in order to output a word with the
5475 value `4' and that word would act as the terminator for the list of
5476 DIEs describing file-scope items. Unfortunately, if we were to simply
5477 do that, the label that would follow this DIE in the .debug section
5478 (i.e. `..D2') would *not* be properly aligned (as it must be on some
5479 machines) to a 4 byte boundary.
5481 In order to force the label `..D2' to get aligned to a 4 byte boundary,
5482 the trick used is to insert extra (otherwise useless) padding bytes
5483 into the (null) DIE that we know must precede the ..D2 label in the
5484 .debug section. The amount of padding required can be anywhere between
5485 0 and 3 bytes. The length word at the start of this DIE (i.e. the one
5486 with the padding) would normally contain the value 4, but now it will
5487 also have to include the padding bytes, so it will instead have some
5488 value in the range 4..7.
5490 Fortunately, the rules of Dwarf say that any DIE whose length word
5491 contains *any* value less than 8 should be treated as a null DIE, so
5492 this trick works out nicely. Clever, eh? Don't give me any credit
5493 (or blame). I didn't think of this scheme. I just conformed to it.
5496 output_die (output_padded_null_die, (void *)0);
5499 sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
5500 ASM_OUTPUT_LABEL (asm_out_file, label); /* should be ..D2 */
5501 ASM_OUTPUT_POP_SECTION (asm_out_file);
5503 /* Output a terminator label for the .text section. */
5505 fputc ('\n', asm_out_file);
5506 ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
5507 ASM_OUTPUT_LABEL (asm_out_file, TEXT_END_LABEL);
5508 ASM_OUTPUT_POP_SECTION (asm_out_file);
5510 /* Output a terminator label for the .data section. */
5512 fputc ('\n', asm_out_file);
5513 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
5514 ASM_OUTPUT_LABEL (asm_out_file, DATA_END_LABEL);
5515 ASM_OUTPUT_POP_SECTION (asm_out_file);
5517 #if 0 /* GNU C doesn't currently use .data1. */
5518 /* Output a terminator label for the .data1 section. */
5520 fputc ('\n', asm_out_file);
5521 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
5522 ASM_OUTPUT_LABEL (asm_out_file, DATA1_END_LABEL);
5523 ASM_OUTPUT_POP_SECTION (asm_out_file);
5526 /* Output a terminator label for the .rodata section. */
5528 fputc ('\n', asm_out_file);
5529 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
5530 ASM_OUTPUT_LABEL (asm_out_file, RODATA_END_LABEL);
5531 ASM_OUTPUT_POP_SECTION (asm_out_file);
5533 #if 0 /* GNU C doesn't currently use .rodata1. */
5534 /* Output a terminator label for the .rodata1 section. */
5536 fputc ('\n', asm_out_file);
5537 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
5538 ASM_OUTPUT_LABEL (asm_out_file, RODATA1_END_LABEL);
5539 ASM_OUTPUT_POP_SECTION (asm_out_file);
5542 /* Output a terminator label for the .bss section. */
5544 fputc ('\n', asm_out_file);
5545 ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
5546 ASM_OUTPUT_LABEL (asm_out_file, BSS_END_LABEL);
5547 ASM_OUTPUT_POP_SECTION (asm_out_file);
5549 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5551 /* Output a terminating entry for the .line section. */
5553 fputc ('\n', asm_out_file);
5554 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
5555 ASM_OUTPUT_LABEL (asm_out_file, LINE_LAST_ENTRY_LABEL);
5556 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5557 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
5558 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
5559 ASM_OUTPUT_LABEL (asm_out_file, LINE_END_LABEL);
5560 ASM_OUTPUT_POP_SECTION (asm_out_file);
5562 /* Output a terminating entry for the .debug_srcinfo section. */
5564 fputc ('\n', asm_out_file);
5565 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
5566 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
5567 LINE_LAST_ENTRY_LABEL, LINE_BEGIN_LABEL);
5568 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
5569 ASM_OUTPUT_POP_SECTION (asm_out_file);
5571 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
5573 /* Output terminating entries for the .debug_macinfo section. */
5575 dwarfout_resume_previous_source_file (0);
5577 fputc ('\n', asm_out_file);
5578 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
5579 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5580 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
5581 ASM_OUTPUT_POP_SECTION (asm_out_file);
5584 /* Generate the terminating entry for the .debug_pubnames section. */
5586 fputc ('\n', asm_out_file);
5587 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
5588 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5589 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
5590 ASM_OUTPUT_POP_SECTION (asm_out_file);
5592 /* Generate the terminating entries for the .debug_aranges section.
5594 Note that we want to do this only *after* we have output the end
5595 labels (for the various program sections) which we are going to
5596 refer to here. This allows us to work around a bug in the m68k
5597 svr4 assembler. That assembler gives bogus assembly-time errors
5598 if (within any given section) you try to take the difference of
5599 two relocatable symbols, both of which are located within some
5600 other section, and if one (or both?) of the symbols involved is
5601 being forward-referenced. By generating the .debug_aranges
5602 entries at this late point in the assembly output, we skirt the
5603 issue simply by avoiding forward-references.
5606 fputc ('\n', asm_out_file);
5607 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
5609 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
5610 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
5612 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA_BEGIN_LABEL);
5613 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA_END_LABEL, DATA_BEGIN_LABEL);
5615 #if 0 /* GNU C doesn't currently use .data1. */
5616 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA1_BEGIN_LABEL);
5617 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA1_END_LABEL,
5621 ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA_BEGIN_LABEL);
5622 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA_END_LABEL,
5623 RODATA_BEGIN_LABEL);
5625 #if 0 /* GNU C doesn't currently use .rodata1. */
5626 ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA1_BEGIN_LABEL);
5627 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA1_END_LABEL,
5628 RODATA1_BEGIN_LABEL);
5631 ASM_OUTPUT_DWARF_ADDR (asm_out_file, BSS_BEGIN_LABEL);
5632 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, BSS_END_LABEL, BSS_BEGIN_LABEL);
5634 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5635 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5637 ASM_OUTPUT_POP_SECTION (asm_out_file);
5641 #endif /* DWARF_DEBUGGING_INFO */