1 /* Output Dwarf2 format symbol table information from the GNU C compiler.
2 Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001
3 Free Software Foundation, Inc.
4 Contributed by Gary Funck (gary@intrepid.com).
5 Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.com).
6 Extensively modified by Jason Merrill (jason@cygnus.com).
8 This file is part of GCC.
10 GCC is free software; you can redistribute it and/or modify it under
11 the terms of the GNU General Public License as published by the Free
12 Software Foundation; either version 2, or (at your option) any later
15 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 You should have received a copy of the GNU General Public License
21 along with GCC; see the file COPYING. If not, write to the Free
22 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 /* TODO: Emit .debug_line header even when there are no functions, since
26 the file numbers are used by .debug_info. Alternately, leave
27 out locations for types and decls.
28 Avoid talking about ctors and op= for PODs.
29 Factor out common prologue sequences into multiple CIEs. */
31 /* The first part of this file deals with the DWARF 2 frame unwind
32 information, which is also used by the GCC efficient exception handling
33 mechanism. The second part, controlled only by an #ifdef
34 DWARF2_DEBUGGING_INFO, deals with the other DWARF 2 debugging
42 #include "hard-reg-set.h"
44 #include "insn-config.h"
52 #include "dwarf2out.h"
53 #include "dwarf2asm.h"
59 #include "diagnostic.h"
62 #include "langhooks.h"
63 #include "hashtable.h"
65 #ifdef DWARF2_DEBUGGING_INFO
66 static void dwarf2out_source_line
PARAMS ((unsigned int, const char *));
69 /* DWARF2 Abbreviation Glossary:
70 CFA = Canonical Frame Address
71 a fixed address on the stack which identifies a call frame.
72 We define it to be the value of SP just before the call insn.
73 The CFA register and offset, which may change during the course
74 of the function, are used to calculate its value at runtime.
75 CFI = Call Frame Instruction
76 an instruction for the DWARF2 abstract machine
77 CIE = Common Information Entry
78 information describing information common to one or more FDEs
79 DIE = Debugging Information Entry
80 FDE = Frame Description Entry
81 information describing the stack call frame, in particular,
82 how to restore registers
84 DW_CFA_... = DWARF2 CFA call frame instruction
85 DW_TAG_... = DWARF2 DIE tag */
87 /* Decide whether we want to emit frame unwind information for the current
93 return (write_symbols
== DWARF2_DEBUG
94 || write_symbols
== VMS_AND_DWARF2_DEBUG
95 #ifdef DWARF2_FRAME_INFO
98 #ifdef DWARF2_UNWIND_INFO
100 || (flag_exceptions
&& ! USING_SJLJ_EXCEPTIONS
)
105 /* The number of the current function definition for which debugging
106 information is being generated. These numbers range from 1 up to the
107 maximum number of function definitions contained within the current
108 compilation unit. These numbers are used to create unique label id's
109 unique to each function definition. */
110 unsigned current_funcdef_number
= 0;
112 /* The size of the target's pointer type. */
114 #define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
117 /* Default version of targetm.eh_frame_section. Note this must appear
118 outside the DWARF2_DEBUGGING_INFO || DWARF2_UNWIND_INFO macro
122 default_eh_frame_section ()
124 #ifdef EH_FRAME_SECTION_NAME
125 named_section_flags (EH_FRAME_SECTION_NAME
, SECTION_WRITE
);
127 tree label
= get_file_function_name ('F');
130 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (PTR_SIZE
));
131 ASM_GLOBALIZE_LABEL (asm_out_file
, IDENTIFIER_POINTER (label
));
132 ASM_OUTPUT_LABEL (asm_out_file
, IDENTIFIER_POINTER (label
));
136 #if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
138 /* How to start an assembler comment. */
139 #ifndef ASM_COMMENT_START
140 #define ASM_COMMENT_START ";#"
143 typedef struct dw_cfi_struct
*dw_cfi_ref
;
144 typedef struct dw_fde_struct
*dw_fde_ref
;
145 typedef union dw_cfi_oprnd_struct
*dw_cfi_oprnd_ref
;
147 /* Call frames are described using a sequence of Call Frame
148 Information instructions. The register number, offset
149 and address fields are provided as possible operands;
150 their use is selected by the opcode field. */
152 typedef union dw_cfi_oprnd_struct
154 unsigned long dw_cfi_reg_num
;
155 long int dw_cfi_offset
;
156 const char *dw_cfi_addr
;
157 struct dw_loc_descr_struct
*dw_cfi_loc
;
161 typedef struct dw_cfi_struct
163 dw_cfi_ref dw_cfi_next
;
164 enum dwarf_call_frame_info dw_cfi_opc
;
165 dw_cfi_oprnd dw_cfi_oprnd1
;
166 dw_cfi_oprnd dw_cfi_oprnd2
;
170 /* This is how we define the location of the CFA. We use to handle it
171 as REG + OFFSET all the time, but now it can be more complex.
172 It can now be either REG + CFA_OFFSET or *(REG + BASE_OFFSET) + CFA_OFFSET.
173 Instead of passing around REG and OFFSET, we pass a copy
174 of this structure. */
175 typedef struct cfa_loc
180 int indirect
; /* 1 if CFA is accessed via a dereference. */
183 /* All call frame descriptions (FDE's) in the GCC generated DWARF
184 refer to a single Common Information Entry (CIE), defined at
185 the beginning of the .debug_frame section. This use of a single
186 CIE obviates the need to keep track of multiple CIE's
187 in the DWARF generation routines below. */
189 typedef struct dw_fde_struct
191 const char *dw_fde_begin
;
192 const char *dw_fde_current_label
;
193 const char *dw_fde_end
;
194 dw_cfi_ref dw_fde_cfi
;
195 unsigned funcdef_number
;
196 unsigned nothrow
: 1;
197 unsigned uses_eh_lsda
: 1;
201 /* Maximum size (in bytes) of an artificially generated label. */
202 #define MAX_ARTIFICIAL_LABEL_BYTES 30
204 /* The size of addresses as they appear in the Dwarf 2 data.
205 Some architectures use word addresses to refer to code locations,
206 but Dwarf 2 info always uses byte addresses. On such machines,
207 Dwarf 2 addresses need to be larger than the architecture's
209 #ifndef DWARF2_ADDR_SIZE
210 #define DWARF2_ADDR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
213 /* The size in bytes of a DWARF field indicating an offset or length
214 relative to a debug info section, specified to be 4 bytes in the
215 DWARF-2 specification. The SGI/MIPS ABI defines it to be the same
218 #ifndef DWARF_OFFSET_SIZE
219 #define DWARF_OFFSET_SIZE 4
222 #define DWARF_VERSION 2
224 /* Round SIZE up to the nearest BOUNDARY. */
225 #define DWARF_ROUND(SIZE,BOUNDARY) \
226 ((((SIZE) + (BOUNDARY) - 1) / (BOUNDARY)) * (BOUNDARY))
228 /* Offsets recorded in opcodes are a multiple of this alignment factor. */
229 #ifndef DWARF_CIE_DATA_ALIGNMENT
230 #ifdef STACK_GROWS_DOWNWARD
231 #define DWARF_CIE_DATA_ALIGNMENT (-((int) UNITS_PER_WORD))
233 #define DWARF_CIE_DATA_ALIGNMENT ((int) UNITS_PER_WORD)
235 #endif /* not DWARF_CIE_DATA_ALIGNMENT */
237 /* A pointer to the base of a table that contains frame description
238 information for each routine. */
239 static dw_fde_ref fde_table
;
241 /* Number of elements currently allocated for fde_table. */
242 static unsigned fde_table_allocated
;
244 /* Number of elements in fde_table currently in use. */
245 static unsigned fde_table_in_use
;
247 /* Size (in elements) of increments by which we may expand the
249 #define FDE_TABLE_INCREMENT 256
251 /* A list of call frame insns for the CIE. */
252 static dw_cfi_ref cie_cfi_head
;
254 /* Some DWARF extensions (e.g., MIPS/SGI) implement a subprogram
255 attribute that accelerates the lookup of the FDE associated
256 with the subprogram. This variable holds the table index of the FDE
257 associated with the current function (body) definition. */
258 static unsigned current_funcdef_fde
;
260 struct ht
*debug_str_hash
;
262 struct indirect_string_node
264 struct ht_identifier id
;
265 unsigned int refcount
;
270 /* Forward declarations for functions defined in this file. */
272 static char *stripattributes
PARAMS ((const char *));
273 static const char *dwarf_cfi_name
PARAMS ((unsigned));
274 static dw_cfi_ref new_cfi
PARAMS ((void));
275 static void add_cfi
PARAMS ((dw_cfi_ref
*, dw_cfi_ref
));
276 static void add_fde_cfi
PARAMS ((const char *, dw_cfi_ref
));
277 static void lookup_cfa_1
PARAMS ((dw_cfi_ref
, dw_cfa_location
*));
278 static void lookup_cfa
PARAMS ((dw_cfa_location
*));
279 static void reg_save
PARAMS ((const char *, unsigned,
281 static void initial_return_save
PARAMS ((rtx
));
282 static long stack_adjust_offset
PARAMS ((rtx
));
283 static void output_cfi
PARAMS ((dw_cfi_ref
, dw_fde_ref
, int));
284 static void output_call_frame_info
PARAMS ((int));
285 static void dwarf2out_stack_adjust
PARAMS ((rtx
));
286 static void queue_reg_save
PARAMS ((const char *, rtx
, long));
287 static void flush_queued_reg_saves
PARAMS ((void));
288 static bool clobbers_queued_reg_save
PARAMS ((rtx
));
289 static void dwarf2out_frame_debug_expr
PARAMS ((rtx
, const char *));
291 /* Support for complex CFA locations. */
292 static void output_cfa_loc
PARAMS ((dw_cfi_ref
));
293 static void get_cfa_from_loc_descr
PARAMS ((dw_cfa_location
*,
294 struct dw_loc_descr_struct
*));
295 static struct dw_loc_descr_struct
*build_cfa_loc
296 PARAMS ((dw_cfa_location
*));
297 static void def_cfa_1
PARAMS ((const char *, dw_cfa_location
*));
299 /* .debug_str support. */
300 static hashnode indirect_string_alloc
PARAMS ((hash_table
*));
301 static int output_indirect_string
PARAMS ((struct cpp_reader
*,
302 hashnode
, const PTR
));
304 /* How to start an assembler comment. */
305 #ifndef ASM_COMMENT_START
306 #define ASM_COMMENT_START ";#"
309 /* Data and reference forms for relocatable data. */
310 #define DW_FORM_data (DWARF_OFFSET_SIZE == 8 ? DW_FORM_data8 : DW_FORM_data4)
311 #define DW_FORM_ref (DWARF_OFFSET_SIZE == 8 ? DW_FORM_ref8 : DW_FORM_ref4)
313 /* Pseudo-op for defining a new section. */
314 #ifndef SECTION_ASM_OP
315 #define SECTION_ASM_OP "\t.section\t"
318 #ifndef DEBUG_FRAME_SECTION
319 #define DEBUG_FRAME_SECTION ".debug_frame"
322 #ifndef FUNC_BEGIN_LABEL
323 #define FUNC_BEGIN_LABEL "LFB"
325 #ifndef FUNC_END_LABEL
326 #define FUNC_END_LABEL "LFE"
328 #define FRAME_BEGIN_LABEL "Lframe"
329 #define CIE_AFTER_SIZE_LABEL "LSCIE"
330 #define CIE_END_LABEL "LECIE"
331 #define CIE_LENGTH_LABEL "LLCIE"
332 #define FDE_LABEL "LSFDE"
333 #define FDE_AFTER_SIZE_LABEL "LASFDE"
334 #define FDE_END_LABEL "LEFDE"
335 #define FDE_LENGTH_LABEL "LLFDE"
336 #define LINE_NUMBER_BEGIN_LABEL "LSLT"
337 #define LINE_NUMBER_END_LABEL "LELT"
338 #define LN_PROLOG_AS_LABEL "LASLTP"
339 #define LN_PROLOG_END_LABEL "LELTP"
340 #define DIE_LABEL_PREFIX "DW"
342 /* Definitions of defaults for various types of primitive assembly language
343 output operations. These may be overridden from within the tm.h file,
344 but typically, that is unnecessary. */
347 #ifndef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
348 #define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO) \
350 fprintf (FILE, "%s", SET_ASM_OP); \
351 assemble_name (FILE, SY); \
353 assemble_name (FILE, HI); \
355 assemble_name (FILE, LO); \
358 #endif /* SET_ASM_OP */
360 /* The DWARF 2 CFA column which tracks the return address. Normally this
361 is the column for PC, or the first column after all of the hard
363 #ifndef DWARF_FRAME_RETURN_COLUMN
365 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (PC_REGNUM)
367 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGISTERS
371 /* The mapping from gcc register number to DWARF 2 CFA column number. By
372 default, we just provide columns for all registers. */
373 #ifndef DWARF_FRAME_REGNUM
374 #define DWARF_FRAME_REGNUM(REG) DBX_REGISTER_NUMBER (REG)
377 /* Hook used by __throw. */
380 expand_builtin_dwarf_fp_regnum ()
382 return GEN_INT (DWARF_FRAME_REGNUM (HARD_FRAME_POINTER_REGNUM
));
385 /* The offset from the incoming value of %sp to the top of the stack frame
386 for the current function. */
387 #ifndef INCOMING_FRAME_SP_OFFSET
388 #define INCOMING_FRAME_SP_OFFSET 0
391 /* Return a pointer to a copy of the section string name S with all
392 attributes stripped off, and an asterisk prepended (for assemble_name). */
398 char *stripped
= xmalloc (strlen (s
) + 2);
403 while (*s
&& *s
!= ',')
410 /* Generate code to initialize the register size table. */
413 expand_builtin_init_dwarf_reg_sizes (address
)
417 enum machine_mode mode
= TYPE_MODE (char_type_node
);
418 rtx addr
= expand_expr (address
, NULL_RTX
, VOIDmode
, 0);
419 rtx mem
= gen_rtx_MEM (mode
, addr
);
421 for (i
= 0; i
< DWARF_FRAME_REGISTERS
; ++i
)
423 int offset
= DWARF_FRAME_REGNUM (i
) * GET_MODE_SIZE (mode
);
424 int size
= GET_MODE_SIZE (reg_raw_mode
[i
]);
429 emit_move_insn (adjust_address (mem
, mode
, offset
), GEN_INT (size
));
433 /* Convert a DWARF call frame info. operation to its string name */
436 dwarf_cfi_name (cfi_opc
)
441 case DW_CFA_advance_loc
:
442 return "DW_CFA_advance_loc";
444 return "DW_CFA_offset";
446 return "DW_CFA_restore";
450 return "DW_CFA_set_loc";
451 case DW_CFA_advance_loc1
:
452 return "DW_CFA_advance_loc1";
453 case DW_CFA_advance_loc2
:
454 return "DW_CFA_advance_loc2";
455 case DW_CFA_advance_loc4
:
456 return "DW_CFA_advance_loc4";
457 case DW_CFA_offset_extended
:
458 return "DW_CFA_offset_extended";
459 case DW_CFA_restore_extended
:
460 return "DW_CFA_restore_extended";
461 case DW_CFA_undefined
:
462 return "DW_CFA_undefined";
463 case DW_CFA_same_value
:
464 return "DW_CFA_same_value";
465 case DW_CFA_register
:
466 return "DW_CFA_register";
467 case DW_CFA_remember_state
:
468 return "DW_CFA_remember_state";
469 case DW_CFA_restore_state
:
470 return "DW_CFA_restore_state";
472 return "DW_CFA_def_cfa";
473 case DW_CFA_def_cfa_register
:
474 return "DW_CFA_def_cfa_register";
475 case DW_CFA_def_cfa_offset
:
476 return "DW_CFA_def_cfa_offset";
477 case DW_CFA_def_cfa_expression
:
478 return "DW_CFA_def_cfa_expression";
480 /* SGI/MIPS specific */
481 case DW_CFA_MIPS_advance_loc8
:
482 return "DW_CFA_MIPS_advance_loc8";
485 case DW_CFA_GNU_window_save
:
486 return "DW_CFA_GNU_window_save";
487 case DW_CFA_GNU_args_size
:
488 return "DW_CFA_GNU_args_size";
489 case DW_CFA_GNU_negative_offset_extended
:
490 return "DW_CFA_GNU_negative_offset_extended";
493 return "DW_CFA_<unknown>";
497 /* Return a pointer to a newly allocated Call Frame Instruction. */
499 static inline dw_cfi_ref
502 dw_cfi_ref cfi
= (dw_cfi_ref
) xmalloc (sizeof (dw_cfi_node
));
504 cfi
->dw_cfi_next
= NULL
;
505 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= 0;
506 cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
= 0;
511 /* Add a Call Frame Instruction to list of instructions. */
514 add_cfi (list_head
, cfi
)
515 dw_cfi_ref
*list_head
;
520 /* Find the end of the chain. */
521 for (p
= list_head
; (*p
) != NULL
; p
= &(*p
)->dw_cfi_next
)
527 /* Generate a new label for the CFI info to refer to. */
530 dwarf2out_cfi_label ()
532 static char label
[20];
533 static unsigned long label_num
= 0;
535 ASM_GENERATE_INTERNAL_LABEL (label
, "LCFI", label_num
++);
536 ASM_OUTPUT_LABEL (asm_out_file
, label
);
541 /* Add CFI to the current fde at the PC value indicated by LABEL if specified,
542 or to the CIE if LABEL is NULL. */
545 add_fde_cfi (label
, cfi
)
551 dw_fde_ref fde
= &fde_table
[fde_table_in_use
- 1];
554 label
= dwarf2out_cfi_label ();
556 if (fde
->dw_fde_current_label
== NULL
557 || strcmp (label
, fde
->dw_fde_current_label
) != 0)
561 fde
->dw_fde_current_label
= label
= xstrdup (label
);
563 /* Set the location counter to the new label. */
565 xcfi
->dw_cfi_opc
= DW_CFA_advance_loc4
;
566 xcfi
->dw_cfi_oprnd1
.dw_cfi_addr
= label
;
567 add_cfi (&fde
->dw_fde_cfi
, xcfi
);
570 add_cfi (&fde
->dw_fde_cfi
, cfi
);
574 add_cfi (&cie_cfi_head
, cfi
);
577 /* Subroutine of lookup_cfa. */
580 lookup_cfa_1 (cfi
, loc
)
582 dw_cfa_location
*loc
;
584 switch (cfi
->dw_cfi_opc
)
586 case DW_CFA_def_cfa_offset
:
587 loc
->offset
= cfi
->dw_cfi_oprnd1
.dw_cfi_offset
;
589 case DW_CFA_def_cfa_register
:
590 loc
->reg
= cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
;
593 loc
->reg
= cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
;
594 loc
->offset
= cfi
->dw_cfi_oprnd2
.dw_cfi_offset
;
596 case DW_CFA_def_cfa_expression
:
597 get_cfa_from_loc_descr (loc
, cfi
->dw_cfi_oprnd1
.dw_cfi_loc
);
604 /* Find the previous value for the CFA. */
608 dw_cfa_location
*loc
;
612 loc
->reg
= (unsigned long) -1;
615 loc
->base_offset
= 0;
617 for (cfi
= cie_cfi_head
; cfi
; cfi
= cfi
->dw_cfi_next
)
618 lookup_cfa_1 (cfi
, loc
);
620 if (fde_table_in_use
)
622 dw_fde_ref fde
= &fde_table
[fde_table_in_use
- 1];
623 for (cfi
= fde
->dw_fde_cfi
; cfi
; cfi
= cfi
->dw_cfi_next
)
624 lookup_cfa_1 (cfi
, loc
);
628 /* The current rule for calculating the DWARF2 canonical frame address. */
629 static dw_cfa_location cfa
;
631 /* The register used for saving registers to the stack, and its offset
633 static dw_cfa_location cfa_store
;
635 /* The running total of the size of arguments pushed onto the stack. */
636 static long args_size
;
638 /* The last args_size we actually output. */
639 static long old_args_size
;
641 /* Entry point to update the canonical frame address (CFA).
642 LABEL is passed to add_fde_cfi. The value of CFA is now to be
643 calculated from REG+OFFSET. */
646 dwarf2out_def_cfa (label
, reg
, offset
)
656 def_cfa_1 (label
, &loc
);
659 /* This routine does the actual work. The CFA is now calculated from
660 the dw_cfa_location structure. */
662 def_cfa_1 (label
, loc_p
)
664 dw_cfa_location
*loc_p
;
667 dw_cfa_location old_cfa
, loc
;
672 if (cfa_store
.reg
== loc
.reg
&& loc
.indirect
== 0)
673 cfa_store
.offset
= loc
.offset
;
675 loc
.reg
= DWARF_FRAME_REGNUM (loc
.reg
);
676 lookup_cfa (&old_cfa
);
678 if (loc
.reg
== old_cfa
.reg
&& loc
.offset
== old_cfa
.offset
&&
679 loc
.indirect
== old_cfa
.indirect
)
681 if (loc
.indirect
== 0
682 || loc
.base_offset
== old_cfa
.base_offset
)
683 /* Nothing changed so no need to issue any call frame
690 if (loc
.reg
== old_cfa
.reg
&& !loc
.indirect
)
692 /* Construct a "DW_CFA_def_cfa_offset <offset>" instruction,
693 indicating the CFA register did not change but the offset
695 cfi
->dw_cfi_opc
= DW_CFA_def_cfa_offset
;
696 cfi
->dw_cfi_oprnd1
.dw_cfi_offset
= loc
.offset
;
699 #ifndef MIPS_DEBUGGING_INFO /* SGI dbx thinks this means no offset. */
700 else if (loc
.offset
== old_cfa
.offset
&& old_cfa
.reg
!= (unsigned long) -1
703 /* Construct a "DW_CFA_def_cfa_register <register>" instruction,
704 indicating the CFA register has changed to <register> but the
705 offset has not changed. */
706 cfi
->dw_cfi_opc
= DW_CFA_def_cfa_register
;
707 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= loc
.reg
;
711 else if (loc
.indirect
== 0)
713 /* Construct a "DW_CFA_def_cfa <register> <offset>" instruction,
714 indicating the CFA register has changed to <register> with
715 the specified offset. */
716 cfi
->dw_cfi_opc
= DW_CFA_def_cfa
;
717 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= loc
.reg
;
718 cfi
->dw_cfi_oprnd2
.dw_cfi_offset
= loc
.offset
;
722 /* Construct a DW_CFA_def_cfa_expression instruction to
723 calculate the CFA using a full location expression since no
724 register-offset pair is available. */
725 struct dw_loc_descr_struct
*loc_list
;
726 cfi
->dw_cfi_opc
= DW_CFA_def_cfa_expression
;
727 loc_list
= build_cfa_loc (&loc
);
728 cfi
->dw_cfi_oprnd1
.dw_cfi_loc
= loc_list
;
731 add_fde_cfi (label
, cfi
);
734 /* Add the CFI for saving a register. REG is the CFA column number.
735 LABEL is passed to add_fde_cfi.
736 If SREG is -1, the register is saved at OFFSET from the CFA;
737 otherwise it is saved in SREG. */
740 reg_save (label
, reg
, sreg
, offset
)
746 dw_cfi_ref cfi
= new_cfi ();
748 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= reg
;
750 /* The following comparison is correct. -1 is used to indicate that
751 the value isn't a register number. */
752 if (sreg
== (unsigned int) -1)
755 /* The register number won't fit in 6 bits, so we have to use
757 cfi
->dw_cfi_opc
= DW_CFA_offset_extended
;
759 cfi
->dw_cfi_opc
= DW_CFA_offset
;
761 #ifdef ENABLE_CHECKING
763 /* If we get an offset that is not a multiple of
764 DWARF_CIE_DATA_ALIGNMENT, there is either a bug in the
765 definition of DWARF_CIE_DATA_ALIGNMENT, or a bug in the machine
767 long check_offset
= offset
/ DWARF_CIE_DATA_ALIGNMENT
;
769 if (check_offset
* DWARF_CIE_DATA_ALIGNMENT
!= offset
)
773 offset
/= DWARF_CIE_DATA_ALIGNMENT
;
776 cfi
->dw_cfi_opc
= DW_CFA_GNU_negative_offset_extended
;
779 cfi
->dw_cfi_oprnd2
.dw_cfi_offset
= offset
;
781 else if (sreg
== reg
)
782 /* We could emit a DW_CFA_same_value in this case, but don't bother. */
786 cfi
->dw_cfi_opc
= DW_CFA_register
;
787 cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
= sreg
;
790 add_fde_cfi (label
, cfi
);
793 /* Add the CFI for saving a register window. LABEL is passed to reg_save.
794 This CFI tells the unwinder that it needs to restore the window registers
795 from the previous frame's window save area.
797 ??? Perhaps we should note in the CIE where windows are saved (instead of
798 assuming 0(cfa)) and what registers are in the window. */
801 dwarf2out_window_save (label
)
804 dw_cfi_ref cfi
= new_cfi ();
805 cfi
->dw_cfi_opc
= DW_CFA_GNU_window_save
;
806 add_fde_cfi (label
, cfi
);
809 /* Add a CFI to update the running total of the size of arguments
810 pushed onto the stack. */
813 dwarf2out_args_size (label
, size
)
819 if (size
== old_args_size
)
821 old_args_size
= size
;
824 cfi
->dw_cfi_opc
= DW_CFA_GNU_args_size
;
825 cfi
->dw_cfi_oprnd1
.dw_cfi_offset
= size
;
826 add_fde_cfi (label
, cfi
);
829 /* Entry point for saving a register to the stack. REG is the GCC register
830 number. LABEL and OFFSET are passed to reg_save. */
833 dwarf2out_reg_save (label
, reg
, offset
)
838 reg_save (label
, DWARF_FRAME_REGNUM (reg
), -1, offset
);
841 /* Entry point for saving the return address in the stack.
842 LABEL and OFFSET are passed to reg_save. */
845 dwarf2out_return_save (label
, offset
)
849 reg_save (label
, DWARF_FRAME_RETURN_COLUMN
, -1, offset
);
852 /* Entry point for saving the return address in a register.
853 LABEL and SREG are passed to reg_save. */
856 dwarf2out_return_reg (label
, sreg
)
860 reg_save (label
, DWARF_FRAME_RETURN_COLUMN
, sreg
, 0);
863 /* Record the initial position of the return address. RTL is
864 INCOMING_RETURN_ADDR_RTX. */
867 initial_return_save (rtl
)
870 unsigned int reg
= (unsigned int) -1;
873 switch (GET_CODE (rtl
))
876 /* RA is in a register. */
877 reg
= DWARF_FRAME_REGNUM (REGNO (rtl
));
880 /* RA is on the stack. */
882 switch (GET_CODE (rtl
))
885 if (REGNO (rtl
) != STACK_POINTER_REGNUM
)
890 if (REGNO (XEXP (rtl
, 0)) != STACK_POINTER_REGNUM
)
892 offset
= INTVAL (XEXP (rtl
, 1));
895 if (REGNO (XEXP (rtl
, 0)) != STACK_POINTER_REGNUM
)
897 offset
= -INTVAL (XEXP (rtl
, 1));
904 /* The return address is at some offset from any value we can
905 actually load. For instance, on the SPARC it is in %i7+8. Just
906 ignore the offset for now; it doesn't matter for unwinding frames. */
907 if (GET_CODE (XEXP (rtl
, 1)) != CONST_INT
)
909 initial_return_save (XEXP (rtl
, 0));
915 reg_save (NULL
, DWARF_FRAME_RETURN_COLUMN
, reg
, offset
- cfa
.offset
);
918 /* Given a SET, calculate the amount of stack adjustment it
922 stack_adjust_offset (pattern
)
925 rtx src
= SET_SRC (pattern
);
926 rtx dest
= SET_DEST (pattern
);
930 if (dest
== stack_pointer_rtx
)
932 /* (set (reg sp) (plus (reg sp) (const_int))) */
933 code
= GET_CODE (src
);
934 if (! (code
== PLUS
|| code
== MINUS
)
935 || XEXP (src
, 0) != stack_pointer_rtx
936 || GET_CODE (XEXP (src
, 1)) != CONST_INT
)
939 offset
= INTVAL (XEXP (src
, 1));
941 else if (GET_CODE (dest
) == MEM
)
943 /* (set (mem (pre_dec (reg sp))) (foo)) */
944 src
= XEXP (dest
, 0);
945 code
= GET_CODE (src
);
947 if (! (code
== PRE_DEC
|| code
== PRE_INC
948 || code
== PRE_MODIFY
)
949 || XEXP (src
, 0) != stack_pointer_rtx
)
952 if (code
== PRE_MODIFY
)
954 rtx val
= XEXP (XEXP (src
, 1), 1);
955 /* We handle only adjustments by constant amount. */
956 if (GET_CODE (XEXP (src
, 1)) != PLUS
||
957 GET_CODE (val
) != CONST_INT
)
959 offset
= -INTVAL (val
);
961 else offset
= GET_MODE_SIZE (GET_MODE (dest
));
966 if (code
== PLUS
|| code
== PRE_INC
)
972 /* Check INSN to see if it looks like a push or a stack adjustment, and
973 make a note of it if it does. EH uses this information to find out how
974 much extra space it needs to pop off the stack. */
977 dwarf2out_stack_adjust (insn
)
983 if (!flag_asynchronous_unwind_tables
984 && GET_CODE (insn
) == CALL_INSN
)
986 /* Extract the size of the args from the CALL rtx itself. */
988 insn
= PATTERN (insn
);
989 if (GET_CODE (insn
) == PARALLEL
)
990 insn
= XVECEXP (insn
, 0, 0);
991 if (GET_CODE (insn
) == SET
)
992 insn
= SET_SRC (insn
);
993 if (GET_CODE (insn
) != CALL
)
995 dwarf2out_args_size ("", INTVAL (XEXP (insn
, 1)));
999 /* If only calls can throw, and we have a frame pointer,
1000 save up adjustments until we see the CALL_INSN. */
1001 else if (!flag_asynchronous_unwind_tables
1002 && cfa
.reg
!= STACK_POINTER_REGNUM
)
1005 if (GET_CODE (insn
) == BARRIER
)
1007 /* When we see a BARRIER, we know to reset args_size to 0. Usually
1008 the compiler will have already emitted a stack adjustment, but
1009 doesn't bother for calls to noreturn functions. */
1010 #ifdef STACK_GROWS_DOWNWARD
1011 offset
= -args_size
;
1016 else if (GET_CODE (PATTERN (insn
)) == SET
)
1018 offset
= stack_adjust_offset (PATTERN (insn
));
1020 else if (GET_CODE (PATTERN (insn
)) == PARALLEL
1021 || GET_CODE (PATTERN (insn
)) == SEQUENCE
)
1023 /* There may be stack adjustments inside compound insns. Search
1028 for (j
= XVECLEN (PATTERN (insn
), 0) - 1; j
>= 0; j
--)
1030 rtx pattern
= XVECEXP (PATTERN (insn
), 0, j
);
1031 if (GET_CODE (pattern
) == SET
)
1032 offset
+= stack_adjust_offset (pattern
);
1041 if (cfa
.reg
== STACK_POINTER_REGNUM
)
1042 cfa
.offset
+= offset
;
1044 #ifndef STACK_GROWS_DOWNWARD
1047 args_size
+= offset
;
1051 label
= dwarf2out_cfi_label ();
1052 def_cfa_1 (label
, &cfa
);
1053 dwarf2out_args_size (label
, args_size
);
1056 /* We delay emitting a register save until either (a) we reach the end
1057 of the prologue or (b) the register is clobbered. This clusters
1058 register saves so that there are fewer pc advances. */
1060 struct queued_reg_save
1062 struct queued_reg_save
*next
;
1067 static struct queued_reg_save
*queued_reg_saves
;
1068 static const char *last_reg_save_label
;
1071 queue_reg_save (label
, reg
, offset
)
1076 struct queued_reg_save
*q
= (struct queued_reg_save
*) xmalloc (sizeof (*q
));
1078 q
->next
= queued_reg_saves
;
1080 q
->cfa_offset
= offset
;
1081 queued_reg_saves
= q
;
1083 last_reg_save_label
= label
;
1087 flush_queued_reg_saves ()
1089 struct queued_reg_save
*q
, *next
;
1091 for (q
= queued_reg_saves
; q
; q
= next
)
1093 dwarf2out_reg_save (last_reg_save_label
, REGNO (q
->reg
), q
->cfa_offset
);
1098 queued_reg_saves
= NULL
;
1099 last_reg_save_label
= NULL
;
1103 clobbers_queued_reg_save (insn
)
1106 struct queued_reg_save
*q
;
1108 for (q
= queued_reg_saves
; q
; q
= q
->next
)
1109 if (modified_in_p (q
->reg
, insn
))
1116 /* A temporary register holding an integral value used in adjusting SP
1117 or setting up the store_reg. The "offset" field holds the integer
1118 value, not an offset. */
1119 static dw_cfa_location cfa_temp
;
1121 /* Record call frame debugging information for an expression EXPR,
1122 which either sets SP or FP (adjusting how we calculate the frame
1123 address) or saves a register to the stack. LABEL indicates the
1126 This function encodes a state machine mapping rtxes to actions on
1127 cfa, cfa_store, and cfa_temp.reg. We describe these rules so
1128 users need not read the source code.
1130 The High-Level Picture
1132 Changes in the register we use to calculate the CFA: Currently we
1133 assume that if you copy the CFA register into another register, we
1134 should take the other one as the new CFA register; this seems to
1135 work pretty well. If it's wrong for some target, it's simple
1136 enough not to set RTX_FRAME_RELATED_P on the insn in question.
1138 Changes in the register we use for saving registers to the stack:
1139 This is usually SP, but not always. Again, we deduce that if you
1140 copy SP into another register (and SP is not the CFA register),
1141 then the new register is the one we will be using for register
1142 saves. This also seems to work.
1144 Register saves: There's not much guesswork about this one; if
1145 RTX_FRAME_RELATED_P is set on an insn which modifies memory, it's a
1146 register save, and the register used to calculate the destination
1147 had better be the one we think we're using for this purpose.
1149 Except: If the register being saved is the CFA register, and the
1150 offset is non-zero, we are saving the CFA, so we assume we have to
1151 use DW_CFA_def_cfa_expression. If the offset is 0, we assume that
1152 the intent is to save the value of SP from the previous frame.
1154 Invariants / Summaries of Rules
1156 cfa current rule for calculating the CFA. It usually
1157 consists of a register and an offset.
1158 cfa_store register used by prologue code to save things to the stack
1159 cfa_store.offset is the offset from the value of
1160 cfa_store.reg to the actual CFA
1161 cfa_temp register holding an integral value. cfa_temp.offset
1162 stores the value, which will be used to adjust the
1163 stack pointer. cfa_temp is also used like cfa_store,
1164 to track stores to the stack via fp or a temp reg.
1166 Rules 1- 4: Setting a register's value to cfa.reg or an expression
1167 with cfa.reg as the first operand changes the cfa.reg and its
1168 cfa.offset. Rule 1 and 4 also set cfa_temp.reg and
1171 Rules 6- 9: Set a non-cfa.reg register value to a constant or an
1172 expression yielding a constant. This sets cfa_temp.reg
1173 and cfa_temp.offset.
1175 Rule 5: Create a new register cfa_store used to save items to the
1178 Rules 10-14: Save a register to the stack. Define offset as the
1179 difference of the original location and cfa_store's
1180 location (or cfa_temp's location if cfa_temp is used).
1184 "{a,b}" indicates a choice of a xor b.
1185 "<reg>:cfa.reg" indicates that <reg> must equal cfa.reg.
1188 (set <reg1> <reg2>:cfa.reg)
1189 effects: cfa.reg = <reg1>
1190 cfa.offset unchanged
1191 cfa_temp.reg = <reg1>
1192 cfa_temp.offset = cfa.offset
1195 (set sp ({minus,plus,losum} {sp,fp}:cfa.reg {<const_int>,<reg>:cfa_temp.reg}))
1196 effects: cfa.reg = sp if fp used
1197 cfa.offset += {+/- <const_int>, cfa_temp.offset} if cfa.reg==sp
1198 cfa_store.offset += {+/- <const_int>, cfa_temp.offset}
1199 if cfa_store.reg==sp
1202 (set fp ({minus,plus,losum} <reg>:cfa.reg <const_int>))
1203 effects: cfa.reg = fp
1204 cfa_offset += +/- <const_int>
1207 (set <reg1> ({plus,losum} <reg2>:cfa.reg <const_int>))
1208 constraints: <reg1> != fp
1210 effects: cfa.reg = <reg1>
1211 cfa_temp.reg = <reg1>
1212 cfa_temp.offset = cfa.offset
1215 (set <reg1> (plus <reg2>:cfa_temp.reg sp:cfa.reg))
1216 constraints: <reg1> != fp
1218 effects: cfa_store.reg = <reg1>
1219 cfa_store.offset = cfa.offset - cfa_temp.offset
1222 (set <reg> <const_int>)
1223 effects: cfa_temp.reg = <reg>
1224 cfa_temp.offset = <const_int>
1227 (set <reg1>:cfa_temp.reg (ior <reg2>:cfa_temp.reg <const_int>))
1228 effects: cfa_temp.reg = <reg1>
1229 cfa_temp.offset |= <const_int>
1232 (set <reg> (high <exp>))
1236 (set <reg> (lo_sum <exp> <const_int>))
1237 effects: cfa_temp.reg = <reg>
1238 cfa_temp.offset = <const_int>
1241 (set (mem (pre_modify sp:cfa_store (???? <reg1> <const_int>))) <reg2>)
1242 effects: cfa_store.offset -= <const_int>
1243 cfa.offset = cfa_store.offset if cfa.reg == sp
1245 cfa.base_offset = -cfa_store.offset
1248 (set (mem ({pre_inc,pre_dec} sp:cfa_store.reg)) <reg>)
1249 effects: cfa_store.offset += -/+ mode_size(mem)
1250 cfa.offset = cfa_store.offset if cfa.reg == sp
1252 cfa.base_offset = -cfa_store.offset
1255 (set (mem ({minus,plus,losum} <reg1>:{cfa_store,cfa_temp} <const_int>)) <reg2>)
1256 effects: cfa.reg = <reg1>
1257 cfa.base_offset = -/+ <const_int> - {cfa_store,cfa_temp}.offset
1260 (set (mem <reg1>:{cfa_store,cfa_temp}) <reg2>)
1261 effects: cfa.reg = <reg1>
1262 cfa.base_offset = -{cfa_store,cfa_temp}.offset
1265 (set (mem (postinc <reg1>:cfa_temp <const_int>)) <reg2>)
1266 effects: cfa.reg = <reg1>
1267 cfa.base_offset = -cfa_temp.offset
1268 cfa_temp.offset -= mode_size(mem) */
1271 dwarf2out_frame_debug_expr (expr
, label
)
1278 /* If RTX_FRAME_RELATED_P is set on a PARALLEL, process each member of
1279 the PARALLEL independently. The first element is always processed if
1280 it is a SET. This is for backward compatibility. Other elements
1281 are processed only if they are SETs and the RTX_FRAME_RELATED_P
1282 flag is set in them. */
1284 if (GET_CODE (expr
) == PARALLEL
1285 || GET_CODE (expr
) == SEQUENCE
)
1288 int limit
= XVECLEN (expr
, 0);
1290 for (par_index
= 0; par_index
< limit
; par_index
++)
1292 rtx x
= XVECEXP (expr
, 0, par_index
);
1294 if (GET_CODE (x
) == SET
&&
1295 (RTX_FRAME_RELATED_P (x
) || par_index
== 0))
1296 dwarf2out_frame_debug_expr (x
, label
);
1301 if (GET_CODE (expr
) != SET
)
1304 src
= SET_SRC (expr
);
1305 dest
= SET_DEST (expr
);
1307 switch (GET_CODE (dest
))
1311 /* Update the CFA rule wrt SP or FP. Make sure src is
1312 relative to the current CFA register. */
1313 switch (GET_CODE (src
))
1315 /* Setting FP from SP. */
1317 if (cfa
.reg
== (unsigned) REGNO (src
))
1323 /* We used to require that dest be either SP or FP, but the
1324 ARM copies SP to a temporary register, and from there to
1325 FP. So we just rely on the backends to only set
1326 RTX_FRAME_RELATED_P on appropriate insns. */
1327 cfa
.reg
= REGNO (dest
);
1328 cfa_temp
.reg
= cfa
.reg
;
1329 cfa_temp
.offset
= cfa
.offset
;
1335 if (dest
== stack_pointer_rtx
)
1339 switch (GET_CODE (XEXP (src
, 1)))
1342 offset
= INTVAL (XEXP (src
, 1));
1345 if ((unsigned) REGNO (XEXP (src
, 1)) != cfa_temp
.reg
)
1347 offset
= cfa_temp
.offset
;
1353 if (XEXP (src
, 0) == hard_frame_pointer_rtx
)
1355 /* Restoring SP from FP in the epilogue. */
1356 if (cfa
.reg
!= (unsigned) HARD_FRAME_POINTER_REGNUM
)
1358 cfa
.reg
= STACK_POINTER_REGNUM
;
1360 else if (GET_CODE (src
) == LO_SUM
)
1361 /* Assume we've set the source reg of the LO_SUM from sp. */
1363 else if (XEXP (src
, 0) != stack_pointer_rtx
)
1366 if (GET_CODE (src
) != MINUS
)
1368 if (cfa
.reg
== STACK_POINTER_REGNUM
)
1369 cfa
.offset
+= offset
;
1370 if (cfa_store
.reg
== STACK_POINTER_REGNUM
)
1371 cfa_store
.offset
+= offset
;
1373 else if (dest
== hard_frame_pointer_rtx
)
1376 /* Either setting the FP from an offset of the SP,
1377 or adjusting the FP */
1378 if (! frame_pointer_needed
)
1381 if (GET_CODE (XEXP (src
, 0)) == REG
1382 && (unsigned) REGNO (XEXP (src
, 0)) == cfa
.reg
1383 && GET_CODE (XEXP (src
, 1)) == CONST_INT
)
1385 offset
= INTVAL (XEXP (src
, 1));
1386 if (GET_CODE (src
) != MINUS
)
1388 cfa
.offset
+= offset
;
1389 cfa
.reg
= HARD_FRAME_POINTER_REGNUM
;
1396 if (GET_CODE (src
) == MINUS
)
1400 if (GET_CODE (XEXP (src
, 0)) == REG
1401 && REGNO (XEXP (src
, 0)) == cfa
.reg
1402 && GET_CODE (XEXP (src
, 1)) == CONST_INT
)
1404 /* Setting a temporary CFA register that will be copied
1405 into the FP later on. */
1406 offset
= - INTVAL (XEXP (src
, 1));
1407 cfa
.offset
+= offset
;
1408 cfa
.reg
= REGNO (dest
);
1409 /* Or used to save regs to the stack. */
1410 cfa_temp
.reg
= cfa
.reg
;
1411 cfa_temp
.offset
= cfa
.offset
;
1414 else if (GET_CODE (XEXP (src
, 0)) == REG
1415 && REGNO (XEXP (src
, 0)) == cfa_temp
.reg
1416 && XEXP (src
, 1) == stack_pointer_rtx
)
1418 /* Setting a scratch register that we will use instead
1419 of SP for saving registers to the stack. */
1420 if (cfa
.reg
!= STACK_POINTER_REGNUM
)
1422 cfa_store
.reg
= REGNO (dest
);
1423 cfa_store
.offset
= cfa
.offset
- cfa_temp
.offset
;
1426 else if (GET_CODE (src
) == LO_SUM
1427 && GET_CODE (XEXP (src
, 1)) == CONST_INT
)
1429 cfa_temp
.reg
= REGNO (dest
);
1430 cfa_temp
.offset
= INTVAL (XEXP (src
, 1));
1439 cfa_temp
.reg
= REGNO (dest
);
1440 cfa_temp
.offset
= INTVAL (src
);
1445 if (GET_CODE (XEXP (src
, 0)) != REG
1446 || (unsigned) REGNO (XEXP (src
, 0)) != cfa_temp
.reg
1447 || GET_CODE (XEXP (src
, 1)) != CONST_INT
)
1449 if ((unsigned) REGNO (dest
) != cfa_temp
.reg
)
1450 cfa_temp
.reg
= REGNO (dest
);
1451 cfa_temp
.offset
|= INTVAL (XEXP (src
, 1));
1454 /* Skip over HIGH, assuming it will be followed by a LO_SUM,
1455 which will fill in all of the bits. */
1463 def_cfa_1 (label
, &cfa
);
1467 if (GET_CODE (src
) != REG
)
1470 /* Saving a register to the stack. Make sure dest is relative to the
1472 switch (GET_CODE (XEXP (dest
, 0)))
1477 /* We can't handle variable size modifications. */
1478 if (GET_CODE (XEXP (XEXP (XEXP (dest
, 0), 1), 1)) != CONST_INT
)
1480 offset
= -INTVAL (XEXP (XEXP (XEXP (dest
, 0), 1), 1));
1482 if (REGNO (XEXP (XEXP (dest
, 0), 0)) != STACK_POINTER_REGNUM
1483 || cfa_store
.reg
!= STACK_POINTER_REGNUM
)
1485 cfa_store
.offset
+= offset
;
1486 if (cfa
.reg
== STACK_POINTER_REGNUM
)
1487 cfa
.offset
= cfa_store
.offset
;
1489 offset
= -cfa_store
.offset
;
1494 offset
= GET_MODE_SIZE (GET_MODE (dest
));
1495 if (GET_CODE (XEXP (dest
, 0)) == PRE_INC
)
1498 if (REGNO (XEXP (XEXP (dest
, 0), 0)) != STACK_POINTER_REGNUM
1499 || cfa_store
.reg
!= STACK_POINTER_REGNUM
)
1501 cfa_store
.offset
+= offset
;
1502 if (cfa
.reg
== STACK_POINTER_REGNUM
)
1503 cfa
.offset
= cfa_store
.offset
;
1505 offset
= -cfa_store
.offset
;
1509 /* With an offset. */
1513 if (GET_CODE (XEXP (XEXP (dest
, 0), 1)) != CONST_INT
)
1515 offset
= INTVAL (XEXP (XEXP (dest
, 0), 1));
1516 if (GET_CODE (XEXP (dest
, 0)) == MINUS
)
1519 if (cfa_store
.reg
== (unsigned) REGNO (XEXP (XEXP (dest
, 0), 0)))
1520 offset
-= cfa_store
.offset
;
1521 else if (cfa_temp
.reg
== (unsigned) REGNO (XEXP (XEXP (dest
, 0), 0)))
1522 offset
-= cfa_temp
.offset
;
1528 /* Without an offset. */
1530 if (cfa_store
.reg
== (unsigned) REGNO (XEXP (dest
, 0)))
1531 offset
= -cfa_store
.offset
;
1532 else if (cfa_temp
.reg
== (unsigned) REGNO (XEXP (dest
, 0)))
1533 offset
= -cfa_temp
.offset
;
1540 if (cfa_temp
.reg
!= (unsigned) REGNO (XEXP (XEXP (dest
, 0), 0)))
1542 offset
= -cfa_temp
.offset
;
1543 cfa_temp
.offset
-= GET_MODE_SIZE (GET_MODE (dest
));
1550 if (REGNO (src
) != STACK_POINTER_REGNUM
1551 && REGNO (src
) != HARD_FRAME_POINTER_REGNUM
1552 && (unsigned) REGNO (src
) == cfa
.reg
)
1554 /* We're storing the current CFA reg into the stack. */
1556 if (cfa
.offset
== 0)
1558 /* If the source register is exactly the CFA, assume
1559 we're saving SP like any other register; this happens
1562 def_cfa_1 (label
, &cfa
);
1563 queue_reg_save (label
, stack_pointer_rtx
, offset
);
1568 /* Otherwise, we'll need to look in the stack to
1569 calculate the CFA. */
1571 rtx x
= XEXP (dest
, 0);
1572 if (GET_CODE (x
) != REG
)
1574 if (GET_CODE (x
) != REG
)
1576 cfa
.reg
= (unsigned) REGNO (x
);
1577 cfa
.base_offset
= offset
;
1579 def_cfa_1 (label
, &cfa
);
1584 def_cfa_1 (label
, &cfa
);
1585 queue_reg_save (label
, src
, offset
);
1593 /* Record call frame debugging information for INSN, which either
1594 sets SP or FP (adjusting how we calculate the frame address) or saves a
1595 register to the stack. If INSN is NULL_RTX, initialize our state. */
1598 dwarf2out_frame_debug (insn
)
1604 if (insn
== NULL_RTX
)
1606 /* Flush any queued register saves. */
1607 flush_queued_reg_saves ();
1609 /* Set up state for generating call frame debug info. */
1611 if (cfa
.reg
!= (unsigned long) DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM
))
1613 cfa
.reg
= STACK_POINTER_REGNUM
;
1616 cfa_temp
.offset
= 0;
1620 if (GET_CODE (insn
) != INSN
|| clobbers_queued_reg_save (insn
))
1621 flush_queued_reg_saves ();
1623 if (! RTX_FRAME_RELATED_P (insn
))
1625 if (!ACCUMULATE_OUTGOING_ARGS
)
1626 dwarf2out_stack_adjust (insn
);
1630 label
= dwarf2out_cfi_label ();
1632 src
= find_reg_note (insn
, REG_FRAME_RELATED_EXPR
, NULL_RTX
);
1634 insn
= XEXP (src
, 0);
1636 insn
= PATTERN (insn
);
1638 dwarf2out_frame_debug_expr (insn
, label
);
1641 /* Output a Call Frame Information opcode and its operand(s). */
1644 output_cfi (cfi
, fde
, for_eh
)
1649 if (cfi
->dw_cfi_opc
== DW_CFA_advance_loc
)
1651 dw2_asm_output_data (1, (cfi
->dw_cfi_opc
1652 | (cfi
->dw_cfi_oprnd1
.dw_cfi_offset
& 0x3f)),
1653 "DW_CFA_advance_loc 0x%lx",
1654 cfi
->dw_cfi_oprnd1
.dw_cfi_offset
);
1656 else if (cfi
->dw_cfi_opc
== DW_CFA_offset
)
1658 dw2_asm_output_data (1, (cfi
->dw_cfi_opc
1659 | (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
& 0x3f)),
1660 "DW_CFA_offset, column 0x%lx",
1661 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1662 dw2_asm_output_data_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_offset
, NULL
);
1664 else if (cfi
->dw_cfi_opc
== DW_CFA_restore
)
1666 dw2_asm_output_data (1, (cfi
->dw_cfi_opc
1667 | (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
& 0x3f)),
1668 "DW_CFA_restore, column 0x%lx",
1669 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1673 dw2_asm_output_data (1, cfi
->dw_cfi_opc
,
1674 "%s", dwarf_cfi_name (cfi
->dw_cfi_opc
));
1676 switch (cfi
->dw_cfi_opc
)
1678 case DW_CFA_set_loc
:
1680 dw2_asm_output_encoded_addr_rtx (
1681 ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0),
1682 gen_rtx_SYMBOL_REF (Pmode
, cfi
->dw_cfi_oprnd1
.dw_cfi_addr
),
1685 dw2_asm_output_addr (DWARF2_ADDR_SIZE
,
1686 cfi
->dw_cfi_oprnd1
.dw_cfi_addr
, NULL
);
1688 case DW_CFA_advance_loc1
:
1689 dw2_asm_output_delta (1, cfi
->dw_cfi_oprnd1
.dw_cfi_addr
,
1690 fde
->dw_fde_current_label
, NULL
);
1691 fde
->dw_fde_current_label
= cfi
->dw_cfi_oprnd1
.dw_cfi_addr
;
1693 case DW_CFA_advance_loc2
:
1694 dw2_asm_output_delta (2, cfi
->dw_cfi_oprnd1
.dw_cfi_addr
,
1695 fde
->dw_fde_current_label
, NULL
);
1696 fde
->dw_fde_current_label
= cfi
->dw_cfi_oprnd1
.dw_cfi_addr
;
1698 case DW_CFA_advance_loc4
:
1699 dw2_asm_output_delta (4, cfi
->dw_cfi_oprnd1
.dw_cfi_addr
,
1700 fde
->dw_fde_current_label
, NULL
);
1701 fde
->dw_fde_current_label
= cfi
->dw_cfi_oprnd1
.dw_cfi_addr
;
1703 case DW_CFA_MIPS_advance_loc8
:
1704 dw2_asm_output_delta (8, cfi
->dw_cfi_oprnd1
.dw_cfi_addr
,
1705 fde
->dw_fde_current_label
, NULL
);
1706 fde
->dw_fde_current_label
= cfi
->dw_cfi_oprnd1
.dw_cfi_addr
;
1708 case DW_CFA_offset_extended
:
1709 case DW_CFA_GNU_negative_offset_extended
:
1710 case DW_CFA_def_cfa
:
1711 dw2_asm_output_data_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
, NULL
);
1712 dw2_asm_output_data_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_offset
, NULL
);
1714 case DW_CFA_restore_extended
:
1715 case DW_CFA_undefined
:
1716 case DW_CFA_same_value
:
1717 case DW_CFA_def_cfa_register
:
1718 dw2_asm_output_data_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
, NULL
);
1720 case DW_CFA_register
:
1721 dw2_asm_output_data_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
, NULL
);
1722 dw2_asm_output_data_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
, NULL
);
1724 case DW_CFA_def_cfa_offset
:
1725 case DW_CFA_GNU_args_size
:
1726 dw2_asm_output_data_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_offset
, NULL
);
1728 case DW_CFA_GNU_window_save
:
1730 case DW_CFA_def_cfa_expression
:
1731 output_cfa_loc (cfi
);
1739 /* Output the call frame information used to used to record information
1740 that relates to calculating the frame pointer, and records the
1741 location of saved registers. */
1744 output_call_frame_info (for_eh
)
1750 char l1
[20], l2
[20], section_start_label
[20];
1751 int any_lsda_needed
= 0;
1752 char augmentation
[6];
1753 int augmentation_size
;
1754 int fde_encoding
= DW_EH_PE_absptr
;
1755 int per_encoding
= DW_EH_PE_absptr
;
1756 int lsda_encoding
= DW_EH_PE_absptr
;
1758 /* If we don't have any functions we'll want to unwind out of, don't
1759 emit any EH unwind information. */
1762 int any_eh_needed
= flag_asynchronous_unwind_tables
;
1763 for (i
= 0; i
< fde_table_in_use
; ++i
)
1764 if (fde_table
[i
].uses_eh_lsda
)
1765 any_eh_needed
= any_lsda_needed
= 1;
1766 else if (! fde_table
[i
].nothrow
)
1769 if (! any_eh_needed
)
1773 /* We're going to be generating comments, so turn on app. */
1778 (*targetm
.asm_out
.eh_frame_section
) ();
1780 named_section_flags (DEBUG_FRAME_SECTION
, SECTION_DEBUG
);
1782 ASM_GENERATE_INTERNAL_LABEL (section_start_label
, FRAME_BEGIN_LABEL
, for_eh
);
1783 ASM_OUTPUT_LABEL (asm_out_file
, section_start_label
);
1785 /* Output the CIE. */
1786 ASM_GENERATE_INTERNAL_LABEL (l1
, CIE_AFTER_SIZE_LABEL
, for_eh
);
1787 ASM_GENERATE_INTERNAL_LABEL (l2
, CIE_END_LABEL
, for_eh
);
1788 dw2_asm_output_delta (for_eh
? 4 : DWARF_OFFSET_SIZE
, l2
, l1
,
1789 "Length of Common Information Entry");
1790 ASM_OUTPUT_LABEL (asm_out_file
, l1
);
1792 /* Now that the CIE pointer is PC-relative for EH,
1793 use 0 to identify the CIE. */
1794 dw2_asm_output_data ((for_eh
? 4 : DWARF_OFFSET_SIZE
),
1795 (for_eh
? 0 : DW_CIE_ID
),
1796 "CIE Identifier Tag");
1798 dw2_asm_output_data (1, DW_CIE_VERSION
, "CIE Version");
1800 augmentation
[0] = 0;
1801 augmentation_size
= 0;
1807 z Indicates that a uleb128 is present to size the
1808 augmentation section.
1809 L Indicates the encoding (and thus presence) of
1810 an LSDA pointer in the FDE augmentation.
1811 R Indicates a non-default pointer encoding for
1813 P Indicates the presence of an encoding + language
1814 personality routine in the CIE augmentation. */
1816 fde_encoding
= ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0);
1817 per_encoding
= ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1);
1818 lsda_encoding
= ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0);
1820 p
= augmentation
+ 1;
1821 if (eh_personality_libfunc
)
1824 augmentation_size
+= 1 + size_of_encoded_value (per_encoding
);
1826 if (any_lsda_needed
)
1829 augmentation_size
+= 1;
1831 if (fde_encoding
!= DW_EH_PE_absptr
)
1834 augmentation_size
+= 1;
1836 if (p
> augmentation
+ 1)
1838 augmentation
[0] = 'z';
1842 /* Ug. Some platforms can't do unaligned dynamic relocations at all. */
1843 if (eh_personality_libfunc
&& per_encoding
== DW_EH_PE_aligned
)
1845 int offset
= ( 4 /* Length */
1847 + 1 /* CIE version */
1848 + strlen (augmentation
) + 1 /* Augmentation */
1849 + size_of_uleb128 (1) /* Code alignment */
1850 + size_of_sleb128 (DWARF_CIE_DATA_ALIGNMENT
)
1852 + 1 /* Augmentation size */
1853 + 1 /* Personality encoding */ );
1854 int pad
= -offset
& (PTR_SIZE
- 1);
1856 augmentation_size
+= pad
;
1858 /* Augmentations should be small, so there's scarce need to
1859 iterate for a solution. Die if we exceed one uleb128 byte. */
1860 if (size_of_uleb128 (augmentation_size
) != 1)
1864 dw2_asm_output_nstring (augmentation
, -1, "CIE Augmentation");
1866 dw2_asm_output_data_uleb128 (1, "CIE Code Alignment Factor");
1868 dw2_asm_output_data_sleb128 (DWARF_CIE_DATA_ALIGNMENT
,
1869 "CIE Data Alignment Factor");
1871 dw2_asm_output_data (1, DWARF_FRAME_RETURN_COLUMN
, "CIE RA Column");
1873 if (augmentation
[0])
1875 dw2_asm_output_data_uleb128 (augmentation_size
, "Augmentation size");
1876 if (eh_personality_libfunc
)
1878 dw2_asm_output_data (1, per_encoding
, "Personality (%s)",
1879 eh_data_format_name (per_encoding
));
1880 dw2_asm_output_encoded_addr_rtx (per_encoding
,
1881 eh_personality_libfunc
, NULL
);
1883 if (any_lsda_needed
)
1884 dw2_asm_output_data (1, lsda_encoding
, "LSDA Encoding (%s)",
1885 eh_data_format_name (lsda_encoding
));
1886 if (fde_encoding
!= DW_EH_PE_absptr
)
1887 dw2_asm_output_data (1, fde_encoding
, "FDE Encoding (%s)",
1888 eh_data_format_name (fde_encoding
));
1891 for (cfi
= cie_cfi_head
; cfi
!= NULL
; cfi
= cfi
->dw_cfi_next
)
1892 output_cfi (cfi
, NULL
, for_eh
);
1894 /* Pad the CIE out to an address sized boundary. */
1895 ASM_OUTPUT_ALIGN (asm_out_file
,
1896 floor_log2 (for_eh
? PTR_SIZE
: DWARF2_ADDR_SIZE
));
1897 ASM_OUTPUT_LABEL (asm_out_file
, l2
);
1899 /* Loop through all of the FDE's. */
1900 for (i
= 0; i
< fde_table_in_use
; ++i
)
1902 fde
= &fde_table
[i
];
1904 /* Don't emit EH unwind info for leaf functions that don't need it. */
1905 if (for_eh
&& fde
->nothrow
&& ! fde
->uses_eh_lsda
)
1908 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, FDE_LABEL
, for_eh
+ i
* 2);
1909 ASM_GENERATE_INTERNAL_LABEL (l1
, FDE_AFTER_SIZE_LABEL
, for_eh
+ i
* 2);
1910 ASM_GENERATE_INTERNAL_LABEL (l2
, FDE_END_LABEL
, for_eh
+ i
* 2);
1911 dw2_asm_output_delta (for_eh
? 4 : DWARF_OFFSET_SIZE
, l2
, l1
,
1913 ASM_OUTPUT_LABEL (asm_out_file
, l1
);
1916 dw2_asm_output_delta (4, l1
, section_start_label
, "FDE CIE offset");
1918 dw2_asm_output_offset (DWARF_OFFSET_SIZE
, section_start_label
,
1923 dw2_asm_output_encoded_addr_rtx (fde_encoding
,
1924 gen_rtx_SYMBOL_REF (Pmode
, fde
->dw_fde_begin
),
1925 "FDE initial location");
1926 dw2_asm_output_delta (size_of_encoded_value (fde_encoding
),
1927 fde
->dw_fde_end
, fde
->dw_fde_begin
,
1928 "FDE address range");
1932 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, fde
->dw_fde_begin
,
1933 "FDE initial location");
1934 dw2_asm_output_delta (DWARF2_ADDR_SIZE
,
1935 fde
->dw_fde_end
, fde
->dw_fde_begin
,
1936 "FDE address range");
1939 if (augmentation
[0])
1941 if (any_lsda_needed
)
1943 int size
= size_of_encoded_value (lsda_encoding
);
1945 if (lsda_encoding
== DW_EH_PE_aligned
)
1947 int offset
= ( 4 /* Length */
1948 + 4 /* CIE offset */
1949 + 2 * size_of_encoded_value (fde_encoding
)
1950 + 1 /* Augmentation size */ );
1951 int pad
= -offset
& (PTR_SIZE
- 1);
1954 if (size_of_uleb128 (size
) != 1)
1958 dw2_asm_output_data_uleb128 (size
, "Augmentation size");
1960 if (fde
->uses_eh_lsda
)
1962 ASM_GENERATE_INTERNAL_LABEL (l1
, "LLSDA",
1963 fde
->funcdef_number
);
1964 dw2_asm_output_encoded_addr_rtx (
1965 lsda_encoding
, gen_rtx_SYMBOL_REF (Pmode
, l1
),
1966 "Language Specific Data Area");
1970 if (lsda_encoding
== DW_EH_PE_aligned
)
1971 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (PTR_SIZE
));
1972 dw2_asm_output_data (size_of_encoded_value (lsda_encoding
),
1973 0, "Language Specific Data Area (none)");
1977 dw2_asm_output_data_uleb128 (0, "Augmentation size");
1980 /* Loop through the Call Frame Instructions associated with
1982 fde
->dw_fde_current_label
= fde
->dw_fde_begin
;
1983 for (cfi
= fde
->dw_fde_cfi
; cfi
!= NULL
; cfi
= cfi
->dw_cfi_next
)
1984 output_cfi (cfi
, fde
, for_eh
);
1986 /* Pad the FDE out to an address sized boundary. */
1987 ASM_OUTPUT_ALIGN (asm_out_file
,
1988 floor_log2 ((for_eh
? PTR_SIZE
: DWARF2_ADDR_SIZE
)));
1989 ASM_OUTPUT_LABEL (asm_out_file
, l2
);
1992 #ifndef EH_FRAME_SECTION_NAME
1994 dw2_asm_output_data (4, 0, "End of Table");
1996 #ifdef MIPS_DEBUGGING_INFO
1997 /* Work around Irix 6 assembler bug whereby labels at the end of a section
1998 get a value of 0. Putting .align 0 after the label fixes it. */
1999 ASM_OUTPUT_ALIGN (asm_out_file
, 0);
2002 /* Turn off app to make assembly quicker. */
2007 /* Output a marker (i.e. a label) for the beginning of a function, before
2011 dwarf2out_begin_prologue (line
, file
)
2012 unsigned int line ATTRIBUTE_UNUSED
;
2013 const char *file ATTRIBUTE_UNUSED
;
2015 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2018 current_function_func_begin_label
= 0;
2020 #ifdef IA64_UNWIND_INFO
2021 /* ??? current_function_func_begin_label is also used by except.c
2022 for call-site information. We must emit this label if it might
2024 if ((! flag_exceptions
|| USING_SJLJ_EXCEPTIONS
)
2025 && ! dwarf2out_do_frame ())
2028 if (! dwarf2out_do_frame ())
2032 ++current_funcdef_number
;
2034 function_section (current_function_decl
);
2035 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_BEGIN_LABEL
,
2036 current_funcdef_number
);
2037 ASM_OUTPUT_DEBUG_LABEL (asm_out_file
, FUNC_BEGIN_LABEL
,
2038 current_funcdef_number
);
2039 current_function_func_begin_label
= get_identifier (label
);
2041 #ifdef IA64_UNWIND_INFO
2042 /* We can elide the fde allocation if we're not emitting debug info. */
2043 if (! dwarf2out_do_frame ())
2047 /* Expand the fde table if necessary. */
2048 if (fde_table_in_use
== fde_table_allocated
)
2050 fde_table_allocated
+= FDE_TABLE_INCREMENT
;
2052 = (dw_fde_ref
) xrealloc (fde_table
,
2053 fde_table_allocated
* sizeof (dw_fde_node
));
2056 /* Record the FDE associated with this function. */
2057 current_funcdef_fde
= fde_table_in_use
;
2059 /* Add the new FDE at the end of the fde_table. */
2060 fde
= &fde_table
[fde_table_in_use
++];
2061 fde
->dw_fde_begin
= xstrdup (label
);
2062 fde
->dw_fde_current_label
= NULL
;
2063 fde
->dw_fde_end
= NULL
;
2064 fde
->dw_fde_cfi
= NULL
;
2065 fde
->funcdef_number
= current_funcdef_number
;
2066 fde
->nothrow
= current_function_nothrow
;
2067 fde
->uses_eh_lsda
= cfun
->uses_eh_lsda
;
2069 args_size
= old_args_size
= 0;
2071 /* We only want to output line number information for the genuine
2072 dwarf2 prologue case, not the eh frame case. */
2073 #ifdef DWARF2_DEBUGGING_INFO
2075 dwarf2out_source_line (line
, file
);
2079 /* Output a marker (i.e. a label) for the absolute end of the generated code
2080 for a function definition. This gets called *after* the epilogue code has
2084 dwarf2out_end_epilogue ()
2087 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2089 /* Output a label to mark the endpoint of the code generated for this
2091 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_END_LABEL
, current_funcdef_number
);
2092 ASM_OUTPUT_LABEL (asm_out_file
, label
);
2093 fde
= &fde_table
[fde_table_in_use
- 1];
2094 fde
->dw_fde_end
= xstrdup (label
);
2098 dwarf2out_frame_init ()
2100 /* Allocate the initial hunk of the fde_table. */
2101 fde_table
= (dw_fde_ref
) xcalloc (FDE_TABLE_INCREMENT
, sizeof (dw_fde_node
));
2102 fde_table_allocated
= FDE_TABLE_INCREMENT
;
2103 fde_table_in_use
= 0;
2105 /* Generate the CFA instructions common to all FDE's. Do it now for the
2106 sake of lookup_cfa. */
2108 #ifdef DWARF2_UNWIND_INFO
2109 /* On entry, the Canonical Frame Address is at SP. */
2110 dwarf2out_def_cfa (NULL
, STACK_POINTER_REGNUM
, INCOMING_FRAME_SP_OFFSET
);
2111 initial_return_save (INCOMING_RETURN_ADDR_RTX
);
2116 dwarf2out_frame_finish ()
2118 /* Output call frame information. */
2119 if (write_symbols
== DWARF2_DEBUG
|| write_symbols
== VMS_AND_DWARF2_DEBUG
)
2120 output_call_frame_info (0);
2121 if (! USING_SJLJ_EXCEPTIONS
&& (flag_unwind_tables
|| flag_exceptions
))
2122 output_call_frame_info (1);
2125 /* And now, the subset of the debugging information support code necessary
2126 for emitting location expressions. */
2128 typedef struct dw_val_struct
*dw_val_ref
;
2129 typedef struct die_struct
*dw_die_ref
;
2130 typedef struct dw_loc_descr_struct
*dw_loc_descr_ref
;
2131 typedef struct dw_loc_list_struct
*dw_loc_list_ref
;
2133 /* Each DIE may have a series of attribute/value pairs. Values
2134 can take on several forms. The forms that are used in this
2135 implementation are listed below. */
2140 dw_val_class_offset
,
2142 dw_val_class_loc_list
,
2143 dw_val_class_range_list
,
2145 dw_val_class_unsigned_const
,
2146 dw_val_class_long_long
,
2149 dw_val_class_die_ref
,
2150 dw_val_class_fde_ref
,
2151 dw_val_class_lbl_id
,
2152 dw_val_class_lbl_offset
,
2157 /* Describe a double word constant value. */
2158 /* ??? Every instance of long_long in the code really means CONST_DOUBLE. */
2160 typedef struct dw_long_long_struct
2167 /* Describe a floating point constant value. */
2169 typedef struct dw_fp_struct
2176 /* The dw_val_node describes an attribute's value, as it is
2177 represented internally. */
2179 typedef struct dw_val_struct
2181 dw_val_class val_class
;
2185 long unsigned val_offset
;
2186 dw_loc_list_ref val_loc_list
;
2187 dw_loc_descr_ref val_loc
;
2189 long unsigned val_unsigned
;
2190 dw_long_long_const val_long_long
;
2191 dw_float_const val_float
;
2196 unsigned val_fde_index
;
2197 struct indirect_string_node
*val_str
;
2199 unsigned char val_flag
;
2205 /* Locations in memory are described using a sequence of stack machine
2208 typedef struct dw_loc_descr_struct
2210 dw_loc_descr_ref dw_loc_next
;
2211 enum dwarf_location_atom dw_loc_opc
;
2212 dw_val_node dw_loc_oprnd1
;
2213 dw_val_node dw_loc_oprnd2
;
2218 /* Location lists are ranges + location descriptions for that range,
2219 so you can track variables that are in different places over
2220 their entire life. */
2221 typedef struct dw_loc_list_struct
2223 dw_loc_list_ref dw_loc_next
;
2224 const char *begin
; /* Label for begin address of range */
2225 const char *end
; /* Label for end address of range */
2226 char *ll_symbol
; /* Label for beginning of location list. Only on head of list */
2227 const char *section
; /* Section this loclist is relative to */
2228 dw_loc_descr_ref expr
;
2231 static const char *dwarf_stack_op_name
PARAMS ((unsigned));
2232 static dw_loc_descr_ref new_loc_descr
PARAMS ((enum dwarf_location_atom
,
2235 static void add_loc_descr
PARAMS ((dw_loc_descr_ref
*,
2237 static unsigned long size_of_loc_descr
PARAMS ((dw_loc_descr_ref
));
2238 static unsigned long size_of_locs
PARAMS ((dw_loc_descr_ref
));
2239 static void output_loc_operands
PARAMS ((dw_loc_descr_ref
));
2240 static void output_loc_sequence
PARAMS ((dw_loc_descr_ref
));
2242 /* Convert a DWARF stack opcode into its string name. */
2245 dwarf_stack_op_name (op
)
2251 return "DW_OP_addr";
2253 return "DW_OP_deref";
2255 return "DW_OP_const1u";
2257 return "DW_OP_const1s";
2259 return "DW_OP_const2u";
2261 return "DW_OP_const2s";
2263 return "DW_OP_const4u";
2265 return "DW_OP_const4s";
2267 return "DW_OP_const8u";
2269 return "DW_OP_const8s";
2271 return "DW_OP_constu";
2273 return "DW_OP_consts";
2277 return "DW_OP_drop";
2279 return "DW_OP_over";
2281 return "DW_OP_pick";
2283 return "DW_OP_swap";
2287 return "DW_OP_xderef";
2295 return "DW_OP_minus";
2307 return "DW_OP_plus";
2308 case DW_OP_plus_uconst
:
2309 return "DW_OP_plus_uconst";
2315 return "DW_OP_shra";
2333 return "DW_OP_skip";
2335 return "DW_OP_lit0";
2337 return "DW_OP_lit1";
2339 return "DW_OP_lit2";
2341 return "DW_OP_lit3";
2343 return "DW_OP_lit4";
2345 return "DW_OP_lit5";
2347 return "DW_OP_lit6";
2349 return "DW_OP_lit7";
2351 return "DW_OP_lit8";
2353 return "DW_OP_lit9";
2355 return "DW_OP_lit10";
2357 return "DW_OP_lit11";
2359 return "DW_OP_lit12";
2361 return "DW_OP_lit13";
2363 return "DW_OP_lit14";
2365 return "DW_OP_lit15";
2367 return "DW_OP_lit16";
2369 return "DW_OP_lit17";
2371 return "DW_OP_lit18";
2373 return "DW_OP_lit19";
2375 return "DW_OP_lit20";
2377 return "DW_OP_lit21";
2379 return "DW_OP_lit22";
2381 return "DW_OP_lit23";
2383 return "DW_OP_lit24";
2385 return "DW_OP_lit25";
2387 return "DW_OP_lit26";
2389 return "DW_OP_lit27";
2391 return "DW_OP_lit28";
2393 return "DW_OP_lit29";
2395 return "DW_OP_lit30";
2397 return "DW_OP_lit31";
2399 return "DW_OP_reg0";
2401 return "DW_OP_reg1";
2403 return "DW_OP_reg2";
2405 return "DW_OP_reg3";
2407 return "DW_OP_reg4";
2409 return "DW_OP_reg5";
2411 return "DW_OP_reg6";
2413 return "DW_OP_reg7";
2415 return "DW_OP_reg8";
2417 return "DW_OP_reg9";
2419 return "DW_OP_reg10";
2421 return "DW_OP_reg11";
2423 return "DW_OP_reg12";
2425 return "DW_OP_reg13";
2427 return "DW_OP_reg14";
2429 return "DW_OP_reg15";
2431 return "DW_OP_reg16";
2433 return "DW_OP_reg17";
2435 return "DW_OP_reg18";
2437 return "DW_OP_reg19";
2439 return "DW_OP_reg20";
2441 return "DW_OP_reg21";
2443 return "DW_OP_reg22";
2445 return "DW_OP_reg23";
2447 return "DW_OP_reg24";
2449 return "DW_OP_reg25";
2451 return "DW_OP_reg26";
2453 return "DW_OP_reg27";
2455 return "DW_OP_reg28";
2457 return "DW_OP_reg29";
2459 return "DW_OP_reg30";
2461 return "DW_OP_reg31";
2463 return "DW_OP_breg0";
2465 return "DW_OP_breg1";
2467 return "DW_OP_breg2";
2469 return "DW_OP_breg3";
2471 return "DW_OP_breg4";
2473 return "DW_OP_breg5";
2475 return "DW_OP_breg6";
2477 return "DW_OP_breg7";
2479 return "DW_OP_breg8";
2481 return "DW_OP_breg9";
2483 return "DW_OP_breg10";
2485 return "DW_OP_breg11";
2487 return "DW_OP_breg12";
2489 return "DW_OP_breg13";
2491 return "DW_OP_breg14";
2493 return "DW_OP_breg15";
2495 return "DW_OP_breg16";
2497 return "DW_OP_breg17";
2499 return "DW_OP_breg18";
2501 return "DW_OP_breg19";
2503 return "DW_OP_breg20";
2505 return "DW_OP_breg21";
2507 return "DW_OP_breg22";
2509 return "DW_OP_breg23";
2511 return "DW_OP_breg24";
2513 return "DW_OP_breg25";
2515 return "DW_OP_breg26";
2517 return "DW_OP_breg27";
2519 return "DW_OP_breg28";
2521 return "DW_OP_breg29";
2523 return "DW_OP_breg30";
2525 return "DW_OP_breg31";
2527 return "DW_OP_regx";
2529 return "DW_OP_fbreg";
2531 return "DW_OP_bregx";
2533 return "DW_OP_piece";
2534 case DW_OP_deref_size
:
2535 return "DW_OP_deref_size";
2536 case DW_OP_xderef_size
:
2537 return "DW_OP_xderef_size";
2541 return "OP_<unknown>";
2545 /* Return a pointer to a newly allocated location description. Location
2546 descriptions are simple expression terms that can be strung
2547 together to form more complicated location (address) descriptions. */
2549 static inline dw_loc_descr_ref
2550 new_loc_descr (op
, oprnd1
, oprnd2
)
2551 enum dwarf_location_atom op
;
2552 unsigned long oprnd1
;
2553 unsigned long oprnd2
;
2555 /* Use xcalloc here so we clear out all of the long_long constant in
2557 dw_loc_descr_ref descr
2558 = (dw_loc_descr_ref
) xcalloc (1, sizeof (dw_loc_descr_node
));
2560 descr
->dw_loc_opc
= op
;
2561 descr
->dw_loc_oprnd1
.val_class
= dw_val_class_unsigned_const
;
2562 descr
->dw_loc_oprnd1
.v
.val_unsigned
= oprnd1
;
2563 descr
->dw_loc_oprnd2
.val_class
= dw_val_class_unsigned_const
;
2564 descr
->dw_loc_oprnd2
.v
.val_unsigned
= oprnd2
;
2570 /* Add a location description term to a location description expression. */
2573 add_loc_descr (list_head
, descr
)
2574 dw_loc_descr_ref
*list_head
;
2575 dw_loc_descr_ref descr
;
2577 dw_loc_descr_ref
*d
;
2579 /* Find the end of the chain. */
2580 for (d
= list_head
; (*d
) != NULL
; d
= &(*d
)->dw_loc_next
)
2586 /* Return the size of a location descriptor. */
2588 static unsigned long
2589 size_of_loc_descr (loc
)
2590 dw_loc_descr_ref loc
;
2592 unsigned long size
= 1;
2594 switch (loc
->dw_loc_opc
)
2597 size
+= DWARF2_ADDR_SIZE
;
2616 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
2619 size
+= size_of_sleb128 (loc
->dw_loc_oprnd1
.v
.val_int
);
2624 case DW_OP_plus_uconst
:
2625 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
2663 size
+= size_of_sleb128 (loc
->dw_loc_oprnd1
.v
.val_int
);
2666 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
2669 size
+= size_of_sleb128 (loc
->dw_loc_oprnd1
.v
.val_int
);
2672 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
2673 size
+= size_of_sleb128 (loc
->dw_loc_oprnd2
.v
.val_int
);
2676 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
2678 case DW_OP_deref_size
:
2679 case DW_OP_xderef_size
:
2689 /* Return the size of a series of location descriptors. */
2691 static unsigned long
2693 dw_loc_descr_ref loc
;
2695 unsigned long size
= 0;
2697 for (; loc
!= NULL
; loc
= loc
->dw_loc_next
)
2699 loc
->dw_loc_addr
= size
;
2700 size
+= size_of_loc_descr (loc
);
2706 /* Output location description stack opcode's operands (if any). */
2709 output_loc_operands (loc
)
2710 dw_loc_descr_ref loc
;
2712 dw_val_ref val1
= &loc
->dw_loc_oprnd1
;
2713 dw_val_ref val2
= &loc
->dw_loc_oprnd2
;
2715 switch (loc
->dw_loc_opc
)
2717 #ifdef DWARF2_DEBUGGING_INFO
2719 dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE
, val1
->v
.val_addr
, NULL
);
2723 dw2_asm_output_data (2, val1
->v
.val_int
, NULL
);
2727 dw2_asm_output_data (4, val1
->v
.val_int
, NULL
);
2731 if (HOST_BITS_PER_LONG
< 64)
2733 dw2_asm_output_data (8, val1
->v
.val_int
, NULL
);
2740 if (val1
->val_class
== dw_val_class_loc
)
2741 offset
= val1
->v
.val_loc
->dw_loc_addr
- (loc
->dw_loc_addr
+ 3);
2745 dw2_asm_output_data (2, offset
, NULL
);
2758 /* We currently don't make any attempt to make sure these are
2759 aligned properly like we do for the main unwind info, so
2760 don't support emitting things larger than a byte if we're
2761 only doing unwinding. */
2766 dw2_asm_output_data (1, val1
->v
.val_int
, NULL
);
2769 dw2_asm_output_data_uleb128 (val1
->v
.val_unsigned
, NULL
);
2772 dw2_asm_output_data_sleb128 (val1
->v
.val_int
, NULL
);
2775 dw2_asm_output_data (1, val1
->v
.val_int
, NULL
);
2777 case DW_OP_plus_uconst
:
2778 dw2_asm_output_data_uleb128 (val1
->v
.val_unsigned
, NULL
);
2812 dw2_asm_output_data_sleb128 (val1
->v
.val_int
, NULL
);
2815 dw2_asm_output_data_uleb128 (val1
->v
.val_unsigned
, NULL
);
2818 dw2_asm_output_data_sleb128 (val1
->v
.val_int
, NULL
);
2821 dw2_asm_output_data_uleb128 (val1
->v
.val_unsigned
, NULL
);
2822 dw2_asm_output_data_sleb128 (val2
->v
.val_int
, NULL
);
2825 dw2_asm_output_data_uleb128 (val1
->v
.val_unsigned
, NULL
);
2827 case DW_OP_deref_size
:
2828 case DW_OP_xderef_size
:
2829 dw2_asm_output_data (1, val1
->v
.val_int
, NULL
);
2832 /* Other codes have no operands. */
2837 /* Output a sequence of location operations. */
2840 output_loc_sequence (loc
)
2841 dw_loc_descr_ref loc
;
2843 for (; loc
!= NULL
; loc
= loc
->dw_loc_next
)
2845 /* Output the opcode. */
2846 dw2_asm_output_data (1, loc
->dw_loc_opc
,
2847 "%s", dwarf_stack_op_name (loc
->dw_loc_opc
));
2849 /* Output the operand(s) (if any). */
2850 output_loc_operands (loc
);
2854 /* This routine will generate the correct assembly data for a location
2855 description based on a cfi entry with a complex address. */
2858 output_cfa_loc (cfi
)
2861 dw_loc_descr_ref loc
;
2864 /* Output the size of the block. */
2865 loc
= cfi
->dw_cfi_oprnd1
.dw_cfi_loc
;
2866 size
= size_of_locs (loc
);
2867 dw2_asm_output_data_uleb128 (size
, NULL
);
2869 /* Now output the operations themselves. */
2870 output_loc_sequence (loc
);
2873 /* This function builds a dwarf location descriptor sequence from
2874 a dw_cfa_location. */
2876 static struct dw_loc_descr_struct
*
2878 dw_cfa_location
*cfa
;
2880 struct dw_loc_descr_struct
*head
, *tmp
;
2882 if (cfa
->indirect
== 0)
2885 if (cfa
->base_offset
)
2888 head
= new_loc_descr (DW_OP_breg0
+ cfa
->reg
, cfa
->base_offset
, 0);
2890 head
= new_loc_descr (DW_OP_bregx
, cfa
->reg
, cfa
->base_offset
);
2892 else if (cfa
->reg
<= 31)
2893 head
= new_loc_descr (DW_OP_reg0
+ cfa
->reg
, 0, 0);
2895 head
= new_loc_descr (DW_OP_regx
, cfa
->reg
, 0);
2896 head
->dw_loc_oprnd1
.val_class
= dw_val_class_const
;
2897 tmp
= new_loc_descr (DW_OP_deref
, 0, 0);
2898 add_loc_descr (&head
, tmp
);
2899 if (cfa
->offset
!= 0)
2901 tmp
= new_loc_descr (DW_OP_plus_uconst
, cfa
->offset
, 0);
2902 add_loc_descr (&head
, tmp
);
2907 /* This function fills in aa dw_cfa_location structure from a
2908 dwarf location descriptor sequence. */
2911 get_cfa_from_loc_descr (cfa
, loc
)
2912 dw_cfa_location
*cfa
;
2913 struct dw_loc_descr_struct
*loc
;
2915 struct dw_loc_descr_struct
*ptr
;
2917 cfa
->base_offset
= 0;
2921 for (ptr
= loc
; ptr
!= NULL
; ptr
= ptr
->dw_loc_next
)
2923 enum dwarf_location_atom op
= ptr
->dw_loc_opc
;
2958 cfa
->reg
= op
- DW_OP_reg0
;
2961 cfa
->reg
= ptr
->dw_loc_oprnd1
.v
.val_int
;
2995 cfa
->reg
= op
- DW_OP_breg0
;
2996 cfa
->base_offset
= ptr
->dw_loc_oprnd1
.v
.val_int
;
2999 cfa
->reg
= ptr
->dw_loc_oprnd1
.v
.val_int
;
3000 cfa
->base_offset
= ptr
->dw_loc_oprnd2
.v
.val_int
;
3005 case DW_OP_plus_uconst
:
3006 cfa
->offset
= ptr
->dw_loc_oprnd1
.v
.val_unsigned
;
3009 internal_error ("DW_LOC_OP %s not implemented\n",
3010 dwarf_stack_op_name (ptr
->dw_loc_opc
));
3014 #endif /* .debug_frame support */
3016 /* And now, the support for symbolic debugging information. */
3017 #ifdef DWARF2_DEBUGGING_INFO
3019 static void dwarf2out_init
PARAMS ((const char *));
3020 static void dwarf2out_finish
PARAMS ((const char *));
3021 static void dwarf2out_define
PARAMS ((unsigned int, const char *));
3022 static void dwarf2out_undef
PARAMS ((unsigned int, const char *));
3023 static void dwarf2out_start_source_file
PARAMS ((unsigned, const char *));
3024 static void dwarf2out_end_source_file
PARAMS ((unsigned));
3025 static void dwarf2out_begin_block
PARAMS ((unsigned, unsigned));
3026 static void dwarf2out_end_block
PARAMS ((unsigned, unsigned));
3027 static bool dwarf2out_ignore_block
PARAMS ((tree
));
3028 static void dwarf2out_global_decl
PARAMS ((tree
));
3029 static void dwarf2out_abstract_function
PARAMS ((tree
));
3031 /* The debug hooks structure. */
3033 struct gcc_debug_hooks dwarf2_debug_hooks
=
3039 dwarf2out_start_source_file
,
3040 dwarf2out_end_source_file
,
3041 dwarf2out_begin_block
,
3042 dwarf2out_end_block
,
3043 dwarf2out_ignore_block
,
3044 dwarf2out_source_line
,
3045 dwarf2out_begin_prologue
,
3046 debug_nothing_int
, /* end_prologue */
3047 dwarf2out_end_epilogue
,
3048 debug_nothing_tree
, /* begin_function */
3049 debug_nothing_int
, /* end_function */
3050 dwarf2out_decl
, /* function_decl */
3051 dwarf2out_global_decl
,
3052 debug_nothing_tree
, /* deferred_inline_function */
3053 /* The DWARF 2 backend tries to reduce debugging bloat by not
3054 emitting the abstract description of inline functions until
3055 something tries to reference them. */
3056 dwarf2out_abstract_function
, /* outlining_inline_function */
3057 debug_nothing_rtx
/* label */
3060 /* NOTE: In the comments in this file, many references are made to
3061 "Debugging Information Entries". This term is abbreviated as `DIE'
3062 throughout the remainder of this file. */
3064 /* An internal representation of the DWARF output is built, and then
3065 walked to generate the DWARF debugging info. The walk of the internal
3066 representation is done after the entire program has been compiled.
3067 The types below are used to describe the internal representation. */
3069 /* Various DIE's use offsets relative to the beginning of the
3070 .debug_info section to refer to each other. */
3072 typedef long int dw_offset
;
3074 /* Define typedefs here to avoid circular dependencies. */
3076 typedef struct dw_attr_struct
*dw_attr_ref
;
3077 typedef struct dw_line_info_struct
*dw_line_info_ref
;
3078 typedef struct dw_separate_line_info_struct
*dw_separate_line_info_ref
;
3079 typedef struct pubname_struct
*pubname_ref
;
3080 typedef struct dw_ranges_struct
*dw_ranges_ref
;
3082 /* Each entry in the line_info_table maintains the file and
3083 line number associated with the label generated for that
3084 entry. The label gives the PC value associated with
3085 the line number entry. */
3087 typedef struct dw_line_info_struct
3089 unsigned long dw_file_num
;
3090 unsigned long dw_line_num
;
3094 /* Line information for functions in separate sections; each one gets its
3096 typedef struct dw_separate_line_info_struct
3098 unsigned long dw_file_num
;
3099 unsigned long dw_line_num
;
3100 unsigned long function
;
3102 dw_separate_line_info_entry
;
3104 /* Each DIE attribute has a field specifying the attribute kind,
3105 a link to the next attribute in the chain, and an attribute value.
3106 Attributes are typically linked below the DIE they modify. */
3108 typedef struct dw_attr_struct
3110 enum dwarf_attribute dw_attr
;
3111 dw_attr_ref dw_attr_next
;
3112 dw_val_node dw_attr_val
;
3116 /* The Debugging Information Entry (DIE) structure */
3118 typedef struct die_struct
3120 enum dwarf_tag die_tag
;
3122 dw_attr_ref die_attr
;
3123 dw_die_ref die_parent
;
3124 dw_die_ref die_child
;
3126 dw_offset die_offset
;
3127 unsigned long die_abbrev
;
3132 /* The pubname structure */
3134 typedef struct pubname_struct
3141 struct dw_ranges_struct
3146 /* The limbo die list structure. */
3147 typedef struct limbo_die_struct
3150 struct limbo_die_struct
*next
;
3154 /* How to start an assembler comment. */
3155 #ifndef ASM_COMMENT_START
3156 #define ASM_COMMENT_START ";#"
3159 /* Define a macro which returns non-zero for a TYPE_DECL which was
3160 implicitly generated for a tagged type.
3162 Note that unlike the gcc front end (which generates a NULL named
3163 TYPE_DECL node for each complete tagged type, each array type, and
3164 each function type node created) the g++ front end generates a
3165 _named_ TYPE_DECL node for each tagged type node created.
3166 These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
3167 generate a DW_TAG_typedef DIE for them. */
3169 #define TYPE_DECL_IS_STUB(decl) \
3170 (DECL_NAME (decl) == NULL_TREE \
3171 || (DECL_ARTIFICIAL (decl) \
3172 && is_tagged_type (TREE_TYPE (decl)) \
3173 && ((decl == TYPE_STUB_DECL (TREE_TYPE (decl))) \
3174 /* This is necessary for stub decls that \
3175 appear in nested inline functions. */ \
3176 || (DECL_ABSTRACT_ORIGIN (decl) != NULL_TREE \
3177 && (decl_ultimate_origin (decl) \
3178 == TYPE_STUB_DECL (TREE_TYPE (decl)))))))
3180 /* Information concerning the compilation unit's programming
3181 language, and compiler version. */
3183 extern int flag_traditional
;
3185 /* Fixed size portion of the DWARF compilation unit header. */
3186 #define DWARF_COMPILE_UNIT_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 3)
3188 /* Fixed size portion of debugging line information prolog. */
3189 #define DWARF_LINE_PROLOG_HEADER_SIZE 5
3191 /* Fixed size portion of public names info. */
3192 #define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
3194 /* Fixed size portion of the address range info. */
3195 #define DWARF_ARANGES_HEADER_SIZE \
3196 (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, DWARF2_ADDR_SIZE * 2) \
3197 - DWARF_OFFSET_SIZE)
3199 /* Size of padding portion in the address range info. It must be
3200 aligned to twice the pointer size. */
3201 #define DWARF_ARANGES_PAD_SIZE \
3202 (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, DWARF2_ADDR_SIZE * 2) \
3203 - (2 * DWARF_OFFSET_SIZE + 4))
3205 /* Use assembler line directives if available. */
3206 #ifndef DWARF2_ASM_LINE_DEBUG_INFO
3207 #ifdef HAVE_AS_DWARF2_DEBUG_LINE
3208 #define DWARF2_ASM_LINE_DEBUG_INFO 1
3210 #define DWARF2_ASM_LINE_DEBUG_INFO 0
3214 /* Define the architecture-dependent minimum instruction length (in bytes).
3215 In this implementation of DWARF, this field is used for information
3216 purposes only. Since GCC generates assembly language, we have
3217 no a priori knowledge of how many instruction bytes are generated
3218 for each source line, and therefore can use only the DW_LNE_set_address
3219 and DW_LNS_fixed_advance_pc line information commands. */
3221 #ifndef DWARF_LINE_MIN_INSTR_LENGTH
3222 #define DWARF_LINE_MIN_INSTR_LENGTH 4
3225 /* Minimum line offset in a special line info. opcode.
3226 This value was chosen to give a reasonable range of values. */
3227 #define DWARF_LINE_BASE -10
3229 /* First special line opcode - leave room for the standard opcodes. */
3230 #define DWARF_LINE_OPCODE_BASE 10
3232 /* Range of line offsets in a special line info. opcode. */
3233 #define DWARF_LINE_RANGE (254-DWARF_LINE_OPCODE_BASE+1)
3235 /* Flag that indicates the initial value of the is_stmt_start flag.
3236 In the present implementation, we do not mark any lines as
3237 the beginning of a source statement, because that information
3238 is not made available by the GCC front-end. */
3239 #define DWARF_LINE_DEFAULT_IS_STMT_START 1
3241 /* This location is used by calc_die_sizes() to keep track
3242 the offset of each DIE within the .debug_info section. */
3243 static unsigned long next_die_offset
;
3245 /* Record the root of the DIE's built for the current compilation unit. */
3246 static dw_die_ref comp_unit_die
;
3248 /* A list of DIEs with a NULL parent waiting to be relocated. */
3249 static limbo_die_node
*limbo_die_list
= 0;
3251 /* Structure used by lookup_filename to manage sets of filenames. */
3257 unsigned last_lookup_index
;
3260 /* Size (in elements) of increments by which we may expand the filename
3262 #define FILE_TABLE_INCREMENT 64
3264 /* Filenames referenced by this compilation unit. */
3265 static struct file_table file_table
;
3267 /* Local pointer to the name of the main input file. Initialized in
3269 static const char *primary_filename
;
3271 /* A pointer to the base of a table of references to DIE's that describe
3272 declarations. The table is indexed by DECL_UID() which is a unique
3273 number identifying each decl. */
3274 static dw_die_ref
*decl_die_table
;
3276 /* Number of elements currently allocated for the decl_die_table. */
3277 static unsigned decl_die_table_allocated
;
3279 /* Number of elements in decl_die_table currently in use. */
3280 static unsigned decl_die_table_in_use
;
3282 /* Size (in elements) of increments by which we may expand the
3284 #define DECL_DIE_TABLE_INCREMENT 256
3286 /* A pointer to the base of a table of references to declaration
3287 scopes. This table is a display which tracks the nesting
3288 of declaration scopes at the current scope and containing
3289 scopes. This table is used to find the proper place to
3290 define type declaration DIE's. */
3291 varray_type decl_scope_table
;
3293 /* A pointer to the base of a list of references to DIE's that
3294 are uniquely identified by their tag, presence/absence of
3295 children DIE's, and list of attribute/value pairs. */
3296 static dw_die_ref
*abbrev_die_table
;
3298 /* Number of elements currently allocated for abbrev_die_table. */
3299 static unsigned abbrev_die_table_allocated
;
3301 /* Number of elements in type_die_table currently in use. */
3302 static unsigned abbrev_die_table_in_use
;
3304 /* Size (in elements) of increments by which we may expand the
3305 abbrev_die_table. */
3306 #define ABBREV_DIE_TABLE_INCREMENT 256
3308 /* A pointer to the base of a table that contains line information
3309 for each source code line in .text in the compilation unit. */
3310 static dw_line_info_ref line_info_table
;
3312 /* Number of elements currently allocated for line_info_table. */
3313 static unsigned line_info_table_allocated
;
3315 /* Number of elements in separate_line_info_table currently in use. */
3316 static unsigned separate_line_info_table_in_use
;
3318 /* A pointer to the base of a table that contains line information
3319 for each source code line outside of .text in the compilation unit. */
3320 static dw_separate_line_info_ref separate_line_info_table
;
3322 /* Number of elements currently allocated for separate_line_info_table. */
3323 static unsigned separate_line_info_table_allocated
;
3325 /* Number of elements in line_info_table currently in use. */
3326 static unsigned line_info_table_in_use
;
3328 /* Size (in elements) of increments by which we may expand the
3330 #define LINE_INFO_TABLE_INCREMENT 1024
3332 /* A pointer to the base of a table that contains a list of publicly
3333 accessible names. */
3334 static pubname_ref pubname_table
;
3336 /* Number of elements currently allocated for pubname_table. */
3337 static unsigned pubname_table_allocated
;
3339 /* Number of elements in pubname_table currently in use. */
3340 static unsigned pubname_table_in_use
;
3342 /* Size (in elements) of increments by which we may expand the
3344 #define PUBNAME_TABLE_INCREMENT 64
3346 /* Array of dies for which we should generate .debug_arange info. */
3347 static dw_die_ref
*arange_table
;
3349 /* Number of elements currently allocated for arange_table. */
3350 static unsigned arange_table_allocated
;
3352 /* Number of elements in arange_table currently in use. */
3353 static unsigned arange_table_in_use
;
3355 /* Size (in elements) of increments by which we may expand the
3357 #define ARANGE_TABLE_INCREMENT 64
3359 /* Array of dies for which we should generate .debug_ranges info. */
3360 static dw_ranges_ref ranges_table
;
3362 /* Number of elements currently allocated for ranges_table. */
3363 static unsigned ranges_table_allocated
;
3365 /* Number of elements in ranges_table currently in use. */
3366 static unsigned ranges_table_in_use
;
3368 /* Size (in elements) of increments by which we may expand the
3370 #define RANGES_TABLE_INCREMENT 64
3372 /* Whether we have location lists that need outputting */
3373 static unsigned have_location_lists
;
3375 /* A pointer to the base of a list of incomplete types which might be
3376 completed at some later time. incomplete_types_list needs to be a VARRAY
3377 because we want to tell the garbage collector about it. If we don't tell
3378 the garbage collector about it, we can garbage collect live data.
3380 varray_type incomplete_types
;
3382 /* Record whether the function being analyzed contains inlined functions. */
3383 static int current_function_has_inlines
;
3384 #if 0 && defined (MIPS_DEBUGGING_INFO)
3385 static int comp_unit_has_inlines
;
3388 /* Array of RTXes referenced by the debugging information, which therefore
3389 must be kept around forever. We do this rather than perform GC on
3390 the dwarf info because almost all of the dwarf info lives forever, and
3391 it's easier to support non-GC frontends this way. */
3392 static varray_type used_rtx_varray
;
3394 /* Forward declarations for functions defined in this file. */
3396 static int is_pseudo_reg
PARAMS ((rtx
));
3397 static tree type_main_variant
PARAMS ((tree
));
3398 static int is_tagged_type
PARAMS ((tree
));
3399 static const char *dwarf_tag_name
PARAMS ((unsigned));
3400 static const char *dwarf_attr_name
PARAMS ((unsigned));
3401 static const char *dwarf_form_name
PARAMS ((unsigned));
3403 static const char *dwarf_type_encoding_name
PARAMS ((unsigned));
3405 static tree decl_ultimate_origin
PARAMS ((tree
));
3406 static tree block_ultimate_origin
PARAMS ((tree
));
3407 static tree decl_class_context
PARAMS ((tree
));
3408 static void add_dwarf_attr
PARAMS ((dw_die_ref
, dw_attr_ref
));
3409 static void add_AT_flag
PARAMS ((dw_die_ref
,
3410 enum dwarf_attribute
,
3412 static void add_AT_int
PARAMS ((dw_die_ref
,
3413 enum dwarf_attribute
, long));
3414 static void add_AT_unsigned
PARAMS ((dw_die_ref
,
3415 enum dwarf_attribute
,
3417 static void add_AT_long_long
PARAMS ((dw_die_ref
,
3418 enum dwarf_attribute
,
3421 static void add_AT_float
PARAMS ((dw_die_ref
,
3422 enum dwarf_attribute
,
3424 static void add_AT_string
PARAMS ((dw_die_ref
,
3425 enum dwarf_attribute
,
3427 static void add_AT_die_ref
PARAMS ((dw_die_ref
,
3428 enum dwarf_attribute
,
3430 static void add_AT_fde_ref
PARAMS ((dw_die_ref
,
3431 enum dwarf_attribute
,
3433 static void add_AT_loc
PARAMS ((dw_die_ref
,
3434 enum dwarf_attribute
,
3436 static void add_AT_loc_list
PARAMS ((dw_die_ref
,
3437 enum dwarf_attribute
,
3439 static void add_AT_addr
PARAMS ((dw_die_ref
,
3440 enum dwarf_attribute
,
3442 static void add_AT_lbl_id
PARAMS ((dw_die_ref
,
3443 enum dwarf_attribute
,
3445 static void add_AT_lbl_offset
PARAMS ((dw_die_ref
,
3446 enum dwarf_attribute
,
3448 static void add_AT_offset
PARAMS ((dw_die_ref
,
3449 enum dwarf_attribute
,
3451 static void add_AT_range_list
PARAMS ((dw_die_ref
,
3452 enum dwarf_attribute
,
3454 static dw_attr_ref get_AT
PARAMS ((dw_die_ref
,
3455 enum dwarf_attribute
));
3456 static const char *get_AT_low_pc
PARAMS ((dw_die_ref
));
3457 static const char *get_AT_hi_pc
PARAMS ((dw_die_ref
));
3458 static const char *get_AT_string
PARAMS ((dw_die_ref
,
3459 enum dwarf_attribute
));
3460 static int get_AT_flag
PARAMS ((dw_die_ref
,
3461 enum dwarf_attribute
));
3462 static unsigned get_AT_unsigned
PARAMS ((dw_die_ref
,
3463 enum dwarf_attribute
));
3464 static inline dw_die_ref get_AT_ref
PARAMS ((dw_die_ref
,
3465 enum dwarf_attribute
));
3466 static int is_c_family
PARAMS ((void));
3467 static int is_cxx
PARAMS ((void));
3468 static int is_java
PARAMS ((void));
3469 static int is_fortran
PARAMS ((void));
3470 static void remove_AT
PARAMS ((dw_die_ref
,
3471 enum dwarf_attribute
));
3472 static void remove_children
PARAMS ((dw_die_ref
));
3473 static void add_child_die
PARAMS ((dw_die_ref
, dw_die_ref
));
3474 static dw_die_ref new_die
PARAMS ((enum dwarf_tag
, dw_die_ref
));
3475 static dw_die_ref lookup_type_die
PARAMS ((tree
));
3476 static void equate_type_number_to_die
PARAMS ((tree
, dw_die_ref
));
3477 static dw_die_ref lookup_decl_die
PARAMS ((tree
));
3478 static void equate_decl_number_to_die
PARAMS ((tree
, dw_die_ref
));
3479 static void print_spaces
PARAMS ((FILE *));
3480 static void print_die
PARAMS ((dw_die_ref
, FILE *));
3481 static void print_dwarf_line_table
PARAMS ((FILE *));
3482 static void reverse_die_lists
PARAMS ((dw_die_ref
));
3483 static void reverse_all_dies
PARAMS ((dw_die_ref
));
3484 static dw_die_ref push_new_compile_unit
PARAMS ((dw_die_ref
, dw_die_ref
));
3485 static dw_die_ref pop_compile_unit
PARAMS ((dw_die_ref
));
3486 static void loc_checksum
PARAMS ((dw_loc_descr_ref
, struct md5_ctx
*));
3487 static void attr_checksum
PARAMS ((dw_attr_ref
, struct md5_ctx
*));
3488 static void die_checksum
PARAMS ((dw_die_ref
, struct md5_ctx
*));
3489 static void compute_section_prefix
PARAMS ((dw_die_ref
));
3490 static int is_type_die
PARAMS ((dw_die_ref
));
3491 static int is_comdat_die
PARAMS ((dw_die_ref
));
3492 static int is_symbol_die
PARAMS ((dw_die_ref
));
3493 static void assign_symbol_names
PARAMS ((dw_die_ref
));
3494 static void break_out_includes
PARAMS ((dw_die_ref
));
3495 static void add_sibling_attributes
PARAMS ((dw_die_ref
));
3496 static void build_abbrev_table
PARAMS ((dw_die_ref
));
3497 static void output_location_lists
PARAMS ((dw_die_ref
));
3498 static int constant_size
PARAMS ((long unsigned));
3499 static unsigned long size_of_die
PARAMS ((dw_die_ref
));
3500 static void calc_die_sizes
PARAMS ((dw_die_ref
));
3501 static void mark_dies
PARAMS ((dw_die_ref
));
3502 static void unmark_dies
PARAMS ((dw_die_ref
));
3503 static unsigned long size_of_pubnames
PARAMS ((void));
3504 static unsigned long size_of_aranges
PARAMS ((void));
3505 static enum dwarf_form value_format
PARAMS ((dw_attr_ref
));
3506 static void output_value_format
PARAMS ((dw_attr_ref
));
3507 static void output_abbrev_section
PARAMS ((void));
3508 static void output_die_symbol
PARAMS ((dw_die_ref
));
3509 static void output_die
PARAMS ((dw_die_ref
));
3510 static void output_compilation_unit_header
PARAMS ((void));
3511 static void output_comp_unit
PARAMS ((dw_die_ref
));
3512 static const char *dwarf2_name
PARAMS ((tree
, int));
3513 static void add_pubname
PARAMS ((tree
, dw_die_ref
));
3514 static void output_pubnames
PARAMS ((void));
3515 static void add_arange
PARAMS ((tree
, dw_die_ref
));
3516 static void output_aranges
PARAMS ((void));
3517 static unsigned int add_ranges
PARAMS ((tree
));
3518 static void output_ranges
PARAMS ((void));
3519 static void output_line_info
PARAMS ((void));
3520 static void output_file_names
PARAMS ((void));
3521 static dw_die_ref base_type_die
PARAMS ((tree
));
3522 static tree root_type
PARAMS ((tree
));
3523 static int is_base_type
PARAMS ((tree
));
3524 static dw_die_ref modified_type_die
PARAMS ((tree
, int, int, dw_die_ref
));
3525 static int type_is_enum
PARAMS ((tree
));
3526 static unsigned int reg_number
PARAMS ((rtx
));
3527 static dw_loc_descr_ref reg_loc_descriptor
PARAMS ((rtx
));
3528 static dw_loc_descr_ref int_loc_descriptor
PARAMS ((HOST_WIDE_INT
));
3529 static dw_loc_descr_ref based_loc_descr
PARAMS ((unsigned, long));
3530 static int is_based_loc
PARAMS ((rtx
));
3531 static dw_loc_descr_ref mem_loc_descriptor
PARAMS ((rtx
, enum machine_mode mode
));
3532 static dw_loc_descr_ref concat_loc_descriptor
PARAMS ((rtx
, rtx
));
3533 static dw_loc_descr_ref loc_descriptor
PARAMS ((rtx
));
3534 static dw_loc_descr_ref loc_descriptor_from_tree
PARAMS ((tree
, int));
3535 static HOST_WIDE_INT ceiling
PARAMS ((HOST_WIDE_INT
, unsigned int));
3536 static tree field_type
PARAMS ((tree
));
3537 static unsigned int simple_type_align_in_bits
PARAMS ((tree
));
3538 static unsigned int simple_decl_align_in_bits
PARAMS ((tree
));
3539 static unsigned HOST_WIDE_INT simple_type_size_in_bits
PARAMS ((tree
));
3540 static HOST_WIDE_INT field_byte_offset
PARAMS ((tree
));
3541 static void add_AT_location_description
PARAMS ((dw_die_ref
,
3542 enum dwarf_attribute
, rtx
));
3543 static void add_data_member_location_attribute
PARAMS ((dw_die_ref
, tree
));
3544 static void add_const_value_attribute
PARAMS ((dw_die_ref
, rtx
));
3545 static rtx rtl_for_decl_location
PARAMS ((tree
));
3546 static void add_location_or_const_value_attribute
PARAMS ((dw_die_ref
, tree
));
3547 static void tree_add_const_value_attribute
PARAMS ((dw_die_ref
, tree
));
3548 static void add_name_attribute
PARAMS ((dw_die_ref
, const char *));
3549 static void add_bound_info
PARAMS ((dw_die_ref
,
3550 enum dwarf_attribute
, tree
));
3551 static void add_subscript_info
PARAMS ((dw_die_ref
, tree
));
3552 static void add_byte_size_attribute
PARAMS ((dw_die_ref
, tree
));
3553 static void add_bit_offset_attribute
PARAMS ((dw_die_ref
, tree
));
3554 static void add_bit_size_attribute
PARAMS ((dw_die_ref
, tree
));
3555 static void add_prototyped_attribute
PARAMS ((dw_die_ref
, tree
));
3556 static void add_abstract_origin_attribute
PARAMS ((dw_die_ref
, tree
));
3557 static void add_pure_or_virtual_attribute
PARAMS ((dw_die_ref
, tree
));
3558 static void add_src_coords_attributes
PARAMS ((dw_die_ref
, tree
));
3559 static void add_name_and_src_coords_attributes
PARAMS ((dw_die_ref
, tree
));
3560 static void push_decl_scope
PARAMS ((tree
));
3561 static dw_die_ref scope_die_for
PARAMS ((tree
, dw_die_ref
));
3562 static void pop_decl_scope
PARAMS ((void));
3563 static void add_type_attribute
PARAMS ((dw_die_ref
, tree
, int, int,
3565 static const char *type_tag
PARAMS ((tree
));
3566 static tree member_declared_type
PARAMS ((tree
));
3568 static const char *decl_start_label
PARAMS ((tree
));
3570 static void gen_array_type_die
PARAMS ((tree
, dw_die_ref
));
3571 static void gen_set_type_die
PARAMS ((tree
, dw_die_ref
));
3573 static void gen_entry_point_die
PARAMS ((tree
, dw_die_ref
));
3575 static void gen_inlined_enumeration_type_die
PARAMS ((tree
, dw_die_ref
));
3576 static void gen_inlined_structure_type_die
PARAMS ((tree
, dw_die_ref
));
3577 static void gen_inlined_union_type_die
PARAMS ((tree
, dw_die_ref
));
3578 static void gen_enumeration_type_die
PARAMS ((tree
, dw_die_ref
));
3579 static dw_die_ref gen_formal_parameter_die
PARAMS ((tree
, dw_die_ref
));
3580 static void gen_unspecified_parameters_die
PARAMS ((tree
, dw_die_ref
));
3581 static void gen_formal_types_die
PARAMS ((tree
, dw_die_ref
));
3582 static void gen_subprogram_die
PARAMS ((tree
, dw_die_ref
));
3583 static void gen_variable_die
PARAMS ((tree
, dw_die_ref
));
3584 static void gen_label_die
PARAMS ((tree
, dw_die_ref
));
3585 static void gen_lexical_block_die
PARAMS ((tree
, dw_die_ref
, int));
3586 static void gen_inlined_subroutine_die
PARAMS ((tree
, dw_die_ref
, int));
3587 static void gen_field_die
PARAMS ((tree
, dw_die_ref
));
3588 static void gen_ptr_to_mbr_type_die
PARAMS ((tree
, dw_die_ref
));
3589 static dw_die_ref gen_compile_unit_die
PARAMS ((const char *));
3590 static void gen_string_type_die
PARAMS ((tree
, dw_die_ref
));
3591 static void gen_inheritance_die
PARAMS ((tree
, dw_die_ref
));
3592 static void gen_member_die
PARAMS ((tree
, dw_die_ref
));
3593 static void gen_struct_or_union_type_die
PARAMS ((tree
, dw_die_ref
));
3594 static void gen_subroutine_type_die
PARAMS ((tree
, dw_die_ref
));
3595 static void gen_typedef_die
PARAMS ((tree
, dw_die_ref
));
3596 static void gen_type_die
PARAMS ((tree
, dw_die_ref
));
3597 static void gen_tagged_type_instantiation_die
PARAMS ((tree
, dw_die_ref
));
3598 static void gen_block_die
PARAMS ((tree
, dw_die_ref
, int));
3599 static void decls_for_scope
PARAMS ((tree
, dw_die_ref
, int));
3600 static int is_redundant_typedef
PARAMS ((tree
));
3601 static void gen_decl_die
PARAMS ((tree
, dw_die_ref
));
3602 static unsigned lookup_filename
PARAMS ((const char *));
3603 static void init_file_table
PARAMS ((void));
3604 static void add_incomplete_type
PARAMS ((tree
));
3605 static void retry_incomplete_types
PARAMS ((void));
3606 static void gen_type_die_for_member
PARAMS ((tree
, tree
, dw_die_ref
));
3607 static rtx save_rtx
PARAMS ((rtx
));
3608 static void splice_child_die
PARAMS ((dw_die_ref
, dw_die_ref
));
3609 static int file_info_cmp
PARAMS ((const void *, const void *));
3610 static dw_loc_list_ref new_loc_list
PARAMS ((dw_loc_descr_ref
,
3611 const char *, const char *,
3612 const char *, unsigned));
3613 static void add_loc_descr_to_loc_list
PARAMS ((dw_loc_list_ref
*,
3615 const char *, const char *, const char *));
3616 static void output_loc_list
PARAMS ((dw_loc_list_ref
));
3617 static char *gen_internal_sym
PARAMS ((const char *));
3619 /* Section names used to hold DWARF debugging information. */
3620 #ifndef DEBUG_INFO_SECTION
3621 #define DEBUG_INFO_SECTION ".debug_info"
3623 #ifndef DEBUG_ABBREV_SECTION
3624 #define DEBUG_ABBREV_SECTION ".debug_abbrev"
3626 #ifndef DEBUG_ARANGES_SECTION
3627 #define DEBUG_ARANGES_SECTION ".debug_aranges"
3629 #ifndef DEBUG_MACINFO_SECTION
3630 #define DEBUG_MACINFO_SECTION ".debug_macinfo"
3632 #ifndef DEBUG_LINE_SECTION
3633 #define DEBUG_LINE_SECTION ".debug_line"
3635 #ifndef DEBUG_LOC_SECTION
3636 #define DEBUG_LOC_SECTION ".debug_loc"
3638 #ifndef DEBUG_PUBNAMES_SECTION
3639 #define DEBUG_PUBNAMES_SECTION ".debug_pubnames"
3641 #ifndef DEBUG_STR_SECTION
3642 #define DEBUG_STR_SECTION ".debug_str"
3644 #ifndef DEBUG_RANGES_SECTION
3645 #define DEBUG_RANGES_SECTION ".debug_ranges"
3648 /* Standard ELF section names for compiled code and data. */
3649 #ifndef TEXT_SECTION_NAME
3650 #define TEXT_SECTION_NAME ".text"
3653 /* Section flags for .debug_str section. */
3654 #ifdef HAVE_GAS_SHF_MERGE
3655 #define DEBUG_STR_SECTION_FLAGS \
3656 (SECTION_DEBUG | SECTION_MERGE | SECTION_STRINGS | 1)
3658 #define DEBUG_STR_SECTION_FLAGS SECTION_DEBUG
3661 /* Labels we insert at beginning sections we can reference instead of
3662 the section names themselves. */
3664 #ifndef TEXT_SECTION_LABEL
3665 #define TEXT_SECTION_LABEL "Ltext"
3667 #ifndef DEBUG_LINE_SECTION_LABEL
3668 #define DEBUG_LINE_SECTION_LABEL "Ldebug_line"
3670 #ifndef DEBUG_INFO_SECTION_LABEL
3671 #define DEBUG_INFO_SECTION_LABEL "Ldebug_info"
3673 #ifndef DEBUG_ABBREV_SECTION_LABEL
3674 #define DEBUG_ABBREV_SECTION_LABEL "Ldebug_abbrev"
3676 #ifndef DEBUG_LOC_SECTION_LABEL
3677 #define DEBUG_LOC_SECTION_LABEL "Ldebug_loc"
3679 #ifndef DEBUG_RANGES_SECTION_LABEL
3680 #define DEBUG_RANGES_SECTION_LABEL "Ldebug_ranges"
3682 #ifndef DEBUG_MACINFO_SECTION_LABEL
3683 #define DEBUG_MACINFO_SECTION_LABEL "Ldebug_macinfo"
3686 /* Definitions of defaults for formats and names of various special
3687 (artificial) labels which may be generated within this file (when the -g
3688 options is used and DWARF_DEBUGGING_INFO is in effect.
3689 If necessary, these may be overridden from within the tm.h file, but
3690 typically, overriding these defaults is unnecessary. */
3692 static char text_end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3693 static char text_section_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3694 static char abbrev_section_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3695 static char debug_info_section_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3696 static char debug_line_section_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3697 static char macinfo_section_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3698 static char loc_section_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3699 static char ranges_section_label
[2 * MAX_ARTIFICIAL_LABEL_BYTES
];
3700 #ifndef TEXT_END_LABEL
3701 #define TEXT_END_LABEL "Letext"
3703 #ifndef DATA_END_LABEL
3704 #define DATA_END_LABEL "Ledata"
3706 #ifndef BSS_END_LABEL
3707 #define BSS_END_LABEL "Lebss"
3709 #ifndef BLOCK_BEGIN_LABEL
3710 #define BLOCK_BEGIN_LABEL "LBB"
3712 #ifndef BLOCK_END_LABEL
3713 #define BLOCK_END_LABEL "LBE"
3715 #ifndef BODY_BEGIN_LABEL
3716 #define BODY_BEGIN_LABEL "Lbb"
3718 #ifndef BODY_END_LABEL
3719 #define BODY_END_LABEL "Lbe"
3721 #ifndef LINE_CODE_LABEL
3722 #define LINE_CODE_LABEL "LM"
3724 #ifndef SEPARATE_LINE_CODE_LABEL
3725 #define SEPARATE_LINE_CODE_LABEL "LSM"
3728 /* We allow a language front-end to designate a function that is to be
3729 called to "demangle" any name before it it put into a DIE. */
3731 static const char *(*demangle_name_func
) PARAMS ((const char *));
3734 dwarf2out_set_demangle_name_func (func
)
3735 const char *(*func
) PARAMS ((const char *));
3737 demangle_name_func
= func
;
3740 /* Return an rtx like ORIG which lives forever. If we're doing GC,
3741 that means adding it to used_rtx_varray. If not, that means making
3742 a copy on the permanent_obstack. */
3748 VARRAY_PUSH_RTX (used_rtx_varray
, orig
);
3753 /* Test if rtl node points to a pseudo register. */
3759 return ((GET_CODE (rtl
) == REG
&& REGNO (rtl
) >= FIRST_PSEUDO_REGISTER
)
3760 || (GET_CODE (rtl
) == SUBREG
3761 && REGNO (SUBREG_REG (rtl
)) >= FIRST_PSEUDO_REGISTER
));
3764 /* Return a reference to a type, with its const and volatile qualifiers
3768 type_main_variant (type
)
3771 type
= TYPE_MAIN_VARIANT (type
);
3773 /* There really should be only one main variant among any group of variants
3774 of a given type (and all of the MAIN_VARIANT values for all members of
3775 the group should point to that one type) but sometimes the C front-end
3776 messes this up for array types, so we work around that bug here. */
3778 if (TREE_CODE (type
) == ARRAY_TYPE
)
3779 while (type
!= TYPE_MAIN_VARIANT (type
))
3780 type
= TYPE_MAIN_VARIANT (type
);
3785 /* Return non-zero if the given type node represents a tagged type. */
3788 is_tagged_type (type
)
3791 enum tree_code code
= TREE_CODE (type
);
3793 return (code
== RECORD_TYPE
|| code
== UNION_TYPE
3794 || code
== QUAL_UNION_TYPE
|| code
== ENUMERAL_TYPE
);
3797 /* Convert a DIE tag into its string name. */
3800 dwarf_tag_name (tag
)
3805 case DW_TAG_padding
:
3806 return "DW_TAG_padding";
3807 case DW_TAG_array_type
:
3808 return "DW_TAG_array_type";
3809 case DW_TAG_class_type
:
3810 return "DW_TAG_class_type";
3811 case DW_TAG_entry_point
:
3812 return "DW_TAG_entry_point";
3813 case DW_TAG_enumeration_type
:
3814 return "DW_TAG_enumeration_type";
3815 case DW_TAG_formal_parameter
:
3816 return "DW_TAG_formal_parameter";
3817 case DW_TAG_imported_declaration
:
3818 return "DW_TAG_imported_declaration";
3820 return "DW_TAG_label";
3821 case DW_TAG_lexical_block
:
3822 return "DW_TAG_lexical_block";
3824 return "DW_TAG_member";
3825 case DW_TAG_pointer_type
:
3826 return "DW_TAG_pointer_type";
3827 case DW_TAG_reference_type
:
3828 return "DW_TAG_reference_type";
3829 case DW_TAG_compile_unit
:
3830 return "DW_TAG_compile_unit";
3831 case DW_TAG_string_type
:
3832 return "DW_TAG_string_type";
3833 case DW_TAG_structure_type
:
3834 return "DW_TAG_structure_type";
3835 case DW_TAG_subroutine_type
:
3836 return "DW_TAG_subroutine_type";
3837 case DW_TAG_typedef
:
3838 return "DW_TAG_typedef";
3839 case DW_TAG_union_type
:
3840 return "DW_TAG_union_type";
3841 case DW_TAG_unspecified_parameters
:
3842 return "DW_TAG_unspecified_parameters";
3843 case DW_TAG_variant
:
3844 return "DW_TAG_variant";
3845 case DW_TAG_common_block
:
3846 return "DW_TAG_common_block";
3847 case DW_TAG_common_inclusion
:
3848 return "DW_TAG_common_inclusion";
3849 case DW_TAG_inheritance
:
3850 return "DW_TAG_inheritance";
3851 case DW_TAG_inlined_subroutine
:
3852 return "DW_TAG_inlined_subroutine";
3854 return "DW_TAG_module";
3855 case DW_TAG_ptr_to_member_type
:
3856 return "DW_TAG_ptr_to_member_type";
3857 case DW_TAG_set_type
:
3858 return "DW_TAG_set_type";
3859 case DW_TAG_subrange_type
:
3860 return "DW_TAG_subrange_type";
3861 case DW_TAG_with_stmt
:
3862 return "DW_TAG_with_stmt";
3863 case DW_TAG_access_declaration
:
3864 return "DW_TAG_access_declaration";
3865 case DW_TAG_base_type
:
3866 return "DW_TAG_base_type";
3867 case DW_TAG_catch_block
:
3868 return "DW_TAG_catch_block";
3869 case DW_TAG_const_type
:
3870 return "DW_TAG_const_type";
3871 case DW_TAG_constant
:
3872 return "DW_TAG_constant";
3873 case DW_TAG_enumerator
:
3874 return "DW_TAG_enumerator";
3875 case DW_TAG_file_type
:
3876 return "DW_TAG_file_type";
3878 return "DW_TAG_friend";
3879 case DW_TAG_namelist
:
3880 return "DW_TAG_namelist";
3881 case DW_TAG_namelist_item
:
3882 return "DW_TAG_namelist_item";
3883 case DW_TAG_packed_type
:
3884 return "DW_TAG_packed_type";
3885 case DW_TAG_subprogram
:
3886 return "DW_TAG_subprogram";
3887 case DW_TAG_template_type_param
:
3888 return "DW_TAG_template_type_param";
3889 case DW_TAG_template_value_param
:
3890 return "DW_TAG_template_value_param";
3891 case DW_TAG_thrown_type
:
3892 return "DW_TAG_thrown_type";
3893 case DW_TAG_try_block
:
3894 return "DW_TAG_try_block";
3895 case DW_TAG_variant_part
:
3896 return "DW_TAG_variant_part";
3897 case DW_TAG_variable
:
3898 return "DW_TAG_variable";
3899 case DW_TAG_volatile_type
:
3900 return "DW_TAG_volatile_type";
3901 case DW_TAG_MIPS_loop
:
3902 return "DW_TAG_MIPS_loop";
3903 case DW_TAG_format_label
:
3904 return "DW_TAG_format_label";
3905 case DW_TAG_function_template
:
3906 return "DW_TAG_function_template";
3907 case DW_TAG_class_template
:
3908 return "DW_TAG_class_template";
3909 case DW_TAG_GNU_BINCL
:
3910 return "DW_TAG_GNU_BINCL";
3911 case DW_TAG_GNU_EINCL
:
3912 return "DW_TAG_GNU_EINCL";
3914 return "DW_TAG_<unknown>";
3918 /* Convert a DWARF attribute code into its string name. */
3921 dwarf_attr_name (attr
)
3927 return "DW_AT_sibling";
3928 case DW_AT_location
:
3929 return "DW_AT_location";
3931 return "DW_AT_name";
3932 case DW_AT_ordering
:
3933 return "DW_AT_ordering";
3934 case DW_AT_subscr_data
:
3935 return "DW_AT_subscr_data";
3936 case DW_AT_byte_size
:
3937 return "DW_AT_byte_size";
3938 case DW_AT_bit_offset
:
3939 return "DW_AT_bit_offset";
3940 case DW_AT_bit_size
:
3941 return "DW_AT_bit_size";
3942 case DW_AT_element_list
:
3943 return "DW_AT_element_list";
3944 case DW_AT_stmt_list
:
3945 return "DW_AT_stmt_list";
3947 return "DW_AT_low_pc";
3949 return "DW_AT_high_pc";
3950 case DW_AT_language
:
3951 return "DW_AT_language";
3953 return "DW_AT_member";
3955 return "DW_AT_discr";
3956 case DW_AT_discr_value
:
3957 return "DW_AT_discr_value";
3958 case DW_AT_visibility
:
3959 return "DW_AT_visibility";
3961 return "DW_AT_import";
3962 case DW_AT_string_length
:
3963 return "DW_AT_string_length";
3964 case DW_AT_common_reference
:
3965 return "DW_AT_common_reference";
3966 case DW_AT_comp_dir
:
3967 return "DW_AT_comp_dir";
3968 case DW_AT_const_value
:
3969 return "DW_AT_const_value";
3970 case DW_AT_containing_type
:
3971 return "DW_AT_containing_type";
3972 case DW_AT_default_value
:
3973 return "DW_AT_default_value";
3975 return "DW_AT_inline";
3976 case DW_AT_is_optional
:
3977 return "DW_AT_is_optional";
3978 case DW_AT_lower_bound
:
3979 return "DW_AT_lower_bound";
3980 case DW_AT_producer
:
3981 return "DW_AT_producer";
3982 case DW_AT_prototyped
:
3983 return "DW_AT_prototyped";
3984 case DW_AT_return_addr
:
3985 return "DW_AT_return_addr";
3986 case DW_AT_start_scope
:
3987 return "DW_AT_start_scope";
3988 case DW_AT_stride_size
:
3989 return "DW_AT_stride_size";
3990 case DW_AT_upper_bound
:
3991 return "DW_AT_upper_bound";
3992 case DW_AT_abstract_origin
:
3993 return "DW_AT_abstract_origin";
3994 case DW_AT_accessibility
:
3995 return "DW_AT_accessibility";
3996 case DW_AT_address_class
:
3997 return "DW_AT_address_class";
3998 case DW_AT_artificial
:
3999 return "DW_AT_artificial";
4000 case DW_AT_base_types
:
4001 return "DW_AT_base_types";
4002 case DW_AT_calling_convention
:
4003 return "DW_AT_calling_convention";
4005 return "DW_AT_count";
4006 case DW_AT_data_member_location
:
4007 return "DW_AT_data_member_location";
4008 case DW_AT_decl_column
:
4009 return "DW_AT_decl_column";
4010 case DW_AT_decl_file
:
4011 return "DW_AT_decl_file";
4012 case DW_AT_decl_line
:
4013 return "DW_AT_decl_line";
4014 case DW_AT_declaration
:
4015 return "DW_AT_declaration";
4016 case DW_AT_discr_list
:
4017 return "DW_AT_discr_list";
4018 case DW_AT_encoding
:
4019 return "DW_AT_encoding";
4020 case DW_AT_external
:
4021 return "DW_AT_external";
4022 case DW_AT_frame_base
:
4023 return "DW_AT_frame_base";
4025 return "DW_AT_friend";
4026 case DW_AT_identifier_case
:
4027 return "DW_AT_identifier_case";
4028 case DW_AT_macro_info
:
4029 return "DW_AT_macro_info";
4030 case DW_AT_namelist_items
:
4031 return "DW_AT_namelist_items";
4032 case DW_AT_priority
:
4033 return "DW_AT_priority";
4035 return "DW_AT_segment";
4036 case DW_AT_specification
:
4037 return "DW_AT_specification";
4038 case DW_AT_static_link
:
4039 return "DW_AT_static_link";
4041 return "DW_AT_type";
4042 case DW_AT_use_location
:
4043 return "DW_AT_use_location";
4044 case DW_AT_variable_parameter
:
4045 return "DW_AT_variable_parameter";
4046 case DW_AT_virtuality
:
4047 return "DW_AT_virtuality";
4048 case DW_AT_vtable_elem_location
:
4049 return "DW_AT_vtable_elem_location";
4051 case DW_AT_allocated
:
4052 return "DW_AT_allocated";
4053 case DW_AT_associated
:
4054 return "DW_AT_associated";
4055 case DW_AT_data_location
:
4056 return "DW_AT_data_location";
4058 return "DW_AT_stride";
4059 case DW_AT_entry_pc
:
4060 return "DW_AT_entry_pc";
4061 case DW_AT_use_UTF8
:
4062 return "DW_AT_use_UTF8";
4063 case DW_AT_extension
:
4064 return "DW_AT_extension";
4066 return "DW_AT_ranges";
4067 case DW_AT_trampoline
:
4068 return "DW_AT_trampoline";
4069 case DW_AT_call_column
:
4070 return "DW_AT_call_column";
4071 case DW_AT_call_file
:
4072 return "DW_AT_call_file";
4073 case DW_AT_call_line
:
4074 return "DW_AT_call_line";
4076 case DW_AT_MIPS_fde
:
4077 return "DW_AT_MIPS_fde";
4078 case DW_AT_MIPS_loop_begin
:
4079 return "DW_AT_MIPS_loop_begin";
4080 case DW_AT_MIPS_tail_loop_begin
:
4081 return "DW_AT_MIPS_tail_loop_begin";
4082 case DW_AT_MIPS_epilog_begin
:
4083 return "DW_AT_MIPS_epilog_begin";
4084 case DW_AT_MIPS_loop_unroll_factor
:
4085 return "DW_AT_MIPS_loop_unroll_factor";
4086 case DW_AT_MIPS_software_pipeline_depth
:
4087 return "DW_AT_MIPS_software_pipeline_depth";
4088 case DW_AT_MIPS_linkage_name
:
4089 return "DW_AT_MIPS_linkage_name";
4090 case DW_AT_MIPS_stride
:
4091 return "DW_AT_MIPS_stride";
4092 case DW_AT_MIPS_abstract_name
:
4093 return "DW_AT_MIPS_abstract_name";
4094 case DW_AT_MIPS_clone_origin
:
4095 return "DW_AT_MIPS_clone_origin";
4096 case DW_AT_MIPS_has_inlines
:
4097 return "DW_AT_MIPS_has_inlines";
4099 case DW_AT_sf_names
:
4100 return "DW_AT_sf_names";
4101 case DW_AT_src_info
:
4102 return "DW_AT_src_info";
4103 case DW_AT_mac_info
:
4104 return "DW_AT_mac_info";
4105 case DW_AT_src_coords
:
4106 return "DW_AT_src_coords";
4107 case DW_AT_body_begin
:
4108 return "DW_AT_body_begin";
4109 case DW_AT_body_end
:
4110 return "DW_AT_body_end";
4111 case DW_AT_VMS_rtnbeg_pd_address
:
4112 return "DW_AT_VMS_rtnbeg_pd_address";
4115 return "DW_AT_<unknown>";
4119 /* Convert a DWARF value form code into its string name. */
4122 dwarf_form_name (form
)
4128 return "DW_FORM_addr";
4129 case DW_FORM_block2
:
4130 return "DW_FORM_block2";
4131 case DW_FORM_block4
:
4132 return "DW_FORM_block4";
4134 return "DW_FORM_data2";
4136 return "DW_FORM_data4";
4138 return "DW_FORM_data8";
4139 case DW_FORM_string
:
4140 return "DW_FORM_string";
4142 return "DW_FORM_block";
4143 case DW_FORM_block1
:
4144 return "DW_FORM_block1";
4146 return "DW_FORM_data1";
4148 return "DW_FORM_flag";
4150 return "DW_FORM_sdata";
4152 return "DW_FORM_strp";
4154 return "DW_FORM_udata";
4155 case DW_FORM_ref_addr
:
4156 return "DW_FORM_ref_addr";
4158 return "DW_FORM_ref1";
4160 return "DW_FORM_ref2";
4162 return "DW_FORM_ref4";
4164 return "DW_FORM_ref8";
4165 case DW_FORM_ref_udata
:
4166 return "DW_FORM_ref_udata";
4167 case DW_FORM_indirect
:
4168 return "DW_FORM_indirect";
4170 return "DW_FORM_<unknown>";
4174 /* Convert a DWARF type code into its string name. */
4178 dwarf_type_encoding_name (enc
)
4183 case DW_ATE_address
:
4184 return "DW_ATE_address";
4185 case DW_ATE_boolean
:
4186 return "DW_ATE_boolean";
4187 case DW_ATE_complex_float
:
4188 return "DW_ATE_complex_float";
4190 return "DW_ATE_float";
4192 return "DW_ATE_signed";
4193 case DW_ATE_signed_char
:
4194 return "DW_ATE_signed_char";
4195 case DW_ATE_unsigned
:
4196 return "DW_ATE_unsigned";
4197 case DW_ATE_unsigned_char
:
4198 return "DW_ATE_unsigned_char";
4200 return "DW_ATE_<unknown>";
4205 /* Determine the "ultimate origin" of a decl. The decl may be an inlined
4206 instance of an inlined instance of a decl which is local to an inline
4207 function, so we have to trace all of the way back through the origin chain
4208 to find out what sort of node actually served as the original seed for the
4212 decl_ultimate_origin (decl
)
4215 /* output_inline_function sets DECL_ABSTRACT_ORIGIN for all the
4216 nodes in the function to point to themselves; ignore that if
4217 we're trying to output the abstract instance of this function. */
4218 if (DECL_ABSTRACT (decl
) && DECL_ABSTRACT_ORIGIN (decl
) == decl
)
4221 #ifdef ENABLE_CHECKING
4222 if (DECL_FROM_INLINE (DECL_ORIGIN (decl
)))
4223 /* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
4224 most distant ancestor, this should never happen. */
4228 return DECL_ABSTRACT_ORIGIN (decl
);
4231 /* Determine the "ultimate origin" of a block. The block may be an inlined
4232 instance of an inlined instance of a block which is local to an inline
4233 function, so we have to trace all of the way back through the origin chain
4234 to find out what sort of node actually served as the original seed for the
4238 block_ultimate_origin (block
)
4241 tree immediate_origin
= BLOCK_ABSTRACT_ORIGIN (block
);
4243 /* output_inline_function sets BLOCK_ABSTRACT_ORIGIN for all the
4244 nodes in the function to point to themselves; ignore that if
4245 we're trying to output the abstract instance of this function. */
4246 if (BLOCK_ABSTRACT (block
) && immediate_origin
== block
)
4249 if (immediate_origin
== NULL_TREE
)
4254 tree lookahead
= immediate_origin
;
4258 ret_val
= lookahead
;
4259 lookahead
= (TREE_CODE (ret_val
) == BLOCK
)
4260 ? BLOCK_ABSTRACT_ORIGIN (ret_val
)
4263 while (lookahead
!= NULL
&& lookahead
!= ret_val
);
4269 /* Get the class to which DECL belongs, if any. In g++, the DECL_CONTEXT
4270 of a virtual function may refer to a base class, so we check the 'this'
4274 decl_class_context (decl
)
4277 tree context
= NULL_TREE
;
4279 if (TREE_CODE (decl
) != FUNCTION_DECL
|| ! DECL_VINDEX (decl
))
4280 context
= DECL_CONTEXT (decl
);
4282 context
= TYPE_MAIN_VARIANT
4283 (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)))));
4285 if (context
&& !TYPE_P (context
))
4286 context
= NULL_TREE
;
4291 /* Add an attribute/value pair to a DIE. We build the lists up in reverse
4292 addition order, and correct that in reverse_all_dies. */
4295 add_dwarf_attr (die
, attr
)
4299 if (die
!= NULL
&& attr
!= NULL
)
4301 attr
->dw_attr_next
= die
->die_attr
;
4302 die
->die_attr
= attr
;
4306 static inline dw_val_class AT_class
PARAMS ((dw_attr_ref
));
4307 static inline dw_val_class
4311 return a
->dw_attr_val
.val_class
;
4314 /* Add a flag value attribute to a DIE. */
4317 add_AT_flag (die
, attr_kind
, flag
)
4319 enum dwarf_attribute attr_kind
;
4322 dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4324 attr
->dw_attr_next
= NULL
;
4325 attr
->dw_attr
= attr_kind
;
4326 attr
->dw_attr_val
.val_class
= dw_val_class_flag
;
4327 attr
->dw_attr_val
.v
.val_flag
= flag
;
4328 add_dwarf_attr (die
, attr
);
4331 static inline unsigned AT_flag
PARAMS ((dw_attr_ref
));
4332 static inline unsigned
4336 if (a
&& AT_class (a
) == dw_val_class_flag
)
4337 return a
->dw_attr_val
.v
.val_flag
;
4342 /* Add a signed integer attribute value to a DIE. */
4345 add_AT_int (die
, attr_kind
, int_val
)
4347 enum dwarf_attribute attr_kind
;
4350 dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4352 attr
->dw_attr_next
= NULL
;
4353 attr
->dw_attr
= attr_kind
;
4354 attr
->dw_attr_val
.val_class
= dw_val_class_const
;
4355 attr
->dw_attr_val
.v
.val_int
= int_val
;
4356 add_dwarf_attr (die
, attr
);
4359 static inline long int AT_int
PARAMS ((dw_attr_ref
));
4360 static inline long int
4364 if (a
&& AT_class (a
) == dw_val_class_const
)
4365 return a
->dw_attr_val
.v
.val_int
;
4370 /* Add an unsigned integer attribute value to a DIE. */
4373 add_AT_unsigned (die
, attr_kind
, unsigned_val
)
4375 enum dwarf_attribute attr_kind
;
4376 unsigned long unsigned_val
;
4378 dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4380 attr
->dw_attr_next
= NULL
;
4381 attr
->dw_attr
= attr_kind
;
4382 attr
->dw_attr_val
.val_class
= dw_val_class_unsigned_const
;
4383 attr
->dw_attr_val
.v
.val_unsigned
= unsigned_val
;
4384 add_dwarf_attr (die
, attr
);
4387 static inline unsigned long AT_unsigned
PARAMS ((dw_attr_ref
));
4388 static inline unsigned long
4392 if (a
&& AT_class (a
) == dw_val_class_unsigned_const
)
4393 return a
->dw_attr_val
.v
.val_unsigned
;
4398 /* Add an unsigned double integer attribute value to a DIE. */
4401 add_AT_long_long (die
, attr_kind
, val_hi
, val_low
)
4403 enum dwarf_attribute attr_kind
;
4404 unsigned long val_hi
;
4405 unsigned long val_low
;
4407 dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4409 attr
->dw_attr_next
= NULL
;
4410 attr
->dw_attr
= attr_kind
;
4411 attr
->dw_attr_val
.val_class
= dw_val_class_long_long
;
4412 attr
->dw_attr_val
.v
.val_long_long
.hi
= val_hi
;
4413 attr
->dw_attr_val
.v
.val_long_long
.low
= val_low
;
4414 add_dwarf_attr (die
, attr
);
4417 /* Add a floating point attribute value to a DIE and return it. */
4420 add_AT_float (die
, attr_kind
, length
, array
)
4422 enum dwarf_attribute attr_kind
;
4426 dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4428 attr
->dw_attr_next
= NULL
;
4429 attr
->dw_attr
= attr_kind
;
4430 attr
->dw_attr_val
.val_class
= dw_val_class_float
;
4431 attr
->dw_attr_val
.v
.val_float
.length
= length
;
4432 attr
->dw_attr_val
.v
.val_float
.array
= array
;
4433 add_dwarf_attr (die
, attr
);
4436 /* Add a string attribute value to a DIE. */
4439 add_AT_string (die
, attr_kind
, str
)
4441 enum dwarf_attribute attr_kind
;
4444 dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4445 struct indirect_string_node
*node
;
4447 if (! debug_str_hash
)
4449 debug_str_hash
= ht_create (10);
4450 debug_str_hash
->alloc_node
= indirect_string_alloc
;
4453 node
= (struct indirect_string_node
*)
4454 ht_lookup (debug_str_hash
, (const unsigned char *) str
,
4455 strlen (str
), HT_ALLOC
);
4458 attr
->dw_attr_next
= NULL
;
4459 attr
->dw_attr
= attr_kind
;
4460 attr
->dw_attr_val
.val_class
= dw_val_class_str
;
4461 attr
->dw_attr_val
.v
.val_str
= node
;
4462 add_dwarf_attr (die
, attr
);
4465 static inline const char *AT_string
PARAMS ((dw_attr_ref
));
4466 static inline const char *
4470 if (a
&& AT_class (a
) == dw_val_class_str
)
4471 return (const char *) HT_STR (&a
->dw_attr_val
.v
.val_str
->id
);
4476 /* Find out whether a string should be output inline in DIE
4477 or out-of-line in .debug_str section. */
4479 static int AT_string_form
PARAMS ((dw_attr_ref
));
4484 if (a
&& AT_class (a
) == dw_val_class_str
)
4486 struct indirect_string_node
*node
;
4488 extern int const_labelno
;
4491 node
= a
->dw_attr_val
.v
.val_str
;
4495 len
= HT_LEN (&node
->id
) + 1;
4497 /* If the string is shorter or equal to the size
4498 of the reference, it is always better to put it
4500 if (len
<= DWARF_OFFSET_SIZE
|| node
->refcount
== 0)
4501 return node
->form
= DW_FORM_string
;
4503 if ((DEBUG_STR_SECTION_FLAGS
& SECTION_MERGE
) == 0)
4505 /* If we cannot expect the linker to merge strings
4506 in .debug_str section, only put it into .debug_str
4507 if it is worth even in this single module. */
4508 if ((len
- DWARF_OFFSET_SIZE
) * node
->refcount
<= len
)
4509 return node
->form
= DW_FORM_string
;
4512 ASM_GENERATE_INTERNAL_LABEL (label
, "LC", const_labelno
);
4514 node
->label
= xstrdup (label
);
4515 return node
->form
= DW_FORM_strp
;
4521 /* Add a DIE reference attribute value to a DIE. */
4524 add_AT_die_ref (die
, attr_kind
, targ_die
)
4526 enum dwarf_attribute attr_kind
;
4527 dw_die_ref targ_die
;
4529 dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4531 attr
->dw_attr_next
= NULL
;
4532 attr
->dw_attr
= attr_kind
;
4533 attr
->dw_attr_val
.val_class
= dw_val_class_die_ref
;
4534 attr
->dw_attr_val
.v
.val_die_ref
.die
= targ_die
;
4535 attr
->dw_attr_val
.v
.val_die_ref
.external
= 0;
4536 add_dwarf_attr (die
, attr
);
4539 static inline dw_die_ref AT_ref
PARAMS ((dw_attr_ref
));
4540 static inline dw_die_ref
4544 if (a
&& AT_class (a
) == dw_val_class_die_ref
)
4545 return a
->dw_attr_val
.v
.val_die_ref
.die
;
4550 static inline int AT_ref_external
PARAMS ((dw_attr_ref
));
4555 if (a
&& AT_class (a
) == dw_val_class_die_ref
)
4556 return a
->dw_attr_val
.v
.val_die_ref
.external
;
4561 static inline void set_AT_ref_external
PARAMS ((dw_attr_ref
, int));
4563 set_AT_ref_external (a
, i
)
4567 if (a
&& AT_class (a
) == dw_val_class_die_ref
)
4568 a
->dw_attr_val
.v
.val_die_ref
.external
= i
;
4573 /* Add an FDE reference attribute value to a DIE. */
4576 add_AT_fde_ref (die
, attr_kind
, targ_fde
)
4578 enum dwarf_attribute attr_kind
;
4581 dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4583 attr
->dw_attr_next
= NULL
;
4584 attr
->dw_attr
= attr_kind
;
4585 attr
->dw_attr_val
.val_class
= dw_val_class_fde_ref
;
4586 attr
->dw_attr_val
.v
.val_fde_index
= targ_fde
;
4587 add_dwarf_attr (die
, attr
);
4590 /* Add a location description attribute value to a DIE. */
4593 add_AT_loc (die
, attr_kind
, loc
)
4595 enum dwarf_attribute attr_kind
;
4596 dw_loc_descr_ref loc
;
4598 dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4600 attr
->dw_attr_next
= NULL
;
4601 attr
->dw_attr
= attr_kind
;
4602 attr
->dw_attr_val
.val_class
= dw_val_class_loc
;
4603 attr
->dw_attr_val
.v
.val_loc
= loc
;
4604 add_dwarf_attr (die
, attr
);
4607 static inline dw_loc_descr_ref AT_loc
PARAMS ((dw_attr_ref
));
4608 static inline dw_loc_descr_ref
4612 if (a
&& AT_class (a
) == dw_val_class_loc
)
4613 return a
->dw_attr_val
.v
.val_loc
;
4619 add_AT_loc_list (die
, attr_kind
, loc_list
)
4621 enum dwarf_attribute attr_kind
;
4622 dw_loc_list_ref loc_list
;
4624 dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4626 attr
->dw_attr_next
= NULL
;
4627 attr
->dw_attr
= attr_kind
;
4628 attr
->dw_attr_val
.val_class
= dw_val_class_loc_list
;
4629 attr
->dw_attr_val
.v
.val_loc_list
= loc_list
;
4630 add_dwarf_attr (die
, attr
);
4631 have_location_lists
= 1;
4634 static inline dw_loc_list_ref AT_loc_list
PARAMS ((dw_attr_ref
));
4636 static inline dw_loc_list_ref
4640 if (a
&& AT_class (a
) == dw_val_class_loc_list
)
4641 return a
->dw_attr_val
.v
.val_loc_list
;
4646 /* Add an address constant attribute value to a DIE. */
4649 add_AT_addr (die
, attr_kind
, addr
)
4651 enum dwarf_attribute attr_kind
;
4654 dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4656 attr
->dw_attr_next
= NULL
;
4657 attr
->dw_attr
= attr_kind
;
4658 attr
->dw_attr_val
.val_class
= dw_val_class_addr
;
4659 attr
->dw_attr_val
.v
.val_addr
= addr
;
4660 add_dwarf_attr (die
, attr
);
4663 static inline rtx AT_addr
PARAMS ((dw_attr_ref
));
4668 if (a
&& AT_class (a
) == dw_val_class_addr
)
4669 return a
->dw_attr_val
.v
.val_addr
;
4674 /* Add a label identifier attribute value to a DIE. */
4677 add_AT_lbl_id (die
, attr_kind
, lbl_id
)
4679 enum dwarf_attribute attr_kind
;
4682 dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4684 attr
->dw_attr_next
= NULL
;
4685 attr
->dw_attr
= attr_kind
;
4686 attr
->dw_attr_val
.val_class
= dw_val_class_lbl_id
;
4687 attr
->dw_attr_val
.v
.val_lbl_id
= xstrdup (lbl_id
);
4688 add_dwarf_attr (die
, attr
);
4691 /* Add a section offset attribute value to a DIE. */
4694 add_AT_lbl_offset (die
, attr_kind
, label
)
4696 enum dwarf_attribute attr_kind
;
4699 dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4701 attr
->dw_attr_next
= NULL
;
4702 attr
->dw_attr
= attr_kind
;
4703 attr
->dw_attr_val
.val_class
= dw_val_class_lbl_offset
;
4704 attr
->dw_attr_val
.v
.val_lbl_id
= xstrdup (label
);
4705 add_dwarf_attr (die
, attr
);
4708 /* Add an offset attribute value to a DIE. */
4711 add_AT_offset (die
, attr_kind
, offset
)
4713 enum dwarf_attribute attr_kind
;
4714 unsigned long offset
;
4716 dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4718 attr
->dw_attr_next
= NULL
;
4719 attr
->dw_attr
= attr_kind
;
4720 attr
->dw_attr_val
.val_class
= dw_val_class_offset
;
4721 attr
->dw_attr_val
.v
.val_offset
= offset
;
4722 add_dwarf_attr (die
, attr
);
4725 /* Add an range_list attribute value to a DIE. */
4728 add_AT_range_list (die
, attr_kind
, offset
)
4730 enum dwarf_attribute attr_kind
;
4731 unsigned long offset
;
4733 dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4735 attr
->dw_attr_next
= NULL
;
4736 attr
->dw_attr
= attr_kind
;
4737 attr
->dw_attr_val
.val_class
= dw_val_class_range_list
;
4738 attr
->dw_attr_val
.v
.val_offset
= offset
;
4739 add_dwarf_attr (die
, attr
);
4742 static inline const char *AT_lbl
PARAMS ((dw_attr_ref
));
4743 static inline const char *
4747 if (a
&& (AT_class (a
) == dw_val_class_lbl_id
4748 || AT_class (a
) == dw_val_class_lbl_offset
))
4749 return a
->dw_attr_val
.v
.val_lbl_id
;
4754 /* Get the attribute of type attr_kind. */
4756 static inline dw_attr_ref
4757 get_AT (die
, attr_kind
)
4759 enum dwarf_attribute attr_kind
;
4762 dw_die_ref spec
= NULL
;
4766 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
4768 if (a
->dw_attr
== attr_kind
)
4771 if (a
->dw_attr
== DW_AT_specification
4772 || a
->dw_attr
== DW_AT_abstract_origin
)
4777 return get_AT (spec
, attr_kind
);
4783 /* Return the "low pc" attribute value, typically associated with
4784 a subprogram DIE. Return null if the "low pc" attribute is
4785 either not present, or if it cannot be represented as an
4786 assembler label identifier. */
4788 static inline const char *
4792 dw_attr_ref a
= get_AT (die
, DW_AT_low_pc
);
4793 return a
? AT_lbl (a
) : NULL
;
4796 /* Return the "high pc" attribute value, typically associated with
4797 a subprogram DIE. Return null if the "high pc" attribute is
4798 either not present, or if it cannot be represented as an
4799 assembler label identifier. */
4801 static inline const char *
4805 dw_attr_ref a
= get_AT (die
, DW_AT_high_pc
);
4806 return a
? AT_lbl (a
) : NULL
;
4809 /* Return the value of the string attribute designated by ATTR_KIND, or
4810 NULL if it is not present. */
4812 static inline const char *
4813 get_AT_string (die
, attr_kind
)
4815 enum dwarf_attribute attr_kind
;
4817 dw_attr_ref a
= get_AT (die
, attr_kind
);
4818 return a
? AT_string (a
) : NULL
;
4821 /* Return the value of the flag attribute designated by ATTR_KIND, or -1
4822 if it is not present. */
4825 get_AT_flag (die
, attr_kind
)
4827 enum dwarf_attribute attr_kind
;
4829 dw_attr_ref a
= get_AT (die
, attr_kind
);
4830 return a
? AT_flag (a
) : 0;
4833 /* Return the value of the unsigned attribute designated by ATTR_KIND, or 0
4834 if it is not present. */
4836 static inline unsigned
4837 get_AT_unsigned (die
, attr_kind
)
4839 enum dwarf_attribute attr_kind
;
4841 dw_attr_ref a
= get_AT (die
, attr_kind
);
4842 return a
? AT_unsigned (a
) : 0;
4845 static inline dw_die_ref
4846 get_AT_ref (die
, attr_kind
)
4848 enum dwarf_attribute attr_kind
;
4850 dw_attr_ref a
= get_AT (die
, attr_kind
);
4851 return a
? AT_ref (a
) : NULL
;
4857 unsigned lang
= get_AT_unsigned (comp_unit_die
, DW_AT_language
);
4859 return (lang
== DW_LANG_C
|| lang
== DW_LANG_C89
4860 || lang
== DW_LANG_C_plus_plus
);
4866 return (get_AT_unsigned (comp_unit_die
, DW_AT_language
)
4867 == DW_LANG_C_plus_plus
);
4873 unsigned lang
= get_AT_unsigned (comp_unit_die
, DW_AT_language
);
4875 return (lang
== DW_LANG_Fortran77
|| lang
== DW_LANG_Fortran90
);
4881 unsigned lang
= get_AT_unsigned (comp_unit_die
, DW_AT_language
);
4883 return (lang
== DW_LANG_Java
);
4886 /* Free up the memory used by A. */
4888 static inline void free_AT
PARAMS ((dw_attr_ref
));
4893 switch (AT_class (a
))
4895 case dw_val_class_str
:
4896 if (a
->dw_attr_val
.v
.val_str
->refcount
)
4897 a
->dw_attr_val
.v
.val_str
->refcount
--;
4900 case dw_val_class_lbl_id
:
4901 case dw_val_class_lbl_offset
:
4902 free (a
->dw_attr_val
.v
.val_lbl_id
);
4905 case dw_val_class_float
:
4906 free (a
->dw_attr_val
.v
.val_float
.array
);
4916 /* Remove the specified attribute if present. */
4919 remove_AT (die
, attr_kind
)
4921 enum dwarf_attribute attr_kind
;
4924 dw_attr_ref removed
= NULL
;
4928 for (p
= &(die
->die_attr
); *p
; p
= &((*p
)->dw_attr_next
))
4929 if ((*p
)->dw_attr
== attr_kind
)
4932 *p
= (*p
)->dw_attr_next
;
4941 /* Free up the memory used by DIE. */
4943 static inline void free_die
PARAMS ((dw_die_ref
));
4948 remove_children (die
);
4952 /* Discard the children of this DIE. */
4955 remove_children (die
)
4958 dw_die_ref child_die
= die
->die_child
;
4960 die
->die_child
= NULL
;
4962 while (child_die
!= NULL
)
4964 dw_die_ref tmp_die
= child_die
;
4967 child_die
= child_die
->die_sib
;
4969 for (a
= tmp_die
->die_attr
; a
!= NULL
;)
4971 dw_attr_ref tmp_a
= a
;
4973 a
= a
->dw_attr_next
;
4981 /* Add a child DIE below its parent. We build the lists up in reverse
4982 addition order, and correct that in reverse_all_dies. */
4985 add_child_die (die
, child_die
)
4987 dw_die_ref child_die
;
4989 if (die
!= NULL
&& child_die
!= NULL
)
4991 if (die
== child_die
)
4993 child_die
->die_parent
= die
;
4994 child_die
->die_sib
= die
->die_child
;
4995 die
->die_child
= child_die
;
4999 /* Move CHILD, which must be a child of PARENT or the DIE for which PARENT
5000 is the specification, to the front of PARENT's list of children. */
5003 splice_child_die (parent
, child
)
5004 dw_die_ref parent
, child
;
5008 /* We want the declaration DIE from inside the class, not the
5009 specification DIE at toplevel. */
5010 if (child
->die_parent
!= parent
)
5012 dw_die_ref tmp
= get_AT_ref (child
, DW_AT_specification
);
5017 if (child
->die_parent
!= parent
5018 && child
->die_parent
!= get_AT_ref (parent
, DW_AT_specification
))
5021 for (p
= &(child
->die_parent
->die_child
); *p
; p
= &((*p
)->die_sib
))
5024 *p
= child
->die_sib
;
5028 child
->die_sib
= parent
->die_child
;
5029 parent
->die_child
= child
;
5032 /* Return a pointer to a newly created DIE node. */
5034 static inline dw_die_ref
5035 new_die (tag_value
, parent_die
)
5036 enum dwarf_tag tag_value
;
5037 dw_die_ref parent_die
;
5039 dw_die_ref die
= (dw_die_ref
) xcalloc (1, sizeof (die_node
));
5041 die
->die_tag
= tag_value
;
5043 if (parent_die
!= NULL
)
5044 add_child_die (parent_die
, die
);
5047 limbo_die_node
*limbo_node
;
5049 limbo_node
= (limbo_die_node
*) xmalloc (sizeof (limbo_die_node
));
5050 limbo_node
->die
= die
;
5051 limbo_node
->next
= limbo_die_list
;
5052 limbo_die_list
= limbo_node
;
5058 /* Return the DIE associated with the given type specifier. */
5060 static inline dw_die_ref
5061 lookup_type_die (type
)
5064 if (TREE_CODE (type
) == VECTOR_TYPE
)
5065 type
= TYPE_DEBUG_REPRESENTATION_TYPE (type
);
5066 return (dw_die_ref
) TYPE_SYMTAB_POINTER (type
);
5069 /* Equate a DIE to a given type specifier. */
5072 equate_type_number_to_die (type
, type_die
)
5074 dw_die_ref type_die
;
5076 TYPE_SYMTAB_POINTER (type
) = (char *) type_die
;
5079 /* Return the DIE associated with a given declaration. */
5081 static inline dw_die_ref
5082 lookup_decl_die (decl
)
5085 unsigned decl_id
= DECL_UID (decl
);
5087 return (decl_id
< decl_die_table_in_use
5088 ? decl_die_table
[decl_id
] : NULL
);
5091 /* Equate a DIE to a particular declaration. */
5094 equate_decl_number_to_die (decl
, decl_die
)
5096 dw_die_ref decl_die
;
5098 unsigned decl_id
= DECL_UID (decl
);
5099 unsigned num_allocated
;
5101 if (decl_id
>= decl_die_table_allocated
)
5104 = ((decl_id
+ 1 + DECL_DIE_TABLE_INCREMENT
- 1)
5105 / DECL_DIE_TABLE_INCREMENT
)
5106 * DECL_DIE_TABLE_INCREMENT
;
5109 = (dw_die_ref
*) xrealloc (decl_die_table
,
5110 sizeof (dw_die_ref
) * num_allocated
);
5112 memset ((char *) &decl_die_table
[decl_die_table_allocated
], 0,
5113 (num_allocated
- decl_die_table_allocated
) * sizeof (dw_die_ref
));
5114 decl_die_table_allocated
= num_allocated
;
5117 if (decl_id
>= decl_die_table_in_use
)
5118 decl_die_table_in_use
= (decl_id
+ 1);
5120 decl_die_table
[decl_id
] = decl_die
;
5123 /* Keep track of the number of spaces used to indent the
5124 output of the debugging routines that print the structure of
5125 the DIE internal representation. */
5126 static int print_indent
;
5128 /* Indent the line the number of spaces given by print_indent. */
5131 print_spaces (outfile
)
5134 fprintf (outfile
, "%*s", print_indent
, "");
5137 /* Print the information associated with a given DIE, and its children.
5138 This routine is a debugging aid only. */
5141 print_die (die
, outfile
)
5148 print_spaces (outfile
);
5149 fprintf (outfile
, "DIE %4lu: %s\n",
5150 die
->die_offset
, dwarf_tag_name (die
->die_tag
));
5151 print_spaces (outfile
);
5152 fprintf (outfile
, " abbrev id: %lu", die
->die_abbrev
);
5153 fprintf (outfile
, " offset: %lu\n", die
->die_offset
);
5155 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
5157 print_spaces (outfile
);
5158 fprintf (outfile
, " %s: ", dwarf_attr_name (a
->dw_attr
));
5160 switch (AT_class (a
))
5162 case dw_val_class_addr
:
5163 fprintf (outfile
, "address");
5165 case dw_val_class_offset
:
5166 fprintf (outfile
, "offset");
5168 case dw_val_class_loc
:
5169 fprintf (outfile
, "location descriptor");
5171 case dw_val_class_loc_list
:
5172 fprintf (outfile
, "location list -> label:%s",
5173 AT_loc_list (a
)->ll_symbol
);
5175 case dw_val_class_range_list
:
5176 fprintf (outfile
, "range list");
5178 case dw_val_class_const
:
5179 fprintf (outfile
, "%ld", AT_int (a
));
5181 case dw_val_class_unsigned_const
:
5182 fprintf (outfile
, "%lu", AT_unsigned (a
));
5184 case dw_val_class_long_long
:
5185 fprintf (outfile
, "constant (%lu,%lu)",
5186 a
->dw_attr_val
.v
.val_long_long
.hi
,
5187 a
->dw_attr_val
.v
.val_long_long
.low
);
5189 case dw_val_class_float
:
5190 fprintf (outfile
, "floating-point constant");
5192 case dw_val_class_flag
:
5193 fprintf (outfile
, "%u", AT_flag (a
));
5195 case dw_val_class_die_ref
:
5196 if (AT_ref (a
) != NULL
)
5198 if (AT_ref (a
)->die_symbol
)
5199 fprintf (outfile
, "die -> label: %s", AT_ref (a
)->die_symbol
);
5201 fprintf (outfile
, "die -> %lu", AT_ref (a
)->die_offset
);
5204 fprintf (outfile
, "die -> <null>");
5206 case dw_val_class_lbl_id
:
5207 case dw_val_class_lbl_offset
:
5208 fprintf (outfile
, "label: %s", AT_lbl (a
));
5210 case dw_val_class_str
:
5211 if (AT_string (a
) != NULL
)
5212 fprintf (outfile
, "\"%s\"", AT_string (a
));
5214 fprintf (outfile
, "<null>");
5220 fprintf (outfile
, "\n");
5223 if (die
->die_child
!= NULL
)
5226 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
5227 print_die (c
, outfile
);
5231 if (print_indent
== 0)
5232 fprintf (outfile
, "\n");
5235 /* Print the contents of the source code line number correspondence table.
5236 This routine is a debugging aid only. */
5239 print_dwarf_line_table (outfile
)
5243 dw_line_info_ref line_info
;
5245 fprintf (outfile
, "\n\nDWARF source line information\n");
5246 for (i
= 1; i
< line_info_table_in_use
; ++i
)
5248 line_info
= &line_info_table
[i
];
5249 fprintf (outfile
, "%5d: ", i
);
5250 fprintf (outfile
, "%-20s", file_table
.table
[line_info
->dw_file_num
]);
5251 fprintf (outfile
, "%6ld", line_info
->dw_line_num
);
5252 fprintf (outfile
, "\n");
5255 fprintf (outfile
, "\n\n");
5258 /* Print the information collected for a given DIE. */
5261 debug_dwarf_die (die
)
5264 print_die (die
, stderr
);
5267 /* Print all DWARF information collected for the compilation unit.
5268 This routine is a debugging aid only. */
5274 print_die (comp_unit_die
, stderr
);
5275 if (! DWARF2_ASM_LINE_DEBUG_INFO
)
5276 print_dwarf_line_table (stderr
);
5279 /* We build up the lists of children and attributes by pushing new ones
5280 onto the beginning of the list. Reverse the lists for DIE so that
5281 they are in order of addition. */
5284 reverse_die_lists (die
)
5287 dw_die_ref c
, cp
, cn
;
5288 dw_attr_ref a
, ap
, an
;
5290 for (a
= die
->die_attr
, ap
= 0; a
; a
= an
)
5292 an
= a
->dw_attr_next
;
5293 a
->dw_attr_next
= ap
;
5298 for (c
= die
->die_child
, cp
= 0; c
; c
= cn
)
5304 die
->die_child
= cp
;
5307 /* reverse_die_lists only reverses the single die you pass it. Since
5308 we used to reverse all dies in add_sibling_attributes, which runs
5309 through all the dies, it would reverse all the dies. Now, however,
5310 since we don't call reverse_die_lists in add_sibling_attributes, we
5311 need a routine to recursively reverse all the dies. This is that
5315 reverse_all_dies (die
)
5320 reverse_die_lists (die
);
5322 for (c
= die
->die_child
; c
; c
= c
->die_sib
)
5323 reverse_all_dies (c
);
5326 /* Start a new compilation unit DIE for an include file. OLD_UNIT is
5327 the CU for the enclosing include file, if any. BINCL_DIE is the
5328 DW_TAG_GNU_BINCL DIE that marks the start of the DIEs for this
5332 push_new_compile_unit (old_unit
, bincl_die
)
5333 dw_die_ref old_unit
, bincl_die
;
5335 const char *filename
= get_AT_string (bincl_die
, DW_AT_name
);
5336 dw_die_ref new_unit
= gen_compile_unit_die (filename
);
5337 new_unit
->die_sib
= old_unit
;
5341 /* Close an include-file CU and reopen the enclosing one. */
5344 pop_compile_unit (old_unit
)
5345 dw_die_ref old_unit
;
5347 dw_die_ref new_unit
= old_unit
->die_sib
;
5348 old_unit
->die_sib
= NULL
;
5352 #define PROCESS(FOO) md5_process_bytes (&(FOO), sizeof (FOO), ctx)
5353 #define PROCESS_STRING(FOO) md5_process_bytes ((FOO), strlen (FOO), ctx)
5355 /* Calculate the checksum of a location expression. */
5358 loc_checksum (loc
, ctx
)
5359 dw_loc_descr_ref loc
;
5360 struct md5_ctx
*ctx
;
5362 PROCESS (loc
->dw_loc_opc
);
5363 PROCESS (loc
->dw_loc_oprnd1
);
5364 PROCESS (loc
->dw_loc_oprnd2
);
5367 /* Calculate the checksum of an attribute. */
5370 attr_checksum (at
, ctx
)
5372 struct md5_ctx
*ctx
;
5374 dw_loc_descr_ref loc
;
5377 PROCESS (at
->dw_attr
);
5379 /* We don't care about differences in file numbering. */
5380 if (at
->dw_attr
== DW_AT_decl_file
5381 /* Or that this was compiled with a different compiler snapshot; if
5382 the output is the same, that's what matters. */
5383 || at
->dw_attr
== DW_AT_producer
)
5386 switch (AT_class (at
))
5388 case dw_val_class_const
:
5389 PROCESS (at
->dw_attr_val
.v
.val_int
);
5391 case dw_val_class_unsigned_const
:
5392 PROCESS (at
->dw_attr_val
.v
.val_unsigned
);
5394 case dw_val_class_long_long
:
5395 PROCESS (at
->dw_attr_val
.v
.val_long_long
);
5397 case dw_val_class_float
:
5398 PROCESS (at
->dw_attr_val
.v
.val_float
);
5400 case dw_val_class_flag
:
5401 PROCESS (at
->dw_attr_val
.v
.val_flag
);
5404 case dw_val_class_str
:
5405 PROCESS_STRING (AT_string (at
));
5408 case dw_val_class_addr
:
5410 switch (GET_CODE (r
))
5413 PROCESS_STRING (XSTR (r
, 0));
5421 case dw_val_class_offset
:
5422 PROCESS (at
->dw_attr_val
.v
.val_offset
);
5425 case dw_val_class_loc
:
5426 for (loc
= AT_loc (at
); loc
; loc
= loc
->dw_loc_next
)
5427 loc_checksum (loc
, ctx
);
5430 case dw_val_class_die_ref
:
5431 if (AT_ref (at
)->die_offset
)
5432 PROCESS (AT_ref (at
)->die_offset
);
5433 /* FIXME else use target die name or something. */
5435 case dw_val_class_fde_ref
:
5436 case dw_val_class_lbl_id
:
5437 case dw_val_class_lbl_offset
:
5445 /* Calculate the checksum of a DIE. */
5448 die_checksum (die
, ctx
)
5450 struct md5_ctx
*ctx
;
5455 PROCESS (die
->die_tag
);
5457 for (a
= die
->die_attr
; a
; a
= a
->dw_attr_next
)
5458 attr_checksum (a
, ctx
);
5460 for (c
= die
->die_child
; c
; c
= c
->die_sib
)
5461 die_checksum (c
, ctx
);
5465 #undef PROCESS_STRING
5467 /* The prefix to attach to symbols on DIEs in the current comdat debug
5469 static char *comdat_symbol_id
;
5471 /* The index of the current symbol within the current comdat CU. */
5472 static unsigned int comdat_symbol_number
;
5474 /* Calculate the MD5 checksum of the compilation unit DIE UNIT_DIE and its
5475 children, and set comdat_symbol_id accordingly. */
5478 compute_section_prefix (unit_die
)
5479 dw_die_ref unit_die
;
5483 unsigned char checksum
[16];
5486 md5_init_ctx (&ctx
);
5487 die_checksum (unit_die
, &ctx
);
5488 md5_finish_ctx (&ctx
, checksum
);
5491 const char *p
= lbasename (get_AT_string (unit_die
, DW_AT_name
));
5492 name
= (char *) alloca (strlen (p
) + 64);
5493 sprintf (name
, "%s.", p
);
5496 clean_symbol_name (name
);
5499 char *p
= name
+ strlen (name
);
5500 for (i
= 0; i
< 4; ++i
)
5502 sprintf (p
, "%.2x", checksum
[i
]);
5507 comdat_symbol_id
= unit_die
->die_symbol
= xstrdup (name
);
5508 comdat_symbol_number
= 0;
5511 /* Returns nonzero iff DIE represents a type, in the sense of TYPE_P. */
5517 switch (die
->die_tag
)
5519 case DW_TAG_array_type
:
5520 case DW_TAG_class_type
:
5521 case DW_TAG_enumeration_type
:
5522 case DW_TAG_pointer_type
:
5523 case DW_TAG_reference_type
:
5524 case DW_TAG_string_type
:
5525 case DW_TAG_structure_type
:
5526 case DW_TAG_subroutine_type
:
5527 case DW_TAG_union_type
:
5528 case DW_TAG_ptr_to_member_type
:
5529 case DW_TAG_set_type
:
5530 case DW_TAG_subrange_type
:
5531 case DW_TAG_base_type
:
5532 case DW_TAG_const_type
:
5533 case DW_TAG_file_type
:
5534 case DW_TAG_packed_type
:
5535 case DW_TAG_volatile_type
:
5542 /* Returns 1 iff C is the sort of DIE that should go into a COMDAT CU.
5543 Basically, we want to choose the bits that are likely to be shared between
5544 compilations (types) and leave out the bits that are specific to individual
5545 compilations (functions). */
5552 /* I think we want to leave base types and __vtbl_ptr_type in the
5553 main CU, as we do for stabs. The advantage is a greater
5554 likelihood of sharing between objects that don't include headers
5555 in the same order (and therefore would put the base types in a
5556 different comdat). jason 8/28/00 */
5557 if (c
->die_tag
== DW_TAG_base_type
)
5560 if (c
->die_tag
== DW_TAG_pointer_type
5561 || c
->die_tag
== DW_TAG_reference_type
5562 || c
->die_tag
== DW_TAG_const_type
5563 || c
->die_tag
== DW_TAG_volatile_type
)
5565 dw_die_ref t
= get_AT_ref (c
, DW_AT_type
);
5566 return t
? is_comdat_die (t
) : 0;
5570 return is_type_die (c
);
5573 /* Returns 1 iff C is the sort of DIE that might be referred to from another
5574 compilation unit. */
5580 if (is_type_die (c
))
5582 if (get_AT (c
, DW_AT_declaration
)
5583 && ! get_AT (c
, DW_AT_specification
))
5589 gen_internal_sym (prefix
)
5593 static int label_num
;
5594 ASM_GENERATE_INTERNAL_LABEL (buf
, prefix
, label_num
++);
5595 return xstrdup (buf
);
5598 /* Assign symbols to all worthy DIEs under DIE. */
5601 assign_symbol_names (die
)
5606 if (is_symbol_die (die
))
5608 if (comdat_symbol_id
)
5610 char *p
= alloca (strlen (comdat_symbol_id
) + 64);
5611 sprintf (p
, "%s.%s.%x", DIE_LABEL_PREFIX
,
5612 comdat_symbol_id
, comdat_symbol_number
++);
5613 die
->die_symbol
= xstrdup (p
);
5616 die
->die_symbol
= gen_internal_sym ("LDIE");
5619 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
5620 assign_symbol_names (c
);
5623 /* Traverse the DIE (which is always comp_unit_die), and set up
5624 additional compilation units for each of the include files we see
5625 bracketed by BINCL/EINCL. */
5628 break_out_includes (die
)
5632 dw_die_ref unit
= NULL
;
5633 limbo_die_node
*node
;
5635 for (ptr
= &(die
->die_child
); *ptr
; )
5637 dw_die_ref c
= *ptr
;
5639 if (c
->die_tag
== DW_TAG_GNU_BINCL
5640 || c
->die_tag
== DW_TAG_GNU_EINCL
5641 || (unit
&& is_comdat_die (c
)))
5643 /* This DIE is for a secondary CU; remove it from the main one. */
5646 if (c
->die_tag
== DW_TAG_GNU_BINCL
)
5648 unit
= push_new_compile_unit (unit
, c
);
5651 else if (c
->die_tag
== DW_TAG_GNU_EINCL
)
5653 unit
= pop_compile_unit (unit
);
5657 add_child_die (unit
, c
);
5661 /* Leave this DIE in the main CU. */
5662 ptr
= &(c
->die_sib
);
5668 /* We can only use this in debugging, since the frontend doesn't check
5669 to make sure that we leave every include file we enter. */
5674 assign_symbol_names (die
);
5675 for (node
= limbo_die_list
; node
; node
= node
->next
)
5677 compute_section_prefix (node
->die
);
5678 assign_symbol_names (node
->die
);
5682 /* Traverse the DIE and add a sibling attribute if it may have the
5683 effect of speeding up access to siblings. To save some space,
5684 avoid generating sibling attributes for DIE's without children. */
5687 add_sibling_attributes (die
)
5692 if (die
->die_tag
!= DW_TAG_compile_unit
5693 && die
->die_sib
&& die
->die_child
!= NULL
)
5694 /* Add the sibling link to the front of the attribute list. */
5695 add_AT_die_ref (die
, DW_AT_sibling
, die
->die_sib
);
5697 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
5698 add_sibling_attributes (c
);
5701 /* Output all location lists for the DIE and it's children */
5703 output_location_lists (die
)
5708 for (d_attr
= die
->die_attr
; d_attr
; d_attr
= d_attr
->dw_attr_next
)
5710 if (AT_class (d_attr
) == dw_val_class_loc_list
)
5712 output_loc_list (AT_loc_list (d_attr
));
5715 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
5716 output_location_lists (c
);
5719 /* The format of each DIE (and its attribute value pairs)
5720 is encoded in an abbreviation table. This routine builds the
5721 abbreviation table and assigns a unique abbreviation id for
5722 each abbreviation entry. The children of each die are visited
5726 build_abbrev_table (die
)
5729 unsigned long abbrev_id
;
5730 unsigned int n_alloc
;
5732 dw_attr_ref d_attr
, a_attr
;
5734 /* Scan the DIE references, and mark as external any that refer to
5735 DIEs from other CUs (i.e. those which are not marked). */
5736 for (d_attr
= die
->die_attr
; d_attr
; d_attr
= d_attr
->dw_attr_next
)
5738 if (AT_class (d_attr
) == dw_val_class_die_ref
5739 && AT_ref (d_attr
)->die_mark
== 0)
5741 if (AT_ref (d_attr
)->die_symbol
== 0)
5743 set_AT_ref_external (d_attr
, 1);
5747 for (abbrev_id
= 1; abbrev_id
< abbrev_die_table_in_use
; ++abbrev_id
)
5749 dw_die_ref abbrev
= abbrev_die_table
[abbrev_id
];
5751 if (abbrev
->die_tag
== die
->die_tag
)
5753 if ((abbrev
->die_child
!= NULL
) == (die
->die_child
!= NULL
))
5755 a_attr
= abbrev
->die_attr
;
5756 d_attr
= die
->die_attr
;
5758 while (a_attr
!= NULL
&& d_attr
!= NULL
)
5760 if ((a_attr
->dw_attr
!= d_attr
->dw_attr
)
5761 || (value_format (a_attr
) != value_format (d_attr
)))
5764 a_attr
= a_attr
->dw_attr_next
;
5765 d_attr
= d_attr
->dw_attr_next
;
5768 if (a_attr
== NULL
&& d_attr
== NULL
)
5774 if (abbrev_id
>= abbrev_die_table_in_use
)
5776 if (abbrev_die_table_in_use
>= abbrev_die_table_allocated
)
5778 n_alloc
= abbrev_die_table_allocated
+ ABBREV_DIE_TABLE_INCREMENT
;
5780 = (dw_die_ref
*) xrealloc (abbrev_die_table
,
5781 sizeof (dw_die_ref
) * n_alloc
);
5783 memset ((char *) &abbrev_die_table
[abbrev_die_table_allocated
], 0,
5784 (n_alloc
- abbrev_die_table_allocated
) * sizeof (dw_die_ref
));
5785 abbrev_die_table_allocated
= n_alloc
;
5788 ++abbrev_die_table_in_use
;
5789 abbrev_die_table
[abbrev_id
] = die
;
5792 die
->die_abbrev
= abbrev_id
;
5793 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
5794 build_abbrev_table (c
);
5797 /* Return the power-of-two number of bytes necessary to represent VALUE. */
5800 constant_size (value
)
5801 long unsigned value
;
5808 log
= floor_log2 (value
);
5811 log
= 1 << (floor_log2 (log
) + 1);
5816 /* Return the size of a DIE, as it is represented in the
5817 .debug_info section. */
5819 static unsigned long
5823 unsigned long size
= 0;
5826 size
+= size_of_uleb128 (die
->die_abbrev
);
5827 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
5829 switch (AT_class (a
))
5831 case dw_val_class_addr
:
5832 size
+= DWARF2_ADDR_SIZE
;
5834 case dw_val_class_offset
:
5835 size
+= DWARF_OFFSET_SIZE
;
5837 case dw_val_class_loc
:
5839 unsigned long lsize
= size_of_locs (AT_loc (a
));
5842 size
+= constant_size (lsize
);
5846 case dw_val_class_loc_list
:
5847 size
+= DWARF_OFFSET_SIZE
;
5849 case dw_val_class_range_list
:
5850 size
+= DWARF_OFFSET_SIZE
;
5852 case dw_val_class_const
:
5853 size
+= size_of_sleb128 (AT_int (a
));
5855 case dw_val_class_unsigned_const
:
5856 size
+= constant_size (AT_unsigned (a
));
5858 case dw_val_class_long_long
:
5859 size
+= 1 + 2*HOST_BITS_PER_LONG
/HOST_BITS_PER_CHAR
; /* block */
5861 case dw_val_class_float
:
5862 size
+= 1 + a
->dw_attr_val
.v
.val_float
.length
* 4; /* block */
5864 case dw_val_class_flag
:
5867 case dw_val_class_die_ref
:
5868 size
+= DWARF_OFFSET_SIZE
;
5870 case dw_val_class_fde_ref
:
5871 size
+= DWARF_OFFSET_SIZE
;
5873 case dw_val_class_lbl_id
:
5874 size
+= DWARF2_ADDR_SIZE
;
5876 case dw_val_class_lbl_offset
:
5877 size
+= DWARF_OFFSET_SIZE
;
5879 case dw_val_class_str
:
5880 if (AT_string_form (a
) == DW_FORM_strp
)
5881 size
+= DWARF_OFFSET_SIZE
;
5883 size
+= HT_LEN (&a
->dw_attr_val
.v
.val_str
->id
) + 1;
5893 /* Size the debugging information associated with a given DIE.
5894 Visits the DIE's children recursively. Updates the global
5895 variable next_die_offset, on each time through. Uses the
5896 current value of next_die_offset to update the die_offset
5897 field in each DIE. */
5900 calc_die_sizes (die
)
5904 die
->die_offset
= next_die_offset
;
5905 next_die_offset
+= size_of_die (die
);
5907 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
5910 if (die
->die_child
!= NULL
)
5911 /* Count the null byte used to terminate sibling lists. */
5912 next_die_offset
+= 1;
5915 /* Set the marks for a die and its children. We do this so
5916 that we know whether or not a reference needs to use FORM_ref_addr; only
5917 DIEs in the same CU will be marked. We used to clear out the offset
5918 and use that as the flag, but ran into ordering problems. */
5926 for (c
= die
->die_child
; c
; c
= c
->die_sib
)
5930 /* Clear the marks for a die and its children. */
5938 for (c
= die
->die_child
; c
; c
= c
->die_sib
)
5942 /* Return the size of the .debug_pubnames table generated for the
5943 compilation unit. */
5945 static unsigned long
5951 size
= DWARF_PUBNAMES_HEADER_SIZE
;
5952 for (i
= 0; i
< pubname_table_in_use
; ++i
)
5954 pubname_ref p
= &pubname_table
[i
];
5955 size
+= DWARF_OFFSET_SIZE
+ strlen (p
->name
) + 1;
5958 size
+= DWARF_OFFSET_SIZE
;
5962 /* Return the size of the information in the .debug_aranges section. */
5964 static unsigned long
5969 size
= DWARF_ARANGES_HEADER_SIZE
;
5971 /* Count the address/length pair for this compilation unit. */
5972 size
+= 2 * DWARF2_ADDR_SIZE
;
5973 size
+= 2 * DWARF2_ADDR_SIZE
* arange_table_in_use
;
5975 /* Count the two zero words used to terminated the address range table. */
5976 size
+= 2 * DWARF2_ADDR_SIZE
;
5980 /* Select the encoding of an attribute value. */
5982 static enum dwarf_form
5986 switch (a
->dw_attr_val
.val_class
)
5988 case dw_val_class_addr
:
5989 return DW_FORM_addr
;
5990 case dw_val_class_range_list
:
5991 case dw_val_class_offset
:
5992 if (DWARF_OFFSET_SIZE
== 4)
5993 return DW_FORM_data4
;
5994 if (DWARF_OFFSET_SIZE
== 8)
5995 return DW_FORM_data8
;
5997 case dw_val_class_loc_list
:
5998 /* FIXME: Could be DW_FORM_data8, with a > 32 bit size
5999 .debug_loc section */
6000 return DW_FORM_data4
;
6001 case dw_val_class_loc
:
6002 switch (constant_size (size_of_locs (AT_loc (a
))))
6005 return DW_FORM_block1
;
6007 return DW_FORM_block2
;
6011 case dw_val_class_const
:
6012 return DW_FORM_sdata
;
6013 case dw_val_class_unsigned_const
:
6014 switch (constant_size (AT_unsigned (a
)))
6017 return DW_FORM_data1
;
6019 return DW_FORM_data2
;
6021 return DW_FORM_data4
;
6023 return DW_FORM_data8
;
6027 case dw_val_class_long_long
:
6028 return DW_FORM_block1
;
6029 case dw_val_class_float
:
6030 return DW_FORM_block1
;
6031 case dw_val_class_flag
:
6032 return DW_FORM_flag
;
6033 case dw_val_class_die_ref
:
6034 if (AT_ref_external (a
))
6035 return DW_FORM_ref_addr
;
6038 case dw_val_class_fde_ref
:
6039 return DW_FORM_data
;
6040 case dw_val_class_lbl_id
:
6041 return DW_FORM_addr
;
6042 case dw_val_class_lbl_offset
:
6043 return DW_FORM_data
;
6044 case dw_val_class_str
:
6045 return AT_string_form (a
);
6052 /* Output the encoding of an attribute value. */
6055 output_value_format (a
)
6058 enum dwarf_form form
= value_format (a
);
6059 dw2_asm_output_data_uleb128 (form
, "(%s)", dwarf_form_name (form
));
6062 /* Output the .debug_abbrev section which defines the DIE abbreviation
6066 output_abbrev_section ()
6068 unsigned long abbrev_id
;
6071 for (abbrev_id
= 1; abbrev_id
< abbrev_die_table_in_use
; ++abbrev_id
)
6073 dw_die_ref abbrev
= abbrev_die_table
[abbrev_id
];
6075 dw2_asm_output_data_uleb128 (abbrev_id
, "(abbrev code)");
6077 dw2_asm_output_data_uleb128 (abbrev
->die_tag
, "(TAG: %s)",
6078 dwarf_tag_name (abbrev
->die_tag
));
6080 if (abbrev
->die_child
!= NULL
)
6081 dw2_asm_output_data (1, DW_children_yes
, "DW_children_yes");
6083 dw2_asm_output_data (1, DW_children_no
, "DW_children_no");
6085 for (a_attr
= abbrev
->die_attr
; a_attr
!= NULL
;
6086 a_attr
= a_attr
->dw_attr_next
)
6088 dw2_asm_output_data_uleb128 (a_attr
->dw_attr
, "(%s)",
6089 dwarf_attr_name (a_attr
->dw_attr
));
6090 output_value_format (a_attr
);
6093 dw2_asm_output_data (1, 0, NULL
);
6094 dw2_asm_output_data (1, 0, NULL
);
6097 /* Terminate the table. */
6098 dw2_asm_output_data (1, 0, NULL
);
6101 /* Output a symbol we can use to refer to this DIE from another CU. */
6104 output_die_symbol (die
)
6107 char *sym
= die
->die_symbol
;
6112 if (strncmp (sym
, DIE_LABEL_PREFIX
, sizeof (DIE_LABEL_PREFIX
) - 1) == 0)
6113 /* We make these global, not weak; if the target doesn't support
6114 .linkonce, it doesn't support combining the sections, so debugging
6116 ASM_GLOBALIZE_LABEL (asm_out_file
, sym
);
6117 ASM_OUTPUT_LABEL (asm_out_file
, sym
);
6120 /* Return a new location list, given the begin and end range, and the
6121 expression. gensym tells us whether to generate a new internal
6122 symbol for this location list node, which is done for the head of
6124 static inline dw_loc_list_ref
6125 new_loc_list (expr
, begin
, end
, section
, gensym
)
6126 dw_loc_descr_ref expr
;
6129 const char *section
;
6132 dw_loc_list_ref retlist
6133 = (dw_loc_list_ref
) xcalloc (1, sizeof (dw_loc_list_node
));
6134 retlist
->begin
= begin
;
6136 retlist
->expr
= expr
;
6137 retlist
->section
= section
;
6139 retlist
->ll_symbol
= gen_internal_sym ("LLST");
6143 /* Add a location description expression to a location list */
6145 add_loc_descr_to_loc_list (list_head
, descr
, begin
, end
, section
)
6146 dw_loc_list_ref
*list_head
;
6147 dw_loc_descr_ref descr
;
6150 const char *section
;
6154 /* Find the end of the chain. */
6155 for (d
= list_head
; (*d
) != NULL
; d
= &(*d
)->dw_loc_next
)
6157 /* Add a new location list node to the list */
6158 *d
= new_loc_list (descr
, begin
, end
, section
, 0);
6161 /* Output the location list given to us */
6163 output_loc_list (list_head
)
6164 dw_loc_list_ref list_head
;
6166 dw_loc_list_ref curr
=list_head
;
6167 ASM_OUTPUT_LABEL (asm_out_file
, list_head
->ll_symbol
);
6169 /* ??? This shouldn't be needed now that we've forced the
6170 compilation unit base address to zero when there is code
6171 in more than one section. */
6172 if (strcmp (curr
->section
, ".text") == 0)
6174 /* dw2_asm_output_data will mask off any extra bits in the ~0. */
6175 dw2_asm_output_data (DWARF2_ADDR_SIZE
, ~(unsigned HOST_WIDE_INT
)0,
6176 "Location list base address specifier fake entry");
6177 dw2_asm_output_offset (DWARF2_ADDR_SIZE
, curr
->section
,
6178 "Location list base address specifier base");
6180 for (curr
= list_head
; curr
!= NULL
; curr
=curr
->dw_loc_next
)
6183 dw2_asm_output_delta (DWARF2_ADDR_SIZE
, curr
->begin
, curr
->section
,
6184 "Location list begin address (%s)",
6185 list_head
->ll_symbol
);
6186 dw2_asm_output_delta (DWARF2_ADDR_SIZE
, curr
->end
, curr
->section
,
6187 "Location list end address (%s)",
6188 list_head
->ll_symbol
);
6189 size
= size_of_locs (curr
->expr
);
6191 /* Output the block length for this list of location operations. */
6194 dw2_asm_output_data (2, size
, "%s", "Location expression size");
6196 output_loc_sequence (curr
->expr
);
6198 dw2_asm_output_data (DWARF_OFFSET_SIZE
, 0,
6199 "Location list terminator begin (%s)",
6200 list_head
->ll_symbol
);
6201 dw2_asm_output_data (DWARF_OFFSET_SIZE
, 0,
6202 "Location list terminator end (%s)",
6203 list_head
->ll_symbol
);
6206 /* Output the DIE and its attributes. Called recursively to generate
6207 the definitions of each child DIE. */
6217 /* If someone in another CU might refer to us, set up a symbol for
6218 them to point to. */
6219 if (die
->die_symbol
)
6220 output_die_symbol (die
);
6222 dw2_asm_output_data_uleb128 (die
->die_abbrev
, "(DIE (0x%lx) %s)",
6223 die
->die_offset
, dwarf_tag_name (die
->die_tag
));
6225 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
6227 const char *name
= dwarf_attr_name (a
->dw_attr
);
6229 switch (AT_class (a
))
6231 case dw_val_class_addr
:
6232 dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE
, AT_addr (a
), "%s", name
);
6235 case dw_val_class_offset
:
6236 dw2_asm_output_data (DWARF_OFFSET_SIZE
, a
->dw_attr_val
.v
.val_offset
,
6240 case dw_val_class_range_list
:
6242 char *p
= strchr (ranges_section_label
, '\0');
6244 sprintf (p
, "+0x%lx", a
->dw_attr_val
.v
.val_offset
);
6245 dw2_asm_output_offset (DWARF_OFFSET_SIZE
, ranges_section_label
,
6251 case dw_val_class_loc
:
6252 size
= size_of_locs (AT_loc (a
));
6254 /* Output the block length for this list of location operations. */
6255 dw2_asm_output_data (constant_size (size
), size
, "%s", name
);
6257 output_loc_sequence (AT_loc (a
));
6260 case dw_val_class_const
:
6261 /* ??? It would be slightly more efficient to use a scheme like is
6262 used for unsigned constants below, but gdb 4.x does not sign
6263 extend. Gdb 5.x does sign extend. */
6264 dw2_asm_output_data_sleb128 (AT_int (a
), "%s", name
);
6267 case dw_val_class_unsigned_const
:
6268 dw2_asm_output_data (constant_size (AT_unsigned (a
)),
6269 AT_unsigned (a
), "%s", name
);
6272 case dw_val_class_long_long
:
6274 unsigned HOST_WIDE_INT first
, second
;
6276 dw2_asm_output_data (1, 2*HOST_BITS_PER_LONG
/HOST_BITS_PER_CHAR
,
6279 if (WORDS_BIG_ENDIAN
)
6281 first
= a
->dw_attr_val
.v
.val_long_long
.hi
;
6282 second
= a
->dw_attr_val
.v
.val_long_long
.low
;
6286 first
= a
->dw_attr_val
.v
.val_long_long
.low
;
6287 second
= a
->dw_attr_val
.v
.val_long_long
.hi
;
6289 dw2_asm_output_data (HOST_BITS_PER_LONG
/HOST_BITS_PER_CHAR
,
6290 first
, "long long constant");
6291 dw2_asm_output_data (HOST_BITS_PER_LONG
/HOST_BITS_PER_CHAR
,
6296 case dw_val_class_float
:
6300 dw2_asm_output_data (1, a
->dw_attr_val
.v
.val_float
.length
* 4,
6303 for (i
= 0; i
< a
->dw_attr_val
.v
.val_float
.length
; ++i
)
6304 dw2_asm_output_data (4, a
->dw_attr_val
.v
.val_float
.array
[i
],
6305 "fp constant word %u", i
);
6309 case dw_val_class_flag
:
6310 dw2_asm_output_data (1, AT_flag (a
), "%s", name
);
6313 case dw_val_class_loc_list
:
6315 char *sym
= AT_loc_list (a
)->ll_symbol
;
6318 dw2_asm_output_delta (DWARF_OFFSET_SIZE
, sym
,
6319 loc_section_label
, "%s", name
);
6323 case dw_val_class_die_ref
:
6324 if (AT_ref_external (a
))
6326 char *sym
= AT_ref (a
)->die_symbol
;
6329 dw2_asm_output_offset (DWARF2_ADDR_SIZE
, sym
, "%s", name
);
6331 else if (AT_ref (a
)->die_offset
== 0)
6334 dw2_asm_output_data (DWARF_OFFSET_SIZE
, AT_ref (a
)->die_offset
,
6338 case dw_val_class_fde_ref
:
6341 ASM_GENERATE_INTERNAL_LABEL (l1
, FDE_LABEL
,
6342 a
->dw_attr_val
.v
.val_fde_index
* 2);
6343 dw2_asm_output_offset (DWARF_OFFSET_SIZE
, l1
, "%s", name
);
6347 case dw_val_class_lbl_id
:
6348 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, AT_lbl (a
), "%s", name
);
6351 case dw_val_class_lbl_offset
:
6352 dw2_asm_output_offset (DWARF_OFFSET_SIZE
, AT_lbl (a
), "%s", name
);
6355 case dw_val_class_str
:
6356 if (AT_string_form (a
) == DW_FORM_strp
)
6357 dw2_asm_output_offset (DWARF_OFFSET_SIZE
,
6358 a
->dw_attr_val
.v
.val_str
->label
,
6359 "%s: \"%s\"", name
, AT_string (a
));
6361 dw2_asm_output_nstring (AT_string (a
), -1, "%s", name
);
6369 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
6372 if (die
->die_child
!= NULL
)
6374 /* Add null byte to terminate sibling list. */
6375 dw2_asm_output_data (1, 0, "end of children of DIE 0x%lx",
6380 /* Output the compilation unit that appears at the beginning of the
6381 .debug_info section, and precedes the DIE descriptions. */
6384 output_compilation_unit_header ()
6386 dw2_asm_output_data (DWARF_OFFSET_SIZE
, next_die_offset
- DWARF_OFFSET_SIZE
,
6387 "Length of Compilation Unit Info");
6389 dw2_asm_output_data (2, DWARF_VERSION
, "DWARF version number");
6391 dw2_asm_output_offset (DWARF_OFFSET_SIZE
, abbrev_section_label
,
6392 "Offset Into Abbrev. Section");
6394 dw2_asm_output_data (1, DWARF2_ADDR_SIZE
, "Pointer Size (in bytes)");
6397 /* Output the compilation unit DIE and its children. */
6400 output_comp_unit (die
)
6403 const char *secname
;
6405 /* Even if there are no children of this DIE, we must output the
6406 information about the compilation unit. Otherwise, on an empty
6407 translation unit, we will generate a present, but empty,
6408 .debug_info section. IRIX 6.5 `nm' will then complain when
6411 Mark all the DIEs in this CU so we know which get local refs. */
6414 build_abbrev_table (die
);
6416 /* Initialize the beginning DIE offset - and calculate sizes/offsets. */
6417 next_die_offset
= DWARF_COMPILE_UNIT_HEADER_SIZE
;
6418 calc_die_sizes (die
);
6420 if (die
->die_symbol
)
6422 char *tmp
= (char *) alloca (strlen (die
->die_symbol
) + 24);
6423 sprintf (tmp
, ".gnu.linkonce.wi.%s", die
->die_symbol
);
6425 die
->die_symbol
= NULL
;
6428 secname
= (const char *) DEBUG_INFO_SECTION
;
6430 /* Output debugging information. */
6431 named_section_flags (secname
, SECTION_DEBUG
);
6432 output_compilation_unit_header ();
6435 /* Leave the marks on the main CU, so we can check them in
6437 if (die
->die_symbol
)
6441 /* The DWARF2 pubname for a nested thingy looks like "A::f". The output
6442 of decl_printable_name for C++ looks like "A::f(int)". Let's drop the
6443 argument list, and maybe the scope. */
6446 dwarf2_name (decl
, scope
)
6450 return (*decl_printable_name
) (decl
, scope
? 1 : 0);
6453 /* Add a new entry to .debug_pubnames if appropriate. */
6456 add_pubname (decl
, die
)
6462 if (! TREE_PUBLIC (decl
))
6465 if (pubname_table_in_use
== pubname_table_allocated
)
6467 pubname_table_allocated
+= PUBNAME_TABLE_INCREMENT
;
6468 pubname_table
= (pubname_ref
) xrealloc
6469 (pubname_table
, pubname_table_allocated
* sizeof (pubname_entry
));
6472 p
= &pubname_table
[pubname_table_in_use
++];
6475 p
->name
= xstrdup (dwarf2_name (decl
, 1));
6478 /* Output the public names table used to speed up access to externally
6479 visible names. For now, only generate entries for externally
6480 visible procedures. */
6486 unsigned long pubnames_length
= size_of_pubnames ();
6488 dw2_asm_output_data (DWARF_OFFSET_SIZE
, pubnames_length
,
6489 "Length of Public Names Info");
6491 dw2_asm_output_data (2, DWARF_VERSION
, "DWARF Version");
6493 dw2_asm_output_offset (DWARF_OFFSET_SIZE
, debug_info_section_label
,
6494 "Offset of Compilation Unit Info");
6496 dw2_asm_output_data (DWARF_OFFSET_SIZE
, next_die_offset
,
6497 "Compilation Unit Length");
6499 for (i
= 0; i
< pubname_table_in_use
; ++i
)
6501 pubname_ref pub
= &pubname_table
[i
];
6503 /* We shouldn't see pubnames for DIEs outside of the main CU. */
6504 if (pub
->die
->die_mark
== 0)
6507 dw2_asm_output_data (DWARF_OFFSET_SIZE
, pub
->die
->die_offset
,
6510 dw2_asm_output_nstring (pub
->name
, -1, "external name");
6513 dw2_asm_output_data (DWARF_OFFSET_SIZE
, 0, NULL
);
6516 /* Add a new entry to .debug_aranges if appropriate. */
6519 add_arange (decl
, die
)
6523 if (! DECL_SECTION_NAME (decl
))
6526 if (arange_table_in_use
== arange_table_allocated
)
6528 arange_table_allocated
+= ARANGE_TABLE_INCREMENT
;
6529 arange_table
= (dw_die_ref
*)
6530 xrealloc (arange_table
, arange_table_allocated
* sizeof (dw_die_ref
));
6533 arange_table
[arange_table_in_use
++] = die
;
6536 /* Output the information that goes into the .debug_aranges table.
6537 Namely, define the beginning and ending address range of the
6538 text section generated for this compilation unit. */
6544 unsigned long aranges_length
= size_of_aranges ();
6546 dw2_asm_output_data (DWARF_OFFSET_SIZE
, aranges_length
,
6547 "Length of Address Ranges Info");
6549 dw2_asm_output_data (2, DWARF_VERSION
, "DWARF Version");
6551 dw2_asm_output_offset (DWARF_OFFSET_SIZE
, debug_info_section_label
,
6552 "Offset of Compilation Unit Info");
6554 dw2_asm_output_data (1, DWARF2_ADDR_SIZE
, "Size of Address");
6556 dw2_asm_output_data (1, 0, "Size of Segment Descriptor");
6558 /* We need to align to twice the pointer size here. */
6559 if (DWARF_ARANGES_PAD_SIZE
)
6561 /* Pad using a 2 byte words so that padding is correct for any
6563 dw2_asm_output_data (2, 0, "Pad to %d byte boundary",
6564 2 * DWARF2_ADDR_SIZE
);
6565 for (i
= 2; i
< (unsigned) DWARF_ARANGES_PAD_SIZE
; i
+= 2)
6566 dw2_asm_output_data (2, 0, NULL
);
6569 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, text_section_label
, "Address");
6570 dw2_asm_output_delta (DWARF2_ADDR_SIZE
, text_end_label
,
6571 text_section_label
, "Length");
6573 for (i
= 0; i
< arange_table_in_use
; ++i
)
6575 dw_die_ref die
= arange_table
[i
];
6577 /* We shouldn't see aranges for DIEs outside of the main CU. */
6578 if (die
->die_mark
== 0)
6581 if (die
->die_tag
== DW_TAG_subprogram
)
6583 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, get_AT_low_pc (die
),
6585 dw2_asm_output_delta (DWARF2_ADDR_SIZE
, get_AT_hi_pc (die
),
6586 get_AT_low_pc (die
), "Length");
6590 /* A static variable; extract the symbol from DW_AT_location.
6591 Note that this code isn't currently hit, as we only emit
6592 aranges for functions (jason 9/23/99). */
6594 dw_attr_ref a
= get_AT (die
, DW_AT_location
);
6595 dw_loc_descr_ref loc
;
6596 if (! a
|| AT_class (a
) != dw_val_class_loc
)
6600 if (loc
->dw_loc_opc
!= DW_OP_addr
)
6603 dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE
,
6604 loc
->dw_loc_oprnd1
.v
.val_addr
, "Address");
6605 dw2_asm_output_data (DWARF2_ADDR_SIZE
,
6606 get_AT_unsigned (die
, DW_AT_byte_size
),
6611 /* Output the terminator words. */
6612 dw2_asm_output_data (DWARF2_ADDR_SIZE
, 0, NULL
);
6613 dw2_asm_output_data (DWARF2_ADDR_SIZE
, 0, NULL
);
6616 /* Add a new entry to .debug_ranges. Return the offset at which it
6623 unsigned int in_use
= ranges_table_in_use
;
6625 if (in_use
== ranges_table_allocated
)
6627 ranges_table_allocated
+= RANGES_TABLE_INCREMENT
;
6628 ranges_table
= (dw_ranges_ref
)
6629 xrealloc (ranges_table
, (ranges_table_allocated
6630 * sizeof (struct dw_ranges_struct
)));
6633 ranges_table
[in_use
].block_num
= (block
? BLOCK_NUMBER (block
) : 0);
6634 ranges_table_in_use
= in_use
+ 1;
6636 return in_use
* 2 * DWARF2_ADDR_SIZE
;
6643 static const char *const start_fmt
= "Offset 0x%x";
6644 const char *fmt
= start_fmt
;
6646 for (i
= 0; i
< ranges_table_in_use
; ++i
)
6648 int block_num
= ranges_table
[i
].block_num
;
6652 char blabel
[MAX_ARTIFICIAL_LABEL_BYTES
];
6653 char elabel
[MAX_ARTIFICIAL_LABEL_BYTES
];
6655 ASM_GENERATE_INTERNAL_LABEL (blabel
, BLOCK_BEGIN_LABEL
, block_num
);
6656 ASM_GENERATE_INTERNAL_LABEL (elabel
, BLOCK_END_LABEL
, block_num
);
6658 /* If all code is in the text section, then the compilation
6659 unit base address defaults to DW_AT_low_pc, which is the
6660 base of the text section. */
6661 if (separate_line_info_table_in_use
== 0)
6663 dw2_asm_output_delta (DWARF2_ADDR_SIZE
, blabel
,
6665 fmt
, i
* 2 * DWARF2_ADDR_SIZE
);
6666 dw2_asm_output_delta (DWARF2_ADDR_SIZE
, elabel
,
6667 text_section_label
, NULL
);
6669 /* Otherwise, we add a DW_AT_entry_pc attribute to force the
6670 compilation unit base address to zero, which allows us to
6671 use absolute addresses, and not worry about whether the
6672 target supports cross-section arithmetic. */
6675 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, blabel
,
6676 fmt
, i
* 2 * DWARF2_ADDR_SIZE
);
6677 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, elabel
, NULL
);
6684 dw2_asm_output_data (DWARF2_ADDR_SIZE
, 0, NULL
);
6685 dw2_asm_output_data (DWARF2_ADDR_SIZE
, 0, NULL
);
6691 /* Data structure containing information about input files. */
6694 char *path
; /* Complete file name. */
6695 char *fname
; /* File name part. */
6696 int length
; /* Length of entire string. */
6697 int file_idx
; /* Index in input file table. */
6698 int dir_idx
; /* Index in directory table. */
6701 /* Data structure containing information about directories with source
6705 char *path
; /* Path including directory name. */
6706 int length
; /* Path length. */
6707 int prefix
; /* Index of directory entry which is a prefix. */
6708 int count
; /* Number of files in this directory. */
6709 int dir_idx
; /* Index of directory used as base. */
6710 int used
; /* Used in the end? */
6713 /* Callback function for file_info comparison. We sort by looking at
6714 the directories in the path. */
6717 file_info_cmp (p1
, p2
)
6721 const struct file_info
*s1
= p1
;
6722 const struct file_info
*s2
= p2
;
6726 /* Take care of file names without directories. We need to make sure that
6727 we return consistent values to qsort since some will get confused if
6728 we return the same value when identical operands are passed in opposite
6729 orders. So if neither has a directory, return 0 and otherwise return
6730 1 or -1 depending on which one has the directory. */
6731 if ((s1
->path
== s1
->fname
|| s2
->path
== s2
->fname
))
6732 return (s2
->path
== s2
->fname
) - (s1
->path
== s1
->fname
);
6734 cp1
= (unsigned char *) s1
->path
;
6735 cp2
= (unsigned char *) s2
->path
;
6741 /* Reached the end of the first path? If so, handle like above. */
6742 if ((cp1
== (unsigned char *) s1
->fname
)
6743 || (cp2
== (unsigned char *) s2
->fname
))
6744 return ((cp2
== (unsigned char *) s2
->fname
)
6745 - (cp1
== (unsigned char *) s1
->fname
));
6747 /* Character of current path component the same? */
6748 else if (*cp1
!= *cp2
)
6753 /* Output the directory table and the file name table. We try to minimize
6754 the total amount of memory needed. A heuristic is used to avoid large
6755 slowdowns with many input files. */
6757 output_file_names ()
6759 struct file_info
*files
;
6760 struct dir_info
*dirs
;
6769 /* Allocate the various arrays we need. */
6770 files
= (struct file_info
*) alloca (file_table
.in_use
6771 * sizeof (struct file_info
));
6772 dirs
= (struct dir_info
*) alloca (file_table
.in_use
6773 * sizeof (struct dir_info
));
6775 /* Sort the file names. */
6776 for (i
= 1; i
< (int) file_table
.in_use
; ++i
)
6780 /* Skip all leading "./". */
6781 f
= file_table
.table
[i
];
6782 while (f
[0] == '.' && f
[1] == '/')
6785 /* Create a new array entry. */
6787 files
[i
].length
= strlen (f
);
6788 files
[i
].file_idx
= i
;
6790 /* Search for the file name part. */
6791 f
= strrchr (f
, '/');
6792 files
[i
].fname
= f
== NULL
? files
[i
].path
: f
+ 1;
6794 qsort (files
+ 1, file_table
.in_use
- 1, sizeof (files
[0]), file_info_cmp
);
6796 /* Find all the different directories used. */
6797 dirs
[0].path
= files
[1].path
;
6798 dirs
[0].length
= files
[1].fname
- files
[1].path
;
6799 dirs
[0].prefix
= -1;
6801 dirs
[0].dir_idx
= 0;
6803 files
[1].dir_idx
= 0;
6806 for (i
= 2; i
< (int) file_table
.in_use
; ++i
)
6807 if (files
[i
].fname
- files
[i
].path
== dirs
[ndirs
- 1].length
6808 && memcmp (dirs
[ndirs
- 1].path
, files
[i
].path
,
6809 dirs
[ndirs
- 1].length
) == 0)
6811 /* Same directory as last entry. */
6812 files
[i
].dir_idx
= ndirs
- 1;
6813 ++dirs
[ndirs
- 1].count
;
6819 /* This is a new directory. */
6820 dirs
[ndirs
].path
= files
[i
].path
;
6821 dirs
[ndirs
].length
= files
[i
].fname
- files
[i
].path
;
6822 dirs
[ndirs
].count
= 1;
6823 dirs
[ndirs
].dir_idx
= ndirs
;
6824 dirs
[ndirs
].used
= 0;
6825 files
[i
].dir_idx
= ndirs
;
6827 /* Search for a prefix. */
6828 dirs
[ndirs
].prefix
= -1;
6829 for (j
= 0; j
< ndirs
; ++j
)
6830 if (dirs
[j
].length
< dirs
[ndirs
].length
6831 && dirs
[j
].length
> 1
6832 && (dirs
[ndirs
].prefix
== -1
6833 || dirs
[j
].length
> dirs
[dirs
[ndirs
].prefix
].length
)
6834 && memcmp (dirs
[j
].path
, dirs
[ndirs
].path
, dirs
[j
].length
) == 0)
6835 dirs
[ndirs
].prefix
= j
;
6840 /* Now to the actual work. We have to find a subset of the
6841 directories which allow expressing the file name using references
6842 to the directory table with the least amount of characters. We
6843 do not do an exhaustive search where we would have to check out
6844 every combination of every single possible prefix. Instead we
6845 use a heuristic which provides nearly optimal results in most
6846 cases and never is much off. */
6847 saved
= (int *) alloca (ndirs
* sizeof (int));
6848 savehere
= (int *) alloca (ndirs
* sizeof (int));
6850 memset (saved
, '\0', ndirs
* sizeof (saved
[0]));
6851 for (i
= 0; i
< ndirs
; ++i
)
6856 /* We can always save some space for the current directory. But
6857 this does not mean it will be enough to justify adding the
6859 savehere
[i
] = dirs
[i
].length
;
6860 total
= (savehere
[i
] - saved
[i
]) * dirs
[i
].count
;
6862 for (j
= i
+ 1; j
< ndirs
; ++j
)
6866 if (saved
[j
] < dirs
[i
].length
)
6868 /* Determine whether the dirs[i] path is a prefix of the
6873 while (k
!= -1 && k
!= i
)
6878 /* Yes it is. We can possibly safe some memory but
6879 writing the filenames in dirs[j] relative to
6881 savehere
[j
] = dirs
[i
].length
;
6882 total
+= (savehere
[j
] - saved
[j
]) * dirs
[j
].count
;
6887 /* Check whether we can safe enough to justify adding the dirs[i]
6889 if (total
> dirs
[i
].length
+ 1)
6891 /* It's worthwhile adding. */
6892 for (j
= i
; j
< ndirs
; ++j
)
6893 if (savehere
[j
] > 0)
6895 /* Remember how much we saved for this directory so far. */
6896 saved
[j
] = savehere
[j
];
6898 /* Remember the prefix directory. */
6899 dirs
[j
].dir_idx
= i
;
6904 /* We have to emit them in the order they appear in the file_table
6905 array since the index is used in the debug info generation. To
6906 do this efficiently we generate a back-mapping of the indices
6908 backmap
= (int *) alloca (file_table
.in_use
* sizeof (int));
6909 for (i
= 1; i
< (int) file_table
.in_use
; ++i
)
6911 backmap
[files
[i
].file_idx
] = i
;
6912 /* Mark this directory as used. */
6913 dirs
[dirs
[files
[i
].dir_idx
].dir_idx
].used
= 1;
6916 /* That was it. We are ready to emit the information. First the
6917 directory name table. Here we have to make sure that the first
6918 actually emitted directory name has the index one. Zero is
6919 reserved for the current working directory. Make sure we do not
6920 confuse these indices with the one for the constructed table
6921 (even though most of the time they are identical). */
6923 idx_offset
= dirs
[0].length
> 0 ? 1 : 0;
6924 for (i
= 1 - idx_offset
; i
< ndirs
; ++i
)
6925 if (dirs
[i
].used
!= 0)
6927 dirs
[i
].used
= idx
++;
6928 dw2_asm_output_nstring (dirs
[i
].path
, dirs
[i
].length
- 1,
6929 "Directory Entry: 0x%x", dirs
[i
].used
);
6931 dw2_asm_output_data (1, 0, "End directory table");
6933 /* Correct the index for the current working directory entry if it
6935 if (idx_offset
== 0)
6938 /* Now write all the file names. */
6939 for (i
= 1; i
< (int) file_table
.in_use
; ++i
)
6941 int file_idx
= backmap
[i
];
6942 int dir_idx
= dirs
[files
[file_idx
].dir_idx
].dir_idx
;
6944 dw2_asm_output_nstring (files
[file_idx
].path
+ dirs
[dir_idx
].length
, -1,
6945 "File Entry: 0x%x", i
);
6947 /* Include directory index. */
6948 dw2_asm_output_data_uleb128 (dirs
[dir_idx
].used
, NULL
);
6950 /* Modification time. */
6951 dw2_asm_output_data_uleb128 (0, NULL
);
6953 /* File length in bytes. */
6954 dw2_asm_output_data_uleb128 (0, NULL
);
6956 dw2_asm_output_data (1, 0, "End file name table");
6960 /* Output the source line number correspondence information. This
6961 information goes into the .debug_line section. */
6966 char l1
[20], l2
[20], p1
[20], p2
[20];
6967 char line_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
6968 char prev_line_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
6971 unsigned long lt_index
;
6972 unsigned long current_line
;
6975 unsigned long current_file
;
6976 unsigned long function
;
6978 ASM_GENERATE_INTERNAL_LABEL (l1
, LINE_NUMBER_BEGIN_LABEL
, 0);
6979 ASM_GENERATE_INTERNAL_LABEL (l2
, LINE_NUMBER_END_LABEL
, 0);
6980 ASM_GENERATE_INTERNAL_LABEL (p1
, LN_PROLOG_AS_LABEL
, 0);
6981 ASM_GENERATE_INTERNAL_LABEL (p2
, LN_PROLOG_END_LABEL
, 0);
6983 dw2_asm_output_delta (DWARF_OFFSET_SIZE
, l2
, l1
,
6984 "Length of Source Line Info");
6985 ASM_OUTPUT_LABEL (asm_out_file
, l1
);
6987 dw2_asm_output_data (2, DWARF_VERSION
, "DWARF Version");
6989 dw2_asm_output_delta (DWARF_OFFSET_SIZE
, p2
, p1
, "Prolog Length");
6990 ASM_OUTPUT_LABEL (asm_out_file
, p1
);
6992 dw2_asm_output_data (1, DWARF_LINE_MIN_INSTR_LENGTH
,
6993 "Minimum Instruction Length");
6995 dw2_asm_output_data (1, DWARF_LINE_DEFAULT_IS_STMT_START
,
6996 "Default is_stmt_start flag");
6998 dw2_asm_output_data (1, DWARF_LINE_BASE
,
6999 "Line Base Value (Special Opcodes)");
7001 dw2_asm_output_data (1, DWARF_LINE_RANGE
,
7002 "Line Range Value (Special Opcodes)");
7004 dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE
,
7005 "Special Opcode Base");
7007 for (opc
= 1; opc
< DWARF_LINE_OPCODE_BASE
; ++opc
)
7011 case DW_LNS_advance_pc
:
7012 case DW_LNS_advance_line
:
7013 case DW_LNS_set_file
:
7014 case DW_LNS_set_column
:
7015 case DW_LNS_fixed_advance_pc
:
7023 dw2_asm_output_data (1, n_op_args
, "opcode: 0x%x has %d args",
7027 /* Write out the information about the files we use. */
7028 output_file_names ();
7029 ASM_OUTPUT_LABEL (asm_out_file
, p2
);
7031 /* We used to set the address register to the first location in the text
7032 section here, but that didn't accomplish anything since we already
7033 have a line note for the opening brace of the first function. */
7035 /* Generate the line number to PC correspondence table, encoded as
7036 a series of state machine operations. */
7039 strcpy (prev_line_label
, text_section_label
);
7040 for (lt_index
= 1; lt_index
< line_info_table_in_use
; ++lt_index
)
7042 dw_line_info_ref line_info
= &line_info_table
[lt_index
];
7045 /* Disable this optimization for now; GDB wants to see two line notes
7046 at the beginning of a function so it can find the end of the
7049 /* Don't emit anything for redundant notes. Just updating the
7050 address doesn't accomplish anything, because we already assume
7051 that anything after the last address is this line. */
7052 if (line_info
->dw_line_num
== current_line
7053 && line_info
->dw_file_num
== current_file
)
7057 /* Emit debug info for the address of the current line.
7059 Unfortunately, we have little choice here currently, and must always
7060 use the most general form. Gcc does not know the address delta
7061 itself, so we can't use DW_LNS_advance_pc. Many ports do have length
7062 attributes which will give an upper bound on the address range. We
7063 could perhaps use length attributes to determine when it is safe to
7064 use DW_LNS_fixed_advance_pc. */
7066 ASM_GENERATE_INTERNAL_LABEL (line_label
, LINE_CODE_LABEL
, lt_index
);
7069 /* This can handle deltas up to 0xffff. This takes 3 bytes. */
7070 dw2_asm_output_data (1, DW_LNS_fixed_advance_pc
,
7071 "DW_LNS_fixed_advance_pc");
7072 dw2_asm_output_delta (2, line_label
, prev_line_label
, NULL
);
7076 /* This can handle any delta. This takes
7077 4+DWARF2_ADDR_SIZE bytes. */
7078 dw2_asm_output_data (1, 0, "DW_LNE_set_address");
7079 dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE
, NULL
);
7080 dw2_asm_output_data (1, DW_LNE_set_address
, NULL
);
7081 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, line_label
, NULL
);
7083 strcpy (prev_line_label
, line_label
);
7085 /* Emit debug info for the source file of the current line, if
7086 different from the previous line. */
7087 if (line_info
->dw_file_num
!= current_file
)
7089 current_file
= line_info
->dw_file_num
;
7090 dw2_asm_output_data (1, DW_LNS_set_file
, "DW_LNS_set_file");
7091 dw2_asm_output_data_uleb128 (current_file
, "(\"%s\")",
7092 file_table
.table
[current_file
]);
7095 /* Emit debug info for the current line number, choosing the encoding
7096 that uses the least amount of space. */
7097 if (line_info
->dw_line_num
!= current_line
)
7099 line_offset
= line_info
->dw_line_num
- current_line
;
7100 line_delta
= line_offset
- DWARF_LINE_BASE
;
7101 current_line
= line_info
->dw_line_num
;
7102 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
7104 /* This can handle deltas from -10 to 234, using the current
7105 definitions of DWARF_LINE_BASE and DWARF_LINE_RANGE. This
7107 dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE
+ line_delta
,
7108 "line %lu", current_line
);
7112 /* This can handle any delta. This takes at least 4 bytes,
7113 depending on the value being encoded. */
7114 dw2_asm_output_data (1, DW_LNS_advance_line
,
7115 "advance to line %lu", current_line
);
7116 dw2_asm_output_data_sleb128 (line_offset
, NULL
);
7117 dw2_asm_output_data (1, DW_LNS_copy
, "DW_LNS_copy");
7122 /* We still need to start a new row, so output a copy insn. */
7123 dw2_asm_output_data (1, DW_LNS_copy
, "DW_LNS_copy");
7127 /* Emit debug info for the address of the end of the function. */
7130 dw2_asm_output_data (1, DW_LNS_fixed_advance_pc
,
7131 "DW_LNS_fixed_advance_pc");
7132 dw2_asm_output_delta (2, text_end_label
, prev_line_label
, NULL
);
7136 dw2_asm_output_data (1, 0, "DW_LNE_set_address");
7137 dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE
, NULL
);
7138 dw2_asm_output_data (1, DW_LNE_set_address
, NULL
);
7139 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, text_end_label
, NULL
);
7142 dw2_asm_output_data (1, 0, "DW_LNE_end_sequence");
7143 dw2_asm_output_data_uleb128 (1, NULL
);
7144 dw2_asm_output_data (1, DW_LNE_end_sequence
, NULL
);
7149 for (lt_index
= 0; lt_index
< separate_line_info_table_in_use
;)
7151 dw_separate_line_info_ref line_info
7152 = &separate_line_info_table
[lt_index
];
7155 /* Don't emit anything for redundant notes. */
7156 if (line_info
->dw_line_num
== current_line
7157 && line_info
->dw_file_num
== current_file
7158 && line_info
->function
== function
)
7162 /* Emit debug info for the address of the current line. If this is
7163 a new function, or the first line of a function, then we need
7164 to handle it differently. */
7165 ASM_GENERATE_INTERNAL_LABEL (line_label
, SEPARATE_LINE_CODE_LABEL
,
7167 if (function
!= line_info
->function
)
7169 function
= line_info
->function
;
7171 /* Set the address register to the first line in the function */
7172 dw2_asm_output_data (1, 0, "DW_LNE_set_address");
7173 dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE
, NULL
);
7174 dw2_asm_output_data (1, DW_LNE_set_address
, NULL
);
7175 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, line_label
, NULL
);
7179 /* ??? See the DW_LNS_advance_pc comment above. */
7182 dw2_asm_output_data (1, DW_LNS_fixed_advance_pc
,
7183 "DW_LNS_fixed_advance_pc");
7184 dw2_asm_output_delta (2, line_label
, prev_line_label
, NULL
);
7188 dw2_asm_output_data (1, 0, "DW_LNE_set_address");
7189 dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE
, NULL
);
7190 dw2_asm_output_data (1, DW_LNE_set_address
, NULL
);
7191 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, line_label
, NULL
);
7194 strcpy (prev_line_label
, line_label
);
7196 /* Emit debug info for the source file of the current line, if
7197 different from the previous line. */
7198 if (line_info
->dw_file_num
!= current_file
)
7200 current_file
= line_info
->dw_file_num
;
7201 dw2_asm_output_data (1, DW_LNS_set_file
, "DW_LNS_set_file");
7202 dw2_asm_output_data_uleb128 (current_file
, "(\"%s\")",
7203 file_table
.table
[current_file
]);
7206 /* Emit debug info for the current line number, choosing the encoding
7207 that uses the least amount of space. */
7208 if (line_info
->dw_line_num
!= current_line
)
7210 line_offset
= line_info
->dw_line_num
- current_line
;
7211 line_delta
= line_offset
- DWARF_LINE_BASE
;
7212 current_line
= line_info
->dw_line_num
;
7213 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
7214 dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE
+ line_delta
,
7215 "line %lu", current_line
);
7218 dw2_asm_output_data (1, DW_LNS_advance_line
,
7219 "advance to line %lu", current_line
);
7220 dw2_asm_output_data_sleb128 (line_offset
, NULL
);
7221 dw2_asm_output_data (1, DW_LNS_copy
, "DW_LNS_copy");
7225 dw2_asm_output_data (1, DW_LNS_copy
, "DW_LNS_copy");
7232 /* If we're done with a function, end its sequence. */
7233 if (lt_index
== separate_line_info_table_in_use
7234 || separate_line_info_table
[lt_index
].function
!= function
)
7239 /* Emit debug info for the address of the end of the function. */
7240 ASM_GENERATE_INTERNAL_LABEL (line_label
, FUNC_END_LABEL
, function
);
7243 dw2_asm_output_data (1, DW_LNS_fixed_advance_pc
,
7244 "DW_LNS_fixed_advance_pc");
7245 dw2_asm_output_delta (2, line_label
, prev_line_label
, NULL
);
7249 dw2_asm_output_data (1, 0, "DW_LNE_set_address");
7250 dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE
, NULL
);
7251 dw2_asm_output_data (1, DW_LNE_set_address
, NULL
);
7252 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, line_label
, NULL
);
7255 /* Output the marker for the end of this sequence. */
7256 dw2_asm_output_data (1, 0, "DW_LNE_end_sequence");
7257 dw2_asm_output_data_uleb128 (1, NULL
);
7258 dw2_asm_output_data (1, DW_LNE_end_sequence
, NULL
);
7262 /* Output the marker for the end of the line number info. */
7263 ASM_OUTPUT_LABEL (asm_out_file
, l2
);
7266 /* Given a pointer to a tree node for some base type, return a pointer to
7267 a DIE that describes the given type.
7269 This routine must only be called for GCC type nodes that correspond to
7270 Dwarf base (fundamental) types. */
7273 base_type_die (type
)
7276 dw_die_ref base_type_result
;
7277 const char *type_name
;
7278 enum dwarf_type encoding
;
7279 tree name
= TYPE_NAME (type
);
7281 if (TREE_CODE (type
) == ERROR_MARK
7282 || TREE_CODE (type
) == VOID_TYPE
)
7287 if (TREE_CODE (name
) == TYPE_DECL
)
7288 name
= DECL_NAME (name
);
7290 type_name
= IDENTIFIER_POINTER (name
);
7293 type_name
= "__unknown__";
7295 switch (TREE_CODE (type
))
7298 /* Carefully distinguish the C character types, without messing
7299 up if the language is not C. Note that we check only for the names
7300 that contain spaces; other names might occur by coincidence in other
7302 if (! (TYPE_PRECISION (type
) == CHAR_TYPE_SIZE
7303 && (type
== char_type_node
7304 || ! strcmp (type_name
, "signed char")
7305 || ! strcmp (type_name
, "unsigned char"))))
7307 if (TREE_UNSIGNED (type
))
7308 encoding
= DW_ATE_unsigned
;
7310 encoding
= DW_ATE_signed
;
7313 /* else fall through. */
7316 /* GNU Pascal/Ada CHAR type. Not used in C. */
7317 if (TREE_UNSIGNED (type
))
7318 encoding
= DW_ATE_unsigned_char
;
7320 encoding
= DW_ATE_signed_char
;
7324 encoding
= DW_ATE_float
;
7327 /* Dwarf2 doesn't know anything about complex ints, so use
7328 a user defined type for it. */
7330 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
7331 encoding
= DW_ATE_complex_float
;
7333 encoding
= DW_ATE_lo_user
;
7337 /* GNU FORTRAN/Ada/C++ BOOLEAN type. */
7338 encoding
= DW_ATE_boolean
;
7342 abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
7345 base_type_result
= new_die (DW_TAG_base_type
, comp_unit_die
);
7346 if (demangle_name_func
)
7347 type_name
= (*demangle_name_func
) (type_name
);
7349 add_AT_string (base_type_result
, DW_AT_name
, type_name
);
7350 add_AT_unsigned (base_type_result
, DW_AT_byte_size
,
7351 int_size_in_bytes (type
));
7352 add_AT_unsigned (base_type_result
, DW_AT_encoding
, encoding
);
7354 return base_type_result
;
7357 /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
7358 the Dwarf "root" type for the given input type. The Dwarf "root" type of
7359 a given type is generally the same as the given type, except that if the
7360 given type is a pointer or reference type, then the root type of the given
7361 type is the root type of the "basis" type for the pointer or reference
7362 type. (This definition of the "root" type is recursive.) Also, the root
7363 type of a `const' qualified type or a `volatile' qualified type is the
7364 root type of the given type without the qualifiers. */
7370 if (TREE_CODE (type
) == ERROR_MARK
)
7371 return error_mark_node
;
7373 switch (TREE_CODE (type
))
7376 return error_mark_node
;
7379 case REFERENCE_TYPE
:
7380 return type_main_variant (root_type (TREE_TYPE (type
)));
7383 return type_main_variant (type
);
7387 /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
7388 given input type is a Dwarf "fundamental" type. Otherwise return null. */
7394 switch (TREE_CODE (type
))
7409 case QUAL_UNION_TYPE
:
7414 case REFERENCE_TYPE
:
7428 /* Given a pointer to an arbitrary ..._TYPE tree node, return a debugging
7429 entry that chains various modifiers in front of the given type. */
7432 modified_type_die (type
, is_const_type
, is_volatile_type
, context_die
)
7435 int is_volatile_type
;
7436 dw_die_ref context_die
;
7438 enum tree_code code
= TREE_CODE (type
);
7439 dw_die_ref mod_type_die
= NULL
;
7440 dw_die_ref sub_die
= NULL
;
7441 tree item_type
= NULL
;
7443 if (code
!= ERROR_MARK
)
7445 tree qualified_type
;
7447 /* See if we already have the appropriately qualified variant of
7450 = get_qualified_type (type
,
7451 ((is_const_type
? TYPE_QUAL_CONST
: 0)
7453 ? TYPE_QUAL_VOLATILE
: 0)));
7454 /* If we do, then we can just use its DIE, if it exists. */
7457 mod_type_die
= lookup_type_die (qualified_type
);
7459 return mod_type_die
;
7462 /* Handle C typedef types. */
7463 if (qualified_type
&& TYPE_NAME (qualified_type
)
7464 && TREE_CODE (TYPE_NAME (qualified_type
)) == TYPE_DECL
7465 && DECL_ORIGINAL_TYPE (TYPE_NAME (qualified_type
)))
7467 tree type_name
= TYPE_NAME (qualified_type
);
7468 tree dtype
= TREE_TYPE (type_name
);
7469 if (qualified_type
== dtype
)
7471 /* For a named type, use the typedef. */
7472 gen_type_die (qualified_type
, context_die
);
7473 mod_type_die
= lookup_type_die (qualified_type
);
7476 else if (is_const_type
< TYPE_READONLY (dtype
)
7477 || is_volatile_type
< TYPE_VOLATILE (dtype
))
7478 /* cv-unqualified version of named type. Just use the unnamed
7479 type to which it refers. */
7481 = modified_type_die (DECL_ORIGINAL_TYPE (type_name
),
7482 is_const_type
, is_volatile_type
,
7484 /* Else cv-qualified version of named type; fall through. */
7490 else if (is_const_type
)
7492 mod_type_die
= new_die (DW_TAG_const_type
, comp_unit_die
);
7493 sub_die
= modified_type_die (type
, 0, is_volatile_type
, context_die
);
7495 else if (is_volatile_type
)
7497 mod_type_die
= new_die (DW_TAG_volatile_type
, comp_unit_die
);
7498 sub_die
= modified_type_die (type
, 0, 0, context_die
);
7500 else if (code
== POINTER_TYPE
)
7502 mod_type_die
= new_die (DW_TAG_pointer_type
, comp_unit_die
);
7503 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
7505 add_AT_unsigned (mod_type_die
, DW_AT_address_class
, 0);
7507 item_type
= TREE_TYPE (type
);
7509 else if (code
== REFERENCE_TYPE
)
7511 mod_type_die
= new_die (DW_TAG_reference_type
, comp_unit_die
);
7512 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
7514 add_AT_unsigned (mod_type_die
, DW_AT_address_class
, 0);
7516 item_type
= TREE_TYPE (type
);
7518 else if (is_base_type (type
))
7519 mod_type_die
= base_type_die (type
);
7522 gen_type_die (type
, context_die
);
7524 /* We have to get the type_main_variant here (and pass that to the
7525 `lookup_type_die' routine) because the ..._TYPE node we have
7526 might simply be a *copy* of some original type node (where the
7527 copy was created to help us keep track of typedef names) and
7528 that copy might have a different TYPE_UID from the original
7530 mod_type_die
= lookup_type_die (type_main_variant (type
));
7531 if (mod_type_die
== NULL
)
7535 /* We want to equate the qualified type to the die below. */
7537 type
= qualified_type
;
7540 equate_type_number_to_die (type
, mod_type_die
);
7542 /* We must do this after the equate_type_number_to_die call, in case
7543 this is a recursive type. This ensures that the modified_type_die
7544 recursion will terminate even if the type is recursive. Recursive
7545 types are possible in Ada. */
7546 sub_die
= modified_type_die (item_type
,
7547 TYPE_READONLY (item_type
),
7548 TYPE_VOLATILE (item_type
),
7551 if (sub_die
!= NULL
)
7552 add_AT_die_ref (mod_type_die
, DW_AT_type
, sub_die
);
7554 return mod_type_die
;
7557 /* Given a pointer to an arbitrary ..._TYPE tree node, return true if it is
7558 an enumerated type. */
7564 return TREE_CODE (type
) == ENUMERAL_TYPE
;
7567 /* Return the register number described by a given RTL node. */
7573 unsigned regno
= REGNO (rtl
);
7575 if (regno
>= FIRST_PSEUDO_REGISTER
)
7578 return DBX_REGISTER_NUMBER (regno
);
7581 /* Return a location descriptor that designates a machine register or
7582 zero if there is no such. */
7584 static dw_loc_descr_ref
7585 reg_loc_descriptor (rtl
)
7588 dw_loc_descr_ref loc_result
= NULL
;
7591 if (REGNO (rtl
) >= FIRST_PSEUDO_REGISTER
)
7594 reg
= reg_number (rtl
);
7596 loc_result
= new_loc_descr (DW_OP_reg0
+ reg
, 0, 0);
7598 loc_result
= new_loc_descr (DW_OP_regx
, reg
, 0);
7603 /* Return a location descriptor that designates a constant. */
7605 static dw_loc_descr_ref
7606 int_loc_descriptor (i
)
7609 enum dwarf_location_atom op
;
7611 /* Pick the smallest representation of a constant, rather than just
7612 defaulting to the LEB encoding. */
7616 op
= DW_OP_lit0
+ i
;
7619 else if (i
<= 0xffff)
7621 else if (HOST_BITS_PER_WIDE_INT
== 32
7631 else if (i
>= -0x8000)
7633 else if (HOST_BITS_PER_WIDE_INT
== 32
7634 || i
>= -0x80000000)
7640 return new_loc_descr (op
, i
, 0);
7643 /* Return a location descriptor that designates a base+offset location. */
7645 static dw_loc_descr_ref
7646 based_loc_descr (reg
, offset
)
7650 dw_loc_descr_ref loc_result
;
7651 /* For the "frame base", we use the frame pointer or stack pointer
7652 registers, since the RTL for local variables is relative to one of
7654 unsigned fp_reg
= DBX_REGISTER_NUMBER (frame_pointer_needed
7655 ? HARD_FRAME_POINTER_REGNUM
7656 : STACK_POINTER_REGNUM
);
7659 loc_result
= new_loc_descr (DW_OP_fbreg
, offset
, 0);
7661 loc_result
= new_loc_descr (DW_OP_breg0
+ reg
, offset
, 0);
7663 loc_result
= new_loc_descr (DW_OP_bregx
, reg
, offset
);
7668 /* Return true if this RTL expression describes a base+offset calculation. */
7674 return (GET_CODE (rtl
) == PLUS
7675 && ((GET_CODE (XEXP (rtl
, 0)) == REG
7676 && REGNO (XEXP (rtl
, 0)) < FIRST_PSEUDO_REGISTER
7677 && GET_CODE (XEXP (rtl
, 1)) == CONST_INT
)));
7680 /* The following routine converts the RTL for a variable or parameter
7681 (resident in memory) into an equivalent Dwarf representation of a
7682 mechanism for getting the address of that same variable onto the top of a
7683 hypothetical "address evaluation" stack.
7685 When creating memory location descriptors, we are effectively transforming
7686 the RTL for a memory-resident object into its Dwarf postfix expression
7687 equivalent. This routine recursively descends an RTL tree, turning
7688 it into Dwarf postfix code as it goes.
7690 MODE is the mode of the memory reference, needed to handle some
7691 autoincrement addressing modes.
7693 Return 0 if we can't represent the location. */
7695 static dw_loc_descr_ref
7696 mem_loc_descriptor (rtl
, mode
)
7698 enum machine_mode mode
;
7700 dw_loc_descr_ref mem_loc_result
= NULL
;
7702 /* Note that for a dynamically sized array, the location we will generate a
7703 description of here will be the lowest numbered location which is
7704 actually within the array. That's *not* necessarily the same as the
7705 zeroth element of the array. */
7707 #ifdef ASM_SIMPLIFY_DWARF_ADDR
7708 rtl
= ASM_SIMPLIFY_DWARF_ADDR (rtl
);
7711 switch (GET_CODE (rtl
))
7716 /* POST_INC and POST_DEC can be handled just like a SUBREG. So we
7717 just fall into the SUBREG code. */
7722 /* The case of a subreg may arise when we have a local (register)
7723 variable or a formal (register) parameter which doesn't quite fill
7724 up an entire register. For now, just assume that it is
7725 legitimate to make the Dwarf info refer to the whole register which
7726 contains the given subreg. */
7727 rtl
= SUBREG_REG (rtl
);
7732 /* Whenever a register number forms a part of the description of the
7733 method for calculating the (dynamic) address of a memory resident
7734 object, DWARF rules require the register number be referred to as
7735 a "base register". This distinction is not based in any way upon
7736 what category of register the hardware believes the given register
7737 belongs to. This is strictly DWARF terminology we're dealing with
7738 here. Note that in cases where the location of a memory-resident
7739 data object could be expressed as: OP_ADD (OP_BASEREG (basereg),
7740 OP_CONST (0)) the actual DWARF location descriptor that we generate
7741 may just be OP_BASEREG (basereg). This may look deceptively like
7742 the object in question was allocated to a register (rather than in
7743 memory) so DWARF consumers need to be aware of the subtle
7744 distinction between OP_REG and OP_BASEREG. */
7745 if (REGNO (rtl
) < FIRST_PSEUDO_REGISTER
)
7746 mem_loc_result
= based_loc_descr (reg_number (rtl
), 0);
7750 mem_loc_result
= mem_loc_descriptor (XEXP (rtl
, 0), GET_MODE (rtl
));
7751 if (mem_loc_result
!= 0)
7752 add_loc_descr (&mem_loc_result
, new_loc_descr (DW_OP_deref
, 0, 0));
7756 /* Some ports can transform a symbol ref into a label ref, because
7757 the symbol ref is too far away and has to be dumped into a constant
7761 /* Alternatively, the symbol in the constant pool might be referenced
7762 by a different symbol. */
7763 if (GET_CODE (rtl
) == SYMBOL_REF
7764 && CONSTANT_POOL_ADDRESS_P (rtl
))
7766 rtx tmp
= get_pool_constant (rtl
);
7767 if (GET_CODE (tmp
) == SYMBOL_REF
)
7771 mem_loc_result
= new_loc_descr (DW_OP_addr
, 0, 0);
7772 mem_loc_result
->dw_loc_oprnd1
.val_class
= dw_val_class_addr
;
7773 mem_loc_result
->dw_loc_oprnd1
.v
.val_addr
= save_rtx (rtl
);
7777 /* Extract the PLUS expression nested inside and fall into
7779 rtl
= XEXP (rtl
, 1);
7784 /* Turn these into a PLUS expression and fall into the PLUS code
7786 rtl
= gen_rtx_PLUS (word_mode
, XEXP (rtl
, 0),
7787 GEN_INT (GET_CODE (rtl
) == PRE_INC
7788 ? GET_MODE_UNIT_SIZE (mode
)
7789 : -GET_MODE_UNIT_SIZE (mode
)));
7795 if (is_based_loc (rtl
))
7796 mem_loc_result
= based_loc_descr (reg_number (XEXP (rtl
, 0)),
7797 INTVAL (XEXP (rtl
, 1)));
7800 mem_loc_result
= mem_loc_descriptor (XEXP (rtl
, 0), mode
);
7801 if (mem_loc_result
== 0)
7804 if (GET_CODE (XEXP (rtl
, 1)) == CONST_INT
7805 && INTVAL (XEXP (rtl
, 1)) >= 0)
7806 add_loc_descr (&mem_loc_result
,
7807 new_loc_descr (DW_OP_plus_uconst
,
7808 INTVAL (XEXP (rtl
, 1)), 0));
7811 add_loc_descr (&mem_loc_result
,
7812 mem_loc_descriptor (XEXP (rtl
, 1), mode
));
7813 add_loc_descr (&mem_loc_result
,
7814 new_loc_descr (DW_OP_plus
, 0, 0));
7821 /* If a pseudo-reg is optimized away, it is possible for it to
7822 be replaced with a MEM containing a multiply. */
7823 dw_loc_descr_ref op0
= mem_loc_descriptor (XEXP (rtl
, 0), mode
);
7824 dw_loc_descr_ref op1
= mem_loc_descriptor (XEXP (rtl
, 1), mode
);
7826 if (op0
== 0 || op1
== 0)
7829 mem_loc_result
= op0
;
7830 add_loc_descr (&mem_loc_result
, op1
);
7831 add_loc_descr (&mem_loc_result
, new_loc_descr (DW_OP_mul
, 0, 0));
7836 mem_loc_result
= int_loc_descriptor (INTVAL (rtl
));
7843 return mem_loc_result
;
7846 /* Return a descriptor that describes the concatenation of two locations.
7847 This is typically a complex variable. */
7849 static dw_loc_descr_ref
7850 concat_loc_descriptor (x0
, x1
)
7853 dw_loc_descr_ref cc_loc_result
= NULL
;
7854 dw_loc_descr_ref x0_ref
= loc_descriptor (x0
);
7855 dw_loc_descr_ref x1_ref
= loc_descriptor (x1
);
7857 if (x0_ref
== 0 || x1_ref
== 0)
7860 cc_loc_result
= x0_ref
;
7861 add_loc_descr (&cc_loc_result
,
7862 new_loc_descr (DW_OP_piece
,
7863 GET_MODE_SIZE (GET_MODE (x0
)), 0));
7865 add_loc_descr (&cc_loc_result
, x1_ref
);
7866 add_loc_descr (&cc_loc_result
,
7867 new_loc_descr (DW_OP_piece
,
7868 GET_MODE_SIZE (GET_MODE (x1
)), 0));
7870 return cc_loc_result
;
7873 /* Output a proper Dwarf location descriptor for a variable or parameter
7874 which is either allocated in a register or in a memory location. For a
7875 register, we just generate an OP_REG and the register number. For a
7876 memory location we provide a Dwarf postfix expression describing how to
7877 generate the (dynamic) address of the object onto the address stack.
7879 If we don't know how to describe it, return 0. */
7881 static dw_loc_descr_ref
7882 loc_descriptor (rtl
)
7885 dw_loc_descr_ref loc_result
= NULL
;
7887 switch (GET_CODE (rtl
))
7890 /* The case of a subreg may arise when we have a local (register)
7891 variable or a formal (register) parameter which doesn't quite fill
7892 up an entire register. For now, just assume that it is
7893 legitimate to make the Dwarf info refer to the whole register which
7894 contains the given subreg. */
7895 rtl
= SUBREG_REG (rtl
);
7900 loc_result
= reg_loc_descriptor (rtl
);
7904 loc_result
= mem_loc_descriptor (XEXP (rtl
, 0), GET_MODE (rtl
));
7908 loc_result
= concat_loc_descriptor (XEXP (rtl
, 0), XEXP (rtl
, 1));
7918 /* Similar, but generate the descriptor from trees instead of rtl.
7919 This comes up particularly with variable length arrays. If ADDRESSP
7920 is nonzero, we are looking for an address. Otherwise, we return a
7921 value. If we can't find a value, return 0. */
7923 static dw_loc_descr_ref
7924 loc_descriptor_from_tree (loc
, addressp
)
7928 dw_loc_descr_ref ret
, ret1
;
7930 int unsignedp
= TREE_UNSIGNED (TREE_TYPE (loc
));
7931 enum dwarf_location_atom op
;
7933 /* ??? Most of the time we do not take proper care for sign/zero
7934 extending the values properly. Hopefully this won't be a real
7937 switch (TREE_CODE (loc
))
7942 case WITH_RECORD_EXPR
:
7943 case PLACEHOLDER_EXPR
:
7944 /* This case involves extracting fields from an object to determine the
7945 position of other fields. We don't try to encode this here. The
7946 only user of this is Ada, which encodes the needed information using
7947 the names of types. */
7953 rtx rtl
= rtl_for_decl_location (loc
);
7954 enum machine_mode mode
= GET_MODE (rtl
);
7956 if (rtl
== NULL_RTX
)
7958 else if (CONSTANT_P (rtl
))
7960 ret
= new_loc_descr (DW_OP_addr
, 0, 0);
7961 ret
->dw_loc_oprnd1
.val_class
= dw_val_class_addr
;
7962 ret
->dw_loc_oprnd1
.v
.val_addr
= rtl
;
7967 if (GET_CODE (rtl
) == MEM
)
7970 rtl
= XEXP (rtl
, 0);
7972 ret
= mem_loc_descriptor (rtl
, mode
);
7978 ret
= loc_descriptor_from_tree (TREE_OPERAND (loc
, 0), 0);
7983 return loc_descriptor_from_tree (TREE_OPERAND (loc
, 1), addressp
);
7987 case NON_LVALUE_EXPR
:
7988 case VIEW_CONVERT_EXPR
:
7990 return loc_descriptor_from_tree (TREE_OPERAND (loc
, 0), addressp
);
7995 case ARRAY_RANGE_REF
:
7998 HOST_WIDE_INT bitsize
, bitpos
, bytepos
;
7999 enum machine_mode mode
;
8002 obj
= get_inner_reference (loc
, &bitsize
, &bitpos
, &offset
, &mode
,
8003 &unsignedp
, &volatilep
);
8008 ret
= loc_descriptor_from_tree (obj
, 1);
8010 || bitpos
% BITS_PER_UNIT
!= 0
8011 || bitsize
% BITS_PER_UNIT
!= 0)
8014 if (offset
!= NULL_TREE
)
8016 /* Variable offset. */
8017 add_loc_descr (&ret
, loc_descriptor_from_tree (offset
, 0));
8018 add_loc_descr (&ret
, new_loc_descr (DW_OP_plus
, 0, 0));
8024 bytepos
= bitpos
/ BITS_PER_UNIT
;
8026 add_loc_descr (&ret
, new_loc_descr (DW_OP_plus_uconst
, bytepos
, 0));
8027 else if (bytepos
< 0)
8029 add_loc_descr (&ret
, int_loc_descriptor (bytepos
));
8030 add_loc_descr (&ret
, new_loc_descr (DW_OP_plus
, 0, 0));
8036 if (host_integerp (loc
, 0))
8037 ret
= int_loc_descriptor (tree_low_cst (loc
, 0));
8054 case TRUNC_DIV_EXPR
:
8062 case TRUNC_MOD_EXPR
:
8075 op
= (unsignedp
? DW_OP_shr
: DW_OP_shra
);
8079 if (TREE_CODE (TREE_OPERAND (loc
, 1)) == INTEGER_CST
8080 && host_integerp (TREE_OPERAND (loc
, 1), 0))
8082 ret
= loc_descriptor_from_tree (TREE_OPERAND (loc
, 0), 0);
8086 add_loc_descr (&ret
,
8087 new_loc_descr (DW_OP_plus_uconst
,
8088 tree_low_cst (TREE_OPERAND (loc
, 1),
8097 if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc
, 0))))
8104 if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc
, 0))))
8111 if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc
, 0))))
8118 if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc
, 0))))
8133 ret
= loc_descriptor_from_tree (TREE_OPERAND (loc
, 0), 0);
8134 ret1
= loc_descriptor_from_tree (TREE_OPERAND (loc
, 1), 0);
8135 if (ret
== 0 || ret1
== 0)
8138 add_loc_descr (&ret
, ret1
);
8139 add_loc_descr (&ret
, new_loc_descr (op
, 0, 0));
8155 ret
= loc_descriptor_from_tree (TREE_OPERAND (loc
, 0), 0);
8159 add_loc_descr (&ret
, new_loc_descr (op
, 0, 0));
8163 loc
= build (COND_EXPR
, TREE_TYPE (loc
),
8164 build (LT_EXPR
, integer_type_node
,
8165 TREE_OPERAND (loc
, 0), TREE_OPERAND (loc
, 1)),
8166 TREE_OPERAND (loc
, 1), TREE_OPERAND (loc
, 0));
8171 dw_loc_descr_ref lhs
8172 = loc_descriptor_from_tree (TREE_OPERAND (loc
, 1), 0);
8173 dw_loc_descr_ref rhs
8174 = loc_descriptor_from_tree (TREE_OPERAND (loc
, 2), 0);
8175 dw_loc_descr_ref bra_node
, jump_node
, tmp
;
8177 ret
= loc_descriptor_from_tree (TREE_OPERAND (loc
, 0), 0);
8178 if (ret
== 0 || lhs
== 0 || rhs
== 0)
8181 bra_node
= new_loc_descr (DW_OP_bra
, 0, 0);
8182 add_loc_descr (&ret
, bra_node
);
8184 add_loc_descr (&ret
, rhs
);
8185 jump_node
= new_loc_descr (DW_OP_skip
, 0, 0);
8186 add_loc_descr (&ret
, jump_node
);
8188 add_loc_descr (&ret
, lhs
);
8189 bra_node
->dw_loc_oprnd1
.val_class
= dw_val_class_loc
;
8190 bra_node
->dw_loc_oprnd1
.v
.val_loc
= lhs
;
8192 /* ??? Need a node to point the skip at. Use a nop. */
8193 tmp
= new_loc_descr (DW_OP_nop
, 0, 0);
8194 add_loc_descr (&ret
, tmp
);
8195 jump_node
->dw_loc_oprnd1
.val_class
= dw_val_class_loc
;
8196 jump_node
->dw_loc_oprnd1
.v
.val_loc
= tmp
;
8204 /* Show if we can't fill the request for an address. */
8205 if (addressp
&& indirect_p
== 0)
8208 /* If we've got an address and don't want one, dereference. */
8209 if (!addressp
&& indirect_p
> 0)
8211 HOST_WIDE_INT size
= int_size_in_bytes (TREE_TYPE (loc
));
8213 if (size
> DWARF2_ADDR_SIZE
|| size
== -1)
8215 if (size
== DWARF2_ADDR_SIZE
)
8218 op
= DW_OP_deref_size
;
8220 add_loc_descr (&ret
, new_loc_descr (op
, size
, 0));
8226 /* Given a value, round it up to the lowest multiple of `boundary'
8227 which is not less than the value itself. */
8229 static inline HOST_WIDE_INT
8230 ceiling (value
, boundary
)
8231 HOST_WIDE_INT value
;
8232 unsigned int boundary
;
8234 return (((value
+ boundary
- 1) / boundary
) * boundary
);
8237 /* Given a pointer to what is assumed to be a FIELD_DECL node, return a
8238 pointer to the declared type for the relevant field variable, or return
8239 `integer_type_node' if the given node turns out to be an
8248 if (TREE_CODE (decl
) == ERROR_MARK
)
8249 return integer_type_node
;
8251 type
= DECL_BIT_FIELD_TYPE (decl
);
8252 if (type
== NULL_TREE
)
8253 type
= TREE_TYPE (decl
);
8258 /* Given a pointer to a tree node, return the alignment in bits for
8259 it, or else return BITS_PER_WORD if the node actually turns out to
8260 be an ERROR_MARK node. */
8262 static inline unsigned
8263 simple_type_align_in_bits (type
)
8266 return (TREE_CODE (type
) != ERROR_MARK
) ? TYPE_ALIGN (type
) : BITS_PER_WORD
;
8269 static inline unsigned
8270 simple_decl_align_in_bits (decl
)
8273 return (TREE_CODE (decl
) != ERROR_MARK
) ? DECL_ALIGN (decl
) : BITS_PER_WORD
;
8276 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
8277 node, return the size in bits for the type if it is a constant, or else
8278 return the alignment for the type if the type's size is not constant, or
8279 else return BITS_PER_WORD if the type actually turns out to be an
8282 static inline unsigned HOST_WIDE_INT
8283 simple_type_size_in_bits (type
)
8286 tree type_size_tree
;
8288 if (TREE_CODE (type
) == ERROR_MARK
)
8289 return BITS_PER_WORD
;
8290 type_size_tree
= TYPE_SIZE (type
);
8292 if (type_size_tree
== NULL_TREE
)
8294 if (! host_integerp (type_size_tree
, 1))
8295 return TYPE_ALIGN (type
);
8296 return tree_low_cst (type_size_tree
, 1);
8299 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
8300 return the byte offset of the lowest addressed byte of the "containing
8301 object" for the given FIELD_DECL, or return 0 if we are unable to
8302 determine what that offset is, either because the argument turns out to
8303 be a pointer to an ERROR_MARK node, or because the offset is actually
8304 variable. (We can't handle the latter case just yet). */
8306 static HOST_WIDE_INT
8307 field_byte_offset (decl
)
8310 unsigned int type_align_in_bits
;
8311 unsigned int decl_align_in_bits
;
8312 unsigned HOST_WIDE_INT type_size_in_bits
;
8313 HOST_WIDE_INT object_offset_in_bits
;
8314 HOST_WIDE_INT object_offset_in_bytes
;
8316 tree field_size_tree
;
8317 HOST_WIDE_INT bitpos_int
;
8318 HOST_WIDE_INT deepest_bitpos
;
8319 unsigned HOST_WIDE_INT field_size_in_bits
;
8321 if (TREE_CODE (decl
) == ERROR_MARK
)
8324 if (TREE_CODE (decl
) != FIELD_DECL
)
8327 type
= field_type (decl
);
8328 field_size_tree
= DECL_SIZE (decl
);
8330 /* The size could be unspecified if there was an error, or for
8331 a flexible array member. */
8332 if (! field_size_tree
)
8333 field_size_tree
= bitsize_zero_node
;
8335 /* We cannot yet cope with fields whose positions are variable, so
8336 for now, when we see such things, we simply return 0. Someday, we may
8337 be able to handle such cases, but it will be damn difficult. */
8338 if (! host_integerp (bit_position (decl
), 0))
8341 bitpos_int
= int_bit_position (decl
);
8343 /* If we don't know the size of the field, pretend it's a full word. */
8344 if (host_integerp (field_size_tree
, 1))
8345 field_size_in_bits
= tree_low_cst (field_size_tree
, 1);
8347 field_size_in_bits
= BITS_PER_WORD
;
8349 type_size_in_bits
= simple_type_size_in_bits (type
);
8350 type_align_in_bits
= simple_type_align_in_bits (type
);
8351 decl_align_in_bits
= simple_decl_align_in_bits (decl
);
8353 /* Note that the GCC front-end doesn't make any attempt to keep track of
8354 the starting bit offset (relative to the start of the containing
8355 structure type) of the hypothetical "containing object" for a bit-
8356 field. Thus, when computing the byte offset value for the start of the
8357 "containing object" of a bit-field, we must deduce this information on
8358 our own. This can be rather tricky to do in some cases. For example,
8359 handling the following structure type definition when compiling for an
8360 i386/i486 target (which only aligns long long's to 32-bit boundaries)
8363 struct S { int field1; long long field2:31; };
8365 Fortunately, there is a simple rule-of-thumb which can be
8366 used in such cases. When compiling for an i386/i486, GCC will allocate
8367 8 bytes for the structure shown above. It decides to do this based upon
8368 one simple rule for bit-field allocation. Quite simply, GCC allocates
8369 each "containing object" for each bit-field at the first (i.e. lowest
8370 addressed) legitimate alignment boundary (based upon the required
8371 minimum alignment for the declared type of the field) which it can
8372 possibly use, subject to the condition that there is still enough
8373 available space remaining in the containing object (when allocated at
8374 the selected point) to fully accommodate all of the bits of the
8375 bit-field itself. This simple rule makes it obvious why GCC allocates
8376 8 bytes for each object of the structure type shown above. When looking
8377 for a place to allocate the "containing object" for `field2', the
8378 compiler simply tries to allocate a 64-bit "containing object" at each
8379 successive 32-bit boundary (starting at zero) until it finds a place to
8380 allocate that 64- bit field such that at least 31 contiguous (and
8381 previously unallocated) bits remain within that selected 64 bit field.
8382 (As it turns out, for the example above, the compiler finds that it is
8383 OK to allocate the "containing object" 64-bit field at bit-offset zero
8384 within the structure type.) Here we attempt to work backwards from the
8385 limited set of facts we're given, and we try to deduce from those facts,
8386 where GCC must have believed that the containing object started (within
8387 the structure type). The value we deduce is then used (by the callers of
8388 this routine) to generate DW_AT_location and DW_AT_bit_offset attributes
8389 for fields (both bit-fields and, in the case of DW_AT_location, regular
8392 /* Figure out the bit-distance from the start of the structure to the
8393 "deepest" bit of the bit-field. */
8394 deepest_bitpos
= bitpos_int
+ field_size_in_bits
;
8396 /* This is the tricky part. Use some fancy footwork to deduce where the
8397 lowest addressed bit of the containing object must be. */
8398 object_offset_in_bits
= deepest_bitpos
- type_size_in_bits
;
8400 /* Round up to type_align by default. This works best for bitfields. */
8401 object_offset_in_bits
+= type_align_in_bits
- 1;
8402 object_offset_in_bits
/= type_align_in_bits
;
8403 object_offset_in_bits
*= type_align_in_bits
;
8405 if (object_offset_in_bits
> bitpos_int
)
8407 /* Sigh, the decl must be packed. */
8408 object_offset_in_bits
= deepest_bitpos
- type_size_in_bits
;
8410 /* Round up to decl_align instead. */
8411 object_offset_in_bits
+= decl_align_in_bits
- 1;
8412 object_offset_in_bits
/= decl_align_in_bits
;
8413 object_offset_in_bits
*= decl_align_in_bits
;
8416 object_offset_in_bytes
= object_offset_in_bits
/ BITS_PER_UNIT
;
8418 return object_offset_in_bytes
;
8421 /* The following routines define various Dwarf attributes and any data
8422 associated with them. */
8424 /* Add a location description attribute value to a DIE.
8426 This emits location attributes suitable for whole variables and
8427 whole parameters. Note that the location attributes for struct fields are
8428 generated by the routine `data_member_location_attribute' below. */
8431 add_AT_location_description (die
, attr_kind
, rtl
)
8433 enum dwarf_attribute attr_kind
;
8436 dw_loc_descr_ref descr
= loc_descriptor (rtl
);
8439 add_AT_loc (die
, attr_kind
, descr
);
8442 /* Attach the specialized form of location attribute used for data
8443 members of struct and union types. In the special case of a
8444 FIELD_DECL node which represents a bit-field, the "offset" part
8445 of this special location descriptor must indicate the distance
8446 in bytes from the lowest-addressed byte of the containing struct
8447 or union type to the lowest-addressed byte of the "containing
8448 object" for the bit-field. (See the `field_byte_offset' function
8449 above).. For any given bit-field, the "containing object" is a
8450 hypothetical object (of some integral or enum type) within which
8451 the given bit-field lives. The type of this hypothetical
8452 "containing object" is always the same as the declared type of
8453 the individual bit-field itself (for GCC anyway... the DWARF
8454 spec doesn't actually mandate this). Note that it is the size
8455 (in bytes) of the hypothetical "containing object" which will
8456 be given in the DW_AT_byte_size attribute for this bit-field.
8457 (See the `byte_size_attribute' function below.) It is also used
8458 when calculating the value of the DW_AT_bit_offset attribute.
8459 (See the `bit_offset_attribute' function below). */
8462 add_data_member_location_attribute (die
, decl
)
8467 dw_loc_descr_ref loc_descr
= 0;
8469 if (TREE_CODE (decl
) == TREE_VEC
)
8471 /* We're working on the TAG_inheritance for a base class. */
8473 if (TREE_VIA_VIRTUAL (decl
) && is_cxx ())
8475 /* For C++ virtual bases we can't just use BINFO_OFFSET, as they
8476 aren't at a fixed offset from all (sub)objects of the same
8477 type. We need to extract the appropriate offset from our
8478 vtable. The following dwarf expression means
8480 BaseAddr = ObAddr + *((*ObAddr) - Offset)
8482 This is specific to the V3 ABI, of course. */
8484 dw_loc_descr_ref tmp
;
8485 /* Make a copy of the object address. */
8486 tmp
= new_loc_descr (DW_OP_dup
, 0, 0);
8487 add_loc_descr (&loc_descr
, tmp
);
8488 /* Extract the vtable address. */
8489 tmp
= new_loc_descr (DW_OP_deref
, 0, 0);
8490 add_loc_descr (&loc_descr
, tmp
);
8491 /* Calculate the address of the offset. */
8492 offset
= tree_low_cst (BINFO_VPTR_FIELD (decl
), 0);
8495 tmp
= int_loc_descriptor (-offset
);
8496 add_loc_descr (&loc_descr
, tmp
);
8497 tmp
= new_loc_descr (DW_OP_minus
, 0, 0);
8498 add_loc_descr (&loc_descr
, tmp
);
8499 /* Extract the offset. */
8500 tmp
= new_loc_descr (DW_OP_deref
, 0, 0);
8501 add_loc_descr (&loc_descr
, tmp
);
8502 /* Add it to the object address. */
8503 tmp
= new_loc_descr (DW_OP_plus
, 0, 0);
8504 add_loc_descr (&loc_descr
, tmp
);
8507 offset
= tree_low_cst (BINFO_OFFSET (decl
), 0);
8510 offset
= field_byte_offset (decl
);
8514 enum dwarf_location_atom op
;
8516 /* The DWARF2 standard says that we should assume that the structure address
8517 is already on the stack, so we can specify a structure field address
8518 by using DW_OP_plus_uconst. */
8520 #ifdef MIPS_DEBUGGING_INFO
8521 /* ??? The SGI dwarf reader does not handle the DW_OP_plus_uconst operator
8522 correctly. It works only if we leave the offset on the stack. */
8525 op
= DW_OP_plus_uconst
;
8528 loc_descr
= new_loc_descr (op
, offset
, 0);
8530 add_AT_loc (die
, DW_AT_data_member_location
, loc_descr
);
8533 /* Attach an DW_AT_const_value attribute for a variable or a parameter which
8534 does not have a "location" either in memory or in a register. These
8535 things can arise in GNU C when a constant is passed as an actual parameter
8536 to an inlined function. They can also arise in C++ where declared
8537 constants do not necessarily get memory "homes". */
8540 add_const_value_attribute (die
, rtl
)
8544 switch (GET_CODE (rtl
))
8547 /* Note that a CONST_INT rtx could represent either an integer
8548 or a floating-point constant. A CONST_INT is used whenever
8549 the constant will fit into a single word. In all such
8550 cases, the original mode of the constant value is wiped
8551 out, and the CONST_INT rtx is assigned VOIDmode. */
8553 HOST_WIDE_INT val
= INTVAL (rtl
);
8555 /* ??? We really should be using HOST_WIDE_INT throughout. */
8556 if (val
< 0 && (long) val
== val
)
8557 add_AT_int (die
, DW_AT_const_value
, (long) val
);
8558 else if ((unsigned long) val
== (unsigned HOST_WIDE_INT
) val
)
8559 add_AT_unsigned (die
, DW_AT_const_value
, (unsigned long) val
);
8562 #if HOST_BITS_PER_LONG * 2 == HOST_BITS_PER_WIDE_INT
8563 add_AT_long_long (die
, DW_AT_const_value
,
8564 val
>> HOST_BITS_PER_LONG
, val
);
8573 /* Note that a CONST_DOUBLE rtx could represent either an integer or a
8574 floating-point constant. A CONST_DOUBLE is used whenever the
8575 constant requires more than one word in order to be adequately
8576 represented. We output CONST_DOUBLEs as blocks. */
8578 enum machine_mode mode
= GET_MODE (rtl
);
8580 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
)
8582 unsigned length
= GET_MODE_SIZE (mode
) / 4;
8583 long *array
= (long *) xmalloc (sizeof (long) * length
);
8586 REAL_VALUE_FROM_CONST_DOUBLE (rv
, rtl
);
8590 REAL_VALUE_TO_TARGET_SINGLE (rv
, array
[0]);
8594 REAL_VALUE_TO_TARGET_DOUBLE (rv
, array
);
8599 REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv
, array
);
8606 add_AT_float (die
, DW_AT_const_value
, length
, array
);
8610 /* ??? We really should be using HOST_WIDE_INT throughout. */
8611 if (HOST_BITS_PER_LONG
!= HOST_BITS_PER_WIDE_INT
)
8613 add_AT_long_long (die
, DW_AT_const_value
,
8614 CONST_DOUBLE_HIGH (rtl
), CONST_DOUBLE_LOW (rtl
));
8620 add_AT_string (die
, DW_AT_const_value
, XSTR (rtl
, 0));
8626 add_AT_addr (die
, DW_AT_const_value
, save_rtx (rtl
));
8630 /* In cases where an inlined instance of an inline function is passed
8631 the address of an `auto' variable (which is local to the caller) we
8632 can get a situation where the DECL_RTL of the artificial local
8633 variable (for the inlining) which acts as a stand-in for the
8634 corresponding formal parameter (of the inline function) will look
8635 like (plus:SI (reg:SI FRAME_PTR) (const_int ...)). This is not
8636 exactly a compile-time constant expression, but it isn't the address
8637 of the (artificial) local variable either. Rather, it represents the
8638 *value* which the artificial local variable always has during its
8639 lifetime. We currently have no way to represent such quasi-constant
8640 values in Dwarf, so for now we just punt and generate nothing. */
8644 /* No other kinds of rtx should be possible here. */
8651 rtl_for_decl_location (decl
)
8656 /* Here we have to decide where we are going to say the parameter "lives"
8657 (as far as the debugger is concerned). We only have a couple of
8658 choices. GCC provides us with DECL_RTL and with DECL_INCOMING_RTL.
8660 DECL_RTL normally indicates where the parameter lives during most of the
8661 activation of the function. If optimization is enabled however, this
8662 could be either NULL or else a pseudo-reg. Both of those cases indicate
8663 that the parameter doesn't really live anywhere (as far as the code
8664 generation parts of GCC are concerned) during most of the function's
8665 activation. That will happen (for example) if the parameter is never
8666 referenced within the function.
8668 We could just generate a location descriptor here for all non-NULL
8669 non-pseudo values of DECL_RTL and ignore all of the rest, but we can be
8670 a little nicer than that if we also consider DECL_INCOMING_RTL in cases
8671 where DECL_RTL is NULL or is a pseudo-reg.
8673 Note however that we can only get away with using DECL_INCOMING_RTL as
8674 a backup substitute for DECL_RTL in certain limited cases. In cases
8675 where DECL_ARG_TYPE (decl) indicates the same type as TREE_TYPE (decl),
8676 we can be sure that the parameter was passed using the same type as it is
8677 declared to have within the function, and that its DECL_INCOMING_RTL
8678 points us to a place where a value of that type is passed.
8680 In cases where DECL_ARG_TYPE (decl) and TREE_TYPE (decl) are different,
8681 we cannot (in general) use DECL_INCOMING_RTL as a substitute for DECL_RTL
8682 because in these cases DECL_INCOMING_RTL points us to a value of some
8683 type which is *different* from the type of the parameter itself. Thus,
8684 if we tried to use DECL_INCOMING_RTL to generate a location attribute in
8685 such cases, the debugger would end up (for example) trying to fetch a
8686 `float' from a place which actually contains the first part of a
8687 `double'. That would lead to really incorrect and confusing
8688 output at debug-time.
8690 So, in general, we *do not* use DECL_INCOMING_RTL as a backup for DECL_RTL
8691 in cases where DECL_ARG_TYPE (decl) != TREE_TYPE (decl). There
8692 are a couple of exceptions however. On little-endian machines we can
8693 get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE (decl) is
8694 not the same as TREE_TYPE (decl), but only when DECL_ARG_TYPE (decl) is
8695 an integral type that is smaller than TREE_TYPE (decl). These cases arise
8696 when (on a little-endian machine) a non-prototyped function has a
8697 parameter declared to be of type `short' or `char'. In such cases,
8698 TREE_TYPE (decl) will be `short' or `char', DECL_ARG_TYPE (decl) will
8699 be `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
8700 passed `int' value. If the debugger then uses that address to fetch
8701 a `short' or a `char' (on a little-endian machine) the result will be
8702 the correct data, so we allow for such exceptional cases below.
8704 Note that our goal here is to describe the place where the given formal
8705 parameter lives during most of the function's activation (i.e. between
8706 the end of the prologue and the start of the epilogue). We'll do that
8707 as best as we can. Note however that if the given formal parameter is
8708 modified sometime during the execution of the function, then a stack
8709 backtrace (at debug-time) will show the function as having been
8710 called with the *new* value rather than the value which was
8711 originally passed in. This happens rarely enough that it is not
8712 a major problem, but it *is* a problem, and I'd like to fix it.
8714 A future version of dwarf2out.c may generate two additional
8715 attributes for any given DW_TAG_formal_parameter DIE which will
8716 describe the "passed type" and the "passed location" for the
8717 given formal parameter in addition to the attributes we now
8718 generate to indicate the "declared type" and the "active
8719 location" for each parameter. This additional set of attributes
8720 could be used by debuggers for stack backtraces. Separately, note
8721 that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL can be
8722 NULL also. This happens (for example) for inlined-instances of
8723 inline function formal parameters which are never referenced.
8724 This really shouldn't be happening. All PARM_DECL nodes should
8725 get valid non-NULL DECL_INCOMING_RTL values, but integrate.c
8726 doesn't currently generate these values for inlined instances of
8727 inline function parameters, so when we see such cases, we are
8728 just out-of-luck for the time being (until integrate.c
8731 /* Use DECL_RTL as the "location" unless we find something better. */
8732 rtl
= DECL_RTL_IF_SET (decl
);
8734 if (TREE_CODE (decl
) == PARM_DECL
)
8736 if (rtl
== NULL_RTX
|| is_pseudo_reg (rtl
))
8738 tree declared_type
= type_main_variant (TREE_TYPE (decl
));
8739 tree passed_type
= type_main_variant (DECL_ARG_TYPE (decl
));
8741 /* This decl represents a formal parameter which was optimized out.
8742 Note that DECL_INCOMING_RTL may be NULL in here, but we handle
8743 all* cases where (rtl == NULL_RTX) just below. */
8744 if (declared_type
== passed_type
)
8745 rtl
= DECL_INCOMING_RTL (decl
);
8746 else if (! BYTES_BIG_ENDIAN
8747 && TREE_CODE (declared_type
) == INTEGER_TYPE
8748 && (GET_MODE_SIZE (TYPE_MODE (declared_type
))
8749 <= GET_MODE_SIZE (TYPE_MODE (passed_type
))))
8750 rtl
= DECL_INCOMING_RTL (decl
);
8753 /* If the parm was passed in registers, but lives on the stack, then
8754 make a big endian correction if the mode of the type of the
8755 parameter is not the same as the mode of the rtl. */
8756 /* ??? This is the same series of checks that are made in dbxout.c before
8757 we reach the big endian correction code there. It isn't clear if all
8758 of these checks are necessary here, but keeping them all is the safe
8760 else if (GET_CODE (rtl
) == MEM
8761 && XEXP (rtl
, 0) != const0_rtx
8762 && ! CONSTANT_P (XEXP (rtl
, 0))
8763 /* Not passed in memory. */
8764 && GET_CODE (DECL_INCOMING_RTL (decl
)) != MEM
8765 /* Not passed by invisible reference. */
8766 && (GET_CODE (XEXP (rtl
, 0)) != REG
8767 || REGNO (XEXP (rtl
, 0)) == HARD_FRAME_POINTER_REGNUM
8768 || REGNO (XEXP (rtl
, 0)) == STACK_POINTER_REGNUM
8769 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
8770 || REGNO (XEXP (rtl
, 0)) == ARG_POINTER_REGNUM
8773 /* Big endian correction check. */
8775 && TYPE_MODE (TREE_TYPE (decl
)) != GET_MODE (rtl
)
8776 && (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (decl
)))
8779 int offset
= (UNITS_PER_WORD
8780 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (decl
))));
8781 rtl
= gen_rtx_MEM (TYPE_MODE (TREE_TYPE (decl
)),
8782 plus_constant (XEXP (rtl
, 0), offset
));
8786 if (rtl
!= NULL_RTX
)
8788 rtl
= eliminate_regs (rtl
, 0, NULL_RTX
);
8789 #ifdef LEAF_REG_REMAP
8790 if (current_function_uses_only_leaf_regs
)
8791 leaf_renumber_regs_insn (rtl
);
8795 /* A variable with no DECL_RTL but a DECL_INITIAL is a compile-time
8796 constant, and will have been substituted directly into all
8797 expressions that use it. C does not have such a concept, but
8798 C++ and other languages do. */
8799 else if (DECL_INITIAL (decl
))
8801 rtl
= expand_expr (DECL_INITIAL (decl
), NULL_RTX
, VOIDmode
,
8802 EXPAND_INITIALIZER
);
8808 /* Generate *either* an DW_AT_location attribute or else an DW_AT_const_value
8809 data attribute for a variable or a parameter. We generate the
8810 DW_AT_const_value attribute only in those cases where the given variable
8811 or parameter does not have a true "location" either in memory or in a
8812 register. This can happen (for example) when a constant is passed as an
8813 actual argument in a call to an inline function. (It's possible that
8814 these things can crop up in other ways also.) Note that one type of
8815 constant value which can be passed into an inlined function is a constant
8816 pointer. This can happen for example if an actual argument in an inlined
8817 function call evaluates to a compile-time constant address. */
8820 add_location_or_const_value_attribute (die
, decl
)
8826 if (TREE_CODE (decl
) == ERROR_MARK
)
8829 if (TREE_CODE (decl
) != VAR_DECL
&& TREE_CODE (decl
) != PARM_DECL
)
8832 rtl
= rtl_for_decl_location (decl
);
8833 if (rtl
== NULL_RTX
)
8836 /* If we don't look past the constant pool, we risk emitting a
8837 reference to a constant pool entry that isn't referenced from
8838 code, and thus is not emitted. */
8839 rtl
= avoid_constant_pool_reference (rtl
);
8841 switch (GET_CODE (rtl
))
8844 /* The address of a variable that was optimized away; don't emit
8855 /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
8856 add_const_value_attribute (die
, rtl
);
8863 add_AT_location_description (die
, DW_AT_location
, rtl
);
8871 /* If we don't have a copy of this variable in memory for some reason (such
8872 as a C++ member constant that doesn't have an out-of-line definition),
8873 we should tell the debugger about the constant value. */
8876 tree_add_const_value_attribute (var_die
, decl
)
8880 tree init
= DECL_INITIAL (decl
);
8881 tree type
= TREE_TYPE (decl
);
8883 if (TREE_READONLY (decl
) && ! TREE_THIS_VOLATILE (decl
) && init
8884 && initializer_constant_valid_p (init
, type
) == null_pointer_node
)
8889 switch (TREE_CODE (type
))
8892 if (host_integerp (init
, 0))
8893 add_AT_unsigned (var_die
, DW_AT_const_value
,
8894 TREE_INT_CST_LOW (init
));
8896 add_AT_long_long (var_die
, DW_AT_const_value
,
8897 TREE_INT_CST_HIGH (init
),
8898 TREE_INT_CST_LOW (init
));
8905 /* Generate an DW_AT_name attribute given some string value to be included as
8906 the value of the attribute. */
8909 add_name_attribute (die
, name_string
)
8911 const char *name_string
;
8913 if (name_string
!= NULL
&& *name_string
!= 0)
8915 if (demangle_name_func
)
8916 name_string
= (*demangle_name_func
) (name_string
);
8918 add_AT_string (die
, DW_AT_name
, name_string
);
8922 /* Given a tree node describing an array bound (either lower or upper) output
8923 a representation for that bound. */
8926 add_bound_info (subrange_die
, bound_attr
, bound
)
8927 dw_die_ref subrange_die
;
8928 enum dwarf_attribute bound_attr
;
8931 switch (TREE_CODE (bound
))
8936 /* All fixed-bounds are represented by INTEGER_CST nodes. */
8938 if (! host_integerp (bound
, 0)
8939 || (bound_attr
== DW_AT_lower_bound
8940 && (((is_c_family () || is_java ()) && integer_zerop (bound
))
8941 || (is_fortran () && integer_onep (bound
)))))
8942 /* use the default */
8945 add_AT_unsigned (subrange_die
, bound_attr
, tree_low_cst (bound
, 0));
8950 case NON_LVALUE_EXPR
:
8951 case VIEW_CONVERT_EXPR
:
8952 add_bound_info (subrange_die
, bound_attr
, TREE_OPERAND (bound
, 0));
8956 /* If optimization is turned on, the SAVE_EXPRs that describe how to
8957 access the upper bound values may be bogus. If they refer to a
8958 register, they may only describe how to get at these values at the
8959 points in the generated code right after they have just been
8960 computed. Worse yet, in the typical case, the upper bound values
8961 will not even *be* computed in the optimized code (though the
8962 number of elements will), so these SAVE_EXPRs are entirely
8963 bogus. In order to compensate for this fact, we check here to see
8964 if optimization is enabled, and if so, we don't add an attribute
8965 for the (unknown and unknowable) upper bound. This should not
8966 cause too much trouble for existing (stupid?) debuggers because
8967 they have to deal with empty upper bounds location descriptions
8968 anyway in order to be able to deal with incomplete array types.
8969 Of course an intelligent debugger (GDB?) should be able to
8970 comprehend that a missing upper bound specification in an array
8971 type used for a storage class `auto' local array variable
8972 indicates that the upper bound is both unknown (at compile- time)
8973 and unknowable (at run-time) due to optimization.
8975 We assume that a MEM rtx is safe because gcc wouldn't put the
8976 value there unless it was going to be used repeatedly in the
8977 function, i.e. for cleanups. */
8978 if (SAVE_EXPR_RTL (bound
)
8979 && (! optimize
|| GET_CODE (SAVE_EXPR_RTL (bound
)) == MEM
))
8981 dw_die_ref ctx
= lookup_decl_die (current_function_decl
);
8982 dw_die_ref decl_die
= new_die (DW_TAG_variable
, ctx
);
8983 rtx loc
= SAVE_EXPR_RTL (bound
);
8985 /* If the RTL for the SAVE_EXPR is memory, handle the case where
8986 it references an outer function's frame. */
8988 if (GET_CODE (loc
) == MEM
)
8990 rtx new_addr
= fix_lexical_addr (XEXP (loc
, 0), bound
);
8992 if (XEXP (loc
, 0) != new_addr
)
8993 loc
= gen_rtx_MEM (GET_MODE (loc
), new_addr
);
8996 add_AT_flag (decl_die
, DW_AT_artificial
, 1);
8997 add_type_attribute (decl_die
, TREE_TYPE (bound
), 1, 0, ctx
);
8998 add_AT_location_description (decl_die
, DW_AT_location
, loc
);
8999 add_AT_die_ref (subrange_die
, bound_attr
, decl_die
);
9002 /* Else leave out the attribute. */
9008 dw_die_ref decl_die
= lookup_decl_die (bound
);
9010 /* ??? Can this happen, or should the variable have been bound
9011 first? Probably it can, since I imagine that we try to create
9012 the types of parameters in the order in which they exist in
9013 the list, and won't have created a forward reference to a
9015 if (decl_die
!= NULL
)
9016 add_AT_die_ref (subrange_die
, bound_attr
, decl_die
);
9022 /* Otherwise try to create a stack operation procedure to
9023 evaluate the value of the array bound. */
9025 dw_die_ref ctx
, decl_die
;
9026 dw_loc_descr_ref loc
;
9028 loc
= loc_descriptor_from_tree (bound
, 0);
9032 if (current_function_decl
== 0)
9033 ctx
= comp_unit_die
;
9035 ctx
= lookup_decl_die (current_function_decl
);
9037 decl_die
= new_die (DW_TAG_variable
, ctx
);
9038 add_AT_flag (decl_die
, DW_AT_artificial
, 1);
9039 add_type_attribute (decl_die
, TREE_TYPE (bound
), 1, 0, ctx
);
9040 add_AT_loc (decl_die
, DW_AT_location
, loc
);
9042 add_AT_die_ref (subrange_die
, bound_attr
, decl_die
);
9048 /* Note that the block of subscript information for an array type also
9049 includes information about the element type of type given array type. */
9052 add_subscript_info (type_die
, type
)
9053 dw_die_ref type_die
;
9056 #ifndef MIPS_DEBUGGING_INFO
9057 unsigned dimension_number
;
9060 dw_die_ref subrange_die
;
9062 /* The GNU compilers represent multidimensional array types as sequences of
9063 one dimensional array types whose element types are themselves array
9064 types. Here we squish that down, so that each multidimensional array
9065 type gets only one array_type DIE in the Dwarf debugging info. The draft
9066 Dwarf specification say that we are allowed to do this kind of
9067 compression in C (because there is no difference between an array or
9068 arrays and a multidimensional array in C) but for other source languages
9069 (e.g. Ada) we probably shouldn't do this. */
9071 /* ??? The SGI dwarf reader fails for multidimensional arrays with a
9072 const enum type. E.g. const enum machine_mode insn_operand_mode[2][10].
9073 We work around this by disabling this feature. See also
9074 gen_array_type_die. */
9075 #ifndef MIPS_DEBUGGING_INFO
9076 for (dimension_number
= 0;
9077 TREE_CODE (type
) == ARRAY_TYPE
;
9078 type
= TREE_TYPE (type
), dimension_number
++)
9081 tree domain
= TYPE_DOMAIN (type
);
9083 /* Arrays come in three flavors: Unspecified bounds, fixed bounds,
9084 and (in GNU C only) variable bounds. Handle all three forms
9086 subrange_die
= new_die (DW_TAG_subrange_type
, type_die
);
9089 /* We have an array type with specified bounds. */
9090 lower
= TYPE_MIN_VALUE (domain
);
9091 upper
= TYPE_MAX_VALUE (domain
);
9093 /* define the index type. */
9094 if (TREE_TYPE (domain
))
9096 /* ??? This is probably an Ada unnamed subrange type. Ignore the
9097 TREE_TYPE field. We can't emit debug info for this
9098 because it is an unnamed integral type. */
9099 if (TREE_CODE (domain
) == INTEGER_TYPE
9100 && TYPE_NAME (domain
) == NULL_TREE
9101 && TREE_CODE (TREE_TYPE (domain
)) == INTEGER_TYPE
9102 && TYPE_NAME (TREE_TYPE (domain
)) == NULL_TREE
)
9105 add_type_attribute (subrange_die
, TREE_TYPE (domain
), 0, 0,
9109 /* ??? If upper is NULL, the array has unspecified length,
9110 but it does have a lower bound. This happens with Fortran
9112 Since the debugger is definitely going to need to know N
9113 to produce useful results, go ahead and output the lower
9114 bound solo, and hope the debugger can cope. */
9116 add_bound_info (subrange_die
, DW_AT_lower_bound
, lower
);
9118 add_bound_info (subrange_die
, DW_AT_upper_bound
, upper
);
9121 /* We have an array type with an unspecified length. The DWARF-2
9122 spec does not say how to handle this; let's just leave out the
9126 #ifndef MIPS_DEBUGGING_INFO
9132 add_byte_size_attribute (die
, tree_node
)
9138 switch (TREE_CODE (tree_node
))
9146 case QUAL_UNION_TYPE
:
9147 size
= int_size_in_bytes (tree_node
);
9150 /* For a data member of a struct or union, the DW_AT_byte_size is
9151 generally given as the number of bytes normally allocated for an
9152 object of the *declared* type of the member itself. This is true
9153 even for bit-fields. */
9154 size
= simple_type_size_in_bits (field_type (tree_node
)) / BITS_PER_UNIT
;
9160 /* Note that `size' might be -1 when we get to this point. If it is, that
9161 indicates that the byte size of the entity in question is variable. We
9162 have no good way of expressing this fact in Dwarf at the present time,
9163 so just let the -1 pass on through. */
9165 add_AT_unsigned (die
, DW_AT_byte_size
, size
);
9168 /* For a FIELD_DECL node which represents a bit-field, output an attribute
9169 which specifies the distance in bits from the highest order bit of the
9170 "containing object" for the bit-field to the highest order bit of the
9173 For any given bit-field, the "containing object" is a hypothetical
9174 object (of some integral or enum type) within which the given bit-field
9175 lives. The type of this hypothetical "containing object" is always the
9176 same as the declared type of the individual bit-field itself. The
9177 determination of the exact location of the "containing object" for a
9178 bit-field is rather complicated. It's handled by the
9179 `field_byte_offset' function (above).
9181 Note that it is the size (in bytes) of the hypothetical "containing object"
9182 which will be given in the DW_AT_byte_size attribute for this bit-field.
9183 (See `byte_size_attribute' above). */
9186 add_bit_offset_attribute (die
, decl
)
9190 HOST_WIDE_INT object_offset_in_bytes
= field_byte_offset (decl
);
9191 tree type
= DECL_BIT_FIELD_TYPE (decl
);
9192 HOST_WIDE_INT bitpos_int
;
9193 HOST_WIDE_INT highest_order_object_bit_offset
;
9194 HOST_WIDE_INT highest_order_field_bit_offset
;
9195 HOST_WIDE_INT
unsigned bit_offset
;
9197 /* Must be a field and a bit field. */
9199 || TREE_CODE (decl
) != FIELD_DECL
)
9202 /* We can't yet handle bit-fields whose offsets are variable, so if we
9203 encounter such things, just return without generating any attribute
9204 whatsoever. Likewise for variable or too large size. */
9205 if (! host_integerp (bit_position (decl
), 0)
9206 || ! host_integerp (DECL_SIZE (decl
), 1))
9209 bitpos_int
= int_bit_position (decl
);
9211 /* Note that the bit offset is always the distance (in bits) from the
9212 highest-order bit of the "containing object" to the highest-order bit of
9213 the bit-field itself. Since the "high-order end" of any object or field
9214 is different on big-endian and little-endian machines, the computation
9215 below must take account of these differences. */
9216 highest_order_object_bit_offset
= object_offset_in_bytes
* BITS_PER_UNIT
;
9217 highest_order_field_bit_offset
= bitpos_int
;
9219 if (! BYTES_BIG_ENDIAN
)
9221 highest_order_field_bit_offset
+= tree_low_cst (DECL_SIZE (decl
), 0);
9222 highest_order_object_bit_offset
+= simple_type_size_in_bits (type
);
9226 = (! BYTES_BIG_ENDIAN
9227 ? highest_order_object_bit_offset
- highest_order_field_bit_offset
9228 : highest_order_field_bit_offset
- highest_order_object_bit_offset
);
9230 add_AT_unsigned (die
, DW_AT_bit_offset
, bit_offset
);
9233 /* For a FIELD_DECL node which represents a bit field, output an attribute
9234 which specifies the length in bits of the given field. */
9237 add_bit_size_attribute (die
, decl
)
9241 /* Must be a field and a bit field. */
9242 if (TREE_CODE (decl
) != FIELD_DECL
9243 || ! DECL_BIT_FIELD_TYPE (decl
))
9246 if (host_integerp (DECL_SIZE (decl
), 1))
9247 add_AT_unsigned (die
, DW_AT_bit_size
, tree_low_cst (DECL_SIZE (decl
), 1));
9250 /* If the compiled language is ANSI C, then add a 'prototyped'
9251 attribute, if arg types are given for the parameters of a function. */
9254 add_prototyped_attribute (die
, func_type
)
9258 if (get_AT_unsigned (comp_unit_die
, DW_AT_language
) == DW_LANG_C89
9259 && TYPE_ARG_TYPES (func_type
) != NULL
)
9260 add_AT_flag (die
, DW_AT_prototyped
, 1);
9263 /* Add an 'abstract_origin' attribute below a given DIE. The DIE is found
9264 by looking in either the type declaration or object declaration
9268 add_abstract_origin_attribute (die
, origin
)
9272 dw_die_ref origin_die
= NULL
;
9274 if (TREE_CODE (origin
) != FUNCTION_DECL
)
9276 /* We may have gotten separated from the block for the inlined
9277 function, if we're in an exception handler or some such; make
9278 sure that the abstract function has been written out.
9280 Doing this for nested functions is wrong, however; functions are
9281 distinct units, and our context might not even be inline. */
9284 fn
= TYPE_STUB_DECL (fn
);
9285 fn
= decl_function_context (fn
);
9287 dwarf2out_abstract_function (fn
);
9290 if (DECL_P (origin
))
9291 origin_die
= lookup_decl_die (origin
);
9292 else if (TYPE_P (origin
))
9293 origin_die
= lookup_type_die (origin
);
9295 if (origin_die
== NULL
)
9298 add_AT_die_ref (die
, DW_AT_abstract_origin
, origin_die
);
9301 /* We do not currently support the pure_virtual attribute. */
9304 add_pure_or_virtual_attribute (die
, func_decl
)
9308 if (DECL_VINDEX (func_decl
))
9310 add_AT_unsigned (die
, DW_AT_virtuality
, DW_VIRTUALITY_virtual
);
9312 if (host_integerp (DECL_VINDEX (func_decl
), 0))
9313 add_AT_loc (die
, DW_AT_vtable_elem_location
,
9314 new_loc_descr (DW_OP_constu
,
9315 tree_low_cst (DECL_VINDEX (func_decl
), 0),
9318 /* GNU extension: Record what type this method came from originally. */
9319 if (debug_info_level
> DINFO_LEVEL_TERSE
)
9320 add_AT_die_ref (die
, DW_AT_containing_type
,
9321 lookup_type_die (DECL_CONTEXT (func_decl
)));
9325 /* Add source coordinate attributes for the given decl. */
9328 add_src_coords_attributes (die
, decl
)
9332 unsigned file_index
= lookup_filename (DECL_SOURCE_FILE (decl
));
9334 add_AT_unsigned (die
, DW_AT_decl_file
, file_index
);
9335 add_AT_unsigned (die
, DW_AT_decl_line
, DECL_SOURCE_LINE (decl
));
9338 /* Add an DW_AT_name attribute and source coordinate attribute for the
9339 given decl, but only if it actually has a name. */
9342 add_name_and_src_coords_attributes (die
, decl
)
9348 decl_name
= DECL_NAME (decl
);
9349 if (decl_name
!= NULL
&& IDENTIFIER_POINTER (decl_name
) != NULL
)
9351 add_name_attribute (die
, dwarf2_name (decl
, 0));
9352 if (! DECL_ARTIFICIAL (decl
))
9353 add_src_coords_attributes (die
, decl
);
9355 if ((TREE_CODE (decl
) == FUNCTION_DECL
|| TREE_CODE (decl
) == VAR_DECL
)
9356 && TREE_PUBLIC (decl
)
9357 && DECL_ASSEMBLER_NAME (decl
) != DECL_NAME (decl
)
9358 && !DECL_ABSTRACT (decl
))
9359 add_AT_string (die
, DW_AT_MIPS_linkage_name
,
9360 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
9363 #ifdef VMS_DEBUGGING_INFO
9365 /* Get the function's name, as described by its RTL. This may be different
9366 from the DECL_NAME name used in the source file. */
9367 if (TREE_CODE (decl
) == FUNCTION_DECL
&& TREE_ASM_WRITTEN (decl
))
9368 add_AT_string (die
, DW_AT_VMS_rtnbeg_pd_address
,
9369 xstrdup (XSTR (XEXP (DECL_RTL (decl
), 0), 0)));
9373 /* Push a new declaration scope. */
9376 push_decl_scope (scope
)
9379 VARRAY_PUSH_TREE (decl_scope_table
, scope
);
9382 /* Pop a declaration scope. */
9386 if (VARRAY_ACTIVE_SIZE (decl_scope_table
) <= 0)
9388 VARRAY_POP (decl_scope_table
);
9391 /* Return the DIE for the scope that immediately contains this type.
9392 Non-named types get global scope. Named types nested in other
9393 types get their containing scope if it's open, or global scope
9394 otherwise. All other types (i.e. function-local named types) get
9395 the current active scope. */
9398 scope_die_for (t
, context_die
)
9400 dw_die_ref context_die
;
9402 dw_die_ref scope_die
= NULL
;
9403 tree containing_scope
;
9406 /* Non-types always go in the current scope. */
9410 containing_scope
= TYPE_CONTEXT (t
);
9412 /* Ignore namespaces for the moment. */
9413 if (containing_scope
&& TREE_CODE (containing_scope
) == NAMESPACE_DECL
)
9414 containing_scope
= NULL_TREE
;
9416 /* Ignore function type "scopes" from the C frontend. They mean that
9417 a tagged type is local to a parmlist of a function declarator, but
9418 that isn't useful to DWARF. */
9419 if (containing_scope
&& TREE_CODE (containing_scope
) == FUNCTION_TYPE
)
9420 containing_scope
= NULL_TREE
;
9422 if (containing_scope
== NULL_TREE
)
9423 scope_die
= comp_unit_die
;
9424 else if (TYPE_P (containing_scope
))
9426 /* For types, we can just look up the appropriate DIE. But
9427 first we check to see if we're in the middle of emitting it
9428 so we know where the new DIE should go. */
9430 for (i
= VARRAY_ACTIVE_SIZE (decl_scope_table
) - 1; i
>= 0; --i
)
9431 if (VARRAY_TREE (decl_scope_table
, i
) == containing_scope
)
9436 if (debug_info_level
> DINFO_LEVEL_TERSE
9437 && !TREE_ASM_WRITTEN (containing_scope
))
9440 /* If none of the current dies are suitable, we get file scope. */
9441 scope_die
= comp_unit_die
;
9444 scope_die
= lookup_type_die (containing_scope
);
9447 scope_die
= context_die
;
9452 /* Returns nonzero iff CONTEXT_DIE is internal to a function. */
9454 static inline int local_scope_p
PARAMS ((dw_die_ref
));
9456 local_scope_p (context_die
)
9457 dw_die_ref context_die
;
9459 for (; context_die
; context_die
= context_die
->die_parent
)
9460 if (context_die
->die_tag
== DW_TAG_inlined_subroutine
9461 || context_die
->die_tag
== DW_TAG_subprogram
)
9466 /* Returns nonzero iff CONTEXT_DIE is a class. */
9468 static inline int class_scope_p
PARAMS ((dw_die_ref
));
9470 class_scope_p (context_die
)
9471 dw_die_ref context_die
;
9474 && (context_die
->die_tag
== DW_TAG_structure_type
9475 || context_die
->die_tag
== DW_TAG_union_type
));
9478 /* Many forms of DIEs require a "type description" attribute. This
9479 routine locates the proper "type descriptor" die for the type given
9480 by 'type', and adds an DW_AT_type attribute below the given die. */
9483 add_type_attribute (object_die
, type
, decl_const
, decl_volatile
, context_die
)
9484 dw_die_ref object_die
;
9488 dw_die_ref context_die
;
9490 enum tree_code code
= TREE_CODE (type
);
9491 dw_die_ref type_die
= NULL
;
9493 /* ??? If this type is an unnamed subrange type of an integral or
9494 floating-point type, use the inner type. This is because we have no
9495 support for unnamed types in base_type_die. This can happen if this is
9496 an Ada subrange type. Correct solution is emit a subrange type die. */
9497 if ((code
== INTEGER_TYPE
|| code
== REAL_TYPE
)
9498 && TREE_TYPE (type
) != 0 && TYPE_NAME (type
) == 0)
9499 type
= TREE_TYPE (type
), code
= TREE_CODE (type
);
9501 if (code
== ERROR_MARK
)
9504 /* Handle a special case. For functions whose return type is void, we
9505 generate *no* type attribute. (Note that no object may have type
9506 `void', so this only applies to function return types). */
9507 if (code
== VOID_TYPE
)
9510 type_die
= modified_type_die (type
,
9511 decl_const
|| TYPE_READONLY (type
),
9512 decl_volatile
|| TYPE_VOLATILE (type
),
9514 if (type_die
!= NULL
)
9515 add_AT_die_ref (object_die
, DW_AT_type
, type_die
);
9518 /* Given a tree pointer to a struct, class, union, or enum type node, return
9519 a pointer to the (string) tag name for the given type, or zero if the type
9520 was declared without a tag. */
9526 const char *name
= 0;
9528 if (TYPE_NAME (type
) != 0)
9532 /* Find the IDENTIFIER_NODE for the type name. */
9533 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
9534 t
= TYPE_NAME (type
);
9536 /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
9537 a TYPE_DECL node, regardless of whether or not a `typedef' was
9539 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
9540 && ! DECL_IGNORED_P (TYPE_NAME (type
)))
9541 t
= DECL_NAME (TYPE_NAME (type
));
9543 /* Now get the name as a string, or invent one. */
9545 name
= IDENTIFIER_POINTER (t
);
9548 return (name
== 0 || *name
== '\0') ? 0 : name
;
9551 /* Return the type associated with a data member, make a special check
9552 for bit field types. */
9555 member_declared_type (member
)
9558 return (DECL_BIT_FIELD_TYPE (member
)
9559 ? DECL_BIT_FIELD_TYPE (member
)
9560 : TREE_TYPE (member
));
9563 /* Get the decl's label, as described by its RTL. This may be different
9564 from the DECL_NAME name used in the source file. */
9568 decl_start_label (decl
)
9573 x
= DECL_RTL (decl
);
9574 if (GET_CODE (x
) != MEM
)
9578 if (GET_CODE (x
) != SYMBOL_REF
)
9581 fnname
= XSTR (x
, 0);
9586 /* These routines generate the internal representation of the DIE's for
9587 the compilation unit. Debugging information is collected by walking
9588 the declaration trees passed in from dwarf2out_decl(). */
9591 gen_array_type_die (type
, context_die
)
9593 dw_die_ref context_die
;
9595 dw_die_ref scope_die
= scope_die_for (type
, context_die
);
9596 dw_die_ref array_die
;
9599 /* ??? The SGI dwarf reader fails for array of array of enum types unless
9600 the inner array type comes before the outer array type. Thus we must
9601 call gen_type_die before we call new_die. See below also. */
9602 #ifdef MIPS_DEBUGGING_INFO
9603 gen_type_die (TREE_TYPE (type
), context_die
);
9606 array_die
= new_die (DW_TAG_array_type
, scope_die
);
9609 /* We default the array ordering. SDB will probably do
9610 the right things even if DW_AT_ordering is not present. It's not even
9611 an issue until we start to get into multidimensional arrays anyway. If
9612 SDB is ever caught doing the Wrong Thing for multi-dimensional arrays,
9613 then we'll have to put the DW_AT_ordering attribute back in. (But if
9614 and when we find out that we need to put these in, we will only do so
9615 for multidimensional arrays. */
9616 add_AT_unsigned (array_die
, DW_AT_ordering
, DW_ORD_row_major
);
9619 #ifdef MIPS_DEBUGGING_INFO
9620 /* The SGI compilers handle arrays of unknown bound by setting
9621 AT_declaration and not emitting any subrange DIEs. */
9622 if (! TYPE_DOMAIN (type
))
9623 add_AT_unsigned (array_die
, DW_AT_declaration
, 1);
9626 add_subscript_info (array_die
, type
);
9628 add_name_attribute (array_die
, type_tag (type
));
9629 equate_type_number_to_die (type
, array_die
);
9631 /* Add representation of the type of the elements of this array type. */
9632 element_type
= TREE_TYPE (type
);
9634 /* ??? The SGI dwarf reader fails for multidimensional arrays with a
9635 const enum type. E.g. const enum machine_mode insn_operand_mode[2][10].
9636 We work around this by disabling this feature. See also
9637 add_subscript_info. */
9638 #ifndef MIPS_DEBUGGING_INFO
9639 while (TREE_CODE (element_type
) == ARRAY_TYPE
)
9640 element_type
= TREE_TYPE (element_type
);
9642 gen_type_die (element_type
, context_die
);
9645 add_type_attribute (array_die
, element_type
, 0, 0, context_die
);
9649 gen_set_type_die (type
, context_die
)
9651 dw_die_ref context_die
;
9654 = new_die (DW_TAG_set_type
, scope_die_for (type
, context_die
));
9656 equate_type_number_to_die (type
, type_die
);
9657 add_type_attribute (type_die
, TREE_TYPE (type
), 0, 0, context_die
);
9662 gen_entry_point_die (decl
, context_die
)
9664 dw_die_ref context_die
;
9666 tree origin
= decl_ultimate_origin (decl
);
9667 dw_die_ref decl_die
= new_die (DW_TAG_entry_point
, context_die
);
9669 add_abstract_origin_attribute (decl_die
, origin
);
9672 add_name_and_src_coords_attributes (decl_die
, decl
);
9673 add_type_attribute (decl_die
, TREE_TYPE (TREE_TYPE (decl
)),
9677 if (DECL_ABSTRACT (decl
))
9678 equate_decl_number_to_die (decl
, decl_die
);
9680 add_AT_lbl_id (decl_die
, DW_AT_low_pc
, decl_start_label (decl
));
9684 /* Remember a type in the incomplete_types_list. */
9686 add_incomplete_type (type
)
9689 VARRAY_PUSH_TREE (incomplete_types
, type
);
9692 /* Walk through the list of incomplete types again, trying once more to
9693 emit full debugging info for them. */
9696 retry_incomplete_types ()
9699 for (i
= VARRAY_ACTIVE_SIZE (incomplete_types
) - 1; i
>= 0; i
--)
9701 gen_type_die (VARRAY_TREE (incomplete_types
, i
), comp_unit_die
);
9705 /* Generate a DIE to represent an inlined instance of an enumeration type. */
9708 gen_inlined_enumeration_type_die (type
, context_die
)
9710 dw_die_ref context_die
;
9712 dw_die_ref type_die
= new_die (DW_TAG_enumeration_type
, context_die
);
9713 /* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
9714 be incomplete and such types are not marked. */
9715 add_abstract_origin_attribute (type_die
, type
);
9718 /* Generate a DIE to represent an inlined instance of a structure type. */
9721 gen_inlined_structure_type_die (type
, context_die
)
9723 dw_die_ref context_die
;
9725 dw_die_ref type_die
= new_die (DW_TAG_structure_type
, context_die
);
9727 /* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
9728 be incomplete and such types are not marked. */
9729 add_abstract_origin_attribute (type_die
, type
);
9732 /* Generate a DIE to represent an inlined instance of a union type. */
9735 gen_inlined_union_type_die (type
, context_die
)
9737 dw_die_ref context_die
;
9739 dw_die_ref type_die
= new_die (DW_TAG_union_type
, context_die
);
9741 /* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
9742 be incomplete and such types are not marked. */
9743 add_abstract_origin_attribute (type_die
, type
);
9746 /* Generate a DIE to represent an enumeration type. Note that these DIEs
9747 include all of the information about the enumeration values also. Each
9748 enumerated type name/value is listed as a child of the enumerated type
9752 gen_enumeration_type_die (type
, context_die
)
9754 dw_die_ref context_die
;
9756 dw_die_ref type_die
= lookup_type_die (type
);
9758 if (type_die
== NULL
)
9760 type_die
= new_die (DW_TAG_enumeration_type
,
9761 scope_die_for (type
, context_die
));
9762 equate_type_number_to_die (type
, type_die
);
9763 add_name_attribute (type_die
, type_tag (type
));
9765 else if (! TYPE_SIZE (type
))
9768 remove_AT (type_die
, DW_AT_declaration
);
9770 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
9771 given enum type is incomplete, do not generate the DW_AT_byte_size
9772 attribute or the DW_AT_element_list attribute. */
9773 if (TYPE_SIZE (type
))
9777 TREE_ASM_WRITTEN (type
) = 1;
9778 add_byte_size_attribute (type_die
, type
);
9779 if (TYPE_STUB_DECL (type
) != NULL_TREE
)
9780 add_src_coords_attributes (type_die
, TYPE_STUB_DECL (type
));
9782 /* If the first reference to this type was as the return type of an
9783 inline function, then it may not have a parent. Fix this now. */
9784 if (type_die
->die_parent
== NULL
)
9785 add_child_die (scope_die_for (type
, context_die
), type_die
);
9787 for (link
= TYPE_FIELDS (type
);
9788 link
!= NULL
; link
= TREE_CHAIN (link
))
9790 dw_die_ref enum_die
= new_die (DW_TAG_enumerator
, type_die
);
9792 add_name_attribute (enum_die
,
9793 IDENTIFIER_POINTER (TREE_PURPOSE (link
)));
9795 if (host_integerp (TREE_VALUE (link
), 0))
9797 if (tree_int_cst_sgn (TREE_VALUE (link
)) < 0)
9798 add_AT_int (enum_die
, DW_AT_const_value
,
9799 tree_low_cst (TREE_VALUE (link
), 0));
9801 add_AT_unsigned (enum_die
, DW_AT_const_value
,
9802 tree_low_cst (TREE_VALUE (link
), 0));
9807 add_AT_flag (type_die
, DW_AT_declaration
, 1);
9810 /* Generate a DIE to represent either a real live formal parameter decl or to
9811 represent just the type of some formal parameter position in some function
9814 Note that this routine is a bit unusual because its argument may be a
9815 ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
9816 represents an inlining of some PARM_DECL) or else some sort of a ..._TYPE
9817 node. If it's the former then this function is being called to output a
9818 DIE to represent a formal parameter object (or some inlining thereof). If
9819 it's the latter, then this function is only being called to output a
9820 DW_TAG_formal_parameter DIE to stand as a placeholder for some formal
9821 argument type of some subprogram type. */
9824 gen_formal_parameter_die (node
, context_die
)
9826 dw_die_ref context_die
;
9829 = new_die (DW_TAG_formal_parameter
, context_die
);
9832 switch (TREE_CODE_CLASS (TREE_CODE (node
)))
9835 origin
= decl_ultimate_origin (node
);
9837 add_abstract_origin_attribute (parm_die
, origin
);
9840 add_name_and_src_coords_attributes (parm_die
, node
);
9841 add_type_attribute (parm_die
, TREE_TYPE (node
),
9842 TREE_READONLY (node
),
9843 TREE_THIS_VOLATILE (node
),
9845 if (DECL_ARTIFICIAL (node
))
9846 add_AT_flag (parm_die
, DW_AT_artificial
, 1);
9849 equate_decl_number_to_die (node
, parm_die
);
9850 if (! DECL_ABSTRACT (node
))
9851 add_location_or_const_value_attribute (parm_die
, node
);
9856 /* We were called with some kind of a ..._TYPE node. */
9857 add_type_attribute (parm_die
, node
, 0, 0, context_die
);
9867 /* Generate a special type of DIE used as a stand-in for a trailing ellipsis
9868 at the end of an (ANSI prototyped) formal parameters list. */
9871 gen_unspecified_parameters_die (decl_or_type
, context_die
)
9872 tree decl_or_type ATTRIBUTE_UNUSED
;
9873 dw_die_ref context_die
;
9875 new_die (DW_TAG_unspecified_parameters
, context_die
);
9878 /* Generate a list of nameless DW_TAG_formal_parameter DIEs (and perhaps a
9879 DW_TAG_unspecified_parameters DIE) to represent the types of the formal
9880 parameters as specified in some function type specification (except for
9881 those which appear as part of a function *definition*). */
9884 gen_formal_types_die (function_or_method_type
, context_die
)
9885 tree function_or_method_type
;
9886 dw_die_ref context_die
;
9889 tree formal_type
= NULL
;
9890 tree first_parm_type
;
9893 if (TREE_CODE (function_or_method_type
) == FUNCTION_DECL
)
9895 arg
= DECL_ARGUMENTS (function_or_method_type
);
9896 function_or_method_type
= TREE_TYPE (function_or_method_type
);
9901 first_parm_type
= TYPE_ARG_TYPES (function_or_method_type
);
9903 /* Make our first pass over the list of formal parameter types and output a
9904 DW_TAG_formal_parameter DIE for each one. */
9905 for (link
= first_parm_type
; link
; )
9907 dw_die_ref parm_die
;
9909 formal_type
= TREE_VALUE (link
);
9910 if (formal_type
== void_type_node
)
9913 /* Output a (nameless) DIE to represent the formal parameter itself. */
9914 parm_die
= gen_formal_parameter_die (formal_type
, context_die
);
9915 if ((TREE_CODE (function_or_method_type
) == METHOD_TYPE
9916 && link
== first_parm_type
)
9917 || (arg
&& DECL_ARTIFICIAL (arg
)))
9918 add_AT_flag (parm_die
, DW_AT_artificial
, 1);
9920 link
= TREE_CHAIN (link
);
9922 arg
= TREE_CHAIN (arg
);
9925 /* If this function type has an ellipsis, add a
9926 DW_TAG_unspecified_parameters DIE to the end of the parameter list. */
9927 if (formal_type
!= void_type_node
)
9928 gen_unspecified_parameters_die (function_or_method_type
, context_die
);
9930 /* Make our second (and final) pass over the list of formal parameter types
9931 and output DIEs to represent those types (as necessary). */
9932 for (link
= TYPE_ARG_TYPES (function_or_method_type
);
9934 link
= TREE_CHAIN (link
))
9936 formal_type
= TREE_VALUE (link
);
9937 if (formal_type
== void_type_node
)
9940 gen_type_die (formal_type
, context_die
);
9944 /* We want to generate the DIE for TYPE so that we can generate the
9945 die for MEMBER, which has been defined; we will need to refer back
9946 to the member declaration nested within TYPE. If we're trying to
9947 generate minimal debug info for TYPE, processing TYPE won't do the
9948 trick; we need to attach the member declaration by hand. */
9951 gen_type_die_for_member (type
, member
, context_die
)
9953 dw_die_ref context_die
;
9955 gen_type_die (type
, context_die
);
9957 /* If we're trying to avoid duplicate debug info, we may not have
9958 emitted the member decl for this function. Emit it now. */
9959 if (TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type
))
9960 && ! lookup_decl_die (member
))
9962 if (decl_ultimate_origin (member
))
9965 push_decl_scope (type
);
9966 if (TREE_CODE (member
) == FUNCTION_DECL
)
9967 gen_subprogram_die (member
, lookup_type_die (type
));
9969 gen_variable_die (member
, lookup_type_die (type
));
9974 /* Generate the DWARF2 info for the "abstract" instance
9975 of a function which we may later generate inlined and/or
9976 out-of-line instances of. */
9979 dwarf2out_abstract_function (decl
)
9985 int was_abstract
= DECL_ABSTRACT (decl
);
9987 /* Make sure we have the actual abstract inline, not a clone. */
9988 decl
= DECL_ORIGIN (decl
);
9990 old_die
= lookup_decl_die (decl
);
9991 if (old_die
&& get_AT_unsigned (old_die
, DW_AT_inline
))
9992 /* We've already generated the abstract instance. */
9995 /* Be sure we've emitted the in-class declaration DIE (if any) first, so
9996 we don't get confused by DECL_ABSTRACT. */
9997 if (debug_info_level
> DINFO_LEVEL_TERSE
)
9999 context
= decl_class_context (decl
);
10001 gen_type_die_for_member
10002 (context
, decl
, decl_function_context (decl
) ? NULL
: comp_unit_die
);
10005 /* Pretend we've just finished compiling this function. */
10006 save_fn
= current_function_decl
;
10007 current_function_decl
= decl
;
10009 set_decl_abstract_flags (decl
, 1);
10010 dwarf2out_decl (decl
);
10011 if (! was_abstract
)
10012 set_decl_abstract_flags (decl
, 0);
10014 current_function_decl
= save_fn
;
10017 /* Generate a DIE to represent a declared function (either file-scope or
10021 gen_subprogram_die (decl
, context_die
)
10023 dw_die_ref context_die
;
10025 char label_id
[MAX_ARTIFICIAL_LABEL_BYTES
];
10026 tree origin
= decl_ultimate_origin (decl
);
10027 dw_die_ref subr_die
;
10031 dw_die_ref old_die
= lookup_decl_die (decl
);
10032 int declaration
= (current_function_decl
!= decl
10033 || class_scope_p (context_die
));
10035 /* Note that it is possible to have both DECL_ABSTRACT and `declaration'
10036 be true, if we started to generate the abstract instance of an inline,
10037 decided to output its containing class, and proceeded to emit the
10038 declaration of the inline from the member list for the class. In that
10039 case, `declaration' takes priority; we'll get back to the abstract
10040 instance when we're done with the class. */
10042 /* The class-scope declaration DIE must be the primary DIE. */
10043 if (origin
&& declaration
&& class_scope_p (context_die
))
10050 if (origin
!= NULL
)
10052 if (declaration
&& ! local_scope_p (context_die
))
10055 /* Fixup die_parent for the abstract instance of a nested
10056 inline function. */
10057 if (old_die
&& old_die
->die_parent
== NULL
)
10058 add_child_die (context_die
, old_die
);
10060 subr_die
= new_die (DW_TAG_subprogram
, context_die
);
10061 add_abstract_origin_attribute (subr_die
, origin
);
10065 unsigned file_index
= lookup_filename (DECL_SOURCE_FILE (decl
));
10067 if (!get_AT_flag (old_die
, DW_AT_declaration
)
10068 /* We can have a normal definition following an inline one in the
10069 case of redefinition of GNU C extern inlines.
10070 It seems reasonable to use AT_specification in this case. */
10071 && !get_AT_unsigned (old_die
, DW_AT_inline
))
10073 /* ??? This can happen if there is a bug in the program, for
10074 instance, if it has duplicate function definitions. Ideally,
10075 we should detect this case and ignore it. For now, if we have
10076 already reported an error, any error at all, then assume that
10077 we got here because of an input error, not a dwarf2 bug. */
10083 /* If the definition comes from the same place as the declaration,
10084 maybe use the old DIE. We always want the DIE for this function
10085 that has the *_pc attributes to be under comp_unit_die so the
10086 debugger can find it. We also need to do this for abstract
10087 instances of inlines, since the spec requires the out-of-line copy
10088 to have the same parent. For local class methods, this doesn't
10089 apply; we just use the old DIE. */
10090 if ((old_die
->die_parent
== comp_unit_die
|| context_die
== NULL
)
10091 && (DECL_ARTIFICIAL (decl
)
10092 || (get_AT_unsigned (old_die
, DW_AT_decl_file
) == file_index
10093 && (get_AT_unsigned (old_die
, DW_AT_decl_line
)
10094 == (unsigned) DECL_SOURCE_LINE (decl
)))))
10096 subr_die
= old_die
;
10098 /* Clear out the declaration attribute and the parm types. */
10099 remove_AT (subr_die
, DW_AT_declaration
);
10100 remove_children (subr_die
);
10104 subr_die
= new_die (DW_TAG_subprogram
, context_die
);
10105 add_AT_die_ref (subr_die
, DW_AT_specification
, old_die
);
10106 if (get_AT_unsigned (old_die
, DW_AT_decl_file
) != file_index
)
10107 add_AT_unsigned (subr_die
, DW_AT_decl_file
, file_index
);
10108 if (get_AT_unsigned (old_die
, DW_AT_decl_line
)
10109 != (unsigned) DECL_SOURCE_LINE (decl
))
10111 (subr_die
, DW_AT_decl_line
, DECL_SOURCE_LINE (decl
));
10116 subr_die
= new_die (DW_TAG_subprogram
, context_die
);
10118 if (TREE_PUBLIC (decl
))
10119 add_AT_flag (subr_die
, DW_AT_external
, 1);
10121 add_name_and_src_coords_attributes (subr_die
, decl
);
10122 if (debug_info_level
> DINFO_LEVEL_TERSE
)
10124 tree type
= TREE_TYPE (decl
);
10126 add_prototyped_attribute (subr_die
, type
);
10127 add_type_attribute (subr_die
, TREE_TYPE (type
), 0, 0, context_die
);
10130 add_pure_or_virtual_attribute (subr_die
, decl
);
10131 if (DECL_ARTIFICIAL (decl
))
10132 add_AT_flag (subr_die
, DW_AT_artificial
, 1);
10133 if (TREE_PROTECTED (decl
))
10134 add_AT_unsigned (subr_die
, DW_AT_accessibility
, DW_ACCESS_protected
);
10135 else if (TREE_PRIVATE (decl
))
10136 add_AT_unsigned (subr_die
, DW_AT_accessibility
, DW_ACCESS_private
);
10141 if (!(old_die
&& get_AT_unsigned (old_die
, DW_AT_inline
)))
10143 add_AT_flag (subr_die
, DW_AT_declaration
, 1);
10145 /* The first time we see a member function, it is in the context of
10146 the class to which it belongs. We make sure of this by emitting
10147 the class first. The next time is the definition, which is
10148 handled above. The two may come from the same source text. */
10149 if (DECL_CONTEXT (decl
) || DECL_ABSTRACT (decl
))
10150 equate_decl_number_to_die (decl
, subr_die
);
10153 else if (DECL_ABSTRACT (decl
))
10155 if (DECL_INLINE (decl
) && !flag_no_inline
)
10157 /* ??? Checking DECL_DEFER_OUTPUT is correct for static
10158 inline functions, but not for extern inline functions.
10159 We can't get this completely correct because information
10160 about whether the function was declared inline is not
10162 if (DECL_DEFER_OUTPUT (decl
))
10163 add_AT_unsigned (subr_die
, DW_AT_inline
, DW_INL_declared_inlined
);
10165 add_AT_unsigned (subr_die
, DW_AT_inline
, DW_INL_inlined
);
10168 add_AT_unsigned (subr_die
, DW_AT_inline
, DW_INL_declared_not_inlined
);
10170 equate_decl_number_to_die (decl
, subr_die
);
10172 else if (!DECL_EXTERNAL (decl
))
10174 if (!(old_die
&& get_AT_unsigned (old_die
, DW_AT_inline
)))
10175 equate_decl_number_to_die (decl
, subr_die
);
10177 ASM_GENERATE_INTERNAL_LABEL (label_id
, FUNC_BEGIN_LABEL
,
10178 current_funcdef_number
);
10179 add_AT_lbl_id (subr_die
, DW_AT_low_pc
, label_id
);
10180 ASM_GENERATE_INTERNAL_LABEL (label_id
, FUNC_END_LABEL
,
10181 current_funcdef_number
);
10182 add_AT_lbl_id (subr_die
, DW_AT_high_pc
, label_id
);
10184 add_pubname (decl
, subr_die
);
10185 add_arange (decl
, subr_die
);
10187 #ifdef MIPS_DEBUGGING_INFO
10188 /* Add a reference to the FDE for this routine. */
10189 add_AT_fde_ref (subr_die
, DW_AT_MIPS_fde
, current_funcdef_fde
);
10192 /* Define the "frame base" location for this routine. We use the
10193 frame pointer or stack pointer registers, since the RTL for local
10194 variables is relative to one of them. */
10196 = frame_pointer_needed
? hard_frame_pointer_rtx
: stack_pointer_rtx
;
10197 add_AT_loc (subr_die
, DW_AT_frame_base
, reg_loc_descriptor (fp_reg
));
10200 /* ??? This fails for nested inline functions, because context_display
10201 is not part of the state saved/restored for inline functions. */
10202 if (current_function_needs_context
)
10203 add_AT_location_description (subr_die
, DW_AT_static_link
,
10204 lookup_static_chain (decl
));
10208 /* Now output descriptions of the arguments for this function. This gets
10209 (unnecessarily?) complex because of the fact that the DECL_ARGUMENT list
10210 for a FUNCTION_DECL doesn't indicate cases where there was a trailing
10211 `...' at the end of the formal parameter list. In order to find out if
10212 there was a trailing ellipsis or not, we must instead look at the type
10213 associated with the FUNCTION_DECL. This will be a node of type
10214 FUNCTION_TYPE. If the chain of type nodes hanging off of this
10215 FUNCTION_TYPE node ends with a void_type_node then there should *not* be
10216 an ellipsis at the end. */
10218 /* In the case where we are describing a mere function declaration, all we
10219 need to do here (and all we *can* do here) is to describe the *types* of
10220 its formal parameters. */
10221 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
10223 else if (declaration
)
10224 gen_formal_types_die (decl
, subr_die
);
10227 /* Generate DIEs to represent all known formal parameters */
10228 tree arg_decls
= DECL_ARGUMENTS (decl
);
10231 /* When generating DIEs, generate the unspecified_parameters DIE
10232 instead if we come across the arg "__builtin_va_alist" */
10233 for (parm
= arg_decls
; parm
; parm
= TREE_CHAIN (parm
))
10234 if (TREE_CODE (parm
) == PARM_DECL
)
10236 if (DECL_NAME (parm
)
10237 && !strcmp (IDENTIFIER_POINTER (DECL_NAME (parm
)),
10238 "__builtin_va_alist"))
10239 gen_unspecified_parameters_die (parm
, subr_die
);
10241 gen_decl_die (parm
, subr_die
);
10244 /* Decide whether we need an unspecified_parameters DIE at the end.
10245 There are 2 more cases to do this for: 1) the ansi ... declaration -
10246 this is detectable when the end of the arg list is not a
10247 void_type_node 2) an unprototyped function declaration (not a
10248 definition). This just means that we have no info about the
10249 parameters at all. */
10250 fn_arg_types
= TYPE_ARG_TYPES (TREE_TYPE (decl
));
10251 if (fn_arg_types
!= NULL
)
10253 /* this is the prototyped case, check for ... */
10254 if (TREE_VALUE (tree_last (fn_arg_types
)) != void_type_node
)
10255 gen_unspecified_parameters_die (decl
, subr_die
);
10257 else if (DECL_INITIAL (decl
) == NULL_TREE
)
10258 gen_unspecified_parameters_die (decl
, subr_die
);
10261 /* Output Dwarf info for all of the stuff within the body of the function
10262 (if it has one - it may be just a declaration). */
10263 outer_scope
= DECL_INITIAL (decl
);
10265 /* Note that here, `outer_scope' is a pointer to the outermost BLOCK
10266 node created to represent a function. This outermost BLOCK actually
10267 represents the outermost binding contour for the function, i.e. the
10268 contour in which the function's formal parameters and labels get
10269 declared. Curiously, it appears that the front end doesn't actually
10270 put the PARM_DECL nodes for the current function onto the BLOCK_VARS
10271 list for this outer scope. (They are strung off of the DECL_ARGUMENTS
10272 list for the function instead.) The BLOCK_VARS list for the
10273 `outer_scope' does provide us with a list of the LABEL_DECL nodes for
10274 the function however, and we output DWARF info for those in
10275 decls_for_scope. Just within the `outer_scope' there will be a BLOCK
10276 node representing the function's outermost pair of curly braces, and
10277 any blocks used for the base and member initializers of a C++
10278 constructor function. */
10279 if (! declaration
&& TREE_CODE (outer_scope
) != ERROR_MARK
)
10281 current_function_has_inlines
= 0;
10282 decls_for_scope (outer_scope
, subr_die
, 0);
10284 #if 0 && defined (MIPS_DEBUGGING_INFO)
10285 if (current_function_has_inlines
)
10287 add_AT_flag (subr_die
, DW_AT_MIPS_has_inlines
, 1);
10288 if (! comp_unit_has_inlines
)
10290 add_AT_flag (comp_unit_die
, DW_AT_MIPS_has_inlines
, 1);
10291 comp_unit_has_inlines
= 1;
10298 /* Generate a DIE to represent a declared data object. */
10301 gen_variable_die (decl
, context_die
)
10303 dw_die_ref context_die
;
10305 tree origin
= decl_ultimate_origin (decl
);
10306 dw_die_ref var_die
= new_die (DW_TAG_variable
, context_die
);
10308 dw_die_ref old_die
= lookup_decl_die (decl
);
10309 int declaration
= (DECL_EXTERNAL (decl
)
10310 || class_scope_p (context_die
));
10312 if (origin
!= NULL
)
10313 add_abstract_origin_attribute (var_die
, origin
);
10314 /* Loop unrolling can create multiple blocks that refer to the same
10315 static variable, so we must test for the DW_AT_declaration flag. */
10316 /* ??? Loop unrolling/reorder_blocks should perhaps be rewritten to
10317 copy decls and set the DECL_ABSTRACT flag on them instead of
10319 /* ??? Duplicated blocks have been rewritten to use .debug_ranges. */
10320 else if (old_die
&& TREE_STATIC (decl
)
10321 && get_AT_flag (old_die
, DW_AT_declaration
) == 1)
10323 /* This is a definition of a C++ class level static. */
10324 add_AT_die_ref (var_die
, DW_AT_specification
, old_die
);
10325 if (DECL_NAME (decl
))
10327 unsigned file_index
= lookup_filename (DECL_SOURCE_FILE (decl
));
10329 if (get_AT_unsigned (old_die
, DW_AT_decl_file
) != file_index
)
10330 add_AT_unsigned (var_die
, DW_AT_decl_file
, file_index
);
10332 if (get_AT_unsigned (old_die
, DW_AT_decl_line
)
10333 != (unsigned) DECL_SOURCE_LINE (decl
))
10335 add_AT_unsigned (var_die
, DW_AT_decl_line
,
10336 DECL_SOURCE_LINE (decl
));
10341 add_name_and_src_coords_attributes (var_die
, decl
);
10342 add_type_attribute (var_die
, TREE_TYPE (decl
),
10343 TREE_READONLY (decl
),
10344 TREE_THIS_VOLATILE (decl
), context_die
);
10346 if (TREE_PUBLIC (decl
))
10347 add_AT_flag (var_die
, DW_AT_external
, 1);
10349 if (DECL_ARTIFICIAL (decl
))
10350 add_AT_flag (var_die
, DW_AT_artificial
, 1);
10352 if (TREE_PROTECTED (decl
))
10353 add_AT_unsigned (var_die
, DW_AT_accessibility
, DW_ACCESS_protected
);
10355 else if (TREE_PRIVATE (decl
))
10356 add_AT_unsigned (var_die
, DW_AT_accessibility
, DW_ACCESS_private
);
10360 add_AT_flag (var_die
, DW_AT_declaration
, 1);
10362 if (class_scope_p (context_die
) || DECL_ABSTRACT (decl
))
10363 equate_decl_number_to_die (decl
, var_die
);
10365 if (! declaration
&& ! DECL_ABSTRACT (decl
))
10367 add_location_or_const_value_attribute (var_die
, decl
);
10368 add_pubname (decl
, var_die
);
10371 tree_add_const_value_attribute (var_die
, decl
);
10374 /* Generate a DIE to represent a label identifier. */
10377 gen_label_die (decl
, context_die
)
10379 dw_die_ref context_die
;
10381 tree origin
= decl_ultimate_origin (decl
);
10382 dw_die_ref lbl_die
= new_die (DW_TAG_label
, context_die
);
10384 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
10386 if (origin
!= NULL
)
10387 add_abstract_origin_attribute (lbl_die
, origin
);
10389 add_name_and_src_coords_attributes (lbl_die
, decl
);
10391 if (DECL_ABSTRACT (decl
))
10392 equate_decl_number_to_die (decl
, lbl_die
);
10395 insn
= DECL_RTL (decl
);
10397 /* Deleted labels are programmer specified labels which have been
10398 eliminated because of various optimisations. We still emit them
10399 here so that it is possible to put breakpoints on them. */
10400 if (GET_CODE (insn
) == CODE_LABEL
10401 || ((GET_CODE (insn
) == NOTE
10402 && NOTE_LINE_NUMBER (insn
) == NOTE_INSN_DELETED_LABEL
)))
10404 /* When optimization is enabled (via -O) some parts of the compiler
10405 (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
10406 represent source-level labels which were explicitly declared by
10407 the user. This really shouldn't be happening though, so catch
10408 it if it ever does happen. */
10409 if (INSN_DELETED_P (insn
))
10412 ASM_GENERATE_INTERNAL_LABEL (label
, "L", CODE_LABEL_NUMBER (insn
));
10413 add_AT_lbl_id (lbl_die
, DW_AT_low_pc
, label
);
10418 /* Generate a DIE for a lexical block. */
10421 gen_lexical_block_die (stmt
, context_die
, depth
)
10423 dw_die_ref context_die
;
10426 dw_die_ref stmt_die
= new_die (DW_TAG_lexical_block
, context_die
);
10427 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
10429 if (! BLOCK_ABSTRACT (stmt
))
10431 if (BLOCK_FRAGMENT_CHAIN (stmt
))
10435 add_AT_range_list (stmt_die
, DW_AT_ranges
, add_ranges (stmt
));
10437 chain
= BLOCK_FRAGMENT_CHAIN (stmt
);
10440 add_ranges (chain
);
10441 chain
= BLOCK_FRAGMENT_CHAIN (chain
);
10448 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_BEGIN_LABEL
,
10449 BLOCK_NUMBER (stmt
));
10450 add_AT_lbl_id (stmt_die
, DW_AT_low_pc
, label
);
10451 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_END_LABEL
,
10452 BLOCK_NUMBER (stmt
));
10453 add_AT_lbl_id (stmt_die
, DW_AT_high_pc
, label
);
10457 decls_for_scope (stmt
, stmt_die
, depth
);
10460 /* Generate a DIE for an inlined subprogram. */
10463 gen_inlined_subroutine_die (stmt
, context_die
, depth
)
10465 dw_die_ref context_die
;
10468 if (! BLOCK_ABSTRACT (stmt
))
10470 dw_die_ref subr_die
10471 = new_die (DW_TAG_inlined_subroutine
, context_die
);
10472 tree decl
= block_ultimate_origin (stmt
);
10473 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
10475 /* Emit info for the abstract instance first, if we haven't yet. */
10476 dwarf2out_abstract_function (decl
);
10478 add_abstract_origin_attribute (subr_die
, decl
);
10479 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_BEGIN_LABEL
,
10480 BLOCK_NUMBER (stmt
));
10481 add_AT_lbl_id (subr_die
, DW_AT_low_pc
, label
);
10482 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_END_LABEL
,
10483 BLOCK_NUMBER (stmt
));
10484 add_AT_lbl_id (subr_die
, DW_AT_high_pc
, label
);
10485 decls_for_scope (stmt
, subr_die
, depth
);
10486 current_function_has_inlines
= 1;
10490 /* Generate a DIE for a field in a record, or structure. */
10493 gen_field_die (decl
, context_die
)
10495 dw_die_ref context_die
;
10497 dw_die_ref decl_die
= new_die (DW_TAG_member
, context_die
);
10499 add_name_and_src_coords_attributes (decl_die
, decl
);
10500 add_type_attribute (decl_die
, member_declared_type (decl
),
10501 TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
),
10504 /* If this is a bit field... */
10505 if (DECL_BIT_FIELD_TYPE (decl
))
10507 add_byte_size_attribute (decl_die
, decl
);
10508 add_bit_size_attribute (decl_die
, decl
);
10509 add_bit_offset_attribute (decl_die
, decl
);
10512 if (TREE_CODE (DECL_FIELD_CONTEXT (decl
)) != UNION_TYPE
)
10513 add_data_member_location_attribute (decl_die
, decl
);
10515 if (DECL_ARTIFICIAL (decl
))
10516 add_AT_flag (decl_die
, DW_AT_artificial
, 1);
10518 if (TREE_PROTECTED (decl
))
10519 add_AT_unsigned (decl_die
, DW_AT_accessibility
, DW_ACCESS_protected
);
10521 else if (TREE_PRIVATE (decl
))
10522 add_AT_unsigned (decl_die
, DW_AT_accessibility
, DW_ACCESS_private
);
10526 /* Don't generate either pointer_type DIEs or reference_type DIEs here.
10527 Use modified_type_die instead.
10528 We keep this code here just in case these types of DIEs may be needed to
10529 represent certain things in other languages (e.g. Pascal) someday. */
10531 gen_pointer_type_die (type
, context_die
)
10533 dw_die_ref context_die
;
10536 = new_die (DW_TAG_pointer_type
, scope_die_for (type
, context_die
));
10538 equate_type_number_to_die (type
, ptr_die
);
10539 add_type_attribute (ptr_die
, TREE_TYPE (type
), 0, 0, context_die
);
10540 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
10543 /* Don't generate either pointer_type DIEs or reference_type DIEs here.
10544 Use modified_type_die instead.
10545 We keep this code here just in case these types of DIEs may be needed to
10546 represent certain things in other languages (e.g. Pascal) someday. */
10548 gen_reference_type_die (type
, context_die
)
10550 dw_die_ref context_die
;
10553 = new_die (DW_TAG_reference_type
, scope_die_for (type
, context_die
));
10555 equate_type_number_to_die (type
, ref_die
);
10556 add_type_attribute (ref_die
, TREE_TYPE (type
), 0, 0, context_die
);
10557 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
10561 /* Generate a DIE for a pointer to a member type. */
10563 gen_ptr_to_mbr_type_die (type
, context_die
)
10565 dw_die_ref context_die
;
10568 = new_die (DW_TAG_ptr_to_member_type
, scope_die_for (type
, context_die
));
10570 equate_type_number_to_die (type
, ptr_die
);
10571 add_AT_die_ref (ptr_die
, DW_AT_containing_type
,
10572 lookup_type_die (TYPE_OFFSET_BASETYPE (type
)));
10573 add_type_attribute (ptr_die
, TREE_TYPE (type
), 0, 0, context_die
);
10576 /* Generate the DIE for the compilation unit. */
10579 gen_compile_unit_die (filename
)
10580 const char *filename
;
10583 char producer
[250];
10584 const char *wd
= getpwd ();
10585 const char *language_string
= lang_hooks
.name
;
10588 die
= new_die (DW_TAG_compile_unit
, NULL
);
10589 add_name_attribute (die
, filename
);
10591 if (wd
!= NULL
&& filename
[0] != DIR_SEPARATOR
)
10592 add_AT_string (die
, DW_AT_comp_dir
, wd
);
10594 sprintf (producer
, "%s %s", language_string
, version_string
);
10596 #ifdef MIPS_DEBUGGING_INFO
10597 /* The MIPS/SGI compilers place the 'cc' command line options in the producer
10598 string. The SGI debugger looks for -g, -g1, -g2, or -g3; if they do
10599 not appear in the producer string, the debugger reaches the conclusion
10600 that the object file is stripped and has no debugging information.
10601 To get the MIPS/SGI debugger to believe that there is debugging
10602 information in the object file, we add a -g to the producer string. */
10603 if (debug_info_level
> DINFO_LEVEL_TERSE
)
10604 strcat (producer
, " -g");
10607 add_AT_string (die
, DW_AT_producer
, producer
);
10609 if (strcmp (language_string
, "GNU C++") == 0)
10610 language
= DW_LANG_C_plus_plus
;
10611 else if (strcmp (language_string
, "GNU Ada") == 0)
10612 language
= DW_LANG_Ada83
;
10613 else if (strcmp (language_string
, "GNU F77") == 0)
10614 language
= DW_LANG_Fortran77
;
10615 else if (strcmp (language_string
, "GNU Pascal") == 0)
10616 language
= DW_LANG_Pascal83
;
10617 else if (strcmp (language_string
, "GNU Java") == 0)
10618 language
= DW_LANG_Java
;
10619 else if (flag_traditional
)
10620 language
= DW_LANG_C
;
10622 language
= DW_LANG_C89
;
10624 add_AT_unsigned (die
, DW_AT_language
, language
);
10629 /* Generate a DIE for a string type. */
10632 gen_string_type_die (type
, context_die
)
10634 dw_die_ref context_die
;
10636 dw_die_ref type_die
10637 = new_die (DW_TAG_string_type
, scope_die_for (type
, context_die
));
10639 equate_type_number_to_die (type
, type_die
);
10641 /* Fudge the string length attribute for now. */
10643 /* TODO: add string length info.
10644 string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
10645 bound_representation (upper_bound, 0, 'u'); */
10648 /* Generate the DIE for a base class. */
10651 gen_inheritance_die (binfo
, context_die
)
10653 dw_die_ref context_die
;
10655 dw_die_ref die
= new_die (DW_TAG_inheritance
, context_die
);
10657 add_type_attribute (die
, BINFO_TYPE (binfo
), 0, 0, context_die
);
10658 add_data_member_location_attribute (die
, binfo
);
10660 if (TREE_VIA_VIRTUAL (binfo
))
10661 add_AT_unsigned (die
, DW_AT_virtuality
, DW_VIRTUALITY_virtual
);
10662 if (TREE_VIA_PUBLIC (binfo
))
10663 add_AT_unsigned (die
, DW_AT_accessibility
, DW_ACCESS_public
);
10664 else if (TREE_VIA_PROTECTED (binfo
))
10665 add_AT_unsigned (die
, DW_AT_accessibility
, DW_ACCESS_protected
);
10668 /* Generate a DIE for a class member. */
10671 gen_member_die (type
, context_die
)
10673 dw_die_ref context_die
;
10678 /* If this is not an incomplete type, output descriptions of each of its
10679 members. Note that as we output the DIEs necessary to represent the
10680 members of this record or union type, we will also be trying to output
10681 DIEs to represent the *types* of those members. However the `type'
10682 function (above) will specifically avoid generating type DIEs for member
10683 types *within* the list of member DIEs for this (containing) type except
10684 for those types (of members) which are explicitly marked as also being
10685 members of this (containing) type themselves. The g++ front- end can
10686 force any given type to be treated as a member of some other
10687 (containing) type by setting the TYPE_CONTEXT of the given (member) type
10688 to point to the TREE node representing the appropriate (containing)
10691 /* First output info about the base classes. */
10692 if (TYPE_BINFO (type
) && TYPE_BINFO_BASETYPES (type
))
10694 tree bases
= TYPE_BINFO_BASETYPES (type
);
10695 int n_bases
= TREE_VEC_LENGTH (bases
);
10698 for (i
= 0; i
< n_bases
; i
++)
10699 gen_inheritance_die (TREE_VEC_ELT (bases
, i
), context_die
);
10702 /* Now output info about the data members and type members. */
10703 for (member
= TYPE_FIELDS (type
); member
; member
= TREE_CHAIN (member
))
10705 /* If we thought we were generating minimal debug info for TYPE
10706 and then changed our minds, some of the member declarations
10707 may have already been defined. Don't define them again, but
10708 do put them in the right order. */
10710 child
= lookup_decl_die (member
);
10712 splice_child_die (context_die
, child
);
10714 gen_decl_die (member
, context_die
);
10717 /* Now output info about the function members (if any). */
10718 for (member
= TYPE_METHODS (type
); member
; member
= TREE_CHAIN (member
))
10720 /* Don't include clones in the member list. */
10721 if (DECL_ABSTRACT_ORIGIN (member
))
10724 child
= lookup_decl_die (member
);
10726 splice_child_die (context_die
, child
);
10728 gen_decl_die (member
, context_die
);
10732 /* Generate a DIE for a structure or union type. If TYPE_DECL_SUPPRESS_DEBUG
10733 is set, we pretend that the type was never defined, so we only get the
10734 member DIEs needed by later specification DIEs. */
10737 gen_struct_or_union_type_die (type
, context_die
)
10739 dw_die_ref context_die
;
10741 dw_die_ref type_die
= lookup_type_die (type
);
10742 dw_die_ref scope_die
= 0;
10744 int complete
= (TYPE_SIZE (type
)
10745 && (! TYPE_STUB_DECL (type
)
10746 || ! TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type
))));
10748 if (type_die
&& ! complete
)
10751 if (TYPE_CONTEXT (type
) != NULL_TREE
10752 && AGGREGATE_TYPE_P (TYPE_CONTEXT (type
)))
10755 scope_die
= scope_die_for (type
, context_die
);
10757 if (! type_die
|| (nested
&& scope_die
== comp_unit_die
))
10758 /* First occurrence of type or toplevel definition of nested class. */
10760 dw_die_ref old_die
= type_die
;
10762 type_die
= new_die (TREE_CODE (type
) == RECORD_TYPE
10763 ? DW_TAG_structure_type
: DW_TAG_union_type
,
10765 equate_type_number_to_die (type
, type_die
);
10767 add_AT_die_ref (type_die
, DW_AT_specification
, old_die
);
10769 add_name_attribute (type_die
, type_tag (type
));
10772 remove_AT (type_die
, DW_AT_declaration
);
10774 /* If this type has been completed, then give it a byte_size attribute and
10775 then give a list of members. */
10778 /* Prevent infinite recursion in cases where the type of some member of
10779 this type is expressed in terms of this type itself. */
10780 TREE_ASM_WRITTEN (type
) = 1;
10781 add_byte_size_attribute (type_die
, type
);
10782 if (TYPE_STUB_DECL (type
) != NULL_TREE
)
10783 add_src_coords_attributes (type_die
, TYPE_STUB_DECL (type
));
10785 /* If the first reference to this type was as the return type of an
10786 inline function, then it may not have a parent. Fix this now. */
10787 if (type_die
->die_parent
== NULL
)
10788 add_child_die (scope_die
, type_die
);
10790 push_decl_scope (type
);
10791 gen_member_die (type
, type_die
);
10794 /* GNU extension: Record what type our vtable lives in. */
10795 if (TYPE_VFIELD (type
))
10797 tree vtype
= DECL_FCONTEXT (TYPE_VFIELD (type
));
10799 gen_type_die (vtype
, context_die
);
10800 add_AT_die_ref (type_die
, DW_AT_containing_type
,
10801 lookup_type_die (vtype
));
10806 add_AT_flag (type_die
, DW_AT_declaration
, 1);
10808 /* We don't need to do this for function-local types. */
10809 if (! decl_function_context (TYPE_STUB_DECL (type
)))
10810 add_incomplete_type (type
);
10814 /* Generate a DIE for a subroutine _type_. */
10817 gen_subroutine_type_die (type
, context_die
)
10819 dw_die_ref context_die
;
10821 tree return_type
= TREE_TYPE (type
);
10822 dw_die_ref subr_die
10823 = new_die (DW_TAG_subroutine_type
, scope_die_for (type
, context_die
));
10825 equate_type_number_to_die (type
, subr_die
);
10826 add_prototyped_attribute (subr_die
, type
);
10827 add_type_attribute (subr_die
, return_type
, 0, 0, context_die
);
10828 gen_formal_types_die (type
, subr_die
);
10831 /* Generate a DIE for a type definition */
10834 gen_typedef_die (decl
, context_die
)
10836 dw_die_ref context_die
;
10838 dw_die_ref type_die
;
10841 if (TREE_ASM_WRITTEN (decl
))
10843 TREE_ASM_WRITTEN (decl
) = 1;
10845 type_die
= new_die (DW_TAG_typedef
, context_die
);
10846 origin
= decl_ultimate_origin (decl
);
10847 if (origin
!= NULL
)
10848 add_abstract_origin_attribute (type_die
, origin
);
10852 add_name_and_src_coords_attributes (type_die
, decl
);
10853 if (DECL_ORIGINAL_TYPE (decl
))
10855 type
= DECL_ORIGINAL_TYPE (decl
);
10857 if (type
== TREE_TYPE (decl
))
10860 equate_type_number_to_die (TREE_TYPE (decl
), type_die
);
10863 type
= TREE_TYPE (decl
);
10864 add_type_attribute (type_die
, type
, TREE_READONLY (decl
),
10865 TREE_THIS_VOLATILE (decl
), context_die
);
10868 if (DECL_ABSTRACT (decl
))
10869 equate_decl_number_to_die (decl
, type_die
);
10872 /* Generate a type description DIE. */
10875 gen_type_die (type
, context_die
)
10877 dw_die_ref context_die
;
10881 if (type
== NULL_TREE
|| type
== error_mark_node
)
10884 /* We are going to output a DIE to represent the unqualified version of
10885 this type (i.e. without any const or volatile qualifiers) so get the
10886 main variant (i.e. the unqualified version) of this type now. */
10887 type
= type_main_variant (type
);
10889 if (TREE_ASM_WRITTEN (type
))
10892 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
10893 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
10895 TREE_ASM_WRITTEN (type
) = 1;
10896 gen_decl_die (TYPE_NAME (type
), context_die
);
10900 switch (TREE_CODE (type
))
10906 case REFERENCE_TYPE
:
10907 /* We must set TREE_ASM_WRITTEN in case this is a recursive type. This
10908 ensures that the gen_type_die recursion will terminate even if the
10909 type is recursive. Recursive types are possible in Ada. */
10910 /* ??? We could perhaps do this for all types before the switch
10912 TREE_ASM_WRITTEN (type
) = 1;
10914 /* For these types, all that is required is that we output a DIE (or a
10915 set of DIEs) to represent the "basis" type. */
10916 gen_type_die (TREE_TYPE (type
), context_die
);
10920 /* This code is used for C++ pointer-to-data-member types.
10921 Output a description of the relevant class type. */
10922 gen_type_die (TYPE_OFFSET_BASETYPE (type
), context_die
);
10924 /* Output a description of the type of the object pointed to. */
10925 gen_type_die (TREE_TYPE (type
), context_die
);
10927 /* Now output a DIE to represent this pointer-to-data-member type
10929 gen_ptr_to_mbr_type_die (type
, context_die
);
10933 gen_type_die (TYPE_DOMAIN (type
), context_die
);
10934 gen_set_type_die (type
, context_die
);
10938 gen_type_die (TREE_TYPE (type
), context_die
);
10939 abort (); /* No way to represent these in Dwarf yet! */
10942 case FUNCTION_TYPE
:
10943 /* Force out return type (in case it wasn't forced out already). */
10944 gen_type_die (TREE_TYPE (type
), context_die
);
10945 gen_subroutine_type_die (type
, context_die
);
10949 /* Force out return type (in case it wasn't forced out already). */
10950 gen_type_die (TREE_TYPE (type
), context_die
);
10951 gen_subroutine_type_die (type
, context_die
);
10955 if (TYPE_STRING_FLAG (type
) && TREE_CODE (TREE_TYPE (type
)) == CHAR_TYPE
)
10957 gen_type_die (TREE_TYPE (type
), context_die
);
10958 gen_string_type_die (type
, context_die
);
10961 gen_array_type_die (type
, context_die
);
10965 gen_type_die (TYPE_DEBUG_REPRESENTATION_TYPE (type
), context_die
);
10968 case ENUMERAL_TYPE
:
10971 case QUAL_UNION_TYPE
:
10972 /* If this is a nested type whose containing class hasn't been
10973 written out yet, writing it out will cover this one, too.
10974 This does not apply to instantiations of member class templates;
10975 they need to be added to the containing class as they are
10976 generated. FIXME: This hurts the idea of combining type decls
10977 from multiple TUs, since we can't predict what set of template
10978 instantiations we'll get. */
10979 if (TYPE_CONTEXT (type
)
10980 && AGGREGATE_TYPE_P (TYPE_CONTEXT (type
))
10981 && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type
)))
10983 gen_type_die (TYPE_CONTEXT (type
), context_die
);
10985 if (TREE_ASM_WRITTEN (type
))
10988 /* If that failed, attach ourselves to the stub. */
10989 push_decl_scope (TYPE_CONTEXT (type
));
10990 context_die
= lookup_type_die (TYPE_CONTEXT (type
));
10996 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
10997 gen_enumeration_type_die (type
, context_die
);
10999 gen_struct_or_union_type_die (type
, context_die
);
11004 /* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix
11005 it up if it is ever completed. gen_*_type_die will set it for us
11006 when appropriate. */
11015 /* No DIEs needed for fundamental types. */
11019 /* No Dwarf representation currently defined. */
11026 TREE_ASM_WRITTEN (type
) = 1;
11029 /* Generate a DIE for a tagged type instantiation. */
11032 gen_tagged_type_instantiation_die (type
, context_die
)
11034 dw_die_ref context_die
;
11036 if (type
== NULL_TREE
|| type
== error_mark_node
)
11039 /* We are going to output a DIE to represent the unqualified version of
11040 this type (i.e. without any const or volatile qualifiers) so make sure
11041 that we have the main variant (i.e. the unqualified version) of this
11043 if (type
!= type_main_variant (type
))
11046 /* Do not check TREE_ASM_WRITTEN (type) as it may not be set if this is
11047 an instance of an unresolved type. */
11049 switch (TREE_CODE (type
))
11054 case ENUMERAL_TYPE
:
11055 gen_inlined_enumeration_type_die (type
, context_die
);
11059 gen_inlined_structure_type_die (type
, context_die
);
11063 case QUAL_UNION_TYPE
:
11064 gen_inlined_union_type_die (type
, context_die
);
11072 /* Generate a DW_TAG_lexical_block DIE followed by DIEs to represent all of the
11073 things which are local to the given block. */
11076 gen_block_die (stmt
, context_die
, depth
)
11078 dw_die_ref context_die
;
11081 int must_output_die
= 0;
11084 enum tree_code origin_code
;
11086 /* Ignore blocks never really used to make RTL. */
11087 if (stmt
== NULL_TREE
|| !TREE_USED (stmt
)
11088 || (!TREE_ASM_WRITTEN (stmt
) && !BLOCK_ABSTRACT (stmt
)))
11091 /* If the block is one fragment of a non-contiguous block, do not
11092 process the variables, since they will have been done by the
11093 origin block. Do process subblocks. */
11094 if (BLOCK_FRAGMENT_ORIGIN (stmt
))
11098 for (sub
= BLOCK_SUBBLOCKS (stmt
); sub
; sub
= BLOCK_CHAIN (sub
))
11099 gen_block_die (sub
, context_die
, depth
+ 1);
11103 /* Determine the "ultimate origin" of this block. This block may be an
11104 inlined instance of an inlined instance of inline function, so we have
11105 to trace all of the way back through the origin chain to find out what
11106 sort of node actually served as the original seed for the creation of
11107 the current block. */
11108 origin
= block_ultimate_origin (stmt
);
11109 origin_code
= (origin
!= NULL
) ? TREE_CODE (origin
) : ERROR_MARK
;
11111 /* Determine if we need to output any Dwarf DIEs at all to represent this
11113 if (origin_code
== FUNCTION_DECL
)
11114 /* The outer scopes for inlinings *must* always be represented. We
11115 generate DW_TAG_inlined_subroutine DIEs for them. (See below.) */
11116 must_output_die
= 1;
11119 /* In the case where the current block represents an inlining of the
11120 "body block" of an inline function, we must *NOT* output any DIE for
11121 this block because we have already output a DIE to represent the
11122 whole inlined function scope and the "body block" of any function
11123 doesn't really represent a different scope according to ANSI C
11124 rules. So we check here to make sure that this block does not
11125 represent a "body block inlining" before trying to set the
11126 `must_output_die' flag. */
11127 if (! is_body_block (origin
? origin
: stmt
))
11129 /* Determine if this block directly contains any "significant"
11130 local declarations which we will need to output DIEs for. */
11131 if (debug_info_level
> DINFO_LEVEL_TERSE
)
11132 /* We are not in terse mode so *any* local declaration counts
11133 as being a "significant" one. */
11134 must_output_die
= (BLOCK_VARS (stmt
) != NULL
);
11136 /* We are in terse mode, so only local (nested) function
11137 definitions count as "significant" local declarations. */
11138 for (decl
= BLOCK_VARS (stmt
);
11139 decl
!= NULL
; decl
= TREE_CHAIN (decl
))
11140 if (TREE_CODE (decl
) == FUNCTION_DECL
11141 && DECL_INITIAL (decl
))
11143 must_output_die
= 1;
11149 /* It would be a waste of space to generate a Dwarf DW_TAG_lexical_block
11150 DIE for any block which contains no significant local declarations at
11151 all. Rather, in such cases we just call `decls_for_scope' so that any
11152 needed Dwarf info for any sub-blocks will get properly generated. Note
11153 that in terse mode, our definition of what constitutes a "significant"
11154 local declaration gets restricted to include only inlined function
11155 instances and local (nested) function definitions. */
11156 if (must_output_die
)
11158 if (origin_code
== FUNCTION_DECL
)
11159 gen_inlined_subroutine_die (stmt
, context_die
, depth
);
11161 gen_lexical_block_die (stmt
, context_die
, depth
);
11164 decls_for_scope (stmt
, context_die
, depth
);
11167 /* Generate all of the decls declared within a given scope and (recursively)
11168 all of its sub-blocks. */
11171 decls_for_scope (stmt
, context_die
, depth
)
11173 dw_die_ref context_die
;
11179 /* Ignore blocks never really used to make RTL. */
11180 if (stmt
== NULL_TREE
|| ! TREE_USED (stmt
))
11183 /* Output the DIEs to represent all of the data objects and typedefs
11184 declared directly within this block but not within any nested
11185 sub-blocks. Also, nested function and tag DIEs have been
11186 generated with a parent of NULL; fix that up now. */
11187 for (decl
= BLOCK_VARS (stmt
);
11188 decl
!= NULL
; decl
= TREE_CHAIN (decl
))
11192 if (TREE_CODE (decl
) == FUNCTION_DECL
)
11193 die
= lookup_decl_die (decl
);
11194 else if (TREE_CODE (decl
) == TYPE_DECL
&& TYPE_DECL_IS_STUB (decl
))
11195 die
= lookup_type_die (TREE_TYPE (decl
));
11199 if (die
!= NULL
&& die
->die_parent
== NULL
)
11200 add_child_die (context_die
, die
);
11202 gen_decl_die (decl
, context_die
);
11205 /* Output the DIEs to represent all sub-blocks (and the items declared
11206 therein) of this block. */
11207 for (subblocks
= BLOCK_SUBBLOCKS (stmt
);
11209 subblocks
= BLOCK_CHAIN (subblocks
))
11210 gen_block_die (subblocks
, context_die
, depth
+ 1);
11213 /* Is this a typedef we can avoid emitting? */
11216 is_redundant_typedef (decl
)
11219 if (TYPE_DECL_IS_STUB (decl
))
11222 if (DECL_ARTIFICIAL (decl
)
11223 && DECL_CONTEXT (decl
)
11224 && is_tagged_type (DECL_CONTEXT (decl
))
11225 && TREE_CODE (TYPE_NAME (DECL_CONTEXT (decl
))) == TYPE_DECL
11226 && DECL_NAME (decl
) == DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl
))))
11227 /* Also ignore the artificial member typedef for the class name. */
11233 /* Generate Dwarf debug information for a decl described by DECL. */
11236 gen_decl_die (decl
, context_die
)
11238 dw_die_ref context_die
;
11242 if (TREE_CODE (decl
) == ERROR_MARK
)
11245 /* If this ..._DECL node is marked to be ignored, then ignore it. */
11246 if (DECL_IGNORED_P (decl
))
11249 switch (TREE_CODE (decl
))
11252 /* The individual enumerators of an enum type get output when we output
11253 the Dwarf representation of the relevant enum type itself. */
11256 case FUNCTION_DECL
:
11257 /* Don't output any DIEs to represent mere function declarations,
11258 unless they are class members or explicit block externs. */
11259 if (DECL_INITIAL (decl
) == NULL_TREE
&& DECL_CONTEXT (decl
) == NULL_TREE
11260 && (current_function_decl
== NULL_TREE
|| DECL_ARTIFICIAL (decl
)))
11263 /* If we're emitting a clone, emit info for the abstract instance. */
11264 if (DECL_ORIGIN (decl
) != decl
)
11265 dwarf2out_abstract_function (DECL_ABSTRACT_ORIGIN (decl
));
11266 /* If we're emitting an out-of-line copy of an inline function,
11267 emit info for the abstract instance and set up to refer to it. */
11268 else if (DECL_INLINE (decl
) && ! DECL_ABSTRACT (decl
)
11269 && ! class_scope_p (context_die
)
11270 /* dwarf2out_abstract_function won't emit a die if this is just
11271 a declaration. We must avoid setting DECL_ABSTRACT_ORIGIN in
11272 that case, because that works only if we have a die. */
11273 && DECL_INITIAL (decl
) != NULL_TREE
)
11275 dwarf2out_abstract_function (decl
);
11276 set_decl_origin_self (decl
);
11278 /* Otherwise we're emitting the primary DIE for this decl. */
11279 else if (debug_info_level
> DINFO_LEVEL_TERSE
)
11281 /* Before we describe the FUNCTION_DECL itself, make sure that we
11282 have described its return type. */
11283 gen_type_die (TREE_TYPE (TREE_TYPE (decl
)), context_die
);
11285 /* And its virtual context. */
11286 if (DECL_VINDEX (decl
) != NULL_TREE
)
11287 gen_type_die (DECL_CONTEXT (decl
), context_die
);
11289 /* And its containing type. */
11290 origin
= decl_class_context (decl
);
11291 if (origin
!= NULL_TREE
)
11292 gen_type_die_for_member (origin
, decl
, context_die
);
11295 /* Now output a DIE to represent the function itself. */
11296 gen_subprogram_die (decl
, context_die
);
11300 /* If we are in terse mode, don't generate any DIEs to represent any
11301 actual typedefs. */
11302 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
11305 /* In the special case of a TYPE_DECL node representing the
11306 declaration of some type tag, if the given TYPE_DECL is marked as
11307 having been instantiated from some other (original) TYPE_DECL node
11308 (e.g. one which was generated within the original definition of an
11309 inline function) we have to generate a special (abbreviated)
11310 DW_TAG_structure_type, DW_TAG_union_type, or DW_TAG_enumeration_type
11312 if (TYPE_DECL_IS_STUB (decl
) && decl_ultimate_origin (decl
) != NULL_TREE
)
11314 gen_tagged_type_instantiation_die (TREE_TYPE (decl
), context_die
);
11318 if (is_redundant_typedef (decl
))
11319 gen_type_die (TREE_TYPE (decl
), context_die
);
11321 /* Output a DIE to represent the typedef itself. */
11322 gen_typedef_die (decl
, context_die
);
11326 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
11327 gen_label_die (decl
, context_die
);
11331 /* If we are in terse mode, don't generate any DIEs to represent any
11332 variable declarations or definitions. */
11333 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
11336 /* Output any DIEs that are needed to specify the type of this data
11338 gen_type_die (TREE_TYPE (decl
), context_die
);
11340 /* And its containing type. */
11341 origin
= decl_class_context (decl
);
11342 if (origin
!= NULL_TREE
)
11343 gen_type_die_for_member (origin
, decl
, context_die
);
11345 /* Now output the DIE to represent the data object itself. This gets
11346 complicated because of the possibility that the VAR_DECL really
11347 represents an inlined instance of a formal parameter for an inline
11349 origin
= decl_ultimate_origin (decl
);
11350 if (origin
!= NULL_TREE
&& TREE_CODE (origin
) == PARM_DECL
)
11351 gen_formal_parameter_die (decl
, context_die
);
11353 gen_variable_die (decl
, context_die
);
11357 /* Ignore the nameless fields that are used to skip bits, but
11358 handle C++ anonymous unions. */
11359 if (DECL_NAME (decl
) != NULL_TREE
11360 || TREE_CODE (TREE_TYPE (decl
)) == UNION_TYPE
)
11362 gen_type_die (member_declared_type (decl
), context_die
);
11363 gen_field_die (decl
, context_die
);
11368 gen_type_die (TREE_TYPE (decl
), context_die
);
11369 gen_formal_parameter_die (decl
, context_die
);
11372 case NAMESPACE_DECL
:
11373 /* Ignore for now. */
11381 /* Add Ada "use" clause information for SGI Workshop debugger. */
11384 dwarf2out_add_library_unit_info (filename
, context_list
)
11385 const char *filename
;
11386 const char *context_list
;
11388 unsigned int file_index
;
11390 if (filename
!= NULL
)
11392 dw_die_ref unit_die
= new_die (DW_TAG_module
, comp_unit_die
);
11393 tree context_list_decl
11394 = build_decl (LABEL_DECL
, get_identifier (context_list
),
11397 TREE_PUBLIC (context_list_decl
) = TRUE
;
11398 add_name_attribute (unit_die
, context_list
);
11399 file_index
= lookup_filename (filename
);
11400 add_AT_unsigned (unit_die
, DW_AT_decl_file
, file_index
);
11401 add_pubname (context_list_decl
, unit_die
);
11405 /* Debug information for a global DECL. Called from toplev.c after
11406 compilation proper has finished. */
11408 dwarf2out_global_decl (decl
)
11411 /* Output DWARF2 information for file-scope tentative data object
11412 declarations, file-scope (extern) function declarations (which
11413 had no corresponding body) and file-scope tagged type
11414 declarations and definitions which have not yet been forced out. */
11416 if (TREE_CODE (decl
) != FUNCTION_DECL
|| !DECL_INITIAL (decl
))
11417 dwarf2out_decl (decl
);
11420 /* Write the debugging output for DECL. */
11423 dwarf2out_decl (decl
)
11426 dw_die_ref context_die
= comp_unit_die
;
11428 if (TREE_CODE (decl
) == ERROR_MARK
)
11431 /* If this ..._DECL node is marked to be ignored, then ignore it. */
11432 if (DECL_IGNORED_P (decl
))
11435 switch (TREE_CODE (decl
))
11437 case FUNCTION_DECL
:
11438 /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of a
11439 builtin function. Explicit programmer-supplied declarations of
11440 these same functions should NOT be ignored however. */
11441 if (DECL_EXTERNAL (decl
) && DECL_BUILT_IN (decl
))
11444 /* What we would really like to do here is to filter out all mere
11445 file-scope declarations of file-scope functions which are never
11446 referenced later within this translation unit (and keep all of ones
11447 that *are* referenced later on) but we aren't clairvoyant, so we have
11448 no idea which functions will be referenced in the future (i.e. later
11449 on within the current translation unit). So here we just ignore all
11450 file-scope function declarations which are not also definitions. If
11451 and when the debugger needs to know something about these functions,
11452 it will have to hunt around and find the DWARF information associated
11453 with the definition of the function. Note that we can't just check
11454 `DECL_EXTERNAL' to find out which FUNCTION_DECL nodes represent
11455 definitions and which ones represent mere declarations. We have to
11456 check `DECL_INITIAL' instead. That's because the C front-end
11457 supports some weird semantics for "extern inline" function
11458 definitions. These can get inlined within the current translation
11459 unit (an thus, we need to generate DWARF info for their abstract
11460 instances so that the DWARF info for the concrete inlined instances
11461 can have something to refer to) but the compiler never generates any
11462 out-of-lines instances of such things (despite the fact that they
11463 *are* definitions). The important point is that the C front-end
11464 marks these "extern inline" functions as DECL_EXTERNAL, but we need
11465 to generate DWARF for them anyway. Note that the C++ front-end also
11466 plays some similar games for inline function definitions appearing
11467 within include files which also contain
11468 `#pragma interface' pragmas. */
11469 if (DECL_INITIAL (decl
) == NULL_TREE
)
11472 /* If we're a nested function, initially use a parent of NULL; if we're
11473 a plain function, this will be fixed up in decls_for_scope. If
11474 we're a method, it will be ignored, since we already have a DIE. */
11475 if (decl_function_context (decl
))
11476 context_die
= NULL
;
11481 /* Ignore this VAR_DECL if it refers to a file-scope extern data object
11482 declaration and if the declaration was never even referenced from
11483 within this entire compilation unit. We suppress these DIEs in
11484 order to save space in the .debug section (by eliminating entries
11485 which are probably useless). Note that we must not suppress
11486 block-local extern declarations (whether used or not) because that
11487 would screw-up the debugger's name lookup mechanism and cause it to
11488 miss things which really ought to be in scope at a given point. */
11489 if (DECL_EXTERNAL (decl
) && !TREE_USED (decl
))
11492 /* If we are in terse mode, don't generate any DIEs to represent any
11493 variable declarations or definitions. */
11494 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
11499 /* Don't emit stubs for types unless they are needed by other DIEs. */
11500 if (TYPE_DECL_SUPPRESS_DEBUG (decl
))
11503 /* Don't bother trying to generate any DIEs to represent any of the
11504 normal built-in types for the language we are compiling. */
11505 if (DECL_SOURCE_LINE (decl
) == 0)
11507 /* OK, we need to generate one for `bool' so GDB knows what type
11508 comparisons have. */
11509 if ((get_AT_unsigned (comp_unit_die
, DW_AT_language
)
11510 == DW_LANG_C_plus_plus
)
11511 && TREE_CODE (TREE_TYPE (decl
)) == BOOLEAN_TYPE
)
11512 modified_type_die (TREE_TYPE (decl
), 0, 0, NULL
);
11517 /* If we are in terse mode, don't generate any DIEs for types. */
11518 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
11521 /* If we're a function-scope tag, initially use a parent of NULL;
11522 this will be fixed up in decls_for_scope. */
11523 if (decl_function_context (decl
))
11524 context_die
= NULL
;
11532 gen_decl_die (decl
, context_die
);
11535 /* Output a marker (i.e. a label) for the beginning of the generated code for
11536 a lexical block. */
11539 dwarf2out_begin_block (line
, blocknum
)
11540 unsigned int line ATTRIBUTE_UNUSED
;
11541 unsigned int blocknum
;
11543 function_section (current_function_decl
);
11544 ASM_OUTPUT_DEBUG_LABEL (asm_out_file
, BLOCK_BEGIN_LABEL
, blocknum
);
11547 /* Output a marker (i.e. a label) for the end of the generated code for a
11551 dwarf2out_end_block (line
, blocknum
)
11552 unsigned int line ATTRIBUTE_UNUSED
;
11553 unsigned int blocknum
;
11555 function_section (current_function_decl
);
11556 ASM_OUTPUT_DEBUG_LABEL (asm_out_file
, BLOCK_END_LABEL
, blocknum
);
11559 /* Returns nonzero if it is appropriate not to emit any debugging
11560 information for BLOCK, because it doesn't contain any instructions.
11562 Don't allow this for blocks with nested functions or local classes
11563 as we would end up with orphans, and in the presence of scheduling
11564 we may end up calling them anyway. */
11567 dwarf2out_ignore_block (block
)
11571 for (decl
= BLOCK_VARS (block
); decl
; decl
= TREE_CHAIN (decl
))
11572 if (TREE_CODE (decl
) == FUNCTION_DECL
11573 || (TREE_CODE (decl
) == TYPE_DECL
&& TYPE_DECL_IS_STUB (decl
)))
11578 /* Lookup a filename (in the list of filenames that we know about here in
11579 dwarf2out.c) and return its "index". The index of each (known) filename is
11580 just a unique number which is associated with only that one filename.
11581 We need such numbers for the sake of generating labels
11582 (in the .debug_sfnames section) and references to those
11583 files numbers (in the .debug_srcinfo and.debug_macinfo sections).
11584 If the filename given as an argument is not found in our current list,
11585 add it to the list and assign it the next available unique index number.
11586 In order to speed up searches, we remember the index of the filename
11587 was looked up last. This handles the majority of all searches. */
11590 lookup_filename (file_name
)
11591 const char *file_name
;
11595 /* ??? Why isn't DECL_SOURCE_FILE left null instead. */
11596 if (strcmp (file_name
, "<internal>") == 0
11597 || strcmp (file_name
, "<built-in>") == 0)
11600 /* Check to see if the file name that was searched on the previous
11601 call matches this file name. If so, return the index. */
11602 if (file_table
.last_lookup_index
!= 0)
11603 if (strcmp (file_name
, file_table
.table
[file_table
.last_lookup_index
]) == 0)
11604 return file_table
.last_lookup_index
;
11606 /* Didn't match the previous lookup, search the table */
11607 for (i
= 1; i
< file_table
.in_use
; ++i
)
11608 if (strcmp (file_name
, file_table
.table
[i
]) == 0)
11610 file_table
.last_lookup_index
= i
;
11614 /* Prepare to add a new table entry by making sure there is enough space in
11615 the table to do so. If not, expand the current table. */
11616 if (i
== file_table
.allocated
)
11618 file_table
.allocated
= i
+ FILE_TABLE_INCREMENT
;
11619 file_table
.table
= (char **)
11620 xrealloc (file_table
.table
, file_table
.allocated
* sizeof (char *));
11623 /* Add the new entry to the end of the filename table. */
11624 file_table
.table
[i
] = xstrdup (file_name
);
11625 file_table
.in_use
= i
+ 1;
11626 file_table
.last_lookup_index
= i
;
11628 if (DWARF2_ASM_LINE_DEBUG_INFO
)
11629 fprintf (asm_out_file
, "\t.file %u \"%s\"\n", i
, file_name
);
11637 /* Allocate the initial hunk of the file_table. */
11638 file_table
.table
= (char **) xcalloc (FILE_TABLE_INCREMENT
, sizeof (char *));
11639 file_table
.allocated
= FILE_TABLE_INCREMENT
;
11641 /* Skip the first entry - file numbers begin at 1. */
11642 file_table
.in_use
= 1;
11643 file_table
.last_lookup_index
= 0;
11646 /* Output a label to mark the beginning of a source code line entry
11647 and record information relating to this source line, in
11648 'line_info_table' for later output of the .debug_line section. */
11651 dwarf2out_source_line (line
, filename
)
11653 const char *filename
;
11655 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
11657 function_section (current_function_decl
);
11659 /* If requested, emit something human-readable. */
11660 if (flag_debug_asm
)
11661 fprintf (asm_out_file
, "\t%s %s:%d\n", ASM_COMMENT_START
,
11664 if (DWARF2_ASM_LINE_DEBUG_INFO
)
11666 unsigned file_num
= lookup_filename (filename
);
11668 /* Emit the .loc directive understood by GNU as. */
11669 fprintf (asm_out_file
, "\t.loc %d %d 0\n", file_num
, line
);
11671 /* Indicate that line number info exists. */
11672 ++line_info_table_in_use
;
11674 /* Indicate that multiple line number tables exist. */
11675 if (DECL_SECTION_NAME (current_function_decl
))
11676 ++separate_line_info_table_in_use
;
11678 else if (DECL_SECTION_NAME (current_function_decl
))
11680 dw_separate_line_info_ref line_info
;
11681 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, SEPARATE_LINE_CODE_LABEL
,
11682 separate_line_info_table_in_use
);
11684 /* expand the line info table if necessary */
11685 if (separate_line_info_table_in_use
11686 == separate_line_info_table_allocated
)
11688 separate_line_info_table_allocated
+= LINE_INFO_TABLE_INCREMENT
;
11689 separate_line_info_table
11690 = (dw_separate_line_info_ref
)
11691 xrealloc (separate_line_info_table
,
11692 separate_line_info_table_allocated
11693 * sizeof (dw_separate_line_info_entry
));
11696 /* Add the new entry at the end of the line_info_table. */
11698 = &separate_line_info_table
[separate_line_info_table_in_use
++];
11699 line_info
->dw_file_num
= lookup_filename (filename
);
11700 line_info
->dw_line_num
= line
;
11701 line_info
->function
= current_funcdef_number
;
11705 dw_line_info_ref line_info
;
11707 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, LINE_CODE_LABEL
,
11708 line_info_table_in_use
);
11710 /* Expand the line info table if necessary. */
11711 if (line_info_table_in_use
== line_info_table_allocated
)
11713 line_info_table_allocated
+= LINE_INFO_TABLE_INCREMENT
;
11715 = (dw_line_info_ref
)
11716 xrealloc (line_info_table
,
11717 (line_info_table_allocated
11718 * sizeof (dw_line_info_entry
)));
11721 /* Add the new entry at the end of the line_info_table. */
11722 line_info
= &line_info_table
[line_info_table_in_use
++];
11723 line_info
->dw_file_num
= lookup_filename (filename
);
11724 line_info
->dw_line_num
= line
;
11729 /* Record the beginning of a new source file. */
11732 dwarf2out_start_source_file (lineno
, filename
)
11733 unsigned int lineno
;
11734 const char *filename
;
11736 if (flag_eliminate_dwarf2_dups
)
11738 /* Record the beginning of the file for break_out_includes. */
11739 dw_die_ref bincl_die
= new_die (DW_TAG_GNU_BINCL
, comp_unit_die
);
11740 add_AT_string (bincl_die
, DW_AT_name
, filename
);
11742 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
11744 named_section_flags (DEBUG_MACINFO_SECTION
, SECTION_DEBUG
);
11745 dw2_asm_output_data (1, DW_MACINFO_start_file
, "Start new file");
11746 dw2_asm_output_data_uleb128 (lineno
, "Included from line number %d",
11748 dw2_asm_output_data_uleb128 (lookup_filename (filename
),
11749 "Filename we just started");
11753 /* Record the end of a source file. */
11756 dwarf2out_end_source_file (lineno
)
11757 unsigned int lineno ATTRIBUTE_UNUSED
;
11759 if (flag_eliminate_dwarf2_dups
)
11761 /* Record the end of the file for break_out_includes. */
11762 new_die (DW_TAG_GNU_EINCL
, comp_unit_die
);
11764 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
11766 named_section_flags (DEBUG_MACINFO_SECTION
, SECTION_DEBUG
);
11767 dw2_asm_output_data (1, DW_MACINFO_end_file
, "End file");
11771 /* Called from debug_define in toplev.c. The `buffer' parameter contains
11772 the tail part of the directive line, i.e. the part which is past the
11773 initial whitespace, #, whitespace, directive-name, whitespace part. */
11776 dwarf2out_define (lineno
, buffer
)
11777 unsigned lineno ATTRIBUTE_UNUSED
;
11778 const char *buffer ATTRIBUTE_UNUSED
;
11780 static int initialized
= 0;
11783 dwarf2out_start_source_file (0, primary_filename
);
11786 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
11788 named_section_flags (DEBUG_MACINFO_SECTION
, SECTION_DEBUG
);
11789 dw2_asm_output_data (1, DW_MACINFO_define
, "Define macro");
11790 dw2_asm_output_data_uleb128 (lineno
, "At line number %d", lineno
);
11791 dw2_asm_output_nstring (buffer
, -1, "The macro");
11795 /* Called from debug_undef in toplev.c. The `buffer' parameter contains
11796 the tail part of the directive line, i.e. the part which is past the
11797 initial whitespace, #, whitespace, directive-name, whitespace part. */
11800 dwarf2out_undef (lineno
, buffer
)
11801 unsigned lineno ATTRIBUTE_UNUSED
;
11802 const char *buffer ATTRIBUTE_UNUSED
;
11804 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
11806 named_section_flags (DEBUG_MACINFO_SECTION
, SECTION_DEBUG
);
11807 dw2_asm_output_data (1, DW_MACINFO_undef
, "Undefine macro");
11808 dw2_asm_output_data_uleb128 (lineno
, "At line number %d", lineno
);
11809 dw2_asm_output_nstring (buffer
, -1, "The macro");
11813 /* Set up for Dwarf output at the start of compilation. */
11816 dwarf2out_init (main_input_filename
)
11817 const char *main_input_filename
;
11819 init_file_table ();
11821 /* Remember the name of the primary input file. */
11822 primary_filename
= main_input_filename
;
11824 /* Add it to the file table first, under the assumption that we'll
11825 be emitting line number data for it first, which avoids having
11826 to add an initial DW_LNS_set_file. */
11827 lookup_filename (main_input_filename
);
11829 /* Allocate the initial hunk of the decl_die_table. */
11831 = (dw_die_ref
*) xcalloc (DECL_DIE_TABLE_INCREMENT
, sizeof (dw_die_ref
));
11832 decl_die_table_allocated
= DECL_DIE_TABLE_INCREMENT
;
11833 decl_die_table_in_use
= 0;
11835 /* Allocate the initial hunk of the decl_scope_table. */
11836 VARRAY_TREE_INIT (decl_scope_table
, 256, "decl_scope_table");
11837 ggc_add_tree_varray_root (&decl_scope_table
, 1);
11839 /* Allocate the initial hunk of the abbrev_die_table. */
11841 = (dw_die_ref
*) xcalloc (ABBREV_DIE_TABLE_INCREMENT
,
11842 sizeof (dw_die_ref
));
11843 abbrev_die_table_allocated
= ABBREV_DIE_TABLE_INCREMENT
;
11844 /* Zero-th entry is allocated, but unused */
11845 abbrev_die_table_in_use
= 1;
11847 /* Allocate the initial hunk of the line_info_table. */
11849 = (dw_line_info_ref
) xcalloc (LINE_INFO_TABLE_INCREMENT
,
11850 sizeof (dw_line_info_entry
));
11851 line_info_table_allocated
= LINE_INFO_TABLE_INCREMENT
;
11852 /* Zero-th entry is allocated, but unused */
11853 line_info_table_in_use
= 1;
11855 /* Generate the initial DIE for the .debug section. Note that the (string)
11856 value given in the DW_AT_name attribute of the DW_TAG_compile_unit DIE
11857 will (typically) be a relative pathname and that this pathname should be
11858 taken as being relative to the directory from which the compiler was
11859 invoked when the given (base) source file was compiled. */
11860 comp_unit_die
= gen_compile_unit_die (main_input_filename
);
11862 VARRAY_TREE_INIT (incomplete_types
, 64, "incomplete_types");
11863 ggc_add_tree_varray_root (&incomplete_types
, 1);
11865 VARRAY_RTX_INIT (used_rtx_varray
, 32, "used_rtx_varray");
11866 ggc_add_rtx_varray_root (&used_rtx_varray
, 1);
11868 ASM_GENERATE_INTERNAL_LABEL (text_end_label
, TEXT_END_LABEL
, 0);
11869 ASM_GENERATE_INTERNAL_LABEL (abbrev_section_label
,
11870 DEBUG_ABBREV_SECTION_LABEL
, 0);
11871 if (DWARF2_GENERATE_TEXT_SECTION_LABEL
)
11872 ASM_GENERATE_INTERNAL_LABEL (text_section_label
, TEXT_SECTION_LABEL
, 0);
11874 strcpy (text_section_label
, stripattributes (TEXT_SECTION_NAME
));
11875 ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label
,
11876 DEBUG_INFO_SECTION_LABEL
, 0);
11877 ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label
,
11878 DEBUG_LINE_SECTION_LABEL
, 0);
11879 ASM_GENERATE_INTERNAL_LABEL (ranges_section_label
,
11880 DEBUG_RANGES_SECTION_LABEL
, 0);
11881 named_section_flags (DEBUG_ABBREV_SECTION
, SECTION_DEBUG
);
11882 ASM_OUTPUT_LABEL (asm_out_file
, abbrev_section_label
);
11883 named_section_flags (DEBUG_INFO_SECTION
, SECTION_DEBUG
);
11884 ASM_OUTPUT_LABEL (asm_out_file
, debug_info_section_label
);
11885 named_section_flags (DEBUG_LINE_SECTION
, SECTION_DEBUG
);
11886 ASM_OUTPUT_LABEL (asm_out_file
, debug_line_section_label
);
11887 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
11889 named_section_flags (DEBUG_MACINFO_SECTION
, SECTION_DEBUG
);
11890 ASM_GENERATE_INTERNAL_LABEL (macinfo_section_label
,
11891 DEBUG_MACINFO_SECTION_LABEL
, 0);
11892 ASM_OUTPUT_LABEL (asm_out_file
, macinfo_section_label
);
11895 if (DWARF2_GENERATE_TEXT_SECTION_LABEL
)
11898 ASM_OUTPUT_LABEL (asm_out_file
, text_section_label
);
11902 /* Allocate a string in .debug_str hash table. */
11905 indirect_string_alloc (tab
)
11906 hash_table
*tab ATTRIBUTE_UNUSED
;
11908 struct indirect_string_node
*node
;
11910 node
= xmalloc (sizeof (struct indirect_string_node
));
11911 node
->refcount
= 0;
11913 node
->label
= NULL
;
11914 return (hashnode
) node
;
11917 /* A helper function for dwarf2out_finish called through
11918 ht_forall. Emit one queued .debug_str string. */
11921 output_indirect_string (pfile
, h
, v
)
11922 struct cpp_reader
*pfile ATTRIBUTE_UNUSED
;
11924 const PTR v ATTRIBUTE_UNUSED
;
11926 struct indirect_string_node
*node
;
11928 node
= (struct indirect_string_node
*) h
;
11929 if (node
->form
== DW_FORM_strp
)
11931 named_section_flags (DEBUG_STR_SECTION
, DEBUG_STR_SECTION_FLAGS
);
11932 ASM_OUTPUT_LABEL (asm_out_file
, node
->label
);
11933 assemble_string ((const char *) HT_STR (&node
->id
),
11934 HT_LEN (&node
->id
) + 1);
11939 /* Output stuff that dwarf requires at the end of every file,
11940 and generate the DWARF-2 debugging info. */
11943 dwarf2out_finish (input_filename
)
11944 const char *input_filename ATTRIBUTE_UNUSED
;
11946 limbo_die_node
*node
, *next_node
;
11947 dw_die_ref die
= 0;
11949 /* Traverse the limbo die list, and add parent/child links. The only
11950 dies without parents that should be here are concrete instances of
11951 inline functions, and the comp_unit_die. We can ignore the comp_unit_die.
11952 For concrete instances, we can get the parent die from the abstract
11954 for (node
= limbo_die_list
; node
; node
= next_node
)
11956 next_node
= node
->next
;
11959 if (die
->die_parent
== NULL
)
11961 dw_die_ref origin
= get_AT_ref (die
, DW_AT_abstract_origin
);
11963 add_child_die (origin
->die_parent
, die
);
11964 else if (die
== comp_unit_die
)
11966 else if (errorcount
> 0 || sorrycount
> 0)
11967 /* It's OK to be confused by errors in the input. */
11968 add_child_die (comp_unit_die
, die
);
11974 limbo_die_list
= NULL
;
11976 /* Walk through the list of incomplete types again, trying once more to
11977 emit full debugging info for them. */
11978 retry_incomplete_types ();
11980 /* We need to reverse all the dies before break_out_includes, or
11981 we'll see the end of an include file before the beginning. */
11982 reverse_all_dies (comp_unit_die
);
11984 /* Generate separate CUs for each of the include files we've seen.
11985 They will go into limbo_die_list. */
11986 if (flag_eliminate_dwarf2_dups
)
11987 break_out_includes (comp_unit_die
);
11989 /* Traverse the DIE's and add add sibling attributes to those DIE's
11990 that have children. */
11991 add_sibling_attributes (comp_unit_die
);
11992 for (node
= limbo_die_list
; node
; node
= node
->next
)
11993 add_sibling_attributes (node
->die
);
11995 /* Output a terminator label for the .text section. */
11997 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, TEXT_END_LABEL
, 0);
11999 /* Output the source line correspondence table. We must do this
12000 even if there is no line information. Otherwise, on an empty
12001 translation unit, we will generate a present, but empty,
12002 .debug_info section. IRIX 6.5 `nm' will then complain when
12003 examining the file. */
12004 if (! DWARF2_ASM_LINE_DEBUG_INFO
)
12006 named_section_flags (DEBUG_LINE_SECTION
, SECTION_DEBUG
);
12007 output_line_info ();
12010 /* Output location list section if necessary. */
12011 if (have_location_lists
)
12013 /* Output the location lists info. */
12014 named_section_flags (DEBUG_LOC_SECTION
, SECTION_DEBUG
);
12015 ASM_GENERATE_INTERNAL_LABEL (loc_section_label
,
12016 DEBUG_LOC_SECTION_LABEL
, 0);
12017 ASM_OUTPUT_LABEL (asm_out_file
, loc_section_label
);
12018 output_location_lists (die
);
12019 have_location_lists
= 0;
12022 /* We can only use the low/high_pc attributes if all of the code was
12024 if (separate_line_info_table_in_use
== 0)
12026 add_AT_lbl_id (comp_unit_die
, DW_AT_low_pc
, text_section_label
);
12027 add_AT_lbl_id (comp_unit_die
, DW_AT_high_pc
, text_end_label
);
12029 /* And if it wasn't, we need to give .debug_loc and .debug_ranges
12030 an appropriate "base address". Use zero so that these addresses
12031 become absolute. */
12032 else if (have_location_lists
|| ranges_table_in_use
)
12033 add_AT_addr (comp_unit_die
, DW_AT_entry_pc
, const0_rtx
);
12035 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
12036 add_AT_lbl_offset (comp_unit_die
, DW_AT_stmt_list
,
12037 debug_line_section_label
);
12039 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
12040 add_AT_lbl_offset (comp_unit_die
, DW_AT_macro_info
, macinfo_section_label
);
12042 /* Output all of the compilation units. We put the main one last so that
12043 the offsets are available to output_pubnames. */
12044 for (node
= limbo_die_list
; node
; node
= node
->next
)
12045 output_comp_unit (node
->die
);
12046 output_comp_unit (comp_unit_die
);
12048 /* Output the abbreviation table. */
12049 named_section_flags (DEBUG_ABBREV_SECTION
, SECTION_DEBUG
);
12050 output_abbrev_section ();
12052 if (pubname_table_in_use
)
12054 /* Output public names table. */
12055 named_section_flags (DEBUG_PUBNAMES_SECTION
, SECTION_DEBUG
);
12056 output_pubnames ();
12059 /* We only put functions in the arange table, so don't write it out if
12060 we don't have any. */
12061 if (fde_table_in_use
)
12063 /* Output the address range information. */
12064 named_section_flags (DEBUG_ARANGES_SECTION
, SECTION_DEBUG
);
12068 /* Output ranges section if necessary. */
12069 if (ranges_table_in_use
)
12071 named_section_flags (DEBUG_RANGES_SECTION
, SECTION_DEBUG
);
12072 ASM_OUTPUT_LABEL (asm_out_file
, ranges_section_label
);
12076 /* Have to end the primary source file. */
12077 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
12079 named_section_flags (DEBUG_MACINFO_SECTION
, SECTION_DEBUG
);
12080 dw2_asm_output_data (1, DW_MACINFO_end_file
, "End file");
12083 /* If we emitted any DW_FORM_strp form attribute, output string
12085 if (debug_str_hash
)
12086 ht_forall (debug_str_hash
, output_indirect_string
, NULL
);
12088 #endif /* DWARF2_DEBUGGING_INFO || DWARF2_UNWIND_INFO */