1 /* Output Dwarf format symbol table information from the GNU C compiler.
2 Copyright (C) 1992, 1993, 1995, 1996 Free Software Foundation, Inc.
3 Contributed by Ron Guilmette (rfg@monkeys.com) of Network Computing Devices.
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
24 #ifdef DWARF_DEBUGGING_INFO
30 #include "hard-reg-set.h"
31 #include "insn-config.h"
36 /* #define NDEBUG 1 */
39 #if defined(DWARF_TIMESTAMPS)
42 #else /* !defined(POSIX) */
43 #include <sys/types.h>
45 extern time_t time (time_t *);
46 #else /* !defined(__STDC__) */
47 extern time_t time ();
48 #endif /* !defined(__STDC__) */
49 #endif /* !defined(POSIX) */
50 #endif /* defined(DWARF_TIMESTAMPS) */
52 extern char *getpwd ();
54 extern char *index ();
55 extern char *rindex ();
57 /* IMPORTANT NOTE: Please see the file README.DWARF for important details
58 regarding the GNU implementation of Dwarf. */
60 /* NOTE: In the comments in this file, many references are made to
61 so called "Debugging Information Entries". For the sake of brevity,
62 this term is abbreviated to `DIE' throughout the remainder of this
65 /* Note that the implementation of C++ support herein is (as yet) unfinished.
66 If you want to try to complete it, more power to you. */
68 #if !defined(__GNUC__) || (NDEBUG != 1)
72 /* How to start an assembler comment. */
73 #ifndef ASM_COMMENT_START
74 #define ASM_COMMENT_START ";#"
77 /* How to print out a register name. */
79 #define PRINT_REG(RTX, CODE, FILE) \
80 fprintf ((FILE), "%s", reg_names[REGNO (RTX)])
83 /* Define a macro which returns non-zero for any tagged type which is
84 used (directly or indirectly) in the specification of either some
85 function's return type or some formal parameter of some function.
86 We use this macro when we are operating in "terse" mode to help us
87 know what tagged types have to be represented in Dwarf (even in
88 terse mode) and which ones don't.
90 A flag bit with this meaning really should be a part of the normal
91 GCC ..._TYPE nodes, but at the moment, there is no such bit defined
92 for these nodes. For now, we have to just fake it. It it safe for
93 us to simply return zero for all complete tagged types (which will
94 get forced out anyway if they were used in the specification of some
95 formal or return type) and non-zero for all incomplete tagged types.
98 #define TYPE_USED_FOR_FUNCTION(tagged_type) (TYPE_SIZE (tagged_type) == 0)
100 extern int flag_traditional;
101 extern char *version_string;
102 extern char *language_string;
104 /* Maximum size (in bytes) of an artificially generated label. */
106 #define MAX_ARTIFICIAL_LABEL_BYTES 30
108 /* Make sure we know the sizes of the various types dwarf can describe.
109 These are only defaults. If the sizes are different for your target,
110 you should override these values by defining the appropriate symbols
111 in your tm.h file. */
113 #ifndef CHAR_TYPE_SIZE
114 #define CHAR_TYPE_SIZE BITS_PER_UNIT
117 #ifndef SHORT_TYPE_SIZE
118 #define SHORT_TYPE_SIZE (BITS_PER_UNIT * 2)
121 #ifndef INT_TYPE_SIZE
122 #define INT_TYPE_SIZE BITS_PER_WORD
125 #ifndef LONG_TYPE_SIZE
126 #define LONG_TYPE_SIZE BITS_PER_WORD
129 #ifndef LONG_LONG_TYPE_SIZE
130 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
133 #ifndef WCHAR_TYPE_SIZE
134 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
137 #ifndef WCHAR_UNSIGNED
138 #define WCHAR_UNSIGNED 0
141 #ifndef FLOAT_TYPE_SIZE
142 #define FLOAT_TYPE_SIZE BITS_PER_WORD
145 #ifndef DOUBLE_TYPE_SIZE
146 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
149 #ifndef LONG_DOUBLE_TYPE_SIZE
150 #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
153 /* Structure to keep track of source filenames. */
155 struct filename_entry {
160 typedef struct filename_entry filename_entry;
162 /* Pointer to an array of elements, each one having the structure above. */
164 static filename_entry *filename_table;
166 /* Total number of entries in the table (i.e. array) pointed to by
167 `filename_table'. This is the *total* and includes both used and
170 static unsigned ft_entries_allocated;
172 /* Number of entries in the filename_table which are actually in use. */
174 static unsigned ft_entries;
176 /* Size (in elements) of increments by which we may expand the filename
177 table. Actually, a single hunk of space of this size should be enough
178 for most typical programs. */
180 #define FT_ENTRIES_INCREMENT 64
182 /* Local pointer to the name of the main input file. Initialized in
185 static char *primary_filename;
187 /* Pointer to the most recent filename for which we produced some line info. */
189 static char *last_filename;
191 /* For Dwarf output, we must assign lexical-blocks id numbers
192 in the order in which their beginnings are encountered.
193 We output Dwarf debugging info that refers to the beginnings
194 and ends of the ranges of code for each lexical block with
195 assembler labels ..Bn and ..Bn.e, where n is the block number.
196 The labels themselves are generated in final.c, which assigns
197 numbers to the blocks in the same way. */
199 static unsigned next_block_number = 2;
201 /* Counter to generate unique names for DIEs. */
203 static unsigned next_unused_dienum = 1;
205 /* Number of the DIE which is currently being generated. */
207 static unsigned current_dienum;
209 /* Number to use for the special "pubname" label on the next DIE which
210 represents a function or data object defined in this compilation
211 unit which has "extern" linkage. */
213 static next_pubname_number = 0;
215 #define NEXT_DIE_NUM pending_sibling_stack[pending_siblings-1]
217 /* Pointer to a dynamically allocated list of pre-reserved and still
218 pending sibling DIE numbers. Note that this list will grow as needed. */
220 static unsigned *pending_sibling_stack;
222 /* Counter to keep track of the number of pre-reserved and still pending
223 sibling DIE numbers. */
225 static unsigned pending_siblings;
227 /* The currently allocated size of the above list (expressed in number of
230 static unsigned pending_siblings_allocated;
232 /* Size (in elements) of increments by which we may expand the pending
233 sibling stack. Actually, a single hunk of space of this size should
234 be enough for most typical programs. */
236 #define PENDING_SIBLINGS_INCREMENT 64
238 /* Non-zero if we are performing our file-scope finalization pass and if
239 we should force out Dwarf descriptions of any and all file-scope
240 tagged types which are still incomplete types. */
242 static int finalizing = 0;
244 /* A pointer to the base of a list of pending types which we haven't
245 generated DIEs for yet, but which we will have to come back to
248 static tree *pending_types_list;
250 /* Number of elements currently allocated for the pending_types_list. */
252 static unsigned pending_types_allocated;
254 /* Number of elements of pending_types_list currently in use. */
256 static unsigned pending_types;
258 /* Size (in elements) of increments by which we may expand the pending
259 types list. Actually, a single hunk of space of this size should
260 be enough for most typical programs. */
262 #define PENDING_TYPES_INCREMENT 64
264 /* Pointer to an artificial RECORD_TYPE which we create in dwarfout_init.
265 This is used in a hack to help us get the DIEs describing types of
266 formal parameters to come *after* all of the DIEs describing the formal
267 parameters themselves. That's necessary in order to be compatible
268 with what the brain-damaged svr4 SDB debugger requires. */
270 static tree fake_containing_scope;
272 /* The number of the current function definition that we are generating
273 debugging information for. These numbers range from 1 up to the maximum
274 number of function definitions contained within the current compilation
275 unit. These numbers are used to create unique labels for various things
276 contained within various function definitions. */
278 static unsigned current_funcdef_number = 1;
280 /* A pointer to the ..._DECL node which we have most recently been working
281 on. We keep this around just in case something about it looks screwy
282 and we want to tell the user what the source coordinates for the actual
285 static tree dwarf_last_decl;
287 /* Forward declarations for functions defined in this file. */
289 static char *dwarf_tag_name PROTO((unsigned));
290 static char *dwarf_attr_name PROTO((unsigned));
291 static char *dwarf_stack_op_name PROTO((unsigned));
292 static char *dwarf_typemod_name PROTO((unsigned));
293 static char *dwarf_fmt_byte_name PROTO((unsigned));
294 static char *dwarf_fund_type_name PROTO((unsigned));
295 static tree decl_ultimate_origin PROTO((tree));
296 static tree block_ultimate_origin PROTO((tree));
297 static void output_unsigned_leb128 PROTO((unsigned long));
298 static void output_signed_leb128 PROTO((long));
299 static inline int is_body_block PROTO((tree));
300 static int fundamental_type_code PROTO((tree));
301 static tree root_type PROTO((tree));
302 static void write_modifier_bytes PROTO((tree, int, int));
303 static inline int type_is_fundamental PROTO((tree));
304 static void equate_decl_number_to_die_number PROTO((tree));
305 static inline void equate_type_number_to_die_number PROTO((tree));
306 static void output_reg_number PROTO((rtx));
307 static void output_mem_loc_descriptor PROTO((rtx));
308 static void output_loc_descriptor PROTO((rtx));
309 static void output_bound_representation PROTO((tree, unsigned, int));
310 static void output_enumeral_list PROTO((tree));
311 static inline unsigned ceiling PROTO((unsigned, unsigned));
312 static inline tree field_type PROTO((tree));
313 static inline unsigned simple_type_align_in_bits PROTO((tree));
314 static inline unsigned simple_type_size_in_bits PROTO((tree));
315 static unsigned field_byte_offset PROTO((tree));
316 static inline void sibling_attribute PROTO((void));
317 static void location_attribute PROTO((rtx));
318 static void data_member_location_attribute PROTO((tree));
319 static void const_value_attribute PROTO((rtx));
320 static void location_or_const_value_attribute PROTO((tree));
321 static inline void name_attribute PROTO((char *));
322 static inline void fund_type_attribute PROTO((unsigned));
323 static void mod_fund_type_attribute PROTO((tree, int, int));
324 static inline void user_def_type_attribute PROTO((tree));
325 static void mod_u_d_type_attribute PROTO((tree, int, int));
326 static inline void ordering_attribute PROTO((unsigned));
327 static void subscript_data_attribute PROTO((tree));
328 static void byte_size_attribute PROTO((tree));
329 static inline void bit_offset_attribute PROTO((tree));
330 static inline void bit_size_attribute PROTO((tree));
331 static inline void element_list_attribute PROTO((tree));
332 static inline void stmt_list_attribute PROTO((char *));
333 static inline void low_pc_attribute PROTO((char *));
334 static inline void high_pc_attribute PROTO((char *));
335 static inline void body_begin_attribute PROTO((char *));
336 static inline void body_end_attribute PROTO((char *));
337 static inline void langauge_attribute PROTO((unsigned));
338 static inline void member_attribute PROTO((tree));
339 static inline void string_length_attribute PROTO((tree));
340 static inline void comp_dir_attribute PROTO((char *));
341 static inline void sf_names_attribute PROTO((char *));
342 static inline void src_info_attribute PROTO((char *));
343 static inline void mac_info_attribute PROTO((char *));
344 static inline void prototyped_attribute PROTO((tree));
345 static inline void producer_attribute PROTO((char *));
346 static inline void inline_attribute PROTO((tree));
347 static inline void containing_type_attribute PROTO((tree));
348 static inline void abstract_origin_attribute PROTO((tree));
349 static inline void src_coords_attribute PROTO((unsigned, unsigned));
350 static inline void pure_or_virtual_attribute PROTO((tree));
351 static void name_and_src_coords_attributes PROTO((tree));
352 static void type_attribute PROTO((tree, int, int));
353 static char *type_tag PROTO((tree));
354 static inline void dienum_push PROTO((void));
355 static inline void dienum_pop PROTO((void));
356 static inline tree member_declared_type PROTO((tree));
357 static char *function_start_label PROTO((tree));
358 static void output_array_type_die PROTO((void *));
359 static void output_set_type_die PROTO((void *));
360 static void output_entry_point_die PROTO((void *));
361 static void output_inlined_enumeration_type_die PROTO((void *));
362 static void output_inlined_structure_type_die PROTO((void *));
363 static void output_inlined_union_type_die PROTO((void *));
364 static void output_enumeration_type_die PROTO((void *));
365 static void output_formal_parameter_die PROTO((void *));
366 static void output_global_subroutine_die PROTO((void *));
367 static void output_global_variable_die PROTO((void *));
368 static void output_label_die PROTO((void *));
369 static void output_lexical_block_die PROTO((void *));
370 static void output_inlined_subroutine_die PROTO((void *));
371 static void output_local_variable_die PROTO((void *));
372 static void output_member_die PROTO((void *));
373 static void output_pointer_type_die PROTO((void *));
374 static void output_reference_type_die PROTO((void *));
375 static void output_ptr_to_mbr_type_die PROTO((void *));
376 static void output_compile_unit_die PROTO((void *));
377 static void output_string_type_die PROTO((void *));
378 static void output_structure_type_die PROTO((void *));
379 static void output_local_subroutine_die PROTO((void *));
380 static void output_subroutine_type_die PROTO((void *));
381 static void output_typedef_die PROTO((void *));
382 static void output_union_type_die PROTO((void *));
383 static void output_unspecified_parameters_die PROTO((void *));
384 static void output_padded_null_die PROTO((void *));
385 static void output_die PROTO((void (*) (), void *));
386 static void end_sibling_chain PROTO((void));
387 static void output_formal_types PROTO((tree));
388 static void pend_type PROTO((tree));
389 static inline int type_of_for_scope PROTO((tree, tree));
390 static void output_pending_types_for_scope PROTO((tree));
391 static void output_type PROTO((tree, tree));
392 static void output_tagged_type_instantiation PROTO((tree));
393 static void output_block PROTO((tree, int));
394 static void output_decls_for_scope PROTO((tree, int));
395 static void output_decl PROTO((tree, tree));
396 static void shuffle_filename_entry PROTO((filename_entry *));
397 static void geneate_new_sfname_entry PROTO((void));
398 static unsigned lookup_filename PROTO((char *));
399 static void generate_srcinfo_entry PROTO((unsigned, unsigned));
400 static void generate_macinfo_entry PROTO((char *, char *));
402 /* Definitions of defaults for assembler-dependent names of various
403 pseudo-ops and section names.
405 Theses may be overridden in your tm.h file (if necessary) for your
406 particular assembler. The default values provided here correspond to
407 what is expected by "standard" AT&T System V.4 assemblers. */
410 #define FILE_ASM_OP ".file"
412 #ifndef VERSION_ASM_OP
413 #define VERSION_ASM_OP ".version"
415 #ifndef UNALIGNED_SHORT_ASM_OP
416 #define UNALIGNED_SHORT_ASM_OP ".2byte"
418 #ifndef UNALIGNED_INT_ASM_OP
419 #define UNALIGNED_INT_ASM_OP ".4byte"
422 #define ASM_BYTE_OP ".byte"
425 #define SET_ASM_OP ".set"
428 /* Pseudo-ops for pushing the current section onto the section stack (and
429 simultaneously changing to a new section) and for poping back to the
430 section we were in immediately before this one. Note that most svr4
431 assemblers only maintain a one level stack... you can push all the
432 sections you want, but you can only pop out one level. (The sparc
433 svr4 assembler is an exception to this general rule.) That's
434 OK because we only use at most one level of the section stack herein. */
436 #ifndef PUSHSECTION_ASM_OP
437 #define PUSHSECTION_ASM_OP ".section"
439 #ifndef POPSECTION_ASM_OP
440 #define POPSECTION_ASM_OP ".previous"
443 /* The default format used by the ASM_OUTPUT_PUSH_SECTION macro (see below)
444 to print the PUSHSECTION_ASM_OP and the section name. The default here
445 works for almost all svr4 assemblers, except for the sparc, where the
446 section name must be enclosed in double quotes. (See sparcv4.h.) */
448 #ifndef PUSHSECTION_FORMAT
449 #define PUSHSECTION_FORMAT "\t%s\t%s\n"
452 #ifndef DEBUG_SECTION
453 #define DEBUG_SECTION ".debug"
456 #define LINE_SECTION ".line"
458 #ifndef SFNAMES_SECTION
459 #define SFNAMES_SECTION ".debug_sfnames"
461 #ifndef SRCINFO_SECTION
462 #define SRCINFO_SECTION ".debug_srcinfo"
464 #ifndef MACINFO_SECTION
465 #define MACINFO_SECTION ".debug_macinfo"
467 #ifndef PUBNAMES_SECTION
468 #define PUBNAMES_SECTION ".debug_pubnames"
470 #ifndef ARANGES_SECTION
471 #define ARANGES_SECTION ".debug_aranges"
474 #define TEXT_SECTION ".text"
477 #define DATA_SECTION ".data"
479 #ifndef DATA1_SECTION
480 #define DATA1_SECTION ".data1"
482 #ifndef RODATA_SECTION
483 #define RODATA_SECTION ".rodata"
485 #ifndef RODATA1_SECTION
486 #define RODATA1_SECTION ".rodata1"
489 #define BSS_SECTION ".bss"
492 /* Definitions of defaults for formats and names of various special
493 (artificial) labels which may be generated within this file (when
494 the -g options is used and DWARF_DEBUGGING_INFO is in effect.
496 If necessary, these may be overridden from within your tm.h file,
497 but typically, you should never need to override these.
499 These labels have been hacked (temporarily) so that they all begin with
500 a `.L' sequence so as to appease the stock sparc/svr4 assembler and the
501 stock m88k/svr4 assembler, both of which need to see .L at the start of
502 a label in order to prevent that label from going into the linker symbol
503 table). When I get time, I'll have to fix this the right way so that we
504 will use ASM_GENERATE_INTERNAL_LABEL and ASM_OUTPUT_INTERNAL_LABEL herein,
505 but that will require a rather massive set of changes. For the moment,
506 the following definitions out to produce the right results for all svr4
507 and svr3 assemblers. -- rfg
510 #ifndef TEXT_BEGIN_LABEL
511 #define TEXT_BEGIN_LABEL ".L_text_b"
513 #ifndef TEXT_END_LABEL
514 #define TEXT_END_LABEL ".L_text_e"
517 #ifndef DATA_BEGIN_LABEL
518 #define DATA_BEGIN_LABEL ".L_data_b"
520 #ifndef DATA_END_LABEL
521 #define DATA_END_LABEL ".L_data_e"
524 #ifndef DATA1_BEGIN_LABEL
525 #define DATA1_BEGIN_LABEL ".L_data1_b"
527 #ifndef DATA1_END_LABEL
528 #define DATA1_END_LABEL ".L_data1_e"
531 #ifndef RODATA_BEGIN_LABEL
532 #define RODATA_BEGIN_LABEL ".L_rodata_b"
534 #ifndef RODATA_END_LABEL
535 #define RODATA_END_LABEL ".L_rodata_e"
538 #ifndef RODATA1_BEGIN_LABEL
539 #define RODATA1_BEGIN_LABEL ".L_rodata1_b"
541 #ifndef RODATA1_END_LABEL
542 #define RODATA1_END_LABEL ".L_rodata1_e"
545 #ifndef BSS_BEGIN_LABEL
546 #define BSS_BEGIN_LABEL ".L_bss_b"
548 #ifndef BSS_END_LABEL
549 #define BSS_END_LABEL ".L_bss_e"
552 #ifndef LINE_BEGIN_LABEL
553 #define LINE_BEGIN_LABEL ".L_line_b"
555 #ifndef LINE_LAST_ENTRY_LABEL
556 #define LINE_LAST_ENTRY_LABEL ".L_line_last"
558 #ifndef LINE_END_LABEL
559 #define LINE_END_LABEL ".L_line_e"
562 #ifndef DEBUG_BEGIN_LABEL
563 #define DEBUG_BEGIN_LABEL ".L_debug_b"
565 #ifndef SFNAMES_BEGIN_LABEL
566 #define SFNAMES_BEGIN_LABEL ".L_sfnames_b"
568 #ifndef SRCINFO_BEGIN_LABEL
569 #define SRCINFO_BEGIN_LABEL ".L_srcinfo_b"
571 #ifndef MACINFO_BEGIN_LABEL
572 #define MACINFO_BEGIN_LABEL ".L_macinfo_b"
575 #ifndef DIE_BEGIN_LABEL_FMT
576 #define DIE_BEGIN_LABEL_FMT ".L_D%u"
578 #ifndef DIE_END_LABEL_FMT
579 #define DIE_END_LABEL_FMT ".L_D%u_e"
581 #ifndef PUB_DIE_LABEL_FMT
582 #define PUB_DIE_LABEL_FMT ".L_P%u"
584 #ifndef INSN_LABEL_FMT
585 #define INSN_LABEL_FMT ".L_I%u_%u"
587 #ifndef BLOCK_BEGIN_LABEL_FMT
588 #define BLOCK_BEGIN_LABEL_FMT ".L_B%u"
590 #ifndef BLOCK_END_LABEL_FMT
591 #define BLOCK_END_LABEL_FMT ".L_B%u_e"
593 #ifndef SS_BEGIN_LABEL_FMT
594 #define SS_BEGIN_LABEL_FMT ".L_s%u"
596 #ifndef SS_END_LABEL_FMT
597 #define SS_END_LABEL_FMT ".L_s%u_e"
599 #ifndef EE_BEGIN_LABEL_FMT
600 #define EE_BEGIN_LABEL_FMT ".L_e%u"
602 #ifndef EE_END_LABEL_FMT
603 #define EE_END_LABEL_FMT ".L_e%u_e"
605 #ifndef MT_BEGIN_LABEL_FMT
606 #define MT_BEGIN_LABEL_FMT ".L_t%u"
608 #ifndef MT_END_LABEL_FMT
609 #define MT_END_LABEL_FMT ".L_t%u_e"
611 #ifndef LOC_BEGIN_LABEL_FMT
612 #define LOC_BEGIN_LABEL_FMT ".L_l%u"
614 #ifndef LOC_END_LABEL_FMT
615 #define LOC_END_LABEL_FMT ".L_l%u_e"
617 #ifndef BOUND_BEGIN_LABEL_FMT
618 #define BOUND_BEGIN_LABEL_FMT ".L_b%u_%u_%c"
620 #ifndef BOUND_END_LABEL_FMT
621 #define BOUND_END_LABEL_FMT ".L_b%u_%u_%c_e"
623 #ifndef DERIV_BEGIN_LABEL_FMT
624 #define DERIV_BEGIN_LABEL_FMT ".L_d%u"
626 #ifndef DERIV_END_LABEL_FMT
627 #define DERIV_END_LABEL_FMT ".L_d%u_e"
629 #ifndef SL_BEGIN_LABEL_FMT
630 #define SL_BEGIN_LABEL_FMT ".L_sl%u"
632 #ifndef SL_END_LABEL_FMT
633 #define SL_END_LABEL_FMT ".L_sl%u_e"
635 #ifndef BODY_BEGIN_LABEL_FMT
636 #define BODY_BEGIN_LABEL_FMT ".L_b%u"
638 #ifndef BODY_END_LABEL_FMT
639 #define BODY_END_LABEL_FMT ".L_b%u_e"
641 #ifndef FUNC_END_LABEL_FMT
642 #define FUNC_END_LABEL_FMT ".L_f%u_e"
644 #ifndef TYPE_NAME_FMT
645 #define TYPE_NAME_FMT ".L_T%u"
647 #ifndef DECL_NAME_FMT
648 #define DECL_NAME_FMT ".L_E%u"
650 #ifndef LINE_CODE_LABEL_FMT
651 #define LINE_CODE_LABEL_FMT ".L_LC%u"
653 #ifndef SFNAMES_ENTRY_LABEL_FMT
654 #define SFNAMES_ENTRY_LABEL_FMT ".L_F%u"
656 #ifndef LINE_ENTRY_LABEL_FMT
657 #define LINE_ENTRY_LABEL_FMT ".L_LE%u"
660 /* Definitions of defaults for various types of primitive assembly language
663 If necessary, these may be overridden from within your tm.h file,
664 but typically, you shouldn't need to override these. */
666 #ifndef ASM_OUTPUT_PUSH_SECTION
667 #define ASM_OUTPUT_PUSH_SECTION(FILE, SECTION) \
668 fprintf ((FILE), PUSHSECTION_FORMAT, PUSHSECTION_ASM_OP, SECTION)
671 #ifndef ASM_OUTPUT_POP_SECTION
672 #define ASM_OUTPUT_POP_SECTION(FILE) \
673 fprintf ((FILE), "\t%s\n", POPSECTION_ASM_OP)
676 #ifndef ASM_OUTPUT_SOURCE_FILENAME
677 #define ASM_OUTPUT_SOURCE_FILENAME(FILE,NAME) \
678 do { fprintf (FILE, "\t%s\t", FILE_ASM_OP); \
679 output_quoted_string (FILE, NAME); \
680 fputc ('\n', FILE); \
684 #ifndef ASM_OUTPUT_DWARF_DELTA2
685 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
686 do { fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \
687 assemble_name (FILE, LABEL1); \
688 fprintf (FILE, "-"); \
689 assemble_name (FILE, LABEL2); \
690 fprintf (FILE, "\n"); \
694 #ifndef ASM_OUTPUT_DWARF_DELTA4
695 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
696 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
697 assemble_name (FILE, LABEL1); \
698 fprintf (FILE, "-"); \
699 assemble_name (FILE, LABEL2); \
700 fprintf (FILE, "\n"); \
704 #ifndef ASM_OUTPUT_DWARF_TAG
705 #define ASM_OUTPUT_DWARF_TAG(FILE,TAG) \
707 fprintf ((FILE), "\t%s\t0x%x", \
708 UNALIGNED_SHORT_ASM_OP, (unsigned) TAG); \
709 if (flag_debug_asm) \
710 fprintf ((FILE), "\t%s %s", \
711 ASM_COMMENT_START, dwarf_tag_name (TAG)); \
712 fputc ('\n', (FILE)); \
716 #ifndef ASM_OUTPUT_DWARF_ATTRIBUTE
717 #define ASM_OUTPUT_DWARF_ATTRIBUTE(FILE,ATTR) \
719 fprintf ((FILE), "\t%s\t0x%x", \
720 UNALIGNED_SHORT_ASM_OP, (unsigned) ATTR); \
721 if (flag_debug_asm) \
722 fprintf ((FILE), "\t%s %s", \
723 ASM_COMMENT_START, dwarf_attr_name (ATTR)); \
724 fputc ('\n', (FILE)); \
728 #ifndef ASM_OUTPUT_DWARF_STACK_OP
729 #define ASM_OUTPUT_DWARF_STACK_OP(FILE,OP) \
731 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) OP); \
732 if (flag_debug_asm) \
733 fprintf ((FILE), "\t%s %s", \
734 ASM_COMMENT_START, dwarf_stack_op_name (OP)); \
735 fputc ('\n', (FILE)); \
739 #ifndef ASM_OUTPUT_DWARF_FUND_TYPE
740 #define ASM_OUTPUT_DWARF_FUND_TYPE(FILE,FT) \
742 fprintf ((FILE), "\t%s\t0x%x", \
743 UNALIGNED_SHORT_ASM_OP, (unsigned) FT); \
744 if (flag_debug_asm) \
745 fprintf ((FILE), "\t%s %s", \
746 ASM_COMMENT_START, dwarf_fund_type_name (FT)); \
747 fputc ('\n', (FILE)); \
751 #ifndef ASM_OUTPUT_DWARF_FMT_BYTE
752 #define ASM_OUTPUT_DWARF_FMT_BYTE(FILE,FMT) \
754 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) FMT); \
755 if (flag_debug_asm) \
756 fprintf ((FILE), "\t%s %s", \
757 ASM_COMMENT_START, dwarf_fmt_byte_name (FMT)); \
758 fputc ('\n', (FILE)); \
762 #ifndef ASM_OUTPUT_DWARF_TYPE_MODIFIER
763 #define ASM_OUTPUT_DWARF_TYPE_MODIFIER(FILE,MOD) \
765 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) MOD); \
766 if (flag_debug_asm) \
767 fprintf ((FILE), "\t%s %s", \
768 ASM_COMMENT_START, dwarf_typemod_name (MOD)); \
769 fputc ('\n', (FILE)); \
773 #ifndef ASM_OUTPUT_DWARF_ADDR
774 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
775 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
776 assemble_name (FILE, LABEL); \
777 fprintf (FILE, "\n"); \
781 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
782 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX) \
784 fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
785 output_addr_const ((FILE), (RTX)); \
786 fputc ('\n', (FILE)); \
790 #ifndef ASM_OUTPUT_DWARF_REF
791 #define ASM_OUTPUT_DWARF_REF(FILE,LABEL) \
792 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
793 assemble_name (FILE, LABEL); \
794 fprintf (FILE, "\n"); \
798 #ifndef ASM_OUTPUT_DWARF_DATA1
799 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
800 fprintf ((FILE), "\t%s\t0x%x\n", ASM_BYTE_OP, VALUE)
803 #ifndef ASM_OUTPUT_DWARF_DATA2
804 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
805 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_SHORT_ASM_OP, (unsigned) VALUE)
808 #ifndef ASM_OUTPUT_DWARF_DATA4
809 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
810 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, (unsigned) VALUE)
813 #ifndef ASM_OUTPUT_DWARF_DATA8
814 #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \
816 if (WORDS_BIG_ENDIAN) \
818 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
819 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
823 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
824 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
829 #ifndef ASM_OUTPUT_DWARF_STRING
830 #define ASM_OUTPUT_DWARF_STRING(FILE,P) \
831 ASM_OUTPUT_ASCII ((FILE), P, strlen (P)+1)
834 /************************ general utility functions **************************/
840 return (((GET_CODE (rtl) == REG) && (REGNO (rtl) >= FIRST_PSEUDO_REGISTER))
841 || ((GET_CODE (rtl) == SUBREG)
842 && (REGNO (XEXP (rtl, 0)) >= FIRST_PSEUDO_REGISTER)));
846 type_main_variant (type)
849 type = TYPE_MAIN_VARIANT (type);
851 /* There really should be only one main variant among any group of variants
852 of a given type (and all of the MAIN_VARIANT values for all members of
853 the group should point to that one type) but sometimes the C front-end
854 messes this up for array types, so we work around that bug here. */
856 if (TREE_CODE (type) == ARRAY_TYPE)
858 while (type != TYPE_MAIN_VARIANT (type))
859 type = TYPE_MAIN_VARIANT (type);
865 /* Return non-zero if the given type node represents a tagged type. */
868 is_tagged_type (type)
871 register enum tree_code code = TREE_CODE (type);
873 return (code == RECORD_TYPE || code == UNION_TYPE
874 || code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
879 register unsigned tag;
883 case TAG_padding: return "TAG_padding";
884 case TAG_array_type: return "TAG_array_type";
885 case TAG_class_type: return "TAG_class_type";
886 case TAG_entry_point: return "TAG_entry_point";
887 case TAG_enumeration_type: return "TAG_enumeration_type";
888 case TAG_formal_parameter: return "TAG_formal_parameter";
889 case TAG_global_subroutine: return "TAG_global_subroutine";
890 case TAG_global_variable: return "TAG_global_variable";
891 case TAG_label: return "TAG_label";
892 case TAG_lexical_block: return "TAG_lexical_block";
893 case TAG_local_variable: return "TAG_local_variable";
894 case TAG_member: return "TAG_member";
895 case TAG_pointer_type: return "TAG_pointer_type";
896 case TAG_reference_type: return "TAG_reference_type";
897 case TAG_compile_unit: return "TAG_compile_unit";
898 case TAG_string_type: return "TAG_string_type";
899 case TAG_structure_type: return "TAG_structure_type";
900 case TAG_subroutine: return "TAG_subroutine";
901 case TAG_subroutine_type: return "TAG_subroutine_type";
902 case TAG_typedef: return "TAG_typedef";
903 case TAG_union_type: return "TAG_union_type";
904 case TAG_unspecified_parameters: return "TAG_unspecified_parameters";
905 case TAG_variant: return "TAG_variant";
906 case TAG_common_block: return "TAG_common_block";
907 case TAG_common_inclusion: return "TAG_common_inclusion";
908 case TAG_inheritance: return "TAG_inheritance";
909 case TAG_inlined_subroutine: return "TAG_inlined_subroutine";
910 case TAG_module: return "TAG_module";
911 case TAG_ptr_to_member_type: return "TAG_ptr_to_member_type";
912 case TAG_set_type: return "TAG_set_type";
913 case TAG_subrange_type: return "TAG_subrange_type";
914 case TAG_with_stmt: return "TAG_with_stmt";
916 /* GNU extensions. */
918 case TAG_format_label: return "TAG_format_label";
919 case TAG_namelist: return "TAG_namelist";
920 case TAG_function_template: return "TAG_function_template";
921 case TAG_class_template: return "TAG_class_template";
923 default: return "TAG_<unknown>";
928 dwarf_attr_name (attr)
929 register unsigned attr;
933 case AT_sibling: return "AT_sibling";
934 case AT_location: return "AT_location";
935 case AT_name: return "AT_name";
936 case AT_fund_type: return "AT_fund_type";
937 case AT_mod_fund_type: return "AT_mod_fund_type";
938 case AT_user_def_type: return "AT_user_def_type";
939 case AT_mod_u_d_type: return "AT_mod_u_d_type";
940 case AT_ordering: return "AT_ordering";
941 case AT_subscr_data: return "AT_subscr_data";
942 case AT_byte_size: return "AT_byte_size";
943 case AT_bit_offset: return "AT_bit_offset";
944 case AT_bit_size: return "AT_bit_size";
945 case AT_element_list: return "AT_element_list";
946 case AT_stmt_list: return "AT_stmt_list";
947 case AT_low_pc: return "AT_low_pc";
948 case AT_high_pc: return "AT_high_pc";
949 case AT_language: return "AT_language";
950 case AT_member: return "AT_member";
951 case AT_discr: return "AT_discr";
952 case AT_discr_value: return "AT_discr_value";
953 case AT_string_length: return "AT_string_length";
954 case AT_common_reference: return "AT_common_reference";
955 case AT_comp_dir: return "AT_comp_dir";
956 case AT_const_value_string: return "AT_const_value_string";
957 case AT_const_value_data2: return "AT_const_value_data2";
958 case AT_const_value_data4: return "AT_const_value_data4";
959 case AT_const_value_data8: return "AT_const_value_data8";
960 case AT_const_value_block2: return "AT_const_value_block2";
961 case AT_const_value_block4: return "AT_const_value_block4";
962 case AT_containing_type: return "AT_containing_type";
963 case AT_default_value_addr: return "AT_default_value_addr";
964 case AT_default_value_data2: return "AT_default_value_data2";
965 case AT_default_value_data4: return "AT_default_value_data4";
966 case AT_default_value_data8: return "AT_default_value_data8";
967 case AT_default_value_string: return "AT_default_value_string";
968 case AT_friends: return "AT_friends";
969 case AT_inline: return "AT_inline";
970 case AT_is_optional: return "AT_is_optional";
971 case AT_lower_bound_ref: return "AT_lower_bound_ref";
972 case AT_lower_bound_data2: return "AT_lower_bound_data2";
973 case AT_lower_bound_data4: return "AT_lower_bound_data4";
974 case AT_lower_bound_data8: return "AT_lower_bound_data8";
975 case AT_private: return "AT_private";
976 case AT_producer: return "AT_producer";
977 case AT_program: return "AT_program";
978 case AT_protected: return "AT_protected";
979 case AT_prototyped: return "AT_prototyped";
980 case AT_public: return "AT_public";
981 case AT_pure_virtual: return "AT_pure_virtual";
982 case AT_return_addr: return "AT_return_addr";
983 case AT_abstract_origin: return "AT_abstract_origin";
984 case AT_start_scope: return "AT_start_scope";
985 case AT_stride_size: return "AT_stride_size";
986 case AT_upper_bound_ref: return "AT_upper_bound_ref";
987 case AT_upper_bound_data2: return "AT_upper_bound_data2";
988 case AT_upper_bound_data4: return "AT_upper_bound_data4";
989 case AT_upper_bound_data8: return "AT_upper_bound_data8";
990 case AT_virtual: return "AT_virtual";
994 case AT_sf_names: return "AT_sf_names";
995 case AT_src_info: return "AT_src_info";
996 case AT_mac_info: return "AT_mac_info";
997 case AT_src_coords: return "AT_src_coords";
998 case AT_body_begin: return "AT_body_begin";
999 case AT_body_end: return "AT_body_end";
1001 default: return "AT_<unknown>";
1006 dwarf_stack_op_name (op)
1007 register unsigned op;
1011 case OP_REG: return "OP_REG";
1012 case OP_BASEREG: return "OP_BASEREG";
1013 case OP_ADDR: return "OP_ADDR";
1014 case OP_CONST: return "OP_CONST";
1015 case OP_DEREF2: return "OP_DEREF2";
1016 case OP_DEREF4: return "OP_DEREF4";
1017 case OP_ADD: return "OP_ADD";
1018 default: return "OP_<unknown>";
1023 dwarf_typemod_name (mod)
1024 register unsigned mod;
1028 case MOD_pointer_to: return "MOD_pointer_to";
1029 case MOD_reference_to: return "MOD_reference_to";
1030 case MOD_const: return "MOD_const";
1031 case MOD_volatile: return "MOD_volatile";
1032 default: return "MOD_<unknown>";
1037 dwarf_fmt_byte_name (fmt)
1038 register unsigned fmt;
1042 case FMT_FT_C_C: return "FMT_FT_C_C";
1043 case FMT_FT_C_X: return "FMT_FT_C_X";
1044 case FMT_FT_X_C: return "FMT_FT_X_C";
1045 case FMT_FT_X_X: return "FMT_FT_X_X";
1046 case FMT_UT_C_C: return "FMT_UT_C_C";
1047 case FMT_UT_C_X: return "FMT_UT_C_X";
1048 case FMT_UT_X_C: return "FMT_UT_X_C";
1049 case FMT_UT_X_X: return "FMT_UT_X_X";
1050 case FMT_ET: return "FMT_ET";
1051 default: return "FMT_<unknown>";
1056 dwarf_fund_type_name (ft)
1057 register unsigned ft;
1061 case FT_char: return "FT_char";
1062 case FT_signed_char: return "FT_signed_char";
1063 case FT_unsigned_char: return "FT_unsigned_char";
1064 case FT_short: return "FT_short";
1065 case FT_signed_short: return "FT_signed_short";
1066 case FT_unsigned_short: return "FT_unsigned_short";
1067 case FT_integer: return "FT_integer";
1068 case FT_signed_integer: return "FT_signed_integer";
1069 case FT_unsigned_integer: return "FT_unsigned_integer";
1070 case FT_long: return "FT_long";
1071 case FT_signed_long: return "FT_signed_long";
1072 case FT_unsigned_long: return "FT_unsigned_long";
1073 case FT_pointer: return "FT_pointer";
1074 case FT_float: return "FT_float";
1075 case FT_dbl_prec_float: return "FT_dbl_prec_float";
1076 case FT_ext_prec_float: return "FT_ext_prec_float";
1077 case FT_complex: return "FT_complex";
1078 case FT_dbl_prec_complex: return "FT_dbl_prec_complex";
1079 case FT_void: return "FT_void";
1080 case FT_boolean: return "FT_boolean";
1081 case FT_ext_prec_complex: return "FT_ext_prec_complex";
1082 case FT_label: return "FT_label";
1084 /* GNU extensions. */
1086 case FT_long_long: return "FT_long_long";
1087 case FT_signed_long_long: return "FT_signed_long_long";
1088 case FT_unsigned_long_long: return "FT_unsigned_long_long";
1090 case FT_int8: return "FT_int8";
1091 case FT_signed_int8: return "FT_signed_int8";
1092 case FT_unsigned_int8: return "FT_unsigned_int8";
1093 case FT_int16: return "FT_int16";
1094 case FT_signed_int16: return "FT_signed_int16";
1095 case FT_unsigned_int16: return "FT_unsigned_int16";
1096 case FT_int32: return "FT_int32";
1097 case FT_signed_int32: return "FT_signed_int32";
1098 case FT_unsigned_int32: return "FT_unsigned_int32";
1099 case FT_int64: return "FT_int64";
1100 case FT_signed_int64: return "FT_signed_int64";
1101 case FT_unsigned_int64: return "FT_signed_int64";
1103 case FT_real32: return "FT_real32";
1104 case FT_real64: return "FT_real64";
1105 case FT_real96: return "FT_real96";
1106 case FT_real128: return "FT_real128";
1108 default: return "FT_<unknown>";
1112 /* Determine the "ultimate origin" of a decl. The decl may be an
1113 inlined instance of an inlined instance of a decl which is local
1114 to an inline function, so we have to trace all of the way back
1115 through the origin chain to find out what sort of node actually
1116 served as the original seed for the given block. */
1119 decl_ultimate_origin (decl)
1122 register tree immediate_origin = DECL_ABSTRACT_ORIGIN (decl);
1124 if (immediate_origin == NULL)
1128 register tree ret_val;
1129 register tree lookahead = immediate_origin;
1133 ret_val = lookahead;
1134 lookahead = DECL_ABSTRACT_ORIGIN (ret_val);
1136 while (lookahead != NULL && lookahead != ret_val);
1141 /* Determine the "ultimate origin" of a block. The block may be an
1142 inlined instance of an inlined instance of a block which is local
1143 to an inline function, so we have to trace all of the way back
1144 through the origin chain to find out what sort of node actually
1145 served as the original seed for the given block. */
1148 block_ultimate_origin (block)
1149 register tree block;
1151 register tree immediate_origin = BLOCK_ABSTRACT_ORIGIN (block);
1153 if (immediate_origin == NULL)
1157 register tree ret_val;
1158 register tree lookahead = immediate_origin;
1162 ret_val = lookahead;
1163 lookahead = (TREE_CODE (ret_val) == BLOCK)
1164 ? BLOCK_ABSTRACT_ORIGIN (ret_val)
1167 while (lookahead != NULL && lookahead != ret_val);
1173 output_unsigned_leb128 (value)
1174 register unsigned long value;
1176 register unsigned long orig_value = value;
1180 register unsigned byte = (value & 0x7f);
1183 if (value != 0) /* more bytes to follow */
1185 fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) byte);
1186 if (flag_debug_asm && value == 0)
1187 fprintf (asm_out_file, "\t%s ULEB128 number - value = %u",
1188 ASM_COMMENT_START, orig_value);
1189 fputc ('\n', asm_out_file);
1195 output_signed_leb128 (value)
1196 register long value;
1198 register long orig_value = value;
1199 register int negative = (value < 0);
1204 register unsigned byte = (value & 0x7f);
1208 value |= 0xfe000000; /* manually sign extend */
1209 if (((value == 0) && ((byte & 0x40) == 0))
1210 || ((value == -1) && ((byte & 0x40) == 1)))
1217 fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) byte);
1218 if (flag_debug_asm && more == 0)
1219 fprintf (asm_out_file, "\t%s SLEB128 number - value = %d",
1220 ASM_COMMENT_START, orig_value);
1221 fputc ('\n', asm_out_file);
1226 /**************** utility functions for attribute functions ******************/
1228 /* Given a pointer to a BLOCK node return non-zero if (and only if) the
1229 node in question represents the outermost pair of curly braces (i.e.
1230 the "body block") of a function or method.
1232 For any BLOCK node representing a "body block" of a function or method,
1233 the BLOCK_SUPERCONTEXT of the node will point to another BLOCK node
1234 which represents the outermost (function) scope for the function or
1235 method (i.e. the one which includes the formal parameters). The
1236 BLOCK_SUPERCONTEXT of *that* node in turn will point to the relevant
1241 is_body_block (stmt)
1244 if (TREE_CODE (stmt) == BLOCK)
1246 register tree parent = BLOCK_SUPERCONTEXT (stmt);
1248 if (TREE_CODE (parent) == BLOCK)
1250 register tree grandparent = BLOCK_SUPERCONTEXT (parent);
1252 if (TREE_CODE (grandparent) == FUNCTION_DECL)
1259 /* Given a pointer to a tree node for some type, return a Dwarf fundamental
1260 type code for the given type.
1262 This routine must only be called for GCC type nodes that correspond to
1263 Dwarf fundamental types.
1265 The current Dwarf draft specification calls for Dwarf fundamental types
1266 to accurately reflect the fact that a given type was either a "plain"
1267 integral type or an explicitly "signed" integral type. Unfortunately,
1268 we can't always do this, because GCC may already have thrown away the
1269 information about the precise way in which the type was originally
1272 typedef signed int my_type;
1274 struct s { my_type f; };
1276 Since we may be stuck here without enought information to do exactly
1277 what is called for in the Dwarf draft specification, we do the best
1278 that we can under the circumstances and always use the "plain" integral
1279 fundamental type codes for int, short, and long types. That's probably
1280 good enough. The additional accuracy called for in the current DWARF
1281 draft specification is probably never even useful in practice. */
1284 fundamental_type_code (type)
1287 if (TREE_CODE (type) == ERROR_MARK)
1290 switch (TREE_CODE (type))
1299 /* Carefully distinguish all the standard types of C,
1300 without messing up if the language is not C.
1301 Note that we check only for the names that contain spaces;
1302 other names might occur by coincidence in other languages. */
1303 if (TYPE_NAME (type) != 0
1304 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1305 && DECL_NAME (TYPE_NAME (type)) != 0
1306 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
1308 char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
1310 if (!strcmp (name, "unsigned char"))
1311 return FT_unsigned_char;
1312 if (!strcmp (name, "signed char"))
1313 return FT_signed_char;
1314 if (!strcmp (name, "unsigned int"))
1315 return FT_unsigned_integer;
1316 if (!strcmp (name, "short int"))
1318 if (!strcmp (name, "short unsigned int"))
1319 return FT_unsigned_short;
1320 if (!strcmp (name, "long int"))
1322 if (!strcmp (name, "long unsigned int"))
1323 return FT_unsigned_long;
1324 if (!strcmp (name, "long long int"))
1325 return FT_long_long; /* Not grok'ed by svr4 SDB */
1326 if (!strcmp (name, "long long unsigned int"))
1327 return FT_unsigned_long_long; /* Not grok'ed by svr4 SDB */
1330 /* Most integer types will be sorted out above, however, for the
1331 sake of special `array index' integer types, the following code
1332 is also provided. */
1334 if (TYPE_PRECISION (type) == INT_TYPE_SIZE)
1335 return (TREE_UNSIGNED (type) ? FT_unsigned_integer : FT_integer);
1337 if (TYPE_PRECISION (type) == LONG_TYPE_SIZE)
1338 return (TREE_UNSIGNED (type) ? FT_unsigned_long : FT_long);
1340 if (TYPE_PRECISION (type) == LONG_LONG_TYPE_SIZE)
1341 return (TREE_UNSIGNED (type) ? FT_unsigned_long_long : FT_long_long);
1343 if (TYPE_PRECISION (type) == SHORT_TYPE_SIZE)
1344 return (TREE_UNSIGNED (type) ? FT_unsigned_short : FT_short);
1346 if (TYPE_PRECISION (type) == CHAR_TYPE_SIZE)
1347 return (TREE_UNSIGNED (type) ? FT_unsigned_char : FT_char);
1352 /* Carefully distinguish all the standard types of C,
1353 without messing up if the language is not C. */
1354 if (TYPE_NAME (type) != 0
1355 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1356 && DECL_NAME (TYPE_NAME (type)) != 0
1357 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
1359 char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
1361 /* Note that here we can run afowl of a serious bug in "classic"
1362 svr4 SDB debuggers. They don't seem to understand the
1363 FT_ext_prec_float type (even though they should). */
1365 if (!strcmp (name, "long double"))
1366 return FT_ext_prec_float;
1369 if (TYPE_PRECISION (type) == DOUBLE_TYPE_SIZE)
1370 return FT_dbl_prec_float;
1371 if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE)
1374 /* Note that here we can run afowl of a serious bug in "classic"
1375 svr4 SDB debuggers. They don't seem to understand the
1376 FT_ext_prec_float type (even though they should). */
1378 if (TYPE_PRECISION (type) == LONG_DOUBLE_TYPE_SIZE)
1379 return FT_ext_prec_float;
1383 return FT_complex; /* GNU FORTRAN COMPLEX type. */
1386 return FT_char; /* GNU Pascal CHAR type. Not used in C. */
1389 return FT_boolean; /* GNU FORTRAN BOOLEAN type. */
1392 abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
1397 /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
1398 the Dwarf "root" type for the given input type. The Dwarf "root" type
1399 of a given type is generally the same as the given type, except that if
1400 the given type is a pointer or reference type, then the root type of
1401 the given type is the root type of the "basis" type for the pointer or
1402 reference type. (This definition of the "root" type is recursive.)
1403 Also, the root type of a `const' qualified type or a `volatile'
1404 qualified type is the root type of the given type without the
1411 if (TREE_CODE (type) == ERROR_MARK)
1412 return error_mark_node;
1414 switch (TREE_CODE (type))
1417 return error_mark_node;
1420 case REFERENCE_TYPE:
1421 return type_main_variant (root_type (TREE_TYPE (type)));
1424 return type_main_variant (type);
1428 /* Given a pointer to an arbitrary ..._TYPE tree node, write out a sequence
1429 of zero or more Dwarf "type-modifier" bytes applicable to the type. */
1432 write_modifier_bytes (type, decl_const, decl_volatile)
1434 register int decl_const;
1435 register int decl_volatile;
1437 if (TREE_CODE (type) == ERROR_MARK)
1440 if (TYPE_READONLY (type) || decl_const)
1441 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_const);
1442 if (TYPE_VOLATILE (type) || decl_volatile)
1443 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_volatile);
1444 switch (TREE_CODE (type))
1447 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_pointer_to);
1448 write_modifier_bytes (TREE_TYPE (type), 0, 0);
1451 case REFERENCE_TYPE:
1452 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_reference_to);
1453 write_modifier_bytes (TREE_TYPE (type), 0, 0);
1462 /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
1463 given input type is a Dwarf "fundamental" type. Otherwise return zero. */
1466 type_is_fundamental (type)
1469 switch (TREE_CODE (type))
1484 case QUAL_UNION_TYPE:
1489 case REFERENCE_TYPE:
1501 /* Given a pointer to some ..._DECL tree node, generate an assembly language
1502 equate directive which will associate a symbolic name with the current DIE.
1504 The name used is an artificial label generated from the DECL_UID number
1505 associated with the given decl node. The name it gets equated to is the
1506 symbolic label that we (previously) output at the start of the DIE that
1507 we are currently generating.
1509 Calling this function while generating some "decl related" form of DIE
1510 makes it possible to later refer to the DIE which represents the given
1511 decl simply by re-generating the symbolic name from the ..._DECL node's
1515 equate_decl_number_to_die_number (decl)
1518 /* In the case where we are generating a DIE for some ..._DECL node
1519 which represents either some inline function declaration or some
1520 entity declared within an inline function declaration/definition,
1521 setup a symbolic name for the current DIE so that we have a name
1522 for this DIE that we can easily refer to later on within
1523 AT_abstract_origin attributes. */
1525 char decl_label[MAX_ARTIFICIAL_LABEL_BYTES];
1526 char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
1528 sprintf (decl_label, DECL_NAME_FMT, DECL_UID (decl));
1529 sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
1530 ASM_OUTPUT_DEF (asm_out_file, decl_label, die_label);
1533 /* Given a pointer to some ..._TYPE tree node, generate an assembly language
1534 equate directive which will associate a symbolic name with the current DIE.
1536 The name used is an artificial label generated from the TYPE_UID number
1537 associated with the given type node. The name it gets equated to is the
1538 symbolic label that we (previously) output at the start of the DIE that
1539 we are currently generating.
1541 Calling this function while generating some "type related" form of DIE
1542 makes it easy to later refer to the DIE which represents the given type
1543 simply by re-generating the alternative name from the ..._TYPE node's
1547 equate_type_number_to_die_number (type)
1550 char type_label[MAX_ARTIFICIAL_LABEL_BYTES];
1551 char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
1553 /* We are generating a DIE to represent the main variant of this type
1554 (i.e the type without any const or volatile qualifiers) so in order
1555 to get the equate to come out right, we need to get the main variant
1558 type = type_main_variant (type);
1560 sprintf (type_label, TYPE_NAME_FMT, TYPE_UID (type));
1561 sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
1562 ASM_OUTPUT_DEF (asm_out_file, type_label, die_label);
1566 output_reg_number (rtl)
1569 register unsigned regno = REGNO (rtl);
1571 if (regno >= FIRST_PSEUDO_REGISTER)
1573 warning_with_decl (dwarf_last_decl, "internal regno botch: regno = %d\n",
1577 fprintf (asm_out_file, "\t%s\t0x%x",
1578 UNALIGNED_INT_ASM_OP, DBX_REGISTER_NUMBER (regno));
1581 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
1582 PRINT_REG (rtl, 0, asm_out_file);
1584 fputc ('\n', asm_out_file);
1587 /* The following routine is a nice and simple transducer. It converts the
1588 RTL for a variable or parameter (resident in memory) into an equivalent
1589 Dwarf representation of a mechanism for getting the address of that same
1590 variable onto the top of a hypothetical "address evaluation" stack.
1592 When creating memory location descriptors, we are effectively trans-
1593 forming the RTL for a memory-resident object into its Dwarf postfix
1594 expression equivalent. This routine just recursively descends an
1595 RTL tree, turning it into Dwarf postfix code as it goes. */
1598 output_mem_loc_descriptor (rtl)
1601 /* Note that for a dynamically sized array, the location we will
1602 generate a description of here will be the lowest numbered location
1603 which is actually within the array. That's *not* necessarily the
1604 same as the zeroth element of the array. */
1606 switch (GET_CODE (rtl))
1610 /* The case of a subreg may arise when we have a local (register)
1611 variable or a formal (register) parameter which doesn't quite
1612 fill up an entire register. For now, just assume that it is
1613 legitimate to make the Dwarf info refer to the whole register
1614 which contains the given subreg. */
1616 rtl = XEXP (rtl, 0);
1621 /* Whenever a register number forms a part of the description of
1622 the method for calculating the (dynamic) address of a memory
1623 resident object, DWARF rules require the register number to
1624 be referred to as a "base register". This distinction is not
1625 based in any way upon what category of register the hardware
1626 believes the given register belongs to. This is strictly
1627 DWARF terminology we're dealing with here.
1629 Note that in cases where the location of a memory-resident data
1630 object could be expressed as:
1632 OP_ADD (OP_BASEREG (basereg), OP_CONST (0))
1634 the actual DWARF location descriptor that we generate may just
1635 be OP_BASEREG (basereg). This may look deceptively like the
1636 object in question was allocated to a register (rather than
1637 in memory) so DWARF consumers need to be aware of the subtle
1638 distinction between OP_REG and OP_BASEREG. */
1640 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_BASEREG);
1641 output_reg_number (rtl);
1645 output_mem_loc_descriptor (XEXP (rtl, 0));
1646 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_DEREF4);
1651 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADDR);
1652 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
1656 output_mem_loc_descriptor (XEXP (rtl, 0));
1657 output_mem_loc_descriptor (XEXP (rtl, 1));
1658 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
1662 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
1663 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, INTVAL (rtl));
1671 /* Output a proper Dwarf location descriptor for a variable or parameter
1672 which is either allocated in a register or in a memory location. For
1673 a register, we just generate an OP_REG and the register number. For a
1674 memory location we provide a Dwarf postfix expression describing how to
1675 generate the (dynamic) address of the object onto the address stack. */
1678 output_loc_descriptor (rtl)
1681 switch (GET_CODE (rtl))
1685 /* The case of a subreg may arise when we have a local (register)
1686 variable or a formal (register) parameter which doesn't quite
1687 fill up an entire register. For now, just assume that it is
1688 legitimate to make the Dwarf info refer to the whole register
1689 which contains the given subreg. */
1691 rtl = XEXP (rtl, 0);
1695 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_REG);
1696 output_reg_number (rtl);
1700 output_mem_loc_descriptor (XEXP (rtl, 0));
1704 abort (); /* Should never happen */
1708 /* Given a tree node describing an array bound (either lower or upper)
1709 output a representation for that bound. */
1712 output_bound_representation (bound, dim_num, u_or_l)
1713 register tree bound;
1714 register unsigned dim_num; /* For multi-dimensional arrays. */
1715 register char u_or_l; /* Designates upper or lower bound. */
1717 switch (TREE_CODE (bound))
1723 /* All fixed-bounds are represented by INTEGER_CST nodes. */
1726 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
1727 (unsigned) TREE_INT_CST_LOW (bound));
1732 /* Dynamic bounds may be represented by NOP_EXPR nodes containing
1733 SAVE_EXPR nodes, in which case we can do something, or as
1734 an expression, which we cannot represent. */
1736 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
1737 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
1739 sprintf (begin_label, BOUND_BEGIN_LABEL_FMT,
1740 current_dienum, dim_num, u_or_l);
1742 sprintf (end_label, BOUND_END_LABEL_FMT,
1743 current_dienum, dim_num, u_or_l);
1745 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
1746 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
1748 /* If optimization is turned on, the SAVE_EXPRs that describe
1749 how to access the upper bound values are essentially bogus.
1750 They only describe (at best) how to get at these values at
1751 the points in the generated code right after they have just
1752 been computed. Worse yet, in the typical case, the upper
1753 bound values will not even *be* computed in the optimized
1754 code, so these SAVE_EXPRs are entirely bogus.
1756 In order to compensate for this fact, we check here to see
1757 if optimization is enabled, and if so, we effectively create
1758 an empty location description for the (unknown and unknowable)
1761 This should not cause too much trouble for existing (stupid?)
1762 debuggers because they have to deal with empty upper bounds
1763 location descriptions anyway in order to be able to deal with
1764 incomplete array types.
1766 Of course an intelligent debugger (GDB?) should be able to
1767 comprehend that a missing upper bound specification in a
1768 array type used for a storage class `auto' local array variable
1769 indicates that the upper bound is both unknown (at compile-
1770 time) and unknowable (at run-time) due to optimization. */
1774 while (TREE_CODE (bound) == NOP_EXPR
1775 || TREE_CODE (bound) == CONVERT_EXPR)
1776 bound = TREE_OPERAND (bound, 0);
1778 if (TREE_CODE (bound) == SAVE_EXPR)
1779 output_loc_descriptor
1780 (eliminate_regs (SAVE_EXPR_RTL (bound), 0, NULL_RTX));
1783 ASM_OUTPUT_LABEL (asm_out_file, end_label);
1790 /* Recursive function to output a sequence of value/name pairs for
1791 enumeration constants in reversed order. This is called from
1792 enumeration_type_die. */
1795 output_enumeral_list (link)
1800 output_enumeral_list (TREE_CHAIN (link));
1801 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
1802 (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link)));
1803 ASM_OUTPUT_DWARF_STRING (asm_out_file,
1804 IDENTIFIER_POINTER (TREE_PURPOSE (link)));
1808 /* Given an unsigned value, round it up to the lowest multiple of `boundary'
1809 which is not less than the value itself. */
1811 static inline unsigned
1812 ceiling (value, boundary)
1813 register unsigned value;
1814 register unsigned boundary;
1816 return (((value + boundary - 1) / boundary) * boundary);
1819 /* Given a pointer to what is assumed to be a FIELD_DECL node, return a
1820 pointer to the declared type for the relevant field variable, or return
1821 `integer_type_node' if the given node turns out to be an ERROR_MARK node. */
1829 if (TREE_CODE (decl) == ERROR_MARK)
1830 return integer_type_node;
1832 type = DECL_BIT_FIELD_TYPE (decl);
1834 type = TREE_TYPE (decl);
1838 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
1839 node, return the alignment in bits for the type, or else return
1840 BITS_PER_WORD if the node actually turns out to be an ERROR_MARK node. */
1842 static inline unsigned
1843 simple_type_align_in_bits (type)
1846 return (TREE_CODE (type) != ERROR_MARK) ? TYPE_ALIGN (type) : BITS_PER_WORD;
1849 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
1850 node, return the size in bits for the type if it is a constant, or
1851 else return the alignment for the type if the type's size is not
1852 constant, or else return BITS_PER_WORD if the type actually turns out
1853 to be an ERROR_MARK node. */
1855 static inline unsigned
1856 simple_type_size_in_bits (type)
1859 if (TREE_CODE (type) == ERROR_MARK)
1860 return BITS_PER_WORD;
1863 register tree type_size_tree = TYPE_SIZE (type);
1865 if (TREE_CODE (type_size_tree) != INTEGER_CST)
1866 return TYPE_ALIGN (type);
1868 return (unsigned) TREE_INT_CST_LOW (type_size_tree);
1872 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
1873 return the byte offset of the lowest addressed byte of the "containing
1874 object" for the given FIELD_DECL, or return 0 if we are unable to deter-
1875 mine what that offset is, either because the argument turns out to be a
1876 pointer to an ERROR_MARK node, or because the offset is actually variable.
1877 (We can't handle the latter case just yet.) */
1880 field_byte_offset (decl)
1883 register unsigned type_align_in_bytes;
1884 register unsigned type_align_in_bits;
1885 register unsigned type_size_in_bits;
1886 register unsigned object_offset_in_align_units;
1887 register unsigned object_offset_in_bits;
1888 register unsigned object_offset_in_bytes;
1890 register tree bitpos_tree;
1891 register tree field_size_tree;
1892 register unsigned bitpos_int;
1893 register unsigned deepest_bitpos;
1894 register unsigned field_size_in_bits;
1896 if (TREE_CODE (decl) == ERROR_MARK)
1899 if (TREE_CODE (decl) != FIELD_DECL)
1902 type = field_type (decl);
1904 bitpos_tree = DECL_FIELD_BITPOS (decl);
1905 field_size_tree = DECL_SIZE (decl);
1907 /* We cannot yet cope with fields whose positions or sizes are variable,
1908 so for now, when we see such things, we simply return 0. Someday,
1909 we may be able to handle such cases, but it will be damn difficult. */
1911 if (TREE_CODE (bitpos_tree) != INTEGER_CST)
1913 bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
1915 if (TREE_CODE (field_size_tree) != INTEGER_CST)
1917 field_size_in_bits = (unsigned) TREE_INT_CST_LOW (field_size_tree);
1919 type_size_in_bits = simple_type_size_in_bits (type);
1921 type_align_in_bits = simple_type_align_in_bits (type);
1922 type_align_in_bytes = type_align_in_bits / BITS_PER_UNIT;
1924 /* Note that the GCC front-end doesn't make any attempt to keep track
1925 of the starting bit offset (relative to the start of the containing
1926 structure type) of the hypothetical "containing object" for a bit-
1927 field. Thus, when computing the byte offset value for the start of
1928 the "containing object" of a bit-field, we must deduce this infor-
1931 This can be rather tricky to do in some cases. For example, handling
1932 the following structure type definition when compiling for an i386/i486
1933 target (which only aligns long long's to 32-bit boundaries) can be very
1938 long long field2:31;
1941 Fortunately, there is a simple rule-of-thumb which can be used in such
1942 cases. When compiling for an i386/i486, GCC will allocate 8 bytes for
1943 the structure shown above. It decides to do this based upon one simple
1944 rule for bit-field allocation. Quite simply, GCC allocates each "con-
1945 taining object" for each bit-field at the first (i.e. lowest addressed)
1946 legitimate alignment boundary (based upon the required minimum alignment
1947 for the declared type of the field) which it can possibly use, subject
1948 to the condition that there is still enough available space remaining
1949 in the containing object (when allocated at the selected point) to
1950 fully accommodate all of the bits of the bit-field itself.
1952 This simple rule makes it obvious why GCC allocates 8 bytes for each
1953 object of the structure type shown above. When looking for a place to
1954 allocate the "containing object" for `field2', the compiler simply tries
1955 to allocate a 64-bit "containing object" at each successive 32-bit
1956 boundary (starting at zero) until it finds a place to allocate that 64-
1957 bit field such that at least 31 contiguous (and previously unallocated)
1958 bits remain within that selected 64 bit field. (As it turns out, for
1959 the example above, the compiler finds that it is OK to allocate the
1960 "containing object" 64-bit field at bit-offset zero within the
1963 Here we attempt to work backwards from the limited set of facts we're
1964 given, and we try to deduce from those facts, where GCC must have
1965 believed that the containing object started (within the structure type).
1967 The value we deduce is then used (by the callers of this routine) to
1968 generate AT_location and AT_bit_offset attributes for fields (both
1969 bit-fields and, in the case of AT_location, regular fields as well).
1972 /* Figure out the bit-distance from the start of the structure to the
1973 "deepest" bit of the bit-field. */
1974 deepest_bitpos = bitpos_int + field_size_in_bits;
1976 /* This is the tricky part. Use some fancy footwork to deduce where the
1977 lowest addressed bit of the containing object must be. */
1978 object_offset_in_bits
1979 = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits;
1981 /* Compute the offset of the containing object in "alignment units". */
1982 object_offset_in_align_units = object_offset_in_bits / type_align_in_bits;
1984 /* Compute the offset of the containing object in bytes. */
1985 object_offset_in_bytes = object_offset_in_align_units * type_align_in_bytes;
1987 return object_offset_in_bytes;
1990 /****************************** attributes *********************************/
1992 /* The following routines are responsible for writing out the various types
1993 of Dwarf attributes (and any following data bytes associated with them).
1994 These routines are listed in order based on the numerical codes of their
1995 associated attributes. */
1997 /* Generate an AT_sibling attribute. */
2000 sibling_attribute ()
2002 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2004 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sibling);
2005 sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
2006 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2009 /* Output the form of location attributes suitable for whole variables and
2010 whole parameters. Note that the location attributes for struct fields
2011 are generated by the routine `data_member_location_attribute' below. */
2014 location_attribute (rtl)
2017 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2018 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2020 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
2021 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
2022 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
2023 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2024 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2026 /* Handle a special case. If we are about to output a location descriptor
2027 for a variable or parameter which has been optimized out of existence,
2028 don't do that. Instead we output a zero-length location descriptor
2029 value as part of the location attribute.
2031 A variable which has been optimized out of existence will have a
2032 DECL_RTL value which denotes a pseudo-reg.
2034 Currently, in some rare cases, variables can have DECL_RTL values
2035 which look like (MEM (REG pseudo-reg#)). These cases are due to
2036 bugs elsewhere in the compiler. We treat such cases
2037 as if the variable(s) in question had been optimized out of existence.
2039 Note that in all cases where we wish to express the fact that a
2040 variable has been optimized out of existence, we do not simply
2041 suppress the generation of the entire location attribute because
2042 the absence of a location attribute in certain kinds of DIEs is
2043 used to indicate something else entirely... i.e. that the DIE
2044 represents an object declaration, but not a definition. So saith
2048 if (! is_pseudo_reg (rtl)
2049 && (GET_CODE (rtl) != MEM || ! is_pseudo_reg (XEXP (rtl, 0))))
2050 output_loc_descriptor (eliminate_regs (rtl, 0, NULL_RTX));
2052 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2055 /* Output the specialized form of location attribute used for data members
2056 of struct and union types.
2058 In the special case of a FIELD_DECL node which represents a bit-field,
2059 the "offset" part of this special location descriptor must indicate the
2060 distance in bytes from the lowest-addressed byte of the containing
2061 struct or union type to the lowest-addressed byte of the "containing
2062 object" for the bit-field. (See the `field_byte_offset' function above.)
2064 For any given bit-field, the "containing object" is a hypothetical
2065 object (of some integral or enum type) within which the given bit-field
2066 lives. The type of this hypothetical "containing object" is always the
2067 same as the declared type of the individual bit-field itself (for GCC
2068 anyway... the DWARF spec doesn't actually mandate this).
2070 Note that it is the size (in bytes) of the hypothetical "containing
2071 object" which will be given in the AT_byte_size attribute for this
2072 bit-field. (See the `byte_size_attribute' function below.) It is
2073 also used when calculating the value of the AT_bit_offset attribute.
2074 (See the `bit_offset_attribute' function below.) */
2077 data_member_location_attribute (t)
2080 register unsigned object_offset_in_bytes;
2081 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2082 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2084 if (TREE_CODE (t) == TREE_VEC)
2085 object_offset_in_bytes = TREE_INT_CST_LOW (BINFO_OFFSET (t));
2087 object_offset_in_bytes = field_byte_offset (t);
2089 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
2090 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
2091 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
2092 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2093 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2094 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
2095 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, object_offset_in_bytes);
2096 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
2097 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2100 /* Output an AT_const_value attribute for a variable or a parameter which
2101 does not have a "location" either in memory or in a register. These
2102 things can arise in GNU C when a constant is passed as an actual
2103 parameter to an inlined function. They can also arise in C++ where
2104 declared constants do not necessarily get memory "homes". */
2107 const_value_attribute (rtl)
2110 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2111 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2113 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_const_value_block4);
2114 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
2115 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
2116 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
2117 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2119 switch (GET_CODE (rtl))
2122 /* Note that a CONST_INT rtx could represent either an integer or
2123 a floating-point constant. A CONST_INT is used whenever the
2124 constant will fit into a single word. In all such cases, the
2125 original mode of the constant value is wiped out, and the
2126 CONST_INT rtx is assigned VOIDmode. Since we no longer have
2127 precise mode information for these constants, we always just
2128 output them using 4 bytes. */
2130 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, (unsigned) INTVAL (rtl));
2134 /* Note that a CONST_DOUBLE rtx could represent either an integer
2135 or a floating-point constant. A CONST_DOUBLE is used whenever
2136 the constant requires more than one word in order to be adequately
2137 represented. In all such cases, the original mode of the constant
2138 value is preserved as the mode of the CONST_DOUBLE rtx, but for
2139 simplicity we always just output CONST_DOUBLEs using 8 bytes. */
2141 ASM_OUTPUT_DWARF_DATA8 (asm_out_file,
2142 (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (rtl),
2143 (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (rtl));
2147 ASM_OUTPUT_DWARF_STRING (asm_out_file, XSTR (rtl, 0));
2153 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
2157 /* In cases where an inlined instance of an inline function is passed
2158 the address of an `auto' variable (which is local to the caller)
2159 we can get a situation where the DECL_RTL of the artificial
2160 local variable (for the inlining) which acts as a stand-in for
2161 the corresponding formal parameter (of the inline function)
2162 will look like (plus:SI (reg:SI FRAME_PTR) (const_int ...)).
2163 This is not exactly a compile-time constant expression, but it
2164 isn't the address of the (artificial) local variable either.
2165 Rather, it represents the *value* which the artificial local
2166 variable always has during its lifetime. We currently have no
2167 way to represent such quasi-constant values in Dwarf, so for now
2168 we just punt and generate an AT_const_value attribute with form
2169 FORM_BLOCK4 and a length of zero. */
2173 abort (); /* No other kinds of rtx should be possible here. */
2176 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2179 /* Generate *either* an AT_location attribute or else an AT_const_value
2180 data attribute for a variable or a parameter. We generate the
2181 AT_const_value attribute only in those cases where the given
2182 variable or parameter does not have a true "location" either in
2183 memory or in a register. This can happen (for example) when a
2184 constant is passed as an actual argument in a call to an inline
2185 function. (It's possible that these things can crop up in other
2186 ways also.) Note that one type of constant value which can be
2187 passed into an inlined function is a constant pointer. This can
2188 happen for example if an actual argument in an inlined function
2189 call evaluates to a compile-time constant address. */
2192 location_or_const_value_attribute (decl)
2197 if (TREE_CODE (decl) == ERROR_MARK)
2200 if ((TREE_CODE (decl) != VAR_DECL) && (TREE_CODE (decl) != PARM_DECL))
2202 /* Should never happen. */
2207 /* Here we have to decide where we are going to say the parameter "lives"
2208 (as far as the debugger is concerned). We only have a couple of choices.
2209 GCC provides us with DECL_RTL and with DECL_INCOMING_RTL. DECL_RTL
2210 normally indicates where the parameter lives during most of the activa-
2211 tion of the function. If optimization is enabled however, this could
2212 be either NULL or else a pseudo-reg. Both of those cases indicate that
2213 the parameter doesn't really live anywhere (as far as the code generation
2214 parts of GCC are concerned) during most of the function's activation.
2215 That will happen (for example) if the parameter is never referenced
2216 within the function.
2218 We could just generate a location descriptor here for all non-NULL
2219 non-pseudo values of DECL_RTL and ignore all of the rest, but we can
2220 be a little nicer than that if we also consider DECL_INCOMING_RTL in
2221 cases where DECL_RTL is NULL or is a pseudo-reg.
2223 Note however that we can only get away with using DECL_INCOMING_RTL as
2224 a backup substitute for DECL_RTL in certain limited cases. In cases
2225 where DECL_ARG_TYPE(decl) indicates the same type as TREE_TYPE(decl)
2226 we can be sure that the parameter was passed using the same type as it
2227 is declared to have within the function, and that its DECL_INCOMING_RTL
2228 points us to a place where a value of that type is passed. In cases
2229 where DECL_ARG_TYPE(decl) and TREE_TYPE(decl) are different types
2230 however, we cannot (in general) use DECL_INCOMING_RTL as a backup
2231 substitute for DECL_RTL because in these cases, DECL_INCOMING_RTL
2232 points us to a value of some type which is *different* from the type
2233 of the parameter itself. Thus, if we tried to use DECL_INCOMING_RTL
2234 to generate a location attribute in such cases, the debugger would
2235 end up (for example) trying to fetch a `float' from a place which
2236 actually contains the first part of a `double'. That would lead to
2237 really incorrect and confusing output at debug-time, and we don't
2238 want that now do we?
2240 So in general, we DO NOT use DECL_INCOMING_RTL as a backup for DECL_RTL
2241 in cases where DECL_ARG_TYPE(decl) != TREE_TYPE(decl). There are a
2242 couple of cute exceptions however. On little-endian machines we can
2243 get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE(decl) is
2244 not the same as TREE_TYPE(decl) but only when DECL_ARG_TYPE(decl) is
2245 an integral type which is smaller than TREE_TYPE(decl). These cases
2246 arise when (on a little-endian machine) a non-prototyped function has
2247 a parameter declared to be of type `short' or `char'. In such cases,
2248 TREE_TYPE(decl) will be `short' or `char', DECL_ARG_TYPE(decl) will be
2249 `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
2250 passed `int' value. If the debugger then uses that address to fetch a
2251 `short' or a `char' (on a little-endian machine) the result will be the
2252 correct data, so we allow for such exceptional cases below.
2254 Note that our goal here is to describe the place where the given formal
2255 parameter lives during most of the function's activation (i.e. between
2256 the end of the prologue and the start of the epilogue). We'll do that
2257 as best as we can. Note however that if the given formal parameter is
2258 modified sometime during the execution of the function, then a stack
2259 backtrace (at debug-time) will show the function as having been called
2260 with the *new* value rather than the value which was originally passed
2261 in. This happens rarely enough that it is not a major problem, but it
2262 *is* a problem, and I'd like to fix it. A future version of dwarfout.c
2263 may generate two additional attributes for any given TAG_formal_parameter
2264 DIE which will describe the "passed type" and the "passed location" for
2265 the given formal parameter in addition to the attributes we now generate
2266 to indicate the "declared type" and the "active location" for each
2267 parameter. This additional set of attributes could be used by debuggers
2268 for stack backtraces.
2270 Separately, note that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL
2271 can be NULL also. This happens (for example) for inlined-instances of
2272 inline function formal parameters which are never referenced. This really
2273 shouldn't be happening. All PARM_DECL nodes should get valid non-NULL
2274 DECL_INCOMING_RTL values, but integrate.c doesn't currently generate
2275 these values for inlined instances of inline function parameters, so
2276 when we see such cases, we are just SOL (shit-out-of-luck) for the time
2277 being (until integrate.c gets fixed).
2280 /* Use DECL_RTL as the "location" unless we find something better. */
2281 rtl = DECL_RTL (decl);
2283 if (TREE_CODE (decl) == PARM_DECL)
2284 if (rtl == NULL_RTX || is_pseudo_reg (rtl))
2286 /* This decl represents a formal parameter which was optimized out. */
2287 register tree declared_type = type_main_variant (TREE_TYPE (decl));
2288 register tree passed_type = type_main_variant (DECL_ARG_TYPE (decl));
2290 /* Note that DECL_INCOMING_RTL may be NULL in here, but we handle
2291 *all* cases where (rtl == NULL_RTX) just below. */
2293 if (declared_type == passed_type)
2294 rtl = DECL_INCOMING_RTL (decl);
2295 else if (! BYTES_BIG_ENDIAN)
2296 if (TREE_CODE (declared_type) == INTEGER_TYPE)
2297 if (TYPE_SIZE (declared_type) <= TYPE_SIZE (passed_type))
2298 rtl = DECL_INCOMING_RTL (decl);
2301 if (rtl == NULL_RTX)
2304 switch (GET_CODE (rtl))
2312 case PLUS: /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
2313 const_value_attribute (rtl);
2319 location_attribute (rtl);
2323 abort (); /* Should never happen. */
2327 /* Generate an AT_name attribute given some string value to be included as
2328 the value of the attribute. */
2331 name_attribute (name_string)
2332 register char *name_string;
2334 if (name_string && *name_string)
2336 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_name);
2337 ASM_OUTPUT_DWARF_STRING (asm_out_file, name_string);
2342 fund_type_attribute (ft_code)
2343 register unsigned ft_code;
2345 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_fund_type);
2346 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, ft_code);
2350 mod_fund_type_attribute (type, decl_const, decl_volatile)
2352 register int decl_const;
2353 register int decl_volatile;
2355 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2356 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2358 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_fund_type);
2359 sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
2360 sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
2361 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2362 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2363 write_modifier_bytes (type, decl_const, decl_volatile);
2364 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
2365 fundamental_type_code (root_type (type)));
2366 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2370 user_def_type_attribute (type)
2373 char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
2375 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_user_def_type);
2376 sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (type));
2377 ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
2381 mod_u_d_type_attribute (type, decl_const, decl_volatile)
2383 register int decl_const;
2384 register int decl_volatile;
2386 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2387 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2388 char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
2390 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_u_d_type);
2391 sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
2392 sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
2393 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2394 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2395 write_modifier_bytes (type, decl_const, decl_volatile);
2396 sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (root_type (type)));
2397 ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
2398 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2401 #ifdef USE_ORDERING_ATTRIBUTE
2403 ordering_attribute (ordering)
2404 register unsigned ordering;
2406 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_ordering);
2407 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, ordering);
2409 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
2411 /* Note that the block of subscript information for an array type also
2412 includes information about the element type of type given array type. */
2415 subscript_data_attribute (type)
2418 register unsigned dimension_number;
2419 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2420 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2422 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_subscr_data);
2423 sprintf (begin_label, SS_BEGIN_LABEL_FMT, current_dienum);
2424 sprintf (end_label, SS_END_LABEL_FMT, current_dienum);
2425 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2426 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2428 /* The GNU compilers represent multidimensional array types as sequences
2429 of one dimensional array types whose element types are themselves array
2430 types. Here we squish that down, so that each multidimensional array
2431 type gets only one array_type DIE in the Dwarf debugging info. The
2432 draft Dwarf specification say that we are allowed to do this kind
2433 of compression in C (because there is no difference between an
2434 array or arrays and a multidimensional array in C) but for other
2435 source languages (e.g. Ada) we probably shouldn't do this. */
2437 for (dimension_number = 0;
2438 TREE_CODE (type) == ARRAY_TYPE;
2439 type = TREE_TYPE (type), dimension_number++)
2441 register tree domain = TYPE_DOMAIN (type);
2443 /* Arrays come in three flavors. Unspecified bounds, fixed
2444 bounds, and (in GNU C only) variable bounds. Handle all
2445 three forms here. */
2449 /* We have an array type with specified bounds. */
2451 register tree lower = TYPE_MIN_VALUE (domain);
2452 register tree upper = TYPE_MAX_VALUE (domain);
2454 /* Handle only fundamental types as index types for now. */
2456 if (! type_is_fundamental (domain))
2459 /* Output the representation format byte for this dimension. */
2461 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file,
2463 TREE_CODE (lower) == INTEGER_CST,
2464 TREE_CODE (upper) == INTEGER_CST));
2466 /* Output the index type for this dimension. */
2468 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
2469 fundamental_type_code (domain));
2471 /* Output the representation for the lower bound. */
2473 output_bound_representation (lower, dimension_number, 'l');
2475 /* Output the representation for the upper bound. */
2477 output_bound_representation (upper, dimension_number, 'u');
2481 /* We have an array type with an unspecified length. For C and
2482 C++ we can assume that this really means that (a) the index
2483 type is an integral type, and (b) the lower bound is zero.
2484 Note that Dwarf defines the representation of an unspecified
2485 (upper) bound as being a zero-length location description. */
2487 /* Output the array-bounds format byte. */
2489 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_FT_C_X);
2491 /* Output the (assumed) index type. */
2493 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, FT_integer);
2495 /* Output the (assumed) lower bound (constant) value. */
2497 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
2499 /* Output the (empty) location description for the upper bound. */
2501 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0);
2505 /* Output the prefix byte that says that the element type is coming up. */
2507 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_ET);
2509 /* Output a representation of the type of the elements of this array type. */
2511 type_attribute (type, 0, 0);
2513 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2517 byte_size_attribute (tree_node)
2518 register tree tree_node;
2520 register unsigned size;
2522 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_byte_size);
2523 switch (TREE_CODE (tree_node))
2532 case QUAL_UNION_TYPE:
2533 size = int_size_in_bytes (tree_node);
2537 /* For a data member of a struct or union, the AT_byte_size is
2538 generally given as the number of bytes normally allocated for
2539 an object of the *declared* type of the member itself. This
2540 is true even for bit-fields. */
2541 size = simple_type_size_in_bits (field_type (tree_node))
2549 /* Note that `size' might be -1 when we get to this point. If it
2550 is, that indicates that the byte size of the entity in question
2551 is variable. We have no good way of expressing this fact in Dwarf
2552 at the present time, so just let the -1 pass on through. */
2554 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, size);
2557 /* For a FIELD_DECL node which represents a bit-field, output an attribute
2558 which specifies the distance in bits from the highest order bit of the
2559 "containing object" for the bit-field to the highest order bit of the
2562 For any given bit-field, the "containing object" is a hypothetical
2563 object (of some integral or enum type) within which the given bit-field
2564 lives. The type of this hypothetical "containing object" is always the
2565 same as the declared type of the individual bit-field itself.
2567 The determination of the exact location of the "containing object" for
2568 a bit-field is rather complicated. It's handled by the `field_byte_offset'
2571 Note that it is the size (in bytes) of the hypothetical "containing
2572 object" which will be given in the AT_byte_size attribute for this
2573 bit-field. (See `byte_size_attribute' above.) */
2576 bit_offset_attribute (decl)
2579 register unsigned object_offset_in_bytes = field_byte_offset (decl);
2580 register tree type = DECL_BIT_FIELD_TYPE (decl);
2581 register tree bitpos_tree = DECL_FIELD_BITPOS (decl);
2582 register unsigned bitpos_int;
2583 register unsigned highest_order_object_bit_offset;
2584 register unsigned highest_order_field_bit_offset;
2585 register unsigned bit_offset;
2587 assert (TREE_CODE (decl) == FIELD_DECL); /* Must be a field. */
2588 assert (type); /* Must be a bit field. */
2590 /* We can't yet handle bit-fields whose offsets are variable, so if we
2591 encounter such things, just return without generating any attribute
2594 if (TREE_CODE (bitpos_tree) != INTEGER_CST)
2596 bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
2598 /* Note that the bit offset is always the distance (in bits) from the
2599 highest-order bit of the "containing object" to the highest-order
2600 bit of the bit-field itself. Since the "high-order end" of any
2601 object or field is different on big-endian and little-endian machines,
2602 the computation below must take account of these differences. */
2604 highest_order_object_bit_offset = object_offset_in_bytes * BITS_PER_UNIT;
2605 highest_order_field_bit_offset = bitpos_int;
2607 if (! BYTES_BIG_ENDIAN)
2609 highest_order_field_bit_offset
2610 += (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl));
2612 highest_order_object_bit_offset += simple_type_size_in_bits (type);
2617 ? highest_order_object_bit_offset - highest_order_field_bit_offset
2618 : highest_order_field_bit_offset - highest_order_object_bit_offset);
2620 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_offset);
2621 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, bit_offset);
2624 /* For a FIELD_DECL node which represents a bit field, output an attribute
2625 which specifies the length in bits of the given field. */
2628 bit_size_attribute (decl)
2631 assert (TREE_CODE (decl) == FIELD_DECL); /* Must be a field. */
2632 assert (DECL_BIT_FIELD_TYPE (decl)); /* Must be a bit field. */
2634 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_size);
2635 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
2636 (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl)));
2639 /* The following routine outputs the `element_list' attribute for enumeration
2640 type DIEs. The element_lits attribute includes the names and values of
2641 all of the enumeration constants associated with the given enumeration
2645 element_list_attribute (element)
2646 register tree element;
2648 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2649 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2651 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_element_list);
2652 sprintf (begin_label, EE_BEGIN_LABEL_FMT, current_dienum);
2653 sprintf (end_label, EE_END_LABEL_FMT, current_dienum);
2654 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
2655 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2657 /* Here we output a list of value/name pairs for each enumeration constant
2658 defined for this enumeration type (as required), but we do it in REVERSE
2659 order. The order is the one required by the draft #5 Dwarf specification
2660 published by the UI/PLSIG. */
2662 output_enumeral_list (element); /* Recursively output the whole list. */
2664 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2667 /* Generate an AT_stmt_list attribute. These are normally present only in
2668 DIEs with a TAG_compile_unit tag. */
2671 stmt_list_attribute (label)
2672 register char *label;
2674 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_stmt_list);
2675 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2676 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
2679 /* Generate an AT_low_pc attribute for a label DIE, a lexical_block DIE or
2680 for a subroutine DIE. */
2683 low_pc_attribute (asm_low_label)
2684 register char *asm_low_label;
2686 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_low_pc);
2687 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_low_label);
2690 /* Generate an AT_high_pc attribute for a lexical_block DIE or for a
2694 high_pc_attribute (asm_high_label)
2695 register char *asm_high_label;
2697 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_high_pc);
2698 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_high_label);
2701 /* Generate an AT_body_begin attribute for a subroutine DIE. */
2704 body_begin_attribute (asm_begin_label)
2705 register char *asm_begin_label;
2707 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_begin);
2708 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_begin_label);
2711 /* Generate an AT_body_end attribute for a subroutine DIE. */
2714 body_end_attribute (asm_end_label)
2715 register char *asm_end_label;
2717 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_end);
2718 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_end_label);
2721 /* Generate an AT_language attribute given a LANG value. These attributes
2722 are used only within TAG_compile_unit DIEs. */
2725 language_attribute (language_code)
2726 register unsigned language_code;
2728 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_language);
2729 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, language_code);
2733 member_attribute (context)
2734 register tree context;
2736 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2738 /* Generate this attribute only for members in C++. */
2740 if (context != NULL && is_tagged_type (context))
2742 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_member);
2743 sprintf (label, TYPE_NAME_FMT, TYPE_UID (context));
2744 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2749 string_length_attribute (upper_bound)
2750 register tree upper_bound;
2752 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2753 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2755 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_string_length);
2756 sprintf (begin_label, SL_BEGIN_LABEL_FMT, current_dienum);
2757 sprintf (end_label, SL_END_LABEL_FMT, current_dienum);
2758 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2759 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2760 output_bound_representation (upper_bound, 0, 'u');
2761 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2765 comp_dir_attribute (dirname)
2766 register char *dirname;
2768 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_comp_dir);
2769 ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname);
2773 sf_names_attribute (sf_names_start_label)
2774 register char *sf_names_start_label;
2776 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sf_names);
2777 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2778 ASM_OUTPUT_DWARF_ADDR (asm_out_file, sf_names_start_label);
2782 src_info_attribute (src_info_start_label)
2783 register char *src_info_start_label;
2785 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_info);
2786 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2787 ASM_OUTPUT_DWARF_ADDR (asm_out_file, src_info_start_label);
2791 mac_info_attribute (mac_info_start_label)
2792 register char *mac_info_start_label;
2794 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mac_info);
2795 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2796 ASM_OUTPUT_DWARF_ADDR (asm_out_file, mac_info_start_label);
2800 prototyped_attribute (func_type)
2801 register tree func_type;
2803 if ((strcmp (language_string, "GNU C") == 0)
2804 && (TYPE_ARG_TYPES (func_type) != NULL))
2806 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_prototyped);
2807 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
2812 producer_attribute (producer)
2813 register char *producer;
2815 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_producer);
2816 ASM_OUTPUT_DWARF_STRING (asm_out_file, producer);
2820 inline_attribute (decl)
2823 if (DECL_INLINE (decl))
2825 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_inline);
2826 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
2831 containing_type_attribute (containing_type)
2832 register tree containing_type;
2834 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2836 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_containing_type);
2837 sprintf (label, TYPE_NAME_FMT, TYPE_UID (containing_type));
2838 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2842 abstract_origin_attribute (origin)
2843 register tree origin;
2845 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2847 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_abstract_origin);
2848 switch (TREE_CODE_CLASS (TREE_CODE (origin)))
2851 sprintf (label, DECL_NAME_FMT, DECL_UID (origin));
2855 sprintf (label, TYPE_NAME_FMT, TYPE_UID (origin));
2859 abort (); /* Should never happen. */
2862 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2865 #ifdef DWARF_DECL_COORDINATES
2867 src_coords_attribute (src_fileno, src_lineno)
2868 register unsigned src_fileno;
2869 register unsigned src_lineno;
2871 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_coords);
2872 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_fileno);
2873 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_lineno);
2875 #endif /* defined(DWARF_DECL_COORDINATES) */
2878 pure_or_virtual_attribute (func_decl)
2879 register tree func_decl;
2881 if (DECL_VIRTUAL_P (func_decl))
2883 #if 0 /* DECL_ABSTRACT_VIRTUAL_P is C++-specific. */
2884 if (DECL_ABSTRACT_VIRTUAL_P (func_decl))
2885 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_pure_virtual);
2888 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
2889 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
2893 /************************* end of attributes *****************************/
2895 /********************* utility routines for DIEs *************************/
2897 /* Output an AT_name attribute and an AT_src_coords attribute for the
2898 given decl, but only if it actually has a name. */
2901 name_and_src_coords_attributes (decl)
2904 register tree decl_name = DECL_NAME (decl);
2906 if (decl_name && IDENTIFIER_POINTER (decl_name))
2908 name_attribute (IDENTIFIER_POINTER (decl_name));
2909 #ifdef DWARF_DECL_COORDINATES
2911 register unsigned file_index;
2913 /* This is annoying, but we have to pop out of the .debug section
2914 for a moment while we call `lookup_filename' because calling it
2915 may cause a temporary switch into the .debug_sfnames section and
2916 most svr4 assemblers are not smart enough be be able to nest
2917 section switches to any depth greater than one. Note that we
2918 also can't skirt this issue by delaying all output to the
2919 .debug_sfnames section unit the end of compilation because that
2920 would cause us to have inter-section forward references and
2921 Fred Fish sez that m68k/svr4 assemblers botch those. */
2923 ASM_OUTPUT_POP_SECTION (asm_out_file);
2924 file_index = lookup_filename (DECL_SOURCE_FILE (decl));
2925 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
2927 src_coords_attribute (file_index, DECL_SOURCE_LINE (decl));
2929 #endif /* defined(DWARF_DECL_COORDINATES) */
2933 /* Many forms of DIEs contain a "type description" part. The following
2934 routine writes out these "type descriptor" parts. */
2937 type_attribute (type, decl_const, decl_volatile)
2939 register int decl_const;
2940 register int decl_volatile;
2942 register enum tree_code code = TREE_CODE (type);
2943 register int root_type_modified;
2945 if (TREE_CODE (type) == ERROR_MARK)
2948 /* Handle a special case. For functions whose return type is void,
2949 we generate *no* type attribute. (Note that no object may have
2950 type `void', so this only applies to function return types. */
2952 if (TREE_CODE (type) == VOID_TYPE)
2955 root_type_modified = (code == POINTER_TYPE || code == REFERENCE_TYPE
2956 || decl_const || decl_volatile
2957 || TYPE_READONLY (type) || TYPE_VOLATILE (type));
2959 if (type_is_fundamental (root_type (type)))
2960 if (root_type_modified)
2961 mod_fund_type_attribute (type, decl_const, decl_volatile);
2963 fund_type_attribute (fundamental_type_code (type));
2965 if (root_type_modified)
2966 mod_u_d_type_attribute (type, decl_const, decl_volatile);
2968 /* We have to get the type_main_variant here (and pass that to the
2969 `user_def_type_attribute' routine) because the ..._TYPE node we
2970 have might simply be a *copy* of some original type node (where
2971 the copy was created to help us keep track of typedef names)
2972 and that copy might have a different TYPE_UID from the original
2973 ..._TYPE node. (Note that when `equate_type_number_to_die_number'
2974 is labeling a given type DIE for future reference, it always and
2975 only creates labels for DIEs representing *main variants*, and it
2976 never even knows about non-main-variants.) */
2977 user_def_type_attribute (type_main_variant (type));
2980 /* Given a tree pointer to a struct, class, union, or enum type node, return
2981 a pointer to the (string) tag name for the given type, or zero if the
2982 type was declared without a tag. */
2988 register char *name = 0;
2990 if (TYPE_NAME (type) != 0)
2992 register tree t = 0;
2994 /* Find the IDENTIFIER_NODE for the type name. */
2995 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
2996 t = TYPE_NAME (type);
2998 /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
2999 a TYPE_DECL node, regardless of whether or not a `typedef' was
3002 if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
3003 t = DECL_NAME (TYPE_NAME (type));
3005 /* Now get the name as a string, or invent one. */
3007 name = IDENTIFIER_POINTER (t);
3010 return (name == 0 || *name == '\0') ? 0 : name;
3016 /* Start by checking if the pending_sibling_stack needs to be expanded.
3017 If necessary, expand it. */
3019 if (pending_siblings == pending_siblings_allocated)
3021 pending_siblings_allocated += PENDING_SIBLINGS_INCREMENT;
3022 pending_sibling_stack
3023 = (unsigned *) xrealloc (pending_sibling_stack,
3024 pending_siblings_allocated * sizeof(unsigned));
3028 NEXT_DIE_NUM = next_unused_dienum++;
3031 /* Pop the sibling stack so that the most recently pushed DIEnum becomes the
3041 member_declared_type (member)
3042 register tree member;
3044 return (DECL_BIT_FIELD_TYPE (member))
3045 ? DECL_BIT_FIELD_TYPE (member)
3046 : TREE_TYPE (member);
3049 /* Get the function's label, as described by its RTL.
3050 This may be different from the DECL_NAME name used
3051 in the source file. */
3054 function_start_label (decl)
3060 x = DECL_RTL (decl);
3061 if (GET_CODE (x) != MEM)
3064 if (GET_CODE (x) != SYMBOL_REF)
3066 fnname = XSTR (x, 0);
3071 /******************************* DIEs ************************************/
3073 /* Output routines for individual types of DIEs. */
3075 /* Note that every type of DIE (except a null DIE) gets a sibling. */
3078 output_array_type_die (arg)
3081 register tree type = arg;
3083 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_array_type);
3084 sibling_attribute ();
3085 equate_type_number_to_die_number (type);
3086 member_attribute (TYPE_CONTEXT (type));
3088 /* I believe that we can default the array ordering. SDB will probably
3089 do the right things even if AT_ordering is not present. It's not
3090 even an issue until we start to get into multidimensional arrays
3091 anyway. If SDB is ever caught doing the Wrong Thing for multi-
3092 dimensional arrays, then we'll have to put the AT_ordering attribute
3093 back in. (But if and when we find out that we need to put these in,
3094 we will only do so for multidimensional arrays. After all, we don't
3095 want to waste space in the .debug section now do we?) */
3097 #ifdef USE_ORDERING_ATTRIBUTE
3098 ordering_attribute (ORD_row_major);
3099 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
3101 subscript_data_attribute (type);
3105 output_set_type_die (arg)
3108 register tree type = arg;
3110 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_set_type);
3111 sibling_attribute ();
3112 equate_type_number_to_die_number (type);
3113 member_attribute (TYPE_CONTEXT (type));
3114 type_attribute (TREE_TYPE (type), 0, 0);
3118 /* Implement this when there is a GNU FORTRAN or GNU Ada front end. */
3121 output_entry_point_die (arg)
3124 register tree decl = arg;
3125 register tree origin = decl_ultimate_origin (decl);
3127 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_entry_point);
3128 sibling_attribute ();
3131 abstract_origin_attribute (origin);
3134 name_and_src_coords_attributes (decl);
3135 member_attribute (DECL_CONTEXT (decl));
3136 type_attribute (TREE_TYPE (TREE_TYPE (decl)), 0, 0);
3138 if (DECL_ABSTRACT (decl))
3139 equate_decl_number_to_die_number (decl);
3141 low_pc_attribute (function_start_label (decl));
3145 /* Output a DIE to represent an inlined instance of an enumeration type. */
3148 output_inlined_enumeration_type_die (arg)
3151 register tree type = arg;
3153 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
3154 sibling_attribute ();
3155 assert (TREE_ASM_WRITTEN (type));
3156 abstract_origin_attribute (type);
3159 /* Output a DIE to represent an inlined instance of a structure type. */
3162 output_inlined_structure_type_die (arg)
3165 register tree type = arg;
3167 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
3168 sibling_attribute ();
3169 assert (TREE_ASM_WRITTEN (type));
3170 abstract_origin_attribute (type);
3173 /* Output a DIE to represent an inlined instance of a union type. */
3176 output_inlined_union_type_die (arg)
3179 register tree type = arg;
3181 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
3182 sibling_attribute ();
3183 assert (TREE_ASM_WRITTEN (type));
3184 abstract_origin_attribute (type);
3187 /* Output a DIE to represent an enumeration type. Note that these DIEs
3188 include all of the information about the enumeration values also.
3189 This information is encoded into the element_list attribute. */
3192 output_enumeration_type_die (arg)
3195 register tree type = arg;
3197 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
3198 sibling_attribute ();
3199 equate_type_number_to_die_number (type);
3200 name_attribute (type_tag (type));
3201 member_attribute (TYPE_CONTEXT (type));
3203 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
3204 given enum type is incomplete, do not generate the AT_byte_size
3205 attribute or the AT_element_list attribute. */
3207 if (TYPE_SIZE (type))
3209 byte_size_attribute (type);
3210 element_list_attribute (TYPE_FIELDS (type));
3214 /* Output a DIE to represent either a real live formal parameter decl or
3215 to represent just the type of some formal parameter position in some
3218 Note that this routine is a bit unusual because its argument may be
3219 a ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
3220 represents an inlining of some PARM_DECL) or else some sort of a
3221 ..._TYPE node. If it's the former then this function is being called
3222 to output a DIE to represent a formal parameter object (or some inlining
3223 thereof). If it's the latter, then this function is only being called
3224 to output a TAG_formal_parameter DIE to stand as a placeholder for some
3225 formal argument type of some subprogram type. */
3228 output_formal_parameter_die (arg)
3231 register tree node = arg;
3233 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_formal_parameter);
3234 sibling_attribute ();
3236 switch (TREE_CODE_CLASS (TREE_CODE (node)))
3238 case 'd': /* We were called with some kind of a ..._DECL node. */
3240 register tree origin = decl_ultimate_origin (node);
3243 abstract_origin_attribute (origin);
3246 name_and_src_coords_attributes (node);
3247 type_attribute (TREE_TYPE (node),
3248 TREE_READONLY (node), TREE_THIS_VOLATILE (node));
3250 if (DECL_ABSTRACT (node))
3251 equate_decl_number_to_die_number (node);
3253 location_or_const_value_attribute (node);
3257 case 't': /* We were called with some kind of a ..._TYPE node. */
3258 type_attribute (node, 0, 0);
3262 abort (); /* Should never happen. */
3266 /* Output a DIE to represent a declared function (either file-scope
3267 or block-local) which has "external linkage" (according to ANSI-C). */
3270 output_global_subroutine_die (arg)
3273 register tree decl = arg;
3274 register tree origin = decl_ultimate_origin (decl);
3276 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_subroutine);
3277 sibling_attribute ();
3280 abstract_origin_attribute (origin);
3283 register tree type = TREE_TYPE (decl);
3285 name_and_src_coords_attributes (decl);
3286 inline_attribute (decl);
3287 prototyped_attribute (type);
3288 member_attribute (DECL_CONTEXT (decl));
3289 type_attribute (TREE_TYPE (type), 0, 0);
3290 pure_or_virtual_attribute (decl);
3292 if (DECL_ABSTRACT (decl))
3293 equate_decl_number_to_die_number (decl);
3296 if (! DECL_EXTERNAL (decl))
3298 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3300 low_pc_attribute (function_start_label (decl));
3301 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
3302 high_pc_attribute (label);
3303 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
3304 body_begin_attribute (label);
3305 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
3306 body_end_attribute (label);
3311 /* Output a DIE to represent a declared data object (either file-scope
3312 or block-local) which has "external linkage" (according to ANSI-C). */
3315 output_global_variable_die (arg)
3318 register tree decl = arg;
3319 register tree origin = decl_ultimate_origin (decl);
3321 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_variable);
3322 sibling_attribute ();
3324 abstract_origin_attribute (origin);
3327 name_and_src_coords_attributes (decl);
3328 member_attribute (DECL_CONTEXT (decl));
3329 type_attribute (TREE_TYPE (decl),
3330 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3332 if (DECL_ABSTRACT (decl))
3333 equate_decl_number_to_die_number (decl);
3336 if (!DECL_EXTERNAL (decl))
3337 location_or_const_value_attribute (decl);
3342 output_label_die (arg)
3345 register tree decl = arg;
3346 register tree origin = decl_ultimate_origin (decl);
3348 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_label);
3349 sibling_attribute ();
3351 abstract_origin_attribute (origin);
3353 name_and_src_coords_attributes (decl);
3354 if (DECL_ABSTRACT (decl))
3355 equate_decl_number_to_die_number (decl);
3358 register rtx insn = DECL_RTL (decl);
3360 if (GET_CODE (insn) == CODE_LABEL)
3362 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3364 /* When optimization is enabled (via -O) some parts of the compiler
3365 (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
3366 represent source-level labels which were explicitly declared by
3367 the user. This really shouldn't be happening though, so catch
3368 it if it ever does happen. */
3370 if (INSN_DELETED_P (insn))
3371 abort (); /* Should never happen. */
3373 sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
3374 (unsigned) INSN_UID (insn));
3375 low_pc_attribute (label);
3381 output_lexical_block_die (arg)
3384 register tree stmt = arg;
3386 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_lexical_block);
3387 sibling_attribute ();
3389 if (! BLOCK_ABSTRACT (stmt))
3391 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3392 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3394 sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
3395 low_pc_attribute (begin_label);
3396 sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
3397 high_pc_attribute (end_label);
3402 output_inlined_subroutine_die (arg)
3405 register tree stmt = arg;
3407 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inlined_subroutine);
3408 sibling_attribute ();
3410 abstract_origin_attribute (block_ultimate_origin (stmt));
3411 if (! BLOCK_ABSTRACT (stmt))
3413 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3414 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3416 sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
3417 low_pc_attribute (begin_label);
3418 sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
3419 high_pc_attribute (end_label);
3423 /* Output a DIE to represent a declared data object (either file-scope
3424 or block-local) which has "internal linkage" (according to ANSI-C). */
3427 output_local_variable_die (arg)
3430 register tree decl = arg;
3431 register tree origin = decl_ultimate_origin (decl);
3433 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_local_variable);
3434 sibling_attribute ();
3436 abstract_origin_attribute (origin);
3439 name_and_src_coords_attributes (decl);
3440 member_attribute (DECL_CONTEXT (decl));
3441 type_attribute (TREE_TYPE (decl),
3442 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3444 if (DECL_ABSTRACT (decl))
3445 equate_decl_number_to_die_number (decl);
3447 location_or_const_value_attribute (decl);
3451 output_member_die (arg)
3454 register tree decl = arg;
3456 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_member);
3457 sibling_attribute ();
3458 name_and_src_coords_attributes (decl);
3459 member_attribute (DECL_CONTEXT (decl));
3460 type_attribute (member_declared_type (decl),
3461 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3462 if (DECL_BIT_FIELD_TYPE (decl)) /* If this is a bit field... */
3464 byte_size_attribute (decl);
3465 bit_size_attribute (decl);
3466 bit_offset_attribute (decl);
3468 data_member_location_attribute (decl);
3472 /* Don't generate either pointer_type DIEs or reference_type DIEs. Use
3473 modified types instead.
3475 We keep this code here just in case these types of DIEs may be
3476 needed to represent certain things in other languages (e.g. Pascal)
3480 output_pointer_type_die (arg)
3483 register tree type = arg;
3485 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_pointer_type);
3486 sibling_attribute ();
3487 equate_type_number_to_die_number (type);
3488 member_attribute (TYPE_CONTEXT (type));
3489 type_attribute (TREE_TYPE (type), 0, 0);
3493 output_reference_type_die (arg)
3496 register tree type = arg;
3498 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_reference_type);
3499 sibling_attribute ();
3500 equate_type_number_to_die_number (type);
3501 member_attribute (TYPE_CONTEXT (type));
3502 type_attribute (TREE_TYPE (type), 0, 0);
3507 output_ptr_to_mbr_type_die (arg)
3510 register tree type = arg;
3512 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_ptr_to_member_type);
3513 sibling_attribute ();
3514 equate_type_number_to_die_number (type);
3515 member_attribute (TYPE_CONTEXT (type));
3516 containing_type_attribute (TYPE_OFFSET_BASETYPE (type));
3517 type_attribute (TREE_TYPE (type), 0, 0);
3521 output_compile_unit_die (arg)
3524 register char *main_input_filename = arg;
3526 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_compile_unit);
3527 sibling_attribute ();
3529 name_attribute (main_input_filename);
3534 sprintf (producer, "%s %s", language_string, version_string);
3535 producer_attribute (producer);
3538 if (strcmp (language_string, "GNU C++") == 0)
3539 language_attribute (LANG_C_PLUS_PLUS);
3540 else if (strcmp (language_string, "GNU Ada") == 0)
3541 language_attribute (LANG_ADA83);
3542 else if (strcmp (language_string, "GNU F77") == 0)
3543 language_attribute (LANG_FORTRAN77);
3544 else if (flag_traditional)
3545 language_attribute (LANG_C);
3547 language_attribute (LANG_C89);
3548 low_pc_attribute (TEXT_BEGIN_LABEL);
3549 high_pc_attribute (TEXT_END_LABEL);
3550 if (debug_info_level >= DINFO_LEVEL_NORMAL)
3551 stmt_list_attribute (LINE_BEGIN_LABEL);
3552 last_filename = xstrdup (main_input_filename);
3555 char *wd = getpwd ();
3557 comp_dir_attribute (wd);
3560 if (debug_info_level >= DINFO_LEVEL_NORMAL)
3562 sf_names_attribute (SFNAMES_BEGIN_LABEL);
3563 src_info_attribute (SRCINFO_BEGIN_LABEL);
3564 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
3565 mac_info_attribute (MACINFO_BEGIN_LABEL);
3570 output_string_type_die (arg)
3573 register tree type = arg;
3575 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_string_type);
3576 sibling_attribute ();
3577 member_attribute (TYPE_CONTEXT (type));
3579 /* Fudge the string length attribute for now. */
3581 string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
3585 output_inheritance_die (arg)
3588 register tree binfo = arg;
3590 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inheritance);
3591 sibling_attribute ();
3592 type_attribute (BINFO_TYPE (binfo), 0, 0);
3593 data_member_location_attribute (binfo);
3594 if (TREE_VIA_VIRTUAL (binfo))
3596 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
3597 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
3599 if (TREE_VIA_PUBLIC (binfo))
3601 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_public);
3602 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
3604 else if (TREE_VIA_PROTECTED (binfo))
3606 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_protected);
3607 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
3612 output_structure_type_die (arg)
3615 register tree type = arg;
3617 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
3618 sibling_attribute ();
3619 equate_type_number_to_die_number (type);
3620 name_attribute (type_tag (type));
3621 member_attribute (TYPE_CONTEXT (type));
3623 /* If this type has been completed, then give it a byte_size attribute
3624 and prepare to give a list of members. Otherwise, don't do either of
3625 these things. In the latter case, we will not be generating a list
3626 of members (since we don't have any idea what they might be for an
3627 incomplete type). */
3629 if (TYPE_SIZE (type))
3632 byte_size_attribute (type);
3636 /* Output a DIE to represent a declared function (either file-scope
3637 or block-local) which has "internal linkage" (according to ANSI-C). */
3640 output_local_subroutine_die (arg)
3643 register tree decl = arg;
3644 register tree origin = decl_ultimate_origin (decl);
3646 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine);
3647 sibling_attribute ();
3650 abstract_origin_attribute (origin);
3653 register tree type = TREE_TYPE (decl);
3655 name_and_src_coords_attributes (decl);
3656 inline_attribute (decl);
3657 prototyped_attribute (type);
3658 member_attribute (DECL_CONTEXT (decl));
3659 type_attribute (TREE_TYPE (type), 0, 0);
3660 pure_or_virtual_attribute (decl);
3662 if (DECL_ABSTRACT (decl))
3663 equate_decl_number_to_die_number (decl);
3666 /* Avoid getting screwed up in cases where a function was declared
3667 static but where no definition was ever given for it. */
3669 if (TREE_ASM_WRITTEN (decl))
3671 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3672 low_pc_attribute (function_start_label (decl));
3673 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
3674 high_pc_attribute (label);
3675 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
3676 body_begin_attribute (label);
3677 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
3678 body_end_attribute (label);
3684 output_subroutine_type_die (arg)
3687 register tree type = arg;
3688 register tree return_type = TREE_TYPE (type);
3690 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine_type);
3691 sibling_attribute ();
3693 equate_type_number_to_die_number (type);
3694 prototyped_attribute (type);
3695 member_attribute (TYPE_CONTEXT (type));
3696 type_attribute (return_type, 0, 0);
3700 output_typedef_die (arg)
3703 register tree decl = arg;
3704 register tree origin = decl_ultimate_origin (decl);
3706 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_typedef);
3707 sibling_attribute ();
3709 abstract_origin_attribute (origin);
3712 name_and_src_coords_attributes (decl);
3713 member_attribute (DECL_CONTEXT (decl));
3714 type_attribute (TREE_TYPE (decl),
3715 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3717 if (DECL_ABSTRACT (decl))
3718 equate_decl_number_to_die_number (decl);
3722 output_union_type_die (arg)
3725 register tree type = arg;
3727 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
3728 sibling_attribute ();
3729 equate_type_number_to_die_number (type);
3730 name_attribute (type_tag (type));
3731 member_attribute (TYPE_CONTEXT (type));
3733 /* If this type has been completed, then give it a byte_size attribute
3734 and prepare to give a list of members. Otherwise, don't do either of
3735 these things. In the latter case, we will not be generating a list
3736 of members (since we don't have any idea what they might be for an
3737 incomplete type). */
3739 if (TYPE_SIZE (type))
3742 byte_size_attribute (type);
3746 /* Generate a special type of DIE used as a stand-in for a trailing ellipsis
3747 at the end of an (ANSI prototyped) formal parameters list. */
3750 output_unspecified_parameters_die (arg)
3753 register tree decl_or_type = arg;
3755 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_unspecified_parameters);
3756 sibling_attribute ();
3758 /* This kludge is here only for the sake of being compatible with what
3759 the USL CI5 C compiler does. The specification of Dwarf Version 1
3760 doesn't say that TAG_unspecified_parameters DIEs should contain any
3761 attributes other than the AT_sibling attribute, but they are certainly
3762 allowed to contain additional attributes, and the CI5 compiler
3763 generates AT_name, AT_fund_type, and AT_location attributes within
3764 TAG_unspecified_parameters DIEs which appear in the child lists for
3765 DIEs representing function definitions, so we do likewise here. */
3767 if (TREE_CODE (decl_or_type) == FUNCTION_DECL && DECL_INITIAL (decl_or_type))
3769 name_attribute ("...");
3770 fund_type_attribute (FT_pointer);
3771 /* location_attribute (?); */
3776 output_padded_null_die (arg)
3779 ASM_OUTPUT_ALIGN (asm_out_file, 2); /* 2**2 == 4 */
3782 /*************************** end of DIEs *********************************/
3784 /* Generate some type of DIE. This routine generates the generic outer
3785 wrapper stuff which goes around all types of DIE's (regardless of their
3786 TAGs. All forms of DIEs start with a DIE-specific label, followed by a
3787 DIE-length word, followed by the guts of the DIE itself. After the guts
3788 of the DIE, there must always be a terminator label for the DIE. */
3791 output_die (die_specific_output_function, param)
3792 register void (*die_specific_output_function)();
3793 register void *param;
3795 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3796 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3798 current_dienum = NEXT_DIE_NUM;
3799 NEXT_DIE_NUM = next_unused_dienum;
3801 sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
3802 sprintf (end_label, DIE_END_LABEL_FMT, current_dienum);
3804 /* Write a label which will act as the name for the start of this DIE. */
3806 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
3808 /* Write the DIE-length word. */
3810 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
3812 /* Fill in the guts of the DIE. */
3814 next_unused_dienum++;
3815 die_specific_output_function (param);
3817 /* Write a label which will act as the name for the end of this DIE. */
3819 ASM_OUTPUT_LABEL (asm_out_file, end_label);
3823 end_sibling_chain ()
3825 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3827 current_dienum = NEXT_DIE_NUM;
3828 NEXT_DIE_NUM = next_unused_dienum;
3830 sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
3832 /* Write a label which will act as the name for the start of this DIE. */
3834 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
3836 /* Write the DIE-length word. */
3838 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 4);
3843 /* Generate a list of nameless TAG_formal_parameter DIEs (and perhaps a
3844 TAG_unspecified_parameters DIE) to represent the types of the formal
3845 parameters as specified in some function type specification (except
3846 for those which appear as part of a function *definition*).
3848 Note that we must be careful here to output all of the parameter
3849 DIEs *before* we output any DIEs needed to represent the types of
3850 the formal parameters. This keeps svr4 SDB happy because it
3851 (incorrectly) thinks that the first non-parameter DIE it sees ends
3852 the formal parameter list. */
3855 output_formal_types (function_or_method_type)
3856 register tree function_or_method_type;
3859 register tree formal_type = NULL;
3860 register tree first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
3862 /* In the case where we are generating a formal types list for a C++
3863 non-static member function type, skip over the first thing on the
3864 TYPE_ARG_TYPES list because it only represents the type of the
3865 hidden `this pointer'. The debugger should be able to figure
3866 out (without being explicitly told) that this non-static member
3867 function type takes a `this pointer' and should be able to figure
3868 what the type of that hidden parameter is from the AT_member
3869 attribute of the parent TAG_subroutine_type DIE. */
3871 if (TREE_CODE (function_or_method_type) == METHOD_TYPE)
3872 first_parm_type = TREE_CHAIN (first_parm_type);
3874 /* Make our first pass over the list of formal parameter types and output
3875 a TAG_formal_parameter DIE for each one. */
3877 for (link = first_parm_type; link; link = TREE_CHAIN (link))
3879 formal_type = TREE_VALUE (link);
3880 if (formal_type == void_type_node)
3883 /* Output a (nameless) DIE to represent the formal parameter itself. */
3885 output_die (output_formal_parameter_die, formal_type);
3888 /* If this function type has an ellipsis, add a TAG_unspecified_parameters
3889 DIE to the end of the parameter list. */
3891 if (formal_type != void_type_node)
3892 output_die (output_unspecified_parameters_die, function_or_method_type);
3894 /* Make our second (and final) pass over the list of formal parameter types
3895 and output DIEs to represent those types (as necessary). */
3897 for (link = TYPE_ARG_TYPES (function_or_method_type);
3899 link = TREE_CHAIN (link))
3901 formal_type = TREE_VALUE (link);
3902 if (formal_type == void_type_node)
3905 output_type (formal_type, function_or_method_type);
3909 /* Remember a type in the pending_types_list. */
3915 if (pending_types == pending_types_allocated)
3917 pending_types_allocated += PENDING_TYPES_INCREMENT;
3919 = (tree *) xrealloc (pending_types_list,
3920 sizeof (tree) * pending_types_allocated);
3922 pending_types_list[pending_types++] = type;
3924 /* Mark the pending type as having been output already (even though
3925 it hasn't been). This prevents the type from being added to the
3926 pending_types_list more than once. */
3928 TREE_ASM_WRITTEN (type) = 1;
3931 /* Return non-zero if it is legitimate to output DIEs to represent a
3932 given type while we are generating the list of child DIEs for some
3933 DIE (e.g. a function or lexical block DIE) associated with a given scope.
3935 See the comments within the function for a description of when it is
3936 considered legitimate to output DIEs for various kinds of types.
3938 Note that TYPE_CONTEXT(type) may be NULL (to indicate global scope)
3939 or it may point to a BLOCK node (for types local to a block), or to a
3940 FUNCTION_DECL node (for types local to the heading of some function
3941 definition), or to a FUNCTION_TYPE node (for types local to the
3942 prototyped parameter list of a function type specification), or to a
3943 RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node
3944 (in the case of C++ nested types).
3946 The `scope' parameter should likewise be NULL or should point to a
3947 BLOCK node, a FUNCTION_DECL node, a FUNCTION_TYPE node, a RECORD_TYPE
3948 node, a UNION_TYPE node, or a QUAL_UNION_TYPE node.
3950 This function is used only for deciding when to "pend" and when to
3951 "un-pend" types to/from the pending_types_list.
3953 Note that we sometimes make use of this "type pending" feature in a
3954 rather twisted way to temporarily delay the production of DIEs for the
3955 types of formal parameters. (We do this just to make svr4 SDB happy.)
3956 It order to delay the production of DIEs representing types of formal
3957 parameters, callers of this function supply `fake_containing_scope' as
3958 the `scope' parameter to this function. Given that fake_containing_scope
3959 is a tagged type which is *not* the containing scope for *any* other type,
3960 the desired effect is achieved, i.e. output of DIEs representing types
3961 is temporarily suspended, and any type DIEs which would have otherwise
3962 been output are instead placed onto the pending_types_list. Later on,
3963 we force these (temporarily pended) types to be output simply by calling
3964 `output_pending_types_for_scope' with an actual argument equal to the
3965 true scope of the types we temporarily pended. */
3968 type_ok_for_scope (type, scope)
3970 register tree scope;
3972 /* Tagged types (i.e. struct, union, and enum types) must always be
3973 output only in the scopes where they actually belong (or else the
3974 scoping of their own tag names and the scoping of their member
3975 names will be incorrect). Non-tagged-types on the other hand can
3976 generally be output anywhere, except that svr4 SDB really doesn't
3977 want to see them nested within struct or union types, so here we
3978 say it is always OK to immediately output any such a (non-tagged)
3979 type, so long as we are not within such a context. Note that the
3980 only kinds of non-tagged types which we will be dealing with here
3981 (for C and C++ anyway) will be array types and function types. */
3983 return is_tagged_type (type)
3984 ? (TYPE_CONTEXT (type) == scope)
3985 : (scope == NULL_TREE || ! is_tagged_type (scope));
3988 /* Output any pending types (from the pending_types list) which we can output
3989 now (taking into account the scope that we are working on now).
3991 For each type output, remove the given type from the pending_types_list
3992 *before* we try to output it.
3994 Note that we have to process the list in beginning-to-end order,
3995 because the call made here to output_type may cause yet more types
3996 to be added to the end of the list, and we may have to output some
4000 output_pending_types_for_scope (containing_scope)
4001 register tree containing_scope;
4003 register unsigned i;
4005 for (i = 0; i < pending_types; )
4007 register tree type = pending_types_list[i];
4009 if (type_ok_for_scope (type, containing_scope))
4011 register tree *mover;
4012 register tree *limit;
4015 limit = &pending_types_list[pending_types];
4016 for (mover = &pending_types_list[i]; mover < limit; mover++)
4017 *mover = *(mover+1);
4019 /* Un-mark the type as having been output already (because it
4020 hasn't been, really). Then call output_type to generate a
4021 Dwarf representation of it. */
4023 TREE_ASM_WRITTEN (type) = 0;
4024 output_type (type, containing_scope);
4026 /* Don't increment the loop counter in this case because we
4027 have shifted all of the subsequent pending types down one
4028 element in the pending_types_list array. */
4036 output_type (type, containing_scope)
4038 register tree containing_scope;
4040 if (type == 0 || type == error_mark_node)
4043 /* We are going to output a DIE to represent the unqualified version of
4044 of this type (i.e. without any const or volatile qualifiers) so get
4045 the main variant (i.e. the unqualified version) of this type now. */
4047 type = type_main_variant (type);
4049 if (TREE_ASM_WRITTEN (type))
4052 /* Don't generate any DIEs for this type now unless it is OK to do so
4053 (based upon what `type_ok_for_scope' tells us). */
4055 if (! type_ok_for_scope (type, containing_scope))
4061 switch (TREE_CODE (type))
4067 case REFERENCE_TYPE:
4068 /* For these types, all that is required is that we output a DIE
4069 (or a set of DIEs) to represent the "basis" type. */
4070 output_type (TREE_TYPE (type), containing_scope);
4074 /* This code is used for C++ pointer-to-data-member types. */
4075 /* Output a description of the relevant class type. */
4076 output_type (TYPE_OFFSET_BASETYPE (type), containing_scope);
4077 /* Output a description of the type of the object pointed to. */
4078 output_type (TREE_TYPE (type), containing_scope);
4079 /* Now output a DIE to represent this pointer-to-data-member type
4081 output_die (output_ptr_to_mbr_type_die, type);
4085 output_type (TYPE_DOMAIN (type), containing_scope);
4086 output_die (output_set_type_die, type);
4090 output_type (TREE_TYPE (type), containing_scope);
4091 abort (); /* No way to represent these in Dwarf yet! */
4095 /* Force out return type (in case it wasn't forced out already). */
4096 output_type (TREE_TYPE (type), containing_scope);
4097 output_die (output_subroutine_type_die, type);
4098 output_formal_types (type);
4099 end_sibling_chain ();
4103 /* Force out return type (in case it wasn't forced out already). */
4104 output_type (TREE_TYPE (type), containing_scope);
4105 output_die (output_subroutine_type_die, type);
4106 output_formal_types (type);
4107 end_sibling_chain ();
4111 if (TYPE_STRING_FLAG (type) && TREE_CODE(TREE_TYPE(type)) == CHAR_TYPE)
4113 output_type (TREE_TYPE (type), containing_scope);
4114 output_die (output_string_type_die, type);
4118 register tree element_type;
4120 element_type = TREE_TYPE (type);
4121 while (TREE_CODE (element_type) == ARRAY_TYPE)
4122 element_type = TREE_TYPE (element_type);
4124 output_type (element_type, containing_scope);
4125 output_die (output_array_type_die, type);
4132 case QUAL_UNION_TYPE:
4134 /* For a non-file-scope tagged type, we can always go ahead and
4135 output a Dwarf description of this type right now, even if
4136 the type in question is still incomplete, because if this
4137 local type *was* ever completed anywhere within its scope,
4138 that complete definition would already have been attached to
4139 this RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE or ENUMERAL_TYPE
4140 node by the time we reach this point. That's true because of the
4141 way the front-end does its processing of file-scope declarations (of
4142 functions and class types) within which other types might be
4143 nested. The C and C++ front-ends always gobble up such "local
4144 scope" things en-mass before they try to output *any* debugging
4145 information for any of the stuff contained inside them and thus,
4146 we get the benefit here of what is (in effect) a pre-resolution
4147 of forward references to tagged types in local scopes.
4149 Note however that for file-scope tagged types we cannot assume
4150 that such pre-resolution of forward references has taken place.
4151 A given file-scope tagged type may appear to be incomplete when
4152 we reach this point, but it may yet be given a full definition
4153 (at file-scope) later on during compilation. In order to avoid
4154 generating a premature (and possibly incorrect) set of Dwarf
4155 DIEs for such (as yet incomplete) file-scope tagged types, we
4156 generate nothing at all for as-yet incomplete file-scope tagged
4157 types here unless we are making our special "finalization" pass
4158 for file-scope things at the very end of compilation. At that
4159 time, we will certainly know as much about each file-scope tagged
4160 type as we are ever going to know, so at that point in time, we
4161 can safely generate correct Dwarf descriptions for these file-
4164 This loses for C++ nested types that are defined after their
4165 containing class, but I don't see a good way to fix it. I doubt
4166 many people will be using DWARF 1 for C++ in any case. */
4168 if (TYPE_SIZE (type) == 0 && TYPE_CONTEXT (type) == NULL && !finalizing)
4169 return; /* EARLY EXIT! Avoid setting TREE_ASM_WRITTEN. */
4171 /* Prevent infinite recursion in cases where the type of some
4172 member of this type is expressed in terms of this type itself. */
4174 TREE_ASM_WRITTEN (type) = 1;
4176 /* Output a DIE to represent the tagged type itself. */
4178 switch (TREE_CODE (type))
4181 output_die (output_enumeration_type_die, type);
4182 return; /* a special case -- nothing left to do so just return */
4185 output_die (output_structure_type_die, type);
4189 case QUAL_UNION_TYPE:
4190 output_die (output_union_type_die, type);
4194 abort (); /* Should never happen. */
4197 /* If this is not an incomplete type, output descriptions of
4198 each of its members.
4200 Note that as we output the DIEs necessary to represent the
4201 members of this record or union type, we will also be trying
4202 to output DIEs to represent the *types* of those members.
4203 However the `output_type' function (above) will specifically
4204 avoid generating type DIEs for member types *within* the list
4205 of member DIEs for this (containing) type execpt for those
4206 types (of members) which are explicitly marked as also being
4207 members of this (containing) type themselves. The g++ front-
4208 end can force any given type to be treated as a member of some
4209 other (containing) type by setting the TYPE_CONTEXT of the
4210 given (member) type to point to the TREE node representing the
4211 appropriate (containing) type.
4214 if (TYPE_SIZE (type))
4216 /* First output info about the base classes. */
4217 if (TYPE_BINFO (type) && TYPE_BINFO_BASETYPES (type))
4219 register tree bases = TYPE_BINFO_BASETYPES (type);
4220 register int n_bases = TREE_VEC_LENGTH (bases);
4223 for (i = 0; i < n_bases; i++)
4224 output_die (output_inheritance_die, TREE_VEC_ELT (bases, i));
4228 register tree normal_member;
4230 /* Now output info about the data members and type members. */
4232 for (normal_member = TYPE_FIELDS (type);
4234 normal_member = TREE_CHAIN (normal_member))
4235 output_decl (normal_member, type);
4239 register tree func_member;
4241 /* Now output info about the function members (if any). */
4243 for (func_member = TYPE_METHODS (type);
4245 func_member = TREE_CHAIN (func_member))
4246 output_decl (func_member, type);
4249 /* RECORD_TYPEs, UNION_TYPEs, and QUAL_UNION_TYPEs are themselves
4250 scopes (at least in C++) so we must now output any nested
4251 pending types which are local just to this type. */
4253 output_pending_types_for_scope (type);
4255 end_sibling_chain (); /* Terminate member chain. */
4266 break; /* No DIEs needed for fundamental types. */
4268 case LANG_TYPE: /* No Dwarf representation currently defined. */
4275 TREE_ASM_WRITTEN (type) = 1;
4279 output_tagged_type_instantiation (type)
4282 if (type == 0 || type == error_mark_node)
4285 /* We are going to output a DIE to represent the unqualified version of
4286 of this type (i.e. without any const or volatile qualifiers) so make
4287 sure that we have the main variant (i.e. the unqualified version) of
4290 assert (type == type_main_variant (type));
4292 assert (TREE_ASM_WRITTEN (type));
4294 switch (TREE_CODE (type))
4300 output_die (output_inlined_enumeration_type_die, type);
4304 output_die (output_inlined_structure_type_die, type);
4308 case QUAL_UNION_TYPE:
4309 output_die (output_inlined_union_type_die, type);
4313 abort (); /* Should never happen. */
4317 /* Output a TAG_lexical_block DIE followed by DIEs to represent all of
4318 the things which are local to the given block. */
4321 output_block (stmt, depth)
4325 register int must_output_die = 0;
4326 register tree origin;
4327 register enum tree_code origin_code;
4329 /* Ignore blocks never really used to make RTL. */
4331 if (! stmt || ! TREE_USED (stmt))
4334 /* Determine the "ultimate origin" of this block. This block may be an
4335 inlined instance of an inlined instance of inline function, so we
4336 have to trace all of the way back through the origin chain to find
4337 out what sort of node actually served as the original seed for the
4338 creation of the current block. */
4340 origin = block_ultimate_origin (stmt);
4341 origin_code = (origin != NULL) ? TREE_CODE (origin) : ERROR_MARK;
4343 /* Determine if we need to output any Dwarf DIEs at all to represent this
4346 if (origin_code == FUNCTION_DECL)
4347 /* The outer scopes for inlinings *must* always be represented. We
4348 generate TAG_inlined_subroutine DIEs for them. (See below.) */
4349 must_output_die = 1;
4352 /* In the case where the current block represents an inlining of the
4353 "body block" of an inline function, we must *NOT* output any DIE
4354 for this block because we have already output a DIE to represent
4355 the whole inlined function scope and the "body block" of any
4356 function doesn't really represent a different scope according to
4357 ANSI C rules. So we check here to make sure that this block does
4358 not represent a "body block inlining" before trying to set the
4359 `must_output_die' flag. */
4361 if (! is_body_block (origin ? origin : stmt))
4363 /* Determine if this block directly contains any "significant"
4364 local declarations which we will need to output DIEs for. */
4366 if (debug_info_level > DINFO_LEVEL_TERSE)
4367 /* We are not in terse mode so *any* local declaration counts
4368 as being a "significant" one. */
4369 must_output_die = (BLOCK_VARS (stmt) != NULL);
4374 /* We are in terse mode, so only local (nested) function
4375 definitions count as "significant" local declarations. */
4377 for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
4378 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
4380 must_output_die = 1;
4387 /* It would be a waste of space to generate a Dwarf TAG_lexical_block
4388 DIE for any block which contains no significant local declarations
4389 at all. Rather, in such cases we just call `output_decls_for_scope'
4390 so that any needed Dwarf info for any sub-blocks will get properly
4391 generated. Note that in terse mode, our definition of what constitutes
4392 a "significant" local declaration gets restricted to include only
4393 inlined function instances and local (nested) function definitions. */
4395 if (origin_code == FUNCTION_DECL && BLOCK_ABSTRACT (stmt))
4396 /* We don't care about an abstract inlined subroutine. */;
4397 else if (must_output_die)
4399 output_die ((origin_code == FUNCTION_DECL)
4400 ? output_inlined_subroutine_die
4401 : output_lexical_block_die,
4403 output_decls_for_scope (stmt, depth);
4404 end_sibling_chain ();
4407 output_decls_for_scope (stmt, depth);
4410 /* Output all of the decls declared within a given scope (also called
4411 a `binding contour') and (recursively) all of it's sub-blocks. */
4414 output_decls_for_scope (stmt, depth)
4418 /* Ignore blocks never really used to make RTL. */
4420 if (! stmt || ! TREE_USED (stmt))
4423 if (! BLOCK_ABSTRACT (stmt) && depth > 0)
4424 next_block_number++;
4426 /* Output the DIEs to represent all of the data objects, functions,
4427 typedefs, and tagged types declared directly within this block
4428 but not within any nested sub-blocks. */
4433 for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
4434 output_decl (decl, stmt);
4437 output_pending_types_for_scope (stmt);
4439 /* Output the DIEs to represent all sub-blocks (and the items declared
4440 therein) of this block. */
4443 register tree subblocks;
4445 for (subblocks = BLOCK_SUBBLOCKS (stmt);
4447 subblocks = BLOCK_CHAIN (subblocks))
4448 output_block (subblocks, depth + 1);
4452 /* Output Dwarf .debug information for a decl described by DECL. */
4455 output_decl (decl, containing_scope)
4457 register tree containing_scope;
4459 /* Make a note of the decl node we are going to be working on. We may
4460 need to give the user the source coordinates of where it appeared in
4461 case we notice (later on) that something about it looks screwy. */
4463 dwarf_last_decl = decl;
4465 if (TREE_CODE (decl) == ERROR_MARK)
4468 /* If a structure is declared within an initialization, e.g. as the
4469 operand of a sizeof, then it will not have a name. We don't want
4470 to output a DIE for it, as the tree nodes are in the temporary obstack */
4472 if ((TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
4473 || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE)
4474 && ((DECL_NAME (decl) == 0 && TYPE_NAME (TREE_TYPE (decl)) == 0)
4475 || (TYPE_FIELDS (TREE_TYPE (decl))
4476 && (TREE_CODE (TYPE_FIELDS (TREE_TYPE (decl))) == ERROR_MARK))))
4479 /* If this ..._DECL node is marked to be ignored, then ignore it.
4480 But don't ignore a function definition, since that would screw
4481 up our count of blocks, and that it turn will completely screw up the
4482 the labels we will reference in subsequent AT_low_pc and AT_high_pc
4483 attributes (for subsequent blocks). */
4485 if (DECL_IGNORED_P (decl) && TREE_CODE (decl) != FUNCTION_DECL)
4488 switch (TREE_CODE (decl))
4491 /* The individual enumerators of an enum type get output when we
4492 output the Dwarf representation of the relevant enum type itself. */
4496 /* If we are in terse mode, don't output any DIEs to represent
4497 mere function declarations. Also, if we are conforming
4498 to the DWARF version 1 specification, don't output DIEs for
4499 mere function declarations. */
4501 if (DECL_INITIAL (decl) == NULL_TREE)
4502 #if (DWARF_VERSION > 1)
4503 if (debug_info_level <= DINFO_LEVEL_TERSE)
4507 /* Before we describe the FUNCTION_DECL itself, make sure that we
4508 have described its return type. */
4510 output_type (TREE_TYPE (TREE_TYPE (decl)), containing_scope);
4512 /* If the following DIE will represent a function definition for a
4513 function with "extern" linkage, output a special "pubnames" DIE
4514 label just ahead of the actual DIE. A reference to this label
4515 was already generated in the .debug_pubnames section sub-entry
4516 for this function definition. */
4518 if (TREE_PUBLIC (decl))
4520 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4522 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
4523 ASM_OUTPUT_LABEL (asm_out_file, label);
4526 /* Now output a DIE to represent the function itself. */
4528 output_die (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)
4529 ? output_global_subroutine_die
4530 : output_local_subroutine_die,
4533 /* Now output descriptions of the arguments for this function.
4534 This gets (unnecessarily?) complex because of the fact that
4535 the DECL_ARGUMENT list for a FUNCTION_DECL doesn't indicate
4536 cases where there was a trailing `...' at the end of the formal
4537 parameter list. In order to find out if there was a trailing
4538 ellipsis or not, we must instead look at the type associated
4539 with the FUNCTION_DECL. This will be a node of type FUNCTION_TYPE.
4540 If the chain of type nodes hanging off of this FUNCTION_TYPE node
4541 ends with a void_type_node then there should *not* be an ellipsis
4544 /* In the case where we are describing a mere function declaration, all
4545 we need to do here (and all we *can* do here) is to describe
4546 the *types* of its formal parameters. */
4548 if (DECL_INITIAL (decl) == NULL_TREE)
4549 output_formal_types (TREE_TYPE (decl));
4552 /* Generate DIEs to represent all known formal parameters */
4554 register tree arg_decls = DECL_ARGUMENTS (decl);
4557 /* WARNING! Kludge zone ahead! Here we have a special
4558 hack for svr4 SDB compatibility. Instead of passing the
4559 current FUNCTION_DECL node as the second parameter (i.e.
4560 the `containing_scope' parameter) to `output_decl' (as
4561 we ought to) we instead pass a pointer to our own private
4562 fake_containing_scope node. That node is a RECORD_TYPE
4563 node which NO OTHER TYPE may ever actually be a member of.
4565 This pointer will ultimately get passed into `output_type'
4566 as its `containing_scope' parameter. `Output_type' will
4567 then perform its part in the hack... i.e. it will pend
4568 the type of the formal parameter onto the pending_types
4569 list. Later on, when we are done generating the whole
4570 sequence of formal parameter DIEs for this function
4571 definition, we will un-pend all previously pended types
4572 of formal parameters for this function definition.
4574 This whole kludge prevents any type DIEs from being
4575 mixed in with the formal parameter DIEs. That's good
4576 because svr4 SDB believes that the list of formal
4577 parameter DIEs for a function ends wherever the first
4578 non-formal-parameter DIE appears. Thus, we have to
4579 keep the formal parameter DIEs segregated. They must
4580 all appear (consecutively) at the start of the list of
4581 children for the DIE representing the function definition.
4582 Then (and only then) may we output any additional DIEs
4583 needed to represent the types of these formal parameters.
4587 When generating DIEs, generate the unspecified_parameters
4588 DIE instead if we come across the arg "__builtin_va_alist"
4591 for (parm = arg_decls; parm; parm = TREE_CHAIN (parm))
4592 if (TREE_CODE (parm) == PARM_DECL)
4594 if (DECL_NAME(parm) &&
4595 !strcmp(IDENTIFIER_POINTER(DECL_NAME(parm)),
4596 "__builtin_va_alist") )
4597 output_die (output_unspecified_parameters_die, decl);
4599 output_decl (parm, fake_containing_scope);
4603 Now that we have finished generating all of the DIEs to
4604 represent the formal parameters themselves, force out
4605 any DIEs needed to represent their types. We do this
4606 simply by un-pending all previously pended types which
4607 can legitimately go into the chain of children DIEs for
4608 the current FUNCTION_DECL.
4611 output_pending_types_for_scope (decl);
4614 Decide whether we need a unspecified_parameters DIE at the end.
4615 There are 2 more cases to do this for:
4616 1) the ansi ... declaration - this is detectable when the end
4617 of the arg list is not a void_type_node
4618 2) an unprototyped function declaration (not a definition). This
4619 just means that we have no info about the parameters at all.
4623 register tree fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (decl));
4627 /* this is the prototyped case, check for ... */
4628 if (TREE_VALUE (tree_last (fn_arg_types)) != void_type_node)
4629 output_die (output_unspecified_parameters_die, decl);
4633 /* this is unprototyped, check for undefined (just declaration) */
4634 if (!DECL_INITIAL (decl))
4635 output_die (output_unspecified_parameters_die, decl);
4640 /* Output Dwarf info for all of the stuff within the body of the
4641 function (if it has one - it may be just a declaration). */
4644 register tree outer_scope = DECL_INITIAL (decl);
4646 if (outer_scope && TREE_CODE (outer_scope) != ERROR_MARK)
4648 /* Note that here, `outer_scope' is a pointer to the outermost
4649 BLOCK node created to represent a function.
4650 This outermost BLOCK actually represents the outermost
4651 binding contour for the function, i.e. the contour in which
4652 the function's formal parameters and labels get declared.
4654 Curiously, it appears that the front end doesn't actually
4655 put the PARM_DECL nodes for the current function onto the
4656 BLOCK_VARS list for this outer scope. (They are strung
4657 off of the DECL_ARGUMENTS list for the function instead.)
4658 The BLOCK_VARS list for the `outer_scope' does provide us
4659 with a list of the LABEL_DECL nodes for the function however,
4660 and we output DWARF info for those here.
4662 Just within the `outer_scope' there will be a BLOCK node
4663 representing the function's outermost pair of curly braces,
4664 and any blocks used for the base and member initializers of
4665 a C++ constructor function. */
4667 output_decls_for_scope (outer_scope, 0);
4669 /* Finally, force out any pending types which are local to the
4670 outermost block of this function definition. These will
4671 all have a TYPE_CONTEXT which points to the FUNCTION_DECL
4674 output_pending_types_for_scope (decl);
4678 /* Generate a terminator for the list of stuff `owned' by this
4681 end_sibling_chain ();
4686 /* If we are in terse mode, don't generate any DIEs to represent
4687 any actual typedefs. Note that even when we are in terse mode,
4688 we must still output DIEs to represent those tagged types which
4689 are used (directly or indirectly) in the specification of either
4690 a return type or a formal parameter type of some function. */
4692 if (debug_info_level <= DINFO_LEVEL_TERSE)
4693 if (DECL_NAME (decl) != NULL
4694 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
4697 /* In the special case of a null-named TYPE_DECL node (representing
4698 the declaration of some type tag), if the given TYPE_DECL is
4699 marked as having been instantiated from some other (original)
4700 TYPE_DECL node (e.g. one which was generated within the original
4701 definition of an inline function) we have to generate a special
4702 (abbreviated) TAG_structure_type, TAG_union_type, or
4703 TAG_enumeration-type DIE here. */
4705 if (! DECL_NAME (decl) && DECL_ABSTRACT_ORIGIN (decl))
4707 output_tagged_type_instantiation (TREE_TYPE (decl));
4711 output_type (TREE_TYPE (decl), containing_scope);
4713 /* Note that unlike the gcc front end (which generates a NULL named
4714 TYPE_DECL node for each complete tagged type, each array type,
4715 and each function type node created) the g++ front end generates
4716 a *named* TYPE_DECL node for each tagged type node created.
4717 These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
4718 generate a DW_TAG_typedef DIE for them. */
4719 if (DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl))
4720 /* Output a DIE to represent the typedef itself. */
4721 output_die (output_typedef_die, decl);
4725 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4726 output_die (output_label_die, decl);
4730 /* If we are conforming to the DWARF version 1 specification, don't
4731 generated any DIEs to represent mere external object declarations. */
4733 #if (DWARF_VERSION <= 1)
4734 if (DECL_EXTERNAL (decl) && ! TREE_PUBLIC (decl))
4738 /* If we are in terse mode, don't generate any DIEs to represent
4739 any variable declarations or definitions. */
4741 if (debug_info_level <= DINFO_LEVEL_TERSE)
4744 /* Output any DIEs that are needed to specify the type of this data
4747 output_type (TREE_TYPE (decl), containing_scope);
4749 /* If the following DIE will represent a data object definition for a
4750 data object with "extern" linkage, output a special "pubnames" DIE
4751 label just ahead of the actual DIE. A reference to this label
4752 was already generated in the .debug_pubnames section sub-entry
4753 for this data object definition. */
4755 if (TREE_PUBLIC (decl) && ! DECL_ABSTRACT (decl))
4757 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4759 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
4760 ASM_OUTPUT_LABEL (asm_out_file, label);
4763 /* Now output the DIE to represent the data object itself. This gets
4764 complicated because of the possibility that the VAR_DECL really
4765 represents an inlined instance of a formal parameter for an inline
4769 register void (*func) ();
4770 register tree origin = decl_ultimate_origin (decl);
4772 if (origin != NULL && TREE_CODE (origin) == PARM_DECL)
4773 func = output_formal_parameter_die;
4776 if (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
4777 func = output_global_variable_die;
4779 func = output_local_variable_die;
4781 output_die (func, decl);
4786 /* Ignore the nameless fields that are used to skip bits. */
4787 if (DECL_NAME (decl) != 0)
4789 output_type (member_declared_type (decl), containing_scope);
4790 output_die (output_member_die, decl);
4795 /* Force out the type of this formal, if it was not forced out yet.
4796 Note that here we can run afowl of a bug in "classic" svr4 SDB.
4797 It should be able to grok the presence of type DIEs within a list
4798 of TAG_formal_parameter DIEs, but it doesn't. */
4800 output_type (TREE_TYPE (decl), containing_scope);
4801 output_die (output_formal_parameter_die, decl);
4810 dwarfout_file_scope_decl (decl, set_finalizing)
4812 register int set_finalizing;
4814 if (TREE_CODE (decl) == ERROR_MARK)
4817 /* If this ..._DECL node is marked to be ignored, then ignore it. We
4818 gotta hope that the node in question doesn't represent a function
4819 definition. If it does, then totally ignoring it is bound to screw
4820 up our count of blocks, and that it turn will completely screw up the
4821 the labels we will reference in subsequent AT_low_pc and AT_high_pc
4822 attributes (for subsequent blocks). (It's too bad that BLOCK nodes
4823 don't carry their own sequence numbers with them!) */
4825 if (DECL_IGNORED_P (decl))
4827 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
4832 switch (TREE_CODE (decl))
4836 /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of
4837 a builtin function. Explicit programmer-supplied declarations of
4838 these same functions should NOT be ignored however. */
4840 if (DECL_EXTERNAL (decl) && DECL_FUNCTION_CODE (decl))
4843 /* What we would really like to do here is to filter out all mere
4844 file-scope declarations of file-scope functions which are never
4845 referenced later within this translation unit (and keep all of
4846 ones that *are* referenced later on) but we aren't clairvoyant,
4847 so we have no idea which functions will be referenced in the
4848 future (i.e. later on within the current translation unit).
4849 So here we just ignore all file-scope function declarations
4850 which are not also definitions. If and when the debugger needs
4851 to know something about these functions, it wil have to hunt
4852 around and find the DWARF information associated with the
4853 *definition* of the function.
4855 Note that we can't just check `DECL_EXTERNAL' to find out which
4856 FUNCTION_DECL nodes represent definitions and which ones represent
4857 mere declarations. We have to check `DECL_INITIAL' instead. That's
4858 because the C front-end supports some weird semantics for "extern
4859 inline" function definitions. These can get inlined within the
4860 current translation unit (an thus, we need to generate DWARF info
4861 for their abstract instances so that the DWARF info for the
4862 concrete inlined instances can have something to refer to) but
4863 the compiler never generates any out-of-lines instances of such
4864 things (despite the fact that they *are* definitions). The
4865 important point is that the C front-end marks these "extern inline"
4866 functions as DECL_EXTERNAL, but we need to generate DWARF for them
4869 Note that the C++ front-end also plays some similar games for inline
4870 function definitions appearing within include files which also
4871 contain `#pragma interface' pragmas. */
4873 if (DECL_INITIAL (decl) == NULL_TREE)
4876 if (TREE_PUBLIC (decl)
4877 && ! DECL_EXTERNAL (decl)
4878 && ! DECL_ABSTRACT (decl))
4880 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4882 /* Output a .debug_pubnames entry for a public function
4883 defined in this compilation unit. */
4885 fputc ('\n', asm_out_file);
4886 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
4887 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
4888 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
4889 ASM_OUTPUT_DWARF_STRING (asm_out_file,
4890 IDENTIFIER_POINTER (DECL_NAME (decl)));
4891 ASM_OUTPUT_POP_SECTION (asm_out_file);
4898 /* Ignore this VAR_DECL if it refers to a file-scope extern data
4899 object declaration and if the declaration was never even
4900 referenced from within this entire compilation unit. We
4901 suppress these DIEs in order to save space in the .debug section
4902 (by eliminating entries which are probably useless). Note that
4903 we must not suppress block-local extern declarations (whether
4904 used or not) because that would screw-up the debugger's name
4905 lookup mechanism and cause it to miss things which really ought
4906 to be in scope at a given point. */
4908 if (DECL_EXTERNAL (decl) && !TREE_USED (decl))
4911 if (TREE_PUBLIC (decl)
4912 && ! DECL_EXTERNAL (decl)
4913 && GET_CODE (DECL_RTL (decl)) == MEM
4914 && ! DECL_ABSTRACT (decl))
4916 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4918 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4920 /* Output a .debug_pubnames entry for a public variable
4921 defined in this compilation unit. */
4923 fputc ('\n', asm_out_file);
4924 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
4925 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
4926 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
4927 ASM_OUTPUT_DWARF_STRING (asm_out_file,
4928 IDENTIFIER_POINTER (DECL_NAME (decl)));
4929 ASM_OUTPUT_POP_SECTION (asm_out_file);
4932 if (DECL_INITIAL (decl) == NULL)
4934 /* Output a .debug_aranges entry for a public variable
4935 which is tentatively defined in this compilation unit. */
4937 fputc ('\n', asm_out_file);
4938 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
4939 ASM_OUTPUT_DWARF_ADDR (asm_out_file,
4940 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
4941 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
4942 (unsigned) int_size_in_bytes (TREE_TYPE (decl)));
4943 ASM_OUTPUT_POP_SECTION (asm_out_file);
4947 /* If we are in terse mode, don't generate any DIEs to represent
4948 any variable declarations or definitions. */
4950 if (debug_info_level <= DINFO_LEVEL_TERSE)
4956 /* Don't bother trying to generate any DIEs to represent any of the
4957 normal built-in types for the language we are compiling, except
4958 in cases where the types in question are *not* DWARF fundamental
4959 types. We make an exception in the case of non-fundamental types
4960 for the sake of objective C (and perhaps C++) because the GNU
4961 front-ends for these languages may in fact create certain "built-in"
4962 types which are (for example) RECORD_TYPEs. In such cases, we
4963 really need to output these (non-fundamental) types because other
4964 DIEs may contain references to them. */
4966 if (DECL_SOURCE_LINE (decl) == 0
4967 && type_is_fundamental (TREE_TYPE (decl)))
4970 /* If we are in terse mode, don't generate any DIEs to represent
4971 any actual typedefs. Note that even when we are in terse mode,
4972 we must still output DIEs to represent those tagged types which
4973 are used (directly or indirectly) in the specification of either
4974 a return type or a formal parameter type of some function. */
4976 if (debug_info_level <= DINFO_LEVEL_TERSE)
4977 if (DECL_NAME (decl) != NULL
4978 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
4987 fputc ('\n', asm_out_file);
4988 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
4989 finalizing = set_finalizing;
4990 output_decl (decl, NULL_TREE);
4992 /* NOTE: The call above to `output_decl' may have caused one or more
4993 file-scope named types (i.e. tagged types) to be placed onto the
4994 pending_types_list. We have to get those types off of that list
4995 at some point, and this is the perfect time to do it. If we didn't
4996 take them off now, they might still be on the list when cc1 finally
4997 exits. That might be OK if it weren't for the fact that when we put
4998 types onto the pending_types_list, we set the TREE_ASM_WRITTEN flag
4999 for these types, and that causes them never to be output unless
5000 `output_pending_types_for_scope' takes them off of the list and un-sets
5001 their TREE_ASM_WRITTEN flags. */
5003 output_pending_types_for_scope (NULL_TREE);
5005 /* The above call should have totally emptied the pending_types_list. */
5007 assert (pending_types == 0);
5009 ASM_OUTPUT_POP_SECTION (asm_out_file);
5011 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
5012 current_funcdef_number++;
5015 /* Output a marker (i.e. a label) for the beginning of the generated code
5016 for a lexical block. */
5019 dwarfout_begin_block (blocknum)
5020 register unsigned blocknum;
5022 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5024 function_section (current_function_decl);
5025 sprintf (label, BLOCK_BEGIN_LABEL_FMT, blocknum);
5026 ASM_OUTPUT_LABEL (asm_out_file, label);
5029 /* Output a marker (i.e. a label) for the end of the generated code
5030 for a lexical block. */
5033 dwarfout_end_block (blocknum)
5034 register unsigned blocknum;
5036 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5038 function_section (current_function_decl);
5039 sprintf (label, BLOCK_END_LABEL_FMT, blocknum);
5040 ASM_OUTPUT_LABEL (asm_out_file, label);
5043 /* Output a marker (i.e. a label) at a point in the assembly code which
5044 corresponds to a given source level label. */
5047 dwarfout_label (insn)
5050 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5052 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5054 function_section (current_function_decl);
5055 sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
5056 (unsigned) INSN_UID (insn));
5057 ASM_OUTPUT_LABEL (asm_out_file, label);
5061 /* Output a marker (i.e. a label) for the point in the generated code where
5062 the real body of the function begins (after parameters have been moved
5063 to their home locations). */
5066 dwarfout_begin_function ()
5068 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5070 function_section (current_function_decl);
5071 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
5072 ASM_OUTPUT_LABEL (asm_out_file, label);
5075 /* Output a marker (i.e. a label) for the point in the generated code where
5076 the real body of the function ends (just before the epilogue code). */
5079 dwarfout_end_function ()
5081 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5083 function_section (current_function_decl);
5084 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
5085 ASM_OUTPUT_LABEL (asm_out_file, label);
5088 /* Output a marker (i.e. a label) for the absolute end of the generated code
5089 for a function definition. This gets called *after* the epilogue code
5090 has been generated. */
5093 dwarfout_end_epilogue ()
5095 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5097 /* Output a label to mark the endpoint of the code generated for this
5100 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
5101 ASM_OUTPUT_LABEL (asm_out_file, label);
5105 shuffle_filename_entry (new_zeroth)
5106 register filename_entry *new_zeroth;
5108 filename_entry temp_entry;
5109 register filename_entry *limit_p;
5110 register filename_entry *move_p;
5112 if (new_zeroth == &filename_table[0])
5115 temp_entry = *new_zeroth;
5117 /* Shift entries up in the table to make room at [0]. */
5119 limit_p = &filename_table[0];
5120 for (move_p = new_zeroth; move_p > limit_p; move_p--)
5121 *move_p = *(move_p-1);
5123 /* Install the found entry at [0]. */
5125 filename_table[0] = temp_entry;
5128 /* Create a new (string) entry for the .debug_sfnames section. */
5131 generate_new_sfname_entry ()
5133 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5135 fputc ('\n', asm_out_file);
5136 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
5137 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, filename_table[0].number);
5138 ASM_OUTPUT_LABEL (asm_out_file, label);
5139 ASM_OUTPUT_DWARF_STRING (asm_out_file,
5140 filename_table[0].name
5141 ? filename_table[0].name
5143 ASM_OUTPUT_POP_SECTION (asm_out_file);
5146 /* Lookup a filename (in the list of filenames that we know about here in
5147 dwarfout.c) and return its "index". The index of each (known) filename
5148 is just a unique number which is associated with only that one filename.
5149 We need such numbers for the sake of generating labels (in the
5150 .debug_sfnames section) and references to those unique labels (in the
5151 .debug_srcinfo and .debug_macinfo sections).
5153 If the filename given as an argument is not found in our current list,
5154 add it to the list and assign it the next available unique index number.
5156 Whatever we do (i.e. whether we find a pre-existing filename or add a new
5157 one), we shuffle the filename found (or added) up to the zeroth entry of
5158 our list of filenames (which is always searched linearly). We do this so
5159 as to optimize the most common case for these filename lookups within
5160 dwarfout.c. The most common case by far is the case where we call
5161 lookup_filename to lookup the very same filename that we did a lookup
5162 on the last time we called lookup_filename. We make sure that this
5163 common case is fast because such cases will constitute 99.9% of the
5164 lookups we ever do (in practice).
5166 If we add a new filename entry to our table, we go ahead and generate
5167 the corresponding entry in the .debug_sfnames section right away.
5168 Doing so allows us to avoid tickling an assembler bug (present in some
5169 m68k assemblers) which yields assembly-time errors in cases where the
5170 difference of two label addresses is taken and where the two labels
5171 are in a section *other* than the one where the difference is being
5172 calculated, and where at least one of the two symbol references is a
5173 forward reference. (This bug could be tickled by our .debug_srcinfo
5174 entries if we don't output their corresponding .debug_sfnames entries
5178 lookup_filename (file_name)
5181 register filename_entry *search_p;
5182 register filename_entry *limit_p = &filename_table[ft_entries];
5184 for (search_p = filename_table; search_p < limit_p; search_p++)
5185 if (!strcmp (file_name, search_p->name))
5187 /* When we get here, we have found the filename that we were
5188 looking for in the filename_table. Now we want to make sure
5189 that it gets moved to the zero'th entry in the table (if it
5190 is not already there) so that subsequent attempts to find the
5191 same filename will find it as quickly as possible. */
5193 shuffle_filename_entry (search_p);
5194 return filename_table[0].number;
5197 /* We come here whenever we have a new filename which is not registered
5198 in the current table. Here we add it to the table. */
5200 /* Prepare to add a new table entry by making sure there is enough space
5201 in the table to do so. If not, expand the current table. */
5203 if (ft_entries == ft_entries_allocated)
5205 ft_entries_allocated += FT_ENTRIES_INCREMENT;
5207 = (filename_entry *)
5208 xrealloc (filename_table,
5209 ft_entries_allocated * sizeof (filename_entry));
5212 /* Initially, add the new entry at the end of the filename table. */
5214 filename_table[ft_entries].number = ft_entries;
5215 filename_table[ft_entries].name = xstrdup (file_name);
5217 /* Shuffle the new entry into filename_table[0]. */
5219 shuffle_filename_entry (&filename_table[ft_entries]);
5221 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5222 generate_new_sfname_entry ();
5225 return filename_table[0].number;
5229 generate_srcinfo_entry (line_entry_num, files_entry_num)
5230 unsigned line_entry_num;
5231 unsigned files_entry_num;
5233 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5235 fputc ('\n', asm_out_file);
5236 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
5237 sprintf (label, LINE_ENTRY_LABEL_FMT, line_entry_num);
5238 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, LINE_BEGIN_LABEL);
5239 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, files_entry_num);
5240 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, SFNAMES_BEGIN_LABEL);
5241 ASM_OUTPUT_POP_SECTION (asm_out_file);
5245 dwarfout_line (filename, line)
5246 register char *filename;
5247 register unsigned line;
5249 if (debug_info_level >= DINFO_LEVEL_NORMAL
5250 /* We can't emit line number info for functions in separate sections,
5251 because the assembler can't subtract labels in different sections. */
5252 && DECL_SECTION_NAME (current_function_decl) == NULL_TREE)
5254 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5255 static unsigned last_line_entry_num = 0;
5256 static unsigned prev_file_entry_num = (unsigned) -1;
5257 register unsigned this_file_entry_num = lookup_filename (filename);
5259 function_section (current_function_decl);
5260 sprintf (label, LINE_CODE_LABEL_FMT, ++last_line_entry_num);
5261 ASM_OUTPUT_LABEL (asm_out_file, label);
5263 fputc ('\n', asm_out_file);
5264 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
5266 if (this_file_entry_num != prev_file_entry_num)
5268 char line_entry_label[MAX_ARTIFICIAL_LABEL_BYTES];
5270 sprintf (line_entry_label, LINE_ENTRY_LABEL_FMT, last_line_entry_num);
5271 ASM_OUTPUT_LABEL (asm_out_file, line_entry_label);
5275 register char *tail = rindex (filename, '/');
5281 fprintf (asm_out_file, "\t%s\t%u\t%s %s:%u\n",
5282 UNALIGNED_INT_ASM_OP, line, ASM_COMMENT_START,
5284 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
5285 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, TEXT_BEGIN_LABEL);
5286 ASM_OUTPUT_POP_SECTION (asm_out_file);
5288 if (this_file_entry_num != prev_file_entry_num)
5289 generate_srcinfo_entry (last_line_entry_num, this_file_entry_num);
5290 prev_file_entry_num = this_file_entry_num;
5294 /* Generate an entry in the .debug_macinfo section. */
5297 generate_macinfo_entry (type_and_offset, string)
5298 register char *type_and_offset;
5299 register char *string;
5301 fputc ('\n', asm_out_file);
5302 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
5303 fprintf (asm_out_file, "\t%s\t%s\n", UNALIGNED_INT_ASM_OP, type_and_offset);
5304 ASM_OUTPUT_DWARF_STRING (asm_out_file, string);
5305 ASM_OUTPUT_POP_SECTION (asm_out_file);
5309 dwarfout_start_new_source_file (filename)
5310 register char *filename;
5312 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5313 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*3];
5315 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, lookup_filename (filename));
5316 sprintf (type_and_offset, "0x%08x+%s-%s",
5317 ((unsigned) MACINFO_start << 24), label, SFNAMES_BEGIN_LABEL);
5318 generate_macinfo_entry (type_and_offset, "");
5322 dwarfout_resume_previous_source_file (lineno)
5323 register unsigned lineno;
5325 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
5327 sprintf (type_and_offset, "0x%08x+%u",
5328 ((unsigned) MACINFO_resume << 24), lineno);
5329 generate_macinfo_entry (type_and_offset, "");
5332 /* Called from check_newline in c-parse.y. The `buffer' parameter
5333 contains the tail part of the directive line, i.e. the part which
5334 is past the initial whitespace, #, whitespace, directive-name,
5338 dwarfout_define (lineno, buffer)
5339 register unsigned lineno;
5340 register char *buffer;
5342 static int initialized = 0;
5343 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
5347 dwarfout_start_new_source_file (primary_filename);
5350 sprintf (type_and_offset, "0x%08x+%u",
5351 ((unsigned) MACINFO_define << 24), lineno);
5352 generate_macinfo_entry (type_and_offset, buffer);
5355 /* Called from check_newline in c-parse.y. The `buffer' parameter
5356 contains the tail part of the directive line, i.e. the part which
5357 is past the initial whitespace, #, whitespace, directive-name,
5361 dwarfout_undef (lineno, buffer)
5362 register unsigned lineno;
5363 register char *buffer;
5365 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
5367 sprintf (type_and_offset, "0x%08x+%u",
5368 ((unsigned) MACINFO_undef << 24), lineno);
5369 generate_macinfo_entry (type_and_offset, buffer);
5372 /* Set up for Dwarf output at the start of compilation. */
5375 dwarfout_init (asm_out_file, main_input_filename)
5376 register FILE *asm_out_file;
5377 register char *main_input_filename;
5379 /* Remember the name of the primary input file. */
5381 primary_filename = main_input_filename;
5383 /* Allocate the initial hunk of the pending_sibling_stack. */
5385 pending_sibling_stack
5387 xmalloc (PENDING_SIBLINGS_INCREMENT * sizeof (unsigned));
5388 pending_siblings_allocated = PENDING_SIBLINGS_INCREMENT;
5389 pending_siblings = 1;
5391 /* Allocate the initial hunk of the filename_table. */
5394 = (filename_entry *)
5395 xmalloc (FT_ENTRIES_INCREMENT * sizeof (filename_entry));
5396 ft_entries_allocated = FT_ENTRIES_INCREMENT;
5399 /* Allocate the initial hunk of the pending_types_list. */
5402 = (tree *) xmalloc (PENDING_TYPES_INCREMENT * sizeof (tree));
5403 pending_types_allocated = PENDING_TYPES_INCREMENT;
5406 /* Create an artificial RECORD_TYPE node which we can use in our hack
5407 to get the DIEs representing types of formal parameters to come out
5408 only *after* the DIEs for the formal parameters themselves. */
5410 fake_containing_scope = make_node (RECORD_TYPE);
5412 /* Output a starting label for the .text section. */
5414 fputc ('\n', asm_out_file);
5415 ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
5416 ASM_OUTPUT_LABEL (asm_out_file, TEXT_BEGIN_LABEL);
5417 ASM_OUTPUT_POP_SECTION (asm_out_file);
5419 /* Output a starting label for the .data section. */
5421 fputc ('\n', asm_out_file);
5422 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
5423 ASM_OUTPUT_LABEL (asm_out_file, DATA_BEGIN_LABEL);
5424 ASM_OUTPUT_POP_SECTION (asm_out_file);
5426 #if 0 /* GNU C doesn't currently use .data1. */
5427 /* Output a starting label for the .data1 section. */
5429 fputc ('\n', asm_out_file);
5430 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
5431 ASM_OUTPUT_LABEL (asm_out_file, DATA1_BEGIN_LABEL);
5432 ASM_OUTPUT_POP_SECTION (asm_out_file);
5435 /* Output a starting label for the .rodata section. */
5437 fputc ('\n', asm_out_file);
5438 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
5439 ASM_OUTPUT_LABEL (asm_out_file, RODATA_BEGIN_LABEL);
5440 ASM_OUTPUT_POP_SECTION (asm_out_file);
5442 #if 0 /* GNU C doesn't currently use .rodata1. */
5443 /* Output a starting label for the .rodata1 section. */
5445 fputc ('\n', asm_out_file);
5446 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
5447 ASM_OUTPUT_LABEL (asm_out_file, RODATA1_BEGIN_LABEL);
5448 ASM_OUTPUT_POP_SECTION (asm_out_file);
5451 /* Output a starting label for the .bss section. */
5453 fputc ('\n', asm_out_file);
5454 ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
5455 ASM_OUTPUT_LABEL (asm_out_file, BSS_BEGIN_LABEL);
5456 ASM_OUTPUT_POP_SECTION (asm_out_file);
5458 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5460 /* Output a starting label and an initial (compilation directory)
5461 entry for the .debug_sfnames section. The starting label will be
5462 referenced by the initial entry in the .debug_srcinfo section. */
5464 fputc ('\n', asm_out_file);
5465 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
5466 ASM_OUTPUT_LABEL (asm_out_file, SFNAMES_BEGIN_LABEL);
5469 register unsigned len;
5470 register char *dirname;
5474 pfatal_with_name ("getpwd");
5476 dirname = (char *) xmalloc (len + 2);
5478 strcpy (dirname, pwd);
5479 strcpy (dirname + len, "/");
5480 ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname);
5483 ASM_OUTPUT_POP_SECTION (asm_out_file);
5485 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
5487 /* Output a starting label for the .debug_macinfo section. This
5488 label will be referenced by the AT_mac_info attribute in the
5489 TAG_compile_unit DIE. */
5491 fputc ('\n', asm_out_file);
5492 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
5493 ASM_OUTPUT_LABEL (asm_out_file, MACINFO_BEGIN_LABEL);
5494 ASM_OUTPUT_POP_SECTION (asm_out_file);
5497 /* Generate the initial entry for the .line section. */
5499 fputc ('\n', asm_out_file);
5500 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
5501 ASM_OUTPUT_LABEL (asm_out_file, LINE_BEGIN_LABEL);
5502 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, LINE_END_LABEL, LINE_BEGIN_LABEL);
5503 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
5504 ASM_OUTPUT_POP_SECTION (asm_out_file);
5506 /* Generate the initial entry for the .debug_srcinfo section. */
5508 fputc ('\n', asm_out_file);
5509 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
5510 ASM_OUTPUT_LABEL (asm_out_file, SRCINFO_BEGIN_LABEL);
5511 ASM_OUTPUT_DWARF_ADDR (asm_out_file, LINE_BEGIN_LABEL);
5512 ASM_OUTPUT_DWARF_ADDR (asm_out_file, SFNAMES_BEGIN_LABEL);
5513 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
5514 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_END_LABEL);
5515 #ifdef DWARF_TIMESTAMPS
5516 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, time (NULL));
5518 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
5520 ASM_OUTPUT_POP_SECTION (asm_out_file);
5522 /* Generate the initial entry for the .debug_pubnames section. */
5524 fputc ('\n', asm_out_file);
5525 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
5526 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
5527 ASM_OUTPUT_POP_SECTION (asm_out_file);
5529 /* Generate the initial entry for the .debug_aranges section. */
5531 fputc ('\n', asm_out_file);
5532 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
5533 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
5534 ASM_OUTPUT_POP_SECTION (asm_out_file);
5537 /* Setup first DIE number == 1. */
5538 NEXT_DIE_NUM = next_unused_dienum++;
5540 /* Generate the initial DIE for the .debug section. Note that the
5541 (string) value given in the AT_name attribute of the TAG_compile_unit
5542 DIE will (typically) be a relative pathname and that this pathname
5543 should be taken as being relative to the directory from which the
5544 compiler was invoked when the given (base) source file was compiled. */
5546 fputc ('\n', asm_out_file);
5547 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
5548 ASM_OUTPUT_LABEL (asm_out_file, DEBUG_BEGIN_LABEL);
5549 output_die (output_compile_unit_die, main_input_filename);
5550 ASM_OUTPUT_POP_SECTION (asm_out_file);
5552 fputc ('\n', asm_out_file);
5555 /* Output stuff that dwarf requires at the end of every file. */
5560 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5562 fputc ('\n', asm_out_file);
5563 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
5565 /* Mark the end of the chain of siblings which represent all file-scope
5566 declarations in this compilation unit. */
5568 /* The (null) DIE which represents the terminator for the (sibling linked)
5569 list of file-scope items is *special*. Normally, we would just call
5570 end_sibling_chain at this point in order to output a word with the
5571 value `4' and that word would act as the terminator for the list of
5572 DIEs describing file-scope items. Unfortunately, if we were to simply
5573 do that, the label that would follow this DIE in the .debug section
5574 (i.e. `..D2') would *not* be properly aligned (as it must be on some
5575 machines) to a 4 byte boundary.
5577 In order to force the label `..D2' to get aligned to a 4 byte boundary,
5578 the trick used is to insert extra (otherwise useless) padding bytes
5579 into the (null) DIE that we know must precede the ..D2 label in the
5580 .debug section. The amount of padding required can be anywhere between
5581 0 and 3 bytes. The length word at the start of this DIE (i.e. the one
5582 with the padding) would normally contain the value 4, but now it will
5583 also have to include the padding bytes, so it will instead have some
5584 value in the range 4..7.
5586 Fortunately, the rules of Dwarf say that any DIE whose length word
5587 contains *any* value less than 8 should be treated as a null DIE, so
5588 this trick works out nicely. Clever, eh? Don't give me any credit
5589 (or blame). I didn't think of this scheme. I just conformed to it.
5592 output_die (output_padded_null_die, (void *) 0);
5595 sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
5596 ASM_OUTPUT_LABEL (asm_out_file, label); /* should be ..D2 */
5597 ASM_OUTPUT_POP_SECTION (asm_out_file);
5599 /* Output a terminator label for the .text section. */
5601 fputc ('\n', asm_out_file);
5602 ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
5603 ASM_OUTPUT_LABEL (asm_out_file, TEXT_END_LABEL);
5604 ASM_OUTPUT_POP_SECTION (asm_out_file);
5606 /* Output a terminator label for the .data section. */
5608 fputc ('\n', asm_out_file);
5609 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
5610 ASM_OUTPUT_LABEL (asm_out_file, DATA_END_LABEL);
5611 ASM_OUTPUT_POP_SECTION (asm_out_file);
5613 #if 0 /* GNU C doesn't currently use .data1. */
5614 /* Output a terminator label for the .data1 section. */
5616 fputc ('\n', asm_out_file);
5617 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
5618 ASM_OUTPUT_LABEL (asm_out_file, DATA1_END_LABEL);
5619 ASM_OUTPUT_POP_SECTION (asm_out_file);
5622 /* Output a terminator label for the .rodata section. */
5624 fputc ('\n', asm_out_file);
5625 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
5626 ASM_OUTPUT_LABEL (asm_out_file, RODATA_END_LABEL);
5627 ASM_OUTPUT_POP_SECTION (asm_out_file);
5629 #if 0 /* GNU C doesn't currently use .rodata1. */
5630 /* Output a terminator label for the .rodata1 section. */
5632 fputc ('\n', asm_out_file);
5633 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
5634 ASM_OUTPUT_LABEL (asm_out_file, RODATA1_END_LABEL);
5635 ASM_OUTPUT_POP_SECTION (asm_out_file);
5638 /* Output a terminator label for the .bss section. */
5640 fputc ('\n', asm_out_file);
5641 ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
5642 ASM_OUTPUT_LABEL (asm_out_file, BSS_END_LABEL);
5643 ASM_OUTPUT_POP_SECTION (asm_out_file);
5645 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5647 /* Output a terminating entry for the .line section. */
5649 fputc ('\n', asm_out_file);
5650 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
5651 ASM_OUTPUT_LABEL (asm_out_file, LINE_LAST_ENTRY_LABEL);
5652 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5653 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
5654 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
5655 ASM_OUTPUT_LABEL (asm_out_file, LINE_END_LABEL);
5656 ASM_OUTPUT_POP_SECTION (asm_out_file);
5658 /* Output a terminating entry for the .debug_srcinfo section. */
5660 fputc ('\n', asm_out_file);
5661 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
5662 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
5663 LINE_LAST_ENTRY_LABEL, LINE_BEGIN_LABEL);
5664 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
5665 ASM_OUTPUT_POP_SECTION (asm_out_file);
5667 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
5669 /* Output terminating entries for the .debug_macinfo section. */
5671 dwarfout_resume_previous_source_file (0);
5673 fputc ('\n', asm_out_file);
5674 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
5675 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5676 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
5677 ASM_OUTPUT_POP_SECTION (asm_out_file);
5680 /* Generate the terminating entry for the .debug_pubnames section. */
5682 fputc ('\n', asm_out_file);
5683 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
5684 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5685 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
5686 ASM_OUTPUT_POP_SECTION (asm_out_file);
5688 /* Generate the terminating entries for the .debug_aranges section.
5690 Note that we want to do this only *after* we have output the end
5691 labels (for the various program sections) which we are going to
5692 refer to here. This allows us to work around a bug in the m68k
5693 svr4 assembler. That assembler gives bogus assembly-time errors
5694 if (within any given section) you try to take the difference of
5695 two relocatable symbols, both of which are located within some
5696 other section, and if one (or both?) of the symbols involved is
5697 being forward-referenced. By generating the .debug_aranges
5698 entries at this late point in the assembly output, we skirt the
5699 issue simply by avoiding forward-references.
5702 fputc ('\n', asm_out_file);
5703 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
5705 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
5706 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
5708 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA_BEGIN_LABEL);
5709 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA_END_LABEL, DATA_BEGIN_LABEL);
5711 #if 0 /* GNU C doesn't currently use .data1. */
5712 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA1_BEGIN_LABEL);
5713 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA1_END_LABEL,
5717 ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA_BEGIN_LABEL);
5718 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA_END_LABEL,
5719 RODATA_BEGIN_LABEL);
5721 #if 0 /* GNU C doesn't currently use .rodata1. */
5722 ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA1_BEGIN_LABEL);
5723 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA1_END_LABEL,
5724 RODATA1_BEGIN_LABEL);
5727 ASM_OUTPUT_DWARF_ADDR (asm_out_file, BSS_BEGIN_LABEL);
5728 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, BSS_END_LABEL, BSS_BEGIN_LABEL);
5730 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5731 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5733 ASM_OUTPUT_POP_SECTION (asm_out_file);
5737 #endif /* DWARF_DEBUGGING_INFO */