1 /* Output Dwarf format symbol table information from the GNU C compiler.
2 Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998,
3 1999, 2000 Free Software Foundation, Inc.
4 Contributed by Ron Guilmette (rfg@monkeys.com) of Network Computing Devices.
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. */
25 #ifdef DWARF_DEBUGGING_INFO
31 #include "hard-reg-set.h"
32 #include "insn-config.h"
40 #if defined(DWARF_TIMESTAMPS)
42 extern time_t time
PARAMS ((time_t *)); /* FIXME: use NEED_DECLARATION_TIME */
43 #endif /* !defined(POSIX) */
44 #endif /* defined(DWARF_TIMESTAMPS) */
46 /* We cannot use <assert.h> in GCC source, since that would include
47 GCC's assert.h, which may not be compatible with the host compiler. */
52 # define assert(e) do { if (! (e)) abort (); } while (0)
55 /* IMPORTANT NOTE: Please see the file README.DWARF for important details
56 regarding the GNU implementation of Dwarf. */
58 /* NOTE: In the comments in this file, many references are made to
59 so called "Debugging Information Entries". For the sake of brevity,
60 this term is abbreviated to `DIE' throughout the remainder of this
63 /* Note that the implementation of C++ support herein is (as yet) unfinished.
64 If you want to try to complete it, more power to you. */
66 /* How to start an assembler comment. */
67 #ifndef ASM_COMMENT_START
68 #define ASM_COMMENT_START ";#"
71 /* How to print out a register name. */
73 #define PRINT_REG(RTX, CODE, FILE) \
74 fprintf ((FILE), "%s", reg_names[REGNO (RTX)])
77 /* Define a macro which returns non-zero for any tagged type which is
78 used (directly or indirectly) in the specification of either some
79 function's return type or some formal parameter of some function.
80 We use this macro when we are operating in "terse" mode to help us
81 know what tagged types have to be represented in Dwarf (even in
82 terse mode) and which ones don't.
84 A flag bit with this meaning really should be a part of the normal
85 GCC ..._TYPE nodes, but at the moment, there is no such bit defined
86 for these nodes. For now, we have to just fake it. It it safe for
87 us to simply return zero for all complete tagged types (which will
88 get forced out anyway if they were used in the specification of some
89 formal or return type) and non-zero for all incomplete tagged types.
92 #define TYPE_USED_FOR_FUNCTION(tagged_type) (TYPE_SIZE (tagged_type) == 0)
94 /* Define a macro which returns non-zero for a TYPE_DECL which was
95 implicitly generated for a tagged type.
97 Note that unlike the gcc front end (which generates a NULL named
98 TYPE_DECL node for each complete tagged type, each array type, and
99 each function type node created) the g++ front end generates a
100 _named_ TYPE_DECL node for each tagged type node created.
101 These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
102 generate a DW_TAG_typedef DIE for them. */
103 #define TYPE_DECL_IS_STUB(decl) \
104 (DECL_NAME (decl) == NULL \
105 || (DECL_ARTIFICIAL (decl) \
106 && is_tagged_type (TREE_TYPE (decl)) \
107 && decl == TYPE_STUB_DECL (TREE_TYPE (decl))))
109 extern int flag_traditional
;
111 /* Maximum size (in bytes) of an artificially generated label. */
113 #define MAX_ARTIFICIAL_LABEL_BYTES 30
115 /* Make sure we know the sizes of the various types dwarf can describe.
116 These are only defaults. If the sizes are different for your target,
117 you should override these values by defining the appropriate symbols
118 in your tm.h file. */
120 #ifndef CHAR_TYPE_SIZE
121 #define CHAR_TYPE_SIZE BITS_PER_UNIT
124 #ifndef SHORT_TYPE_SIZE
125 #define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
128 #ifndef INT_TYPE_SIZE
129 #define INT_TYPE_SIZE BITS_PER_WORD
132 #ifndef LONG_TYPE_SIZE
133 #define LONG_TYPE_SIZE BITS_PER_WORD
136 #ifndef LONG_LONG_TYPE_SIZE
137 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
140 #ifndef WCHAR_TYPE_SIZE
141 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
144 #ifndef WCHAR_UNSIGNED
145 #define WCHAR_UNSIGNED 0
148 #ifndef FLOAT_TYPE_SIZE
149 #define FLOAT_TYPE_SIZE BITS_PER_WORD
152 #ifndef DOUBLE_TYPE_SIZE
153 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
156 #ifndef LONG_DOUBLE_TYPE_SIZE
157 #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
160 /* Structure to keep track of source filenames. */
162 struct filename_entry
{
167 typedef struct filename_entry filename_entry
;
169 /* Pointer to an array of elements, each one having the structure above. */
171 static filename_entry
*filename_table
;
173 /* Total number of entries in the table (i.e. array) pointed to by
174 `filename_table'. This is the *total* and includes both used and
177 static unsigned ft_entries_allocated
;
179 /* Number of entries in the filename_table which are actually in use. */
181 static unsigned ft_entries
;
183 /* Size (in elements) of increments by which we may expand the filename
184 table. Actually, a single hunk of space of this size should be enough
185 for most typical programs. */
187 #define FT_ENTRIES_INCREMENT 64
189 /* Local pointer to the name of the main input file. Initialized in
192 static char *primary_filename
;
194 /* Pointer to the most recent filename for which we produced some line info. */
196 static char *last_filename
;
198 /* Counter to generate unique names for DIEs. */
200 static unsigned next_unused_dienum
= 1;
202 /* Number of the DIE which is currently being generated. */
204 static unsigned current_dienum
;
206 /* Number to use for the special "pubname" label on the next DIE which
207 represents a function or data object defined in this compilation
208 unit which has "extern" linkage. */
210 static int next_pubname_number
= 0;
212 #define NEXT_DIE_NUM pending_sibling_stack[pending_siblings-1]
214 /* Pointer to a dynamically allocated list of pre-reserved and still
215 pending sibling DIE numbers. Note that this list will grow as needed. */
217 static unsigned *pending_sibling_stack
;
219 /* Counter to keep track of the number of pre-reserved and still pending
220 sibling DIE numbers. */
222 static unsigned pending_siblings
;
224 /* The currently allocated size of the above list (expressed in number of
227 static unsigned pending_siblings_allocated
;
229 /* Size (in elements) of increments by which we may expand the pending
230 sibling stack. Actually, a single hunk of space of this size should
231 be enough for most typical programs. */
233 #define PENDING_SIBLINGS_INCREMENT 64
235 /* Non-zero if we are performing our file-scope finalization pass and if
236 we should force out Dwarf descriptions of any and all file-scope
237 tagged types which are still incomplete types. */
239 static int finalizing
= 0;
241 /* A pointer to the base of a list of pending types which we haven't
242 generated DIEs for yet, but which we will have to come back to
245 static tree
*pending_types_list
;
247 /* Number of elements currently allocated for the pending_types_list. */
249 static unsigned pending_types_allocated
;
251 /* Number of elements of pending_types_list currently in use. */
253 static unsigned pending_types
;
255 /* Size (in elements) of increments by which we may expand the pending
256 types list. Actually, a single hunk of space of this size should
257 be enough for most typical programs. */
259 #define PENDING_TYPES_INCREMENT 64
261 /* A pointer to the base of a list of incomplete types which might be
262 completed at some later time. */
264 static tree
*incomplete_types_list
;
266 /* Number of elements currently allocated for the incomplete_types_list. */
267 static unsigned incomplete_types_allocated
;
269 /* Number of elements of incomplete_types_list currently in use. */
270 static unsigned incomplete_types
;
272 /* Size (in elements) of increments by which we may expand the incomplete
273 types list. Actually, a single hunk of space of this size should
274 be enough for most typical programs. */
275 #define INCOMPLETE_TYPES_INCREMENT 64
277 /* Pointer to an artificial RECORD_TYPE which we create in dwarfout_init.
278 This is used in a hack to help us get the DIEs describing types of
279 formal parameters to come *after* all of the DIEs describing the formal
280 parameters themselves. That's necessary in order to be compatible
281 with what the brain-damaged svr4 SDB debugger requires. */
283 static tree fake_containing_scope
;
285 /* The number of the current function definition that we are generating
286 debugging information for. These numbers range from 1 up to the maximum
287 number of function definitions contained within the current compilation
288 unit. These numbers are used to create unique labels for various things
289 contained within various function definitions. */
291 static unsigned current_funcdef_number
= 1;
293 /* A pointer to the ..._DECL node which we have most recently been working
294 on. We keep this around just in case something about it looks screwy
295 and we want to tell the user what the source coordinates for the actual
298 static tree dwarf_last_decl
;
300 /* A flag indicating that we are emitting the member declarations of a
301 class, so member functions and variables should not be entirely emitted.
302 This is a kludge to avoid passing a second argument to output_*_die. */
306 /* Forward declarations for functions defined in this file. */
308 static const char *dwarf_tag_name
PARAMS ((unsigned));
309 static const char *dwarf_attr_name
PARAMS ((unsigned));
310 static const char *dwarf_stack_op_name
PARAMS ((unsigned));
311 static const char *dwarf_typemod_name
PARAMS ((unsigned));
312 static const char *dwarf_fmt_byte_name
PARAMS ((unsigned));
313 static const char *dwarf_fund_type_name
PARAMS ((unsigned));
314 static tree decl_ultimate_origin
PARAMS ((tree
));
315 static tree block_ultimate_origin
PARAMS ((tree
));
316 static tree decl_class_context
PARAMS ((tree
));
318 static void output_unsigned_leb128
PARAMS ((unsigned long));
319 static void output_signed_leb128
PARAMS ((long));
321 static int fundamental_type_code
PARAMS ((tree
));
322 static tree root_type_1
PARAMS ((tree
, int));
323 static tree root_type
PARAMS ((tree
));
324 static void write_modifier_bytes_1
PARAMS ((tree
, int, int, int));
325 static void write_modifier_bytes
PARAMS ((tree
, int, int));
326 static inline int type_is_fundamental
PARAMS ((tree
));
327 static void equate_decl_number_to_die_number
PARAMS ((tree
));
328 static inline void equate_type_number_to_die_number
PARAMS ((tree
));
329 static void output_reg_number
PARAMS ((rtx
));
330 static void output_mem_loc_descriptor
PARAMS ((rtx
));
331 static void output_loc_descriptor
PARAMS ((rtx
));
332 static void output_bound_representation
PARAMS ((tree
, unsigned, int));
333 static void output_enumeral_list
PARAMS ((tree
));
334 static inline HOST_WIDE_INT ceiling
PARAMS ((HOST_WIDE_INT
, unsigned int));
335 static inline tree field_type
PARAMS ((tree
));
336 static inline unsigned int simple_type_align_in_bits
PARAMS ((tree
));
337 static inline unsigned HOST_WIDE_INT simple_type_size_in_bits
PARAMS ((tree
));
338 static HOST_WIDE_INT field_byte_offset
PARAMS ((tree
));
339 static inline void sibling_attribute
PARAMS ((void));
340 static void location_attribute
PARAMS ((rtx
));
341 static void data_member_location_attribute
PARAMS ((tree
));
342 static void const_value_attribute
PARAMS ((rtx
));
343 static void location_or_const_value_attribute
PARAMS ((tree
));
344 static inline void name_attribute
PARAMS ((const char *));
345 static inline void fund_type_attribute
PARAMS ((unsigned));
346 static void mod_fund_type_attribute
PARAMS ((tree
, int, int));
347 static inline void user_def_type_attribute
PARAMS ((tree
));
348 static void mod_u_d_type_attribute
PARAMS ((tree
, int, int));
349 #ifdef USE_ORDERING_ATTRIBUTE
350 static inline void ordering_attribute
PARAMS ((unsigned));
351 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
352 static void subscript_data_attribute
PARAMS ((tree
));
353 static void byte_size_attribute
PARAMS ((tree
));
354 static inline void bit_offset_attribute
PARAMS ((tree
));
355 static inline void bit_size_attribute
PARAMS ((tree
));
356 static inline void element_list_attribute
PARAMS ((tree
));
357 static inline void stmt_list_attribute
PARAMS ((const char *));
358 static inline void low_pc_attribute
PARAMS ((const char *));
359 static inline void high_pc_attribute
PARAMS ((const char *));
360 static inline void body_begin_attribute
PARAMS ((const char *));
361 static inline void body_end_attribute
PARAMS ((const char *));
362 static inline void language_attribute
PARAMS ((unsigned));
363 static inline void member_attribute
PARAMS ((tree
));
365 static inline void string_length_attribute
PARAMS ((tree
));
367 static inline void comp_dir_attribute
PARAMS ((const char *));
368 static inline void sf_names_attribute
PARAMS ((const char *));
369 static inline void src_info_attribute
PARAMS ((const char *));
370 static inline void mac_info_attribute
PARAMS ((const char *));
371 static inline void prototyped_attribute
PARAMS ((tree
));
372 static inline void producer_attribute
PARAMS ((const char *));
373 static inline void inline_attribute
PARAMS ((tree
));
374 static inline void containing_type_attribute
PARAMS ((tree
));
375 static inline void abstract_origin_attribute
PARAMS ((tree
));
376 #ifdef DWARF_DECL_COORDINATES
377 static inline void src_coords_attribute
PARAMS ((unsigned, unsigned));
378 #endif /* defined(DWARF_DECL_COORDINATES) */
379 static inline void pure_or_virtual_attribute
PARAMS ((tree
));
380 static void name_and_src_coords_attributes
PARAMS ((tree
));
381 static void type_attribute
PARAMS ((tree
, int, int));
382 static char *type_tag
PARAMS ((tree
));
383 static inline void dienum_push
PARAMS ((void));
384 static inline void dienum_pop
PARAMS ((void));
385 static inline tree member_declared_type
PARAMS ((tree
));
386 static const char *function_start_label
PARAMS ((tree
));
387 static void output_array_type_die
PARAMS ((void *));
388 static void output_set_type_die
PARAMS ((void *));
390 static void output_entry_point_die
PARAMS ((void *));
392 static void output_inlined_enumeration_type_die
PARAMS ((void *));
393 static void output_inlined_structure_type_die
PARAMS ((void *));
394 static void output_inlined_union_type_die
PARAMS ((void *));
395 static void output_enumeration_type_die
PARAMS ((void *));
396 static void output_formal_parameter_die
PARAMS ((void *));
397 static void output_global_subroutine_die
PARAMS ((void *));
398 static void output_global_variable_die
PARAMS ((void *));
399 static void output_label_die
PARAMS ((void *));
400 static void output_lexical_block_die
PARAMS ((void *));
401 static void output_inlined_subroutine_die
PARAMS ((void *));
402 static void output_local_variable_die
PARAMS ((void *));
403 static void output_member_die
PARAMS ((void *));
405 static void output_pointer_type_die
PARAMS ((void *));
406 static void output_reference_type_die
PARAMS ((void *));
408 static void output_ptr_to_mbr_type_die
PARAMS ((void *));
409 static void output_compile_unit_die
PARAMS ((void *));
410 static void output_string_type_die
PARAMS ((void *));
411 static void output_inheritance_die
PARAMS ((void *));
412 static void output_structure_type_die
PARAMS ((void *));
413 static void output_local_subroutine_die
PARAMS ((void *));
414 static void output_subroutine_type_die
PARAMS ((void *));
415 static void output_typedef_die
PARAMS ((void *));
416 static void output_union_type_die
PARAMS ((void *));
417 static void output_unspecified_parameters_die
PARAMS ((void *));
418 static void output_padded_null_die
PARAMS ((void *));
419 static void output_die
PARAMS ((void (*)(void *), void *));
420 static void end_sibling_chain
PARAMS ((void));
421 static void output_formal_types
PARAMS ((tree
));
422 static void pend_type
PARAMS ((tree
));
423 static int type_ok_for_scope
PARAMS ((tree
, tree
));
424 static void output_pending_types_for_scope
PARAMS ((tree
));
425 static void output_type
PARAMS ((tree
, tree
));
426 static void output_tagged_type_instantiation
PARAMS ((tree
));
427 static void output_block
PARAMS ((tree
, int));
428 static void output_decls_for_scope
PARAMS ((tree
, int));
429 static void output_decl
PARAMS ((tree
, tree
));
430 static void shuffle_filename_entry
PARAMS ((filename_entry
*));
431 static void generate_new_sfname_entry
PARAMS ((void));
432 static unsigned lookup_filename
PARAMS ((const char *));
433 static void generate_srcinfo_entry
PARAMS ((unsigned, unsigned));
434 static void generate_macinfo_entry
PARAMS ((const char *, const char *));
435 static int is_pseudo_reg
PARAMS ((rtx
));
436 static tree type_main_variant
PARAMS ((tree
));
437 static int is_tagged_type
PARAMS ((tree
));
438 static int is_redundant_typedef
PARAMS ((tree
));
439 static void add_incomplete_type
PARAMS ((tree
));
440 static void retry_incomplete_types
PARAMS ((void));
442 /* Definitions of defaults for assembler-dependent names of various
443 pseudo-ops and section names.
445 Theses may be overridden in your tm.h file (if necessary) for your
446 particular assembler. The default values provided here correspond to
447 what is expected by "standard" AT&T System V.4 assemblers. */
450 #define FILE_ASM_OP ".file"
452 #ifndef VERSION_ASM_OP
453 #define VERSION_ASM_OP ".version"
455 #ifndef UNALIGNED_SHORT_ASM_OP
456 #define UNALIGNED_SHORT_ASM_OP ".2byte"
458 #ifndef UNALIGNED_INT_ASM_OP
459 #define UNALIGNED_INT_ASM_OP ".4byte"
462 #define ASM_BYTE_OP ".byte"
465 #define SET_ASM_OP ".set"
468 /* Pseudo-ops for pushing the current section onto the section stack (and
469 simultaneously changing to a new section) and for poping back to the
470 section we were in immediately before this one. Note that most svr4
471 assemblers only maintain a one level stack... you can push all the
472 sections you want, but you can only pop out one level. (The sparc
473 svr4 assembler is an exception to this general rule.) That's
474 OK because we only use at most one level of the section stack herein. */
476 #ifndef PUSHSECTION_ASM_OP
477 #define PUSHSECTION_ASM_OP ".section"
479 #ifndef POPSECTION_ASM_OP
480 #define POPSECTION_ASM_OP ".previous"
483 /* The default format used by the ASM_OUTPUT_PUSH_SECTION macro (see below)
484 to print the PUSHSECTION_ASM_OP and the section name. The default here
485 works for almost all svr4 assemblers, except for the sparc, where the
486 section name must be enclosed in double quotes. (See sparcv4.h.) */
488 #ifndef PUSHSECTION_FORMAT
489 #define PUSHSECTION_FORMAT "\t%s\t%s\n"
492 #ifndef DEBUG_SECTION
493 #define DEBUG_SECTION ".debug"
496 #define LINE_SECTION ".line"
498 #ifndef SFNAMES_SECTION
499 #define SFNAMES_SECTION ".debug_sfnames"
501 #ifndef SRCINFO_SECTION
502 #define SRCINFO_SECTION ".debug_srcinfo"
504 #ifndef MACINFO_SECTION
505 #define MACINFO_SECTION ".debug_macinfo"
507 #ifndef PUBNAMES_SECTION
508 #define PUBNAMES_SECTION ".debug_pubnames"
510 #ifndef ARANGES_SECTION
511 #define ARANGES_SECTION ".debug_aranges"
514 #define TEXT_SECTION ".text"
517 #define DATA_SECTION ".data"
519 #ifndef DATA1_SECTION
520 #define DATA1_SECTION ".data1"
522 #ifndef RODATA_SECTION
523 #define RODATA_SECTION ".rodata"
525 #ifndef RODATA1_SECTION
526 #define RODATA1_SECTION ".rodata1"
529 #define BSS_SECTION ".bss"
532 /* Definitions of defaults for formats and names of various special
533 (artificial) labels which may be generated within this file (when
534 the -g options is used and DWARF_DEBUGGING_INFO is in effect.
536 If necessary, these may be overridden from within your tm.h file,
537 but typically, you should never need to override these.
539 These labels have been hacked (temporarily) so that they all begin with
540 a `.L' sequence so as to appease the stock sparc/svr4 assembler and the
541 stock m88k/svr4 assembler, both of which need to see .L at the start of
542 a label in order to prevent that label from going into the linker symbol
543 table). When I get time, I'll have to fix this the right way so that we
544 will use ASM_GENERATE_INTERNAL_LABEL and ASM_OUTPUT_INTERNAL_LABEL herein,
545 but that will require a rather massive set of changes. For the moment,
546 the following definitions out to produce the right results for all svr4
547 and svr3 assemblers. -- rfg
550 #ifndef TEXT_BEGIN_LABEL
551 #define TEXT_BEGIN_LABEL "*.L_text_b"
553 #ifndef TEXT_END_LABEL
554 #define TEXT_END_LABEL "*.L_text_e"
557 #ifndef DATA_BEGIN_LABEL
558 #define DATA_BEGIN_LABEL "*.L_data_b"
560 #ifndef DATA_END_LABEL
561 #define DATA_END_LABEL "*.L_data_e"
564 #ifndef DATA1_BEGIN_LABEL
565 #define DATA1_BEGIN_LABEL "*.L_data1_b"
567 #ifndef DATA1_END_LABEL
568 #define DATA1_END_LABEL "*.L_data1_e"
571 #ifndef RODATA_BEGIN_LABEL
572 #define RODATA_BEGIN_LABEL "*.L_rodata_b"
574 #ifndef RODATA_END_LABEL
575 #define RODATA_END_LABEL "*.L_rodata_e"
578 #ifndef RODATA1_BEGIN_LABEL
579 #define RODATA1_BEGIN_LABEL "*.L_rodata1_b"
581 #ifndef RODATA1_END_LABEL
582 #define RODATA1_END_LABEL "*.L_rodata1_e"
585 #ifndef BSS_BEGIN_LABEL
586 #define BSS_BEGIN_LABEL "*.L_bss_b"
588 #ifndef BSS_END_LABEL
589 #define BSS_END_LABEL "*.L_bss_e"
592 #ifndef LINE_BEGIN_LABEL
593 #define LINE_BEGIN_LABEL "*.L_line_b"
595 #ifndef LINE_LAST_ENTRY_LABEL
596 #define LINE_LAST_ENTRY_LABEL "*.L_line_last"
598 #ifndef LINE_END_LABEL
599 #define LINE_END_LABEL "*.L_line_e"
602 #ifndef DEBUG_BEGIN_LABEL
603 #define DEBUG_BEGIN_LABEL "*.L_debug_b"
605 #ifndef SFNAMES_BEGIN_LABEL
606 #define SFNAMES_BEGIN_LABEL "*.L_sfnames_b"
608 #ifndef SRCINFO_BEGIN_LABEL
609 #define SRCINFO_BEGIN_LABEL "*.L_srcinfo_b"
611 #ifndef MACINFO_BEGIN_LABEL
612 #define MACINFO_BEGIN_LABEL "*.L_macinfo_b"
615 #ifndef DIE_BEGIN_LABEL_FMT
616 #define DIE_BEGIN_LABEL_FMT "*.L_D%u"
618 #ifndef DIE_END_LABEL_FMT
619 #define DIE_END_LABEL_FMT "*.L_D%u_e"
621 #ifndef PUB_DIE_LABEL_FMT
622 #define PUB_DIE_LABEL_FMT "*.L_P%u"
624 #ifndef INSN_LABEL_FMT
625 #define INSN_LABEL_FMT "*.L_I%u_%u"
627 #ifndef BLOCK_BEGIN_LABEL_FMT
628 #define BLOCK_BEGIN_LABEL_FMT "*.L_B%u"
630 #ifndef BLOCK_END_LABEL_FMT
631 #define BLOCK_END_LABEL_FMT "*.L_B%u_e"
633 #ifndef SS_BEGIN_LABEL_FMT
634 #define SS_BEGIN_LABEL_FMT "*.L_s%u"
636 #ifndef SS_END_LABEL_FMT
637 #define SS_END_LABEL_FMT "*.L_s%u_e"
639 #ifndef EE_BEGIN_LABEL_FMT
640 #define EE_BEGIN_LABEL_FMT "*.L_e%u"
642 #ifndef EE_END_LABEL_FMT
643 #define EE_END_LABEL_FMT "*.L_e%u_e"
645 #ifndef MT_BEGIN_LABEL_FMT
646 #define MT_BEGIN_LABEL_FMT "*.L_t%u"
648 #ifndef MT_END_LABEL_FMT
649 #define MT_END_LABEL_FMT "*.L_t%u_e"
651 #ifndef LOC_BEGIN_LABEL_FMT
652 #define LOC_BEGIN_LABEL_FMT "*.L_l%u"
654 #ifndef LOC_END_LABEL_FMT
655 #define LOC_END_LABEL_FMT "*.L_l%u_e"
657 #ifndef BOUND_BEGIN_LABEL_FMT
658 #define BOUND_BEGIN_LABEL_FMT "*.L_b%u_%u_%c"
660 #ifndef BOUND_END_LABEL_FMT
661 #define BOUND_END_LABEL_FMT "*.L_b%u_%u_%c_e"
663 #ifndef DERIV_BEGIN_LABEL_FMT
664 #define DERIV_BEGIN_LABEL_FMT "*.L_d%u"
666 #ifndef DERIV_END_LABEL_FMT
667 #define DERIV_END_LABEL_FMT "*.L_d%u_e"
669 #ifndef SL_BEGIN_LABEL_FMT
670 #define SL_BEGIN_LABEL_FMT "*.L_sl%u"
672 #ifndef SL_END_LABEL_FMT
673 #define SL_END_LABEL_FMT "*.L_sl%u_e"
675 #ifndef BODY_BEGIN_LABEL_FMT
676 #define BODY_BEGIN_LABEL_FMT "*.L_b%u"
678 #ifndef BODY_END_LABEL_FMT
679 #define BODY_END_LABEL_FMT "*.L_b%u_e"
681 #ifndef FUNC_END_LABEL_FMT
682 #define FUNC_END_LABEL_FMT "*.L_f%u_e"
684 #ifndef TYPE_NAME_FMT
685 #define TYPE_NAME_FMT "*.L_T%u"
687 #ifndef DECL_NAME_FMT
688 #define DECL_NAME_FMT "*.L_E%u"
690 #ifndef LINE_CODE_LABEL_FMT
691 #define LINE_CODE_LABEL_FMT "*.L_LC%u"
693 #ifndef SFNAMES_ENTRY_LABEL_FMT
694 #define SFNAMES_ENTRY_LABEL_FMT "*.L_F%u"
696 #ifndef LINE_ENTRY_LABEL_FMT
697 #define LINE_ENTRY_LABEL_FMT "*.L_LE%u"
700 /* Definitions of defaults for various types of primitive assembly language
703 If necessary, these may be overridden from within your tm.h file,
704 but typically, you shouldn't need to override these. */
706 #ifndef ASM_OUTPUT_PUSH_SECTION
707 #define ASM_OUTPUT_PUSH_SECTION(FILE, SECTION) \
708 fprintf ((FILE), PUSHSECTION_FORMAT, PUSHSECTION_ASM_OP, SECTION)
711 #ifndef ASM_OUTPUT_POP_SECTION
712 #define ASM_OUTPUT_POP_SECTION(FILE) \
713 fprintf ((FILE), "\t%s\n", POPSECTION_ASM_OP)
716 #ifndef ASM_OUTPUT_DWARF_DELTA2
717 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
718 do { fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \
719 assemble_name (FILE, LABEL1); \
720 fprintf (FILE, "-"); \
721 assemble_name (FILE, LABEL2); \
722 fprintf (FILE, "\n"); \
726 #ifndef ASM_OUTPUT_DWARF_DELTA4
727 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
728 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
729 assemble_name (FILE, LABEL1); \
730 fprintf (FILE, "-"); \
731 assemble_name (FILE, LABEL2); \
732 fprintf (FILE, "\n"); \
736 #ifndef ASM_OUTPUT_DWARF_TAG
737 #define ASM_OUTPUT_DWARF_TAG(FILE,TAG) \
739 fprintf ((FILE), "\t%s\t0x%x", \
740 UNALIGNED_SHORT_ASM_OP, (unsigned) TAG); \
741 if (flag_debug_asm) \
742 fprintf ((FILE), "\t%s %s", \
743 ASM_COMMENT_START, dwarf_tag_name (TAG)); \
744 fputc ('\n', (FILE)); \
748 #ifndef ASM_OUTPUT_DWARF_ATTRIBUTE
749 #define ASM_OUTPUT_DWARF_ATTRIBUTE(FILE,ATTR) \
751 fprintf ((FILE), "\t%s\t0x%x", \
752 UNALIGNED_SHORT_ASM_OP, (unsigned) ATTR); \
753 if (flag_debug_asm) \
754 fprintf ((FILE), "\t%s %s", \
755 ASM_COMMENT_START, dwarf_attr_name (ATTR)); \
756 fputc ('\n', (FILE)); \
760 #ifndef ASM_OUTPUT_DWARF_STACK_OP
761 #define ASM_OUTPUT_DWARF_STACK_OP(FILE,OP) \
763 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) OP); \
764 if (flag_debug_asm) \
765 fprintf ((FILE), "\t%s %s", \
766 ASM_COMMENT_START, dwarf_stack_op_name (OP)); \
767 fputc ('\n', (FILE)); \
771 #ifndef ASM_OUTPUT_DWARF_FUND_TYPE
772 #define ASM_OUTPUT_DWARF_FUND_TYPE(FILE,FT) \
774 fprintf ((FILE), "\t%s\t0x%x", \
775 UNALIGNED_SHORT_ASM_OP, (unsigned) FT); \
776 if (flag_debug_asm) \
777 fprintf ((FILE), "\t%s %s", \
778 ASM_COMMENT_START, dwarf_fund_type_name (FT)); \
779 fputc ('\n', (FILE)); \
783 #ifndef ASM_OUTPUT_DWARF_FMT_BYTE
784 #define ASM_OUTPUT_DWARF_FMT_BYTE(FILE,FMT) \
786 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) FMT); \
787 if (flag_debug_asm) \
788 fprintf ((FILE), "\t%s %s", \
789 ASM_COMMENT_START, dwarf_fmt_byte_name (FMT)); \
790 fputc ('\n', (FILE)); \
794 #ifndef ASM_OUTPUT_DWARF_TYPE_MODIFIER
795 #define ASM_OUTPUT_DWARF_TYPE_MODIFIER(FILE,MOD) \
797 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) MOD); \
798 if (flag_debug_asm) \
799 fprintf ((FILE), "\t%s %s", \
800 ASM_COMMENT_START, dwarf_typemod_name (MOD)); \
801 fputc ('\n', (FILE)); \
805 #ifndef ASM_OUTPUT_DWARF_ADDR
806 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
807 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
808 assemble_name (FILE, LABEL); \
809 fprintf (FILE, "\n"); \
813 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
814 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX) \
816 fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
817 output_addr_const ((FILE), (RTX)); \
818 fputc ('\n', (FILE)); \
822 #ifndef ASM_OUTPUT_DWARF_REF
823 #define ASM_OUTPUT_DWARF_REF(FILE,LABEL) \
824 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
825 assemble_name (FILE, LABEL); \
826 fprintf (FILE, "\n"); \
830 #ifndef ASM_OUTPUT_DWARF_DATA1
831 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
832 fprintf ((FILE), "\t%s\t0x%x\n", ASM_BYTE_OP, VALUE)
835 #ifndef ASM_OUTPUT_DWARF_DATA2
836 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
837 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_SHORT_ASM_OP, (unsigned) VALUE)
840 #ifndef ASM_OUTPUT_DWARF_DATA4
841 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
842 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, (unsigned) VALUE)
845 #ifndef ASM_OUTPUT_DWARF_DATA8
846 #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \
848 if (WORDS_BIG_ENDIAN) \
850 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
851 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
855 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
856 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
861 /* ASM_OUTPUT_DWARF_STRING is defined to output an ascii string, but to
862 NOT issue a trailing newline. We define ASM_OUTPUT_DWARF_STRING_NEWLINE
863 based on whether ASM_OUTPUT_DWARF_STRING is defined or not. If it is
864 defined, we call it, then issue the line feed. If not, we supply a
865 default defintion of calling ASM_OUTPUT_ASCII */
867 #ifndef ASM_OUTPUT_DWARF_STRING
868 #define ASM_OUTPUT_DWARF_STRING_NEWLINE(FILE,P) \
869 ASM_OUTPUT_ASCII ((FILE), P, strlen (P)+1)
871 #define ASM_OUTPUT_DWARF_STRING_NEWLINE(FILE,P) \
872 ASM_OUTPUT_DWARF_STRING (FILE,P), ASM_OUTPUT_DWARF_STRING (FILE,"\n")
876 /************************ general utility functions **************************/
882 return (((GET_CODE (rtl
) == REG
) && (REGNO (rtl
) >= FIRST_PSEUDO_REGISTER
))
883 || ((GET_CODE (rtl
) == SUBREG
)
884 && (REGNO (XEXP (rtl
, 0)) >= FIRST_PSEUDO_REGISTER
)));
888 type_main_variant (type
)
891 type
= TYPE_MAIN_VARIANT (type
);
893 /* There really should be only one main variant among any group of variants
894 of a given type (and all of the MAIN_VARIANT values for all members of
895 the group should point to that one type) but sometimes the C front-end
896 messes this up for array types, so we work around that bug here. */
898 if (TREE_CODE (type
) == ARRAY_TYPE
)
900 while (type
!= TYPE_MAIN_VARIANT (type
))
901 type
= TYPE_MAIN_VARIANT (type
);
907 /* Return non-zero if the given type node represents a tagged type. */
910 is_tagged_type (type
)
913 register enum tree_code code
= TREE_CODE (type
);
915 return (code
== RECORD_TYPE
|| code
== UNION_TYPE
916 || code
== QUAL_UNION_TYPE
|| code
== ENUMERAL_TYPE
);
921 register unsigned tag
;
925 case TAG_padding
: return "TAG_padding";
926 case TAG_array_type
: return "TAG_array_type";
927 case TAG_class_type
: return "TAG_class_type";
928 case TAG_entry_point
: return "TAG_entry_point";
929 case TAG_enumeration_type
: return "TAG_enumeration_type";
930 case TAG_formal_parameter
: return "TAG_formal_parameter";
931 case TAG_global_subroutine
: return "TAG_global_subroutine";
932 case TAG_global_variable
: return "TAG_global_variable";
933 case TAG_label
: return "TAG_label";
934 case TAG_lexical_block
: return "TAG_lexical_block";
935 case TAG_local_variable
: return "TAG_local_variable";
936 case TAG_member
: return "TAG_member";
937 case TAG_pointer_type
: return "TAG_pointer_type";
938 case TAG_reference_type
: return "TAG_reference_type";
939 case TAG_compile_unit
: return "TAG_compile_unit";
940 case TAG_string_type
: return "TAG_string_type";
941 case TAG_structure_type
: return "TAG_structure_type";
942 case TAG_subroutine
: return "TAG_subroutine";
943 case TAG_subroutine_type
: return "TAG_subroutine_type";
944 case TAG_typedef
: return "TAG_typedef";
945 case TAG_union_type
: return "TAG_union_type";
946 case TAG_unspecified_parameters
: return "TAG_unspecified_parameters";
947 case TAG_variant
: return "TAG_variant";
948 case TAG_common_block
: return "TAG_common_block";
949 case TAG_common_inclusion
: return "TAG_common_inclusion";
950 case TAG_inheritance
: return "TAG_inheritance";
951 case TAG_inlined_subroutine
: return "TAG_inlined_subroutine";
952 case TAG_module
: return "TAG_module";
953 case TAG_ptr_to_member_type
: return "TAG_ptr_to_member_type";
954 case TAG_set_type
: return "TAG_set_type";
955 case TAG_subrange_type
: return "TAG_subrange_type";
956 case TAG_with_stmt
: return "TAG_with_stmt";
958 /* GNU extensions. */
960 case TAG_format_label
: return "TAG_format_label";
961 case TAG_namelist
: return "TAG_namelist";
962 case TAG_function_template
: return "TAG_function_template";
963 case TAG_class_template
: return "TAG_class_template";
965 default: return "TAG_<unknown>";
970 dwarf_attr_name (attr
)
971 register unsigned attr
;
975 case AT_sibling
: return "AT_sibling";
976 case AT_location
: return "AT_location";
977 case AT_name
: return "AT_name";
978 case AT_fund_type
: return "AT_fund_type";
979 case AT_mod_fund_type
: return "AT_mod_fund_type";
980 case AT_user_def_type
: return "AT_user_def_type";
981 case AT_mod_u_d_type
: return "AT_mod_u_d_type";
982 case AT_ordering
: return "AT_ordering";
983 case AT_subscr_data
: return "AT_subscr_data";
984 case AT_byte_size
: return "AT_byte_size";
985 case AT_bit_offset
: return "AT_bit_offset";
986 case AT_bit_size
: return "AT_bit_size";
987 case AT_element_list
: return "AT_element_list";
988 case AT_stmt_list
: return "AT_stmt_list";
989 case AT_low_pc
: return "AT_low_pc";
990 case AT_high_pc
: return "AT_high_pc";
991 case AT_language
: return "AT_language";
992 case AT_member
: return "AT_member";
993 case AT_discr
: return "AT_discr";
994 case AT_discr_value
: return "AT_discr_value";
995 case AT_string_length
: return "AT_string_length";
996 case AT_common_reference
: return "AT_common_reference";
997 case AT_comp_dir
: return "AT_comp_dir";
998 case AT_const_value_string
: return "AT_const_value_string";
999 case AT_const_value_data2
: return "AT_const_value_data2";
1000 case AT_const_value_data4
: return "AT_const_value_data4";
1001 case AT_const_value_data8
: return "AT_const_value_data8";
1002 case AT_const_value_block2
: return "AT_const_value_block2";
1003 case AT_const_value_block4
: return "AT_const_value_block4";
1004 case AT_containing_type
: return "AT_containing_type";
1005 case AT_default_value_addr
: return "AT_default_value_addr";
1006 case AT_default_value_data2
: return "AT_default_value_data2";
1007 case AT_default_value_data4
: return "AT_default_value_data4";
1008 case AT_default_value_data8
: return "AT_default_value_data8";
1009 case AT_default_value_string
: return "AT_default_value_string";
1010 case AT_friends
: return "AT_friends";
1011 case AT_inline
: return "AT_inline";
1012 case AT_is_optional
: return "AT_is_optional";
1013 case AT_lower_bound_ref
: return "AT_lower_bound_ref";
1014 case AT_lower_bound_data2
: return "AT_lower_bound_data2";
1015 case AT_lower_bound_data4
: return "AT_lower_bound_data4";
1016 case AT_lower_bound_data8
: return "AT_lower_bound_data8";
1017 case AT_private
: return "AT_private";
1018 case AT_producer
: return "AT_producer";
1019 case AT_program
: return "AT_program";
1020 case AT_protected
: return "AT_protected";
1021 case AT_prototyped
: return "AT_prototyped";
1022 case AT_public
: return "AT_public";
1023 case AT_pure_virtual
: return "AT_pure_virtual";
1024 case AT_return_addr
: return "AT_return_addr";
1025 case AT_abstract_origin
: return "AT_abstract_origin";
1026 case AT_start_scope
: return "AT_start_scope";
1027 case AT_stride_size
: return "AT_stride_size";
1028 case AT_upper_bound_ref
: return "AT_upper_bound_ref";
1029 case AT_upper_bound_data2
: return "AT_upper_bound_data2";
1030 case AT_upper_bound_data4
: return "AT_upper_bound_data4";
1031 case AT_upper_bound_data8
: return "AT_upper_bound_data8";
1032 case AT_virtual
: return "AT_virtual";
1034 /* GNU extensions */
1036 case AT_sf_names
: return "AT_sf_names";
1037 case AT_src_info
: return "AT_src_info";
1038 case AT_mac_info
: return "AT_mac_info";
1039 case AT_src_coords
: return "AT_src_coords";
1040 case AT_body_begin
: return "AT_body_begin";
1041 case AT_body_end
: return "AT_body_end";
1043 default: return "AT_<unknown>";
1048 dwarf_stack_op_name (op
)
1049 register unsigned op
;
1053 case OP_REG
: return "OP_REG";
1054 case OP_BASEREG
: return "OP_BASEREG";
1055 case OP_ADDR
: return "OP_ADDR";
1056 case OP_CONST
: return "OP_CONST";
1057 case OP_DEREF2
: return "OP_DEREF2";
1058 case OP_DEREF4
: return "OP_DEREF4";
1059 case OP_ADD
: return "OP_ADD";
1060 default: return "OP_<unknown>";
1065 dwarf_typemod_name (mod
)
1066 register unsigned mod
;
1070 case MOD_pointer_to
: return "MOD_pointer_to";
1071 case MOD_reference_to
: return "MOD_reference_to";
1072 case MOD_const
: return "MOD_const";
1073 case MOD_volatile
: return "MOD_volatile";
1074 default: return "MOD_<unknown>";
1079 dwarf_fmt_byte_name (fmt
)
1080 register unsigned fmt
;
1084 case FMT_FT_C_C
: return "FMT_FT_C_C";
1085 case FMT_FT_C_X
: return "FMT_FT_C_X";
1086 case FMT_FT_X_C
: return "FMT_FT_X_C";
1087 case FMT_FT_X_X
: return "FMT_FT_X_X";
1088 case FMT_UT_C_C
: return "FMT_UT_C_C";
1089 case FMT_UT_C_X
: return "FMT_UT_C_X";
1090 case FMT_UT_X_C
: return "FMT_UT_X_C";
1091 case FMT_UT_X_X
: return "FMT_UT_X_X";
1092 case FMT_ET
: return "FMT_ET";
1093 default: return "FMT_<unknown>";
1098 dwarf_fund_type_name (ft
)
1099 register unsigned ft
;
1103 case FT_char
: return "FT_char";
1104 case FT_signed_char
: return "FT_signed_char";
1105 case FT_unsigned_char
: return "FT_unsigned_char";
1106 case FT_short
: return "FT_short";
1107 case FT_signed_short
: return "FT_signed_short";
1108 case FT_unsigned_short
: return "FT_unsigned_short";
1109 case FT_integer
: return "FT_integer";
1110 case FT_signed_integer
: return "FT_signed_integer";
1111 case FT_unsigned_integer
: return "FT_unsigned_integer";
1112 case FT_long
: return "FT_long";
1113 case FT_signed_long
: return "FT_signed_long";
1114 case FT_unsigned_long
: return "FT_unsigned_long";
1115 case FT_pointer
: return "FT_pointer";
1116 case FT_float
: return "FT_float";
1117 case FT_dbl_prec_float
: return "FT_dbl_prec_float";
1118 case FT_ext_prec_float
: return "FT_ext_prec_float";
1119 case FT_complex
: return "FT_complex";
1120 case FT_dbl_prec_complex
: return "FT_dbl_prec_complex";
1121 case FT_void
: return "FT_void";
1122 case FT_boolean
: return "FT_boolean";
1123 case FT_ext_prec_complex
: return "FT_ext_prec_complex";
1124 case FT_label
: return "FT_label";
1126 /* GNU extensions. */
1128 case FT_long_long
: return "FT_long_long";
1129 case FT_signed_long_long
: return "FT_signed_long_long";
1130 case FT_unsigned_long_long
: return "FT_unsigned_long_long";
1132 case FT_int8
: return "FT_int8";
1133 case FT_signed_int8
: return "FT_signed_int8";
1134 case FT_unsigned_int8
: return "FT_unsigned_int8";
1135 case FT_int16
: return "FT_int16";
1136 case FT_signed_int16
: return "FT_signed_int16";
1137 case FT_unsigned_int16
: return "FT_unsigned_int16";
1138 case FT_int32
: return "FT_int32";
1139 case FT_signed_int32
: return "FT_signed_int32";
1140 case FT_unsigned_int32
: return "FT_unsigned_int32";
1141 case FT_int64
: return "FT_int64";
1142 case FT_signed_int64
: return "FT_signed_int64";
1143 case FT_unsigned_int64
: return "FT_unsigned_int64";
1145 case FT_real32
: return "FT_real32";
1146 case FT_real64
: return "FT_real64";
1147 case FT_real96
: return "FT_real96";
1148 case FT_real128
: return "FT_real128";
1150 default: return "FT_<unknown>";
1154 /* Determine the "ultimate origin" of a decl. The decl may be an
1155 inlined instance of an inlined instance of a decl which is local
1156 to an inline function, so we have to trace all of the way back
1157 through the origin chain to find out what sort of node actually
1158 served as the original seed for the given block. */
1161 decl_ultimate_origin (decl
)
1164 #ifdef ENABLE_CHECKING
1165 if (DECL_FROM_INLINE (DECL_ORIGIN (decl
)))
1166 /* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
1167 most distant ancestor, this should never happen. */
1171 return DECL_ABSTRACT_ORIGIN (decl
);
1174 /* Determine the "ultimate origin" of a block. The block may be an
1175 inlined instance of an inlined instance of a block which is local
1176 to an inline function, so we have to trace all of the way back
1177 through the origin chain to find out what sort of node actually
1178 served as the original seed for the given block. */
1181 block_ultimate_origin (block
)
1182 register tree block
;
1184 register tree immediate_origin
= BLOCK_ABSTRACT_ORIGIN (block
);
1186 if (immediate_origin
== NULL
)
1190 register tree ret_val
;
1191 register tree lookahead
= immediate_origin
;
1195 ret_val
= lookahead
;
1196 lookahead
= (TREE_CODE (ret_val
) == BLOCK
)
1197 ? BLOCK_ABSTRACT_ORIGIN (ret_val
)
1200 while (lookahead
!= NULL
&& lookahead
!= ret_val
);
1205 /* Get the class to which DECL belongs, if any. In g++, the DECL_CONTEXT
1206 of a virtual function may refer to a base class, so we check the 'this'
1210 decl_class_context (decl
)
1213 tree context
= NULL_TREE
;
1214 if (TREE_CODE (decl
) != FUNCTION_DECL
|| ! DECL_VINDEX (decl
))
1215 context
= DECL_CONTEXT (decl
);
1217 context
= TYPE_MAIN_VARIANT
1218 (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)))));
1220 if (context
&& !TYPE_P (context
))
1221 context
= NULL_TREE
;
1228 output_unsigned_leb128 (value
)
1229 register unsigned long value
;
1231 register unsigned long orig_value
= value
;
1235 register unsigned byte
= (value
& 0x7f);
1238 if (value
!= 0) /* more bytes to follow */
1240 fprintf (asm_out_file
, "\t%s\t0x%x", ASM_BYTE_OP
, (unsigned) byte
);
1241 if (flag_debug_asm
&& value
== 0)
1242 fprintf (asm_out_file
, "\t%s ULEB128 number - value = %lu",
1243 ASM_COMMENT_START
, orig_value
);
1244 fputc ('\n', asm_out_file
);
1250 output_signed_leb128 (value
)
1251 register long value
;
1253 register long orig_value
= value
;
1254 register int negative
= (value
< 0);
1259 register unsigned byte
= (value
& 0x7f);
1263 value
|= 0xfe000000; /* manually sign extend */
1264 if (((value
== 0) && ((byte
& 0x40) == 0))
1265 || ((value
== -1) && ((byte
& 0x40) == 1)))
1272 fprintf (asm_out_file
, "\t%s\t0x%x", ASM_BYTE_OP
, (unsigned) byte
);
1273 if (flag_debug_asm
&& more
== 0)
1274 fprintf (asm_out_file
, "\t%s SLEB128 number - value = %ld",
1275 ASM_COMMENT_START
, orig_value
);
1276 fputc ('\n', asm_out_file
);
1282 /**************** utility functions for attribute functions ******************/
1284 /* Given a pointer to a tree node for some type, return a Dwarf fundamental
1285 type code for the given type.
1287 This routine must only be called for GCC type nodes that correspond to
1288 Dwarf fundamental types.
1290 The current Dwarf draft specification calls for Dwarf fundamental types
1291 to accurately reflect the fact that a given type was either a "plain"
1292 integral type or an explicitly "signed" integral type. Unfortunately,
1293 we can't always do this, because GCC may already have thrown away the
1294 information about the precise way in which the type was originally
1297 typedef signed int my_type;
1299 struct s { my_type f; };
1301 Since we may be stuck here without enought information to do exactly
1302 what is called for in the Dwarf draft specification, we do the best
1303 that we can under the circumstances and always use the "plain" integral
1304 fundamental type codes for int, short, and long types. That's probably
1305 good enough. The additional accuracy called for in the current DWARF
1306 draft specification is probably never even useful in practice. */
1309 fundamental_type_code (type
)
1312 if (TREE_CODE (type
) == ERROR_MARK
)
1315 switch (TREE_CODE (type
))
1324 /* Carefully distinguish all the standard types of C,
1325 without messing up if the language is not C.
1326 Note that we check only for the names that contain spaces;
1327 other names might occur by coincidence in other languages. */
1328 if (TYPE_NAME (type
) != 0
1329 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1330 && DECL_NAME (TYPE_NAME (type
)) != 0
1331 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
1334 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
1336 if (!strcmp (name
, "unsigned char"))
1337 return FT_unsigned_char
;
1338 if (!strcmp (name
, "signed char"))
1339 return FT_signed_char
;
1340 if (!strcmp (name
, "unsigned int"))
1341 return FT_unsigned_integer
;
1342 if (!strcmp (name
, "short int"))
1344 if (!strcmp (name
, "short unsigned int"))
1345 return FT_unsigned_short
;
1346 if (!strcmp (name
, "long int"))
1348 if (!strcmp (name
, "long unsigned int"))
1349 return FT_unsigned_long
;
1350 if (!strcmp (name
, "long long int"))
1351 return FT_long_long
; /* Not grok'ed by svr4 SDB */
1352 if (!strcmp (name
, "long long unsigned int"))
1353 return FT_unsigned_long_long
; /* Not grok'ed by svr4 SDB */
1356 /* Most integer types will be sorted out above, however, for the
1357 sake of special `array index' integer types, the following code
1358 is also provided. */
1360 if (TYPE_PRECISION (type
) == INT_TYPE_SIZE
)
1361 return (TREE_UNSIGNED (type
) ? FT_unsigned_integer
: FT_integer
);
1363 if (TYPE_PRECISION (type
) == LONG_TYPE_SIZE
)
1364 return (TREE_UNSIGNED (type
) ? FT_unsigned_long
: FT_long
);
1366 if (TYPE_PRECISION (type
) == LONG_LONG_TYPE_SIZE
)
1367 return (TREE_UNSIGNED (type
) ? FT_unsigned_long_long
: FT_long_long
);
1369 if (TYPE_PRECISION (type
) == SHORT_TYPE_SIZE
)
1370 return (TREE_UNSIGNED (type
) ? FT_unsigned_short
: FT_short
);
1372 if (TYPE_PRECISION (type
) == CHAR_TYPE_SIZE
)
1373 return (TREE_UNSIGNED (type
) ? FT_unsigned_char
: FT_char
);
1375 /* In C++, __java_boolean is an INTEGER_TYPE with precision == 1 */
1376 if (TYPE_PRECISION (type
) == 1)
1382 /* Carefully distinguish all the standard types of C,
1383 without messing up if the language is not C. */
1384 if (TYPE_NAME (type
) != 0
1385 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1386 && DECL_NAME (TYPE_NAME (type
)) != 0
1387 && TREE_CODE (DECL_NAME (TYPE_NAME (type
))) == IDENTIFIER_NODE
)
1390 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type
)));
1392 /* Note that here we can run afowl of a serious bug in "classic"
1393 svr4 SDB debuggers. They don't seem to understand the
1394 FT_ext_prec_float type (even though they should). */
1396 if (!strcmp (name
, "long double"))
1397 return FT_ext_prec_float
;
1400 if (TYPE_PRECISION (type
) == DOUBLE_TYPE_SIZE
)
1402 /* On the SH, when compiling with -m3e or -m4-single-only, both
1403 float and double are 32 bits. But since the debugger doesn't
1404 know about the subtarget, it always thinks double is 64 bits.
1405 So we have to tell the debugger that the type is float to
1406 make the output of the 'print' command etc. readable. */
1407 if (DOUBLE_TYPE_SIZE
== FLOAT_TYPE_SIZE
&& FLOAT_TYPE_SIZE
== 32)
1409 return FT_dbl_prec_float
;
1411 if (TYPE_PRECISION (type
) == FLOAT_TYPE_SIZE
)
1414 /* Note that here we can run afowl of a serious bug in "classic"
1415 svr4 SDB debuggers. They don't seem to understand the
1416 FT_ext_prec_float type (even though they should). */
1418 if (TYPE_PRECISION (type
) == LONG_DOUBLE_TYPE_SIZE
)
1419 return FT_ext_prec_float
;
1423 return FT_complex
; /* GNU FORTRAN COMPLEX type. */
1426 return FT_char
; /* GNU Pascal CHAR type. Not used in C. */
1429 return FT_boolean
; /* GNU FORTRAN BOOLEAN type. */
1432 abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
1437 /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
1438 the Dwarf "root" type for the given input type. The Dwarf "root" type
1439 of a given type is generally the same as the given type, except that if
1440 the given type is a pointer or reference type, then the root type of
1441 the given type is the root type of the "basis" type for the pointer or
1442 reference type. (This definition of the "root" type is recursive.)
1443 Also, the root type of a `const' qualified type or a `volatile'
1444 qualified type is the root type of the given type without the
1448 root_type_1 (type
, count
)
1452 /* Give up after searching 1000 levels, in case this is a recursive
1453 pointer type. Such types are possible in Ada, but it is not possible
1454 to represent them in DWARF1 debug info. */
1456 return error_mark_node
;
1458 switch (TREE_CODE (type
))
1461 return error_mark_node
;
1464 case REFERENCE_TYPE
:
1465 return root_type_1 (TREE_TYPE (type
), count
+1);
1476 type
= root_type_1 (type
, 0);
1477 if (type
!= error_mark_node
)
1478 type
= type_main_variant (type
);
1482 /* Given a pointer to an arbitrary ..._TYPE tree node, write out a sequence
1483 of zero or more Dwarf "type-modifier" bytes applicable to the type. */
1486 write_modifier_bytes_1 (type
, decl_const
, decl_volatile
, count
)
1488 register int decl_const
;
1489 register int decl_volatile
;
1492 if (TREE_CODE (type
) == ERROR_MARK
)
1495 /* Give up after searching 1000 levels, in case this is a recursive
1496 pointer type. Such types are possible in Ada, but it is not possible
1497 to represent them in DWARF1 debug info. */
1501 if (TYPE_READONLY (type
) || decl_const
)
1502 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file
, MOD_const
);
1503 if (TYPE_VOLATILE (type
) || decl_volatile
)
1504 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file
, MOD_volatile
);
1505 switch (TREE_CODE (type
))
1508 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file
, MOD_pointer_to
);
1509 write_modifier_bytes_1 (TREE_TYPE (type
), 0, 0, count
+1);
1512 case REFERENCE_TYPE
:
1513 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file
, MOD_reference_to
);
1514 write_modifier_bytes_1 (TREE_TYPE (type
), 0, 0, count
+1);
1524 write_modifier_bytes (type
, decl_const
, decl_volatile
)
1526 register int decl_const
;
1527 register int decl_volatile
;
1529 write_modifier_bytes_1 (type
, decl_const
, decl_volatile
, 0);
1532 /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
1533 given input type is a Dwarf "fundamental" type. Otherwise return zero. */
1536 type_is_fundamental (type
)
1539 switch (TREE_CODE (type
))
1554 case QUAL_UNION_TYPE
:
1559 case REFERENCE_TYPE
:
1571 /* Given a pointer to some ..._DECL tree node, generate an assembly language
1572 equate directive which will associate a symbolic name with the current DIE.
1574 The name used is an artificial label generated from the DECL_UID number
1575 associated with the given decl node. The name it gets equated to is the
1576 symbolic label that we (previously) output at the start of the DIE that
1577 we are currently generating.
1579 Calling this function while generating some "decl related" form of DIE
1580 makes it possible to later refer to the DIE which represents the given
1581 decl simply by re-generating the symbolic name from the ..._DECL node's
1585 equate_decl_number_to_die_number (decl
)
1588 /* In the case where we are generating a DIE for some ..._DECL node
1589 which represents either some inline function declaration or some
1590 entity declared within an inline function declaration/definition,
1591 setup a symbolic name for the current DIE so that we have a name
1592 for this DIE that we can easily refer to later on within
1593 AT_abstract_origin attributes. */
1595 char decl_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1596 char die_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1598 sprintf (decl_label
, DECL_NAME_FMT
, DECL_UID (decl
));
1599 sprintf (die_label
, DIE_BEGIN_LABEL_FMT
, current_dienum
);
1600 ASM_OUTPUT_DEF (asm_out_file
, decl_label
, die_label
);
1603 /* Given a pointer to some ..._TYPE tree node, generate an assembly language
1604 equate directive which will associate a symbolic name with the current DIE.
1606 The name used is an artificial label generated from the TYPE_UID number
1607 associated with the given type node. The name it gets equated to is the
1608 symbolic label that we (previously) output at the start of the DIE that
1609 we are currently generating.
1611 Calling this function while generating some "type related" form of DIE
1612 makes it easy to later refer to the DIE which represents the given type
1613 simply by re-generating the alternative name from the ..._TYPE node's
1617 equate_type_number_to_die_number (type
)
1620 char type_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1621 char die_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1623 /* We are generating a DIE to represent the main variant of this type
1624 (i.e the type without any const or volatile qualifiers) so in order
1625 to get the equate to come out right, we need to get the main variant
1628 type
= type_main_variant (type
);
1630 sprintf (type_label
, TYPE_NAME_FMT
, TYPE_UID (type
));
1631 sprintf (die_label
, DIE_BEGIN_LABEL_FMT
, current_dienum
);
1632 ASM_OUTPUT_DEF (asm_out_file
, type_label
, die_label
);
1636 output_reg_number (rtl
)
1639 register unsigned regno
= REGNO (rtl
);
1641 if (regno
>= DWARF_FRAME_REGISTERS
)
1643 warning_with_decl (dwarf_last_decl
, "internal regno botch: regno = %d\n",
1647 fprintf (asm_out_file
, "\t%s\t0x%x",
1648 UNALIGNED_INT_ASM_OP
, DBX_REGISTER_NUMBER (regno
));
1651 fprintf (asm_out_file
, "\t%s ", ASM_COMMENT_START
);
1652 PRINT_REG (rtl
, 0, asm_out_file
);
1654 fputc ('\n', asm_out_file
);
1657 /* The following routine is a nice and simple transducer. It converts the
1658 RTL for a variable or parameter (resident in memory) into an equivalent
1659 Dwarf representation of a mechanism for getting the address of that same
1660 variable onto the top of a hypothetical "address evaluation" stack.
1662 When creating memory location descriptors, we are effectively trans-
1663 forming the RTL for a memory-resident object into its Dwarf postfix
1664 expression equivalent. This routine just recursively descends an
1665 RTL tree, turning it into Dwarf postfix code as it goes. */
1668 output_mem_loc_descriptor (rtl
)
1671 /* Note that for a dynamically sized array, the location we will
1672 generate a description of here will be the lowest numbered location
1673 which is actually within the array. That's *not* necessarily the
1674 same as the zeroth element of the array. */
1676 #ifdef ASM_SIMPLIFY_DWARF_ADDR
1677 rtl
= ASM_SIMPLIFY_DWARF_ADDR (rtl
);
1680 switch (GET_CODE (rtl
))
1684 /* The case of a subreg may arise when we have a local (register)
1685 variable or a formal (register) parameter which doesn't quite
1686 fill up an entire register. For now, just assume that it is
1687 legitimate to make the Dwarf info refer to the whole register
1688 which contains the given subreg. */
1690 rtl
= XEXP (rtl
, 0);
1695 /* Whenever a register number forms a part of the description of
1696 the method for calculating the (dynamic) address of a memory
1697 resident object, DWARF rules require the register number to
1698 be referred to as a "base register". This distinction is not
1699 based in any way upon what category of register the hardware
1700 believes the given register belongs to. This is strictly
1701 DWARF terminology we're dealing with here.
1703 Note that in cases where the location of a memory-resident data
1704 object could be expressed as:
1706 OP_ADD (OP_BASEREG (basereg), OP_CONST (0))
1708 the actual DWARF location descriptor that we generate may just
1709 be OP_BASEREG (basereg). This may look deceptively like the
1710 object in question was allocated to a register (rather than
1711 in memory) so DWARF consumers need to be aware of the subtle
1712 distinction between OP_REG and OP_BASEREG. */
1714 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_BASEREG
);
1715 output_reg_number (rtl
);
1719 output_mem_loc_descriptor (XEXP (rtl
, 0));
1720 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_DEREF4
);
1725 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_ADDR
);
1726 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file
, rtl
);
1730 output_mem_loc_descriptor (XEXP (rtl
, 0));
1731 output_mem_loc_descriptor (XEXP (rtl
, 1));
1732 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_ADD
);
1736 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_CONST
);
1737 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, INTVAL (rtl
));
1741 /* If a pseudo-reg is optimized away, it is possible for it to
1742 be replaced with a MEM containing a multiply. Use a GNU extension
1744 output_mem_loc_descriptor (XEXP (rtl
, 0));
1745 output_mem_loc_descriptor (XEXP (rtl
, 1));
1746 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_MULT
);
1754 /* Output a proper Dwarf location descriptor for a variable or parameter
1755 which is either allocated in a register or in a memory location. For
1756 a register, we just generate an OP_REG and the register number. For a
1757 memory location we provide a Dwarf postfix expression describing how to
1758 generate the (dynamic) address of the object onto the address stack. */
1761 output_loc_descriptor (rtl
)
1764 switch (GET_CODE (rtl
))
1768 /* The case of a subreg may arise when we have a local (register)
1769 variable or a formal (register) parameter which doesn't quite
1770 fill up an entire register. For now, just assume that it is
1771 legitimate to make the Dwarf info refer to the whole register
1772 which contains the given subreg. */
1774 rtl
= XEXP (rtl
, 0);
1778 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_REG
);
1779 output_reg_number (rtl
);
1783 output_mem_loc_descriptor (XEXP (rtl
, 0));
1787 abort (); /* Should never happen */
1791 /* Given a tree node describing an array bound (either lower or upper)
1792 output a representation for that bound. */
1795 output_bound_representation (bound
, dim_num
, u_or_l
)
1796 register tree bound
;
1797 register unsigned dim_num
; /* For multi-dimensional arrays. */
1798 register char u_or_l
; /* Designates upper or lower bound. */
1800 switch (TREE_CODE (bound
))
1806 /* All fixed-bounds are represented by INTEGER_CST nodes. */
1809 if (host_integerp (bound
, 0))
1810 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, tree_low_cst (bound
, 0));
1815 /* Dynamic bounds may be represented by NOP_EXPR nodes containing
1816 SAVE_EXPR nodes, in which case we can do something, or as
1817 an expression, which we cannot represent. */
1819 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1820 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1822 sprintf (begin_label
, BOUND_BEGIN_LABEL_FMT
,
1823 current_dienum
, dim_num
, u_or_l
);
1825 sprintf (end_label
, BOUND_END_LABEL_FMT
,
1826 current_dienum
, dim_num
, u_or_l
);
1828 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
1829 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
1831 /* If optimization is turned on, the SAVE_EXPRs that describe
1832 how to access the upper bound values are essentially bogus.
1833 They only describe (at best) how to get at these values at
1834 the points in the generated code right after they have just
1835 been computed. Worse yet, in the typical case, the upper
1836 bound values will not even *be* computed in the optimized
1837 code, so these SAVE_EXPRs are entirely bogus.
1839 In order to compensate for this fact, we check here to see
1840 if optimization is enabled, and if so, we effectively create
1841 an empty location description for the (unknown and unknowable)
1844 This should not cause too much trouble for existing (stupid?)
1845 debuggers because they have to deal with empty upper bounds
1846 location descriptions anyway in order to be able to deal with
1847 incomplete array types.
1849 Of course an intelligent debugger (GDB?) should be able to
1850 comprehend that a missing upper bound specification in a
1851 array type used for a storage class `auto' local array variable
1852 indicates that the upper bound is both unknown (at compile-
1853 time) and unknowable (at run-time) due to optimization. */
1857 while (TREE_CODE (bound
) == NOP_EXPR
1858 || TREE_CODE (bound
) == CONVERT_EXPR
)
1859 bound
= TREE_OPERAND (bound
, 0);
1861 if (TREE_CODE (bound
) == SAVE_EXPR
)
1862 output_loc_descriptor
1863 (eliminate_regs (SAVE_EXPR_RTL (bound
), 0, NULL_RTX
));
1866 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
1873 /* Recursive function to output a sequence of value/name pairs for
1874 enumeration constants in reversed order. This is called from
1875 enumeration_type_die. */
1878 output_enumeral_list (link
)
1883 output_enumeral_list (TREE_CHAIN (link
));
1885 if (host_integerp (TREE_VALUE (link
), 0))
1886 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
1887 tree_low_cst (TREE_VALUE (link
), 0));
1889 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
,
1890 IDENTIFIER_POINTER (TREE_PURPOSE (link
)));
1894 /* Given an unsigned value, round it up to the lowest multiple of `boundary'
1895 which is not less than the value itself. */
1897 static inline HOST_WIDE_INT
1898 ceiling (value
, boundary
)
1899 register HOST_WIDE_INT value
;
1900 register unsigned int boundary
;
1902 return (((value
+ boundary
- 1) / boundary
) * boundary
);
1905 /* Given a pointer to what is assumed to be a FIELD_DECL node, return a
1906 pointer to the declared type for the relevant field variable, or return
1907 `integer_type_node' if the given node turns out to be an ERROR_MARK node. */
1915 if (TREE_CODE (decl
) == ERROR_MARK
)
1916 return integer_type_node
;
1918 type
= DECL_BIT_FIELD_TYPE (decl
);
1920 type
= TREE_TYPE (decl
);
1924 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
1925 node, return the alignment in bits for the type, or else return
1926 BITS_PER_WORD if the node actually turns out to be an ERROR_MARK node. */
1928 static inline unsigned int
1929 simple_type_align_in_bits (type
)
1932 return (TREE_CODE (type
) != ERROR_MARK
) ? TYPE_ALIGN (type
) : BITS_PER_WORD
;
1935 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
1936 node, return the size in bits for the type if it is a constant, or
1937 else return the alignment for the type if the type's size is not
1938 constant, or else return BITS_PER_WORD if the type actually turns out
1939 to be an ERROR_MARK node. */
1941 static inline unsigned HOST_WIDE_INT
1942 simple_type_size_in_bits (type
)
1945 if (TREE_CODE (type
) == ERROR_MARK
)
1946 return BITS_PER_WORD
;
1949 register tree type_size_tree
= TYPE_SIZE (type
);
1951 if (! host_integerp (type_size_tree
, 1))
1952 return TYPE_ALIGN (type
);
1954 return tree_low_cst (type_size_tree
, 1);
1958 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
1959 return the byte offset of the lowest addressed byte of the "containing
1960 object" for the given FIELD_DECL, or return 0 if we are unable to deter-
1961 mine what that offset is, either because the argument turns out to be a
1962 pointer to an ERROR_MARK node, or because the offset is actually variable.
1963 (We can't handle the latter case just yet.) */
1965 static HOST_WIDE_INT
1966 field_byte_offset (decl
)
1969 unsigned int type_align_in_bytes
;
1970 unsigned int type_align_in_bits
;
1971 unsigned HOST_WIDE_INT type_size_in_bits
;
1972 HOST_WIDE_INT object_offset_in_align_units
;
1973 HOST_WIDE_INT object_offset_in_bits
;
1974 HOST_WIDE_INT object_offset_in_bytes
;
1976 tree field_size_tree
;
1977 HOST_WIDE_INT bitpos_int
;
1978 HOST_WIDE_INT deepest_bitpos
;
1979 unsigned HOST_WIDE_INT field_size_in_bits
;
1981 if (TREE_CODE (decl
) == ERROR_MARK
)
1984 if (TREE_CODE (decl
) != FIELD_DECL
)
1987 type
= field_type (decl
);
1988 field_size_tree
= DECL_SIZE (decl
);
1990 /* If there was an error, the size could be zero. */
1991 if (! field_size_tree
)
1999 /* We cannot yet cope with fields whose positions or sizes are variable,
2000 so for now, when we see such things, we simply return 0. Someday,
2001 we may be able to handle such cases, but it will be damn difficult. */
2003 if (! host_integerp (bit_position (decl
), 0)
2004 || ! host_integerp (field_size_tree
, 1))
2007 bitpos_int
= int_bit_position (decl
);
2008 field_size_in_bits
= tree_low_cst (field_size_tree
, 1);
2010 type_size_in_bits
= simple_type_size_in_bits (type
);
2011 type_align_in_bits
= simple_type_align_in_bits (type
);
2012 type_align_in_bytes
= type_align_in_bits
/ BITS_PER_UNIT
;
2014 /* Note that the GCC front-end doesn't make any attempt to keep track
2015 of the starting bit offset (relative to the start of the containing
2016 structure type) of the hypothetical "containing object" for a bit-
2017 field. Thus, when computing the byte offset value for the start of
2018 the "containing object" of a bit-field, we must deduce this infor-
2021 This can be rather tricky to do in some cases. For example, handling
2022 the following structure type definition when compiling for an i386/i486
2023 target (which only aligns long long's to 32-bit boundaries) can be very
2028 long long field2:31;
2031 Fortunately, there is a simple rule-of-thumb which can be used in such
2032 cases. When compiling for an i386/i486, GCC will allocate 8 bytes for
2033 the structure shown above. It decides to do this based upon one simple
2034 rule for bit-field allocation. Quite simply, GCC allocates each "con-
2035 taining object" for each bit-field at the first (i.e. lowest addressed)
2036 legitimate alignment boundary (based upon the required minimum alignment
2037 for the declared type of the field) which it can possibly use, subject
2038 to the condition that there is still enough available space remaining
2039 in the containing object (when allocated at the selected point) to
2040 fully accommodate all of the bits of the bit-field itself.
2042 This simple rule makes it obvious why GCC allocates 8 bytes for each
2043 object of the structure type shown above. When looking for a place to
2044 allocate the "containing object" for `field2', the compiler simply tries
2045 to allocate a 64-bit "containing object" at each successive 32-bit
2046 boundary (starting at zero) until it finds a place to allocate that 64-
2047 bit field such that at least 31 contiguous (and previously unallocated)
2048 bits remain within that selected 64 bit field. (As it turns out, for
2049 the example above, the compiler finds that it is OK to allocate the
2050 "containing object" 64-bit field at bit-offset zero within the
2053 Here we attempt to work backwards from the limited set of facts we're
2054 given, and we try to deduce from those facts, where GCC must have
2055 believed that the containing object started (within the structure type).
2057 The value we deduce is then used (by the callers of this routine) to
2058 generate AT_location and AT_bit_offset attributes for fields (both
2059 bit-fields and, in the case of AT_location, regular fields as well). */
2061 /* Figure out the bit-distance from the start of the structure to the
2062 "deepest" bit of the bit-field. */
2063 deepest_bitpos
= bitpos_int
+ field_size_in_bits
;
2065 /* This is the tricky part. Use some fancy footwork to deduce where the
2066 lowest addressed bit of the containing object must be. */
2067 object_offset_in_bits
2068 = ceiling (deepest_bitpos
, type_align_in_bits
) - type_size_in_bits
;
2070 /* Compute the offset of the containing object in "alignment units". */
2071 object_offset_in_align_units
= object_offset_in_bits
/ type_align_in_bits
;
2073 /* Compute the offset of the containing object in bytes. */
2074 object_offset_in_bytes
= object_offset_in_align_units
* type_align_in_bytes
;
2076 /* The above code assumes that the field does not cross an alignment
2077 boundary. This can happen if PCC_BITFIELD_TYPE_MATTERS is not defined,
2078 or if the structure is packed. If this happens, then we get an object
2079 which starts after the bitfield, which means that the bit offset is
2080 negative. Gdb fails when given negative bit offsets. We avoid this
2081 by recomputing using the first bit of the bitfield. This will give
2082 us an object which does not completely contain the bitfield, but it
2083 will be aligned, and it will contain the first bit of the bitfield.
2085 However, only do this for a BYTES_BIG_ENDIAN target. For a
2086 ! BYTES_BIG_ENDIAN target, bitpos_int + field_size_in_bits is the first
2087 first bit of the bitfield. If we recompute using bitpos_int + 1 below,
2088 then we end up computing the object byte offset for the wrong word of the
2089 desired bitfield, which in turn causes the field offset to be negative
2090 in bit_offset_attribute. */
2091 if (BYTES_BIG_ENDIAN
2092 && object_offset_in_bits
> bitpos_int
)
2094 deepest_bitpos
= bitpos_int
+ 1;
2095 object_offset_in_bits
2096 = ceiling (deepest_bitpos
, type_align_in_bits
) - type_size_in_bits
;
2097 object_offset_in_align_units
= (object_offset_in_bits
2098 / type_align_in_bits
);
2099 object_offset_in_bytes
= (object_offset_in_align_units
2100 * type_align_in_bytes
);
2103 return object_offset_in_bytes
;
2106 /****************************** attributes *********************************/
2108 /* The following routines are responsible for writing out the various types
2109 of Dwarf attributes (and any following data bytes associated with them).
2110 These routines are listed in order based on the numerical codes of their
2111 associated attributes. */
2113 /* Generate an AT_sibling attribute. */
2116 sibling_attribute ()
2118 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2120 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_sibling
);
2121 sprintf (label
, DIE_BEGIN_LABEL_FMT
, NEXT_DIE_NUM
);
2122 ASM_OUTPUT_DWARF_REF (asm_out_file
, label
);
2125 /* Output the form of location attributes suitable for whole variables and
2126 whole parameters. Note that the location attributes for struct fields
2127 are generated by the routine `data_member_location_attribute' below. */
2130 location_attribute (rtl
)
2133 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2134 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2136 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_location
);
2137 sprintf (begin_label
, LOC_BEGIN_LABEL_FMT
, current_dienum
);
2138 sprintf (end_label
, LOC_END_LABEL_FMT
, current_dienum
);
2139 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
2140 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2142 /* Handle a special case. If we are about to output a location descriptor
2143 for a variable or parameter which has been optimized out of existence,
2144 don't do that. Instead we output a zero-length location descriptor
2145 value as part of the location attribute.
2147 A variable which has been optimized out of existence will have a
2148 DECL_RTL value which denotes a pseudo-reg.
2150 Currently, in some rare cases, variables can have DECL_RTL values
2151 which look like (MEM (REG pseudo-reg#)). These cases are due to
2152 bugs elsewhere in the compiler. We treat such cases
2153 as if the variable(s) in question had been optimized out of existence.
2155 Note that in all cases where we wish to express the fact that a
2156 variable has been optimized out of existence, we do not simply
2157 suppress the generation of the entire location attribute because
2158 the absence of a location attribute in certain kinds of DIEs is
2159 used to indicate something else entirely... i.e. that the DIE
2160 represents an object declaration, but not a definition. So saith
2164 if (! is_pseudo_reg (rtl
)
2165 && (GET_CODE (rtl
) != MEM
|| ! is_pseudo_reg (XEXP (rtl
, 0))))
2166 output_loc_descriptor (rtl
);
2168 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2171 /* Output the specialized form of location attribute used for data members
2172 of struct and union types.
2174 In the special case of a FIELD_DECL node which represents a bit-field,
2175 the "offset" part of this special location descriptor must indicate the
2176 distance in bytes from the lowest-addressed byte of the containing
2177 struct or union type to the lowest-addressed byte of the "containing
2178 object" for the bit-field. (See the `field_byte_offset' function above.)
2180 For any given bit-field, the "containing object" is a hypothetical
2181 object (of some integral or enum type) within which the given bit-field
2182 lives. The type of this hypothetical "containing object" is always the
2183 same as the declared type of the individual bit-field itself (for GCC
2184 anyway... the DWARF spec doesn't actually mandate this).
2186 Note that it is the size (in bytes) of the hypothetical "containing
2187 object" which will be given in the AT_byte_size attribute for this
2188 bit-field. (See the `byte_size_attribute' function below.) It is
2189 also used when calculating the value of the AT_bit_offset attribute.
2190 (See the `bit_offset_attribute' function below.) */
2193 data_member_location_attribute (t
)
2196 register unsigned object_offset_in_bytes
;
2197 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2198 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2200 if (TREE_CODE (t
) == TREE_VEC
)
2201 object_offset_in_bytes
= tree_low_cst (BINFO_OFFSET (t
), 0);
2203 object_offset_in_bytes
= field_byte_offset (t
);
2205 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_location
);
2206 sprintf (begin_label
, LOC_BEGIN_LABEL_FMT
, current_dienum
);
2207 sprintf (end_label
, LOC_END_LABEL_FMT
, current_dienum
);
2208 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
2209 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2210 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_CONST
);
2211 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, object_offset_in_bytes
);
2212 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file
, OP_ADD
);
2213 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2216 /* Output an AT_const_value attribute for a variable or a parameter which
2217 does not have a "location" either in memory or in a register. These
2218 things can arise in GNU C when a constant is passed as an actual
2219 parameter to an inlined function. They can also arise in C++ where
2220 declared constants do not necessarily get memory "homes". */
2223 const_value_attribute (rtl
)
2226 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2227 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2229 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_const_value_block4
);
2230 sprintf (begin_label
, LOC_BEGIN_LABEL_FMT
, current_dienum
);
2231 sprintf (end_label
, LOC_END_LABEL_FMT
, current_dienum
);
2232 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, end_label
, begin_label
);
2233 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2235 switch (GET_CODE (rtl
))
2238 /* Note that a CONST_INT rtx could represent either an integer or
2239 a floating-point constant. A CONST_INT is used whenever the
2240 constant will fit into a single word. In all such cases, the
2241 original mode of the constant value is wiped out, and the
2242 CONST_INT rtx is assigned VOIDmode. Since we no longer have
2243 precise mode information for these constants, we always just
2244 output them using 4 bytes. */
2246 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, (unsigned) INTVAL (rtl
));
2250 /* Note that a CONST_DOUBLE rtx could represent either an integer
2251 or a floating-point constant. A CONST_DOUBLE is used whenever
2252 the constant requires more than one word in order to be adequately
2253 represented. In all such cases, the original mode of the constant
2254 value is preserved as the mode of the CONST_DOUBLE rtx, but for
2255 simplicity we always just output CONST_DOUBLEs using 8 bytes. */
2257 ASM_OUTPUT_DWARF_DATA8 (asm_out_file
,
2258 (unsigned int) CONST_DOUBLE_HIGH (rtl
),
2259 (unsigned int) CONST_DOUBLE_LOW (rtl
));
2263 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, XSTR (rtl
, 0));
2269 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file
, rtl
);
2273 /* In cases where an inlined instance of an inline function is passed
2274 the address of an `auto' variable (which is local to the caller)
2275 we can get a situation where the DECL_RTL of the artificial
2276 local variable (for the inlining) which acts as a stand-in for
2277 the corresponding formal parameter (of the inline function)
2278 will look like (plus:SI (reg:SI FRAME_PTR) (const_int ...)).
2279 This is not exactly a compile-time constant expression, but it
2280 isn't the address of the (artificial) local variable either.
2281 Rather, it represents the *value* which the artificial local
2282 variable always has during its lifetime. We currently have no
2283 way to represent such quasi-constant values in Dwarf, so for now
2284 we just punt and generate an AT_const_value attribute with form
2285 FORM_BLOCK4 and a length of zero. */
2289 abort (); /* No other kinds of rtx should be possible here. */
2292 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2295 /* Generate *either* an AT_location attribute or else an AT_const_value
2296 data attribute for a variable or a parameter. We generate the
2297 AT_const_value attribute only in those cases where the given
2298 variable or parameter does not have a true "location" either in
2299 memory or in a register. This can happen (for example) when a
2300 constant is passed as an actual argument in a call to an inline
2301 function. (It's possible that these things can crop up in other
2302 ways also.) Note that one type of constant value which can be
2303 passed into an inlined function is a constant pointer. This can
2304 happen for example if an actual argument in an inlined function
2305 call evaluates to a compile-time constant address. */
2308 location_or_const_value_attribute (decl
)
2313 if (TREE_CODE (decl
) == ERROR_MARK
)
2316 if ((TREE_CODE (decl
) != VAR_DECL
) && (TREE_CODE (decl
) != PARM_DECL
))
2318 /* Should never happen. */
2323 /* Here we have to decide where we are going to say the parameter "lives"
2324 (as far as the debugger is concerned). We only have a couple of choices.
2325 GCC provides us with DECL_RTL and with DECL_INCOMING_RTL. DECL_RTL
2326 normally indicates where the parameter lives during most of the activa-
2327 tion of the function. If optimization is enabled however, this could
2328 be either NULL or else a pseudo-reg. Both of those cases indicate that
2329 the parameter doesn't really live anywhere (as far as the code generation
2330 parts of GCC are concerned) during most of the function's activation.
2331 That will happen (for example) if the parameter is never referenced
2332 within the function.
2334 We could just generate a location descriptor here for all non-NULL
2335 non-pseudo values of DECL_RTL and ignore all of the rest, but we can
2336 be a little nicer than that if we also consider DECL_INCOMING_RTL in
2337 cases where DECL_RTL is NULL or is a pseudo-reg.
2339 Note however that we can only get away with using DECL_INCOMING_RTL as
2340 a backup substitute for DECL_RTL in certain limited cases. In cases
2341 where DECL_ARG_TYPE(decl) indicates the same type as TREE_TYPE(decl)
2342 we can be sure that the parameter was passed using the same type as it
2343 is declared to have within the function, and that its DECL_INCOMING_RTL
2344 points us to a place where a value of that type is passed. In cases
2345 where DECL_ARG_TYPE(decl) and TREE_TYPE(decl) are different types
2346 however, we cannot (in general) use DECL_INCOMING_RTL as a backup
2347 substitute for DECL_RTL because in these cases, DECL_INCOMING_RTL
2348 points us to a value of some type which is *different* from the type
2349 of the parameter itself. Thus, if we tried to use DECL_INCOMING_RTL
2350 to generate a location attribute in such cases, the debugger would
2351 end up (for example) trying to fetch a `float' from a place which
2352 actually contains the first part of a `double'. That would lead to
2353 really incorrect and confusing output at debug-time, and we don't
2354 want that now do we?
2356 So in general, we DO NOT use DECL_INCOMING_RTL as a backup for DECL_RTL
2357 in cases where DECL_ARG_TYPE(decl) != TREE_TYPE(decl). There are a
2358 couple of cute exceptions however. On little-endian machines we can
2359 get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE(decl) is
2360 not the same as TREE_TYPE(decl) but only when DECL_ARG_TYPE(decl) is
2361 an integral type which is smaller than TREE_TYPE(decl). These cases
2362 arise when (on a little-endian machine) a non-prototyped function has
2363 a parameter declared to be of type `short' or `char'. In such cases,
2364 TREE_TYPE(decl) will be `short' or `char', DECL_ARG_TYPE(decl) will be
2365 `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
2366 passed `int' value. If the debugger then uses that address to fetch a
2367 `short' or a `char' (on a little-endian machine) the result will be the
2368 correct data, so we allow for such exceptional cases below.
2370 Note that our goal here is to describe the place where the given formal
2371 parameter lives during most of the function's activation (i.e. between
2372 the end of the prologue and the start of the epilogue). We'll do that
2373 as best as we can. Note however that if the given formal parameter is
2374 modified sometime during the execution of the function, then a stack
2375 backtrace (at debug-time) will show the function as having been called
2376 with the *new* value rather than the value which was originally passed
2377 in. This happens rarely enough that it is not a major problem, but it
2378 *is* a problem, and I'd like to fix it. A future version of dwarfout.c
2379 may generate two additional attributes for any given TAG_formal_parameter
2380 DIE which will describe the "passed type" and the "passed location" for
2381 the given formal parameter in addition to the attributes we now generate
2382 to indicate the "declared type" and the "active location" for each
2383 parameter. This additional set of attributes could be used by debuggers
2384 for stack backtraces.
2386 Separately, note that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL
2387 can be NULL also. This happens (for example) for inlined-instances of
2388 inline function formal parameters which are never referenced. This really
2389 shouldn't be happening. All PARM_DECL nodes should get valid non-NULL
2390 DECL_INCOMING_RTL values, but integrate.c doesn't currently generate
2391 these values for inlined instances of inline function parameters, so
2392 when we see such cases, we are just out-of-luck for the time
2393 being (until integrate.c gets fixed).
2396 /* Use DECL_RTL as the "location" unless we find something better. */
2397 rtl
= DECL_RTL (decl
);
2399 if (TREE_CODE (decl
) == PARM_DECL
)
2400 if (rtl
== NULL_RTX
|| is_pseudo_reg (rtl
))
2402 /* This decl represents a formal parameter which was optimized out. */
2403 register tree declared_type
= type_main_variant (TREE_TYPE (decl
));
2404 register tree passed_type
= type_main_variant (DECL_ARG_TYPE (decl
));
2406 /* Note that DECL_INCOMING_RTL may be NULL in here, but we handle
2407 *all* cases where (rtl == NULL_RTX) just below. */
2409 if (declared_type
== passed_type
)
2410 rtl
= DECL_INCOMING_RTL (decl
);
2411 else if (! BYTES_BIG_ENDIAN
)
2412 if (TREE_CODE (declared_type
) == INTEGER_TYPE
)
2414 if (TYPE_SIZE (declared_type
) <= TYPE_SIZE (passed_type
))
2415 rtl
= DECL_INCOMING_RTL (decl
);
2418 if (rtl
== NULL_RTX
)
2421 rtl
= eliminate_regs (rtl
, 0, NULL_RTX
);
2422 #ifdef LEAF_REG_REMAP
2423 if (current_function_uses_only_leaf_regs
)
2424 leaf_renumber_regs_insn (rtl
);
2427 switch (GET_CODE (rtl
))
2430 /* The address of a variable that was optimized away; don't emit
2440 case PLUS
: /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
2441 const_value_attribute (rtl
);
2447 location_attribute (rtl
);
2451 /* ??? CONCAT is used for complex variables, which may have the real
2452 part stored in one place and the imag part stored somewhere else.
2453 DWARF1 has no way to describe a variable that lives in two different
2454 places, so we just describe where the first part lives, and hope that
2455 the second part is stored after it. */
2456 location_attribute (XEXP (rtl
, 0));
2460 abort (); /* Should never happen. */
2464 /* Generate an AT_name attribute given some string value to be included as
2465 the value of the attribute. */
2468 name_attribute (name_string
)
2469 register const char *name_string
;
2471 if (name_string
&& *name_string
)
2473 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_name
);
2474 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, name_string
);
2479 fund_type_attribute (ft_code
)
2480 register unsigned ft_code
;
2482 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_fund_type
);
2483 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file
, ft_code
);
2487 mod_fund_type_attribute (type
, decl_const
, decl_volatile
)
2489 register int decl_const
;
2490 register int decl_volatile
;
2492 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2493 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2495 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_mod_fund_type
);
2496 sprintf (begin_label
, MT_BEGIN_LABEL_FMT
, current_dienum
);
2497 sprintf (end_label
, MT_END_LABEL_FMT
, current_dienum
);
2498 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
2499 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2500 write_modifier_bytes (type
, decl_const
, decl_volatile
);
2501 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file
,
2502 fundamental_type_code (root_type (type
)));
2503 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2507 user_def_type_attribute (type
)
2510 char ud_type_name
[MAX_ARTIFICIAL_LABEL_BYTES
];
2512 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_user_def_type
);
2513 sprintf (ud_type_name
, TYPE_NAME_FMT
, TYPE_UID (type
));
2514 ASM_OUTPUT_DWARF_REF (asm_out_file
, ud_type_name
);
2518 mod_u_d_type_attribute (type
, decl_const
, decl_volatile
)
2520 register int decl_const
;
2521 register int decl_volatile
;
2523 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2524 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2525 char ud_type_name
[MAX_ARTIFICIAL_LABEL_BYTES
];
2527 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_mod_u_d_type
);
2528 sprintf (begin_label
, MT_BEGIN_LABEL_FMT
, current_dienum
);
2529 sprintf (end_label
, MT_END_LABEL_FMT
, current_dienum
);
2530 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
2531 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2532 write_modifier_bytes (type
, decl_const
, decl_volatile
);
2533 sprintf (ud_type_name
, TYPE_NAME_FMT
, TYPE_UID (root_type (type
)));
2534 ASM_OUTPUT_DWARF_REF (asm_out_file
, ud_type_name
);
2535 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2538 #ifdef USE_ORDERING_ATTRIBUTE
2540 ordering_attribute (ordering
)
2541 register unsigned ordering
;
2543 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_ordering
);
2544 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, ordering
);
2546 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
2548 /* Note that the block of subscript information for an array type also
2549 includes information about the element type of type given array type. */
2552 subscript_data_attribute (type
)
2555 register unsigned dimension_number
;
2556 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2557 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2559 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_subscr_data
);
2560 sprintf (begin_label
, SS_BEGIN_LABEL_FMT
, current_dienum
);
2561 sprintf (end_label
, SS_END_LABEL_FMT
, current_dienum
);
2562 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
2563 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2565 /* The GNU compilers represent multidimensional array types as sequences
2566 of one dimensional array types whose element types are themselves array
2567 types. Here we squish that down, so that each multidimensional array
2568 type gets only one array_type DIE in the Dwarf debugging info. The
2569 draft Dwarf specification say that we are allowed to do this kind
2570 of compression in C (because there is no difference between an
2571 array or arrays and a multidimensional array in C) but for other
2572 source languages (e.g. Ada) we probably shouldn't do this. */
2574 for (dimension_number
= 0;
2575 TREE_CODE (type
) == ARRAY_TYPE
;
2576 type
= TREE_TYPE (type
), dimension_number
++)
2578 register tree domain
= TYPE_DOMAIN (type
);
2580 /* Arrays come in three flavors. Unspecified bounds, fixed
2581 bounds, and (in GNU C only) variable bounds. Handle all
2582 three forms here. */
2586 /* We have an array type with specified bounds. */
2588 register tree lower
= TYPE_MIN_VALUE (domain
);
2589 register tree upper
= TYPE_MAX_VALUE (domain
);
2591 /* Handle only fundamental types as index types for now. */
2593 if (! type_is_fundamental (domain
))
2596 /* Output the representation format byte for this dimension. */
2598 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file
,
2599 FMT_CODE (1, TREE_CODE (lower
) == INTEGER_CST
,
2600 (upper
&& TREE_CODE (upper
) == INTEGER_CST
)));
2602 /* Output the index type for this dimension. */
2604 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file
,
2605 fundamental_type_code (domain
));
2607 /* Output the representation for the lower bound. */
2609 output_bound_representation (lower
, dimension_number
, 'l');
2611 /* Output the representation for the upper bound. */
2613 output_bound_representation (upper
, dimension_number
, 'u');
2617 /* We have an array type with an unspecified length. For C and
2618 C++ we can assume that this really means that (a) the index
2619 type is an integral type, and (b) the lower bound is zero.
2620 Note that Dwarf defines the representation of an unspecified
2621 (upper) bound as being a zero-length location description. */
2623 /* Output the array-bounds format byte. */
2625 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file
, FMT_FT_C_X
);
2627 /* Output the (assumed) index type. */
2629 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file
, FT_integer
);
2631 /* Output the (assumed) lower bound (constant) value. */
2633 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
2635 /* Output the (empty) location description for the upper bound. */
2637 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, 0);
2641 /* Output the prefix byte that says that the element type is coming up. */
2643 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file
, FMT_ET
);
2645 /* Output a representation of the type of the elements of this array type. */
2647 type_attribute (type
, 0, 0);
2649 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2653 byte_size_attribute (tree_node
)
2654 register tree tree_node
;
2656 register unsigned size
;
2658 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_byte_size
);
2659 switch (TREE_CODE (tree_node
))
2668 case QUAL_UNION_TYPE
:
2670 size
= int_size_in_bytes (tree_node
);
2674 /* For a data member of a struct or union, the AT_byte_size is
2675 generally given as the number of bytes normally allocated for
2676 an object of the *declared* type of the member itself. This
2677 is true even for bit-fields. */
2678 size
= simple_type_size_in_bits (field_type (tree_node
))
2686 /* Note that `size' might be -1 when we get to this point. If it
2687 is, that indicates that the byte size of the entity in question
2688 is variable. We have no good way of expressing this fact in Dwarf
2689 at the present time, so just let the -1 pass on through. */
2691 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, size
);
2694 /* For a FIELD_DECL node which represents a bit-field, output an attribute
2695 which specifies the distance in bits from the highest order bit of the
2696 "containing object" for the bit-field to the highest order bit of the
2699 For any given bit-field, the "containing object" is a hypothetical
2700 object (of some integral or enum type) within which the given bit-field
2701 lives. The type of this hypothetical "containing object" is always the
2702 same as the declared type of the individual bit-field itself.
2704 The determination of the exact location of the "containing object" for
2705 a bit-field is rather complicated. It's handled by the `field_byte_offset'
2708 Note that it is the size (in bytes) of the hypothetical "containing
2709 object" which will be given in the AT_byte_size attribute for this
2710 bit-field. (See `byte_size_attribute' above.) */
2713 bit_offset_attribute (decl
)
2716 HOST_WIDE_INT object_offset_in_bytes
= field_byte_offset (decl
);
2717 tree type
= DECL_BIT_FIELD_TYPE (decl
);
2718 HOST_WIDE_INT bitpos_int
;
2719 HOST_WIDE_INT highest_order_object_bit_offset
;
2720 HOST_WIDE_INT highest_order_field_bit_offset
;
2721 HOST_WIDE_INT bit_offset
;
2723 /* Must be a bit field. */
2725 || TREE_CODE (decl
) != FIELD_DECL
)
2728 /* We can't yet handle bit-fields whose offsets or sizes are variable, so
2729 if we encounter such things, just return without generating any
2730 attribute whatsoever. */
2732 if (! host_integerp (bit_position (decl
), 0)
2733 || ! host_integerp (DECL_SIZE (decl
), 1))
2736 bitpos_int
= int_bit_position (decl
);
2738 /* Note that the bit offset is always the distance (in bits) from the
2739 highest-order bit of the "containing object" to the highest-order
2740 bit of the bit-field itself. Since the "high-order end" of any
2741 object or field is different on big-endian and little-endian machines,
2742 the computation below must take account of these differences. */
2744 highest_order_object_bit_offset
= object_offset_in_bytes
* BITS_PER_UNIT
;
2745 highest_order_field_bit_offset
= bitpos_int
;
2747 if (! BYTES_BIG_ENDIAN
)
2749 highest_order_field_bit_offset
+= tree_low_cst (DECL_SIZE (decl
), 1);
2750 highest_order_object_bit_offset
+= simple_type_size_in_bits (type
);
2755 ? highest_order_object_bit_offset
- highest_order_field_bit_offset
2756 : highest_order_field_bit_offset
- highest_order_object_bit_offset
);
2758 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_bit_offset
);
2759 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, bit_offset
);
2762 /* For a FIELD_DECL node which represents a bit field, output an attribute
2763 which specifies the length in bits of the given field. */
2766 bit_size_attribute (decl
)
2769 /* Must be a field and a bit field. */
2770 if (TREE_CODE (decl
) != FIELD_DECL
2771 || ! DECL_BIT_FIELD_TYPE (decl
))
2774 if (host_integerp (DECL_SIZE (decl
), 1))
2776 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_bit_size
);
2777 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
2778 tree_low_cst (DECL_SIZE (decl
), 1));
2782 /* The following routine outputs the `element_list' attribute for enumeration
2783 type DIEs. The element_lits attribute includes the names and values of
2784 all of the enumeration constants associated with the given enumeration
2788 element_list_attribute (element
)
2789 register tree element
;
2791 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2792 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2794 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_element_list
);
2795 sprintf (begin_label
, EE_BEGIN_LABEL_FMT
, current_dienum
);
2796 sprintf (end_label
, EE_END_LABEL_FMT
, current_dienum
);
2797 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, end_label
, begin_label
);
2798 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2800 /* Here we output a list of value/name pairs for each enumeration constant
2801 defined for this enumeration type (as required), but we do it in REVERSE
2802 order. The order is the one required by the draft #5 Dwarf specification
2803 published by the UI/PLSIG. */
2805 output_enumeral_list (element
); /* Recursively output the whole list. */
2807 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2810 /* Generate an AT_stmt_list attribute. These are normally present only in
2811 DIEs with a TAG_compile_unit tag. */
2814 stmt_list_attribute (label
)
2815 register const char *label
;
2817 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_stmt_list
);
2818 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2819 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, label
);
2822 /* Generate an AT_low_pc attribute for a label DIE, a lexical_block DIE or
2823 for a subroutine DIE. */
2826 low_pc_attribute (asm_low_label
)
2827 register const char *asm_low_label
;
2829 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_low_pc
);
2830 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, asm_low_label
);
2833 /* Generate an AT_high_pc attribute for a lexical_block DIE or for a
2837 high_pc_attribute (asm_high_label
)
2838 register const char *asm_high_label
;
2840 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_high_pc
);
2841 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, asm_high_label
);
2844 /* Generate an AT_body_begin attribute for a subroutine DIE. */
2847 body_begin_attribute (asm_begin_label
)
2848 register const char *asm_begin_label
;
2850 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_body_begin
);
2851 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, asm_begin_label
);
2854 /* Generate an AT_body_end attribute for a subroutine DIE. */
2857 body_end_attribute (asm_end_label
)
2858 register const char *asm_end_label
;
2860 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_body_end
);
2861 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, asm_end_label
);
2864 /* Generate an AT_language attribute given a LANG value. These attributes
2865 are used only within TAG_compile_unit DIEs. */
2868 language_attribute (language_code
)
2869 register unsigned language_code
;
2871 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_language
);
2872 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, language_code
);
2876 member_attribute (context
)
2877 register tree context
;
2879 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2881 /* Generate this attribute only for members in C++. */
2883 if (context
!= NULL
&& is_tagged_type (context
))
2885 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_member
);
2886 sprintf (label
, TYPE_NAME_FMT
, TYPE_UID (context
));
2887 ASM_OUTPUT_DWARF_REF (asm_out_file
, label
);
2893 string_length_attribute (upper_bound
)
2894 register tree upper_bound
;
2896 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2897 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2899 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_string_length
);
2900 sprintf (begin_label
, SL_BEGIN_LABEL_FMT
, current_dienum
);
2901 sprintf (end_label
, SL_END_LABEL_FMT
, current_dienum
);
2902 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, end_label
, begin_label
);
2903 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
2904 output_bound_representation (upper_bound
, 0, 'u');
2905 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
2910 comp_dir_attribute (dirname
)
2911 register const char *dirname
;
2913 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_comp_dir
);
2914 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, dirname
);
2918 sf_names_attribute (sf_names_start_label
)
2919 register const char *sf_names_start_label
;
2921 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_sf_names
);
2922 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2923 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, sf_names_start_label
);
2927 src_info_attribute (src_info_start_label
)
2928 register const char *src_info_start_label
;
2930 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_src_info
);
2931 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2932 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, src_info_start_label
);
2936 mac_info_attribute (mac_info_start_label
)
2937 register const char *mac_info_start_label
;
2939 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_mac_info
);
2940 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2941 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, mac_info_start_label
);
2945 prototyped_attribute (func_type
)
2946 register tree func_type
;
2948 if ((strcmp (language_string
, "GNU C") == 0)
2949 && (TYPE_ARG_TYPES (func_type
) != NULL
))
2951 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_prototyped
);
2952 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
2957 producer_attribute (producer
)
2958 register const char *producer
;
2960 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_producer
);
2961 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, producer
);
2965 inline_attribute (decl
)
2968 if (DECL_INLINE (decl
))
2970 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_inline
);
2971 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
2976 containing_type_attribute (containing_type
)
2977 register tree containing_type
;
2979 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2981 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_containing_type
);
2982 sprintf (label
, TYPE_NAME_FMT
, TYPE_UID (containing_type
));
2983 ASM_OUTPUT_DWARF_REF (asm_out_file
, label
);
2987 abstract_origin_attribute (origin
)
2988 register tree origin
;
2990 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2992 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_abstract_origin
);
2993 switch (TREE_CODE_CLASS (TREE_CODE (origin
)))
2996 sprintf (label
, DECL_NAME_FMT
, DECL_UID (origin
));
3000 sprintf (label
, TYPE_NAME_FMT
, TYPE_UID (origin
));
3004 abort (); /* Should never happen. */
3007 ASM_OUTPUT_DWARF_REF (asm_out_file
, label
);
3010 #ifdef DWARF_DECL_COORDINATES
3012 src_coords_attribute (src_fileno
, src_lineno
)
3013 register unsigned src_fileno
;
3014 register unsigned src_lineno
;
3016 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_src_coords
);
3017 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, src_fileno
);
3018 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, src_lineno
);
3020 #endif /* defined(DWARF_DECL_COORDINATES) */
3023 pure_or_virtual_attribute (func_decl
)
3024 register tree func_decl
;
3026 if (DECL_VIRTUAL_P (func_decl
))
3028 #if 0 /* DECL_ABSTRACT_VIRTUAL_P is C++-specific. */
3029 if (DECL_ABSTRACT_VIRTUAL_P (func_decl
))
3030 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_pure_virtual
);
3033 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_virtual
);
3034 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
3038 /************************* end of attributes *****************************/
3040 /********************* utility routines for DIEs *************************/
3042 /* Output an AT_name attribute and an AT_src_coords attribute for the
3043 given decl, but only if it actually has a name. */
3046 name_and_src_coords_attributes (decl
)
3049 register tree decl_name
= DECL_NAME (decl
);
3051 if (decl_name
&& IDENTIFIER_POINTER (decl_name
))
3053 name_attribute (IDENTIFIER_POINTER (decl_name
));
3054 #ifdef DWARF_DECL_COORDINATES
3056 register unsigned file_index
;
3058 /* This is annoying, but we have to pop out of the .debug section
3059 for a moment while we call `lookup_filename' because calling it
3060 may cause a temporary switch into the .debug_sfnames section and
3061 most svr4 assemblers are not smart enough to be able to nest
3062 section switches to any depth greater than one. Note that we
3063 also can't skirt this issue by delaying all output to the
3064 .debug_sfnames section unit the end of compilation because that
3065 would cause us to have inter-section forward references and
3066 Fred Fish sez that m68k/svr4 assemblers botch those. */
3068 ASM_OUTPUT_POP_SECTION (asm_out_file
);
3069 file_index
= lookup_filename (DECL_SOURCE_FILE (decl
));
3070 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DEBUG_SECTION
);
3072 src_coords_attribute (file_index
, DECL_SOURCE_LINE (decl
));
3074 #endif /* defined(DWARF_DECL_COORDINATES) */
3078 /* Many forms of DIEs contain a "type description" part. The following
3079 routine writes out these "type descriptor" parts. */
3082 type_attribute (type
, decl_const
, decl_volatile
)
3084 register int decl_const
;
3085 register int decl_volatile
;
3087 register enum tree_code code
= TREE_CODE (type
);
3088 register int root_type_modified
;
3090 if (code
== ERROR_MARK
)
3093 /* Handle a special case. For functions whose return type is void,
3094 we generate *no* type attribute. (Note that no object may have
3095 type `void', so this only applies to function return types. */
3097 if (code
== VOID_TYPE
)
3100 /* If this is a subtype, find the underlying type. Eventually,
3101 this should write out the appropriate subtype info. */
3102 while ((code
== INTEGER_TYPE
|| code
== REAL_TYPE
)
3103 && TREE_TYPE (type
) != 0)
3104 type
= TREE_TYPE (type
), code
= TREE_CODE (type
);
3106 root_type_modified
= (code
== POINTER_TYPE
|| code
== REFERENCE_TYPE
3107 || decl_const
|| decl_volatile
3108 || TYPE_READONLY (type
) || TYPE_VOLATILE (type
));
3110 if (type_is_fundamental (root_type (type
)))
3112 if (root_type_modified
)
3113 mod_fund_type_attribute (type
, decl_const
, decl_volatile
);
3115 fund_type_attribute (fundamental_type_code (type
));
3119 if (root_type_modified
)
3120 mod_u_d_type_attribute (type
, decl_const
, decl_volatile
);
3122 /* We have to get the type_main_variant here (and pass that to the
3123 `user_def_type_attribute' routine) because the ..._TYPE node we
3124 have might simply be a *copy* of some original type node (where
3125 the copy was created to help us keep track of typedef names)
3126 and that copy might have a different TYPE_UID from the original
3127 ..._TYPE node. (Note that when `equate_type_number_to_die_number'
3128 is labeling a given type DIE for future reference, it always and
3129 only creates labels for DIEs representing *main variants*, and it
3130 never even knows about non-main-variants.) */
3131 user_def_type_attribute (type_main_variant (type
));
3135 /* Given a tree pointer to a struct, class, union, or enum type node, return
3136 a pointer to the (string) tag name for the given type, or zero if the
3137 type was declared without a tag. */
3143 register char *name
= 0;
3145 if (TYPE_NAME (type
) != 0)
3147 register tree t
= 0;
3149 /* Find the IDENTIFIER_NODE for the type name. */
3150 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
3151 t
= TYPE_NAME (type
);
3153 /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
3154 a TYPE_DECL node, regardless of whether or not a `typedef' was
3156 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
3157 && ! DECL_IGNORED_P (TYPE_NAME (type
)))
3158 t
= DECL_NAME (TYPE_NAME (type
));
3160 /* Now get the name as a string, or invent one. */
3162 name
= IDENTIFIER_POINTER (t
);
3165 return (name
== 0 || *name
== '\0') ? 0 : name
;
3171 /* Start by checking if the pending_sibling_stack needs to be expanded.
3172 If necessary, expand it. */
3174 if (pending_siblings
== pending_siblings_allocated
)
3176 pending_siblings_allocated
+= PENDING_SIBLINGS_INCREMENT
;
3177 pending_sibling_stack
3178 = (unsigned *) xrealloc (pending_sibling_stack
,
3179 pending_siblings_allocated
* sizeof(unsigned));
3183 NEXT_DIE_NUM
= next_unused_dienum
++;
3186 /* Pop the sibling stack so that the most recently pushed DIEnum becomes the
3196 member_declared_type (member
)
3197 register tree member
;
3199 return (DECL_BIT_FIELD_TYPE (member
))
3200 ? DECL_BIT_FIELD_TYPE (member
)
3201 : TREE_TYPE (member
);
3204 /* Get the function's label, as described by its RTL.
3205 This may be different from the DECL_NAME name used
3206 in the source file. */
3209 function_start_label (decl
)
3215 x
= DECL_RTL (decl
);
3216 if (GET_CODE (x
) != MEM
)
3219 if (GET_CODE (x
) != SYMBOL_REF
)
3221 fnname
= XSTR (x
, 0);
3226 /******************************* DIEs ************************************/
3228 /* Output routines for individual types of DIEs. */
3230 /* Note that every type of DIE (except a null DIE) gets a sibling. */
3233 output_array_type_die (arg
)
3236 register tree type
= arg
;
3238 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_array_type
);
3239 sibling_attribute ();
3240 equate_type_number_to_die_number (type
);
3241 member_attribute (TYPE_CONTEXT (type
));
3243 /* I believe that we can default the array ordering. SDB will probably
3244 do the right things even if AT_ordering is not present. It's not
3245 even an issue until we start to get into multidimensional arrays
3246 anyway. If SDB is ever caught doing the Wrong Thing for multi-
3247 dimensional arrays, then we'll have to put the AT_ordering attribute
3248 back in. (But if and when we find out that we need to put these in,
3249 we will only do so for multidimensional arrays. After all, we don't
3250 want to waste space in the .debug section now do we?) */
3252 #ifdef USE_ORDERING_ATTRIBUTE
3253 ordering_attribute (ORD_row_major
);
3254 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
3256 subscript_data_attribute (type
);
3260 output_set_type_die (arg
)
3263 register tree type
= arg
;
3265 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_set_type
);
3266 sibling_attribute ();
3267 equate_type_number_to_die_number (type
);
3268 member_attribute (TYPE_CONTEXT (type
));
3269 type_attribute (TREE_TYPE (type
), 0, 0);
3273 /* Implement this when there is a GNU FORTRAN or GNU Ada front end. */
3276 output_entry_point_die (arg
)
3279 register tree decl
= arg
;
3280 register tree origin
= decl_ultimate_origin (decl
);
3282 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_entry_point
);
3283 sibling_attribute ();
3286 abstract_origin_attribute (origin
);
3289 name_and_src_coords_attributes (decl
);
3290 member_attribute (DECL_CONTEXT (decl
));
3291 type_attribute (TREE_TYPE (TREE_TYPE (decl
)), 0, 0);
3293 if (DECL_ABSTRACT (decl
))
3294 equate_decl_number_to_die_number (decl
);
3296 low_pc_attribute (function_start_label (decl
));
3300 /* Output a DIE to represent an inlined instance of an enumeration type. */
3303 output_inlined_enumeration_type_die (arg
)
3306 register tree type
= arg
;
3308 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_enumeration_type
);
3309 sibling_attribute ();
3310 if (!TREE_ASM_WRITTEN (type
))
3312 abstract_origin_attribute (type
);
3315 /* Output a DIE to represent an inlined instance of a structure type. */
3318 output_inlined_structure_type_die (arg
)
3321 register tree type
= arg
;
3323 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_structure_type
);
3324 sibling_attribute ();
3325 if (!TREE_ASM_WRITTEN (type
))
3327 abstract_origin_attribute (type
);
3330 /* Output a DIE to represent an inlined instance of a union type. */
3333 output_inlined_union_type_die (arg
)
3336 register tree type
= arg
;
3338 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_union_type
);
3339 sibling_attribute ();
3340 if (!TREE_ASM_WRITTEN (type
))
3342 abstract_origin_attribute (type
);
3345 /* Output a DIE to represent an enumeration type. Note that these DIEs
3346 include all of the information about the enumeration values also.
3347 This information is encoded into the element_list attribute. */
3350 output_enumeration_type_die (arg
)
3353 register tree type
= arg
;
3355 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_enumeration_type
);
3356 sibling_attribute ();
3357 equate_type_number_to_die_number (type
);
3358 name_attribute (type_tag (type
));
3359 member_attribute (TYPE_CONTEXT (type
));
3361 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
3362 given enum type is incomplete, do not generate the AT_byte_size
3363 attribute or the AT_element_list attribute. */
3365 if (COMPLETE_TYPE_P (type
))
3367 byte_size_attribute (type
);
3368 element_list_attribute (TYPE_FIELDS (type
));
3372 /* Output a DIE to represent either a real live formal parameter decl or
3373 to represent just the type of some formal parameter position in some
3376 Note that this routine is a bit unusual because its argument may be
3377 a ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
3378 represents an inlining of some PARM_DECL) or else some sort of a
3379 ..._TYPE node. If it's the former then this function is being called
3380 to output a DIE to represent a formal parameter object (or some inlining
3381 thereof). If it's the latter, then this function is only being called
3382 to output a TAG_formal_parameter DIE to stand as a placeholder for some
3383 formal argument type of some subprogram type. */
3386 output_formal_parameter_die (arg
)
3389 register tree node
= arg
;
3391 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_formal_parameter
);
3392 sibling_attribute ();
3394 switch (TREE_CODE_CLASS (TREE_CODE (node
)))
3396 case 'd': /* We were called with some kind of a ..._DECL node. */
3398 register tree origin
= decl_ultimate_origin (node
);
3401 abstract_origin_attribute (origin
);
3404 name_and_src_coords_attributes (node
);
3405 type_attribute (TREE_TYPE (node
),
3406 TREE_READONLY (node
), TREE_THIS_VOLATILE (node
));
3408 if (DECL_ABSTRACT (node
))
3409 equate_decl_number_to_die_number (node
);
3411 location_or_const_value_attribute (node
);
3415 case 't': /* We were called with some kind of a ..._TYPE node. */
3416 type_attribute (node
, 0, 0);
3420 abort (); /* Should never happen. */
3424 /* Output a DIE to represent a declared function (either file-scope
3425 or block-local) which has "external linkage" (according to ANSI-C). */
3428 output_global_subroutine_die (arg
)
3431 register tree decl
= arg
;
3432 register tree origin
= decl_ultimate_origin (decl
);
3434 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_global_subroutine
);
3435 sibling_attribute ();
3438 abstract_origin_attribute (origin
);
3441 register tree type
= TREE_TYPE (decl
);
3443 name_and_src_coords_attributes (decl
);
3444 inline_attribute (decl
);
3445 prototyped_attribute (type
);
3446 member_attribute (DECL_CONTEXT (decl
));
3447 type_attribute (TREE_TYPE (type
), 0, 0);
3448 pure_or_virtual_attribute (decl
);
3450 if (DECL_ABSTRACT (decl
))
3451 equate_decl_number_to_die_number (decl
);
3454 if (! DECL_EXTERNAL (decl
) && ! in_class
3455 && decl
== current_function_decl
)
3457 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3459 low_pc_attribute (function_start_label (decl
));
3460 sprintf (label
, FUNC_END_LABEL_FMT
, current_funcdef_number
);
3461 high_pc_attribute (label
);
3462 if (use_gnu_debug_info_extensions
)
3464 sprintf (label
, BODY_BEGIN_LABEL_FMT
, current_funcdef_number
);
3465 body_begin_attribute (label
);
3466 sprintf (label
, BODY_END_LABEL_FMT
, current_funcdef_number
);
3467 body_end_attribute (label
);
3473 /* Output a DIE to represent a declared data object (either file-scope
3474 or block-local) which has "external linkage" (according to ANSI-C). */
3477 output_global_variable_die (arg
)
3480 register tree decl
= arg
;
3481 register tree origin
= decl_ultimate_origin (decl
);
3483 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_global_variable
);
3484 sibling_attribute ();
3486 abstract_origin_attribute (origin
);
3489 name_and_src_coords_attributes (decl
);
3490 member_attribute (DECL_CONTEXT (decl
));
3491 type_attribute (TREE_TYPE (decl
),
3492 TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
));
3494 if (DECL_ABSTRACT (decl
))
3495 equate_decl_number_to_die_number (decl
);
3498 if (! DECL_EXTERNAL (decl
) && ! in_class
3499 && current_function_decl
== decl_function_context (decl
))
3500 location_or_const_value_attribute (decl
);
3505 output_label_die (arg
)
3508 register tree decl
= arg
;
3509 register tree origin
= decl_ultimate_origin (decl
);
3511 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_label
);
3512 sibling_attribute ();
3514 abstract_origin_attribute (origin
);
3516 name_and_src_coords_attributes (decl
);
3517 if (DECL_ABSTRACT (decl
))
3518 equate_decl_number_to_die_number (decl
);
3521 register rtx insn
= DECL_RTL (decl
);
3523 /* Deleted labels are programmer specified labels which have been
3524 eliminated because of various optimisations. We still emit them
3525 here so that it is possible to put breakpoints on them. */
3526 if (GET_CODE (insn
) == CODE_LABEL
3527 || ((GET_CODE (insn
) == NOTE
3528 && NOTE_LINE_NUMBER (insn
) == NOTE_INSN_DELETED_LABEL
)))
3530 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3532 /* When optimization is enabled (via -O) some parts of the compiler
3533 (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
3534 represent source-level labels which were explicitly declared by
3535 the user. This really shouldn't be happening though, so catch
3536 it if it ever does happen. */
3538 if (INSN_DELETED_P (insn
))
3539 abort (); /* Should never happen. */
3541 sprintf (label
, INSN_LABEL_FMT
, current_funcdef_number
,
3542 (unsigned) INSN_UID (insn
));
3543 low_pc_attribute (label
);
3549 output_lexical_block_die (arg
)
3552 register tree stmt
= arg
;
3554 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_lexical_block
);
3555 sibling_attribute ();
3557 if (! BLOCK_ABSTRACT (stmt
))
3559 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3560 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3562 sprintf (begin_label
, BLOCK_BEGIN_LABEL_FMT
, BLOCK_NUMBER (stmt
));
3563 low_pc_attribute (begin_label
);
3564 sprintf (end_label
, BLOCK_END_LABEL_FMT
, BLOCK_NUMBER (stmt
));
3565 high_pc_attribute (end_label
);
3570 output_inlined_subroutine_die (arg
)
3573 register tree stmt
= arg
;
3575 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_inlined_subroutine
);
3576 sibling_attribute ();
3578 abstract_origin_attribute (block_ultimate_origin (stmt
));
3579 if (! BLOCK_ABSTRACT (stmt
))
3581 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3582 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3584 sprintf (begin_label
, BLOCK_BEGIN_LABEL_FMT
, BLOCK_NUMBER (stmt
));
3585 low_pc_attribute (begin_label
);
3586 sprintf (end_label
, BLOCK_END_LABEL_FMT
, BLOCK_NUMBER (stmt
));
3587 high_pc_attribute (end_label
);
3591 /* Output a DIE to represent a declared data object (either file-scope
3592 or block-local) which has "internal linkage" (according to ANSI-C). */
3595 output_local_variable_die (arg
)
3598 register tree decl
= arg
;
3599 register tree origin
= decl_ultimate_origin (decl
);
3601 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_local_variable
);
3602 sibling_attribute ();
3604 abstract_origin_attribute (origin
);
3607 name_and_src_coords_attributes (decl
);
3608 member_attribute (DECL_CONTEXT (decl
));
3609 type_attribute (TREE_TYPE (decl
),
3610 TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
));
3612 if (DECL_ABSTRACT (decl
))
3613 equate_decl_number_to_die_number (decl
);
3615 location_or_const_value_attribute (decl
);
3619 output_member_die (arg
)
3622 register tree decl
= arg
;
3624 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_member
);
3625 sibling_attribute ();
3626 name_and_src_coords_attributes (decl
);
3627 member_attribute (DECL_CONTEXT (decl
));
3628 type_attribute (member_declared_type (decl
),
3629 TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
));
3630 if (DECL_BIT_FIELD_TYPE (decl
)) /* If this is a bit field... */
3632 byte_size_attribute (decl
);
3633 bit_size_attribute (decl
);
3634 bit_offset_attribute (decl
);
3636 data_member_location_attribute (decl
);
3640 /* Don't generate either pointer_type DIEs or reference_type DIEs. Use
3641 modified types instead.
3643 We keep this code here just in case these types of DIEs may be
3644 needed to represent certain things in other languages (e.g. Pascal)
3648 output_pointer_type_die (arg
)
3651 register tree type
= arg
;
3653 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_pointer_type
);
3654 sibling_attribute ();
3655 equate_type_number_to_die_number (type
);
3656 member_attribute (TYPE_CONTEXT (type
));
3657 type_attribute (TREE_TYPE (type
), 0, 0);
3661 output_reference_type_die (arg
)
3664 register tree type
= arg
;
3666 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_reference_type
);
3667 sibling_attribute ();
3668 equate_type_number_to_die_number (type
);
3669 member_attribute (TYPE_CONTEXT (type
));
3670 type_attribute (TREE_TYPE (type
), 0, 0);
3675 output_ptr_to_mbr_type_die (arg
)
3678 register tree type
= arg
;
3680 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_ptr_to_member_type
);
3681 sibling_attribute ();
3682 equate_type_number_to_die_number (type
);
3683 member_attribute (TYPE_CONTEXT (type
));
3684 containing_type_attribute (TYPE_OFFSET_BASETYPE (type
));
3685 type_attribute (TREE_TYPE (type
), 0, 0);
3689 output_compile_unit_die (arg
)
3692 register char *main_input_filename
= arg
;
3694 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_compile_unit
);
3695 sibling_attribute ();
3697 name_attribute (main_input_filename
);
3702 sprintf (producer
, "%s %s", language_string
, version_string
);
3703 producer_attribute (producer
);
3706 if (strcmp (language_string
, "GNU C++") == 0)
3707 language_attribute (LANG_C_PLUS_PLUS
);
3708 else if (strcmp (language_string
, "GNU Ada") == 0)
3709 language_attribute (LANG_ADA83
);
3710 else if (strcmp (language_string
, "GNU F77") == 0)
3711 language_attribute (LANG_FORTRAN77
);
3712 else if (strcmp (language_string
, "GNU Pascal") == 0)
3713 language_attribute (LANG_PASCAL83
);
3714 else if (flag_traditional
)
3715 language_attribute (LANG_C
);
3717 language_attribute (LANG_C89
);
3718 low_pc_attribute (TEXT_BEGIN_LABEL
);
3719 high_pc_attribute (TEXT_END_LABEL
);
3720 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
3721 stmt_list_attribute (LINE_BEGIN_LABEL
);
3722 last_filename
= xstrdup (main_input_filename
);
3725 char *wd
= getpwd ();
3727 comp_dir_attribute (wd
);
3730 if (debug_info_level
>= DINFO_LEVEL_NORMAL
&& use_gnu_debug_info_extensions
)
3732 sf_names_attribute (SFNAMES_BEGIN_LABEL
);
3733 src_info_attribute (SRCINFO_BEGIN_LABEL
);
3734 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
3735 mac_info_attribute (MACINFO_BEGIN_LABEL
);
3740 output_string_type_die (arg
)
3743 register tree type
= arg
;
3745 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_string_type
);
3746 sibling_attribute ();
3747 equate_type_number_to_die_number (type
);
3748 member_attribute (TYPE_CONTEXT (type
));
3749 /* this is a fixed length string */
3750 byte_size_attribute (type
);
3754 output_inheritance_die (arg
)
3757 register tree binfo
= arg
;
3759 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_inheritance
);
3760 sibling_attribute ();
3761 type_attribute (BINFO_TYPE (binfo
), 0, 0);
3762 data_member_location_attribute (binfo
);
3763 if (TREE_VIA_VIRTUAL (binfo
))
3765 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_virtual
);
3766 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
3768 if (TREE_VIA_PUBLIC (binfo
))
3770 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_public
);
3771 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
3773 else if (TREE_VIA_PROTECTED (binfo
))
3775 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file
, AT_protected
);
3776 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
3781 output_structure_type_die (arg
)
3784 register tree type
= arg
;
3786 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_structure_type
);
3787 sibling_attribute ();
3788 equate_type_number_to_die_number (type
);
3789 name_attribute (type_tag (type
));
3790 member_attribute (TYPE_CONTEXT (type
));
3792 /* If this type has been completed, then give it a byte_size attribute
3793 and prepare to give a list of members. Otherwise, don't do either of
3794 these things. In the latter case, we will not be generating a list
3795 of members (since we don't have any idea what they might be for an
3796 incomplete type). */
3798 if (COMPLETE_TYPE_P (type
))
3801 byte_size_attribute (type
);
3805 /* Output a DIE to represent a declared function (either file-scope
3806 or block-local) which has "internal linkage" (according to ANSI-C). */
3809 output_local_subroutine_die (arg
)
3812 register tree decl
= arg
;
3813 register tree origin
= decl_ultimate_origin (decl
);
3815 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_subroutine
);
3816 sibling_attribute ();
3819 abstract_origin_attribute (origin
);
3822 register tree type
= TREE_TYPE (decl
);
3824 name_and_src_coords_attributes (decl
);
3825 inline_attribute (decl
);
3826 prototyped_attribute (type
);
3827 member_attribute (DECL_CONTEXT (decl
));
3828 type_attribute (TREE_TYPE (type
), 0, 0);
3829 pure_or_virtual_attribute (decl
);
3831 if (DECL_ABSTRACT (decl
))
3832 equate_decl_number_to_die_number (decl
);
3835 /* Avoid getting screwed up in cases where a function was declared
3836 static but where no definition was ever given for it. */
3838 if (TREE_ASM_WRITTEN (decl
))
3840 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3841 low_pc_attribute (function_start_label (decl
));
3842 sprintf (label
, FUNC_END_LABEL_FMT
, current_funcdef_number
);
3843 high_pc_attribute (label
);
3844 if (use_gnu_debug_info_extensions
)
3846 sprintf (label
, BODY_BEGIN_LABEL_FMT
, current_funcdef_number
);
3847 body_begin_attribute (label
);
3848 sprintf (label
, BODY_END_LABEL_FMT
, current_funcdef_number
);
3849 body_end_attribute (label
);
3856 output_subroutine_type_die (arg
)
3859 register tree type
= arg
;
3860 register tree return_type
= TREE_TYPE (type
);
3862 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_subroutine_type
);
3863 sibling_attribute ();
3865 equate_type_number_to_die_number (type
);
3866 prototyped_attribute (type
);
3867 member_attribute (TYPE_CONTEXT (type
));
3868 type_attribute (return_type
, 0, 0);
3872 output_typedef_die (arg
)
3875 register tree decl
= arg
;
3876 register tree origin
= decl_ultimate_origin (decl
);
3878 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_typedef
);
3879 sibling_attribute ();
3881 abstract_origin_attribute (origin
);
3884 name_and_src_coords_attributes (decl
);
3885 member_attribute (DECL_CONTEXT (decl
));
3886 type_attribute (TREE_TYPE (decl
),
3887 TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
));
3889 if (DECL_ABSTRACT (decl
))
3890 equate_decl_number_to_die_number (decl
);
3894 output_union_type_die (arg
)
3897 register tree type
= arg
;
3899 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_union_type
);
3900 sibling_attribute ();
3901 equate_type_number_to_die_number (type
);
3902 name_attribute (type_tag (type
));
3903 member_attribute (TYPE_CONTEXT (type
));
3905 /* If this type has been completed, then give it a byte_size attribute
3906 and prepare to give a list of members. Otherwise, don't do either of
3907 these things. In the latter case, we will not be generating a list
3908 of members (since we don't have any idea what they might be for an
3909 incomplete type). */
3911 if (COMPLETE_TYPE_P (type
))
3914 byte_size_attribute (type
);
3918 /* Generate a special type of DIE used as a stand-in for a trailing ellipsis
3919 at the end of an (ANSI prototyped) formal parameters list. */
3922 output_unspecified_parameters_die (arg
)
3925 register tree decl_or_type
= arg
;
3927 ASM_OUTPUT_DWARF_TAG (asm_out_file
, TAG_unspecified_parameters
);
3928 sibling_attribute ();
3930 /* This kludge is here only for the sake of being compatible with what
3931 the USL CI5 C compiler does. The specification of Dwarf Version 1
3932 doesn't say that TAG_unspecified_parameters DIEs should contain any
3933 attributes other than the AT_sibling attribute, but they are certainly
3934 allowed to contain additional attributes, and the CI5 compiler
3935 generates AT_name, AT_fund_type, and AT_location attributes within
3936 TAG_unspecified_parameters DIEs which appear in the child lists for
3937 DIEs representing function definitions, so we do likewise here. */
3939 if (TREE_CODE (decl_or_type
) == FUNCTION_DECL
&& DECL_INITIAL (decl_or_type
))
3941 name_attribute ("...");
3942 fund_type_attribute (FT_pointer
);
3943 /* location_attribute (?); */
3948 output_padded_null_die (arg
)
3949 register void *arg ATTRIBUTE_UNUSED
;
3951 ASM_OUTPUT_ALIGN (asm_out_file
, 2); /* 2**2 == 4 */
3954 /*************************** end of DIEs *********************************/
3956 /* Generate some type of DIE. This routine generates the generic outer
3957 wrapper stuff which goes around all types of DIE's (regardless of their
3958 TAGs. All forms of DIEs start with a DIE-specific label, followed by a
3959 DIE-length word, followed by the guts of the DIE itself. After the guts
3960 of the DIE, there must always be a terminator label for the DIE. */
3963 output_die (die_specific_output_function
, param
)
3964 register void (*die_specific_output_function
) PARAMS ((void *));
3965 register void *param
;
3967 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3968 char end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3970 current_dienum
= NEXT_DIE_NUM
;
3971 NEXT_DIE_NUM
= next_unused_dienum
;
3973 sprintf (begin_label
, DIE_BEGIN_LABEL_FMT
, current_dienum
);
3974 sprintf (end_label
, DIE_END_LABEL_FMT
, current_dienum
);
3976 /* Write a label which will act as the name for the start of this DIE. */
3978 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
3980 /* Write the DIE-length word. */
3982 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, end_label
, begin_label
);
3984 /* Fill in the guts of the DIE. */
3986 next_unused_dienum
++;
3987 die_specific_output_function (param
);
3989 /* Write a label which will act as the name for the end of this DIE. */
3991 ASM_OUTPUT_LABEL (asm_out_file
, end_label
);
3995 end_sibling_chain ()
3997 char begin_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3999 current_dienum
= NEXT_DIE_NUM
;
4000 NEXT_DIE_NUM
= next_unused_dienum
;
4002 sprintf (begin_label
, DIE_BEGIN_LABEL_FMT
, current_dienum
);
4004 /* Write a label which will act as the name for the start of this DIE. */
4006 ASM_OUTPUT_LABEL (asm_out_file
, begin_label
);
4008 /* Write the DIE-length word. */
4010 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 4);
4015 /* Generate a list of nameless TAG_formal_parameter DIEs (and perhaps a
4016 TAG_unspecified_parameters DIE) to represent the types of the formal
4017 parameters as specified in some function type specification (except
4018 for those which appear as part of a function *definition*).
4020 Note that we must be careful here to output all of the parameter
4021 DIEs *before* we output any DIEs needed to represent the types of
4022 the formal parameters. This keeps svr4 SDB happy because it
4023 (incorrectly) thinks that the first non-parameter DIE it sees ends
4024 the formal parameter list. */
4027 output_formal_types (function_or_method_type
)
4028 register tree function_or_method_type
;
4031 register tree formal_type
= NULL
;
4032 register tree first_parm_type
= TYPE_ARG_TYPES (function_or_method_type
);
4034 /* Set TREE_ASM_WRITTEN while processing the parameters, lest we
4035 get bogus recursion when outputting tagged types local to a
4036 function declaration. */
4037 int save_asm_written
= TREE_ASM_WRITTEN (function_or_method_type
);
4038 TREE_ASM_WRITTEN (function_or_method_type
) = 1;
4040 /* In the case where we are generating a formal types list for a C++
4041 non-static member function type, skip over the first thing on the
4042 TYPE_ARG_TYPES list because it only represents the type of the
4043 hidden `this pointer'. The debugger should be able to figure
4044 out (without being explicitly told) that this non-static member
4045 function type takes a `this pointer' and should be able to figure
4046 what the type of that hidden parameter is from the AT_member
4047 attribute of the parent TAG_subroutine_type DIE. */
4049 if (TREE_CODE (function_or_method_type
) == METHOD_TYPE
)
4050 first_parm_type
= TREE_CHAIN (first_parm_type
);
4052 /* Make our first pass over the list of formal parameter types and output
4053 a TAG_formal_parameter DIE for each one. */
4055 for (link
= first_parm_type
; link
; link
= TREE_CHAIN (link
))
4057 formal_type
= TREE_VALUE (link
);
4058 if (formal_type
== void_type_node
)
4061 /* Output a (nameless) DIE to represent the formal parameter itself. */
4063 output_die (output_formal_parameter_die
, formal_type
);
4066 /* If this function type has an ellipsis, add a TAG_unspecified_parameters
4067 DIE to the end of the parameter list. */
4069 if (formal_type
!= void_type_node
)
4070 output_die (output_unspecified_parameters_die
, function_or_method_type
);
4072 /* Make our second (and final) pass over the list of formal parameter types
4073 and output DIEs to represent those types (as necessary). */
4075 for (link
= TYPE_ARG_TYPES (function_or_method_type
);
4077 link
= TREE_CHAIN (link
))
4079 formal_type
= TREE_VALUE (link
);
4080 if (formal_type
== void_type_node
)
4083 output_type (formal_type
, function_or_method_type
);
4086 TREE_ASM_WRITTEN (function_or_method_type
) = save_asm_written
;
4089 /* Remember a type in the pending_types_list. */
4095 if (pending_types
== pending_types_allocated
)
4097 pending_types_allocated
+= PENDING_TYPES_INCREMENT
;
4099 = (tree
*) xrealloc (pending_types_list
,
4100 sizeof (tree
) * pending_types_allocated
);
4102 pending_types_list
[pending_types
++] = type
;
4104 /* Mark the pending type as having been output already (even though
4105 it hasn't been). This prevents the type from being added to the
4106 pending_types_list more than once. */
4108 TREE_ASM_WRITTEN (type
) = 1;
4111 /* Return non-zero if it is legitimate to output DIEs to represent a
4112 given type while we are generating the list of child DIEs for some
4113 DIE (e.g. a function or lexical block DIE) associated with a given scope.
4115 See the comments within the function for a description of when it is
4116 considered legitimate to output DIEs for various kinds of types.
4118 Note that TYPE_CONTEXT(type) may be NULL (to indicate global scope)
4119 or it may point to a BLOCK node (for types local to a block), or to a
4120 FUNCTION_DECL node (for types local to the heading of some function
4121 definition), or to a FUNCTION_TYPE node (for types local to the
4122 prototyped parameter list of a function type specification), or to a
4123 RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node
4124 (in the case of C++ nested types).
4126 The `scope' parameter should likewise be NULL or should point to a
4127 BLOCK node, a FUNCTION_DECL node, a FUNCTION_TYPE node, a RECORD_TYPE
4128 node, a UNION_TYPE node, or a QUAL_UNION_TYPE node.
4130 This function is used only for deciding when to "pend" and when to
4131 "un-pend" types to/from the pending_types_list.
4133 Note that we sometimes make use of this "type pending" feature in a
4134 rather twisted way to temporarily delay the production of DIEs for the
4135 types of formal parameters. (We do this just to make svr4 SDB happy.)
4136 It order to delay the production of DIEs representing types of formal
4137 parameters, callers of this function supply `fake_containing_scope' as
4138 the `scope' parameter to this function. Given that fake_containing_scope
4139 is a tagged type which is *not* the containing scope for *any* other type,
4140 the desired effect is achieved, i.e. output of DIEs representing types
4141 is temporarily suspended, and any type DIEs which would have otherwise
4142 been output are instead placed onto the pending_types_list. Later on,
4143 we force these (temporarily pended) types to be output simply by calling
4144 `output_pending_types_for_scope' with an actual argument equal to the
4145 true scope of the types we temporarily pended. */
4148 type_ok_for_scope (type
, scope
)
4150 register tree scope
;
4152 /* Tagged types (i.e. struct, union, and enum types) must always be
4153 output only in the scopes where they actually belong (or else the
4154 scoping of their own tag names and the scoping of their member
4155 names will be incorrect). Non-tagged-types on the other hand can
4156 generally be output anywhere, except that svr4 SDB really doesn't
4157 want to see them nested within struct or union types, so here we
4158 say it is always OK to immediately output any such a (non-tagged)
4159 type, so long as we are not within such a context. Note that the
4160 only kinds of non-tagged types which we will be dealing with here
4161 (for C and C++ anyway) will be array types and function types. */
4163 return is_tagged_type (type
)
4164 ? (TYPE_CONTEXT (type
) == scope
4165 /* Ignore namespaces for the moment. */
4166 || (scope
== NULL_TREE
4167 && TREE_CODE (TYPE_CONTEXT (type
)) == NAMESPACE_DECL
)
4168 || (scope
== NULL_TREE
&& is_tagged_type (TYPE_CONTEXT (type
))
4169 && TREE_ASM_WRITTEN (TYPE_CONTEXT (type
))))
4170 : (scope
== NULL_TREE
|| ! is_tagged_type (scope
));
4173 /* Output any pending types (from the pending_types list) which we can output
4174 now (taking into account the scope that we are working on now).
4176 For each type output, remove the given type from the pending_types_list
4177 *before* we try to output it.
4179 Note that we have to process the list in beginning-to-end order,
4180 because the call made here to output_type may cause yet more types
4181 to be added to the end of the list, and we may have to output some
4185 output_pending_types_for_scope (containing_scope
)
4186 register tree containing_scope
;
4188 register unsigned i
;
4190 for (i
= 0; i
< pending_types
; )
4192 register tree type
= pending_types_list
[i
];
4194 if (type_ok_for_scope (type
, containing_scope
))
4196 register tree
*mover
;
4197 register tree
*limit
;
4200 limit
= &pending_types_list
[pending_types
];
4201 for (mover
= &pending_types_list
[i
]; mover
< limit
; mover
++)
4202 *mover
= *(mover
+1);
4204 /* Un-mark the type as having been output already (because it
4205 hasn't been, really). Then call output_type to generate a
4206 Dwarf representation of it. */
4208 TREE_ASM_WRITTEN (type
) = 0;
4209 output_type (type
, containing_scope
);
4211 /* Don't increment the loop counter in this case because we
4212 have shifted all of the subsequent pending types down one
4213 element in the pending_types_list array. */
4220 /* Remember a type in the incomplete_types_list. */
4223 add_incomplete_type (type
)
4226 if (incomplete_types
== incomplete_types_allocated
)
4228 incomplete_types_allocated
+= INCOMPLETE_TYPES_INCREMENT
;
4229 incomplete_types_list
4230 = (tree
*) xrealloc (incomplete_types_list
,
4231 sizeof (tree
) * incomplete_types_allocated
);
4234 incomplete_types_list
[incomplete_types
++] = type
;
4237 /* Walk through the list of incomplete types again, trying once more to
4238 emit full debugging info for them. */
4241 retry_incomplete_types ()
4246 while (incomplete_types
)
4249 type
= incomplete_types_list
[incomplete_types
];
4250 output_type (type
, NULL_TREE
);
4255 output_type (type
, containing_scope
)
4257 register tree containing_scope
;
4259 if (type
== 0 || type
== error_mark_node
)
4262 /* We are going to output a DIE to represent the unqualified version of
4263 this type (i.e. without any const or volatile qualifiers) so get
4264 the main variant (i.e. the unqualified version) of this type now. */
4266 type
= type_main_variant (type
);
4268 if (TREE_ASM_WRITTEN (type
))
4270 if (finalizing
&& AGGREGATE_TYPE_P (type
))
4272 register tree member
;
4274 /* Some of our nested types might not have been defined when we
4275 were written out before; force them out now. */
4277 for (member
= TYPE_FIELDS (type
); member
;
4278 member
= TREE_CHAIN (member
))
4279 if (TREE_CODE (member
) == TYPE_DECL
4280 && ! TREE_ASM_WRITTEN (TREE_TYPE (member
)))
4281 output_type (TREE_TYPE (member
), containing_scope
);
4286 /* If this is a nested type whose containing class hasn't been
4287 written out yet, writing it out will cover this one, too. */
4289 if (TYPE_CONTEXT (type
)
4290 && TYPE_P (TYPE_CONTEXT (type
))
4291 && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type
)))
4293 output_type (TYPE_CONTEXT (type
), containing_scope
);
4297 /* Don't generate any DIEs for this type now unless it is OK to do so
4298 (based upon what `type_ok_for_scope' tells us). */
4300 if (! type_ok_for_scope (type
, containing_scope
))
4306 switch (TREE_CODE (type
))
4312 case REFERENCE_TYPE
:
4313 /* Prevent infinite recursion in cases where this is a recursive
4314 type. Recursive types are possible in Ada. */
4315 TREE_ASM_WRITTEN (type
) = 1;
4316 /* For these types, all that is required is that we output a DIE
4317 (or a set of DIEs) to represent the "basis" type. */
4318 output_type (TREE_TYPE (type
), containing_scope
);
4322 /* This code is used for C++ pointer-to-data-member types. */
4323 /* Output a description of the relevant class type. */
4324 output_type (TYPE_OFFSET_BASETYPE (type
), containing_scope
);
4325 /* Output a description of the type of the object pointed to. */
4326 output_type (TREE_TYPE (type
), containing_scope
);
4327 /* Now output a DIE to represent this pointer-to-data-member type
4329 output_die (output_ptr_to_mbr_type_die
, type
);
4333 output_type (TYPE_DOMAIN (type
), containing_scope
);
4334 output_die (output_set_type_die
, type
);
4338 output_type (TREE_TYPE (type
), containing_scope
);
4339 abort (); /* No way to represent these in Dwarf yet! */
4343 /* Force out return type (in case it wasn't forced out already). */
4344 output_type (TREE_TYPE (type
), containing_scope
);
4345 output_die (output_subroutine_type_die
, type
);
4346 output_formal_types (type
);
4347 end_sibling_chain ();
4351 /* Force out return type (in case it wasn't forced out already). */
4352 output_type (TREE_TYPE (type
), containing_scope
);
4353 output_die (output_subroutine_type_die
, type
);
4354 output_formal_types (type
);
4355 end_sibling_chain ();
4359 if (TYPE_STRING_FLAG (type
) && TREE_CODE(TREE_TYPE(type
)) == CHAR_TYPE
)
4361 output_type (TREE_TYPE (type
), containing_scope
);
4362 output_die (output_string_type_die
, type
);
4366 register tree element_type
;
4368 element_type
= TREE_TYPE (type
);
4369 while (TREE_CODE (element_type
) == ARRAY_TYPE
)
4370 element_type
= TREE_TYPE (element_type
);
4372 output_type (element_type
, containing_scope
);
4373 output_die (output_array_type_die
, type
);
4380 case QUAL_UNION_TYPE
:
4382 /* For a non-file-scope tagged type, we can always go ahead and
4383 output a Dwarf description of this type right now, even if
4384 the type in question is still incomplete, because if this
4385 local type *was* ever completed anywhere within its scope,
4386 that complete definition would already have been attached to
4387 this RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE or ENUMERAL_TYPE
4388 node by the time we reach this point. That's true because of the
4389 way the front-end does its processing of file-scope declarations (of
4390 functions and class types) within which other types might be
4391 nested. The C and C++ front-ends always gobble up such "local
4392 scope" things en-mass before they try to output *any* debugging
4393 information for any of the stuff contained inside them and thus,
4394 we get the benefit here of what is (in effect) a pre-resolution
4395 of forward references to tagged types in local scopes.
4397 Note however that for file-scope tagged types we cannot assume
4398 that such pre-resolution of forward references has taken place.
4399 A given file-scope tagged type may appear to be incomplete when
4400 we reach this point, but it may yet be given a full definition
4401 (at file-scope) later on during compilation. In order to avoid
4402 generating a premature (and possibly incorrect) set of Dwarf
4403 DIEs for such (as yet incomplete) file-scope tagged types, we
4404 generate nothing at all for as-yet incomplete file-scope tagged
4405 types here unless we are making our special "finalization" pass
4406 for file-scope things at the very end of compilation. At that
4407 time, we will certainly know as much about each file-scope tagged
4408 type as we are ever going to know, so at that point in time, we
4409 can safely generate correct Dwarf descriptions for these file-
4410 scope tagged types. */
4412 if (!COMPLETE_TYPE_P (type
)
4413 && (TYPE_CONTEXT (type
) == NULL
4414 || AGGREGATE_TYPE_P (TYPE_CONTEXT (type
))
4415 || TREE_CODE (TYPE_CONTEXT (type
)) == NAMESPACE_DECL
)
4418 /* We don't need to do this for function-local types. */
4419 if (! decl_function_context (TYPE_STUB_DECL (type
)))
4420 add_incomplete_type (type
);
4421 return; /* EARLY EXIT! Avoid setting TREE_ASM_WRITTEN. */
4424 /* Prevent infinite recursion in cases where the type of some
4425 member of this type is expressed in terms of this type itself. */
4427 TREE_ASM_WRITTEN (type
) = 1;
4429 /* Output a DIE to represent the tagged type itself. */
4431 switch (TREE_CODE (type
))
4434 output_die (output_enumeration_type_die
, type
);
4435 return; /* a special case -- nothing left to do so just return */
4438 output_die (output_structure_type_die
, type
);
4442 case QUAL_UNION_TYPE
:
4443 output_die (output_union_type_die
, type
);
4447 abort (); /* Should never happen. */
4450 /* If this is not an incomplete type, output descriptions of
4451 each of its members.
4453 Note that as we output the DIEs necessary to represent the
4454 members of this record or union type, we will also be trying
4455 to output DIEs to represent the *types* of those members.
4456 However the `output_type' function (above) will specifically
4457 avoid generating type DIEs for member types *within* the list
4458 of member DIEs for this (containing) type execpt for those
4459 types (of members) which are explicitly marked as also being
4460 members of this (containing) type themselves. The g++ front-
4461 end can force any given type to be treated as a member of some
4462 other (containing) type by setting the TYPE_CONTEXT of the
4463 given (member) type to point to the TREE node representing the
4464 appropriate (containing) type.
4467 if (COMPLETE_TYPE_P (type
))
4469 /* First output info about the base classes. */
4470 if (TYPE_BINFO (type
) && TYPE_BINFO_BASETYPES (type
))
4472 register tree bases
= TYPE_BINFO_BASETYPES (type
);
4473 register int n_bases
= TREE_VEC_LENGTH (bases
);
4476 for (i
= 0; i
< n_bases
; i
++)
4478 tree binfo
= TREE_VEC_ELT (bases
, i
);
4479 output_type (BINFO_TYPE (binfo
), containing_scope
);
4480 output_die (output_inheritance_die
, binfo
);
4487 register tree normal_member
;
4489 /* Now output info about the data members and type members. */
4491 for (normal_member
= TYPE_FIELDS (type
);
4493 normal_member
= TREE_CHAIN (normal_member
))
4494 output_decl (normal_member
, type
);
4498 register tree func_member
;
4500 /* Now output info about the function members (if any). */
4502 for (func_member
= TYPE_METHODS (type
);
4504 func_member
= TREE_CHAIN (func_member
))
4505 output_decl (func_member
, type
);
4510 /* RECORD_TYPEs, UNION_TYPEs, and QUAL_UNION_TYPEs are themselves
4511 scopes (at least in C++) so we must now output any nested
4512 pending types which are local just to this type. */
4514 output_pending_types_for_scope (type
);
4516 end_sibling_chain (); /* Terminate member chain. */
4527 break; /* No DIEs needed for fundamental types. */
4529 case LANG_TYPE
: /* No Dwarf representation currently defined. */
4536 TREE_ASM_WRITTEN (type
) = 1;
4540 output_tagged_type_instantiation (type
)
4543 if (type
== 0 || type
== error_mark_node
)
4546 /* We are going to output a DIE to represent the unqualified version of
4547 this type (i.e. without any const or volatile qualifiers) so make
4548 sure that we have the main variant (i.e. the unqualified version) of
4551 if (type
!= type_main_variant (type
))
4554 if (!TREE_ASM_WRITTEN (type
))
4557 switch (TREE_CODE (type
))
4563 output_die (output_inlined_enumeration_type_die
, type
);
4567 output_die (output_inlined_structure_type_die
, type
);
4571 case QUAL_UNION_TYPE
:
4572 output_die (output_inlined_union_type_die
, type
);
4576 abort (); /* Should never happen. */
4580 /* Output a TAG_lexical_block DIE followed by DIEs to represent all of
4581 the things which are local to the given block. */
4584 output_block (stmt
, depth
)
4588 register int must_output_die
= 0;
4589 register tree origin
;
4590 register enum tree_code origin_code
;
4592 /* Ignore blocks never really used to make RTL. */
4594 if (! stmt
|| ! TREE_USED (stmt
)
4595 || (!TREE_ASM_WRITTEN (stmt
) && !BLOCK_ABSTRACT (stmt
)))
4598 /* Determine the "ultimate origin" of this block. This block may be an
4599 inlined instance of an inlined instance of inline function, so we
4600 have to trace all of the way back through the origin chain to find
4601 out what sort of node actually served as the original seed for the
4602 creation of the current block. */
4604 origin
= block_ultimate_origin (stmt
);
4605 origin_code
= (origin
!= NULL
) ? TREE_CODE (origin
) : ERROR_MARK
;
4607 /* Determine if we need to output any Dwarf DIEs at all to represent this
4610 if (origin_code
== FUNCTION_DECL
)
4611 /* The outer scopes for inlinings *must* always be represented. We
4612 generate TAG_inlined_subroutine DIEs for them. (See below.) */
4613 must_output_die
= 1;
4616 /* In the case where the current block represents an inlining of the
4617 "body block" of an inline function, we must *NOT* output any DIE
4618 for this block because we have already output a DIE to represent
4619 the whole inlined function scope and the "body block" of any
4620 function doesn't really represent a different scope according to
4621 ANSI C rules. So we check here to make sure that this block does
4622 not represent a "body block inlining" before trying to set the
4623 `must_output_die' flag. */
4625 if (! is_body_block (origin
? origin
: stmt
))
4627 /* Determine if this block directly contains any "significant"
4628 local declarations which we will need to output DIEs for. */
4630 if (debug_info_level
> DINFO_LEVEL_TERSE
)
4631 /* We are not in terse mode so *any* local declaration counts
4632 as being a "significant" one. */
4633 must_output_die
= (BLOCK_VARS (stmt
) != NULL
);
4638 /* We are in terse mode, so only local (nested) function
4639 definitions count as "significant" local declarations. */
4641 for (decl
= BLOCK_VARS (stmt
); decl
; decl
= TREE_CHAIN (decl
))
4642 if (TREE_CODE (decl
) == FUNCTION_DECL
&& DECL_INITIAL (decl
))
4644 must_output_die
= 1;
4651 /* It would be a waste of space to generate a Dwarf TAG_lexical_block
4652 DIE for any block which contains no significant local declarations
4653 at all. Rather, in such cases we just call `output_decls_for_scope'
4654 so that any needed Dwarf info for any sub-blocks will get properly
4655 generated. Note that in terse mode, our definition of what constitutes
4656 a "significant" local declaration gets restricted to include only
4657 inlined function instances and local (nested) function definitions. */
4659 if (origin_code
== FUNCTION_DECL
&& BLOCK_ABSTRACT (stmt
))
4660 /* We don't care about an abstract inlined subroutine. */;
4661 else if (must_output_die
)
4663 output_die ((origin_code
== FUNCTION_DECL
)
4664 ? output_inlined_subroutine_die
4665 : output_lexical_block_die
,
4667 output_decls_for_scope (stmt
, depth
);
4668 end_sibling_chain ();
4671 output_decls_for_scope (stmt
, depth
);
4674 /* Output all of the decls declared within a given scope (also called
4675 a `binding contour') and (recursively) all of it's sub-blocks. */
4678 output_decls_for_scope (stmt
, depth
)
4682 /* Ignore blocks never really used to make RTL. */
4684 if (! stmt
|| ! TREE_USED (stmt
))
4687 /* Output the DIEs to represent all of the data objects, functions,
4688 typedefs, and tagged types declared directly within this block
4689 but not within any nested sub-blocks. */
4694 for (decl
= BLOCK_VARS (stmt
); decl
; decl
= TREE_CHAIN (decl
))
4695 output_decl (decl
, stmt
);
4698 output_pending_types_for_scope (stmt
);
4700 /* Output the DIEs to represent all sub-blocks (and the items declared
4701 therein) of this block. */
4704 register tree subblocks
;
4706 for (subblocks
= BLOCK_SUBBLOCKS (stmt
);
4708 subblocks
= BLOCK_CHAIN (subblocks
))
4709 output_block (subblocks
, depth
+ 1);
4713 /* Is this a typedef we can avoid emitting? */
4716 is_redundant_typedef (decl
)
4719 if (TYPE_DECL_IS_STUB (decl
))
4721 if (DECL_ARTIFICIAL (decl
)
4722 && DECL_CONTEXT (decl
)
4723 && is_tagged_type (DECL_CONTEXT (decl
))
4724 && TREE_CODE (TYPE_NAME (DECL_CONTEXT (decl
))) == TYPE_DECL
4725 && DECL_NAME (decl
) == DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl
))))
4726 /* Also ignore the artificial member typedef for the class name. */
4731 /* Output Dwarf .debug information for a decl described by DECL. */
4734 output_decl (decl
, containing_scope
)
4736 register tree containing_scope
;
4738 /* Make a note of the decl node we are going to be working on. We may
4739 need to give the user the source coordinates of where it appeared in
4740 case we notice (later on) that something about it looks screwy. */
4742 dwarf_last_decl
= decl
;
4744 if (TREE_CODE (decl
) == ERROR_MARK
)
4747 /* If a structure is declared within an initialization, e.g. as the
4748 operand of a sizeof, then it will not have a name. We don't want
4749 to output a DIE for it, as the tree nodes are in the temporary obstack */
4751 if ((TREE_CODE (TREE_TYPE (decl
)) == RECORD_TYPE
4752 || TREE_CODE (TREE_TYPE (decl
)) == UNION_TYPE
)
4753 && ((DECL_NAME (decl
) == 0 && TYPE_NAME (TREE_TYPE (decl
)) == 0)
4754 || (TYPE_FIELDS (TREE_TYPE (decl
))
4755 && (TREE_CODE (TYPE_FIELDS (TREE_TYPE (decl
))) == ERROR_MARK
))))
4758 /* If this ..._DECL node is marked to be ignored, then ignore it. */
4760 if (DECL_IGNORED_P (decl
))
4763 switch (TREE_CODE (decl
))
4766 /* The individual enumerators of an enum type get output when we
4767 output the Dwarf representation of the relevant enum type itself. */
4771 /* If we are in terse mode, don't output any DIEs to represent
4772 mere function declarations. Also, if we are conforming
4773 to the DWARF version 1 specification, don't output DIEs for
4774 mere function declarations. */
4776 if (DECL_INITIAL (decl
) == NULL_TREE
)
4777 #if (DWARF_VERSION > 1)
4778 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
4782 /* Before we describe the FUNCTION_DECL itself, make sure that we
4783 have described its return type. */
4785 output_type (TREE_TYPE (TREE_TYPE (decl
)), containing_scope
);
4788 /* And its containing type. */
4789 register tree origin
= decl_class_context (decl
);
4791 output_type (origin
, containing_scope
);
4794 /* If the following DIE will represent a function definition for a
4795 function with "extern" linkage, output a special "pubnames" DIE
4796 label just ahead of the actual DIE. A reference to this label
4797 was already generated in the .debug_pubnames section sub-entry
4798 for this function definition. */
4800 if (TREE_PUBLIC (decl
))
4802 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4804 sprintf (label
, PUB_DIE_LABEL_FMT
, next_pubname_number
++);
4805 ASM_OUTPUT_LABEL (asm_out_file
, label
);
4808 /* Now output a DIE to represent the function itself. */
4810 output_die (TREE_PUBLIC (decl
) || DECL_EXTERNAL (decl
)
4811 ? output_global_subroutine_die
4812 : output_local_subroutine_die
,
4815 /* Now output descriptions of the arguments for this function.
4816 This gets (unnecessarily?) complex because of the fact that
4817 the DECL_ARGUMENT list for a FUNCTION_DECL doesn't indicate
4818 cases where there was a trailing `...' at the end of the formal
4819 parameter list. In order to find out if there was a trailing
4820 ellipsis or not, we must instead look at the type associated
4821 with the FUNCTION_DECL. This will be a node of type FUNCTION_TYPE.
4822 If the chain of type nodes hanging off of this FUNCTION_TYPE node
4823 ends with a void_type_node then there should *not* be an ellipsis
4826 /* In the case where we are describing a mere function declaration, all
4827 we need to do here (and all we *can* do here) is to describe
4828 the *types* of its formal parameters. */
4830 if (decl
!= current_function_decl
|| in_class
)
4831 output_formal_types (TREE_TYPE (decl
));
4834 /* Generate DIEs to represent all known formal parameters */
4836 register tree arg_decls
= DECL_ARGUMENTS (decl
);
4839 /* WARNING! Kludge zone ahead! Here we have a special
4840 hack for svr4 SDB compatibility. Instead of passing the
4841 current FUNCTION_DECL node as the second parameter (i.e.
4842 the `containing_scope' parameter) to `output_decl' (as
4843 we ought to) we instead pass a pointer to our own private
4844 fake_containing_scope node. That node is a RECORD_TYPE
4845 node which NO OTHER TYPE may ever actually be a member of.
4847 This pointer will ultimately get passed into `output_type'
4848 as its `containing_scope' parameter. `Output_type' will
4849 then perform its part in the hack... i.e. it will pend
4850 the type of the formal parameter onto the pending_types
4851 list. Later on, when we are done generating the whole
4852 sequence of formal parameter DIEs for this function
4853 definition, we will un-pend all previously pended types
4854 of formal parameters for this function definition.
4856 This whole kludge prevents any type DIEs from being
4857 mixed in with the formal parameter DIEs. That's good
4858 because svr4 SDB believes that the list of formal
4859 parameter DIEs for a function ends wherever the first
4860 non-formal-parameter DIE appears. Thus, we have to
4861 keep the formal parameter DIEs segregated. They must
4862 all appear (consecutively) at the start of the list of
4863 children for the DIE representing the function definition.
4864 Then (and only then) may we output any additional DIEs
4865 needed to represent the types of these formal parameters.
4869 When generating DIEs, generate the unspecified_parameters
4870 DIE instead if we come across the arg "__builtin_va_alist"
4873 for (parm
= arg_decls
; parm
; parm
= TREE_CHAIN (parm
))
4874 if (TREE_CODE (parm
) == PARM_DECL
)
4876 if (DECL_NAME(parm
) &&
4877 !strcmp(IDENTIFIER_POINTER(DECL_NAME(parm
)),
4878 "__builtin_va_alist") )
4879 output_die (output_unspecified_parameters_die
, decl
);
4881 output_decl (parm
, fake_containing_scope
);
4885 Now that we have finished generating all of the DIEs to
4886 represent the formal parameters themselves, force out
4887 any DIEs needed to represent their types. We do this
4888 simply by un-pending all previously pended types which
4889 can legitimately go into the chain of children DIEs for
4890 the current FUNCTION_DECL.
4893 output_pending_types_for_scope (decl
);
4896 Decide whether we need a unspecified_parameters DIE at the end.
4897 There are 2 more cases to do this for:
4898 1) the ansi ... declaration - this is detectable when the end
4899 of the arg list is not a void_type_node
4900 2) an unprototyped function declaration (not a definition). This
4901 just means that we have no info about the parameters at all.
4905 register tree fn_arg_types
= TYPE_ARG_TYPES (TREE_TYPE (decl
));
4909 /* this is the prototyped case, check for ... */
4910 if (TREE_VALUE (tree_last (fn_arg_types
)) != void_type_node
)
4911 output_die (output_unspecified_parameters_die
, decl
);
4915 /* this is unprototyped, check for undefined (just declaration) */
4916 if (!DECL_INITIAL (decl
))
4917 output_die (output_unspecified_parameters_die
, decl
);
4921 /* Output Dwarf info for all of the stuff within the body of the
4922 function (if it has one - it may be just a declaration). */
4925 register tree outer_scope
= DECL_INITIAL (decl
);
4927 if (outer_scope
&& TREE_CODE (outer_scope
) != ERROR_MARK
)
4929 /* Note that here, `outer_scope' is a pointer to the outermost
4930 BLOCK node created to represent a function.
4931 This outermost BLOCK actually represents the outermost
4932 binding contour for the function, i.e. the contour in which
4933 the function's formal parameters and labels get declared.
4935 Curiously, it appears that the front end doesn't actually
4936 put the PARM_DECL nodes for the current function onto the
4937 BLOCK_VARS list for this outer scope. (They are strung
4938 off of the DECL_ARGUMENTS list for the function instead.)
4939 The BLOCK_VARS list for the `outer_scope' does provide us
4940 with a list of the LABEL_DECL nodes for the function however,
4941 and we output DWARF info for those here.
4943 Just within the `outer_scope' there will be a BLOCK node
4944 representing the function's outermost pair of curly braces,
4945 and any blocks used for the base and member initializers of
4946 a C++ constructor function. */
4948 output_decls_for_scope (outer_scope
, 0);
4950 /* Finally, force out any pending types which are local to the
4951 outermost block of this function definition. These will
4952 all have a TYPE_CONTEXT which points to the FUNCTION_DECL
4955 output_pending_types_for_scope (decl
);
4960 /* Generate a terminator for the list of stuff `owned' by this
4963 end_sibling_chain ();
4968 /* If we are in terse mode, don't generate any DIEs to represent
4969 any actual typedefs. Note that even when we are in terse mode,
4970 we must still output DIEs to represent those tagged types which
4971 are used (directly or indirectly) in the specification of either
4972 a return type or a formal parameter type of some function. */
4974 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
4975 if (! TYPE_DECL_IS_STUB (decl
)
4976 || (! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl
)) && ! in_class
))
4979 /* In the special case of a TYPE_DECL node representing
4980 the declaration of some type tag, if the given TYPE_DECL is
4981 marked as having been instantiated from some other (original)
4982 TYPE_DECL node (e.g. one which was generated within the original
4983 definition of an inline function) we have to generate a special
4984 (abbreviated) TAG_structure_type, TAG_union_type, or
4985 TAG_enumeration-type DIE here. */
4987 if (TYPE_DECL_IS_STUB (decl
) && DECL_ABSTRACT_ORIGIN (decl
))
4989 output_tagged_type_instantiation (TREE_TYPE (decl
));
4993 output_type (TREE_TYPE (decl
), containing_scope
);
4995 if (! is_redundant_typedef (decl
))
4996 /* Output a DIE to represent the typedef itself. */
4997 output_die (output_typedef_die
, decl
);
5001 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
5002 output_die (output_label_die
, decl
);
5006 /* If we are conforming to the DWARF version 1 specification, don't
5007 generated any DIEs to represent mere external object declarations. */
5009 #if (DWARF_VERSION <= 1)
5010 if (DECL_EXTERNAL (decl
) && ! TREE_PUBLIC (decl
))
5014 /* If we are in terse mode, don't generate any DIEs to represent
5015 any variable declarations or definitions. */
5017 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
5020 /* Output any DIEs that are needed to specify the type of this data
5023 output_type (TREE_TYPE (decl
), containing_scope
);
5026 /* And its containing type. */
5027 register tree origin
= decl_class_context (decl
);
5029 output_type (origin
, containing_scope
);
5032 /* If the following DIE will represent a data object definition for a
5033 data object with "extern" linkage, output a special "pubnames" DIE
5034 label just ahead of the actual DIE. A reference to this label
5035 was already generated in the .debug_pubnames section sub-entry
5036 for this data object definition. */
5038 if (TREE_PUBLIC (decl
) && ! DECL_ABSTRACT (decl
))
5040 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5042 sprintf (label
, PUB_DIE_LABEL_FMT
, next_pubname_number
++);
5043 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5046 /* Now output the DIE to represent the data object itself. This gets
5047 complicated because of the possibility that the VAR_DECL really
5048 represents an inlined instance of a formal parameter for an inline
5052 register void (*func
) PARAMS ((void *));
5053 register tree origin
= decl_ultimate_origin (decl
);
5055 if (origin
!= NULL
&& TREE_CODE (origin
) == PARM_DECL
)
5056 func
= output_formal_parameter_die
;
5059 if (TREE_PUBLIC (decl
) || DECL_EXTERNAL (decl
))
5060 func
= output_global_variable_die
;
5062 func
= output_local_variable_die
;
5064 output_die (func
, decl
);
5069 /* Ignore the nameless fields that are used to skip bits. */
5070 if (DECL_NAME (decl
) != 0)
5072 output_type (member_declared_type (decl
), containing_scope
);
5073 output_die (output_member_die
, decl
);
5078 /* Force out the type of this formal, if it was not forced out yet.
5079 Note that here we can run afowl of a bug in "classic" svr4 SDB.
5080 It should be able to grok the presence of type DIEs within a list
5081 of TAG_formal_parameter DIEs, but it doesn't. */
5083 output_type (TREE_TYPE (decl
), containing_scope
);
5084 output_die (output_formal_parameter_die
, decl
);
5093 dwarfout_file_scope_decl (decl
, set_finalizing
)
5095 register int set_finalizing
;
5097 if (TREE_CODE (decl
) == ERROR_MARK
)
5100 /* If this ..._DECL node is marked to be ignored, then ignore it. */
5102 if (DECL_IGNORED_P (decl
))
5105 switch (TREE_CODE (decl
))
5109 /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of
5110 a builtin function. Explicit programmer-supplied declarations of
5111 these same functions should NOT be ignored however. */
5113 if (DECL_EXTERNAL (decl
) && DECL_FUNCTION_CODE (decl
))
5116 /* What we would really like to do here is to filter out all mere
5117 file-scope declarations of file-scope functions which are never
5118 referenced later within this translation unit (and keep all of
5119 ones that *are* referenced later on) but we aren't clairvoyant,
5120 so we have no idea which functions will be referenced in the
5121 future (i.e. later on within the current translation unit).
5122 So here we just ignore all file-scope function declarations
5123 which are not also definitions. If and when the debugger needs
5124 to know something about these functions, it wil have to hunt
5125 around and find the DWARF information associated with the
5126 *definition* of the function.
5128 Note that we can't just check `DECL_EXTERNAL' to find out which
5129 FUNCTION_DECL nodes represent definitions and which ones represent
5130 mere declarations. We have to check `DECL_INITIAL' instead. That's
5131 because the C front-end supports some weird semantics for "extern
5132 inline" function definitions. These can get inlined within the
5133 current translation unit (an thus, we need to generate DWARF info
5134 for their abstract instances so that the DWARF info for the
5135 concrete inlined instances can have something to refer to) but
5136 the compiler never generates any out-of-lines instances of such
5137 things (despite the fact that they *are* definitions). The
5138 important point is that the C front-end marks these "extern inline"
5139 functions as DECL_EXTERNAL, but we need to generate DWARF for them
5142 Note that the C++ front-end also plays some similar games for inline
5143 function definitions appearing within include files which also
5144 contain `#pragma interface' pragmas. */
5146 if (DECL_INITIAL (decl
) == NULL_TREE
)
5149 if (TREE_PUBLIC (decl
)
5150 && ! DECL_EXTERNAL (decl
)
5151 && ! DECL_ABSTRACT (decl
))
5153 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5155 /* Output a .debug_pubnames entry for a public function
5156 defined in this compilation unit. */
5158 fputc ('\n', asm_out_file
);
5159 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, PUBNAMES_SECTION
);
5160 sprintf (label
, PUB_DIE_LABEL_FMT
, next_pubname_number
);
5161 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, label
);
5162 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
,
5163 IDENTIFIER_POINTER (DECL_NAME (decl
)));
5164 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5171 /* Ignore this VAR_DECL if it refers to a file-scope extern data
5172 object declaration and if the declaration was never even
5173 referenced from within this entire compilation unit. We
5174 suppress these DIEs in order to save space in the .debug section
5175 (by eliminating entries which are probably useless). Note that
5176 we must not suppress block-local extern declarations (whether
5177 used or not) because that would screw-up the debugger's name
5178 lookup mechanism and cause it to miss things which really ought
5179 to be in scope at a given point. */
5181 if (DECL_EXTERNAL (decl
) && !TREE_USED (decl
))
5184 if (TREE_PUBLIC (decl
)
5185 && ! DECL_EXTERNAL (decl
)
5186 && GET_CODE (DECL_RTL (decl
)) == MEM
5187 && ! DECL_ABSTRACT (decl
))
5189 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5191 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
5193 /* Output a .debug_pubnames entry for a public variable
5194 defined in this compilation unit. */
5196 fputc ('\n', asm_out_file
);
5197 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, PUBNAMES_SECTION
);
5198 sprintf (label
, PUB_DIE_LABEL_FMT
, next_pubname_number
);
5199 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, label
);
5200 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
,
5201 IDENTIFIER_POINTER (DECL_NAME (decl
)));
5202 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5205 if (DECL_INITIAL (decl
) == NULL
)
5207 /* Output a .debug_aranges entry for a public variable
5208 which is tentatively defined in this compilation unit. */
5210 fputc ('\n', asm_out_file
);
5211 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, ARANGES_SECTION
);
5212 ASM_OUTPUT_DWARF_ADDR (asm_out_file
,
5213 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
5214 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
5215 (unsigned) int_size_in_bytes (TREE_TYPE (decl
)));
5216 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5220 /* If we are in terse mode, don't generate any DIEs to represent
5221 any variable declarations or definitions. */
5223 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
5229 /* Don't bother trying to generate any DIEs to represent any of the
5230 normal built-in types for the language we are compiling, except
5231 in cases where the types in question are *not* DWARF fundamental
5232 types. We make an exception in the case of non-fundamental types
5233 for the sake of objective C (and perhaps C++) because the GNU
5234 front-ends for these languages may in fact create certain "built-in"
5235 types which are (for example) RECORD_TYPEs. In such cases, we
5236 really need to output these (non-fundamental) types because other
5237 DIEs may contain references to them. */
5239 /* Also ignore language dependent types here, because they are probably
5240 also built-in types. If we didn't ignore them, then we would get
5241 references to undefined labels because output_type doesn't support
5242 them. So, for now, we need to ignore them to avoid assembler
5245 /* ??? This code is different than the equivalent code in dwarf2out.c.
5246 The dwarf2out.c code is probably more correct. */
5248 if (DECL_SOURCE_LINE (decl
) == 0
5249 && (type_is_fundamental (TREE_TYPE (decl
))
5250 || TREE_CODE (TREE_TYPE (decl
)) == LANG_TYPE
))
5253 /* If we are in terse mode, don't generate any DIEs to represent
5254 any actual typedefs. Note that even when we are in terse mode,
5255 we must still output DIEs to represent those tagged types which
5256 are used (directly or indirectly) in the specification of either
5257 a return type or a formal parameter type of some function. */
5259 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
5260 if (! TYPE_DECL_IS_STUB (decl
)
5261 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl
)))
5270 fputc ('\n', asm_out_file
);
5271 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DEBUG_SECTION
);
5272 finalizing
= set_finalizing
;
5273 output_decl (decl
, NULL_TREE
);
5275 /* NOTE: The call above to `output_decl' may have caused one or more
5276 file-scope named types (i.e. tagged types) to be placed onto the
5277 pending_types_list. We have to get those types off of that list
5278 at some point, and this is the perfect time to do it. If we didn't
5279 take them off now, they might still be on the list when cc1 finally
5280 exits. That might be OK if it weren't for the fact that when we put
5281 types onto the pending_types_list, we set the TREE_ASM_WRITTEN flag
5282 for these types, and that causes them never to be output unless
5283 `output_pending_types_for_scope' takes them off of the list and un-sets
5284 their TREE_ASM_WRITTEN flags. */
5286 output_pending_types_for_scope (NULL_TREE
);
5288 /* The above call should have totally emptied the pending_types_list
5289 if this is not a nested function or class. If this is a nested type,
5290 then the remaining pending_types will be emitted when the containing type
5293 if (! DECL_CONTEXT (decl
))
5295 if (pending_types
!= 0)
5299 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5301 if (TREE_CODE (decl
) == FUNCTION_DECL
&& DECL_INITIAL (decl
) != NULL
)
5302 current_funcdef_number
++;
5305 /* Output a marker (i.e. a label) for the beginning of the generated code
5306 for a lexical block. */
5309 dwarfout_begin_block (blocknum
)
5310 register unsigned blocknum
;
5312 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5314 function_section (current_function_decl
);
5315 sprintf (label
, BLOCK_BEGIN_LABEL_FMT
, blocknum
);
5316 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5319 /* Output a marker (i.e. a label) for the end of the generated code
5320 for a lexical block. */
5323 dwarfout_end_block (blocknum
)
5324 register unsigned blocknum
;
5326 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5328 function_section (current_function_decl
);
5329 sprintf (label
, BLOCK_END_LABEL_FMT
, blocknum
);
5330 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5333 /* Output a marker (i.e. a label) at a point in the assembly code which
5334 corresponds to a given source level label. */
5337 dwarfout_label (insn
)
5340 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
5342 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5344 function_section (current_function_decl
);
5345 sprintf (label
, INSN_LABEL_FMT
, current_funcdef_number
,
5346 (unsigned) INSN_UID (insn
));
5347 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5351 /* Output a marker (i.e. a label) for the point in the generated code where
5352 the real body of the function begins (after parameters have been moved
5353 to their home locations). */
5356 dwarfout_begin_function ()
5358 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5360 if (! use_gnu_debug_info_extensions
)
5362 function_section (current_function_decl
);
5363 sprintf (label
, BODY_BEGIN_LABEL_FMT
, current_funcdef_number
);
5364 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5367 /* Output a marker (i.e. a label) for the point in the generated code where
5368 the real body of the function ends (just before the epilogue code). */
5371 dwarfout_end_function ()
5373 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5375 if (! use_gnu_debug_info_extensions
)
5377 function_section (current_function_decl
);
5378 sprintf (label
, BODY_END_LABEL_FMT
, current_funcdef_number
);
5379 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5382 /* Output a marker (i.e. a label) for the absolute end of the generated code
5383 for a function definition. This gets called *after* the epilogue code
5384 has been generated. */
5387 dwarfout_end_epilogue ()
5389 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5391 /* Output a label to mark the endpoint of the code generated for this
5394 sprintf (label
, FUNC_END_LABEL_FMT
, current_funcdef_number
);
5395 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5399 shuffle_filename_entry (new_zeroth
)
5400 register filename_entry
*new_zeroth
;
5402 filename_entry temp_entry
;
5403 register filename_entry
*limit_p
;
5404 register filename_entry
*move_p
;
5406 if (new_zeroth
== &filename_table
[0])
5409 temp_entry
= *new_zeroth
;
5411 /* Shift entries up in the table to make room at [0]. */
5413 limit_p
= &filename_table
[0];
5414 for (move_p
= new_zeroth
; move_p
> limit_p
; move_p
--)
5415 *move_p
= *(move_p
-1);
5417 /* Install the found entry at [0]. */
5419 filename_table
[0] = temp_entry
;
5422 /* Create a new (string) entry for the .debug_sfnames section. */
5425 generate_new_sfname_entry ()
5427 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5429 fputc ('\n', asm_out_file
);
5430 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, SFNAMES_SECTION
);
5431 sprintf (label
, SFNAMES_ENTRY_LABEL_FMT
, filename_table
[0].number
);
5432 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5433 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
,
5434 filename_table
[0].name
5435 ? filename_table
[0].name
5437 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5440 /* Lookup a filename (in the list of filenames that we know about here in
5441 dwarfout.c) and return its "index". The index of each (known) filename
5442 is just a unique number which is associated with only that one filename.
5443 We need such numbers for the sake of generating labels (in the
5444 .debug_sfnames section) and references to those unique labels (in the
5445 .debug_srcinfo and .debug_macinfo sections).
5447 If the filename given as an argument is not found in our current list,
5448 add it to the list and assign it the next available unique index number.
5450 Whatever we do (i.e. whether we find a pre-existing filename or add a new
5451 one), we shuffle the filename found (or added) up to the zeroth entry of
5452 our list of filenames (which is always searched linearly). We do this so
5453 as to optimize the most common case for these filename lookups within
5454 dwarfout.c. The most common case by far is the case where we call
5455 lookup_filename to lookup the very same filename that we did a lookup
5456 on the last time we called lookup_filename. We make sure that this
5457 common case is fast because such cases will constitute 99.9% of the
5458 lookups we ever do (in practice).
5460 If we add a new filename entry to our table, we go ahead and generate
5461 the corresponding entry in the .debug_sfnames section right away.
5462 Doing so allows us to avoid tickling an assembler bug (present in some
5463 m68k assemblers) which yields assembly-time errors in cases where the
5464 difference of two label addresses is taken and where the two labels
5465 are in a section *other* than the one where the difference is being
5466 calculated, and where at least one of the two symbol references is a
5467 forward reference. (This bug could be tickled by our .debug_srcinfo
5468 entries if we don't output their corresponding .debug_sfnames entries
5472 lookup_filename (file_name
)
5473 const char *file_name
;
5475 register filename_entry
*search_p
;
5476 register filename_entry
*limit_p
= &filename_table
[ft_entries
];
5478 for (search_p
= filename_table
; search_p
< limit_p
; search_p
++)
5479 if (!strcmp (file_name
, search_p
->name
))
5481 /* When we get here, we have found the filename that we were
5482 looking for in the filename_table. Now we want to make sure
5483 that it gets moved to the zero'th entry in the table (if it
5484 is not already there) so that subsequent attempts to find the
5485 same filename will find it as quickly as possible. */
5487 shuffle_filename_entry (search_p
);
5488 return filename_table
[0].number
;
5491 /* We come here whenever we have a new filename which is not registered
5492 in the current table. Here we add it to the table. */
5494 /* Prepare to add a new table entry by making sure there is enough space
5495 in the table to do so. If not, expand the current table. */
5497 if (ft_entries
== ft_entries_allocated
)
5499 ft_entries_allocated
+= FT_ENTRIES_INCREMENT
;
5501 = (filename_entry
*)
5502 xrealloc (filename_table
,
5503 ft_entries_allocated
* sizeof (filename_entry
));
5506 /* Initially, add the new entry at the end of the filename table. */
5508 filename_table
[ft_entries
].number
= ft_entries
;
5509 filename_table
[ft_entries
].name
= xstrdup (file_name
);
5511 /* Shuffle the new entry into filename_table[0]. */
5513 shuffle_filename_entry (&filename_table
[ft_entries
]);
5515 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
5516 generate_new_sfname_entry ();
5519 return filename_table
[0].number
;
5523 generate_srcinfo_entry (line_entry_num
, files_entry_num
)
5524 unsigned line_entry_num
;
5525 unsigned files_entry_num
;
5527 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5529 fputc ('\n', asm_out_file
);
5530 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, SRCINFO_SECTION
);
5531 sprintf (label
, LINE_ENTRY_LABEL_FMT
, line_entry_num
);
5532 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, label
, LINE_BEGIN_LABEL
);
5533 sprintf (label
, SFNAMES_ENTRY_LABEL_FMT
, files_entry_num
);
5534 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, label
, SFNAMES_BEGIN_LABEL
);
5535 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5539 dwarfout_line (filename
, line
)
5540 register const char *filename
;
5541 register unsigned line
;
5543 if (debug_info_level
>= DINFO_LEVEL_NORMAL
5544 /* We can't emit line number info for functions in separate sections,
5545 because the assembler can't subtract labels in different sections. */
5546 && DECL_SECTION_NAME (current_function_decl
) == NULL_TREE
)
5548 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5549 static unsigned last_line_entry_num
= 0;
5550 static unsigned prev_file_entry_num
= (unsigned) -1;
5551 register unsigned this_file_entry_num
;
5553 function_section (current_function_decl
);
5554 sprintf (label
, LINE_CODE_LABEL_FMT
, ++last_line_entry_num
);
5555 ASM_OUTPUT_LABEL (asm_out_file
, label
);
5557 fputc ('\n', asm_out_file
);
5559 if (use_gnu_debug_info_extensions
)
5560 this_file_entry_num
= lookup_filename (filename
);
5562 this_file_entry_num
= (unsigned) -1;
5564 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, LINE_SECTION
);
5565 if (this_file_entry_num
!= prev_file_entry_num
)
5567 char line_entry_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5569 sprintf (line_entry_label
, LINE_ENTRY_LABEL_FMT
, last_line_entry_num
);
5570 ASM_OUTPUT_LABEL (asm_out_file
, line_entry_label
);
5574 register const char *tail
= rindex (filename
, '/');
5580 fprintf (asm_out_file
, "\t%s\t%u\t%s %s:%u\n",
5581 UNALIGNED_INT_ASM_OP
, line
, ASM_COMMENT_START
,
5583 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, 0xffff);
5584 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, label
, TEXT_BEGIN_LABEL
);
5585 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5587 if (this_file_entry_num
!= prev_file_entry_num
)
5588 generate_srcinfo_entry (last_line_entry_num
, this_file_entry_num
);
5589 prev_file_entry_num
= this_file_entry_num
;
5593 /* Generate an entry in the .debug_macinfo section. */
5596 generate_macinfo_entry (type_and_offset
, string
)
5597 register const char *type_and_offset
;
5598 register const char *string
;
5600 if (! use_gnu_debug_info_extensions
)
5603 fputc ('\n', asm_out_file
);
5604 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, MACINFO_SECTION
);
5605 fprintf (asm_out_file
, "\t%s\t%s\n", UNALIGNED_INT_ASM_OP
, type_and_offset
);
5606 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, string
);
5607 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5611 dwarfout_start_new_source_file (filename
)
5612 register const char *filename
;
5614 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5615 char type_and_offset
[MAX_ARTIFICIAL_LABEL_BYTES
*3];
5617 sprintf (label
, SFNAMES_ENTRY_LABEL_FMT
, lookup_filename (filename
));
5618 sprintf (type_and_offset
, "0x%08x+%s-%s",
5619 ((unsigned) MACINFO_start
<< 24),
5620 /* Hack: skip leading '*' . */
5621 (*label
== '*') + label
,
5622 (*SFNAMES_BEGIN_LABEL
== '*') + SFNAMES_BEGIN_LABEL
);
5623 generate_macinfo_entry (type_and_offset
, "");
5627 dwarfout_resume_previous_source_file (lineno
)
5628 register unsigned lineno
;
5630 char type_and_offset
[MAX_ARTIFICIAL_LABEL_BYTES
*2];
5632 sprintf (type_and_offset
, "0x%08x+%u",
5633 ((unsigned) MACINFO_resume
<< 24), lineno
);
5634 generate_macinfo_entry (type_and_offset
, "");
5637 /* Called from check_newline in c-parse.y. The `buffer' parameter
5638 contains the tail part of the directive line, i.e. the part which
5639 is past the initial whitespace, #, whitespace, directive-name,
5643 dwarfout_define (lineno
, buffer
)
5644 register unsigned lineno
;
5645 register const char *buffer
;
5647 static int initialized
= 0;
5648 char type_and_offset
[MAX_ARTIFICIAL_LABEL_BYTES
*2];
5652 dwarfout_start_new_source_file (primary_filename
);
5655 sprintf (type_and_offset
, "0x%08x+%u",
5656 ((unsigned) MACINFO_define
<< 24), lineno
);
5657 generate_macinfo_entry (type_and_offset
, buffer
);
5660 /* Called from check_newline in c-parse.y. The `buffer' parameter
5661 contains the tail part of the directive line, i.e. the part which
5662 is past the initial whitespace, #, whitespace, directive-name,
5666 dwarfout_undef (lineno
, buffer
)
5667 register unsigned lineno
;
5668 register const char *buffer
;
5670 char type_and_offset
[MAX_ARTIFICIAL_LABEL_BYTES
*2];
5672 sprintf (type_and_offset
, "0x%08x+%u",
5673 ((unsigned) MACINFO_undef
<< 24), lineno
);
5674 generate_macinfo_entry (type_and_offset
, buffer
);
5677 /* Set up for Dwarf output at the start of compilation. */
5680 dwarfout_init (asm_out_file
, main_input_filename
)
5681 register FILE *asm_out_file
;
5682 register char *main_input_filename
;
5684 /* Remember the name of the primary input file. */
5686 primary_filename
= main_input_filename
;
5688 /* Allocate the initial hunk of the pending_sibling_stack. */
5690 pending_sibling_stack
5692 xmalloc (PENDING_SIBLINGS_INCREMENT
* sizeof (unsigned));
5693 pending_siblings_allocated
= PENDING_SIBLINGS_INCREMENT
;
5694 pending_siblings
= 1;
5696 /* Allocate the initial hunk of the filename_table. */
5699 = (filename_entry
*)
5700 xmalloc (FT_ENTRIES_INCREMENT
* sizeof (filename_entry
));
5701 ft_entries_allocated
= FT_ENTRIES_INCREMENT
;
5704 /* Allocate the initial hunk of the pending_types_list. */
5707 = (tree
*) xmalloc (PENDING_TYPES_INCREMENT
* sizeof (tree
));
5708 pending_types_allocated
= PENDING_TYPES_INCREMENT
;
5711 /* Create an artificial RECORD_TYPE node which we can use in our hack
5712 to get the DIEs representing types of formal parameters to come out
5713 only *after* the DIEs for the formal parameters themselves. */
5715 fake_containing_scope
= make_node (RECORD_TYPE
);
5717 /* Output a starting label for the .text section. */
5719 fputc ('\n', asm_out_file
);
5720 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, TEXT_SECTION
);
5721 ASM_OUTPUT_LABEL (asm_out_file
, TEXT_BEGIN_LABEL
);
5722 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5724 /* Output a starting label for the .data section. */
5726 fputc ('\n', asm_out_file
);
5727 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DATA_SECTION
);
5728 ASM_OUTPUT_LABEL (asm_out_file
, DATA_BEGIN_LABEL
);
5729 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5731 #if 0 /* GNU C doesn't currently use .data1. */
5732 /* Output a starting label for the .data1 section. */
5734 fputc ('\n', asm_out_file
);
5735 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DATA1_SECTION
);
5736 ASM_OUTPUT_LABEL (asm_out_file
, DATA1_BEGIN_LABEL
);
5737 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5740 /* Output a starting label for the .rodata section. */
5742 fputc ('\n', asm_out_file
);
5743 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, RODATA_SECTION
);
5744 ASM_OUTPUT_LABEL (asm_out_file
, RODATA_BEGIN_LABEL
);
5745 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5747 #if 0 /* GNU C doesn't currently use .rodata1. */
5748 /* Output a starting label for the .rodata1 section. */
5750 fputc ('\n', asm_out_file
);
5751 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, RODATA1_SECTION
);
5752 ASM_OUTPUT_LABEL (asm_out_file
, RODATA1_BEGIN_LABEL
);
5753 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5756 /* Output a starting label for the .bss section. */
5758 fputc ('\n', asm_out_file
);
5759 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, BSS_SECTION
);
5760 ASM_OUTPUT_LABEL (asm_out_file
, BSS_BEGIN_LABEL
);
5761 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5763 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
5765 if (use_gnu_debug_info_extensions
)
5767 /* Output a starting label and an initial (compilation directory)
5768 entry for the .debug_sfnames section. The starting label will be
5769 referenced by the initial entry in the .debug_srcinfo section. */
5771 fputc ('\n', asm_out_file
);
5772 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, SFNAMES_SECTION
);
5773 ASM_OUTPUT_LABEL (asm_out_file
, SFNAMES_BEGIN_LABEL
);
5775 register char *pwd
= getpwd ();
5776 register char *dirname
;
5779 pfatal_with_name ("getpwd");
5780 dirname
= concat (pwd
, "/", NULL
);
5781 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, dirname
);
5784 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5787 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
5788 && use_gnu_debug_info_extensions
)
5790 /* Output a starting label for the .debug_macinfo section. This
5791 label will be referenced by the AT_mac_info attribute in the
5792 TAG_compile_unit DIE. */
5794 fputc ('\n', asm_out_file
);
5795 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, MACINFO_SECTION
);
5796 ASM_OUTPUT_LABEL (asm_out_file
, MACINFO_BEGIN_LABEL
);
5797 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5800 /* Generate the initial entry for the .line section. */
5802 fputc ('\n', asm_out_file
);
5803 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, LINE_SECTION
);
5804 ASM_OUTPUT_LABEL (asm_out_file
, LINE_BEGIN_LABEL
);
5805 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, LINE_END_LABEL
, LINE_BEGIN_LABEL
);
5806 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_BEGIN_LABEL
);
5807 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5809 if (use_gnu_debug_info_extensions
)
5811 /* Generate the initial entry for the .debug_srcinfo section. */
5813 fputc ('\n', asm_out_file
);
5814 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, SRCINFO_SECTION
);
5815 ASM_OUTPUT_LABEL (asm_out_file
, SRCINFO_BEGIN_LABEL
);
5816 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, LINE_BEGIN_LABEL
);
5817 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, SFNAMES_BEGIN_LABEL
);
5818 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_BEGIN_LABEL
);
5819 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_END_LABEL
);
5820 #ifdef DWARF_TIMESTAMPS
5821 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, time (NULL
));
5823 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, -1);
5825 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5828 /* Generate the initial entry for the .debug_pubnames section. */
5830 fputc ('\n', asm_out_file
);
5831 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, PUBNAMES_SECTION
);
5832 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, DEBUG_BEGIN_LABEL
);
5833 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5835 /* Generate the initial entry for the .debug_aranges section. */
5837 fputc ('\n', asm_out_file
);
5838 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, ARANGES_SECTION
);
5839 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, DEBUG_BEGIN_LABEL
);
5840 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5843 /* Setup first DIE number == 1. */
5844 NEXT_DIE_NUM
= next_unused_dienum
++;
5846 /* Generate the initial DIE for the .debug section. Note that the
5847 (string) value given in the AT_name attribute of the TAG_compile_unit
5848 DIE will (typically) be a relative pathname and that this pathname
5849 should be taken as being relative to the directory from which the
5850 compiler was invoked when the given (base) source file was compiled. */
5852 fputc ('\n', asm_out_file
);
5853 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DEBUG_SECTION
);
5854 ASM_OUTPUT_LABEL (asm_out_file
, DEBUG_BEGIN_LABEL
);
5855 output_die (output_compile_unit_die
, main_input_filename
);
5856 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5858 fputc ('\n', asm_out_file
);
5861 /* Output stuff that dwarf requires at the end of every file. */
5866 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5868 retry_incomplete_types ();
5870 fputc ('\n', asm_out_file
);
5871 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DEBUG_SECTION
);
5873 /* Mark the end of the chain of siblings which represent all file-scope
5874 declarations in this compilation unit. */
5876 /* The (null) DIE which represents the terminator for the (sibling linked)
5877 list of file-scope items is *special*. Normally, we would just call
5878 end_sibling_chain at this point in order to output a word with the
5879 value `4' and that word would act as the terminator for the list of
5880 DIEs describing file-scope items. Unfortunately, if we were to simply
5881 do that, the label that would follow this DIE in the .debug section
5882 (i.e. `..D2') would *not* be properly aligned (as it must be on some
5883 machines) to a 4 byte boundary.
5885 In order to force the label `..D2' to get aligned to a 4 byte boundary,
5886 the trick used is to insert extra (otherwise useless) padding bytes
5887 into the (null) DIE that we know must precede the ..D2 label in the
5888 .debug section. The amount of padding required can be anywhere between
5889 0 and 3 bytes. The length word at the start of this DIE (i.e. the one
5890 with the padding) would normally contain the value 4, but now it will
5891 also have to include the padding bytes, so it will instead have some
5892 value in the range 4..7.
5894 Fortunately, the rules of Dwarf say that any DIE whose length word
5895 contains *any* value less than 8 should be treated as a null DIE, so
5896 this trick works out nicely. Clever, eh? Don't give me any credit
5897 (or blame). I didn't think of this scheme. I just conformed to it.
5900 output_die (output_padded_null_die
, (void *) 0);
5903 sprintf (label
, DIE_BEGIN_LABEL_FMT
, NEXT_DIE_NUM
);
5904 ASM_OUTPUT_LABEL (asm_out_file
, label
); /* should be ..D2 */
5905 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5907 /* Output a terminator label for the .text section. */
5909 fputc ('\n', asm_out_file
);
5910 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, TEXT_SECTION
);
5911 ASM_OUTPUT_LABEL (asm_out_file
, TEXT_END_LABEL
);
5912 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5914 /* Output a terminator label for the .data section. */
5916 fputc ('\n', asm_out_file
);
5917 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DATA_SECTION
);
5918 ASM_OUTPUT_LABEL (asm_out_file
, DATA_END_LABEL
);
5919 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5921 #if 0 /* GNU C doesn't currently use .data1. */
5922 /* Output a terminator label for the .data1 section. */
5924 fputc ('\n', asm_out_file
);
5925 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, DATA1_SECTION
);
5926 ASM_OUTPUT_LABEL (asm_out_file
, DATA1_END_LABEL
);
5927 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5930 /* Output a terminator label for the .rodata section. */
5932 fputc ('\n', asm_out_file
);
5933 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, RODATA_SECTION
);
5934 ASM_OUTPUT_LABEL (asm_out_file
, RODATA_END_LABEL
);
5935 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5937 #if 0 /* GNU C doesn't currently use .rodata1. */
5938 /* Output a terminator label for the .rodata1 section. */
5940 fputc ('\n', asm_out_file
);
5941 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, RODATA1_SECTION
);
5942 ASM_OUTPUT_LABEL (asm_out_file
, RODATA1_END_LABEL
);
5943 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5946 /* Output a terminator label for the .bss section. */
5948 fputc ('\n', asm_out_file
);
5949 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, BSS_SECTION
);
5950 ASM_OUTPUT_LABEL (asm_out_file
, BSS_END_LABEL
);
5951 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5953 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
5955 /* Output a terminating entry for the .line section. */
5957 fputc ('\n', asm_out_file
);
5958 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, LINE_SECTION
);
5959 ASM_OUTPUT_LABEL (asm_out_file
, LINE_LAST_ENTRY_LABEL
);
5960 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
5961 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, 0xffff);
5962 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, TEXT_END_LABEL
, TEXT_BEGIN_LABEL
);
5963 ASM_OUTPUT_LABEL (asm_out_file
, LINE_END_LABEL
);
5964 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5966 if (use_gnu_debug_info_extensions
)
5968 /* Output a terminating entry for the .debug_srcinfo section. */
5970 fputc ('\n', asm_out_file
);
5971 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, SRCINFO_SECTION
);
5972 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
,
5973 LINE_LAST_ENTRY_LABEL
, LINE_BEGIN_LABEL
);
5974 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, -1);
5975 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5978 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
5980 /* Output terminating entries for the .debug_macinfo section. */
5982 dwarfout_resume_previous_source_file (0);
5984 fputc ('\n', asm_out_file
);
5985 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, MACINFO_SECTION
);
5986 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
5987 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
5988 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5991 /* Generate the terminating entry for the .debug_pubnames section. */
5993 fputc ('\n', asm_out_file
);
5994 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, PUBNAMES_SECTION
);
5995 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
5996 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file
, "");
5997 ASM_OUTPUT_POP_SECTION (asm_out_file
);
5999 /* Generate the terminating entries for the .debug_aranges section.
6001 Note that we want to do this only *after* we have output the end
6002 labels (for the various program sections) which we are going to
6003 refer to here. This allows us to work around a bug in the m68k
6004 svr4 assembler. That assembler gives bogus assembly-time errors
6005 if (within any given section) you try to take the difference of
6006 two relocatable symbols, both of which are located within some
6007 other section, and if one (or both?) of the symbols involved is
6008 being forward-referenced. By generating the .debug_aranges
6009 entries at this late point in the assembly output, we skirt the
6010 issue simply by avoiding forward-references.
6013 fputc ('\n', asm_out_file
);
6014 ASM_OUTPUT_PUSH_SECTION (asm_out_file
, ARANGES_SECTION
);
6016 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_BEGIN_LABEL
);
6017 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, TEXT_END_LABEL
, TEXT_BEGIN_LABEL
);
6019 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, DATA_BEGIN_LABEL
);
6020 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, DATA_END_LABEL
, DATA_BEGIN_LABEL
);
6022 #if 0 /* GNU C doesn't currently use .data1. */
6023 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, DATA1_BEGIN_LABEL
);
6024 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, DATA1_END_LABEL
,
6028 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, RODATA_BEGIN_LABEL
);
6029 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, RODATA_END_LABEL
,
6030 RODATA_BEGIN_LABEL
);
6032 #if 0 /* GNU C doesn't currently use .rodata1. */
6033 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, RODATA1_BEGIN_LABEL
);
6034 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, RODATA1_END_LABEL
,
6035 RODATA1_BEGIN_LABEL
);
6038 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, BSS_BEGIN_LABEL
);
6039 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, BSS_END_LABEL
, BSS_BEGIN_LABEL
);
6041 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
6042 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
6044 ASM_OUTPUT_POP_SECTION (asm_out_file
);
6047 /* There should not be any pending types left at the end. We need
6048 this now because it may not have been checked on the last call to
6049 dwarfout_file_scope_decl. */
6050 if (pending_types
!= 0)
6054 #endif /* DWARF_DEBUGGING_INFO */