1 /* Output Dwarf2 format symbol table information from the GNU C compiler.
2 Copyright (C) 1992, 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
3 Contributed by Gary Funck (gary@intrepid.com). Derived from the
4 DWARF 1 implementation written by Ron Guilmette (rfg@monkeys.com).
5 Extensively modified by Jason Merrill (jason@cygnus.com).
7 This file is part of GNU CC.
9 GNU CC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
14 GNU CC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING. If not, write to
21 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
25 #ifdef DWARF2_DEBUGGING_INFO
32 #include "hard-reg-set.h"
34 #include "insn-config.h"
40 /* #define NDEBUG 1 */
43 extern char *getpwd ();
45 /* NOTE: In the comments in this file, many references are made to
46 "Debugging Information Entries". This term is abbreviated as `DIE'
47 throughout the remainder of this file. */
53 /* An internal representation of the DWARF output is built, and then
54 walked to generate the DWARF debugging info. The walk of the internal
55 representation is done after the entire program has been compiled.
56 The types below are used to describe the internal representation. */
58 /* Each DIE may have a series of attribute/value pairs. Values
59 can take on several forms. The forms that are used in this
60 implementation are listed below. */
67 dw_val_class_unsigned_const
,
68 dw_val_class_long_long
,
74 dw_val_class_section_offset
,
79 /* Various DIE's use offsets relative to the beginning of the
80 .debug_info section to refer to each other. */
82 typedef long int dw_offset
;
84 /* Define typedefs here to avoid circular dependencies. */
86 typedef struct die_struct
*dw_die_ref
;
87 typedef struct dw_attr_struct
*dw_attr_ref
;
88 typedef struct dw_val_struct
*dw_val_ref
;
89 typedef struct dw_line_info_struct
*dw_line_info_ref
;
90 typedef struct dw_separate_line_info_struct
*dw_separate_line_info_ref
;
91 typedef struct dw_loc_descr_struct
*dw_loc_descr_ref
;
92 typedef struct dw_cfi_struct
*dw_cfi_ref
;
93 typedef struct dw_fde_struct
*dw_fde_ref
;
94 typedef union dw_cfi_oprnd_struct
*dw_cfi_oprnd_ref
;
95 typedef struct pubname_struct
*pubname_ref
;
96 typedef dw_die_ref
*arange_ref
;
98 /* Describe a double word constant value. */
100 typedef struct dw_long_long_struct
107 /* Describe a floating point constant value. */
109 typedef struct dw_fp_struct
116 /* Each entry in the line_info_table maintains the file and
117 line nuber associated with the label generated for that
118 entry. The label gives the PC value associated with
119 the line number entry. */
121 typedef struct dw_line_info_struct
123 unsigned long dw_file_num
;
124 unsigned long dw_line_num
;
128 /* Line information for functions in separate sections; each one gets its
130 typedef struct dw_separate_line_info_struct
132 unsigned long dw_file_num
;
133 unsigned long dw_line_num
;
134 unsigned long function
;
136 dw_separate_line_info_entry
;
138 /* The dw_val_node describes an attibute's value, as it is
139 represented internally. */
141 typedef struct dw_val_struct
143 dw_val_class val_class
;
147 dw_loc_descr_ref val_loc
;
149 long unsigned val_unsigned
;
150 dw_long_long_const val_long_long
;
151 dw_float_const val_float
;
152 dw_die_ref val_die_ref
;
153 unsigned val_fde_index
;
157 unsigned char val_flag
;
163 /* Locations in memory are described using a sequence of stack machine
166 typedef struct dw_loc_descr_struct
168 dw_loc_descr_ref dw_loc_next
;
169 enum dwarf_location_atom dw_loc_opc
;
170 dw_val_node dw_loc_oprnd1
;
171 dw_val_node dw_loc_oprnd2
;
175 /* Each DIE attribute has a field specifying the attribute kind,
176 a link to the next attribute in the chain, and an attribute value.
177 Attributes are typically linked below the DIE they modify. */
179 typedef struct dw_attr_struct
181 enum dwarf_attribute dw_attr
;
182 dw_attr_ref dw_attr_next
;
183 dw_val_node dw_attr_val
;
187 /* Call frames are described using a sequence of Call Frame
188 Information instructions. The register number, offset
189 and address fields are provided as possible operands;
190 their use is selected by the opcode field. */
192 typedef union dw_cfi_oprnd_struct
194 unsigned long dw_cfi_reg_num
;
195 long int dw_cfi_offset
;
200 typedef struct dw_cfi_struct
202 dw_cfi_ref dw_cfi_next
;
203 enum dwarf_call_frame_info dw_cfi_opc
;
204 dw_cfi_oprnd dw_cfi_oprnd1
;
205 dw_cfi_oprnd dw_cfi_oprnd2
;
209 /* All call frame descriptions (FDE's) in the GCC generated DWARF
210 refer to a single Common Information Entry (CIE), defined at
211 the beginning of the .debug_frame section. This used of a single
212 CIE obviates the need to keep track of multiple CIE's
213 in the DWARF generation routines below. */
215 typedef struct dw_fde_struct
217 unsigned long dw_fde_offset
;
219 char *dw_fde_current_label
;
221 dw_cfi_ref dw_fde_cfi
;
225 /* The Debugging Information Entry (DIE) structure */
227 typedef struct die_struct
229 enum dwarf_tag die_tag
;
230 dw_attr_ref die_attr
;
231 dw_attr_ref die_attr_last
;
232 dw_die_ref die_parent
;
233 dw_die_ref die_child
;
234 dw_die_ref die_child_last
;
236 dw_offset die_offset
;
237 unsigned long die_abbrev
;
241 /* The pubname structure */
243 typedef struct pubname_struct
250 /* How to start an assembler comment. */
251 #ifndef ASM_COMMENT_START
252 #define ASM_COMMENT_START ";#"
255 /* Define a macro which returns non-zero for a TYPE_DECL which was
256 implicitly generated for a tagged type.
258 Note that unlike the gcc front end (which generates a NULL named
259 TYPE_DECL node for each complete tagged type, each array type, and
260 each function type node created) the g++ front end generates a
261 _named_ TYPE_DECL node for each tagged type node created.
262 These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
263 generate a DW_TAG_typedef DIE for them. */
265 #define TYPE_DECL_IS_STUB(decl) \
266 (DECL_NAME (decl) == NULL_TREE \
267 || (DECL_ARTIFICIAL (decl) \
268 && is_tagged_type (TREE_TYPE (decl)) \
269 && decl == TYPE_STUB_DECL (TREE_TYPE (decl))))
271 /* Information concerning the compilation unit's programming
272 language, and compiler version. */
274 extern int flag_traditional
;
275 extern char *version_string
;
276 extern char *language_string
;
278 /* Maximum size (in bytes) of an artificially generated label. */
279 #define MAX_ARTIFICIAL_LABEL_BYTES 30
281 /* Make sure we know the sizes of the various types dwarf can describe. These
282 are only defaults. If the sizes are different for your target, you should
283 override these values by defining the appropriate symbols in your tm.h
286 #ifndef CHAR_TYPE_SIZE
287 #define CHAR_TYPE_SIZE BITS_PER_UNIT
290 #define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
293 /* The size in bytes of a DWARF field indicating an offset or length
294 relative to a debug info section, specified to be 4 bytes in the DWARF-2
295 specification. The SGI/MIPS ABI defines it to be the same as PTR_SIZE. */
297 #ifndef DWARF_OFFSET_SIZE
298 #define DWARF_OFFSET_SIZE 4
301 #define DWARF_VERSION 2
303 /* Fixed size portion of the DWARF compilation unit header. */
304 #define DWARF_COMPILE_UNIT_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 3)
306 /* Fixed size portion of debugging line information prolog. */
307 #define DWARF_LINE_PROLOG_HEADER_SIZE 5
309 /* Fixed size portion of public names info. */
310 #define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
312 /* Round SIZE up to the nearest BOUNDARY. */
313 #define DWARF_ROUND(SIZE,BOUNDARY) \
314 (((SIZE) + (BOUNDARY) - 1) & ~((BOUNDARY) - 1))
316 /* Fixed size portion of the address range info. */
317 #define DWARF_ARANGES_HEADER_SIZE \
318 (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, PTR_SIZE * 2) - DWARF_OFFSET_SIZE)
320 /* Fixed size portion of the CIE (including the length field). */
321 #define DWARF_CIE_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 5)
323 /* The un-padded size of the CIE. Initialized in calc_fde_sizes, used
324 in output_call_frame_info. */
325 static unsigned cie_size
;
327 /* Offsets recorded in opcodes are a multiple of this alignment factor. */
328 #ifdef STACK_GROWS_DOWNWARD
329 #define DWARF_CIE_DATA_ALIGNMENT (-UNITS_PER_WORD)
331 #define DWARF_CIE_DATA_ALIGNMENT UNITS_PER_WORD
334 /* Fixed size portion of the FDE. */
335 #define DWARF_FDE_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2 * PTR_SIZE)
337 /* Define the architecture-dependent minimum instruction length (in bytes).
338 In this implementation of DWARF, this field is used for information
339 purposes only. Since GCC generates assembly language, we have
340 no a priori knowledge of how many instruction bytes are generated
341 for each source line, and therefore can use only the DW_LNE_set_address
342 and DW_LNS_fixed_advance_pc line information commands. */
344 #ifndef DWARF_LINE_MIN_INSTR_LENGTH
345 #define DWARF_LINE_MIN_INSTR_LENGTH 4
348 /* Minimum line offset in a special line info. opcode.
349 This value was chosen to give a reasonable range of values. */
350 #define DWARF_LINE_BASE -10
352 /* First special line opcde - leave room for the standard opcodes. */
353 #define DWARF_LINE_OPCODE_BASE 10
355 /* Range of line offsets in a special line info. opcode. */
356 #define DWARF_LINE_RANGE (254-DWARF_LINE_OPCODE_BASE+1)
358 /* Flag that indicates the initial value of the is_stmt_start flag.
359 In the present implementation, we do not mark any lines as
360 the beginning of a source statement, because that information
361 is not made available by the GCC front-end. */
362 #define DWARF_LINE_DEFAULT_IS_STMT_START 1
364 /* This location is used by calc_die_sizes() to keep track
365 the offset of each DIE within the .debug_info section. */
366 static unsigned long next_die_offset
;
368 /* This location is used by calc_fde_sizes() to keep track
369 the offset of each FDE within the .debug_frame section. */
370 static unsigned long next_fde_offset
;
372 /* Record the root of the DIE's built for the current compilation unit. */
373 static dw_die_ref comp_unit_die
;
375 /* The number of DIEs with a NULL parent waiting to be relocated. */
376 static int limbo_die_count
;
378 /* Pointer to an array of filenames referenced by this compilation unit. */
379 static char **file_table
;
381 /* Total number of entries in the table (i.e. array) pointed to by
382 `file_table'. This is the *total* and includes both used and unused
384 static unsigned file_table_allocated
;
386 /* Number of entries in the file_table which are actually in use. */
387 static unsigned file_table_in_use
;
389 /* Size (in elements) of increments by which we may expand the filename
391 #define FILE_TABLE_INCREMENT 64
393 /* Local pointer to the name of the main input file. Initialized in
395 static char *primary_filename
;
397 /* For Dwarf output, we must assign lexical-blocks id numbers in the order in
398 which their beginnings are encountered. We output Dwarf debugging info
399 that refers to the beginnings and ends of the ranges of code for each
400 lexical block. The labels themselves are generated in final.c, which
401 assigns numbers to the blocks in the same way. */
402 static unsigned next_block_number
= 2;
404 /* A pointer to the base of a table of references to DIE's that describe
405 declarations. The table is indexed by DECL_UID() which is a unique
406 number, indentifying each decl. */
407 static dw_die_ref
*decl_die_table
;
409 /* Number of elements currently allocated for the decl_die_table. */
410 static unsigned decl_die_table_allocated
;
412 /* Number of elements in decl_die_table currently in use. */
413 static unsigned decl_die_table_in_use
;
415 /* Size (in elements) of increments by which we may expand the
417 #define DECL_DIE_TABLE_INCREMENT 256
419 /* A pointer to the base of a table of references to declaration
420 scopes. This table is a display which tracks the nesting
421 of declaration scopes at the current scope and containing
422 scopes. This table is used to find the proper place to
423 define type declaration DIE's. */
424 static tree
*decl_scope_table
;
426 /* Number of elements currently allocated for the decl_scope_table. */
427 static unsigned decl_scope_table_allocated
;
429 /* Current level of nesting of declataion scopes. */
430 static unsigned decl_scope_depth
;
432 /* Size (in elements) of increments by which we may expand the
434 #define DECL_SCOPE_TABLE_INCREMENT 64
436 /* A pointer to the base of a list of references to DIE's that
437 are uniquely identified by their tag, presence/absence of
438 children DIE's, and list of attribute/value pairs. */
439 static dw_die_ref
*abbrev_die_table
;
441 /* Number of elements currently allocated for abbrev_die_table. */
442 static unsigned abbrev_die_table_allocated
;
444 /* Number of elements in type_die_table currently in use. */
445 static unsigned abbrev_die_table_in_use
;
447 /* Size (in elements) of increments by which we may expand the
449 #define ABBREV_DIE_TABLE_INCREMENT 256
451 /* A pointer to the base of a table that contains line information
452 for each source code line in .text in the compilation unit. */
453 static dw_line_info_ref line_info_table
;
455 /* Number of elements currently allocated for line_info_table. */
456 static unsigned line_info_table_allocated
;
458 /* Number of elements in separate_line_info_table currently in use. */
459 static unsigned separate_line_info_table_in_use
;
461 /* A pointer to the base of a table that contains line information
462 for each source code line outside of .text in the compilation unit. */
463 static dw_separate_line_info_ref separate_line_info_table
;
465 /* Number of elements currently allocated for separate_line_info_table. */
466 static unsigned separate_line_info_table_allocated
;
468 /* Number of elements in line_info_table currently in use. */
469 static unsigned line_info_table_in_use
;
471 /* Size (in elements) of increments by which we may expand the
473 #define LINE_INFO_TABLE_INCREMENT 1024
475 /* A pointer to the base of a table that contains frame description
476 information for each routine. */
477 static dw_fde_ref fde_table
;
479 /* Number of elements currently allocated for fde_table. */
480 static unsigned fde_table_allocated
;
482 /* Number of elements in fde_table currently in use. */
483 static unsigned fde_table_in_use
;
485 /* Size (in elements) of increments by which we may expand the
487 #define FDE_TABLE_INCREMENT 256
489 /* A list of call frame insns for the CIE. */
490 static dw_cfi_ref cie_cfi_head
;
492 /* A pointer to the base of a table that contains a list of publicly
494 static pubname_ref pubname_table
;
496 /* Number of elements currently allocated for pubname_table. */
497 static unsigned pubname_table_allocated
;
499 /* Number of elements in pubname_table currently in use. */
500 static unsigned pubname_table_in_use
;
502 /* Size (in elements) of increments by which we may expand the
504 #define PUBNAME_TABLE_INCREMENT 64
506 /* A pointer to the base of a table that contains a list of publicly
508 static arange_ref arange_table
;
510 /* Number of elements currently allocated for arange_table. */
511 static unsigned arange_table_allocated
;
513 /* Number of elements in arange_table currently in use. */
514 static unsigned arange_table_in_use
;
516 /* Size (in elements) of increments by which we may expand the
518 #define ARANGE_TABLE_INCREMENT 64
520 /* A pointer to the base of a list of pending types which we haven't
521 generated DIEs for yet, but which we will have to come back to
524 static tree
*pending_types_list
;
526 /* Number of elements currently allocated for the pending_types_list. */
527 static unsigned pending_types_allocated
;
529 /* Number of elements of pending_types_list currently in use. */
530 static unsigned pending_types
;
532 /* Size (in elements) of increments by which we may expand the pending
533 types list. Actually, a single hunk of space of this size should
534 be enough for most typical programs. */
535 #define PENDING_TYPES_INCREMENT 64
537 /* The number of the current function definition for which debugging
538 information is being generated. These numbers range from 1 up to the
539 maximum number of function definitions contained within the current
540 compilation unit. These numbers are used to create unique label id's
541 unique to each function definition. */
542 static unsigned current_funcdef_number
= 1;
544 /* Some DWARF extensions (e.g., MIPS/SGI) implement a subprogram
545 attribute that accelerates the lookup of the FDE associated
546 with the subprogram. This variable holds the table index of the FDE
547 associated with the current function (body) definition. */
548 static unsigned current_funcdef_fde
;
550 /* Record whether the function being analyzed contains inlined functions. */
551 static int current_function_has_inlines
;
552 static int comp_unit_has_inlines
;
554 /* A pointer to the ..._DECL node which we have most recently been working
555 on. We keep this around just in case something about it looks screwy and
556 we want to tell the user what the source coordinates for the actual
558 static tree dwarf_last_decl
;
560 /* Forward declarations for functions defined in this file. */
562 static char *stripattributes
PROTO((char *));
563 static void addr_const_to_string
PROTO((char *, rtx
));
564 static char *addr_to_string
PROTO((rtx
));
565 static int is_pseudo_reg
PROTO((rtx
));
566 static tree type_main_variant
PROTO((tree
));
567 static int is_tagged_type
PROTO((tree
));
568 static char *dwarf_tag_name
PROTO((unsigned));
569 static char *dwarf_attr_name
PROTO((unsigned));
570 static char *dwarf_form_name
PROTO((unsigned));
571 static char *dwarf_stack_op_name
PROTO((unsigned));
572 static char *dwarf_type_encoding_name
PROTO((unsigned));
573 static char *dward_cfi_name
PROTO((unsigned));
574 static tree decl_ultimate_origin
PROTO((tree
));
575 static tree block_ultimate_origin
PROTO((tree
));
576 static tree decl_class_context
PROTO((tree
));
577 static void add_dwarf_attr
PROTO((dw_die_ref
, dw_attr_ref
));
578 static void add_AT_flag
PROTO((dw_die_ref
,
579 enum dwarf_attribute
,
581 static void add_AT_int
PROTO((dw_die_ref
,
582 enum dwarf_attribute
, long));
583 static void add_AT_unsigned
PROTO((dw_die_ref
,
584 enum dwarf_attribute
,
586 static void add_AT_long_long
PROTO((dw_die_ref
,
587 enum dwarf_attribute
,
588 unsigned long, unsigned long));
589 static void add_AT_float
PROTO((dw_die_ref
,
590 enum dwarf_attribute
,
592 static void add_AT_string
PROTO((dw_die_ref
,
593 enum dwarf_attribute
, char *));
594 static void add_AT_die_ref
PROTO((dw_die_ref
,
595 enum dwarf_attribute
,
597 static void add_AT_fde_ref
PROTO((dw_die_ref
,
598 enum dwarf_attribute
,
600 static void add_AT_loc
PROTO((dw_die_ref
,
601 enum dwarf_attribute
,
603 static void add_AT_addr
PROTO((dw_die_ref
,
604 enum dwarf_attribute
, char *));
605 static void add_AT_lbl_id
PROTO((dw_die_ref
,
606 enum dwarf_attribute
, char *));
607 static void add_AT_setion_offset
PROTO((dw_die_ref
,
608 enum dwarf_attribute
, char *));
609 static int is_extern_subr_die
PROTO((dw_die_ref
));
610 static dw_attr_ref get_AT
PROTO((dw_die_ref
,
611 enum dwarf_attribute
));
612 static char *get_AT_low_pc
PROTO((dw_die_ref
));
613 static char *get_AT_hi_pc
PROTO((dw_die_ref
));
614 static char *get_AT_string
PROTO((dw_die_ref
,
615 enum dwarf_attribute
));
616 static int get_AT_flag
PROTO((dw_die_ref
,
617 enum dwarf_attribute
));
618 static unsigned get_AT_unsigned
PROTO((dw_die_ref
,
619 enum dwarf_attribute
));
620 static int is_c_family
PROTO((void));
621 static int is_fortran
PROTO((void));
622 static void remove_AT
PROTO((dw_die_ref
,
623 enum dwarf_attribute
));
624 static void remove_children
PROTO((dw_die_ref
));
625 static void add_child_die
PROTO((dw_die_ref
, dw_die_ref
));
626 static dw_die_ref new_die
PROTO((enum dwarf_tag
, dw_die_ref
));
627 static dw_die_ref lookup_type_die
PROTO((tree
));
628 static void equate_type_number_to_die
PROTO((tree
, dw_die_ref
));
629 static dw_die_ref lookup_decl_die
PROTO((tree
));
630 static void equate_decl_number_to_die
PROTO((tree
, dw_die_ref
));
631 static dw_loc_descr_ref new_loc_descr
PROTO((enum dwarf_location_atom
,
632 unsigned long, unsigned long));
633 static void add_loc_descr
PROTO((dw_loc_descr_ref
*,
635 static dw_cfi_ref new_cfe
PROTO((void));
636 static void add_cfe
PROTO((dw_cfi_ref
*, dw_cfi_ref
));
637 static void print_spaces
PROTO((FILE *));
638 static void print_die
PROTO((dw_die_ref
, FILE *));
639 static void print_dwarf_line_table
PROTO((FILE *));
640 static void add_sibling_atttributes
PROTO((dw_die_ref
));
641 static void build_abbrev_table
PROTO((dw_die_ref
));
642 static unsigned long size_of_uleb128
PROTO((unsigned long));
643 static unsigned long size_of_sleb128
PROTO((long));
644 static unsigned long size_of_string
PROTO((char *));
645 static unsigned long size_of_loc_descr
PROTO((dw_loc_descr_ref
));
646 static unsigned long size_of_locs
PROTO((dw_loc_descr_ref
));
647 static int constant_size
PROTO((long unsigned));
648 static unsigned long size_of_die
PROTO((dw_die_ref
));
649 static void calc_die_sizes
PROTO((dw_die_ref
));
650 static unsigned long size_of_prolog
PROTO((void));
651 static unsigned long size_of_line_info
PROTO((void));
652 static unsigned long size_of_pubnames
PROTO((void));
653 static unsigned long size_of_aranges
PROTO((void));
654 static void output_uleb128
PROTO((unsigned long));
655 static void output_sleb128
PROTO((long));
656 static enum dwarf_form value_format
PROTO((dw_val_ref
));
657 static void output_value_format
PROTO((dw_val_ref
));
658 static void output_abbrev_section
PROTO((void));
659 static void output_loc_operands
PROTO((dw_loc_descr_ref
));
660 static unsigned long sibling_offset
PROTO((dw_die_ref
));
661 static void output_die
PROTO((dw_die_ref
));
662 static void output_compilation_unit_header
PROTO((void));
663 static char *dwarf2out_cfi_label
PROTO((void));
664 static void add_fde_cfi
PROTO((char *, dw_cfi_ref
));
665 static void lookup_cfa_1
PROTO((dw_cfi_ref
, unsigned long *,
667 static void lookup_cfa
PROTO((unsigned long *, long *));
668 static void reg_save
PROTO((char *, unsigned, unsigned,
670 static void initial_return_save
PROTO((rtx
));
671 static unsigned long size_of_cfi
PROTO((dw_cfi_ref
));
672 static unsigned long size_of_fde
PROTO((dw_fde_ref
, unsigned long *));
673 static void calc_fde_sizes
PROTO((void));
674 static void output_cfi
PROTO((dw_cfi_ref
, dw_fde_ref
));
675 static void output_call_frame_info
PROTO((void));
676 static char *dwarf2_name
PROTO((tree
, int));
677 static void add_pubname
PROTO((tree
, dw_die_ref
));
678 static void output_pubnames
PROTO((void));
679 static void add_arrange
PROTO((tree
, dw_die_ref
));
680 static void output_arranges
PROTO((void));
681 static void output_line_info
PROTO((void));
682 static int is_body_block
PROTO((tree
));
683 static dw_die_ref base_type_die
PROTO((tree
));
684 static tree root_type
PROTO((tree
));
685 static int is_base_type
PROTO((tree
));
686 static dw_die_ref modified_type_die
PROTO((tree
, int, int, dw_die_ref
));
687 static int type_is_enum
PROTO((tree
));
688 static unsigned reg_number
PROTO((rtx
));
689 static dw_loc_descr_ref reg_loc_descr_ref
PROTO((rtx
));
690 static dw_loc_descr_ref based_loc_descr
PROTO((unsigned, long));
691 static int is_based_loc
PROTO((rtx
));
692 static dw_loc_descr_ref mem_loc_descriptor
PROTO((rtx
));
693 static dw_loc_descr_ref loc_descriptor
PROTO((rtx
));
694 static unsigned ceiling
PROTO((unsigned, unsigned));
695 static tree field_type
PROTO((tree
));
696 static unsigned simple_type_align_in_bits
PROTO((tree
));
697 static unsigned simple_type_size_in_bits
PROTO((tree
));
698 static unsigned field_byte_offset
PROTO((tree
));
699 static void add_location_attribute
PROTO((dw_die_ref
, rtx
));
700 static void add_data_member_location_attribute
PROTO((dw_die_ref
, tree
));
701 static void add_const_value_attribute
PROTO((dw_die_ref
, rtx
));
702 static void add_location_or_const_value_attribute
PROTO((dw_die_ref
, tree
));
703 static void add_name_attribute
PROTO((dw_die_ref
, char *));
704 static void add_bound_info
PROTO((dw_die_ref
,
705 enum dwarf_attribute
, tree
));
706 static void add_subscript_info
PROTO((dw_die_ref
, tree
));
707 static void add_byte_size_attribute
PROTO((dw_die_ref
, tree
));
708 static void add_bit_offset_attribute
PROTO((dw_die_ref
, tree
));
709 static void add_bit_size_attribute
PROTO((dw_die_ref
, tree
));
710 static void add_prototyped_attribute
PROTO((dw_die_ref
, tree
));
711 static void add_abstract_origin_attribute
PROTO((dw_die_ref
, tree
));
712 static void add_pure_or_virtual_attribute
PROTO((dw_die_ref
, tree
));
713 static void add_src_coords_attributes
PROTO((dw_die_ref
, tree
));
714 static void ad_name_and_src_coords_attributes
PROTO((dw_die_ref
, tree
));
715 static void push_decl_scope
PROTO((tree
));
716 static dw_die_ref scope_die_for
PROTO((tree
, dw_die_ref
));
717 static void pop_decl_scope
PROTO((void));
718 static void add_type_attribute
PROTO((dw_die_ref
, tree
, int, int,
720 static char *type_tag
PROTO((tree
));
721 static tree member_declared_type
PROTO((tree
));
722 static char *decl_start_label
PROTO((tree
));
723 static void gen_arrqay_type_die
PROTO((tree
, dw_die_ref
));
724 static void gen_set_type_die
PROTO((tree
, dw_die_ref
));
725 static void gen_entry_point_die
PROTO((tree
, dw_die_ref
));
726 static void pend_type
PROTO((tree
));
727 static void output_pending_types_for_scope
PROTO((dw_die_ref
));
728 static void gen_inlined_enumeration_type_die
PROTO((tree
, dw_die_ref
));
729 static void gen_inlined_structure_type_die
PROTO((tree
, dw_die_ref
));
730 static void gen_inlined_union_type_die
PROTO((tree
, dw_die_ref
));
731 static void gen_enumeration_type_die
PROTO((tree
, dw_die_ref
));
732 static dw_die_ref gen_formal_parameter_die
PROTO((tree
, dw_die_ref
));
733 static void gen_unspecified_parameters_die
PROTO((tree
, dw_die_ref
));
734 static void gen_formal_types_die
PROTO((tree
, dw_die_ref
));
735 static void gen_subprogram_die
PROTO((tree
, dw_die_ref
));
736 static void gen_variable_die
PROTO((tree
, dw_die_ref
));
737 static void gen_labeld_die
PROTO((tree
, dw_die_ref
));
738 static void gen_lexical_block_die
PROTO((tree
, dw_die_ref
, int));
739 static void gen_inlined_subprogram_die
PROTO((tree
, dw_die_ref
, int));
740 static void gen_field_die
PROTO((tree
, dw_die_ref
));
741 static void gen_ptr_to_mbr_type_die
PROTO((tree
, dw_die_ref
));
742 static void gen_compile_unit_die
PROTO((char *));
743 static void gen_string_type_die
PROTO((tree
, dw_die_ref
));
744 static void gen_inheritance_die
PROTO((tree
, dw_die_ref
));
745 static void gen_member_die
PROTO((tree
, dw_die_ref
));
746 static void gen_struct_or_union_type_die
PROTO((tree
, dw_die_ref
));
747 static void gen_subroutine_type_die
PROTO((tree
, dw_die_ref
));
748 static void gen_typedef_die
PROTO((tree
, dw_die_ref
));
749 static void gen_type_die
PROTO((tree
, dw_die_ref
));
750 static void gen_tagged_type_instantiation_die
PROTO((tree
, dw_die_ref
));
751 static void gen_block_die
PROTO((tree
, dw_die_ref
, int));
752 static void decls_for_scope
PROTO((tree
, dw_die_ref
, int));
753 static int is_redundant_typedef
PROTO((tree
));
754 static void gen_decl_die
PROTO((tree
, dw_die_ref
));
755 static unsigned lookup_filename
PROTO((char *));
757 /* Definitions of defaults for assembler-dependent names of various
758 pseudo-ops and section names.
759 Theses may be overridden in the tm.h file (if necessary) for a particular
762 #ifndef UNALIGNED_SHORT_ASM_OP
763 #define UNALIGNED_SHORT_ASM_OP ".2byte"
765 #ifndef UNALIGNED_INT_ASM_OP
766 #define UNALIGNED_INT_ASM_OP ".4byte"
768 #ifndef UNALIGNED_DOUBLE_INT_ASM_OP
769 #define UNALIGNED_DOUBLE_INT_ASM_OP ".8byte"
772 #define ASM_BYTE_OP ".byte"
775 #ifndef UNALIGNED_OFFSET_ASM_OP
776 #define UNALIGNED_OFFSET_ASM_OP \
777 (DWARF_OFFSET_SIZE == 8 ? UNALIGNED_DOUBLE_INT_ASM_OP : UNALIGNED_INT_ASM_OP)
780 #ifndef UNALIGNED_WORD_ASM_OP
781 #define UNALIGNED_WORD_ASM_OP \
782 (PTR_SIZE == 8 ? UNALIGNED_DOUBLE_INT_ASM_OP : UNALIGNED_INT_ASM_OP)
785 /* Data and reference forms for relocatable data. */
786 #define DW_FORM_data (DWARF_OFFSET_SIZE == 8 ? DW_FORM_data8 : DW_FORM_data4)
787 #define DW_FORM_ref (DWARF_OFFSET_SIZE == 8 ? DW_FORM_ref8 : DW_FORM_ref4)
789 /* Pseudo-op for defining a new section. */
790 #ifndef SECTION_ASM_OP
791 #define SECTION_ASM_OP ".section"
794 /* The default format used by the ASM_OUTPUT_SECTION macro (see below) to
795 print the SECTION_ASM_OP and the section name. The default here works for
796 almost all svr4 assemblers, except for the sparc, where the section name
797 must be enclosed in double quotes. (See sparcv4.h). */
798 #ifndef SECTION_FORMAT
799 #define SECTION_FORMAT "\t%s\t%s\n"
802 /* Section names used to hold DWARF debugging information. */
803 #ifndef DEBUG_SECTION
804 #define DEBUG_SECTION ".debug_info"
806 #ifndef ABBREV_SECTION
807 #define ABBREV_SECTION ".debug_abbrev"
809 #ifndef ARANGES_SECTION
810 #define ARANGES_SECTION ".debug_aranges"
812 #ifndef DW_MACINFO_SECTION
813 #define DW_MACINFO_SECTION ".debug_macinfo"
815 #ifndef FRAME_SECTION
816 #define FRAME_SECTION ".debug_frame"
819 #define LINE_SECTION ".debug_line"
822 #define LOC_SECTION ".debug_loc"
824 #ifndef PUBNAMES_SECTION
825 #define PUBNAMES_SECTION ".debug_pubnames"
828 #define STR_SECTION ".debug_str"
831 /* Standerd ELF section names for compiled code and data. */
833 #define TEXT_SECTION ".text"
836 #define DATA_SECTION ".data"
839 #define BSS_SECTION ".bss"
843 /* Definitions of defaults for formats and names of various special
844 (artificial) labels which may be generated within this file (when the -g
845 options is used and DWARF_DEBUGGING_INFO is in effect.
846 If necessary, these may be overridden from within the tm.h file, but
847 typically, overriding these defaults is unnecessary. */
849 char text_end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
851 #ifndef TEXT_END_LABEL
852 #define TEXT_END_LABEL "Letext"
854 #ifndef DATA_END_LABEL
855 #define DATA_END_LABEL "Ledata"
857 #ifndef BSS_END_LABEL
858 #define BSS_END_LABEL "Lebss"
860 #ifndef INSN_LABEL_FMT
861 #define INSN_LABEL_FMT "LI%u_"
863 #ifndef BLOCK_BEGIN_LABEL
864 #define BLOCK_BEGIN_LABEL "LBB"
866 #ifndef BLOCK_END_LABEL
867 #define BLOCK_END_LABEL "LBE"
869 #ifndef BODY_BEGIN_LABEL
870 #define BODY_BEGIN_LABEL "Lbb"
872 #ifndef BODY_END_LABEL
873 #define BODY_END_LABEL "Lbe"
875 #ifndef FUNC_BEGIN_LABEL
876 #define FUNC_BEGIN_LABEL "LFB"
878 #ifndef FUNC_END_LABEL
879 #define FUNC_END_LABEL "LFE"
881 #ifndef LINE_CODE_LABEL
882 #define LINE_CODE_LABEL "LM"
884 #ifndef SEPARATE_LINE_CODE_LABEL
885 #define SEPARATE_LINE_CODE_LABEL "LSM"
888 /* Definitions of defaults for various types of primitive assembly language
889 output operations. These may be overridden from within the tm.h file,
890 but typically, that is unecessary. */
892 #ifndef ASM_OUTPUT_SECTION
893 #define ASM_OUTPUT_SECTION(FILE, SECTION) \
894 fprintf ((FILE), SECTION_FORMAT, SECTION_ASM_OP, SECTION)
897 #ifndef ASM_OUTPUT_DWARF_DELTA2
898 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
899 do { fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \
900 assemble_name (FILE, LABEL1); \
901 fprintf (FILE, "-"); \
902 assemble_name (FILE, LABEL2); \
906 #ifndef ASM_OUTPUT_DWARF_DELTA4
907 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
908 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
909 assemble_name (FILE, LABEL1); \
910 fprintf (FILE, "-"); \
911 assemble_name (FILE, LABEL2); \
915 #ifndef ASM_OUTPUT_DWARF_DELTA
916 #define ASM_OUTPUT_DWARF_DELTA(FILE,LABEL1,LABEL2) \
917 do { fprintf ((FILE), "\t%s\t", UNALIGNED_OFFSET_ASM_OP); \
918 assemble_name (FILE, LABEL1); \
919 fprintf (FILE, "-"); \
920 assemble_name (FILE, LABEL2); \
924 #ifndef ASM_OUTPUT_DWARF_ADDR_DELTA
925 #define ASM_OUTPUT_DWARF_ADDR_DELTA(FILE,LABEL1,LABEL2) \
926 do { fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP); \
927 assemble_name (FILE, LABEL1); \
928 fprintf (FILE, "-"); \
929 assemble_name (FILE, LABEL2); \
933 #ifndef ASM_OUTPUT_DWARF_ADDR
934 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
935 do { fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP); \
936 assemble_name (FILE, LABEL); \
940 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
941 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,ADDR) \
942 fprintf ((FILE), "\t%s\t%s", UNALIGNED_WORD_ASM_OP, (ADDR))
945 #ifndef ASM_OUTPUT_DWARF_OFFSET
946 #define ASM_OUTPUT_DWARF_OFFSET(FILE,LABEL) \
947 do { fprintf ((FILE), "\t%s\t", UNALIGNED_OFFSET_ASM_OP); \
948 assemble_name (FILE, LABEL); \
952 #ifndef ASM_OUTPUT_DWARF_DATA1
953 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
954 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, VALUE)
957 #ifndef ASM_OUTPUT_DWARF_DATA2
958 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
959 fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_SHORT_ASM_OP, (unsigned) VALUE)
962 #ifndef ASM_OUTPUT_DWARF_DATA4
963 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
964 fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_INT_ASM_OP, (unsigned) VALUE)
967 #ifndef ASM_OUTPUT_DWARF_DATA
968 #define ASM_OUTPUT_DWARF_DATA(FILE,VALUE) \
969 fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_OFFSET_ASM_OP, \
970 (unsigned long) VALUE)
973 #ifndef ASM_OUTPUT_DWARF_ADDR_DATA
974 #define ASM_OUTPUT_DWARF_ADDR_DATA(FILE,VALUE) \
975 fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_WORD_ASM_OP, \
976 (unsigned long) VALUE)
979 #ifndef ASM_OUTPUT_DWARF_DATA8
980 #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \
982 if (WORDS_BIG_ENDIAN) \
984 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
985 fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
989 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
990 fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
995 /* This is similar to the default ASM_OUTPUT_ASCII, except that no trailing
996 newline is produced. When flag_verbose_asm is asserted, we add commnetary
997 at the end of the line, so we must avoid output of a newline here. */
998 #ifndef ASM_OUTPUT_DWARF_STRING
999 #define ASM_OUTPUT_DWARF_STRING(FILE,P) \
1001 register int slen = strlen(P); \
1002 register char *p = (P); \
1004 fprintf (FILE, "\t.ascii \""); \
1005 for (i = 0; i < slen; i++) \
1007 register int c = p[i]; \
1008 if (c == '\"' || c == '\\') \
1009 putc ('\\', FILE); \
1010 if (c >= ' ' && c < 0177) \
1014 fprintf (FILE, "\\%o", c); \
1017 fprintf (FILE, "\\0\""); \
1022 /* Convert a reference to the assembler name of a C-level name. This
1023 macro has the same effect as ASM_OUTPUT_LABELREF, but copies to
1024 a string rather than writing to a file. */
1025 #ifndef ASM_NAME_TO_STRING
1026 #define ASM_NAME_TO_STRING(STR, NAME) \
1028 if ((NAME)[0] == '*') \
1029 strcpy (STR, NAME+1); \
1031 strcpy (STR, NAME); \
1036 /* The DWARF 2 CFA column which tracks the return address. Normally this
1037 is the column for PC, or the first column after all of the hard
1039 #ifndef DWARF_FRAME_RETURN_COLUMN
1041 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (PC_REGNUM)
1043 #define DWARF_FRAME_RETURN_COLUMN FIRST_PSEUDO_REGISTER
1047 /* The mapping from gcc register number to DWARF 2 CFA column number. By
1048 default, we just provide columns for all registers. */
1049 #ifndef DWARF_FRAME_REGNUM
1050 #define DWARF_FRAME_REGNUM(REG) DBX_REGISTER_NUMBER (REG)
1053 /* Return a pointer to a copy of the section string name S with all
1054 attributes stripped off. */
1056 static inline char *
1060 char *stripped
= xstrdup (s
);
1063 while (*p
&& *p
!= ',')
1070 /* Convert an integer constant expression into assembler syntax. Addition
1071 and subtraction are the only arithmetic that may appear in these
1072 expressions. This is an adaptation of output_addr_const in final.c.
1073 Here, the target of the conversion is a string buffer. We can't use
1074 output_addr_const directly, because it writes to a file. */
1077 addr_const_to_string (str
, x
)
1086 switch (GET_CODE (x
))
1096 ASM_NAME_TO_STRING (buf1
, XSTR (x
, 0));
1101 ASM_GENERATE_INTERNAL_LABEL (buf1
, "L", CODE_LABEL_NUMBER (XEXP (x
, 0)));
1102 ASM_NAME_TO_STRING (buf2
, buf1
);
1107 ASM_GENERATE_INTERNAL_LABEL (buf1
, "L", CODE_LABEL_NUMBER (x
));
1108 ASM_NAME_TO_STRING (buf2
, buf1
);
1113 sprintf (buf1
, HOST_WIDE_INT_PRINT_DEC
, INTVAL (x
));
1118 /* This used to output parentheses around the expression, but that does
1119 not work on the 386 (either ATT or BSD assembler). */
1120 addr_const_to_string (buf1
, XEXP (x
, 0));
1125 if (GET_MODE (x
) == VOIDmode
)
1127 /* We can use %d if the number is one word and positive. */
1128 if (CONST_DOUBLE_HIGH (x
))
1129 sprintf (buf1
, HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
1130 CONST_DOUBLE_HIGH (x
), CONST_DOUBLE_LOW (x
));
1131 else if (CONST_DOUBLE_LOW (x
) < 0)
1132 sprintf (buf1
, HOST_WIDE_INT_PRINT_HEX
, CONST_DOUBLE_LOW (x
));
1134 sprintf (buf1
, HOST_WIDE_INT_PRINT_DEC
,
1135 CONST_DOUBLE_LOW (x
));
1139 /* We can't handle floating point constants; PRINT_OPERAND must
1141 output_operand_lossage ("floating constant misused");
1145 /* Some assemblers need integer constants to appear last (eg masm). */
1146 if (GET_CODE (XEXP (x
, 0)) == CONST_INT
)
1148 addr_const_to_string (buf1
, XEXP (x
, 1));
1150 if (INTVAL (XEXP (x
, 0)) >= 0)
1153 addr_const_to_string (buf1
, XEXP (x
, 0));
1158 addr_const_to_string (buf1
, XEXP (x
, 0));
1160 if (INTVAL (XEXP (x
, 1)) >= 0)
1163 addr_const_to_string (buf1
, XEXP (x
, 1));
1169 /* Avoid outputting things like x-x or x+5-x, since some assemblers
1170 can't handle that. */
1171 x
= simplify_subtraction (x
);
1172 if (GET_CODE (x
) != MINUS
)
1175 addr_const_to_string (buf1
, XEXP (x
, 0));
1178 if (GET_CODE (XEXP (x
, 1)) == CONST_INT
1179 && INTVAL (XEXP (x
, 1)) < 0)
1181 strcat (str
, ASM_OPEN_PAREN
);
1182 addr_const_to_string (buf1
, XEXP (x
, 1));
1184 strcat (str
, ASM_CLOSE_PAREN
);
1188 addr_const_to_string (buf1
, XEXP (x
, 1));
1195 addr_const_to_string (buf1
, XEXP (x
, 0));
1200 output_operand_lossage ("invalid expression as operand");
1204 /* Convert an address constant to a string, and return a pointer to
1205 a copy of the result, located on the heap. */
1212 addr_const_to_string (buf
, x
);
1213 return xstrdup (buf
);
1216 /* Test if rtl node points to a psuedo register. */
1222 return (((GET_CODE (rtl
) == REG
) && (REGNO (rtl
) >= FIRST_PSEUDO_REGISTER
))
1223 || ((GET_CODE (rtl
) == SUBREG
)
1224 && (REGNO (XEXP (rtl
, 0)) >= FIRST_PSEUDO_REGISTER
)));
1227 /* Return a reference to a type, with its const and volatile qualifiers
1231 type_main_variant (type
)
1234 type
= TYPE_MAIN_VARIANT (type
);
1236 /* There really should be only one main variant among any group of variants
1237 of a given type (and all of the MAIN_VARIANT values for all members of
1238 the group should point to that one type) but sometimes the C front-end
1239 messes this up for array types, so we work around that bug here. */
1241 if (TREE_CODE (type
) == ARRAY_TYPE
)
1242 while (type
!= TYPE_MAIN_VARIANT (type
))
1243 type
= TYPE_MAIN_VARIANT (type
);
1248 /* Return non-zero if the given type node represents a tagged type. */
1251 is_tagged_type (type
)
1254 register enum tree_code code
= TREE_CODE (type
);
1256 return (code
== RECORD_TYPE
|| code
== UNION_TYPE
1257 || code
== QUAL_UNION_TYPE
|| code
== ENUMERAL_TYPE
);
1260 /* Convert a DIE tag into its string name. */
1263 dwarf_tag_name (tag
)
1264 register unsigned tag
;
1268 case DW_TAG_padding
:
1269 return "DW_TAG_padding";
1270 case DW_TAG_array_type
:
1271 return "DW_TAG_array_type";
1272 case DW_TAG_class_type
:
1273 return "DW_TAG_class_type";
1274 case DW_TAG_entry_point
:
1275 return "DW_TAG_entry_point";
1276 case DW_TAG_enumeration_type
:
1277 return "DW_TAG_enumeration_type";
1278 case DW_TAG_formal_parameter
:
1279 return "DW_TAG_formal_parameter";
1280 case DW_TAG_imported_declaration
:
1281 return "DW_TAG_imported_declaration";
1283 return "DW_TAG_label";
1284 case DW_TAG_lexical_block
:
1285 return "DW_TAG_lexical_block";
1287 return "DW_TAG_member";
1288 case DW_TAG_pointer_type
:
1289 return "DW_TAG_pointer_type";
1290 case DW_TAG_reference_type
:
1291 return "DW_TAG_reference_type";
1292 case DW_TAG_compile_unit
:
1293 return "DW_TAG_compile_unit";
1294 case DW_TAG_string_type
:
1295 return "DW_TAG_string_type";
1296 case DW_TAG_structure_type
:
1297 return "DW_TAG_structure_type";
1298 case DW_TAG_subroutine_type
:
1299 return "DW_TAG_subroutine_type";
1300 case DW_TAG_typedef
:
1301 return "DW_TAG_typedef";
1302 case DW_TAG_union_type
:
1303 return "DW_TAG_union_type";
1304 case DW_TAG_unspecified_parameters
:
1305 return "DW_TAG_unspecified_parameters";
1306 case DW_TAG_variant
:
1307 return "DW_TAG_variant";
1308 case DW_TAG_common_block
:
1309 return "DW_TAG_common_block";
1310 case DW_TAG_common_inclusion
:
1311 return "DW_TAG_common_inclusion";
1312 case DW_TAG_inheritance
:
1313 return "DW_TAG_inheritance";
1314 case DW_TAG_inlined_subroutine
:
1315 return "DW_TAG_inlined_subroutine";
1317 return "DW_TAG_module";
1318 case DW_TAG_ptr_to_member_type
:
1319 return "DW_TAG_ptr_to_member_type";
1320 case DW_TAG_set_type
:
1321 return "DW_TAG_set_type";
1322 case DW_TAG_subrange_type
:
1323 return "DW_TAG_subrange_type";
1324 case DW_TAG_with_stmt
:
1325 return "DW_TAG_with_stmt";
1326 case DW_TAG_access_declaration
:
1327 return "DW_TAG_access_declaration";
1328 case DW_TAG_base_type
:
1329 return "DW_TAG_base_type";
1330 case DW_TAG_catch_block
:
1331 return "DW_TAG_catch_block";
1332 case DW_TAG_const_type
:
1333 return "DW_TAG_const_type";
1334 case DW_TAG_constant
:
1335 return "DW_TAG_constant";
1336 case DW_TAG_enumerator
:
1337 return "DW_TAG_enumerator";
1338 case DW_TAG_file_type
:
1339 return "DW_TAG_file_type";
1341 return "DW_TAG_friend";
1342 case DW_TAG_namelist
:
1343 return "DW_TAG_namelist";
1344 case DW_TAG_namelist_item
:
1345 return "DW_TAG_namelist_item";
1346 case DW_TAG_packed_type
:
1347 return "DW_TAG_packed_type";
1348 case DW_TAG_subprogram
:
1349 return "DW_TAG_subprogram";
1350 case DW_TAG_template_type_param
:
1351 return "DW_TAG_template_type_param";
1352 case DW_TAG_template_value_param
:
1353 return "DW_TAG_template_value_param";
1354 case DW_TAG_thrown_type
:
1355 return "DW_TAG_thrown_type";
1356 case DW_TAG_try_block
:
1357 return "DW_TAG_try_block";
1358 case DW_TAG_variant_part
:
1359 return "DW_TAG_variant_part";
1360 case DW_TAG_variable
:
1361 return "DW_TAG_variable";
1362 case DW_TAG_volatile_type
:
1363 return "DW_TAG_volatile_type";
1364 case DW_TAG_MIPS_loop
:
1365 return "DW_TAG_MIPS_loop";
1366 case DW_TAG_format_label
:
1367 return "DW_TAG_format_label";
1368 case DW_TAG_function_template
:
1369 return "DW_TAG_function_template";
1370 case DW_TAG_class_template
:
1371 return "DW_TAG_class_template";
1373 return "DW_TAG_<unknown>";
1377 /* Convert a DWARF attribute code into its string name. */
1380 dwarf_attr_name (attr
)
1381 register unsigned attr
;
1386 return "DW_AT_sibling";
1387 case DW_AT_location
:
1388 return "DW_AT_location";
1390 return "DW_AT_name";
1391 case DW_AT_ordering
:
1392 return "DW_AT_ordering";
1393 case DW_AT_subscr_data
:
1394 return "DW_AT_subscr_data";
1395 case DW_AT_byte_size
:
1396 return "DW_AT_byte_size";
1397 case DW_AT_bit_offset
:
1398 return "DW_AT_bit_offset";
1399 case DW_AT_bit_size
:
1400 return "DW_AT_bit_size";
1401 case DW_AT_element_list
:
1402 return "DW_AT_element_list";
1403 case DW_AT_stmt_list
:
1404 return "DW_AT_stmt_list";
1406 return "DW_AT_low_pc";
1408 return "DW_AT_high_pc";
1409 case DW_AT_language
:
1410 return "DW_AT_language";
1412 return "DW_AT_member";
1414 return "DW_AT_discr";
1415 case DW_AT_discr_value
:
1416 return "DW_AT_discr_value";
1417 case DW_AT_visibility
:
1418 return "DW_AT_visibility";
1420 return "DW_AT_import";
1421 case DW_AT_string_length
:
1422 return "DW_AT_string_length";
1423 case DW_AT_common_reference
:
1424 return "DW_AT_common_reference";
1425 case DW_AT_comp_dir
:
1426 return "DW_AT_comp_dir";
1427 case DW_AT_const_value
:
1428 return "DW_AT_const_value";
1429 case DW_AT_containing_type
:
1430 return "DW_AT_containing_type";
1431 case DW_AT_default_value
:
1432 return "DW_AT_default_value";
1434 return "DW_AT_inline";
1435 case DW_AT_is_optional
:
1436 return "DW_AT_is_optional";
1437 case DW_AT_lower_bound
:
1438 return "DW_AT_lower_bound";
1439 case DW_AT_producer
:
1440 return "DW_AT_producer";
1441 case DW_AT_prototyped
:
1442 return "DW_AT_prototyped";
1443 case DW_AT_return_addr
:
1444 return "DW_AT_return_addr";
1445 case DW_AT_start_scope
:
1446 return "DW_AT_start_scope";
1447 case DW_AT_stride_size
:
1448 return "DW_AT_stride_size";
1449 case DW_AT_upper_bound
:
1450 return "DW_AT_upper_bound";
1451 case DW_AT_abstract_origin
:
1452 return "DW_AT_abstract_origin";
1453 case DW_AT_accessibility
:
1454 return "DW_AT_accessibility";
1455 case DW_AT_address_class
:
1456 return "DW_AT_address_class";
1457 case DW_AT_artificial
:
1458 return "DW_AT_artificial";
1459 case DW_AT_base_types
:
1460 return "DW_AT_base_types";
1461 case DW_AT_calling_convention
:
1462 return "DW_AT_calling_convention";
1464 return "DW_AT_count";
1465 case DW_AT_data_member_location
:
1466 return "DW_AT_data_member_location";
1467 case DW_AT_decl_column
:
1468 return "DW_AT_decl_column";
1469 case DW_AT_decl_file
:
1470 return "DW_AT_decl_file";
1471 case DW_AT_decl_line
:
1472 return "DW_AT_decl_line";
1473 case DW_AT_declaration
:
1474 return "DW_AT_declaration";
1475 case DW_AT_discr_list
:
1476 return "DW_AT_discr_list";
1477 case DW_AT_encoding
:
1478 return "DW_AT_encoding";
1479 case DW_AT_external
:
1480 return "DW_AT_external";
1481 case DW_AT_frame_base
:
1482 return "DW_AT_frame_base";
1484 return "DW_AT_friend";
1485 case DW_AT_identifier_case
:
1486 return "DW_AT_identifier_case";
1487 case DW_AT_macro_info
:
1488 return "DW_AT_macro_info";
1489 case DW_AT_namelist_items
:
1490 return "DW_AT_namelist_items";
1491 case DW_AT_priority
:
1492 return "DW_AT_priority";
1494 return "DW_AT_segment";
1495 case DW_AT_specification
:
1496 return "DW_AT_specification";
1497 case DW_AT_static_link
:
1498 return "DW_AT_static_link";
1500 return "DW_AT_type";
1501 case DW_AT_use_location
:
1502 return "DW_AT_use_location";
1503 case DW_AT_variable_parameter
:
1504 return "DW_AT_variable_parameter";
1505 case DW_AT_virtuality
:
1506 return "DW_AT_virtuality";
1507 case DW_AT_vtable_elem_location
:
1508 return "DW_AT_vtable_elem_location";
1510 case DW_AT_MIPS_fde
:
1511 return "DW_AT_MIPS_fde";
1512 case DW_AT_MIPS_loop_begin
:
1513 return "DW_AT_MIPS_loop_begin";
1514 case DW_AT_MIPS_tail_loop_begin
:
1515 return "DW_AT_MIPS_tail_loop_begin";
1516 case DW_AT_MIPS_epilog_begin
:
1517 return "DW_AT_MIPS_epilog_begin";
1518 case DW_AT_MIPS_loop_unroll_factor
:
1519 return "DW_AT_MIPS_loop_unroll_factor";
1520 case DW_AT_MIPS_software_pipeline_depth
:
1521 return "DW_AT_MIPS_software_pipeline_depth";
1522 case DW_AT_MIPS_linkage_name
:
1523 return "DW_AT_MIPS_linkage_name";
1524 case DW_AT_MIPS_stride
:
1525 return "DW_AT_MIPS_stride";
1526 case DW_AT_MIPS_abstract_name
:
1527 return "DW_AT_MIPS_abstract_name";
1528 case DW_AT_MIPS_clone_origin
:
1529 return "DW_AT_MIPS_clone_origin";
1530 case DW_AT_MIPS_has_inlines
:
1531 return "DW_AT_MIPS_has_inlines";
1533 case DW_AT_sf_names
:
1534 return "DW_AT_sf_names";
1535 case DW_AT_src_info
:
1536 return "DW_AT_src_info";
1537 case DW_AT_mac_info
:
1538 return "DW_AT_mac_info";
1539 case DW_AT_src_coords
:
1540 return "DW_AT_src_coords";
1541 case DW_AT_body_begin
:
1542 return "DW_AT_body_begin";
1543 case DW_AT_body_end
:
1544 return "DW_AT_body_end";
1546 return "DW_AT_<unknown>";
1550 /* Convert a DWARF value form code into its string name. */
1553 dwarf_form_name (form
)
1554 register unsigned form
;
1559 return "DW_FORM_addr";
1560 case DW_FORM_block2
:
1561 return "DW_FORM_block2";
1562 case DW_FORM_block4
:
1563 return "DW_FORM_block4";
1565 return "DW_FORM_data2";
1567 return "DW_FORM_data4";
1569 return "DW_FORM_data8";
1570 case DW_FORM_string
:
1571 return "DW_FORM_string";
1573 return "DW_FORM_block";
1574 case DW_FORM_block1
:
1575 return "DW_FORM_block1";
1577 return "DW_FORM_data1";
1579 return "DW_FORM_flag";
1581 return "DW_FORM_sdata";
1583 return "DW_FORM_strp";
1585 return "DW_FORM_udata";
1586 case DW_FORM_ref_addr
:
1587 return "DW_FORM_ref_addr";
1589 return "DW_FORM_ref1";
1591 return "DW_FORM_ref2";
1593 return "DW_FORM_ref4";
1595 return "DW_FORM_ref8";
1596 case DW_FORM_ref_udata
:
1597 return "DW_FORM_ref_udata";
1598 case DW_FORM_indirect
:
1599 return "DW_FORM_indirect";
1601 return "DW_FORM_<unknown>";
1605 /* Convert a DWARF stack opcode into its string name. */
1608 dwarf_stack_op_name (op
)
1609 register unsigned op
;
1614 return "DW_OP_addr";
1616 return "DW_OP_deref";
1618 return "DW_OP_const1u";
1620 return "DW_OP_const1s";
1622 return "DW_OP_const2u";
1624 return "DW_OP_const2s";
1626 return "DW_OP_const4u";
1628 return "DW_OP_const4s";
1630 return "DW_OP_const8u";
1632 return "DW_OP_const8s";
1634 return "DW_OP_constu";
1636 return "DW_OP_consts";
1640 return "DW_OP_drop";
1642 return "DW_OP_over";
1644 return "DW_OP_pick";
1646 return "DW_OP_swap";
1650 return "DW_OP_xderef";
1658 return "DW_OP_minus";
1670 return "DW_OP_plus";
1671 case DW_OP_plus_uconst
:
1672 return "DW_OP_plus_uconst";
1678 return "DW_OP_shra";
1696 return "DW_OP_skip";
1698 return "DW_OP_lit0";
1700 return "DW_OP_lit1";
1702 return "DW_OP_lit2";
1704 return "DW_OP_lit3";
1706 return "DW_OP_lit4";
1708 return "DW_OP_lit5";
1710 return "DW_OP_lit6";
1712 return "DW_OP_lit7";
1714 return "DW_OP_lit8";
1716 return "DW_OP_lit9";
1718 return "DW_OP_lit10";
1720 return "DW_OP_lit11";
1722 return "DW_OP_lit12";
1724 return "DW_OP_lit13";
1726 return "DW_OP_lit14";
1728 return "DW_OP_lit15";
1730 return "DW_OP_lit16";
1732 return "DW_OP_lit17";
1734 return "DW_OP_lit18";
1736 return "DW_OP_lit19";
1738 return "DW_OP_lit20";
1740 return "DW_OP_lit21";
1742 return "DW_OP_lit22";
1744 return "DW_OP_lit23";
1746 return "DW_OP_lit24";
1748 return "DW_OP_lit25";
1750 return "DW_OP_lit26";
1752 return "DW_OP_lit27";
1754 return "DW_OP_lit28";
1756 return "DW_OP_lit29";
1758 return "DW_OP_lit30";
1760 return "DW_OP_lit31";
1762 return "DW_OP_reg0";
1764 return "DW_OP_reg1";
1766 return "DW_OP_reg2";
1768 return "DW_OP_reg3";
1770 return "DW_OP_reg4";
1772 return "DW_OP_reg5";
1774 return "DW_OP_reg6";
1776 return "DW_OP_reg7";
1778 return "DW_OP_reg8";
1780 return "DW_OP_reg9";
1782 return "DW_OP_reg10";
1784 return "DW_OP_reg11";
1786 return "DW_OP_reg12";
1788 return "DW_OP_reg13";
1790 return "DW_OP_reg14";
1792 return "DW_OP_reg15";
1794 return "DW_OP_reg16";
1796 return "DW_OP_reg17";
1798 return "DW_OP_reg18";
1800 return "DW_OP_reg19";
1802 return "DW_OP_reg20";
1804 return "DW_OP_reg21";
1806 return "DW_OP_reg22";
1808 return "DW_OP_reg23";
1810 return "DW_OP_reg24";
1812 return "DW_OP_reg25";
1814 return "DW_OP_reg26";
1816 return "DW_OP_reg27";
1818 return "DW_OP_reg28";
1820 return "DW_OP_reg29";
1822 return "DW_OP_reg30";
1824 return "DW_OP_reg31";
1826 return "DW_OP_breg0";
1828 return "DW_OP_breg1";
1830 return "DW_OP_breg2";
1832 return "DW_OP_breg3";
1834 return "DW_OP_breg4";
1836 return "DW_OP_breg5";
1838 return "DW_OP_breg6";
1840 return "DW_OP_breg7";
1842 return "DW_OP_breg8";
1844 return "DW_OP_breg9";
1846 return "DW_OP_breg10";
1848 return "DW_OP_breg11";
1850 return "DW_OP_breg12";
1852 return "DW_OP_breg13";
1854 return "DW_OP_breg14";
1856 return "DW_OP_breg15";
1858 return "DW_OP_breg16";
1860 return "DW_OP_breg17";
1862 return "DW_OP_breg18";
1864 return "DW_OP_breg19";
1866 return "DW_OP_breg20";
1868 return "DW_OP_breg21";
1870 return "DW_OP_breg22";
1872 return "DW_OP_breg23";
1874 return "DW_OP_breg24";
1876 return "DW_OP_breg25";
1878 return "DW_OP_breg26";
1880 return "DW_OP_breg27";
1882 return "DW_OP_breg28";
1884 return "DW_OP_breg29";
1886 return "DW_OP_breg30";
1888 return "DW_OP_breg31";
1890 return "DW_OP_regx";
1892 return "DW_OP_fbreg";
1894 return "DW_OP_bregx";
1896 return "DW_OP_piece";
1897 case DW_OP_deref_size
:
1898 return "DW_OP_deref_size";
1899 case DW_OP_xderef_size
:
1900 return "DW_OP_xderef_size";
1904 return "OP_<unknown>";
1908 /* Convert a DWARF type code into its string name. */
1911 dwarf_type_encoding_name (enc
)
1912 register unsigned enc
;
1916 case DW_ATE_address
:
1917 return "DW_ATE_address";
1918 case DW_ATE_boolean
:
1919 return "DW_ATE_boolean";
1920 case DW_ATE_complex_float
:
1921 return "DW_ATE_complex_float";
1923 return "DW_ATE_float";
1925 return "DW_ATE_signed";
1926 case DW_ATE_signed_char
:
1927 return "DW_ATE_signed_char";
1928 case DW_ATE_unsigned
:
1929 return "DW_ATE_unsigned";
1930 case DW_ATE_unsigned_char
:
1931 return "DW_ATE_unsigned_char";
1933 return "DW_ATE_<unknown>";
1937 /* Convert a DWARF call frame info. operation to its string name */
1940 dwarf_cfi_name (cfi_opc
)
1941 register unsigned cfi_opc
;
1945 case DW_CFA_advance_loc
:
1946 return "DW_CFA_advance_loc";
1948 return "DW_CFA_offset";
1949 case DW_CFA_restore
:
1950 return "DW_CFA_restore";
1952 return "DW_CFA_nop";
1953 case DW_CFA_set_loc
:
1954 return "DW_CFA_set_loc";
1955 case DW_CFA_advance_loc1
:
1956 return "DW_CFA_advance_loc1";
1957 case DW_CFA_advance_loc2
:
1958 return "DW_CFA_advance_loc2";
1959 case DW_CFA_advance_loc4
:
1960 return "DW_CFA_advance_loc4";
1961 case DW_CFA_offset_extended
:
1962 return "DW_CFA_offset_extended";
1963 case DW_CFA_restore_extended
:
1964 return "DW_CFA_restore_extended";
1965 case DW_CFA_undefined
:
1966 return "DW_CFA_undefined";
1967 case DW_CFA_same_value
:
1968 return "DW_CFA_same_value";
1969 case DW_CFA_register
:
1970 return "DW_CFA_register";
1971 case DW_CFA_remember_state
:
1972 return "DW_CFA_remember_state";
1973 case DW_CFA_restore_state
:
1974 return "DW_CFA_restore_state";
1975 case DW_CFA_def_cfa
:
1976 return "DW_CFA_def_cfa";
1977 case DW_CFA_def_cfa_register
:
1978 return "DW_CFA_def_cfa_register";
1979 case DW_CFA_def_cfa_offset
:
1980 return "DW_CFA_def_cfa_offset";
1981 /* SGI/MIPS specific */
1982 case DW_CFA_MIPS_advance_loc8
:
1983 return "DW_CFA_MIPS_advance_loc8";
1985 return "DW_CFA_<unknown>";
1989 /* Determine the "ultimate origin" of a decl. The decl may be an inlined
1990 instance of an inlined instance of a decl which is local to an inline
1991 function, so we have to trace all of the way back through the origin chain
1992 to find out what sort of node actually served as the original seed for the
1996 decl_ultimate_origin (decl
)
1999 register tree immediate_origin
= DECL_ABSTRACT_ORIGIN (decl
);
2001 if (immediate_origin
== NULL_TREE
)
2005 register tree ret_val
;
2006 register tree lookahead
= immediate_origin
;
2010 ret_val
= lookahead
;
2011 lookahead
= DECL_ABSTRACT_ORIGIN (ret_val
);
2013 while (lookahead
!= NULL
&& lookahead
!= ret_val
);
2019 /* Determine the "ultimate origin" of a block. The block may be an inlined
2020 instance of an inlined instance of a block which is local to an inline
2021 function, so we have to trace all of the way back through the origin chain
2022 to find out what sort of node actually served as the original seed for the
2026 block_ultimate_origin (block
)
2027 register tree block
;
2029 register tree immediate_origin
= BLOCK_ABSTRACT_ORIGIN (block
);
2031 if (immediate_origin
== NULL_TREE
)
2035 register tree ret_val
;
2036 register tree lookahead
= immediate_origin
;
2040 ret_val
= lookahead
;
2041 lookahead
= (TREE_CODE (ret_val
) == BLOCK
)
2042 ? BLOCK_ABSTRACT_ORIGIN (ret_val
)
2045 while (lookahead
!= NULL
&& lookahead
!= ret_val
);
2051 /* Get the class to which DECL belongs, if any. In g++, the DECL_CONTEXT
2052 of a virtual function may refer to a base class, so we check the 'this'
2056 decl_class_context (decl
)
2059 tree context
= NULL_TREE
;
2061 if (TREE_CODE (decl
) != FUNCTION_DECL
|| ! DECL_VINDEX (decl
))
2062 context
= DECL_CONTEXT (decl
);
2064 context
= TYPE_MAIN_VARIANT
2065 (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)))));
2067 if (context
&& TREE_CODE_CLASS (TREE_CODE (context
)) != 't')
2068 context
= NULL_TREE
;
2073 /* Add an attribute/value pair to a DIE */
2076 add_dwarf_attr (die
, attr
)
2077 register dw_die_ref die
;
2078 register dw_attr_ref attr
;
2080 if (die
!= NULL
&& attr
!= NULL
)
2082 if (die
->die_attr
== NULL
)
2084 die
->die_attr
= attr
;
2085 die
->die_attr_last
= attr
;
2089 die
->die_attr_last
->dw_attr_next
= attr
;
2090 die
->die_attr_last
= attr
;
2095 /* Add a flag value attribute to a DIE. */
2098 add_AT_flag (die
, attr_kind
, flag
)
2099 register dw_die_ref die
;
2100 register enum dwarf_attribute attr_kind
;
2101 register unsigned flag
;
2103 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
2105 attr
->dw_attr_next
= NULL
;
2106 attr
->dw_attr
= attr_kind
;
2107 attr
->dw_attr_val
.val_class
= dw_val_class_flag
;
2108 attr
->dw_attr_val
.v
.val_flag
= flag
;
2109 add_dwarf_attr (die
, attr
);
2112 /* Add a signed integer attribute value to a DIE. */
2115 add_AT_int (die
, attr_kind
, int_val
)
2116 register dw_die_ref die
;
2117 register enum dwarf_attribute attr_kind
;
2118 register long int int_val
;
2120 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
2122 attr
->dw_attr_next
= NULL
;
2123 attr
->dw_attr
= attr_kind
;
2124 attr
->dw_attr_val
.val_class
= dw_val_class_const
;
2125 attr
->dw_attr_val
.v
.val_int
= int_val
;
2126 add_dwarf_attr (die
, attr
);
2129 /* Add an unsigned integer attribute value to a DIE. */
2132 add_AT_unsigned (die
, attr_kind
, unsigned_val
)
2133 register dw_die_ref die
;
2134 register enum dwarf_attribute attr_kind
;
2135 register unsigned long unsigned_val
;
2137 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
2139 attr
->dw_attr_next
= NULL
;
2140 attr
->dw_attr
= attr_kind
;
2141 attr
->dw_attr_val
.val_class
= dw_val_class_unsigned_const
;
2142 attr
->dw_attr_val
.v
.val_unsigned
= unsigned_val
;
2143 add_dwarf_attr (die
, attr
);
2146 /* Add an unsigned double integer attribute value to a DIE. */
2149 add_AT_long_long (die
, attr_kind
, val_hi
, val_low
)
2150 register dw_die_ref die
;
2151 register enum dwarf_attribute attr_kind
;
2152 register unsigned long val_hi
;
2153 register unsigned long val_low
;
2155 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
2157 attr
->dw_attr_next
= NULL
;
2158 attr
->dw_attr
= attr_kind
;
2159 attr
->dw_attr_val
.val_class
= dw_val_class_long_long
;
2160 attr
->dw_attr_val
.v
.val_long_long
.hi
= val_hi
;
2161 attr
->dw_attr_val
.v
.val_long_long
.low
= val_low
;
2162 add_dwarf_attr (die
, attr
);
2165 /* Add a floating point attribute value to a DIE and return it. */
2168 add_AT_float (die
, attr_kind
, length
, array
)
2169 register dw_die_ref die
;
2170 register enum dwarf_attribute attr_kind
;
2171 register unsigned length
;
2172 register long *array
;
2174 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
2176 attr
->dw_attr_next
= NULL
;
2177 attr
->dw_attr
= attr_kind
;
2178 attr
->dw_attr_val
.val_class
= dw_val_class_float
;
2179 attr
->dw_attr_val
.v
.val_float
.length
= length
;
2180 attr
->dw_attr_val
.v
.val_float
.array
= array
;
2181 add_dwarf_attr (die
, attr
);
2184 /* Add a string attribute value to a DIE. */
2187 add_AT_string (die
, attr_kind
, str
)
2188 register dw_die_ref die
;
2189 register enum dwarf_attribute attr_kind
;
2192 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
2194 attr
->dw_attr_next
= NULL
;
2195 attr
->dw_attr
= attr_kind
;
2196 attr
->dw_attr_val
.val_class
= dw_val_class_str
;
2197 attr
->dw_attr_val
.v
.val_str
= xstrdup (str
);
2198 add_dwarf_attr (die
, attr
);
2201 /* Add a DIE reference attribute value to a DIE. */
2204 add_AT_die_ref (die
, attr_kind
, targ_die
)
2205 register dw_die_ref die
;
2206 register enum dwarf_attribute attr_kind
;
2207 register dw_die_ref targ_die
;
2209 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
2211 attr
->dw_attr_next
= NULL
;
2212 attr
->dw_attr
= attr_kind
;
2213 attr
->dw_attr_val
.val_class
= dw_val_class_die_ref
;
2214 attr
->dw_attr_val
.v
.val_die_ref
= targ_die
;
2215 add_dwarf_attr (die
, attr
);
2218 /* Add an FDE reference attribute value to a DIE. */
2221 add_AT_fde_ref (die
, attr_kind
, targ_fde
)
2222 register dw_die_ref die
;
2223 register enum dwarf_attribute attr_kind
;
2224 register unsigned targ_fde
;
2226 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
2228 attr
->dw_attr_next
= NULL
;
2229 attr
->dw_attr
= attr_kind
;
2230 attr
->dw_attr_val
.val_class
= dw_val_class_fde_ref
;
2231 attr
->dw_attr_val
.v
.val_fde_index
= targ_fde
;
2232 add_dwarf_attr (die
, attr
);
2235 /* Add a location description attribute value to a DIE. */
2238 add_AT_loc (die
, attr_kind
, loc
)
2239 register dw_die_ref die
;
2240 register enum dwarf_attribute attr_kind
;
2241 register dw_loc_descr_ref loc
;
2243 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
2245 attr
->dw_attr_next
= NULL
;
2246 attr
->dw_attr
= attr_kind
;
2247 attr
->dw_attr_val
.val_class
= dw_val_class_loc
;
2248 attr
->dw_attr_val
.v
.val_loc
= loc
;
2249 add_dwarf_attr (die
, attr
);
2252 /* Add an address constant attribute value to a DIE. */
2255 add_AT_addr (die
, attr_kind
, addr
)
2256 register dw_die_ref die
;
2257 register enum dwarf_attribute attr_kind
;
2260 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
2262 attr
->dw_attr_next
= NULL
;
2263 attr
->dw_attr
= attr_kind
;
2264 attr
->dw_attr_val
.val_class
= dw_val_class_addr
;
2265 attr
->dw_attr_val
.v
.val_addr
= addr
;
2266 add_dwarf_attr (die
, attr
);
2269 /* Add a label identifier attribute value to a DIE. */
2272 add_AT_lbl_id (die
, attr_kind
, lbl_id
)
2273 register dw_die_ref die
;
2274 register enum dwarf_attribute attr_kind
;
2275 register char *lbl_id
;
2277 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
2279 attr
->dw_attr_next
= NULL
;
2280 attr
->dw_attr
= attr_kind
;
2281 attr
->dw_attr_val
.val_class
= dw_val_class_lbl_id
;
2282 attr
->dw_attr_val
.v
.val_lbl_id
= xstrdup (lbl_id
);
2283 add_dwarf_attr (die
, attr
);
2286 /* Add a section offset attribute value to a DIE. */
2289 add_AT_section_offset (die
, attr_kind
, section
)
2290 register dw_die_ref die
;
2291 register enum dwarf_attribute attr_kind
;
2292 register char *section
;
2294 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
2296 attr
->dw_attr_next
= NULL
;
2297 attr
->dw_attr
= attr_kind
;
2298 attr
->dw_attr_val
.val_class
= dw_val_class_section_offset
;
2299 attr
->dw_attr_val
.v
.val_section
= section
;
2300 add_dwarf_attr (die
, attr
);
2304 /* Test if die refers to an external subroutine. */
2307 is_extern_subr_die (die
)
2308 register dw_die_ref die
;
2310 register dw_attr_ref a
;
2311 register int is_subr
= FALSE
;
2312 register int is_extern
= FALSE
;
2314 if (die
!= NULL
&& die
->die_tag
== DW_TAG_subprogram
)
2317 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
2319 if (a
->dw_attr
== DW_AT_external
2320 && a
->dw_attr_val
.val_class
== dw_val_class_flag
2321 && a
->dw_attr_val
.v
.val_flag
!= 0)
2329 return is_subr
&& is_extern
;
2332 /* Get the attribute of type attr_kind. */
2334 static inline dw_attr_ref
2335 get_AT (die
, attr_kind
)
2336 register dw_die_ref die
;
2337 register enum dwarf_attribute attr_kind
;
2339 register dw_attr_ref a
;
2340 register dw_die_ref spec
= NULL
;
2344 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
2346 if (a
->dw_attr
== attr_kind
)
2349 if (a
->dw_attr
== DW_AT_specification
2350 || a
->dw_attr
== DW_AT_abstract_origin
)
2351 spec
= a
->dw_attr_val
.v
.val_die_ref
;
2355 return get_AT (spec
, attr_kind
);
2361 /* Return the "low pc" attribute value, typically associated with
2362 a subprogram DIE. Return null if the "low pc" attribute is
2363 either not prsent, or if it cannot be represented as an
2364 assembler label identifier. */
2366 static inline char *
2368 register dw_die_ref die
;
2370 register dw_attr_ref a
= get_AT (die
, DW_AT_low_pc
);
2372 if (a
&& a
->dw_attr_val
.val_class
== dw_val_class_lbl_id
)
2373 return a
->dw_attr_val
.v
.val_lbl_id
;
2378 /* Return the "high pc" attribute value, typically associated with
2379 a subprogram DIE. Return null if the "high pc" attribute is
2380 either not prsent, or if it cannot be represented as an
2381 assembler label identifier. */
2383 static inline char *
2385 register dw_die_ref die
;
2387 register dw_attr_ref a
= get_AT (die
, DW_AT_high_pc
);
2389 if (a
&& a
->dw_attr_val
.val_class
== dw_val_class_lbl_id
)
2390 return a
->dw_attr_val
.v
.val_lbl_id
;
2395 /* Return the value of the string attribute designated by ATTR_KIND, or
2396 NULL if it is not present. */
2398 static inline char *
2399 get_AT_string (die
, attr_kind
)
2400 register dw_die_ref die
;
2401 register enum dwarf_attribute attr_kind
;
2403 register dw_attr_ref a
= get_AT (die
, attr_kind
);
2405 if (a
&& a
->dw_attr_val
.val_class
== dw_val_class_str
)
2406 return a
->dw_attr_val
.v
.val_str
;
2411 /* Return the value of the flag attribute designated by ATTR_KIND, or -1
2412 if it is not present. */
2415 get_AT_flag (die
, attr_kind
)
2416 register dw_die_ref die
;
2417 register enum dwarf_attribute attr_kind
;
2419 register dw_attr_ref a
= get_AT (die
, attr_kind
);
2421 if (a
&& a
->dw_attr_val
.val_class
== dw_val_class_flag
)
2422 return a
->dw_attr_val
.v
.val_flag
;
2427 /* Return the value of the unsigned attribute designated by ATTR_KIND, or 0
2428 if it is not present. */
2430 static inline unsigned
2431 get_AT_unsigned (die
, attr_kind
)
2432 register dw_die_ref die
;
2433 register enum dwarf_attribute attr_kind
;
2435 register dw_attr_ref a
= get_AT (die
, attr_kind
);
2437 if (a
&& a
->dw_attr_val
.val_class
== dw_val_class_unsigned_const
)
2438 return a
->dw_attr_val
.v
.val_unsigned
;
2446 register unsigned lang
= get_AT_unsigned (comp_unit_die
, DW_AT_language
);
2448 return (lang
== DW_LANG_C
|| lang
== DW_LANG_C89
2449 || lang
== DW_LANG_C_plus_plus
);
2455 register unsigned lang
= get_AT_unsigned (comp_unit_die
, DW_AT_language
);
2457 return (lang
== DW_LANG_Fortran77
|| lang
== DW_LANG_Fortran90
);
2460 /* Remove the specified attribute if present. */
2463 remove_AT (die
, attr_kind
)
2464 register dw_die_ref die
;
2465 register enum dwarf_attribute attr_kind
;
2467 register dw_attr_ref a
;
2468 register dw_attr_ref removed
= NULL
;;
2472 if (die
->die_attr
->dw_attr
== attr_kind
)
2474 removed
= die
->die_attr
;
2475 if (die
->die_attr_last
== die
->die_attr
)
2476 die
->die_attr_last
= NULL
;
2478 die
->die_attr
= die
->die_attr
->dw_attr_next
;
2482 for (a
= die
->die_attr
; a
->dw_attr_next
!= NULL
;
2483 a
= a
->dw_attr_next
)
2484 if (a
->dw_attr_next
->dw_attr
== attr_kind
)
2486 removed
= a
->dw_attr_next
;
2487 if (die
->die_attr_last
== a
->dw_attr_next
)
2488 die
->die_attr_last
= a
;
2490 a
->dw_attr_next
= a
->dw_attr_next
->dw_attr_next
;
2499 /* Discard the children of this DIE. */
2502 remove_children (die
)
2503 register dw_die_ref die
;
2505 register dw_die_ref child_die
= die
->die_child
;
2507 die
->die_child
= NULL
;
2508 die
->die_child_last
= NULL
;
2510 while (child_die
!= NULL
)
2512 register dw_die_ref tmp_die
= child_die
;
2513 register dw_attr_ref a
;
2515 child_die
= child_die
->die_sib
;
2517 for (a
= tmp_die
->die_attr
; a
!= NULL
; )
2519 register dw_attr_ref tmp_a
= a
;
2521 a
= a
->dw_attr_next
;
2529 /* Add a child DIE below its parent. */
2532 add_child_die (die
, child_die
)
2533 register dw_die_ref die
;
2534 register dw_die_ref child_die
;
2536 if (die
!= NULL
&& child_die
!= NULL
)
2538 assert (die
!= child_die
);
2539 child_die
->die_parent
= die
;
2540 child_die
->die_sib
= NULL
;
2542 if (die
->die_child
== NULL
)
2544 die
->die_child
= child_die
;
2545 die
->die_child_last
= child_die
;
2549 die
->die_child_last
->die_sib
= child_die
;
2550 die
->die_child_last
= child_die
;
2555 /* Return a pointer to a newly created DIE node. */
2557 static inline dw_die_ref
2558 new_die (tag_value
, parent_die
)
2559 register enum dwarf_tag tag_value
;
2560 register dw_die_ref parent_die
;
2562 register dw_die_ref die
= (dw_die_ref
) xmalloc (sizeof (die_node
));
2564 die
->die_tag
= tag_value
;
2565 die
->die_abbrev
= 0;
2566 die
->die_offset
= 0;
2567 die
->die_child
= NULL
;
2568 die
->die_parent
= NULL
;
2569 die
->die_sib
= NULL
;
2570 die
->die_child_last
= NULL
;
2571 die
->die_attr
= NULL
;
2572 die
->die_attr_last
= NULL
;
2574 if (parent_die
!= NULL
)
2575 add_child_die (parent_die
, die
);
2582 /* Return the DIE associated with the given type specifier. */
2584 static inline dw_die_ref
2585 lookup_type_die (type
)
2588 return (dw_die_ref
) TYPE_SYMTAB_POINTER (type
);
2591 /* Equate a DIE to a given type specifier. */
2594 equate_type_number_to_die (type
, type_die
)
2596 register dw_die_ref type_die
;
2598 TYPE_SYMTAB_POINTER (type
) = (char *) type_die
;
2601 /* Return the DIE associated with a given declaration. */
2603 static inline dw_die_ref
2604 lookup_decl_die (decl
)
2607 register unsigned decl_id
= DECL_UID (decl
);
2609 return (decl_id
< decl_die_table_in_use
2610 ? decl_die_table
[decl_id
] : NULL
);
2613 /* Equate a DIE to a particular declaration. */
2616 equate_decl_number_to_die (decl
, decl_die
)
2618 register dw_die_ref decl_die
;
2620 register unsigned decl_id
= DECL_UID (decl
);
2621 register unsigned i
;
2622 register unsigned num_allocated
;
2624 if (decl_id
>= decl_die_table_allocated
)
2627 = ((decl_id
+ 1 + DECL_DIE_TABLE_INCREMENT
- 1)
2628 / DECL_DIE_TABLE_INCREMENT
)
2629 * DECL_DIE_TABLE_INCREMENT
;
2632 = (dw_die_ref
*) xrealloc (decl_die_table
,
2633 sizeof (dw_die_ref
) * num_allocated
);
2635 bzero ((char *) &decl_die_table
[decl_die_table_allocated
],
2636 (num_allocated
- decl_die_table_allocated
) * sizeof (dw_die_ref
));
2637 decl_die_table_allocated
= num_allocated
;
2640 if (decl_id
>= decl_die_table_in_use
)
2641 decl_die_table_in_use
= (decl_id
+ 1);
2643 decl_die_table
[decl_id
] = decl_die
;
2646 /* Return a pointer to a newly allocated location description. Location
2647 descriptions are simple expression terms that can be strung
2648 together to form more complicated location (address) descriptions. */
2650 static inline dw_loc_descr_ref
2651 new_loc_descr (op
, oprnd1
, oprnd2
)
2652 register enum dwarf_location_atom op
;
2653 register unsigned long oprnd1
;
2654 register unsigned long oprnd2
;
2656 register dw_loc_descr_ref descr
2657 = (dw_loc_descr_ref
) xmalloc (sizeof (dw_loc_descr_node
));
2659 descr
->dw_loc_next
= NULL
;
2660 descr
->dw_loc_opc
= op
;
2661 descr
->dw_loc_oprnd1
.val_class
= dw_val_class_unsigned_const
;
2662 descr
->dw_loc_oprnd1
.v
.val_unsigned
= oprnd1
;
2663 descr
->dw_loc_oprnd2
.val_class
= dw_val_class_unsigned_const
;
2664 descr
->dw_loc_oprnd2
.v
.val_unsigned
= oprnd2
;
2669 /* Add a location description term to a location description expression. */
2672 add_loc_descr (list_head
, descr
)
2673 register dw_loc_descr_ref
*list_head
;
2674 register dw_loc_descr_ref descr
;
2676 register dw_loc_descr_ref
*d
;
2678 /* Find the end of the chain. */
2679 for (d
= list_head
; (*d
) != NULL
; d
= &(*d
)->dw_loc_next
)
2685 /* Return a pointer to a newly allocated Call Frame Instruction. */
2687 static inline dw_cfi_ref
2690 register dw_cfi_ref cfi
= (dw_cfi_ref
) xmalloc (sizeof (dw_cfi_node
));
2692 cfi
->dw_cfi_next
= NULL
;
2693 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= 0;
2694 cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
= 0;
2699 /* Add a Call Frame Instruction to list of instructions. */
2702 add_cfi (list_head
, cfi
)
2703 register dw_cfi_ref
*list_head
;
2704 register dw_cfi_ref cfi
;
2706 register dw_cfi_ref
*p
;
2708 /* Find the end of the chain. */
2709 for (p
= list_head
; (*p
) != NULL
; p
= &(*p
)->dw_cfi_next
)
2715 /* Keep track of the number of spaces used to indent the
2716 output of the debugging routines that print the structure of
2717 the DIE internal representation. */
2718 static int print_indent
;
2720 /* Indent the line the number of spaces given by print_indent. */
2723 print_spaces (outfile
)
2726 fprintf (outfile
, "%*s", print_indent
, "");
2729 /* Print the information assoaciated with a given DIE, and its children.
2730 This routine is a debugging aid only. */
2733 print_die (die
, outfile
)
2737 register dw_attr_ref a
;
2738 register dw_die_ref c
;
2740 print_spaces (outfile
);
2741 fprintf (outfile
, "DIE %4u: %s\n",
2742 die
->die_offset
, dwarf_tag_name (die
->die_tag
));
2743 print_spaces (outfile
);
2744 fprintf (outfile
, " abbrev id: %u", die
->die_abbrev
);
2745 fprintf (outfile
, " offset: %u\n", die
->die_offset
);
2747 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
2749 print_spaces (outfile
);
2750 fprintf (outfile
, " %s: ", dwarf_attr_name (a
->dw_attr
));
2752 switch (a
->dw_attr_val
.val_class
)
2754 case dw_val_class_addr
:
2755 fprintf (outfile
, "address");
2757 case dw_val_class_loc
:
2758 fprintf (outfile
, "location descriptor");
2760 case dw_val_class_const
:
2761 fprintf (outfile
, "%d", a
->dw_attr_val
.v
.val_int
);
2763 case dw_val_class_unsigned_const
:
2764 fprintf (outfile
, "%u", a
->dw_attr_val
.v
.val_unsigned
);
2766 case dw_val_class_long_long
:
2767 fprintf (outfile
, "constant (%u,%u)",
2768 a
->dw_attr_val
.v
.val_long_long
.hi
,
2769 a
->dw_attr_val
.v
.val_long_long
.low
);
2771 case dw_val_class_float
:
2772 fprintf (outfile
, "floating-point constant");
2774 case dw_val_class_flag
:
2775 fprintf (outfile
, "%u", a
->dw_attr_val
.v
.val_flag
);
2777 case dw_val_class_die_ref
:
2778 if (a
->dw_attr_val
.v
.val_die_ref
!= NULL
)
2779 fprintf (outfile
, "die -> %u",
2780 a
->dw_attr_val
.v
.val_die_ref
->die_offset
);
2782 fprintf (outfile
, "die -> <null>");
2784 case dw_val_class_lbl_id
:
2785 fprintf (outfile
, "label: %s", a
->dw_attr_val
.v
.val_lbl_id
);
2787 case dw_val_class_section_offset
:
2788 fprintf (outfile
, "section: %s", a
->dw_attr_val
.v
.val_section
);
2790 case dw_val_class_str
:
2791 if (a
->dw_attr_val
.v
.val_str
!= NULL
)
2792 fprintf (outfile
, "\"%s\"", a
->dw_attr_val
.v
.val_str
);
2794 fprintf (outfile
, "<null>");
2798 fprintf (outfile
, "\n");
2801 if (die
->die_child
!= NULL
)
2804 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
2805 print_die (c
, outfile
);
2811 /* Print the contents of the source code line number correspondence table.
2812 This routine is a debugging aid only. */
2815 print_dwarf_line_table (outfile
)
2818 register unsigned i
;
2819 register dw_line_info_ref line_info
;
2821 fprintf (outfile
, "\n\nDWARF source line information\n");
2822 for (i
= 1; i
< line_info_table_in_use
; ++i
)
2824 line_info
= &line_info_table
[i
];
2825 fprintf (outfile
, "%5d: ", i
);
2826 fprintf (outfile
, "%-20s", file_table
[line_info
->dw_file_num
]);
2827 fprintf (outfile
, "%6d", line_info
->dw_line_num
);
2828 fprintf (outfile
, "\n");
2831 fprintf (outfile
, "\n\n");
2834 /* Print the information collected for a given DIE. */
2837 debug_dwarf_die (die
)
2840 print_die (die
, stderr
);
2843 /* Print all DWARF information collected for the compilation unit.
2844 This routine is a debugging aid only. */
2850 print_die (comp_unit_die
, stderr
);
2851 print_dwarf_line_table (stderr
);
2854 /* Traverse the DIE, and add a sibling attribute if it may have the
2855 effect of speeding up access to siblings. To save some space,
2856 avoid generating sibling attributes for DIE's without children. */
2859 add_sibling_attributes(die
)
2860 register dw_die_ref die
;
2862 register dw_die_ref c
;
2863 register dw_attr_ref attr
;
2864 if (die
!= comp_unit_die
&& die
->die_child
!= NULL
)
2866 attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
2867 attr
->dw_attr_next
= NULL
;
2868 attr
->dw_attr
= DW_AT_sibling
;
2869 attr
->dw_attr_val
.val_class
= dw_val_class_die_ref
;
2870 attr
->dw_attr_val
.v
.val_die_ref
= die
->die_sib
;
2872 /* Add the sibling link to the front of the attribute list. */
2873 attr
->dw_attr_next
= die
->die_attr
;
2874 if (die
->die_attr
== NULL
)
2875 die
->die_attr_last
= attr
;
2877 die
->die_attr
= attr
;
2880 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
2881 add_sibling_attributes (c
);
2884 /* The format of each DIE (and its attribute value pairs)
2885 is encoded in an abbreviation table. This routine builds the
2886 abbreviation table and assigns a unique abbreviation id for
2887 each abbreviation entry. The children of each die are visited
2891 build_abbrev_table (die
)
2892 register dw_die_ref die
;
2894 register unsigned long abbrev_id
;
2895 register unsigned long n_alloc
;
2896 register dw_die_ref c
;
2897 register dw_attr_ref d_attr
, a_attr
;
2898 for (abbrev_id
= 1; abbrev_id
< abbrev_die_table_in_use
; ++abbrev_id
)
2900 register dw_die_ref abbrev
= abbrev_die_table
[abbrev_id
];
2902 if (abbrev
->die_tag
== die
->die_tag
)
2904 if ((abbrev
->die_child
!= NULL
) == (die
->die_child
!= NULL
))
2906 a_attr
= abbrev
->die_attr
;
2907 d_attr
= die
->die_attr
;
2909 while (a_attr
!= NULL
&& d_attr
!= NULL
)
2911 if ((a_attr
->dw_attr
!= d_attr
->dw_attr
)
2912 || (value_format (&a_attr
->dw_attr_val
)
2913 != value_format (&d_attr
->dw_attr_val
)))
2916 a_attr
= a_attr
->dw_attr_next
;
2917 d_attr
= d_attr
->dw_attr_next
;
2920 if (a_attr
== NULL
&& d_attr
== NULL
)
2926 if (abbrev_id
>= abbrev_die_table_in_use
)
2928 if (abbrev_die_table_in_use
>= abbrev_die_table_allocated
)
2930 n_alloc
= abbrev_die_table_allocated
+ ABBREV_DIE_TABLE_INCREMENT
;
2932 = (dw_die_ref
*) xmalloc (abbrev_die_table
,
2933 sizeof (dw_die_ref
) * n_alloc
);
2935 bzero ((char *) &abbrev_die_table
[abbrev_die_table_allocated
],
2936 (n_alloc
- abbrev_die_table_allocated
) * sizeof (dw_die_ref
));
2937 abbrev_die_table_allocated
= n_alloc
;
2940 ++abbrev_die_table_in_use
;
2941 abbrev_die_table
[abbrev_id
] = die
;
2944 die
->die_abbrev
= abbrev_id
;
2945 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
2946 build_abbrev_table (c
);
2949 /* Return the size of an unsigned LEB128 quantity. */
2951 static inline unsigned long
2952 size_of_uleb128 (value
)
2953 register unsigned long value
;
2955 register unsigned long size
= 0;
2956 register unsigned byte
;
2960 byte
= (value
& 0x7f);
2969 /* Return the size of a signed LEB128 quantity. */
2971 static inline unsigned long
2972 size_of_sleb128 (value
)
2973 register long value
;
2975 register unsigned long size
= 0;
2976 register unsigned byte
;
2980 byte
= (value
& 0x7f);
2984 while (!(((value
== 0) && ((byte
& 0x40) == 0))
2985 || ((value
== -1) && ((byte
& 0x40) != 0))));
2990 /* Return the size of a string, including the null byte. */
2992 static unsigned long
2993 size_of_string (str
)
2996 register unsigned long size
= 0;
2997 register unsigned long slen
= strlen (str
);
2998 register unsigned long i
;
2999 register unsigned c
;
3001 for (i
= 0; i
< slen
; ++i
)
3010 /* Null terminator. */
3015 /* Return the size of a location descriptor. */
3017 static unsigned long
3018 size_of_loc_descr (loc
)
3019 register dw_loc_descr_ref loc
;
3021 register unsigned long size
= 1;
3023 switch (loc
->dw_loc_opc
)
3045 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
3048 size
+= size_of_sleb128 (loc
->dw_loc_oprnd1
.v
.val_int
);
3053 case DW_OP_plus_uconst
:
3054 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
3092 size
+= size_of_sleb128 (loc
->dw_loc_oprnd1
.v
.val_int
);
3095 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
3098 size
+= size_of_sleb128 (loc
->dw_loc_oprnd1
.v
.val_int
);
3101 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
3102 size
+= size_of_sleb128 (loc
->dw_loc_oprnd2
.v
.val_int
);
3105 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
3107 case DW_OP_deref_size
:
3108 case DW_OP_xderef_size
:
3118 /* Return the size of a series of location descriptors. */
3120 static unsigned long
3122 register dw_loc_descr_ref loc
;
3124 register unsigned long size
= 0;
3126 for (; loc
!= NULL
; loc
= loc
->dw_loc_next
)
3127 size
+= size_of_loc_descr (loc
);
3132 /* Return the power-of-two number of bytes necessary to represent VALUE. */
3135 constant_size (value
)
3136 long unsigned value
;
3143 log
= floor_log2 (value
);
3146 log
= 1 << (floor_log2 (log
) + 1);
3148 return MIN (log
, 4);
3151 /* Return the size of a DIE, as it is represented in the
3152 .debug_info section. */
3154 static unsigned long
3156 register dw_die_ref die
;
3158 register unsigned long size
= 0;
3159 register dw_attr_ref a
;
3161 size
+= size_of_uleb128 (die
->die_abbrev
);
3162 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
3164 switch (a
->dw_attr_val
.val_class
)
3166 case dw_val_class_addr
:
3169 case dw_val_class_loc
:
3171 register unsigned long lsize
3172 = size_of_locs (a
->dw_attr_val
.v
.val_loc
);
3175 size
+= constant_size (lsize
);
3179 case dw_val_class_const
:
3182 case dw_val_class_unsigned_const
:
3183 size
+= constant_size (a
->dw_attr_val
.v
.val_unsigned
);
3185 case dw_val_class_long_long
:
3186 size
+= 1 + 8; /* block */
3188 case dw_val_class_float
:
3189 size
+= 1 + a
->dw_attr_val
.v
.val_float
.length
* 4; /* block */
3191 case dw_val_class_flag
:
3194 case dw_val_class_die_ref
:
3195 size
+= DWARF_OFFSET_SIZE
;
3197 case dw_val_class_fde_ref
:
3198 size
+= DWARF_OFFSET_SIZE
;
3200 case dw_val_class_lbl_id
:
3203 case dw_val_class_section_offset
:
3204 size
+= DWARF_OFFSET_SIZE
;
3206 case dw_val_class_str
:
3207 size
+= size_of_string (a
->dw_attr_val
.v
.val_str
);
3217 /* Size the debgging information associted with a given DIE.
3218 Visits the DIE's children recursively. Updates the global
3219 variable next_die_offset, on each time through. Uses the
3220 current value of next_die_offset to updete the die_offset
3221 field in each DIE. */
3224 calc_die_sizes (die
)
3227 register dw_die_ref c
;
3228 die
->die_offset
= next_die_offset
;
3229 next_die_offset
+= size_of_die (die
);
3231 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
3234 if (die
->die_child
!= NULL
)
3235 /* Count the null byte used to terminate sibling lists. */
3236 next_die_offset
+= 1;
3239 /* Return the size of the line information prolog generated for the
3240 compilation unit. */
3242 static unsigned long
3243 size_of_line_prolog ()
3245 register unsigned long size
;
3246 register unsigned long ft_index
;
3248 size
= DWARF_LINE_PROLOG_HEADER_SIZE
;
3250 /* Count the size of the table giving number of args for each
3252 size
+= DWARF_LINE_OPCODE_BASE
- 1;
3254 /* Include directory table is empty (at present). Count only the
3255 the null byte used to terminate the table. */
3258 for (ft_index
= 1; ft_index
< file_table_in_use
; ++ft_index
)
3260 /* File name entry. */
3261 size
+= size_of_string (file_table
[ft_index
]);
3263 /* Include directory index. */
3264 size
+= size_of_uleb128 (0);
3266 /* Modification time. */
3267 size
+= size_of_uleb128 (0);
3269 /* File length in bytes. */
3270 size
+= size_of_uleb128 (0);
3273 /* Count the file table terminator. */
3278 /* Return the size of the line information generated for this
3279 compilation unit. */
3281 static unsigned long
3282 size_of_line_info ()
3284 register unsigned long size
;
3285 register unsigned long lt_index
;
3286 register unsigned long current_line
;
3287 register long line_offset
;
3288 register long line_delta
;
3289 register unsigned long current_file
;
3290 register unsigned long function
;
3292 /* Version number. */
3295 /* Prolog length specifier. */
3296 size
+= DWARF_OFFSET_SIZE
;
3299 size
+= size_of_line_prolog ();
3301 /* Set address register instruction. */
3302 size
+= 1 + size_of_uleb128 (1 + PTR_SIZE
) + 1 + PTR_SIZE
;
3306 for (lt_index
= 1; lt_index
< line_info_table_in_use
; ++lt_index
)
3308 register dw_line_info_ref line_info
;
3310 /* Advance pc instruction. */
3312 line_info
= &line_info_table
[lt_index
];
3313 if (line_info
->dw_file_num
!= current_file
)
3315 /* Set file number instruction. */
3317 current_file
= line_info
->dw_file_num
;
3318 size
+= size_of_uleb128 (current_file
);
3321 if (line_info
->dw_line_num
!= current_line
)
3323 line_offset
= line_info
->dw_line_num
- current_line
;
3324 line_delta
= line_offset
- DWARF_LINE_BASE
;
3325 current_line
= line_info
->dw_line_num
;
3326 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
3327 /* 1-byte special line number instruction. */
3331 /* Advance line instruction. */
3333 size
+= size_of_sleb128 (line_offset
);
3334 /* Generate line entry instruction. */
3340 /* Advance pc instruction. */
3343 /* End of line number info. marker. */
3344 size
+= 1 + size_of_uleb128 (1) + 1;
3349 for (lt_index
= 0; lt_index
< separate_line_info_table_in_use
; )
3351 register dw_separate_line_info_ref line_info
3352 = &separate_line_info_table
[lt_index
];
3353 if (function
!= line_info
->function
)
3355 function
= line_info
->function
;
3356 /* Set address register instruction. */
3357 size
+= 1 + size_of_uleb128 (1 + PTR_SIZE
) + 1 + PTR_SIZE
;
3360 /* Advance pc instruction. */
3363 if (line_info
->dw_file_num
!= current_file
)
3365 /* Set file number instruction. */
3367 current_file
= line_info
->dw_file_num
;
3368 size
+= size_of_uleb128 (current_file
);
3371 if (line_info
->dw_line_num
!= current_line
)
3373 line_offset
= line_info
->dw_line_num
- current_line
;
3374 line_delta
= line_offset
- DWARF_LINE_BASE
;
3375 current_line
= line_info
->dw_line_num
;
3376 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
3377 /* 1-byte special line number instruction. */
3381 /* Advance line instruction. */
3383 size
+= size_of_sleb128 (line_offset
);
3385 /* Generate line entry instruction. */
3392 /* If we're done with a function, end its sequence. */
3393 if (lt_index
== separate_line_info_table_in_use
3394 || separate_line_info_table
[lt_index
].function
!= function
)
3399 /* Advance pc instruction. */
3402 /* End of line number info. marker. */
3403 size
+= 1 + size_of_uleb128 (1) + 1;
3410 /* Return the size of the .debug_pubnames table generated for the
3411 compilation unit. */
3413 static unsigned long
3416 register unsigned long size
;
3417 register unsigned i
;
3419 size
= DWARF_PUBNAMES_HEADER_SIZE
;
3420 for (i
= 0; i
< pubname_table_in_use
; ++i
)
3422 register pubname_ref p
= &pubname_table
[i
];
3423 size
+= DWARF_OFFSET_SIZE
+ size_of_string (p
->name
);
3426 size
+= DWARF_OFFSET_SIZE
;
3430 /* Return the size of the information in the .debug_aranges seciton. */
3432 static unsigned long
3435 register unsigned long size
;
3437 size
= DWARF_ARANGES_HEADER_SIZE
;
3439 /* Count the address/length pair for this compilation unit. */
3440 size
+= 2 * PTR_SIZE
;
3441 size
+= 2 * PTR_SIZE
* arange_table_in_use
;
3443 /* Count the two zero words used to terminated the address range table. */
3444 size
+= 2 * PTR_SIZE
;
3448 /* Output an unsigned LEB128 quantity. */
3451 output_uleb128 (value
)
3452 register unsigned long value
;
3454 unsigned long save_value
= value
;
3456 fprintf (asm_out_file
, "\t%s\t", ASM_BYTE_OP
);
3459 register unsigned byte
= (value
& 0x7f);
3462 /* More bytes to follow. */
3465 fprintf (asm_out_file
, "0x%x", byte
);
3467 fprintf (asm_out_file
, ",");
3471 if (flag_verbose_asm
)
3472 fprintf (asm_out_file
, "\t%s ULEB128 0x%x", ASM_COMMENT_START
, save_value
);
3475 /* Output an signed LEB128 quantity. */
3478 output_sleb128 (value
)
3479 register long value
;
3482 register unsigned byte
;
3483 long save_value
= value
;
3485 fprintf (asm_out_file
, "\t%s\t", ASM_BYTE_OP
);
3488 byte
= (value
& 0x7f);
3489 /* arithmetic shift */
3491 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
3492 || ((value
== -1) && ((byte
& 0x40) != 0))));
3496 fprintf (asm_out_file
, "0x%x", byte
);
3498 fprintf (asm_out_file
, ",");
3502 if (flag_verbose_asm
)
3503 fprintf (asm_out_file
, "\t%s SLEB128 %d", ASM_COMMENT_START
, save_value
);
3506 /* Select the encoding of an attribute value. */
3508 static enum dwarf_form
3512 switch (v
->val_class
)
3514 case dw_val_class_addr
:
3515 return DW_FORM_addr
;
3516 case dw_val_class_loc
:
3517 switch (constant_size (size_of_locs (v
->v
.val_loc
)))
3520 return DW_FORM_block1
;
3522 return DW_FORM_block2
;
3526 case dw_val_class_const
:
3527 return DW_FORM_data4
;
3528 case dw_val_class_unsigned_const
:
3529 switch (constant_size (v
->v
.val_unsigned
))
3532 return DW_FORM_data1
;
3534 return DW_FORM_data2
;
3536 return DW_FORM_data4
;
3538 return DW_FORM_data8
;
3542 case dw_val_class_long_long
:
3543 return DW_FORM_block1
;
3544 case dw_val_class_float
:
3545 return DW_FORM_block1
;
3546 case dw_val_class_flag
:
3547 return DW_FORM_flag
;
3548 case dw_val_class_die_ref
:
3550 case dw_val_class_fde_ref
:
3551 return DW_FORM_data
;
3552 case dw_val_class_lbl_id
:
3553 return DW_FORM_addr
;
3554 case dw_val_class_section_offset
:
3555 return DW_FORM_data
;
3556 case dw_val_class_str
:
3557 return DW_FORM_string
;
3563 /* Output the encoding of an attribute value. */
3566 output_value_format (v
)
3569 enum dwarf_form form
= value_format (v
);
3571 output_uleb128 (form
);
3572 if (flag_verbose_asm
)
3573 fprintf (asm_out_file
, " (%s)", dwarf_form_name (form
));
3575 fputc ('\n', asm_out_file
);
3578 /* Output the .debug_abbrev section which defines the DIE abbreviation
3582 output_abbrev_section ()
3584 unsigned long abbrev_id
;
3587 for (abbrev_id
= 1; abbrev_id
< abbrev_die_table_in_use
; ++abbrev_id
)
3589 register dw_die_ref abbrev
= abbrev_die_table
[abbrev_id
];
3591 output_uleb128 (abbrev_id
);
3592 if (flag_verbose_asm
)
3593 fprintf (asm_out_file
, " (abbrev code)");
3595 fputc ('\n', asm_out_file
);
3596 output_uleb128 (abbrev
->die_tag
);
3597 if (flag_verbose_asm
)
3598 fprintf (asm_out_file
, " (TAG: %s)",
3599 dwarf_tag_name (abbrev
->die_tag
));
3601 fputc ('\n', asm_out_file
);
3602 fprintf (asm_out_file
, "\t%s\t0x%x", ASM_BYTE_OP
,
3603 abbrev
->die_child
!= NULL
? DW_children_yes
: DW_children_no
);
3605 if (flag_verbose_asm
)
3606 fprintf (asm_out_file
, "\t%s %s",
3608 (abbrev
->die_child
!= NULL
3609 ? "DW_children_yes" : "DW_children_no"));
3611 fputc ('\n', asm_out_file
);
3613 for (a_attr
= abbrev
->die_attr
; a_attr
!= NULL
;
3614 a_attr
= a_attr
->dw_attr_next
)
3616 output_uleb128 (a_attr
->dw_attr
);
3617 if (flag_verbose_asm
)
3618 fprintf (asm_out_file
, " (%s)",
3619 dwarf_attr_name (a_attr
->dw_attr
));
3621 fputc ('\n', asm_out_file
);
3622 output_value_format (&a_attr
->dw_attr_val
);
3625 fprintf (asm_out_file
, "\t%s\t0,0\n", ASM_BYTE_OP
);
3629 /* Output location description stack opcode's operands (if any). */
3632 output_loc_operands (loc
)
3633 register dw_loc_descr_ref loc
;
3635 register dw_val_ref val1
= &loc
->dw_loc_oprnd1
;
3636 register dw_val_ref val2
= &loc
->dw_loc_oprnd2
;
3638 switch (loc
->dw_loc_opc
)
3641 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file
, val1
->v
.val_addr
);
3642 fputc ('\n', asm_out_file
);
3646 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, val1
->v
.val_flag
);
3647 fputc ('\n', asm_out_file
);
3651 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, val1
->v
.val_int
);
3652 fputc ('\n', asm_out_file
);
3656 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, val1
->v
.val_int
);
3657 fputc ('\n', asm_out_file
);
3662 fputc ('\n', asm_out_file
);
3665 output_uleb128 (val1
->v
.val_unsigned
);
3666 fputc ('\n', asm_out_file
);
3669 output_sleb128 (val1
->v
.val_int
);
3670 fputc ('\n', asm_out_file
);
3673 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, val1
->v
.val_int
);
3674 fputc ('\n', asm_out_file
);
3676 case DW_OP_plus_uconst
:
3677 output_uleb128 (val1
->v
.val_unsigned
);
3678 fputc ('\n', asm_out_file
);
3682 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, val1
->v
.val_int
);
3683 fputc ('\n', asm_out_file
);
3717 output_sleb128 (val1
->v
.val_int
);
3718 fputc ('\n', asm_out_file
);
3721 output_uleb128 (val1
->v
.val_unsigned
);
3722 fputc ('\n', asm_out_file
);
3725 output_sleb128 (val1
->v
.val_int
);
3726 fputc ('\n', asm_out_file
);
3729 output_uleb128 (val1
->v
.val_unsigned
);
3730 fputc ('\n', asm_out_file
);
3731 output_sleb128 (val2
->v
.val_int
);
3732 fputc ('\n', asm_out_file
);
3735 output_uleb128 (val1
->v
.val_unsigned
);
3736 fputc ('\n', asm_out_file
);
3738 case DW_OP_deref_size
:
3739 case DW_OP_xderef_size
:
3740 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, val1
->v
.val_flag
);
3741 fputc ('\n', asm_out_file
);
3748 /* Compute the offset of a sibling. */
3750 static unsigned long
3751 sibling_offset (die
)
3754 unsigned long offset
;
3756 if (die
->die_child_last
== NULL
)
3757 offset
= die
->die_offset
+ size_of_die (die
);
3759 offset
= sibling_offset (die
->die_child_last
) + 1;
3764 /* Output the DIE and its attributes. Called recursively to generate
3765 the definitions of each child DIE. */
3769 register dw_die_ref die
;
3771 register dw_attr_ref a
;
3772 register dw_die_ref c
;
3773 register unsigned long ref_offset
;
3774 register unsigned long size
;
3775 register dw_loc_descr_ref loc
;
3778 output_uleb128 (die
->die_abbrev
);
3779 if (flag_verbose_asm
)
3780 fprintf (asm_out_file
, " (DIE (0x%x) %s)",
3781 die
->die_offset
, dwarf_tag_name (die
->die_tag
));
3783 fputc ('\n', asm_out_file
);
3785 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
3787 switch (a
->dw_attr_val
.val_class
)
3789 case dw_val_class_addr
:
3790 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file
,
3791 a
->dw_attr_val
.v
.val_addr
);
3794 case dw_val_class_loc
:
3795 size
= size_of_locs (a
->dw_attr_val
.v
.val_loc
);
3797 /* Output the block length for this list of location operations. */
3798 switch (constant_size (size
))
3801 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, size
);
3804 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, size
);
3810 if (flag_verbose_asm
)
3811 fprintf (asm_out_file
, "\t%s %s",
3812 ASM_COMMENT_START
, dwarf_attr_name (a
->dw_attr
));
3814 fputc ('\n', asm_out_file
);
3815 for (loc
= a
->dw_attr_val
.v
.val_loc
; loc
!= NULL
;
3816 loc
= loc
->dw_loc_next
)
3818 /* Output the opcode. */
3819 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, loc
->dw_loc_opc
);
3820 if (flag_verbose_asm
)
3821 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
,
3822 dwarf_stack_op_name (loc
->dw_loc_opc
));
3824 fputc ('\n', asm_out_file
);
3826 /* Output the operand(s) (if any). */
3827 output_loc_operands (loc
);
3831 case dw_val_class_const
:
3832 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, a
->dw_attr_val
.v
.val_int
);
3835 case dw_val_class_unsigned_const
:
3836 switch (constant_size (a
->dw_attr_val
.v
.val_unsigned
))
3839 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
3840 a
->dw_attr_val
.v
.val_unsigned
);
3843 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
,
3844 a
->dw_attr_val
.v
.val_unsigned
);
3847 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
3848 a
->dw_attr_val
.v
.val_unsigned
);
3855 case dw_val_class_long_long
:
3856 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 8);
3857 if (flag_verbose_asm
)
3858 fprintf (asm_out_file
, "\t%s %s",
3859 ASM_COMMENT_START
, dwarf_attr_name (a
->dw_attr
));
3861 fputc ('\n', asm_out_file
);
3862 ASM_OUTPUT_DWARF_DATA8 (asm_out_file
,
3863 a
->dw_attr_val
.v
.val_long_long
.hi
,
3864 a
->dw_attr_val
.v
.val_long_long
.low
);
3866 if (flag_verbose_asm
)
3867 fprintf (asm_out_file
,
3868 "\t%s long long constant", ASM_COMMENT_START
);
3870 fputc ('\n', asm_out_file
);
3873 case dw_val_class_float
:
3874 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
3875 a
->dw_attr_val
.v
.val_float
.length
* 4);
3876 if (flag_verbose_asm
)
3877 fprintf (asm_out_file
, "\t%s %s",
3878 ASM_COMMENT_START
, dwarf_attr_name (a
->dw_attr
));
3880 fputc ('\n', asm_out_file
);
3881 for (i
= 0; i
< a
->dw_attr_val
.v
.val_float
.length
; ++i
)
3883 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
3884 a
->dw_attr_val
.v
.val_float
.array
[i
]);
3885 if (flag_verbose_asm
)
3886 fprintf (asm_out_file
, "\t%s fp constant word %d",
3887 ASM_COMMENT_START
, i
);
3889 fputc ('\n', asm_out_file
);
3893 case dw_val_class_flag
:
3894 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, a
->dw_attr_val
.v
.val_flag
);
3897 case dw_val_class_die_ref
:
3898 if (a
->dw_attr_val
.v
.val_die_ref
!= NULL
)
3899 ref_offset
= a
->dw_attr_val
.v
.val_die_ref
->die_offset
;
3900 else if (a
->dw_attr
== DW_AT_sibling
)
3901 ref_offset
= sibling_offset(die
);
3905 ASM_OUTPUT_DWARF_DATA (asm_out_file
, ref_offset
);
3908 case dw_val_class_fde_ref
:
3909 ref_offset
= fde_table
[a
->dw_attr_val
.v
.val_fde_index
].dw_fde_offset
;
3910 fprintf (asm_out_file
, "\t%s\t%s+0x%x", UNALIGNED_OFFSET_ASM_OP
,
3911 stripattributes (FRAME_SECTION
), ref_offset
);
3914 case dw_val_class_lbl_id
:
3915 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, a
->dw_attr_val
.v
.val_lbl_id
);
3918 case dw_val_class_section_offset
:
3919 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
,
3921 (a
->dw_attr_val
.v
.val_section
));
3924 case dw_val_class_str
:
3925 ASM_OUTPUT_DWARF_STRING (asm_out_file
, a
->dw_attr_val
.v
.val_str
);
3932 if (a
->dw_attr_val
.val_class
!= dw_val_class_loc
3933 && a
->dw_attr_val
.val_class
!= dw_val_class_long_long
3934 && a
->dw_attr_val
.val_class
!= dw_val_class_float
)
3936 if (flag_verbose_asm
)
3937 fprintf (asm_out_file
, "\t%s %s",
3938 ASM_COMMENT_START
, dwarf_attr_name (a
->dw_attr
));
3940 fputc ('\n', asm_out_file
);
3944 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
3947 if (die
->die_child
!= NULL
)
3949 /* Add null byte to terminate sibling list. */
3950 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
3951 if (flag_verbose_asm
)
3952 fprintf (asm_out_file
, "\t%s end of children of DIE 0x%x",
3953 ASM_COMMENT_START
, die
->die_offset
);
3955 fputc ('\n', asm_out_file
);
3959 /* Output the compilation unit that appears at the beginning of the
3960 .debug_info section, and precedes the DIE descriptions. */
3963 output_compilation_unit_header ()
3965 ASM_OUTPUT_DWARF_DATA (asm_out_file
, next_die_offset
- DWARF_OFFSET_SIZE
);
3966 if (flag_verbose_asm
)
3967 fprintf (asm_out_file
, "\t%s Length of Compilation Unit Info.",
3970 fputc ('\n', asm_out_file
);
3971 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, DWARF_VERSION
);
3972 if (flag_verbose_asm
)
3973 fprintf (asm_out_file
, "\t%s DWARF version number", ASM_COMMENT_START
);
3975 fputc ('\n', asm_out_file
);
3976 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, stripattributes (ABBREV_SECTION
));
3977 if (flag_verbose_asm
)
3978 fprintf (asm_out_file
, "\t%s Offset Into Abbrev. Section",
3981 fputc ('\n', asm_out_file
);
3982 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, PTR_SIZE
);
3983 if (flag_verbose_asm
)
3984 fprintf (asm_out_file
, "\t%s Pointer Size (in bytes)", ASM_COMMENT_START
);
3986 fputc ('\n', asm_out_file
);
3989 /* Generate a new label for the CFI info to refer to. */
3992 dwarf2out_cfi_label ()
3994 static char label
[20];
3995 static unsigned long label_num
= 0;
3997 ASM_GENERATE_INTERNAL_LABEL (label
, "LCFI", label_num
++);
3998 ASM_OUTPUT_LABEL (asm_out_file
, label
);
4003 /* Add CFI to the current fde at the PC value indicated by LABEL if specified,
4004 or to the CIE if LABEL is NULL. */
4007 add_fde_cfi (label
, cfi
)
4008 register char *label
;
4009 register dw_cfi_ref cfi
;
4013 register dw_fde_ref fde
= &fde_table
[fde_table_in_use
- 1];
4016 label
= dwarf2out_cfi_label ();
4018 if (fde
->dw_fde_current_label
== NULL
4019 || strcmp (label
, fde
->dw_fde_current_label
) != 0)
4021 register dw_cfi_ref xcfi
;
4023 fde
->dw_fde_current_label
= label
= xstrdup (label
);
4025 /* Set the location counter to the new label. */
4027 xcfi
->dw_cfi_opc
= DW_CFA_advance_loc4
;
4028 xcfi
->dw_cfi_oprnd1
.dw_cfi_addr
= label
;
4029 add_cfi (&fde
->dw_fde_cfi
, xcfi
);
4032 add_cfi (&fde
->dw_fde_cfi
, cfi
);
4036 add_cfi (&cie_cfi_head
, cfi
);
4039 /* Subroutine of lookup_cfa. */
4042 lookup_cfa_1 (cfi
, regp
, offsetp
)
4043 register dw_cfi_ref cfi
;
4044 register unsigned long *regp
;
4045 register long *offsetp
;
4047 switch (cfi
->dw_cfi_opc
)
4049 case DW_CFA_def_cfa_offset
:
4050 *offsetp
= cfi
->dw_cfi_oprnd1
.dw_cfi_offset
;
4052 case DW_CFA_def_cfa_register
:
4053 *regp
= cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
;
4055 case DW_CFA_def_cfa
:
4056 *regp
= cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
;
4057 *offsetp
= cfi
->dw_cfi_oprnd2
.dw_cfi_offset
;
4062 /* Find the previous value for the CFA. */
4065 lookup_cfa (regp
, offsetp
)
4066 register unsigned long *regp
;
4067 register long *offsetp
;
4069 register dw_cfi_ref cfi
;
4071 *regp
= (unsigned long) -1;
4074 for (cfi
= cie_cfi_head
; cfi
; cfi
= cfi
->dw_cfi_next
)
4075 lookup_cfa_1 (cfi
, regp
, offsetp
);
4077 if (fde_table_in_use
)
4079 register dw_fde_ref fde
= &fde_table
[fde_table_in_use
- 1];
4080 for (cfi
= fde
->dw_fde_cfi
; cfi
; cfi
= cfi
->dw_cfi_next
)
4081 lookup_cfa_1 (cfi
, regp
, offsetp
);
4085 /* Entry point to update the canonical frame address (CFA).
4086 LABEL is passed to add_fde_cfi. The value of CFA is now to be
4087 calculated from REG+OFFSET. */
4090 dwarf2out_def_cfa (label
, reg
, offset
)
4091 register char *label
;
4092 register unsigned reg
;
4093 register long offset
;
4095 register dw_cfi_ref cfi
;
4096 unsigned long old_reg
;
4099 reg
= DWARF_FRAME_REGNUM (reg
);
4100 lookup_cfa (&old_reg
, &old_offset
);
4102 if (reg
== old_reg
&& offset
== old_offset
)
4109 cfi
->dw_cfi_opc
= DW_CFA_def_cfa_offset
;
4110 cfi
->dw_cfi_oprnd1
.dw_cfi_offset
= offset
;
4113 #ifndef MIPS_DEBUGGING_INFO /* SGI dbx thinks this means no offset. */
4114 else if (offset
== old_offset
&& old_reg
!= (unsigned long) -1)
4116 cfi
->dw_cfi_opc
= DW_CFA_def_cfa_register
;
4117 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= reg
;
4123 cfi
->dw_cfi_opc
= DW_CFA_def_cfa
;
4124 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= reg
;
4125 cfi
->dw_cfi_oprnd2
.dw_cfi_offset
= offset
;
4128 add_fde_cfi (label
, cfi
);
4131 /* Add the CFI for saving a register. REG is the CFA column number.
4132 LABEL is passed to add_fde_cfi.
4133 If SREG is -1, the register is saved at OFFSET from the CFA;
4134 otherwise it is saved in SREG. */
4137 reg_save (label
, reg
, sreg
, offset
)
4138 register char * label
;
4139 register unsigned reg
;
4140 register unsigned sreg
;
4141 register long offset
;
4143 register dw_cfi_ref cfi
= new_cfi ();
4145 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= reg
;
4150 /* The register number won't fit in 6 bits, so we have to use
4152 cfi
->dw_cfi_opc
= DW_CFA_offset_extended
;
4154 cfi
->dw_cfi_opc
= DW_CFA_offset
;
4156 offset
/= DWARF_CIE_DATA_ALIGNMENT
;
4157 assert (offset
>= 0);
4158 cfi
->dw_cfi_oprnd2
.dw_cfi_offset
= offset
;
4162 cfi
->dw_cfi_opc
= DW_CFA_register
;
4163 cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
= sreg
;
4166 add_fde_cfi (label
, cfi
);
4169 /* Entry point for saving a register. REG is the GCC register number.
4170 LABEL and OFFSET are passed to reg_save. */
4173 dwarf2out_reg_save (label
, reg
, offset
)
4174 register char * label
;
4175 register unsigned reg
;
4176 register long offset
;
4178 reg_save (label
, DWARF_FRAME_REGNUM (reg
), -1, offset
);
4181 /* Record the initial position of the return address. RTL is
4182 INCOMING_RETURN_ADDR_RTX. */
4185 initial_return_save (rtl
)
4191 switch (GET_CODE (rtl
))
4194 /* RA is in a register. */
4195 reg
= reg_number (rtl
);
4198 /* RA is on the stack. */
4199 rtl
= XEXP (rtl
, 0);
4200 switch (GET_CODE (rtl
))
4203 assert (REGNO (rtl
) == STACK_POINTER_REGNUM
);
4207 assert (REGNO (XEXP (rtl
, 0)) == STACK_POINTER_REGNUM
);
4208 offset
= INTVAL (XEXP (rtl
, 1));
4211 assert (REGNO (XEXP (rtl
, 0)) == STACK_POINTER_REGNUM
);
4212 offset
= -INTVAL (XEXP (rtl
, 1));
4222 reg_save (NULL
, DWARF_FRAME_RETURN_COLUMN
, reg
, offset
);
4225 /* Record call frame debugging information for INSN, which either
4226 sets SP or FP (adjusting how we calculate the frame address) or saves a
4227 register to the stack. If INSN is NULL_RTX, initialize our state. */
4230 dwarf2out_frame_debug (insn
)
4237 /* The current rule for calculating the DWARF2 canonical frame address. */
4238 static unsigned cfa_reg
;
4239 static long cfa_offset
;
4241 /* The register used for saving registers to the stack, and its offset
4243 static unsigned cfa_store_reg
;
4244 static long cfa_store_offset
;
4246 /* A temporary register used in adjusting SP or setting up the store_reg. */
4247 static unsigned cfa_temp_reg
;
4248 static long cfa_temp_value
;
4250 if (insn
== NULL_RTX
)
4252 /* Set up state for generating call frame debug info. */
4253 cfa_reg
= STACK_POINTER_REGNUM
;
4255 cfa_store_reg
= STACK_POINTER_REGNUM
;
4256 cfa_store_offset
= 0;
4262 label
= dwarf2out_cfi_label ();
4264 insn
= PATTERN (insn
);
4265 assert (GET_CODE (insn
) == SET
);
4267 src
= SET_SRC (insn
);
4268 dest
= SET_DEST (insn
);
4270 switch (GET_CODE (dest
))
4273 /* Update the CFA rule wrt SP or FP. Make sure src is
4274 relative to the current CFA register. */
4275 switch (GET_CODE (src
))
4277 /* Setting FP from SP. */
4279 assert (cfa_reg
== REGNO (src
));
4280 assert (REGNO (dest
) == STACK_POINTER_REGNUM
4281 || (frame_pointer_needed
4282 && REGNO (dest
) == HARD_FRAME_POINTER_REGNUM
));
4283 cfa_reg
= REGNO (dest
);
4288 if (dest
== stack_pointer_rtx
)
4291 switch (GET_CODE (XEXP (src
, 1)))
4294 offset
= INTVAL (XEXP (src
, 1));
4297 assert (REGNO (XEXP (src
, 1)) == cfa_temp_reg
);
4298 offset
= cfa_temp_value
;
4304 if (GET_CODE (src
) == PLUS
)
4306 if (cfa_reg
== STACK_POINTER_REGNUM
)
4307 cfa_offset
+= offset
;
4308 if (cfa_store_reg
== STACK_POINTER_REGNUM
)
4309 cfa_store_offset
+= offset
;
4310 assert (XEXP (src
, 0) == stack_pointer_rtx
);
4314 /* Initializing the store base register. */
4315 assert (GET_CODE (src
) == PLUS
);
4316 assert (XEXP (src
, 1) == stack_pointer_rtx
);
4317 assert (GET_CODE (XEXP (src
, 0)) == REG
4318 && REGNO (XEXP (src
, 0)) == cfa_temp_reg
);
4319 assert (cfa_store_reg
== STACK_POINTER_REGNUM
);
4320 cfa_store_reg
= REGNO (dest
);
4321 cfa_store_offset
-= cfa_temp_value
;
4326 cfa_temp_reg
= REGNO (dest
);
4327 cfa_temp_value
= INTVAL (src
);
4333 dwarf2out_def_cfa (label
, cfa_reg
, cfa_offset
);
4337 /* Saving a register to the stack. Make sure dest is relative to the
4339 assert (GET_CODE (src
) == REG
);
4340 switch (GET_CODE (XEXP (dest
, 0)))
4345 offset
= GET_MODE_SIZE (GET_MODE (dest
));
4346 if (GET_CODE (src
) == PRE_INC
)
4349 assert (REGNO (XEXP (XEXP (dest
, 0), 0)) == STACK_POINTER_REGNUM
);
4350 assert (cfa_store_reg
== STACK_POINTER_REGNUM
);
4351 cfa_store_offset
+= offset
;
4352 if (cfa_reg
== STACK_POINTER_REGNUM
)
4353 cfa_offset
= cfa_store_offset
;
4355 offset
= -cfa_store_offset
;
4358 /* With an offset. */
4361 offset
= INTVAL (XEXP (XEXP (dest
, 0), 1));
4362 if (GET_CODE (src
) == MINUS
)
4365 assert (cfa_store_reg
== REGNO (XEXP (XEXP (dest
, 0), 0)));
4366 offset
-= cfa_store_offset
;
4372 dwarf2out_def_cfa (label
, cfa_reg
, cfa_offset
);
4373 dwarf2out_reg_save (label
, REGNO (src
), offset
);
4381 /* Return the size of a Call Frame Instruction. */
4383 static unsigned long
4387 register unsigned long size
;
4389 /* Count the 1-byte opcode */
4391 switch (cfi
->dw_cfi_opc
)
4394 size
+= size_of_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_offset
);
4396 case DW_CFA_set_loc
:
4399 case DW_CFA_advance_loc1
:
4402 case DW_CFA_advance_loc2
:
4405 case DW_CFA_advance_loc4
:
4408 #ifdef MIPS_DEBUGGING_INFO
4409 case DW_CFA_MIPS_advance_loc8
:
4413 case DW_CFA_offset_extended
:
4414 case DW_CFA_def_cfa
:
4415 size
+= size_of_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
4416 size
+= size_of_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_offset
);
4418 case DW_CFA_restore_extended
:
4419 case DW_CFA_undefined
:
4420 size
+= size_of_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
4422 case DW_CFA_same_value
:
4423 case DW_CFA_def_cfa_register
:
4424 size
+= size_of_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
4426 case DW_CFA_register
:
4427 size
+= size_of_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
4428 size
+= size_of_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
);
4430 case DW_CFA_def_cfa_offset
:
4431 size
+= size_of_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_offset
);
4440 /* Return the size of an FDE sans the length word. */
4442 static inline unsigned long
4443 size_of_fde (fde
, npad
)
4445 unsigned long *npad
;
4447 register dw_cfi_ref cfi
;
4448 register unsigned long aligned_size
;
4449 register unsigned long size
;
4451 size
= DWARF_FDE_HEADER_SIZE
;
4452 for (cfi
= fde
->dw_fde_cfi
; cfi
!= NULL
; cfi
= cfi
->dw_cfi_next
)
4453 size
+= size_of_cfi(cfi
);
4455 /* Round the size up to a word boundary. */
4456 aligned_size
= DWARF_ROUND (size
, PTR_SIZE
);
4457 *npad
= aligned_size
- size
;
4458 return aligned_size
;
4461 /* Calculate the size of the FDE table, and establish the offset
4462 of each FDE in the .debug_frame section. */
4467 register unsigned long i
;
4468 register dw_fde_ref fde
;
4469 register unsigned long fde_size
;
4470 register dw_cfi_ref cfi
;
4471 unsigned long fde_pad
;
4473 cie_size
= DWARF_CIE_HEADER_SIZE
;
4474 for (cfi
= cie_cfi_head
; cfi
!= NULL
; cfi
= cfi
->dw_cfi_next
)
4475 cie_size
+= size_of_cfi (cfi
);
4477 /* Initialize the beginning FDE offset. */
4478 next_fde_offset
= DWARF_ROUND (cie_size
, PTR_SIZE
);
4480 for (i
= 0; i
< fde_table_in_use
; ++i
)
4482 fde
= &fde_table
[i
];
4483 fde
->dw_fde_offset
= next_fde_offset
;
4484 fde_size
= size_of_fde (fde
, &fde_pad
);
4485 next_fde_offset
+= fde_size
;
4489 /* Output a Call Frame Information opcode and its operand(s). */
4492 output_cfi (cfi
, fde
)
4493 register dw_cfi_ref cfi
;
4494 register dw_fde_ref fde
;
4496 if (cfi
->dw_cfi_opc
== DW_CFA_advance_loc
)
4498 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
4500 | (cfi
->dw_cfi_oprnd1
.dw_cfi_offset
& 0x3f));
4501 if (flag_verbose_asm
)
4502 fprintf (asm_out_file
, "\t%s DW_CFA_advance_loc 0x%x",
4503 ASM_COMMENT_START
, cfi
->dw_cfi_oprnd1
.dw_cfi_offset
);
4504 fputc ('\n', asm_out_file
);
4507 else if (cfi
->dw_cfi_opc
== DW_CFA_offset
)
4509 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
4511 | (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
& 0x3f));
4512 if (flag_verbose_asm
)
4513 fprintf (asm_out_file
, "\t%s DW_CFA_offset, column 0x%x",
4514 ASM_COMMENT_START
, cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
4516 fputc ('\n', asm_out_file
);
4517 output_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_offset
);
4518 fputc ('\n', asm_out_file
);
4520 else if (cfi
->dw_cfi_opc
== DW_CFA_restore
)
4522 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
4524 | (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
& 0x3f));
4525 if (flag_verbose_asm
)
4526 fprintf (asm_out_file
, "\t%s DW_CFA_restore, column 0x%x",
4527 ASM_COMMENT_START
, cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
4529 fputc ('\n', asm_out_file
);
4533 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, cfi
->dw_cfi_opc
);
4534 if (flag_verbose_asm
)
4535 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
,
4536 dwarf_cfi_name (cfi
->dw_cfi_opc
));
4538 fputc ('\n', asm_out_file
);
4539 switch (cfi
->dw_cfi_opc
)
4541 case DW_CFA_set_loc
:
4542 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, cfi
->dw_cfi_oprnd1
.dw_cfi_addr
);
4543 fputc ('\n', asm_out_file
);
4545 case DW_CFA_advance_loc1
:
4546 /* TODO: not currently implemented. */
4549 case DW_CFA_advance_loc2
:
4550 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
,
4551 cfi
->dw_cfi_oprnd1
.dw_cfi_addr
,
4552 fde
->dw_fde_current_label
);
4553 fputc ('\n', asm_out_file
);
4554 fde
->dw_fde_current_label
= cfi
->dw_cfi_oprnd1
.dw_cfi_addr
;
4556 case DW_CFA_advance_loc4
:
4557 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
,
4558 cfi
->dw_cfi_oprnd1
.dw_cfi_addr
,
4559 fde
->dw_fde_current_label
);
4560 fputc ('\n', asm_out_file
);
4561 fde
->dw_fde_current_label
= cfi
->dw_cfi_oprnd1
.dw_cfi_addr
;
4563 #ifdef MIPS_DEBUGGING_INFO
4564 case DW_CFA_MIPS_advance_loc8
:
4565 /* TODO: not currently implemented. */
4569 case DW_CFA_offset_extended
:
4570 case DW_CFA_def_cfa
:
4571 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
4572 fputc ('\n', asm_out_file
);
4573 output_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_offset
);
4574 fputc ('\n', asm_out_file
);
4576 case DW_CFA_restore_extended
:
4577 case DW_CFA_undefined
:
4578 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
4579 fputc ('\n', asm_out_file
);
4581 case DW_CFA_same_value
:
4582 case DW_CFA_def_cfa_register
:
4583 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
4584 fputc ('\n', asm_out_file
);
4586 case DW_CFA_register
:
4587 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
4588 fputc ('\n', asm_out_file
);
4589 output_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
);
4590 fputc ('\n', asm_out_file
);
4592 case DW_CFA_def_cfa_offset
:
4593 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_offset
);
4594 fputc ('\n', asm_out_file
);
4602 /* Output the call frame information used to used to record information
4603 that relates to calculating the frame pointer, and records the
4604 location of saved registers. */
4607 output_call_frame_info ()
4609 register unsigned long i
, j
;
4610 register dw_fde_ref fde
;
4611 register unsigned long fde_size
;
4612 register dw_cfi_ref cfi
;
4613 unsigned long fde_pad
;
4615 /* Only output the info if it will be interesting. */
4616 for (i
= 0; i
< fde_table_in_use
; ++i
)
4617 if (fde_table
[i
].dw_fde_cfi
!= NULL
)
4619 if (i
== fde_table_in_use
)
4622 /* (re-)initialize the beginning FDE offset. */
4623 next_fde_offset
= DWARF_ROUND (cie_size
, PTR_SIZE
);
4625 fputc ('\n', asm_out_file
);
4626 ASM_OUTPUT_SECTION (asm_out_file
, FRAME_SECTION
);
4628 /* Output the CIE. */
4629 ASM_OUTPUT_DWARF_DATA (asm_out_file
, next_fde_offset
- DWARF_OFFSET_SIZE
);
4630 if (flag_verbose_asm
)
4631 fprintf (asm_out_file
, "\t%s Length of Common Information Entry",
4634 fputc ('\n', asm_out_file
);
4635 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, DW_CIE_ID
);
4636 if (flag_verbose_asm
)
4637 fprintf (asm_out_file
, "\t%s CIE Identifier Tag", ASM_COMMENT_START
);
4639 fputc ('\n', asm_out_file
);
4640 if (DWARF_OFFSET_SIZE
== 8)
4642 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, DW_CIE_ID
);
4643 fputc ('\n', asm_out_file
);
4646 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_CIE_VERSION
);
4647 if (flag_verbose_asm
)
4648 fprintf (asm_out_file
, "\t%s CIE Version", ASM_COMMENT_START
);
4650 fputc ('\n', asm_out_file
);
4651 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
4652 if (flag_verbose_asm
)
4653 fprintf (asm_out_file
, "\t%s CIE Augmentation (none)", ASM_COMMENT_START
);
4655 fputc ('\n', asm_out_file
);
4657 if (flag_verbose_asm
)
4658 fprintf (asm_out_file
, " (CIE Code Alignment Factor)");
4660 fputc ('\n', asm_out_file
);
4661 output_sleb128 (DWARF_CIE_DATA_ALIGNMENT
);
4662 if (flag_verbose_asm
)
4663 fprintf (asm_out_file
, " (CIE Data Alignment Factor)");
4665 fputc ('\n', asm_out_file
);
4666 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DWARF_FRAME_RETURN_COLUMN
);
4667 if (flag_verbose_asm
)
4668 fprintf (asm_out_file
, "\t%s CIE RA Column", ASM_COMMENT_START
);
4670 fputc ('\n', asm_out_file
);
4672 for (cfi
= cie_cfi_head
; cfi
!= NULL
; cfi
= cfi
->dw_cfi_next
)
4673 output_cfi (cfi
, NULL
);
4675 /* Pad the CIE out to an address sized boundary. */
4676 for (i
= next_fde_offset
- cie_size
; i
; --i
)
4678 /* Pad out to a pointer size boundary */
4679 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_CFA_nop
);
4680 if (flag_verbose_asm
)
4681 fprintf (asm_out_file
, "\t%s CIE DW_CFA_nop (pad)", ASM_COMMENT_START
);
4683 fputc ('\n', asm_out_file
);
4686 /* Loop through all of the FDE's. */
4687 for (i
= 0; i
< fde_table_in_use
; ++i
)
4689 fde
= &fde_table
[i
];
4690 if (fde
->dw_fde_cfi
== NULL
)
4693 fde_size
= size_of_fde (fde
, &fde_pad
);
4694 ASM_OUTPUT_DWARF_DATA (asm_out_file
, fde_size
- DWARF_OFFSET_SIZE
);
4695 if (flag_verbose_asm
)
4696 fprintf (asm_out_file
, "\t%s FDE Length", ASM_COMMENT_START
);
4698 fputc ('\n', asm_out_file
);
4699 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, stripattributes (FRAME_SECTION
));
4700 if (flag_verbose_asm
)
4701 fprintf (asm_out_file
, "\t%s FDE CIE offset", ASM_COMMENT_START
);
4703 fputc ('\n', asm_out_file
);
4704 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, fde
->dw_fde_begin
);
4705 if (flag_verbose_asm
)
4706 fprintf (asm_out_file
, "\t%s FDE initial location", ASM_COMMENT_START
);
4708 fputc ('\n', asm_out_file
);
4709 ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file
,
4710 fde
->dw_fde_end
, fde
->dw_fde_begin
);
4711 if (flag_verbose_asm
)
4712 fprintf (asm_out_file
, "\t%s FDE address range", ASM_COMMENT_START
);
4714 fputc ('\n', asm_out_file
);
4716 /* Loop through the Call Frame Instructions associated with
4718 fde
->dw_fde_current_label
= fde
->dw_fde_begin
;
4719 for (cfi
= fde
->dw_fde_cfi
; cfi
!= NULL
; cfi
= cfi
->dw_cfi_next
)
4720 output_cfi (cfi
, fde
);
4722 /* Pad to a double word boundary. */
4723 for (j
= 0; j
< fde_pad
; ++j
)
4725 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_CFA_nop
);
4726 if (flag_verbose_asm
)
4727 fprintf (asm_out_file
, "\t%s CIE DW_CFA_nop (pad)",
4730 fputc ('\n', asm_out_file
);
4735 /* The DWARF2 pubname for a nested thingy looks like "A::f". The output
4736 of decl_printable_name for C++ looks like "A::f(int)". Let's drop the
4737 argument list, and maybe the scope. */
4740 dwarf2_name (decl
, scope
)
4744 return (*decl_printable_name
) (decl
, scope
? 1 : 0);
4747 /* Add a new entry to .debug_pubnames if appropriate. */
4750 add_pubname (decl
, die
)
4756 if (! TREE_PUBLIC (decl
))
4759 if (pubname_table_in_use
== pubname_table_allocated
)
4761 pubname_table_allocated
+= PUBNAME_TABLE_INCREMENT
;
4762 pubname_table
= (pubname_ref
) xrealloc
4763 (pubname_table
, pubname_table_allocated
* sizeof (pubname_entry
));
4766 p
= &pubname_table
[pubname_table_in_use
++];
4769 p
->name
= xstrdup (dwarf2_name (decl
, 1));
4772 /* Output the public names table used to speed up access to externally
4773 visible names. For now, only generate entries for externally
4774 visible procedures. */
4779 register unsigned i
;
4780 register unsigned long pubnames_length
= size_of_pubnames ();
4782 ASM_OUTPUT_DWARF_DATA (asm_out_file
, pubnames_length
);
4784 if (flag_verbose_asm
)
4785 fprintf (asm_out_file
, "\t%s Length of Public Names Info.",
4788 fputc ('\n', asm_out_file
);
4789 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, DWARF_VERSION
);
4791 if (flag_verbose_asm
)
4792 fprintf (asm_out_file
, "\t%s DWARF Version", ASM_COMMENT_START
);
4794 fputc ('\n', asm_out_file
);
4795 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, stripattributes (DEBUG_SECTION
));
4796 if (flag_verbose_asm
)
4797 fprintf (asm_out_file
, "\t%s Offset of Compilation Unit Info.",
4800 fputc ('\n', asm_out_file
);
4801 ASM_OUTPUT_DWARF_DATA (asm_out_file
, next_die_offset
);
4802 if (flag_verbose_asm
)
4803 fprintf (asm_out_file
, "\t%s Compilation Unit Length", ASM_COMMENT_START
);
4805 fputc ('\n', asm_out_file
);
4806 for (i
= 0; i
< pubname_table_in_use
; ++i
)
4808 register pubname_ref pub
= &pubname_table
[i
];
4810 ASM_OUTPUT_DWARF_DATA (asm_out_file
, pub
->die
->die_offset
);
4811 if (flag_verbose_asm
)
4812 fprintf (asm_out_file
, "\t%s DIE offset", ASM_COMMENT_START
);
4814 fputc ('\n', asm_out_file
);
4816 ASM_OUTPUT_DWARF_STRING (asm_out_file
, pub
->name
);
4817 if (flag_verbose_asm
)
4818 fprintf (asm_out_file
, "%s external name", ASM_COMMENT_START
);
4820 fputc ('\n', asm_out_file
);
4823 ASM_OUTPUT_DWARF_DATA (asm_out_file
, 0);
4824 fputc ('\n', asm_out_file
);
4827 /* Add a new entry to .debug_aranges if appropriate. */
4830 add_arange (decl
, die
)
4834 if (! DECL_SECTION_NAME (decl
))
4837 if (arange_table_in_use
== arange_table_allocated
)
4839 arange_table_allocated
+= ARANGE_TABLE_INCREMENT
;
4841 = (arange_ref
) xrealloc (arange_table
,
4842 arange_table_allocated
* sizeof (dw_die_ref
));
4845 arange_table
[arange_table_in_use
++] = die
;
4848 /* Output the information that goes into the .debug_aranges table.
4849 Namely, define the beginning and ending address range of the
4850 text section generated for this compilation unit. */
4855 register unsigned i
;
4856 register unsigned long aranges_length
= size_of_aranges ();
4858 ASM_OUTPUT_DWARF_DATA (asm_out_file
, aranges_length
);
4859 if (flag_verbose_asm
)
4860 fprintf (asm_out_file
, "\t%s Length of Address Ranges Info.",
4863 fputc ('\n', asm_out_file
);
4864 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, DWARF_VERSION
);
4865 if (flag_verbose_asm
)
4866 fprintf (asm_out_file
, "\t%s DWARF Version", ASM_COMMENT_START
);
4868 fputc ('\n', asm_out_file
);
4869 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, stripattributes (DEBUG_SECTION
));
4870 if (flag_verbose_asm
)
4871 fprintf (asm_out_file
, "\t%s Offset of Compilation Unit Info.",
4874 fputc ('\n', asm_out_file
);
4875 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, PTR_SIZE
);
4876 if (flag_verbose_asm
)
4877 fprintf (asm_out_file
, "\t%s Size of Address", ASM_COMMENT_START
);
4879 fputc ('\n', asm_out_file
);
4880 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
4881 if (flag_verbose_asm
)
4882 fprintf (asm_out_file
, "\t%s Size of Segment Descriptor",
4885 fputc ('\n', asm_out_file
);
4886 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 4);
4888 fprintf (asm_out_file
, ",0,0");
4890 if (flag_verbose_asm
)
4891 fprintf (asm_out_file
, "\t%s Pad to %d byte boundary",
4892 ASM_COMMENT_START
, 2 * PTR_SIZE
);
4894 fputc ('\n', asm_out_file
);
4895 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_SECTION
);
4896 if (flag_verbose_asm
)
4897 fprintf (asm_out_file
, "\t%s Address", ASM_COMMENT_START
);
4899 fputc ('\n', asm_out_file
);
4900 ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file
, text_end_label
, TEXT_SECTION
);
4901 if (flag_verbose_asm
)
4902 fprintf (asm_out_file
, "%s Length", ASM_COMMENT_START
);
4904 fputc ('\n', asm_out_file
);
4905 for (i
= 0; i
< arange_table_in_use
; ++i
)
4907 dw_die_ref a
= arange_table
[i
];
4909 if (a
->die_tag
== DW_TAG_subprogram
)
4910 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, get_AT_low_pc (a
));
4913 char *name
= get_AT_string (a
, DW_AT_MIPS_linkage_name
);
4915 name
= get_AT_string (a
, DW_AT_name
);
4917 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, name
);
4920 if (flag_verbose_asm
)
4921 fprintf (asm_out_file
, "\t%s Address", ASM_COMMENT_START
);
4923 fputc ('\n', asm_out_file
);
4924 if (a
->die_tag
== DW_TAG_subprogram
)
4925 ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file
, get_AT_hi_pc (a
),
4928 ASM_OUTPUT_DWARF_ADDR_DATA (asm_out_file
,
4929 get_AT_unsigned (a
, DW_AT_byte_size
));
4931 if (flag_verbose_asm
)
4932 fprintf (asm_out_file
, "%s Length", ASM_COMMENT_START
);
4934 fputc ('\n', asm_out_file
);
4937 /* Output the terminator words. */
4938 ASM_OUTPUT_DWARF_ADDR_DATA (asm_out_file
, 0);
4939 fputc ('\n', asm_out_file
);
4940 ASM_OUTPUT_DWARF_ADDR_DATA (asm_out_file
, 0);
4941 fputc ('\n', asm_out_file
);
4944 /* Output the source line number correspondence information. This
4945 information goes into the .debug_line section. */
4950 char line_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4951 char prev_line_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
4952 register unsigned opc
;
4953 register unsigned n_op_args
;
4954 register unsigned long ft_index
;
4955 register unsigned long lt_index
;
4956 register unsigned long current_line
;
4957 register long line_offset
;
4958 register long line_delta
;
4959 register unsigned long current_file
;
4960 register unsigned long function
;
4962 ASM_OUTPUT_DWARF_DATA (asm_out_file
, size_of_line_info ());
4963 if (flag_verbose_asm
)
4964 fprintf (asm_out_file
, "\t%s Length of Source Line Info.",
4967 fputc ('\n', asm_out_file
);
4968 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, DWARF_VERSION
);
4969 if (flag_verbose_asm
)
4970 fprintf (asm_out_file
, "\t%s DWARF Version", ASM_COMMENT_START
);
4972 fputc ('\n', asm_out_file
);
4973 ASM_OUTPUT_DWARF_DATA (asm_out_file
, size_of_line_prolog ());
4974 if (flag_verbose_asm
)
4975 fprintf (asm_out_file
, "\t%s Prolog Length", ASM_COMMENT_START
);
4977 fputc ('\n', asm_out_file
);
4978 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DWARF_LINE_MIN_INSTR_LENGTH
);
4979 if (flag_verbose_asm
)
4980 fprintf (asm_out_file
, "\t%s Minimum Instruction Length",
4983 fputc ('\n', asm_out_file
);
4984 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DWARF_LINE_DEFAULT_IS_STMT_START
);
4985 if (flag_verbose_asm
)
4986 fprintf (asm_out_file
, "\t%s Default is_stmt_start flag",
4989 fputc ('\n', asm_out_file
);
4990 fprintf (asm_out_file
, "\t%s\t%d", ASM_BYTE_OP
, DWARF_LINE_BASE
);
4991 if (flag_verbose_asm
)
4992 fprintf (asm_out_file
, "\t%s Line Base Value (Special Opcodes)",
4995 fputc ('\n', asm_out_file
);
4996 fprintf (asm_out_file
, "\t%s\t%u", ASM_BYTE_OP
, DWARF_LINE_RANGE
);
4997 if (flag_verbose_asm
)
4998 fprintf (asm_out_file
, "\t%s Line Range Value (Special Opcodes)",
5001 fputc ('\n', asm_out_file
);
5002 fprintf (asm_out_file
, "\t%s\t%u", ASM_BYTE_OP
, DWARF_LINE_OPCODE_BASE
);
5003 if (flag_verbose_asm
)
5004 fprintf (asm_out_file
, "\t%s Special Opcode Base", ASM_COMMENT_START
);
5006 fputc ('\n', asm_out_file
);
5007 for (opc
= 1; opc
< DWARF_LINE_OPCODE_BASE
; ++opc
)
5011 case DW_LNS_advance_pc
:
5012 case DW_LNS_advance_line
:
5013 case DW_LNS_set_file
:
5014 case DW_LNS_set_column
:
5015 case DW_LNS_fixed_advance_pc
:
5022 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, n_op_args
);
5023 if (flag_verbose_asm
)
5024 fprintf (asm_out_file
, "\t%s opcode: 0x%x has %d args",
5025 ASM_COMMENT_START
, opc
, n_op_args
);
5026 fputc ('\n', asm_out_file
);
5029 if (flag_verbose_asm
)
5030 fprintf (asm_out_file
, "%s Include Directory Table\n", ASM_COMMENT_START
);
5032 /* Include directory table is empty, at present */
5033 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5034 fputc ('\n', asm_out_file
);
5035 if (flag_verbose_asm
)
5036 fprintf (asm_out_file
, "%s File Name Table\n", ASM_COMMENT_START
);
5038 for (ft_index
= 1; ft_index
< file_table_in_use
; ++ft_index
)
5040 ASM_OUTPUT_DWARF_STRING (asm_out_file
, file_table
[ft_index
]);
5041 if (flag_verbose_asm
)
5042 fprintf (asm_out_file
, "%s File Entry: 0x%x",
5043 ASM_COMMENT_START
, ft_index
);
5045 fputc ('\n', asm_out_file
);
5047 /* Include directory index */
5049 fputc ('\n', asm_out_file
);
5051 /* Modification time */
5053 fputc ('\n', asm_out_file
);
5055 /* File length in bytes */
5057 fputc ('\n', asm_out_file
);
5060 /* Terminate the file name table */
5061 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5062 fputc ('\n', asm_out_file
);
5064 /* Set the address register to the first location in the text section */
5065 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5066 if (flag_verbose_asm
)
5067 fprintf (asm_out_file
, "\t%s DW_LNE_set_address", ASM_COMMENT_START
);
5069 fputc ('\n', asm_out_file
);
5070 output_uleb128 (1 + PTR_SIZE
);
5071 fputc ('\n', asm_out_file
);
5072 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_set_address
);
5073 fputc ('\n', asm_out_file
);
5074 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_SECTION
);
5075 fputc ('\n', asm_out_file
);
5077 /* Generate the line number to PC correspondence table, encoded as
5078 a series of state machine operations. */
5081 strcpy (prev_line_label
, TEXT_SECTION
);
5082 for (lt_index
= 1; lt_index
< line_info_table_in_use
; ++lt_index
)
5084 register dw_line_info_ref line_info
;
5086 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_fixed_advance_pc
);
5087 if (flag_verbose_asm
)
5088 fprintf (asm_out_file
, "\t%s DW_LNS_fixed_advance_pc",
5091 fputc ('\n', asm_out_file
);
5092 ASM_GENERATE_INTERNAL_LABEL (line_label
, LINE_CODE_LABEL
, lt_index
);
5093 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, line_label
, prev_line_label
);
5094 fputc ('\n', asm_out_file
);
5095 line_info
= &line_info_table
[lt_index
];
5096 if (line_info
->dw_file_num
!= current_file
)
5098 current_file
= line_info
->dw_file_num
;
5099 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_set_file
);
5100 if (flag_verbose_asm
)
5101 fprintf (asm_out_file
, "\t%s DW_LNS_set_file", ASM_COMMENT_START
);
5103 fputc ('\n', asm_out_file
);
5104 output_uleb128 (current_file
);
5105 if (flag_verbose_asm
)
5106 fprintf (asm_out_file
, " (\"%s\")", file_table
[current_file
]);
5108 fputc ('\n', asm_out_file
);
5111 line_offset
= line_info
->dw_line_num
- current_line
;
5112 line_delta
= line_offset
- DWARF_LINE_BASE
;
5113 current_line
= line_info
->dw_line_num
;
5114 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
5116 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
5117 DWARF_LINE_OPCODE_BASE
+ line_delta
);
5118 if (flag_verbose_asm
)
5119 fprintf (asm_out_file
,
5120 "\t%s line %d", ASM_COMMENT_START
, current_line
);
5122 fputc ('\n', asm_out_file
);
5126 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_advance_line
);
5127 if (flag_verbose_asm
)
5128 fprintf (asm_out_file
, "\t%s advance to line %d",
5129 ASM_COMMENT_START
, current_line
);
5131 fputc ('\n', asm_out_file
);
5132 output_sleb128 (line_offset
);
5133 fputc ('\n', asm_out_file
);
5134 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_copy
);
5135 fputc ('\n', asm_out_file
);
5138 strcpy (prev_line_label
, line_label
);
5141 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_fixed_advance_pc
);
5142 if (flag_verbose_asm
)
5143 fprintf (asm_out_file
, "\t%s DW_LNS_fixed_advance_pc", ASM_COMMENT_START
);
5145 fputc ('\n', asm_out_file
);
5146 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, text_end_label
, prev_line_label
);
5147 fputc ('\n', asm_out_file
);
5149 /* Output the marker for the end of the line number info. */
5150 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5151 if (flag_verbose_asm
)
5152 fprintf (asm_out_file
, "\t%s DW_LNE_end_sequence", ASM_COMMENT_START
);
5154 fputc ('\n', asm_out_file
);
5156 fputc ('\n', asm_out_file
);
5157 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_end_sequence
);
5158 fputc ('\n', asm_out_file
);
5163 for (lt_index
= 0; lt_index
< separate_line_info_table_in_use
; )
5165 register dw_separate_line_info_ref line_info
5166 = &separate_line_info_table
[lt_index
];
5168 ASM_GENERATE_INTERNAL_LABEL (line_label
, SEPARATE_LINE_CODE_LABEL
,
5170 if (function
!= line_info
->function
)
5172 function
= line_info
->function
;
5174 /* Set the address register to the first line in the function */
5175 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5176 if (flag_verbose_asm
)
5177 fprintf (asm_out_file
, "\t%s DW_LNE_set_address",
5180 fputc ('\n', asm_out_file
);
5181 output_uleb128 (1 + PTR_SIZE
);
5182 fputc ('\n', asm_out_file
);
5183 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_set_address
);
5184 fputc ('\n', asm_out_file
);
5185 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, line_label
);
5186 fputc ('\n', asm_out_file
);
5190 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_fixed_advance_pc
);
5191 if (flag_verbose_asm
)
5192 fprintf (asm_out_file
, "\t%s DW_LNS_fixed_advance_pc",
5195 fputc ('\n', asm_out_file
);
5196 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, line_label
, prev_line_label
);
5197 fputc ('\n', asm_out_file
);
5200 if (line_info
->dw_file_num
!= current_file
)
5202 current_file
= line_info
->dw_file_num
;
5203 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_set_file
);
5204 if (flag_verbose_asm
)
5205 fprintf (asm_out_file
, "\t%s DW_LNS_set_file", ASM_COMMENT_START
);
5207 fputc ('\n', asm_out_file
);
5208 output_uleb128 (current_file
);
5209 if (flag_verbose_asm
)
5210 fprintf (asm_out_file
, " (\"%s\")", file_table
[current_file
]);
5212 fputc ('\n', asm_out_file
);
5215 if (line_info
->dw_line_num
!= current_line
)
5217 line_offset
= line_info
->dw_line_num
- current_line
;
5218 line_delta
= line_offset
- DWARF_LINE_BASE
;
5219 current_line
= line_info
->dw_line_num
;
5220 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
5222 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
5223 DWARF_LINE_OPCODE_BASE
+ line_delta
);
5224 if (flag_verbose_asm
)
5225 fprintf (asm_out_file
,
5226 "\t%s line %d", ASM_COMMENT_START
, current_line
);
5228 fputc ('\n', asm_out_file
);
5232 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_advance_line
);
5233 if (flag_verbose_asm
)
5234 fprintf (asm_out_file
, "\t%s advance to line %d",
5235 ASM_COMMENT_START
, current_line
);
5237 fputc ('\n', asm_out_file
);
5238 output_sleb128 (line_offset
);
5239 fputc ('\n', asm_out_file
);
5240 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_copy
);
5241 fputc ('\n', asm_out_file
);
5246 strcpy (prev_line_label
, line_label
);
5248 /* If we're done with a function, end its sequence. */
5249 if (lt_index
== separate_line_info_table_in_use
5250 || separate_line_info_table
[lt_index
].function
!= function
)
5254 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_fixed_advance_pc
);
5255 if (flag_verbose_asm
)
5256 fprintf (asm_out_file
, "\t%s DW_LNS_fixed_advance_pc",
5259 fputc ('\n', asm_out_file
);
5260 ASM_GENERATE_INTERNAL_LABEL (line_label
, FUNC_END_LABEL
, function
);
5261 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, line_label
, prev_line_label
);
5262 fputc ('\n', asm_out_file
);
5264 /* Output the marker for the end of this sequence. */
5265 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5266 if (flag_verbose_asm
)
5267 fprintf (asm_out_file
, "\t%s DW_LNE_end_sequence",
5270 fputc ('\n', asm_out_file
);
5272 fputc ('\n', asm_out_file
);
5273 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_end_sequence
);
5274 fputc ('\n', asm_out_file
);
5279 /* Given a pointer to a BLOCK node return non-zero if (and only if) the node
5280 in question represents the outermost pair of curly braces (i.e. the "body
5281 block") of a function or method.
5283 For any BLOCK node representing a "body block" of a function or method, the
5284 BLOCK_SUPERCONTEXT of the node will point to another BLOCK node which
5285 represents the outermost (function) scope for the function or method (i.e.
5286 the one which includes the formal parameters). The BLOCK_SUPERCONTEXT of
5287 *that* node in turn will point to the relevant FUNCTION_DECL node. */
5290 is_body_block (stmt
)
5293 if (TREE_CODE (stmt
) == BLOCK
)
5295 register tree parent
= BLOCK_SUPERCONTEXT (stmt
);
5297 if (TREE_CODE (parent
) == BLOCK
)
5299 register tree grandparent
= BLOCK_SUPERCONTEXT (parent
);
5301 if (TREE_CODE (grandparent
) == FUNCTION_DECL
)
5309 /* Given a pointer to a tree node for some base type, return a pointer to
5310 a DIE that describes the given type.
5312 This routine must only be called for GCC type nodes that correspond to
5313 Dwarf base (fundamental) types. */
5316 base_type_die (type
)
5319 register dw_die_ref base_type_result
;
5320 register char *type_name
;
5321 register enum dwarf_type encoding
;
5322 register tree name
= TYPE_NAME (type
);
5324 if (TREE_CODE (type
) == ERROR_MARK
5325 || TREE_CODE (type
) == VOID_TYPE
)
5328 if (TREE_CODE (name
) == TYPE_DECL
)
5329 name
= DECL_NAME (name
);
5330 type_name
= IDENTIFIER_POINTER (name
);
5332 switch (TREE_CODE (type
))
5335 /* Carefully distinguish the C character types, without messing
5336 up if the language is not C. Note that we check only for the names
5337 that contain spaces; other names might occur by coincidence in other
5339 if (! (TYPE_PRECISION (type
) == CHAR_TYPE_SIZE
5340 && (type
== char_type_node
5341 || ! strcmp (type_name
, "signed char")
5342 || ! strcmp (type_name
, "unsigned char"))))
5344 if (TREE_UNSIGNED (type
))
5345 encoding
= DW_ATE_unsigned
;
5347 encoding
= DW_ATE_signed
;
5350 /* else fall through */
5353 /* GNU Pascal/Ada CHAR type. Not used in C. */
5354 if (TREE_UNSIGNED (type
))
5355 encoding
= DW_ATE_unsigned_char
;
5357 encoding
= DW_ATE_signed_char
;
5361 encoding
= DW_ATE_float
;
5365 encoding
= DW_ATE_complex_float
;
5369 /* GNU FORTRAN/Ada/C++ BOOLEAN type. */
5370 encoding
= DW_ATE_boolean
;
5374 abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
5377 base_type_result
= new_die (DW_TAG_base_type
, comp_unit_die
);
5378 add_AT_string (base_type_result
, DW_AT_name
, type_name
);
5379 add_AT_unsigned (base_type_result
, DW_AT_byte_size
,
5380 TYPE_PRECISION (type
) / BITS_PER_UNIT
);
5381 add_AT_unsigned (base_type_result
, DW_AT_encoding
, encoding
);
5383 return base_type_result
;
5386 /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
5387 the Dwarf "root" type for the given input type. The Dwarf "root" type of
5388 a given type is generally the same as the given type, except that if the
5389 given type is a pointer or reference type, then the root type of the given
5390 type is the root type of the "basis" type for the pointer or reference
5391 type. (This definition of the "root" type is recursive.) Also, the root
5392 type of a `const' qualified type or a `volatile' qualified type is the
5393 root type of the given type without the qualifiers. */
5399 if (TREE_CODE (type
) == ERROR_MARK
)
5400 return error_mark_node
;
5402 switch (TREE_CODE (type
))
5405 return error_mark_node
;
5408 case REFERENCE_TYPE
:
5409 return type_main_variant (root_type (TREE_TYPE (type
)));
5412 return type_main_variant (type
);
5416 /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
5417 given input type is a Dwarf "fundamental" type. Otherwise return null. */
5423 switch (TREE_CODE (type
))
5438 case QUAL_UNION_TYPE
:
5443 case REFERENCE_TYPE
:
5456 /* Given a pointer to an arbitrary ..._TYPE tree node, return a debugging
5457 entry that chains various modifiers in front of the given type. */
5460 modified_type_die (type
, is_const_type
, is_volatile_type
, context_die
)
5462 register int is_const_type
;
5463 register int is_volatile_type
;
5464 register dw_die_ref context_die
;
5466 register enum tree_code code
= TREE_CODE (type
);
5467 register dw_die_ref mod_type_die
= NULL
;
5468 register dw_die_ref sub_die
= NULL
;
5469 register tree item_type
= NULL
;
5471 if (code
!= ERROR_MARK
)
5473 type
= build_type_variant (type
, is_const_type
, is_volatile_type
);
5475 mod_type_die
= lookup_type_die (type
);
5477 return mod_type_die
;
5479 /* Handle C typedef types. */
5480 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
5481 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
5483 tree dtype
= TREE_TYPE (TYPE_NAME (type
));
5486 /* For a named type, use the typedef. */
5487 gen_type_die (type
, context_die
);
5488 mod_type_die
= lookup_type_die (type
);
5491 else if (is_const_type
< TYPE_READONLY (dtype
)
5492 || is_volatile_type
< TYPE_VOLATILE (dtype
))
5493 /* cv-unqualified version of named type. Just use the unnamed
5494 type to which it refers. */
5496 = modified_type_die (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)),
5497 is_const_type
, is_volatile_type
,
5499 /* Else cv-qualified version of named type; fall through. */
5504 else if (is_const_type
)
5506 mod_type_die
= new_die (DW_TAG_const_type
, comp_unit_die
);
5507 sub_die
= modified_type_die (type
, 0, is_volatile_type
, context_die
);
5509 else if (is_volatile_type
)
5511 mod_type_die
= new_die (DW_TAG_volatile_type
, comp_unit_die
);
5512 sub_die
= modified_type_die (type
, 0, 0, context_die
);
5514 else if (code
== POINTER_TYPE
)
5516 mod_type_die
= new_die (DW_TAG_pointer_type
, comp_unit_die
);
5517 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
5519 add_AT_unsigned (mod_type_die
, DW_AT_address_class
, 0);
5521 item_type
= TREE_TYPE (type
);
5523 else if (code
== REFERENCE_TYPE
)
5525 mod_type_die
= new_die (DW_TAG_reference_type
, comp_unit_die
);
5526 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
5528 add_AT_unsigned (mod_type_die
, DW_AT_address_class
, 0);
5530 item_type
= TREE_TYPE (type
);
5532 else if (is_base_type (type
))
5533 mod_type_die
= base_type_die (type
);
5536 gen_type_die (type
, context_die
);
5538 /* We have to get the type_main_variant here (and pass that to the
5539 `lookup_type_die' routine) because the ..._TYPE node we have
5540 might simply be a *copy* of some original type node (where the
5541 copy was created to help us keep track of typedef names) and
5542 that copy might have a different TYPE_UID from the original
5544 mod_type_die
= lookup_type_die (type_main_variant (type
));
5545 assert (mod_type_die
!= NULL
);
5549 equate_type_number_to_die (type
, mod_type_die
);
5551 /* We must do this after the equate_type_number_to_die call, in case
5552 this is a recursive type. This ensures that the modified_type_die
5553 recursion will terminate even if the type is recursive. Recursive
5554 types are possible in Ada. */
5555 sub_die
= modified_type_die (item_type
,
5556 TYPE_READONLY (item_type
),
5557 TYPE_VOLATILE (item_type
),
5560 if (sub_die
!= NULL
)
5561 add_AT_die_ref (mod_type_die
, DW_AT_type
, sub_die
);
5563 return mod_type_die
;
5566 /* Given a pointer to an arbitrary ..._TYPE tree node, return true if it is
5567 an enumerated type. */
5573 return TREE_CODE (type
) == ENUMERAL_TYPE
;
5576 /* Return the register number described by a given RTL node. */
5582 register unsigned regno
= REGNO (rtl
);
5584 if (regno
>= FIRST_PSEUDO_REGISTER
)
5586 warning_with_decl (dwarf_last_decl
, "internal regno botch: regno = %d\n",
5591 regno
= DBX_REGISTER_NUMBER (regno
);
5595 /* Return a location descriptor that designates a machine register. */
5597 static dw_loc_descr_ref
5598 reg_loc_descriptor (rtl
)
5601 register dw_loc_descr_ref loc_result
= NULL
;
5602 register unsigned reg
= reg_number (rtl
);
5604 if (reg
>= 0 && reg
<= 31)
5605 loc_result
= new_loc_descr (DW_OP_reg0
+ reg
, 0, 0);
5607 loc_result
= new_loc_descr (DW_OP_regx
, reg
, 0);
5612 /* Return a location descriptor that designates a base+offset location. */
5614 static dw_loc_descr_ref
5615 based_loc_descr (reg
, offset
)
5619 register dw_loc_descr_ref loc_result
;
5620 /* For the "frame base", we use the frame pointer or stack pointer
5621 registers, since the RTL for local variables is relative to one of
5623 register unsigned fp_reg
= DBX_REGISTER_NUMBER (frame_pointer_needed
5624 ? HARD_FRAME_POINTER_REGNUM
5625 : STACK_POINTER_REGNUM
);
5628 loc_result
= new_loc_descr (DW_OP_fbreg
, offset
, 0);
5629 else if (reg
>= 0 && reg
<= 31)
5630 loc_result
= new_loc_descr (DW_OP_breg0
+ reg
, offset
, 0);
5632 loc_result
= new_loc_descr (DW_OP_bregx
, reg
, offset
);
5637 /* Return true if this RTL expression describes a base+offset calculation. */
5643 return (GET_CODE (rtl
) == PLUS
5644 && ((GET_CODE (XEXP (rtl
, 0)) == REG
5645 && GET_CODE (XEXP (rtl
, 1)) == CONST_INT
)));
5648 /* The following routine converts the RTL for a variable or parameter
5649 (resident in memory) into an equivalent Dwarf representation of a
5650 mechanism for getting the address of that same variable onto the top of a
5651 hypothetical "address evaluation" stack.
5653 When creating memory location descriptors, we are effectively transforming
5654 the RTL for a memory-resident object into its Dwarf postfix expression
5655 equivalent. This routine recursively descends an RTL tree, turning
5656 it into Dwarf postfix code as it goes. */
5658 static dw_loc_descr_ref
5659 mem_loc_descriptor (rtl
)
5662 dw_loc_descr_ref mem_loc_result
= NULL
;
5663 /* Note that for a dynamically sized array, the location we will generate a
5664 description of here will be the lowest numbered location which is
5665 actually within the array. That's *not* necessarily the same as the
5666 zeroth element of the array. */
5668 switch (GET_CODE (rtl
))
5671 /* The case of a subreg may arise when we have a local (register)
5672 variable or a formal (register) parameter which doesn't quite fill
5673 up an entire register. For now, just assume that it is
5674 legitimate to make the Dwarf info refer to the whole register which
5675 contains the given subreg. */
5676 rtl
= XEXP (rtl
, 0);
5678 /* ... fall through ... */
5681 /* Whenever a register number forms a part of the description of the
5682 method for calculating the (dynamic) address of a memory resident
5683 object, DWARF rules require the register number be referred to as
5684 a "base register". This distinction is not based in any way upon
5685 what category of register the hardware believes the given register
5686 belongs to. This is strictly DWARF terminology we're dealing with
5687 here. Note that in cases where the location of a memory-resident
5688 data object could be expressed as: OP_ADD (OP_BASEREG (basereg),
5689 OP_CONST (0)) the actual DWARF location descriptor that we generate
5690 may just be OP_BASEREG (basereg). This may look deceptively like
5691 the object in question was allocated to a register (rather than in
5692 memory) so DWARF consumers need to be aware of the subtle
5693 distinction between OP_REG and OP_BASEREG. */
5694 mem_loc_result
= based_loc_descr (reg_number (rtl
), 0);
5698 mem_loc_result
= mem_loc_descriptor (XEXP (rtl
, 0));
5699 add_loc_descr (&mem_loc_result
, new_loc_descr (DW_OP_deref
, 0, 0));
5704 mem_loc_result
= new_loc_descr (DW_OP_addr
, 0, 0);
5705 mem_loc_result
->dw_loc_oprnd1
.val_class
= dw_val_class_addr
;
5706 mem_loc_result
->dw_loc_oprnd1
.v
.val_addr
= addr_to_string (rtl
);
5710 if (is_based_loc (rtl
))
5711 mem_loc_result
= based_loc_descr (reg_number (XEXP (rtl
, 0)),
5712 INTVAL (XEXP (rtl
, 1)));
5715 add_loc_descr (&mem_loc_result
, mem_loc_descriptor (XEXP (rtl
, 0)));
5716 add_loc_descr (&mem_loc_result
, mem_loc_descriptor (XEXP (rtl
, 1)));
5717 add_loc_descr (&mem_loc_result
, new_loc_descr (DW_OP_plus
, 0, 0));
5722 /* If a pseudo-reg is optimized away, it is possible for it to
5723 be replaced with a MEM containing a multiply. */
5724 add_loc_descr (&mem_loc_result
, mem_loc_descriptor (XEXP (rtl
, 0)));
5725 add_loc_descr (&mem_loc_result
, mem_loc_descriptor (XEXP (rtl
, 1)));
5726 add_loc_descr (&mem_loc_result
, new_loc_descr (DW_OP_mul
, 0, 0));
5730 mem_loc_result
= new_loc_descr (DW_OP_constu
, INTVAL (rtl
), 0);
5737 return mem_loc_result
;
5740 /* Output a proper Dwarf location descriptor for a variable or parameter
5741 which is either allocated in a register or in a memory location. For a
5742 register, we just generate an OP_REG and the register number. For a
5743 memory location we provide a Dwarf postfix expression describing how to
5744 generate the (dynamic) address of the object onto the address stack. */
5746 static dw_loc_descr_ref
5747 loc_descriptor (rtl
)
5750 dw_loc_descr_ref loc_result
= NULL
;
5751 switch (GET_CODE (rtl
))
5754 /* The case of a subreg may arise when we have a local (register)
5755 variable or a formal (register) parameter which doesn't quite fill
5756 up an entire register. For now, just assume that it is
5757 legitimate to make the Dwarf info refer to the whole register which
5758 contains the given subreg. */
5759 rtl
= XEXP (rtl
, 0);
5761 /* ... fall through ... */
5764 loc_result
= reg_loc_descriptor (rtl
);
5768 loc_result
= mem_loc_descriptor (XEXP (rtl
, 0));
5778 /* Given an unsigned value, round it up to the lowest multiple of `boundary'
5779 which is not less than the value itself. */
5781 static inline unsigned
5782 ceiling (value
, boundary
)
5783 register unsigned value
;
5784 register unsigned boundary
;
5786 return (((value
+ boundary
- 1) / boundary
) * boundary
);
5789 /* Given a pointer to what is assumed to be a FIELD_DECL node, return a
5790 pointer to the declared type for the relevant field variable, or return
5791 `integer_type_node' if the given node turns out to be an
5800 if (TREE_CODE (decl
) == ERROR_MARK
)
5801 return integer_type_node
;
5803 type
= DECL_BIT_FIELD_TYPE (decl
);
5804 if (type
== NULL_TREE
)
5805 type
= TREE_TYPE (decl
);
5810 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
5811 node, return the alignment in bits for the type, or else return
5812 BITS_PER_WORD if the node actually turns out to be an
5815 static inline unsigned
5816 simple_type_align_in_bits (type
)
5819 return (TREE_CODE (type
) != ERROR_MARK
) ? TYPE_ALIGN (type
) : BITS_PER_WORD
;
5822 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
5823 node, return the size in bits for the type if it is a constant, or else
5824 return the alignment for the type if the type's size is not constant, or
5825 else return BITS_PER_WORD if the type actually turns out to be an
5828 static inline unsigned
5829 simple_type_size_in_bits (type
)
5832 if (TREE_CODE (type
) == ERROR_MARK
)
5833 return BITS_PER_WORD
;
5836 register tree type_size_tree
= TYPE_SIZE (type
);
5838 if (TREE_CODE (type_size_tree
) != INTEGER_CST
)
5839 return TYPE_ALIGN (type
);
5841 return (unsigned) TREE_INT_CST_LOW (type_size_tree
);
5845 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
5846 return the byte offset of the lowest addressed byte of the "containing
5847 object" for the given FIELD_DECL, or return 0 if we are unable to
5848 determine what that offset is, either because the argument turns out to
5849 be a pointer to an ERROR_MARK node, or because the offset is actually
5850 variable. (We can't handle the latter case just yet). */
5853 field_byte_offset (decl
)
5856 register unsigned type_align_in_bytes
;
5857 register unsigned type_align_in_bits
;
5858 register unsigned type_size_in_bits
;
5859 register unsigned object_offset_in_align_units
;
5860 register unsigned object_offset_in_bits
;
5861 register unsigned object_offset_in_bytes
;
5863 register tree bitpos_tree
;
5864 register tree field_size_tree
;
5865 register unsigned bitpos_int
;
5866 register unsigned deepest_bitpos
;
5867 register unsigned field_size_in_bits
;
5869 if (TREE_CODE (decl
) == ERROR_MARK
)
5872 if (TREE_CODE (decl
) != FIELD_DECL
)
5875 type
= field_type (decl
);
5877 bitpos_tree
= DECL_FIELD_BITPOS (decl
);
5878 field_size_tree
= DECL_SIZE (decl
);
5880 /* We cannot yet cope with fields whose positions or sizes are variable, so
5881 for now, when we see such things, we simply return 0. Someday, we may
5882 be able to handle such cases, but it will be damn difficult. */
5883 if (TREE_CODE (bitpos_tree
) != INTEGER_CST
)
5885 bitpos_int
= (unsigned) TREE_INT_CST_LOW (bitpos_tree
);
5887 if (TREE_CODE (field_size_tree
) != INTEGER_CST
)
5890 field_size_in_bits
= (unsigned) TREE_INT_CST_LOW (field_size_tree
);
5891 type_size_in_bits
= simple_type_size_in_bits (type
);
5892 type_align_in_bits
= simple_type_align_in_bits (type
);
5893 type_align_in_bytes
= type_align_in_bits
/ BITS_PER_UNIT
;
5895 /* Note that the GCC front-end doesn't make any attempt to keep track of
5896 the starting bit offset (relative to the start of the containing
5897 structure type) of the hypothetical "containing object" for a bit-
5898 field. Thus, when computing the byte offset value for the start of the
5899 "containing object" of a bit-field, we must deduce this information on
5900 our own. This can be rather tricky to do in some cases. For example,
5901 handling the following structure type definition when compiling for an
5902 i386/i486 target (which only aligns long long's to 32-bit boundaries)
5905 struct S { int field1; long long field2:31; };
5907 Fortunately, there is a simple rule-of-thumb which can be
5908 used in such cases. When compiling for an i386/i486, GCC will allocate
5909 8 bytes for the structure shown above. It decides to do this based upon
5910 one simple rule for bit-field allocation. Quite simply, GCC allocates
5911 each "containing object" for each bit-field at the first (i.e. lowest
5912 addressed) legitimate alignment boundary (based upon the required
5913 minimum alignment for the declared type of the field) which it can
5914 possibly use, subject to the condition that there is still enough
5915 available space remaining in the containing object (when allocated at
5916 the selected point) to fully accommodate all of the bits of the
5917 bit-field itself. This simple rule makes it obvious why GCC allocates
5918 8 bytes for each object of the structure type shown above. When looking
5919 for a place to allocate the "containing object" for `field2', the
5920 compiler simply tries to allocate a 64-bit "containing object" at each
5921 successive 32-bit boundary (starting at zero) until it finds a place to
5922 allocate that 64- bit field such that at least 31 contiguous (and
5923 previously unallocated) bits remain within that selected 64 bit field.
5924 (As it turns out, for the example above, the compiler finds that it is
5925 OK to allocate the "containing object" 64-bit field at bit-offset zero
5926 within the structure type.) Here we attempt to work backwards from the
5927 limited set of facts we're given, and we try to deduce from those facts,
5928 where GCC must have believed that the containing object started (within
5929 the structure type). The value we deduce is then used (by the callers of
5930 this routine) to generate DW_AT_location and DW_AT_bit_offset attributes
5931 for fields (both bit-fields and, in the case of DW_AT_location, regular
5934 /* Figure out the bit-distance from the start of the structure to the
5935 "deepest" bit of the bit-field. */
5936 deepest_bitpos
= bitpos_int
+ field_size_in_bits
;
5938 /* This is the tricky part. Use some fancy footwork to deduce where the
5939 lowest addressed bit of the containing object must be. */
5940 object_offset_in_bits
5941 = ceiling (deepest_bitpos
, type_align_in_bits
) - type_size_in_bits
;
5943 /* Compute the offset of the containing object in "alignment units". */
5944 object_offset_in_align_units
= object_offset_in_bits
/ type_align_in_bits
;
5946 /* Compute the offset of the containing object in bytes. */
5947 object_offset_in_bytes
= object_offset_in_align_units
* type_align_in_bytes
;
5949 return object_offset_in_bytes
;
5952 /* The following routines define various Dwarf attributes and any data
5953 associated with them. */
5956 /* Output the form of location attributes suitable for whole variables and
5957 whole parameters. Note that the location attributes for struct fields are
5958 generated by the routine `data_member_location_attribute' below. */
5961 add_location_attribute (die
, rtl
)
5965 dw_loc_descr_ref loc_descr
= NULL
;
5967 /* Handle a special case. If we are about to output a location descriptor
5968 for a variable or parameter which has been optimized out of existence,
5969 don't do that. Instead we output a null location descriptor value as
5970 part of the location attribute. A variable which has been optimized out
5971 of existence will have a DECL_RTL value which denotes a pseudo-reg.
5972 Currently, in some rare cases, variables can have DECL_RTL values which
5973 look like (MEM (REG pseudo-reg#)). These cases are due to bugs
5974 elsewhere in the compiler. We treat such cases as if the variable(s) in
5975 question had been optimized out of existence. Note that in all cases
5976 where we wish to express the fact that a variable has been optimized out
5977 of existence, we do not simply suppress the generation of the entire
5978 location attribute because the absence of a location attribute in
5979 certain kinds of DIEs is used to indicate something else entirely...
5980 i.e. that the DIE represents an object declaration, but not a
5981 definition. So sayeth the PLSIG. */
5983 if (!is_pseudo_reg (rtl
)
5984 && (GET_CODE (rtl
) != MEM
5985 || !is_pseudo_reg (XEXP (rtl
, 0))))
5986 loc_descr
= loc_descriptor (eliminate_regs (rtl
, 0, NULL_RTX
, 0));
5988 #ifdef MIPS_DEBUGGING_INFO
5989 /* ??? SGI's dwarf reader is buggy, and will not accept a zero size
5990 location descriptor. Lets just use r0 for now to represent a
5991 variable that has been optimized away. */
5992 if (loc_descr
== NULL
)
5993 loc_descr
= loc_descriptor (gen_rtx (REG
, word_mode
, 0));
5996 add_AT_loc (die
, DW_AT_location
, loc_descr
);
5999 /* Attach the specialized form of location attribute used for data
6000 members of struct and union types. In the special case of a
6001 FIELD_DECL node which represents a bit-field, the "offset" part
6002 of this special location descriptor must indicate the distance
6003 in bytes from the lowest-addressed byte of the containing struct
6004 or union type to the lowest-addressed byte of the "containing
6005 object" for the bit-field. (See the `field_byte_offset' function
6006 above).. For any given bit-field, the "containing object" is a
6007 hypothetical object (of some integral or enum type) within which
6008 the given bit-field lives. The type of this hypothetical
6009 "containing object" is always the same as the declared type of
6010 the individual bit-field itself (for GCC anyway... the DWARF
6011 spec doesn't actually mandate this). Note that it is the size
6012 (in bytes) of the hypothetical "containing object" which will
6013 be given in the DW_AT_byte_size attribute for this bit-field.
6014 (See the `byte_size_attribute' function below.) It is also used
6015 when calculating the value of the DW_AT_bit_offset attribute.
6016 (See the `bit_offset_attribute' function below). */
6019 add_data_member_location_attribute (die
, decl
)
6020 register dw_die_ref die
;
6023 register unsigned long offset
;
6024 register dw_loc_descr_ref loc_descr
;
6025 register enum dwarf_location_atom op
;
6027 if (TREE_CODE (decl
) == TREE_VEC
)
6028 offset
= TREE_INT_CST_LOW (BINFO_OFFSET (decl
));
6030 offset
= field_byte_offset (decl
);
6032 /* The DWARF2 standard says that we should assume that the structure address
6033 is already on the stack, so we can specify a structure field address
6034 by using DW_OP_plus_uconst. */
6036 #ifdef MIPS_DEBUGGING_INFO
6037 /* ??? The SGI dwarf reader does not handle the DW_OP_plus_uconst operator
6038 correctly. It works only if we leave the offset on the stack. */
6041 op
= DW_OP_plus_uconst
;
6044 loc_descr
= new_loc_descr (op
, offset
, 0);
6045 add_AT_loc (die
, DW_AT_data_member_location
, loc_descr
);
6048 /* Attach an DW_AT_const_value attribute for a variable or a parameter which
6049 does not have a "location" either in memory or in a register. These
6050 things can arise in GNU C when a constant is passed as an actual parameter
6051 to an inlined function. They can also arise in C++ where declared
6052 constants do not necessarily get memory "homes". */
6055 add_const_value_attribute (die
, rtl
)
6056 register dw_die_ref die
;
6059 switch (GET_CODE (rtl
))
6062 /* Note that a CONST_INT rtx could represent either an integer or a
6063 floating-point constant. A CONST_INT is used whenever the constant
6064 will fit into a single word. In all such cases, the original mode
6065 of the constant value is wiped out, and the CONST_INT rtx is
6066 assigned VOIDmode. */
6067 add_AT_unsigned (die
, DW_AT_const_value
, (unsigned) INTVAL (rtl
));
6071 /* Note that a CONST_DOUBLE rtx could represent either an integer or a
6072 floating-point constant. A CONST_DOUBLE is used whenever the
6073 constant requires more than one word in order to be adequately
6074 represented. We output CONST_DOUBLEs as blocks. */
6076 register enum machine_mode mode
= GET_MODE (rtl
);
6078 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
)
6080 register unsigned length
= GET_MODE_SIZE (mode
) / sizeof (long);
6084 REAL_VALUE_FROM_CONST_DOUBLE (rv
, rtl
);
6088 REAL_VALUE_TO_TARGET_SINGLE (rv
, array
[0]);
6092 REAL_VALUE_TO_TARGET_DOUBLE (rv
, array
);
6097 REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv
, array
);
6104 add_AT_float (die
, DW_AT_const_value
, length
, array
);
6107 add_AT_long_long (die
, DW_AT_const_value
,
6108 CONST_DOUBLE_HIGH (rtl
), CONST_DOUBLE_LOW (rtl
));
6113 add_AT_string (die
, DW_AT_const_value
, XSTR (rtl
, 0));
6119 add_AT_addr (die
, DW_AT_const_value
, addr_to_string (rtl
));
6123 /* In cases where an inlined instance of an inline function is passed
6124 the address of an `auto' variable (which is local to the caller) we
6125 can get a situation where the DECL_RTL of the artificial local
6126 variable (for the inlining) which acts as a stand-in for the
6127 corresponding formal parameter (of the inline function) will look
6128 like (plus:SI (reg:SI FRAME_PTR) (const_int ...)). This is not
6129 exactly a compile-time constant expression, but it isn't the address
6130 of the (artificial) local variable either. Rather, it represents the
6131 *value* which the artificial local variable always has during its
6132 lifetime. We currently have no way to represent such quasi-constant
6133 values in Dwarf, so for now we just punt and generate an
6134 DW_AT_const_value attribute with null address. */
6135 add_AT_addr (die
, DW_AT_const_value
, addr_to_string (const0_rtx
));
6139 /* No other kinds of rtx should be possible here. */
6145 /* Generate *either* an DW_AT_location attribute or else an DW_AT_const_value
6146 data attribute for a variable or a parameter. We generate the
6147 DW_AT_const_value attribute only in those cases where the given variable
6148 or parameter does not have a true "location" either in memory or in a
6149 register. This can happen (for example) when a constant is passed as an
6150 actual argument in a call to an inline function. (It's possible that
6151 these things can crop up in other ways also.) Note that one type of
6152 constant value which can be passed into an inlined function is a constant
6153 pointer. This can happen for example if an actual argument in an inlined
6154 function call evaluates to a compile-time constant address. */
6157 add_location_or_const_value_attribute (die
, decl
)
6158 register dw_die_ref die
;
6162 register tree declared_type
;
6163 register tree passed_type
;
6165 if (TREE_CODE (decl
) == ERROR_MARK
)
6168 if (TREE_CODE (decl
) != VAR_DECL
&& TREE_CODE (decl
) != PARM_DECL
)
6171 /* Here we have to decide where we are going to say the parameter "lives"
6172 (as far as the debugger is concerned). We only have a couple of
6173 choices. GCC provides us with DECL_RTL and with DECL_INCOMING_RTL.
6175 DECL_RTL normally indicates where the parameter lives during most of the
6176 activation of the function. If optimization is enabled however, this
6177 could be either NULL or else a pseudo-reg. Both of those cases indicate
6178 that the parameter doesn't really live anywhere (as far as the code
6179 generation parts of GCC are concerned) during most of the function's
6180 activation. That will happen (for example) if the parameter is never
6181 referenced within the function.
6183 We could just generate a location descriptor here for all non-NULL
6184 non-pseudo values of DECL_RTL and ignore all of the rest, but we can be
6185 a little nicer than that if we also consider DECL_INCOMING_RTL in cases
6186 where DECL_RTL is NULL or is a pseudo-reg.
6188 Note however that we can only get away with using DECL_INCOMING_RTL as
6189 a backup substitute for DECL_RTL in certain limited cases. In cases
6190 where DECL_ARG_TYPE (decl) indicates the same type as TREE_TYPE (decl),
6191 we can be sure that the parameter was passed using the same type as it is
6192 declared to have within the function, and that its DECL_INCOMING_RTL
6193 points us to a place where a value of that type is passed.
6195 In cases where DECL_ARG_TYPE (decl) and TREE_TYPE (decl) are different,
6196 we cannot (in general) use DECL_INCOMING_RTL as a substitute for DECL_RTL
6197 because in these cases DECL_INCOMING_RTL points us to a value of some
6198 type which is *different* from the type of the parameter itself. Thus,
6199 if we tried to use DECL_INCOMING_RTL to generate a location attribute in
6200 such cases, the debugger would end up (for example) trying to fetch a
6201 `float' from a place which actually contains the first part of a
6202 `double'. That would lead to really incorrect and confusing
6203 output at debug-time.
6205 So, in general, we *do not* use DECL_INCOMING_RTL as a backup for DECL_RTL
6206 in cases where DECL_ARG_TYPE (decl) != TREE_TYPE (decl). There
6207 are a couple of exceptions however. On little-endian machines we can
6208 get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE (decl) is
6209 not the same as TREE_TYPE (decl), but only when DECL_ARG_TYPE (decl) is
6210 an integral type that is smaller than TREE_TYPE (decl). These cases arise
6211 when (on a little-endian machine) a non-prototyped function has a
6212 parameter declared to be of type `short' or `char'. In such cases,
6213 TREE_TYPE (decl) will be `short' or `char', DECL_ARG_TYPE (decl) will
6214 be `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
6215 passed `int' value. If the debugger then uses that address to fetch
6216 a `short' or a `char' (on a little-endian machine) the result will be
6217 the correct data, so we allow for such exceptional cases below.
6219 Note that our goal here is to describe the place where the given formal
6220 parameter lives during most of the function's activation (i.e. between
6221 the end of the prologue and the start of the epilogue). We'll do that
6222 as best as we can. Note however that if the given formal parameter is
6223 modified sometime during the execution of the function, then a stack
6224 backtrace (at debug-time) will show the function as having been
6225 called with the *new* value rather than the value which was
6226 originally passed in. This happens rarely enough that it is not
6227 a major problem, but it *is* a problem, and I'd like to fix it.
6229 A future version of dwarf2out.c may generate two additional
6230 attributes for any given DW_TAG_formal_parameter DIE which will
6231 describe the "passed type" and the "passed location" for the
6232 given formal parameter in addition to the attributes we now
6233 generate to indicate the "declared type" and the "active
6234 location" for each parameter. This additional set of attributes
6235 could be used by debuggers for stack backtraces. Separately, note
6236 that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL can be
6237 NULL also. This happens (for example) for inlined-instances of
6238 inline function formal parameters which are never referenced.
6239 This really shouldn't be happening. All PARM_DECL nodes should
6240 get valid non-NULL DECL_INCOMING_RTL values, but integrate.c
6241 doesn't currently generate these values for inlined instances of
6242 inline function parameters, so when we see such cases, we are
6243 just SOL (shit-out-of-luck) for the time being (until integrate.c
6246 /* Use DECL_RTL as the "location" unless we find something better. */
6247 rtl
= DECL_RTL (decl
);
6249 if (TREE_CODE (decl
) == PARM_DECL
)
6251 if (rtl
== NULL_RTX
|| is_pseudo_reg (rtl
))
6253 declared_type
= type_main_variant (TREE_TYPE (decl
));
6254 passed_type
= type_main_variant (DECL_ARG_TYPE (decl
));
6256 /* This decl represents a formal parameter which was optimized out.
6257 Note that DECL_INCOMING_RTL may be NULL in here, but we handle
6258 all* cases where (rtl == NULL_RTX) just below. */
6259 if (declared_type
== passed_type
)
6260 rtl
= DECL_INCOMING_RTL (decl
);
6261 else if (! BYTES_BIG_ENDIAN
6262 && TREE_CODE (declared_type
) == INTEGER_TYPE
6263 && TYPE_SIZE (declared_type
) <= TYPE_SIZE (passed_type
))
6264 rtl
= DECL_INCOMING_RTL (decl
);
6268 if (rtl
== NULL_RTX
)
6271 switch (GET_CODE (rtl
))
6280 /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
6281 add_const_value_attribute (die
, rtl
);
6287 add_location_attribute (die
, rtl
);
6295 /* Generate an DW_AT_name attribute given some string value to be included as
6296 the value of the attribute. */
6299 add_name_attribute (die
, name_string
)
6300 register dw_die_ref die
;
6301 register char *name_string
;
6303 if (name_string
!= NULL
&& *name_string
!= 0)
6304 add_AT_string (die
, DW_AT_name
, name_string
);
6307 /* Given a tree node describing an array bound (either lower or upper) output
6308 a representation for that bound. */
6311 add_bound_info (subrange_die
, bound_attr
, bound
)
6312 register dw_die_ref subrange_die
;
6313 register enum dwarf_attribute bound_attr
;
6314 register tree bound
;
6316 register unsigned bound_value
= 0;
6317 switch (TREE_CODE (bound
))
6322 /* All fixed-bounds are represented by INTEGER_CST nodes. */
6324 bound_value
= TREE_INT_CST_LOW (bound
);
6325 if (bound_attr
== DW_AT_lower_bound
6326 && ((is_c_family () && bound_value
== 0)
6327 || (is_fortran () && bound_value
== 1)))
6328 /* use the default */;
6330 add_AT_unsigned (subrange_die
, bound_attr
, bound_value
);
6335 case NON_LVALUE_EXPR
:
6336 add_bound_info (subrange_die
, bound_attr
, TREE_OPERAND (bound
, 0));
6340 /* If optimization is turned on, the SAVE_EXPRs that describe how to
6341 access the upper bound values may be bogus. If they refer to a
6342 register, they may only describe how to get at these values at the
6343 points in the generated code right after they have just been
6344 computed. Worse yet, in the typical case, the upper bound values
6345 will not even *be* computed in the optimized code (though the
6346 number of elements will), so these SAVE_EXPRs are entirely
6347 bogus. In order to compensate for this fact, we check here to see
6348 if optimization is enabled, and if so, we don't add an attribute
6349 for the (unknown and unknowable) upper bound. This should not
6350 cause too much trouble for existing (stupid?) debuggers because
6351 they have to deal with empty upper bounds location descriptions
6352 anyway in order to be able to deal with incomplete array types.
6353 Of course an intelligent debugger (GDB?) should be able to
6354 comprehend that a missing upper bound specification in a array
6355 type used for a storage class `auto' local array variable
6356 indicates that the upper bound is both unknown (at compile- time)
6357 and unknowable (at run-time) due to optimization.
6359 We assume that a MEM rtx is safe because gcc wouldn't put the
6360 value there unless it was going to be used repeatedly in the
6361 function, i.e. for cleanups. */
6362 if (! optimize
|| GET_CODE (SAVE_EXPR_RTL (bound
)) == MEM
)
6364 register dw_die_ref ctx
= lookup_decl_die (current_function_decl
);
6365 register dw_die_ref decl_die
= new_die (DW_TAG_variable
, ctx
);
6366 add_AT_flag (decl_die
, DW_AT_artificial
, 1);
6367 add_type_attribute (decl_die
, TREE_TYPE (bound
), 1, 0, ctx
);
6368 add_location_attribute (decl_die
, SAVE_EXPR_RTL (bound
));
6369 add_AT_die_ref (subrange_die
, bound_attr
, decl_die
);
6372 /* Else leave out the attribute. */
6377 /* Note that the block of subscript information for an array type also
6378 includes information about the element type of type given array type. */
6381 add_subscript_info (type_die
, type
)
6382 register dw_die_ref type_die
;
6385 register unsigned dimension_number
;
6386 register tree lower
, upper
;
6387 register dw_die_ref subrange_die
;
6389 /* The GNU compilers represent multidimensional array types as sequences of
6390 one dimensional array types whose element types are themselves array
6391 types. Here we squish that down, so that each multidimensional array
6392 type gets only one array_type DIE in the Dwarf debugging info. The draft
6393 Dwarf specification say that we are allowed to do this kind of
6394 compression in C (because there is no difference between an array or
6395 arrays and a multidimensional array in C) but for other source languages
6396 (e.g. Ada) we probably shouldn't do this. */
6398 /* ??? The SGI dwarf reader fails for multidimensional arrays with a
6399 const enum type. E.g. const enum machine_mode insn_operand_mode[2][10].
6400 We work around this by disabling this feature. See also
6401 gen_array_type_die. */
6402 #ifndef MIPS_DEBUGGING_INFO
6403 for (dimension_number
= 0;
6404 TREE_CODE (type
) == ARRAY_TYPE
;
6405 type
= TREE_TYPE (type
), dimension_number
++)
6408 register tree domain
= TYPE_DOMAIN (type
);
6410 /* Arrays come in three flavors: Unspecified bounds, fixed bounds,
6411 and (in GNU C only) variable bounds. Handle all three forms
6413 subrange_die
= new_die (DW_TAG_subrange_type
, type_die
);
6416 /* We have an array type with specified bounds. */
6417 lower
= TYPE_MIN_VALUE (domain
);
6418 upper
= TYPE_MAX_VALUE (domain
);
6420 /* define the index type. */
6421 if (TREE_TYPE (domain
))
6422 add_type_attribute (subrange_die
, TREE_TYPE (domain
), 0, 0,
6425 add_bound_info (subrange_die
, DW_AT_lower_bound
, lower
);
6426 add_bound_info (subrange_die
, DW_AT_upper_bound
, upper
);
6429 /* We have an array type with an unspecified length. The DWARF-2
6430 spec does not say how to handle this; let's just leave out the
6434 #ifndef MIPS_DEBUGGING_INFO
6440 add_byte_size_attribute (die
, tree_node
)
6442 register tree tree_node
;
6444 register unsigned size
;
6446 switch (TREE_CODE (tree_node
))
6454 case QUAL_UNION_TYPE
:
6455 size
= int_size_in_bytes (tree_node
);
6458 /* For a data member of a struct or union, the DW_AT_byte_size is
6459 generally given as the number of bytes normally allocated for an
6460 object of the *declared* type of the member itself. This is true
6461 even for bit-fields. */
6462 size
= simple_type_size_in_bits (field_type (tree_node
)) / BITS_PER_UNIT
;
6468 /* Note that `size' might be -1 when we get to this point. If it is, that
6469 indicates that the byte size of the entity in question is variable. We
6470 have no good way of expressing this fact in Dwarf at the present time,
6471 so just let the -1 pass on through. */
6473 add_AT_unsigned (die
, DW_AT_byte_size
, size
);
6476 /* For a FIELD_DECL node which represents a bit-field, output an attribute
6477 which specifies the distance in bits from the highest order bit of the
6478 "containing object" for the bit-field to the highest order bit of the
6481 For any given bit-field, the "containing object" is a hypothetical
6482 object (of some integral or enum type) within which the given bit-field
6483 lives. The type of this hypothetical "containing object" is always the
6484 same as the declared type of the individual bit-field itself. The
6485 determination of the exact location of the "containing object" for a
6486 bit-field is rather complicated. It's handled by the
6487 `field_byte_offset' function (above).
6489 Note that it is the size (in bytes) of the hypothetical "containing object"
6490 which will be given in the DW_AT_byte_size attribute for this bit-field.
6491 (See `byte_size_attribute' above). */
6494 add_bit_offset_attribute (die
, decl
)
6495 register dw_die_ref die
;
6498 register unsigned object_offset_in_bytes
= field_byte_offset (decl
);
6499 register tree type
= DECL_BIT_FIELD_TYPE (decl
);
6500 register tree bitpos_tree
= DECL_FIELD_BITPOS (decl
);
6501 register unsigned bitpos_int
;
6502 register unsigned highest_order_object_bit_offset
;
6503 register unsigned highest_order_field_bit_offset
;
6504 register unsigned bit_offset
;
6506 assert (TREE_CODE (decl
) == FIELD_DECL
); /* Must be a field. */
6507 assert (type
); /* Must be a bit field. */
6509 /* We can't yet handle bit-fields whose offsets are variable, so if we
6510 encounter such things, just return without generating any attribute
6512 if (TREE_CODE (bitpos_tree
) != INTEGER_CST
)
6515 bitpos_int
= (unsigned) TREE_INT_CST_LOW (bitpos_tree
);
6517 /* Note that the bit offset is always the distance (in bits) from the
6518 highest-order bit of the "containing object" to the highest-order bit of
6519 the bit-field itself. Since the "high-order end" of any object or field
6520 is different on big-endian and little-endian machines, the computation
6521 below must take account of these differences. */
6522 highest_order_object_bit_offset
= object_offset_in_bytes
* BITS_PER_UNIT
;
6523 highest_order_field_bit_offset
= bitpos_int
;
6525 if (! BYTES_BIG_ENDIAN
)
6527 highest_order_field_bit_offset
6528 += (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl
));
6530 highest_order_object_bit_offset
+= simple_type_size_in_bits (type
);
6534 = (! BYTES_BIG_ENDIAN
6535 ? highest_order_object_bit_offset
- highest_order_field_bit_offset
6536 : highest_order_field_bit_offset
- highest_order_object_bit_offset
);
6538 add_AT_unsigned (die
, DW_AT_bit_offset
, bit_offset
);
6541 /* For a FIELD_DECL node which represents a bit field, output an attribute
6542 which specifies the length in bits of the given field. */
6545 add_bit_size_attribute (die
, decl
)
6546 register dw_die_ref die
;
6549 assert (TREE_CODE (decl
) == FIELD_DECL
); /* Must be a field. */
6550 assert (DECL_BIT_FIELD_TYPE (decl
)); /* Must be a bit field. */
6551 add_AT_unsigned (die
, DW_AT_bit_size
,
6552 (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl
)));
6555 /* If the compiled language is ANSI C, then add a 'prototyped'
6556 attribute, if arg types are given for the parameters of a function. */
6559 add_prototyped_attribute (die
, func_type
)
6560 register dw_die_ref die
;
6561 register tree func_type
;
6563 if (get_AT_unsigned (comp_unit_die
, DW_AT_language
) == DW_LANG_C89
6564 && TYPE_ARG_TYPES (func_type
) != NULL
)
6565 add_AT_flag (die
, DW_AT_prototyped
, 1);
6569 /* Add an 'abstract_origin' attribute below a given DIE. The DIE is found
6570 by looking in either the type declaration or object declaration
6574 add_abstract_origin_attribute (die
, origin
)
6575 register dw_die_ref die
;
6576 register tree origin
;
6578 dw_die_ref origin_die
= NULL
;
6579 if (TREE_CODE_CLASS (TREE_CODE (origin
)) == 'd')
6580 origin_die
= lookup_decl_die (origin
);
6581 else if (TREE_CODE_CLASS (TREE_CODE (origin
)) == 't')
6582 origin_die
= lookup_type_die (origin
);
6584 add_AT_die_ref (die
, DW_AT_abstract_origin
, origin_die
);
6587 /* We do not currently support the pure_virtual attribute. */
6590 add_pure_or_virtual_attribute (die
, func_decl
)
6591 register dw_die_ref die
;
6592 register tree func_decl
;
6594 if (DECL_VINDEX (func_decl
))
6596 add_AT_unsigned (die
, DW_AT_virtuality
, DW_VIRTUALITY_virtual
);
6597 add_AT_loc (die
, DW_AT_vtable_elem_location
,
6598 new_loc_descr (DW_OP_constu
,
6599 TREE_INT_CST_LOW (DECL_VINDEX (func_decl
)),
6602 /* GNU extension: Record what type this method came from originally. */
6603 if (debug_info_level
> DINFO_LEVEL_TERSE
)
6604 add_AT_die_ref (die
, DW_AT_containing_type
,
6605 lookup_type_die (DECL_CONTEXT (func_decl
)));
6609 /* Add source coordinate attributes for the given decl. */
6612 add_src_coords_attributes (die
, decl
)
6613 register dw_die_ref die
;
6616 register unsigned file_index
= lookup_filename (DECL_SOURCE_FILE (decl
));
6618 add_AT_unsigned (die
, DW_AT_decl_file
, file_index
);
6619 add_AT_unsigned (die
, DW_AT_decl_line
, DECL_SOURCE_LINE (decl
));
6622 /* Add an DW_AT_name attribute and source coordinate attribute for the
6623 given decl, but only if it actually has a name. */
6626 add_name_and_src_coords_attributes (die
, decl
)
6627 register dw_die_ref die
;
6630 register tree decl_name
;
6632 decl_name
= DECL_NAME (decl
);
6633 if (decl_name
!= NULL
&& IDENTIFIER_POINTER (decl_name
) != NULL
)
6635 add_name_attribute (die
, dwarf2_name (decl
, 0));
6636 add_src_coords_attributes (die
, decl
);
6637 if ((TREE_CODE (decl
) == FUNCTION_DECL
|| TREE_CODE (decl
) == VAR_DECL
)
6638 && DECL_ASSEMBLER_NAME (decl
) != DECL_NAME (decl
))
6639 add_AT_string (die
, DW_AT_MIPS_linkage_name
,
6640 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
6644 /* Push a new declaration scope. */
6647 push_decl_scope (scope
)
6650 /* Make room in the decl_scope_table, if necessary. */
6651 if (decl_scope_table_allocated
== decl_scope_depth
)
6653 decl_scope_table_allocated
+= DECL_SCOPE_TABLE_INCREMENT
;
6655 = (tree
*) xrealloc (decl_scope_table
,
6656 decl_scope_table_allocated
* sizeof (tree
));
6659 decl_scope_table
[decl_scope_depth
++] = scope
;
6662 /* Return the DIE for the scope the immediately contains this declaration. */
6665 scope_die_for (t
, context_die
)
6667 register dw_die_ref context_die
;
6669 register dw_die_ref scope_die
= NULL
;
6670 register tree containing_scope
;
6671 register unsigned long i
;
6673 /* Function-local tags and functions get stuck in limbo until they are
6674 fixed up by decls_for_scope. */
6675 if (context_die
== NULL
6676 && (TREE_CODE (t
) == FUNCTION_DECL
|| is_tagged_type (t
)))
6679 /* Walk back up the declaration tree looking for a place to define
6681 if (TREE_CODE_CLASS (TREE_CODE (t
)) == 't')
6682 containing_scope
= TYPE_CONTEXT (t
);
6683 else if (TREE_CODE (t
) == FUNCTION_DECL
&& DECL_VINDEX (t
))
6684 containing_scope
= decl_class_context (t
);
6686 containing_scope
= DECL_CONTEXT (t
);
6688 if (containing_scope
== NULL_TREE
)
6689 scope_die
= comp_unit_die
;
6692 for (i
= decl_scope_depth
, scope_die
= context_die
;
6693 i
> 0 && decl_scope_table
[i
- 1] != containing_scope
;
6694 scope_die
= scope_die
->die_parent
, --i
)
6699 assert (scope_die
== comp_unit_die
);
6700 assert (TREE_CODE_CLASS (TREE_CODE (containing_scope
)) == 't');
6701 if (debug_info_level
> DINFO_LEVEL_TERSE
)
6702 assert (TREE_ASM_WRITTEN (containing_scope
));
6709 /* Pop a declaration scope. */
6713 assert (decl_scope_depth
> 0);
6717 /* Many forms of DIEs require a "type description" attribute. This
6718 routine locates the proper "type descriptor" die for the type given
6719 by 'type', and adds an DW_AT_type attribute below the given die. */
6722 add_type_attribute (object_die
, type
, decl_const
, decl_volatile
, context_die
)
6723 register dw_die_ref object_die
;
6725 register int decl_const
;
6726 register int decl_volatile
;
6727 register dw_die_ref context_die
;
6729 register enum tree_code code
= TREE_CODE (type
);
6730 register dw_die_ref type_die
= NULL
;
6732 /* If this type is an unnamed subtype of an integral or floating-point
6733 type, use the inner type. */
6734 if ((code
== INTEGER_TYPE
|| code
== REAL_TYPE
)
6735 && TREE_TYPE (type
) != 0 && TYPE_NAME (type
) == 0)
6736 type
= TREE_TYPE (type
), code
= TREE_CODE (type
);
6738 if (code
== ERROR_MARK
)
6741 /* Handle a special case. For functions whose return type is void, we
6742 generate *no* type attribute. (Note that no object may have type
6743 `void', so this only applies to function return types). */
6744 if (code
== VOID_TYPE
)
6747 type_die
= modified_type_die (type
,
6748 decl_const
|| TYPE_READONLY (type
),
6749 decl_volatile
|| TYPE_VOLATILE (type
),
6751 if (type_die
!= NULL
)
6752 add_AT_die_ref (object_die
, DW_AT_type
, type_die
);
6755 /* Given a tree pointer to a struct, class, union, or enum type node, return
6756 a pointer to the (string) tag name for the given type, or zero if the type
6757 was declared without a tag. */
6763 register char *name
= 0;
6765 if (TYPE_NAME (type
) != 0)
6767 register tree t
= 0;
6769 /* Find the IDENTIFIER_NODE for the type name. */
6770 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
6771 t
= TYPE_NAME (type
);
6773 /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
6774 a TYPE_DECL node, regardless of whether or not a `typedef' was
6776 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
6777 && ! DECL_IGNORED_P (TYPE_NAME (type
)))
6778 t
= DECL_NAME (TYPE_NAME (type
));
6780 /* Now get the name as a string, or invent one. */
6782 name
= IDENTIFIER_POINTER (t
);
6785 return (name
== 0 || *name
== '\0') ? 0 : name
;
6788 /* Return the type associated with a data member, make a special check
6789 for bit field types. */
6792 member_declared_type (member
)
6793 register tree member
;
6795 return (DECL_BIT_FIELD_TYPE (member
)
6796 ? DECL_BIT_FIELD_TYPE (member
)
6797 : TREE_TYPE (member
));
6800 /* Get the decl's label, as described by its RTL. This may be different
6801 from the DECL_NAME name used in the source file. */
6804 decl_start_label (decl
)
6809 x
= DECL_RTL (decl
);
6810 if (GET_CODE (x
) != MEM
)
6814 if (GET_CODE (x
) != SYMBOL_REF
)
6817 fnname
= XSTR (x
, 0);
6821 /* These routines generate the internnal representation of the DIE's for
6822 the compilation unit. Debugging information is collected by walking
6823 the declaration trees passed in from dwarf2out_decl(). */
6826 gen_array_type_die (type
, context_die
)
6828 register dw_die_ref context_die
;
6830 register dw_die_ref scope_die
= scope_die_for (type
, context_die
);
6831 register dw_die_ref array_die
;
6832 register tree element_type
;
6834 /* ??? The SGI dwarf reader fails for array of array of enum types unless
6835 the inner array type comes before the outer array type. Thus we must
6836 call gen_type_die before we call new_die. See below also. */
6837 #ifdef MIPS_DEBUGGING_INFO
6838 gen_type_die (TREE_TYPE (type
), context_die
);
6841 array_die
= new_die (DW_TAG_array_type
, scope_die
);
6844 /* We default the array ordering. SDB will probably do
6845 the right things even if DW_AT_ordering is not present. It's not even
6846 an issue until we start to get into multidimensional arrays anyway. If
6847 SDB is ever caught doing the Wrong Thing for multi-dimensional arrays,
6848 then we'll have to put the DW_AT_ordering attribute back in. (But if
6849 and when we find out that we need to put these in, we will only do so
6850 for multidimensional arrays. */
6851 add_AT_unsigned (array_die
, DW_AT_ordering
, DW_ORD_row_major
);
6854 #ifdef MIPS_DEBUGGING_INFO
6855 /* The SGI compilers handle arrays of unknown bound by setting
6856 AT_declaration and not emitting any subrange DIEs. */
6857 if (! TYPE_DOMAIN (type
))
6858 add_AT_unsigned (array_die
, DW_AT_declaration
, 1);
6861 add_subscript_info (array_die
, type
);
6863 equate_type_number_to_die (type
, array_die
);
6865 /* Add representation of the type of the elements of this array type. */
6866 element_type
= TREE_TYPE (type
);
6868 /* ??? The SGI dwarf reader fails for multidimensional arrays with a
6869 const enum type. E.g. const enum machine_mode insn_operand_mode[2][10].
6870 We work around this by disabling this feature. See also
6871 add_subscript_info. */
6872 #ifndef MIPS_DEBUGGING_INFO
6873 while (TREE_CODE (element_type
) == ARRAY_TYPE
)
6874 element_type
= TREE_TYPE (element_type
);
6876 gen_type_die (element_type
, context_die
);
6879 add_type_attribute (array_die
, element_type
, 0, 0, context_die
);
6883 gen_set_type_die (type
, context_die
)
6885 register dw_die_ref context_die
;
6887 register dw_die_ref type_die
6888 = new_die (DW_TAG_set_type
, scope_die_for (type
, context_die
));
6890 equate_type_number_to_die (type
, type_die
);
6891 add_type_attribute (type_die
, TREE_TYPE (type
), 0, 0, context_die
);
6895 gen_entry_point_die (decl
, context_die
)
6897 register dw_die_ref context_die
;
6899 register tree origin
= decl_ultimate_origin (decl
);
6900 register dw_die_ref decl_die
= new_die (DW_TAG_entry_point
, context_die
);
6902 add_abstract_origin_attribute (decl_die
, origin
);
6905 add_name_and_src_coords_attributes (decl_die
, decl
);
6906 add_type_attribute (decl_die
, TREE_TYPE (TREE_TYPE (decl
)),
6910 if (DECL_ABSTRACT (decl
))
6911 equate_decl_number_to_die (decl
, decl_die
);
6913 add_AT_lbl_id (decl_die
, DW_AT_low_pc
, decl_start_label (decl
));
6916 /* Remember a type in the pending_types_list. */
6922 if (pending_types
== pending_types_allocated
)
6924 pending_types_allocated
+= PENDING_TYPES_INCREMENT
;
6926 = (tree
*) xrealloc (pending_types_list
,
6927 sizeof (tree
) * pending_types_allocated
);
6930 pending_types_list
[pending_types
++] = type
;
6933 /* Output any pending types (from the pending_types list) which we can output
6934 now (taking into account the scope that we are working on now).
6936 For each type output, remove the given type from the pending_types_list
6937 *before* we try to output it. */
6940 output_pending_types_for_scope (context_die
)
6941 register dw_die_ref context_die
;
6945 while (pending_types
)
6948 type
= pending_types_list
[pending_types
];
6949 gen_type_die (type
, context_die
);
6950 assert (TREE_ASM_WRITTEN (type
));
6954 /* Generate a DIE to represent an inlined instance of an enumeration type. */
6957 gen_inlined_enumeration_type_die (type
, context_die
)
6959 register dw_die_ref context_die
;
6961 register dw_die_ref type_die
= new_die (DW_TAG_enumeration_type
,
6962 scope_die_for (type
, context_die
));
6964 assert (TREE_ASM_WRITTEN (type
));
6965 add_abstract_origin_attribute (type_die
, type
);
6968 /* Generate a DIE to represent an inlined instance of a structure type. */
6971 gen_inlined_structure_type_die (type
, context_die
)
6973 register dw_die_ref context_die
;
6975 register dw_die_ref type_die
= new_die (DW_TAG_structure_type
,
6976 scope_die_for (type
, context_die
));
6978 assert (TREE_ASM_WRITTEN (type
));
6979 add_abstract_origin_attribute (type_die
, type
);
6982 /* Generate a DIE to represent an inlined instance of a union type. */
6985 gen_inlined_union_type_die (type
, context_die
)
6987 register dw_die_ref context_die
;
6989 register dw_die_ref type_die
= new_die (DW_TAG_union_type
,
6990 scope_die_for (type
, context_die
));
6992 assert (TREE_ASM_WRITTEN (type
));
6993 add_abstract_origin_attribute (type_die
, type
);
6996 /* Generate a DIE to represent an enumeration type. Note that these DIEs
6997 include all of the information about the enumeration values also. Each
6998 enumerated type name/value is listed as a child of the enumerated type
7002 gen_enumeration_type_die (type
, context_die
)
7004 register dw_die_ref context_die
;
7006 register dw_die_ref type_die
= lookup_type_die (type
);
7008 if (type_die
== NULL
)
7010 type_die
= new_die (DW_TAG_enumeration_type
,
7011 scope_die_for (type
, context_die
));
7012 equate_type_number_to_die (type
, type_die
);
7013 add_name_attribute (type_die
, type_tag (type
));
7015 else if (! TYPE_SIZE (type
))
7018 remove_AT (type_die
, DW_AT_declaration
);
7020 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
7021 given enum type is incomplete, do not generate the DW_AT_byte_size
7022 attribute or the DW_AT_element_list attribute. */
7023 if (TYPE_SIZE (type
))
7027 TREE_ASM_WRITTEN (type
) = 1;
7028 add_byte_size_attribute (type_die
, type
);
7029 if (type_tag (type
))
7030 add_src_coords_attributes (type_die
, TYPE_STUB_DECL (type
));
7032 for (link
= TYPE_FIELDS (type
);
7033 link
!= NULL
; link
= TREE_CHAIN (link
))
7035 register dw_die_ref enum_die
= new_die (DW_TAG_enumerator
, type_die
);
7037 add_name_attribute (enum_die
,
7038 IDENTIFIER_POINTER (TREE_PURPOSE (link
)));
7039 add_AT_unsigned (enum_die
, DW_AT_const_value
,
7040 (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link
)));
7044 add_AT_flag (type_die
, DW_AT_declaration
, 1);
7048 /* Generate a DIE to represent either a real live formal parameter decl or to
7049 represent just the type of some formal parameter position in some function
7052 Note that this routine is a bit unusual because its argument may be a
7053 ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
7054 represents an inlining of some PARM_DECL) or else some sort of a ..._TYPE
7055 node. If it's the former then this function is being called to output a
7056 DIE to represent a formal parameter object (or some inlining thereof). If
7057 it's the latter, then this function is only being called to output a
7058 DW_TAG_formal_parameter DIE to stand as a placeholder for some formal
7059 argument type of some subprogram type. */
7062 gen_formal_parameter_die (node
, context_die
)
7064 register dw_die_ref context_die
;
7066 register dw_die_ref parm_die
7067 = new_die (DW_TAG_formal_parameter
, context_die
);
7068 register tree origin
;
7070 switch (TREE_CODE_CLASS (TREE_CODE (node
)))
7073 origin
= decl_ultimate_origin (node
);
7075 add_abstract_origin_attribute (parm_die
, origin
);
7078 add_name_and_src_coords_attributes (parm_die
, node
);
7079 add_type_attribute (parm_die
, TREE_TYPE (node
),
7080 TREE_READONLY (node
),
7081 TREE_THIS_VOLATILE (node
),
7083 if (DECL_ARTIFICIAL (node
))
7084 add_AT_flag (parm_die
, DW_AT_artificial
, 1);
7087 equate_decl_number_to_die (node
, parm_die
);
7088 if (! DECL_ABSTRACT (node
))
7089 add_location_or_const_value_attribute (parm_die
, node
);
7094 /* We were called with some kind of a ..._TYPE node. */
7095 add_type_attribute (parm_die
, node
, 0, 0, context_die
);
7105 /* Generate a special type of DIE used as a stand-in for a trailing ellipsis
7106 at the end of an (ANSI prototyped) formal parameters list. */
7109 gen_unspecified_parameters_die (decl_or_type
, context_die
)
7110 register tree decl_or_type
;
7111 register dw_die_ref context_die
;
7113 register dw_die_ref parm_die
= new_die (DW_TAG_unspecified_parameters
,
7117 /* Generate a list of nameless DW_TAG_formal_parameter DIEs (and perhaps a
7118 DW_TAG_unspecified_parameters DIE) to represent the types of the formal
7119 parameters as specified in some function type specification (except for
7120 those which appear as part of a function *definition*).
7122 Note we must be careful here to output all of the parameter DIEs before*
7123 we output any DIEs needed to represent the types of the formal parameters.
7124 This keeps svr4 SDB happy because it (incorrectly) thinks that the first
7125 non-parameter DIE it sees ends the formal parameter list. */
7128 gen_formal_types_die (function_or_method_type
, context_die
)
7129 register tree function_or_method_type
;
7130 register dw_die_ref context_die
;
7133 register tree formal_type
= NULL
;
7134 register tree first_parm_type
= TYPE_ARG_TYPES (function_or_method_type
);
7137 /* In the case where we are generating a formal types list for a C++
7138 non-static member function type, skip over the first thing on the
7139 TYPE_ARG_TYPES list because it only represents the type of the hidden
7140 `this pointer'. The debugger should be able to figure out (without
7141 being explicitly told) that this non-static member function type takes a
7142 `this pointer' and should be able to figure what the type of that hidden
7143 parameter is from the DW_AT_member attribute of the parent
7144 DW_TAG_subroutine_type DIE. */
7145 if (TREE_CODE (function_or_method_type
) == METHOD_TYPE
)
7146 first_parm_type
= TREE_CHAIN (first_parm_type
);
7149 /* Make our first pass over the list of formal parameter types and output a
7150 DW_TAG_formal_parameter DIE for each one. */
7151 for (link
= first_parm_type
; link
; link
= TREE_CHAIN (link
))
7153 register dw_die_ref parm_die
;
7155 formal_type
= TREE_VALUE (link
);
7156 if (formal_type
== void_type_node
)
7159 /* Output a (nameless) DIE to represent the formal parameter itself. */
7160 parm_die
= gen_formal_parameter_die (formal_type
, context_die
);
7161 if (TREE_CODE (function_or_method_type
) == METHOD_TYPE
7162 && link
== first_parm_type
)
7163 add_AT_flag (parm_die
, DW_AT_artificial
, 1);
7166 /* If this function type has an ellipsis, add a
7167 DW_TAG_unspecified_parameters DIE to the end of the parameter list. */
7168 if (formal_type
!= void_type_node
)
7169 gen_unspecified_parameters_die (function_or_method_type
, context_die
);
7171 /* Make our second (and final) pass over the list of formal parameter types
7172 and output DIEs to represent those types (as necessary). */
7173 for (link
= TYPE_ARG_TYPES (function_or_method_type
);
7175 link
= TREE_CHAIN (link
))
7177 formal_type
= TREE_VALUE (link
);
7178 if (formal_type
== void_type_node
)
7181 gen_type_die (formal_type
, context_die
);
7185 /* Generate a DIE to represent a declared function (either file-scope or
7189 gen_subprogram_die (decl
, context_die
)
7191 register dw_die_ref context_die
;
7193 char label_id
[MAX_ARTIFICIAL_LABEL_BYTES
];
7194 register tree origin
= decl_ultimate_origin (decl
);
7195 register dw_die_ref subr_die
;
7196 register dw_loc_descr_ref fp_loc
= NULL
;
7197 register rtx fp_reg
;
7198 register tree fn_arg_types
;
7199 register tree outer_scope
;
7200 register dw_die_ref old_die
= lookup_decl_die (decl
);
7201 register int declaration
= (current_function_decl
!= decl
7202 || context_die
->die_tag
== DW_TAG_structure_type
7203 || context_die
->die_tag
== DW_TAG_union_type
);
7207 subr_die
= new_die (DW_TAG_subprogram
, context_die
);
7208 add_abstract_origin_attribute (subr_die
, origin
);
7212 register unsigned file_index
7213 = lookup_filename (DECL_SOURCE_FILE (decl
));
7215 assert (get_AT_flag (old_die
, DW_AT_declaration
) == 1);
7217 /* If the definition comes from the same place as the declaration,
7218 maybe use the old DIE. We always want the DIE for this function
7219 that has the *_pc attributes to be under comp_unit_die so the
7220 debugger can find it. For inlines, that is the concrete instance,
7221 so we can use the old DIE here. For non-inline methods, we want a
7222 specification DIE at toplevel, so we need a new DIE. For local
7223 class methods, this does not apply. */
7224 if ((DECL_ABSTRACT (decl
) || old_die
->die_parent
== comp_unit_die
7225 || context_die
== NULL
)
7226 && get_AT_unsigned (old_die
, DW_AT_decl_file
) == file_index
7227 && (get_AT_unsigned (old_die
, DW_AT_decl_line
)
7228 == DECL_SOURCE_LINE (decl
)))
7232 /* Clear out the declaration attribute and the parm types. */
7233 remove_AT (subr_die
, DW_AT_declaration
);
7234 remove_children (subr_die
);
7238 subr_die
= new_die (DW_TAG_subprogram
, context_die
);
7239 add_AT_die_ref (subr_die
, DW_AT_specification
, old_die
);
7240 if (get_AT_unsigned (old_die
, DW_AT_decl_file
) != file_index
)
7241 add_AT_unsigned (subr_die
, DW_AT_decl_file
, file_index
);
7242 if (get_AT_unsigned (old_die
, DW_AT_decl_line
)
7243 != DECL_SOURCE_LINE (decl
))
7245 (subr_die
, DW_AT_decl_line
, DECL_SOURCE_LINE (decl
));
7250 register dw_die_ref scope_die
;
7252 if (DECL_CONTEXT (decl
))
7253 scope_die
= scope_die_for (decl
, context_die
);
7255 /* Don't put block extern declarations under comp_unit_die. */
7256 scope_die
= context_die
;
7258 subr_die
= new_die (DW_TAG_subprogram
, scope_die
);
7260 if (TREE_PUBLIC (decl
))
7261 add_AT_flag (subr_die
, DW_AT_external
, 1);
7263 add_name_and_src_coords_attributes (subr_die
, decl
);
7264 if (debug_info_level
> DINFO_LEVEL_TERSE
)
7266 register tree type
= TREE_TYPE (decl
);
7268 add_prototyped_attribute (subr_die
, type
);
7269 add_type_attribute (subr_die
, TREE_TYPE (type
), 0, 0, context_die
);
7272 add_pure_or_virtual_attribute (subr_die
, decl
);
7273 if (DECL_ARTIFICIAL (decl
))
7274 add_AT_flag (subr_die
, DW_AT_artificial
, 1);
7275 if (TREE_PROTECTED (decl
))
7276 add_AT_unsigned (subr_die
, DW_AT_accessibility
, DW_ACCESS_protected
);
7277 else if (TREE_PRIVATE (decl
))
7278 add_AT_unsigned (subr_die
, DW_AT_accessibility
, DW_ACCESS_private
);
7283 add_AT_flag (subr_die
, DW_AT_declaration
, 1);
7285 /* The first time we see a member function, it is in the context of
7286 the class to which it belongs. We make sure of this by emitting
7287 the class first. The next time is the definition, which is
7288 handled above. The two may come from the same source text. */
7289 if (decl_class_context (decl
))
7290 equate_decl_number_to_die (decl
, subr_die
);
7292 else if (DECL_ABSTRACT (decl
))
7294 if (DECL_DEFER_OUTPUT (decl
))
7296 if (DECL_INLINE (decl
))
7297 add_AT_unsigned (subr_die
, DW_AT_inline
, DW_INL_declared_inlined
);
7299 add_AT_unsigned (subr_die
, DW_AT_inline
,
7300 DW_INL_declared_not_inlined
);
7302 else if (DECL_INLINE (decl
))
7303 add_AT_unsigned (subr_die
, DW_AT_inline
, DW_INL_inlined
);
7304 else if (declaration
)
7305 /* Block extern declaration in an inline function. */
7306 add_AT_flag (subr_die
, DW_AT_declaration
, 1);
7310 equate_decl_number_to_die (decl
, subr_die
);
7312 else if (!DECL_EXTERNAL (decl
))
7314 if (origin
== NULL_TREE
)
7315 equate_decl_number_to_die (decl
, subr_die
);
7317 ASM_GENERATE_INTERNAL_LABEL (label_id
, FUNC_BEGIN_LABEL
,
7318 current_funcdef_number
);
7319 add_AT_lbl_id (subr_die
, DW_AT_low_pc
, label_id
);
7320 ASM_GENERATE_INTERNAL_LABEL (label_id
, FUNC_END_LABEL
,
7321 current_funcdef_number
);
7322 add_AT_lbl_id (subr_die
, DW_AT_high_pc
, label_id
);
7324 add_pubname (decl
, subr_die
);
7325 add_arange (decl
, subr_die
);
7327 #ifdef MIPS_DEBUGGING_INFO
7328 /* Add a reference to the FDE for this routine. */
7329 add_AT_fde_ref (subr_die
, DW_AT_MIPS_fde
, current_funcdef_fde
);
7332 /* Define the "frame base" location for this routine. We use the
7333 frame pointer or stack pointer registers, since the RTL for local
7334 variables is relative to one of them. */
7336 = frame_pointer_needed
? hard_frame_pointer_rtx
: stack_pointer_rtx
;
7337 add_AT_loc (subr_die
, DW_AT_frame_base
, reg_loc_descriptor (fp_reg
));
7339 if (current_function_needs_context
)
7340 add_AT_loc (subr_die
, DW_AT_static_link
,
7341 loc_descriptor (lookup_static_chain (decl
)));
7344 /* Now output descriptions of the arguments for this function. This gets
7345 (unnecessarily?) complex because of the fact that the DECL_ARGUMENT list
7346 for a FUNCTION_DECL doesn't indicate cases where there was a trailing
7347 `...' at the end of the formal parameter list. In order to find out if
7348 there was a trailing ellipsis or not, we must instead look at the type
7349 associated with the FUNCTION_DECL. This will be a node of type
7350 FUNCTION_TYPE. If the chain of type nodes hanging off of this
7351 FUNCTION_TYPE node ends with a void_type_node then there should *not* be
7352 an ellipsis at the end. */
7353 push_decl_scope (decl
);
7355 /* In the case where we are describing a mere function declaration, all we
7356 need to do here (and all we *can* do here) is to describe the *types* of
7357 its formal parameters. */
7358 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
7360 else if (declaration
)
7361 gen_formal_types_die (TREE_TYPE (decl
), subr_die
);
7364 /* Generate DIEs to represent all known formal parameters */
7365 register tree arg_decls
= DECL_ARGUMENTS (decl
);
7368 /* When generating DIEs, generate the unspecified_parameters DIE
7369 instead if we come across the arg "__builtin_va_alist" */
7370 for (parm
= arg_decls
; parm
; parm
= TREE_CHAIN (parm
))
7371 if (TREE_CODE (parm
) == PARM_DECL
)
7373 if (DECL_NAME (parm
) &&
7374 !strcmp (IDENTIFIER_POINTER (DECL_NAME (parm
)),
7375 "__builtin_va_alist"))
7376 gen_unspecified_parameters_die (parm
, subr_die
);
7378 gen_decl_die (parm
, subr_die
);
7381 /* Decide whether we need a unspecified_parameters DIE at the end.
7382 There are 2 more cases to do this for: 1) the ansi ... declaration -
7383 this is detectable when the end of the arg list is not a
7384 void_type_node 2) an unprototyped function declaration (not a
7385 definition). This just means that we have no info about the
7386 parameters at all. */
7387 fn_arg_types
= TYPE_ARG_TYPES (TREE_TYPE (decl
));
7388 if (fn_arg_types
!= NULL
)
7390 /* this is the prototyped case, check for ... */
7391 if (TREE_VALUE (tree_last (fn_arg_types
)) != void_type_node
)
7392 gen_unspecified_parameters_die (decl
, subr_die
);
7394 else if (DECL_INITIAL (decl
) == NULL_TREE
)
7395 gen_unspecified_parameters_die (decl
, subr_die
);
7398 /* Output Dwarf info for all of the stuff within the body of the function
7399 (if it has one - it may be just a declaration). */
7400 outer_scope
= DECL_INITIAL (decl
);
7402 /* Note that here, `outer_scope' is a pointer to the outermost BLOCK
7403 node created to represent a function. This outermost BLOCK actually
7404 represents the outermost binding contour for the function, i.e. the
7405 contour in which the function's formal parameters and labels get
7406 declared. Curiously, it appears that the front end doesn't actually
7407 put the PARM_DECL nodes for the current function onto the BLOCK_VARS
7408 list for this outer scope. (They are strung off of the DECL_ARGUMENTS
7409 list for the function instead.) The BLOCK_VARS list for the
7410 `outer_scope' does provide us with a list of the LABEL_DECL nodes for
7411 the function however, and we output DWARF info for those in
7412 decls_for_scope. Just within the `outer_scope' there will be a BLOCK
7413 node representing the function's outermost pair of curly braces, and
7414 any blocks used for the base and member initializers of a C++
7415 constructor function. */
7416 if (! declaration
&& TREE_CODE (outer_scope
) != ERROR_MARK
)
7418 current_function_has_inlines
= 0;
7419 decls_for_scope (outer_scope
, subr_die
, 0);
7421 #if 0 && defined (MIPS_DEBUGGING_INFO)
7422 if (current_function_has_inlines
)
7424 add_AT_flag (subr_die
, DW_AT_MIPS_has_inlines
, 1);
7425 if (! comp_unit_has_inlines
)
7427 add_AT_flag (comp_unit_die
, DW_AT_MIPS_has_inlines
, 1);
7428 comp_unit_has_inlines
= 1;
7437 /* Generate a DIE to represent a declared data object. */
7440 gen_variable_die (decl
, context_die
)
7442 register dw_die_ref context_die
;
7444 register tree origin
= decl_ultimate_origin (decl
);
7445 register dw_die_ref var_die
= new_die (DW_TAG_variable
, context_die
);
7447 dw_die_ref old_die
= lookup_decl_die (decl
);
7449 = (DECL_EXTERNAL (decl
)
7450 || current_function_decl
!= decl_function_context (decl
)
7451 || context_die
->die_tag
== DW_TAG_structure_type
7452 || context_die
->die_tag
== DW_TAG_union_type
);
7455 add_abstract_origin_attribute (var_die
, origin
);
7456 /* Loop unrolling can create multiple blocks that refer to the same
7457 static variable, so we must test for the DW_AT_declaration flag. */
7458 /* ??? Loop unrolling/reorder_blocks should perhaps be rewritten to
7459 copy decls and set the DECL_ABSTRACT flag on them instead of
7461 else if (old_die
&& TREE_STATIC (decl
)
7462 && get_AT_flag (old_die
, DW_AT_declaration
) == 1)
7464 /* ??? This is an instantiation of a C++ class level static. */
7465 add_AT_die_ref (var_die
, DW_AT_specification
, old_die
);
7466 if (DECL_NAME (decl
))
7468 register unsigned file_index
7469 = lookup_filename (DECL_SOURCE_FILE (decl
));
7471 if (get_AT_unsigned (old_die
, DW_AT_decl_file
) != file_index
)
7472 add_AT_unsigned (var_die
, DW_AT_decl_file
, file_index
);
7474 if (get_AT_unsigned (old_die
, DW_AT_decl_line
)
7475 != DECL_SOURCE_LINE (decl
))
7477 add_AT_unsigned (var_die
, DW_AT_decl_line
,
7478 DECL_SOURCE_LINE (decl
));
7483 add_name_and_src_coords_attributes (var_die
, decl
);
7484 add_type_attribute (var_die
, TREE_TYPE (decl
),
7485 TREE_READONLY (decl
),
7486 TREE_THIS_VOLATILE (decl
), context_die
);
7488 if (TREE_PUBLIC (decl
))
7489 add_AT_flag (var_die
, DW_AT_external
, 1);
7491 if (DECL_ARTIFICIAL (decl
))
7492 add_AT_flag (var_die
, DW_AT_artificial
, 1);
7494 if (TREE_PROTECTED (decl
))
7495 add_AT_unsigned (var_die
, DW_AT_accessibility
, DW_ACCESS_protected
);
7497 else if (TREE_PRIVATE (decl
))
7498 add_AT_unsigned (var_die
, DW_AT_accessibility
, DW_ACCESS_private
);
7502 add_AT_flag (var_die
, DW_AT_declaration
, 1);
7504 if ((declaration
&& decl_class_context (decl
)) || DECL_ABSTRACT (decl
))
7505 equate_decl_number_to_die (decl
, var_die
);
7507 if (! declaration
&& ! DECL_ABSTRACT (decl
))
7509 equate_decl_number_to_die (decl
, var_die
);
7510 add_location_or_const_value_attribute (var_die
, decl
);
7511 add_pubname (decl
, var_die
);
7515 /* Generate a DIE to represent a label identifier. */
7518 gen_label_die (decl
, context_die
)
7520 register dw_die_ref context_die
;
7522 register tree origin
= decl_ultimate_origin (decl
);
7523 register dw_die_ref lbl_die
= new_die (DW_TAG_label
, context_die
);
7525 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
7526 char label2
[MAX_ARTIFICIAL_LABEL_BYTES
];
7529 add_abstract_origin_attribute (lbl_die
, origin
);
7531 add_name_and_src_coords_attributes (lbl_die
, decl
);
7533 if (DECL_ABSTRACT (decl
))
7534 equate_decl_number_to_die (decl
, lbl_die
);
7537 insn
= DECL_RTL (decl
);
7538 if (GET_CODE (insn
) == CODE_LABEL
)
7540 /* When optimization is enabled (via -O) some parts of the compiler
7541 (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
7542 represent source-level labels which were explicitly declared by
7543 the user. This really shouldn't be happening though, so catch
7544 it if it ever does happen. */
7545 if (INSN_DELETED_P (insn
))
7548 sprintf (label2
, INSN_LABEL_FMT
, current_funcdef_number
);
7549 ASM_GENERATE_INTERNAL_LABEL (label
, label2
,
7550 (unsigned) INSN_UID (insn
));
7551 add_AT_lbl_id (lbl_die
, DW_AT_low_pc
, label
);
7556 /* Generate a DIE for a lexical block. */
7559 gen_lexical_block_die (stmt
, context_die
, depth
)
7561 register dw_die_ref context_die
;
7564 register dw_die_ref stmt_die
= new_die (DW_TAG_lexical_block
, context_die
);
7565 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
7567 if (! BLOCK_ABSTRACT (stmt
))
7569 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_BEGIN_LABEL
,
7571 add_AT_lbl_id (stmt_die
, DW_AT_low_pc
, label
);
7572 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_END_LABEL
, next_block_number
);
7573 add_AT_lbl_id (stmt_die
, DW_AT_high_pc
, label
);
7576 push_decl_scope (stmt
);
7577 decls_for_scope (stmt
, stmt_die
, depth
);
7581 /* Generate a DIE for an inlined subprogram. */
7584 gen_inlined_subroutine_die (stmt
, context_die
, depth
)
7586 register dw_die_ref context_die
;
7589 if (! BLOCK_ABSTRACT (stmt
))
7591 register dw_die_ref subr_die
7592 = new_die (DW_TAG_inlined_subroutine
, context_die
);
7593 register tree decl
= block_ultimate_origin (stmt
);
7594 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
7596 add_abstract_origin_attribute (subr_die
, decl
);
7597 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_BEGIN_LABEL
,
7599 add_AT_lbl_id (subr_die
, DW_AT_low_pc
, label
);
7600 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_END_LABEL
, next_block_number
);
7601 add_AT_lbl_id (subr_die
, DW_AT_high_pc
, label
);
7602 push_decl_scope (decl
);
7603 decls_for_scope (stmt
, subr_die
, depth
);
7605 current_function_has_inlines
= 1;
7609 /* Generate a DIE for a field in a record, or structure. */
7612 gen_field_die (decl
, context_die
)
7614 register dw_die_ref context_die
;
7616 register dw_die_ref decl_die
= new_die (DW_TAG_member
, context_die
);
7618 add_name_and_src_coords_attributes (decl_die
, decl
);
7619 add_type_attribute (decl_die
, member_declared_type (decl
),
7620 TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
),
7623 /* If this is a bit field... */
7624 if (DECL_BIT_FIELD_TYPE (decl
))
7626 add_byte_size_attribute (decl_die
, decl
);
7627 add_bit_size_attribute (decl_die
, decl
);
7628 add_bit_offset_attribute (decl_die
, decl
);
7631 if (TREE_CODE (DECL_FIELD_CONTEXT (decl
)) != UNION_TYPE
)
7632 add_data_member_location_attribute (decl_die
, decl
);
7634 if (DECL_ARTIFICIAL (decl
))
7635 add_AT_flag (decl_die
, DW_AT_artificial
, 1);
7637 if (TREE_PROTECTED (decl
))
7638 add_AT_unsigned (decl_die
, DW_AT_accessibility
, DW_ACCESS_protected
);
7640 else if (TREE_PRIVATE (decl
))
7641 add_AT_unsigned (decl_die
, DW_AT_accessibility
, DW_ACCESS_private
);
7645 /* Don't generate either pointer_type DIEs or reference_type DIEs here.
7646 Use modified_type_die instead.
7647 We keep this code here just in case these types of DIEs may be needed to
7648 represent certain things in other languages (e.g. Pascal) someday. */
7650 gen_pointer_type_die (type
, context_die
)
7652 register dw_die_ref context_die
;
7654 register dw_die_ref ptr_die
7655 = new_die (DW_TAG_pointer_type
, scope_die_for (type
, context_die
));
7657 equate_type_number_to_die (type
, ptr_die
);
7658 add_type_attribute (ptr_die
, TREE_TYPE (type
), 0, 0, context_die
);
7659 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
7662 /* Don't generate either pointer_type DIEs or reference_type DIEs here.
7663 Use modified_type_die instead.
7664 We keep this code here just in case these types of DIEs may be needed to
7665 represent certain things in other languages (e.g. Pascal) someday. */
7667 gen_reference_type_die (type
, context_die
)
7669 register dw_die_ref context_die
;
7671 register dw_die_ref ref_die
7672 = new_die (DW_TAG_reference_type
, scope_die_for (type
, context_die
));
7674 equate_type_number_to_die (type
, ref_die
);
7675 add_type_attribute (ref_die
, TREE_TYPE (type
), 0, 0, context_die
);
7676 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
7680 /* Generate a DIE for a pointer to a member type. */
7682 gen_ptr_to_mbr_type_die (type
, context_die
)
7684 register dw_die_ref context_die
;
7686 register dw_die_ref ptr_die
7687 = new_die (DW_TAG_ptr_to_member_type
, scope_die_for (type
, context_die
));
7689 equate_type_number_to_die (type
, ptr_die
);
7690 add_AT_die_ref (ptr_die
, DW_AT_containing_type
,
7691 lookup_type_die (TYPE_OFFSET_BASETYPE (type
)));
7692 add_type_attribute (ptr_die
, TREE_TYPE (type
), 0, 0, context_die
);
7695 /* Generate the DIE for the compilation unit. */
7698 gen_compile_unit_die (main_input_filename
)
7699 register char *main_input_filename
;
7702 char *wd
= getpwd ();
7704 comp_unit_die
= new_die (DW_TAG_compile_unit
, NULL
);
7705 add_name_attribute (comp_unit_die
, main_input_filename
);
7708 add_AT_string (comp_unit_die
, DW_AT_comp_dir
, wd
);
7710 sprintf (producer
, "%s %s", language_string
, version_string
);
7712 #ifdef MIPS_DEBUGGING_INFO
7713 /* The MIPS/SGI compilers place the 'cc' command line options in the producer
7714 string. The SGI debugger looks for -g, -g1, -g2, or -g3; if they do
7715 not appear in the producer string, the debugger reaches the conclusion
7716 that the object file is stripped and has no debugging information.
7717 To get the MIPS/SGI debugger to believe that there is debugging
7718 information in the object file, we add a -g to the producer string. */
7719 if (debug_info_level
> DINFO_LEVEL_TERSE
)
7720 strcat (producer
, " -g");
7723 add_AT_string (comp_unit_die
, DW_AT_producer
, producer
);
7725 if (strcmp (language_string
, "GNU C++") == 0)
7726 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_C_plus_plus
);
7728 else if (strcmp (language_string
, "GNU Ada") == 0)
7729 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_Ada83
);
7731 else if (strcmp (language_string
, "GNU F77") == 0)
7732 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_Fortran77
);
7734 else if (flag_traditional
)
7735 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_C
);
7738 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_C89
);
7740 #if 0 /* unimplemented */
7741 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
7742 add_AT_unsigned (comp_unit_die
, DW_AT_macro_info
, 0);
7746 /* Generate a DIE for a string type. */
7749 gen_string_type_die (type
, context_die
)
7751 register dw_die_ref context_die
;
7753 register dw_die_ref type_die
7754 = new_die (DW_TAG_string_type
, scope_die_for (type
, context_die
));
7756 equate_type_number_to_die (type
, type_die
);
7758 /* Fudge the string length attribute for now. */
7760 /* TODO: add string length info.
7761 string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
7762 bound_representation (upper_bound, 0, 'u'); */
7765 /* Generate the DIE for a base class. */
7768 gen_inheritance_die (binfo
, context_die
)
7769 register tree binfo
;
7770 register dw_die_ref context_die
;
7772 dw_die_ref die
= new_die (DW_TAG_inheritance
, context_die
);
7774 add_type_attribute (die
, BINFO_TYPE (binfo
), 0, 0, context_die
);
7775 add_data_member_location_attribute (die
, binfo
);
7777 if (TREE_VIA_VIRTUAL (binfo
))
7778 add_AT_unsigned (die
, DW_AT_virtuality
, DW_VIRTUALITY_virtual
);
7779 if (TREE_VIA_PUBLIC (binfo
))
7780 add_AT_unsigned (die
, DW_AT_accessibility
, DW_ACCESS_public
);
7781 else if (TREE_VIA_PROTECTED (binfo
))
7782 add_AT_unsigned (die
, DW_AT_accessibility
, DW_ACCESS_protected
);
7785 /* Genearate a DIE for a class member. */
7788 gen_member_die (type
, context_die
)
7790 register dw_die_ref context_die
;
7792 register tree member
;
7794 /* If this is not an incomplete type, output descriptions of each of its
7795 members. Note that as we output the DIEs necessary to represent the
7796 members of this record or union type, we will also be trying to output
7797 DIEs to represent the *types* of those members. However the `type'
7798 function (above) will specifically avoid generating type DIEs for member
7799 types *within* the list of member DIEs for this (containing) type execpt
7800 for those types (of members) which are explicitly marked as also being
7801 members of this (containing) type themselves. The g++ front- end can
7802 force any given type to be treated as a member of some other
7803 (containing) type by setting the TYPE_CONTEXT of the given (member) type
7804 to point to the TREE node representing the appropriate (containing)
7807 /* First output info about the base classes. */
7808 if (TYPE_BINFO (type
) && TYPE_BINFO_BASETYPES (type
))
7810 register tree bases
= TYPE_BINFO_BASETYPES (type
);
7811 register int n_bases
= TREE_VEC_LENGTH (bases
);
7814 for (i
= 0; i
< n_bases
; i
++)
7815 gen_inheritance_die (TREE_VEC_ELT (bases
, i
), context_die
);
7818 /* Now output info about the data members and type members. */
7819 for (member
= TYPE_FIELDS (type
); member
; member
= TREE_CHAIN (member
))
7820 gen_decl_die (member
, context_die
);
7822 /* Now output info about the function members (if any). */
7823 for (member
= TYPE_METHODS (type
); member
; member
= TREE_CHAIN (member
))
7824 gen_decl_die (member
, context_die
);
7827 /* Generate a DIE for a structure or union type. */
7830 gen_struct_or_union_type_die (type
, context_die
)
7832 register dw_die_ref context_die
;
7834 register dw_die_ref type_die
= lookup_type_die (type
);
7835 register dw_die_ref scope_die
= 0;
7836 register int nested
= 0;
7838 if (type_die
&& ! TYPE_SIZE (type
))
7841 if (TYPE_CONTEXT (type
) != NULL_TREE
7842 && TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type
))) == 't')
7845 scope_die
= scope_die_for (type
, context_die
);
7847 if (! type_die
|| (nested
&& scope_die
== comp_unit_die
))
7848 /* First occurrence of type or toplevel definition of nested class. */
7850 register dw_die_ref old_die
= type_die
;
7852 type_die
= new_die (TREE_CODE (type
) == RECORD_TYPE
7853 ? DW_TAG_structure_type
: DW_TAG_union_type
,
7855 equate_type_number_to_die (type
, type_die
);
7856 add_name_attribute (type_die
, type_tag (type
));
7858 add_AT_die_ref (type_die
, DW_AT_specification
, old_die
);
7861 remove_AT (type_die
, DW_AT_declaration
);
7863 /* If we're not in the right context to be defining this type, defer to
7864 avoid tricky recursion. */
7865 if (TYPE_SIZE (type
) && decl_scope_depth
> 0 && scope_die
== comp_unit_die
)
7867 add_AT_flag (type_die
, DW_AT_declaration
, 1);
7870 /* If this type has been completed, then give it a byte_size attribute and
7871 then give a list of members. */
7872 else if (TYPE_SIZE (type
))
7874 /* Prevent infinite recursion in cases where the type of some member of
7875 this type is expressed in terms of this type itself. */
7876 TREE_ASM_WRITTEN (type
) = 1;
7877 add_byte_size_attribute (type_die
, type
);
7878 if (type_tag (type
))
7879 add_src_coords_attributes (type_die
, TYPE_STUB_DECL (type
));
7881 push_decl_scope (type
);
7882 gen_member_die (type
, type_die
);
7885 /* GNU extension: Record what type our vtable lives in. */
7886 if (TYPE_VFIELD (type
))
7888 tree vtype
= DECL_FCONTEXT (TYPE_VFIELD (type
));
7890 gen_type_die (vtype
, context_die
);
7891 add_AT_die_ref (type_die
, DW_AT_containing_type
,
7892 lookup_type_die (vtype
));
7896 add_AT_flag (type_die
, DW_AT_declaration
, 1);
7899 /* Generate a DIE for a subroutine _type_. */
7902 gen_subroutine_type_die (type
, context_die
)
7904 register dw_die_ref context_die
;
7906 register tree return_type
= TREE_TYPE (type
);
7907 register dw_die_ref subr_die
7908 = new_die (DW_TAG_subroutine_type
, scope_die_for (type
, context_die
));
7910 equate_type_number_to_die (type
, subr_die
);
7911 add_prototyped_attribute (subr_die
, type
);
7912 add_type_attribute (subr_die
, return_type
, 0, 0, context_die
);
7913 gen_formal_types_die (type
, subr_die
);
7916 /* Generate a DIE for a type definition */
7919 gen_typedef_die (decl
, context_die
)
7921 register dw_die_ref context_die
;
7923 register dw_die_ref type_die
;
7924 register tree origin
;
7926 if (TREE_ASM_WRITTEN (decl
))
7928 TREE_ASM_WRITTEN (decl
) = 1;
7930 type_die
= new_die (DW_TAG_typedef
, scope_die_for (decl
, context_die
));
7931 origin
= decl_ultimate_origin (decl
);
7933 add_abstract_origin_attribute (type_die
, origin
);
7937 add_name_and_src_coords_attributes (type_die
, decl
);
7938 if (DECL_ORIGINAL_TYPE (decl
))
7940 type
= DECL_ORIGINAL_TYPE (decl
);
7941 equate_type_number_to_die (TREE_TYPE (decl
), type_die
);
7944 type
= TREE_TYPE (decl
);
7945 add_type_attribute (type_die
, type
, TREE_READONLY (decl
),
7946 TREE_THIS_VOLATILE (decl
), context_die
);
7949 if (DECL_ABSTRACT (decl
))
7950 equate_decl_number_to_die (decl
, type_die
);
7953 /* Generate a type description DIE. */
7956 gen_type_die (type
, context_die
)
7958 register dw_die_ref context_die
;
7960 if (type
== NULL_TREE
|| type
== error_mark_node
)
7963 /* We are going to output a DIE to represent the unqualified version of of
7964 this type (i.e. without any const or volatile qualifiers) so get the
7965 main variant (i.e. the unqualified version) of this type now. */
7966 type
= type_main_variant (type
);
7968 if (TREE_ASM_WRITTEN (type
))
7971 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
7972 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
7974 TREE_ASM_WRITTEN (type
) = 1;
7975 gen_decl_die (TYPE_NAME (type
), context_die
);
7979 switch (TREE_CODE (type
))
7985 case REFERENCE_TYPE
:
7986 /* For these types, all that is required is that we output a DIE (or a
7987 set of DIEs) to represent the "basis" type. */
7988 gen_type_die (TREE_TYPE (type
), context_die
);
7992 /* This code is used for C++ pointer-to-data-member types.
7993 Output a description of the relevant class type. */
7994 gen_type_die (TYPE_OFFSET_BASETYPE (type
), context_die
);
7996 /* Output a description of the type of the object pointed to. */
7997 gen_type_die (TREE_TYPE (type
), context_die
);
7999 /* Now output a DIE to represent this pointer-to-data-member type
8001 gen_ptr_to_mbr_type_die (type
, context_die
);
8005 gen_type_die (TYPE_DOMAIN (type
), context_die
);
8006 gen_set_type_die (type
, context_die
);
8010 gen_type_die (TREE_TYPE (type
), context_die
);
8011 abort (); /* No way to represent these in Dwarf yet! */
8015 /* Force out return type (in case it wasn't forced out already). */
8016 gen_type_die (TREE_TYPE (type
), context_die
);
8017 gen_subroutine_type_die (type
, context_die
);
8021 /* Force out return type (in case it wasn't forced out already). */
8022 gen_type_die (TREE_TYPE (type
), context_die
);
8023 gen_subroutine_type_die (type
, context_die
);
8027 if (TYPE_STRING_FLAG (type
) && TREE_CODE (TREE_TYPE (type
)) == CHAR_TYPE
)
8029 gen_type_die (TREE_TYPE (type
), context_die
);
8030 gen_string_type_die (type
, context_die
);
8033 gen_array_type_die (type
, context_die
);
8039 case QUAL_UNION_TYPE
:
8040 /* If this is a nested type whose containing class hasn't been
8041 written out yet, writing it out will cover this one, too. */
8042 if (TYPE_CONTEXT (type
)
8043 && TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type
))) == 't'
8044 && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type
)))
8046 gen_type_die (TYPE_CONTEXT (type
), context_die
);
8048 if (TREE_ASM_WRITTEN (TYPE_CONTEXT (type
)))
8051 /* If that failed, attach ourselves to the stub. */
8052 push_decl_scope (TYPE_CONTEXT (type
));
8053 context_die
= lookup_type_die (TYPE_CONTEXT (type
));
8056 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
8057 gen_enumeration_type_die (type
, context_die
);
8059 gen_struct_or_union_type_die (type
, context_die
);
8061 if (TYPE_CONTEXT (type
)
8062 && TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type
))) == 't'
8063 && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type
)))
8066 /* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix
8067 it up if it is ever completed. gen_*_type_die will set it for us
8068 when appropriate. */
8077 /* No DIEs needed for fundamental types. */
8081 /* No Dwarf representation currently defined. */
8088 TREE_ASM_WRITTEN (type
) = 1;
8091 /* Generate a DIE for a tagged type instantiation. */
8094 gen_tagged_type_instantiation_die (type
, context_die
)
8096 register dw_die_ref context_die
;
8098 if (type
== NULL_TREE
|| type
== error_mark_node
)
8101 /* We are going to output a DIE to represent the unqualified version of of
8102 this type (i.e. without any const or volatile qualifiers) so make sure
8103 that we have the main variant (i.e. the unqualified version) of this
8105 assert (type
== type_main_variant (type
));
8106 assert (TREE_ASM_WRITTEN (type
));
8108 switch (TREE_CODE (type
))
8114 gen_inlined_enumeration_type_die (type
, context_die
);
8118 gen_inlined_structure_type_die (type
, context_die
);
8122 case QUAL_UNION_TYPE
:
8123 gen_inlined_union_type_die (type
, context_die
);
8131 /* Generate a DW_TAG_lexical_block DIE followed by DIEs to represent all of the
8132 things which are local to the given block. */
8135 gen_block_die (stmt
, context_die
, depth
)
8137 register dw_die_ref context_die
;
8140 register int must_output_die
= 0;
8141 register tree origin
;
8143 register enum tree_code origin_code
;
8145 /* Ignore blocks never really used to make RTL. */
8147 if (stmt
== NULL_TREE
|| !TREE_USED (stmt
))
8150 /* Determine the "ultimate origin" of this block. This block may be an
8151 inlined instance of an inlined instance of inline function, so we have
8152 to trace all of the way back through the origin chain to find out what
8153 sort of node actually served as the original seed for the creation of
8154 the current block. */
8155 origin
= block_ultimate_origin (stmt
);
8156 origin_code
= (origin
!= NULL
) ? TREE_CODE (origin
) : ERROR_MARK
;
8158 /* Determine if we need to output any Dwarf DIEs at all to represent this
8160 if (origin_code
== FUNCTION_DECL
)
8161 /* The outer scopes for inlinings *must* always be represented. We
8162 generate DW_TAG_inlined_subroutine DIEs for them. (See below.) */
8163 must_output_die
= 1;
8166 /* In the case where the current block represents an inlining of the
8167 "body block" of an inline function, we must *NOT* output any DIE for
8168 this block because we have already output a DIE to represent the
8169 whole inlined function scope and the "body block" of any function
8170 doesn't really represent a different scope according to ANSI C
8171 rules. So we check here to make sure that this block does not
8172 represent a "body block inlining" before trying to set the
8173 `must_output_die' flag. */
8174 if (! is_body_block (origin
? origin
: stmt
))
8176 /* Determine if this block directly contains any "significant"
8177 local declarations which we will need to output DIEs for. */
8178 if (debug_info_level
> DINFO_LEVEL_TERSE
)
8179 /* We are not in terse mode so *any* local declaration counts
8180 as being a "significant" one. */
8181 must_output_die
= (BLOCK_VARS (stmt
) != NULL
);
8183 /* We are in terse mode, so only local (nested) function
8184 definitions count as "significant" local declarations. */
8185 for (decl
= BLOCK_VARS (stmt
);
8186 decl
!= NULL
; decl
= TREE_CHAIN (decl
))
8187 if (TREE_CODE (decl
) == FUNCTION_DECL
8188 && DECL_INITIAL (decl
))
8190 must_output_die
= 1;
8196 /* It would be a waste of space to generate a Dwarf DW_TAG_lexical_block
8197 DIE for any block which contains no significant local declarations at
8198 all. Rather, in such cases we just call `decls_for_scope' so that any
8199 needed Dwarf info for any sub-blocks will get properly generated. Note
8200 that in terse mode, our definition of what constitutes a "significant"
8201 local declaration gets restricted to include only inlined function
8202 instances and local (nested) function definitions. */
8203 if (must_output_die
)
8205 if (origin_code
== FUNCTION_DECL
)
8206 gen_inlined_subroutine_die (stmt
, context_die
, depth
);
8208 gen_lexical_block_die (stmt
, context_die
, depth
);
8211 decls_for_scope (stmt
, context_die
, depth
);
8214 /* Generate all of the decls declared within a given scope and (recursively)
8215 all of it's sub-blocks. */
8218 decls_for_scope (stmt
, context_die
, depth
)
8220 register dw_die_ref context_die
;
8224 register tree subblocks
;
8226 /* Ignore blocks never really used to make RTL. */
8227 if (stmt
== NULL_TREE
|| ! TREE_USED (stmt
))
8230 if (!BLOCK_ABSTRACT (stmt
) && depth
> 0)
8231 next_block_number
++;
8233 /* Output the DIEs to represent all of the data objects and typedefs
8234 declared directly within this block but not within any nested
8235 sub-blocks. Also, nested function and tag DIEs have been
8236 generated with a parent of NULL; fix that up now. */
8237 for (decl
= BLOCK_VARS (stmt
);
8238 decl
!= NULL
; decl
= TREE_CHAIN (decl
))
8240 register dw_die_ref die
;
8242 if (TREE_CODE (decl
) == FUNCTION_DECL
)
8243 die
= lookup_decl_die (decl
);
8244 else if (TREE_CODE (decl
) == TYPE_DECL
&& TYPE_DECL_IS_STUB (decl
))
8245 die
= lookup_type_die (TREE_TYPE (decl
));
8249 if (die
!= NULL
&& die
->die_parent
== NULL
)
8251 add_child_die (context_die
, die
);
8255 gen_decl_die (decl
, context_die
);
8258 /* Output the DIEs to represent all sub-blocks (and the items declared
8259 therein) of this block. */
8260 for (subblocks
= BLOCK_SUBBLOCKS (stmt
);
8262 subblocks
= BLOCK_CHAIN (subblocks
))
8263 gen_block_die (subblocks
, context_die
, depth
+ 1);
8266 /* Is this a typedef we can avoid emitting? */
8269 is_redundant_typedef (decl
)
8272 if (TYPE_DECL_IS_STUB (decl
))
8275 if (DECL_ARTIFICIAL (decl
)
8276 && DECL_CONTEXT (decl
)
8277 && is_tagged_type (DECL_CONTEXT (decl
))
8278 && TREE_CODE (TYPE_NAME (DECL_CONTEXT (decl
))) == TYPE_DECL
8279 && DECL_NAME (decl
) == DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl
))))
8280 /* Also ignore the artificial member typedef for the class name. */
8286 /* Generate Dwarf debug information for a decl described by DECL. */
8289 gen_decl_die (decl
, context_die
)
8291 register dw_die_ref context_die
;
8293 register tree origin
;
8295 /* Make a note of the decl node we are going to be working on. We may need
8296 to give the user the source coordinates of where it appeared in case we
8297 notice (later on) that something about it looks screwy. */
8298 dwarf_last_decl
= decl
;
8300 if (TREE_CODE (decl
) == ERROR_MARK
)
8303 /* If this ..._DECL node is marked to be ignored, then ignore it. But don't
8304 ignore a function definition, since that would screw up our count of
8305 blocks, and that it turn will completely screw up the the labels we will
8306 reference in subsequent DW_AT_low_pc and DW_AT_high_pc attributes (for
8307 subsequent blocks). */
8308 if (DECL_IGNORED_P (decl
) && TREE_CODE (decl
) != FUNCTION_DECL
)
8311 switch (TREE_CODE (decl
))
8314 /* The individual enumerators of an enum type get output when we output
8315 the Dwarf representation of the relevant enum type itself. */
8319 /* Don't output any DIEs to represent mere function declarations,
8320 unless they are class members or explicit block externs. */
8321 if (DECL_INITIAL (decl
) == NULL_TREE
&& DECL_CONTEXT (decl
) == NULL_TREE
8322 && (current_function_decl
== NULL_TREE
|| ! DECL_ARTIFICIAL (decl
)))
8325 if (debug_info_level
> DINFO_LEVEL_TERSE
)
8327 /* Before we describe the FUNCTION_DECL itself, make sure that we
8328 have described its return type. */
8329 gen_type_die (TREE_TYPE (TREE_TYPE (decl
)), context_die
);
8331 /* And its containing type. */
8332 origin
= decl_class_context (decl
);
8333 if (origin
!= NULL_TREE
)
8334 gen_type_die (origin
, context_die
);
8336 /* And its virtual context. */
8337 if (DECL_VINDEX (decl
) != NULL_TREE
)
8338 gen_type_die (DECL_CONTEXT (decl
), context_die
);
8341 /* Now output a DIE to represent the function itself. */
8342 gen_subprogram_die (decl
, context_die
);
8346 /* If we are in terse mode, don't generate any DIEs to represent any
8348 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
8351 /* In the special case of a TYPE_DECL node representing the
8352 declaration of some type tag, if the given TYPE_DECL is marked as
8353 having been instantiated from some other (original) TYPE_DECL node
8354 (e.g. one which was generated within the original definition of an
8355 inline function) we have to generate a special (abbreviated)
8356 DW_TAG_structure_type, DW_TAG_union_type, or DW_TAG_enumeration-type
8358 if (TYPE_DECL_IS_STUB (decl
) && DECL_ABSTRACT_ORIGIN (decl
) != NULL_TREE
)
8360 gen_tagged_type_instantiation_die (TREE_TYPE (decl
), context_die
);
8364 if (is_redundant_typedef (decl
))
8365 gen_type_die (TREE_TYPE (decl
), context_die
);
8367 /* Output a DIE to represent the typedef itself. */
8368 gen_typedef_die (decl
, context_die
);
8372 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
8373 gen_label_die (decl
, context_die
);
8377 /* If we are in terse mode, don't generate any DIEs to represent any
8378 variable declarations or definitions. */
8379 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
8382 /* Output any DIEs that are needed to specify the type of this data
8384 gen_type_die (TREE_TYPE (decl
), context_die
);
8386 /* And its containing type. */
8387 origin
= decl_class_context (decl
);
8388 if (origin
!= NULL_TREE
)
8389 gen_type_die (origin
, context_die
);
8391 /* Now output the DIE to represent the data object itself. This gets
8392 complicated because of the possibility that the VAR_DECL really
8393 represents an inlined instance of a formal parameter for an inline
8395 origin
= decl_ultimate_origin (decl
);
8396 if (origin
!= NULL_TREE
&& TREE_CODE (origin
) == PARM_DECL
)
8397 gen_formal_parameter_die (decl
, context_die
);
8399 gen_variable_die (decl
, context_die
);
8403 /* Ignore the nameless fields that are used to skip bits, but
8404 handle C++ anonymous unions. */
8405 if (DECL_NAME (decl
) != NULL_TREE
8406 || TREE_CODE (TREE_TYPE (decl
)) == UNION_TYPE
)
8408 gen_type_die (member_declared_type (decl
), context_die
);
8409 gen_field_die (decl
, context_die
);
8414 gen_type_die (TREE_TYPE (decl
), context_die
);
8415 gen_formal_parameter_die (decl
, context_die
);
8423 /* Write the debugging output for DECL. */
8426 dwarf2out_decl (decl
)
8429 register dw_die_ref context_die
= comp_unit_die
;
8431 if (TREE_CODE (decl
) == ERROR_MARK
)
8434 /* If this ..._DECL node is marked to be ignored, then ignore it. We gotta
8435 hope that the node in question doesn't represent a function definition.
8436 If it does, then totally ignoring it is bound to screw up our count of
8437 blocks, and that it turn will completely screw up the the labels we will
8438 reference in subsequent DW_AT_low_pc and DW_AT_high_pc attributes (for
8439 subsequent blocks). (It's too bad that BLOCK nodes don't carry their
8440 own sequence numbers with them!) */
8441 if (DECL_IGNORED_P (decl
))
8443 if (TREE_CODE (decl
) == FUNCTION_DECL
8444 && DECL_INITIAL (decl
) != NULL
)
8450 switch (TREE_CODE (decl
))
8453 /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of a
8454 builtin function. Explicit programmer-supplied declarations of
8455 these same functions should NOT be ignored however. */
8456 if (DECL_EXTERNAL (decl
) && DECL_FUNCTION_CODE (decl
))
8459 /* What we would really like to do here is to filter out all mere
8460 file-scope declarations of file-scope functions which are never
8461 referenced later within this translation unit (and keep all of ones
8462 that *are* referenced later on) but we aren't clarvoiant, so we have
8463 no idea which functions will be referenced in the future (i.e. later
8464 on within the current translation unit). So here we just ignore all
8465 file-scope function declarations which are not also definitions. If
8466 and when the debugger needs to know something about these funcstion,
8467 it wil have to hunt around and find the DWARF information associated
8468 with the definition of the function. Note that we can't just check
8469 `DECL_EXTERNAL' to find out which FUNCTION_DECL nodes represent
8470 definitions and which ones represent mere declarations. We have to
8471 check `DECL_INITIAL' instead. That's because the C front-end
8472 supports some weird semantics for "extern inline" function
8473 definitions. These can get inlined within the current translation
8474 unit (an thus, we need to generate DWARF info for their abstract
8475 instances so that the DWARF info for the concrete inlined instances
8476 can have something to refer to) but the compiler never generates any
8477 out-of-lines instances of such things (despite the fact that they
8478 *are* definitions). The important point is that the C front-end
8479 marks these "extern inline" functions as DECL_EXTERNAL, but we need
8480 to generate DWARF for them anyway. Note that the C++ front-end also
8481 plays some similar games for inline function definitions appearing
8482 within include files which also contain
8483 `#pragma interface' pragmas. */
8484 if (DECL_INITIAL (decl
) == NULL_TREE
)
8487 /* Ignore nested functions, since they will be written in decl_for_scope.
8488 ??? There was an old comment here about methods, which now need to
8490 if (decl_function_context (decl
))
8496 /* Ignore this VAR_DECL if it refers to a file-scope extern data object
8497 declaration and if the declaration was never even referenced from
8498 within this entire compilation unit. We suppress these DIEs in
8499 order to save space in the .debug section (by eliminating entries
8500 which are probably useless). Note that we must not suppress
8501 block-local extern declarations (whether used or not) because that
8502 would screw-up the debugger's name lookup mechanism and cause it to
8503 miss things which really ought to be in scope at a given point. */
8504 if (DECL_EXTERNAL (decl
) && !TREE_USED (decl
))
8507 /* If we are in terse mode, don't generate any DIEs to represent any
8508 variable declarations or definitions. */
8509 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
8514 /* Don't bother trying to generate any DIEs to represent any of the
8515 normal built-in types for the language we are compiling. */
8516 if (DECL_SOURCE_LINE (decl
) == 0)
8518 /* OK, we need to generate one for `bool' so GDB knows what type
8519 comparisons have. */
8520 if ((get_AT_unsigned (comp_unit_die
, DW_AT_language
)
8521 == DW_LANG_C_plus_plus
)
8522 && TREE_CODE (TREE_TYPE (decl
)) == BOOLEAN_TYPE
)
8523 modified_type_die (TREE_TYPE (decl
), 0, 0, NULL
);
8528 /* If we are in terse mode, don't generate any DIEs for types. */
8529 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
8532 /* If we're a function-scope tag, initially use a parent of NULL;
8533 this will be fixed up in decls_for_scope. */
8534 if (decl_function_context (decl
))
8543 gen_decl_die (decl
, context_die
);
8544 output_pending_types_for_scope (comp_unit_die
);
8546 if (TREE_CODE (decl
) == FUNCTION_DECL
&& DECL_INITIAL (decl
) != NULL_TREE
)
8547 current_funcdef_number
++;
8550 /* Output a marker (i.e. a label) for the beginning of the generated code for
8554 dwarf2out_begin_block (blocknum
)
8555 register unsigned blocknum
;
8557 function_section (current_function_decl
);
8558 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, BLOCK_BEGIN_LABEL
, blocknum
);
8561 /* Output a marker (i.e. a label) for the end of the generated code for a
8565 dwarf2out_end_block (blocknum
)
8566 register unsigned blocknum
;
8568 function_section (current_function_decl
);
8569 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, BLOCK_END_LABEL
, blocknum
);
8572 /* Output a marker (i.e. a label) at a point in the assembly code which
8573 corresponds to a given source level label. */
8576 dwarf2out_label (insn
)
8579 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
8581 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
8583 function_section (current_function_decl
);
8584 sprintf (label
, INSN_LABEL_FMT
, current_funcdef_number
);
8585 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, label
,
8586 (unsigned) INSN_UID (insn
));
8590 /* Output a marker (i.e. a label) for the beginning of a function, before
8594 dwarf2out_begin_prologue ()
8596 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
8597 register dw_fde_ref fde
;
8599 function_section (current_function_decl
);
8600 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_BEGIN_LABEL
,
8601 current_funcdef_number
);
8602 ASM_OUTPUT_LABEL (asm_out_file
, label
);
8604 /* Expand the fde table if necessary. */
8605 if (fde_table_in_use
== fde_table_allocated
)
8607 fde_table_allocated
+= FDE_TABLE_INCREMENT
;
8609 = (dw_fde_ref
) xrealloc (fde_table
,
8610 fde_table_allocated
* sizeof (dw_fde_node
));
8613 /* Record the FDE associated with this function. */
8614 current_funcdef_fde
= fde_table_in_use
;
8616 /* Add the new FDE at the end of the fde_table. */
8617 fde
= &fde_table
[fde_table_in_use
++];
8618 fde
->dw_fde_begin
= xstrdup (label
);
8619 fde
->dw_fde_current_label
= NULL
;
8620 fde
->dw_fde_end
= NULL
;
8621 fde
->dw_fde_cfi
= NULL
;
8624 /* Output a marker (i.e. a label) for the absolute end of the generated code
8625 for a function definition. This gets called *after* the epilogue code has
8629 dwarf2out_end_epilogue ()
8632 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
8634 /* Output a label to mark the endpoint of the code generated for this
8636 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_END_LABEL
, current_funcdef_number
);
8637 ASM_OUTPUT_LABEL (asm_out_file
, label
);
8638 fde
= &fde_table
[fde_table_in_use
- 1];
8639 fde
->dw_fde_end
= xstrdup (label
);
8642 /* Lookup a filename (in the list of filenames that we know about here in
8643 dwarf2out.c) and return its "index". The index of each (known) filename is
8644 just a unique number which is associated with only that one filename.
8645 We need such numbers for the sake of generating labels
8646 (in the .debug_sfnames section) and references to those
8647 files numbers (in the .debug_srcinfo and.debug_macinfo sections).
8648 If the filename given as an argument is not found in our current list,
8649 add it to the list and assign it the next available unique index number.
8650 In order to speed up searches, we remember the index of the filename
8651 was looked up last. This handles the majority of all searches. */
8654 lookup_filename (file_name
)
8657 static unsigned last_file_lookup_index
= 0;
8658 register unsigned i
;
8660 /* Check to see if the file name that was searched on the previous call
8661 matches this file name. If so, return the index. */
8662 if (last_file_lookup_index
!= 0)
8663 if (strcmp (file_name
, file_table
[last_file_lookup_index
]) == 0)
8664 return last_file_lookup_index
;
8666 /* Didn't match the previous lookup, search the table */
8667 for (i
= 1; i
< file_table_in_use
; ++i
)
8668 if (strcmp (file_name
, file_table
[i
]) == 0)
8670 last_file_lookup_index
= i
;
8674 /* Prepare to add a new table entry by making sure there is enough space in
8675 the table to do so. If not, expand the current table. */
8676 if (file_table_in_use
== file_table_allocated
)
8678 file_table_allocated
+= FILE_TABLE_INCREMENT
;
8680 = (char **) xrealloc (file_table
,
8681 file_table_allocated
* sizeof (char *));
8684 /* Add the new entry to the end of the filename table. */
8685 file_table
[file_table_in_use
] = xstrdup (file_name
);
8686 last_file_lookup_index
= file_table_in_use
++;
8688 return last_file_lookup_index
;
8691 /* Output a label to mark the beginning of a source code line entry
8692 and record information relating to this source line, in
8693 'line_info_table' for later output of the .debug_line section. */
8696 dwarf2out_line (filename
, line
)
8697 register char *filename
;
8698 register unsigned line
;
8700 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
8702 function_section (current_function_decl
);
8704 if (DECL_SECTION_NAME (current_function_decl
))
8706 register dw_separate_line_info_ref line_info
;
8707 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, SEPARATE_LINE_CODE_LABEL
,
8708 separate_line_info_table_in_use
);
8709 fputc ('\n', asm_out_file
);
8711 /* expand the line info table if necessary */
8712 if (separate_line_info_table_in_use
8713 == separate_line_info_table_allocated
)
8715 separate_line_info_table_allocated
+= LINE_INFO_TABLE_INCREMENT
;
8716 separate_line_info_table
8717 = (dw_separate_line_info_ref
)
8718 xrealloc (separate_line_info_table
,
8719 separate_line_info_table_allocated
8720 * sizeof (dw_separate_line_info_entry
));
8723 /* Add the new entry at the end of the line_info_table. */
8725 = &separate_line_info_table
[separate_line_info_table_in_use
++];
8726 line_info
->dw_file_num
= lookup_filename (filename
);
8727 line_info
->dw_line_num
= line
;
8728 line_info
->function
= current_funcdef_number
;
8732 register dw_line_info_ref line_info
;
8734 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, LINE_CODE_LABEL
,
8735 line_info_table_in_use
);
8736 fputc ('\n', asm_out_file
);
8738 /* Expand the line info table if necessary. */
8739 if (line_info_table_in_use
== line_info_table_allocated
)
8741 line_info_table_allocated
+= LINE_INFO_TABLE_INCREMENT
;
8743 = (dw_line_info_ref
)
8744 xrealloc (line_info_table
,
8745 (line_info_table_allocated
8746 * sizeof (dw_line_info_entry
)));
8749 /* Add the new entry at the end of the line_info_table. */
8750 line_info
= &line_info_table
[line_info_table_in_use
++];
8751 line_info
->dw_file_num
= lookup_filename (filename
);
8752 line_info
->dw_line_num
= line
;
8757 /* Record the beginning of a new source file, for later output
8758 of the .debug_macinfo section. At present, unimplemented. */
8761 dwarf2out_start_source_file (filename
)
8762 register char *filename
;
8766 /* Record the end of a source file, for later output
8767 of the .debug_macinfo section. At present, unimplemented. */
8770 dwarf2out_end_source_file ()
8774 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
8775 the tail part of the directive line, i.e. the part which is past the
8776 initial whitespace, #, whitespace, directive-name, whitespace part. */
8779 dwarf2out_define (lineno
, buffer
)
8780 register unsigned lineno
;
8781 register char *buffer
;
8783 static int initialized
= 0;
8786 dwarf2out_start_source_file (primary_filename
);
8791 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
8792 the tail part of the directive line, i.e. the part which is past the
8793 initial whitespace, #, whitespace, directive-name, whitespace part. */
8796 dwarf2out_undef (lineno
, buffer
)
8797 register unsigned lineno
;
8798 register char *buffer
;
8802 /* Set up for Dwarf output at the start of compilation. */
8805 dwarf2out_init (asm_out_file
, main_input_filename
)
8806 register FILE *asm_out_file
;
8807 register char *main_input_filename
;
8809 /* Remember the name of the primary input file. */
8810 primary_filename
= main_input_filename
;
8812 /* Allocate the initial hunk of the file_table. */
8813 file_table
= (char **) xmalloc (FILE_TABLE_INCREMENT
* sizeof (char *));
8814 bzero ((char *) file_table
, FILE_TABLE_INCREMENT
* sizeof (char *));
8815 file_table_allocated
= FILE_TABLE_INCREMENT
;
8817 /* Skip the first entry - file numbers begin at 1. */
8818 file_table_in_use
= 1;
8820 /* Allocate the initial hunk of the decl_die_table. */
8822 = (dw_die_ref
*) xmalloc (DECL_DIE_TABLE_INCREMENT
* sizeof (dw_die_ref
));
8823 bzero ((char *) decl_die_table
,
8824 DECL_DIE_TABLE_INCREMENT
* sizeof (dw_die_ref
));
8825 decl_die_table_allocated
= DECL_DIE_TABLE_INCREMENT
;
8826 decl_die_table_in_use
= 0;
8828 /* Allocate the initial hunk of the decl_scope_table. */
8830 = (tree
*) xmalloc (DECL_SCOPE_TABLE_INCREMENT
* sizeof (tree
));
8831 bzero ((char *) decl_scope_table
,
8832 DECL_SCOPE_TABLE_INCREMENT
* sizeof (tree
));
8833 decl_scope_table_allocated
= DECL_SCOPE_TABLE_INCREMENT
;
8834 decl_scope_depth
= 0;
8836 /* Allocate the initial hunk of the abbrev_die_table. */
8838 = (dw_die_ref
*) xmalloc (ABBREV_DIE_TABLE_INCREMENT
8839 * sizeof (dw_die_ref
));
8840 bzero ((char *) abbrev_die_table
,
8841 ABBREV_DIE_TABLE_INCREMENT
* sizeof (dw_die_ref
));
8842 abbrev_die_table_allocated
= ABBREV_DIE_TABLE_INCREMENT
;
8843 /* Zero-th entry is allocated, but unused */
8844 abbrev_die_table_in_use
= 1;
8846 /* Allocate the initial hunk of the line_info_table. */
8848 = (dw_line_info_ref
) xmalloc (LINE_INFO_TABLE_INCREMENT
8849 * sizeof (dw_line_info_entry
));
8850 bzero ((char *) line_info_table
,
8851 LINE_INFO_TABLE_INCREMENT
* sizeof (dw_line_info_entry
));
8852 line_info_table_allocated
= LINE_INFO_TABLE_INCREMENT
;
8853 /* Zero-th entry is allocated, but unused */
8854 line_info_table_in_use
= 1;
8856 /* Allocate the initial hunk of the fde_table. */
8858 = (dw_fde_ref
) xmalloc (FDE_TABLE_INCREMENT
* sizeof (dw_fde_node
));
8859 bzero ((char *) fde_table
, FDE_TABLE_INCREMENT
* sizeof (dw_fde_node
));
8860 fde_table_allocated
= FDE_TABLE_INCREMENT
;
8861 fde_table_in_use
= 0;
8863 /* Generate the initial DIE for the .debug section. Note that the (string)
8864 value given in the DW_AT_name attribute of the DW_TAG_compile_unit DIE
8865 will (typically) be a relative pathname and that this pathname should be
8866 taken as being relative to the directory from which the compiler was
8867 invoked when the given (base) source file was compiled. */
8868 gen_compile_unit_die (main_input_filename
);
8870 ASM_GENERATE_INTERNAL_LABEL (text_end_label
, TEXT_END_LABEL
, 0);
8872 /* Generate the CFA instructions common to all FDE's. Do it now for the
8873 sake of lookup_cfa. */
8875 #ifdef INCOMING_RETURN_ADDR_RTX
8876 /* On entry, the Canonical Frame Address is at SP+0. */
8877 dwarf2out_def_cfa (NULL
, STACK_POINTER_REGNUM
, 0);
8878 initial_return_save (INCOMING_RETURN_ADDR_RTX
);
8882 /* Output stuff that dwarf requires at the end of every file,
8883 and generate the DWARF-2 debugging info. */
8888 /* Traverse the DIE tree and add sibling attributes to those DIE's
8889 that have children. */
8890 add_sibling_attributes (comp_unit_die
);
8892 /* Output a terminator label for the .text section. */
8893 fputc ('\n', asm_out_file
);
8894 ASM_OUTPUT_SECTION (asm_out_file
, TEXT_SECTION
);
8895 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, TEXT_END_LABEL
, 0);
8898 /* Output a terminator label for the .data section. */
8899 fputc ('\n', asm_out_file
);
8900 ASM_OUTPUT_SECTION (asm_out_file
, DATA_SECTION
);
8901 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, DATA_END_LABEL
, 0);
8903 /* Output a terminator label for the .bss section. */
8904 fputc ('\n', asm_out_file
);
8905 ASM_OUTPUT_SECTION (asm_out_file
, BSS_SECTION
);
8906 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, BSS_END_LABEL
, 0);
8909 /* Output the source line correspondence table. */
8910 if (line_info_table_in_use
> 1 || separate_line_info_table_in_use
)
8912 fputc ('\n', asm_out_file
);
8913 ASM_OUTPUT_SECTION (asm_out_file
, LINE_SECTION
);
8914 output_line_info ();
8916 /* We can only use the low/high_pc attributes if all of the code
8918 if (separate_line_info_table_in_use
== 0)
8920 add_AT_lbl_id (comp_unit_die
, DW_AT_low_pc
, TEXT_SECTION
);
8921 add_AT_lbl_id (comp_unit_die
, DW_AT_high_pc
, text_end_label
);
8924 add_AT_section_offset (comp_unit_die
, DW_AT_stmt_list
, LINE_SECTION
);
8927 /* Output the abbreviation table. */
8928 fputc ('\n', asm_out_file
);
8929 ASM_OUTPUT_SECTION (asm_out_file
, ABBREV_SECTION
);
8930 build_abbrev_table (comp_unit_die
);
8931 output_abbrev_section ();
8933 /* Initialize the beginning DIE offset - and calculate sizes/offsets. */
8934 next_die_offset
= DWARF_COMPILE_UNIT_HEADER_SIZE
;
8935 calc_die_sizes (comp_unit_die
);
8937 /* calculate sizes/offsets for FDEs. */
8940 /* Output debugging information. */
8941 fputc ('\n', asm_out_file
);
8942 ASM_OUTPUT_SECTION (asm_out_file
, DEBUG_SECTION
);
8943 output_compilation_unit_header ();
8944 output_die (comp_unit_die
);
8946 if (pubname_table_in_use
)
8948 /* Output public names table. */
8949 fputc ('\n', asm_out_file
);
8950 ASM_OUTPUT_SECTION (asm_out_file
, PUBNAMES_SECTION
);
8954 if (fde_table_in_use
)
8956 /* Output call frame information. */
8957 output_call_frame_info ();
8959 /* Output the address range information. */
8960 fputc ('\n', asm_out_file
);
8961 ASM_OUTPUT_SECTION (asm_out_file
, ARANGES_SECTION
);
8965 /* The only DIE we should have with a parent of NULL is comp_unit_die. */
8966 assert (limbo_die_count
== 1);
8968 #endif /* DWARF2_DEBUGGING_INFO */