1 /* Output Dwarf format symbol table information from the GNU C compiler.
2 Copyright (C) 1992, 1993, 95-99, 2000 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"
39 #if defined(DWARF_TIMESTAMPS)
41 extern time_t time
PARAMS ((time_t *)); /* FIXME: use NEED_DECLARATION_TIME */
42 #endif /* !defined(POSIX) */
43 #endif /* defined(DWARF_TIMESTAMPS) */
45 /* We cannot use <assert.h> in GCC source, since that would include
46 GCC's assert.h, which may not be compatible with the host compiler. */
51 # define assert(e) do { if (! (e)) abort (); } while (0)
54 /* IMPORTANT NOTE: Please see the file README.DWARF for important details
55 regarding the GNU implementation of Dwarf. */
57 /* NOTE: In the comments in this file, many references are made to
58 so called "Debugging Information Entries". For the sake of brevity,
59 this term is abbreviated to `DIE' throughout the remainder of this
62 /* Note that the implementation of C++ support herein is (as yet) unfinished.
63 If you want to try to complete it, more power to you. */
65 /* How to start an assembler comment. */
66 #ifndef ASM_COMMENT_START
67 #define ASM_COMMENT_START ";#"
70 /* How to print out a register name. */
72 #define PRINT_REG(RTX, CODE, FILE) \
73 fprintf ((FILE), "%s", reg_names[REGNO (RTX)])
76 /* Define a macro which returns non-zero for any tagged type which is
77 used (directly or indirectly) in the specification of either some
78 function's return type or some formal parameter of some function.
79 We use this macro when we are operating in "terse" mode to help us
80 know what tagged types have to be represented in Dwarf (even in
81 terse mode) and which ones don't.
83 A flag bit with this meaning really should be a part of the normal
84 GCC ..._TYPE nodes, but at the moment, there is no such bit defined
85 for these nodes. For now, we have to just fake it. It it safe for
86 us to simply return zero for all complete tagged types (which will
87 get forced out anyway if they were used in the specification of some
88 formal or return type) and non-zero for all incomplete tagged types.
91 #define TYPE_USED_FOR_FUNCTION(tagged_type) (TYPE_SIZE (tagged_type) == 0)
93 /* Define a macro which returns non-zero for a TYPE_DECL which was
94 implicitly generated for a tagged type.
96 Note that unlike the gcc front end (which generates a NULL named
97 TYPE_DECL node for each complete tagged type, each array type, and
98 each function type node created) the g++ front end generates a
99 _named_ TYPE_DECL node for each tagged type node created.
100 These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
101 generate a DW_TAG_typedef DIE for them. */
102 #define TYPE_DECL_IS_STUB(decl) \
103 (DECL_NAME (decl) == NULL \
104 || (DECL_ARTIFICIAL (decl) \
105 && is_tagged_type (TREE_TYPE (decl)) \
106 && decl == TYPE_STUB_DECL (TREE_TYPE (decl))))
108 extern int flag_traditional
;
110 /* Maximum size (in bytes) of an artificially generated label. */
112 #define MAX_ARTIFICIAL_LABEL_BYTES 30
114 /* Make sure we know the sizes of the various types dwarf can describe.
115 These are only defaults. If the sizes are different for your target,
116 you should override these values by defining the appropriate symbols
117 in your tm.h file. */
119 #ifndef CHAR_TYPE_SIZE
120 #define CHAR_TYPE_SIZE BITS_PER_UNIT
123 #ifndef SHORT_TYPE_SIZE
124 #define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
127 #ifndef INT_TYPE_SIZE
128 #define INT_TYPE_SIZE BITS_PER_WORD
131 #ifndef LONG_TYPE_SIZE
132 #define LONG_TYPE_SIZE BITS_PER_WORD
135 #ifndef LONG_LONG_TYPE_SIZE
136 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
139 #ifndef WCHAR_TYPE_SIZE
140 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
143 #ifndef WCHAR_UNSIGNED
144 #define WCHAR_UNSIGNED 0
147 #ifndef FLOAT_TYPE_SIZE
148 #define FLOAT_TYPE_SIZE BITS_PER_WORD
151 #ifndef DOUBLE_TYPE_SIZE
152 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
155 #ifndef LONG_DOUBLE_TYPE_SIZE
156 #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
159 /* Structure to keep track of source filenames. */
161 struct filename_entry
{
166 typedef struct filename_entry filename_entry
;
168 /* Pointer to an array of elements, each one having the structure above. */
170 static filename_entry
*filename_table
;
172 /* Total number of entries in the table (i.e. array) pointed to by
173 `filename_table'. This is the *total* and includes both used and
176 static unsigned ft_entries_allocated
;
178 /* Number of entries in the filename_table which are actually in use. */
180 static unsigned ft_entries
;
182 /* Size (in elements) of increments by which we may expand the filename
183 table. Actually, a single hunk of space of this size should be enough
184 for most typical programs. */
186 #define FT_ENTRIES_INCREMENT 64
188 /* Local pointer to the name of the main input file. Initialized in
191 static char *primary_filename
;
193 /* Pointer to the most recent filename for which we produced some line info. */
195 static char *last_filename
;
197 /* For Dwarf output, we must assign lexical-blocks id numbers
198 in the order in which their beginnings are encountered.
199 We output Dwarf debugging info that refers to the beginnings
200 and ends of the ranges of code for each lexical block with
201 assembler labels ..Bn and ..Bn.e, where n is the block number.
202 The labels themselves are generated in final.c, which assigns
203 numbers to the blocks in the same way. */
205 static unsigned next_block_number
= 2;
207 /* Counter to generate unique names for DIEs. */
209 static unsigned next_unused_dienum
= 1;
211 /* Number of the DIE which is currently being generated. */
213 static unsigned current_dienum
;
215 /* Number to use for the special "pubname" label on the next DIE which
216 represents a function or data object defined in this compilation
217 unit which has "extern" linkage. */
219 static int next_pubname_number
= 0;
221 #define NEXT_DIE_NUM pending_sibling_stack[pending_siblings-1]
223 /* Pointer to a dynamically allocated list of pre-reserved and still
224 pending sibling DIE numbers. Note that this list will grow as needed. */
226 static unsigned *pending_sibling_stack
;
228 /* Counter to keep track of the number of pre-reserved and still pending
229 sibling DIE numbers. */
231 static unsigned pending_siblings
;
233 /* The currently allocated size of the above list (expressed in number of
236 static unsigned pending_siblings_allocated
;
238 /* Size (in elements) of increments by which we may expand the pending
239 sibling stack. Actually, a single hunk of space of this size should
240 be enough for most typical programs. */
242 #define PENDING_SIBLINGS_INCREMENT 64
244 /* Non-zero if we are performing our file-scope finalization pass and if
245 we should force out Dwarf descriptions of any and all file-scope
246 tagged types which are still incomplete types. */
248 static int finalizing
= 0;
250 /* A pointer to the base of a list of pending types which we haven't
251 generated DIEs for yet, but which we will have to come back to
254 static tree
*pending_types_list
;
256 /* Number of elements currently allocated for the pending_types_list. */
258 static unsigned pending_types_allocated
;
260 /* Number of elements of pending_types_list currently in use. */
262 static unsigned pending_types
;
264 /* Size (in elements) of increments by which we may expand the pending
265 types list. Actually, a single hunk of space of this size should
266 be enough for most typical programs. */
268 #define PENDING_TYPES_INCREMENT 64
270 /* A pointer to the base of a list of incomplete types which might be
271 completed at some later time. */
273 static tree
*incomplete_types_list
;
275 /* Number of elements currently allocated for the incomplete_types_list. */
276 static unsigned incomplete_types_allocated
;
278 /* Number of elements of incomplete_types_list currently in use. */
279 static unsigned incomplete_types
;
281 /* Size (in elements) of increments by which we may expand the incomplete
282 types list. Actually, a single hunk of space of this size should
283 be enough for most typical programs. */
284 #define INCOMPLETE_TYPES_INCREMENT 64
286 /* Pointer to an artificial RECORD_TYPE which we create in dwarfout_init.
287 This is used in a hack to help us get the DIEs describing types of
288 formal parameters to come *after* all of the DIEs describing the formal
289 parameters themselves. That's necessary in order to be compatible
290 with what the brain-damaged svr4 SDB debugger requires. */
292 static tree fake_containing_scope
;
294 /* The number of the current function definition that we are generating
295 debugging information for. These numbers range from 1 up to the maximum
296 number of function definitions contained within the current compilation
297 unit. These numbers are used to create unique labels for various things
298 contained within various function definitions. */
300 static unsigned current_funcdef_number
= 1;
302 /* A pointer to the ..._DECL node which we have most recently been working
303 on. We keep this around just in case something about it looks screwy
304 and we want to tell the user what the source coordinates for the actual
307 static tree dwarf_last_decl
;
309 /* A flag indicating that we are emitting the member declarations of a
310 class, so member functions and variables should not be entirely emitted.
311 This is a kludge to avoid passing a second argument to output_*_die. */
315 /* Forward declarations for functions defined in this file. */
317 static const char *dwarf_tag_name
PARAMS ((unsigned));
318 static const char *dwarf_attr_name
PARAMS ((unsigned));
319 static const char *dwarf_stack_op_name
PARAMS ((unsigned));
320 static const char *dwarf_typemod_name
PARAMS ((unsigned));
321 static const char *dwarf_fmt_byte_name
PARAMS ((unsigned));
322 static const char *dwarf_fund_type_name
PARAMS ((unsigned));
323 static tree decl_ultimate_origin
PARAMS ((tree
));
324 static tree block_ultimate_origin
PARAMS ((tree
));
325 static tree decl_class_context
PARAMS ((tree
));
327 static void output_unsigned_leb128
PARAMS ((unsigned long));
328 static void output_signed_leb128
PARAMS ((long));
330 static inline int is_body_block
PARAMS ((tree
));
331 static int fundamental_type_code
PARAMS ((tree
));
332 static tree root_type_1
PARAMS ((tree
, int));
333 static tree root_type
PARAMS ((tree
));
334 static void write_modifier_bytes_1
PARAMS ((tree
, int, int, int));
335 static void write_modifier_bytes
PARAMS ((tree
, int, int));
336 static inline int type_is_fundamental
PARAMS ((tree
));
337 static void equate_decl_number_to_die_number
PARAMS ((tree
));
338 static inline void equate_type_number_to_die_number
PARAMS ((tree
));
339 static void output_reg_number
PARAMS ((rtx
));
340 static void output_mem_loc_descriptor
PARAMS ((rtx
));
341 static void output_loc_descriptor
PARAMS ((rtx
));
342 static void output_bound_representation
PARAMS ((tree
, unsigned, int));
343 static void output_enumeral_list
PARAMS ((tree
));
344 static inline unsigned ceiling
PARAMS ((unsigned, unsigned));
345 static inline tree field_type
PARAMS ((tree
));
346 static inline unsigned simple_type_align_in_bits
PARAMS ((tree
));
347 static inline unsigned simple_type_size_in_bits
PARAMS ((tree
));
348 static unsigned field_byte_offset
PARAMS ((tree
));
349 static inline void sibling_attribute
PARAMS ((void));
350 static void location_attribute
PARAMS ((rtx
));
351 static void data_member_location_attribute
PARAMS ((tree
));
352 static void const_value_attribute
PARAMS ((rtx
));
353 static void location_or_const_value_attribute
PARAMS ((tree
));
354 static inline void name_attribute
PARAMS ((const char *));
355 static inline void fund_type_attribute
PARAMS ((unsigned));
356 static void mod_fund_type_attribute
PARAMS ((tree
, int, int));
357 static inline void user_def_type_attribute
PARAMS ((tree
));
358 static void mod_u_d_type_attribute
PARAMS ((tree
, int, int));
359 #ifdef USE_ORDERING_ATTRIBUTE
360 static inline void ordering_attribute
PARAMS ((unsigned));
361 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
362 static void subscript_data_attribute
PARAMS ((tree
));
363 static void byte_size_attribute
PARAMS ((tree
));
364 static inline void bit_offset_attribute
PARAMS ((tree
));
365 static inline void bit_size_attribute
PARAMS ((tree
));
366 static inline void element_list_attribute
PARAMS ((tree
));
367 static inline void stmt_list_attribute
PARAMS ((const char *));
368 static inline void low_pc_attribute
PARAMS ((const char *));
369 static inline void high_pc_attribute
PARAMS ((const char *));
370 static inline void body_begin_attribute
PARAMS ((const char *));
371 static inline void body_end_attribute
PARAMS ((const char *));
372 static inline void language_attribute
PARAMS ((unsigned));
373 static inline void member_attribute
PARAMS ((tree
));
375 static inline void string_length_attribute
PARAMS ((tree
));
377 static inline void comp_dir_attribute
PARAMS ((const char *));
378 static inline void sf_names_attribute
PARAMS ((const char *));
379 static inline void src_info_attribute
PARAMS ((const char *));
380 static inline void mac_info_attribute
PARAMS ((const char *));
381 static inline void prototyped_attribute
PARAMS ((tree
));
382 static inline void producer_attribute
PARAMS ((const char *));
383 static inline void inline_attribute
PARAMS ((tree
));
384 static inline void containing_type_attribute
PARAMS ((tree
));
385 static inline void abstract_origin_attribute
PARAMS ((tree
));
386 #ifdef DWARF_DECL_COORDINATES
387 static inline void src_coords_attribute
PARAMS ((unsigned, unsigned));
388 #endif /* defined(DWARF_DECL_COORDINATES) */
389 static inline void pure_or_virtual_attribute
PARAMS ((tree
));
390 static void name_and_src_coords_attributes
PARAMS ((tree
));
391 static void type_attribute
PARAMS ((tree
, int, int));
392 static char *type_tag
PARAMS ((tree
));
393 static inline void dienum_push
PARAMS ((void));
394 static inline void dienum_pop
PARAMS ((void));
395 static inline tree member_declared_type
PARAMS ((tree
));
396 static char *function_start_label
PARAMS ((tree
));
397 static void output_array_type_die
PARAMS ((void *));
398 static void output_set_type_die
PARAMS ((void *));
400 static void output_entry_point_die
PARAMS ((void *));
402 static void output_inlined_enumeration_type_die
PARAMS ((void *));
403 static void output_inlined_structure_type_die
PARAMS ((void *));
404 static void output_inlined_union_type_die
PARAMS ((void *));
405 static void output_enumeration_type_die
PARAMS ((void *));
406 static void output_formal_parameter_die
PARAMS ((void *));
407 static void output_global_subroutine_die
PARAMS ((void *));
408 static void output_global_variable_die
PARAMS ((void *));
409 static void output_label_die
PARAMS ((void *));
410 static void output_lexical_block_die
PARAMS ((void *));
411 static void output_inlined_subroutine_die
PARAMS ((void *));
412 static void output_local_variable_die
PARAMS ((void *));
413 static void output_member_die
PARAMS ((void *));
415 static void output_pointer_type_die
PARAMS ((void *));
416 static void output_reference_type_die
PARAMS ((void *));
418 static void output_ptr_to_mbr_type_die
PARAMS ((void *));
419 static void output_compile_unit_die
PARAMS ((void *));
420 static void output_string_type_die
PARAMS ((void *));
421 static void output_inheritance_die
PARAMS ((void *));
422 static void output_structure_type_die
PARAMS ((void *));
423 static void output_local_subroutine_die
PARAMS ((void *));
424 static void output_subroutine_type_die
PARAMS ((void *));
425 static void output_typedef_die
PARAMS ((void *));
426 static void output_union_type_die
PARAMS ((void *));
427 static void output_unspecified_parameters_die
PARAMS ((void *));
428 static void output_padded_null_die
PARAMS ((void *));
429 static void output_die
PARAMS ((void (*)(void *), void *));
430 static void end_sibling_chain
PARAMS ((void));
431 static void output_formal_types
PARAMS ((tree
));
432 static void pend_type
PARAMS ((tree
));
433 static int type_ok_for_scope
PARAMS ((tree
, tree
));
434 static void output_pending_types_for_scope
PARAMS ((tree
));
435 static void output_type
PARAMS ((tree
, tree
));
436 static void output_tagged_type_instantiation
PARAMS ((tree
));
437 static void output_block
PARAMS ((tree
, int));
438 static void output_decls_for_scope
PARAMS ((tree
, int));
439 static void output_decl
PARAMS ((tree
, tree
));
440 static void shuffle_filename_entry
PARAMS ((filename_entry
*));
441 static void generate_new_sfname_entry
PARAMS ((void));
442 static unsigned lookup_filename
PARAMS ((const char *));
443 static void generate_srcinfo_entry
PARAMS ((unsigned, unsigned));
444 static void generate_macinfo_entry
PARAMS ((const char *, const char *));
445 static int is_pseudo_reg
PARAMS ((rtx
));
446 static tree type_main_variant
PARAMS ((tree
));
447 static int is_tagged_type
PARAMS ((tree
));
448 static int is_redundant_typedef
PARAMS ((tree
));
449 static void add_incomplete_type
PARAMS ((tree
));
450 static void retry_incomplete_types
PARAMS ((void));
452 /* Definitions of defaults for assembler-dependent names of various
453 pseudo-ops and section names.
455 Theses may be overridden in your tm.h file (if necessary) for your
456 particular assembler. The default values provided here correspond to
457 what is expected by "standard" AT&T System V.4 assemblers. */
460 #define FILE_ASM_OP ".file"
462 #ifndef VERSION_ASM_OP
463 #define VERSION_ASM_OP ".version"
465 #ifndef UNALIGNED_SHORT_ASM_OP
466 #define UNALIGNED_SHORT_ASM_OP ".2byte"
468 #ifndef UNALIGNED_INT_ASM_OP
469 #define UNALIGNED_INT_ASM_OP ".4byte"
472 #define ASM_BYTE_OP ".byte"
475 #define SET_ASM_OP ".set"
478 /* Pseudo-ops for pushing the current section onto the section stack (and
479 simultaneously changing to a new section) and for poping back to the
480 section we were in immediately before this one. Note that most svr4
481 assemblers only maintain a one level stack... you can push all the
482 sections you want, but you can only pop out one level. (The sparc
483 svr4 assembler is an exception to this general rule.) That's
484 OK because we only use at most one level of the section stack herein. */
486 #ifndef PUSHSECTION_ASM_OP
487 #define PUSHSECTION_ASM_OP ".section"
489 #ifndef POPSECTION_ASM_OP
490 #define POPSECTION_ASM_OP ".previous"
493 /* The default format used by the ASM_OUTPUT_PUSH_SECTION macro (see below)
494 to print the PUSHSECTION_ASM_OP and the section name. The default here
495 works for almost all svr4 assemblers, except for the sparc, where the
496 section name must be enclosed in double quotes. (See sparcv4.h.) */
498 #ifndef PUSHSECTION_FORMAT
499 #define PUSHSECTION_FORMAT "\t%s\t%s\n"
502 #ifndef DEBUG_SECTION
503 #define DEBUG_SECTION ".debug"
506 #define LINE_SECTION ".line"
508 #ifndef SFNAMES_SECTION
509 #define SFNAMES_SECTION ".debug_sfnames"
511 #ifndef SRCINFO_SECTION
512 #define SRCINFO_SECTION ".debug_srcinfo"
514 #ifndef MACINFO_SECTION
515 #define MACINFO_SECTION ".debug_macinfo"
517 #ifndef PUBNAMES_SECTION
518 #define PUBNAMES_SECTION ".debug_pubnames"
520 #ifndef ARANGES_SECTION
521 #define ARANGES_SECTION ".debug_aranges"
524 #define TEXT_SECTION ".text"
527 #define DATA_SECTION ".data"
529 #ifndef DATA1_SECTION
530 #define DATA1_SECTION ".data1"
532 #ifndef RODATA_SECTION
533 #define RODATA_SECTION ".rodata"
535 #ifndef RODATA1_SECTION
536 #define RODATA1_SECTION ".rodata1"
539 #define BSS_SECTION ".bss"
542 /* Definitions of defaults for formats and names of various special
543 (artificial) labels which may be generated within this file (when
544 the -g options is used and DWARF_DEBUGGING_INFO is in effect.
546 If necessary, these may be overridden from within your tm.h file,
547 but typically, you should never need to override these.
549 These labels have been hacked (temporarily) so that they all begin with
550 a `.L' sequence so as to appease the stock sparc/svr4 assembler and the
551 stock m88k/svr4 assembler, both of which need to see .L at the start of
552 a label in order to prevent that label from going into the linker symbol
553 table). When I get time, I'll have to fix this the right way so that we
554 will use ASM_GENERATE_INTERNAL_LABEL and ASM_OUTPUT_INTERNAL_LABEL herein,
555 but that will require a rather massive set of changes. For the moment,
556 the following definitions out to produce the right results for all svr4
557 and svr3 assemblers. -- rfg
560 #ifndef TEXT_BEGIN_LABEL
561 #define TEXT_BEGIN_LABEL "*.L_text_b"
563 #ifndef TEXT_END_LABEL
564 #define TEXT_END_LABEL "*.L_text_e"
567 #ifndef DATA_BEGIN_LABEL
568 #define DATA_BEGIN_LABEL "*.L_data_b"
570 #ifndef DATA_END_LABEL
571 #define DATA_END_LABEL "*.L_data_e"
574 #ifndef DATA1_BEGIN_LABEL
575 #define DATA1_BEGIN_LABEL "*.L_data1_b"
577 #ifndef DATA1_END_LABEL
578 #define DATA1_END_LABEL "*.L_data1_e"
581 #ifndef RODATA_BEGIN_LABEL
582 #define RODATA_BEGIN_LABEL "*.L_rodata_b"
584 #ifndef RODATA_END_LABEL
585 #define RODATA_END_LABEL "*.L_rodata_e"
588 #ifndef RODATA1_BEGIN_LABEL
589 #define RODATA1_BEGIN_LABEL "*.L_rodata1_b"
591 #ifndef RODATA1_END_LABEL
592 #define RODATA1_END_LABEL "*.L_rodata1_e"
595 #ifndef BSS_BEGIN_LABEL
596 #define BSS_BEGIN_LABEL "*.L_bss_b"
598 #ifndef BSS_END_LABEL
599 #define BSS_END_LABEL "*.L_bss_e"
602 #ifndef LINE_BEGIN_LABEL
603 #define LINE_BEGIN_LABEL "*.L_line_b"
605 #ifndef LINE_LAST_ENTRY_LABEL
606 #define LINE_LAST_ENTRY_LABEL "*.L_line_last"
608 #ifndef LINE_END_LABEL
609 #define LINE_END_LABEL "*.L_line_e"
612 #ifndef DEBUG_BEGIN_LABEL
613 #define DEBUG_BEGIN_LABEL "*.L_debug_b"
615 #ifndef SFNAMES_BEGIN_LABEL
616 #define SFNAMES_BEGIN_LABEL "*.L_sfnames_b"
618 #ifndef SRCINFO_BEGIN_LABEL
619 #define SRCINFO_BEGIN_LABEL "*.L_srcinfo_b"
621 #ifndef MACINFO_BEGIN_LABEL
622 #define MACINFO_BEGIN_LABEL "*.L_macinfo_b"
625 #ifndef DIE_BEGIN_LABEL_FMT
626 #define DIE_BEGIN_LABEL_FMT "*.L_D%u"
628 #ifndef DIE_END_LABEL_FMT
629 #define DIE_END_LABEL_FMT "*.L_D%u_e"
631 #ifndef PUB_DIE_LABEL_FMT
632 #define PUB_DIE_LABEL_FMT "*.L_P%u"
634 #ifndef INSN_LABEL_FMT
635 #define INSN_LABEL_FMT "*.L_I%u_%u"
637 #ifndef BLOCK_BEGIN_LABEL_FMT
638 #define BLOCK_BEGIN_LABEL_FMT "*.L_B%u"
640 #ifndef BLOCK_END_LABEL_FMT
641 #define BLOCK_END_LABEL_FMT "*.L_B%u_e"
643 #ifndef SS_BEGIN_LABEL_FMT
644 #define SS_BEGIN_LABEL_FMT "*.L_s%u"
646 #ifndef SS_END_LABEL_FMT
647 #define SS_END_LABEL_FMT "*.L_s%u_e"
649 #ifndef EE_BEGIN_LABEL_FMT
650 #define EE_BEGIN_LABEL_FMT "*.L_e%u"
652 #ifndef EE_END_LABEL_FMT
653 #define EE_END_LABEL_FMT "*.L_e%u_e"
655 #ifndef MT_BEGIN_LABEL_FMT
656 #define MT_BEGIN_LABEL_FMT "*.L_t%u"
658 #ifndef MT_END_LABEL_FMT
659 #define MT_END_LABEL_FMT "*.L_t%u_e"
661 #ifndef LOC_BEGIN_LABEL_FMT
662 #define LOC_BEGIN_LABEL_FMT "*.L_l%u"
664 #ifndef LOC_END_LABEL_FMT
665 #define LOC_END_LABEL_FMT "*.L_l%u_e"
667 #ifndef BOUND_BEGIN_LABEL_FMT
668 #define BOUND_BEGIN_LABEL_FMT "*.L_b%u_%u_%c"
670 #ifndef BOUND_END_LABEL_FMT
671 #define BOUND_END_LABEL_FMT "*.L_b%u_%u_%c_e"
673 #ifndef DERIV_BEGIN_LABEL_FMT
674 #define DERIV_BEGIN_LABEL_FMT "*.L_d%u"
676 #ifndef DERIV_END_LABEL_FMT
677 #define DERIV_END_LABEL_FMT "*.L_d%u_e"
679 #ifndef SL_BEGIN_LABEL_FMT
680 #define SL_BEGIN_LABEL_FMT "*.L_sl%u"
682 #ifndef SL_END_LABEL_FMT
683 #define SL_END_LABEL_FMT "*.L_sl%u_e"
685 #ifndef BODY_BEGIN_LABEL_FMT
686 #define BODY_BEGIN_LABEL_FMT "*.L_b%u"
688 #ifndef BODY_END_LABEL_FMT
689 #define BODY_END_LABEL_FMT "*.L_b%u_e"
691 #ifndef FUNC_END_LABEL_FMT
692 #define FUNC_END_LABEL_FMT "*.L_f%u_e"
694 #ifndef TYPE_NAME_FMT
695 #define TYPE_NAME_FMT "*.L_T%u"
697 #ifndef DECL_NAME_FMT
698 #define DECL_NAME_FMT "*.L_E%u"
700 #ifndef LINE_CODE_LABEL_FMT
701 #define LINE_CODE_LABEL_FMT "*.L_LC%u"
703 #ifndef SFNAMES_ENTRY_LABEL_FMT
704 #define SFNAMES_ENTRY_LABEL_FMT "*.L_F%u"
706 #ifndef LINE_ENTRY_LABEL_FMT
707 #define LINE_ENTRY_LABEL_FMT "*.L_LE%u"
710 /* Definitions of defaults for various types of primitive assembly language
713 If necessary, these may be overridden from within your tm.h file,
714 but typically, you shouldn't need to override these. */
716 #ifndef ASM_OUTPUT_PUSH_SECTION
717 #define ASM_OUTPUT_PUSH_SECTION(FILE, SECTION) \
718 fprintf ((FILE), PUSHSECTION_FORMAT, PUSHSECTION_ASM_OP, SECTION)
721 #ifndef ASM_OUTPUT_POP_SECTION
722 #define ASM_OUTPUT_POP_SECTION(FILE) \
723 fprintf ((FILE), "\t%s\n", POPSECTION_ASM_OP)
726 #ifndef ASM_OUTPUT_DWARF_DELTA2
727 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
728 do { fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \
729 assemble_name (FILE, LABEL1); \
730 fprintf (FILE, "-"); \
731 assemble_name (FILE, LABEL2); \
732 fprintf (FILE, "\n"); \
736 #ifndef ASM_OUTPUT_DWARF_DELTA4
737 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
738 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
739 assemble_name (FILE, LABEL1); \
740 fprintf (FILE, "-"); \
741 assemble_name (FILE, LABEL2); \
742 fprintf (FILE, "\n"); \
746 #ifndef ASM_OUTPUT_DWARF_TAG
747 #define ASM_OUTPUT_DWARF_TAG(FILE,TAG) \
749 fprintf ((FILE), "\t%s\t0x%x", \
750 UNALIGNED_SHORT_ASM_OP, (unsigned) TAG); \
751 if (flag_debug_asm) \
752 fprintf ((FILE), "\t%s %s", \
753 ASM_COMMENT_START, dwarf_tag_name (TAG)); \
754 fputc ('\n', (FILE)); \
758 #ifndef ASM_OUTPUT_DWARF_ATTRIBUTE
759 #define ASM_OUTPUT_DWARF_ATTRIBUTE(FILE,ATTR) \
761 fprintf ((FILE), "\t%s\t0x%x", \
762 UNALIGNED_SHORT_ASM_OP, (unsigned) ATTR); \
763 if (flag_debug_asm) \
764 fprintf ((FILE), "\t%s %s", \
765 ASM_COMMENT_START, dwarf_attr_name (ATTR)); \
766 fputc ('\n', (FILE)); \
770 #ifndef ASM_OUTPUT_DWARF_STACK_OP
771 #define ASM_OUTPUT_DWARF_STACK_OP(FILE,OP) \
773 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) OP); \
774 if (flag_debug_asm) \
775 fprintf ((FILE), "\t%s %s", \
776 ASM_COMMENT_START, dwarf_stack_op_name (OP)); \
777 fputc ('\n', (FILE)); \
781 #ifndef ASM_OUTPUT_DWARF_FUND_TYPE
782 #define ASM_OUTPUT_DWARF_FUND_TYPE(FILE,FT) \
784 fprintf ((FILE), "\t%s\t0x%x", \
785 UNALIGNED_SHORT_ASM_OP, (unsigned) FT); \
786 if (flag_debug_asm) \
787 fprintf ((FILE), "\t%s %s", \
788 ASM_COMMENT_START, dwarf_fund_type_name (FT)); \
789 fputc ('\n', (FILE)); \
793 #ifndef ASM_OUTPUT_DWARF_FMT_BYTE
794 #define ASM_OUTPUT_DWARF_FMT_BYTE(FILE,FMT) \
796 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) FMT); \
797 if (flag_debug_asm) \
798 fprintf ((FILE), "\t%s %s", \
799 ASM_COMMENT_START, dwarf_fmt_byte_name (FMT)); \
800 fputc ('\n', (FILE)); \
804 #ifndef ASM_OUTPUT_DWARF_TYPE_MODIFIER
805 #define ASM_OUTPUT_DWARF_TYPE_MODIFIER(FILE,MOD) \
807 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) MOD); \
808 if (flag_debug_asm) \
809 fprintf ((FILE), "\t%s %s", \
810 ASM_COMMENT_START, dwarf_typemod_name (MOD)); \
811 fputc ('\n', (FILE)); \
815 #ifndef ASM_OUTPUT_DWARF_ADDR
816 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
817 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
818 assemble_name (FILE, LABEL); \
819 fprintf (FILE, "\n"); \
823 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
824 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX) \
826 fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
827 output_addr_const ((FILE), (RTX)); \
828 fputc ('\n', (FILE)); \
832 #ifndef ASM_OUTPUT_DWARF_REF
833 #define ASM_OUTPUT_DWARF_REF(FILE,LABEL) \
834 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
835 assemble_name (FILE, LABEL); \
836 fprintf (FILE, "\n"); \
840 #ifndef ASM_OUTPUT_DWARF_DATA1
841 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
842 fprintf ((FILE), "\t%s\t0x%x\n", ASM_BYTE_OP, VALUE)
845 #ifndef ASM_OUTPUT_DWARF_DATA2
846 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
847 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_SHORT_ASM_OP, (unsigned) VALUE)
850 #ifndef ASM_OUTPUT_DWARF_DATA4
851 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
852 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, (unsigned) VALUE)
855 #ifndef ASM_OUTPUT_DWARF_DATA8
856 #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \
858 if (WORDS_BIG_ENDIAN) \
860 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
861 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
865 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
866 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
871 /* ASM_OUTPUT_DWARF_STRING is defined to output an ascii string, but to
872 NOT issue a trailing newline. We define ASM_OUTPUT_DWARF_STRING_NEWLINE
873 based on whether ASM_OUTPUT_DWARF_STRING is defined or not. If it is
874 defined, we call it, then issue the line feed. If not, we supply a
875 default defintion of calling ASM_OUTPUT_ASCII */
877 #ifndef ASM_OUTPUT_DWARF_STRING
878 #define ASM_OUTPUT_DWARF_STRING_NEWLINE(FILE,P) \
879 ASM_OUTPUT_ASCII ((FILE), P, strlen (P)+1)
881 #define ASM_OUTPUT_DWARF_STRING_NEWLINE(FILE,P) \
882 ASM_OUTPUT_DWARF_STRING (FILE,P), ASM_OUTPUT_DWARF_STRING (FILE,"\n")
886 /************************ general utility functions **************************/
892 return (((GET_CODE (rtl
) == REG
) && (REGNO (rtl
) >= FIRST_PSEUDO_REGISTER
))
893 || ((GET_CODE (rtl
) == SUBREG
)
894 && (REGNO (XEXP (rtl
, 0)) >= FIRST_PSEUDO_REGISTER
)));
898 type_main_variant (type
)
901 type
= TYPE_MAIN_VARIANT (type
);
903 /* There really should be only one main variant among any group of variants
904 of a given type (and all of the MAIN_VARIANT values for all members of
905 the group should point to that one type) but sometimes the C front-end
906 messes this up for array types, so we work around that bug here. */
908 if (TREE_CODE (type
) == ARRAY_TYPE
)
910 while (type
!= TYPE_MAIN_VARIANT (type
))
911 type
= TYPE_MAIN_VARIANT (type
);
917 /* Return non-zero if the given type node represents a tagged type. */
920 is_tagged_type (type
)
923 register enum tree_code code
= TREE_CODE (type
);
925 return (code
== RECORD_TYPE
|| code
== UNION_TYPE
926 || code
== QUAL_UNION_TYPE
|| code
== ENUMERAL_TYPE
);
931 register unsigned tag
;
935 case TAG_padding
: return "TAG_padding";
936 case TAG_array_type
: return "TAG_array_type";
937 case TAG_class_type
: return "TAG_class_type";
938 case TAG_entry_point
: return "TAG_entry_point";
939 case TAG_enumeration_type
: return "TAG_enumeration_type";
940 case TAG_formal_parameter
: return "TAG_formal_parameter";
941 case TAG_global_subroutine
: return "TAG_global_subroutine";
942 case TAG_global_variable
: return "TAG_global_variable";
943 case TAG_label
: return "TAG_label";
944 case TAG_lexical_block
: return "TAG_lexical_block";
945 case TAG_local_variable
: return "TAG_local_variable";
946 case TAG_member
: return "TAG_member";
947 case TAG_pointer_type
: return "TAG_pointer_type";
948 case TAG_reference_type
: return "TAG_reference_type";
949 case TAG_compile_unit
: return "TAG_compile_unit";
950 case TAG_string_type
: return "TAG_string_type";
951 case TAG_structure_type
: return "TAG_structure_type";
952 case TAG_subroutine
: return "TAG_subroutine";
953 case TAG_subroutine_type
: return "TAG_subroutine_type";
954 case TAG_typedef
: return "TAG_typedef";
955 case TAG_union_type
: return "TAG_union_type";
956 case TAG_unspecified_parameters
: return "TAG_unspecified_parameters";
957 case TAG_variant
: return "TAG_variant";
958 case TAG_common_block
: return "TAG_common_block";
959 case TAG_common_inclusion
: return "TAG_common_inclusion";
960 case TAG_inheritance
: return "TAG_inheritance";
961 case TAG_inlined_subroutine
: return "TAG_inlined_subroutine";
962 case TAG_module
: return "TAG_module";
963 case TAG_ptr_to_member_type
: return "TAG_ptr_to_member_type";
964 case TAG_set_type
: return "TAG_set_type";
965 case TAG_subrange_type
: return "TAG_subrange_type";
966 case TAG_with_stmt
: return "TAG_with_stmt";
968 /* GNU extensions. */
970 case TAG_format_label
: return "TAG_format_label";
971 case TAG_namelist
: return "TAG_namelist";
972 case TAG_function_template
: return "TAG_function_template";
973 case TAG_class_template
: return "TAG_class_template";
975 default: return "TAG_<unknown>";
980 dwarf_attr_name (attr
)
981 register unsigned attr
;
985 case AT_sibling
: return "AT_sibling";
986 case AT_location
: return "AT_location";
987 case AT_name
: return "AT_name";
988 case AT_fund_type
: return "AT_fund_type";
989 case AT_mod_fund_type
: return "AT_mod_fund_type";
990 case AT_user_def_type
: return "AT_user_def_type";
991 case AT_mod_u_d_type
: return "AT_mod_u_d_type";
992 case AT_ordering
: return "AT_ordering";
993 case AT_subscr_data
: return "AT_subscr_data";
994 case AT_byte_size
: return "AT_byte_size";
995 case AT_bit_offset
: return "AT_bit_offset";
996 case AT_bit_size
: return "AT_bit_size";
997 case AT_element_list
: return "AT_element_list";
998 case AT_stmt_list
: return "AT_stmt_list";
999 case AT_low_pc
: return "AT_low_pc";
1000 case AT_high_pc
: return "AT_high_pc";
1001 case AT_language
: return "AT_language";
1002 case AT_member
: return "AT_member";
1003 case AT_discr
: return "AT_discr";
1004 case AT_discr_value
: return "AT_discr_value";
1005 case AT_string_length
: return "AT_string_length";
1006 case AT_common_reference
: return "AT_common_reference";
1007 case AT_comp_dir
: return "AT_comp_dir";
1008 case AT_const_value_string
: return "AT_const_value_string";
1009 case AT_const_value_data2
: return "AT_const_value_data2";
1010 case AT_const_value_data4
: return "AT_const_value_data4";
1011 case AT_const_value_data8
: return "AT_const_value_data8";
1012 case AT_const_value_block2
: return "AT_const_value_block2";
1013 case AT_const_value_block4
: return "AT_const_value_block4";
1014 case AT_containing_type
: return "AT_containing_type";
1015 case AT_default_value_addr
: return "AT_default_value_addr";
1016 case AT_default_value_data2
: return "AT_default_value_data2";
1017 case AT_default_value_data4
: return "AT_default_value_data4";
1018 case AT_default_value_data8
: return "AT_default_value_data8";
1019 case AT_default_value_string
: return "AT_default_value_string";
1020 case AT_friends
: return "AT_friends";
1021 case AT_inline
: return "AT_inline";
1022 case AT_is_optional
: return "AT_is_optional";
1023 case AT_lower_bound_ref
: return "AT_lower_bound_ref";
1024 case AT_lower_bound_data2
: return "AT_lower_bound_data2";
1025 case AT_lower_bound_data4
: return "AT_lower_bound_data4";
1026 case AT_lower_bound_data8
: return "AT_lower_bound_data8";
1027 case AT_private
: return "AT_private";
1028 case AT_producer
: return "AT_producer";
1029 case AT_program
: return "AT_program";
1030 case AT_protected
: return "AT_protected";
1031 case AT_prototyped
: return "AT_prototyped";
1032 case AT_public
: return "AT_public";
1033 case AT_pure_virtual
: return "AT_pure_virtual";
1034 case AT_return_addr
: return "AT_return_addr";
1035 case AT_abstract_origin
: return "AT_abstract_origin";
1036 case AT_start_scope
: return "AT_start_scope";
1037 case AT_stride_size
: return "AT_stride_size";
1038 case AT_upper_bound_ref
: return "AT_upper_bound_ref";
1039 case AT_upper_bound_data2
: return "AT_upper_bound_data2";
1040 case AT_upper_bound_data4
: return "AT_upper_bound_data4";
1041 case AT_upper_bound_data8
: return "AT_upper_bound_data8";
1042 case AT_virtual
: return "AT_virtual";
1044 /* GNU extensions */
1046 case AT_sf_names
: return "AT_sf_names";
1047 case AT_src_info
: return "AT_src_info";
1048 case AT_mac_info
: return "AT_mac_info";
1049 case AT_src_coords
: return "AT_src_coords";
1050 case AT_body_begin
: return "AT_body_begin";
1051 case AT_body_end
: return "AT_body_end";
1053 default: return "AT_<unknown>";
1058 dwarf_stack_op_name (op
)
1059 register unsigned op
;
1063 case OP_REG
: return "OP_REG";
1064 case OP_BASEREG
: return "OP_BASEREG";
1065 case OP_ADDR
: return "OP_ADDR";
1066 case OP_CONST
: return "OP_CONST";
1067 case OP_DEREF2
: return "OP_DEREF2";
1068 case OP_DEREF4
: return "OP_DEREF4";
1069 case OP_ADD
: return "OP_ADD";
1070 default: return "OP_<unknown>";
1075 dwarf_typemod_name (mod
)
1076 register unsigned mod
;
1080 case MOD_pointer_to
: return "MOD_pointer_to";
1081 case MOD_reference_to
: return "MOD_reference_to";
1082 case MOD_const
: return "MOD_const";
1083 case MOD_volatile
: return "MOD_volatile";
1084 default: return "MOD_<unknown>";
1089 dwarf_fmt_byte_name (fmt
)
1090 register unsigned fmt
;
1094 case FMT_FT_C_C
: return "FMT_FT_C_C";
1095 case FMT_FT_C_X
: return "FMT_FT_C_X";
1096 case FMT_FT_X_C
: return "FMT_FT_X_C";
1097 case FMT_FT_X_X
: return "FMT_FT_X_X";
1098 case FMT_UT_C_C
: return "FMT_UT_C_C";
1099 case FMT_UT_C_X
: return "FMT_UT_C_X";
1100 case FMT_UT_X_C
: return "FMT_UT_X_C";
1101 case FMT_UT_X_X
: return "FMT_UT_X_X";
1102 case FMT_ET
: return "FMT_ET";
1103 default: return "FMT_<unknown>";
1108 dwarf_fund_type_name (ft
)
1109 register unsigned ft
;
1113 case FT_char
: return "FT_char";
1114 case FT_signed_char
: return "FT_signed_char";
1115 case FT_unsigned_char
: return "FT_unsigned_char";
1116 case FT_short
: return "FT_short";
1117 case FT_signed_short
: return "FT_signed_short";
1118 case FT_unsigned_short
: return "FT_unsigned_short";
1119 case FT_integer
: return "FT_integer";
1120 case FT_signed_integer
: return "FT_signed_integer";
1121 case FT_unsigned_integer
: return "FT_unsigned_integer";
1122 case FT_long
: return "FT_long";
1123 case FT_signed_long
: return "FT_signed_long";
1124 case FT_unsigned_long
: return "FT_unsigned_long";
1125 case FT_pointer
: return "FT_pointer";
1126 case FT_float
: return "FT_float";
1127 case FT_dbl_prec_float
: return "FT_dbl_prec_float";
1128 case FT_ext_prec_float
: return "FT_ext_prec_float";
1129 case FT_complex
: return "FT_complex";
1130 case FT_dbl_prec_complex
: return "FT_dbl_prec_complex";
1131 case FT_void
: return "FT_void";
1132 case FT_boolean
: return "FT_boolean";
1133 case FT_ext_prec_complex
: return "FT_ext_prec_complex";
1134 case FT_label
: return "FT_label";
1136 /* GNU extensions. */
1138 case FT_long_long
: return "FT_long_long";
1139 case FT_signed_long_long
: return "FT_signed_long_long";
1140 case FT_unsigned_long_long
: return "FT_unsigned_long_long";
1142 case FT_int8
: return "FT_int8";
1143 case FT_signed_int8
: return "FT_signed_int8";
1144 case FT_unsigned_int8
: return "FT_unsigned_int8";
1145 case FT_int16
: return "FT_int16";
1146 case FT_signed_int16
: return "FT_signed_int16";
1147 case FT_unsigned_int16
: return "FT_unsigned_int16";
1148 case FT_int32
: return "FT_int32";
1149 case FT_signed_int32
: return "FT_signed_int32";
1150 case FT_unsigned_int32
: return "FT_unsigned_int32";
1151 case FT_int64
: return "FT_int64";
1152 case FT_signed_int64
: return "FT_signed_int64";
1153 case FT_unsigned_int64
: return "FT_unsigned_int64";
1155 case FT_real32
: return "FT_real32";
1156 case FT_real64
: return "FT_real64";
1157 case FT_real96
: return "FT_real96";
1158 case FT_real128
: return "FT_real128";
1160 default: return "FT_<unknown>";
1164 /* Determine the "ultimate origin" of a decl. The decl may be an
1165 inlined instance of an inlined instance of a decl which is local
1166 to an inline function, so we have to trace all of the way back
1167 through the origin chain to find out what sort of node actually
1168 served as the original seed for the given block. */
1171 decl_ultimate_origin (decl
)
1174 #ifdef ENABLE_CHECKING
1175 if (DECL_FROM_INLINE (DECL_ORIGIN (decl
)))
1176 /* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
1177 most distant ancestor, this should never happen. */
1181 return DECL_ABSTRACT_ORIGIN (decl
);
1184 /* Determine the "ultimate origin" of a block. The block may be an
1185 inlined instance of an inlined instance of a block which is local
1186 to an inline function, so we have to trace all of the way back
1187 through the origin chain to find out what sort of node actually
1188 served as the original seed for the given block. */
1191 block_ultimate_origin (block
)
1192 register tree block
;
1194 register tree immediate_origin
= BLOCK_ABSTRACT_ORIGIN (block
);
1196 if (immediate_origin
== NULL
)
1200 register tree ret_val
;
1201 register tree lookahead
= immediate_origin
;
1205 ret_val
= lookahead
;
1206 lookahead
= (TREE_CODE (ret_val
) == BLOCK
)
1207 ? BLOCK_ABSTRACT_ORIGIN (ret_val
)
1210 while (lookahead
!= NULL
&& lookahead
!= ret_val
);
1215 /* Get the class to which DECL belongs, if any. In g++, the DECL_CONTEXT
1216 of a virtual function may refer to a base class, so we check the 'this'
1220 decl_class_context (decl
)
1223 tree context
= NULL_TREE
;
1224 if (TREE_CODE (decl
) != FUNCTION_DECL
|| ! DECL_VINDEX (decl
))
1225 context
= DECL_CONTEXT (decl
);
1227 context
= TYPE_MAIN_VARIANT
1228 (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)))));
1230 if (context
&& TREE_CODE_CLASS (TREE_CODE (context
)) != 't')
1231 context
= NULL_TREE
;
1238 output_unsigned_leb128 (value
)
1239 register unsigned long value
;
1241 register unsigned long orig_value
= value
;
1245 register unsigned byte
= (value
& 0x7f);
1248 if (value
!= 0) /* more bytes to follow */
1250 fprintf (asm_out_file
, "\t%s\t0x%x", ASM_BYTE_OP
, (unsigned) byte
);
1251 if (flag_debug_asm
&& value
== 0)
1252 fprintf (asm_out_file
, "\t%s ULEB128 number - value = %lu",
1253 ASM_COMMENT_START
, orig_value
);
1254 fputc ('\n', asm_out_file
);
1260 output_signed_leb128 (value
)
1261 register long value
;
1263 register long orig_value
= value
;
1264 register int negative
= (value
< 0);
1269 register unsigned byte
= (value
& 0x7f);
1273 value
|= 0xfe000000; /* manually sign extend */
1274 if (((value
== 0) && ((byte
& 0x40) == 0))
1275 || ((value
== -1) && ((byte
& 0x40) == 1)))
1282 fprintf (asm_out_file
, "\t%s\t0x%x", ASM_BYTE_OP
, (unsigned) byte
);
1283 if (flag_debug_asm
&& more
== 0)
1284 fprintf (asm_out_file
, "\t%s SLEB128 number - value = %ld",
1285 ASM_COMMENT_START
, orig_value
);
1286 fputc ('\n', asm_out_file
);
1292 /**************** utility functions for attribute functions ******************/
1294 /* Given a pointer to a BLOCK node return non-zero if (and only if) the
1295 node in question represents the outermost pair of curly braces (i.e.
1296 the "body block") of a function or method.
1298 For any BLOCK node representing a "body block" of a function or method,
1299 the BLOCK_SUPERCONTEXT of the node will point to another BLOCK node
1300 which represents the outermost (function) scope for the function or
1301 method (i.e. the one which includes the formal parameters). The
1302 BLOCK_SUPERCONTEXT of *that* node in turn will point to the relevant
1307 is_body_block (stmt
)
1310 if (TREE_CODE (stmt
) == BLOCK
)
1312 register tree parent
= BLOCK_SUPERCONTEXT (stmt
);
1314 if (TREE_CODE (parent
) == BLOCK
)
1316 register tree grandparent
= BLOCK_SUPERCONTEXT (parent
);
1318 if (TREE_CODE (grandparent
) == FUNCTION_DECL
)
1325 /* Given a pointer to a tree node for some type, return a Dwarf fundamental
1326 type code for the given type.
1328 This routine must only be called for GCC type nodes that correspond to
1329 Dwarf fundamental types.
1331 The current Dwarf draft specification calls for Dwarf fundamental types
1332 to accurately reflect the fact that a given type was either a "plain"
1333 integral type or an explicitly "signed" integral type. Unfortunately,
1334 we can't always do this, because GCC may already have thrown away the
1335 information about the precise way in which the type was originally
1338 typedef signed int my_type;
1340 struct s { my_type f; };
1342 Since we may be stuck here without enought information to do exactly
1343 what is called for in the Dwarf draft specification, we do the best
1344 that we can under the circumstances and always use the "plain" integral
1345 fundamental type codes for int, short, and long types. That's probably
1346 good enough. The additional accuracy called for in the current DWARF
1347 draft specification is probably never even useful in practice. */
1350 fundamental_type_code (type
)
1353 if (TREE_CODE (type
) == ERROR_MARK
)
1356 switch (TREE_CODE (type
))
1365 /* Carefully distinguish all the standard types of C,
1366 without messing up if the language is not C.
1367 Note that we check only for the names that contain spaces;
1368 other names might occur by coincidence in other languages. */
1369 if (TYPE_NAME (type
) != 0
1370 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1371 && DECL_NAME (TYPE_NAME (type
)) != 0
1372 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
1375 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
1377 if (!strcmp (name
, "unsigned char"))
1378 return FT_unsigned_char
;
1379 if (!strcmp (name
, "signed char"))
1380 return FT_signed_char
;
1381 if (!strcmp (name
, "unsigned int"))
1382 return FT_unsigned_integer
;
1383 if (!strcmp (name
, "short int"))
1385 if (!strcmp (name
, "short unsigned int"))
1386 return FT_unsigned_short
;
1387 if (!strcmp (name
, "long int"))
1389 if (!strcmp (name
, "long unsigned int"))
1390 return FT_unsigned_long
;
1391 if (!strcmp (name
, "long long int"))
1392 return FT_long_long
; /* Not grok'ed by svr4 SDB */
1393 if (!strcmp (name
, "long long unsigned int"))
1394 return FT_unsigned_long_long
; /* Not grok'ed by svr4 SDB */
1397 /* Most integer types will be sorted out above, however, for the
1398 sake of special `array index' integer types, the following code
1399 is also provided. */
1401 if (TYPE_PRECISION (type
) == INT_TYPE_SIZE
)
1402 return (TREE_UNSIGNED (type
) ? FT_unsigned_integer
: FT_integer
);
1404 if (TYPE_PRECISION (type
) == LONG_TYPE_SIZE
)
1405 return (TREE_UNSIGNED (type
) ? FT_unsigned_long
: FT_long
);
1407 if (TYPE_PRECISION (type
) == LONG_LONG_TYPE_SIZE
)
1408 return (TREE_UNSIGNED (type
) ? FT_unsigned_long_long
: FT_long_long
);
1410 if (TYPE_PRECISION (type
) == SHORT_TYPE_SIZE
)
1411 return (TREE_UNSIGNED (type
) ? FT_unsigned_short
: FT_short
);
1413 if (TYPE_PRECISION (type
) == CHAR_TYPE_SIZE
)
1414 return (TREE_UNSIGNED (type
) ? FT_unsigned_char
: FT_char
);
1416 /* In C++, __java_boolean is an INTEGER_TYPE with precision == 1 */
1417 if (TYPE_PRECISION (type
) == 1)
1423 /* Carefully distinguish all the standard types of C,
1424 without messing up if the language is not C. */
1425 if (TYPE_NAME (type
) != 0
1426 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1427 && DECL_NAME (TYPE_NAME (type
)) != 0
1428 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
1431 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
1433 /* Note that here we can run afowl of a serious bug in "classic"
1434 svr4 SDB debuggers. They don't seem to understand the
1435 FT_ext_prec_float type (even though they should). */
1437 if (!strcmp (name
, "long double"))
1438 return FT_ext_prec_float
;
1441 if (TYPE_PRECISION (type
) == DOUBLE_TYPE_SIZE
)
1443 /* On the SH, when compiling with -m3e or -m4-single-only, both
1444 float and double are 32 bits. But since the debugger doesn't
1445 know about the subtarget, it always thinks double is 64 bits.
1446 So we have to tell the debugger that the type is float to
1447 make the output of the 'print' command etc. readable. */
1448 if (DOUBLE_TYPE_SIZE
== FLOAT_TYPE_SIZE
&& FLOAT_TYPE_SIZE
== 32)
1450 return FT_dbl_prec_float
;
1452 if (TYPE_PRECISION (type
) == FLOAT_TYPE_SIZE
)
1455 /* Note that here we can run afowl of a serious bug in "classic"
1456 svr4 SDB debuggers. They don't seem to understand the
1457 FT_ext_prec_float type (even though they should). */
1459 if (TYPE_PRECISION (type
) == LONG_DOUBLE_TYPE_SIZE
)
1460 return FT_ext_prec_float
;
1464 return FT_complex
; /* GNU FORTRAN COMPLEX type. */
1467 return FT_char
; /* GNU Pascal CHAR type. Not used in C. */
1470 return FT_boolean
; /* GNU FORTRAN BOOLEAN type. */
1473 abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
1478 /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
1479 the Dwarf "root" type for the given input type. The Dwarf "root" type
1480 of a given type is generally the same as the given type, except that if
1481 the given type is a pointer or reference type, then the root type of
1482 the given type is the root type of the "basis" type for the pointer or
1483 reference type. (This definition of the "root" type is recursive.)
1484 Also, the root type of a `const' qualified type or a `volatile'
1485 qualified type is the root type of the given type without the
1489 root_type_1 (type
, count
)
1493 /* Give up after searching 1000 levels, in case this is a recursive
1494 pointer type. Such types are possible in Ada, but it is not possible
1495 to represent them in DWARF1 debug info. */
1497 return error_mark_node
;
1499 switch (TREE_CODE (type
))
1502 return error_mark_node
;
1505 case REFERENCE_TYPE
:
1506 return root_type_1 (TREE_TYPE (type
), count
+1);
1517 type
= root_type_1 (type
, 0);
1518 if (type
!= error_mark_node
)
1519 type
= type_main_variant (type
);
1523 /* Given a pointer to an arbitrary ..._TYPE tree node, write out a sequence
1524 of zero or more Dwarf "type-modifier" bytes applicable to the type. */
1527 write_modifier_bytes_1 (type
, decl_const
, decl_volatile
, count
)
1529 register int decl_const
;
1530 register int decl_volatile
;
1533 if (TREE_CODE (type
) == ERROR_MARK
)
1536 /* Give up after searching 1000 levels, in case this is a recursive
1537 pointer type. Such types are possible in Ada, but it is not possible
1538 to represent them in DWARF1 debug info. */
1542 if (TYPE_READONLY (type
) || decl_const
)
1543 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file
, MOD_const
);
1544 if (TYPE_VOLATILE (type
) || decl_volatile
)
1545 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file
, MOD_volatile
);
1546 switch (TREE_CODE (type
))
1549 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file
, MOD_pointer_to
);
1550 write_modifier_bytes_1 (TREE_TYPE (type
), 0, 0, count
+1);
1553 case REFERENCE_TYPE
:
1554 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file
, MOD_reference_to
);
1555 write_modifier_bytes_1 (TREE_TYPE (type
), 0, 0, count
+1);
1565 write_modifier_bytes (type
, decl_const
, decl_volatile
)
1567 register int decl_const
;
1568 register int decl_volatile
;
1570 write_modifier_bytes_1 (type
, decl_const
, decl_volatile
, 0);
1573 /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
1574 given input type is a Dwarf "fundamental" type. Otherwise return zero. */
1577 type_is_fundamental (type
)
1580 switch (TREE_CODE (type
))
1595 case QUAL_UNION_TYPE
:
1600 case REFERENCE_TYPE
:
1612 /* Given a pointer to some ..._DECL tree node, generate an assembly language
1613 equate directive which will associate a symbolic name with the current DIE.
1615 The name used is an artificial label generated from the DECL_UID number
1616 associated with the given decl node. The name it gets equated to is the
1617 symbolic label that we (previously) output at the start of the DIE that
1618 we are currently generating.
1620 Calling this function while generating some "decl related" form of DIE
1621 makes it possible to later refer to the DIE which represents the given
1622 decl simply by re-generating the symbolic name from the ..._DECL node's
1626 equate_decl_number_to_die_number (decl
)
1629 /* In the case where we are generating a DIE for some ..._DECL node
1630 which represents either some inline function declaration or some
1631 entity declared within an inline function declaration/definition,
1632 setup a symbolic name for the current DIE so that we have a name
1633 for this DIE that we can easily refer to later on within
1634 AT_abstract_origin attributes. */
1636 char decl_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1637 char die_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1639 sprintf (decl_label
, DECL_NAME_FMT
, DECL_UID (decl
));
1640 sprintf (die_label
, DIE_BEGIN_LABEL_FMT
, current_dienum
);
1641 ASM_OUTPUT_DEF (asm_out_file
, decl_label
, die_label
);
1644 /* Given a pointer to some ..._TYPE tree node, generate an assembly language
1645 equate directive which will associate a symbolic name with the current DIE.
1647 The name used is an artificial label generated from the TYPE_UID number
1648 associated with the given type node. The name it gets equated to is the
1649 symbolic label that we (previously) output at the start of the DIE that
1650 we are currently generating.
1652 Calling this function while generating some "type related" form of DIE
1653 makes it easy to later refer to the DIE which represents the given type
1654 simply by re-generating the alternative name from the ..._TYPE node's
1658 equate_type_number_to_die_number (type
)
1661 char type_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1662 char die_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1664 /* We are generating a DIE to represent the main variant of this type
1665 (i.e the type without any const or volatile qualifiers) so in order
1666 to get the equate to come out right, we need to get the main variant
1669 type
= type_main_variant (type
);
1671 sprintf (type_label
, TYPE_NAME_FMT
, TYPE_UID (type
));
1672 sprintf (die_label
, DIE_BEGIN_LABEL_FMT
, current_dienum
);
1673 ASM_OUTPUT_DEF (asm_out_file
, type_label
, die_label
);
1677 output_reg_number (rtl
)
1680 register unsigned regno
= REGNO (rtl
);
1682 if (regno
>= DWARF_FRAME_REGISTERS
)
1684 warning_with_decl (dwarf_last_decl
, "internal regno botch: regno = %d\n",
1688 fprintf (asm_out_file
, "\t%s\t0x%x",
1689 UNALIGNED_INT_ASM_OP
, DBX_REGISTER_NUMBER (regno
));
1692 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
1693 PRINT_REG (rtl
, 0, asm_out_file
);
1695 fputc ('\n', asm_out_file
);
1698 /* The following routine is a nice and simple transducer. It converts the
1699 RTL for a variable or parameter (resident in memory) into an equivalent
1700 Dwarf representation of a mechanism for getting the address of that same
1701 variable onto the top of a hypothetical "address evaluation" stack.
1703 When creating memory location descriptors, we are effectively trans-
1704 forming the RTL for a memory-resident object into its Dwarf postfix
1705 expression equivalent. This routine just recursively descends an
1706 RTL tree, turning it into Dwarf postfix code as it goes. */
1709 output_mem_loc_descriptor (rtl
)
1712 /* Note that for a dynamically sized array, the location we will
1713 generate a description of here will be the lowest numbered location
1714 which is actually within the array. That's *not* necessarily the
1715 same as the zeroth element of the array. */
1717 #ifdef ASM_SIMPLIFY_DWARF_ADDR
1718 rtl
= ASM_SIMPLIFY_DWARF_ADDR (rtl
);
1721 switch (GET_CODE (rtl
))
1725 /* The case of a subreg may arise when we have a local (register)
1726 variable or a formal (register) parameter which doesn't quite
1727 fill up an entire register. For now, just assume that it is
1728 legitimate to make the Dwarf info refer to the whole register
1729 which contains the given subreg. */
1731 rtl
= XEXP (rtl
, 0);
1736 /* Whenever a register number forms a part of the description of
1737 the method for calculating the (dynamic) address of a memory
1738 resident object, DWARF rules require the register number to
1739 be referred to as a "base register". This distinction is not
1740 based in any way upon what category of register the hardware
1741 believes the given register belongs to. This is strictly
1742 DWARF terminology we're dealing with here.
1744 Note that in cases where the location of a memory-resident data
1745 object could be expressed as:
1747 OP_ADD (OP_BASEREG (basereg), OP_CONST (0))
1749 the actual DWARF location descriptor that we generate may just
1750 be OP_BASEREG (basereg). This may look deceptively like the
1751 object in question was allocated to a register (rather than
1752 in memory) so DWARF consumers need to be aware of the subtle
1753 distinction between OP_REG and OP_BASEREG. */
1755 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_BASEREG
);
1756 output_reg_number (rtl
);
1760 output_mem_loc_descriptor (XEXP (rtl
, 0));
1761 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_DEREF4
);
1766 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_ADDR
);
1767 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file
, rtl
);
1771 output_mem_loc_descriptor (XEXP (rtl
, 0));
1772 output_mem_loc_descriptor (XEXP (rtl
, 1));
1773 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_ADD
);
1777 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_CONST
);
1778 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, INTVAL (rtl
));
1782 /* If a pseudo-reg is optimized away, it is possible for it to
1783 be replaced with a MEM containing a multiply. Use a GNU extension
1785 output_mem_loc_descriptor (XEXP (rtl
, 0));
1786 output_mem_loc_descriptor (XEXP (rtl
, 1));
1787 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_MULT
);
1795 /* Output a proper Dwarf location descriptor for a variable or parameter
1796 which is either allocated in a register or in a memory location. For
1797 a register, we just generate an OP_REG and the register number. For a
1798 memory location we provide a Dwarf postfix expression describing how to
1799 generate the (dynamic) address of the object onto the address stack. */
1802 output_loc_descriptor (rtl
)
1805 switch (GET_CODE (rtl
))
1809 /* The case of a subreg may arise when we have a local (register)
1810 variable or a formal (register) parameter which doesn't quite
1811 fill up an entire register. For now, just assume that it is
1812 legitimate to make the Dwarf info refer to the whole register
1813 which contains the given subreg. */
1815 rtl
= XEXP (rtl
, 0);
1819 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_REG
);
1820 output_reg_number (rtl
);
1824 output_mem_loc_descriptor (XEXP (rtl
, 0));
1828 abort (); /* Should never happen */
1832 /* Given a tree node describing an array bound (either lower or upper)
1833 output a representation for that bound. */
1836 output_bound_representation (bound
, dim_num
, u_or_l
)
1837 register tree bound
;
1838 register unsigned dim_num
; /* For multi-dimensional arrays. */
1839 register char u_or_l
; /* Designates upper or lower bound. */
1841 switch (TREE_CODE (bound
))
1847 /* All fixed-bounds are represented by INTEGER_CST nodes. */
1850 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
1851 (unsigned) TREE_INT_CST_LOW (bound
));
1856 /* Dynamic bounds may be represented by NOP_EXPR nodes containing
1857 SAVE_EXPR nodes, in which case we can do something, or as
1858 an expression, which we cannot represent. */
1860 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1861 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1863 sprintf (begin_label
, BOUND_BEGIN_LABEL_FMT
,
1864 current_dienum
, dim_num
, u_or_l
);
1866 sprintf (end_label
, BOUND_END_LABEL_FMT
,
1867 current_dienum
, dim_num
, u_or_l
);
1869 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
1870 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
1872 /* If optimization is turned on, the SAVE_EXPRs that describe
1873 how to access the upper bound values are essentially bogus.
1874 They only describe (at best) how to get at these values at
1875 the points in the generated code right after they have just
1876 been computed. Worse yet, in the typical case, the upper
1877 bound values will not even *be* computed in the optimized
1878 code, so these SAVE_EXPRs are entirely bogus.
1880 In order to compensate for this fact, we check here to see
1881 if optimization is enabled, and if so, we effectively create
1882 an empty location description for the (unknown and unknowable)
1885 This should not cause too much trouble for existing (stupid?)
1886 debuggers because they have to deal with empty upper bounds
1887 location descriptions anyway in order to be able to deal with
1888 incomplete array types.
1890 Of course an intelligent debugger (GDB?) should be able to
1891 comprehend that a missing upper bound specification in a
1892 array type used for a storage class `auto' local array variable
1893 indicates that the upper bound is both unknown (at compile-
1894 time) and unknowable (at run-time) due to optimization. */
1898 while (TREE_CODE (bound
) == NOP_EXPR
1899 || TREE_CODE (bound
) == CONVERT_EXPR
)
1900 bound
= TREE_OPERAND (bound
, 0);
1902 if (TREE_CODE (bound
) == SAVE_EXPR
)
1903 output_loc_descriptor
1904 (eliminate_regs (SAVE_EXPR_RTL (bound
), 0, NULL_RTX
));
1907 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
1914 /* Recursive function to output a sequence of value/name pairs for
1915 enumeration constants in reversed order. This is called from
1916 enumeration_type_die. */
1919 output_enumeral_list (link
)
1924 output_enumeral_list (TREE_CHAIN (link
));
1925 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
1926 (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link
)));
1927 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
,
1928 IDENTIFIER_POINTER (TREE_PURPOSE (link
)));
1932 /* Given an unsigned value, round it up to the lowest multiple of `boundary'
1933 which is not less than the value itself. */
1935 static inline unsigned
1936 ceiling (value
, boundary
)
1937 register unsigned value
;
1938 register unsigned boundary
;
1940 return (((value
+ boundary
- 1) / boundary
) * boundary
);
1943 /* Given a pointer to what is assumed to be a FIELD_DECL node, return a
1944 pointer to the declared type for the relevant field variable, or return
1945 `integer_type_node' if the given node turns out to be an ERROR_MARK node. */
1953 if (TREE_CODE (decl
) == ERROR_MARK
)
1954 return integer_type_node
;
1956 type
= DECL_BIT_FIELD_TYPE (decl
);
1958 type
= TREE_TYPE (decl
);
1962 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
1963 node, return the alignment in bits for the type, or else return
1964 BITS_PER_WORD if the node actually turns out to be an ERROR_MARK node. */
1966 static inline unsigned
1967 simple_type_align_in_bits (type
)
1970 return (TREE_CODE (type
) != ERROR_MARK
) ? TYPE_ALIGN (type
) : BITS_PER_WORD
;
1973 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
1974 node, return the size in bits for the type if it is a constant, or
1975 else return the alignment for the type if the type's size is not
1976 constant, or else return BITS_PER_WORD if the type actually turns out
1977 to be an ERROR_MARK node. */
1979 static inline unsigned
1980 simple_type_size_in_bits (type
)
1983 if (TREE_CODE (type
) == ERROR_MARK
)
1984 return BITS_PER_WORD
;
1987 register tree type_size_tree
= TYPE_SIZE (type
);
1989 if (TREE_CODE (type_size_tree
) != INTEGER_CST
)
1990 return TYPE_ALIGN (type
);
1992 return (unsigned) TREE_INT_CST_LOW (type_size_tree
);
1996 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
1997 return the byte offset of the lowest addressed byte of the "containing
1998 object" for the given FIELD_DECL, or return 0 if we are unable to deter-
1999 mine what that offset is, either because the argument turns out to be a
2000 pointer to an ERROR_MARK node, or because the offset is actually variable.
2001 (We can't handle the latter case just yet.) */
2004 field_byte_offset (decl
)
2007 register unsigned type_align_in_bytes
;
2008 register unsigned type_align_in_bits
;
2009 register unsigned type_size_in_bits
;
2010 register unsigned object_offset_in_align_units
;
2011 register unsigned object_offset_in_bits
;
2012 register unsigned object_offset_in_bytes
;
2014 register tree bitpos_tree
;
2015 register tree field_size_tree
;
2016 register unsigned bitpos_int
;
2017 register unsigned deepest_bitpos
;
2018 register unsigned field_size_in_bits
;
2020 if (TREE_CODE (decl
) == ERROR_MARK
)
2023 if (TREE_CODE (decl
) != FIELD_DECL
)
2026 type
= field_type (decl
);
2028 bitpos_tree
= DECL_FIELD_BITPOS (decl
);
2029 field_size_tree
= DECL_SIZE (decl
);
2031 /* If there was an error, the size could be zero. */
2032 if (! field_size_tree
)
2040 /* We cannot yet cope with fields whose positions or sizes are variable,
2041 so for now, when we see such things, we simply return 0. Someday,
2042 we may be able to handle such cases, but it will be damn difficult. */
2044 if (TREE_CODE (bitpos_tree
) != INTEGER_CST
)
2046 bitpos_int
= (unsigned) TREE_INT_CST_LOW (bitpos_tree
);
2048 if (TREE_CODE (field_size_tree
) != INTEGER_CST
)
2050 field_size_in_bits
= (unsigned) TREE_INT_CST_LOW (field_size_tree
);
2052 type_size_in_bits
= simple_type_size_in_bits (type
);
2054 type_align_in_bits
= simple_type_align_in_bits (type
);
2055 type_align_in_bytes
= type_align_in_bits
/ BITS_PER_UNIT
;
2057 /* Note that the GCC front-end doesn't make any attempt to keep track
2058 of the starting bit offset (relative to the start of the containing
2059 structure type) of the hypothetical "containing object" for a bit-
2060 field. Thus, when computing the byte offset value for the start of
2061 the "containing object" of a bit-field, we must deduce this infor-
2064 This can be rather tricky to do in some cases. For example, handling
2065 the following structure type definition when compiling for an i386/i486
2066 target (which only aligns long long's to 32-bit boundaries) can be very
2071 long long field2:31;
2074 Fortunately, there is a simple rule-of-thumb which can be used in such
2075 cases. When compiling for an i386/i486, GCC will allocate 8 bytes for
2076 the structure shown above. It decides to do this based upon one simple
2077 rule for bit-field allocation. Quite simply, GCC allocates each "con-
2078 taining object" for each bit-field at the first (i.e. lowest addressed)
2079 legitimate alignment boundary (based upon the required minimum alignment
2080 for the declared type of the field) which it can possibly use, subject
2081 to the condition that there is still enough available space remaining
2082 in the containing object (when allocated at the selected point) to
2083 fully accommodate all of the bits of the bit-field itself.
2085 This simple rule makes it obvious why GCC allocates 8 bytes for each
2086 object of the structure type shown above. When looking for a place to
2087 allocate the "containing object" for `field2', the compiler simply tries
2088 to allocate a 64-bit "containing object" at each successive 32-bit
2089 boundary (starting at zero) until it finds a place to allocate that 64-
2090 bit field such that at least 31 contiguous (and previously unallocated)
2091 bits remain within that selected 64 bit field. (As it turns out, for
2092 the example above, the compiler finds that it is OK to allocate the
2093 "containing object" 64-bit field at bit-offset zero within the
2096 Here we attempt to work backwards from the limited set of facts we're
2097 given, and we try to deduce from those facts, where GCC must have
2098 believed that the containing object started (within the structure type).
2100 The value we deduce is then used (by the callers of this routine) to
2101 generate AT_location and AT_bit_offset attributes for fields (both
2102 bit-fields and, in the case of AT_location, regular fields as well).
2105 /* Figure out the bit-distance from the start of the structure to the
2106 "deepest" bit of the bit-field. */
2107 deepest_bitpos
= bitpos_int
+ field_size_in_bits
;
2109 /* This is the tricky part. Use some fancy footwork to deduce where the
2110 lowest addressed bit of the containing object must be. */
2111 object_offset_in_bits
2112 = ceiling (deepest_bitpos
, type_align_in_bits
) - type_size_in_bits
;
2114 /* Compute the offset of the containing object in "alignment units". */
2115 object_offset_in_align_units
= object_offset_in_bits
/ type_align_in_bits
;
2117 /* Compute the offset of the containing object in bytes. */
2118 object_offset_in_bytes
= object_offset_in_align_units
* type_align_in_bytes
;
2120 /* The above code assumes that the field does not cross an alignment
2121 boundary. This can happen if PCC_BITFIELD_TYPE_MATTERS is not defined,
2122 or if the structure is packed. If this happens, then we get an object
2123 which starts after the bitfield, which means that the bit offset is
2124 negative. Gdb fails when given negative bit offsets. We avoid this
2125 by recomputing using the first bit of the bitfield. This will give
2126 us an object which does not completely contain the bitfield, but it
2127 will be aligned, and it will contain the first bit of the bitfield.
2129 However, only do this for a BYTES_BIG_ENDIAN target. For a
2130 ! BYTES_BIG_ENDIAN target, bitpos_int + field_size_in_bits is the first
2131 first bit of the bitfield. If we recompute using bitpos_int + 1 below,
2132 then we end up computing the object byte offset for the wrong word of the
2133 desired bitfield, which in turn causes the field offset to be negative
2134 in bit_offset_attribute. */
2135 if (BYTES_BIG_ENDIAN
2136 && object_offset_in_bits
> bitpos_int
)
2138 deepest_bitpos
= bitpos_int
+ 1;
2139 object_offset_in_bits
2140 = ceiling (deepest_bitpos
, type_align_in_bits
) - type_size_in_bits
;
2141 object_offset_in_align_units
= (object_offset_in_bits
2142 / type_align_in_bits
);
2143 object_offset_in_bytes
= (object_offset_in_align_units
2144 * type_align_in_bytes
);
2147 return object_offset_in_bytes
;
2150 /****************************** attributes *********************************/
2152 /* The following routines are responsible for writing out the various types
2153 of Dwarf attributes (and any following data bytes associated with them).
2154 These routines are listed in order based on the numerical codes of their
2155 associated attributes. */
2157 /* Generate an AT_sibling attribute. */
2160 sibling_attribute ()
2162 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2164 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_sibling
);
2165 sprintf (label
, DIE_BEGIN_LABEL_FMT
, NEXT_DIE_NUM
);
2166 ASM_OUTPUT_DWARF_REF (asm_out_file
, label
);
2169 /* Output the form of location attributes suitable for whole variables and
2170 whole parameters. Note that the location attributes for struct fields
2171 are generated by the routine `data_member_location_attribute' below. */
2174 location_attribute (rtl
)
2177 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2178 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2180 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_location
);
2181 sprintf (begin_label
, LOC_BEGIN_LABEL_FMT
, current_dienum
);
2182 sprintf (end_label
, LOC_END_LABEL_FMT
, current_dienum
);
2183 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
2184 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2186 /* Handle a special case. If we are about to output a location descriptor
2187 for a variable or parameter which has been optimized out of existence,
2188 don't do that. Instead we output a zero-length location descriptor
2189 value as part of the location attribute.
2191 A variable which has been optimized out of existence will have a
2192 DECL_RTL value which denotes a pseudo-reg.
2194 Currently, in some rare cases, variables can have DECL_RTL values
2195 which look like (MEM (REG pseudo-reg#)). These cases are due to
2196 bugs elsewhere in the compiler. We treat such cases
2197 as if the variable(s) in question had been optimized out of existence.
2199 Note that in all cases where we wish to express the fact that a
2200 variable has been optimized out of existence, we do not simply
2201 suppress the generation of the entire location attribute because
2202 the absence of a location attribute in certain kinds of DIEs is
2203 used to indicate something else entirely... i.e. that the DIE
2204 represents an object declaration, but not a definition. So saith
2208 if (! is_pseudo_reg (rtl
)
2209 && (GET_CODE (rtl
) != MEM
|| ! is_pseudo_reg (XEXP (rtl
, 0))))
2210 output_loc_descriptor (rtl
);
2212 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2215 /* Output the specialized form of location attribute used for data members
2216 of struct and union types.
2218 In the special case of a FIELD_DECL node which represents a bit-field,
2219 the "offset" part of this special location descriptor must indicate the
2220 distance in bytes from the lowest-addressed byte of the containing
2221 struct or union type to the lowest-addressed byte of the "containing
2222 object" for the bit-field. (See the `field_byte_offset' function above.)
2224 For any given bit-field, the "containing object" is a hypothetical
2225 object (of some integral or enum type) within which the given bit-field
2226 lives. The type of this hypothetical "containing object" is always the
2227 same as the declared type of the individual bit-field itself (for GCC
2228 anyway... the DWARF spec doesn't actually mandate this).
2230 Note that it is the size (in bytes) of the hypothetical "containing
2231 object" which will be given in the AT_byte_size attribute for this
2232 bit-field. (See the `byte_size_attribute' function below.) It is
2233 also used when calculating the value of the AT_bit_offset attribute.
2234 (See the `bit_offset_attribute' function below.) */
2237 data_member_location_attribute (t
)
2240 register unsigned object_offset_in_bytes
;
2241 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2242 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2244 if (TREE_CODE (t
) == TREE_VEC
)
2245 object_offset_in_bytes
= TREE_INT_CST_LOW (BINFO_OFFSET (t
));
2247 object_offset_in_bytes
= field_byte_offset (t
);
2249 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_location
);
2250 sprintf (begin_label
, LOC_BEGIN_LABEL_FMT
, current_dienum
);
2251 sprintf (end_label
, LOC_END_LABEL_FMT
, current_dienum
);
2252 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
2253 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2254 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_CONST
);
2255 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, object_offset_in_bytes
);
2256 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_ADD
);
2257 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2260 /* Output an AT_const_value attribute for a variable or a parameter which
2261 does not have a "location" either in memory or in a register. These
2262 things can arise in GNU C when a constant is passed as an actual
2263 parameter to an inlined function. They can also arise in C++ where
2264 declared constants do not necessarily get memory "homes". */
2267 const_value_attribute (rtl
)
2270 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2271 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2273 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_const_value_block4
);
2274 sprintf (begin_label
, LOC_BEGIN_LABEL_FMT
, current_dienum
);
2275 sprintf (end_label
, LOC_END_LABEL_FMT
, current_dienum
);
2276 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, end_label
, begin_label
);
2277 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2279 switch (GET_CODE (rtl
))
2282 /* Note that a CONST_INT rtx could represent either an integer or
2283 a floating-point constant. A CONST_INT is used whenever the
2284 constant will fit into a single word. In all such cases, the
2285 original mode of the constant value is wiped out, and the
2286 CONST_INT rtx is assigned VOIDmode. Since we no longer have
2287 precise mode information for these constants, we always just
2288 output them using 4 bytes. */
2290 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, (unsigned) INTVAL (rtl
));
2294 /* Note that a CONST_DOUBLE rtx could represent either an integer
2295 or a floating-point constant. A CONST_DOUBLE is used whenever
2296 the constant requires more than one word in order to be adequately
2297 represented. In all such cases, the original mode of the constant
2298 value is preserved as the mode of the CONST_DOUBLE rtx, but for
2299 simplicity we always just output CONST_DOUBLEs using 8 bytes. */
2301 ASM_OUTPUT_DWARF_DATA8 (asm_out_file
,
2302 (unsigned HOST_WIDE_INT
) CONST_DOUBLE_HIGH (rtl
),
2303 (unsigned HOST_WIDE_INT
) CONST_DOUBLE_LOW (rtl
));
2307 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, XSTR (rtl
, 0));
2313 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file
, rtl
);
2317 /* In cases where an inlined instance of an inline function is passed
2318 the address of an `auto' variable (which is local to the caller)
2319 we can get a situation where the DECL_RTL of the artificial
2320 local variable (for the inlining) which acts as a stand-in for
2321 the corresponding formal parameter (of the inline function)
2322 will look like (plus:SI (reg:SI FRAME_PTR) (const_int ...)).
2323 This is not exactly a compile-time constant expression, but it
2324 isn't the address of the (artificial) local variable either.
2325 Rather, it represents the *value* which the artificial local
2326 variable always has during its lifetime. We currently have no
2327 way to represent such quasi-constant values in Dwarf, so for now
2328 we just punt and generate an AT_const_value attribute with form
2329 FORM_BLOCK4 and a length of zero. */
2333 abort (); /* No other kinds of rtx should be possible here. */
2336 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2339 /* Generate *either* an AT_location attribute or else an AT_const_value
2340 data attribute for a variable or a parameter. We generate the
2341 AT_const_value attribute only in those cases where the given
2342 variable or parameter does not have a true "location" either in
2343 memory or in a register. This can happen (for example) when a
2344 constant is passed as an actual argument in a call to an inline
2345 function. (It's possible that these things can crop up in other
2346 ways also.) Note that one type of constant value which can be
2347 passed into an inlined function is a constant pointer. This can
2348 happen for example if an actual argument in an inlined function
2349 call evaluates to a compile-time constant address. */
2352 location_or_const_value_attribute (decl
)
2357 if (TREE_CODE (decl
) == ERROR_MARK
)
2360 if ((TREE_CODE (decl
) != VAR_DECL
) && (TREE_CODE (decl
) != PARM_DECL
))
2362 /* Should never happen. */
2367 /* Here we have to decide where we are going to say the parameter "lives"
2368 (as far as the debugger is concerned). We only have a couple of choices.
2369 GCC provides us with DECL_RTL and with DECL_INCOMING_RTL. DECL_RTL
2370 normally indicates where the parameter lives during most of the activa-
2371 tion of the function. If optimization is enabled however, this could
2372 be either NULL or else a pseudo-reg. Both of those cases indicate that
2373 the parameter doesn't really live anywhere (as far as the code generation
2374 parts of GCC are concerned) during most of the function's activation.
2375 That will happen (for example) if the parameter is never referenced
2376 within the function.
2378 We could just generate a location descriptor here for all non-NULL
2379 non-pseudo values of DECL_RTL and ignore all of the rest, but we can
2380 be a little nicer than that if we also consider DECL_INCOMING_RTL in
2381 cases where DECL_RTL is NULL or is a pseudo-reg.
2383 Note however that we can only get away with using DECL_INCOMING_RTL as
2384 a backup substitute for DECL_RTL in certain limited cases. In cases
2385 where DECL_ARG_TYPE(decl) indicates the same type as TREE_TYPE(decl)
2386 we can be sure that the parameter was passed using the same type as it
2387 is declared to have within the function, and that its DECL_INCOMING_RTL
2388 points us to a place where a value of that type is passed. In cases
2389 where DECL_ARG_TYPE(decl) and TREE_TYPE(decl) are different types
2390 however, we cannot (in general) use DECL_INCOMING_RTL as a backup
2391 substitute for DECL_RTL because in these cases, DECL_INCOMING_RTL
2392 points us to a value of some type which is *different* from the type
2393 of the parameter itself. Thus, if we tried to use DECL_INCOMING_RTL
2394 to generate a location attribute in such cases, the debugger would
2395 end up (for example) trying to fetch a `float' from a place which
2396 actually contains the first part of a `double'. That would lead to
2397 really incorrect and confusing output at debug-time, and we don't
2398 want that now do we?
2400 So in general, we DO NOT use DECL_INCOMING_RTL as a backup for DECL_RTL
2401 in cases where DECL_ARG_TYPE(decl) != TREE_TYPE(decl). There are a
2402 couple of cute exceptions however. On little-endian machines we can
2403 get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE(decl) is
2404 not the same as TREE_TYPE(decl) but only when DECL_ARG_TYPE(decl) is
2405 an integral type which is smaller than TREE_TYPE(decl). These cases
2406 arise when (on a little-endian machine) a non-prototyped function has
2407 a parameter declared to be of type `short' or `char'. In such cases,
2408 TREE_TYPE(decl) will be `short' or `char', DECL_ARG_TYPE(decl) will be
2409 `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
2410 passed `int' value. If the debugger then uses that address to fetch a
2411 `short' or a `char' (on a little-endian machine) the result will be the
2412 correct data, so we allow for such exceptional cases below.
2414 Note that our goal here is to describe the place where the given formal
2415 parameter lives during most of the function's activation (i.e. between
2416 the end of the prologue and the start of the epilogue). We'll do that
2417 as best as we can. Note however that if the given formal parameter is
2418 modified sometime during the execution of the function, then a stack
2419 backtrace (at debug-time) will show the function as having been called
2420 with the *new* value rather than the value which was originally passed
2421 in. This happens rarely enough that it is not a major problem, but it
2422 *is* a problem, and I'd like to fix it. A future version of dwarfout.c
2423 may generate two additional attributes for any given TAG_formal_parameter
2424 DIE which will describe the "passed type" and the "passed location" for
2425 the given formal parameter in addition to the attributes we now generate
2426 to indicate the "declared type" and the "active location" for each
2427 parameter. This additional set of attributes could be used by debuggers
2428 for stack backtraces.
2430 Separately, note that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL
2431 can be NULL also. This happens (for example) for inlined-instances of
2432 inline function formal parameters which are never referenced. This really
2433 shouldn't be happening. All PARM_DECL nodes should get valid non-NULL
2434 DECL_INCOMING_RTL values, but integrate.c doesn't currently generate
2435 these values for inlined instances of inline function parameters, so
2436 when we see such cases, we are just out-of-luck for the time
2437 being (until integrate.c gets fixed).
2440 /* Use DECL_RTL as the "location" unless we find something better. */
2441 rtl
= DECL_RTL (decl
);
2443 if (TREE_CODE (decl
) == PARM_DECL
)
2444 if (rtl
== NULL_RTX
|| is_pseudo_reg (rtl
))
2446 /* This decl represents a formal parameter which was optimized out. */
2447 register tree declared_type
= type_main_variant (TREE_TYPE (decl
));
2448 register tree passed_type
= type_main_variant (DECL_ARG_TYPE (decl
));
2450 /* Note that DECL_INCOMING_RTL may be NULL in here, but we handle
2451 *all* cases where (rtl == NULL_RTX) just below. */
2453 if (declared_type
== passed_type
)
2454 rtl
= DECL_INCOMING_RTL (decl
);
2455 else if (! BYTES_BIG_ENDIAN
)
2456 if (TREE_CODE (declared_type
) == INTEGER_TYPE
)
2457 if (TYPE_SIZE (declared_type
) <= TYPE_SIZE (passed_type
))
2458 rtl
= DECL_INCOMING_RTL (decl
);
2461 if (rtl
== NULL_RTX
)
2464 rtl
= eliminate_regs (rtl
, 0, NULL_RTX
);
2465 #ifdef LEAF_REG_REMAP
2466 if (current_function_uses_only_leaf_regs
)
2467 leaf_renumber_regs_insn (rtl
);
2470 switch (GET_CODE (rtl
))
2473 /* The address of a variable that was optimized away; don't emit
2483 case PLUS
: /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
2484 const_value_attribute (rtl
);
2490 location_attribute (rtl
);
2494 /* ??? CONCAT is used for complex variables, which may have the real
2495 part stored in one place and the imag part stored somewhere else.
2496 DWARF1 has no way to describe a variable that lives in two different
2497 places, so we just describe where the first part lives, and hope that
2498 the second part is stored after it. */
2499 location_attribute (XEXP (rtl
, 0));
2503 abort (); /* Should never happen. */
2507 /* Generate an AT_name attribute given some string value to be included as
2508 the value of the attribute. */
2511 name_attribute (name_string
)
2512 register const char *name_string
;
2514 if (name_string
&& *name_string
)
2516 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_name
);
2517 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, name_string
);
2522 fund_type_attribute (ft_code
)
2523 register unsigned ft_code
;
2525 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_fund_type
);
2526 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file
, ft_code
);
2530 mod_fund_type_attribute (type
, decl_const
, decl_volatile
)
2532 register int decl_const
;
2533 register int decl_volatile
;
2535 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2536 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2538 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_mod_fund_type
);
2539 sprintf (begin_label
, MT_BEGIN_LABEL_FMT
, current_dienum
);
2540 sprintf (end_label
, MT_END_LABEL_FMT
, current_dienum
);
2541 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
2542 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2543 write_modifier_bytes (type
, decl_const
, decl_volatile
);
2544 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file
,
2545 fundamental_type_code (root_type (type
)));
2546 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2550 user_def_type_attribute (type
)
2553 char ud_type_name
[MAX_ARTIFICIAL_LABEL_BYTES
];
2555 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_user_def_type
);
2556 sprintf (ud_type_name
, TYPE_NAME_FMT
, TYPE_UID (type
));
2557 ASM_OUTPUT_DWARF_REF (asm_out_file
, ud_type_name
);
2561 mod_u_d_type_attribute (type
, decl_const
, decl_volatile
)
2563 register int decl_const
;
2564 register int decl_volatile
;
2566 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2567 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2568 char ud_type_name
[MAX_ARTIFICIAL_LABEL_BYTES
];
2570 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_mod_u_d_type
);
2571 sprintf (begin_label
, MT_BEGIN_LABEL_FMT
, current_dienum
);
2572 sprintf (end_label
, MT_END_LABEL_FMT
, current_dienum
);
2573 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
2574 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2575 write_modifier_bytes (type
, decl_const
, decl_volatile
);
2576 sprintf (ud_type_name
, TYPE_NAME_FMT
, TYPE_UID (root_type (type
)));
2577 ASM_OUTPUT_DWARF_REF (asm_out_file
, ud_type_name
);
2578 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2581 #ifdef USE_ORDERING_ATTRIBUTE
2583 ordering_attribute (ordering
)
2584 register unsigned ordering
;
2586 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_ordering
);
2587 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, ordering
);
2589 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
2591 /* Note that the block of subscript information for an array type also
2592 includes information about the element type of type given array type. */
2595 subscript_data_attribute (type
)
2598 register unsigned dimension_number
;
2599 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2600 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2602 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_subscr_data
);
2603 sprintf (begin_label
, SS_BEGIN_LABEL_FMT
, current_dienum
);
2604 sprintf (end_label
, SS_END_LABEL_FMT
, current_dienum
);
2605 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
2606 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2608 /* The GNU compilers represent multidimensional array types as sequences
2609 of one dimensional array types whose element types are themselves array
2610 types. Here we squish that down, so that each multidimensional array
2611 type gets only one array_type DIE in the Dwarf debugging info. The
2612 draft Dwarf specification say that we are allowed to do this kind
2613 of compression in C (because there is no difference between an
2614 array or arrays and a multidimensional array in C) but for other
2615 source languages (e.g. Ada) we probably shouldn't do this. */
2617 for (dimension_number
= 0;
2618 TREE_CODE (type
) == ARRAY_TYPE
;
2619 type
= TREE_TYPE (type
), dimension_number
++)
2621 register tree domain
= TYPE_DOMAIN (type
);
2623 /* Arrays come in three flavors. Unspecified bounds, fixed
2624 bounds, and (in GNU C only) variable bounds. Handle all
2625 three forms here. */
2629 /* We have an array type with specified bounds. */
2631 register tree lower
= TYPE_MIN_VALUE (domain
);
2632 register tree upper
= TYPE_MAX_VALUE (domain
);
2634 /* Handle only fundamental types as index types for now. */
2636 if (! type_is_fundamental (domain
))
2639 /* Output the representation format byte for this dimension. */
2641 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file
,
2642 FMT_CODE (1, TREE_CODE (lower
) == INTEGER_CST
,
2643 (upper
&& TREE_CODE (upper
) == INTEGER_CST
)));
2645 /* Output the index type for this dimension. */
2647 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file
,
2648 fundamental_type_code (domain
));
2650 /* Output the representation for the lower bound. */
2652 output_bound_representation (lower
, dimension_number
, 'l');
2654 /* Output the representation for the upper bound. */
2656 output_bound_representation (upper
, dimension_number
, 'u');
2660 /* We have an array type with an unspecified length. For C and
2661 C++ we can assume that this really means that (a) the index
2662 type is an integral type, and (b) the lower bound is zero.
2663 Note that Dwarf defines the representation of an unspecified
2664 (upper) bound as being a zero-length location description. */
2666 /* Output the array-bounds format byte. */
2668 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file
, FMT_FT_C_X
);
2670 /* Output the (assumed) index type. */
2672 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file
, FT_integer
);
2674 /* Output the (assumed) lower bound (constant) value. */
2676 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
2678 /* Output the (empty) location description for the upper bound. */
2680 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, 0);
2684 /* Output the prefix byte that says that the element type is coming up. */
2686 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file
, FMT_ET
);
2688 /* Output a representation of the type of the elements of this array type. */
2690 type_attribute (type
, 0, 0);
2692 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2696 byte_size_attribute (tree_node
)
2697 register tree tree_node
;
2699 register unsigned size
;
2701 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_byte_size
);
2702 switch (TREE_CODE (tree_node
))
2711 case QUAL_UNION_TYPE
:
2713 size
= int_size_in_bytes (tree_node
);
2717 /* For a data member of a struct or union, the AT_byte_size is
2718 generally given as the number of bytes normally allocated for
2719 an object of the *declared* type of the member itself. This
2720 is true even for bit-fields. */
2721 size
= simple_type_size_in_bits (field_type (tree_node
))
2729 /* Note that `size' might be -1 when we get to this point. If it
2730 is, that indicates that the byte size of the entity in question
2731 is variable. We have no good way of expressing this fact in Dwarf
2732 at the present time, so just let the -1 pass on through. */
2734 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, size
);
2737 /* For a FIELD_DECL node which represents a bit-field, output an attribute
2738 which specifies the distance in bits from the highest order bit of the
2739 "containing object" for the bit-field to the highest order bit of the
2742 For any given bit-field, the "containing object" is a hypothetical
2743 object (of some integral or enum type) within which the given bit-field
2744 lives. The type of this hypothetical "containing object" is always the
2745 same as the declared type of the individual bit-field itself.
2747 The determination of the exact location of the "containing object" for
2748 a bit-field is rather complicated. It's handled by the `field_byte_offset'
2751 Note that it is the size (in bytes) of the hypothetical "containing
2752 object" which will be given in the AT_byte_size attribute for this
2753 bit-field. (See `byte_size_attribute' above.) */
2756 bit_offset_attribute (decl
)
2759 register unsigned object_offset_in_bytes
= field_byte_offset (decl
);
2760 register tree type
= DECL_BIT_FIELD_TYPE (decl
);
2761 register tree bitpos_tree
= DECL_FIELD_BITPOS (decl
);
2762 register unsigned bitpos_int
;
2763 register unsigned highest_order_object_bit_offset
;
2764 register unsigned highest_order_field_bit_offset
;
2765 register unsigned bit_offset
;
2767 /* Must be a bit field. */
2769 || TREE_CODE (decl
) != FIELD_DECL
)
2772 /* We can't yet handle bit-fields whose offsets are variable, so if we
2773 encounter such things, just return without generating any attribute
2776 if (TREE_CODE (bitpos_tree
) != INTEGER_CST
)
2778 bitpos_int
= (unsigned) TREE_INT_CST_LOW (bitpos_tree
);
2780 /* Note that the bit offset is always the distance (in bits) from the
2781 highest-order bit of the "containing object" to the highest-order
2782 bit of the bit-field itself. Since the "high-order end" of any
2783 object or field is different on big-endian and little-endian machines,
2784 the computation below must take account of these differences. */
2786 highest_order_object_bit_offset
= object_offset_in_bytes
* BITS_PER_UNIT
;
2787 highest_order_field_bit_offset
= bitpos_int
;
2789 if (! BYTES_BIG_ENDIAN
)
2791 highest_order_field_bit_offset
2792 += (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl
));
2794 highest_order_object_bit_offset
+= simple_type_size_in_bits (type
);
2799 ? highest_order_object_bit_offset
- highest_order_field_bit_offset
2800 : highest_order_field_bit_offset
- highest_order_object_bit_offset
);
2802 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_bit_offset
);
2803 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, bit_offset
);
2806 /* For a FIELD_DECL node which represents a bit field, output an attribute
2807 which specifies the length in bits of the given field. */
2810 bit_size_attribute (decl
)
2813 /* Must be a field and a bit field. */
2814 if (TREE_CODE (decl
) != FIELD_DECL
2815 || ! DECL_BIT_FIELD_TYPE (decl
))
2818 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_bit_size
);
2819 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
2820 (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl
)));
2823 /* The following routine outputs the `element_list' attribute for enumeration
2824 type DIEs. The element_lits attribute includes the names and values of
2825 all of the enumeration constants associated with the given enumeration
2829 element_list_attribute (element
)
2830 register tree element
;
2832 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2833 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2835 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_element_list
);
2836 sprintf (begin_label
, EE_BEGIN_LABEL_FMT
, current_dienum
);
2837 sprintf (end_label
, EE_END_LABEL_FMT
, current_dienum
);
2838 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, end_label
, begin_label
);
2839 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2841 /* Here we output a list of value/name pairs for each enumeration constant
2842 defined for this enumeration type (as required), but we do it in REVERSE
2843 order. The order is the one required by the draft #5 Dwarf specification
2844 published by the UI/PLSIG. */
2846 output_enumeral_list (element
); /* Recursively output the whole list. */
2848 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2851 /* Generate an AT_stmt_list attribute. These are normally present only in
2852 DIEs with a TAG_compile_unit tag. */
2855 stmt_list_attribute (label
)
2856 register const char *label
;
2858 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_stmt_list
);
2859 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2860 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, label
);
2863 /* Generate an AT_low_pc attribute for a label DIE, a lexical_block DIE or
2864 for a subroutine DIE. */
2867 low_pc_attribute (asm_low_label
)
2868 register const char *asm_low_label
;
2870 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_low_pc
);
2871 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, asm_low_label
);
2874 /* Generate an AT_high_pc attribute for a lexical_block DIE or for a
2878 high_pc_attribute (asm_high_label
)
2879 register const char *asm_high_label
;
2881 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_high_pc
);
2882 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, asm_high_label
);
2885 /* Generate an AT_body_begin attribute for a subroutine DIE. */
2888 body_begin_attribute (asm_begin_label
)
2889 register const char *asm_begin_label
;
2891 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_body_begin
);
2892 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, asm_begin_label
);
2895 /* Generate an AT_body_end attribute for a subroutine DIE. */
2898 body_end_attribute (asm_end_label
)
2899 register const char *asm_end_label
;
2901 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_body_end
);
2902 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, asm_end_label
);
2905 /* Generate an AT_language attribute given a LANG value. These attributes
2906 are used only within TAG_compile_unit DIEs. */
2909 language_attribute (language_code
)
2910 register unsigned language_code
;
2912 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_language
);
2913 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, language_code
);
2917 member_attribute (context
)
2918 register tree context
;
2920 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2922 /* Generate this attribute only for members in C++. */
2924 if (context
!= NULL
&& is_tagged_type (context
))
2926 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_member
);
2927 sprintf (label
, TYPE_NAME_FMT
, TYPE_UID (context
));
2928 ASM_OUTPUT_DWARF_REF (asm_out_file
, label
);
2934 string_length_attribute (upper_bound
)
2935 register tree upper_bound
;
2937 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2938 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2940 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_string_length
);
2941 sprintf (begin_label
, SL_BEGIN_LABEL_FMT
, current_dienum
);
2942 sprintf (end_label
, SL_END_LABEL_FMT
, current_dienum
);
2943 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
2944 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2945 output_bound_representation (upper_bound
, 0, 'u');
2946 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2951 comp_dir_attribute (dirname
)
2952 register const char *dirname
;
2954 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_comp_dir
);
2955 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, dirname
);
2959 sf_names_attribute (sf_names_start_label
)
2960 register const char *sf_names_start_label
;
2962 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_sf_names
);
2963 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2964 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, sf_names_start_label
);
2968 src_info_attribute (src_info_start_label
)
2969 register const char *src_info_start_label
;
2971 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_src_info
);
2972 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2973 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, src_info_start_label
);
2977 mac_info_attribute (mac_info_start_label
)
2978 register const char *mac_info_start_label
;
2980 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_mac_info
);
2981 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2982 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, mac_info_start_label
);
2986 prototyped_attribute (func_type
)
2987 register tree func_type
;
2989 if ((strcmp (language_string
, "GNU C") == 0)
2990 && (TYPE_ARG_TYPES (func_type
) != NULL
))
2992 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_prototyped
);
2993 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
2998 producer_attribute (producer
)
2999 register const char *producer
;
3001 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_producer
);
3002 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, producer
);
3006 inline_attribute (decl
)
3009 if (DECL_INLINE (decl
))
3011 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_inline
);
3012 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
3017 containing_type_attribute (containing_type
)
3018 register tree containing_type
;
3020 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3022 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_containing_type
);
3023 sprintf (label
, TYPE_NAME_FMT
, TYPE_UID (containing_type
));
3024 ASM_OUTPUT_DWARF_REF (asm_out_file
, label
);
3028 abstract_origin_attribute (origin
)
3029 register tree origin
;
3031 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3033 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_abstract_origin
);
3034 switch (TREE_CODE_CLASS (TREE_CODE (origin
)))
3037 sprintf (label
, DECL_NAME_FMT
, DECL_UID (origin
));
3041 sprintf (label
, TYPE_NAME_FMT
, TYPE_UID (origin
));
3045 abort (); /* Should never happen. */
3048 ASM_OUTPUT_DWARF_REF (asm_out_file
, label
);
3051 #ifdef DWARF_DECL_COORDINATES
3053 src_coords_attribute (src_fileno
, src_lineno
)
3054 register unsigned src_fileno
;
3055 register unsigned src_lineno
;
3057 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_src_coords
);
3058 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, src_fileno
);
3059 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, src_lineno
);
3061 #endif /* defined(DWARF_DECL_COORDINATES) */
3064 pure_or_virtual_attribute (func_decl
)
3065 register tree func_decl
;
3067 if (DECL_VIRTUAL_P (func_decl
))
3069 #if 0 /* DECL_ABSTRACT_VIRTUAL_P is C++-specific. */
3070 if (DECL_ABSTRACT_VIRTUAL_P (func_decl
))
3071 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_pure_virtual
);
3074 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_virtual
);
3075 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
3079 /************************* end of attributes *****************************/
3081 /********************* utility routines for DIEs *************************/
3083 /* Output an AT_name attribute and an AT_src_coords attribute for the
3084 given decl, but only if it actually has a name. */
3087 name_and_src_coords_attributes (decl
)
3090 register tree decl_name
= DECL_NAME (decl
);
3092 if (decl_name
&& IDENTIFIER_POINTER (decl_name
))
3094 name_attribute (IDENTIFIER_POINTER (decl_name
));
3095 #ifdef DWARF_DECL_COORDINATES
3097 register unsigned file_index
;
3099 /* This is annoying, but we have to pop out of the .debug section
3100 for a moment while we call `lookup_filename' because calling it
3101 may cause a temporary switch into the .debug_sfnames section and
3102 most svr4 assemblers are not smart enough to be able to nest
3103 section switches to any depth greater than one. Note that we
3104 also can't skirt this issue by delaying all output to the
3105 .debug_sfnames section unit the end of compilation because that
3106 would cause us to have inter-section forward references and
3107 Fred Fish sez that m68k/svr4 assemblers botch those. */
3109 ASM_OUTPUT_POP_SECTION (asm_out_file
);
3110 file_index
= lookup_filename (DECL_SOURCE_FILE (decl
));
3111 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DEBUG_SECTION
);
3113 src_coords_attribute (file_index
, DECL_SOURCE_LINE (decl
));
3115 #endif /* defined(DWARF_DECL_COORDINATES) */
3119 /* Many forms of DIEs contain a "type description" part. The following
3120 routine writes out these "type descriptor" parts. */
3123 type_attribute (type
, decl_const
, decl_volatile
)
3125 register int decl_const
;
3126 register int decl_volatile
;
3128 register enum tree_code code
= TREE_CODE (type
);
3129 register int root_type_modified
;
3131 if (code
== ERROR_MARK
)
3134 /* Handle a special case. For functions whose return type is void,
3135 we generate *no* type attribute. (Note that no object may have
3136 type `void', so this only applies to function return types. */
3138 if (code
== VOID_TYPE
)
3141 /* If this is a subtype, find the underlying type. Eventually,
3142 this should write out the appropriate subtype info. */
3143 while ((code
== INTEGER_TYPE
|| code
== REAL_TYPE
)
3144 && TREE_TYPE (type
) != 0)
3145 type
= TREE_TYPE (type
), code
= TREE_CODE (type
);
3147 root_type_modified
= (code
== POINTER_TYPE
|| code
== REFERENCE_TYPE
3148 || decl_const
|| decl_volatile
3149 || TYPE_READONLY (type
) || TYPE_VOLATILE (type
));
3151 if (type_is_fundamental (root_type (type
)))
3153 if (root_type_modified
)
3154 mod_fund_type_attribute (type
, decl_const
, decl_volatile
);
3156 fund_type_attribute (fundamental_type_code (type
));
3160 if (root_type_modified
)
3161 mod_u_d_type_attribute (type
, decl_const
, decl_volatile
);
3163 /* We have to get the type_main_variant here (and pass that to the
3164 `user_def_type_attribute' routine) because the ..._TYPE node we
3165 have might simply be a *copy* of some original type node (where
3166 the copy was created to help us keep track of typedef names)
3167 and that copy might have a different TYPE_UID from the original
3168 ..._TYPE node. (Note that when `equate_type_number_to_die_number'
3169 is labeling a given type DIE for future reference, it always and
3170 only creates labels for DIEs representing *main variants*, and it
3171 never even knows about non-main-variants.) */
3172 user_def_type_attribute (type_main_variant (type
));
3176 /* Given a tree pointer to a struct, class, union, or enum type node, return
3177 a pointer to the (string) tag name for the given type, or zero if the
3178 type was declared without a tag. */
3184 register char *name
= 0;
3186 if (TYPE_NAME (type
) != 0)
3188 register tree t
= 0;
3190 /* Find the IDENTIFIER_NODE for the type name. */
3191 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
3192 t
= TYPE_NAME (type
);
3194 /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
3195 a TYPE_DECL node, regardless of whether or not a `typedef' was
3197 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
3198 && ! DECL_IGNORED_P (TYPE_NAME (type
)))
3199 t
= DECL_NAME (TYPE_NAME (type
));
3201 /* Now get the name as a string, or invent one. */
3203 name
= IDENTIFIER_POINTER (t
);
3206 return (name
== 0 || *name
== '\0') ? 0 : name
;
3212 /* Start by checking if the pending_sibling_stack needs to be expanded.
3213 If necessary, expand it. */
3215 if (pending_siblings
== pending_siblings_allocated
)
3217 pending_siblings_allocated
+= PENDING_SIBLINGS_INCREMENT
;
3218 pending_sibling_stack
3219 = (unsigned *) xrealloc (pending_sibling_stack
,
3220 pending_siblings_allocated
* sizeof(unsigned));
3224 NEXT_DIE_NUM
= next_unused_dienum
++;
3227 /* Pop the sibling stack so that the most recently pushed DIEnum becomes the
3237 member_declared_type (member
)
3238 register tree member
;
3240 return (DECL_BIT_FIELD_TYPE (member
))
3241 ? DECL_BIT_FIELD_TYPE (member
)
3242 : TREE_TYPE (member
);
3245 /* Get the function's label, as described by its RTL.
3246 This may be different from the DECL_NAME name used
3247 in the source file. */
3250 function_start_label (decl
)
3256 x
= DECL_RTL (decl
);
3257 if (GET_CODE (x
) != MEM
)
3260 if (GET_CODE (x
) != SYMBOL_REF
)
3262 fnname
= XSTR (x
, 0);
3267 /******************************* DIEs ************************************/
3269 /* Output routines for individual types of DIEs. */
3271 /* Note that every type of DIE (except a null DIE) gets a sibling. */
3274 output_array_type_die (arg
)
3277 register tree type
= arg
;
3279 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_array_type
);
3280 sibling_attribute ();
3281 equate_type_number_to_die_number (type
);
3282 member_attribute (TYPE_CONTEXT (type
));
3284 /* I believe that we can default the array ordering. SDB will probably
3285 do the right things even if AT_ordering is not present. It's not
3286 even an issue until we start to get into multidimensional arrays
3287 anyway. If SDB is ever caught doing the Wrong Thing for multi-
3288 dimensional arrays, then we'll have to put the AT_ordering attribute
3289 back in. (But if and when we find out that we need to put these in,
3290 we will only do so for multidimensional arrays. After all, we don't
3291 want to waste space in the .debug section now do we?) */
3293 #ifdef USE_ORDERING_ATTRIBUTE
3294 ordering_attribute (ORD_row_major
);
3295 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
3297 subscript_data_attribute (type
);
3301 output_set_type_die (arg
)
3304 register tree type
= arg
;
3306 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_set_type
);
3307 sibling_attribute ();
3308 equate_type_number_to_die_number (type
);
3309 member_attribute (TYPE_CONTEXT (type
));
3310 type_attribute (TREE_TYPE (type
), 0, 0);
3314 /* Implement this when there is a GNU FORTRAN or GNU Ada front end. */
3317 output_entry_point_die (arg
)
3320 register tree decl
= arg
;
3321 register tree origin
= decl_ultimate_origin (decl
);
3323 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_entry_point
);
3324 sibling_attribute ();
3327 abstract_origin_attribute (origin
);
3330 name_and_src_coords_attributes (decl
);
3331 member_attribute (DECL_CONTEXT (decl
));
3332 type_attribute (TREE_TYPE (TREE_TYPE (decl
)), 0, 0);
3334 if (DECL_ABSTRACT (decl
))
3335 equate_decl_number_to_die_number (decl
);
3337 low_pc_attribute (function_start_label (decl
));
3341 /* Output a DIE to represent an inlined instance of an enumeration type. */
3344 output_inlined_enumeration_type_die (arg
)
3347 register tree type
= arg
;
3349 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_enumeration_type
);
3350 sibling_attribute ();
3351 if (!TREE_ASM_WRITTEN (type
))
3353 abstract_origin_attribute (type
);
3356 /* Output a DIE to represent an inlined instance of a structure type. */
3359 output_inlined_structure_type_die (arg
)
3362 register tree type
= arg
;
3364 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_structure_type
);
3365 sibling_attribute ();
3366 if (!TREE_ASM_WRITTEN (type
))
3368 abstract_origin_attribute (type
);
3371 /* Output a DIE to represent an inlined instance of a union type. */
3374 output_inlined_union_type_die (arg
)
3377 register tree type
= arg
;
3379 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_union_type
);
3380 sibling_attribute ();
3381 if (!TREE_ASM_WRITTEN (type
))
3383 abstract_origin_attribute (type
);
3386 /* Output a DIE to represent an enumeration type. Note that these DIEs
3387 include all of the information about the enumeration values also.
3388 This information is encoded into the element_list attribute. */
3391 output_enumeration_type_die (arg
)
3394 register tree type
= arg
;
3396 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_enumeration_type
);
3397 sibling_attribute ();
3398 equate_type_number_to_die_number (type
);
3399 name_attribute (type_tag (type
));
3400 member_attribute (TYPE_CONTEXT (type
));
3402 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
3403 given enum type is incomplete, do not generate the AT_byte_size
3404 attribute or the AT_element_list attribute. */
3406 if (TYPE_SIZE (type
))
3408 byte_size_attribute (type
);
3409 element_list_attribute (TYPE_FIELDS (type
));
3413 /* Output a DIE to represent either a real live formal parameter decl or
3414 to represent just the type of some formal parameter position in some
3417 Note that this routine is a bit unusual because its argument may be
3418 a ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
3419 represents an inlining of some PARM_DECL) or else some sort of a
3420 ..._TYPE node. If it's the former then this function is being called
3421 to output a DIE to represent a formal parameter object (or some inlining
3422 thereof). If it's the latter, then this function is only being called
3423 to output a TAG_formal_parameter DIE to stand as a placeholder for some
3424 formal argument type of some subprogram type. */
3427 output_formal_parameter_die (arg
)
3430 register tree node
= arg
;
3432 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_formal_parameter
);
3433 sibling_attribute ();
3435 switch (TREE_CODE_CLASS (TREE_CODE (node
)))
3437 case 'd': /* We were called with some kind of a ..._DECL node. */
3439 register tree origin
= decl_ultimate_origin (node
);
3442 abstract_origin_attribute (origin
);
3445 name_and_src_coords_attributes (node
);
3446 type_attribute (TREE_TYPE (node
),
3447 TREE_READONLY (node
), TREE_THIS_VOLATILE (node
));
3449 if (DECL_ABSTRACT (node
))
3450 equate_decl_number_to_die_number (node
);
3452 location_or_const_value_attribute (node
);
3456 case 't': /* We were called with some kind of a ..._TYPE node. */
3457 type_attribute (node
, 0, 0);
3461 abort (); /* Should never happen. */
3465 /* Output a DIE to represent a declared function (either file-scope
3466 or block-local) which has "external linkage" (according to ANSI-C). */
3469 output_global_subroutine_die (arg
)
3472 register tree decl
= arg
;
3473 register tree origin
= decl_ultimate_origin (decl
);
3475 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_global_subroutine
);
3476 sibling_attribute ();
3479 abstract_origin_attribute (origin
);
3482 register tree type
= TREE_TYPE (decl
);
3484 name_and_src_coords_attributes (decl
);
3485 inline_attribute (decl
);
3486 prototyped_attribute (type
);
3487 member_attribute (DECL_CONTEXT (decl
));
3488 type_attribute (TREE_TYPE (type
), 0, 0);
3489 pure_or_virtual_attribute (decl
);
3491 if (DECL_ABSTRACT (decl
))
3492 equate_decl_number_to_die_number (decl
);
3495 if (! DECL_EXTERNAL (decl
) && ! in_class
3496 && decl
== current_function_decl
)
3498 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3500 low_pc_attribute (function_start_label (decl
));
3501 sprintf (label
, FUNC_END_LABEL_FMT
, current_funcdef_number
);
3502 high_pc_attribute (label
);
3503 if (use_gnu_debug_info_extensions
)
3505 sprintf (label
, BODY_BEGIN_LABEL_FMT
, current_funcdef_number
);
3506 body_begin_attribute (label
);
3507 sprintf (label
, BODY_END_LABEL_FMT
, current_funcdef_number
);
3508 body_end_attribute (label
);
3514 /* Output a DIE to represent a declared data object (either file-scope
3515 or block-local) which has "external linkage" (according to ANSI-C). */
3518 output_global_variable_die (arg
)
3521 register tree decl
= arg
;
3522 register tree origin
= decl_ultimate_origin (decl
);
3524 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_global_variable
);
3525 sibling_attribute ();
3527 abstract_origin_attribute (origin
);
3530 name_and_src_coords_attributes (decl
);
3531 member_attribute (DECL_CONTEXT (decl
));
3532 type_attribute (TREE_TYPE (decl
),
3533 TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
));
3535 if (DECL_ABSTRACT (decl
))
3536 equate_decl_number_to_die_number (decl
);
3539 if (! DECL_EXTERNAL (decl
) && ! in_class
3540 && current_function_decl
== decl_function_context (decl
))
3541 location_or_const_value_attribute (decl
);
3546 output_label_die (arg
)
3549 register tree decl
= arg
;
3550 register tree origin
= decl_ultimate_origin (decl
);
3552 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_label
);
3553 sibling_attribute ();
3555 abstract_origin_attribute (origin
);
3557 name_and_src_coords_attributes (decl
);
3558 if (DECL_ABSTRACT (decl
))
3559 equate_decl_number_to_die_number (decl
);
3562 register rtx insn
= DECL_RTL (decl
);
3564 /* Deleted labels are programmer specified labels which have been
3565 eliminated because of various optimisations. We still emit them
3566 here so that it is possible to put breakpoints on them. */
3567 if (GET_CODE (insn
) == CODE_LABEL
3568 || ((GET_CODE (insn
) == NOTE
3569 && NOTE_LINE_NUMBER (insn
) == NOTE_INSN_DELETED_LABEL
)))
3571 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3573 /* When optimization is enabled (via -O) some parts of the compiler
3574 (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
3575 represent source-level labels which were explicitly declared by
3576 the user. This really shouldn't be happening though, so catch
3577 it if it ever does happen. */
3579 if (INSN_DELETED_P (insn
))
3580 abort (); /* Should never happen. */
3582 sprintf (label
, INSN_LABEL_FMT
, current_funcdef_number
,
3583 (unsigned) INSN_UID (insn
));
3584 low_pc_attribute (label
);
3590 output_lexical_block_die (arg
)
3593 register tree stmt
= arg
;
3595 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_lexical_block
);
3596 sibling_attribute ();
3598 if (! BLOCK_ABSTRACT (stmt
))
3600 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3601 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3603 sprintf (begin_label
, BLOCK_BEGIN_LABEL_FMT
, next_block_number
);
3604 low_pc_attribute (begin_label
);
3605 sprintf (end_label
, BLOCK_END_LABEL_FMT
, next_block_number
);
3606 high_pc_attribute (end_label
);
3611 output_inlined_subroutine_die (arg
)
3614 register tree stmt
= arg
;
3616 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_inlined_subroutine
);
3617 sibling_attribute ();
3619 abstract_origin_attribute (block_ultimate_origin (stmt
));
3620 if (! BLOCK_ABSTRACT (stmt
))
3622 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3623 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3625 sprintf (begin_label
, BLOCK_BEGIN_LABEL_FMT
, next_block_number
);
3626 low_pc_attribute (begin_label
);
3627 sprintf (end_label
, BLOCK_END_LABEL_FMT
, next_block_number
);
3628 high_pc_attribute (end_label
);
3632 /* Output a DIE to represent a declared data object (either file-scope
3633 or block-local) which has "internal linkage" (according to ANSI-C). */
3636 output_local_variable_die (arg
)
3639 register tree decl
= arg
;
3640 register tree origin
= decl_ultimate_origin (decl
);
3642 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_local_variable
);
3643 sibling_attribute ();
3645 abstract_origin_attribute (origin
);
3648 name_and_src_coords_attributes (decl
);
3649 member_attribute (DECL_CONTEXT (decl
));
3650 type_attribute (TREE_TYPE (decl
),
3651 TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
));
3653 if (DECL_ABSTRACT (decl
))
3654 equate_decl_number_to_die_number (decl
);
3656 location_or_const_value_attribute (decl
);
3660 output_member_die (arg
)
3663 register tree decl
= arg
;
3665 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_member
);
3666 sibling_attribute ();
3667 name_and_src_coords_attributes (decl
);
3668 member_attribute (DECL_CONTEXT (decl
));
3669 type_attribute (member_declared_type (decl
),
3670 TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
));
3671 if (DECL_BIT_FIELD_TYPE (decl
)) /* If this is a bit field... */
3673 byte_size_attribute (decl
);
3674 bit_size_attribute (decl
);
3675 bit_offset_attribute (decl
);
3677 data_member_location_attribute (decl
);
3681 /* Don't generate either pointer_type DIEs or reference_type DIEs. Use
3682 modified types instead.
3684 We keep this code here just in case these types of DIEs may be
3685 needed to represent certain things in other languages (e.g. Pascal)
3689 output_pointer_type_die (arg
)
3692 register tree type
= arg
;
3694 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_pointer_type
);
3695 sibling_attribute ();
3696 equate_type_number_to_die_number (type
);
3697 member_attribute (TYPE_CONTEXT (type
));
3698 type_attribute (TREE_TYPE (type
), 0, 0);
3702 output_reference_type_die (arg
)
3705 register tree type
= arg
;
3707 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_reference_type
);
3708 sibling_attribute ();
3709 equate_type_number_to_die_number (type
);
3710 member_attribute (TYPE_CONTEXT (type
));
3711 type_attribute (TREE_TYPE (type
), 0, 0);
3716 output_ptr_to_mbr_type_die (arg
)
3719 register tree type
= arg
;
3721 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_ptr_to_member_type
);
3722 sibling_attribute ();
3723 equate_type_number_to_die_number (type
);
3724 member_attribute (TYPE_CONTEXT (type
));
3725 containing_type_attribute (TYPE_OFFSET_BASETYPE (type
));
3726 type_attribute (TREE_TYPE (type
), 0, 0);
3730 output_compile_unit_die (arg
)
3733 register char *main_input_filename
= arg
;
3735 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_compile_unit
);
3736 sibling_attribute ();
3738 name_attribute (main_input_filename
);
3743 sprintf (producer
, "%s %s", language_string
, version_string
);
3744 producer_attribute (producer
);
3747 if (strcmp (language_string
, "GNU C++") == 0)
3748 language_attribute (LANG_C_PLUS_PLUS
);
3749 else if (strcmp (language_string
, "GNU Ada") == 0)
3750 language_attribute (LANG_ADA83
);
3751 else if (strcmp (language_string
, "GNU F77") == 0)
3752 language_attribute (LANG_FORTRAN77
);
3753 else if (strcmp (language_string
, "GNU Pascal") == 0)
3754 language_attribute (LANG_PASCAL83
);
3755 else if (flag_traditional
)
3756 language_attribute (LANG_C
);
3758 language_attribute (LANG_C89
);
3759 low_pc_attribute (TEXT_BEGIN_LABEL
);
3760 high_pc_attribute (TEXT_END_LABEL
);
3761 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
3762 stmt_list_attribute (LINE_BEGIN_LABEL
);
3763 last_filename
= xstrdup (main_input_filename
);
3766 char *wd
= getpwd ();
3768 comp_dir_attribute (wd
);
3771 if (debug_info_level
>= DINFO_LEVEL_NORMAL
&& use_gnu_debug_info_extensions
)
3773 sf_names_attribute (SFNAMES_BEGIN_LABEL
);
3774 src_info_attribute (SRCINFO_BEGIN_LABEL
);
3775 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
3776 mac_info_attribute (MACINFO_BEGIN_LABEL
);
3781 output_string_type_die (arg
)
3784 register tree type
= arg
;
3786 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_string_type
);
3787 sibling_attribute ();
3788 equate_type_number_to_die_number (type
);
3789 member_attribute (TYPE_CONTEXT (type
));
3790 /* this is a fixed length string */
3791 byte_size_attribute (type
);
3795 output_inheritance_die (arg
)
3798 register tree binfo
= arg
;
3800 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_inheritance
);
3801 sibling_attribute ();
3802 type_attribute (BINFO_TYPE (binfo
), 0, 0);
3803 data_member_location_attribute (binfo
);
3804 if (TREE_VIA_VIRTUAL (binfo
))
3806 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_virtual
);
3807 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
3809 if (TREE_VIA_PUBLIC (binfo
))
3811 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_public
);
3812 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
3814 else if (TREE_VIA_PROTECTED (binfo
))
3816 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_protected
);
3817 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
3822 output_structure_type_die (arg
)
3825 register tree type
= arg
;
3827 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_structure_type
);
3828 sibling_attribute ();
3829 equate_type_number_to_die_number (type
);
3830 name_attribute (type_tag (type
));
3831 member_attribute (TYPE_CONTEXT (type
));
3833 /* If this type has been completed, then give it a byte_size attribute
3834 and prepare to give a list of members. Otherwise, don't do either of
3835 these things. In the latter case, we will not be generating a list
3836 of members (since we don't have any idea what they might be for an
3837 incomplete type). */
3839 if (TYPE_SIZE (type
))
3842 byte_size_attribute (type
);
3846 /* Output a DIE to represent a declared function (either file-scope
3847 or block-local) which has "internal linkage" (according to ANSI-C). */
3850 output_local_subroutine_die (arg
)
3853 register tree decl
= arg
;
3854 register tree origin
= decl_ultimate_origin (decl
);
3856 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_subroutine
);
3857 sibling_attribute ();
3860 abstract_origin_attribute (origin
);
3863 register tree type
= TREE_TYPE (decl
);
3865 name_and_src_coords_attributes (decl
);
3866 inline_attribute (decl
);
3867 prototyped_attribute (type
);
3868 member_attribute (DECL_CONTEXT (decl
));
3869 type_attribute (TREE_TYPE (type
), 0, 0);
3870 pure_or_virtual_attribute (decl
);
3872 if (DECL_ABSTRACT (decl
))
3873 equate_decl_number_to_die_number (decl
);
3876 /* Avoid getting screwed up in cases where a function was declared
3877 static but where no definition was ever given for it. */
3879 if (TREE_ASM_WRITTEN (decl
))
3881 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3882 low_pc_attribute (function_start_label (decl
));
3883 sprintf (label
, FUNC_END_LABEL_FMT
, current_funcdef_number
);
3884 high_pc_attribute (label
);
3885 if (use_gnu_debug_info_extensions
)
3887 sprintf (label
, BODY_BEGIN_LABEL_FMT
, current_funcdef_number
);
3888 body_begin_attribute (label
);
3889 sprintf (label
, BODY_END_LABEL_FMT
, current_funcdef_number
);
3890 body_end_attribute (label
);
3897 output_subroutine_type_die (arg
)
3900 register tree type
= arg
;
3901 register tree return_type
= TREE_TYPE (type
);
3903 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_subroutine_type
);
3904 sibling_attribute ();
3906 equate_type_number_to_die_number (type
);
3907 prototyped_attribute (type
);
3908 member_attribute (TYPE_CONTEXT (type
));
3909 type_attribute (return_type
, 0, 0);
3913 output_typedef_die (arg
)
3916 register tree decl
= arg
;
3917 register tree origin
= decl_ultimate_origin (decl
);
3919 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_typedef
);
3920 sibling_attribute ();
3922 abstract_origin_attribute (origin
);
3925 name_and_src_coords_attributes (decl
);
3926 member_attribute (DECL_CONTEXT (decl
));
3927 type_attribute (TREE_TYPE (decl
),
3928 TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
));
3930 if (DECL_ABSTRACT (decl
))
3931 equate_decl_number_to_die_number (decl
);
3935 output_union_type_die (arg
)
3938 register tree type
= arg
;
3940 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_union_type
);
3941 sibling_attribute ();
3942 equate_type_number_to_die_number (type
);
3943 name_attribute (type_tag (type
));
3944 member_attribute (TYPE_CONTEXT (type
));
3946 /* If this type has been completed, then give it a byte_size attribute
3947 and prepare to give a list of members. Otherwise, don't do either of
3948 these things. In the latter case, we will not be generating a list
3949 of members (since we don't have any idea what they might be for an
3950 incomplete type). */
3952 if (TYPE_SIZE (type
))
3955 byte_size_attribute (type
);
3959 /* Generate a special type of DIE used as a stand-in for a trailing ellipsis
3960 at the end of an (ANSI prototyped) formal parameters list. */
3963 output_unspecified_parameters_die (arg
)
3966 register tree decl_or_type
= arg
;
3968 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_unspecified_parameters
);
3969 sibling_attribute ();
3971 /* This kludge is here only for the sake of being compatible with what
3972 the USL CI5 C compiler does. The specification of Dwarf Version 1
3973 doesn't say that TAG_unspecified_parameters DIEs should contain any
3974 attributes other than the AT_sibling attribute, but they are certainly
3975 allowed to contain additional attributes, and the CI5 compiler
3976 generates AT_name, AT_fund_type, and AT_location attributes within
3977 TAG_unspecified_parameters DIEs which appear in the child lists for
3978 DIEs representing function definitions, so we do likewise here. */
3980 if (TREE_CODE (decl_or_type
) == FUNCTION_DECL
&& DECL_INITIAL (decl_or_type
))
3982 name_attribute ("...");
3983 fund_type_attribute (FT_pointer
);
3984 /* location_attribute (?); */
3989 output_padded_null_die (arg
)
3990 register void *arg ATTRIBUTE_UNUSED
;
3992 ASM_OUTPUT_ALIGN (asm_out_file
, 2); /* 2**2 == 4 */
3995 /*************************** end of DIEs *********************************/
3997 /* Generate some type of DIE. This routine generates the generic outer
3998 wrapper stuff which goes around all types of DIE's (regardless of their
3999 TAGs. All forms of DIEs start with a DIE-specific label, followed by a
4000 DIE-length word, followed by the guts of the DIE itself. After the guts
4001 of the DIE, there must always be a terminator label for the DIE. */
4004 output_die (die_specific_output_function
, param
)
4005 register void (*die_specific_output_function
) PARAMS ((void *));
4006 register void *param
;
4008 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4009 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4011 current_dienum
= NEXT_DIE_NUM
;
4012 NEXT_DIE_NUM
= next_unused_dienum
;
4014 sprintf (begin_label
, DIE_BEGIN_LABEL_FMT
, current_dienum
);
4015 sprintf (end_label
, DIE_END_LABEL_FMT
, current_dienum
);
4017 /* Write a label which will act as the name for the start of this DIE. */
4019 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
4021 /* Write the DIE-length word. */
4023 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, end_label
, begin_label
);
4025 /* Fill in the guts of the DIE. */
4027 next_unused_dienum
++;
4028 die_specific_output_function (param
);
4030 /* Write a label which will act as the name for the end of this DIE. */
4032 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
4036 end_sibling_chain ()
4038 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4040 current_dienum
= NEXT_DIE_NUM
;
4041 NEXT_DIE_NUM
= next_unused_dienum
;
4043 sprintf (begin_label
, DIE_BEGIN_LABEL_FMT
, current_dienum
);
4045 /* Write a label which will act as the name for the start of this DIE. */
4047 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
4049 /* Write the DIE-length word. */
4051 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 4);
4056 /* Generate a list of nameless TAG_formal_parameter DIEs (and perhaps a
4057 TAG_unspecified_parameters DIE) to represent the types of the formal
4058 parameters as specified in some function type specification (except
4059 for those which appear as part of a function *definition*).
4061 Note that we must be careful here to output all of the parameter
4062 DIEs *before* we output any DIEs needed to represent the types of
4063 the formal parameters. This keeps svr4 SDB happy because it
4064 (incorrectly) thinks that the first non-parameter DIE it sees ends
4065 the formal parameter list. */
4068 output_formal_types (function_or_method_type
)
4069 register tree function_or_method_type
;
4072 register tree formal_type
= NULL
;
4073 register tree first_parm_type
= TYPE_ARG_TYPES (function_or_method_type
);
4075 /* Set TREE_ASM_WRITTEN while processing the parameters, lest we
4076 get bogus recursion when outputting tagged types local to a
4077 function declaration. */
4078 int save_asm_written
= TREE_ASM_WRITTEN (function_or_method_type
);
4079 TREE_ASM_WRITTEN (function_or_method_type
) = 1;
4081 /* In the case where we are generating a formal types list for a C++
4082 non-static member function type, skip over the first thing on the
4083 TYPE_ARG_TYPES list because it only represents the type of the
4084 hidden `this pointer'. The debugger should be able to figure
4085 out (without being explicitly told) that this non-static member
4086 function type takes a `this pointer' and should be able to figure
4087 what the type of that hidden parameter is from the AT_member
4088 attribute of the parent TAG_subroutine_type DIE. */
4090 if (TREE_CODE (function_or_method_type
) == METHOD_TYPE
)
4091 first_parm_type
= TREE_CHAIN (first_parm_type
);
4093 /* Make our first pass over the list of formal parameter types and output
4094 a TAG_formal_parameter DIE for each one. */
4096 for (link
= first_parm_type
; link
; link
= TREE_CHAIN (link
))
4098 formal_type
= TREE_VALUE (link
);
4099 if (formal_type
== void_type_node
)
4102 /* Output a (nameless) DIE to represent the formal parameter itself. */
4104 output_die (output_formal_parameter_die
, formal_type
);
4107 /* If this function type has an ellipsis, add a TAG_unspecified_parameters
4108 DIE to the end of the parameter list. */
4110 if (formal_type
!= void_type_node
)
4111 output_die (output_unspecified_parameters_die
, function_or_method_type
);
4113 /* Make our second (and final) pass over the list of formal parameter types
4114 and output DIEs to represent those types (as necessary). */
4116 for (link
= TYPE_ARG_TYPES (function_or_method_type
);
4118 link
= TREE_CHAIN (link
))
4120 formal_type
= TREE_VALUE (link
);
4121 if (formal_type
== void_type_node
)
4124 output_type (formal_type
, function_or_method_type
);
4127 TREE_ASM_WRITTEN (function_or_method_type
) = save_asm_written
;
4130 /* Remember a type in the pending_types_list. */
4136 if (pending_types
== pending_types_allocated
)
4138 pending_types_allocated
+= PENDING_TYPES_INCREMENT
;
4140 = (tree
*) xrealloc (pending_types_list
,
4141 sizeof (tree
) * pending_types_allocated
);
4143 pending_types_list
[pending_types
++] = type
;
4145 /* Mark the pending type as having been output already (even though
4146 it hasn't been). This prevents the type from being added to the
4147 pending_types_list more than once. */
4149 TREE_ASM_WRITTEN (type
) = 1;
4152 /* Return non-zero if it is legitimate to output DIEs to represent a
4153 given type while we are generating the list of child DIEs for some
4154 DIE (e.g. a function or lexical block DIE) associated with a given scope.
4156 See the comments within the function for a description of when it is
4157 considered legitimate to output DIEs for various kinds of types.
4159 Note that TYPE_CONTEXT(type) may be NULL (to indicate global scope)
4160 or it may point to a BLOCK node (for types local to a block), or to a
4161 FUNCTION_DECL node (for types local to the heading of some function
4162 definition), or to a FUNCTION_TYPE node (for types local to the
4163 prototyped parameter list of a function type specification), or to a
4164 RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node
4165 (in the case of C++ nested types).
4167 The `scope' parameter should likewise be NULL or should point to a
4168 BLOCK node, a FUNCTION_DECL node, a FUNCTION_TYPE node, a RECORD_TYPE
4169 node, a UNION_TYPE node, or a QUAL_UNION_TYPE node.
4171 This function is used only for deciding when to "pend" and when to
4172 "un-pend" types to/from the pending_types_list.
4174 Note that we sometimes make use of this "type pending" feature in a
4175 rather twisted way to temporarily delay the production of DIEs for the
4176 types of formal parameters. (We do this just to make svr4 SDB happy.)
4177 It order to delay the production of DIEs representing types of formal
4178 parameters, callers of this function supply `fake_containing_scope' as
4179 the `scope' parameter to this function. Given that fake_containing_scope
4180 is a tagged type which is *not* the containing scope for *any* other type,
4181 the desired effect is achieved, i.e. output of DIEs representing types
4182 is temporarily suspended, and any type DIEs which would have otherwise
4183 been output are instead placed onto the pending_types_list. Later on,
4184 we force these (temporarily pended) types to be output simply by calling
4185 `output_pending_types_for_scope' with an actual argument equal to the
4186 true scope of the types we temporarily pended. */
4189 type_ok_for_scope (type
, scope
)
4191 register tree scope
;
4193 /* Tagged types (i.e. struct, union, and enum types) must always be
4194 output only in the scopes where they actually belong (or else the
4195 scoping of their own tag names and the scoping of their member
4196 names will be incorrect). Non-tagged-types on the other hand can
4197 generally be output anywhere, except that svr4 SDB really doesn't
4198 want to see them nested within struct or union types, so here we
4199 say it is always OK to immediately output any such a (non-tagged)
4200 type, so long as we are not within such a context. Note that the
4201 only kinds of non-tagged types which we will be dealing with here
4202 (for C and C++ anyway) will be array types and function types. */
4204 return is_tagged_type (type
)
4205 ? (TYPE_CONTEXT (type
) == scope
4206 /* Ignore namespaces for the moment. */
4207 || (scope
== NULL_TREE
4208 && TREE_CODE (TYPE_CONTEXT (type
)) == NAMESPACE_DECL
)
4209 || (scope
== NULL_TREE
&& is_tagged_type (TYPE_CONTEXT (type
))
4210 && TREE_ASM_WRITTEN (TYPE_CONTEXT (type
))))
4211 : (scope
== NULL_TREE
|| ! is_tagged_type (scope
));
4214 /* Output any pending types (from the pending_types list) which we can output
4215 now (taking into account the scope that we are working on now).
4217 For each type output, remove the given type from the pending_types_list
4218 *before* we try to output it.
4220 Note that we have to process the list in beginning-to-end order,
4221 because the call made here to output_type may cause yet more types
4222 to be added to the end of the list, and we may have to output some
4226 output_pending_types_for_scope (containing_scope
)
4227 register tree containing_scope
;
4229 register unsigned i
;
4231 for (i
= 0; i
< pending_types
; )
4233 register tree type
= pending_types_list
[i
];
4235 if (type_ok_for_scope (type
, containing_scope
))
4237 register tree
*mover
;
4238 register tree
*limit
;
4241 limit
= &pending_types_list
[pending_types
];
4242 for (mover
= &pending_types_list
[i
]; mover
< limit
; mover
++)
4243 *mover
= *(mover
+1);
4245 /* Un-mark the type as having been output already (because it
4246 hasn't been, really). Then call output_type to generate a
4247 Dwarf representation of it. */
4249 TREE_ASM_WRITTEN (type
) = 0;
4250 output_type (type
, containing_scope
);
4252 /* Don't increment the loop counter in this case because we
4253 have shifted all of the subsequent pending types down one
4254 element in the pending_types_list array. */
4261 /* Remember a type in the incomplete_types_list. */
4264 add_incomplete_type (type
)
4267 if (incomplete_types
== incomplete_types_allocated
)
4269 incomplete_types_allocated
+= INCOMPLETE_TYPES_INCREMENT
;
4270 incomplete_types_list
4271 = (tree
*) xrealloc (incomplete_types_list
,
4272 sizeof (tree
) * incomplete_types_allocated
);
4275 incomplete_types_list
[incomplete_types
++] = type
;
4278 /* Walk through the list of incomplete types again, trying once more to
4279 emit full debugging info for them. */
4282 retry_incomplete_types ()
4287 while (incomplete_types
)
4290 type
= incomplete_types_list
[incomplete_types
];
4291 output_type (type
, NULL_TREE
);
4296 output_type (type
, containing_scope
)
4298 register tree containing_scope
;
4300 if (type
== 0 || type
== error_mark_node
)
4303 /* We are going to output a DIE to represent the unqualified version of
4304 this type (i.e. without any const or volatile qualifiers) so get
4305 the main variant (i.e. the unqualified version) of this type now. */
4307 type
= type_main_variant (type
);
4309 if (TREE_ASM_WRITTEN (type
))
4311 if (finalizing
&& AGGREGATE_TYPE_P (type
))
4313 register tree member
;
4315 /* Some of our nested types might not have been defined when we
4316 were written out before; force them out now. */
4318 for (member
= TYPE_FIELDS (type
); member
;
4319 member
= TREE_CHAIN (member
))
4320 if (TREE_CODE (member
) == TYPE_DECL
4321 && ! TREE_ASM_WRITTEN (TREE_TYPE (member
)))
4322 output_type (TREE_TYPE (member
), containing_scope
);
4327 /* If this is a nested type whose containing class hasn't been
4328 written out yet, writing it out will cover this one, too. */
4330 if (TYPE_CONTEXT (type
)
4331 && TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type
))) == 't'
4332 && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type
)))
4334 output_type (TYPE_CONTEXT (type
), containing_scope
);
4338 /* Don't generate any DIEs for this type now unless it is OK to do so
4339 (based upon what `type_ok_for_scope' tells us). */
4341 if (! type_ok_for_scope (type
, containing_scope
))
4347 switch (TREE_CODE (type
))
4353 case REFERENCE_TYPE
:
4354 /* Prevent infinite recursion in cases where this is a recursive
4355 type. Recursive types are possible in Ada. */
4356 TREE_ASM_WRITTEN (type
) = 1;
4357 /* For these types, all that is required is that we output a DIE
4358 (or a set of DIEs) to represent the "basis" type. */
4359 output_type (TREE_TYPE (type
), containing_scope
);
4363 /* This code is used for C++ pointer-to-data-member types. */
4364 /* Output a description of the relevant class type. */
4365 output_type (TYPE_OFFSET_BASETYPE (type
), containing_scope
);
4366 /* Output a description of the type of the object pointed to. */
4367 output_type (TREE_TYPE (type
), containing_scope
);
4368 /* Now output a DIE to represent this pointer-to-data-member type
4370 output_die (output_ptr_to_mbr_type_die
, type
);
4374 output_type (TYPE_DOMAIN (type
), containing_scope
);
4375 output_die (output_set_type_die
, type
);
4379 output_type (TREE_TYPE (type
), containing_scope
);
4380 abort (); /* No way to represent these in Dwarf yet! */
4384 /* Force out return type (in case it wasn't forced out already). */
4385 output_type (TREE_TYPE (type
), containing_scope
);
4386 output_die (output_subroutine_type_die
, type
);
4387 output_formal_types (type
);
4388 end_sibling_chain ();
4392 /* Force out return type (in case it wasn't forced out already). */
4393 output_type (TREE_TYPE (type
), containing_scope
);
4394 output_die (output_subroutine_type_die
, type
);
4395 output_formal_types (type
);
4396 end_sibling_chain ();
4400 if (TYPE_STRING_FLAG (type
) && TREE_CODE(TREE_TYPE(type
)) == CHAR_TYPE
)
4402 output_type (TREE_TYPE (type
), containing_scope
);
4403 output_die (output_string_type_die
, type
);
4407 register tree element_type
;
4409 element_type
= TREE_TYPE (type
);
4410 while (TREE_CODE (element_type
) == ARRAY_TYPE
)
4411 element_type
= TREE_TYPE (element_type
);
4413 output_type (element_type
, containing_scope
);
4414 output_die (output_array_type_die
, type
);
4421 case QUAL_UNION_TYPE
:
4423 /* For a non-file-scope tagged type, we can always go ahead and
4424 output a Dwarf description of this type right now, even if
4425 the type in question is still incomplete, because if this
4426 local type *was* ever completed anywhere within its scope,
4427 that complete definition would already have been attached to
4428 this RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE or ENUMERAL_TYPE
4429 node by the time we reach this point. That's true because of the
4430 way the front-end does its processing of file-scope declarations (of
4431 functions and class types) within which other types might be
4432 nested. The C and C++ front-ends always gobble up such "local
4433 scope" things en-mass before they try to output *any* debugging
4434 information for any of the stuff contained inside them and thus,
4435 we get the benefit here of what is (in effect) a pre-resolution
4436 of forward references to tagged types in local scopes.
4438 Note however that for file-scope tagged types we cannot assume
4439 that such pre-resolution of forward references has taken place.
4440 A given file-scope tagged type may appear to be incomplete when
4441 we reach this point, but it may yet be given a full definition
4442 (at file-scope) later on during compilation. In order to avoid
4443 generating a premature (and possibly incorrect) set of Dwarf
4444 DIEs for such (as yet incomplete) file-scope tagged types, we
4445 generate nothing at all for as-yet incomplete file-scope tagged
4446 types here unless we are making our special "finalization" pass
4447 for file-scope things at the very end of compilation. At that
4448 time, we will certainly know as much about each file-scope tagged
4449 type as we are ever going to know, so at that point in time, we
4450 can safely generate correct Dwarf descriptions for these file-
4451 scope tagged types. */
4453 if (TYPE_SIZE (type
) == 0
4454 && (TYPE_CONTEXT (type
) == NULL
4455 || AGGREGATE_TYPE_P (TYPE_CONTEXT (type
))
4456 || TREE_CODE (TYPE_CONTEXT (type
)) == NAMESPACE_DECL
)
4459 /* We don't need to do this for function-local types. */
4460 if (! decl_function_context (TYPE_STUB_DECL (type
)))
4461 add_incomplete_type (type
);
4462 return; /* EARLY EXIT! Avoid setting TREE_ASM_WRITTEN. */
4465 /* Prevent infinite recursion in cases where the type of some
4466 member of this type is expressed in terms of this type itself. */
4468 TREE_ASM_WRITTEN (type
) = 1;
4470 /* Output a DIE to represent the tagged type itself. */
4472 switch (TREE_CODE (type
))
4475 output_die (output_enumeration_type_die
, type
);
4476 return; /* a special case -- nothing left to do so just return */
4479 output_die (output_structure_type_die
, type
);
4483 case QUAL_UNION_TYPE
:
4484 output_die (output_union_type_die
, type
);
4488 abort (); /* Should never happen. */
4491 /* If this is not an incomplete type, output descriptions of
4492 each of its members.
4494 Note that as we output the DIEs necessary to represent the
4495 members of this record or union type, we will also be trying
4496 to output DIEs to represent the *types* of those members.
4497 However the `output_type' function (above) will specifically
4498 avoid generating type DIEs for member types *within* the list
4499 of member DIEs for this (containing) type execpt for those
4500 types (of members) which are explicitly marked as also being
4501 members of this (containing) type themselves. The g++ front-
4502 end can force any given type to be treated as a member of some
4503 other (containing) type by setting the TYPE_CONTEXT of the
4504 given (member) type to point to the TREE node representing the
4505 appropriate (containing) type.
4508 if (TYPE_SIZE (type
))
4510 /* First output info about the base classes. */
4511 if (TYPE_BINFO (type
) && TYPE_BINFO_BASETYPES (type
))
4513 register tree bases
= TYPE_BINFO_BASETYPES (type
);
4514 register int n_bases
= TREE_VEC_LENGTH (bases
);
4517 for (i
= 0; i
< n_bases
; i
++)
4519 tree binfo
= TREE_VEC_ELT (bases
, i
);
4520 output_type (BINFO_TYPE (binfo
), containing_scope
);
4521 output_die (output_inheritance_die
, binfo
);
4528 register tree normal_member
;
4530 /* Now output info about the data members and type members. */
4532 for (normal_member
= TYPE_FIELDS (type
);
4534 normal_member
= TREE_CHAIN (normal_member
))
4535 output_decl (normal_member
, type
);
4539 register tree func_member
;
4541 /* Now output info about the function members (if any). */
4543 for (func_member
= TYPE_METHODS (type
);
4545 func_member
= TREE_CHAIN (func_member
))
4546 output_decl (func_member
, type
);
4551 /* RECORD_TYPEs, UNION_TYPEs, and QUAL_UNION_TYPEs are themselves
4552 scopes (at least in C++) so we must now output any nested
4553 pending types which are local just to this type. */
4555 output_pending_types_for_scope (type
);
4557 end_sibling_chain (); /* Terminate member chain. */
4568 break; /* No DIEs needed for fundamental types. */
4570 case LANG_TYPE
: /* No Dwarf representation currently defined. */
4577 TREE_ASM_WRITTEN (type
) = 1;
4581 output_tagged_type_instantiation (type
)
4584 if (type
== 0 || type
== error_mark_node
)
4587 /* We are going to output a DIE to represent the unqualified version of
4588 this type (i.e. without any const or volatile qualifiers) so make
4589 sure that we have the main variant (i.e. the unqualified version) of
4592 if (type
!= type_main_variant (type
))
4595 if (!TREE_ASM_WRITTEN (type
))
4598 switch (TREE_CODE (type
))
4604 output_die (output_inlined_enumeration_type_die
, type
);
4608 output_die (output_inlined_structure_type_die
, type
);
4612 case QUAL_UNION_TYPE
:
4613 output_die (output_inlined_union_type_die
, type
);
4617 abort (); /* Should never happen. */
4621 /* Output a TAG_lexical_block DIE followed by DIEs to represent all of
4622 the things which are local to the given block. */
4625 output_block (stmt
, depth
)
4629 register int must_output_die
= 0;
4630 register tree origin
;
4631 register enum tree_code origin_code
;
4633 /* Ignore blocks never really used to make RTL. */
4635 if (! stmt
|| ! TREE_USED (stmt
))
4638 /* Determine the "ultimate origin" of this block. This block may be an
4639 inlined instance of an inlined instance of inline function, so we
4640 have to trace all of the way back through the origin chain to find
4641 out what sort of node actually served as the original seed for the
4642 creation of the current block. */
4644 origin
= block_ultimate_origin (stmt
);
4645 origin_code
= (origin
!= NULL
) ? TREE_CODE (origin
) : ERROR_MARK
;
4647 /* Determine if we need to output any Dwarf DIEs at all to represent this
4650 if (origin_code
== FUNCTION_DECL
)
4651 /* The outer scopes for inlinings *must* always be represented. We
4652 generate TAG_inlined_subroutine DIEs for them. (See below.) */
4653 must_output_die
= 1;
4656 /* In the case where the current block represents an inlining of the
4657 "body block" of an inline function, we must *NOT* output any DIE
4658 for this block because we have already output a DIE to represent
4659 the whole inlined function scope and the "body block" of any
4660 function doesn't really represent a different scope according to
4661 ANSI C rules. So we check here to make sure that this block does
4662 not represent a "body block inlining" before trying to set the
4663 `must_output_die' flag. */
4665 if (! is_body_block (origin
? origin
: stmt
))
4667 /* Determine if this block directly contains any "significant"
4668 local declarations which we will need to output DIEs for. */
4670 if (debug_info_level
> DINFO_LEVEL_TERSE
)
4671 /* We are not in terse mode so *any* local declaration counts
4672 as being a "significant" one. */
4673 must_output_die
= (BLOCK_VARS (stmt
) != NULL
);
4678 /* We are in terse mode, so only local (nested) function
4679 definitions count as "significant" local declarations. */
4681 for (decl
= BLOCK_VARS (stmt
); decl
; decl
= TREE_CHAIN (decl
))
4682 if (TREE_CODE (decl
) == FUNCTION_DECL
&& DECL_INITIAL (decl
))
4684 must_output_die
= 1;
4691 /* It would be a waste of space to generate a Dwarf TAG_lexical_block
4692 DIE for any block which contains no significant local declarations
4693 at all. Rather, in such cases we just call `output_decls_for_scope'
4694 so that any needed Dwarf info for any sub-blocks will get properly
4695 generated. Note that in terse mode, our definition of what constitutes
4696 a "significant" local declaration gets restricted to include only
4697 inlined function instances and local (nested) function definitions. */
4699 if (origin_code
== FUNCTION_DECL
&& BLOCK_ABSTRACT (stmt
))
4700 /* We don't care about an abstract inlined subroutine. */;
4701 else if (must_output_die
)
4703 output_die ((origin_code
== FUNCTION_DECL
)
4704 ? output_inlined_subroutine_die
4705 : output_lexical_block_die
,
4707 output_decls_for_scope (stmt
, depth
);
4708 end_sibling_chain ();
4711 output_decls_for_scope (stmt
, depth
);
4714 /* Output all of the decls declared within a given scope (also called
4715 a `binding contour') and (recursively) all of it's sub-blocks. */
4718 output_decls_for_scope (stmt
, depth
)
4722 /* Ignore blocks never really used to make RTL. */
4724 if (! stmt
|| ! TREE_USED (stmt
))
4727 if (! BLOCK_ABSTRACT (stmt
) && depth
> 0)
4728 next_block_number
++;
4730 /* Output the DIEs to represent all of the data objects, functions,
4731 typedefs, and tagged types declared directly within this block
4732 but not within any nested sub-blocks. */
4737 for (decl
= BLOCK_VARS (stmt
); decl
; decl
= TREE_CHAIN (decl
))
4738 output_decl (decl
, stmt
);
4741 output_pending_types_for_scope (stmt
);
4743 /* Output the DIEs to represent all sub-blocks (and the items declared
4744 therein) of this block. */
4747 register tree subblocks
;
4749 for (subblocks
= BLOCK_SUBBLOCKS (stmt
);
4751 subblocks
= BLOCK_CHAIN (subblocks
))
4752 output_block (subblocks
, depth
+ 1);
4756 /* Is this a typedef we can avoid emitting? */
4759 is_redundant_typedef (decl
)
4762 if (TYPE_DECL_IS_STUB (decl
))
4764 if (DECL_ARTIFICIAL (decl
)
4765 && DECL_CONTEXT (decl
)
4766 && is_tagged_type (DECL_CONTEXT (decl
))
4767 && TREE_CODE (TYPE_NAME (DECL_CONTEXT (decl
))) == TYPE_DECL
4768 && DECL_NAME (decl
) == DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl
))))
4769 /* Also ignore the artificial member typedef for the class name. */
4774 /* Output Dwarf .debug information for a decl described by DECL. */
4777 output_decl (decl
, containing_scope
)
4779 register tree containing_scope
;
4781 /* Make a note of the decl node we are going to be working on. We may
4782 need to give the user the source coordinates of where it appeared in
4783 case we notice (later on) that something about it looks screwy. */
4785 dwarf_last_decl
= decl
;
4787 if (TREE_CODE (decl
) == ERROR_MARK
)
4790 /* If a structure is declared within an initialization, e.g. as the
4791 operand of a sizeof, then it will not have a name. We don't want
4792 to output a DIE for it, as the tree nodes are in the temporary obstack */
4794 if ((TREE_CODE (TREE_TYPE (decl
)) == RECORD_TYPE
4795 || TREE_CODE (TREE_TYPE (decl
)) == UNION_TYPE
)
4796 && ((DECL_NAME (decl
) == 0 && TYPE_NAME (TREE_TYPE (decl
)) == 0)
4797 || (TYPE_FIELDS (TREE_TYPE (decl
))
4798 && (TREE_CODE (TYPE_FIELDS (TREE_TYPE (decl
))) == ERROR_MARK
))))
4801 /* If this ..._DECL node is marked to be ignored, then ignore it.
4802 But don't ignore a function definition, since that would screw
4803 up our count of blocks, and that it turn will completely screw up the
4804 labels we will reference in subsequent AT_low_pc and AT_high_pc
4805 attributes (for subsequent blocks). */
4807 if (DECL_IGNORED_P (decl
) && TREE_CODE (decl
) != FUNCTION_DECL
)
4810 switch (TREE_CODE (decl
))
4813 /* The individual enumerators of an enum type get output when we
4814 output the Dwarf representation of the relevant enum type itself. */
4818 /* If we are in terse mode, don't output any DIEs to represent
4819 mere function declarations. Also, if we are conforming
4820 to the DWARF version 1 specification, don't output DIEs for
4821 mere function declarations. */
4823 if (DECL_INITIAL (decl
) == NULL_TREE
)
4824 #if (DWARF_VERSION > 1)
4825 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
4829 /* Before we describe the FUNCTION_DECL itself, make sure that we
4830 have described its return type. */
4832 output_type (TREE_TYPE (TREE_TYPE (decl
)), containing_scope
);
4835 /* And its containing type. */
4836 register tree origin
= decl_class_context (decl
);
4838 output_type (origin
, containing_scope
);
4841 /* If the following DIE will represent a function definition for a
4842 function with "extern" linkage, output a special "pubnames" DIE
4843 label just ahead of the actual DIE. A reference to this label
4844 was already generated in the .debug_pubnames section sub-entry
4845 for this function definition. */
4847 if (TREE_PUBLIC (decl
))
4849 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4851 sprintf (label
, PUB_DIE_LABEL_FMT
, next_pubname_number
++);
4852 ASM_OUTPUT_LABEL (asm_out_file
, label
);
4855 /* Now output a DIE to represent the function itself. */
4857 output_die (TREE_PUBLIC (decl
) || DECL_EXTERNAL (decl
)
4858 ? output_global_subroutine_die
4859 : output_local_subroutine_die
,
4862 /* Now output descriptions of the arguments for this function.
4863 This gets (unnecessarily?) complex because of the fact that
4864 the DECL_ARGUMENT list for a FUNCTION_DECL doesn't indicate
4865 cases where there was a trailing `...' at the end of the formal
4866 parameter list. In order to find out if there was a trailing
4867 ellipsis or not, we must instead look at the type associated
4868 with the FUNCTION_DECL. This will be a node of type FUNCTION_TYPE.
4869 If the chain of type nodes hanging off of this FUNCTION_TYPE node
4870 ends with a void_type_node then there should *not* be an ellipsis
4873 /* In the case where we are describing a mere function declaration, all
4874 we need to do here (and all we *can* do here) is to describe
4875 the *types* of its formal parameters. */
4877 if (decl
!= current_function_decl
|| in_class
)
4878 output_formal_types (TREE_TYPE (decl
));
4881 /* Generate DIEs to represent all known formal parameters */
4883 register tree arg_decls
= DECL_ARGUMENTS (decl
);
4886 /* WARNING! Kludge zone ahead! Here we have a special
4887 hack for svr4 SDB compatibility. Instead of passing the
4888 current FUNCTION_DECL node as the second parameter (i.e.
4889 the `containing_scope' parameter) to `output_decl' (as
4890 we ought to) we instead pass a pointer to our own private
4891 fake_containing_scope node. That node is a RECORD_TYPE
4892 node which NO OTHER TYPE may ever actually be a member of.
4894 This pointer will ultimately get passed into `output_type'
4895 as its `containing_scope' parameter. `Output_type' will
4896 then perform its part in the hack... i.e. it will pend
4897 the type of the formal parameter onto the pending_types
4898 list. Later on, when we are done generating the whole
4899 sequence of formal parameter DIEs for this function
4900 definition, we will un-pend all previously pended types
4901 of formal parameters for this function definition.
4903 This whole kludge prevents any type DIEs from being
4904 mixed in with the formal parameter DIEs. That's good
4905 because svr4 SDB believes that the list of formal
4906 parameter DIEs for a function ends wherever the first
4907 non-formal-parameter DIE appears. Thus, we have to
4908 keep the formal parameter DIEs segregated. They must
4909 all appear (consecutively) at the start of the list of
4910 children for the DIE representing the function definition.
4911 Then (and only then) may we output any additional DIEs
4912 needed to represent the types of these formal parameters.
4916 When generating DIEs, generate the unspecified_parameters
4917 DIE instead if we come across the arg "__builtin_va_alist"
4920 for (parm
= arg_decls
; parm
; parm
= TREE_CHAIN (parm
))
4921 if (TREE_CODE (parm
) == PARM_DECL
)
4923 if (DECL_NAME(parm
) &&
4924 !strcmp(IDENTIFIER_POINTER(DECL_NAME(parm
)),
4925 "__builtin_va_alist") )
4926 output_die (output_unspecified_parameters_die
, decl
);
4928 output_decl (parm
, fake_containing_scope
);
4932 Now that we have finished generating all of the DIEs to
4933 represent the formal parameters themselves, force out
4934 any DIEs needed to represent their types. We do this
4935 simply by un-pending all previously pended types which
4936 can legitimately go into the chain of children DIEs for
4937 the current FUNCTION_DECL.
4940 output_pending_types_for_scope (decl
);
4943 Decide whether we need a unspecified_parameters DIE at the end.
4944 There are 2 more cases to do this for:
4945 1) the ansi ... declaration - this is detectable when the end
4946 of the arg list is not a void_type_node
4947 2) an unprototyped function declaration (not a definition). This
4948 just means that we have no info about the parameters at all.
4952 register tree fn_arg_types
= TYPE_ARG_TYPES (TREE_TYPE (decl
));
4956 /* this is the prototyped case, check for ... */
4957 if (TREE_VALUE (tree_last (fn_arg_types
)) != void_type_node
)
4958 output_die (output_unspecified_parameters_die
, decl
);
4962 /* this is unprototyped, check for undefined (just declaration) */
4963 if (!DECL_INITIAL (decl
))
4964 output_die (output_unspecified_parameters_die
, decl
);
4968 /* Output Dwarf info for all of the stuff within the body of the
4969 function (if it has one - it may be just a declaration). */
4972 register tree outer_scope
= DECL_INITIAL (decl
);
4974 if (outer_scope
&& TREE_CODE (outer_scope
) != ERROR_MARK
)
4976 /* Note that here, `outer_scope' is a pointer to the outermost
4977 BLOCK node created to represent a function.
4978 This outermost BLOCK actually represents the outermost
4979 binding contour for the function, i.e. the contour in which
4980 the function's formal parameters and labels get declared.
4982 Curiously, it appears that the front end doesn't actually
4983 put the PARM_DECL nodes for the current function onto the
4984 BLOCK_VARS list for this outer scope. (They are strung
4985 off of the DECL_ARGUMENTS list for the function instead.)
4986 The BLOCK_VARS list for the `outer_scope' does provide us
4987 with a list of the LABEL_DECL nodes for the function however,
4988 and we output DWARF info for those here.
4990 Just within the `outer_scope' there will be a BLOCK node
4991 representing the function's outermost pair of curly braces,
4992 and any blocks used for the base and member initializers of
4993 a C++ constructor function. */
4995 output_decls_for_scope (outer_scope
, 0);
4997 /* Finally, force out any pending types which are local to the
4998 outermost block of this function definition. These will
4999 all have a TYPE_CONTEXT which points to the FUNCTION_DECL
5002 output_pending_types_for_scope (decl
);
5007 /* Generate a terminator for the list of stuff `owned' by this
5010 end_sibling_chain ();
5015 /* If we are in terse mode, don't generate any DIEs to represent
5016 any actual typedefs. Note that even when we are in terse mode,
5017 we must still output DIEs to represent those tagged types which
5018 are used (directly or indirectly) in the specification of either
5019 a return type or a formal parameter type of some function. */
5021 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
5022 if (! TYPE_DECL_IS_STUB (decl
)
5023 || (! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl
)) && ! in_class
))
5026 /* In the special case of a TYPE_DECL node representing
5027 the declaration of some type tag, if the given TYPE_DECL is
5028 marked as having been instantiated from some other (original)
5029 TYPE_DECL node (e.g. one which was generated within the original
5030 definition of an inline function) we have to generate a special
5031 (abbreviated) TAG_structure_type, TAG_union_type, or
5032 TAG_enumeration-type DIE here. */
5034 if (TYPE_DECL_IS_STUB (decl
) && DECL_ABSTRACT_ORIGIN (decl
))
5036 output_tagged_type_instantiation (TREE_TYPE (decl
));
5040 output_type (TREE_TYPE (decl
), containing_scope
);
5042 if (! is_redundant_typedef (decl
))
5043 /* Output a DIE to represent the typedef itself. */
5044 output_die (output_typedef_die
, decl
);
5048 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
5049 output_die (output_label_die
, decl
);
5053 /* If we are conforming to the DWARF version 1 specification, don't
5054 generated any DIEs to represent mere external object declarations. */
5056 #if (DWARF_VERSION <= 1)
5057 if (DECL_EXTERNAL (decl
) && ! TREE_PUBLIC (decl
))
5061 /* If we are in terse mode, don't generate any DIEs to represent
5062 any variable declarations or definitions. */
5064 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
5067 /* Output any DIEs that are needed to specify the type of this data
5070 output_type (TREE_TYPE (decl
), containing_scope
);
5073 /* And its containing type. */
5074 register tree origin
= decl_class_context (decl
);
5076 output_type (origin
, containing_scope
);
5079 /* If the following DIE will represent a data object definition for a
5080 data object with "extern" linkage, output a special "pubnames" DIE
5081 label just ahead of the actual DIE. A reference to this label
5082 was already generated in the .debug_pubnames section sub-entry
5083 for this data object definition. */
5085 if (TREE_PUBLIC (decl
) && ! DECL_ABSTRACT (decl
))
5087 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5089 sprintf (label
, PUB_DIE_LABEL_FMT
, next_pubname_number
++);
5090 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5093 /* Now output the DIE to represent the data object itself. This gets
5094 complicated because of the possibility that the VAR_DECL really
5095 represents an inlined instance of a formal parameter for an inline
5099 register void (*func
) PARAMS ((void *));
5100 register tree origin
= decl_ultimate_origin (decl
);
5102 if (origin
!= NULL
&& TREE_CODE (origin
) == PARM_DECL
)
5103 func
= output_formal_parameter_die
;
5106 if (TREE_PUBLIC (decl
) || DECL_EXTERNAL (decl
))
5107 func
= output_global_variable_die
;
5109 func
= output_local_variable_die
;
5111 output_die (func
, decl
);
5116 /* Ignore the nameless fields that are used to skip bits. */
5117 if (DECL_NAME (decl
) != 0)
5119 output_type (member_declared_type (decl
), containing_scope
);
5120 output_die (output_member_die
, decl
);
5125 /* Force out the type of this formal, if it was not forced out yet.
5126 Note that here we can run afowl of a bug in "classic" svr4 SDB.
5127 It should be able to grok the presence of type DIEs within a list
5128 of TAG_formal_parameter DIEs, but it doesn't. */
5130 output_type (TREE_TYPE (decl
), containing_scope
);
5131 output_die (output_formal_parameter_die
, decl
);
5140 dwarfout_file_scope_decl (decl
, set_finalizing
)
5142 register int set_finalizing
;
5144 if (TREE_CODE (decl
) == ERROR_MARK
)
5147 /* If this ..._DECL node is marked to be ignored, then ignore it. We
5148 gotta hope that the node in question doesn't represent a function
5149 definition. If it does, then totally ignoring it is bound to screw
5150 up our count of blocks, and that it turn will completely screw up the
5151 labels we will reference in subsequent AT_low_pc and AT_high_pc
5152 attributes (for subsequent blocks). (It's too bad that BLOCK nodes
5153 don't carry their own sequence numbers with them!) */
5155 if (DECL_IGNORED_P (decl
))
5157 if (TREE_CODE (decl
) == FUNCTION_DECL
&& DECL_INITIAL (decl
) != NULL
)
5162 switch (TREE_CODE (decl
))
5166 /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of
5167 a builtin function. Explicit programmer-supplied declarations of
5168 these same functions should NOT be ignored however. */
5170 if (DECL_EXTERNAL (decl
) && DECL_FUNCTION_CODE (decl
))
5173 /* What we would really like to do here is to filter out all mere
5174 file-scope declarations of file-scope functions which are never
5175 referenced later within this translation unit (and keep all of
5176 ones that *are* referenced later on) but we aren't clairvoyant,
5177 so we have no idea which functions will be referenced in the
5178 future (i.e. later on within the current translation unit).
5179 So here we just ignore all file-scope function declarations
5180 which are not also definitions. If and when the debugger needs
5181 to know something about these functions, it wil have to hunt
5182 around and find the DWARF information associated with the
5183 *definition* of the function.
5185 Note that we can't just check `DECL_EXTERNAL' to find out which
5186 FUNCTION_DECL nodes represent definitions and which ones represent
5187 mere declarations. We have to check `DECL_INITIAL' instead. That's
5188 because the C front-end supports some weird semantics for "extern
5189 inline" function definitions. These can get inlined within the
5190 current translation unit (an thus, we need to generate DWARF info
5191 for their abstract instances so that the DWARF info for the
5192 concrete inlined instances can have something to refer to) but
5193 the compiler never generates any out-of-lines instances of such
5194 things (despite the fact that they *are* definitions). The
5195 important point is that the C front-end marks these "extern inline"
5196 functions as DECL_EXTERNAL, but we need to generate DWARF for them
5199 Note that the C++ front-end also plays some similar games for inline
5200 function definitions appearing within include files which also
5201 contain `#pragma interface' pragmas. */
5203 if (DECL_INITIAL (decl
) == NULL_TREE
)
5206 if (TREE_PUBLIC (decl
)
5207 && ! DECL_EXTERNAL (decl
)
5208 && ! DECL_ABSTRACT (decl
))
5210 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5212 /* Output a .debug_pubnames entry for a public function
5213 defined in this compilation unit. */
5215 fputc ('\n', asm_out_file
);
5216 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, PUBNAMES_SECTION
);
5217 sprintf (label
, PUB_DIE_LABEL_FMT
, next_pubname_number
);
5218 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, label
);
5219 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
,
5220 IDENTIFIER_POINTER (DECL_NAME (decl
)));
5221 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5228 /* Ignore this VAR_DECL if it refers to a file-scope extern data
5229 object declaration and if the declaration was never even
5230 referenced from within this entire compilation unit. We
5231 suppress these DIEs in order to save space in the .debug section
5232 (by eliminating entries which are probably useless). Note that
5233 we must not suppress block-local extern declarations (whether
5234 used or not) because that would screw-up the debugger's name
5235 lookup mechanism and cause it to miss things which really ought
5236 to be in scope at a given point. */
5238 if (DECL_EXTERNAL (decl
) && !TREE_USED (decl
))
5241 if (TREE_PUBLIC (decl
)
5242 && ! DECL_EXTERNAL (decl
)
5243 && GET_CODE (DECL_RTL (decl
)) == MEM
5244 && ! DECL_ABSTRACT (decl
))
5246 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5248 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
5250 /* Output a .debug_pubnames entry for a public variable
5251 defined in this compilation unit. */
5253 fputc ('\n', asm_out_file
);
5254 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, PUBNAMES_SECTION
);
5255 sprintf (label
, PUB_DIE_LABEL_FMT
, next_pubname_number
);
5256 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, label
);
5257 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
,
5258 IDENTIFIER_POINTER (DECL_NAME (decl
)));
5259 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5262 if (DECL_INITIAL (decl
) == NULL
)
5264 /* Output a .debug_aranges entry for a public variable
5265 which is tentatively defined in this compilation unit. */
5267 fputc ('\n', asm_out_file
);
5268 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, ARANGES_SECTION
);
5269 ASM_OUTPUT_DWARF_ADDR (asm_out_file
,
5270 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
5271 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
5272 (unsigned) int_size_in_bytes (TREE_TYPE (decl
)));
5273 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5277 /* If we are in terse mode, don't generate any DIEs to represent
5278 any variable declarations or definitions. */
5280 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
5286 /* Don't bother trying to generate any DIEs to represent any of the
5287 normal built-in types for the language we are compiling, except
5288 in cases where the types in question are *not* DWARF fundamental
5289 types. We make an exception in the case of non-fundamental types
5290 for the sake of objective C (and perhaps C++) because the GNU
5291 front-ends for these languages may in fact create certain "built-in"
5292 types which are (for example) RECORD_TYPEs. In such cases, we
5293 really need to output these (non-fundamental) types because other
5294 DIEs may contain references to them. */
5296 /* Also ignore language dependent types here, because they are probably
5297 also built-in types. If we didn't ignore them, then we would get
5298 references to undefined labels because output_type doesn't support
5299 them. So, for now, we need to ignore them to avoid assembler
5302 /* ??? This code is different than the equivalent code in dwarf2out.c.
5303 The dwarf2out.c code is probably more correct. */
5305 if (DECL_SOURCE_LINE (decl
) == 0
5306 && (type_is_fundamental (TREE_TYPE (decl
))
5307 || TREE_CODE (TREE_TYPE (decl
)) == LANG_TYPE
))
5310 /* If we are in terse mode, don't generate any DIEs to represent
5311 any actual typedefs. Note that even when we are in terse mode,
5312 we must still output DIEs to represent those tagged types which
5313 are used (directly or indirectly) in the specification of either
5314 a return type or a formal parameter type of some function. */
5316 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
5317 if (! TYPE_DECL_IS_STUB (decl
)
5318 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl
)))
5327 fputc ('\n', asm_out_file
);
5328 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DEBUG_SECTION
);
5329 finalizing
= set_finalizing
;
5330 output_decl (decl
, NULL_TREE
);
5332 /* NOTE: The call above to `output_decl' may have caused one or more
5333 file-scope named types (i.e. tagged types) to be placed onto the
5334 pending_types_list. We have to get those types off of that list
5335 at some point, and this is the perfect time to do it. If we didn't
5336 take them off now, they might still be on the list when cc1 finally
5337 exits. That might be OK if it weren't for the fact that when we put
5338 types onto the pending_types_list, we set the TREE_ASM_WRITTEN flag
5339 for these types, and that causes them never to be output unless
5340 `output_pending_types_for_scope' takes them off of the list and un-sets
5341 their TREE_ASM_WRITTEN flags. */
5343 output_pending_types_for_scope (NULL_TREE
);
5345 /* The above call should have totally emptied the pending_types_list
5346 if this is not a nested function or class. If this is a nested type,
5347 then the remaining pending_types will be emitted when the containing type
5350 if (! DECL_CONTEXT (decl
))
5352 if (pending_types
!= 0)
5356 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5358 if (TREE_CODE (decl
) == FUNCTION_DECL
&& DECL_INITIAL (decl
) != NULL
)
5359 current_funcdef_number
++;
5362 /* Output a marker (i.e. a label) for the beginning of the generated code
5363 for a lexical block. */
5366 dwarfout_begin_block (blocknum
)
5367 register unsigned blocknum
;
5369 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5371 function_section (current_function_decl
);
5372 sprintf (label
, BLOCK_BEGIN_LABEL_FMT
, blocknum
);
5373 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5376 /* Output a marker (i.e. a label) for the end of the generated code
5377 for a lexical block. */
5380 dwarfout_end_block (blocknum
)
5381 register unsigned blocknum
;
5383 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5385 function_section (current_function_decl
);
5386 sprintf (label
, BLOCK_END_LABEL_FMT
, blocknum
);
5387 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5390 /* Output a marker (i.e. a label) at a point in the assembly code which
5391 corresponds to a given source level label. */
5394 dwarfout_label (insn
)
5397 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
5399 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5401 function_section (current_function_decl
);
5402 sprintf (label
, INSN_LABEL_FMT
, current_funcdef_number
,
5403 (unsigned) INSN_UID (insn
));
5404 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5408 /* Output a marker (i.e. a label) for the point in the generated code where
5409 the real body of the function begins (after parameters have been moved
5410 to their home locations). */
5413 dwarfout_begin_function ()
5415 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5417 if (! use_gnu_debug_info_extensions
)
5419 function_section (current_function_decl
);
5420 sprintf (label
, BODY_BEGIN_LABEL_FMT
, current_funcdef_number
);
5421 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5424 /* Output a marker (i.e. a label) for the point in the generated code where
5425 the real body of the function ends (just before the epilogue code). */
5428 dwarfout_end_function ()
5430 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5432 if (! use_gnu_debug_info_extensions
)
5434 function_section (current_function_decl
);
5435 sprintf (label
, BODY_END_LABEL_FMT
, current_funcdef_number
);
5436 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5439 /* Output a marker (i.e. a label) for the absolute end of the generated code
5440 for a function definition. This gets called *after* the epilogue code
5441 has been generated. */
5444 dwarfout_end_epilogue ()
5446 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5448 /* Output a label to mark the endpoint of the code generated for this
5451 sprintf (label
, FUNC_END_LABEL_FMT
, current_funcdef_number
);
5452 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5456 shuffle_filename_entry (new_zeroth
)
5457 register filename_entry
*new_zeroth
;
5459 filename_entry temp_entry
;
5460 register filename_entry
*limit_p
;
5461 register filename_entry
*move_p
;
5463 if (new_zeroth
== &filename_table
[0])
5466 temp_entry
= *new_zeroth
;
5468 /* Shift entries up in the table to make room at [0]. */
5470 limit_p
= &filename_table
[0];
5471 for (move_p
= new_zeroth
; move_p
> limit_p
; move_p
--)
5472 *move_p
= *(move_p
-1);
5474 /* Install the found entry at [0]. */
5476 filename_table
[0] = temp_entry
;
5479 /* Create a new (string) entry for the .debug_sfnames section. */
5482 generate_new_sfname_entry ()
5484 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5486 fputc ('\n', asm_out_file
);
5487 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, SFNAMES_SECTION
);
5488 sprintf (label
, SFNAMES_ENTRY_LABEL_FMT
, filename_table
[0].number
);
5489 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5490 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
,
5491 filename_table
[0].name
5492 ? filename_table
[0].name
5494 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5497 /* Lookup a filename (in the list of filenames that we know about here in
5498 dwarfout.c) and return its "index". The index of each (known) filename
5499 is just a unique number which is associated with only that one filename.
5500 We need such numbers for the sake of generating labels (in the
5501 .debug_sfnames section) and references to those unique labels (in the
5502 .debug_srcinfo and .debug_macinfo sections).
5504 If the filename given as an argument is not found in our current list,
5505 add it to the list and assign it the next available unique index number.
5507 Whatever we do (i.e. whether we find a pre-existing filename or add a new
5508 one), we shuffle the filename found (or added) up to the zeroth entry of
5509 our list of filenames (which is always searched linearly). We do this so
5510 as to optimize the most common case for these filename lookups within
5511 dwarfout.c. The most common case by far is the case where we call
5512 lookup_filename to lookup the very same filename that we did a lookup
5513 on the last time we called lookup_filename. We make sure that this
5514 common case is fast because such cases will constitute 99.9% of the
5515 lookups we ever do (in practice).
5517 If we add a new filename entry to our table, we go ahead and generate
5518 the corresponding entry in the .debug_sfnames section right away.
5519 Doing so allows us to avoid tickling an assembler bug (present in some
5520 m68k assemblers) which yields assembly-time errors in cases where the
5521 difference of two label addresses is taken and where the two labels
5522 are in a section *other* than the one where the difference is being
5523 calculated, and where at least one of the two symbol references is a
5524 forward reference. (This bug could be tickled by our .debug_srcinfo
5525 entries if we don't output their corresponding .debug_sfnames entries
5529 lookup_filename (file_name
)
5530 const char *file_name
;
5532 register filename_entry
*search_p
;
5533 register filename_entry
*limit_p
= &filename_table
[ft_entries
];
5535 for (search_p
= filename_table
; search_p
< limit_p
; search_p
++)
5536 if (!strcmp (file_name
, search_p
->name
))
5538 /* When we get here, we have found the filename that we were
5539 looking for in the filename_table. Now we want to make sure
5540 that it gets moved to the zero'th entry in the table (if it
5541 is not already there) so that subsequent attempts to find the
5542 same filename will find it as quickly as possible. */
5544 shuffle_filename_entry (search_p
);
5545 return filename_table
[0].number
;
5548 /* We come here whenever we have a new filename which is not registered
5549 in the current table. Here we add it to the table. */
5551 /* Prepare to add a new table entry by making sure there is enough space
5552 in the table to do so. If not, expand the current table. */
5554 if (ft_entries
== ft_entries_allocated
)
5556 ft_entries_allocated
+= FT_ENTRIES_INCREMENT
;
5558 = (filename_entry
*)
5559 xrealloc (filename_table
,
5560 ft_entries_allocated
* sizeof (filename_entry
));
5563 /* Initially, add the new entry at the end of the filename table. */
5565 filename_table
[ft_entries
].number
= ft_entries
;
5566 filename_table
[ft_entries
].name
= xstrdup (file_name
);
5568 /* Shuffle the new entry into filename_table[0]. */
5570 shuffle_filename_entry (&filename_table
[ft_entries
]);
5572 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
5573 generate_new_sfname_entry ();
5576 return filename_table
[0].number
;
5580 generate_srcinfo_entry (line_entry_num
, files_entry_num
)
5581 unsigned line_entry_num
;
5582 unsigned files_entry_num
;
5584 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5586 fputc ('\n', asm_out_file
);
5587 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, SRCINFO_SECTION
);
5588 sprintf (label
, LINE_ENTRY_LABEL_FMT
, line_entry_num
);
5589 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, label
, LINE_BEGIN_LABEL
);
5590 sprintf (label
, SFNAMES_ENTRY_LABEL_FMT
, files_entry_num
);
5591 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, label
, SFNAMES_BEGIN_LABEL
);
5592 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5596 dwarfout_line (filename
, line
)
5597 register const char *filename
;
5598 register unsigned line
;
5600 if (debug_info_level
>= DINFO_LEVEL_NORMAL
5601 /* We can't emit line number info for functions in separate sections,
5602 because the assembler can't subtract labels in different sections. */
5603 && DECL_SECTION_NAME (current_function_decl
) == NULL_TREE
)
5605 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5606 static unsigned last_line_entry_num
= 0;
5607 static unsigned prev_file_entry_num
= (unsigned) -1;
5608 register unsigned this_file_entry_num
;
5610 function_section (current_function_decl
);
5611 sprintf (label
, LINE_CODE_LABEL_FMT
, ++last_line_entry_num
);
5612 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5614 fputc ('\n', asm_out_file
);
5616 if (use_gnu_debug_info_extensions
)
5617 this_file_entry_num
= lookup_filename (filename
);
5619 this_file_entry_num
= (unsigned) -1;
5621 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, LINE_SECTION
);
5622 if (this_file_entry_num
!= prev_file_entry_num
)
5624 char line_entry_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5626 sprintf (line_entry_label
, LINE_ENTRY_LABEL_FMT
, last_line_entry_num
);
5627 ASM_OUTPUT_LABEL (asm_out_file
, line_entry_label
);
5631 register const char *tail
= rindex (filename
, '/');
5637 fprintf (asm_out_file
, "\t%s\t%u\t%s %s:%u\n",
5638 UNALIGNED_INT_ASM_OP
, line
, ASM_COMMENT_START
,
5640 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, 0xffff);
5641 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, label
, TEXT_BEGIN_LABEL
);
5642 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5644 if (this_file_entry_num
!= prev_file_entry_num
)
5645 generate_srcinfo_entry (last_line_entry_num
, this_file_entry_num
);
5646 prev_file_entry_num
= this_file_entry_num
;
5650 /* Generate an entry in the .debug_macinfo section. */
5653 generate_macinfo_entry (type_and_offset
, string
)
5654 register const char *type_and_offset
;
5655 register const char *string
;
5657 if (! use_gnu_debug_info_extensions
)
5660 fputc ('\n', asm_out_file
);
5661 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, MACINFO_SECTION
);
5662 fprintf (asm_out_file
, "\t%s\t%s\n", UNALIGNED_INT_ASM_OP
, type_and_offset
);
5663 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, string
);
5664 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5668 dwarfout_start_new_source_file (filename
)
5669 register const char *filename
;
5671 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5672 char type_and_offset
[MAX_ARTIFICIAL_LABEL_BYTES
*3];
5674 sprintf (label
, SFNAMES_ENTRY_LABEL_FMT
, lookup_filename (filename
));
5675 sprintf (type_and_offset
, "0x%08x+%s-%s",
5676 ((unsigned) MACINFO_start
<< 24),
5677 /* Hack: skip leading '*' . */
5678 (*label
== '*') + label
,
5679 (*SFNAMES_BEGIN_LABEL
== '*') + SFNAMES_BEGIN_LABEL
);
5680 generate_macinfo_entry (type_and_offset
, "");
5684 dwarfout_resume_previous_source_file (lineno
)
5685 register unsigned lineno
;
5687 char type_and_offset
[MAX_ARTIFICIAL_LABEL_BYTES
*2];
5689 sprintf (type_and_offset
, "0x%08x+%u",
5690 ((unsigned) MACINFO_resume
<< 24), lineno
);
5691 generate_macinfo_entry (type_and_offset
, "");
5694 /* Called from check_newline in c-parse.y. The `buffer' parameter
5695 contains the tail part of the directive line, i.e. the part which
5696 is past the initial whitespace, #, whitespace, directive-name,
5700 dwarfout_define (lineno
, buffer
)
5701 register unsigned lineno
;
5702 register const char *buffer
;
5704 static int initialized
= 0;
5705 char type_and_offset
[MAX_ARTIFICIAL_LABEL_BYTES
*2];
5709 dwarfout_start_new_source_file (primary_filename
);
5712 sprintf (type_and_offset
, "0x%08x+%u",
5713 ((unsigned) MACINFO_define
<< 24), lineno
);
5714 generate_macinfo_entry (type_and_offset
, buffer
);
5717 /* Called from check_newline in c-parse.y. The `buffer' parameter
5718 contains the tail part of the directive line, i.e. the part which
5719 is past the initial whitespace, #, whitespace, directive-name,
5723 dwarfout_undef (lineno
, buffer
)
5724 register unsigned lineno
;
5725 register const char *buffer
;
5727 char type_and_offset
[MAX_ARTIFICIAL_LABEL_BYTES
*2];
5729 sprintf (type_and_offset
, "0x%08x+%u",
5730 ((unsigned) MACINFO_undef
<< 24), lineno
);
5731 generate_macinfo_entry (type_and_offset
, buffer
);
5734 /* Set up for Dwarf output at the start of compilation. */
5737 dwarfout_init (asm_out_file
, main_input_filename
)
5738 register FILE *asm_out_file
;
5739 register char *main_input_filename
;
5741 /* Remember the name of the primary input file. */
5743 primary_filename
= main_input_filename
;
5745 /* Allocate the initial hunk of the pending_sibling_stack. */
5747 pending_sibling_stack
5749 xmalloc (PENDING_SIBLINGS_INCREMENT
* sizeof (unsigned));
5750 pending_siblings_allocated
= PENDING_SIBLINGS_INCREMENT
;
5751 pending_siblings
= 1;
5753 /* Allocate the initial hunk of the filename_table. */
5756 = (filename_entry
*)
5757 xmalloc (FT_ENTRIES_INCREMENT
* sizeof (filename_entry
));
5758 ft_entries_allocated
= FT_ENTRIES_INCREMENT
;
5761 /* Allocate the initial hunk of the pending_types_list. */
5764 = (tree
*) xmalloc (PENDING_TYPES_INCREMENT
* sizeof (tree
));
5765 pending_types_allocated
= PENDING_TYPES_INCREMENT
;
5768 /* Create an artificial RECORD_TYPE node which we can use in our hack
5769 to get the DIEs representing types of formal parameters to come out
5770 only *after* the DIEs for the formal parameters themselves. */
5772 fake_containing_scope
= make_node (RECORD_TYPE
);
5774 /* Output a starting label for the .text section. */
5776 fputc ('\n', asm_out_file
);
5777 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, TEXT_SECTION
);
5778 ASM_OUTPUT_LABEL (asm_out_file
, TEXT_BEGIN_LABEL
);
5779 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5781 /* Output a starting label for the .data section. */
5783 fputc ('\n', asm_out_file
);
5784 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DATA_SECTION
);
5785 ASM_OUTPUT_LABEL (asm_out_file
, DATA_BEGIN_LABEL
);
5786 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5788 #if 0 /* GNU C doesn't currently use .data1. */
5789 /* Output a starting label for the .data1 section. */
5791 fputc ('\n', asm_out_file
);
5792 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DATA1_SECTION
);
5793 ASM_OUTPUT_LABEL (asm_out_file
, DATA1_BEGIN_LABEL
);
5794 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5797 /* Output a starting label for the .rodata section. */
5799 fputc ('\n', asm_out_file
);
5800 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, RODATA_SECTION
);
5801 ASM_OUTPUT_LABEL (asm_out_file
, RODATA_BEGIN_LABEL
);
5802 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5804 #if 0 /* GNU C doesn't currently use .rodata1. */
5805 /* Output a starting label for the .rodata1 section. */
5807 fputc ('\n', asm_out_file
);
5808 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, RODATA1_SECTION
);
5809 ASM_OUTPUT_LABEL (asm_out_file
, RODATA1_BEGIN_LABEL
);
5810 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5813 /* Output a starting label for the .bss section. */
5815 fputc ('\n', asm_out_file
);
5816 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, BSS_SECTION
);
5817 ASM_OUTPUT_LABEL (asm_out_file
, BSS_BEGIN_LABEL
);
5818 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5820 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
5822 if (use_gnu_debug_info_extensions
)
5824 /* Output a starting label and an initial (compilation directory)
5825 entry for the .debug_sfnames section. The starting label will be
5826 referenced by the initial entry in the .debug_srcinfo section. */
5828 fputc ('\n', asm_out_file
);
5829 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, SFNAMES_SECTION
);
5830 ASM_OUTPUT_LABEL (asm_out_file
, SFNAMES_BEGIN_LABEL
);
5832 register char *pwd
= getpwd ();
5833 register char *dirname
;
5836 pfatal_with_name ("getpwd");
5837 dirname
= concat (pwd
, "/", NULL
);
5838 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, dirname
);
5841 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5844 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
5845 && use_gnu_debug_info_extensions
)
5847 /* Output a starting label for the .debug_macinfo section. This
5848 label will be referenced by the AT_mac_info attribute in the
5849 TAG_compile_unit DIE. */
5851 fputc ('\n', asm_out_file
);
5852 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, MACINFO_SECTION
);
5853 ASM_OUTPUT_LABEL (asm_out_file
, MACINFO_BEGIN_LABEL
);
5854 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5857 /* Generate the initial entry for the .line section. */
5859 fputc ('\n', asm_out_file
);
5860 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, LINE_SECTION
);
5861 ASM_OUTPUT_LABEL (asm_out_file
, LINE_BEGIN_LABEL
);
5862 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, LINE_END_LABEL
, LINE_BEGIN_LABEL
);
5863 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_BEGIN_LABEL
);
5864 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5866 if (use_gnu_debug_info_extensions
)
5868 /* Generate the initial entry for the .debug_srcinfo section. */
5870 fputc ('\n', asm_out_file
);
5871 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, SRCINFO_SECTION
);
5872 ASM_OUTPUT_LABEL (asm_out_file
, SRCINFO_BEGIN_LABEL
);
5873 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, LINE_BEGIN_LABEL
);
5874 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, SFNAMES_BEGIN_LABEL
);
5875 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_BEGIN_LABEL
);
5876 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_END_LABEL
);
5877 #ifdef DWARF_TIMESTAMPS
5878 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, time (NULL
));
5880 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, -1);
5882 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5885 /* Generate the initial entry for the .debug_pubnames section. */
5887 fputc ('\n', asm_out_file
);
5888 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, PUBNAMES_SECTION
);
5889 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, DEBUG_BEGIN_LABEL
);
5890 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5892 /* Generate the initial entry for the .debug_aranges section. */
5894 fputc ('\n', asm_out_file
);
5895 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, ARANGES_SECTION
);
5896 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, DEBUG_BEGIN_LABEL
);
5897 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5900 /* Setup first DIE number == 1. */
5901 NEXT_DIE_NUM
= next_unused_dienum
++;
5903 /* Generate the initial DIE for the .debug section. Note that the
5904 (string) value given in the AT_name attribute of the TAG_compile_unit
5905 DIE will (typically) be a relative pathname and that this pathname
5906 should be taken as being relative to the directory from which the
5907 compiler was invoked when the given (base) source file was compiled. */
5909 fputc ('\n', asm_out_file
);
5910 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DEBUG_SECTION
);
5911 ASM_OUTPUT_LABEL (asm_out_file
, DEBUG_BEGIN_LABEL
);
5912 output_die (output_compile_unit_die
, main_input_filename
);
5913 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5915 fputc ('\n', asm_out_file
);
5918 /* Output stuff that dwarf requires at the end of every file. */
5923 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5925 retry_incomplete_types ();
5927 fputc ('\n', asm_out_file
);
5928 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DEBUG_SECTION
);
5930 /* Mark the end of the chain of siblings which represent all file-scope
5931 declarations in this compilation unit. */
5933 /* The (null) DIE which represents the terminator for the (sibling linked)
5934 list of file-scope items is *special*. Normally, we would just call
5935 end_sibling_chain at this point in order to output a word with the
5936 value `4' and that word would act as the terminator for the list of
5937 DIEs describing file-scope items. Unfortunately, if we were to simply
5938 do that, the label that would follow this DIE in the .debug section
5939 (i.e. `..D2') would *not* be properly aligned (as it must be on some
5940 machines) to a 4 byte boundary.
5942 In order to force the label `..D2' to get aligned to a 4 byte boundary,
5943 the trick used is to insert extra (otherwise useless) padding bytes
5944 into the (null) DIE that we know must precede the ..D2 label in the
5945 .debug section. The amount of padding required can be anywhere between
5946 0 and 3 bytes. The length word at the start of this DIE (i.e. the one
5947 with the padding) would normally contain the value 4, but now it will
5948 also have to include the padding bytes, so it will instead have some
5949 value in the range 4..7.
5951 Fortunately, the rules of Dwarf say that any DIE whose length word
5952 contains *any* value less than 8 should be treated as a null DIE, so
5953 this trick works out nicely. Clever, eh? Don't give me any credit
5954 (or blame). I didn't think of this scheme. I just conformed to it.
5957 output_die (output_padded_null_die
, (void *) 0);
5960 sprintf (label
, DIE_BEGIN_LABEL_FMT
, NEXT_DIE_NUM
);
5961 ASM_OUTPUT_LABEL (asm_out_file
, label
); /* should be ..D2 */
5962 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5964 /* Output a terminator label for the .text section. */
5966 fputc ('\n', asm_out_file
);
5967 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, TEXT_SECTION
);
5968 ASM_OUTPUT_LABEL (asm_out_file
, TEXT_END_LABEL
);
5969 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5971 /* Output a terminator label for the .data section. */
5973 fputc ('\n', asm_out_file
);
5974 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DATA_SECTION
);
5975 ASM_OUTPUT_LABEL (asm_out_file
, DATA_END_LABEL
);
5976 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5978 #if 0 /* GNU C doesn't currently use .data1. */
5979 /* Output a terminator label for the .data1 section. */
5981 fputc ('\n', asm_out_file
);
5982 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DATA1_SECTION
);
5983 ASM_OUTPUT_LABEL (asm_out_file
, DATA1_END_LABEL
);
5984 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5987 /* Output a terminator label for the .rodata section. */
5989 fputc ('\n', asm_out_file
);
5990 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, RODATA_SECTION
);
5991 ASM_OUTPUT_LABEL (asm_out_file
, RODATA_END_LABEL
);
5992 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5994 #if 0 /* GNU C doesn't currently use .rodata1. */
5995 /* Output a terminator label for the .rodata1 section. */
5997 fputc ('\n', asm_out_file
);
5998 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, RODATA1_SECTION
);
5999 ASM_OUTPUT_LABEL (asm_out_file
, RODATA1_END_LABEL
);
6000 ASM_OUTPUT_POP_SECTION (asm_out_file
);
6003 /* Output a terminator label for the .bss section. */
6005 fputc ('\n', asm_out_file
);
6006 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, BSS_SECTION
);
6007 ASM_OUTPUT_LABEL (asm_out_file
, BSS_END_LABEL
);
6008 ASM_OUTPUT_POP_SECTION (asm_out_file
);
6010 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
6012 /* Output a terminating entry for the .line section. */
6014 fputc ('\n', asm_out_file
);
6015 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, LINE_SECTION
);
6016 ASM_OUTPUT_LABEL (asm_out_file
, LINE_LAST_ENTRY_LABEL
);
6017 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
6018 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, 0xffff);
6019 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, TEXT_END_LABEL
, TEXT_BEGIN_LABEL
);
6020 ASM_OUTPUT_LABEL (asm_out_file
, LINE_END_LABEL
);
6021 ASM_OUTPUT_POP_SECTION (asm_out_file
);
6023 if (use_gnu_debug_info_extensions
)
6025 /* Output a terminating entry for the .debug_srcinfo section. */
6027 fputc ('\n', asm_out_file
);
6028 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, SRCINFO_SECTION
);
6029 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
,
6030 LINE_LAST_ENTRY_LABEL
, LINE_BEGIN_LABEL
);
6031 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, -1);
6032 ASM_OUTPUT_POP_SECTION (asm_out_file
);
6035 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
6037 /* Output terminating entries for the .debug_macinfo section. */
6039 dwarfout_resume_previous_source_file (0);
6041 fputc ('\n', asm_out_file
);
6042 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, MACINFO_SECTION
);
6043 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
6044 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
6045 ASM_OUTPUT_POP_SECTION (asm_out_file
);
6048 /* Generate the terminating entry for the .debug_pubnames section. */
6050 fputc ('\n', asm_out_file
);
6051 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, PUBNAMES_SECTION
);
6052 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
6053 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
6054 ASM_OUTPUT_POP_SECTION (asm_out_file
);
6056 /* Generate the terminating entries for the .debug_aranges section.
6058 Note that we want to do this only *after* we have output the end
6059 labels (for the various program sections) which we are going to
6060 refer to here. This allows us to work around a bug in the m68k
6061 svr4 assembler. That assembler gives bogus assembly-time errors
6062 if (within any given section) you try to take the difference of
6063 two relocatable symbols, both of which are located within some
6064 other section, and if one (or both?) of the symbols involved is
6065 being forward-referenced. By generating the .debug_aranges
6066 entries at this late point in the assembly output, we skirt the
6067 issue simply by avoiding forward-references.
6070 fputc ('\n', asm_out_file
);
6071 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, ARANGES_SECTION
);
6073 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_BEGIN_LABEL
);
6074 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, TEXT_END_LABEL
, TEXT_BEGIN_LABEL
);
6076 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, DATA_BEGIN_LABEL
);
6077 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, DATA_END_LABEL
, DATA_BEGIN_LABEL
);
6079 #if 0 /* GNU C doesn't currently use .data1. */
6080 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, DATA1_BEGIN_LABEL
);
6081 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, DATA1_END_LABEL
,
6085 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, RODATA_BEGIN_LABEL
);
6086 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, RODATA_END_LABEL
,
6087 RODATA_BEGIN_LABEL
);
6089 #if 0 /* GNU C doesn't currently use .rodata1. */
6090 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, RODATA1_BEGIN_LABEL
);
6091 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, RODATA1_END_LABEL
,
6092 RODATA1_BEGIN_LABEL
);
6095 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, BSS_BEGIN_LABEL
);
6096 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, BSS_END_LABEL
, BSS_BEGIN_LABEL
);
6098 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
6099 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
6101 ASM_OUTPUT_POP_SECTION (asm_out_file
);
6104 /* There should not be any pending types left at the end. We need
6105 this now because it may not have been checked on the last call to
6106 dwarfout_file_scope_decl. */
6107 if (pending_types
!= 0)
6111 #endif /* DWARF_DEBUGGING_INFO */