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"
37 #define DWARF_VERSION 1
40 /* #define NDEBUG 1 */
43 #if defined(DWARF_TIMESTAMPS)
46 #else /* !defined(POSIX) */
47 #include <sys/types.h>
49 extern time_t time (time_t *);
50 #else /* !defined(__STDC__) */
51 extern time_t time ();
52 #endif /* !defined(__STDC__) */
53 #endif /* !defined(POSIX) */
54 #endif /* defined(DWARF_TIMESTAMPS) */
56 extern char *getpwd ();
58 extern char *index ();
59 extern char *rindex ();
61 /* IMPORTANT NOTE: Please see the file README.DWARF for important details
62 regarding the GNU implementation of Dwarf. */
64 /* NOTE: In the comments in this file, many references are made to
65 so called "Debugging Information Entries". For the sake of brevity,
66 this term is abbreviated to `DIE' throughout the remainder of this
69 /* Note that the implementation of C++ support herein is (as yet) unfinished.
70 If you want to try to complete it, more power to you. */
72 #if !defined(__GNUC__) || (NDEBUG != 1)
76 /* How to start an assembler comment. */
77 #ifndef ASM_COMMENT_START
78 #define ASM_COMMENT_START ";#"
81 /* How to print out a register name. */
83 #define PRINT_REG(RTX, CODE, FILE) \
84 fprintf ((FILE), "%s", reg_names[REGNO (RTX)])
87 /* Define a macro which returns non-zero for any tagged type which is
88 used (directly or indirectly) in the specification of either some
89 function's return type or some formal parameter of some function.
90 We use this macro when we are operating in "terse" mode to help us
91 know what tagged types have to be represented in Dwarf (even in
92 terse mode) and which ones don't.
94 A flag bit with this meaning really should be a part of the normal
95 GCC ..._TYPE nodes, but at the moment, there is no such bit defined
96 for these nodes. For now, we have to just fake it. It it safe for
97 us to simply return zero for all complete tagged types (which will
98 get forced out anyway if they were used in the specification of some
99 formal or return type) and non-zero for all incomplete tagged types.
102 #define TYPE_USED_FOR_FUNCTION(tagged_type) (TYPE_SIZE (tagged_type) == 0)
104 extern int flag_traditional;
105 extern char *version_string;
106 extern char *language_string;
108 /* Maximum size (in bytes) of an artificially generated label. */
110 #define MAX_ARTIFICIAL_LABEL_BYTES 30
112 /* Make sure we know the sizes of the various types dwarf can describe.
113 These are only defaults. If the sizes are different for your target,
114 you should override these values by defining the appropriate symbols
115 in your tm.h file. */
117 #ifndef CHAR_TYPE_SIZE
118 #define CHAR_TYPE_SIZE BITS_PER_UNIT
121 #ifndef SHORT_TYPE_SIZE
122 #define SHORT_TYPE_SIZE (BITS_PER_UNIT * 2)
125 #ifndef INT_TYPE_SIZE
126 #define INT_TYPE_SIZE BITS_PER_WORD
129 #ifndef LONG_TYPE_SIZE
130 #define LONG_TYPE_SIZE BITS_PER_WORD
133 #ifndef LONG_LONG_TYPE_SIZE
134 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
137 #ifndef WCHAR_TYPE_SIZE
138 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
141 #ifndef WCHAR_UNSIGNED
142 #define WCHAR_UNSIGNED 0
145 #ifndef FLOAT_TYPE_SIZE
146 #define FLOAT_TYPE_SIZE BITS_PER_WORD
149 #ifndef DOUBLE_TYPE_SIZE
150 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
153 #ifndef LONG_DOUBLE_TYPE_SIZE
154 #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
157 /* Structure to keep track of source filenames. */
159 struct filename_entry {
164 typedef struct filename_entry filename_entry;
166 /* Pointer to an array of elements, each one having the structure above. */
168 static filename_entry *filename_table;
170 /* Total number of entries in the table (i.e. array) pointed to by
171 `filename_table'. This is the *total* and includes both used and
174 static unsigned ft_entries_allocated;
176 /* Number of entries in the filename_table which are actually in use. */
178 static unsigned ft_entries;
180 /* Size (in elements) of increments by which we may expand the filename
181 table. Actually, a single hunk of space of this size should be enough
182 for most typical programs. */
184 #define FT_ENTRIES_INCREMENT 64
186 /* Local pointer to the name of the main input file. Initialized in
189 static char *primary_filename;
191 /* Pointer to the most recent filename for which we produced some line info. */
193 static char *last_filename;
195 /* For Dwarf output, we must assign lexical-blocks id numbers
196 in the order in which their beginnings are encountered.
197 We output Dwarf debugging info that refers to the beginnings
198 and ends of the ranges of code for each lexical block with
199 assembler labels ..Bn and ..Bn.e, where n is the block number.
200 The labels themselves are generated in final.c, which assigns
201 numbers to the blocks in the same way. */
203 static unsigned next_block_number = 2;
205 /* Counter to generate unique names for DIEs. */
207 static unsigned next_unused_dienum = 1;
209 /* Number of the DIE which is currently being generated. */
211 static unsigned current_dienum;
213 /* Number to use for the special "pubname" label on the next DIE which
214 represents a function or data object defined in this compilation
215 unit which has "extern" linkage. */
217 static next_pubname_number = 0;
219 #define NEXT_DIE_NUM pending_sibling_stack[pending_siblings-1]
221 /* Pointer to a dynamically allocated list of pre-reserved and still
222 pending sibling DIE numbers. Note that this list will grow as needed. */
224 static unsigned *pending_sibling_stack;
226 /* Counter to keep track of the number of pre-reserved and still pending
227 sibling DIE numbers. */
229 static unsigned pending_siblings;
231 /* The currently allocated size of the above list (expressed in number of
234 static unsigned pending_siblings_allocated;
236 /* Size (in elements) of increments by which we may expand the pending
237 sibling stack. Actually, a single hunk of space of this size should
238 be enough for most typical programs. */
240 #define PENDING_SIBLINGS_INCREMENT 64
242 /* Non-zero if we are performing our file-scope finalization pass and if
243 we should force out Dwarf descriptions of any and all file-scope
244 tagged types which are still incomplete types. */
246 static int finalizing = 0;
248 /* A pointer to the base of a list of pending types which we haven't
249 generated DIEs for yet, but which we will have to come back to
252 static tree *pending_types_list;
254 /* Number of elements currently allocated for the pending_types_list. */
256 static unsigned pending_types_allocated;
258 /* Number of elements of pending_types_list currently in use. */
260 static unsigned pending_types;
262 /* Size (in elements) of increments by which we may expand the pending
263 types list. Actually, a single hunk of space of this size should
264 be enough for most typical programs. */
266 #define PENDING_TYPES_INCREMENT 64
268 /* Pointer to an artificial RECORD_TYPE which we create in dwarfout_init.
269 This is used in a hack to help us get the DIEs describing types of
270 formal parameters to come *after* all of the DIEs describing the formal
271 parameters themselves. That's necessary in order to be compatible
272 with what the brain-damaged svr4 SDB debugger requires. */
274 static tree fake_containing_scope;
276 /* The number of the current function definition that we are generating
277 debugging information for. These numbers range from 1 up to the maximum
278 number of function definitions contained within the current compilation
279 unit. These numbers are used to create unique labels for various things
280 contained within various function definitions. */
282 static unsigned current_funcdef_number = 1;
284 /* A pointer to the ..._DECL node which we have most recently been working
285 on. We keep this around just in case something about it looks screwy
286 and we want to tell the user what the source coordinates for the actual
289 static tree dwarf_last_decl;
291 /* Forward declarations for functions defined in this file. */
293 static char *dwarf_tag_name PROTO((unsigned));
294 static char *dwarf_attr_name PROTO((unsigned));
295 static char *dwarf_stack_op_name PROTO((unsigned));
296 static char *dwarf_typemod_name PROTO((unsigned));
297 static char *dwarf_fmt_byte_name PROTO((unsigned));
298 static char *dwarf_fund_type_name PROTO((unsigned));
299 static tree decl_ultimate_origin PROTO((tree));
300 static tree block_ultimate_origin PROTO((tree));
301 static void output_unsigned_leb128 PROTO((unsigned long));
302 static void output_signed_leb128 PROTO((long));
303 static inline int is_body_block PROTO((tree));
304 static int fundamental_type_code PROTO((tree));
305 static tree root_type PROTO((tree));
306 static void write_modifier_bytes PROTO((tree, int, int));
307 static inline int type_is_fundamental PROTO((tree));
308 static void equate_decl_number_to_die_number PROTO((tree));
309 static inline void equate_type_number_to_die_number PROTO((tree));
310 static void output_reg_number PROTO((rtx));
311 static void output_mem_loc_descriptor PROTO((rtx));
312 static void output_loc_descriptor PROTO((rtx));
313 static void output_bound_representation PROTO((tree, unsigned, char));
314 static void output_enumeral_list PROTO((tree));
315 static inline unsigned ceiling PROTO((unsigned, unsigned));
316 static inline tree field_type PROTO((tree));
317 static inline unsigned simple_type_align_in_bits PROTO((tree));
318 static inline unsigned simple_type_size_in_bits PROTO((tree));
319 static unsigned field_byte_offset PROTO((tree));
320 static inline void sibling_attribute PROTO((void));
321 static void location_attribute PROTO((rtx));
322 static void data_member_location_attribute PROTO((tree));
323 static void const_value_attribute PROTO((rtx));
324 static void location_or_const_value_attribute PROTO((tree));
325 static inline void name_attribute PROTO((char *));
326 static inline void fund_type_attribute PROTO((unsigned));
327 static void mod_fund_type_attribute PROTO((tree, int, int));
328 static inline void user_def_type_attribute PROTO((tree));
329 static void mod_u_d_type_attribute PROTO((tree, int, int));
330 static inline void ordering_attribute PROTO((unsigned));
331 static void subscript_data_attribute PROTO((tree));
332 static void byte_size_attribute PROTO((tree));
333 static inline void bit_offset_attribute PROTO((tree));
334 static inline void bit_size_attribute PROTO((tree));
335 static inline void element_list_attribute PROTO((tree));
336 static inline void stmt_list_attribute PROTO((char *));
337 static inline void low_pc_attribute PROTO((char *));
338 static inline void high_pc_attribute PROTO((char *));
339 static inline void body_begin_attribute PROTO((char *));
340 static inline void body_end_attribute PROTO((char *));
341 static inline void langauge_attribute PROTO((unsigned));
342 static inline void member_attribute PROTO((tree));
343 static inline void string_length_attribute PROTO((tree));
344 static inline void comp_dir_attribute PROTO((char *));
345 static inline void sf_names_attribute PROTO((char *));
346 static inline void src_info_attribute PROTO((char *));
347 static inline void mac_info_attribute PROTO((char *));
348 static inline void prototyped_attribute PROTO((tree));
349 static inline void producer_attribute PROTO((char *));
350 static inline void inline_attribute PROTO((tree));
351 static inline void containing_type_attribute PROTO((tree));
352 static inline void abstract_origin_attribute PROTO((tree));
353 static inline void src_coords_attribute PROTO((unsigned, unsigned));
354 static inline void pure_or_virtual_attribute PROTO((tree));
355 static void name_and_src_coords_attributes PROTO((tree));
356 static void type_attribute PROTO((tree, int, int));
357 static char *type_tag PROTO((tree));
358 static inline void dienum_push PROTO((void));
359 static inline void dienum_pop PROTO((void));
360 static inline tree member_declared_type PROTO((tree));
361 static char *function_start_label PROTO((tree));
362 static void output_array_type_die PROTO((void *));
363 static void output_set_type_die PROTO((void *));
364 static void output_entry_point_die PROTO((void *));
365 static void output_inlined_enumeration_type_die PROTO((void *));
366 static void output_inlined_structure_type_die PROTO((void *));
367 static void output_inlined_union_type_die PROTO((void *));
368 static void output_enumeration_type_die PROTO((void *));
369 static void output_formal_parameter_die PROTO((void *));
370 static void output_global_subroutine_die PROTO((void *));
371 static void output_global_variable_die PROTO((void *));
372 static void output_label_die PROTO((void *));
373 static void output_lexical_block_die PROTO((void *));
374 static void output_inlined_subroutine_die PROTO((void *));
375 static void output_local_variable_die PROTO((void *));
376 static void output_member_die PROTO((void *));
377 static void output_pointer_type_die PROTO((void *));
378 static void output_reference_type_die PROTO((void *));
379 static void output_ptr_to_mbr_type_die PROTO((void *));
380 static void output_compile_unit_die PROTO((void *));
381 static void output_string_type_die PROTO((void *));
382 static void output_structure_type_die PROTO((void *));
383 static void output_local_subroutine_die PROTO((void *));
384 static void output_subroutine_type_die PROTO((void *));
385 static void output_typedef_die PROTO((void *));
386 static void output_union_type_die PROTO((void *));
387 static void output_unspecified_parameters_die PROTO((void *));
388 static void output_padded_null_die PROTO((void *));
389 static void output_die PROTO((void (*) (), void *));
390 static void end_sibling_chain PROTO((void));
391 static void output_formal_types PROTO((tree));
392 static void pend_type PROTO((tree));
393 static inline int type_of_for_scope PROTO((tree, tree));
394 static void output_pending_types_for_scope PROTO((tree));
395 static void output_type PROTO((tree, tree));
396 static void output_tagged_type_instantiation PROTO((tree));
397 static void output_block PROTO((tree));
398 static void output_decls_for_scope PROTO((tree));
399 static void output_decl PROTO((tree, tree));
400 static void shuffle_filename_entry PROTO((filename_entry *));
401 static void geneate_new_sfname_entry PROTO((void));
402 static unsigned lookup_filename PROTO((char *));
403 static void generate_srcinfo_entry PROTO((unsigned, unsigned));
404 static void generate_macinfo_entry PROTO((char *, char *));
406 /* Definitions of defaults for assembler-dependent names of various
407 pseudo-ops and section names.
409 Theses may be overridden in your tm.h file (if necessary) for your
410 particular assembler. The default values provided here correspond to
411 what is expected by "standard" AT&T System V.4 assemblers. */
414 #define FILE_ASM_OP ".file"
416 #ifndef VERSION_ASM_OP
417 #define VERSION_ASM_OP ".version"
419 #ifndef UNALIGNED_SHORT_ASM_OP
420 #define UNALIGNED_SHORT_ASM_OP ".2byte"
422 #ifndef UNALIGNED_INT_ASM_OP
423 #define UNALIGNED_INT_ASM_OP ".4byte"
426 #define ASM_BYTE_OP ".byte"
429 #define SET_ASM_OP ".set"
432 /* Pseudo-ops for pushing the current section onto the section stack (and
433 simultaneously changing to a new section) and for poping back to the
434 section we were in immediately before this one. Note that most svr4
435 assemblers only maintain a one level stack... you can push all the
436 sections you want, but you can only pop out one level. (The sparc
437 svr4 assembler is an exception to this general rule.) That's
438 OK because we only use at most one level of the section stack herein. */
440 #ifndef PUSHSECTION_ASM_OP
441 #define PUSHSECTION_ASM_OP ".section"
443 #ifndef POPSECTION_ASM_OP
444 #define POPSECTION_ASM_OP ".previous"
447 /* The default format used by the ASM_OUTPUT_PUSH_SECTION macro (see below)
448 to print the PUSHSECTION_ASM_OP and the section name. The default here
449 works for almost all svr4 assemblers, except for the sparc, where the
450 section name must be enclosed in double quotes. (See sparcv4.h.) */
452 #ifndef PUSHSECTION_FORMAT
453 #define PUSHSECTION_FORMAT "\t%s\t%s\n"
456 #ifndef DEBUG_SECTION
457 #define DEBUG_SECTION ".debug"
460 #define LINE_SECTION ".line"
462 #ifndef SFNAMES_SECTION
463 #define SFNAMES_SECTION ".debug_sfnames"
465 #ifndef SRCINFO_SECTION
466 #define SRCINFO_SECTION ".debug_srcinfo"
468 #ifndef MACINFO_SECTION
469 #define MACINFO_SECTION ".debug_macinfo"
471 #ifndef PUBNAMES_SECTION
472 #define PUBNAMES_SECTION ".debug_pubnames"
474 #ifndef ARANGES_SECTION
475 #define ARANGES_SECTION ".debug_aranges"
478 #define TEXT_SECTION ".text"
481 #define DATA_SECTION ".data"
483 #ifndef DATA1_SECTION
484 #define DATA1_SECTION ".data1"
486 #ifndef RODATA_SECTION
487 #define RODATA_SECTION ".rodata"
489 #ifndef RODATA1_SECTION
490 #define RODATA1_SECTION ".rodata1"
493 #define BSS_SECTION ".bss"
496 /* Definitions of defaults for formats and names of various special
497 (artificial) labels which may be generated within this file (when
498 the -g options is used and DWARF_DEBUGGING_INFO is in effect.
500 If necessary, these may be overridden from within your tm.h file,
501 but typically, you should never need to override these.
503 These labels have been hacked (temporarily) so that they all begin with
504 a `.L' sequence so as to appease the stock sparc/svr4 assembler and the
505 stock m88k/svr4 assembler, both of which need to see .L at the start of
506 a label in order to prevent that label from going into the linker symbol
507 table). When I get time, I'll have to fix this the right way so that we
508 will use ASM_GENERATE_INTERNAL_LABEL and ASM_OUTPUT_INTERNAL_LABEL herein,
509 but that will require a rather massive set of changes. For the moment,
510 the following definitions out to produce the right results for all svr4
511 and svr3 assemblers. -- rfg
514 #ifndef TEXT_BEGIN_LABEL
515 #define TEXT_BEGIN_LABEL ".L_text_b"
517 #ifndef TEXT_END_LABEL
518 #define TEXT_END_LABEL ".L_text_e"
521 #ifndef DATA_BEGIN_LABEL
522 #define DATA_BEGIN_LABEL ".L_data_b"
524 #ifndef DATA_END_LABEL
525 #define DATA_END_LABEL ".L_data_e"
528 #ifndef DATA1_BEGIN_LABEL
529 #define DATA1_BEGIN_LABEL ".L_data1_b"
531 #ifndef DATA1_END_LABEL
532 #define DATA1_END_LABEL ".L_data1_e"
535 #ifndef RODATA_BEGIN_LABEL
536 #define RODATA_BEGIN_LABEL ".L_rodata_b"
538 #ifndef RODATA_END_LABEL
539 #define RODATA_END_LABEL ".L_rodata_e"
542 #ifndef RODATA1_BEGIN_LABEL
543 #define RODATA1_BEGIN_LABEL ".L_rodata1_b"
545 #ifndef RODATA1_END_LABEL
546 #define RODATA1_END_LABEL ".L_rodata1_e"
549 #ifndef BSS_BEGIN_LABEL
550 #define BSS_BEGIN_LABEL ".L_bss_b"
552 #ifndef BSS_END_LABEL
553 #define BSS_END_LABEL ".L_bss_e"
556 #ifndef LINE_BEGIN_LABEL
557 #define LINE_BEGIN_LABEL ".L_line_b"
559 #ifndef LINE_LAST_ENTRY_LABEL
560 #define LINE_LAST_ENTRY_LABEL ".L_line_last"
562 #ifndef LINE_END_LABEL
563 #define LINE_END_LABEL ".L_line_e"
566 #ifndef DEBUG_BEGIN_LABEL
567 #define DEBUG_BEGIN_LABEL ".L_debug_b"
569 #ifndef SFNAMES_BEGIN_LABEL
570 #define SFNAMES_BEGIN_LABEL ".L_sfnames_b"
572 #ifndef SRCINFO_BEGIN_LABEL
573 #define SRCINFO_BEGIN_LABEL ".L_srcinfo_b"
575 #ifndef MACINFO_BEGIN_LABEL
576 #define MACINFO_BEGIN_LABEL ".L_macinfo_b"
579 #ifndef DIE_BEGIN_LABEL_FMT
580 #define DIE_BEGIN_LABEL_FMT ".L_D%u"
582 #ifndef DIE_END_LABEL_FMT
583 #define DIE_END_LABEL_FMT ".L_D%u_e"
585 #ifndef PUB_DIE_LABEL_FMT
586 #define PUB_DIE_LABEL_FMT ".L_P%u"
588 #ifndef INSN_LABEL_FMT
589 #define INSN_LABEL_FMT ".L_I%u_%u"
591 #ifndef BLOCK_BEGIN_LABEL_FMT
592 #define BLOCK_BEGIN_LABEL_FMT ".L_B%u"
594 #ifndef BLOCK_END_LABEL_FMT
595 #define BLOCK_END_LABEL_FMT ".L_B%u_e"
597 #ifndef SS_BEGIN_LABEL_FMT
598 #define SS_BEGIN_LABEL_FMT ".L_s%u"
600 #ifndef SS_END_LABEL_FMT
601 #define SS_END_LABEL_FMT ".L_s%u_e"
603 #ifndef EE_BEGIN_LABEL_FMT
604 #define EE_BEGIN_LABEL_FMT ".L_e%u"
606 #ifndef EE_END_LABEL_FMT
607 #define EE_END_LABEL_FMT ".L_e%u_e"
609 #ifndef MT_BEGIN_LABEL_FMT
610 #define MT_BEGIN_LABEL_FMT ".L_t%u"
612 #ifndef MT_END_LABEL_FMT
613 #define MT_END_LABEL_FMT ".L_t%u_e"
615 #ifndef LOC_BEGIN_LABEL_FMT
616 #define LOC_BEGIN_LABEL_FMT ".L_l%u"
618 #ifndef LOC_END_LABEL_FMT
619 #define LOC_END_LABEL_FMT ".L_l%u_e"
621 #ifndef BOUND_BEGIN_LABEL_FMT
622 #define BOUND_BEGIN_LABEL_FMT ".L_b%u_%u_%c"
624 #ifndef BOUND_END_LABEL_FMT
625 #define BOUND_END_LABEL_FMT ".L_b%u_%u_%c_e"
627 #ifndef DERIV_BEGIN_LABEL_FMT
628 #define DERIV_BEGIN_LABEL_FMT ".L_d%u"
630 #ifndef DERIV_END_LABEL_FMT
631 #define DERIV_END_LABEL_FMT ".L_d%u_e"
633 #ifndef SL_BEGIN_LABEL_FMT
634 #define SL_BEGIN_LABEL_FMT ".L_sl%u"
636 #ifndef SL_END_LABEL_FMT
637 #define SL_END_LABEL_FMT ".L_sl%u_e"
639 #ifndef BODY_BEGIN_LABEL_FMT
640 #define BODY_BEGIN_LABEL_FMT ".L_b%u"
642 #ifndef BODY_END_LABEL_FMT
643 #define BODY_END_LABEL_FMT ".L_b%u_e"
645 #ifndef FUNC_END_LABEL_FMT
646 #define FUNC_END_LABEL_FMT ".L_f%u_e"
648 #ifndef TYPE_NAME_FMT
649 #define TYPE_NAME_FMT ".L_T%u"
651 #ifndef DECL_NAME_FMT
652 #define DECL_NAME_FMT ".L_E%u"
654 #ifndef LINE_CODE_LABEL_FMT
655 #define LINE_CODE_LABEL_FMT ".L_LC%u"
657 #ifndef SFNAMES_ENTRY_LABEL_FMT
658 #define SFNAMES_ENTRY_LABEL_FMT ".L_F%u"
660 #ifndef LINE_ENTRY_LABEL_FMT
661 #define LINE_ENTRY_LABEL_FMT ".L_LE%u"
664 /* Definitions of defaults for various types of primitive assembly language
667 If necessary, these may be overridden from within your tm.h file,
668 but typically, you shouldn't need to override these. */
670 #ifndef ASM_OUTPUT_PUSH_SECTION
671 #define ASM_OUTPUT_PUSH_SECTION(FILE, SECTION) \
672 fprintf ((FILE), PUSHSECTION_FORMAT, PUSHSECTION_ASM_OP, SECTION)
675 #ifndef ASM_OUTPUT_POP_SECTION
676 #define ASM_OUTPUT_POP_SECTION(FILE) \
677 fprintf ((FILE), "\t%s\n", POPSECTION_ASM_OP)
680 #ifndef ASM_OUTPUT_SOURCE_FILENAME
681 #define ASM_OUTPUT_SOURCE_FILENAME(FILE,NAME) \
682 do { fprintf (FILE, "\t%s\t", FILE_ASM_OP); \
683 output_quoted_string (FILE, NAME); \
684 fputc ('\n', FILE); \
688 #ifndef ASM_OUTPUT_DWARF_DELTA2
689 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
690 do { fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \
691 assemble_name (FILE, LABEL1); \
692 fprintf (FILE, "-"); \
693 assemble_name (FILE, LABEL2); \
694 fprintf (FILE, "\n"); \
698 #ifndef ASM_OUTPUT_DWARF_DELTA4
699 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
700 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
701 assemble_name (FILE, LABEL1); \
702 fprintf (FILE, "-"); \
703 assemble_name (FILE, LABEL2); \
704 fprintf (FILE, "\n"); \
708 #ifndef ASM_OUTPUT_DWARF_TAG
709 #define ASM_OUTPUT_DWARF_TAG(FILE,TAG) \
711 fprintf ((FILE), "\t%s\t0x%x", \
712 UNALIGNED_SHORT_ASM_OP, (unsigned) TAG); \
713 if (flag_debug_asm) \
714 fprintf ((FILE), "\t%s %s", \
715 ASM_COMMENT_START, dwarf_tag_name (TAG)); \
716 fputc ('\n', (FILE)); \
720 #ifndef ASM_OUTPUT_DWARF_ATTRIBUTE
721 #define ASM_OUTPUT_DWARF_ATTRIBUTE(FILE,ATTR) \
723 fprintf ((FILE), "\t%s\t0x%x", \
724 UNALIGNED_SHORT_ASM_OP, (unsigned) ATTR); \
725 if (flag_debug_asm) \
726 fprintf ((FILE), "\t%s %s", \
727 ASM_COMMENT_START, dwarf_attr_name (ATTR)); \
728 fputc ('\n', (FILE)); \
732 #ifndef ASM_OUTPUT_DWARF_STACK_OP
733 #define ASM_OUTPUT_DWARF_STACK_OP(FILE,OP) \
735 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) OP); \
736 if (flag_debug_asm) \
737 fprintf ((FILE), "\t%s %s", \
738 ASM_COMMENT_START, dwarf_stack_op_name (OP)); \
739 fputc ('\n', (FILE)); \
743 #ifndef ASM_OUTPUT_DWARF_FUND_TYPE
744 #define ASM_OUTPUT_DWARF_FUND_TYPE(FILE,FT) \
746 fprintf ((FILE), "\t%s\t0x%x", \
747 UNALIGNED_SHORT_ASM_OP, (unsigned) FT); \
748 if (flag_debug_asm) \
749 fprintf ((FILE), "\t%s %s", \
750 ASM_COMMENT_START, dwarf_fund_type_name (FT)); \
751 fputc ('\n', (FILE)); \
755 #ifndef ASM_OUTPUT_DWARF_FMT_BYTE
756 #define ASM_OUTPUT_DWARF_FMT_BYTE(FILE,FMT) \
758 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) FMT); \
759 if (flag_debug_asm) \
760 fprintf ((FILE), "\t%s %s", \
761 ASM_COMMENT_START, dwarf_fmt_byte_name (FMT)); \
762 fputc ('\n', (FILE)); \
766 #ifndef ASM_OUTPUT_DWARF_TYPE_MODIFIER
767 #define ASM_OUTPUT_DWARF_TYPE_MODIFIER(FILE,MOD) \
769 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) MOD); \
770 if (flag_debug_asm) \
771 fprintf ((FILE), "\t%s %s", \
772 ASM_COMMENT_START, dwarf_typemod_name (MOD)); \
773 fputc ('\n', (FILE)); \
777 #ifndef ASM_OUTPUT_DWARF_ADDR
778 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
779 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
780 assemble_name (FILE, LABEL); \
781 fprintf (FILE, "\n"); \
785 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
786 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX) \
788 fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
789 output_addr_const ((FILE), (RTX)); \
790 fputc ('\n', (FILE)); \
794 #ifndef ASM_OUTPUT_DWARF_REF
795 #define ASM_OUTPUT_DWARF_REF(FILE,LABEL) \
796 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
797 assemble_name (FILE, LABEL); \
798 fprintf (FILE, "\n"); \
802 #ifndef ASM_OUTPUT_DWARF_DATA1
803 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
804 fprintf ((FILE), "\t%s\t0x%x\n", ASM_BYTE_OP, VALUE)
807 #ifndef ASM_OUTPUT_DWARF_DATA2
808 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
809 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_SHORT_ASM_OP, (unsigned) VALUE)
812 #ifndef ASM_OUTPUT_DWARF_DATA4
813 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
814 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, (unsigned) VALUE)
817 #ifndef ASM_OUTPUT_DWARF_DATA8
818 #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \
820 if (WORDS_BIG_ENDIAN) \
822 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
823 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
827 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
828 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
833 #ifndef ASM_OUTPUT_DWARF_STRING
834 #define ASM_OUTPUT_DWARF_STRING(FILE,P) \
835 ASM_OUTPUT_ASCII ((FILE), P, strlen (P)+1)
838 /************************ general utility functions **************************/
844 return (((GET_CODE (rtl) == REG) && (REGNO (rtl) >= FIRST_PSEUDO_REGISTER))
845 || ((GET_CODE (rtl) == SUBREG)
846 && (REGNO (XEXP (rtl, 0)) >= FIRST_PSEUDO_REGISTER)));
850 type_main_variant (type)
853 type = TYPE_MAIN_VARIANT (type);
855 /* There really should be only one main variant among any group of variants
856 of a given type (and all of the MAIN_VARIANT values for all members of
857 the group should point to that one type) but sometimes the C front-end
858 messes this up for array types, so we work around that bug here. */
860 if (TREE_CODE (type) == ARRAY_TYPE)
862 while (type != TYPE_MAIN_VARIANT (type))
863 type = TYPE_MAIN_VARIANT (type);
869 /* Return non-zero if the given type node represents a tagged type. */
872 is_tagged_type (type)
875 register enum tree_code code = TREE_CODE (type);
877 return (code == RECORD_TYPE || code == UNION_TYPE
878 || code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
883 register unsigned tag;
887 case TAG_padding: return "TAG_padding";
888 case TAG_array_type: return "TAG_array_type";
889 case TAG_class_type: return "TAG_class_type";
890 case TAG_entry_point: return "TAG_entry_point";
891 case TAG_enumeration_type: return "TAG_enumeration_type";
892 case TAG_formal_parameter: return "TAG_formal_parameter";
893 case TAG_global_subroutine: return "TAG_global_subroutine";
894 case TAG_global_variable: return "TAG_global_variable";
895 case TAG_label: return "TAG_label";
896 case TAG_lexical_block: return "TAG_lexical_block";
897 case TAG_local_variable: return "TAG_local_variable";
898 case TAG_member: return "TAG_member";
899 case TAG_pointer_type: return "TAG_pointer_type";
900 case TAG_reference_type: return "TAG_reference_type";
901 case TAG_compile_unit: return "TAG_compile_unit";
902 case TAG_string_type: return "TAG_string_type";
903 case TAG_structure_type: return "TAG_structure_type";
904 case TAG_subroutine: return "TAG_subroutine";
905 case TAG_subroutine_type: return "TAG_subroutine_type";
906 case TAG_typedef: return "TAG_typedef";
907 case TAG_union_type: return "TAG_union_type";
908 case TAG_unspecified_parameters: return "TAG_unspecified_parameters";
909 case TAG_variant: return "TAG_variant";
910 case TAG_common_block: return "TAG_common_block";
911 case TAG_common_inclusion: return "TAG_common_inclusion";
912 case TAG_inheritance: return "TAG_inheritance";
913 case TAG_inlined_subroutine: return "TAG_inlined_subroutine";
914 case TAG_module: return "TAG_module";
915 case TAG_ptr_to_member_type: return "TAG_ptr_to_member_type";
916 case TAG_set_type: return "TAG_set_type";
917 case TAG_subrange_type: return "TAG_subrange_type";
918 case TAG_with_stmt: return "TAG_with_stmt";
920 /* GNU extensions. */
922 case TAG_format_label: return "TAG_format_label";
923 case TAG_namelist: return "TAG_namelist";
924 case TAG_function_template: return "TAG_function_template";
925 case TAG_class_template: return "TAG_class_template";
927 default: return "TAG_<unknown>";
932 dwarf_attr_name (attr)
933 register unsigned attr;
937 case AT_sibling: return "AT_sibling";
938 case AT_location: return "AT_location";
939 case AT_name: return "AT_name";
940 case AT_fund_type: return "AT_fund_type";
941 case AT_mod_fund_type: return "AT_mod_fund_type";
942 case AT_user_def_type: return "AT_user_def_type";
943 case AT_mod_u_d_type: return "AT_mod_u_d_type";
944 case AT_ordering: return "AT_ordering";
945 case AT_subscr_data: return "AT_subscr_data";
946 case AT_byte_size: return "AT_byte_size";
947 case AT_bit_offset: return "AT_bit_offset";
948 case AT_bit_size: return "AT_bit_size";
949 case AT_element_list: return "AT_element_list";
950 case AT_stmt_list: return "AT_stmt_list";
951 case AT_low_pc: return "AT_low_pc";
952 case AT_high_pc: return "AT_high_pc";
953 case AT_language: return "AT_language";
954 case AT_member: return "AT_member";
955 case AT_discr: return "AT_discr";
956 case AT_discr_value: return "AT_discr_value";
957 case AT_string_length: return "AT_string_length";
958 case AT_common_reference: return "AT_common_reference";
959 case AT_comp_dir: return "AT_comp_dir";
960 case AT_const_value_string: return "AT_const_value_string";
961 case AT_const_value_data2: return "AT_const_value_data2";
962 case AT_const_value_data4: return "AT_const_value_data4";
963 case AT_const_value_data8: return "AT_const_value_data8";
964 case AT_const_value_block2: return "AT_const_value_block2";
965 case AT_const_value_block4: return "AT_const_value_block4";
966 case AT_containing_type: return "AT_containing_type";
967 case AT_default_value_addr: return "AT_default_value_addr";
968 case AT_default_value_data2: return "AT_default_value_data2";
969 case AT_default_value_data4: return "AT_default_value_data4";
970 case AT_default_value_data8: return "AT_default_value_data8";
971 case AT_default_value_string: return "AT_default_value_string";
972 case AT_friends: return "AT_friends";
973 case AT_inline: return "AT_inline";
974 case AT_is_optional: return "AT_is_optional";
975 case AT_lower_bound_ref: return "AT_lower_bound_ref";
976 case AT_lower_bound_data2: return "AT_lower_bound_data2";
977 case AT_lower_bound_data4: return "AT_lower_bound_data4";
978 case AT_lower_bound_data8: return "AT_lower_bound_data8";
979 case AT_private: return "AT_private";
980 case AT_producer: return "AT_producer";
981 case AT_program: return "AT_program";
982 case AT_protected: return "AT_protected";
983 case AT_prototyped: return "AT_prototyped";
984 case AT_public: return "AT_public";
985 case AT_pure_virtual: return "AT_pure_virtual";
986 case AT_return_addr: return "AT_return_addr";
987 case AT_abstract_origin: return "AT_abstract_origin";
988 case AT_start_scope: return "AT_start_scope";
989 case AT_stride_size: return "AT_stride_size";
990 case AT_upper_bound_ref: return "AT_upper_bound_ref";
991 case AT_upper_bound_data2: return "AT_upper_bound_data2";
992 case AT_upper_bound_data4: return "AT_upper_bound_data4";
993 case AT_upper_bound_data8: return "AT_upper_bound_data8";
994 case AT_virtual: return "AT_virtual";
998 case AT_sf_names: return "AT_sf_names";
999 case AT_src_info: return "AT_src_info";
1000 case AT_mac_info: return "AT_mac_info";
1001 case AT_src_coords: return "AT_src_coords";
1002 case AT_body_begin: return "AT_body_begin";
1003 case AT_body_end: return "AT_body_end";
1005 default: return "AT_<unknown>";
1010 dwarf_stack_op_name (op)
1011 register unsigned op;
1015 case OP_REG: return "OP_REG";
1016 case OP_BASEREG: return "OP_BASEREG";
1017 case OP_ADDR: return "OP_ADDR";
1018 case OP_CONST: return "OP_CONST";
1019 case OP_DEREF2: return "OP_DEREF2";
1020 case OP_DEREF4: return "OP_DEREF4";
1021 case OP_ADD: return "OP_ADD";
1022 default: return "OP_<unknown>";
1027 dwarf_typemod_name (mod)
1028 register unsigned mod;
1032 case MOD_pointer_to: return "MOD_pointer_to";
1033 case MOD_reference_to: return "MOD_reference_to";
1034 case MOD_const: return "MOD_const";
1035 case MOD_volatile: return "MOD_volatile";
1036 default: return "MOD_<unknown>";
1041 dwarf_fmt_byte_name (fmt)
1042 register unsigned fmt;
1046 case FMT_FT_C_C: return "FMT_FT_C_C";
1047 case FMT_FT_C_X: return "FMT_FT_C_X";
1048 case FMT_FT_X_C: return "FMT_FT_X_C";
1049 case FMT_FT_X_X: return "FMT_FT_X_X";
1050 case FMT_UT_C_C: return "FMT_UT_C_C";
1051 case FMT_UT_C_X: return "FMT_UT_C_X";
1052 case FMT_UT_X_C: return "FMT_UT_X_C";
1053 case FMT_UT_X_X: return "FMT_UT_X_X";
1054 case FMT_ET: return "FMT_ET";
1055 default: return "FMT_<unknown>";
1060 dwarf_fund_type_name (ft)
1061 register unsigned ft;
1065 case FT_char: return "FT_char";
1066 case FT_signed_char: return "FT_signed_char";
1067 case FT_unsigned_char: return "FT_unsigned_char";
1068 case FT_short: return "FT_short";
1069 case FT_signed_short: return "FT_signed_short";
1070 case FT_unsigned_short: return "FT_unsigned_short";
1071 case FT_integer: return "FT_integer";
1072 case FT_signed_integer: return "FT_signed_integer";
1073 case FT_unsigned_integer: return "FT_unsigned_integer";
1074 case FT_long: return "FT_long";
1075 case FT_signed_long: return "FT_signed_long";
1076 case FT_unsigned_long: return "FT_unsigned_long";
1077 case FT_pointer: return "FT_pointer";
1078 case FT_float: return "FT_float";
1079 case FT_dbl_prec_float: return "FT_dbl_prec_float";
1080 case FT_ext_prec_float: return "FT_ext_prec_float";
1081 case FT_complex: return "FT_complex";
1082 case FT_dbl_prec_complex: return "FT_dbl_prec_complex";
1083 case FT_void: return "FT_void";
1084 case FT_boolean: return "FT_boolean";
1085 case FT_ext_prec_complex: return "FT_ext_prec_complex";
1086 case FT_label: return "FT_label";
1088 /* GNU extensions. */
1090 case FT_long_long: return "FT_long_long";
1091 case FT_signed_long_long: return "FT_signed_long_long";
1092 case FT_unsigned_long_long: return "FT_unsigned_long_long";
1094 case FT_int8: return "FT_int8";
1095 case FT_signed_int8: return "FT_signed_int8";
1096 case FT_unsigned_int8: return "FT_unsigned_int8";
1097 case FT_int16: return "FT_int16";
1098 case FT_signed_int16: return "FT_signed_int16";
1099 case FT_unsigned_int16: return "FT_unsigned_int16";
1100 case FT_int32: return "FT_int32";
1101 case FT_signed_int32: return "FT_signed_int32";
1102 case FT_unsigned_int32: return "FT_unsigned_int32";
1103 case FT_int64: return "FT_int64";
1104 case FT_signed_int64: return "FT_signed_int64";
1105 case FT_unsigned_int64: return "FT_signed_int64";
1107 case FT_real32: return "FT_real32";
1108 case FT_real64: return "FT_real64";
1109 case FT_real96: return "FT_real96";
1110 case FT_real128: return "FT_real128";
1112 default: return "FT_<unknown>";
1116 /* Determine the "ultimate origin" of a decl. The decl may be an
1117 inlined instance of an inlined instance of a decl which is local
1118 to an inline function, so we have to trace all of the way back
1119 through the origin chain to find out what sort of node actually
1120 served as the original seed for the given block. */
1123 decl_ultimate_origin (decl)
1126 register tree immediate_origin = DECL_ABSTRACT_ORIGIN (decl);
1128 if (immediate_origin == NULL)
1132 register tree ret_val;
1133 register tree lookahead = immediate_origin;
1137 ret_val = lookahead;
1138 lookahead = DECL_ABSTRACT_ORIGIN (ret_val);
1140 while (lookahead != NULL && lookahead != ret_val);
1145 /* Determine the "ultimate origin" of a block. The block may be an
1146 inlined instance of an inlined instance of a block which is local
1147 to an inline function, so we have to trace all of the way back
1148 through the origin chain to find out what sort of node actually
1149 served as the original seed for the given block. */
1152 block_ultimate_origin (block)
1153 register tree block;
1155 register tree immediate_origin = BLOCK_ABSTRACT_ORIGIN (block);
1157 if (immediate_origin == NULL)
1161 register tree ret_val;
1162 register tree lookahead = immediate_origin;
1166 ret_val = lookahead;
1167 lookahead = (TREE_CODE (ret_val) == BLOCK)
1168 ? BLOCK_ABSTRACT_ORIGIN (ret_val)
1171 while (lookahead != NULL && lookahead != ret_val);
1177 output_unsigned_leb128 (value)
1178 register unsigned long value;
1180 register unsigned long orig_value = value;
1184 register unsigned byte = (value & 0x7f);
1187 if (value != 0) /* more bytes to follow */
1189 fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) byte);
1190 if (flag_debug_asm && value == 0)
1191 fprintf (asm_out_file, "\t%s ULEB128 number - value = %u",
1192 ASM_COMMENT_START, orig_value);
1193 fputc ('\n', asm_out_file);
1199 output_signed_leb128 (value)
1200 register long value;
1202 register long orig_value = value;
1203 register int negative = (value < 0);
1208 register unsigned byte = (value & 0x7f);
1212 value |= 0xfe000000; /* manually sign extend */
1213 if (((value == 0) && ((byte & 0x40) == 0))
1214 || ((value == -1) && ((byte & 0x40) == 1)))
1221 fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) byte);
1222 if (flag_debug_asm && more == 0)
1223 fprintf (asm_out_file, "\t%s SLEB128 number - value = %d",
1224 ASM_COMMENT_START, orig_value);
1225 fputc ('\n', asm_out_file);
1230 /**************** utility functions for attribute functions ******************/
1232 /* Given a pointer to a BLOCK node return non-zero if (and only if) the
1233 node in question represents the outermost pair of curly braces (i.e.
1234 the "body block") of a function or method.
1236 For any BLOCK node representing a "body block" of a function or method,
1237 the BLOCK_SUPERCONTEXT of the node will point to another BLOCK node
1238 which represents the outermost (function) scope for the function or
1239 method (i.e. the one which includes the formal parameters). The
1240 BLOCK_SUPERCONTEXT of *that* node in turn will point to the relevant
1245 is_body_block (stmt)
1248 if (TREE_CODE (stmt) == BLOCK)
1250 register tree parent = BLOCK_SUPERCONTEXT (stmt);
1252 if (TREE_CODE (parent) == BLOCK)
1254 register tree grandparent = BLOCK_SUPERCONTEXT (parent);
1256 if (TREE_CODE (grandparent) == FUNCTION_DECL)
1263 /* Given a pointer to a tree node for some type, return a Dwarf fundamental
1264 type code for the given type.
1266 This routine must only be called for GCC type nodes that correspond to
1267 Dwarf fundamental types.
1269 The current Dwarf draft specification calls for Dwarf fundamental types
1270 to accurately reflect the fact that a given type was either a "plain"
1271 integral type or an explicitly "signed" integral type. Unfortunately,
1272 we can't always do this, because GCC may already have thrown away the
1273 information about the precise way in which the type was originally
1276 typedef signed int my_type;
1278 struct s { my_type f; };
1280 Since we may be stuck here without enought information to do exactly
1281 what is called for in the Dwarf draft specification, we do the best
1282 that we can under the circumstances and always use the "plain" integral
1283 fundamental type codes for int, short, and long types. That's probably
1284 good enough. The additional accuracy called for in the current DWARF
1285 draft specification is probably never even useful in practice. */
1288 fundamental_type_code (type)
1291 if (TREE_CODE (type) == ERROR_MARK)
1294 switch (TREE_CODE (type))
1303 /* Carefully distinguish all the standard types of C,
1304 without messing up if the language is not C.
1305 Note that we check only for the names that contain spaces;
1306 other names might occur by coincidence in other languages. */
1307 if (TYPE_NAME (type) != 0
1308 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1309 && DECL_NAME (TYPE_NAME (type)) != 0
1310 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
1312 char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
1314 if (!strcmp (name, "unsigned char"))
1315 return FT_unsigned_char;
1316 if (!strcmp (name, "signed char"))
1317 return FT_signed_char;
1318 if (!strcmp (name, "unsigned int"))
1319 return FT_unsigned_integer;
1320 if (!strcmp (name, "short int"))
1322 if (!strcmp (name, "short unsigned int"))
1323 return FT_unsigned_short;
1324 if (!strcmp (name, "long int"))
1326 if (!strcmp (name, "long unsigned int"))
1327 return FT_unsigned_long;
1328 if (!strcmp (name, "long long int"))
1329 return FT_long_long; /* Not grok'ed by svr4 SDB */
1330 if (!strcmp (name, "long long unsigned int"))
1331 return FT_unsigned_long_long; /* Not grok'ed by svr4 SDB */
1334 /* Most integer types will be sorted out above, however, for the
1335 sake of special `array index' integer types, the following code
1336 is also provided. */
1338 if (TYPE_PRECISION (type) == INT_TYPE_SIZE)
1339 return (TREE_UNSIGNED (type) ? FT_unsigned_integer : FT_integer);
1341 if (TYPE_PRECISION (type) == LONG_TYPE_SIZE)
1342 return (TREE_UNSIGNED (type) ? FT_unsigned_long : FT_long);
1344 if (TYPE_PRECISION (type) == LONG_LONG_TYPE_SIZE)
1345 return (TREE_UNSIGNED (type) ? FT_unsigned_long_long : FT_long_long);
1347 if (TYPE_PRECISION (type) == SHORT_TYPE_SIZE)
1348 return (TREE_UNSIGNED (type) ? FT_unsigned_short : FT_short);
1350 if (TYPE_PRECISION (type) == CHAR_TYPE_SIZE)
1351 return (TREE_UNSIGNED (type) ? FT_unsigned_char : FT_char);
1356 /* Carefully distinguish all the standard types of C,
1357 without messing up if the language is not C. */
1358 if (TYPE_NAME (type) != 0
1359 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1360 && DECL_NAME (TYPE_NAME (type)) != 0
1361 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
1363 char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
1365 /* Note that here we can run afowl of a serious bug in "classic"
1366 svr4 SDB debuggers. They don't seem to understand the
1367 FT_ext_prec_float type (even though they should). */
1369 if (!strcmp (name, "long double"))
1370 return FT_ext_prec_float;
1373 if (TYPE_PRECISION (type) == DOUBLE_TYPE_SIZE)
1374 return FT_dbl_prec_float;
1375 if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE)
1378 /* Note that here we can run afowl of a serious bug in "classic"
1379 svr4 SDB debuggers. They don't seem to understand the
1380 FT_ext_prec_float type (even though they should). */
1382 if (TYPE_PRECISION (type) == LONG_DOUBLE_TYPE_SIZE)
1383 return FT_ext_prec_float;
1387 return FT_complex; /* GNU FORTRAN COMPLEX type. */
1390 return FT_char; /* GNU Pascal CHAR type. Not used in C. */
1393 return FT_boolean; /* GNU FORTRAN BOOLEAN type. */
1396 abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
1401 /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
1402 the Dwarf "root" type for the given input type. The Dwarf "root" type
1403 of a given type is generally the same as the given type, except that if
1404 the given type is a pointer or reference type, then the root type of
1405 the given type is the root type of the "basis" type for the pointer or
1406 reference type. (This definition of the "root" type is recursive.)
1407 Also, the root type of a `const' qualified type or a `volatile'
1408 qualified type is the root type of the given type without the
1415 if (TREE_CODE (type) == ERROR_MARK)
1416 return error_mark_node;
1418 switch (TREE_CODE (type))
1421 return error_mark_node;
1424 case REFERENCE_TYPE:
1425 return type_main_variant (root_type (TREE_TYPE (type)));
1428 return type_main_variant (type);
1432 /* Given a pointer to an arbitrary ..._TYPE tree node, write out a sequence
1433 of zero or more Dwarf "type-modifier" bytes applicable to the type. */
1436 write_modifier_bytes (type, decl_const, decl_volatile)
1438 register int decl_const;
1439 register int decl_volatile;
1441 if (TREE_CODE (type) == ERROR_MARK)
1444 if (TYPE_READONLY (type) || decl_const)
1445 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_const);
1446 if (TYPE_VOLATILE (type) || decl_volatile)
1447 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_volatile);
1448 switch (TREE_CODE (type))
1451 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_pointer_to);
1452 write_modifier_bytes (TREE_TYPE (type), 0, 0);
1455 case REFERENCE_TYPE:
1456 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_reference_to);
1457 write_modifier_bytes (TREE_TYPE (type), 0, 0);
1466 /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
1467 given input type is a Dwarf "fundamental" type. Otherwise return zero. */
1470 type_is_fundamental (type)
1473 switch (TREE_CODE (type))
1488 case QUAL_UNION_TYPE:
1493 case REFERENCE_TYPE:
1505 /* Given a pointer to some ..._DECL tree node, generate an assembly language
1506 equate directive which will associate a symbolic name with the current DIE.
1508 The name used is an artificial label generated from the DECL_UID number
1509 associated with the given decl node. The name it gets equated to is the
1510 symbolic label that we (previously) output at the start of the DIE that
1511 we are currently generating.
1513 Calling this function while generating some "decl related" form of DIE
1514 makes it possible to later refer to the DIE which represents the given
1515 decl simply by re-generating the symbolic name from the ..._DECL node's
1519 equate_decl_number_to_die_number (decl)
1522 /* In the case where we are generating a DIE for some ..._DECL node
1523 which represents either some inline function declaration or some
1524 entity declared within an inline function declaration/definition,
1525 setup a symbolic name for the current DIE so that we have a name
1526 for this DIE that we can easily refer to later on within
1527 AT_abstract_origin attributes. */
1529 char decl_label[MAX_ARTIFICIAL_LABEL_BYTES];
1530 char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
1532 sprintf (decl_label, DECL_NAME_FMT, DECL_UID (decl));
1533 sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
1534 ASM_OUTPUT_DEF (asm_out_file, decl_label, die_label);
1537 /* Given a pointer to some ..._TYPE tree node, generate an assembly language
1538 equate directive which will associate a symbolic name with the current DIE.
1540 The name used is an artificial label generated from the TYPE_UID number
1541 associated with the given type node. The name it gets equated to is the
1542 symbolic label that we (previously) output at the start of the DIE that
1543 we are currently generating.
1545 Calling this function while generating some "type related" form of DIE
1546 makes it easy to later refer to the DIE which represents the given type
1547 simply by re-generating the alternative name from the ..._TYPE node's
1551 equate_type_number_to_die_number (type)
1554 char type_label[MAX_ARTIFICIAL_LABEL_BYTES];
1555 char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
1557 /* We are generating a DIE to represent the main variant of this type
1558 (i.e the type without any const or volatile qualifiers) so in order
1559 to get the equate to come out right, we need to get the main variant
1562 type = type_main_variant (type);
1564 sprintf (type_label, TYPE_NAME_FMT, TYPE_UID (type));
1565 sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
1566 ASM_OUTPUT_DEF (asm_out_file, type_label, die_label);
1570 output_reg_number (rtl)
1573 register unsigned regno = REGNO (rtl);
1575 if (regno >= FIRST_PSEUDO_REGISTER)
1577 warning_with_decl (dwarf_last_decl, "internal regno botch: regno = %d\n",
1581 fprintf (asm_out_file, "\t%s\t0x%x",
1582 UNALIGNED_INT_ASM_OP, DBX_REGISTER_NUMBER (regno));
1585 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
1586 PRINT_REG (rtl, 0, asm_out_file);
1588 fputc ('\n', asm_out_file);
1591 /* The following routine is a nice and simple transducer. It converts the
1592 RTL for a variable or parameter (resident in memory) into an equivalent
1593 Dwarf representation of a mechanism for getting the address of that same
1594 variable onto the top of a hypothetical "address evaluation" stack.
1596 When creating memory location descriptors, we are effectively trans-
1597 forming the RTL for a memory-resident object into its Dwarf postfix
1598 expression equivalent. This routine just recursively descends an
1599 RTL tree, turning it into Dwarf postfix code as it goes. */
1602 output_mem_loc_descriptor (rtl)
1605 /* Note that for a dynamically sized array, the location we will
1606 generate a description of here will be the lowest numbered location
1607 which is actually within the array. That's *not* necessarily the
1608 same as the zeroth element of the array. */
1610 switch (GET_CODE (rtl))
1614 /* The case of a subreg may arise when we have a local (register)
1615 variable or a formal (register) parameter which doesn't quite
1616 fill up an entire register. For now, just assume that it is
1617 legitimate to make the Dwarf info refer to the whole register
1618 which contains the given subreg. */
1620 rtl = XEXP (rtl, 0);
1625 /* Whenever a register number forms a part of the description of
1626 the method for calculating the (dynamic) address of a memory
1627 resident object, DWARF rules require the register number to
1628 be referred to as a "base register". This distinction is not
1629 based in any way upon what category of register the hardware
1630 believes the given register belongs to. This is strictly
1631 DWARF terminology we're dealing with here.
1633 Note that in cases where the location of a memory-resident data
1634 object could be expressed as:
1636 OP_ADD (OP_BASEREG (basereg), OP_CONST (0))
1638 the actual DWARF location descriptor that we generate may just
1639 be OP_BASEREG (basereg). This may look deceptively like the
1640 object in question was allocated to a register (rather than
1641 in memory) so DWARF consumers need to be aware of the subtle
1642 distinction between OP_REG and OP_BASEREG. */
1644 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_BASEREG);
1645 output_reg_number (rtl);
1649 output_mem_loc_descriptor (XEXP (rtl, 0));
1650 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_DEREF4);
1655 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADDR);
1656 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
1660 output_mem_loc_descriptor (XEXP (rtl, 0));
1661 output_mem_loc_descriptor (XEXP (rtl, 1));
1662 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
1666 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
1667 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, INTVAL (rtl));
1675 /* Output a proper Dwarf location descriptor for a variable or parameter
1676 which is either allocated in a register or in a memory location. For
1677 a register, we just generate an OP_REG and the register number. For a
1678 memory location we provide a Dwarf postfix expression describing how to
1679 generate the (dynamic) address of the object onto the address stack. */
1682 output_loc_descriptor (rtl)
1685 switch (GET_CODE (rtl))
1689 /* The case of a subreg may arise when we have a local (register)
1690 variable or a formal (register) parameter which doesn't quite
1691 fill up an entire register. For now, just assume that it is
1692 legitimate to make the Dwarf info refer to the whole register
1693 which contains the given subreg. */
1695 rtl = XEXP (rtl, 0);
1699 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_REG);
1700 output_reg_number (rtl);
1704 output_mem_loc_descriptor (XEXP (rtl, 0));
1708 abort (); /* Should never happen */
1712 /* Given a tree node describing an array bound (either lower or upper)
1713 output a representation for that bound. */
1716 output_bound_representation (bound, dim_num, u_or_l)
1717 register tree bound;
1718 register unsigned dim_num; /* For multi-dimensional arrays. */
1719 register char u_or_l; /* Designates upper or lower bound. */
1721 switch (TREE_CODE (bound))
1727 /* All fixed-bounds are represented by INTEGER_CST nodes. */
1730 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
1731 (unsigned) TREE_INT_CST_LOW (bound));
1734 /* Dynamic bounds may be represented by NOP_EXPR nodes containing
1738 bound = TREE_OPERAND (bound, 0);
1739 /* ... fall thru... */
1743 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
1744 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
1746 sprintf (begin_label, BOUND_BEGIN_LABEL_FMT,
1747 current_dienum, dim_num, u_or_l);
1749 sprintf (end_label, BOUND_END_LABEL_FMT,
1750 current_dienum, dim_num, u_or_l);
1752 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
1753 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
1755 /* If we are working on a bound for a dynamic dimension in C,
1756 the dynamic dimension in question had better have a static
1757 (zero) lower bound and a dynamic *upper* bound. */
1762 /* If optimization is turned on, the SAVE_EXPRs that describe
1763 how to access the upper bound values are essentially bogus.
1764 They only describe (at best) how to get at these values at
1765 the points in the generated code right after they have just
1766 been computed. Worse yet, in the typical case, the upper
1767 bound values will not even *be* computed in the optimized
1768 code, so these SAVE_EXPRs are entirely bogus.
1770 In order to compensate for this fact, we check here to see
1771 if optimization is enabled, and if so, we effectively create
1772 an empty location description for the (unknown and unknowable)
1775 This should not cause too much trouble for existing (stupid?)
1776 debuggers because they have to deal with empty upper bounds
1777 location descriptions anyway in order to be able to deal with
1778 incomplete array types.
1780 Of course an intelligent debugger (GDB?) should be able to
1781 comprehend that a missing upper bound specification in a
1782 array type used for a storage class `auto' local array variable
1783 indicates that the upper bound is both unknown (at compile-
1784 time) and unknowable (at run-time) due to optimization.
1788 output_loc_descriptor
1789 (eliminate_regs (SAVE_EXPR_RTL (bound), 0, NULL_RTX));
1791 ASM_OUTPUT_LABEL (asm_out_file, end_label);
1800 /* Recursive function to output a sequence of value/name pairs for
1801 enumeration constants in reversed order. This is called from
1802 enumeration_type_die. */
1805 output_enumeral_list (link)
1810 output_enumeral_list (TREE_CHAIN (link));
1811 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
1812 (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link)));
1813 ASM_OUTPUT_DWARF_STRING (asm_out_file,
1814 IDENTIFIER_POINTER (TREE_PURPOSE (link)));
1818 /* Given an unsigned value, round it up to the lowest multiple of `boundary'
1819 which is not less than the value itself. */
1821 static inline unsigned
1822 ceiling (value, boundary)
1823 register unsigned value;
1824 register unsigned boundary;
1826 return (((value + boundary - 1) / boundary) * boundary);
1829 /* Given a pointer to what is assumed to be a FIELD_DECL node, return a
1830 pointer to the declared type for the relevant field variable, or return
1831 `integer_type_node' if the given node turns out to be an ERROR_MARK node. */
1839 if (TREE_CODE (decl) == ERROR_MARK)
1840 return integer_type_node;
1842 type = DECL_BIT_FIELD_TYPE (decl);
1844 type = TREE_TYPE (decl);
1848 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
1849 node, return the alignment in bits for the type, or else return
1850 BITS_PER_WORD if the node actually turns out to be an ERROR_MARK node. */
1852 static inline unsigned
1853 simple_type_align_in_bits (type)
1856 return (TREE_CODE (type) != ERROR_MARK) ? TYPE_ALIGN (type) : BITS_PER_WORD;
1859 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
1860 node, return the size in bits for the type if it is a constant, or
1861 else return the alignment for the type if the type's size is not
1862 constant, or else return BITS_PER_WORD if the type actually turns out
1863 to be an ERROR_MARK node. */
1865 static inline unsigned
1866 simple_type_size_in_bits (type)
1869 if (TREE_CODE (type) == ERROR_MARK)
1870 return BITS_PER_WORD;
1873 register tree type_size_tree = TYPE_SIZE (type);
1875 if (TREE_CODE (type_size_tree) != INTEGER_CST)
1876 return TYPE_ALIGN (type);
1878 return (unsigned) TREE_INT_CST_LOW (type_size_tree);
1882 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
1883 return the byte offset of the lowest addressed byte of the "containing
1884 object" for the given FIELD_DECL, or return 0 if we are unable to deter-
1885 mine what that offset is, either because the argument turns out to be a
1886 pointer to an ERROR_MARK node, or because the offset is actually variable.
1887 (We can't handle the latter case just yet.) */
1890 field_byte_offset (decl)
1893 register unsigned type_align_in_bytes;
1894 register unsigned type_align_in_bits;
1895 register unsigned type_size_in_bits;
1896 register unsigned object_offset_in_align_units;
1897 register unsigned object_offset_in_bits;
1898 register unsigned object_offset_in_bytes;
1900 register tree bitpos_tree;
1901 register tree field_size_tree;
1902 register unsigned bitpos_int;
1903 register unsigned deepest_bitpos;
1904 register unsigned field_size_in_bits;
1906 if (TREE_CODE (decl) == ERROR_MARK)
1909 if (TREE_CODE (decl) != FIELD_DECL)
1912 type = field_type (decl);
1914 bitpos_tree = DECL_FIELD_BITPOS (decl);
1915 field_size_tree = DECL_SIZE (decl);
1917 /* We cannot yet cope with fields whose positions or sizes are variable,
1918 so for now, when we see such things, we simply return 0. Someday,
1919 we may be able to handle such cases, but it will be damn difficult. */
1921 if (TREE_CODE (bitpos_tree) != INTEGER_CST)
1923 bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
1925 if (TREE_CODE (field_size_tree) != INTEGER_CST)
1927 field_size_in_bits = (unsigned) TREE_INT_CST_LOW (field_size_tree);
1929 type_size_in_bits = simple_type_size_in_bits (type);
1931 type_align_in_bits = simple_type_align_in_bits (type);
1932 type_align_in_bytes = type_align_in_bits / BITS_PER_UNIT;
1934 /* Note that the GCC front-end doesn't make any attempt to keep track
1935 of the starting bit offset (relative to the start of the containing
1936 structure type) of the hypothetical "containing object" for a bit-
1937 field. Thus, when computing the byte offset value for the start of
1938 the "containing object" of a bit-field, we must deduce this infor-
1941 This can be rather tricky to do in some cases. For example, handling
1942 the following structure type definition when compiling for an i386/i486
1943 target (which only aligns long long's to 32-bit boundaries) can be very
1948 long long field2:31;
1951 Fortunately, there is a simple rule-of-thumb which can be used in such
1952 cases. When compiling for an i386/i486, GCC will allocate 8 bytes for
1953 the structure shown above. It decides to do this based upon one simple
1954 rule for bit-field allocation. Quite simply, GCC allocates each "con-
1955 taining object" for each bit-field at the first (i.e. lowest addressed)
1956 legitimate alignment boundary (based upon the required minimum alignment
1957 for the declared type of the field) which it can possibly use, subject
1958 to the condition that there is still enough available space remaining
1959 in the containing object (when allocated at the selected point) to
1960 fully accommodate all of the bits of the bit-field itself.
1962 This simple rule makes it obvious why GCC allocates 8 bytes for each
1963 object of the structure type shown above. When looking for a place to
1964 allocate the "containing object" for `field2', the compiler simply tries
1965 to allocate a 64-bit "containing object" at each successive 32-bit
1966 boundary (starting at zero) until it finds a place to allocate that 64-
1967 bit field such that at least 31 contiguous (and previously unallocated)
1968 bits remain within that selected 64 bit field. (As it turns out, for
1969 the example above, the compiler finds that it is OK to allocate the
1970 "containing object" 64-bit field at bit-offset zero within the
1973 Here we attempt to work backwards from the limited set of facts we're
1974 given, and we try to deduce from those facts, where GCC must have
1975 believed that the containing object started (within the structure type).
1977 The value we deduce is then used (by the callers of this routine) to
1978 generate AT_location and AT_bit_offset attributes for fields (both
1979 bit-fields and, in the case of AT_location, regular fields as well).
1982 /* Figure out the bit-distance from the start of the structure to the
1983 "deepest" bit of the bit-field. */
1984 deepest_bitpos = bitpos_int + field_size_in_bits;
1986 /* This is the tricky part. Use some fancy footwork to deduce where the
1987 lowest addressed bit of the containing object must be. */
1988 object_offset_in_bits
1989 = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits;
1991 /* Compute the offset of the containing object in "alignment units". */
1992 object_offset_in_align_units = object_offset_in_bits / type_align_in_bits;
1994 /* Compute the offset of the containing object in bytes. */
1995 object_offset_in_bytes = object_offset_in_align_units * type_align_in_bytes;
1997 return object_offset_in_bytes;
2000 /****************************** attributes *********************************/
2002 /* The following routines are responsible for writing out the various types
2003 of Dwarf attributes (and any following data bytes associated with them).
2004 These routines are listed in order based on the numerical codes of their
2005 associated attributes. */
2007 /* Generate an AT_sibling attribute. */
2010 sibling_attribute ()
2012 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2014 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sibling);
2015 sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
2016 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2019 /* Output the form of location attributes suitable for whole variables and
2020 whole parameters. Note that the location attributes for struct fields
2021 are generated by the routine `data_member_location_attribute' below. */
2024 location_attribute (rtl)
2027 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2028 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2030 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
2031 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
2032 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
2033 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2034 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2036 /* Handle a special case. If we are about to output a location descriptor
2037 for a variable or parameter which has been optimized out of existence,
2038 don't do that. Instead we output a zero-length location descriptor
2039 value as part of the location attribute.
2041 A variable which has been optimized out of existence will have a
2042 DECL_RTL value which denotes a pseudo-reg.
2044 Currently, in some rare cases, variables can have DECL_RTL values
2045 which look like (MEM (REG pseudo-reg#)). These cases are due to
2046 bugs elsewhere in the compiler. We treat such cases
2047 as if the variable(s) in question had been optimized out of existence.
2049 Note that in all cases where we wish to express the fact that a
2050 variable has been optimized out of existence, we do not simply
2051 suppress the generation of the entire location attribute because
2052 the absence of a location attribute in certain kinds of DIEs is
2053 used to indicate something else entirely... i.e. that the DIE
2054 represents an object declaration, but not a definition. So saith
2058 if (! is_pseudo_reg (rtl)
2059 && (GET_CODE (rtl) != MEM || ! is_pseudo_reg (XEXP (rtl, 0))))
2060 output_loc_descriptor (eliminate_regs (rtl, 0, NULL_RTX));
2062 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2065 /* Output the specialized form of location attribute used for data members
2066 of struct and union types.
2068 In the special case of a FIELD_DECL node which represents a bit-field,
2069 the "offset" part of this special location descriptor must indicate the
2070 distance in bytes from the lowest-addressed byte of the containing
2071 struct or union type to the lowest-addressed byte of the "containing
2072 object" for the bit-field. (See the `field_byte_offset' function above.)
2074 For any given bit-field, the "containing object" is a hypothetical
2075 object (of some integral or enum type) within which the given bit-field
2076 lives. The type of this hypothetical "containing object" is always the
2077 same as the declared type of the individual bit-field itself (for GCC
2078 anyway... the DWARF spec doesn't actually mandate this).
2080 Note that it is the size (in bytes) of the hypothetical "containing
2081 object" which will be given in the AT_byte_size attribute for this
2082 bit-field. (See the `byte_size_attribute' function below.) It is
2083 also used when calculating the value of the AT_bit_offset attribute.
2084 (See the `bit_offset_attribute' function below.)
2088 data_member_location_attribute (decl)
2091 register unsigned object_offset_in_bytes = field_byte_offset (decl);
2092 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2093 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2095 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
2096 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
2097 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
2098 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2099 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2100 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
2101 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, object_offset_in_bytes);
2102 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
2103 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2106 /* Output an AT_const_value attribute for a variable or a parameter which
2107 does not have a "location" either in memory or in a register. These
2108 things can arise in GNU C when a constant is passed as an actual
2109 parameter to an inlined function. They can also arise in C++ where
2110 declared constants do not necessarily get memory "homes". */
2113 const_value_attribute (rtl)
2116 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2117 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2119 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_const_value_block4);
2120 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
2121 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
2122 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
2123 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2125 switch (GET_CODE (rtl))
2128 /* Note that a CONST_INT rtx could represent either an integer or
2129 a floating-point constant. A CONST_INT is used whenever the
2130 constant will fit into a single word. In all such cases, the
2131 original mode of the constant value is wiped out, and the
2132 CONST_INT rtx is assigned VOIDmode. Since we no longer have
2133 precise mode information for these constants, we always just
2134 output them using 4 bytes. */
2136 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, (unsigned) INTVAL (rtl));
2140 /* Note that a CONST_DOUBLE rtx could represent either an integer
2141 or a floating-point constant. A CONST_DOUBLE is used whenever
2142 the constant requires more than one word in order to be adequately
2143 represented. In all such cases, the original mode of the constant
2144 value is preserved as the mode of the CONST_DOUBLE rtx, but for
2145 simplicity we always just output CONST_DOUBLEs using 8 bytes. */
2147 ASM_OUTPUT_DWARF_DATA8 (asm_out_file,
2148 (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (rtl),
2149 (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (rtl));
2153 ASM_OUTPUT_DWARF_STRING (asm_out_file, XSTR (rtl, 0));
2159 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
2163 /* In cases where an inlined instance of an inline function is passed
2164 the address of an `auto' variable (which is local to the caller)
2165 we can get a situation where the DECL_RTL of the artificial
2166 local variable (for the inlining) which acts as a stand-in for
2167 the corresponding formal parameter (of the inline function)
2168 will look like (plus:SI (reg:SI FRAME_PTR) (const_int ...)).
2169 This is not exactly a compile-time constant expression, but it
2170 isn't the address of the (artificial) local variable either.
2171 Rather, it represents the *value* which the artificial local
2172 variable always has during its lifetime. We currently have no
2173 way to represent such quasi-constant values in Dwarf, so for now
2174 we just punt and generate an AT_const_value attribute with form
2175 FORM_BLOCK4 and a length of zero. */
2179 abort (); /* No other kinds of rtx should be possible here. */
2182 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2185 /* Generate *either* an AT_location attribute or else an AT_const_value
2186 data attribute for a variable or a parameter. We generate the
2187 AT_const_value attribute only in those cases where the given
2188 variable or parameter does not have a true "location" either in
2189 memory or in a register. This can happen (for example) when a
2190 constant is passed as an actual argument in a call to an inline
2191 function. (It's possible that these things can crop up in other
2192 ways also.) Note that one type of constant value which can be
2193 passed into an inlined function is a constant pointer. This can
2194 happen for example if an actual argument in an inlined function
2195 call evaluates to a compile-time constant address. */
2198 location_or_const_value_attribute (decl)
2203 if (TREE_CODE (decl) == ERROR_MARK)
2206 if ((TREE_CODE (decl) != VAR_DECL) && (TREE_CODE (decl) != PARM_DECL))
2208 /* Should never happen. */
2213 /* Here we have to decide where we are going to say the parameter "lives"
2214 (as far as the debugger is concerned). We only have a couple of choices.
2215 GCC provides us with DECL_RTL and with DECL_INCOMING_RTL. DECL_RTL
2216 normally indicates where the parameter lives during most of the activa-
2217 tion of the function. If optimization is enabled however, this could
2218 be either NULL or else a pseudo-reg. Both of those cases indicate that
2219 the parameter doesn't really live anywhere (as far as the code generation
2220 parts of GCC are concerned) during most of the function's activation.
2221 That will happen (for example) if the parameter is never referenced
2222 within the function.
2224 We could just generate a location descriptor here for all non-NULL
2225 non-pseudo values of DECL_RTL and ignore all of the rest, but we can
2226 be a little nicer than that if we also consider DECL_INCOMING_RTL in
2227 cases where DECL_RTL is NULL or is a pseudo-reg.
2229 Note however that we can only get away with using DECL_INCOMING_RTL as
2230 a backup substitute for DECL_RTL in certain limited cases. In cases
2231 where DECL_ARG_TYPE(decl) indicates the same type as TREE_TYPE(decl)
2232 we can be sure that the parameter was passed using the same type as it
2233 is declared to have within the function, and that its DECL_INCOMING_RTL
2234 points us to a place where a value of that type is passed. In cases
2235 where DECL_ARG_TYPE(decl) and TREE_TYPE(decl) are different types
2236 however, we cannot (in general) use DECL_INCOMING_RTL as a backup
2237 substitute for DECL_RTL because in these cases, DECL_INCOMING_RTL
2238 points us to a value of some type which is *different* from the type
2239 of the parameter itself. Thus, if we tried to use DECL_INCOMING_RTL
2240 to generate a location attribute in such cases, the debugger would
2241 end up (for example) trying to fetch a `float' from a place which
2242 actually contains the first part of a `double'. That would lead to
2243 really incorrect and confusing output at debug-time, and we don't
2244 want that now do we?
2246 So in general, we DO NOT use DECL_INCOMING_RTL as a backup for DECL_RTL
2247 in cases where DECL_ARG_TYPE(decl) != TREE_TYPE(decl). There are a
2248 couple of cute exceptions however. On little-endian machines we can
2249 get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE(decl) is
2250 not the same as TREE_TYPE(decl) but only when DECL_ARG_TYPE(decl) is
2251 an integral type which is smaller than TREE_TYPE(decl). These cases
2252 arise when (on a little-endian machine) a non-prototyped function has
2253 a parameter declared to be of type `short' or `char'. In such cases,
2254 TREE_TYPE(decl) will be `short' or `char', DECL_ARG_TYPE(decl) will be
2255 `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
2256 passed `int' value. If the debugger then uses that address to fetch a
2257 `short' or a `char' (on a little-endian machine) the result will be the
2258 correct data, so we allow for such exceptional cases below.
2260 Note that our goal here is to describe the place where the given formal
2261 parameter lives during most of the function's activation (i.e. between
2262 the end of the prologue and the start of the epilogue). We'll do that
2263 as best as we can. Note however that if the given formal parameter is
2264 modified sometime during the execution of the function, then a stack
2265 backtrace (at debug-time) will show the function as having been called
2266 with the *new* value rather than the value which was originally passed
2267 in. This happens rarely enough that it is not a major problem, but it
2268 *is* a problem, and I'd like to fix it. A future version of dwarfout.c
2269 may generate two additional attributes for any given TAG_formal_parameter
2270 DIE which will describe the "passed type" and the "passed location" for
2271 the given formal parameter in addition to the attributes we now generate
2272 to indicate the "declared type" and the "active location" for each
2273 parameter. This additional set of attributes could be used by debuggers
2274 for stack backtraces.
2276 Separately, note that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL
2277 can be NULL also. This happens (for example) for inlined-instances of
2278 inline function formal parameters which are never referenced. This really
2279 shouldn't be happening. All PARM_DECL nodes should get valid non-NULL
2280 DECL_INCOMING_RTL values, but integrate.c doesn't currently generate
2281 these values for inlined instances of inline function parameters, so
2282 when we see such cases, we are just SOL (shit-out-of-luck) for the time
2283 being (until integrate.c gets fixed).
2286 /* Use DECL_RTL as the "location" unless we find something better. */
2287 rtl = DECL_RTL (decl);
2289 if (TREE_CODE (decl) == PARM_DECL)
2290 if (rtl == NULL_RTX || is_pseudo_reg (rtl))
2292 /* This decl represents a formal parameter which was optimized out. */
2293 register tree declared_type = type_main_variant (TREE_TYPE (decl));
2294 register tree passed_type = type_main_variant (DECL_ARG_TYPE (decl));
2296 /* Note that DECL_INCOMING_RTL may be NULL in here, but we handle
2297 *all* cases where (rtl == NULL_RTX) just below. */
2299 if (declared_type == passed_type)
2300 rtl = DECL_INCOMING_RTL (decl);
2301 else if (! BYTES_BIG_ENDIAN)
2302 if (TREE_CODE (declared_type) == INTEGER_TYPE)
2303 if (TYPE_SIZE (declared_type) <= TYPE_SIZE (passed_type))
2304 rtl = DECL_INCOMING_RTL (decl);
2307 if (rtl == NULL_RTX)
2310 switch (GET_CODE (rtl))
2318 case PLUS: /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
2319 const_value_attribute (rtl);
2325 location_attribute (rtl);
2329 abort (); /* Should never happen. */
2333 /* Generate an AT_name attribute given some string value to be included as
2334 the value of the attribute. */
2337 name_attribute (name_string)
2338 register char *name_string;
2340 if (name_string && *name_string)
2342 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_name);
2343 ASM_OUTPUT_DWARF_STRING (asm_out_file, name_string);
2348 fund_type_attribute (ft_code)
2349 register unsigned ft_code;
2351 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_fund_type);
2352 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, ft_code);
2356 mod_fund_type_attribute (type, decl_const, decl_volatile)
2358 register int decl_const;
2359 register int decl_volatile;
2361 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2362 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2364 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_fund_type);
2365 sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
2366 sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
2367 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2368 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2369 write_modifier_bytes (type, decl_const, decl_volatile);
2370 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
2371 fundamental_type_code (root_type (type)));
2372 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2376 user_def_type_attribute (type)
2379 char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
2381 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_user_def_type);
2382 sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (type));
2383 ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
2387 mod_u_d_type_attribute (type, decl_const, decl_volatile)
2389 register int decl_const;
2390 register int decl_volatile;
2392 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2393 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2394 char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
2396 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_u_d_type);
2397 sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
2398 sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
2399 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2400 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2401 write_modifier_bytes (type, decl_const, decl_volatile);
2402 sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (root_type (type)));
2403 ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
2404 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2407 #ifdef USE_ORDERING_ATTRIBUTE
2409 ordering_attribute (ordering)
2410 register unsigned ordering;
2412 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_ordering);
2413 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, ordering);
2415 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
2417 /* Note that the block of subscript information for an array type also
2418 includes information about the element type of type given array type. */
2421 subscript_data_attribute (type)
2424 register unsigned dimension_number;
2425 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2426 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2428 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_subscr_data);
2429 sprintf (begin_label, SS_BEGIN_LABEL_FMT, current_dienum);
2430 sprintf (end_label, SS_END_LABEL_FMT, current_dienum);
2431 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2432 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2434 /* The GNU compilers represent multidimensional array types as sequences
2435 of one dimensional array types whose element types are themselves array
2436 types. Here we squish that down, so that each multidimensional array
2437 type gets only one array_type DIE in the Dwarf debugging info. The
2438 draft Dwarf specification say that we are allowed to do this kind
2439 of compression in C (because there is no difference between an
2440 array or arrays and a multidimensional array in C) but for other
2441 source languages (e.g. Ada) we probably shouldn't do this. */
2443 for (dimension_number = 0;
2444 TREE_CODE (type) == ARRAY_TYPE;
2445 type = TREE_TYPE (type), dimension_number++)
2447 register tree domain = TYPE_DOMAIN (type);
2449 /* Arrays come in three flavors. Unspecified bounds, fixed
2450 bounds, and (in GNU C only) variable bounds. Handle all
2451 three forms here. */
2455 /* We have an array type with specified bounds. */
2457 register tree lower = TYPE_MIN_VALUE (domain);
2458 register tree upper = TYPE_MAX_VALUE (domain);
2460 /* Handle only fundamental types as index types for now. */
2462 if (! type_is_fundamental (domain))
2465 /* Output the representation format byte for this dimension. */
2467 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file,
2469 TREE_CODE (lower) == INTEGER_CST,
2470 TREE_CODE (upper) == INTEGER_CST));
2472 /* Output the index type for this dimension. */
2474 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
2475 fundamental_type_code (domain));
2477 /* Output the representation for the lower bound. */
2479 output_bound_representation (lower, dimension_number, 'l');
2481 /* Output the representation for the upper bound. */
2483 output_bound_representation (upper, dimension_number, 'u');
2487 /* We have an array type with an unspecified length. For C and
2488 C++ we can assume that this really means that (a) the index
2489 type is an integral type, and (b) the lower bound is zero.
2490 Note that Dwarf defines the representation of an unspecified
2491 (upper) bound as being a zero-length location description. */
2493 /* Output the array-bounds format byte. */
2495 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_FT_C_X);
2497 /* Output the (assumed) index type. */
2499 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, FT_integer);
2501 /* Output the (assumed) lower bound (constant) value. */
2503 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
2505 /* Output the (empty) location description for the upper bound. */
2507 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0);
2511 /* Output the prefix byte that says that the element type is coming up. */
2513 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_ET);
2515 /* Output a representation of the type of the elements of this array type. */
2517 type_attribute (type, 0, 0);
2519 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2523 byte_size_attribute (tree_node)
2524 register tree tree_node;
2526 register unsigned size;
2528 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_byte_size);
2529 switch (TREE_CODE (tree_node))
2538 case QUAL_UNION_TYPE:
2539 size = int_size_in_bytes (tree_node);
2543 /* For a data member of a struct or union, the AT_byte_size is
2544 generally given as the number of bytes normally allocated for
2545 an object of the *declared* type of the member itself. This
2546 is true even for bit-fields. */
2547 size = simple_type_size_in_bits (field_type (tree_node))
2555 /* Note that `size' might be -1 when we get to this point. If it
2556 is, that indicates that the byte size of the entity in question
2557 is variable. We have no good way of expressing this fact in Dwarf
2558 at the present time, so just let the -1 pass on through. */
2560 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, size);
2563 /* For a FIELD_DECL node which represents a bit-field, output an attribute
2564 which specifies the distance in bits from the highest order bit of the
2565 "containing object" for the bit-field to the highest order bit of the
2568 For any given bit-field, the "containing object" is a hypothetical
2569 object (of some integral or enum type) within which the given bit-field
2570 lives. The type of this hypothetical "containing object" is always the
2571 same as the declared type of the individual bit-field itself.
2573 The determination of the exact location of the "containing object" for
2574 a bit-field is rather complicated. It's handled by the `field_byte_offset'
2577 Note that it is the size (in bytes) of the hypothetical "containing
2578 object" which will be given in the AT_byte_size attribute for this
2579 bit-field. (See `byte_size_attribute' above.) */
2582 bit_offset_attribute (decl)
2585 register unsigned object_offset_in_bytes = field_byte_offset (decl);
2586 register tree type = DECL_BIT_FIELD_TYPE (decl);
2587 register tree bitpos_tree = DECL_FIELD_BITPOS (decl);
2588 register unsigned bitpos_int;
2589 register unsigned highest_order_object_bit_offset;
2590 register unsigned highest_order_field_bit_offset;
2591 register unsigned bit_offset;
2593 assert (TREE_CODE (decl) == FIELD_DECL); /* Must be a field. */
2594 assert (type); /* Must be a bit field. */
2596 /* We can't yet handle bit-fields whose offsets are variable, so if we
2597 encounter such things, just return without generating any attribute
2600 if (TREE_CODE (bitpos_tree) != INTEGER_CST)
2602 bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
2604 /* Note that the bit offset is always the distance (in bits) from the
2605 highest-order bit of the "containing object" to the highest-order
2606 bit of the bit-field itself. Since the "high-order end" of any
2607 object or field is different on big-endian and little-endian machines,
2608 the computation below must take account of these differences. */
2610 highest_order_object_bit_offset = object_offset_in_bytes * BITS_PER_UNIT;
2611 highest_order_field_bit_offset = bitpos_int;
2613 if (! BYTES_BIG_ENDIAN)
2615 highest_order_field_bit_offset
2616 += (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl));
2618 highest_order_object_bit_offset += simple_type_size_in_bits (type);
2623 ? highest_order_object_bit_offset - highest_order_field_bit_offset
2624 : highest_order_field_bit_offset - highest_order_object_bit_offset);
2626 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_offset);
2627 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, bit_offset);
2630 /* For a FIELD_DECL node which represents a bit field, output an attribute
2631 which specifies the length in bits of the given field. */
2634 bit_size_attribute (decl)
2637 assert (TREE_CODE (decl) == FIELD_DECL); /* Must be a field. */
2638 assert (DECL_BIT_FIELD_TYPE (decl)); /* Must be a bit field. */
2640 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_size);
2641 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
2642 (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl)));
2645 /* The following routine outputs the `element_list' attribute for enumeration
2646 type DIEs. The element_lits attribute includes the names and values of
2647 all of the enumeration constants associated with the given enumeration
2651 element_list_attribute (element)
2652 register tree element;
2654 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2655 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2657 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_element_list);
2658 sprintf (begin_label, EE_BEGIN_LABEL_FMT, current_dienum);
2659 sprintf (end_label, EE_END_LABEL_FMT, current_dienum);
2660 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
2661 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2663 /* Here we output a list of value/name pairs for each enumeration constant
2664 defined for this enumeration type (as required), but we do it in REVERSE
2665 order. The order is the one required by the draft #5 Dwarf specification
2666 published by the UI/PLSIG. */
2668 output_enumeral_list (element); /* Recursively output the whole list. */
2670 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2673 /* Generate an AT_stmt_list attribute. These are normally present only in
2674 DIEs with a TAG_compile_unit tag. */
2677 stmt_list_attribute (label)
2678 register char *label;
2680 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_stmt_list);
2681 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2682 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
2685 /* Generate an AT_low_pc attribute for a label DIE, a lexical_block DIE or
2686 for a subroutine DIE. */
2689 low_pc_attribute (asm_low_label)
2690 register char *asm_low_label;
2692 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_low_pc);
2693 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_low_label);
2696 /* Generate an AT_high_pc attribute for a lexical_block DIE or for a
2700 high_pc_attribute (asm_high_label)
2701 register char *asm_high_label;
2703 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_high_pc);
2704 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_high_label);
2707 /* Generate an AT_body_begin attribute for a subroutine DIE. */
2710 body_begin_attribute (asm_begin_label)
2711 register char *asm_begin_label;
2713 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_begin);
2714 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_begin_label);
2717 /* Generate an AT_body_end attribute for a subroutine DIE. */
2720 body_end_attribute (asm_end_label)
2721 register char *asm_end_label;
2723 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_end);
2724 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_end_label);
2727 /* Generate an AT_language attribute given a LANG value. These attributes
2728 are used only within TAG_compile_unit DIEs. */
2731 language_attribute (language_code)
2732 register unsigned language_code;
2734 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_language);
2735 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, language_code);
2739 member_attribute (context)
2740 register tree context;
2742 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2744 /* Generate this attribute only for members in C++. */
2746 if (context != NULL && is_tagged_type (context))
2748 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_member);
2749 sprintf (label, TYPE_NAME_FMT, TYPE_UID (context));
2750 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2755 string_length_attribute (upper_bound)
2756 register tree upper_bound;
2758 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2759 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2761 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_string_length);
2762 sprintf (begin_label, SL_BEGIN_LABEL_FMT, current_dienum);
2763 sprintf (end_label, SL_END_LABEL_FMT, current_dienum);
2764 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2765 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2766 output_bound_representation (upper_bound, 0, 'u');
2767 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2771 comp_dir_attribute (dirname)
2772 register char *dirname;
2774 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_comp_dir);
2775 ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname);
2779 sf_names_attribute (sf_names_start_label)
2780 register char *sf_names_start_label;
2782 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sf_names);
2783 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2784 ASM_OUTPUT_DWARF_ADDR (asm_out_file, sf_names_start_label);
2788 src_info_attribute (src_info_start_label)
2789 register char *src_info_start_label;
2791 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_info);
2792 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2793 ASM_OUTPUT_DWARF_ADDR (asm_out_file, src_info_start_label);
2797 mac_info_attribute (mac_info_start_label)
2798 register char *mac_info_start_label;
2800 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mac_info);
2801 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2802 ASM_OUTPUT_DWARF_ADDR (asm_out_file, mac_info_start_label);
2806 prototyped_attribute (func_type)
2807 register tree func_type;
2809 if ((strcmp (language_string, "GNU C") == 0)
2810 && (TYPE_ARG_TYPES (func_type) != NULL))
2812 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_prototyped);
2813 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
2818 producer_attribute (producer)
2819 register char *producer;
2821 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_producer);
2822 ASM_OUTPUT_DWARF_STRING (asm_out_file, producer);
2826 inline_attribute (decl)
2829 if (DECL_INLINE (decl))
2831 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_inline);
2832 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
2837 containing_type_attribute (containing_type)
2838 register tree containing_type;
2840 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2842 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_containing_type);
2843 sprintf (label, TYPE_NAME_FMT, TYPE_UID (containing_type));
2844 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2848 abstract_origin_attribute (origin)
2849 register tree origin;
2851 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2853 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_abstract_origin);
2854 switch (TREE_CODE_CLASS (TREE_CODE (origin)))
2857 sprintf (label, DECL_NAME_FMT, DECL_UID (origin));
2861 sprintf (label, TYPE_NAME_FMT, TYPE_UID (origin));
2865 abort (); /* Should never happen. */
2868 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2871 #ifdef DWARF_DECL_COORDINATES
2873 src_coords_attribute (src_fileno, src_lineno)
2874 register unsigned src_fileno;
2875 register unsigned src_lineno;
2877 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_coords);
2878 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_fileno);
2879 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_lineno);
2881 #endif /* defined(DWARF_DECL_COORDINATES) */
2884 pure_or_virtual_attribute (func_decl)
2885 register tree func_decl;
2887 if (DECL_VIRTUAL_P (func_decl))
2889 #if 0 /* DECL_ABSTRACT_VIRTUAL_P is C++-specific. */
2890 if (DECL_ABSTRACT_VIRTUAL_P (func_decl))
2891 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_pure_virtual);
2894 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
2895 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
2899 /************************* end of attributes *****************************/
2901 /********************* utility routines for DIEs *************************/
2903 /* Output an AT_name attribute and an AT_src_coords attribute for the
2904 given decl, but only if it actually has a name. */
2907 name_and_src_coords_attributes (decl)
2910 register tree decl_name = DECL_NAME (decl);
2912 if (decl_name && IDENTIFIER_POINTER (decl_name))
2914 name_attribute (IDENTIFIER_POINTER (decl_name));
2915 #ifdef DWARF_DECL_COORDINATES
2917 register unsigned file_index;
2919 /* This is annoying, but we have to pop out of the .debug section
2920 for a moment while we call `lookup_filename' because calling it
2921 may cause a temporary switch into the .debug_sfnames section and
2922 most svr4 assemblers are not smart enough be be able to nest
2923 section switches to any depth greater than one. Note that we
2924 also can't skirt this issue by delaying all output to the
2925 .debug_sfnames section unit the end of compilation because that
2926 would cause us to have inter-section forward references and
2927 Fred Fish sez that m68k/svr4 assemblers botch those. */
2929 ASM_OUTPUT_POP_SECTION (asm_out_file);
2930 file_index = lookup_filename (DECL_SOURCE_FILE (decl));
2931 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
2933 src_coords_attribute (file_index, DECL_SOURCE_LINE (decl));
2935 #endif /* defined(DWARF_DECL_COORDINATES) */
2939 /* Many forms of DIEs contain a "type description" part. The following
2940 routine writes out these "type descriptor" parts. */
2943 type_attribute (type, decl_const, decl_volatile)
2945 register int decl_const;
2946 register int decl_volatile;
2948 register enum tree_code code = TREE_CODE (type);
2949 register int root_type_modified;
2951 if (TREE_CODE (type) == ERROR_MARK)
2954 /* Handle a special case. For functions whose return type is void,
2955 we generate *no* type attribute. (Note that no object may have
2956 type `void', so this only applies to function return types. */
2958 if (TREE_CODE (type) == VOID_TYPE)
2961 root_type_modified = (code == POINTER_TYPE || code == REFERENCE_TYPE
2962 || decl_const || decl_volatile
2963 || TYPE_READONLY (type) || TYPE_VOLATILE (type));
2965 if (type_is_fundamental (root_type (type)))
2966 if (root_type_modified)
2967 mod_fund_type_attribute (type, decl_const, decl_volatile);
2969 fund_type_attribute (fundamental_type_code (type));
2971 if (root_type_modified)
2972 mod_u_d_type_attribute (type, decl_const, decl_volatile);
2974 /* We have to get the type_main_variant here (and pass that to the
2975 `user_def_type_attribute' routine) because the ..._TYPE node we
2976 have might simply be a *copy* of some original type node (where
2977 the copy was created to help us keep track of typedef names)
2978 and that copy might have a different TYPE_UID from the original
2979 ..._TYPE node. (Note that when `equate_type_number_to_die_number'
2980 is labeling a given type DIE for future reference, it always and
2981 only creates labels for DIEs representing *main variants*, and it
2982 never even knows about non-main-variants.) */
2983 user_def_type_attribute (type_main_variant (type));
2986 /* Given a tree pointer to a struct, class, union, or enum type node, return
2987 a pointer to the (string) tag name for the given type, or zero if the
2988 type was declared without a tag. */
2994 register char *name = 0;
2996 if (TYPE_NAME (type) != 0)
2998 register tree t = 0;
3000 /* Find the IDENTIFIER_NODE for the type name. */
3001 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
3002 t = TYPE_NAME (type);
3004 /* The g++ front end makes the TYPE_NAME of *each* tagged type point
3005 to a TYPE_DECL node, regardless of whether or not a `typedef' was
3006 involved. This is distinctly different from what the gcc front-end
3007 does. It always makes the TYPE_NAME for each tagged type be either
3008 NULL (signifying an anonymous tagged type) or else a pointer to an
3009 IDENTIFIER_NODE. Obviously, we would like to generate correct Dwarf
3010 for both C and C++, but given this inconsistency in the TREE
3011 representation of tagged types for C and C++ in the GNU front-ends,
3012 we cannot support both languages correctly unless we introduce some
3013 front-end specific code here, and rms objects to that, so we can
3014 only generate correct Dwarf for one of these two languages. C is
3015 more important, so for now we'll do the right thing for C and let
3019 if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
3020 t = DECL_NAME (TYPE_NAME (type));
3022 /* Now get the name as a string, or invent one. */
3024 name = IDENTIFIER_POINTER (t);
3027 return (name == 0 || *name == '\0') ? 0 : name;
3033 /* Start by checking if the pending_sibling_stack needs to be expanded.
3034 If necessary, expand it. */
3036 if (pending_siblings == pending_siblings_allocated)
3038 pending_siblings_allocated += PENDING_SIBLINGS_INCREMENT;
3039 pending_sibling_stack
3040 = (unsigned *) xrealloc (pending_sibling_stack,
3041 pending_siblings_allocated * sizeof(unsigned));
3045 NEXT_DIE_NUM = next_unused_dienum++;
3048 /* Pop the sibling stack so that the most recently pushed DIEnum becomes the
3058 member_declared_type (member)
3059 register tree member;
3061 return (DECL_BIT_FIELD_TYPE (member))
3062 ? DECL_BIT_FIELD_TYPE (member)
3063 : TREE_TYPE (member);
3066 /* Get the function's label, as described by its RTL.
3067 This may be different from the DECL_NAME name used
3068 in the source file. */
3071 function_start_label (decl)
3077 x = DECL_RTL (decl);
3078 if (GET_CODE (x) != MEM)
3081 if (GET_CODE (x) != SYMBOL_REF)
3083 fnname = XSTR (x, 0);
3088 /******************************* DIEs ************************************/
3090 /* Output routines for individual types of DIEs. */
3092 /* Note that every type of DIE (except a null DIE) gets a sibling. */
3095 output_array_type_die (arg)
3098 register tree type = arg;
3100 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_array_type);
3101 sibling_attribute ();
3102 equate_type_number_to_die_number (type);
3103 member_attribute (TYPE_CONTEXT (type));
3105 /* I believe that we can default the array ordering. SDB will probably
3106 do the right things even if AT_ordering is not present. It's not
3107 even an issue until we start to get into multidimensional arrays
3108 anyway. If SDB is ever caught doing the Wrong Thing for multi-
3109 dimensional arrays, then we'll have to put the AT_ordering attribute
3110 back in. (But if and when we find out that we need to put these in,
3111 we will only do so for multidimensional arrays. After all, we don't
3112 want to waste space in the .debug section now do we?) */
3114 #ifdef USE_ORDERING_ATTRIBUTE
3115 ordering_attribute (ORD_row_major);
3116 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
3118 subscript_data_attribute (type);
3122 output_set_type_die (arg)
3125 register tree type = arg;
3127 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_set_type);
3128 sibling_attribute ();
3129 equate_type_number_to_die_number (type);
3130 member_attribute (TYPE_CONTEXT (type));
3131 type_attribute (TREE_TYPE (type), 0, 0);
3135 /* Implement this when there is a GNU FORTRAN or GNU Ada front end. */
3137 output_entry_point_die (arg)
3140 register tree decl = arg;
3141 register tree origin = decl_ultimate_origin (decl);
3143 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_entry_point);
3144 sibling_attribute ();
3147 abstract_origin_attribute (origin);
3150 name_and_src_coords_attributes (decl);
3151 member_attribute (DECL_CONTEXT (decl));
3152 type_attribute (TREE_TYPE (TREE_TYPE (decl)), 0, 0);
3154 if (DECL_ABSTRACT (decl))
3155 equate_decl_number_to_die_number (decl);
3157 low_pc_attribute (function_start_label (decl));
3161 /* Output a DIE to represent an inlined instance of an enumeration type. */
3164 output_inlined_enumeration_type_die (arg)
3167 register tree type = arg;
3169 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
3170 sibling_attribute ();
3171 assert (TREE_ASM_WRITTEN (type));
3172 abstract_origin_attribute (type);
3175 /* Output a DIE to represent an inlined instance of a structure type. */
3178 output_inlined_structure_type_die (arg)
3181 register tree type = arg;
3183 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
3184 sibling_attribute ();
3185 assert (TREE_ASM_WRITTEN (type));
3186 abstract_origin_attribute (type);
3189 /* Output a DIE to represent an inlined instance of a union type. */
3192 output_inlined_union_type_die (arg)
3195 register tree type = arg;
3197 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
3198 sibling_attribute ();
3199 assert (TREE_ASM_WRITTEN (type));
3200 abstract_origin_attribute (type);
3203 /* Output a DIE to represent an enumeration type. Note that these DIEs
3204 include all of the information about the enumeration values also.
3205 This information is encoded into the element_list attribute. */
3208 output_enumeration_type_die (arg)
3211 register tree type = arg;
3213 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
3214 sibling_attribute ();
3215 equate_type_number_to_die_number (type);
3216 name_attribute (type_tag (type));
3217 member_attribute (TYPE_CONTEXT (type));
3219 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
3220 given enum type is incomplete, do not generate the AT_byte_size
3221 attribute or the AT_element_list attribute. */
3223 if (TYPE_SIZE (type))
3225 byte_size_attribute (type);
3226 element_list_attribute (TYPE_FIELDS (type));
3230 /* Output a DIE to represent either a real live formal parameter decl or
3231 to represent just the type of some formal parameter position in some
3234 Note that this routine is a bit unusual because its argument may be
3235 a ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
3236 represents an inlining of some PARM_DECL) or else some sort of a
3237 ..._TYPE node. If it's the former then this function is being called
3238 to output a DIE to represent a formal parameter object (or some inlining
3239 thereof). If it's the latter, then this function is only being called
3240 to output a TAG_formal_parameter DIE to stand as a placeholder for some
3241 formal argument type of some subprogram type. */
3244 output_formal_parameter_die (arg)
3247 register tree node = arg;
3249 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_formal_parameter);
3250 sibling_attribute ();
3252 switch (TREE_CODE_CLASS (TREE_CODE (node)))
3254 case 'd': /* We were called with some kind of a ..._DECL node. */
3256 register tree origin = decl_ultimate_origin (node);
3259 abstract_origin_attribute (origin);
3262 name_and_src_coords_attributes (node);
3263 type_attribute (TREE_TYPE (node),
3264 TREE_READONLY (node), TREE_THIS_VOLATILE (node));
3266 if (DECL_ABSTRACT (node))
3267 equate_decl_number_to_die_number (node);
3269 location_or_const_value_attribute (node);
3273 case 't': /* We were called with some kind of a ..._TYPE node. */
3274 type_attribute (node, 0, 0);
3278 abort (); /* Should never happen. */
3282 /* Output a DIE to represent a declared function (either file-scope
3283 or block-local) which has "external linkage" (according to ANSI-C). */
3286 output_global_subroutine_die (arg)
3289 register tree decl = arg;
3290 register tree origin = decl_ultimate_origin (decl);
3292 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_subroutine);
3293 sibling_attribute ();
3296 abstract_origin_attribute (origin);
3299 register tree type = TREE_TYPE (decl);
3301 name_and_src_coords_attributes (decl);
3302 inline_attribute (decl);
3303 prototyped_attribute (type);
3304 member_attribute (DECL_CONTEXT (decl));
3305 type_attribute (TREE_TYPE (type), 0, 0);
3306 pure_or_virtual_attribute (decl);
3308 if (DECL_ABSTRACT (decl))
3309 equate_decl_number_to_die_number (decl);
3312 if (! DECL_EXTERNAL (decl))
3314 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3316 low_pc_attribute (function_start_label (decl));
3317 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
3318 high_pc_attribute (label);
3319 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
3320 body_begin_attribute (label);
3321 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
3322 body_end_attribute (label);
3327 /* Output a DIE to represent a declared data object (either file-scope
3328 or block-local) which has "external linkage" (according to ANSI-C). */
3331 output_global_variable_die (arg)
3334 register tree decl = arg;
3335 register tree origin = decl_ultimate_origin (decl);
3337 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_variable);
3338 sibling_attribute ();
3340 abstract_origin_attribute (origin);
3343 name_and_src_coords_attributes (decl);
3344 member_attribute (DECL_CONTEXT (decl));
3345 type_attribute (TREE_TYPE (decl),
3346 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3348 if (DECL_ABSTRACT (decl))
3349 equate_decl_number_to_die_number (decl);
3352 if (!DECL_EXTERNAL (decl))
3353 location_or_const_value_attribute (decl);
3358 output_label_die (arg)
3361 register tree decl = arg;
3362 register tree origin = decl_ultimate_origin (decl);
3364 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_label);
3365 sibling_attribute ();
3367 abstract_origin_attribute (origin);
3369 name_and_src_coords_attributes (decl);
3370 if (DECL_ABSTRACT (decl))
3371 equate_decl_number_to_die_number (decl);
3374 register rtx insn = DECL_RTL (decl);
3376 if (GET_CODE (insn) == CODE_LABEL)
3378 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3380 /* When optimization is enabled (via -O) some parts of the compiler
3381 (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
3382 represent source-level labels which were explicitly declared by
3383 the user. This really shouldn't be happening though, so catch
3384 it if it ever does happen. */
3386 if (INSN_DELETED_P (insn))
3387 abort (); /* Should never happen. */
3389 sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
3390 (unsigned) INSN_UID (insn));
3391 low_pc_attribute (label);
3397 output_lexical_block_die (arg)
3400 register tree stmt = arg;
3402 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_lexical_block);
3403 sibling_attribute ();
3405 if (! BLOCK_ABSTRACT (stmt))
3407 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3408 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3410 sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
3411 low_pc_attribute (begin_label);
3412 sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
3413 high_pc_attribute (end_label);
3418 output_inlined_subroutine_die (arg)
3421 register tree stmt = arg;
3423 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inlined_subroutine);
3424 sibling_attribute ();
3426 abstract_origin_attribute (block_ultimate_origin (stmt));
3427 if (! BLOCK_ABSTRACT (stmt))
3429 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3430 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3432 sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
3433 low_pc_attribute (begin_label);
3434 sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
3435 high_pc_attribute (end_label);
3439 /* Output a DIE to represent a declared data object (either file-scope
3440 or block-local) which has "internal linkage" (according to ANSI-C). */
3443 output_local_variable_die (arg)
3446 register tree decl = arg;
3447 register tree origin = decl_ultimate_origin (decl);
3449 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_local_variable);
3450 sibling_attribute ();
3452 abstract_origin_attribute (origin);
3455 name_and_src_coords_attributes (decl);
3456 member_attribute (DECL_CONTEXT (decl));
3457 type_attribute (TREE_TYPE (decl),
3458 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3460 if (DECL_ABSTRACT (decl))
3461 equate_decl_number_to_die_number (decl);
3463 location_or_const_value_attribute (decl);
3467 output_member_die (arg)
3470 register tree decl = arg;
3472 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_member);
3473 sibling_attribute ();
3474 name_and_src_coords_attributes (decl);
3475 member_attribute (DECL_CONTEXT (decl));
3476 type_attribute (member_declared_type (decl),
3477 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3478 if (DECL_BIT_FIELD_TYPE (decl)) /* If this is a bit field... */
3480 byte_size_attribute (decl);
3481 bit_size_attribute (decl);
3482 bit_offset_attribute (decl);
3484 data_member_location_attribute (decl);
3488 /* Don't generate either pointer_type DIEs or reference_type DIEs. Use
3489 modified types instead.
3491 We keep this code here just in case these types of DIEs may be needed
3492 to represent certain things in other languages (e.g. Pascal) someday.
3496 output_pointer_type_die (arg)
3499 register tree type = arg;
3501 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_pointer_type);
3502 sibling_attribute ();
3503 equate_type_number_to_die_number (type);
3504 member_attribute (TYPE_CONTEXT (type));
3505 type_attribute (TREE_TYPE (type), 0, 0);
3509 output_reference_type_die (arg)
3512 register tree type = arg;
3514 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_reference_type);
3515 sibling_attribute ();
3516 equate_type_number_to_die_number (type);
3517 member_attribute (TYPE_CONTEXT (type));
3518 type_attribute (TREE_TYPE (type), 0, 0);
3523 output_ptr_to_mbr_type_die (arg)
3526 register tree type = arg;
3528 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_ptr_to_member_type);
3529 sibling_attribute ();
3530 equate_type_number_to_die_number (type);
3531 member_attribute (TYPE_CONTEXT (type));
3532 containing_type_attribute (TYPE_OFFSET_BASETYPE (type));
3533 type_attribute (TREE_TYPE (type), 0, 0);
3537 output_compile_unit_die (arg)
3540 register char *main_input_filename = arg;
3542 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_compile_unit);
3543 sibling_attribute ();
3545 name_attribute (main_input_filename);
3550 sprintf (producer, "%s %s", language_string, version_string);
3551 producer_attribute (producer);
3554 if (strcmp (language_string, "GNU C++") == 0)
3555 language_attribute (LANG_C_PLUS_PLUS);
3556 else if (strcmp (language_string, "GNU Ada") == 0)
3557 language_attribute (LANG_ADA83);
3558 else if (strcmp (language_string, "GNU F77") == 0)
3559 language_attribute (LANG_FORTRAN77);
3560 else if (flag_traditional)
3561 language_attribute (LANG_C);
3563 language_attribute (LANG_C89);
3564 low_pc_attribute (TEXT_BEGIN_LABEL);
3565 high_pc_attribute (TEXT_END_LABEL);
3566 if (debug_info_level >= DINFO_LEVEL_NORMAL)
3567 stmt_list_attribute (LINE_BEGIN_LABEL);
3568 last_filename = xstrdup (main_input_filename);
3571 char *wd = getpwd ();
3573 comp_dir_attribute (wd);
3576 if (debug_info_level >= DINFO_LEVEL_NORMAL)
3578 sf_names_attribute (SFNAMES_BEGIN_LABEL);
3579 src_info_attribute (SRCINFO_BEGIN_LABEL);
3580 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
3581 mac_info_attribute (MACINFO_BEGIN_LABEL);
3586 output_string_type_die (arg)
3589 register tree type = arg;
3591 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_string_type);
3592 sibling_attribute ();
3593 member_attribute (TYPE_CONTEXT (type));
3595 /* Fudge the string length attribute for now. */
3597 string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
3601 output_structure_type_die (arg)
3604 register tree type = arg;
3606 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
3607 sibling_attribute ();
3608 equate_type_number_to_die_number (type);
3609 name_attribute (type_tag (type));
3610 member_attribute (TYPE_CONTEXT (type));
3612 /* If this type has been completed, then give it a byte_size attribute
3613 and prepare to give a list of members. Otherwise, don't do either of
3614 these things. In the latter case, we will not be generating a list
3615 of members (since we don't have any idea what they might be for an
3616 incomplete type). */
3618 if (TYPE_SIZE (type))
3621 byte_size_attribute (type);
3625 /* Output a DIE to represent a declared function (either file-scope
3626 or block-local) which has "internal linkage" (according to ANSI-C). */
3629 output_local_subroutine_die (arg)
3632 register tree decl = arg;
3633 register tree origin = decl_ultimate_origin (decl);
3635 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine);
3636 sibling_attribute ();
3639 abstract_origin_attribute (origin);
3642 register tree type = TREE_TYPE (decl);
3644 name_and_src_coords_attributes (decl);
3645 inline_attribute (decl);
3646 prototyped_attribute (type);
3647 member_attribute (DECL_CONTEXT (decl));
3648 type_attribute (TREE_TYPE (type), 0, 0);
3649 pure_or_virtual_attribute (decl);
3651 if (DECL_ABSTRACT (decl))
3652 equate_decl_number_to_die_number (decl);
3655 /* Avoid getting screwed up in cases where a function was declared
3656 static but where no definition was ever given for it. */
3658 if (TREE_ASM_WRITTEN (decl))
3660 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3661 low_pc_attribute (function_start_label (decl));
3662 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
3663 high_pc_attribute (label);
3664 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
3665 body_begin_attribute (label);
3666 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
3667 body_end_attribute (label);
3673 output_subroutine_type_die (arg)
3676 register tree type = arg;
3677 register tree return_type = TREE_TYPE (type);
3679 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine_type);
3680 sibling_attribute ();
3682 equate_type_number_to_die_number (type);
3683 prototyped_attribute (type);
3684 member_attribute (TYPE_CONTEXT (type));
3685 type_attribute (return_type, 0, 0);
3689 output_typedef_die (arg)
3692 register tree decl = arg;
3693 register tree origin = decl_ultimate_origin (decl);
3695 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_typedef);
3696 sibling_attribute ();
3698 abstract_origin_attribute (origin);
3701 name_and_src_coords_attributes (decl);
3702 member_attribute (DECL_CONTEXT (decl));
3703 type_attribute (TREE_TYPE (decl),
3704 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3706 if (DECL_ABSTRACT (decl))
3707 equate_decl_number_to_die_number (decl);
3711 output_union_type_die (arg)
3714 register tree type = arg;
3716 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
3717 sibling_attribute ();
3718 equate_type_number_to_die_number (type);
3719 name_attribute (type_tag (type));
3720 member_attribute (TYPE_CONTEXT (type));
3722 /* If this type has been completed, then give it a byte_size attribute
3723 and prepare to give a list of members. Otherwise, don't do either of
3724 these things. In the latter case, we will not be generating a list
3725 of members (since we don't have any idea what they might be for an
3726 incomplete type). */
3728 if (TYPE_SIZE (type))
3731 byte_size_attribute (type);
3735 /* Generate a special type of DIE used as a stand-in for a trailing ellipsis
3736 at the end of an (ANSI prototyped) formal parameters list. */
3739 output_unspecified_parameters_die (arg)
3742 register tree decl_or_type = arg;
3744 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_unspecified_parameters);
3745 sibling_attribute ();
3747 /* This kludge is here only for the sake of being compatible with what
3748 the USL CI5 C compiler does. The specification of Dwarf Version 1
3749 doesn't say that TAG_unspecified_parameters DIEs should contain any
3750 attributes other than the AT_sibling attribute, but they are certainly
3751 allowed to contain additional attributes, and the CI5 compiler
3752 generates AT_name, AT_fund_type, and AT_location attributes within
3753 TAG_unspecified_parameters DIEs which appear in the child lists for
3754 DIEs representing function definitions, so we do likewise here. */
3756 if (TREE_CODE (decl_or_type) == FUNCTION_DECL && DECL_INITIAL (decl_or_type))
3758 name_attribute ("...");
3759 fund_type_attribute (FT_pointer);
3760 /* location_attribute (?); */
3765 output_padded_null_die (arg)
3768 ASM_OUTPUT_ALIGN (asm_out_file, 2); /* 2**2 == 4 */
3771 /*************************** end of DIEs *********************************/
3773 /* Generate some type of DIE. This routine generates the generic outer
3774 wrapper stuff which goes around all types of DIE's (regardless of their
3775 TAGs. All forms of DIEs start with a DIE-specific label, followed by a
3776 DIE-length word, followed by the guts of the DIE itself. After the guts
3777 of the DIE, there must always be a terminator label for the DIE. */
3780 output_die (die_specific_output_function, param)
3781 register void (*die_specific_output_function)();
3782 register void *param;
3784 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3785 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3787 current_dienum = NEXT_DIE_NUM;
3788 NEXT_DIE_NUM = next_unused_dienum;
3790 sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
3791 sprintf (end_label, DIE_END_LABEL_FMT, current_dienum);
3793 /* Write a label which will act as the name for the start of this DIE. */
3795 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
3797 /* Write the DIE-length word. */
3799 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
3801 /* Fill in the guts of the DIE. */
3803 next_unused_dienum++;
3804 die_specific_output_function (param);
3806 /* Write a label which will act as the name for the end of this DIE. */
3808 ASM_OUTPUT_LABEL (asm_out_file, end_label);
3812 end_sibling_chain ()
3814 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3816 current_dienum = NEXT_DIE_NUM;
3817 NEXT_DIE_NUM = next_unused_dienum;
3819 sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
3821 /* Write a label which will act as the name for the start of this DIE. */
3823 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
3825 /* Write the DIE-length word. */
3827 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 4);
3832 /* Generate a list of nameless TAG_formal_parameter DIEs (and perhaps a
3833 TAG_unspecified_parameters DIE) to represent the types of the formal
3834 parameters as specified in some function type specification (except
3835 for those which appear as part of a function *definition*).
3837 Note that we must be careful here to output all of the parameter DIEs
3838 *before* we output any DIEs needed to represent the types of the formal
3839 parameters. This keeps svr4 SDB happy because it (incorrectly) thinks
3840 that the first non-parameter DIE it sees ends the formal parameter list.
3844 output_formal_types (function_or_method_type)
3845 register tree function_or_method_type;
3848 register tree formal_type = NULL;
3849 register tree first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
3851 /* In the case where we are generating a formal types list for a C++
3852 non-static member function type, skip over the first thing on the
3853 TYPE_ARG_TYPES list because it only represents the type of the
3854 hidden `this pointer'. The debugger should be able to figure
3855 out (without being explicitly told) that this non-static member
3856 function type takes a `this pointer' and should be able to figure
3857 what the type of that hidden parameter is from the AT_member
3858 attribute of the parent TAG_subroutine_type DIE. */
3860 if (TREE_CODE (function_or_method_type) == METHOD_TYPE)
3861 first_parm_type = TREE_CHAIN (first_parm_type);
3863 /* Make our first pass over the list of formal parameter types and output
3864 a TAG_formal_parameter DIE for each one. */
3866 for (link = first_parm_type; link; link = TREE_CHAIN (link))
3868 formal_type = TREE_VALUE (link);
3869 if (formal_type == void_type_node)
3872 /* Output a (nameless) DIE to represent the formal parameter itself. */
3874 output_die (output_formal_parameter_die, formal_type);
3877 /* If this function type has an ellipsis, add a TAG_unspecified_parameters
3878 DIE to the end of the parameter list. */
3880 if (formal_type != void_type_node)
3881 output_die (output_unspecified_parameters_die, function_or_method_type);
3883 /* Make our second (and final) pass over the list of formal parameter types
3884 and output DIEs to represent those types (as necessary). */
3886 for (link = TYPE_ARG_TYPES (function_or_method_type);
3888 link = TREE_CHAIN (link))
3890 formal_type = TREE_VALUE (link);
3891 if (formal_type == void_type_node)
3894 output_type (formal_type, function_or_method_type);
3898 /* Remember a type in the pending_types_list. */
3904 if (pending_types == pending_types_allocated)
3906 pending_types_allocated += PENDING_TYPES_INCREMENT;
3908 = (tree *) xrealloc (pending_types_list,
3909 sizeof (tree) * pending_types_allocated);
3911 pending_types_list[pending_types++] = type;
3913 /* Mark the pending type as having been output already (even though
3914 it hasn't been). This prevents the type from being added to the
3915 pending_types_list more than once. */
3917 TREE_ASM_WRITTEN (type) = 1;
3920 /* Return non-zero if it is legitimate to output DIEs to represent a
3921 given type while we are generating the list of child DIEs for some
3922 DIE (e.g. a function or lexical block DIE) associated with a given scope.
3924 See the comments within the function for a description of when it is
3925 considered legitimate to output DIEs for various kinds of types.
3927 Note that TYPE_CONTEXT(type) may be NULL (to indicate global scope)
3928 or it may point to a BLOCK node (for types local to a block), or to a
3929 FUNCTION_DECL node (for types local to the heading of some function
3930 definition), or to a FUNCTION_TYPE node (for types local to the
3931 prototyped parameter list of a function type specification), or to a
3932 RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node
3933 (in the case of C++ nested types).
3935 The `scope' parameter should likewise be NULL or should point to a
3936 BLOCK node, a FUNCTION_DECL node, a FUNCTION_TYPE node, a RECORD_TYPE
3937 node, a UNION_TYPE node, or a QUAL_UNION_TYPE node.
3939 This function is used only for deciding when to "pend" and when to
3940 "un-pend" types to/from the pending_types_list.
3942 Note that we sometimes make use of this "type pending" feature in a
3943 rather twisted way to temporarily delay the production of DIEs for the
3944 types of formal parameters. (We do this just to make svr4 SDB happy.)
3945 It order to delay the production of DIEs representing types of formal
3946 parameters, callers of this function supply `fake_containing_scope' as
3947 the `scope' parameter to this function. Given that fake_containing_scope
3948 is a tagged type which is *not* the containing scope for *any* other type,
3949 the desired effect is achieved, i.e. output of DIEs representing types
3950 is temporarily suspended, and any type DIEs which would have otherwise
3951 been output are instead placed onto the pending_types_list. Later on,
3952 we force these (temporarily pended) types to be output simply by calling
3953 `output_pending_types_for_scope' with an actual argument equal to the
3954 true scope of the types we temporarily pended. */
3957 type_ok_for_scope (type, scope)
3959 register tree scope;
3961 /* Tagged types (i.e. struct, union, and enum types) must always be
3962 output only in the scopes where they actually belong (or else the
3963 scoping of their own tag names and the scoping of their member
3964 names will be incorrect). Non-tagged-types on the other hand can
3965 generally be output anywhere, except that svr4 SDB really doesn't
3966 want to see them nested within struct or union types, so here we
3967 say it is always OK to immediately output any such a (non-tagged)
3968 type, so long as we are not within such a context. Note that the
3969 only kinds of non-tagged types which we will be dealing with here
3970 (for C and C++ anyway) will be array types and function types. */
3972 return is_tagged_type (type)
3973 ? (TYPE_CONTEXT (type) == scope)
3974 : (scope == NULL_TREE || ! is_tagged_type (scope));
3977 /* Output any pending types (from the pending_types list) which we can output
3978 now (taking into account the scope that we are working on now).
3980 For each type output, remove the given type from the pending_types_list
3981 *before* we try to output it.
3983 Note that we have to process the list in beginning-to-end order,
3984 because the call made here to output_type may cause yet more types
3985 to be added to the end of the list, and we may have to output some
3989 output_pending_types_for_scope (containing_scope)
3990 register tree containing_scope;
3992 register unsigned i;
3994 for (i = 0; i < pending_types; )
3996 register tree type = pending_types_list[i];
3998 if (type_ok_for_scope (type, containing_scope))
4000 register tree *mover;
4001 register tree *limit;
4004 limit = &pending_types_list[pending_types];
4005 for (mover = &pending_types_list[i]; mover < limit; mover++)
4006 *mover = *(mover+1);
4008 /* Un-mark the type as having been output already (because it
4009 hasn't been, really). Then call output_type to generate a
4010 Dwarf representation of it. */
4012 TREE_ASM_WRITTEN (type) = 0;
4013 output_type (type, containing_scope);
4015 /* Don't increment the loop counter in this case because we
4016 have shifted all of the subsequent pending types down one
4017 element in the pending_types_list array. */
4025 output_type (type, containing_scope)
4027 register tree containing_scope;
4029 if (type == 0 || type == error_mark_node)
4032 /* We are going to output a DIE to represent the unqualified version of
4033 of this type (i.e. without any const or volatile qualifiers) so get
4034 the main variant (i.e. the unqualified version) of this type now. */
4036 type = type_main_variant (type);
4038 if (TREE_ASM_WRITTEN (type))
4041 /* Don't generate any DIEs for this type now unless it is OK to do so
4042 (based upon what `type_ok_for_scope' tells us). */
4044 if (! type_ok_for_scope (type, containing_scope))
4050 switch (TREE_CODE (type))
4056 case REFERENCE_TYPE:
4057 /* For these types, all that is required is that we output a DIE
4058 (or a set of DIEs) to represent the "basis" type. */
4059 output_type (TREE_TYPE (type), containing_scope);
4063 /* This code is used for C++ pointer-to-data-member types. */
4064 /* Output a description of the relevant class type. */
4065 output_type (TYPE_OFFSET_BASETYPE (type), containing_scope);
4066 /* Output a description of the type of the object pointed to. */
4067 output_type (TREE_TYPE (type), containing_scope);
4068 /* Now output a DIE to represent this pointer-to-data-member type
4070 output_die (output_ptr_to_mbr_type_die, type);
4074 output_type (TYPE_DOMAIN (type), containing_scope);
4075 output_die (output_set_type_die, type);
4079 output_type (TREE_TYPE (type), containing_scope);
4080 abort (); /* No way to represent these in Dwarf yet! */
4084 /* Force out return type (in case it wasn't forced out already). */
4085 output_type (TREE_TYPE (type), containing_scope);
4086 output_die (output_subroutine_type_die, type);
4087 output_formal_types (type);
4088 end_sibling_chain ();
4092 /* Force out return type (in case it wasn't forced out already). */
4093 output_type (TREE_TYPE (type), containing_scope);
4094 output_die (output_subroutine_type_die, type);
4095 output_formal_types (type);
4096 end_sibling_chain ();
4100 if (TYPE_STRING_FLAG (type) && TREE_CODE(TREE_TYPE(type)) == CHAR_TYPE)
4102 output_type (TREE_TYPE (type), containing_scope);
4103 output_die (output_string_type_die, type);
4107 register tree element_type;
4109 element_type = TREE_TYPE (type);
4110 while (TREE_CODE (element_type) == ARRAY_TYPE)
4111 element_type = TREE_TYPE (element_type);
4113 output_type (element_type, containing_scope);
4114 output_die (output_array_type_die, type);
4121 case QUAL_UNION_TYPE:
4123 /* For a non-file-scope tagged type, we can always go ahead and
4124 output a Dwarf description of this type right now, even if
4125 the type in question is still incomplete, because if this
4126 local type *was* ever completed anywhere within its scope,
4127 that complete definition would already have been attached to
4128 this RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE or ENUMERAL_TYPE
4129 node by the time we reach this point. That's true because of the
4130 way the front-end does its processing of file-scope declarations (of
4131 functions and class types) within which other types might be
4132 nested. The C and C++ front-ends always gobble up such "local
4133 scope" things en-mass before they try to output *any* debugging
4134 information for any of the stuff contained inside them and thus,
4135 we get the benefit here of what is (in effect) a pre-resolution
4136 of forward references to tagged types in local scopes.
4138 Note however that for file-scope tagged types we cannot assume
4139 that such pre-resolution of forward references has taken place.
4140 A given file-scope tagged type may appear to be incomplete when
4141 we reach this point, but it may yet be given a full definition
4142 (at file-scope) later on during compilation. In order to avoid
4143 generating a premature (and possibly incorrect) set of Dwarf
4144 DIEs for such (as yet incomplete) file-scope tagged types, we
4145 generate nothing at all for as-yet incomplete file-scope tagged
4146 types here unless we are making our special "finalization" pass
4147 for file-scope things at the very end of compilation. At that
4148 time, we will certainly know as much about each file-scope tagged
4149 type as we are ever going to know, so at that point in time, we
4150 can safely generate correct Dwarf descriptions for these file-
4154 if (TYPE_SIZE (type) == 0 && TYPE_CONTEXT (type) == NULL && !finalizing)
4155 return; /* EARLY EXIT! Avoid setting TREE_ASM_WRITTEN. */
4157 /* Prevent infinite recursion in cases where the type of some
4158 member of this type is expressed in terms of this type itself. */
4160 TREE_ASM_WRITTEN (type) = 1;
4162 /* Output a DIE to represent the tagged type itself. */
4164 switch (TREE_CODE (type))
4167 output_die (output_enumeration_type_die, type);
4168 return; /* a special case -- nothing left to do so just return */
4171 output_die (output_structure_type_die, type);
4175 case QUAL_UNION_TYPE:
4176 output_die (output_union_type_die, type);
4180 abort (); /* Should never happen. */
4183 /* If this is not an incomplete type, output descriptions of
4184 each of its members.
4186 Note that as we output the DIEs necessary to represent the
4187 members of this record or union type, we will also be trying
4188 to output DIEs to represent the *types* of those members.
4189 However the `output_type' function (above) will specifically
4190 avoid generating type DIEs for member types *within* the list
4191 of member DIEs for this (containing) type execpt for those
4192 types (of members) which are explicitly marked as also being
4193 members of this (containing) type themselves. The g++ front-
4194 end can force any given type to be treated as a member of some
4195 other (containing) type by setting the TYPE_CONTEXT of the
4196 given (member) type to point to the TREE node representing the
4197 appropriate (containing) type.
4200 if (TYPE_SIZE (type))
4203 register tree normal_member;
4205 /* First output info about the data members and type members. */
4207 for (normal_member = TYPE_FIELDS (type);
4209 normal_member = TREE_CHAIN (normal_member))
4210 output_decl (normal_member, type);
4214 register tree vec_base;
4216 /* Now output info about the function members (if any). */
4218 vec_base = TYPE_METHODS (type);
4221 register tree first_func_member = TREE_VEC_ELT (vec_base, 0);
4222 register tree func_member;
4224 /* This isn't documented, but the first element of the
4225 vector of member functions can be NULL in cases where
4226 the class type in question didn't have either a
4227 constructor or a destructor declared for it. We have
4228 to make allowances for that here. */
4230 if (first_func_member == NULL)
4231 first_func_member = TREE_VEC_ELT (vec_base, 1);
4233 for (func_member = first_func_member;
4235 func_member = TREE_CHAIN (func_member))
4236 output_decl (func_member, type);
4240 /* RECORD_TYPEs, UNION_TYPEs, and QUAL_UNION_TYPEs are themselves
4241 scopes (at least in C++) so we must now output any nested
4242 pending types which are local just to this type. */
4244 output_pending_types_for_scope (type);
4246 end_sibling_chain (); /* Terminate member chain. */
4257 break; /* No DIEs needed for fundamental types. */
4259 case LANG_TYPE: /* No Dwarf representation currently defined. */
4266 TREE_ASM_WRITTEN (type) = 1;
4270 output_tagged_type_instantiation (type)
4273 if (type == 0 || type == error_mark_node)
4276 /* We are going to output a DIE to represent the unqualified version of
4277 of this type (i.e. without any const or volatile qualifiers) so make
4278 sure that we have the main variant (i.e. the unqualified version) of
4281 assert (type == type_main_variant (type));
4283 assert (TREE_ASM_WRITTEN (type));
4285 switch (TREE_CODE (type))
4291 output_die (output_inlined_enumeration_type_die, type);
4295 output_die (output_inlined_structure_type_die, type);
4299 case QUAL_UNION_TYPE:
4300 output_die (output_inlined_union_type_die, type);
4304 abort (); /* Should never happen. */
4308 /* Output a TAG_lexical_block DIE followed by DIEs to represent all of
4309 the things which are local to the given block. */
4315 register int must_output_die = 0;
4316 register tree origin;
4317 register enum tree_code origin_code;
4319 /* Ignore blocks never really used to make RTL. */
4321 if (! stmt || ! TREE_USED (stmt))
4324 /* Determine the "ultimate origin" of this block. This block may be an
4325 inlined instance of an inlined instance of inline function, so we
4326 have to trace all of the way back through the origin chain to find
4327 out what sort of node actually served as the original seed for the
4328 creation of the current block. */
4330 origin = block_ultimate_origin (stmt);
4331 origin_code = (origin != NULL) ? TREE_CODE (origin) : ERROR_MARK;
4333 /* Determine if we need to output any Dwarf DIEs at all to represent this
4336 if (origin_code == FUNCTION_DECL)
4337 /* The outer scopes for inlinings *must* always be represented. We
4338 generate TAG_inlined_subroutine DIEs for them. (See below.) */
4339 must_output_die = 1;
4342 /* In the case where the current block represents an inlining of the
4343 "body block" of an inline function, we must *NOT* output any DIE
4344 for this block because we have already output a DIE to represent
4345 the whole inlined function scope and the "body block" of any
4346 function doesn't really represent a different scope according to
4347 ANSI C rules. So we check here to make sure that this block does
4348 not represent a "body block inlining" before trying to set the
4349 `must_output_die' flag. */
4351 if (origin == NULL || ! is_body_block (origin))
4353 /* Determine if this block directly contains any "significant"
4354 local declarations which we will need to output DIEs for. */
4356 if (debug_info_level > DINFO_LEVEL_TERSE)
4357 /* We are not in terse mode so *any* local declaration counts
4358 as being a "significant" one. */
4359 must_output_die = (BLOCK_VARS (stmt) != NULL);
4364 /* We are in terse mode, so only local (nested) function
4365 definitions count as "significant" local declarations. */
4367 for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
4368 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
4370 must_output_die = 1;
4377 /* It would be a waste of space to generate a Dwarf TAG_lexical_block
4378 DIE for any block which contains no significant local declarations
4379 at all. Rather, in such cases we just call `output_decls_for_scope'
4380 so that any needed Dwarf info for any sub-blocks will get properly
4381 generated. Note that in terse mode, our definition of what constitutes
4382 a "significant" local declaration gets restricted to include only
4383 inlined function instances and local (nested) function definitions. */
4385 if (must_output_die)
4387 output_die ((origin_code == FUNCTION_DECL)
4388 ? output_inlined_subroutine_die
4389 : output_lexical_block_die,
4391 output_decls_for_scope (stmt);
4392 end_sibling_chain ();
4395 output_decls_for_scope (stmt);
4398 /* Output all of the decls declared within a given scope (also called
4399 a `binding contour') and (recursively) all of it's sub-blocks. */
4402 output_decls_for_scope (stmt)
4405 /* Ignore blocks never really used to make RTL. */
4407 if (! stmt || ! TREE_USED (stmt))
4410 if (! BLOCK_ABSTRACT (stmt))
4411 next_block_number++;
4413 /* Output the DIEs to represent all of the data objects, functions,
4414 typedefs, and tagged types declared directly within this block
4415 but not within any nested sub-blocks. */
4420 for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
4421 output_decl (decl, stmt);
4424 output_pending_types_for_scope (stmt);
4426 /* Output the DIEs to represent all sub-blocks (and the items declared
4427 therein) of this block. */
4430 register tree subblocks;
4432 for (subblocks = BLOCK_SUBBLOCKS (stmt);
4434 subblocks = BLOCK_CHAIN (subblocks))
4435 output_block (subblocks);
4439 /* Output Dwarf .debug information for a decl described by DECL. */
4442 output_decl (decl, containing_scope)
4444 register tree containing_scope;
4446 /* Make a note of the decl node we are going to be working on. We may
4447 need to give the user the source coordinates of where it appeared in
4448 case we notice (later on) that something about it looks screwy. */
4450 dwarf_last_decl = decl;
4452 if (TREE_CODE (decl) == ERROR_MARK)
4455 /* If a structure is declared within an initialization, e.g. as the
4456 operand of a sizeof, then it will not have a name. We don't want
4457 to output a DIE for it, as the tree nodes are in the temporary obstack */
4459 if ((TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
4460 || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE)
4461 && ((DECL_NAME (decl) == 0 && TYPE_NAME (TREE_TYPE (decl)) == 0)
4462 || (TYPE_FIELDS (TREE_TYPE (decl))
4463 && (TREE_CODE (TYPE_FIELDS (TREE_TYPE (decl))) == ERROR_MARK))))
4466 /* If this ..._DECL node is marked to be ignored, then ignore it.
4467 But don't ignore a function definition, since that would screw
4468 up our count of blocks, and that it turn will completely screw up the
4469 the labels we will reference in subsequent AT_low_pc and AT_high_pc
4470 attributes (for subsequent blocks). */
4472 if (DECL_IGNORED_P (decl) && TREE_CODE (decl) != FUNCTION_DECL)
4475 switch (TREE_CODE (decl))
4478 /* The individual enumerators of an enum type get output when we
4479 output the Dwarf representation of the relevant enum type itself. */
4483 /* If we are in terse mode, don't output any DIEs to represent
4484 mere function declarations. Also, if we are conforming
4485 to the DWARF version 1 specification, don't output DIEs for
4486 mere function declarations. */
4488 if (DECL_INITIAL (decl) == NULL_TREE)
4489 #if (DWARF_VERSION > 1)
4490 if (debug_info_level <= DINFO_LEVEL_TERSE)
4494 /* Before we describe the FUNCTION_DECL itself, make sure that we
4495 have described its return type. */
4497 output_type (TREE_TYPE (TREE_TYPE (decl)), containing_scope);
4499 /* If the following DIE will represent a function definition for a
4500 function with "extern" linkage, output a special "pubnames" DIE
4501 label just ahead of the actual DIE. A reference to this label
4502 was already generated in the .debug_pubnames section sub-entry
4503 for this function definition. */
4505 if (TREE_PUBLIC (decl))
4507 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4509 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
4510 ASM_OUTPUT_LABEL (asm_out_file, label);
4513 /* Now output a DIE to represent the function itself. */
4515 output_die (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)
4516 ? output_global_subroutine_die
4517 : output_local_subroutine_die,
4520 /* Now output descriptions of the arguments for this function.
4521 This gets (unnecessarily?) complex because of the fact that
4522 the DECL_ARGUMENT list for a FUNCTION_DECL doesn't indicate
4523 cases where there was a trailing `...' at the end of the formal
4524 parameter list. In order to find out if there was a trailing
4525 ellipsis or not, we must instead look at the type associated
4526 with the FUNCTION_DECL. This will be a node of type FUNCTION_TYPE.
4527 If the chain of type nodes hanging off of this FUNCTION_TYPE node
4528 ends with a void_type_node then there should *not* be an ellipsis
4531 /* In the case where we are describing a mere function declaration, all
4532 we need to do here (and all we *can* do here) is to describe
4533 the *types* of its formal parameters. */
4535 if (DECL_INITIAL (decl) == NULL_TREE)
4536 output_formal_types (TREE_TYPE (decl));
4539 /* Generate DIEs to represent all known formal parameters */
4541 register tree arg_decls = DECL_ARGUMENTS (decl);
4544 /* WARNING! Kludge zone ahead! Here we have a special
4545 hack for svr4 SDB compatibility. Instead of passing the
4546 current FUNCTION_DECL node as the second parameter (i.e.
4547 the `containing_scope' parameter) to `output_decl' (as
4548 we ought to) we instead pass a pointer to our own private
4549 fake_containing_scope node. That node is a RECORD_TYPE
4550 node which NO OTHER TYPE may ever actually be a member of.
4552 This pointer will ultimately get passed into `output_type'
4553 as its `containing_scope' parameter. `Output_type' will
4554 then perform its part in the hack... i.e. it will pend
4555 the type of the formal parameter onto the pending_types
4556 list. Later on, when we are done generating the whole
4557 sequence of formal parameter DIEs for this function
4558 definition, we will un-pend all previously pended types
4559 of formal parameters for this function definition.
4561 This whole kludge prevents any type DIEs from being
4562 mixed in with the formal parameter DIEs. That's good
4563 because svr4 SDB believes that the list of formal
4564 parameter DIEs for a function ends wherever the first
4565 non-formal-parameter DIE appears. Thus, we have to
4566 keep the formal parameter DIEs segregated. They must
4567 all appear (consecutively) at the start of the list of
4568 children for the DIE representing the function definition.
4569 Then (and only then) may we output any additional DIEs
4570 needed to represent the types of these formal parameters.
4574 When generating DIEs, generate the unspecified_parameters
4575 DIE instead if we come across the arg "__builtin_va_alist"
4578 for (parm = arg_decls; parm; parm = TREE_CHAIN (parm))
4579 if (TREE_CODE (parm) == PARM_DECL)
4581 if (DECL_NAME(parm) &&
4582 !strcmp(IDENTIFIER_POINTER(DECL_NAME(parm)),
4583 "__builtin_va_alist") )
4584 output_die (output_unspecified_parameters_die, decl);
4586 output_decl (parm, fake_containing_scope);
4590 Now that we have finished generating all of the DIEs to
4591 represent the formal parameters themselves, force out
4592 any DIEs needed to represent their types. We do this
4593 simply by un-pending all previously pended types which
4594 can legitimately go into the chain of children DIEs for
4595 the current FUNCTION_DECL.
4598 output_pending_types_for_scope (decl);
4601 Decide whether we need a unspecified_parameters DIE at the end.
4602 There are 2 more cases to do this for:
4603 1) the ansi ... declaration - this is detectable when the end
4604 of the arg list is not a void_type_node
4605 2) an unprototyped function declaration (not a definition). This
4606 just means that we have no info about the parameters at all.
4610 register tree fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (decl));
4614 /* this is the prototyped case, check for ... */
4615 if (TREE_VALUE (tree_last (fn_arg_types)) != void_type_node)
4616 output_die (output_unspecified_parameters_die, decl);
4620 /* this is unprototyped, check for undefined (just declaration) */
4621 if (!DECL_INITIAL (decl))
4622 output_die (output_unspecified_parameters_die, decl);
4627 /* Output Dwarf info for all of the stuff within the body of the
4628 function (if it has one - it may be just a declaration). */
4631 register tree outer_scope = DECL_INITIAL (decl);
4633 if (outer_scope && TREE_CODE (outer_scope) != ERROR_MARK)
4635 /* Note that here, `outer_scope' is a pointer to the outermost
4636 BLOCK node created to represent a function.
4637 This outermost BLOCK actually represents the outermost
4638 binding contour for the function, i.e. the contour in which
4639 the function's formal parameters and labels get declared.
4641 Curiously, it appears that the front end doesn't actually
4642 put the PARM_DECL nodes for the current function onto the
4643 BLOCK_VARS list for this outer scope. (They are strung
4644 off of the DECL_ARGUMENTS list for the function instead.)
4645 The BLOCK_VARS list for the `outer_scope' does provide us
4646 with a list of the LABEL_DECL nodes for the function however,
4647 and we output DWARF info for those here.
4649 Just within the `outer_scope' there will be another BLOCK
4650 node representing the function's outermost pair of curly
4651 braces. We mustn't generate a lexical_block DIE for this
4652 outermost pair of curly braces because that is not really an
4653 independent scope according to ANSI C rules. Rather, it is
4654 the same scope in which the parameters were declared. */
4657 register tree label;
4659 for (label = BLOCK_VARS (outer_scope);
4661 label = TREE_CHAIN (label))
4662 output_decl (label, outer_scope);
4665 /* Note here that `BLOCK_SUBBLOCKS (outer_scope)' points to a
4666 list of BLOCK nodes which is always only one element long.
4667 That one element represents the outermost pair of curley
4668 braces for the function body. */
4670 output_decls_for_scope (BLOCK_SUBBLOCKS (outer_scope));
4672 /* Finally, force out any pending types which are local to the
4673 outermost block of this function definition. These will
4674 all have a TYPE_CONTEXT which points to the FUNCTION_DECL
4677 output_pending_types_for_scope (decl);
4681 /* Generate a terminator for the list of stuff `owned' by this
4684 end_sibling_chain ();
4689 /* If we are in terse mode, don't generate any DIEs to represent
4690 any actual typedefs. Note that even when we are in terse mode,
4691 we must still output DIEs to represent those tagged types which
4692 are used (directly or indirectly) in the specification of either
4693 a return type or a formal parameter type of some function. */
4695 if (debug_info_level <= DINFO_LEVEL_TERSE)
4696 if (DECL_NAME (decl) != NULL
4697 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
4700 /* In the special case of a null-named TYPE_DECL node (representing
4701 the declaration of some type tag), if the given TYPE_DECL is
4702 marked as having been instantiated from some other (original)
4703 TYPE_DECL node (e.g. one which was generated within the original
4704 definition of an inline function) we have to generate a special
4705 (abbreviated) TAG_structure_type, TAG_union_type, or
4706 TAG_enumeration-type DIE here. */
4708 if (! DECL_NAME (decl) && DECL_ABSTRACT_ORIGIN (decl))
4710 output_tagged_type_instantiation (TREE_TYPE (decl));
4714 output_type (TREE_TYPE (decl), containing_scope);
4716 /* Note that unlike the gcc front end (which generates a NULL named
4717 TYPE_DECL node for each complete tagged type, each array type,
4718 and each function type node created) the g++ front end generates
4719 a *named* TYPE_DECL node for each tagged type node created.
4720 Unfortunately, these g++ TYPE_DECL nodes cause us to output many
4721 superfluous and unnecessary TAG_typedef DIEs here. When g++ is
4722 fixed to stop generating these superfluous named TYPE_DECL nodes,
4723 the superfluous TAG_typedef DIEs will likewise cease. */
4725 if (DECL_NAME (decl))
4726 /* Output a DIE to represent the typedef itself. */
4727 output_die (output_typedef_die, decl);
4731 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4732 output_die (output_label_die, decl);
4736 /* If we are conforming to the DWARF version 1 specification, don't
4737 generated any DIEs to represent mere external object declarations. */
4739 #if (DWARF_VERSION <= 1)
4740 if (DECL_EXTERNAL (decl) && ! TREE_PUBLIC (decl))
4744 /* If we are in terse mode, don't generate any DIEs to represent
4745 any variable declarations or definitions. */
4747 if (debug_info_level <= DINFO_LEVEL_TERSE)
4750 /* Output any DIEs that are needed to specify the type of this data
4753 output_type (TREE_TYPE (decl), containing_scope);
4755 /* If the following DIE will represent a data object definition for a
4756 data object with "extern" linkage, output a special "pubnames" DIE
4757 label just ahead of the actual DIE. A reference to this label
4758 was already generated in the .debug_pubnames section sub-entry
4759 for this data object definition. */
4761 if (TREE_PUBLIC (decl) && ! DECL_ABSTRACT (decl))
4763 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4765 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
4766 ASM_OUTPUT_LABEL (asm_out_file, label);
4769 /* Now output the DIE to represent the data object itself. This gets
4770 complicated because of the possibility that the VAR_DECL really
4771 represents an inlined instance of a formal parameter for an inline
4775 register void (*func) ();
4776 register tree origin = decl_ultimate_origin (decl);
4778 if (origin != NULL && TREE_CODE (origin) == PARM_DECL)
4779 func = output_formal_parameter_die;
4782 if (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
4783 func = output_global_variable_die;
4785 func = output_local_variable_die;
4787 output_die (func, decl);
4792 /* Ignore the nameless fields that are used to skip bits. */
4793 if (DECL_NAME (decl) != 0)
4795 output_type (member_declared_type (decl), containing_scope);
4796 output_die (output_member_die, decl);
4801 /* Force out the type of this formal, if it was not forced out yet.
4802 Note that here we can run afowl of a bug in "classic" svr4 SDB.
4803 It should be able to grok the presence of type DIEs within a list
4804 of TAG_formal_parameter DIEs, but it doesn't. */
4806 output_type (TREE_TYPE (decl), containing_scope);
4807 output_die (output_formal_parameter_die, decl);
4816 dwarfout_file_scope_decl (decl, set_finalizing)
4818 register int set_finalizing;
4820 if (TREE_CODE (decl) == ERROR_MARK)
4823 /* If this ..._DECL node is marked to be ignored, then ignore it. We
4824 gotta hope that the node in question doesn't represent a function
4825 definition. If it does, then totally ignoring it is bound to screw
4826 up our count of blocks, and that it turn will completely screw up the
4827 the labels we will reference in subsequent AT_low_pc and AT_high_pc
4828 attributes (for subsequent blocks). (It's too bad that BLOCK nodes
4829 don't carry their own sequence numbers with them!) */
4831 if (DECL_IGNORED_P (decl))
4833 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
4838 switch (TREE_CODE (decl))
4842 /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of
4843 a builtin function. Explicit programmer-supplied declarations of
4844 these same functions should NOT be ignored however. */
4846 if (DECL_EXTERNAL (decl) && DECL_FUNCTION_CODE (decl))
4849 /* What we would really like to do here is to filter out all mere
4850 file-scope declarations of file-scope functions which are never
4851 referenced later within this translation unit (and keep all of
4852 ones that *are* referenced later on) but we aren't clairvoyant,
4853 so we have no idea which functions will be referenced in the
4854 future (i.e. later on within the current translation unit).
4855 So here we just ignore all file-scope function declarations
4856 which are not also definitions. If and when the debugger needs
4857 to know something about these functions, it wil have to hunt
4858 around and find the DWARF information associated with the
4859 *definition* of the function.
4861 Note that we can't just check `DECL_EXTERNAL' to find out which
4862 FUNCTION_DECL nodes represent definitions and which ones represent
4863 mere declarations. We have to check `DECL_INITIAL' instead. That's
4864 because the C front-end supports some weird semantics for "extern
4865 inline" function definitions. These can get inlined within the
4866 current translation unit (an thus, we need to generate DWARF info
4867 for their abstract instances so that the DWARF info for the
4868 concrete inlined instances can have something to refer to) but
4869 the compiler never generates any out-of-lines instances of such
4870 things (despite the fact that they *are* definitions). The
4871 important point is that the C front-end marks these "extern inline"
4872 functions as DECL_EXTERNAL, but we need to generate DWARf for them
4875 Note that the C++ front-end also plays some similar games for inline
4876 function definitions appearing within include files which also
4877 contain `#pragma interface' pragmas. */
4879 if (DECL_INITIAL (decl) == NULL_TREE)
4882 if (TREE_PUBLIC (decl)
4883 && ! DECL_EXTERNAL (decl)
4884 && ! DECL_ABSTRACT (decl))
4886 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4888 /* Output a .debug_pubnames entry for a public function
4889 defined in this compilation unit. */
4891 fputc ('\n', asm_out_file);
4892 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
4893 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
4894 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
4895 ASM_OUTPUT_DWARF_STRING (asm_out_file,
4896 IDENTIFIER_POINTER (DECL_NAME (decl)));
4897 ASM_OUTPUT_POP_SECTION (asm_out_file);
4904 /* Ignore this VAR_DECL if it refers to a file-scope extern data
4905 object declaration and if the declaration was never even
4906 referenced from within this entire compilation unit. We
4907 suppress these DIEs in order to save space in the .debug section
4908 (by eliminating entries which are probably useless). Note that
4909 we must not suppress block-local extern declarations (whether
4910 used or not) because that would screw-up the debugger's name
4911 lookup mechanism and cause it to miss things which really ought
4912 to be in scope at a given point. */
4914 if (DECL_EXTERNAL (decl) && !TREE_USED (decl))
4917 if (TREE_PUBLIC (decl)
4918 && ! DECL_EXTERNAL (decl)
4919 && GET_CODE (DECL_RTL (decl)) == MEM
4920 && ! DECL_ABSTRACT (decl))
4922 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4924 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4926 /* Output a .debug_pubnames entry for a public variable
4927 defined in this compilation unit. */
4929 fputc ('\n', asm_out_file);
4930 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
4931 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
4932 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
4933 ASM_OUTPUT_DWARF_STRING (asm_out_file,
4934 IDENTIFIER_POINTER (DECL_NAME (decl)));
4935 ASM_OUTPUT_POP_SECTION (asm_out_file);
4938 if (DECL_INITIAL (decl) == NULL)
4940 /* Output a .debug_aranges entry for a public variable
4941 which is tentatively defined in this compilation unit. */
4943 fputc ('\n', asm_out_file);
4944 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
4945 ASM_OUTPUT_DWARF_ADDR (asm_out_file,
4946 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
4947 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
4948 (unsigned) int_size_in_bytes (TREE_TYPE (decl)));
4949 ASM_OUTPUT_POP_SECTION (asm_out_file);
4953 /* If we are in terse mode, don't generate any DIEs to represent
4954 any variable declarations or definitions. */
4956 if (debug_info_level <= DINFO_LEVEL_TERSE)
4962 /* Don't bother trying to generate any DIEs to represent any of the
4963 normal built-in types for the language we are compiling, except
4964 in cases where the types in question are *not* DWARF fundamental
4965 types. We make an exception in the case of non-fundamental types
4966 for the sake of objective C (and perhaps C++) because the GNU
4967 front-ends for these languages may in fact create certain "built-in"
4968 types which are (for example) RECORD_TYPEs. In such cases, we
4969 really need to output these (non-fundamental) types because other
4970 DIEs may contain references to them. */
4972 if (DECL_SOURCE_LINE (decl) == 0
4973 && type_is_fundamental (TREE_TYPE (decl)))
4976 /* If we are in terse mode, don't generate any DIEs to represent
4977 any actual typedefs. Note that even when we are in terse mode,
4978 we must still output DIEs to represent those tagged types which
4979 are used (directly or indirectly) in the specification of either
4980 a return type or a formal parameter type of some function. */
4982 if (debug_info_level <= DINFO_LEVEL_TERSE)
4983 if (DECL_NAME (decl) != NULL
4984 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
4993 fputc ('\n', asm_out_file);
4994 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
4995 finalizing = set_finalizing;
4996 output_decl (decl, NULL_TREE);
4998 /* NOTE: The call above to `output_decl' may have caused one or more
4999 file-scope named types (i.e. tagged types) to be placed onto the
5000 pending_types_list. We have to get those types off of that list
5001 at some point, and this is the perfect time to do it. If we didn't
5002 take them off now, they might still be on the list when cc1 finally
5003 exits. That might be OK if it weren't for the fact that when we put
5004 types onto the pending_types_list, we set the TREE_ASM_WRITTEN flag
5005 for these types, and that causes them never to be output unless
5006 `output_pending_types_for_scope' takes them off of the list and un-sets
5007 their TREE_ASM_WRITTEN flags. */
5009 output_pending_types_for_scope (NULL_TREE);
5011 /* The above call should have totally emptied the pending_types_list. */
5013 assert (pending_types == 0);
5015 ASM_OUTPUT_POP_SECTION (asm_out_file);
5017 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
5018 current_funcdef_number++;
5021 /* Output a marker (i.e. a label) for the beginning of the generated code
5022 for a lexical block. */
5025 dwarfout_begin_block (blocknum)
5026 register unsigned blocknum;
5028 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5030 function_section (current_function_decl);
5031 sprintf (label, BLOCK_BEGIN_LABEL_FMT, blocknum);
5032 ASM_OUTPUT_LABEL (asm_out_file, label);
5035 /* Output a marker (i.e. a label) for the end of the generated code
5036 for a lexical block. */
5039 dwarfout_end_block (blocknum)
5040 register unsigned blocknum;
5042 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5044 function_section (current_function_decl);
5045 sprintf (label, BLOCK_END_LABEL_FMT, blocknum);
5046 ASM_OUTPUT_LABEL (asm_out_file, label);
5049 /* Output a marker (i.e. a label) at a point in the assembly code which
5050 corresponds to a given source level label. */
5053 dwarfout_label (insn)
5056 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5058 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5060 function_section (current_function_decl);
5061 sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
5062 (unsigned) INSN_UID (insn));
5063 ASM_OUTPUT_LABEL (asm_out_file, label);
5067 /* Output a marker (i.e. a label) for the point in the generated code where
5068 the real body of the function begins (after parameters have been moved
5069 to their home locations). */
5072 dwarfout_begin_function ()
5074 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5076 function_section (current_function_decl);
5077 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
5078 ASM_OUTPUT_LABEL (asm_out_file, label);
5081 /* Output a marker (i.e. a label) for the point in the generated code where
5082 the real body of the function ends (just before the epilogue code). */
5085 dwarfout_end_function ()
5087 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5089 function_section (current_function_decl);
5090 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
5091 ASM_OUTPUT_LABEL (asm_out_file, label);
5094 /* Output a marker (i.e. a label) for the absolute end of the generated code
5095 for a function definition. This gets called *after* the epilogue code
5096 has been generated. */
5099 dwarfout_end_epilogue ()
5101 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5103 /* Output a label to mark the endpoint of the code generated for this
5106 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
5107 ASM_OUTPUT_LABEL (asm_out_file, label);
5111 shuffle_filename_entry (new_zeroth)
5112 register filename_entry *new_zeroth;
5114 filename_entry temp_entry;
5115 register filename_entry *limit_p;
5116 register filename_entry *move_p;
5118 if (new_zeroth == &filename_table[0])
5121 temp_entry = *new_zeroth;
5123 /* Shift entries up in the table to make room at [0]. */
5125 limit_p = &filename_table[0];
5126 for (move_p = new_zeroth; move_p > limit_p; move_p--)
5127 *move_p = *(move_p-1);
5129 /* Install the found entry at [0]. */
5131 filename_table[0] = temp_entry;
5134 /* Create a new (string) entry for the .debug_sfnames section. */
5137 generate_new_sfname_entry ()
5139 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5141 fputc ('\n', asm_out_file);
5142 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
5143 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, filename_table[0].number);
5144 ASM_OUTPUT_LABEL (asm_out_file, label);
5145 ASM_OUTPUT_DWARF_STRING (asm_out_file,
5146 filename_table[0].name
5147 ? filename_table[0].name
5149 ASM_OUTPUT_POP_SECTION (asm_out_file);
5152 /* Lookup a filename (in the list of filenames that we know about here in
5153 dwarfout.c) and return its "index". The index of each (known) filename
5154 is just a unique number which is associated with only that one filename.
5155 We need such numbers for the sake of generating labels (in the
5156 .debug_sfnames section) and references to those unique labels (in the
5157 .debug_srcinfo and .debug_macinfo sections).
5159 If the filename given as an argument is not found in our current list,
5160 add it to the list and assign it the next available unique index number.
5162 Whatever we do (i.e. whether we find a pre-existing filename or add a new
5163 one), we shuffle the filename found (or added) up to the zeroth entry of
5164 our list of filenames (which is always searched linearly). We do this so
5165 as to optimize the most common case for these filename lookups within
5166 dwarfout.c. The most common case by far is the case where we call
5167 lookup_filename to lookup the very same filename that we did a lookup
5168 on the last time we called lookup_filename. We make sure that this
5169 common case is fast because such cases will constitute 99.9% of the
5170 lookups we ever do (in practice).
5172 If we add a new filename entry to our table, we go ahead and generate
5173 the corresponding entry in the .debug_sfnames section right away.
5174 Doing so allows us to avoid tickling an assembler bug (present in some
5175 m68k assemblers) which yields assembly-time errors in cases where the
5176 difference of two label addresses is taken and where the two labels
5177 are in a section *other* than the one where the difference is being
5178 calculated, and where at least one of the two symbol references is a
5179 forward reference. (This bug could be tickled by our .debug_srcinfo
5180 entries if we don't output their corresponding .debug_sfnames entries
5184 lookup_filename (file_name)
5187 register filename_entry *search_p;
5188 register filename_entry *limit_p = &filename_table[ft_entries];
5190 for (search_p = filename_table; search_p < limit_p; search_p++)
5191 if (!strcmp (file_name, search_p->name))
5193 /* When we get here, we have found the filename that we were
5194 looking for in the filename_table. Now we want to make sure
5195 that it gets moved to the zero'th entry in the table (if it
5196 is not already there) so that subsequent attempts to find the
5197 same filename will find it as quickly as possible. */
5199 shuffle_filename_entry (search_p);
5200 return filename_table[0].number;
5203 /* We come here whenever we have a new filename which is not registered
5204 in the current table. Here we add it to the table. */
5206 /* Prepare to add a new table entry by making sure there is enough space
5207 in the table to do so. If not, expand the current table. */
5209 if (ft_entries == ft_entries_allocated)
5211 ft_entries_allocated += FT_ENTRIES_INCREMENT;
5213 = (filename_entry *)
5214 xrealloc (filename_table,
5215 ft_entries_allocated * sizeof (filename_entry));
5218 /* Initially, add the new entry at the end of the filename table. */
5220 filename_table[ft_entries].number = ft_entries;
5221 filename_table[ft_entries].name = xstrdup (file_name);
5223 /* Shuffle the new entry into filename_table[0]. */
5225 shuffle_filename_entry (&filename_table[ft_entries]);
5227 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5228 generate_new_sfname_entry ();
5231 return filename_table[0].number;
5235 generate_srcinfo_entry (line_entry_num, files_entry_num)
5236 unsigned line_entry_num;
5237 unsigned files_entry_num;
5239 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5241 fputc ('\n', asm_out_file);
5242 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
5243 sprintf (label, LINE_ENTRY_LABEL_FMT, line_entry_num);
5244 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, LINE_BEGIN_LABEL);
5245 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, files_entry_num);
5246 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, SFNAMES_BEGIN_LABEL);
5247 ASM_OUTPUT_POP_SECTION (asm_out_file);
5251 dwarfout_line (filename, line)
5252 register char *filename;
5253 register unsigned line;
5255 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5257 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5258 static unsigned last_line_entry_num = 0;
5259 static unsigned prev_file_entry_num = (unsigned) -1;
5260 register unsigned this_file_entry_num = lookup_filename (filename);
5262 function_section (current_function_decl);
5263 sprintf (label, LINE_CODE_LABEL_FMT, ++last_line_entry_num);
5264 ASM_OUTPUT_LABEL (asm_out_file, label);
5266 fputc ('\n', asm_out_file);
5267 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
5269 if (this_file_entry_num != prev_file_entry_num)
5271 char line_entry_label[MAX_ARTIFICIAL_LABEL_BYTES];
5273 sprintf (line_entry_label, LINE_ENTRY_LABEL_FMT, last_line_entry_num);
5274 ASM_OUTPUT_LABEL (asm_out_file, line_entry_label);
5278 register char *tail = rindex (filename, '/');
5284 fprintf (asm_out_file, "\t%s\t%u\t%s %s:%u\n",
5285 UNALIGNED_INT_ASM_OP, line, ASM_COMMENT_START,
5287 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
5288 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, TEXT_BEGIN_LABEL);
5289 ASM_OUTPUT_POP_SECTION (asm_out_file);
5291 if (this_file_entry_num != prev_file_entry_num)
5292 generate_srcinfo_entry (last_line_entry_num, this_file_entry_num);
5293 prev_file_entry_num = this_file_entry_num;
5297 /* Generate an entry in the .debug_macinfo section. */
5300 generate_macinfo_entry (type_and_offset, string)
5301 register char *type_and_offset;
5302 register char *string;
5304 fputc ('\n', asm_out_file);
5305 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
5306 fprintf (asm_out_file, "\t%s\t%s\n", UNALIGNED_INT_ASM_OP, type_and_offset);
5307 ASM_OUTPUT_DWARF_STRING (asm_out_file, string);
5308 ASM_OUTPUT_POP_SECTION (asm_out_file);
5312 dwarfout_start_new_source_file (filename)
5313 register char *filename;
5315 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5316 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*3];
5318 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, lookup_filename (filename));
5319 sprintf (type_and_offset, "0x%08x+%s-%s",
5320 ((unsigned) MACINFO_start << 24), label, SFNAMES_BEGIN_LABEL);
5321 generate_macinfo_entry (type_and_offset, "");
5325 dwarfout_resume_previous_source_file (lineno)
5326 register unsigned lineno;
5328 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
5330 sprintf (type_and_offset, "0x%08x+%u",
5331 ((unsigned) MACINFO_resume << 24), lineno);
5332 generate_macinfo_entry (type_and_offset, "");
5335 /* Called from check_newline in c-parse.y. The `buffer' parameter
5336 contains the tail part of the directive line, i.e. the part which
5337 is past the initial whitespace, #, whitespace, directive-name,
5341 dwarfout_define (lineno, buffer)
5342 register unsigned lineno;
5343 register char *buffer;
5345 static int initialized = 0;
5346 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
5350 dwarfout_start_new_source_file (primary_filename);
5353 sprintf (type_and_offset, "0x%08x+%u",
5354 ((unsigned) MACINFO_define << 24), lineno);
5355 generate_macinfo_entry (type_and_offset, buffer);
5358 /* Called from check_newline in c-parse.y. The `buffer' parameter
5359 contains the tail part of the directive line, i.e. the part which
5360 is past the initial whitespace, #, whitespace, directive-name,
5364 dwarfout_undef (lineno, buffer)
5365 register unsigned lineno;
5366 register char *buffer;
5368 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
5370 sprintf (type_and_offset, "0x%08x+%u",
5371 ((unsigned) MACINFO_undef << 24), lineno);
5372 generate_macinfo_entry (type_and_offset, buffer);
5375 /* Set up for Dwarf output at the start of compilation. */
5378 dwarfout_init (asm_out_file, main_input_filename)
5379 register FILE *asm_out_file;
5380 register char *main_input_filename;
5382 /* Remember the name of the primary input file. */
5384 primary_filename = main_input_filename;
5386 /* Allocate the initial hunk of the pending_sibling_stack. */
5388 pending_sibling_stack
5390 xmalloc (PENDING_SIBLINGS_INCREMENT * sizeof (unsigned));
5391 pending_siblings_allocated = PENDING_SIBLINGS_INCREMENT;
5392 pending_siblings = 1;
5394 /* Allocate the initial hunk of the filename_table. */
5397 = (filename_entry *)
5398 xmalloc (FT_ENTRIES_INCREMENT * sizeof (filename_entry));
5399 ft_entries_allocated = FT_ENTRIES_INCREMENT;
5402 /* Allocate the initial hunk of the pending_types_list. */
5405 = (tree *) xmalloc (PENDING_TYPES_INCREMENT * sizeof (tree));
5406 pending_types_allocated = PENDING_TYPES_INCREMENT;
5409 /* Create an artificial RECORD_TYPE node which we can use in our hack
5410 to get the DIEs representing types of formal parameters to come out
5411 only *after* the DIEs for the formal parameters themselves. */
5413 fake_containing_scope = make_node (RECORD_TYPE);
5415 /* Output a starting label for the .text section. */
5417 fputc ('\n', asm_out_file);
5418 ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
5419 ASM_OUTPUT_LABEL (asm_out_file, TEXT_BEGIN_LABEL);
5420 ASM_OUTPUT_POP_SECTION (asm_out_file);
5422 /* Output a starting label for the .data section. */
5424 fputc ('\n', asm_out_file);
5425 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
5426 ASM_OUTPUT_LABEL (asm_out_file, DATA_BEGIN_LABEL);
5427 ASM_OUTPUT_POP_SECTION (asm_out_file);
5429 #if 0 /* GNU C doesn't currently use .data1. */
5430 /* Output a starting label for the .data1 section. */
5432 fputc ('\n', asm_out_file);
5433 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
5434 ASM_OUTPUT_LABEL (asm_out_file, DATA1_BEGIN_LABEL);
5435 ASM_OUTPUT_POP_SECTION (asm_out_file);
5438 /* Output a starting label for the .rodata section. */
5440 fputc ('\n', asm_out_file);
5441 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
5442 ASM_OUTPUT_LABEL (asm_out_file, RODATA_BEGIN_LABEL);
5443 ASM_OUTPUT_POP_SECTION (asm_out_file);
5445 #if 0 /* GNU C doesn't currently use .rodata1. */
5446 /* Output a starting label for the .rodata1 section. */
5448 fputc ('\n', asm_out_file);
5449 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
5450 ASM_OUTPUT_LABEL (asm_out_file, RODATA1_BEGIN_LABEL);
5451 ASM_OUTPUT_POP_SECTION (asm_out_file);
5454 /* Output a starting label for the .bss section. */
5456 fputc ('\n', asm_out_file);
5457 ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
5458 ASM_OUTPUT_LABEL (asm_out_file, BSS_BEGIN_LABEL);
5459 ASM_OUTPUT_POP_SECTION (asm_out_file);
5461 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5463 /* Output a starting label and an initial (compilation directory)
5464 entry for the .debug_sfnames section. The starting label will be
5465 referenced by the initial entry in the .debug_srcinfo section. */
5467 fputc ('\n', asm_out_file);
5468 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
5469 ASM_OUTPUT_LABEL (asm_out_file, SFNAMES_BEGIN_LABEL);
5472 register unsigned len;
5473 register char *dirname;
5477 pfatal_with_name ("getpwd");
5479 dirname = (char *) xmalloc (len + 2);
5481 strcpy (dirname, pwd);
5482 strcpy (dirname + len, "/");
5483 ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname);
5486 ASM_OUTPUT_POP_SECTION (asm_out_file);
5488 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
5490 /* Output a starting label for the .debug_macinfo section. This
5491 label will be referenced by the AT_mac_info attribute in the
5492 TAG_compile_unit DIE. */
5494 fputc ('\n', asm_out_file);
5495 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
5496 ASM_OUTPUT_LABEL (asm_out_file, MACINFO_BEGIN_LABEL);
5497 ASM_OUTPUT_POP_SECTION (asm_out_file);
5500 /* Generate the initial entry for the .line section. */
5502 fputc ('\n', asm_out_file);
5503 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
5504 ASM_OUTPUT_LABEL (asm_out_file, LINE_BEGIN_LABEL);
5505 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, LINE_END_LABEL, LINE_BEGIN_LABEL);
5506 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
5507 ASM_OUTPUT_POP_SECTION (asm_out_file);
5509 /* Generate the initial entry for the .debug_srcinfo section. */
5511 fputc ('\n', asm_out_file);
5512 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
5513 ASM_OUTPUT_LABEL (asm_out_file, SRCINFO_BEGIN_LABEL);
5514 ASM_OUTPUT_DWARF_ADDR (asm_out_file, LINE_BEGIN_LABEL);
5515 ASM_OUTPUT_DWARF_ADDR (asm_out_file, SFNAMES_BEGIN_LABEL);
5516 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
5517 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_END_LABEL);
5518 #ifdef DWARF_TIMESTAMPS
5519 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, time (NULL));
5521 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
5523 ASM_OUTPUT_POP_SECTION (asm_out_file);
5525 /* Generate the initial entry for the .debug_pubnames section. */
5527 fputc ('\n', asm_out_file);
5528 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
5529 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
5530 ASM_OUTPUT_POP_SECTION (asm_out_file);
5532 /* Generate the initial entry for the .debug_aranges section. */
5534 fputc ('\n', asm_out_file);
5535 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
5536 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
5537 ASM_OUTPUT_POP_SECTION (asm_out_file);
5540 /* Setup first DIE number == 1. */
5541 NEXT_DIE_NUM = next_unused_dienum++;
5543 /* Generate the initial DIE for the .debug section. Note that the
5544 (string) value given in the AT_name attribute of the TAG_compile_unit
5545 DIE will (typically) be a relative pathname and that this pathname
5546 should be taken as being relative to the directory from which the
5547 compiler was invoked when the given (base) source file was compiled. */
5549 fputc ('\n', asm_out_file);
5550 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
5551 ASM_OUTPUT_LABEL (asm_out_file, DEBUG_BEGIN_LABEL);
5552 output_die (output_compile_unit_die, main_input_filename);
5553 ASM_OUTPUT_POP_SECTION (asm_out_file);
5555 fputc ('\n', asm_out_file);
5558 /* Output stuff that dwarf requires at the end of every file. */
5563 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5565 fputc ('\n', asm_out_file);
5566 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
5568 /* Mark the end of the chain of siblings which represent all file-scope
5569 declarations in this compilation unit. */
5571 /* The (null) DIE which represents the terminator for the (sibling linked)
5572 list of file-scope items is *special*. Normally, we would just call
5573 end_sibling_chain at this point in order to output a word with the
5574 value `4' and that word would act as the terminator for the list of
5575 DIEs describing file-scope items. Unfortunately, if we were to simply
5576 do that, the label that would follow this DIE in the .debug section
5577 (i.e. `..D2') would *not* be properly aligned (as it must be on some
5578 machines) to a 4 byte boundary.
5580 In order to force the label `..D2' to get aligned to a 4 byte boundary,
5581 the trick used is to insert extra (otherwise useless) padding bytes
5582 into the (null) DIE that we know must precede the ..D2 label in the
5583 .debug section. The amount of padding required can be anywhere between
5584 0 and 3 bytes. The length word at the start of this DIE (i.e. the one
5585 with the padding) would normally contain the value 4, but now it will
5586 also have to include the padding bytes, so it will instead have some
5587 value in the range 4..7.
5589 Fortunately, the rules of Dwarf say that any DIE whose length word
5590 contains *any* value less than 8 should be treated as a null DIE, so
5591 this trick works out nicely. Clever, eh? Don't give me any credit
5592 (or blame). I didn't think of this scheme. I just conformed to it.
5595 output_die (output_padded_null_die, (void *)0);
5598 sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
5599 ASM_OUTPUT_LABEL (asm_out_file, label); /* should be ..D2 */
5600 ASM_OUTPUT_POP_SECTION (asm_out_file);
5602 /* Output a terminator label for the .text section. */
5604 fputc ('\n', asm_out_file);
5605 ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
5606 ASM_OUTPUT_LABEL (asm_out_file, TEXT_END_LABEL);
5607 ASM_OUTPUT_POP_SECTION (asm_out_file);
5609 /* Output a terminator label for the .data section. */
5611 fputc ('\n', asm_out_file);
5612 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
5613 ASM_OUTPUT_LABEL (asm_out_file, DATA_END_LABEL);
5614 ASM_OUTPUT_POP_SECTION (asm_out_file);
5616 #if 0 /* GNU C doesn't currently use .data1. */
5617 /* Output a terminator label for the .data1 section. */
5619 fputc ('\n', asm_out_file);
5620 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
5621 ASM_OUTPUT_LABEL (asm_out_file, DATA1_END_LABEL);
5622 ASM_OUTPUT_POP_SECTION (asm_out_file);
5625 /* Output a terminator label for the .rodata section. */
5627 fputc ('\n', asm_out_file);
5628 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
5629 ASM_OUTPUT_LABEL (asm_out_file, RODATA_END_LABEL);
5630 ASM_OUTPUT_POP_SECTION (asm_out_file);
5632 #if 0 /* GNU C doesn't currently use .rodata1. */
5633 /* Output a terminator label for the .rodata1 section. */
5635 fputc ('\n', asm_out_file);
5636 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
5637 ASM_OUTPUT_LABEL (asm_out_file, RODATA1_END_LABEL);
5638 ASM_OUTPUT_POP_SECTION (asm_out_file);
5641 /* Output a terminator label for the .bss section. */
5643 fputc ('\n', asm_out_file);
5644 ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
5645 ASM_OUTPUT_LABEL (asm_out_file, BSS_END_LABEL);
5646 ASM_OUTPUT_POP_SECTION (asm_out_file);
5648 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5650 /* Output a terminating entry for the .line section. */
5652 fputc ('\n', asm_out_file);
5653 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
5654 ASM_OUTPUT_LABEL (asm_out_file, LINE_LAST_ENTRY_LABEL);
5655 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5656 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
5657 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
5658 ASM_OUTPUT_LABEL (asm_out_file, LINE_END_LABEL);
5659 ASM_OUTPUT_POP_SECTION (asm_out_file);
5661 /* Output a terminating entry for the .debug_srcinfo section. */
5663 fputc ('\n', asm_out_file);
5664 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
5665 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
5666 LINE_LAST_ENTRY_LABEL, LINE_BEGIN_LABEL);
5667 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
5668 ASM_OUTPUT_POP_SECTION (asm_out_file);
5670 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
5672 /* Output terminating entries for the .debug_macinfo section. */
5674 dwarfout_resume_previous_source_file (0);
5676 fputc ('\n', asm_out_file);
5677 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
5678 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5679 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
5680 ASM_OUTPUT_POP_SECTION (asm_out_file);
5683 /* Generate the terminating entry for the .debug_pubnames section. */
5685 fputc ('\n', asm_out_file);
5686 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
5687 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5688 ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
5689 ASM_OUTPUT_POP_SECTION (asm_out_file);
5691 /* Generate the terminating entries for the .debug_aranges section.
5693 Note that we want to do this only *after* we have output the end
5694 labels (for the various program sections) which we are going to
5695 refer to here. This allows us to work around a bug in the m68k
5696 svr4 assembler. That assembler gives bogus assembly-time errors
5697 if (within any given section) you try to take the difference of
5698 two relocatable symbols, both of which are located within some
5699 other section, and if one (or both?) of the symbols involved is
5700 being forward-referenced. By generating the .debug_aranges
5701 entries at this late point in the assembly output, we skirt the
5702 issue simply by avoiding forward-references.
5705 fputc ('\n', asm_out_file);
5706 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
5708 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
5709 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
5711 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA_BEGIN_LABEL);
5712 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA_END_LABEL, DATA_BEGIN_LABEL);
5714 #if 0 /* GNU C doesn't currently use .data1. */
5715 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA1_BEGIN_LABEL);
5716 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA1_END_LABEL,
5720 ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA_BEGIN_LABEL);
5721 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA_END_LABEL,
5722 RODATA_BEGIN_LABEL);
5724 #if 0 /* GNU C doesn't currently use .rodata1. */
5725 ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA1_BEGIN_LABEL);
5726 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA1_END_LABEL,
5727 RODATA1_BEGIN_LABEL);
5730 ASM_OUTPUT_DWARF_ADDR (asm_out_file, BSS_BEGIN_LABEL);
5731 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, BSS_END_LABEL, BSS_BEGIN_LABEL);
5733 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5734 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5736 ASM_OUTPUT_POP_SECTION (asm_out_file);
5740 #endif /* DWARF_DEBUGGING_INFO */