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 GNU CC.
10 GNU CC is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
15 GNU CC is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with GNU CC; see the file COPYING. If not, write to
22 the Free Software Foundation, 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
25 /* TODO: Implement .debug_str handling, and share entries somehow.
26 Emit .debug_line header even when there are no functions, since
27 the file numbers are used by .debug_info. Alternately, leave
28 out locations for types and decls.
29 Avoid talking about ctors and op= for PODs.
30 Factor out common prologue sequences into multiple CIEs. */
32 /* The first part of this file deals with the DWARF 2 frame unwind
33 information, which is also used by the GCC efficient exception handling
34 mechanism. The second part, controlled only by an #ifdef
35 DWARF2_DEBUGGING_INFO, deals with the other DWARF 2 debugging
43 #include "hard-reg-set.h"
45 #include "insn-config.h"
52 #include "dwarf2out.h"
53 #include "dwarf2asm.h"
59 #include "diagnostic.h"
62 #ifdef DWARF2_DEBUGGING_INFO
63 static void dwarf2out_source_line
PARAMS ((unsigned int, const char *));
66 /* DWARF2 Abbreviation Glossary:
67 CFA = Canonical Frame Address
68 a fixed address on the stack which identifies a call frame.
69 We define it to be the value of SP just before the call insn.
70 The CFA register and offset, which may change during the course
71 of the function, are used to calculate its value at runtime.
72 CFI = Call Frame Instruction
73 an instruction for the DWARF2 abstract machine
74 CIE = Common Information Entry
75 information describing information common to one or more FDEs
76 DIE = Debugging Information Entry
77 FDE = Frame Description Entry
78 information describing the stack call frame, in particular,
79 how to restore registers
81 DW_CFA_... = DWARF2 CFA call frame instruction
82 DW_TAG_... = DWARF2 DIE tag */
84 /* Decide whether we want to emit frame unwind information for the current
90 return (write_symbols
== DWARF2_DEBUG
91 #ifdef DWARF2_FRAME_INFO
94 #ifdef DWARF2_UNWIND_INFO
96 || (flag_exceptions
&& ! USING_SJLJ_EXCEPTIONS
)
101 /* The number of the current function definition for which debugging
102 information is being generated. These numbers range from 1 up to the
103 maximum number of function definitions contained within the current
104 compilation unit. These numbers are used to create unique label id's
105 unique to each function definition. */
106 unsigned current_funcdef_number
= 0;
108 #if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
110 /* How to start an assembler comment. */
111 #ifndef ASM_COMMENT_START
112 #define ASM_COMMENT_START ";#"
115 typedef struct dw_cfi_struct
*dw_cfi_ref
;
116 typedef struct dw_fde_struct
*dw_fde_ref
;
117 typedef union dw_cfi_oprnd_struct
*dw_cfi_oprnd_ref
;
119 /* Call frames are described using a sequence of Call Frame
120 Information instructions. The register number, offset
121 and address fields are provided as possible operands;
122 their use is selected by the opcode field. */
124 typedef union dw_cfi_oprnd_struct
126 unsigned long dw_cfi_reg_num
;
127 long int dw_cfi_offset
;
128 const char *dw_cfi_addr
;
129 struct dw_loc_descr_struct
*dw_cfi_loc
;
133 typedef struct dw_cfi_struct
135 dw_cfi_ref dw_cfi_next
;
136 enum dwarf_call_frame_info dw_cfi_opc
;
137 dw_cfi_oprnd dw_cfi_oprnd1
;
138 dw_cfi_oprnd dw_cfi_oprnd2
;
142 /* This is how we define the location of the CFA. We use to handle it
143 as REG + OFFSET all the time, but now it can be more complex.
144 It can now be either REG + CFA_OFFSET or *(REG + BASE_OFFSET) + CFA_OFFSET.
145 Instead of passing around REG and OFFSET, we pass a copy
146 of this structure. */
147 typedef struct cfa_loc
152 int indirect
; /* 1 if CFA is accessed via a dereference. */
155 /* All call frame descriptions (FDE's) in the GCC generated DWARF
156 refer to a single Common Information Entry (CIE), defined at
157 the beginning of the .debug_frame section. This used of a single
158 CIE obviates the need to keep track of multiple CIE's
159 in the DWARF generation routines below. */
161 typedef struct dw_fde_struct
163 const char *dw_fde_begin
;
164 const char *dw_fde_current_label
;
165 const char *dw_fde_end
;
166 dw_cfi_ref dw_fde_cfi
;
167 unsigned funcdef_number
;
168 unsigned nothrow
: 1;
169 unsigned uses_eh_lsda
: 1;
173 /* Maximum size (in bytes) of an artificially generated label. */
174 #define MAX_ARTIFICIAL_LABEL_BYTES 30
176 /* The size of the target's pointer type. */
178 #define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
181 /* The size of addresses as they appear in the Dwarf 2 data.
182 Some architectures use word addresses to refer to code locations,
183 but Dwarf 2 info always uses byte addresses. On such machines,
184 Dwarf 2 addresses need to be larger than the architecture's
186 #ifndef DWARF2_ADDR_SIZE
187 #define DWARF2_ADDR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
190 /* The size in bytes of a DWARF field indicating an offset or length
191 relative to a debug info section, specified to be 4 bytes in the
192 DWARF-2 specification. The SGI/MIPS ABI defines it to be the same
195 #ifndef DWARF_OFFSET_SIZE
196 #define DWARF_OFFSET_SIZE 4
199 #define DWARF_VERSION 2
201 /* Round SIZE up to the nearest BOUNDARY. */
202 #define DWARF_ROUND(SIZE,BOUNDARY) \
203 ((((SIZE) + (BOUNDARY) - 1) / (BOUNDARY)) * (BOUNDARY))
205 /* Offsets recorded in opcodes are a multiple of this alignment factor. */
206 #ifndef DWARF_CIE_DATA_ALIGNMENT
207 #ifdef STACK_GROWS_DOWNWARD
208 #define DWARF_CIE_DATA_ALIGNMENT (-((int) UNITS_PER_WORD))
210 #define DWARF_CIE_DATA_ALIGNMENT ((int) UNITS_PER_WORD)
212 #endif /* not DWARF_CIE_DATA_ALIGNMENT */
214 /* A pointer to the base of a table that contains frame description
215 information for each routine. */
216 static dw_fde_ref fde_table
;
218 /* Number of elements currently allocated for fde_table. */
219 static unsigned fde_table_allocated
;
221 /* Number of elements in fde_table currently in use. */
222 static unsigned fde_table_in_use
;
224 /* Size (in elements) of increments by which we may expand the
226 #define FDE_TABLE_INCREMENT 256
228 /* A list of call frame insns for the CIE. */
229 static dw_cfi_ref cie_cfi_head
;
231 /* Some DWARF extensions (e.g., MIPS/SGI) implement a subprogram
232 attribute that accelerates the lookup of the FDE associated
233 with the subprogram. This variable holds the table index of the FDE
234 associated with the current function (body) definition. */
235 static unsigned current_funcdef_fde
;
237 /* Forward declarations for functions defined in this file. */
239 static char *stripattributes
PARAMS ((const char *));
240 static const char *dwarf_cfi_name
PARAMS ((unsigned));
241 static dw_cfi_ref new_cfi
PARAMS ((void));
242 static void add_cfi
PARAMS ((dw_cfi_ref
*, dw_cfi_ref
));
243 static void add_fde_cfi
PARAMS ((const char *, dw_cfi_ref
));
244 static void lookup_cfa_1
PARAMS ((dw_cfi_ref
, dw_cfa_location
*));
245 static void lookup_cfa
PARAMS ((dw_cfa_location
*));
246 static void reg_save
PARAMS ((const char *, unsigned,
248 static void initial_return_save
PARAMS ((rtx
));
249 static long stack_adjust_offset
PARAMS ((rtx
));
250 static void output_cfi
PARAMS ((dw_cfi_ref
, dw_fde_ref
, int));
251 static void output_call_frame_info
PARAMS ((int));
252 static void dwarf2out_stack_adjust
PARAMS ((rtx
));
253 static void queue_reg_save
PARAMS ((const char *, rtx
, long));
254 static void flush_queued_reg_saves
PARAMS ((void));
255 static bool clobbers_queued_reg_save
PARAMS ((rtx
));
256 static void dwarf2out_frame_debug_expr
PARAMS ((rtx
, const char *));
258 /* Support for complex CFA locations. */
259 static void output_cfa_loc
PARAMS ((dw_cfi_ref
));
260 static void get_cfa_from_loc_descr
PARAMS ((dw_cfa_location
*,
261 struct dw_loc_descr_struct
*));
262 static struct dw_loc_descr_struct
*build_cfa_loc
263 PARAMS ((dw_cfa_location
*));
264 static void def_cfa_1
PARAMS ((const char *, dw_cfa_location
*));
266 /* How to start an assembler comment. */
267 #ifndef ASM_COMMENT_START
268 #define ASM_COMMENT_START ";#"
271 /* Data and reference forms for relocatable data. */
272 #define DW_FORM_data (DWARF_OFFSET_SIZE == 8 ? DW_FORM_data8 : DW_FORM_data4)
273 #define DW_FORM_ref (DWARF_OFFSET_SIZE == 8 ? DW_FORM_ref8 : DW_FORM_ref4)
275 /* Pseudo-op for defining a new section. */
276 #ifndef SECTION_ASM_OP
277 #define SECTION_ASM_OP "\t.section\t"
280 #ifndef DEBUG_FRAME_SECTION
281 #define DEBUG_FRAME_SECTION ".debug_frame"
284 #ifndef FUNC_BEGIN_LABEL
285 #define FUNC_BEGIN_LABEL "LFB"
287 #ifndef FUNC_END_LABEL
288 #define FUNC_END_LABEL "LFE"
290 #define CIE_AFTER_SIZE_LABEL "LSCIE"
291 #define CIE_END_LABEL "LECIE"
292 #define CIE_LENGTH_LABEL "LLCIE"
293 #define FDE_LABEL "LSFDE"
294 #define FDE_AFTER_SIZE_LABEL "LASFDE"
295 #define FDE_END_LABEL "LEFDE"
296 #define FDE_LENGTH_LABEL "LLFDE"
297 #define LINE_NUMBER_BEGIN_LABEL "LSLT"
298 #define LINE_NUMBER_END_LABEL "LELT"
299 #define LN_PROLOG_AS_LABEL "LASLTP"
300 #define LN_PROLOG_END_LABEL "LELTP"
301 #define DIE_LABEL_PREFIX "DW"
303 /* Definitions of defaults for various types of primitive assembly language
304 output operations. These may be overridden from within the tm.h file,
305 but typically, that is unnecessary. */
308 #ifndef ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL
309 #define ASM_OUTPUT_DEFINE_LABEL_DIFFERENCE_SYMBOL(FILE, SY, HI, LO) \
311 fprintf (FILE, "%s", SET_ASM_OP); \
312 assemble_name (FILE, SY); \
314 assemble_name (FILE, HI); \
316 assemble_name (FILE, LO); \
319 #endif /* SET_ASM_OP */
321 /* The DWARF 2 CFA column which tracks the return address. Normally this
322 is the column for PC, or the first column after all of the hard
324 #ifndef DWARF_FRAME_RETURN_COLUMN
326 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (PC_REGNUM)
328 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGISTERS
332 /* The mapping from gcc register number to DWARF 2 CFA column number. By
333 default, we just provide columns for all registers. */
334 #ifndef DWARF_FRAME_REGNUM
335 #define DWARF_FRAME_REGNUM(REG) DBX_REGISTER_NUMBER (REG)
338 /* Hook used by __throw. */
341 expand_builtin_dwarf_fp_regnum ()
343 return GEN_INT (DWARF_FRAME_REGNUM (HARD_FRAME_POINTER_REGNUM
));
346 /* The offset from the incoming value of %sp to the top of the stack frame
347 for the current function. */
348 #ifndef INCOMING_FRAME_SP_OFFSET
349 #define INCOMING_FRAME_SP_OFFSET 0
352 /* Return a pointer to a copy of the section string name S with all
353 attributes stripped off, and an asterisk prepended (for assemble_name). */
359 char *stripped
= xmalloc (strlen (s
) + 2);
364 while (*s
&& *s
!= ',')
371 /* Generate code to initialize the register size table. */
374 expand_builtin_init_dwarf_reg_sizes (address
)
378 enum machine_mode mode
= TYPE_MODE (char_type_node
);
379 rtx addr
= expand_expr (address
, NULL_RTX
, VOIDmode
, 0);
380 rtx mem
= gen_rtx_MEM (mode
, addr
);
382 for (i
= 0; i
< DWARF_FRAME_REGISTERS
; ++i
)
384 int offset
= DWARF_FRAME_REGNUM (i
) * GET_MODE_SIZE (mode
);
385 int size
= GET_MODE_SIZE (reg_raw_mode
[i
]);
390 emit_move_insn (adjust_address (mem
, mode
, offset
), GEN_INT (size
));
394 /* Convert a DWARF call frame info. operation to its string name */
397 dwarf_cfi_name (cfi_opc
)
398 register unsigned cfi_opc
;
402 case DW_CFA_advance_loc
:
403 return "DW_CFA_advance_loc";
405 return "DW_CFA_offset";
407 return "DW_CFA_restore";
411 return "DW_CFA_set_loc";
412 case DW_CFA_advance_loc1
:
413 return "DW_CFA_advance_loc1";
414 case DW_CFA_advance_loc2
:
415 return "DW_CFA_advance_loc2";
416 case DW_CFA_advance_loc4
:
417 return "DW_CFA_advance_loc4";
418 case DW_CFA_offset_extended
:
419 return "DW_CFA_offset_extended";
420 case DW_CFA_restore_extended
:
421 return "DW_CFA_restore_extended";
422 case DW_CFA_undefined
:
423 return "DW_CFA_undefined";
424 case DW_CFA_same_value
:
425 return "DW_CFA_same_value";
426 case DW_CFA_register
:
427 return "DW_CFA_register";
428 case DW_CFA_remember_state
:
429 return "DW_CFA_remember_state";
430 case DW_CFA_restore_state
:
431 return "DW_CFA_restore_state";
433 return "DW_CFA_def_cfa";
434 case DW_CFA_def_cfa_register
:
435 return "DW_CFA_def_cfa_register";
436 case DW_CFA_def_cfa_offset
:
437 return "DW_CFA_def_cfa_offset";
438 case DW_CFA_def_cfa_expression
:
439 return "DW_CFA_def_cfa_expression";
441 /* SGI/MIPS specific */
442 case DW_CFA_MIPS_advance_loc8
:
443 return "DW_CFA_MIPS_advance_loc8";
446 case DW_CFA_GNU_window_save
:
447 return "DW_CFA_GNU_window_save";
448 case DW_CFA_GNU_args_size
:
449 return "DW_CFA_GNU_args_size";
450 case DW_CFA_GNU_negative_offset_extended
:
451 return "DW_CFA_GNU_negative_offset_extended";
454 return "DW_CFA_<unknown>";
458 /* Return a pointer to a newly allocated Call Frame Instruction. */
460 static inline dw_cfi_ref
463 register dw_cfi_ref cfi
= (dw_cfi_ref
) xmalloc (sizeof (dw_cfi_node
));
465 cfi
->dw_cfi_next
= NULL
;
466 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= 0;
467 cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
= 0;
472 /* Add a Call Frame Instruction to list of instructions. */
475 add_cfi (list_head
, cfi
)
476 register dw_cfi_ref
*list_head
;
477 register dw_cfi_ref cfi
;
479 register dw_cfi_ref
*p
;
481 /* Find the end of the chain. */
482 for (p
= list_head
; (*p
) != NULL
; p
= &(*p
)->dw_cfi_next
)
488 /* Generate a new label for the CFI info to refer to. */
491 dwarf2out_cfi_label ()
493 static char label
[20];
494 static unsigned long label_num
= 0;
496 ASM_GENERATE_INTERNAL_LABEL (label
, "LCFI", label_num
++);
497 ASM_OUTPUT_LABEL (asm_out_file
, label
);
502 /* Add CFI to the current fde at the PC value indicated by LABEL if specified,
503 or to the CIE if LABEL is NULL. */
506 add_fde_cfi (label
, cfi
)
507 register const char *label
;
508 register dw_cfi_ref cfi
;
512 register dw_fde_ref fde
= &fde_table
[fde_table_in_use
- 1];
515 label
= dwarf2out_cfi_label ();
517 if (fde
->dw_fde_current_label
== NULL
518 || strcmp (label
, fde
->dw_fde_current_label
) != 0)
520 register dw_cfi_ref xcfi
;
522 fde
->dw_fde_current_label
= label
= xstrdup (label
);
524 /* Set the location counter to the new label. */
526 xcfi
->dw_cfi_opc
= DW_CFA_advance_loc4
;
527 xcfi
->dw_cfi_oprnd1
.dw_cfi_addr
= label
;
528 add_cfi (&fde
->dw_fde_cfi
, xcfi
);
531 add_cfi (&fde
->dw_fde_cfi
, cfi
);
535 add_cfi (&cie_cfi_head
, cfi
);
538 /* Subroutine of lookup_cfa. */
541 lookup_cfa_1 (cfi
, loc
)
542 register dw_cfi_ref cfi
;
543 register dw_cfa_location
*loc
;
545 switch (cfi
->dw_cfi_opc
)
547 case DW_CFA_def_cfa_offset
:
548 loc
->offset
= cfi
->dw_cfi_oprnd1
.dw_cfi_offset
;
550 case DW_CFA_def_cfa_register
:
551 loc
->reg
= cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
;
554 loc
->reg
= cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
;
555 loc
->offset
= cfi
->dw_cfi_oprnd2
.dw_cfi_offset
;
557 case DW_CFA_def_cfa_expression
:
558 get_cfa_from_loc_descr (loc
, cfi
->dw_cfi_oprnd1
.dw_cfi_loc
);
565 /* Find the previous value for the CFA. */
569 register dw_cfa_location
*loc
;
571 register dw_cfi_ref cfi
;
573 loc
->reg
= (unsigned long) -1;
576 loc
->base_offset
= 0;
578 for (cfi
= cie_cfi_head
; cfi
; cfi
= cfi
->dw_cfi_next
)
579 lookup_cfa_1 (cfi
, loc
);
581 if (fde_table_in_use
)
583 register dw_fde_ref fde
= &fde_table
[fde_table_in_use
- 1];
584 for (cfi
= fde
->dw_fde_cfi
; cfi
; cfi
= cfi
->dw_cfi_next
)
585 lookup_cfa_1 (cfi
, loc
);
589 /* The current rule for calculating the DWARF2 canonical frame address. */
590 static dw_cfa_location cfa
;
592 /* The register used for saving registers to the stack, and its offset
594 static dw_cfa_location cfa_store
;
596 /* The running total of the size of arguments pushed onto the stack. */
597 static long args_size
;
599 /* The last args_size we actually output. */
600 static long old_args_size
;
602 /* Entry point to update the canonical frame address (CFA).
603 LABEL is passed to add_fde_cfi. The value of CFA is now to be
604 calculated from REG+OFFSET. */
607 dwarf2out_def_cfa (label
, reg
, offset
)
608 register const char *label
;
617 def_cfa_1 (label
, &loc
);
620 /* This routine does the actual work. The CFA is now calculated from
621 the dw_cfa_location structure. */
623 def_cfa_1 (label
, loc_p
)
624 register const char *label
;
625 dw_cfa_location
*loc_p
;
627 register dw_cfi_ref cfi
;
628 dw_cfa_location old_cfa
, loc
;
633 if (cfa_store
.reg
== loc
.reg
&& loc
.indirect
== 0)
634 cfa_store
.offset
= loc
.offset
;
636 loc
.reg
= DWARF_FRAME_REGNUM (loc
.reg
);
637 lookup_cfa (&old_cfa
);
639 if (loc
.reg
== old_cfa
.reg
&& loc
.offset
== old_cfa
.offset
&&
640 loc
.indirect
== old_cfa
.indirect
)
642 if (loc
.indirect
== 0
643 || loc
.base_offset
== old_cfa
.base_offset
)
644 /* Nothing changed so no need to issue any call frame
651 if (loc
.reg
== old_cfa
.reg
&& !loc
.indirect
)
653 /* Construct a "DW_CFA_def_cfa_offset <offset>" instruction,
654 indicating the CFA register did not change but the offset
656 cfi
->dw_cfi_opc
= DW_CFA_def_cfa_offset
;
657 cfi
->dw_cfi_oprnd1
.dw_cfi_offset
= loc
.offset
;
660 #ifndef MIPS_DEBUGGING_INFO /* SGI dbx thinks this means no offset. */
661 else if (loc
.offset
== old_cfa
.offset
&& old_cfa
.reg
!= (unsigned long) -1
664 /* Construct a "DW_CFA_def_cfa_register <register>" instruction,
665 indicating the CFA register has changed to <register> but the
666 offset has not changed. */
667 cfi
->dw_cfi_opc
= DW_CFA_def_cfa_register
;
668 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= loc
.reg
;
672 else if (loc
.indirect
== 0)
674 /* Construct a "DW_CFA_def_cfa <register> <offset>" instruction,
675 indicating the CFA register has changed to <register> with
676 the specified offset. */
677 cfi
->dw_cfi_opc
= DW_CFA_def_cfa
;
678 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= loc
.reg
;
679 cfi
->dw_cfi_oprnd2
.dw_cfi_offset
= loc
.offset
;
683 /* Construct a DW_CFA_def_cfa_expression instruction to
684 calculate the CFA using a full location expression since no
685 register-offset pair is available. */
686 struct dw_loc_descr_struct
*loc_list
;
687 cfi
->dw_cfi_opc
= DW_CFA_def_cfa_expression
;
688 loc_list
= build_cfa_loc (&loc
);
689 cfi
->dw_cfi_oprnd1
.dw_cfi_loc
= loc_list
;
692 add_fde_cfi (label
, cfi
);
695 /* Add the CFI for saving a register. REG is the CFA column number.
696 LABEL is passed to add_fde_cfi.
697 If SREG is -1, the register is saved at OFFSET from the CFA;
698 otherwise it is saved in SREG. */
701 reg_save (label
, reg
, sreg
, offset
)
702 register const char *label
;
703 register unsigned reg
;
704 register unsigned sreg
;
705 register long offset
;
707 register dw_cfi_ref cfi
= new_cfi ();
709 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= reg
;
711 /* The following comparison is correct. -1 is used to indicate that
712 the value isn't a register number. */
713 if (sreg
== (unsigned int) -1)
716 /* The register number won't fit in 6 bits, so we have to use
718 cfi
->dw_cfi_opc
= DW_CFA_offset_extended
;
720 cfi
->dw_cfi_opc
= DW_CFA_offset
;
722 #ifdef ENABLE_CHECKING
724 /* If we get an offset that is not a multiple of
725 DWARF_CIE_DATA_ALIGNMENT, there is either a bug in the
726 definition of DWARF_CIE_DATA_ALIGNMENT, or a bug in the machine
728 long check_offset
= offset
/ DWARF_CIE_DATA_ALIGNMENT
;
730 if (check_offset
* DWARF_CIE_DATA_ALIGNMENT
!= offset
)
734 offset
/= DWARF_CIE_DATA_ALIGNMENT
;
737 cfi
->dw_cfi_opc
= DW_CFA_GNU_negative_offset_extended
;
740 cfi
->dw_cfi_oprnd2
.dw_cfi_offset
= offset
;
742 else if (sreg
== reg
)
743 /* We could emit a DW_CFA_same_value in this case, but don't bother. */
747 cfi
->dw_cfi_opc
= DW_CFA_register
;
748 cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
= sreg
;
751 add_fde_cfi (label
, cfi
);
754 /* Add the CFI for saving a register window. LABEL is passed to reg_save.
755 This CFI tells the unwinder that it needs to restore the window registers
756 from the previous frame's window save area.
758 ??? Perhaps we should note in the CIE where windows are saved (instead of
759 assuming 0(cfa)) and what registers are in the window. */
762 dwarf2out_window_save (label
)
763 register const char *label
;
765 register dw_cfi_ref cfi
= new_cfi ();
766 cfi
->dw_cfi_opc
= DW_CFA_GNU_window_save
;
767 add_fde_cfi (label
, cfi
);
770 /* Add a CFI to update the running total of the size of arguments
771 pushed onto the stack. */
774 dwarf2out_args_size (label
, size
)
778 register dw_cfi_ref cfi
;
780 if (size
== old_args_size
)
782 old_args_size
= size
;
785 cfi
->dw_cfi_opc
= DW_CFA_GNU_args_size
;
786 cfi
->dw_cfi_oprnd1
.dw_cfi_offset
= size
;
787 add_fde_cfi (label
, cfi
);
790 /* Entry point for saving a register to the stack. REG is the GCC register
791 number. LABEL and OFFSET are passed to reg_save. */
794 dwarf2out_reg_save (label
, reg
, offset
)
795 register const char *label
;
796 register unsigned reg
;
797 register long offset
;
799 reg_save (label
, DWARF_FRAME_REGNUM (reg
), -1, offset
);
802 /* Entry point for saving the return address in the stack.
803 LABEL and OFFSET are passed to reg_save. */
806 dwarf2out_return_save (label
, offset
)
807 register const char *label
;
808 register long offset
;
810 reg_save (label
, DWARF_FRAME_RETURN_COLUMN
, -1, offset
);
813 /* Entry point for saving the return address in a register.
814 LABEL and SREG are passed to reg_save. */
817 dwarf2out_return_reg (label
, sreg
)
818 register const char *label
;
819 register unsigned sreg
;
821 reg_save (label
, DWARF_FRAME_RETURN_COLUMN
, sreg
, 0);
824 /* Record the initial position of the return address. RTL is
825 INCOMING_RETURN_ADDR_RTX. */
828 initial_return_save (rtl
)
831 unsigned int reg
= (unsigned int) -1;
834 switch (GET_CODE (rtl
))
837 /* RA is in a register. */
838 reg
= DWARF_FRAME_REGNUM (REGNO (rtl
));
841 /* RA is on the stack. */
843 switch (GET_CODE (rtl
))
846 if (REGNO (rtl
) != STACK_POINTER_REGNUM
)
851 if (REGNO (XEXP (rtl
, 0)) != STACK_POINTER_REGNUM
)
853 offset
= INTVAL (XEXP (rtl
, 1));
856 if (REGNO (XEXP (rtl
, 0)) != STACK_POINTER_REGNUM
)
858 offset
= -INTVAL (XEXP (rtl
, 1));
865 /* The return address is at some offset from any value we can
866 actually load. For instance, on the SPARC it is in %i7+8. Just
867 ignore the offset for now; it doesn't matter for unwinding frames. */
868 if (GET_CODE (XEXP (rtl
, 1)) != CONST_INT
)
870 initial_return_save (XEXP (rtl
, 0));
876 reg_save (NULL
, DWARF_FRAME_RETURN_COLUMN
, reg
, offset
- cfa
.offset
);
879 /* Given a SET, calculate the amount of stack adjustment it
883 stack_adjust_offset (pattern
)
886 rtx src
= SET_SRC (pattern
);
887 rtx dest
= SET_DEST (pattern
);
891 if (dest
== stack_pointer_rtx
)
893 /* (set (reg sp) (plus (reg sp) (const_int))) */
894 code
= GET_CODE (src
);
895 if (! (code
== PLUS
|| code
== MINUS
)
896 || XEXP (src
, 0) != stack_pointer_rtx
897 || GET_CODE (XEXP (src
, 1)) != CONST_INT
)
900 offset
= INTVAL (XEXP (src
, 1));
902 else if (GET_CODE (dest
) == MEM
)
904 /* (set (mem (pre_dec (reg sp))) (foo)) */
905 src
= XEXP (dest
, 0);
906 code
= GET_CODE (src
);
908 if (! (code
== PRE_DEC
|| code
== PRE_INC
909 || code
== PRE_MODIFY
)
910 || XEXP (src
, 0) != stack_pointer_rtx
)
913 if (code
== PRE_MODIFY
)
915 rtx val
= XEXP (XEXP (src
, 1), 1);
916 /* We handle only adjustments by constant amount. */
917 if (GET_CODE (XEXP (src
, 1)) != PLUS
||
918 GET_CODE (val
) != CONST_INT
)
920 offset
= -INTVAL (val
);
922 else offset
= GET_MODE_SIZE (GET_MODE (dest
));
927 if (code
== PLUS
|| code
== PRE_INC
)
933 /* Check INSN to see if it looks like a push or a stack adjustment, and
934 make a note of it if it does. EH uses this information to find out how
935 much extra space it needs to pop off the stack. */
938 dwarf2out_stack_adjust (insn
)
944 if (! flag_non_call_exceptions
&& GET_CODE (insn
) == CALL_INSN
)
946 /* Extract the size of the args from the CALL rtx itself. */
948 insn
= PATTERN (insn
);
949 if (GET_CODE (insn
) == PARALLEL
)
950 insn
= XVECEXP (insn
, 0, 0);
951 if (GET_CODE (insn
) == SET
)
952 insn
= SET_SRC (insn
);
953 if (GET_CODE (insn
) != CALL
)
955 dwarf2out_args_size ("", INTVAL (XEXP (insn
, 1)));
959 /* If only calls can throw, and we have a frame pointer,
960 save up adjustments until we see the CALL_INSN. */
961 else if (! flag_non_call_exceptions
962 && cfa
.reg
!= STACK_POINTER_REGNUM
)
965 if (GET_CODE (insn
) == BARRIER
)
967 /* When we see a BARRIER, we know to reset args_size to 0. Usually
968 the compiler will have already emitted a stack adjustment, but
969 doesn't bother for calls to noreturn functions. */
970 #ifdef STACK_GROWS_DOWNWARD
976 else if (GET_CODE (PATTERN (insn
)) == SET
)
978 offset
= stack_adjust_offset (PATTERN (insn
));
980 else if (GET_CODE (PATTERN (insn
)) == PARALLEL
981 || GET_CODE (PATTERN (insn
)) == SEQUENCE
)
983 /* There may be stack adjustments inside compound insns. Search
988 for (j
= XVECLEN (PATTERN (insn
), 0) - 1; j
>= 0; j
--)
990 rtx pattern
= XVECEXP (PATTERN (insn
), 0, j
);
991 if (GET_CODE (pattern
) == SET
)
992 offset
+= stack_adjust_offset (pattern
);
1001 if (cfa
.reg
== STACK_POINTER_REGNUM
)
1002 cfa
.offset
+= offset
;
1004 #ifndef STACK_GROWS_DOWNWARD
1007 args_size
+= offset
;
1011 label
= dwarf2out_cfi_label ();
1012 def_cfa_1 (label
, &cfa
);
1013 dwarf2out_args_size (label
, args_size
);
1016 /* We delay emitting a register save until either (a) we reach the end
1017 of the prologue or (b) the register is clobbered. This clusters
1018 register saves so that there are fewer pc advances. */
1020 struct queued_reg_save
1022 struct queued_reg_save
*next
;
1027 static struct queued_reg_save
*queued_reg_saves
;
1028 static const char *last_reg_save_label
;
1031 queue_reg_save (label
, reg
, offset
)
1036 struct queued_reg_save
*q
= (struct queued_reg_save
*) xmalloc (sizeof (*q
));
1038 q
->next
= queued_reg_saves
;
1040 q
->cfa_offset
= offset
;
1041 queued_reg_saves
= q
;
1043 last_reg_save_label
= label
;
1047 flush_queued_reg_saves ()
1049 struct queued_reg_save
*q
, *next
;
1051 for (q
= queued_reg_saves
; q
; q
= next
)
1053 dwarf2out_reg_save (last_reg_save_label
, REGNO (q
->reg
), q
->cfa_offset
);
1058 queued_reg_saves
= NULL
;
1059 last_reg_save_label
= NULL
;
1063 clobbers_queued_reg_save (insn
)
1066 struct queued_reg_save
*q
;
1068 for (q
= queued_reg_saves
; q
; q
= q
->next
)
1069 if (modified_in_p (q
->reg
, insn
))
1076 /* A temporary register holding an integral value used in adjusting SP
1077 or setting up the store_reg. The "offset" field holds the integer
1078 value, not an offset. */
1079 static dw_cfa_location cfa_temp
;
1081 /* Record call frame debugging information for an expression EXPR,
1082 which either sets SP or FP (adjusting how we calculate the frame
1083 address) or saves a register to the stack. LABEL indicates the
1086 This function encodes a state machine mapping rtxes to actions on
1087 cfa, cfa_store, and cfa_temp.reg. We describe these rules so
1088 users need not read the source code.
1090 The High-Level Picture
1092 Changes in the register we use to calculate the CFA: Currently we
1093 assume that if you copy the CFA register into another register, we
1094 should take the other one as the new CFA register; this seems to
1095 work pretty well. If it's wrong for some target, it's simple
1096 enough not to set RTX_FRAME_RELATED_P on the insn in question.
1098 Changes in the register we use for saving registers to the stack:
1099 This is usually SP, but not always. Again, we deduce that if you
1100 copy SP into another register (and SP is not the CFA register),
1101 then the new register is the one we will be using for register
1102 saves. This also seems to work.
1104 Register saves: There's not much guesswork about this one; if
1105 RTX_FRAME_RELATED_P is set on an insn which modifies memory, it's a
1106 register save, and the register used to calculate the destination
1107 had better be the one we think we're using for this purpose.
1109 Except: If the register being saved is the CFA register, and the
1110 offset is non-zero, we are saving the CFA, so we assume we have to
1111 use DW_CFA_def_cfa_expression. If the offset is 0, we assume that
1112 the intent is to save the value of SP from the previous frame.
1114 Invariants / Summaries of Rules
1116 cfa current rule for calculating the CFA. It usually
1117 consists of a register and an offset.
1118 cfa_store register used by prologue code to save things to the stack
1119 cfa_store.offset is the offset from the value of
1120 cfa_store.reg to the actual CFA
1121 cfa_temp register holding an integral value. cfa_temp.offset
1122 stores the value, which will be used to adjust the
1123 stack pointer. cfa_temp is also used like cfa_store,
1124 to track stores to the stack via fp or a temp reg.
1126 Rules 1- 4: Setting a register's value to cfa.reg or an expression
1127 with cfa.reg as the first operand changes the cfa.reg and its
1128 cfa.offset. Rule 1 and 4 also set cfa_temp.reg and
1131 Rules 6- 9: Set a non-cfa.reg register value to a constant or an
1132 expression yielding a constant. This sets cfa_temp.reg
1133 and cfa_temp.offset.
1135 Rule 5: Create a new register cfa_store used to save items to the
1138 Rules 10-14: Save a register to the stack. Define offset as the
1139 difference of the original location and cfa_store's
1140 location (or cfa_temp's location if cfa_temp is used).
1144 "{a,b}" indicates a choice of a xor b.
1145 "<reg>:cfa.reg" indicates that <reg> must equal cfa.reg.
1148 (set <reg1> <reg2>:cfa.reg)
1149 effects: cfa.reg = <reg1>
1150 cfa.offset unchanged
1151 cfa_temp.reg = <reg1>
1152 cfa_temp.offset = cfa.offset
1155 (set sp ({minus,plus,losum} {sp,fp}:cfa.reg {<const_int>,<reg>:cfa_temp.reg}))
1156 effects: cfa.reg = sp if fp used
1157 cfa.offset += {+/- <const_int>, cfa_temp.offset} if cfa.reg==sp
1158 cfa_store.offset += {+/- <const_int>, cfa_temp.offset}
1159 if cfa_store.reg==sp
1162 (set fp ({minus,plus,losum} <reg>:cfa.reg <const_int>))
1163 effects: cfa.reg = fp
1164 cfa_offset += +/- <const_int>
1167 (set <reg1> ({plus,losum} <reg2>:cfa.reg <const_int>))
1168 constraints: <reg1> != fp
1170 effects: cfa.reg = <reg1>
1171 cfa_temp.reg = <reg1>
1172 cfa_temp.offset = cfa.offset
1175 (set <reg1> (plus <reg2>:cfa_temp.reg sp:cfa.reg))
1176 constraints: <reg1> != fp
1178 effects: cfa_store.reg = <reg1>
1179 cfa_store.offset = cfa.offset - cfa_temp.offset
1182 (set <reg> <const_int>)
1183 effects: cfa_temp.reg = <reg>
1184 cfa_temp.offset = <const_int>
1187 (set <reg1>:cfa_temp.reg (ior <reg2>:cfa_temp.reg <const_int>))
1188 effects: cfa_temp.reg = <reg1>
1189 cfa_temp.offset |= <const_int>
1192 (set <reg> (high <exp>))
1196 (set <reg> (lo_sum <exp> <const_int>))
1197 effects: cfa_temp.reg = <reg>
1198 cfa_temp.offset = <const_int>
1201 (set (mem (pre_modify sp:cfa_store (???? <reg1> <const_int>))) <reg2>)
1202 effects: cfa_store.offset -= <const_int>
1203 cfa.offset = cfa_store.offset if cfa.reg == sp
1205 cfa.base_offset = -cfa_store.offset
1208 (set (mem ({pre_inc,pre_dec} sp:cfa_store.reg)) <reg>)
1209 effects: cfa_store.offset += -/+ mode_size(mem)
1210 cfa.offset = cfa_store.offset if cfa.reg == sp
1212 cfa.base_offset = -cfa_store.offset
1215 (set (mem ({minus,plus,losum} <reg1>:{cfa_store,cfa_temp} <const_int>)) <reg2>)
1216 effects: cfa.reg = <reg1>
1217 cfa.base_offset = -/+ <const_int> - {cfa_store,cfa_temp}.offset
1220 (set (mem <reg1>:{cfa_store,cfa_temp}) <reg2>)
1221 effects: cfa.reg = <reg1>
1222 cfa.base_offset = -{cfa_store,cfa_temp}.offset
1225 (set (mem (postinc <reg1>:cfa_temp <const_int>)) <reg2>)
1226 effects: cfa.reg = <reg1>
1227 cfa.base_offset = -cfa_temp.offset
1228 cfa_temp.offset -= mode_size(mem) */
1231 dwarf2out_frame_debug_expr (expr
, label
)
1238 /* If RTX_FRAME_RELATED_P is set on a PARALLEL, process each member of
1239 the PARALLEL independently. The first element is always processed if
1240 it is a SET. This is for backward compatibility. Other elements
1241 are processed only if they are SETs and the RTX_FRAME_RELATED_P
1242 flag is set in them. */
1244 if (GET_CODE (expr
) == PARALLEL
1245 || GET_CODE (expr
) == SEQUENCE
)
1248 int limit
= XVECLEN (expr
, 0);
1250 for (par_index
= 0; par_index
< limit
; par_index
++)
1252 rtx x
= XVECEXP (expr
, 0, par_index
);
1254 if (GET_CODE (x
) == SET
&&
1255 (RTX_FRAME_RELATED_P (x
) || par_index
== 0))
1256 dwarf2out_frame_debug_expr (x
, label
);
1261 if (GET_CODE (expr
) != SET
)
1264 src
= SET_SRC (expr
);
1265 dest
= SET_DEST (expr
);
1267 switch (GET_CODE (dest
))
1271 /* Update the CFA rule wrt SP or FP. Make sure src is
1272 relative to the current CFA register. */
1273 switch (GET_CODE (src
))
1275 /* Setting FP from SP. */
1277 if (cfa
.reg
== (unsigned) REGNO (src
))
1283 /* We used to require that dest be either SP or FP, but the
1284 ARM copies SP to a temporary register, and from there to
1285 FP. So we just rely on the backends to only set
1286 RTX_FRAME_RELATED_P on appropriate insns. */
1287 cfa
.reg
= REGNO (dest
);
1288 cfa_temp
.reg
= cfa
.reg
;
1289 cfa_temp
.offset
= cfa
.offset
;
1295 if (dest
== stack_pointer_rtx
)
1299 switch (GET_CODE (XEXP (src
, 1)))
1302 offset
= INTVAL (XEXP (src
, 1));
1305 if ((unsigned) REGNO (XEXP (src
, 1)) != cfa_temp
.reg
)
1307 offset
= cfa_temp
.offset
;
1313 if (XEXP (src
, 0) == hard_frame_pointer_rtx
)
1315 /* Restoring SP from FP in the epilogue. */
1316 if (cfa
.reg
!= (unsigned) HARD_FRAME_POINTER_REGNUM
)
1318 cfa
.reg
= STACK_POINTER_REGNUM
;
1320 else if (GET_CODE (src
) == LO_SUM
)
1321 /* Assume we've set the source reg of the LO_SUM from sp. */
1323 else if (XEXP (src
, 0) != stack_pointer_rtx
)
1326 if (GET_CODE (src
) != MINUS
)
1328 if (cfa
.reg
== STACK_POINTER_REGNUM
)
1329 cfa
.offset
+= offset
;
1330 if (cfa_store
.reg
== STACK_POINTER_REGNUM
)
1331 cfa_store
.offset
+= offset
;
1333 else if (dest
== hard_frame_pointer_rtx
)
1336 /* Either setting the FP from an offset of the SP,
1337 or adjusting the FP */
1338 if (! frame_pointer_needed
)
1341 if (GET_CODE (XEXP (src
, 0)) == REG
1342 && (unsigned) REGNO (XEXP (src
, 0)) == cfa
.reg
1343 && GET_CODE (XEXP (src
, 1)) == CONST_INT
)
1345 offset
= INTVAL (XEXP (src
, 1));
1346 if (GET_CODE (src
) != MINUS
)
1348 cfa
.offset
+= offset
;
1349 cfa
.reg
= HARD_FRAME_POINTER_REGNUM
;
1356 if (GET_CODE (src
) == MINUS
)
1360 if (GET_CODE (XEXP (src
, 0)) == REG
1361 && REGNO (XEXP (src
, 0)) == cfa
.reg
1362 && GET_CODE (XEXP (src
, 1)) == CONST_INT
)
1364 /* Setting a temporary CFA register that will be copied
1365 into the FP later on. */
1366 offset
= - INTVAL (XEXP (src
, 1));
1367 cfa
.offset
+= offset
;
1368 cfa
.reg
= REGNO (dest
);
1369 /* Or used to save regs to the stack. */
1370 cfa_temp
.reg
= cfa
.reg
;
1371 cfa_temp
.offset
= cfa
.offset
;
1374 else if (GET_CODE (XEXP (src
, 0)) == REG
1375 && REGNO (XEXP (src
, 0)) == cfa_temp
.reg
1376 && XEXP (src
, 1) == stack_pointer_rtx
)
1378 /* Setting a scratch register that we will use instead
1379 of SP for saving registers to the stack. */
1380 if (cfa
.reg
!= STACK_POINTER_REGNUM
)
1382 cfa_store
.reg
= REGNO (dest
);
1383 cfa_store
.offset
= cfa
.offset
- cfa_temp
.offset
;
1386 else if (GET_CODE (src
) == LO_SUM
1387 && GET_CODE (XEXP (src
, 1)) == CONST_INT
)
1389 cfa_temp
.reg
= REGNO (dest
);
1390 cfa_temp
.offset
= INTVAL (XEXP (src
, 1));
1399 cfa_temp
.reg
= REGNO (dest
);
1400 cfa_temp
.offset
= INTVAL (src
);
1405 if (GET_CODE (XEXP (src
, 0)) != REG
1406 || (unsigned) REGNO (XEXP (src
, 0)) != cfa_temp
.reg
1407 || GET_CODE (XEXP (src
, 1)) != CONST_INT
)
1409 if ((unsigned) REGNO (dest
) != cfa_temp
.reg
)
1410 cfa_temp
.reg
= REGNO (dest
);
1411 cfa_temp
.offset
|= INTVAL (XEXP (src
, 1));
1414 /* Skip over HIGH, assuming it will be followed by a LO_SUM,
1415 which will fill in all of the bits. */
1423 def_cfa_1 (label
, &cfa
);
1427 if (GET_CODE (src
) != REG
)
1430 /* Saving a register to the stack. Make sure dest is relative to the
1432 switch (GET_CODE (XEXP (dest
, 0)))
1437 /* We can't handle variable size modifications. */
1438 if (GET_CODE (XEXP (XEXP (XEXP (dest
, 0), 1), 1)) != CONST_INT
)
1440 offset
= -INTVAL (XEXP (XEXP (XEXP (dest
, 0), 1), 1));
1442 if (REGNO (XEXP (XEXP (dest
, 0), 0)) != STACK_POINTER_REGNUM
1443 || cfa_store
.reg
!= STACK_POINTER_REGNUM
)
1445 cfa_store
.offset
+= offset
;
1446 if (cfa
.reg
== STACK_POINTER_REGNUM
)
1447 cfa
.offset
= cfa_store
.offset
;
1449 offset
= -cfa_store
.offset
;
1454 offset
= GET_MODE_SIZE (GET_MODE (dest
));
1455 if (GET_CODE (XEXP (dest
, 0)) == PRE_INC
)
1458 if (REGNO (XEXP (XEXP (dest
, 0), 0)) != STACK_POINTER_REGNUM
1459 || cfa_store
.reg
!= STACK_POINTER_REGNUM
)
1461 cfa_store
.offset
+= offset
;
1462 if (cfa
.reg
== STACK_POINTER_REGNUM
)
1463 cfa
.offset
= cfa_store
.offset
;
1465 offset
= -cfa_store
.offset
;
1469 /* With an offset. */
1473 if (GET_CODE (XEXP (XEXP (dest
, 0), 1)) != CONST_INT
)
1475 offset
= INTVAL (XEXP (XEXP (dest
, 0), 1));
1476 if (GET_CODE (XEXP (dest
, 0)) == MINUS
)
1479 if (cfa_store
.reg
== (unsigned) REGNO (XEXP (XEXP (dest
, 0), 0)))
1480 offset
-= cfa_store
.offset
;
1481 else if (cfa_temp
.reg
== (unsigned) REGNO (XEXP (XEXP (dest
, 0), 0)))
1482 offset
-= cfa_temp
.offset
;
1488 /* Without an offset. */
1490 if (cfa_store
.reg
== (unsigned) REGNO (XEXP (dest
, 0)))
1491 offset
= -cfa_store
.offset
;
1492 else if (cfa_temp
.reg
== (unsigned) REGNO (XEXP (dest
, 0)))
1493 offset
= -cfa_temp
.offset
;
1500 if (cfa_temp
.reg
!= (unsigned) REGNO (XEXP (XEXP (dest
, 0), 0)))
1502 offset
= -cfa_temp
.offset
;
1503 cfa_temp
.offset
-= GET_MODE_SIZE (GET_MODE (dest
));
1510 if (REGNO (src
) != STACK_POINTER_REGNUM
1511 && REGNO (src
) != HARD_FRAME_POINTER_REGNUM
1512 && (unsigned) REGNO (src
) == cfa
.reg
)
1514 /* We're storing the current CFA reg into the stack. */
1516 if (cfa
.offset
== 0)
1518 /* If the source register is exactly the CFA, assume
1519 we're saving SP like any other register; this happens
1522 def_cfa_1 (label
, &cfa
);
1523 queue_reg_save (label
, stack_pointer_rtx
, offset
);
1528 /* Otherwise, we'll need to look in the stack to
1529 calculate the CFA. */
1531 rtx x
= XEXP (dest
, 0);
1532 if (GET_CODE (x
) != REG
)
1534 if (GET_CODE (x
) != REG
)
1536 cfa
.reg
= (unsigned) REGNO (x
);
1537 cfa
.base_offset
= offset
;
1539 def_cfa_1 (label
, &cfa
);
1544 def_cfa_1 (label
, &cfa
);
1545 queue_reg_save (label
, src
, offset
);
1553 /* Record call frame debugging information for INSN, which either
1554 sets SP or FP (adjusting how we calculate the frame address) or saves a
1555 register to the stack. If INSN is NULL_RTX, initialize our state. */
1558 dwarf2out_frame_debug (insn
)
1564 if (insn
== NULL_RTX
)
1566 /* Flush any queued register saves. */
1567 flush_queued_reg_saves ();
1569 /* Set up state for generating call frame debug info. */
1571 if (cfa
.reg
!= (unsigned long) DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM
))
1573 cfa
.reg
= STACK_POINTER_REGNUM
;
1576 cfa_temp
.offset
= 0;
1580 if (GET_CODE (insn
) != INSN
|| clobbers_queued_reg_save (insn
))
1581 flush_queued_reg_saves ();
1583 if (! RTX_FRAME_RELATED_P (insn
))
1585 if (!ACCUMULATE_OUTGOING_ARGS
)
1586 dwarf2out_stack_adjust (insn
);
1590 label
= dwarf2out_cfi_label ();
1592 src
= find_reg_note (insn
, REG_FRAME_RELATED_EXPR
, NULL_RTX
);
1594 insn
= XEXP (src
, 0);
1596 insn
= PATTERN (insn
);
1598 dwarf2out_frame_debug_expr (insn
, label
);
1601 /* Output a Call Frame Information opcode and its operand(s). */
1604 output_cfi (cfi
, fde
, for_eh
)
1605 register dw_cfi_ref cfi
;
1606 register dw_fde_ref fde
;
1609 if (cfi
->dw_cfi_opc
== DW_CFA_advance_loc
)
1611 dw2_asm_output_data (1, (cfi
->dw_cfi_opc
1612 | (cfi
->dw_cfi_oprnd1
.dw_cfi_offset
& 0x3f)),
1613 "DW_CFA_advance_loc 0x%lx",
1614 cfi
->dw_cfi_oprnd1
.dw_cfi_offset
);
1616 else if (cfi
->dw_cfi_opc
== DW_CFA_offset
)
1618 dw2_asm_output_data (1, (cfi
->dw_cfi_opc
1619 | (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
& 0x3f)),
1620 "DW_CFA_offset, column 0x%lx",
1621 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1622 dw2_asm_output_data_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_offset
, NULL
);
1624 else if (cfi
->dw_cfi_opc
== DW_CFA_restore
)
1626 dw2_asm_output_data (1, (cfi
->dw_cfi_opc
1627 | (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
& 0x3f)),
1628 "DW_CFA_restore, column 0x%lx",
1629 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1633 dw2_asm_output_data (1, cfi
->dw_cfi_opc
,
1634 "%s", dwarf_cfi_name (cfi
->dw_cfi_opc
));
1636 switch (cfi
->dw_cfi_opc
)
1638 case DW_CFA_set_loc
:
1640 dw2_asm_output_encoded_addr_rtx (
1641 ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0),
1642 gen_rtx_SYMBOL_REF (Pmode
, cfi
->dw_cfi_oprnd1
.dw_cfi_addr
),
1645 dw2_asm_output_addr (DWARF2_ADDR_SIZE
,
1646 cfi
->dw_cfi_oprnd1
.dw_cfi_addr
, NULL
);
1648 case DW_CFA_advance_loc1
:
1649 dw2_asm_output_delta (1, cfi
->dw_cfi_oprnd1
.dw_cfi_addr
,
1650 fde
->dw_fde_current_label
, NULL
);
1651 fde
->dw_fde_current_label
= cfi
->dw_cfi_oprnd1
.dw_cfi_addr
;
1653 case DW_CFA_advance_loc2
:
1654 dw2_asm_output_delta (2, cfi
->dw_cfi_oprnd1
.dw_cfi_addr
,
1655 fde
->dw_fde_current_label
, NULL
);
1656 fde
->dw_fde_current_label
= cfi
->dw_cfi_oprnd1
.dw_cfi_addr
;
1658 case DW_CFA_advance_loc4
:
1659 dw2_asm_output_delta (4, cfi
->dw_cfi_oprnd1
.dw_cfi_addr
,
1660 fde
->dw_fde_current_label
, NULL
);
1661 fde
->dw_fde_current_label
= cfi
->dw_cfi_oprnd1
.dw_cfi_addr
;
1663 case DW_CFA_MIPS_advance_loc8
:
1664 dw2_asm_output_delta (8, cfi
->dw_cfi_oprnd1
.dw_cfi_addr
,
1665 fde
->dw_fde_current_label
, NULL
);
1666 fde
->dw_fde_current_label
= cfi
->dw_cfi_oprnd1
.dw_cfi_addr
;
1668 case DW_CFA_offset_extended
:
1669 case DW_CFA_GNU_negative_offset_extended
:
1670 case DW_CFA_def_cfa
:
1671 dw2_asm_output_data_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
, NULL
);
1672 dw2_asm_output_data_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_offset
, NULL
);
1674 case DW_CFA_restore_extended
:
1675 case DW_CFA_undefined
:
1676 case DW_CFA_same_value
:
1677 case DW_CFA_def_cfa_register
:
1678 dw2_asm_output_data_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
, NULL
);
1680 case DW_CFA_register
:
1681 dw2_asm_output_data_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
, NULL
);
1682 dw2_asm_output_data_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
, NULL
);
1684 case DW_CFA_def_cfa_offset
:
1685 case DW_CFA_GNU_args_size
:
1686 dw2_asm_output_data_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_offset
, NULL
);
1688 case DW_CFA_GNU_window_save
:
1690 case DW_CFA_def_cfa_expression
:
1691 output_cfa_loc (cfi
);
1699 /* Output the call frame information used to used to record information
1700 that relates to calculating the frame pointer, and records the
1701 location of saved registers. */
1704 output_call_frame_info (for_eh
)
1707 register unsigned int i
;
1708 register dw_fde_ref fde
;
1709 register dw_cfi_ref cfi
;
1710 char l1
[20], l2
[20];
1711 int any_lsda_needed
= 0;
1712 char augmentation
[6];
1713 int augmentation_size
;
1714 int fde_encoding
= DW_EH_PE_absptr
;
1715 int per_encoding
= DW_EH_PE_absptr
;
1716 int lsda_encoding
= DW_EH_PE_absptr
;
1718 /* If we don't have any functions we'll want to unwind out of, don't
1719 emit any EH unwind information. */
1722 int any_eh_needed
= 0;
1723 for (i
= 0; i
< fde_table_in_use
; ++i
)
1724 if (fde_table
[i
].uses_eh_lsda
)
1725 any_eh_needed
= any_lsda_needed
= 1;
1726 else if (! fde_table
[i
].nothrow
)
1729 if (! any_eh_needed
)
1733 /* We're going to be generating comments, so turn on app. */
1739 #ifdef EH_FRAME_SECTION_NAME
1740 named_section_flags (EH_FRAME_SECTION_NAME
, SECTION_WRITE
,
1743 tree label
= get_file_function_name ('F');
1746 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (PTR_SIZE
));
1747 ASM_GLOBALIZE_LABEL (asm_out_file
, IDENTIFIER_POINTER (label
));
1748 ASM_OUTPUT_LABEL (asm_out_file
, IDENTIFIER_POINTER (label
));
1750 assemble_label ("__FRAME_BEGIN__");
1753 named_section_flags (DEBUG_FRAME_SECTION
, SECTION_DEBUG
, 1);
1755 /* Output the CIE. */
1756 ASM_GENERATE_INTERNAL_LABEL (l1
, CIE_AFTER_SIZE_LABEL
, for_eh
);
1757 ASM_GENERATE_INTERNAL_LABEL (l2
, CIE_END_LABEL
, for_eh
);
1758 dw2_asm_output_delta (for_eh
? 4 : DWARF_OFFSET_SIZE
, l2
, l1
,
1759 "Length of Common Information Entry");
1760 ASM_OUTPUT_LABEL (asm_out_file
, l1
);
1762 /* Now that the CIE pointer is PC-relative for EH,
1763 use 0 to identify the CIE. */
1764 dw2_asm_output_data ((for_eh
? 4 : DWARF_OFFSET_SIZE
),
1765 (for_eh
? 0 : DW_CIE_ID
),
1766 "CIE Identifier Tag");
1768 dw2_asm_output_data (1, DW_CIE_VERSION
, "CIE Version");
1770 augmentation
[0] = 0;
1771 augmentation_size
= 0;
1777 z Indicates that a uleb128 is present to size the
1778 augmentation section.
1779 L Indicates the encoding (and thus presence) of
1780 an LSDA pointer in the FDE augmentation.
1781 R Indicates a non-default pointer encoding for
1783 P Indicates the presence of an encoding + language
1784 personality routine in the CIE augmentation. */
1786 fde_encoding
= ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0);
1787 per_encoding
= ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1);
1788 lsda_encoding
= ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0);
1790 p
= augmentation
+ 1;
1791 if (eh_personality_libfunc
)
1794 augmentation_size
+= 1 + size_of_encoded_value (per_encoding
);
1796 if (any_lsda_needed
)
1799 augmentation_size
+= 1;
1801 if (fde_encoding
!= DW_EH_PE_absptr
)
1804 augmentation_size
+= 1;
1806 if (p
> augmentation
+ 1)
1808 augmentation
[0] = 'z';
1812 /* Ug. Some platforms can't do unaligned dynamic relocations at all. */
1813 if (eh_personality_libfunc
&& per_encoding
== DW_EH_PE_aligned
)
1815 int offset
= ( 4 /* Length */
1817 + 1 /* CIE version */
1818 + strlen (augmentation
) + 1 /* Augmentation */
1819 + size_of_uleb128 (1) /* Code alignment */
1820 + size_of_sleb128 (DWARF_CIE_DATA_ALIGNMENT
)
1822 + 1 /* Augmentation size */
1823 + 1 /* Personality encoding */ );
1824 int pad
= -offset
& (PTR_SIZE
- 1);
1826 augmentation_size
+= pad
;
1828 /* Augmentations should be small, so there's scarce need to
1829 iterate for a solution. Die if we exceed one uleb128 byte. */
1830 if (size_of_uleb128 (augmentation_size
) != 1)
1834 dw2_asm_output_nstring (augmentation
, -1, "CIE Augmentation");
1836 dw2_asm_output_data_uleb128 (1, "CIE Code Alignment Factor");
1838 dw2_asm_output_data_sleb128 (DWARF_CIE_DATA_ALIGNMENT
,
1839 "CIE Data Alignment Factor");
1841 dw2_asm_output_data (1, DWARF_FRAME_RETURN_COLUMN
, "CIE RA Column");
1843 if (augmentation
[0])
1845 dw2_asm_output_data_uleb128 (augmentation_size
, "Augmentation size");
1846 if (eh_personality_libfunc
)
1848 dw2_asm_output_data (1, per_encoding
, "Personality (%s)",
1849 eh_data_format_name (per_encoding
));
1850 dw2_asm_output_encoded_addr_rtx (per_encoding
,
1851 eh_personality_libfunc
, NULL
);
1853 if (any_lsda_needed
)
1854 dw2_asm_output_data (1, lsda_encoding
, "LSDA Encoding (%s)",
1855 eh_data_format_name (lsda_encoding
));
1856 if (fde_encoding
!= DW_EH_PE_absptr
)
1857 dw2_asm_output_data (1, fde_encoding
, "FDE Encoding (%s)",
1858 eh_data_format_name (fde_encoding
));
1861 for (cfi
= cie_cfi_head
; cfi
!= NULL
; cfi
= cfi
->dw_cfi_next
)
1862 output_cfi (cfi
, NULL
, for_eh
);
1864 /* Pad the CIE out to an address sized boundary. */
1865 ASM_OUTPUT_ALIGN (asm_out_file
,
1866 floor_log2 (for_eh
? PTR_SIZE
: DWARF2_ADDR_SIZE
));
1867 ASM_OUTPUT_LABEL (asm_out_file
, l2
);
1869 /* Loop through all of the FDE's. */
1870 for (i
= 0; i
< fde_table_in_use
; ++i
)
1872 fde
= &fde_table
[i
];
1874 /* Don't emit EH unwind info for leaf functions that don't need it. */
1875 if (for_eh
&& fde
->nothrow
&& ! fde
->uses_eh_lsda
)
1878 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, FDE_LABEL
, for_eh
+ i
* 2);
1879 ASM_GENERATE_INTERNAL_LABEL (l1
, FDE_AFTER_SIZE_LABEL
, for_eh
+ i
* 2);
1880 ASM_GENERATE_INTERNAL_LABEL (l2
, FDE_END_LABEL
, for_eh
+ i
* 2);
1881 dw2_asm_output_delta (for_eh
? 4 : DWARF_OFFSET_SIZE
, l2
, l1
,
1883 ASM_OUTPUT_LABEL (asm_out_file
, l1
);
1885 /* ??? This always emits a 4 byte offset when for_eh is true, but it
1886 emits a target dependent sized offset when for_eh is not true.
1887 This inconsistency may confuse gdb. The only case where we need a
1888 non-4 byte offset is for the Irix6 N64 ABI, so we may lose SGI
1889 compatibility if we emit a 4 byte offset. We need a 4 byte offset
1890 though in order to be compatible with the dwarf_fde struct in frame.c.
1891 If the for_eh case is changed, then the struct in frame.c has
1892 to be adjusted appropriately. */
1894 dw2_asm_output_delta (4, l1
, "__FRAME_BEGIN__", "FDE CIE offset");
1896 dw2_asm_output_offset (DWARF_OFFSET_SIZE
,
1897 stripattributes (DEBUG_FRAME_SECTION
),
1902 dw2_asm_output_encoded_addr_rtx (fde_encoding
,
1903 gen_rtx_SYMBOL_REF (Pmode
, fde
->dw_fde_begin
),
1904 "FDE initial location");
1905 dw2_asm_output_delta (size_of_encoded_value (fde_encoding
),
1906 fde
->dw_fde_end
, fde
->dw_fde_begin
,
1907 "FDE address range");
1911 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, fde
->dw_fde_begin
,
1912 "FDE initial location");
1913 dw2_asm_output_delta (DWARF2_ADDR_SIZE
,
1914 fde
->dw_fde_end
, fde
->dw_fde_begin
,
1915 "FDE address range");
1918 if (augmentation
[0])
1920 if (any_lsda_needed
)
1922 int size
= size_of_encoded_value (lsda_encoding
);
1924 if (lsda_encoding
== DW_EH_PE_aligned
)
1926 int offset
= ( 4 /* Length */
1927 + 4 /* CIE offset */
1928 + 2 * size_of_encoded_value (fde_encoding
)
1929 + 1 /* Augmentation size */ );
1930 int pad
= -offset
& (PTR_SIZE
- 1);
1933 if (size_of_uleb128 (size
) != 1)
1937 dw2_asm_output_data_uleb128 (size
, "Augmentation size");
1939 if (fde
->uses_eh_lsda
)
1941 ASM_GENERATE_INTERNAL_LABEL (l1
, "LLSDA",
1942 fde
->funcdef_number
);
1943 dw2_asm_output_encoded_addr_rtx (
1944 lsda_encoding
, gen_rtx_SYMBOL_REF (Pmode
, l1
),
1945 "Language Specific Data Area");
1949 if (lsda_encoding
== DW_EH_PE_aligned
)
1950 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (PTR_SIZE
));
1951 dw2_asm_output_data (size_of_encoded_value (lsda_encoding
),
1952 0, "Language Specific Data Area (none)");
1956 dw2_asm_output_data_uleb128 (0, "Augmentation size");
1959 /* Loop through the Call Frame Instructions associated with
1961 fde
->dw_fde_current_label
= fde
->dw_fde_begin
;
1962 for (cfi
= fde
->dw_fde_cfi
; cfi
!= NULL
; cfi
= cfi
->dw_cfi_next
)
1963 output_cfi (cfi
, fde
, for_eh
);
1965 /* Pad the FDE out to an address sized boundary. */
1966 ASM_OUTPUT_ALIGN (asm_out_file
,
1967 floor_log2 ((for_eh
? PTR_SIZE
: DWARF2_ADDR_SIZE
)));
1968 ASM_OUTPUT_LABEL (asm_out_file
, l2
);
1971 #ifndef EH_FRAME_SECTION_NAME
1973 dw2_asm_output_data (4, 0, "End of Table");
1975 #ifdef MIPS_DEBUGGING_INFO
1976 /* Work around Irix 6 assembler bug whereby labels at the end of a section
1977 get a value of 0. Putting .align 0 after the label fixes it. */
1978 ASM_OUTPUT_ALIGN (asm_out_file
, 0);
1981 /* Turn off app to make assembly quicker. */
1986 /* Output a marker (i.e. a label) for the beginning of a function, before
1990 dwarf2out_begin_prologue (line
, file
)
1991 unsigned int line ATTRIBUTE_UNUSED
;
1992 const char *file ATTRIBUTE_UNUSED
;
1994 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1995 register dw_fde_ref fde
;
1997 current_function_func_begin_label
= 0;
1999 #ifdef IA64_UNWIND_INFO
2000 /* ??? current_function_func_begin_label is also used by except.c
2001 for call-site information. We must emit this label if it might
2003 if ((! flag_exceptions
|| USING_SJLJ_EXCEPTIONS
)
2004 && ! dwarf2out_do_frame ())
2007 if (! dwarf2out_do_frame ())
2011 ++current_funcdef_number
;
2013 function_section (current_function_decl
);
2014 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_BEGIN_LABEL
,
2015 current_funcdef_number
);
2016 ASM_OUTPUT_DEBUG_LABEL (asm_out_file
, FUNC_BEGIN_LABEL
,
2017 current_funcdef_number
);
2018 current_function_func_begin_label
= get_identifier (label
);
2020 #ifdef IA64_UNWIND_INFO
2021 /* We can elide the fde allocation if we're not emitting debug info. */
2022 if (! dwarf2out_do_frame ())
2026 /* Expand the fde table if necessary. */
2027 if (fde_table_in_use
== fde_table_allocated
)
2029 fde_table_allocated
+= FDE_TABLE_INCREMENT
;
2031 = (dw_fde_ref
) xrealloc (fde_table
,
2032 fde_table_allocated
* sizeof (dw_fde_node
));
2035 /* Record the FDE associated with this function. */
2036 current_funcdef_fde
= fde_table_in_use
;
2038 /* Add the new FDE at the end of the fde_table. */
2039 fde
= &fde_table
[fde_table_in_use
++];
2040 fde
->dw_fde_begin
= xstrdup (label
);
2041 fde
->dw_fde_current_label
= NULL
;
2042 fde
->dw_fde_end
= NULL
;
2043 fde
->dw_fde_cfi
= NULL
;
2044 fde
->funcdef_number
= current_funcdef_number
;
2045 fde
->nothrow
= current_function_nothrow
;
2046 fde
->uses_eh_lsda
= cfun
->uses_eh_lsda
;
2048 args_size
= old_args_size
= 0;
2050 /* We only want to output line number information for the genuine
2051 dwarf2 prologue case, not the eh frame case. */
2052 #ifdef DWARF2_DEBUGGING_INFO
2054 dwarf2out_source_line (line
, file
);
2058 /* Output a marker (i.e. a label) for the absolute end of the generated code
2059 for a function definition. This gets called *after* the epilogue code has
2063 dwarf2out_end_epilogue ()
2066 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2068 /* Output a label to mark the endpoint of the code generated for this
2070 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_END_LABEL
, current_funcdef_number
);
2071 ASM_OUTPUT_LABEL (asm_out_file
, label
);
2072 fde
= &fde_table
[fde_table_in_use
- 1];
2073 fde
->dw_fde_end
= xstrdup (label
);
2077 dwarf2out_frame_init ()
2079 /* Allocate the initial hunk of the fde_table. */
2080 fde_table
= (dw_fde_ref
) xcalloc (FDE_TABLE_INCREMENT
, sizeof (dw_fde_node
));
2081 fde_table_allocated
= FDE_TABLE_INCREMENT
;
2082 fde_table_in_use
= 0;
2084 /* Generate the CFA instructions common to all FDE's. Do it now for the
2085 sake of lookup_cfa. */
2087 #ifdef DWARF2_UNWIND_INFO
2088 /* On entry, the Canonical Frame Address is at SP. */
2089 dwarf2out_def_cfa (NULL
, STACK_POINTER_REGNUM
, INCOMING_FRAME_SP_OFFSET
);
2090 initial_return_save (INCOMING_RETURN_ADDR_RTX
);
2095 dwarf2out_frame_finish ()
2097 /* Output call frame information. */
2098 #ifdef MIPS_DEBUGGING_INFO
2099 if (write_symbols
== DWARF2_DEBUG
)
2100 output_call_frame_info (0);
2101 if (flag_unwind_tables
|| (flag_exceptions
&& ! USING_SJLJ_EXCEPTIONS
))
2102 output_call_frame_info (1);
2104 if (write_symbols
== DWARF2_DEBUG
2105 || flag_unwind_tables
|| (flag_exceptions
&& ! USING_SJLJ_EXCEPTIONS
))
2106 output_call_frame_info (1);
2110 /* And now, the subset of the debugging information support code necessary
2111 for emitting location expressions. */
2113 typedef struct dw_val_struct
*dw_val_ref
;
2114 typedef struct die_struct
*dw_die_ref
;
2115 typedef struct dw_loc_descr_struct
*dw_loc_descr_ref
;
2116 typedef struct dw_loc_list_struct
*dw_loc_list_ref
;
2118 /* Each DIE may have a series of attribute/value pairs. Values
2119 can take on several forms. The forms that are used in this
2120 implementation are listed below. */
2125 dw_val_class_offset
,
2127 dw_val_class_loc_list
,
2129 dw_val_class_unsigned_const
,
2130 dw_val_class_long_long
,
2133 dw_val_class_die_ref
,
2134 dw_val_class_fde_ref
,
2135 dw_val_class_lbl_id
,
2136 dw_val_class_lbl_offset
,
2141 /* Describe a double word constant value. */
2142 /* ??? Every instance of long_long in the code really means CONST_DOUBLE. */
2144 typedef struct dw_long_long_struct
2151 /* Describe a floating point constant value. */
2153 typedef struct dw_fp_struct
2160 /* The dw_val_node describes an attribute's value, as it is
2161 represented internally. */
2163 typedef struct dw_val_struct
2165 dw_val_class val_class
;
2169 long unsigned val_offset
;
2170 dw_loc_list_ref val_loc_list
;
2171 dw_loc_descr_ref val_loc
;
2173 long unsigned val_unsigned
;
2174 dw_long_long_const val_long_long
;
2175 dw_float_const val_float
;
2180 unsigned val_fde_index
;
2183 unsigned char val_flag
;
2189 /* Locations in memory are described using a sequence of stack machine
2192 typedef struct dw_loc_descr_struct
2194 dw_loc_descr_ref dw_loc_next
;
2195 enum dwarf_location_atom dw_loc_opc
;
2196 dw_val_node dw_loc_oprnd1
;
2197 dw_val_node dw_loc_oprnd2
;
2202 /* Location lists are ranges + location descriptions for that range,
2203 so you can track variables that are in different places over
2204 their entire life. */
2205 typedef struct dw_loc_list_struct
2207 dw_loc_list_ref dw_loc_next
;
2208 const char *begin
; /* Label for begin address of range */
2209 const char *end
; /* Label for end address of range */
2210 char *ll_symbol
; /* Label for beginning of location list. Only on head of list */
2211 const char *section
; /* Section this loclist is relative to */
2212 dw_loc_descr_ref expr
;
2215 static const char *dwarf_stack_op_name
PARAMS ((unsigned));
2216 static dw_loc_descr_ref new_loc_descr
PARAMS ((enum dwarf_location_atom
,
2219 static void add_loc_descr
PARAMS ((dw_loc_descr_ref
*,
2221 static unsigned long size_of_loc_descr
PARAMS ((dw_loc_descr_ref
));
2222 static unsigned long size_of_locs
PARAMS ((dw_loc_descr_ref
));
2223 static void output_loc_operands
PARAMS ((dw_loc_descr_ref
));
2224 static void output_loc_sequence
PARAMS ((dw_loc_descr_ref
));
2226 /* Convert a DWARF stack opcode into its string name. */
2229 dwarf_stack_op_name (op
)
2230 register unsigned op
;
2235 return "DW_OP_addr";
2237 return "DW_OP_deref";
2239 return "DW_OP_const1u";
2241 return "DW_OP_const1s";
2243 return "DW_OP_const2u";
2245 return "DW_OP_const2s";
2247 return "DW_OP_const4u";
2249 return "DW_OP_const4s";
2251 return "DW_OP_const8u";
2253 return "DW_OP_const8s";
2255 return "DW_OP_constu";
2257 return "DW_OP_consts";
2261 return "DW_OP_drop";
2263 return "DW_OP_over";
2265 return "DW_OP_pick";
2267 return "DW_OP_swap";
2271 return "DW_OP_xderef";
2279 return "DW_OP_minus";
2291 return "DW_OP_plus";
2292 case DW_OP_plus_uconst
:
2293 return "DW_OP_plus_uconst";
2299 return "DW_OP_shra";
2317 return "DW_OP_skip";
2319 return "DW_OP_lit0";
2321 return "DW_OP_lit1";
2323 return "DW_OP_lit2";
2325 return "DW_OP_lit3";
2327 return "DW_OP_lit4";
2329 return "DW_OP_lit5";
2331 return "DW_OP_lit6";
2333 return "DW_OP_lit7";
2335 return "DW_OP_lit8";
2337 return "DW_OP_lit9";
2339 return "DW_OP_lit10";
2341 return "DW_OP_lit11";
2343 return "DW_OP_lit12";
2345 return "DW_OP_lit13";
2347 return "DW_OP_lit14";
2349 return "DW_OP_lit15";
2351 return "DW_OP_lit16";
2353 return "DW_OP_lit17";
2355 return "DW_OP_lit18";
2357 return "DW_OP_lit19";
2359 return "DW_OP_lit20";
2361 return "DW_OP_lit21";
2363 return "DW_OP_lit22";
2365 return "DW_OP_lit23";
2367 return "DW_OP_lit24";
2369 return "DW_OP_lit25";
2371 return "DW_OP_lit26";
2373 return "DW_OP_lit27";
2375 return "DW_OP_lit28";
2377 return "DW_OP_lit29";
2379 return "DW_OP_lit30";
2381 return "DW_OP_lit31";
2383 return "DW_OP_reg0";
2385 return "DW_OP_reg1";
2387 return "DW_OP_reg2";
2389 return "DW_OP_reg3";
2391 return "DW_OP_reg4";
2393 return "DW_OP_reg5";
2395 return "DW_OP_reg6";
2397 return "DW_OP_reg7";
2399 return "DW_OP_reg8";
2401 return "DW_OP_reg9";
2403 return "DW_OP_reg10";
2405 return "DW_OP_reg11";
2407 return "DW_OP_reg12";
2409 return "DW_OP_reg13";
2411 return "DW_OP_reg14";
2413 return "DW_OP_reg15";
2415 return "DW_OP_reg16";
2417 return "DW_OP_reg17";
2419 return "DW_OP_reg18";
2421 return "DW_OP_reg19";
2423 return "DW_OP_reg20";
2425 return "DW_OP_reg21";
2427 return "DW_OP_reg22";
2429 return "DW_OP_reg23";
2431 return "DW_OP_reg24";
2433 return "DW_OP_reg25";
2435 return "DW_OP_reg26";
2437 return "DW_OP_reg27";
2439 return "DW_OP_reg28";
2441 return "DW_OP_reg29";
2443 return "DW_OP_reg30";
2445 return "DW_OP_reg31";
2447 return "DW_OP_breg0";
2449 return "DW_OP_breg1";
2451 return "DW_OP_breg2";
2453 return "DW_OP_breg3";
2455 return "DW_OP_breg4";
2457 return "DW_OP_breg5";
2459 return "DW_OP_breg6";
2461 return "DW_OP_breg7";
2463 return "DW_OP_breg8";
2465 return "DW_OP_breg9";
2467 return "DW_OP_breg10";
2469 return "DW_OP_breg11";
2471 return "DW_OP_breg12";
2473 return "DW_OP_breg13";
2475 return "DW_OP_breg14";
2477 return "DW_OP_breg15";
2479 return "DW_OP_breg16";
2481 return "DW_OP_breg17";
2483 return "DW_OP_breg18";
2485 return "DW_OP_breg19";
2487 return "DW_OP_breg20";
2489 return "DW_OP_breg21";
2491 return "DW_OP_breg22";
2493 return "DW_OP_breg23";
2495 return "DW_OP_breg24";
2497 return "DW_OP_breg25";
2499 return "DW_OP_breg26";
2501 return "DW_OP_breg27";
2503 return "DW_OP_breg28";
2505 return "DW_OP_breg29";
2507 return "DW_OP_breg30";
2509 return "DW_OP_breg31";
2511 return "DW_OP_regx";
2513 return "DW_OP_fbreg";
2515 return "DW_OP_bregx";
2517 return "DW_OP_piece";
2518 case DW_OP_deref_size
:
2519 return "DW_OP_deref_size";
2520 case DW_OP_xderef_size
:
2521 return "DW_OP_xderef_size";
2525 return "OP_<unknown>";
2529 /* Return a pointer to a newly allocated location description. Location
2530 descriptions are simple expression terms that can be strung
2531 together to form more complicated location (address) descriptions. */
2533 static inline dw_loc_descr_ref
2534 new_loc_descr (op
, oprnd1
, oprnd2
)
2535 register enum dwarf_location_atom op
;
2536 register unsigned long oprnd1
;
2537 register unsigned long oprnd2
;
2539 /* Use xcalloc here so we clear out all of the long_long constant in
2541 register dw_loc_descr_ref descr
2542 = (dw_loc_descr_ref
) xcalloc (1, sizeof (dw_loc_descr_node
));
2544 descr
->dw_loc_opc
= op
;
2545 descr
->dw_loc_oprnd1
.val_class
= dw_val_class_unsigned_const
;
2546 descr
->dw_loc_oprnd1
.v
.val_unsigned
= oprnd1
;
2547 descr
->dw_loc_oprnd2
.val_class
= dw_val_class_unsigned_const
;
2548 descr
->dw_loc_oprnd2
.v
.val_unsigned
= oprnd2
;
2554 /* Add a location description term to a location description expression. */
2557 add_loc_descr (list_head
, descr
)
2558 register dw_loc_descr_ref
*list_head
;
2559 register dw_loc_descr_ref descr
;
2561 register dw_loc_descr_ref
*d
;
2563 /* Find the end of the chain. */
2564 for (d
= list_head
; (*d
) != NULL
; d
= &(*d
)->dw_loc_next
)
2570 /* Return the size of a location descriptor. */
2572 static unsigned long
2573 size_of_loc_descr (loc
)
2574 register dw_loc_descr_ref loc
;
2576 register unsigned long size
= 1;
2578 switch (loc
->dw_loc_opc
)
2581 size
+= DWARF2_ADDR_SIZE
;
2600 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
2603 size
+= size_of_sleb128 (loc
->dw_loc_oprnd1
.v
.val_int
);
2608 case DW_OP_plus_uconst
:
2609 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
2647 size
+= size_of_sleb128 (loc
->dw_loc_oprnd1
.v
.val_int
);
2650 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
2653 size
+= size_of_sleb128 (loc
->dw_loc_oprnd1
.v
.val_int
);
2656 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
2657 size
+= size_of_sleb128 (loc
->dw_loc_oprnd2
.v
.val_int
);
2660 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
2662 case DW_OP_deref_size
:
2663 case DW_OP_xderef_size
:
2673 /* Return the size of a series of location descriptors. */
2675 static unsigned long
2677 register dw_loc_descr_ref loc
;
2679 register unsigned long size
= 0;
2681 for (; loc
!= NULL
; loc
= loc
->dw_loc_next
)
2683 loc
->dw_loc_addr
= size
;
2684 size
+= size_of_loc_descr (loc
);
2690 /* Output location description stack opcode's operands (if any). */
2693 output_loc_operands (loc
)
2694 register dw_loc_descr_ref loc
;
2696 register dw_val_ref val1
= &loc
->dw_loc_oprnd1
;
2697 register dw_val_ref val2
= &loc
->dw_loc_oprnd2
;
2699 switch (loc
->dw_loc_opc
)
2701 #ifdef DWARF2_DEBUGGING_INFO
2703 dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE
, val1
->v
.val_addr
, NULL
);
2707 dw2_asm_output_data (2, val1
->v
.val_int
, NULL
);
2711 dw2_asm_output_data (4, val1
->v
.val_int
, NULL
);
2715 if (HOST_BITS_PER_LONG
< 64)
2717 dw2_asm_output_data (8, val1
->v
.val_int
, NULL
);
2724 if (val1
->val_class
== dw_val_class_loc
)
2725 offset
= val1
->v
.val_loc
->dw_loc_addr
- (loc
->dw_loc_addr
+ 3);
2729 dw2_asm_output_data (2, offset
, NULL
);
2742 /* We currently don't make any attempt to make sure these are
2743 aligned properly like we do for the main unwind info, so
2744 don't support emitting things larger than a byte if we're
2745 only doing unwinding. */
2750 dw2_asm_output_data (1, val1
->v
.val_int
, NULL
);
2753 dw2_asm_output_data_uleb128 (val1
->v
.val_unsigned
, NULL
);
2756 dw2_asm_output_data_sleb128 (val1
->v
.val_int
, NULL
);
2759 dw2_asm_output_data (1, val1
->v
.val_int
, NULL
);
2761 case DW_OP_plus_uconst
:
2762 dw2_asm_output_data_uleb128 (val1
->v
.val_unsigned
, NULL
);
2796 dw2_asm_output_data_sleb128 (val1
->v
.val_int
, NULL
);
2799 dw2_asm_output_data_uleb128 (val1
->v
.val_unsigned
, NULL
);
2802 dw2_asm_output_data_sleb128 (val1
->v
.val_int
, NULL
);
2805 dw2_asm_output_data_uleb128 (val1
->v
.val_unsigned
, NULL
);
2806 dw2_asm_output_data_sleb128 (val2
->v
.val_int
, NULL
);
2809 dw2_asm_output_data_uleb128 (val1
->v
.val_unsigned
, NULL
);
2811 case DW_OP_deref_size
:
2812 case DW_OP_xderef_size
:
2813 dw2_asm_output_data (1, val1
->v
.val_int
, NULL
);
2816 /* Other codes have no operands. */
2821 /* Output a sequence of location operations. */
2824 output_loc_sequence (loc
)
2825 dw_loc_descr_ref loc
;
2827 for (; loc
!= NULL
; loc
= loc
->dw_loc_next
)
2829 /* Output the opcode. */
2830 dw2_asm_output_data (1, loc
->dw_loc_opc
,
2831 "%s", dwarf_stack_op_name (loc
->dw_loc_opc
));
2833 /* Output the operand(s) (if any). */
2834 output_loc_operands (loc
);
2838 /* This routine will generate the correct assembly data for a location
2839 description based on a cfi entry with a complex address. */
2842 output_cfa_loc (cfi
)
2845 dw_loc_descr_ref loc
;
2848 /* Output the size of the block. */
2849 loc
= cfi
->dw_cfi_oprnd1
.dw_cfi_loc
;
2850 size
= size_of_locs (loc
);
2851 dw2_asm_output_data_uleb128 (size
, NULL
);
2853 /* Now output the operations themselves. */
2854 output_loc_sequence (loc
);
2857 /* This function builds a dwarf location descriptor sequence from
2858 a dw_cfa_location. */
2860 static struct dw_loc_descr_struct
*
2862 dw_cfa_location
*cfa
;
2864 struct dw_loc_descr_struct
*head
, *tmp
;
2866 if (cfa
->indirect
== 0)
2869 if (cfa
->base_offset
)
2872 head
= new_loc_descr (DW_OP_breg0
+ cfa
->reg
, cfa
->base_offset
, 0);
2874 head
= new_loc_descr (DW_OP_bregx
, cfa
->reg
, cfa
->base_offset
);
2876 else if (cfa
->reg
<= 31)
2877 head
= new_loc_descr (DW_OP_reg0
+ cfa
->reg
, 0, 0);
2879 head
= new_loc_descr (DW_OP_regx
, cfa
->reg
, 0);
2880 head
->dw_loc_oprnd1
.val_class
= dw_val_class_const
;
2881 tmp
= new_loc_descr (DW_OP_deref
, 0, 0);
2882 add_loc_descr (&head
, tmp
);
2883 if (cfa
->offset
!= 0)
2885 tmp
= new_loc_descr (DW_OP_plus_uconst
, cfa
->offset
, 0);
2886 add_loc_descr (&head
, tmp
);
2891 /* This function fills in aa dw_cfa_location structure from a
2892 dwarf location descriptor sequence. */
2895 get_cfa_from_loc_descr (cfa
, loc
)
2896 dw_cfa_location
*cfa
;
2897 struct dw_loc_descr_struct
*loc
;
2899 struct dw_loc_descr_struct
*ptr
;
2901 cfa
->base_offset
= 0;
2905 for (ptr
= loc
; ptr
!= NULL
; ptr
= ptr
->dw_loc_next
)
2907 enum dwarf_location_atom op
= ptr
->dw_loc_opc
;
2942 cfa
->reg
= op
- DW_OP_reg0
;
2945 cfa
->reg
= ptr
->dw_loc_oprnd1
.v
.val_int
;
2979 cfa
->reg
= op
- DW_OP_breg0
;
2980 cfa
->base_offset
= ptr
->dw_loc_oprnd1
.v
.val_int
;
2983 cfa
->reg
= ptr
->dw_loc_oprnd1
.v
.val_int
;
2984 cfa
->base_offset
= ptr
->dw_loc_oprnd2
.v
.val_int
;
2989 case DW_OP_plus_uconst
:
2990 cfa
->offset
= ptr
->dw_loc_oprnd1
.v
.val_unsigned
;
2993 internal_error ("DW_LOC_OP %s not implememnted\n",
2994 dwarf_stack_op_name (ptr
->dw_loc_opc
));
2998 #endif /* .debug_frame support */
3000 /* And now, the support for symbolic debugging information. */
3001 #ifdef DWARF2_DEBUGGING_INFO
3003 static void dwarf2out_init
PARAMS ((const char *));
3004 static void dwarf2out_finish
PARAMS ((const char *));
3005 static void dwarf2out_define
PARAMS ((unsigned int, const char *));
3006 static void dwarf2out_undef
PARAMS ((unsigned int, const char *));
3007 static void dwarf2out_start_source_file
PARAMS ((unsigned, const char *));
3008 static void dwarf2out_end_source_file
PARAMS ((unsigned));
3009 static void dwarf2out_begin_block
PARAMS ((unsigned, unsigned));
3010 static void dwarf2out_end_block
PARAMS ((unsigned, unsigned));
3011 static bool dwarf2out_ignore_block
PARAMS ((tree
));
3012 static void dwarf2out_global_decl
PARAMS ((tree
));
3013 static void dwarf2out_abstract_function
PARAMS ((tree
));
3015 /* The debug hooks structure. */
3017 struct gcc_debug_hooks dwarf2_debug_hooks
=
3023 dwarf2out_start_source_file
,
3024 dwarf2out_end_source_file
,
3025 dwarf2out_begin_block
,
3026 dwarf2out_end_block
,
3027 dwarf2out_ignore_block
,
3028 dwarf2out_source_line
,
3029 dwarf2out_begin_prologue
,
3030 debug_nothing_int
, /* end_prologue */
3031 dwarf2out_end_epilogue
,
3032 debug_nothing_tree
, /* begin_function */
3033 debug_nothing_int
, /* end_function */
3034 dwarf2out_decl
, /* function_decl */
3035 dwarf2out_global_decl
,
3036 debug_nothing_tree
, /* deferred_inline_function */
3037 /* The DWARF 2 backend tries to reduce debugging bloat by not
3038 emitting the abstract description of inline functions until
3039 something tries to reference them. */
3040 dwarf2out_abstract_function
, /* outlining_inline_function */
3041 debug_nothing_rtx
/* label */
3044 /* NOTE: In the comments in this file, many references are made to
3045 "Debugging Information Entries". This term is abbreviated as `DIE'
3046 throughout the remainder of this file. */
3048 /* An internal representation of the DWARF output is built, and then
3049 walked to generate the DWARF debugging info. The walk of the internal
3050 representation is done after the entire program has been compiled.
3051 The types below are used to describe the internal representation. */
3053 /* Various DIE's use offsets relative to the beginning of the
3054 .debug_info section to refer to each other. */
3056 typedef long int dw_offset
;
3058 /* Define typedefs here to avoid circular dependencies. */
3060 typedef struct dw_attr_struct
*dw_attr_ref
;
3061 typedef struct dw_line_info_struct
*dw_line_info_ref
;
3062 typedef struct dw_separate_line_info_struct
*dw_separate_line_info_ref
;
3063 typedef struct pubname_struct
*pubname_ref
;
3064 typedef struct dw_ranges_struct
*dw_ranges_ref
;
3066 /* Each entry in the line_info_table maintains the file and
3067 line number associated with the label generated for that
3068 entry. The label gives the PC value associated with
3069 the line number entry. */
3071 typedef struct dw_line_info_struct
3073 unsigned long dw_file_num
;
3074 unsigned long dw_line_num
;
3078 /* Line information for functions in separate sections; each one gets its
3080 typedef struct dw_separate_line_info_struct
3082 unsigned long dw_file_num
;
3083 unsigned long dw_line_num
;
3084 unsigned long function
;
3086 dw_separate_line_info_entry
;
3088 /* Each DIE attribute has a field specifying the attribute kind,
3089 a link to the next attribute in the chain, and an attribute value.
3090 Attributes are typically linked below the DIE they modify. */
3092 typedef struct dw_attr_struct
3094 enum dwarf_attribute dw_attr
;
3095 dw_attr_ref dw_attr_next
;
3096 dw_val_node dw_attr_val
;
3100 /* The Debugging Information Entry (DIE) structure */
3102 typedef struct die_struct
3104 enum dwarf_tag die_tag
;
3106 dw_attr_ref die_attr
;
3107 dw_die_ref die_parent
;
3108 dw_die_ref die_child
;
3110 dw_offset die_offset
;
3111 unsigned long die_abbrev
;
3116 /* The pubname structure */
3118 typedef struct pubname_struct
3125 struct dw_ranges_struct
3130 /* The limbo die list structure. */
3131 typedef struct limbo_die_struct
3134 struct limbo_die_struct
*next
;
3138 /* How to start an assembler comment. */
3139 #ifndef ASM_COMMENT_START
3140 #define ASM_COMMENT_START ";#"
3143 /* Define a macro which returns non-zero for a TYPE_DECL which was
3144 implicitly generated for a tagged type.
3146 Note that unlike the gcc front end (which generates a NULL named
3147 TYPE_DECL node for each complete tagged type, each array type, and
3148 each function type node created) the g++ front end generates a
3149 _named_ TYPE_DECL node for each tagged type node created.
3150 These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
3151 generate a DW_TAG_typedef DIE for them. */
3153 #define TYPE_DECL_IS_STUB(decl) \
3154 (DECL_NAME (decl) == NULL_TREE \
3155 || (DECL_ARTIFICIAL (decl) \
3156 && is_tagged_type (TREE_TYPE (decl)) \
3157 && ((decl == TYPE_STUB_DECL (TREE_TYPE (decl))) \
3158 /* This is necessary for stub decls that \
3159 appear in nested inline functions. */ \
3160 || (DECL_ABSTRACT_ORIGIN (decl) != NULL_TREE \
3161 && (decl_ultimate_origin (decl) \
3162 == TYPE_STUB_DECL (TREE_TYPE (decl)))))))
3164 /* Information concerning the compilation unit's programming
3165 language, and compiler version. */
3167 extern int flag_traditional
;
3169 /* Fixed size portion of the DWARF compilation unit header. */
3170 #define DWARF_COMPILE_UNIT_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 3)
3172 /* Fixed size portion of debugging line information prolog. */
3173 #define DWARF_LINE_PROLOG_HEADER_SIZE 5
3175 /* Fixed size portion of public names info. */
3176 #define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
3178 /* Fixed size portion of the address range info. */
3179 #define DWARF_ARANGES_HEADER_SIZE \
3180 (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, DWARF2_ADDR_SIZE * 2) \
3181 - DWARF_OFFSET_SIZE)
3183 /* Size of padding portion in the address range info. It must be
3184 aligned to twice the pointer size. */
3185 #define DWARF_ARANGES_PAD_SIZE \
3186 (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, DWARF2_ADDR_SIZE * 2) \
3187 - (2 * DWARF_OFFSET_SIZE + 4))
3189 /* Use assembler line directives if available. */
3190 #ifndef DWARF2_ASM_LINE_DEBUG_INFO
3191 #ifdef HAVE_AS_DWARF2_DEBUG_LINE
3192 #define DWARF2_ASM_LINE_DEBUG_INFO 1
3194 #define DWARF2_ASM_LINE_DEBUG_INFO 0
3198 /* Define the architecture-dependent minimum instruction length (in bytes).
3199 In this implementation of DWARF, this field is used for information
3200 purposes only. Since GCC generates assembly language, we have
3201 no a priori knowledge of how many instruction bytes are generated
3202 for each source line, and therefore can use only the DW_LNE_set_address
3203 and DW_LNS_fixed_advance_pc line information commands. */
3205 #ifndef DWARF_LINE_MIN_INSTR_LENGTH
3206 #define DWARF_LINE_MIN_INSTR_LENGTH 4
3209 /* Minimum line offset in a special line info. opcode.
3210 This value was chosen to give a reasonable range of values. */
3211 #define DWARF_LINE_BASE -10
3213 /* First special line opcde - leave room for the standard opcodes. */
3214 #define DWARF_LINE_OPCODE_BASE 10
3216 /* Range of line offsets in a special line info. opcode. */
3217 #define DWARF_LINE_RANGE (254-DWARF_LINE_OPCODE_BASE+1)
3219 /* Flag that indicates the initial value of the is_stmt_start flag.
3220 In the present implementation, we do not mark any lines as
3221 the beginning of a source statement, because that information
3222 is not made available by the GCC front-end. */
3223 #define DWARF_LINE_DEFAULT_IS_STMT_START 1
3225 /* This location is used by calc_die_sizes() to keep track
3226 the offset of each DIE within the .debug_info section. */
3227 static unsigned long next_die_offset
;
3229 /* Record the root of the DIE's built for the current compilation unit. */
3230 static dw_die_ref comp_unit_die
;
3232 /* A list of DIEs with a NULL parent waiting to be relocated. */
3233 static limbo_die_node
*limbo_die_list
= 0;
3235 /* Structure used by lookup_filename to manage sets of filenames. */
3241 unsigned last_lookup_index
;
3244 /* Size (in elements) of increments by which we may expand the filename
3246 #define FILE_TABLE_INCREMENT 64
3248 /* Filenames referenced by this compilation unit. */
3249 static struct file_table file_table
;
3251 /* Local pointer to the name of the main input file. Initialized in
3253 static const char *primary_filename
;
3255 /* A pointer to the base of a table of references to DIE's that describe
3256 declarations. The table is indexed by DECL_UID() which is a unique
3257 number identifying each decl. */
3258 static dw_die_ref
*decl_die_table
;
3260 /* Number of elements currently allocated for the decl_die_table. */
3261 static unsigned decl_die_table_allocated
;
3263 /* Number of elements in decl_die_table currently in use. */
3264 static unsigned decl_die_table_in_use
;
3266 /* Size (in elements) of increments by which we may expand the
3268 #define DECL_DIE_TABLE_INCREMENT 256
3270 /* A pointer to the base of a table of references to declaration
3271 scopes. This table is a display which tracks the nesting
3272 of declaration scopes at the current scope and containing
3273 scopes. This table is used to find the proper place to
3274 define type declaration DIE's. */
3275 static tree
*decl_scope_table
;
3277 /* Number of elements currently allocated for the decl_scope_table. */
3278 static int decl_scope_table_allocated
;
3280 /* Current level of nesting of declaration scopes. */
3281 static int decl_scope_depth
;
3283 /* Size (in elements) of increments by which we may expand the
3284 decl_scope_table. */
3285 #define DECL_SCOPE_TABLE_INCREMENT 64
3287 /* A pointer to the base of a list of references to DIE's that
3288 are uniquely identified by their tag, presence/absence of
3289 children DIE's, and list of attribute/value pairs. */
3290 static dw_die_ref
*abbrev_die_table
;
3292 /* Number of elements currently allocated for abbrev_die_table. */
3293 static unsigned abbrev_die_table_allocated
;
3295 /* Number of elements in type_die_table currently in use. */
3296 static unsigned abbrev_die_table_in_use
;
3298 /* Size (in elements) of increments by which we may expand the
3299 abbrev_die_table. */
3300 #define ABBREV_DIE_TABLE_INCREMENT 256
3302 /* A pointer to the base of a table that contains line information
3303 for each source code line in .text in the compilation unit. */
3304 static dw_line_info_ref line_info_table
;
3306 /* Number of elements currently allocated for line_info_table. */
3307 static unsigned line_info_table_allocated
;
3309 /* Number of elements in separate_line_info_table currently in use. */
3310 static unsigned separate_line_info_table_in_use
;
3312 /* A pointer to the base of a table that contains line information
3313 for each source code line outside of .text in the compilation unit. */
3314 static dw_separate_line_info_ref separate_line_info_table
;
3316 /* Number of elements currently allocated for separate_line_info_table. */
3317 static unsigned separate_line_info_table_allocated
;
3319 /* Number of elements in line_info_table currently in use. */
3320 static unsigned line_info_table_in_use
;
3322 /* Size (in elements) of increments by which we may expand the
3324 #define LINE_INFO_TABLE_INCREMENT 1024
3326 /* A pointer to the base of a table that contains a list of publicly
3327 accessible names. */
3328 static pubname_ref pubname_table
;
3330 /* Number of elements currently allocated for pubname_table. */
3331 static unsigned pubname_table_allocated
;
3333 /* Number of elements in pubname_table currently in use. */
3334 static unsigned pubname_table_in_use
;
3336 /* Size (in elements) of increments by which we may expand the
3338 #define PUBNAME_TABLE_INCREMENT 64
3340 /* Array of dies for which we should generate .debug_arange info. */
3341 static dw_die_ref
*arange_table
;
3343 /* Number of elements currently allocated for arange_table. */
3344 static unsigned arange_table_allocated
;
3346 /* Number of elements in arange_table currently in use. */
3347 static unsigned arange_table_in_use
;
3349 /* Size (in elements) of increments by which we may expand the
3351 #define ARANGE_TABLE_INCREMENT 64
3353 /* Array of dies for which we should generate .debug_ranges info. */
3354 static dw_ranges_ref ranges_table
;
3356 /* Number of elements currently allocated for ranges_table. */
3357 static unsigned ranges_table_allocated
;
3359 /* Number of elements in ranges_table currently in use. */
3360 static unsigned ranges_table_in_use
;
3362 /* Size (in elements) of increments by which we may expand the
3364 #define RANGES_TABLE_INCREMENT 64
3366 /* Whether we have location lists that need outputting */
3367 static unsigned have_location_lists
;
3369 /* A pointer to the base of a list of incomplete types which might be
3370 completed at some later time. */
3372 static tree
*incomplete_types_list
;
3374 /* Number of elements currently allocated for the incomplete_types_list. */
3375 static unsigned incomplete_types_allocated
;
3377 /* Number of elements of incomplete_types_list currently in use. */
3378 static unsigned incomplete_types
;
3380 /* Size (in elements) of increments by which we may expand the incomplete
3381 types list. Actually, a single hunk of space of this size should
3382 be enough for most typical programs. */
3383 #define INCOMPLETE_TYPES_INCREMENT 64
3385 /* Record whether the function being analyzed contains inlined functions. */
3386 static int current_function_has_inlines
;
3387 #if 0 && defined (MIPS_DEBUGGING_INFO)
3388 static int comp_unit_has_inlines
;
3391 /* Array of RTXes referenced by the debugging information, which therefore
3392 must be kept around forever. We do this rather than perform GC on
3393 the dwarf info because almost all of the dwarf info lives forever, and
3394 it's easier to support non-GC frontends this way. */
3395 static varray_type used_rtx_varray
;
3397 /* Forward declarations for functions defined in this file. */
3399 static int is_pseudo_reg
PARAMS ((rtx
));
3400 static tree type_main_variant
PARAMS ((tree
));
3401 static int is_tagged_type
PARAMS ((tree
));
3402 static const char *dwarf_tag_name
PARAMS ((unsigned));
3403 static const char *dwarf_attr_name
PARAMS ((unsigned));
3404 static const char *dwarf_form_name
PARAMS ((unsigned));
3406 static const char *dwarf_type_encoding_name
PARAMS ((unsigned));
3408 static tree decl_ultimate_origin
PARAMS ((tree
));
3409 static tree block_ultimate_origin
PARAMS ((tree
));
3410 static tree decl_class_context
PARAMS ((tree
));
3411 static void add_dwarf_attr
PARAMS ((dw_die_ref
, dw_attr_ref
));
3412 static void add_AT_flag
PARAMS ((dw_die_ref
,
3413 enum dwarf_attribute
,
3415 static void add_AT_int
PARAMS ((dw_die_ref
,
3416 enum dwarf_attribute
, long));
3417 static void add_AT_unsigned
PARAMS ((dw_die_ref
,
3418 enum dwarf_attribute
,
3420 static void add_AT_long_long
PARAMS ((dw_die_ref
,
3421 enum dwarf_attribute
,
3424 static void add_AT_float
PARAMS ((dw_die_ref
,
3425 enum dwarf_attribute
,
3427 static void add_AT_string
PARAMS ((dw_die_ref
,
3428 enum dwarf_attribute
,
3430 static void add_AT_die_ref
PARAMS ((dw_die_ref
,
3431 enum dwarf_attribute
,
3433 static void add_AT_fde_ref
PARAMS ((dw_die_ref
,
3434 enum dwarf_attribute
,
3436 static void add_AT_loc
PARAMS ((dw_die_ref
,
3437 enum dwarf_attribute
,
3439 static void add_AT_loc_list
PARAMS ((dw_die_ref
,
3440 enum dwarf_attribute
,
3442 static void add_AT_addr
PARAMS ((dw_die_ref
,
3443 enum dwarf_attribute
,
3445 static void add_AT_lbl_id
PARAMS ((dw_die_ref
,
3446 enum dwarf_attribute
,
3448 static void add_AT_lbl_offset
PARAMS ((dw_die_ref
,
3449 enum dwarf_attribute
,
3451 static void add_AT_offset
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_java
PARAMS ((void));
3468 static int is_fortran
PARAMS ((void));
3469 static void remove_AT
PARAMS ((dw_die_ref
,
3470 enum dwarf_attribute
));
3471 static void remove_children
PARAMS ((dw_die_ref
));
3472 static void add_child_die
PARAMS ((dw_die_ref
, dw_die_ref
));
3473 static dw_die_ref new_die
PARAMS ((enum dwarf_tag
, dw_die_ref
));
3474 static dw_die_ref lookup_type_die
PARAMS ((tree
));
3475 static void equate_type_number_to_die
PARAMS ((tree
, dw_die_ref
));
3476 static dw_die_ref lookup_decl_die
PARAMS ((tree
));
3477 static void equate_decl_number_to_die
PARAMS ((tree
, dw_die_ref
));
3478 static void print_spaces
PARAMS ((FILE *));
3479 static void print_die
PARAMS ((dw_die_ref
, FILE *));
3480 static void print_dwarf_line_table
PARAMS ((FILE *));
3481 static void reverse_die_lists
PARAMS ((dw_die_ref
));
3482 static void reverse_all_dies
PARAMS ((dw_die_ref
));
3483 static dw_die_ref push_new_compile_unit
PARAMS ((dw_die_ref
, dw_die_ref
));
3484 static dw_die_ref pop_compile_unit
PARAMS ((dw_die_ref
));
3485 static void loc_checksum
PARAMS ((dw_loc_descr_ref
, struct md5_ctx
*));
3486 static void attr_checksum
PARAMS ((dw_attr_ref
, struct md5_ctx
*));
3487 static void die_checksum
PARAMS ((dw_die_ref
, struct md5_ctx
*));
3488 static void compute_section_prefix
PARAMS ((dw_die_ref
));
3489 static int is_type_die
PARAMS ((dw_die_ref
));
3490 static int is_comdat_die
PARAMS ((dw_die_ref
));
3491 static int is_symbol_die
PARAMS ((dw_die_ref
));
3492 static void assign_symbol_names
PARAMS ((dw_die_ref
));
3493 static void break_out_includes
PARAMS ((dw_die_ref
));
3494 static void add_sibling_attributes
PARAMS ((dw_die_ref
));
3495 static void build_abbrev_table
PARAMS ((dw_die_ref
));
3496 static void output_location_lists
PARAMS ((dw_die_ref
));
3497 static unsigned long size_of_string
PARAMS ((const char *));
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
3650 #define TEXT_SECTION ".text"
3652 #ifndef DATA_SECTION
3653 #define DATA_SECTION ".data"
3656 #define BSS_SECTION ".bss"
3659 /* Labels we insert at beginning sections we can reference instead of
3660 the section names themselves. */
3662 #ifndef TEXT_SECTION_LABEL
3663 #define TEXT_SECTION_LABEL "Ltext"
3665 #ifndef DEBUG_LINE_SECTION_LABEL
3666 #define DEBUG_LINE_SECTION_LABEL "Ldebug_line"
3668 #ifndef DEBUG_INFO_SECTION_LABEL
3669 #define DEBUG_INFO_SECTION_LABEL "Ldebug_info"
3671 #ifndef DEBUG_ABBREV_SECTION_LABEL
3672 #define DEBUG_ABBREV_SECTION_LABEL "Ldebug_abbrev"
3674 #ifndef DEBUG_LOC_SECTION_LABEL
3675 #define DEBUG_LOC_SECTION_LABEL "Ldebug_loc"
3677 #ifndef DEBUG_MACINFO_SECTION_LABEL
3678 #define DEBUG_MACINFO_SECTION_LABEL "Ldebug_macinfo"
3681 /* Definitions of defaults for formats and names of various special
3682 (artificial) labels which may be generated within this file (when the -g
3683 options is used and DWARF_DEBUGGING_INFO is in effect.
3684 If necessary, these may be overridden from within the tm.h file, but
3685 typically, overriding these defaults is unnecessary. */
3687 static char text_end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3688 static char text_section_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3689 static char abbrev_section_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3690 static char debug_info_section_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3691 static char debug_line_section_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3692 static char macinfo_section_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3693 static char loc_section_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
3694 #ifndef TEXT_END_LABEL
3695 #define TEXT_END_LABEL "Letext"
3697 #ifndef DATA_END_LABEL
3698 #define DATA_END_LABEL "Ledata"
3700 #ifndef BSS_END_LABEL
3701 #define BSS_END_LABEL "Lebss"
3703 #ifndef BLOCK_BEGIN_LABEL
3704 #define BLOCK_BEGIN_LABEL "LBB"
3706 #ifndef BLOCK_END_LABEL
3707 #define BLOCK_END_LABEL "LBE"
3709 #ifndef BODY_BEGIN_LABEL
3710 #define BODY_BEGIN_LABEL "Lbb"
3712 #ifndef BODY_END_LABEL
3713 #define BODY_END_LABEL "Lbe"
3715 #ifndef LINE_CODE_LABEL
3716 #define LINE_CODE_LABEL "LM"
3718 #ifndef SEPARATE_LINE_CODE_LABEL
3719 #define SEPARATE_LINE_CODE_LABEL "LSM"
3722 /* We allow a language front-end to designate a function that is to be
3723 called to "demangle" any name before it it put into a DIE. */
3725 static const char *(*demangle_name_func
) PARAMS ((const char *));
3728 dwarf2out_set_demangle_name_func (func
)
3729 const char *(*func
) PARAMS ((const char *));
3731 demangle_name_func
= func
;
3734 /* Return an rtx like ORIG which lives forever. If we're doing GC,
3735 that means adding it to used_rtx_varray. If not, that means making
3736 a copy on the permanent_obstack. */
3742 VARRAY_PUSH_RTX (used_rtx_varray
, orig
);
3747 /* Test if rtl node points to a pseudo register. */
3753 return ((GET_CODE (rtl
) == REG
&& REGNO (rtl
) >= FIRST_PSEUDO_REGISTER
)
3754 || (GET_CODE (rtl
) == SUBREG
3755 && REGNO (SUBREG_REG (rtl
)) >= FIRST_PSEUDO_REGISTER
));
3758 /* Return a reference to a type, with its const and volatile qualifiers
3762 type_main_variant (type
)
3765 type
= TYPE_MAIN_VARIANT (type
);
3767 /* There really should be only one main variant among any group of variants
3768 of a given type (and all of the MAIN_VARIANT values for all members of
3769 the group should point to that one type) but sometimes the C front-end
3770 messes this up for array types, so we work around that bug here. */
3772 if (TREE_CODE (type
) == ARRAY_TYPE
)
3773 while (type
!= TYPE_MAIN_VARIANT (type
))
3774 type
= TYPE_MAIN_VARIANT (type
);
3779 /* Return non-zero if the given type node represents a tagged type. */
3782 is_tagged_type (type
)
3785 register enum tree_code code
= TREE_CODE (type
);
3787 return (code
== RECORD_TYPE
|| code
== UNION_TYPE
3788 || code
== QUAL_UNION_TYPE
|| code
== ENUMERAL_TYPE
);
3791 /* Convert a DIE tag into its string name. */
3794 dwarf_tag_name (tag
)
3795 register unsigned tag
;
3799 case DW_TAG_padding
:
3800 return "DW_TAG_padding";
3801 case DW_TAG_array_type
:
3802 return "DW_TAG_array_type";
3803 case DW_TAG_class_type
:
3804 return "DW_TAG_class_type";
3805 case DW_TAG_entry_point
:
3806 return "DW_TAG_entry_point";
3807 case DW_TAG_enumeration_type
:
3808 return "DW_TAG_enumeration_type";
3809 case DW_TAG_formal_parameter
:
3810 return "DW_TAG_formal_parameter";
3811 case DW_TAG_imported_declaration
:
3812 return "DW_TAG_imported_declaration";
3814 return "DW_TAG_label";
3815 case DW_TAG_lexical_block
:
3816 return "DW_TAG_lexical_block";
3818 return "DW_TAG_member";
3819 case DW_TAG_pointer_type
:
3820 return "DW_TAG_pointer_type";
3821 case DW_TAG_reference_type
:
3822 return "DW_TAG_reference_type";
3823 case DW_TAG_compile_unit
:
3824 return "DW_TAG_compile_unit";
3825 case DW_TAG_string_type
:
3826 return "DW_TAG_string_type";
3827 case DW_TAG_structure_type
:
3828 return "DW_TAG_structure_type";
3829 case DW_TAG_subroutine_type
:
3830 return "DW_TAG_subroutine_type";
3831 case DW_TAG_typedef
:
3832 return "DW_TAG_typedef";
3833 case DW_TAG_union_type
:
3834 return "DW_TAG_union_type";
3835 case DW_TAG_unspecified_parameters
:
3836 return "DW_TAG_unspecified_parameters";
3837 case DW_TAG_variant
:
3838 return "DW_TAG_variant";
3839 case DW_TAG_common_block
:
3840 return "DW_TAG_common_block";
3841 case DW_TAG_common_inclusion
:
3842 return "DW_TAG_common_inclusion";
3843 case DW_TAG_inheritance
:
3844 return "DW_TAG_inheritance";
3845 case DW_TAG_inlined_subroutine
:
3846 return "DW_TAG_inlined_subroutine";
3848 return "DW_TAG_module";
3849 case DW_TAG_ptr_to_member_type
:
3850 return "DW_TAG_ptr_to_member_type";
3851 case DW_TAG_set_type
:
3852 return "DW_TAG_set_type";
3853 case DW_TAG_subrange_type
:
3854 return "DW_TAG_subrange_type";
3855 case DW_TAG_with_stmt
:
3856 return "DW_TAG_with_stmt";
3857 case DW_TAG_access_declaration
:
3858 return "DW_TAG_access_declaration";
3859 case DW_TAG_base_type
:
3860 return "DW_TAG_base_type";
3861 case DW_TAG_catch_block
:
3862 return "DW_TAG_catch_block";
3863 case DW_TAG_const_type
:
3864 return "DW_TAG_const_type";
3865 case DW_TAG_constant
:
3866 return "DW_TAG_constant";
3867 case DW_TAG_enumerator
:
3868 return "DW_TAG_enumerator";
3869 case DW_TAG_file_type
:
3870 return "DW_TAG_file_type";
3872 return "DW_TAG_friend";
3873 case DW_TAG_namelist
:
3874 return "DW_TAG_namelist";
3875 case DW_TAG_namelist_item
:
3876 return "DW_TAG_namelist_item";
3877 case DW_TAG_packed_type
:
3878 return "DW_TAG_packed_type";
3879 case DW_TAG_subprogram
:
3880 return "DW_TAG_subprogram";
3881 case DW_TAG_template_type_param
:
3882 return "DW_TAG_template_type_param";
3883 case DW_TAG_template_value_param
:
3884 return "DW_TAG_template_value_param";
3885 case DW_TAG_thrown_type
:
3886 return "DW_TAG_thrown_type";
3887 case DW_TAG_try_block
:
3888 return "DW_TAG_try_block";
3889 case DW_TAG_variant_part
:
3890 return "DW_TAG_variant_part";
3891 case DW_TAG_variable
:
3892 return "DW_TAG_variable";
3893 case DW_TAG_volatile_type
:
3894 return "DW_TAG_volatile_type";
3895 case DW_TAG_MIPS_loop
:
3896 return "DW_TAG_MIPS_loop";
3897 case DW_TAG_format_label
:
3898 return "DW_TAG_format_label";
3899 case DW_TAG_function_template
:
3900 return "DW_TAG_function_template";
3901 case DW_TAG_class_template
:
3902 return "DW_TAG_class_template";
3903 case DW_TAG_GNU_BINCL
:
3904 return "DW_TAG_GNU_BINCL";
3905 case DW_TAG_GNU_EINCL
:
3906 return "DW_TAG_GNU_EINCL";
3908 return "DW_TAG_<unknown>";
3912 /* Convert a DWARF attribute code into its string name. */
3915 dwarf_attr_name (attr
)
3916 register unsigned attr
;
3921 return "DW_AT_sibling";
3922 case DW_AT_location
:
3923 return "DW_AT_location";
3925 return "DW_AT_name";
3926 case DW_AT_ordering
:
3927 return "DW_AT_ordering";
3928 case DW_AT_subscr_data
:
3929 return "DW_AT_subscr_data";
3930 case DW_AT_byte_size
:
3931 return "DW_AT_byte_size";
3932 case DW_AT_bit_offset
:
3933 return "DW_AT_bit_offset";
3934 case DW_AT_bit_size
:
3935 return "DW_AT_bit_size";
3936 case DW_AT_element_list
:
3937 return "DW_AT_element_list";
3938 case DW_AT_stmt_list
:
3939 return "DW_AT_stmt_list";
3941 return "DW_AT_low_pc";
3943 return "DW_AT_high_pc";
3944 case DW_AT_language
:
3945 return "DW_AT_language";
3947 return "DW_AT_member";
3949 return "DW_AT_discr";
3950 case DW_AT_discr_value
:
3951 return "DW_AT_discr_value";
3952 case DW_AT_visibility
:
3953 return "DW_AT_visibility";
3955 return "DW_AT_import";
3956 case DW_AT_string_length
:
3957 return "DW_AT_string_length";
3958 case DW_AT_common_reference
:
3959 return "DW_AT_common_reference";
3960 case DW_AT_comp_dir
:
3961 return "DW_AT_comp_dir";
3962 case DW_AT_const_value
:
3963 return "DW_AT_const_value";
3964 case DW_AT_containing_type
:
3965 return "DW_AT_containing_type";
3966 case DW_AT_default_value
:
3967 return "DW_AT_default_value";
3969 return "DW_AT_inline";
3970 case DW_AT_is_optional
:
3971 return "DW_AT_is_optional";
3972 case DW_AT_lower_bound
:
3973 return "DW_AT_lower_bound";
3974 case DW_AT_producer
:
3975 return "DW_AT_producer";
3976 case DW_AT_prototyped
:
3977 return "DW_AT_prototyped";
3978 case DW_AT_return_addr
:
3979 return "DW_AT_return_addr";
3980 case DW_AT_start_scope
:
3981 return "DW_AT_start_scope";
3982 case DW_AT_stride_size
:
3983 return "DW_AT_stride_size";
3984 case DW_AT_upper_bound
:
3985 return "DW_AT_upper_bound";
3986 case DW_AT_abstract_origin
:
3987 return "DW_AT_abstract_origin";
3988 case DW_AT_accessibility
:
3989 return "DW_AT_accessibility";
3990 case DW_AT_address_class
:
3991 return "DW_AT_address_class";
3992 case DW_AT_artificial
:
3993 return "DW_AT_artificial";
3994 case DW_AT_base_types
:
3995 return "DW_AT_base_types";
3996 case DW_AT_calling_convention
:
3997 return "DW_AT_calling_convention";
3999 return "DW_AT_count";
4000 case DW_AT_data_member_location
:
4001 return "DW_AT_data_member_location";
4002 case DW_AT_decl_column
:
4003 return "DW_AT_decl_column";
4004 case DW_AT_decl_file
:
4005 return "DW_AT_decl_file";
4006 case DW_AT_decl_line
:
4007 return "DW_AT_decl_line";
4008 case DW_AT_declaration
:
4009 return "DW_AT_declaration";
4010 case DW_AT_discr_list
:
4011 return "DW_AT_discr_list";
4012 case DW_AT_encoding
:
4013 return "DW_AT_encoding";
4014 case DW_AT_external
:
4015 return "DW_AT_external";
4016 case DW_AT_frame_base
:
4017 return "DW_AT_frame_base";
4019 return "DW_AT_friend";
4020 case DW_AT_identifier_case
:
4021 return "DW_AT_identifier_case";
4022 case DW_AT_macro_info
:
4023 return "DW_AT_macro_info";
4024 case DW_AT_namelist_items
:
4025 return "DW_AT_namelist_items";
4026 case DW_AT_priority
:
4027 return "DW_AT_priority";
4029 return "DW_AT_segment";
4030 case DW_AT_specification
:
4031 return "DW_AT_specification";
4032 case DW_AT_static_link
:
4033 return "DW_AT_static_link";
4035 return "DW_AT_type";
4036 case DW_AT_use_location
:
4037 return "DW_AT_use_location";
4038 case DW_AT_variable_parameter
:
4039 return "DW_AT_variable_parameter";
4040 case DW_AT_virtuality
:
4041 return "DW_AT_virtuality";
4042 case DW_AT_vtable_elem_location
:
4043 return "DW_AT_vtable_elem_location";
4045 case DW_AT_allocated
:
4046 return "DW_AT_allocated";
4047 case DW_AT_associated
:
4048 return "DW_AT_associated";
4049 case DW_AT_data_location
:
4050 return "DW_AT_data_location";
4052 return "DW_AT_stride";
4053 case DW_AT_entry_pc
:
4054 return "DW_AT_entry_pc";
4055 case DW_AT_use_UTF8
:
4056 return "DW_AT_use_UTF8";
4057 case DW_AT_extension
:
4058 return "DW_AT_extension";
4060 return "DW_AT_ranges";
4061 case DW_AT_trampoline
:
4062 return "DW_AT_trampoline";
4063 case DW_AT_call_column
:
4064 return "DW_AT_call_column";
4065 case DW_AT_call_file
:
4066 return "DW_AT_call_file";
4067 case DW_AT_call_line
:
4068 return "DW_AT_call_line";
4070 case DW_AT_MIPS_fde
:
4071 return "DW_AT_MIPS_fde";
4072 case DW_AT_MIPS_loop_begin
:
4073 return "DW_AT_MIPS_loop_begin";
4074 case DW_AT_MIPS_tail_loop_begin
:
4075 return "DW_AT_MIPS_tail_loop_begin";
4076 case DW_AT_MIPS_epilog_begin
:
4077 return "DW_AT_MIPS_epilog_begin";
4078 case DW_AT_MIPS_loop_unroll_factor
:
4079 return "DW_AT_MIPS_loop_unroll_factor";
4080 case DW_AT_MIPS_software_pipeline_depth
:
4081 return "DW_AT_MIPS_software_pipeline_depth";
4082 case DW_AT_MIPS_linkage_name
:
4083 return "DW_AT_MIPS_linkage_name";
4084 case DW_AT_MIPS_stride
:
4085 return "DW_AT_MIPS_stride";
4086 case DW_AT_MIPS_abstract_name
:
4087 return "DW_AT_MIPS_abstract_name";
4088 case DW_AT_MIPS_clone_origin
:
4089 return "DW_AT_MIPS_clone_origin";
4090 case DW_AT_MIPS_has_inlines
:
4091 return "DW_AT_MIPS_has_inlines";
4093 case DW_AT_sf_names
:
4094 return "DW_AT_sf_names";
4095 case DW_AT_src_info
:
4096 return "DW_AT_src_info";
4097 case DW_AT_mac_info
:
4098 return "DW_AT_mac_info";
4099 case DW_AT_src_coords
:
4100 return "DW_AT_src_coords";
4101 case DW_AT_body_begin
:
4102 return "DW_AT_body_begin";
4103 case DW_AT_body_end
:
4104 return "DW_AT_body_end";
4106 return "DW_AT_<unknown>";
4110 /* Convert a DWARF value form code into its string name. */
4113 dwarf_form_name (form
)
4114 register unsigned form
;
4119 return "DW_FORM_addr";
4120 case DW_FORM_block2
:
4121 return "DW_FORM_block2";
4122 case DW_FORM_block4
:
4123 return "DW_FORM_block4";
4125 return "DW_FORM_data2";
4127 return "DW_FORM_data4";
4129 return "DW_FORM_data8";
4130 case DW_FORM_string
:
4131 return "DW_FORM_string";
4133 return "DW_FORM_block";
4134 case DW_FORM_block1
:
4135 return "DW_FORM_block1";
4137 return "DW_FORM_data1";
4139 return "DW_FORM_flag";
4141 return "DW_FORM_sdata";
4143 return "DW_FORM_strp";
4145 return "DW_FORM_udata";
4146 case DW_FORM_ref_addr
:
4147 return "DW_FORM_ref_addr";
4149 return "DW_FORM_ref1";
4151 return "DW_FORM_ref2";
4153 return "DW_FORM_ref4";
4155 return "DW_FORM_ref8";
4156 case DW_FORM_ref_udata
:
4157 return "DW_FORM_ref_udata";
4158 case DW_FORM_indirect
:
4159 return "DW_FORM_indirect";
4161 return "DW_FORM_<unknown>";
4165 /* Convert a DWARF type code into its string name. */
4169 dwarf_type_encoding_name (enc
)
4170 register unsigned enc
;
4174 case DW_ATE_address
:
4175 return "DW_ATE_address";
4176 case DW_ATE_boolean
:
4177 return "DW_ATE_boolean";
4178 case DW_ATE_complex_float
:
4179 return "DW_ATE_complex_float";
4181 return "DW_ATE_float";
4183 return "DW_ATE_signed";
4184 case DW_ATE_signed_char
:
4185 return "DW_ATE_signed_char";
4186 case DW_ATE_unsigned
:
4187 return "DW_ATE_unsigned";
4188 case DW_ATE_unsigned_char
:
4189 return "DW_ATE_unsigned_char";
4191 return "DW_ATE_<unknown>";
4196 /* Determine the "ultimate origin" of a decl. The decl may be an inlined
4197 instance of an inlined instance of a decl which is local to an inline
4198 function, so we have to trace all of the way back through the origin chain
4199 to find out what sort of node actually served as the original seed for the
4203 decl_ultimate_origin (decl
)
4206 /* output_inline_function sets DECL_ABSTRACT_ORIGIN for all the
4207 nodes in the function to point to themselves; ignore that if
4208 we're trying to output the abstract instance of this function. */
4209 if (DECL_ABSTRACT (decl
) && DECL_ABSTRACT_ORIGIN (decl
) == decl
)
4212 #ifdef ENABLE_CHECKING
4213 if (DECL_FROM_INLINE (DECL_ORIGIN (decl
)))
4214 /* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
4215 most distant ancestor, this should never happen. */
4219 return DECL_ABSTRACT_ORIGIN (decl
);
4222 /* Determine the "ultimate origin" of a block. The block may be an inlined
4223 instance of an inlined instance of a block which is local to an inline
4224 function, so we have to trace all of the way back through the origin chain
4225 to find out what sort of node actually served as the original seed for the
4229 block_ultimate_origin (block
)
4230 register tree block
;
4232 register tree immediate_origin
= BLOCK_ABSTRACT_ORIGIN (block
);
4234 /* output_inline_function sets BLOCK_ABSTRACT_ORIGIN for all the
4235 nodes in the function to point to themselves; ignore that if
4236 we're trying to output the abstract instance of this function. */
4237 if (BLOCK_ABSTRACT (block
) && immediate_origin
== block
)
4240 if (immediate_origin
== NULL_TREE
)
4244 register tree ret_val
;
4245 register tree lookahead
= immediate_origin
;
4249 ret_val
= lookahead
;
4250 lookahead
= (TREE_CODE (ret_val
) == BLOCK
)
4251 ? BLOCK_ABSTRACT_ORIGIN (ret_val
)
4254 while (lookahead
!= NULL
&& lookahead
!= ret_val
);
4260 /* Get the class to which DECL belongs, if any. In g++, the DECL_CONTEXT
4261 of a virtual function may refer to a base class, so we check the 'this'
4265 decl_class_context (decl
)
4268 tree context
= NULL_TREE
;
4270 if (TREE_CODE (decl
) != FUNCTION_DECL
|| ! DECL_VINDEX (decl
))
4271 context
= DECL_CONTEXT (decl
);
4273 context
= TYPE_MAIN_VARIANT
4274 (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)))));
4276 if (context
&& !TYPE_P (context
))
4277 context
= NULL_TREE
;
4282 /* Add an attribute/value pair to a DIE. We build the lists up in reverse
4283 addition order, and correct that in reverse_all_dies. */
4286 add_dwarf_attr (die
, attr
)
4287 register dw_die_ref die
;
4288 register dw_attr_ref attr
;
4290 if (die
!= NULL
&& attr
!= NULL
)
4292 attr
->dw_attr_next
= die
->die_attr
;
4293 die
->die_attr
= attr
;
4297 static inline dw_val_class AT_class
PARAMS ((dw_attr_ref
));
4298 static inline dw_val_class
4302 return a
->dw_attr_val
.val_class
;
4305 /* Add a flag value attribute to a DIE. */
4308 add_AT_flag (die
, attr_kind
, flag
)
4309 register dw_die_ref die
;
4310 register enum dwarf_attribute attr_kind
;
4311 register unsigned flag
;
4313 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4315 attr
->dw_attr_next
= NULL
;
4316 attr
->dw_attr
= attr_kind
;
4317 attr
->dw_attr_val
.val_class
= dw_val_class_flag
;
4318 attr
->dw_attr_val
.v
.val_flag
= flag
;
4319 add_dwarf_attr (die
, attr
);
4322 static inline unsigned AT_flag
PARAMS ((dw_attr_ref
));
4323 static inline unsigned
4325 register dw_attr_ref a
;
4327 if (a
&& AT_class (a
) == dw_val_class_flag
)
4328 return a
->dw_attr_val
.v
.val_flag
;
4333 /* Add a signed integer attribute value to a DIE. */
4336 add_AT_int (die
, attr_kind
, int_val
)
4337 register dw_die_ref die
;
4338 register enum dwarf_attribute attr_kind
;
4339 register long int int_val
;
4341 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4343 attr
->dw_attr_next
= NULL
;
4344 attr
->dw_attr
= attr_kind
;
4345 attr
->dw_attr_val
.val_class
= dw_val_class_const
;
4346 attr
->dw_attr_val
.v
.val_int
= int_val
;
4347 add_dwarf_attr (die
, attr
);
4350 static inline long int AT_int
PARAMS ((dw_attr_ref
));
4351 static inline long int
4353 register dw_attr_ref a
;
4355 if (a
&& AT_class (a
) == dw_val_class_const
)
4356 return a
->dw_attr_val
.v
.val_int
;
4361 /* Add an unsigned integer attribute value to a DIE. */
4364 add_AT_unsigned (die
, attr_kind
, unsigned_val
)
4365 register dw_die_ref die
;
4366 register enum dwarf_attribute attr_kind
;
4367 register unsigned long unsigned_val
;
4369 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4371 attr
->dw_attr_next
= NULL
;
4372 attr
->dw_attr
= attr_kind
;
4373 attr
->dw_attr_val
.val_class
= dw_val_class_unsigned_const
;
4374 attr
->dw_attr_val
.v
.val_unsigned
= unsigned_val
;
4375 add_dwarf_attr (die
, attr
);
4378 static inline unsigned long AT_unsigned
PARAMS ((dw_attr_ref
));
4379 static inline unsigned long
4381 register dw_attr_ref a
;
4383 if (a
&& AT_class (a
) == dw_val_class_unsigned_const
)
4384 return a
->dw_attr_val
.v
.val_unsigned
;
4389 /* Add an unsigned double integer attribute value to a DIE. */
4392 add_AT_long_long (die
, attr_kind
, val_hi
, val_low
)
4393 register dw_die_ref die
;
4394 register enum dwarf_attribute attr_kind
;
4395 register unsigned long val_hi
;
4396 register unsigned long val_low
;
4398 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4400 attr
->dw_attr_next
= NULL
;
4401 attr
->dw_attr
= attr_kind
;
4402 attr
->dw_attr_val
.val_class
= dw_val_class_long_long
;
4403 attr
->dw_attr_val
.v
.val_long_long
.hi
= val_hi
;
4404 attr
->dw_attr_val
.v
.val_long_long
.low
= val_low
;
4405 add_dwarf_attr (die
, attr
);
4408 /* Add a floating point attribute value to a DIE and return it. */
4411 add_AT_float (die
, attr_kind
, length
, array
)
4412 register dw_die_ref die
;
4413 register enum dwarf_attribute attr_kind
;
4414 register unsigned length
;
4415 register long *array
;
4417 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4419 attr
->dw_attr_next
= NULL
;
4420 attr
->dw_attr
= attr_kind
;
4421 attr
->dw_attr_val
.val_class
= dw_val_class_float
;
4422 attr
->dw_attr_val
.v
.val_float
.length
= length
;
4423 attr
->dw_attr_val
.v
.val_float
.array
= array
;
4424 add_dwarf_attr (die
, attr
);
4427 /* Add a string attribute value to a DIE. */
4430 add_AT_string (die
, attr_kind
, str
)
4431 register dw_die_ref die
;
4432 register enum dwarf_attribute attr_kind
;
4433 register const char *str
;
4435 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4437 attr
->dw_attr_next
= NULL
;
4438 attr
->dw_attr
= attr_kind
;
4439 attr
->dw_attr_val
.val_class
= dw_val_class_str
;
4440 attr
->dw_attr_val
.v
.val_str
= xstrdup (str
);
4441 add_dwarf_attr (die
, attr
);
4444 static inline const char *AT_string
PARAMS ((dw_attr_ref
));
4445 static inline const char *
4447 register dw_attr_ref a
;
4449 if (a
&& AT_class (a
) == dw_val_class_str
)
4450 return a
->dw_attr_val
.v
.val_str
;
4455 /* Add a DIE reference attribute value to a DIE. */
4458 add_AT_die_ref (die
, attr_kind
, targ_die
)
4459 register dw_die_ref die
;
4460 register enum dwarf_attribute attr_kind
;
4461 register dw_die_ref targ_die
;
4463 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4465 attr
->dw_attr_next
= NULL
;
4466 attr
->dw_attr
= attr_kind
;
4467 attr
->dw_attr_val
.val_class
= dw_val_class_die_ref
;
4468 attr
->dw_attr_val
.v
.val_die_ref
.die
= targ_die
;
4469 attr
->dw_attr_val
.v
.val_die_ref
.external
= 0;
4470 add_dwarf_attr (die
, attr
);
4473 static inline dw_die_ref AT_ref
PARAMS ((dw_attr_ref
));
4474 static inline dw_die_ref
4476 register dw_attr_ref a
;
4478 if (a
&& AT_class (a
) == dw_val_class_die_ref
)
4479 return a
->dw_attr_val
.v
.val_die_ref
.die
;
4484 static inline int AT_ref_external
PARAMS ((dw_attr_ref
));
4487 register dw_attr_ref a
;
4489 if (a
&& AT_class (a
) == dw_val_class_die_ref
)
4490 return a
->dw_attr_val
.v
.val_die_ref
.external
;
4495 static inline void set_AT_ref_external
PARAMS ((dw_attr_ref
, int));
4497 set_AT_ref_external (a
, i
)
4498 register dw_attr_ref a
;
4501 if (a
&& AT_class (a
) == dw_val_class_die_ref
)
4502 a
->dw_attr_val
.v
.val_die_ref
.external
= i
;
4507 /* Add an FDE reference attribute value to a DIE. */
4510 add_AT_fde_ref (die
, attr_kind
, targ_fde
)
4511 register dw_die_ref die
;
4512 register enum dwarf_attribute attr_kind
;
4513 register unsigned targ_fde
;
4515 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4517 attr
->dw_attr_next
= NULL
;
4518 attr
->dw_attr
= attr_kind
;
4519 attr
->dw_attr_val
.val_class
= dw_val_class_fde_ref
;
4520 attr
->dw_attr_val
.v
.val_fde_index
= targ_fde
;
4521 add_dwarf_attr (die
, attr
);
4524 /* Add a location description attribute value to a DIE. */
4527 add_AT_loc (die
, attr_kind
, loc
)
4528 register dw_die_ref die
;
4529 register enum dwarf_attribute attr_kind
;
4530 register dw_loc_descr_ref loc
;
4532 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4534 attr
->dw_attr_next
= NULL
;
4535 attr
->dw_attr
= attr_kind
;
4536 attr
->dw_attr_val
.val_class
= dw_val_class_loc
;
4537 attr
->dw_attr_val
.v
.val_loc
= loc
;
4538 add_dwarf_attr (die
, attr
);
4541 static inline dw_loc_descr_ref AT_loc
PARAMS ((dw_attr_ref
));
4542 static inline dw_loc_descr_ref
4544 register dw_attr_ref a
;
4546 if (a
&& AT_class (a
) == dw_val_class_loc
)
4547 return a
->dw_attr_val
.v
.val_loc
;
4553 add_AT_loc_list (die
, attr_kind
, loc_list
)
4554 register dw_die_ref die
;
4555 register enum dwarf_attribute attr_kind
;
4556 register dw_loc_list_ref loc_list
;
4558 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4560 attr
->dw_attr_next
= NULL
;
4561 attr
->dw_attr
= attr_kind
;
4562 attr
->dw_attr_val
.val_class
= dw_val_class_loc_list
;
4563 attr
->dw_attr_val
.v
.val_loc_list
= loc_list
;
4564 add_dwarf_attr (die
, attr
);
4565 have_location_lists
= 1;
4568 static inline dw_loc_list_ref AT_loc_list
PARAMS ((dw_attr_ref
));
4570 static inline dw_loc_list_ref
4572 register dw_attr_ref a
;
4574 if (a
&& AT_class (a
) == dw_val_class_loc_list
)
4575 return a
->dw_attr_val
.v
.val_loc_list
;
4580 /* Add an address constant attribute value to a DIE. */
4583 add_AT_addr (die
, attr_kind
, addr
)
4584 register dw_die_ref die
;
4585 register enum dwarf_attribute attr_kind
;
4588 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4590 attr
->dw_attr_next
= NULL
;
4591 attr
->dw_attr
= attr_kind
;
4592 attr
->dw_attr_val
.val_class
= dw_val_class_addr
;
4593 attr
->dw_attr_val
.v
.val_addr
= addr
;
4594 add_dwarf_attr (die
, attr
);
4597 static inline rtx AT_addr
PARAMS ((dw_attr_ref
));
4600 register dw_attr_ref a
;
4602 if (a
&& AT_class (a
) == dw_val_class_addr
)
4603 return a
->dw_attr_val
.v
.val_addr
;
4608 /* Add a label identifier attribute value to a DIE. */
4611 add_AT_lbl_id (die
, attr_kind
, lbl_id
)
4612 register dw_die_ref die
;
4613 register enum dwarf_attribute attr_kind
;
4614 register const char *lbl_id
;
4616 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4618 attr
->dw_attr_next
= NULL
;
4619 attr
->dw_attr
= attr_kind
;
4620 attr
->dw_attr_val
.val_class
= dw_val_class_lbl_id
;
4621 attr
->dw_attr_val
.v
.val_lbl_id
= xstrdup (lbl_id
);
4622 add_dwarf_attr (die
, attr
);
4625 /* Add a section offset attribute value to a DIE. */
4628 add_AT_lbl_offset (die
, attr_kind
, label
)
4629 register dw_die_ref die
;
4630 register enum dwarf_attribute attr_kind
;
4631 register const char *label
;
4633 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4635 attr
->dw_attr_next
= NULL
;
4636 attr
->dw_attr
= attr_kind
;
4637 attr
->dw_attr_val
.val_class
= dw_val_class_lbl_offset
;
4638 attr
->dw_attr_val
.v
.val_lbl_id
= xstrdup (label
);
4639 add_dwarf_attr (die
, attr
);
4642 /* Add an offset attribute value to a DIE. */
4645 add_AT_offset (die
, attr_kind
, offset
)
4646 register dw_die_ref die
;
4647 register enum dwarf_attribute attr_kind
;
4648 register unsigned long offset
;
4650 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4652 attr
->dw_attr_next
= NULL
;
4653 attr
->dw_attr
= attr_kind
;
4654 attr
->dw_attr_val
.val_class
= dw_val_class_offset
;
4655 attr
->dw_attr_val
.v
.val_offset
= offset
;
4656 add_dwarf_attr (die
, attr
);
4659 static inline const char *AT_lbl
PARAMS ((dw_attr_ref
));
4660 static inline const char *
4662 register dw_attr_ref a
;
4664 if (a
&& (AT_class (a
) == dw_val_class_lbl_id
4665 || AT_class (a
) == dw_val_class_lbl_offset
))
4666 return a
->dw_attr_val
.v
.val_lbl_id
;
4671 /* Get the attribute of type attr_kind. */
4673 static inline dw_attr_ref
4674 get_AT (die
, attr_kind
)
4675 register dw_die_ref die
;
4676 register enum dwarf_attribute attr_kind
;
4678 register dw_attr_ref a
;
4679 register dw_die_ref spec
= NULL
;
4683 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
4685 if (a
->dw_attr
== attr_kind
)
4688 if (a
->dw_attr
== DW_AT_specification
4689 || a
->dw_attr
== DW_AT_abstract_origin
)
4694 return get_AT (spec
, attr_kind
);
4700 /* Return the "low pc" attribute value, typically associated with
4701 a subprogram DIE. Return null if the "low pc" attribute is
4702 either not prsent, or if it cannot be represented as an
4703 assembler label identifier. */
4705 static inline const char *
4707 register dw_die_ref die
;
4709 register dw_attr_ref a
= get_AT (die
, DW_AT_low_pc
);
4710 return a
? AT_lbl (a
) : NULL
;
4713 /* Return the "high pc" attribute value, typically associated with
4714 a subprogram DIE. Return null if the "high pc" attribute is
4715 either not prsent, or if it cannot be represented as an
4716 assembler label identifier. */
4718 static inline const char *
4720 register dw_die_ref die
;
4722 register dw_attr_ref a
= get_AT (die
, DW_AT_high_pc
);
4723 return a
? AT_lbl (a
) : NULL
;
4726 /* Return the value of the string attribute designated by ATTR_KIND, or
4727 NULL if it is not present. */
4729 static inline const char *
4730 get_AT_string (die
, attr_kind
)
4731 register dw_die_ref die
;
4732 register enum dwarf_attribute attr_kind
;
4734 register dw_attr_ref a
= get_AT (die
, attr_kind
);
4735 return a
? AT_string (a
) : NULL
;
4738 /* Return the value of the flag attribute designated by ATTR_KIND, or -1
4739 if it is not present. */
4742 get_AT_flag (die
, attr_kind
)
4743 register dw_die_ref die
;
4744 register enum dwarf_attribute attr_kind
;
4746 register dw_attr_ref a
= get_AT (die
, attr_kind
);
4747 return a
? AT_flag (a
) : 0;
4750 /* Return the value of the unsigned attribute designated by ATTR_KIND, or 0
4751 if it is not present. */
4753 static inline unsigned
4754 get_AT_unsigned (die
, attr_kind
)
4755 register dw_die_ref die
;
4756 register enum dwarf_attribute attr_kind
;
4758 register dw_attr_ref a
= get_AT (die
, attr_kind
);
4759 return a
? AT_unsigned (a
) : 0;
4762 static inline dw_die_ref
4763 get_AT_ref (die
, attr_kind
)
4765 register enum dwarf_attribute attr_kind
;
4767 register dw_attr_ref a
= get_AT (die
, attr_kind
);
4768 return a
? AT_ref (a
) : NULL
;
4774 register unsigned lang
= get_AT_unsigned (comp_unit_die
, DW_AT_language
);
4776 return (lang
== DW_LANG_C
|| lang
== DW_LANG_C89
4777 || lang
== DW_LANG_C_plus_plus
);
4783 register unsigned lang
= get_AT_unsigned (comp_unit_die
, DW_AT_language
);
4785 return (lang
== DW_LANG_Fortran77
|| lang
== DW_LANG_Fortran90
);
4791 register unsigned lang
= get_AT_unsigned (comp_unit_die
, DW_AT_language
);
4793 return (lang
== DW_LANG_Java
);
4796 /* Free up the memory used by A. */
4798 static inline void free_AT
PARAMS ((dw_attr_ref
));
4803 switch (AT_class (a
))
4805 case dw_val_class_str
:
4806 case dw_val_class_lbl_id
:
4807 case dw_val_class_lbl_offset
:
4808 free (a
->dw_attr_val
.v
.val_str
);
4811 case dw_val_class_float
:
4812 free (a
->dw_attr_val
.v
.val_float
.array
);
4822 /* Remove the specified attribute if present. */
4825 remove_AT (die
, attr_kind
)
4826 register dw_die_ref die
;
4827 register enum dwarf_attribute attr_kind
;
4829 register dw_attr_ref
*p
;
4830 register dw_attr_ref removed
= NULL
;
4834 for (p
= &(die
->die_attr
); *p
; p
= &((*p
)->dw_attr_next
))
4835 if ((*p
)->dw_attr
== attr_kind
)
4838 *p
= (*p
)->dw_attr_next
;
4847 /* Free up the memory used by DIE. */
4849 static inline void free_die
PARAMS ((dw_die_ref
));
4854 remove_children (die
);
4858 /* Discard the children of this DIE. */
4861 remove_children (die
)
4862 register dw_die_ref die
;
4864 register dw_die_ref child_die
= die
->die_child
;
4866 die
->die_child
= NULL
;
4868 while (child_die
!= NULL
)
4870 register dw_die_ref tmp_die
= child_die
;
4871 register dw_attr_ref a
;
4873 child_die
= child_die
->die_sib
;
4875 for (a
= tmp_die
->die_attr
; a
!= NULL
;)
4877 register dw_attr_ref tmp_a
= a
;
4879 a
= a
->dw_attr_next
;
4887 /* Add a child DIE below its parent. We build the lists up in reverse
4888 addition order, and correct that in reverse_all_dies. */
4891 add_child_die (die
, child_die
)
4892 register dw_die_ref die
;
4893 register dw_die_ref child_die
;
4895 if (die
!= NULL
&& child_die
!= NULL
)
4897 if (die
== child_die
)
4899 child_die
->die_parent
= die
;
4900 child_die
->die_sib
= die
->die_child
;
4901 die
->die_child
= child_die
;
4905 /* Move CHILD, which must be a child of PARENT or the DIE for which PARENT
4906 is the specification, to the front of PARENT's list of children. */
4909 splice_child_die (parent
, child
)
4910 dw_die_ref parent
, child
;
4914 /* We want the declaration DIE from inside the class, not the
4915 specification DIE at toplevel. */
4916 if (child
->die_parent
!= parent
)
4918 dw_die_ref tmp
= get_AT_ref (child
, DW_AT_specification
);
4923 if (child
->die_parent
!= parent
4924 && child
->die_parent
!= get_AT_ref (parent
, DW_AT_specification
))
4927 for (p
= &(child
->die_parent
->die_child
); *p
; p
= &((*p
)->die_sib
))
4930 *p
= child
->die_sib
;
4934 child
->die_sib
= parent
->die_child
;
4935 parent
->die_child
= child
;
4938 /* Return a pointer to a newly created DIE node. */
4940 static inline dw_die_ref
4941 new_die (tag_value
, parent_die
)
4942 register enum dwarf_tag tag_value
;
4943 register dw_die_ref parent_die
;
4945 register dw_die_ref die
= (dw_die_ref
) xcalloc (1, sizeof (die_node
));
4947 die
->die_tag
= tag_value
;
4949 if (parent_die
!= NULL
)
4950 add_child_die (parent_die
, die
);
4953 limbo_die_node
*limbo_node
;
4955 limbo_node
= (limbo_die_node
*) xmalloc (sizeof (limbo_die_node
));
4956 limbo_node
->die
= die
;
4957 limbo_node
->next
= limbo_die_list
;
4958 limbo_die_list
= limbo_node
;
4964 /* Return the DIE associated with the given type specifier. */
4966 static inline dw_die_ref
4967 lookup_type_die (type
)
4970 if (TREE_CODE (type
) == VECTOR_TYPE
)
4971 type
= TYPE_DEBUG_REPRESENTATION_TYPE (type
);
4972 return (dw_die_ref
) TYPE_SYMTAB_POINTER (type
);
4975 /* Equate a DIE to a given type specifier. */
4978 equate_type_number_to_die (type
, type_die
)
4980 register dw_die_ref type_die
;
4982 TYPE_SYMTAB_POINTER (type
) = (char *) type_die
;
4985 /* Return the DIE associated with a given declaration. */
4987 static inline dw_die_ref
4988 lookup_decl_die (decl
)
4991 register unsigned decl_id
= DECL_UID (decl
);
4993 return (decl_id
< decl_die_table_in_use
4994 ? decl_die_table
[decl_id
] : NULL
);
4997 /* Equate a DIE to a particular declaration. */
5000 equate_decl_number_to_die (decl
, decl_die
)
5002 register dw_die_ref decl_die
;
5004 register unsigned decl_id
= DECL_UID (decl
);
5005 register unsigned num_allocated
;
5007 if (decl_id
>= decl_die_table_allocated
)
5010 = ((decl_id
+ 1 + DECL_DIE_TABLE_INCREMENT
- 1)
5011 / DECL_DIE_TABLE_INCREMENT
)
5012 * DECL_DIE_TABLE_INCREMENT
;
5015 = (dw_die_ref
*) xrealloc (decl_die_table
,
5016 sizeof (dw_die_ref
) * num_allocated
);
5018 memset ((char *) &decl_die_table
[decl_die_table_allocated
], 0,
5019 (num_allocated
- decl_die_table_allocated
) * sizeof (dw_die_ref
));
5020 decl_die_table_allocated
= num_allocated
;
5023 if (decl_id
>= decl_die_table_in_use
)
5024 decl_die_table_in_use
= (decl_id
+ 1);
5026 decl_die_table
[decl_id
] = decl_die
;
5029 /* Keep track of the number of spaces used to indent the
5030 output of the debugging routines that print the structure of
5031 the DIE internal representation. */
5032 static int print_indent
;
5034 /* Indent the line the number of spaces given by print_indent. */
5037 print_spaces (outfile
)
5040 fprintf (outfile
, "%*s", print_indent
, "");
5043 /* Print the information associated with a given DIE, and its children.
5044 This routine is a debugging aid only. */
5047 print_die (die
, outfile
)
5051 register dw_attr_ref a
;
5052 register dw_die_ref c
;
5054 print_spaces (outfile
);
5055 fprintf (outfile
, "DIE %4lu: %s\n",
5056 die
->die_offset
, dwarf_tag_name (die
->die_tag
));
5057 print_spaces (outfile
);
5058 fprintf (outfile
, " abbrev id: %lu", die
->die_abbrev
);
5059 fprintf (outfile
, " offset: %lu\n", die
->die_offset
);
5061 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
5063 print_spaces (outfile
);
5064 fprintf (outfile
, " %s: ", dwarf_attr_name (a
->dw_attr
));
5066 switch (AT_class (a
))
5068 case dw_val_class_addr
:
5069 fprintf (outfile
, "address");
5071 case dw_val_class_offset
:
5072 fprintf (outfile
, "offset");
5074 case dw_val_class_loc
:
5075 fprintf (outfile
, "location descriptor");
5077 case dw_val_class_loc_list
:
5078 fprintf (outfile
, "location list -> label:%s",
5079 AT_loc_list (a
)->ll_symbol
);
5081 case dw_val_class_const
:
5082 fprintf (outfile
, "%ld", AT_int (a
));
5084 case dw_val_class_unsigned_const
:
5085 fprintf (outfile
, "%lu", AT_unsigned (a
));
5087 case dw_val_class_long_long
:
5088 fprintf (outfile
, "constant (%lu,%lu)",
5089 a
->dw_attr_val
.v
.val_long_long
.hi
,
5090 a
->dw_attr_val
.v
.val_long_long
.low
);
5092 case dw_val_class_float
:
5093 fprintf (outfile
, "floating-point constant");
5095 case dw_val_class_flag
:
5096 fprintf (outfile
, "%u", AT_flag (a
));
5098 case dw_val_class_die_ref
:
5099 if (AT_ref (a
) != NULL
)
5101 if (AT_ref (a
)->die_symbol
)
5102 fprintf (outfile
, "die -> label: %s", AT_ref (a
)->die_symbol
);
5104 fprintf (outfile
, "die -> %lu", AT_ref (a
)->die_offset
);
5107 fprintf (outfile
, "die -> <null>");
5109 case dw_val_class_lbl_id
:
5110 case dw_val_class_lbl_offset
:
5111 fprintf (outfile
, "label: %s", AT_lbl (a
));
5113 case dw_val_class_str
:
5114 if (AT_string (a
) != NULL
)
5115 fprintf (outfile
, "\"%s\"", AT_string (a
));
5117 fprintf (outfile
, "<null>");
5123 fprintf (outfile
, "\n");
5126 if (die
->die_child
!= NULL
)
5129 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
5130 print_die (c
, outfile
);
5134 if (print_indent
== 0)
5135 fprintf (outfile
, "\n");
5138 /* Print the contents of the source code line number correspondence table.
5139 This routine is a debugging aid only. */
5142 print_dwarf_line_table (outfile
)
5145 register unsigned i
;
5146 register dw_line_info_ref line_info
;
5148 fprintf (outfile
, "\n\nDWARF source line information\n");
5149 for (i
= 1; i
< line_info_table_in_use
; ++i
)
5151 line_info
= &line_info_table
[i
];
5152 fprintf (outfile
, "%5d: ", i
);
5153 fprintf (outfile
, "%-20s", file_table
.table
[line_info
->dw_file_num
]);
5154 fprintf (outfile
, "%6ld", line_info
->dw_line_num
);
5155 fprintf (outfile
, "\n");
5158 fprintf (outfile
, "\n\n");
5161 /* Print the information collected for a given DIE. */
5164 debug_dwarf_die (die
)
5167 print_die (die
, stderr
);
5170 /* Print all DWARF information collected for the compilation unit.
5171 This routine is a debugging aid only. */
5177 print_die (comp_unit_die
, stderr
);
5178 if (! DWARF2_ASM_LINE_DEBUG_INFO
)
5179 print_dwarf_line_table (stderr
);
5182 /* We build up the lists of children and attributes by pushing new ones
5183 onto the beginning of the list. Reverse the lists for DIE so that
5184 they are in order of addition. */
5187 reverse_die_lists (die
)
5188 register dw_die_ref die
;
5190 register dw_die_ref c
, cp
, cn
;
5191 register dw_attr_ref a
, ap
, an
;
5193 for (a
= die
->die_attr
, ap
= 0; a
; a
= an
)
5195 an
= a
->dw_attr_next
;
5196 a
->dw_attr_next
= ap
;
5201 for (c
= die
->die_child
, cp
= 0; c
; c
= cn
)
5207 die
->die_child
= cp
;
5210 /* reverse_die_lists only reverses the single die you pass it. Since
5211 we used to reverse all dies in add_sibling_attributes, which runs
5212 through all the dies, it would reverse all the dies. Now, however,
5213 since we don't call reverse_die_lists in add_sibling_attributes, we
5214 need a routine to recursively reverse all the dies. This is that
5218 reverse_all_dies (die
)
5219 register dw_die_ref die
;
5221 register dw_die_ref c
;
5223 reverse_die_lists (die
);
5225 for (c
= die
->die_child
; c
; c
= c
->die_sib
)
5226 reverse_all_dies (c
);
5229 /* Start a new compilation unit DIE for an include file. OLD_UNIT is
5230 the CU for the enclosing include file, if any. BINCL_DIE is the
5231 DW_TAG_GNU_BINCL DIE that marks the start of the DIEs for this
5235 push_new_compile_unit (old_unit
, bincl_die
)
5236 dw_die_ref old_unit
, bincl_die
;
5238 const char *filename
= get_AT_string (bincl_die
, DW_AT_name
);
5239 dw_die_ref new_unit
= gen_compile_unit_die (filename
);
5240 new_unit
->die_sib
= old_unit
;
5244 /* Close an include-file CU and reopen the enclosing one. */
5247 pop_compile_unit (old_unit
)
5248 dw_die_ref old_unit
;
5250 dw_die_ref new_unit
= old_unit
->die_sib
;
5251 old_unit
->die_sib
= NULL
;
5255 #define PROCESS(FOO) md5_process_bytes (&(FOO), sizeof (FOO), ctx)
5256 #define PROCESS_STRING(FOO) md5_process_bytes ((FOO), strlen (FOO), ctx)
5258 /* Calculate the checksum of a location expression. */
5261 loc_checksum (loc
, ctx
)
5262 dw_loc_descr_ref loc
;
5263 struct md5_ctx
*ctx
;
5265 PROCESS (loc
->dw_loc_opc
);
5266 PROCESS (loc
->dw_loc_oprnd1
);
5267 PROCESS (loc
->dw_loc_oprnd2
);
5270 /* Calculate the checksum of an attribute. */
5273 attr_checksum (at
, ctx
)
5275 struct md5_ctx
*ctx
;
5277 dw_loc_descr_ref loc
;
5280 PROCESS (at
->dw_attr
);
5282 /* We don't care about differences in file numbering. */
5283 if (at
->dw_attr
== DW_AT_decl_file
5284 /* Or that this was compiled with a different compiler snapshot; if
5285 the output is the same, that's what matters. */
5286 || at
->dw_attr
== DW_AT_producer
)
5289 switch (AT_class (at
))
5291 case dw_val_class_const
:
5292 PROCESS (at
->dw_attr_val
.v
.val_int
);
5294 case dw_val_class_unsigned_const
:
5295 PROCESS (at
->dw_attr_val
.v
.val_unsigned
);
5297 case dw_val_class_long_long
:
5298 PROCESS (at
->dw_attr_val
.v
.val_long_long
);
5300 case dw_val_class_float
:
5301 PROCESS (at
->dw_attr_val
.v
.val_float
);
5303 case dw_val_class_flag
:
5304 PROCESS (at
->dw_attr_val
.v
.val_flag
);
5307 case dw_val_class_str
:
5308 PROCESS_STRING (AT_string (at
));
5311 case dw_val_class_addr
:
5313 switch (GET_CODE (r
))
5316 PROCESS_STRING (XSTR (r
, 0));
5324 case dw_val_class_offset
:
5325 PROCESS (at
->dw_attr_val
.v
.val_offset
);
5328 case dw_val_class_loc
:
5329 for (loc
= AT_loc (at
); loc
; loc
= loc
->dw_loc_next
)
5330 loc_checksum (loc
, ctx
);
5333 case dw_val_class_die_ref
:
5334 if (AT_ref (at
)->die_offset
)
5335 PROCESS (AT_ref (at
)->die_offset
);
5336 /* FIXME else use target die name or something. */
5338 case dw_val_class_fde_ref
:
5339 case dw_val_class_lbl_id
:
5340 case dw_val_class_lbl_offset
:
5348 /* Calculate the checksum of a DIE. */
5351 die_checksum (die
, ctx
)
5353 struct md5_ctx
*ctx
;
5358 PROCESS (die
->die_tag
);
5360 for (a
= die
->die_attr
; a
; a
= a
->dw_attr_next
)
5361 attr_checksum (a
, ctx
);
5363 for (c
= die
->die_child
; c
; c
= c
->die_sib
)
5364 die_checksum (c
, ctx
);
5368 #undef PROCESS_STRING
5370 /* The prefix to attach to symbols on DIEs in the current comdat debug
5372 static char *comdat_symbol_id
;
5374 /* The index of the current symbol within the current comdat CU. */
5375 static unsigned int comdat_symbol_number
;
5377 /* Calculate the MD5 checksum of the compilation unit DIE UNIT_DIE and its
5378 children, and set comdat_symbol_id accordingly. */
5381 compute_section_prefix (unit_die
)
5382 dw_die_ref unit_die
;
5386 unsigned char checksum
[16];
5389 md5_init_ctx (&ctx
);
5390 die_checksum (unit_die
, &ctx
);
5391 md5_finish_ctx (&ctx
, checksum
);
5394 const char *p
= lbasename (get_AT_string (unit_die
, DW_AT_name
));
5395 name
= (char *) alloca (strlen (p
) + 64);
5396 sprintf (name
, "%s.", p
);
5399 clean_symbol_name (name
);
5402 char *p
= name
+ strlen (name
);
5403 for (i
= 0; i
< 4; ++i
)
5405 sprintf (p
, "%.2x", checksum
[i
]);
5410 comdat_symbol_id
= unit_die
->die_symbol
= xstrdup (name
);
5411 comdat_symbol_number
= 0;
5414 /* Returns nonzero iff DIE represents a type, in the sense of TYPE_P. */
5420 switch (die
->die_tag
)
5422 case DW_TAG_array_type
:
5423 case DW_TAG_class_type
:
5424 case DW_TAG_enumeration_type
:
5425 case DW_TAG_pointer_type
:
5426 case DW_TAG_reference_type
:
5427 case DW_TAG_string_type
:
5428 case DW_TAG_structure_type
:
5429 case DW_TAG_subroutine_type
:
5430 case DW_TAG_union_type
:
5431 case DW_TAG_ptr_to_member_type
:
5432 case DW_TAG_set_type
:
5433 case DW_TAG_subrange_type
:
5434 case DW_TAG_base_type
:
5435 case DW_TAG_const_type
:
5436 case DW_TAG_file_type
:
5437 case DW_TAG_packed_type
:
5438 case DW_TAG_volatile_type
:
5445 /* Returns 1 iff C is the sort of DIE that should go into a COMDAT CU.
5446 Basically, we want to choose the bits that are likely to be shared between
5447 compilations (types) and leave out the bits that are specific to individual
5448 compilations (functions). */
5455 /* I think we want to leave base types and __vtbl_ptr_type in the
5456 main CU, as we do for stabs. The advantage is a greater
5457 likelihood of sharing between objects that don't include headers
5458 in the same order (and therefore would put the base types in a
5459 different comdat). jason 8/28/00 */
5460 if (c
->die_tag
== DW_TAG_base_type
)
5463 if (c
->die_tag
== DW_TAG_pointer_type
5464 || c
->die_tag
== DW_TAG_reference_type
5465 || c
->die_tag
== DW_TAG_const_type
5466 || c
->die_tag
== DW_TAG_volatile_type
)
5468 dw_die_ref t
= get_AT_ref (c
, DW_AT_type
);
5469 return t
? is_comdat_die (t
) : 0;
5473 return is_type_die (c
);
5476 /* Returns 1 iff C is the sort of DIE that might be referred to from another
5477 compilation unit. */
5483 if (is_type_die (c
))
5485 if (get_AT (c
, DW_AT_declaration
)
5486 && ! get_AT (c
, DW_AT_specification
))
5492 gen_internal_sym (prefix
)
5496 static int label_num
;
5497 ASM_GENERATE_INTERNAL_LABEL (buf
, prefix
, label_num
++);
5498 return xstrdup (buf
);
5501 /* Assign symbols to all worthy DIEs under DIE. */
5504 assign_symbol_names (die
)
5505 register dw_die_ref die
;
5507 register dw_die_ref c
;
5509 if (is_symbol_die (die
))
5511 if (comdat_symbol_id
)
5513 char *p
= alloca (strlen (comdat_symbol_id
) + 64);
5514 sprintf (p
, "%s.%s.%x", DIE_LABEL_PREFIX
,
5515 comdat_symbol_id
, comdat_symbol_number
++);
5516 die
->die_symbol
= xstrdup (p
);
5519 die
->die_symbol
= gen_internal_sym ("LDIE");
5522 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
5523 assign_symbol_names (c
);
5526 /* Traverse the DIE (which is always comp_unit_die), and set up
5527 additional compilation units for each of the include files we see
5528 bracketed by BINCL/EINCL. */
5531 break_out_includes (die
)
5532 register dw_die_ref die
;
5535 register dw_die_ref unit
= NULL
;
5536 limbo_die_node
*node
;
5538 for (ptr
= &(die
->die_child
); *ptr
; )
5540 register dw_die_ref c
= *ptr
;
5542 if (c
->die_tag
== DW_TAG_GNU_BINCL
5543 || c
->die_tag
== DW_TAG_GNU_EINCL
5544 || (unit
&& is_comdat_die (c
)))
5546 /* This DIE is for a secondary CU; remove it from the main one. */
5549 if (c
->die_tag
== DW_TAG_GNU_BINCL
)
5551 unit
= push_new_compile_unit (unit
, c
);
5554 else if (c
->die_tag
== DW_TAG_GNU_EINCL
)
5556 unit
= pop_compile_unit (unit
);
5560 add_child_die (unit
, c
);
5564 /* Leave this DIE in the main CU. */
5565 ptr
= &(c
->die_sib
);
5571 /* We can only use this in debugging, since the frontend doesn't check
5572 to make sure that we leave every include file we enter. */
5577 assign_symbol_names (die
);
5578 for (node
= limbo_die_list
; node
; node
= node
->next
)
5580 compute_section_prefix (node
->die
);
5581 assign_symbol_names (node
->die
);
5585 /* Traverse the DIE and add a sibling attribute if it may have the
5586 effect of speeding up access to siblings. To save some space,
5587 avoid generating sibling attributes for DIE's without children. */
5590 add_sibling_attributes (die
)
5591 register dw_die_ref die
;
5593 register dw_die_ref c
;
5595 if (die
->die_tag
!= DW_TAG_compile_unit
5596 && die
->die_sib
&& die
->die_child
!= NULL
)
5597 /* Add the sibling link to the front of the attribute list. */
5598 add_AT_die_ref (die
, DW_AT_sibling
, die
->die_sib
);
5600 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
5601 add_sibling_attributes (c
);
5604 /* Output all location lists for the DIE and it's children */
5606 output_location_lists (die
)
5607 register dw_die_ref die
;
5611 for (d_attr
= die
->die_attr
; d_attr
; d_attr
= d_attr
->dw_attr_next
)
5613 if (AT_class (d_attr
) == dw_val_class_loc_list
)
5615 output_loc_list (AT_loc_list (d_attr
));
5618 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
5619 output_location_lists (c
);
5622 /* The format of each DIE (and its attribute value pairs)
5623 is encoded in an abbreviation table. This routine builds the
5624 abbreviation table and assigns a unique abbreviation id for
5625 each abbreviation entry. The children of each die are visited
5629 build_abbrev_table (die
)
5630 register dw_die_ref die
;
5632 register unsigned long abbrev_id
;
5633 register unsigned int n_alloc
;
5634 register dw_die_ref c
;
5635 register dw_attr_ref d_attr
, a_attr
;
5637 /* Scan the DIE references, and mark as external any that refer to
5638 DIEs from other CUs (i.e. those which are not marked). */
5639 for (d_attr
= die
->die_attr
; d_attr
; d_attr
= d_attr
->dw_attr_next
)
5641 if (AT_class (d_attr
) == dw_val_class_die_ref
5642 && AT_ref (d_attr
)->die_mark
== 0)
5644 if (AT_ref (d_attr
)->die_symbol
== 0)
5646 set_AT_ref_external (d_attr
, 1);
5650 for (abbrev_id
= 1; abbrev_id
< abbrev_die_table_in_use
; ++abbrev_id
)
5652 register dw_die_ref abbrev
= abbrev_die_table
[abbrev_id
];
5654 if (abbrev
->die_tag
== die
->die_tag
)
5656 if ((abbrev
->die_child
!= NULL
) == (die
->die_child
!= NULL
))
5658 a_attr
= abbrev
->die_attr
;
5659 d_attr
= die
->die_attr
;
5661 while (a_attr
!= NULL
&& d_attr
!= NULL
)
5663 if ((a_attr
->dw_attr
!= d_attr
->dw_attr
)
5664 || (value_format (a_attr
) != value_format (d_attr
)))
5667 a_attr
= a_attr
->dw_attr_next
;
5668 d_attr
= d_attr
->dw_attr_next
;
5671 if (a_attr
== NULL
&& d_attr
== NULL
)
5677 if (abbrev_id
>= abbrev_die_table_in_use
)
5679 if (abbrev_die_table_in_use
>= abbrev_die_table_allocated
)
5681 n_alloc
= abbrev_die_table_allocated
+ ABBREV_DIE_TABLE_INCREMENT
;
5683 = (dw_die_ref
*) xrealloc (abbrev_die_table
,
5684 sizeof (dw_die_ref
) * n_alloc
);
5686 memset ((char *) &abbrev_die_table
[abbrev_die_table_allocated
], 0,
5687 (n_alloc
- abbrev_die_table_allocated
) * sizeof (dw_die_ref
));
5688 abbrev_die_table_allocated
= n_alloc
;
5691 ++abbrev_die_table_in_use
;
5692 abbrev_die_table
[abbrev_id
] = die
;
5695 die
->die_abbrev
= abbrev_id
;
5696 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
5697 build_abbrev_table (c
);
5700 /* Return the size of a string, including the null byte.
5702 This used to treat backslashes as escapes, and hence they were not included
5703 in the count. However, that conflicts with what ASM_OUTPUT_ASCII does,
5704 which treats a backslash as a backslash, escaping it if necessary, and hence
5705 we must include them in the count. */
5707 static unsigned long
5708 size_of_string (str
)
5709 register const char *str
;
5711 return strlen (str
) + 1;
5714 /* Return the power-of-two number of bytes necessary to represent VALUE. */
5717 constant_size (value
)
5718 long unsigned value
;
5725 log
= floor_log2 (value
);
5728 log
= 1 << (floor_log2 (log
) + 1);
5733 /* Return the size of a DIE, as it is represented in the
5734 .debug_info section. */
5736 static unsigned long
5738 register dw_die_ref die
;
5740 register unsigned long size
= 0;
5741 register dw_attr_ref a
;
5743 size
+= size_of_uleb128 (die
->die_abbrev
);
5744 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
5746 switch (AT_class (a
))
5748 case dw_val_class_addr
:
5749 size
+= DWARF2_ADDR_SIZE
;
5751 case dw_val_class_offset
:
5752 size
+= DWARF_OFFSET_SIZE
;
5754 case dw_val_class_loc
:
5756 register unsigned long lsize
= size_of_locs (AT_loc (a
));
5759 size
+= constant_size (lsize
);
5763 case dw_val_class_loc_list
:
5764 size
+= DWARF_OFFSET_SIZE
;
5766 case dw_val_class_const
:
5767 size
+= size_of_sleb128 (AT_int (a
));
5769 case dw_val_class_unsigned_const
:
5770 size
+= constant_size (AT_unsigned (a
));
5772 case dw_val_class_long_long
:
5773 size
+= 1 + 2*HOST_BITS_PER_LONG
/HOST_BITS_PER_CHAR
; /* block */
5775 case dw_val_class_float
:
5776 size
+= 1 + a
->dw_attr_val
.v
.val_float
.length
* 4; /* block */
5778 case dw_val_class_flag
:
5781 case dw_val_class_die_ref
:
5782 size
+= DWARF_OFFSET_SIZE
;
5784 case dw_val_class_fde_ref
:
5785 size
+= DWARF_OFFSET_SIZE
;
5787 case dw_val_class_lbl_id
:
5788 size
+= DWARF2_ADDR_SIZE
;
5790 case dw_val_class_lbl_offset
:
5791 size
+= DWARF_OFFSET_SIZE
;
5793 case dw_val_class_str
:
5794 size
+= size_of_string (AT_string (a
));
5804 /* Size the debugging information associated with a given DIE.
5805 Visits the DIE's children recursively. Updates the global
5806 variable next_die_offset, on each time through. Uses the
5807 current value of next_die_offset to update the die_offset
5808 field in each DIE. */
5811 calc_die_sizes (die
)
5814 register dw_die_ref c
;
5815 die
->die_offset
= next_die_offset
;
5816 next_die_offset
+= size_of_die (die
);
5818 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
5821 if (die
->die_child
!= NULL
)
5822 /* Count the null byte used to terminate sibling lists. */
5823 next_die_offset
+= 1;
5826 /* Set the marks for a die and its children. We do this so
5827 that we know whether or not a reference needs to use FORM_ref_addr; only
5828 DIEs in the same CU will be marked. We used to clear out the offset
5829 and use that as the flag, but ran into ordering problems. */
5835 register dw_die_ref c
;
5837 for (c
= die
->die_child
; c
; c
= c
->die_sib
)
5841 /* Clear the marks for a die and its children. */
5847 register dw_die_ref c
;
5849 for (c
= die
->die_child
; c
; c
= c
->die_sib
)
5853 /* Return the size of the .debug_pubnames table generated for the
5854 compilation unit. */
5856 static unsigned long
5859 register unsigned long size
;
5860 register unsigned i
;
5862 size
= DWARF_PUBNAMES_HEADER_SIZE
;
5863 for (i
= 0; i
< pubname_table_in_use
; ++i
)
5865 register pubname_ref p
= &pubname_table
[i
];
5866 size
+= DWARF_OFFSET_SIZE
+ size_of_string (p
->name
);
5869 size
+= DWARF_OFFSET_SIZE
;
5873 /* Return the size of the information in the .debug_aranges section. */
5875 static unsigned long
5878 register unsigned long size
;
5880 size
= DWARF_ARANGES_HEADER_SIZE
;
5882 /* Count the address/length pair for this compilation unit. */
5883 size
+= 2 * DWARF2_ADDR_SIZE
;
5884 size
+= 2 * DWARF2_ADDR_SIZE
* arange_table_in_use
;
5886 /* Count the two zero words used to terminated the address range table. */
5887 size
+= 2 * DWARF2_ADDR_SIZE
;
5891 /* Select the encoding of an attribute value. */
5893 static enum dwarf_form
5897 switch (a
->dw_attr_val
.val_class
)
5899 case dw_val_class_addr
:
5900 return DW_FORM_addr
;
5901 case dw_val_class_offset
:
5902 if (DWARF_OFFSET_SIZE
== 4)
5903 return DW_FORM_data4
;
5904 if (DWARF_OFFSET_SIZE
== 8)
5905 return DW_FORM_data8
;
5907 case dw_val_class_loc_list
:
5908 /* FIXME: Could be DW_FORM_data8, with a > 32 bit size
5909 .debug_loc section */
5910 return DW_FORM_data4
;
5911 case dw_val_class_loc
:
5912 switch (constant_size (size_of_locs (AT_loc (a
))))
5915 return DW_FORM_block1
;
5917 return DW_FORM_block2
;
5921 case dw_val_class_const
:
5922 return DW_FORM_sdata
;
5923 case dw_val_class_unsigned_const
:
5924 switch (constant_size (AT_unsigned (a
)))
5927 return DW_FORM_data1
;
5929 return DW_FORM_data2
;
5931 return DW_FORM_data4
;
5933 return DW_FORM_data8
;
5937 case dw_val_class_long_long
:
5938 return DW_FORM_block1
;
5939 case dw_val_class_float
:
5940 return DW_FORM_block1
;
5941 case dw_val_class_flag
:
5942 return DW_FORM_flag
;
5943 case dw_val_class_die_ref
:
5944 if (AT_ref_external (a
))
5945 return DW_FORM_ref_addr
;
5948 case dw_val_class_fde_ref
:
5949 return DW_FORM_data
;
5950 case dw_val_class_lbl_id
:
5951 return DW_FORM_addr
;
5952 case dw_val_class_lbl_offset
:
5953 return DW_FORM_data
;
5954 case dw_val_class_str
:
5955 return DW_FORM_string
;
5962 /* Output the encoding of an attribute value. */
5965 output_value_format (a
)
5968 enum dwarf_form form
= value_format (a
);
5969 dw2_asm_output_data_uleb128 (form
, "(%s)", dwarf_form_name (form
));
5972 /* Output the .debug_abbrev section which defines the DIE abbreviation
5976 output_abbrev_section ()
5978 unsigned long abbrev_id
;
5981 for (abbrev_id
= 1; abbrev_id
< abbrev_die_table_in_use
; ++abbrev_id
)
5983 register dw_die_ref abbrev
= abbrev_die_table
[abbrev_id
];
5985 dw2_asm_output_data_uleb128 (abbrev_id
, "(abbrev code)");
5987 dw2_asm_output_data_uleb128 (abbrev
->die_tag
, "(TAG: %s)",
5988 dwarf_tag_name (abbrev
->die_tag
));
5990 if (abbrev
->die_child
!= NULL
)
5991 dw2_asm_output_data (1, DW_children_yes
, "DW_children_yes");
5993 dw2_asm_output_data (1, DW_children_no
, "DW_children_no");
5995 for (a_attr
= abbrev
->die_attr
; a_attr
!= NULL
;
5996 a_attr
= a_attr
->dw_attr_next
)
5998 dw2_asm_output_data_uleb128 (a_attr
->dw_attr
, "(%s)",
5999 dwarf_attr_name (a_attr
->dw_attr
));
6000 output_value_format (a_attr
);
6003 dw2_asm_output_data (1, 0, NULL
);
6004 dw2_asm_output_data (1, 0, NULL
);
6007 /* Terminate the table. */
6008 dw2_asm_output_data (1, 0, NULL
);
6011 /* Output a symbol we can use to refer to this DIE from another CU. */
6014 output_die_symbol (die
)
6015 register dw_die_ref die
;
6017 char *sym
= die
->die_symbol
;
6022 if (strncmp (sym
, DIE_LABEL_PREFIX
, sizeof (DIE_LABEL_PREFIX
) - 1) == 0)
6023 /* We make these global, not weak; if the target doesn't support
6024 .linkonce, it doesn't support combining the sections, so debugging
6026 ASM_GLOBALIZE_LABEL (asm_out_file
, sym
);
6027 ASM_OUTPUT_LABEL (asm_out_file
, sym
);
6030 /* Return a new location list, given the begin and end range, and the
6031 expression. gensym tells us whether to generate a new internal
6032 symbol for this location list node, which is done for the head of
6034 static inline dw_loc_list_ref
6035 new_loc_list (expr
, begin
, end
, section
, gensym
)
6036 register dw_loc_descr_ref expr
;
6037 register const char *begin
;
6038 register const char *end
;
6039 register const char *section
;
6040 register unsigned gensym
;
6042 register dw_loc_list_ref retlist
6043 = (dw_loc_list_ref
) xcalloc (1, sizeof (dw_loc_list_node
));
6044 retlist
->begin
= begin
;
6046 retlist
->expr
= expr
;
6047 retlist
->section
= section
;
6049 retlist
->ll_symbol
= gen_internal_sym ("LLST");
6053 /* Add a location description expression to a location list */
6055 add_loc_descr_to_loc_list (list_head
, descr
, begin
, end
, section
)
6056 register dw_loc_list_ref
*list_head
;
6057 register dw_loc_descr_ref descr
;
6058 register const char *begin
;
6059 register const char *end
;
6060 register const char *section
;
6062 register dw_loc_list_ref
*d
;
6064 /* Find the end of the chain. */
6065 for (d
= list_head
; (*d
) != NULL
; d
= &(*d
)->dw_loc_next
)
6067 /* Add a new location list node to the list */
6068 *d
= new_loc_list (descr
, begin
, end
, section
, 0);
6071 /* Output the location list given to us */
6073 output_loc_list (list_head
)
6074 register dw_loc_list_ref list_head
;
6076 register dw_loc_list_ref curr
=list_head
;
6077 ASM_OUTPUT_LABEL (asm_out_file
, list_head
->ll_symbol
);
6079 /* ??? This shouldn't be needed now that we've forced the
6080 compilation unit base address to zero when there is code
6081 in more than one section. */
6082 if (strcmp (curr
->section
, ".text") == 0)
6084 /* dw2_asm_output_data will mask off any extra bits in the ~0. */
6085 dw2_asm_output_data (DWARF2_ADDR_SIZE
, ~(unsigned HOST_WIDE_INT
)0,
6086 "Location list base address specifier fake entry");
6087 dw2_asm_output_offset (DWARF2_ADDR_SIZE
, curr
->section
,
6088 "Location list base address specifier base");
6090 for (curr
= list_head
; curr
!= NULL
; curr
=curr
->dw_loc_next
)
6093 dw2_asm_output_delta (DWARF2_ADDR_SIZE
, curr
->begin
, curr
->section
,
6094 "Location list begin address (%s)",
6095 list_head
->ll_symbol
);
6096 dw2_asm_output_delta (DWARF2_ADDR_SIZE
, curr
->end
, curr
->section
,
6097 "Location list end address (%s)",
6098 list_head
->ll_symbol
);
6099 size
= size_of_locs (curr
->expr
);
6101 /* Output the block length for this list of location operations. */
6102 dw2_asm_output_data (constant_size (size
), size
, "%s",
6103 "Location expression size");
6105 output_loc_sequence (curr
->expr
);
6107 dw2_asm_output_data (DWARF_OFFSET_SIZE
, 0,
6108 "Location list terminator begin (%s)",
6109 list_head
->ll_symbol
);
6110 dw2_asm_output_data (DWARF_OFFSET_SIZE
, 0,
6111 "Location list terminator end (%s)",
6112 list_head
->ll_symbol
);
6114 /* Output the DIE and its attributes. Called recursively to generate
6115 the definitions of each child DIE. */
6119 register dw_die_ref die
;
6121 register dw_attr_ref a
;
6122 register dw_die_ref c
;
6123 register unsigned long size
;
6125 /* If someone in another CU might refer to us, set up a symbol for
6126 them to point to. */
6127 if (die
->die_symbol
)
6128 output_die_symbol (die
);
6130 dw2_asm_output_data_uleb128 (die
->die_abbrev
, "(DIE (0x%lx) %s)",
6131 die
->die_offset
, dwarf_tag_name (die
->die_tag
));
6133 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
6135 const char *name
= dwarf_attr_name (a
->dw_attr
);
6137 switch (AT_class (a
))
6139 case dw_val_class_addr
:
6140 dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE
, AT_addr (a
), "%s", name
);
6143 case dw_val_class_offset
:
6144 dw2_asm_output_data (DWARF_OFFSET_SIZE
, a
->dw_attr_val
.v
.val_offset
,
6148 case dw_val_class_loc
:
6149 size
= size_of_locs (AT_loc (a
));
6151 /* Output the block length for this list of location operations. */
6152 dw2_asm_output_data (constant_size (size
), size
, "%s", name
);
6154 output_loc_sequence (AT_loc (a
));
6157 case dw_val_class_const
:
6158 /* ??? It would be slightly more efficient to use a scheme like is
6159 used for unsigned constants below, but gdb 4.x does not sign
6160 extend. Gdb 5.x does sign extend. */
6161 dw2_asm_output_data_sleb128 (AT_int (a
), "%s", name
);
6164 case dw_val_class_unsigned_const
:
6165 dw2_asm_output_data (constant_size (AT_unsigned (a
)),
6166 AT_unsigned (a
), "%s", name
);
6169 case dw_val_class_long_long
:
6171 unsigned HOST_WIDE_INT first
, second
;
6173 dw2_asm_output_data (1, 2*HOST_BITS_PER_LONG
/HOST_BITS_PER_CHAR
,
6176 if (WORDS_BIG_ENDIAN
)
6178 first
= a
->dw_attr_val
.v
.val_long_long
.hi
;
6179 second
= a
->dw_attr_val
.v
.val_long_long
.low
;
6183 first
= a
->dw_attr_val
.v
.val_long_long
.low
;
6184 second
= a
->dw_attr_val
.v
.val_long_long
.hi
;
6186 dw2_asm_output_data (HOST_BITS_PER_LONG
/HOST_BITS_PER_CHAR
,
6187 first
, "long long constant");
6188 dw2_asm_output_data (HOST_BITS_PER_LONG
/HOST_BITS_PER_CHAR
,
6193 case dw_val_class_float
:
6195 register unsigned int i
;
6197 dw2_asm_output_data (1, a
->dw_attr_val
.v
.val_float
.length
* 4,
6200 for (i
= 0; i
< a
->dw_attr_val
.v
.val_float
.length
; ++i
)
6201 dw2_asm_output_data (4, a
->dw_attr_val
.v
.val_float
.array
[i
],
6202 "fp constant word %u", i
);
6206 case dw_val_class_flag
:
6207 dw2_asm_output_data (1, AT_flag (a
), "%s", name
);
6210 case dw_val_class_loc_list
:
6212 char *sym
= AT_loc_list (a
)->ll_symbol
;
6215 dw2_asm_output_delta (DWARF_OFFSET_SIZE
, sym
,
6216 loc_section_label
, "%s", name
);
6220 case dw_val_class_die_ref
:
6221 if (AT_ref_external (a
))
6223 char *sym
= AT_ref (a
)->die_symbol
;
6226 dw2_asm_output_offset (DWARF2_ADDR_SIZE
, sym
, "%s", name
);
6228 else if (AT_ref (a
)->die_offset
== 0)
6231 dw2_asm_output_data (DWARF_OFFSET_SIZE
, AT_ref (a
)->die_offset
,
6235 case dw_val_class_fde_ref
:
6238 ASM_GENERATE_INTERNAL_LABEL (l1
, FDE_LABEL
,
6239 a
->dw_attr_val
.v
.val_fde_index
* 2);
6240 dw2_asm_output_offset (DWARF_OFFSET_SIZE
, l1
, "%s", name
);
6244 case dw_val_class_lbl_id
:
6245 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, AT_lbl (a
), "%s", name
);
6248 case dw_val_class_lbl_offset
:
6249 dw2_asm_output_offset (DWARF_OFFSET_SIZE
, AT_lbl (a
), "%s", name
);
6252 case dw_val_class_str
:
6253 dw2_asm_output_nstring (AT_string (a
), -1, "%s", name
);
6261 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
6264 if (die
->die_child
!= NULL
)
6266 /* Add null byte to terminate sibling list. */
6267 dw2_asm_output_data (1, 0, "end of children of DIE 0x%lx",
6272 /* Output the compilation unit that appears at the beginning of the
6273 .debug_info section, and precedes the DIE descriptions. */
6276 output_compilation_unit_header ()
6278 dw2_asm_output_data (DWARF_OFFSET_SIZE
, next_die_offset
- DWARF_OFFSET_SIZE
,
6279 "Length of Compilation Unit Info");
6281 dw2_asm_output_data (2, DWARF_VERSION
, "DWARF version number");
6283 dw2_asm_output_offset (DWARF_OFFSET_SIZE
, abbrev_section_label
,
6284 "Offset Into Abbrev. Section");
6286 dw2_asm_output_data (1, DWARF2_ADDR_SIZE
, "Pointer Size (in bytes)");
6289 /* Output the compilation unit DIE and its children. */
6292 output_comp_unit (die
)
6295 const char *secname
;
6297 /* Even if there are no children of this DIE, we must output the
6298 information about the compilation unit. Otherwise, on an empty
6299 translation unit, we will generate a present, but empty,
6300 .debug_info section. IRIX 6.5 `nm' will then complain when
6303 Mark all the DIEs in this CU so we know which get local refs. */
6306 build_abbrev_table (die
);
6308 /* Initialize the beginning DIE offset - and calculate sizes/offsets. */
6309 next_die_offset
= DWARF_COMPILE_UNIT_HEADER_SIZE
;
6310 calc_die_sizes (die
);
6312 if (die
->die_symbol
)
6314 char *tmp
= (char *) alloca (strlen (die
->die_symbol
) + 24);
6315 sprintf (tmp
, ".gnu.linkonce.wi.%s", die
->die_symbol
);
6317 die
->die_symbol
= NULL
;
6320 secname
= (const char *) DEBUG_INFO_SECTION
;
6322 /* Output debugging information. */
6323 named_section_flags (secname
, SECTION_DEBUG
, 1);
6324 output_compilation_unit_header ();
6327 /* Leave the marks on the main CU, so we can check them in
6329 if (die
->die_symbol
)
6333 /* The DWARF2 pubname for a nested thingy looks like "A::f". The output
6334 of decl_printable_name for C++ looks like "A::f(int)". Let's drop the
6335 argument list, and maybe the scope. */
6338 dwarf2_name (decl
, scope
)
6342 return (*decl_printable_name
) (decl
, scope
? 1 : 0);
6345 /* Add a new entry to .debug_pubnames if appropriate. */
6348 add_pubname (decl
, die
)
6354 if (! TREE_PUBLIC (decl
))
6357 if (pubname_table_in_use
== pubname_table_allocated
)
6359 pubname_table_allocated
+= PUBNAME_TABLE_INCREMENT
;
6360 pubname_table
= (pubname_ref
) xrealloc
6361 (pubname_table
, pubname_table_allocated
* sizeof (pubname_entry
));
6364 p
= &pubname_table
[pubname_table_in_use
++];
6367 p
->name
= xstrdup (dwarf2_name (decl
, 1));
6370 /* Output the public names table used to speed up access to externally
6371 visible names. For now, only generate entries for externally
6372 visible procedures. */
6377 register unsigned i
;
6378 register unsigned long pubnames_length
= size_of_pubnames ();
6380 dw2_asm_output_data (DWARF_OFFSET_SIZE
, pubnames_length
,
6381 "Length of Public Names Info");
6383 dw2_asm_output_data (2, DWARF_VERSION
, "DWARF Version");
6385 dw2_asm_output_offset (DWARF_OFFSET_SIZE
, debug_info_section_label
,
6386 "Offset of Compilation Unit Info");
6388 dw2_asm_output_data (DWARF_OFFSET_SIZE
, next_die_offset
,
6389 "Compilation Unit Length");
6391 for (i
= 0; i
< pubname_table_in_use
; ++i
)
6393 register pubname_ref pub
= &pubname_table
[i
];
6395 /* We shouldn't see pubnames for DIEs outside of the main CU. */
6396 if (pub
->die
->die_mark
== 0)
6399 dw2_asm_output_data (DWARF_OFFSET_SIZE
, pub
->die
->die_offset
,
6402 dw2_asm_output_nstring (pub
->name
, -1, "external name");
6405 dw2_asm_output_data (DWARF_OFFSET_SIZE
, 0, NULL
);
6408 /* Add a new entry to .debug_aranges if appropriate. */
6411 add_arange (decl
, die
)
6415 if (! DECL_SECTION_NAME (decl
))
6418 if (arange_table_in_use
== arange_table_allocated
)
6420 arange_table_allocated
+= ARANGE_TABLE_INCREMENT
;
6421 arange_table
= (dw_die_ref
*)
6422 xrealloc (arange_table
, arange_table_allocated
* sizeof (dw_die_ref
));
6425 arange_table
[arange_table_in_use
++] = die
;
6428 /* Output the information that goes into the .debug_aranges table.
6429 Namely, define the beginning and ending address range of the
6430 text section generated for this compilation unit. */
6435 register unsigned i
;
6436 register unsigned long aranges_length
= size_of_aranges ();
6438 dw2_asm_output_data (DWARF_OFFSET_SIZE
, aranges_length
,
6439 "Length of Address Ranges Info");
6441 dw2_asm_output_data (2, DWARF_VERSION
, "DWARF Version");
6443 dw2_asm_output_offset (DWARF_OFFSET_SIZE
, debug_info_section_label
,
6444 "Offset of Compilation Unit Info");
6446 dw2_asm_output_data (1, DWARF2_ADDR_SIZE
, "Size of Address");
6448 dw2_asm_output_data (1, 0, "Size of Segment Descriptor");
6450 /* We need to align to twice the pointer size here. */
6451 if (DWARF_ARANGES_PAD_SIZE
)
6453 /* Pad using a 2 byte words so that padding is correct for any
6455 dw2_asm_output_data (2, 0, "Pad to %d byte boundary",
6456 2 * DWARF2_ADDR_SIZE
);
6457 for (i
= 2; i
< (unsigned) DWARF_ARANGES_PAD_SIZE
; i
+= 2)
6458 dw2_asm_output_data (2, 0, NULL
);
6461 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, text_section_label
, "Address");
6462 dw2_asm_output_delta (DWARF2_ADDR_SIZE
, text_end_label
,
6463 text_section_label
, "Length");
6465 for (i
= 0; i
< arange_table_in_use
; ++i
)
6467 dw_die_ref die
= arange_table
[i
];
6469 /* We shouldn't see aranges for DIEs outside of the main CU. */
6470 if (die
->die_mark
== 0)
6473 if (die
->die_tag
== DW_TAG_subprogram
)
6475 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, get_AT_low_pc (die
),
6477 dw2_asm_output_delta (DWARF2_ADDR_SIZE
, get_AT_hi_pc (die
),
6478 get_AT_low_pc (die
), "Length");
6482 /* A static variable; extract the symbol from DW_AT_location.
6483 Note that this code isn't currently hit, as we only emit
6484 aranges for functions (jason 9/23/99). */
6486 dw_attr_ref a
= get_AT (die
, DW_AT_location
);
6487 dw_loc_descr_ref loc
;
6488 if (! a
|| AT_class (a
) != dw_val_class_loc
)
6492 if (loc
->dw_loc_opc
!= DW_OP_addr
)
6495 dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE
,
6496 loc
->dw_loc_oprnd1
.v
.val_addr
, "Address");
6497 dw2_asm_output_data (DWARF2_ADDR_SIZE
,
6498 get_AT_unsigned (die
, DW_AT_byte_size
),
6503 /* Output the terminator words. */
6504 dw2_asm_output_data (DWARF2_ADDR_SIZE
, 0, NULL
);
6505 dw2_asm_output_data (DWARF2_ADDR_SIZE
, 0, NULL
);
6508 /* Add a new entry to .debug_ranges. Return the offset at which it
6515 unsigned int in_use
= ranges_table_in_use
;
6517 if (in_use
== ranges_table_allocated
)
6519 ranges_table_allocated
+= RANGES_TABLE_INCREMENT
;
6520 ranges_table
= (dw_ranges_ref
)
6521 xrealloc (ranges_table
, (ranges_table_allocated
6522 * sizeof (struct dw_ranges_struct
)));
6525 ranges_table
[in_use
].block_num
= (block
? BLOCK_NUMBER (block
) : 0);
6526 ranges_table_in_use
= in_use
+ 1;
6528 return in_use
* 2 * DWARF2_ADDR_SIZE
;
6534 register unsigned i
;
6535 const char *start_fmt
= "Offset 0x%x";
6536 const char *fmt
= start_fmt
;
6538 for (i
= 0; i
< ranges_table_in_use
; ++i
)
6540 int block_num
= ranges_table
[i
].block_num
;
6544 char blabel
[MAX_ARTIFICIAL_LABEL_BYTES
];
6545 char elabel
[MAX_ARTIFICIAL_LABEL_BYTES
];
6547 ASM_GENERATE_INTERNAL_LABEL (blabel
, BLOCK_BEGIN_LABEL
, block_num
);
6548 ASM_GENERATE_INTERNAL_LABEL (elabel
, BLOCK_END_LABEL
, block_num
);
6550 /* If all code is in the text section, then the compilation
6551 unit base address defaults to DW_AT_low_pc, which is the
6552 base of the text section. */
6553 if (separate_line_info_table_in_use
== 0)
6555 dw2_asm_output_delta (DWARF2_ADDR_SIZE
, blabel
,
6557 fmt
, i
* 2 * DWARF2_ADDR_SIZE
);
6558 dw2_asm_output_delta (DWARF2_ADDR_SIZE
, elabel
,
6559 text_section_label
, NULL
);
6561 /* Otherwise, we add a DW_AT_entry_pc attribute to force the
6562 compilation unit base address to zero, which allows us to
6563 use absolute addresses, and not worry about whether the
6564 target supports cross-section arithmetic. */
6567 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, blabel
,
6568 fmt
, i
* 2 * DWARF2_ADDR_SIZE
);
6569 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, elabel
, NULL
);
6576 dw2_asm_output_data (DWARF2_ADDR_SIZE
, 0, NULL
);
6577 dw2_asm_output_data (DWARF2_ADDR_SIZE
, 0, NULL
);
6583 /* Data structure containing information about input files. */
6586 char *path
; /* Complete file name. */
6587 char *fname
; /* File name part. */
6588 int length
; /* Length of entire string. */
6589 int file_idx
; /* Index in input file table. */
6590 int dir_idx
; /* Index in directory table. */
6593 /* Data structure containing information about directories with source
6597 char *path
; /* Path including directory name. */
6598 int length
; /* Path length. */
6599 int prefix
; /* Index of directory entry which is a prefix. */
6600 int count
; /* Number of files in this directory. */
6601 int dir_idx
; /* Index of directory used as base. */
6602 int used
; /* Used in the end? */
6605 /* Callback function for file_info comparison. We sort by looking at
6606 the directories in the path. */
6608 file_info_cmp (p1
, p2
)
6612 const struct file_info
*s1
= p1
;
6613 const struct file_info
*s2
= p2
;
6617 /* Take care of file names without directories. */
6618 if (s1
->path
== s1
->fname
)
6620 else if (s2
->path
== s2
->fname
)
6623 cp1
= (unsigned char *) s1
->path
;
6624 cp2
= (unsigned char *) s2
->path
;
6630 /* Reached the end of the first path? */
6631 if (cp1
== (unsigned char *) s1
->fname
)
6632 /* It doesn't really matter in which order files from the
6633 same directory are sorted in. Therefore don't test for
6634 the second path reaching the end. */
6636 else if (cp2
== (unsigned char *) s2
->fname
)
6639 /* Character of current path component the same? */
6645 /* Output the directory table and the file name table. We try to minimize
6646 the total amount of memory needed. A heuristic is used to avoid large
6647 slowdowns with many input files. */
6649 output_file_names ()
6651 struct file_info
*files
;
6652 struct dir_info
*dirs
;
6661 /* Allocate the various arrays we need. */
6662 files
= (struct file_info
*) alloca (file_table
.in_use
6663 * sizeof (struct file_info
));
6664 dirs
= (struct dir_info
*) alloca (file_table
.in_use
6665 * sizeof (struct dir_info
));
6667 /* Sort the file names. */
6668 for (i
= 1; i
< (int) file_table
.in_use
; ++i
)
6672 /* Skip all leading "./". */
6673 f
= file_table
.table
[i
];
6674 while (f
[0] == '.' && f
[1] == '/')
6677 /* Create a new array entry. */
6679 files
[i
].length
= strlen (f
);
6680 files
[i
].file_idx
= i
;
6682 /* Search for the file name part. */
6683 f
= strrchr (f
, '/');
6684 files
[i
].fname
= f
== NULL
? files
[i
].path
: f
+ 1;
6686 qsort (files
+ 1, file_table
.in_use
- 1, sizeof (files
[0]), file_info_cmp
);
6688 /* Find all the different directories used. */
6689 dirs
[0].path
= files
[1].path
;
6690 dirs
[0].length
= files
[1].fname
- files
[1].path
;
6691 dirs
[0].prefix
= -1;
6693 dirs
[0].dir_idx
= 0;
6695 files
[1].dir_idx
= 0;
6698 for (i
= 2; i
< (int) file_table
.in_use
; ++i
)
6699 if (files
[i
].fname
- files
[i
].path
== dirs
[ndirs
- 1].length
6700 && memcmp (dirs
[ndirs
- 1].path
, files
[i
].path
,
6701 dirs
[ndirs
- 1].length
) == 0)
6703 /* Same directory as last entry. */
6704 files
[i
].dir_idx
= ndirs
- 1;
6705 ++dirs
[ndirs
- 1].count
;
6711 /* This is a new directory. */
6712 dirs
[ndirs
].path
= files
[i
].path
;
6713 dirs
[ndirs
].length
= files
[i
].fname
- files
[i
].path
;
6714 dirs
[ndirs
].count
= 1;
6715 dirs
[ndirs
].dir_idx
= ndirs
;
6716 dirs
[ndirs
].used
= 0;
6717 files
[i
].dir_idx
= ndirs
;
6719 /* Search for a prefix. */
6720 dirs
[ndirs
].prefix
= -1;
6721 for (j
= 0; j
< ndirs
; ++j
)
6722 if (dirs
[j
].length
< dirs
[ndirs
].length
6723 && dirs
[j
].length
> 1
6724 && (dirs
[ndirs
].prefix
== -1
6725 || dirs
[j
].length
> dirs
[dirs
[ndirs
].prefix
].length
)
6726 && memcmp (dirs
[j
].path
, dirs
[ndirs
].path
, dirs
[j
].length
) == 0)
6727 dirs
[ndirs
].prefix
= j
;
6732 /* Now to the actual work. We have to find a subset of the
6733 directories which allow expressing the file name using references
6734 to the directory table with the least amount of characters. We
6735 do not do an exhaustive search where we would have to check out
6736 every combination of every single possible prefix. Instead we
6737 use a heuristic which provides nearly optimal results in most
6738 cases and never is much off. */
6739 saved
= (int *) alloca (ndirs
* sizeof (int));
6740 savehere
= (int *) alloca (ndirs
* sizeof (int));
6742 memset (saved
, '\0', ndirs
* sizeof (saved
[0]));
6743 for (i
= 0; i
< ndirs
; ++i
)
6748 /* We can always save some space for the current directory. But
6749 this does not mean it will be enough to justify adding the
6751 savehere
[i
] = dirs
[i
].length
;
6752 total
= (savehere
[i
] - saved
[i
]) * dirs
[i
].count
;
6754 for (j
= i
+ 1; j
< ndirs
; ++j
)
6758 if (saved
[j
] < dirs
[i
].length
)
6760 /* Determine whether the dirs[i] path is a prefix of the
6765 while (k
!= -1 && k
!= i
)
6770 /* Yes it is. We can possibly safe some memory but
6771 writing the filenames in dirs[j] relative to
6773 savehere
[j
] = dirs
[i
].length
;
6774 total
+= (savehere
[j
] - saved
[j
]) * dirs
[j
].count
;
6779 /* Check whether we can safe enough to justify adding the dirs[i]
6781 if (total
> dirs
[i
].length
+ 1)
6783 /* It's worthwhile adding. */
6784 for (j
= i
; j
< ndirs
; ++j
)
6785 if (savehere
[j
] > 0)
6787 /* Remember how much we saved for this directory so far. */
6788 saved
[j
] = savehere
[j
];
6790 /* Remember the prefix directory. */
6791 dirs
[j
].dir_idx
= i
;
6796 /* We have to emit them in the order they appear in the file_table
6797 array since the index is used in the debug info generation. To
6798 do this efficiently we generate a back-mapping of the indices
6800 backmap
= (int *) alloca (file_table
.in_use
* sizeof (int));
6801 for (i
= 1; i
< (int) file_table
.in_use
; ++i
)
6803 backmap
[files
[i
].file_idx
] = i
;
6804 /* Mark this directory as used. */
6805 dirs
[dirs
[files
[i
].dir_idx
].dir_idx
].used
= 1;
6808 /* That was it. We are ready to emit the information. First the
6809 directory name table. Here we have to make sure that the first
6810 actually emitted directory name has the index one. Zero is
6811 reserved for the current working directory. Make sure we do not
6812 confuse these indices with the one for the constructed table
6813 (even though most of the time they are identical). */
6815 idx_offset
= dirs
[0].length
> 0 ? 1 : 0;
6816 for (i
= 1 - idx_offset
; i
< ndirs
; ++i
)
6817 if (dirs
[i
].used
!= 0)
6819 dirs
[i
].used
= idx
++;
6820 dw2_asm_output_nstring (dirs
[i
].path
, dirs
[i
].length
- 1,
6821 "Directory Entry: 0x%x", dirs
[i
].used
);
6823 dw2_asm_output_data (1, 0, "End directory table");
6825 /* Correct the index for the current working directory entry if it
6827 if (idx_offset
== 0)
6830 /* Now write all the file names. */
6831 for (i
= 1; i
< (int) file_table
.in_use
; ++i
)
6833 int file_idx
= backmap
[i
];
6834 int dir_idx
= dirs
[files
[file_idx
].dir_idx
].dir_idx
;
6836 dw2_asm_output_nstring (files
[file_idx
].path
+ dirs
[dir_idx
].length
, -1,
6837 "File Entry: 0x%x", i
);
6839 /* Include directory index. */
6840 dw2_asm_output_data_uleb128 (dirs
[dir_idx
].used
, NULL
);
6842 /* Modification time. */
6843 dw2_asm_output_data_uleb128 (0, NULL
);
6845 /* File length in bytes. */
6846 dw2_asm_output_data_uleb128 (0, NULL
);
6848 dw2_asm_output_data (1, 0, "End file name table");
6852 /* Output the source line number correspondence information. This
6853 information goes into the .debug_line section. */
6858 char l1
[20], l2
[20], p1
[20], p2
[20];
6859 char line_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
6860 char prev_line_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
6861 register unsigned opc
;
6862 register unsigned n_op_args
;
6863 register unsigned long lt_index
;
6864 register unsigned long current_line
;
6865 register long line_offset
;
6866 register long line_delta
;
6867 register unsigned long current_file
;
6868 register unsigned long function
;
6870 ASM_GENERATE_INTERNAL_LABEL (l1
, LINE_NUMBER_BEGIN_LABEL
, 0);
6871 ASM_GENERATE_INTERNAL_LABEL (l2
, LINE_NUMBER_END_LABEL
, 0);
6872 ASM_GENERATE_INTERNAL_LABEL (p1
, LN_PROLOG_AS_LABEL
, 0);
6873 ASM_GENERATE_INTERNAL_LABEL (p2
, LN_PROLOG_END_LABEL
, 0);
6875 dw2_asm_output_delta (DWARF_OFFSET_SIZE
, l2
, l1
,
6876 "Length of Source Line Info");
6877 ASM_OUTPUT_LABEL (asm_out_file
, l1
);
6879 dw2_asm_output_data (2, DWARF_VERSION
, "DWARF Version");
6881 dw2_asm_output_delta (DWARF_OFFSET_SIZE
, p2
, p1
, "Prolog Length");
6882 ASM_OUTPUT_LABEL (asm_out_file
, p1
);
6884 dw2_asm_output_data (1, DWARF_LINE_MIN_INSTR_LENGTH
,
6885 "Minimum Instruction Length");
6887 dw2_asm_output_data (1, DWARF_LINE_DEFAULT_IS_STMT_START
,
6888 "Default is_stmt_start flag");
6890 dw2_asm_output_data (1, DWARF_LINE_BASE
,
6891 "Line Base Value (Special Opcodes)");
6893 dw2_asm_output_data (1, DWARF_LINE_RANGE
,
6894 "Line Range Value (Special Opcodes)");
6896 dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE
,
6897 "Special Opcode Base");
6899 for (opc
= 1; opc
< DWARF_LINE_OPCODE_BASE
; ++opc
)
6903 case DW_LNS_advance_pc
:
6904 case DW_LNS_advance_line
:
6905 case DW_LNS_set_file
:
6906 case DW_LNS_set_column
:
6907 case DW_LNS_fixed_advance_pc
:
6915 dw2_asm_output_data (1, n_op_args
, "opcode: 0x%x has %d args",
6919 /* Write out the information about the files we use. */
6920 output_file_names ();
6921 ASM_OUTPUT_LABEL (asm_out_file
, p2
);
6923 /* We used to set the address register to the first location in the text
6924 section here, but that didn't accomplish anything since we already
6925 have a line note for the opening brace of the first function. */
6927 /* Generate the line number to PC correspondence table, encoded as
6928 a series of state machine operations. */
6931 strcpy (prev_line_label
, text_section_label
);
6932 for (lt_index
= 1; lt_index
< line_info_table_in_use
; ++lt_index
)
6934 register dw_line_info_ref line_info
= &line_info_table
[lt_index
];
6937 /* Disable this optimization for now; GDB wants to see two line notes
6938 at the beginning of a function so it can find the end of the
6941 /* Don't emit anything for redundant notes. Just updating the
6942 address doesn't accomplish anything, because we already assume
6943 that anything after the last address is this line. */
6944 if (line_info
->dw_line_num
== current_line
6945 && line_info
->dw_file_num
== current_file
)
6949 /* Emit debug info for the address of the current line.
6951 Unfortunately, we have little choice here currently, and must always
6952 use the most general form. Gcc does not know the address delta
6953 itself, so we can't use DW_LNS_advance_pc. Many ports do have length
6954 attributes which will give an upper bound on the address range. We
6955 could perhaps use length attributes to determine when it is safe to
6956 use DW_LNS_fixed_advance_pc. */
6958 ASM_GENERATE_INTERNAL_LABEL (line_label
, LINE_CODE_LABEL
, lt_index
);
6961 /* This can handle deltas up to 0xffff. This takes 3 bytes. */
6962 dw2_asm_output_data (1, DW_LNS_fixed_advance_pc
,
6963 "DW_LNS_fixed_advance_pc");
6964 dw2_asm_output_delta (2, line_label
, prev_line_label
, NULL
);
6968 /* This can handle any delta. This takes
6969 4+DWARF2_ADDR_SIZE bytes. */
6970 dw2_asm_output_data (1, 0, "DW_LNE_set_address");
6971 dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE
, NULL
);
6972 dw2_asm_output_data (1, DW_LNE_set_address
, NULL
);
6973 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, line_label
, NULL
);
6975 strcpy (prev_line_label
, line_label
);
6977 /* Emit debug info for the source file of the current line, if
6978 different from the previous line. */
6979 if (line_info
->dw_file_num
!= current_file
)
6981 current_file
= line_info
->dw_file_num
;
6982 dw2_asm_output_data (1, DW_LNS_set_file
, "DW_LNS_set_file");
6983 dw2_asm_output_data_uleb128 (current_file
, "(\"%s\")",
6984 file_table
.table
[current_file
]);
6987 /* Emit debug info for the current line number, choosing the encoding
6988 that uses the least amount of space. */
6989 if (line_info
->dw_line_num
!= current_line
)
6991 line_offset
= line_info
->dw_line_num
- current_line
;
6992 line_delta
= line_offset
- DWARF_LINE_BASE
;
6993 current_line
= line_info
->dw_line_num
;
6994 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
6996 /* This can handle deltas from -10 to 234, using the current
6997 definitions of DWARF_LINE_BASE and DWARF_LINE_RANGE. This
6999 dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE
+ line_delta
,
7000 "line %lu", current_line
);
7004 /* This can handle any delta. This takes at least 4 bytes,
7005 depending on the value being encoded. */
7006 dw2_asm_output_data (1, DW_LNS_advance_line
,
7007 "advance to line %lu", current_line
);
7008 dw2_asm_output_data_sleb128 (line_offset
, NULL
);
7009 dw2_asm_output_data (1, DW_LNS_copy
, "DW_LNS_copy");
7014 /* We still need to start a new row, so output a copy insn. */
7015 dw2_asm_output_data (1, DW_LNS_copy
, "DW_LNS_copy");
7019 /* Emit debug info for the address of the end of the function. */
7022 dw2_asm_output_data (1, DW_LNS_fixed_advance_pc
,
7023 "DW_LNS_fixed_advance_pc");
7024 dw2_asm_output_delta (2, text_end_label
, prev_line_label
, NULL
);
7028 dw2_asm_output_data (1, 0, "DW_LNE_set_address");
7029 dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE
, NULL
);
7030 dw2_asm_output_data (1, DW_LNE_set_address
, NULL
);
7031 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, text_end_label
, NULL
);
7034 dw2_asm_output_data (1, 0, "DW_LNE_end_sequence");
7035 dw2_asm_output_data_uleb128 (1, NULL
);
7036 dw2_asm_output_data (1, DW_LNE_end_sequence
, NULL
);
7041 for (lt_index
= 0; lt_index
< separate_line_info_table_in_use
;)
7043 register dw_separate_line_info_ref line_info
7044 = &separate_line_info_table
[lt_index
];
7047 /* Don't emit anything for redundant notes. */
7048 if (line_info
->dw_line_num
== current_line
7049 && line_info
->dw_file_num
== current_file
7050 && line_info
->function
== function
)
7054 /* Emit debug info for the address of the current line. If this is
7055 a new function, or the first line of a function, then we need
7056 to handle it differently. */
7057 ASM_GENERATE_INTERNAL_LABEL (line_label
, SEPARATE_LINE_CODE_LABEL
,
7059 if (function
!= line_info
->function
)
7061 function
= line_info
->function
;
7063 /* Set the address register to the first line in the function */
7064 dw2_asm_output_data (1, 0, "DW_LNE_set_address");
7065 dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE
, NULL
);
7066 dw2_asm_output_data (1, DW_LNE_set_address
, NULL
);
7067 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, line_label
, NULL
);
7071 /* ??? See the DW_LNS_advance_pc comment above. */
7074 dw2_asm_output_data (1, DW_LNS_fixed_advance_pc
,
7075 "DW_LNS_fixed_advance_pc");
7076 dw2_asm_output_delta (2, line_label
, prev_line_label
, NULL
);
7080 dw2_asm_output_data (1, 0, "DW_LNE_set_address");
7081 dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE
, NULL
);
7082 dw2_asm_output_data (1, DW_LNE_set_address
, NULL
);
7083 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, line_label
, NULL
);
7086 strcpy (prev_line_label
, line_label
);
7088 /* Emit debug info for the source file of the current line, if
7089 different from the previous line. */
7090 if (line_info
->dw_file_num
!= current_file
)
7092 current_file
= line_info
->dw_file_num
;
7093 dw2_asm_output_data (1, DW_LNS_set_file
, "DW_LNS_set_file");
7094 dw2_asm_output_data_uleb128 (current_file
, "(\"%s\")",
7095 file_table
.table
[current_file
]);
7098 /* Emit debug info for the current line number, choosing the encoding
7099 that uses the least amount of space. */
7100 if (line_info
->dw_line_num
!= current_line
)
7102 line_offset
= line_info
->dw_line_num
- current_line
;
7103 line_delta
= line_offset
- DWARF_LINE_BASE
;
7104 current_line
= line_info
->dw_line_num
;
7105 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
7106 dw2_asm_output_data (1, DWARF_LINE_OPCODE_BASE
+ line_delta
,
7107 "line %lu", current_line
);
7110 dw2_asm_output_data (1, DW_LNS_advance_line
,
7111 "advance to line %lu", current_line
);
7112 dw2_asm_output_data_sleb128 (line_offset
, NULL
);
7113 dw2_asm_output_data (1, DW_LNS_copy
, "DW_LNS_copy");
7117 dw2_asm_output_data (1, DW_LNS_copy
, "DW_LNS_copy");
7124 /* If we're done with a function, end its sequence. */
7125 if (lt_index
== separate_line_info_table_in_use
7126 || separate_line_info_table
[lt_index
].function
!= function
)
7131 /* Emit debug info for the address of the end of the function. */
7132 ASM_GENERATE_INTERNAL_LABEL (line_label
, FUNC_END_LABEL
, function
);
7135 dw2_asm_output_data (1, DW_LNS_fixed_advance_pc
,
7136 "DW_LNS_fixed_advance_pc");
7137 dw2_asm_output_delta (2, line_label
, prev_line_label
, NULL
);
7141 dw2_asm_output_data (1, 0, "DW_LNE_set_address");
7142 dw2_asm_output_data_uleb128 (1 + DWARF2_ADDR_SIZE
, NULL
);
7143 dw2_asm_output_data (1, DW_LNE_set_address
, NULL
);
7144 dw2_asm_output_addr (DWARF2_ADDR_SIZE
, line_label
, NULL
);
7147 /* Output the marker for the end of this sequence. */
7148 dw2_asm_output_data (1, 0, "DW_LNE_end_sequence");
7149 dw2_asm_output_data_uleb128 (1, NULL
);
7150 dw2_asm_output_data (1, DW_LNE_end_sequence
, NULL
);
7154 /* Output the marker for the end of the line number info. */
7155 ASM_OUTPUT_LABEL (asm_out_file
, l2
);
7158 /* Given a pointer to a tree node for some base type, return a pointer to
7159 a DIE that describes the given type.
7161 This routine must only be called for GCC type nodes that correspond to
7162 Dwarf base (fundamental) types. */
7165 base_type_die (type
)
7168 register dw_die_ref base_type_result
;
7169 register const char *type_name
;
7170 register enum dwarf_type encoding
;
7171 register tree name
= TYPE_NAME (type
);
7173 if (TREE_CODE (type
) == ERROR_MARK
7174 || TREE_CODE (type
) == VOID_TYPE
)
7179 if (TREE_CODE (name
) == TYPE_DECL
)
7180 name
= DECL_NAME (name
);
7182 type_name
= IDENTIFIER_POINTER (name
);
7185 type_name
= "__unknown__";
7187 switch (TREE_CODE (type
))
7190 /* Carefully distinguish the C character types, without messing
7191 up if the language is not C. Note that we check only for the names
7192 that contain spaces; other names might occur by coincidence in other
7194 if (! (TYPE_PRECISION (type
) == CHAR_TYPE_SIZE
7195 && (type
== char_type_node
7196 || ! strcmp (type_name
, "signed char")
7197 || ! strcmp (type_name
, "unsigned char"))))
7199 if (TREE_UNSIGNED (type
))
7200 encoding
= DW_ATE_unsigned
;
7202 encoding
= DW_ATE_signed
;
7205 /* else fall through. */
7208 /* GNU Pascal/Ada CHAR type. Not used in C. */
7209 if (TREE_UNSIGNED (type
))
7210 encoding
= DW_ATE_unsigned_char
;
7212 encoding
= DW_ATE_signed_char
;
7216 encoding
= DW_ATE_float
;
7219 /* Dwarf2 doesn't know anything about complex ints, so use
7220 a user defined type for it. */
7222 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
7223 encoding
= DW_ATE_complex_float
;
7225 encoding
= DW_ATE_lo_user
;
7229 /* GNU FORTRAN/Ada/C++ BOOLEAN type. */
7230 encoding
= DW_ATE_boolean
;
7234 abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
7237 base_type_result
= new_die (DW_TAG_base_type
, comp_unit_die
);
7238 if (demangle_name_func
)
7239 type_name
= (*demangle_name_func
) (type_name
);
7241 add_AT_string (base_type_result
, DW_AT_name
, type_name
);
7242 add_AT_unsigned (base_type_result
, DW_AT_byte_size
,
7243 int_size_in_bytes (type
));
7244 add_AT_unsigned (base_type_result
, DW_AT_encoding
, encoding
);
7246 return base_type_result
;
7249 /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
7250 the Dwarf "root" type for the given input type. The Dwarf "root" type of
7251 a given type is generally the same as the given type, except that if the
7252 given type is a pointer or reference type, then the root type of the given
7253 type is the root type of the "basis" type for the pointer or reference
7254 type. (This definition of the "root" type is recursive.) Also, the root
7255 type of a `const' qualified type or a `volatile' qualified type is the
7256 root type of the given type without the qualifiers. */
7262 if (TREE_CODE (type
) == ERROR_MARK
)
7263 return error_mark_node
;
7265 switch (TREE_CODE (type
))
7268 return error_mark_node
;
7271 case REFERENCE_TYPE
:
7272 return type_main_variant (root_type (TREE_TYPE (type
)));
7275 return type_main_variant (type
);
7279 /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
7280 given input type is a Dwarf "fundamental" type. Otherwise return null. */
7286 switch (TREE_CODE (type
))
7301 case QUAL_UNION_TYPE
:
7306 case REFERENCE_TYPE
:
7320 /* Given a pointer to an arbitrary ..._TYPE tree node, return a debugging
7321 entry that chains various modifiers in front of the given type. */
7324 modified_type_die (type
, is_const_type
, is_volatile_type
, context_die
)
7326 register int is_const_type
;
7327 register int is_volatile_type
;
7328 register dw_die_ref context_die
;
7330 register enum tree_code code
= TREE_CODE (type
);
7331 register dw_die_ref mod_type_die
= NULL
;
7332 register dw_die_ref sub_die
= NULL
;
7333 register tree item_type
= NULL
;
7335 if (code
!= ERROR_MARK
)
7337 tree qualified_type
;
7339 /* See if we already have the appropriately qualified variant of
7342 = get_qualified_type (type
,
7343 ((is_const_type
? TYPE_QUAL_CONST
: 0)
7345 ? TYPE_QUAL_VOLATILE
: 0)));
7346 /* If we do, then we can just use its DIE, if it exists. */
7349 mod_type_die
= lookup_type_die (qualified_type
);
7351 return mod_type_die
;
7354 /* Handle C typedef types. */
7355 if (qualified_type
&& TYPE_NAME (qualified_type
)
7356 && TREE_CODE (TYPE_NAME (qualified_type
)) == TYPE_DECL
7357 && DECL_ORIGINAL_TYPE (TYPE_NAME (qualified_type
)))
7359 tree type_name
= TYPE_NAME (qualified_type
);
7360 tree dtype
= TREE_TYPE (type_name
);
7361 if (qualified_type
== dtype
)
7363 /* For a named type, use the typedef. */
7364 gen_type_die (qualified_type
, context_die
);
7365 mod_type_die
= lookup_type_die (qualified_type
);
7368 else if (is_const_type
< TYPE_READONLY (dtype
)
7369 || is_volatile_type
< TYPE_VOLATILE (dtype
))
7370 /* cv-unqualified version of named type. Just use the unnamed
7371 type to which it refers. */
7373 = modified_type_die (DECL_ORIGINAL_TYPE (type_name
),
7374 is_const_type
, is_volatile_type
,
7376 /* Else cv-qualified version of named type; fall through. */
7382 else if (is_const_type
)
7384 mod_type_die
= new_die (DW_TAG_const_type
, comp_unit_die
);
7385 sub_die
= modified_type_die (type
, 0, is_volatile_type
, context_die
);
7387 else if (is_volatile_type
)
7389 mod_type_die
= new_die (DW_TAG_volatile_type
, comp_unit_die
);
7390 sub_die
= modified_type_die (type
, 0, 0, context_die
);
7392 else if (code
== POINTER_TYPE
)
7394 mod_type_die
= new_die (DW_TAG_pointer_type
, comp_unit_die
);
7395 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
7397 add_AT_unsigned (mod_type_die
, DW_AT_address_class
, 0);
7399 item_type
= TREE_TYPE (type
);
7401 else if (code
== REFERENCE_TYPE
)
7403 mod_type_die
= new_die (DW_TAG_reference_type
, comp_unit_die
);
7404 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
7406 add_AT_unsigned (mod_type_die
, DW_AT_address_class
, 0);
7408 item_type
= TREE_TYPE (type
);
7410 else if (is_base_type (type
))
7411 mod_type_die
= base_type_die (type
);
7414 gen_type_die (type
, context_die
);
7416 /* We have to get the type_main_variant here (and pass that to the
7417 `lookup_type_die' routine) because the ..._TYPE node we have
7418 might simply be a *copy* of some original type node (where the
7419 copy was created to help us keep track of typedef names) and
7420 that copy might have a different TYPE_UID from the original
7422 mod_type_die
= lookup_type_die (type_main_variant (type
));
7423 if (mod_type_die
== NULL
)
7427 /* We want to equate the qualified type to the die below. */
7429 type
= qualified_type
;
7432 equate_type_number_to_die (type
, mod_type_die
);
7434 /* We must do this after the equate_type_number_to_die call, in case
7435 this is a recursive type. This ensures that the modified_type_die
7436 recursion will terminate even if the type is recursive. Recursive
7437 types are possible in Ada. */
7438 sub_die
= modified_type_die (item_type
,
7439 TYPE_READONLY (item_type
),
7440 TYPE_VOLATILE (item_type
),
7443 if (sub_die
!= NULL
)
7444 add_AT_die_ref (mod_type_die
, DW_AT_type
, sub_die
);
7446 return mod_type_die
;
7449 /* Given a pointer to an arbitrary ..._TYPE tree node, return true if it is
7450 an enumerated type. */
7456 return TREE_CODE (type
) == ENUMERAL_TYPE
;
7459 /* Return the register number described by a given RTL node. */
7465 register unsigned regno
= REGNO (rtl
);
7467 if (regno
>= FIRST_PSEUDO_REGISTER
)
7469 warning ("internal regno botch: regno = %d\n", regno
);
7473 regno
= DBX_REGISTER_NUMBER (regno
);
7477 /* Return a location descriptor that designates a machine register. */
7479 static dw_loc_descr_ref
7480 reg_loc_descriptor (rtl
)
7483 register dw_loc_descr_ref loc_result
= NULL
;
7484 register unsigned reg
= reg_number (rtl
);
7487 loc_result
= new_loc_descr (DW_OP_reg0
+ reg
, 0, 0);
7489 loc_result
= new_loc_descr (DW_OP_regx
, reg
, 0);
7494 /* Return a location descriptor that designates a constant. */
7496 static dw_loc_descr_ref
7497 int_loc_descriptor (i
)
7500 enum dwarf_location_atom op
;
7502 /* Pick the smallest representation of a constant, rather than just
7503 defaulting to the LEB encoding. */
7507 op
= DW_OP_lit0
+ i
;
7510 else if (i
<= 0xffff)
7512 else if (HOST_BITS_PER_WIDE_INT
== 32
7522 else if (i
>= -0x8000)
7524 else if (HOST_BITS_PER_WIDE_INT
== 32
7525 || i
>= -0x80000000)
7531 return new_loc_descr (op
, i
, 0);
7534 /* Return a location descriptor that designates a base+offset location. */
7536 static dw_loc_descr_ref
7537 based_loc_descr (reg
, offset
)
7541 register dw_loc_descr_ref loc_result
;
7542 /* For the "frame base", we use the frame pointer or stack pointer
7543 registers, since the RTL for local variables is relative to one of
7545 register unsigned fp_reg
= DBX_REGISTER_NUMBER (frame_pointer_needed
7546 ? HARD_FRAME_POINTER_REGNUM
7547 : STACK_POINTER_REGNUM
);
7550 loc_result
= new_loc_descr (DW_OP_fbreg
, offset
, 0);
7552 loc_result
= new_loc_descr (DW_OP_breg0
+ reg
, offset
, 0);
7554 loc_result
= new_loc_descr (DW_OP_bregx
, reg
, offset
);
7559 /* Return true if this RTL expression describes a base+offset calculation. */
7565 return (GET_CODE (rtl
) == PLUS
7566 && ((GET_CODE (XEXP (rtl
, 0)) == REG
7567 && GET_CODE (XEXP (rtl
, 1)) == CONST_INT
)));
7570 /* The following routine converts the RTL for a variable or parameter
7571 (resident in memory) into an equivalent Dwarf representation of a
7572 mechanism for getting the address of that same variable onto the top of a
7573 hypothetical "address evaluation" stack.
7575 When creating memory location descriptors, we are effectively transforming
7576 the RTL for a memory-resident object into its Dwarf postfix expression
7577 equivalent. This routine recursively descends an RTL tree, turning
7578 it into Dwarf postfix code as it goes.
7580 MODE is the mode of the memory reference, needed to handle some
7581 autoincrement addressing modes. */
7583 static dw_loc_descr_ref
7584 mem_loc_descriptor (rtl
, mode
)
7586 enum machine_mode mode
;
7588 dw_loc_descr_ref mem_loc_result
= NULL
;
7589 /* Note that for a dynamically sized array, the location we will generate a
7590 description of here will be the lowest numbered location which is
7591 actually within the array. That's *not* necessarily the same as the
7592 zeroth element of the array. */
7594 #ifdef ASM_SIMPLIFY_DWARF_ADDR
7595 rtl
= ASM_SIMPLIFY_DWARF_ADDR (rtl
);
7598 switch (GET_CODE (rtl
))
7603 /* POST_INC and POST_DEC can be handled just like a SUBREG. So we
7604 just fall into the SUBREG code. */
7609 /* The case of a subreg may arise when we have a local (register)
7610 variable or a formal (register) parameter which doesn't quite fill
7611 up an entire register. For now, just assume that it is
7612 legitimate to make the Dwarf info refer to the whole register which
7613 contains the given subreg. */
7614 rtl
= SUBREG_REG (rtl
);
7619 /* Whenever a register number forms a part of the description of the
7620 method for calculating the (dynamic) address of a memory resident
7621 object, DWARF rules require the register number be referred to as
7622 a "base register". This distinction is not based in any way upon
7623 what category of register the hardware believes the given register
7624 belongs to. This is strictly DWARF terminology we're dealing with
7625 here. Note that in cases where the location of a memory-resident
7626 data object could be expressed as: OP_ADD (OP_BASEREG (basereg),
7627 OP_CONST (0)) the actual DWARF location descriptor that we generate
7628 may just be OP_BASEREG (basereg). This may look deceptively like
7629 the object in question was allocated to a register (rather than in
7630 memory) so DWARF consumers need to be aware of the subtle
7631 distinction between OP_REG and OP_BASEREG. */
7632 mem_loc_result
= based_loc_descr (reg_number (rtl
), 0);
7636 mem_loc_result
= mem_loc_descriptor (XEXP (rtl
, 0), GET_MODE (rtl
));
7637 add_loc_descr (&mem_loc_result
, new_loc_descr (DW_OP_deref
, 0, 0));
7641 /* Some ports can transform a symbol ref into a label ref, because
7642 the symbol ref is too far away and has to be dumped into a constant
7646 /* Alternatively, the symbol in the constant pool might be referenced
7647 by a different symbol. */
7648 if (GET_CODE (rtl
) == SYMBOL_REF
7649 && CONSTANT_POOL_ADDRESS_P (rtl
))
7651 rtx tmp
= get_pool_constant (rtl
);
7652 if (GET_CODE (tmp
) == SYMBOL_REF
)
7656 mem_loc_result
= new_loc_descr (DW_OP_addr
, 0, 0);
7657 mem_loc_result
->dw_loc_oprnd1
.val_class
= dw_val_class_addr
;
7658 mem_loc_result
->dw_loc_oprnd1
.v
.val_addr
= save_rtx (rtl
);
7662 /* Extract the PLUS expression nested inside and fall into
7664 rtl
= XEXP (rtl
, 1);
7669 /* Turn these into a PLUS expression and fall into the PLUS code
7671 rtl
= gen_rtx_PLUS (word_mode
, XEXP (rtl
, 0),
7672 GEN_INT (GET_CODE (rtl
) == PRE_INC
7673 ? GET_MODE_UNIT_SIZE (mode
)
7674 : -GET_MODE_UNIT_SIZE (mode
)));
7680 if (is_based_loc (rtl
))
7681 mem_loc_result
= based_loc_descr (reg_number (XEXP (rtl
, 0)),
7682 INTVAL (XEXP (rtl
, 1)));
7685 mem_loc_result
= mem_loc_descriptor (XEXP (rtl
, 0), mode
);
7687 if (GET_CODE (XEXP (rtl
, 1)) == CONST_INT
7688 && INTVAL (XEXP (rtl
, 1)) >= 0)
7690 add_loc_descr (&mem_loc_result
,
7691 new_loc_descr (DW_OP_plus_uconst
,
7692 INTVAL (XEXP (rtl
, 1)), 0));
7696 add_loc_descr (&mem_loc_result
,
7697 mem_loc_descriptor (XEXP (rtl
, 1), mode
));
7698 add_loc_descr (&mem_loc_result
,
7699 new_loc_descr (DW_OP_plus
, 0, 0));
7705 /* If a pseudo-reg is optimized away, it is possible for it to
7706 be replaced with a MEM containing a multiply. */
7707 add_loc_descr (&mem_loc_result
,
7708 mem_loc_descriptor (XEXP (rtl
, 0), mode
));
7709 add_loc_descr (&mem_loc_result
,
7710 mem_loc_descriptor (XEXP (rtl
, 1), mode
));
7711 add_loc_descr (&mem_loc_result
, new_loc_descr (DW_OP_mul
, 0, 0));
7715 mem_loc_result
= int_loc_descriptor (INTVAL (rtl
));
7722 return mem_loc_result
;
7725 /* Return a descriptor that describes the concatenation of two locations.
7726 This is typically a complex variable. */
7728 static dw_loc_descr_ref
7729 concat_loc_descriptor (x0
, x1
)
7730 register rtx x0
, x1
;
7732 dw_loc_descr_ref cc_loc_result
= NULL
;
7734 if (!is_pseudo_reg (x0
)
7735 && (GET_CODE (x0
) != MEM
|| !is_pseudo_reg (XEXP (x0
, 0))))
7736 add_loc_descr (&cc_loc_result
, loc_descriptor (x0
));
7737 add_loc_descr (&cc_loc_result
,
7738 new_loc_descr (DW_OP_piece
, GET_MODE_SIZE (GET_MODE (x0
)), 0));
7740 if (!is_pseudo_reg (x1
)
7741 && (GET_CODE (x1
) != MEM
|| !is_pseudo_reg (XEXP (x1
, 0))))
7742 add_loc_descr (&cc_loc_result
, loc_descriptor (x1
));
7743 add_loc_descr (&cc_loc_result
,
7744 new_loc_descr (DW_OP_piece
, GET_MODE_SIZE (GET_MODE (x1
)), 0));
7746 return cc_loc_result
;
7749 /* Output a proper Dwarf location descriptor for a variable or parameter
7750 which is either allocated in a register or in a memory location. For a
7751 register, we just generate an OP_REG and the register number. For a
7752 memory location we provide a Dwarf postfix expression describing how to
7753 generate the (dynamic) address of the object onto the address stack. */
7755 static dw_loc_descr_ref
7756 loc_descriptor (rtl
)
7759 dw_loc_descr_ref loc_result
= NULL
;
7760 switch (GET_CODE (rtl
))
7763 /* The case of a subreg may arise when we have a local (register)
7764 variable or a formal (register) parameter which doesn't quite fill
7765 up an entire register. For now, just assume that it is
7766 legitimate to make the Dwarf info refer to the whole register which
7767 contains the given subreg. */
7768 rtl
= SUBREG_REG (rtl
);
7773 loc_result
= reg_loc_descriptor (rtl
);
7777 loc_result
= mem_loc_descriptor (XEXP (rtl
, 0), GET_MODE (rtl
));
7781 loc_result
= concat_loc_descriptor (XEXP (rtl
, 0), XEXP (rtl
, 1));
7791 /* Similar, but generate the descriptor from trees instead of rtl.
7792 This comes up particularly with variable length arrays. */
7794 static dw_loc_descr_ref
7795 loc_descriptor_from_tree (loc
, addressp
)
7799 dw_loc_descr_ref ret
= NULL
;
7800 int indirect_size
= 0;
7801 int unsignedp
= TREE_UNSIGNED (TREE_TYPE (loc
));
7802 enum dwarf_location_atom op
;
7804 /* ??? Most of the time we do not take proper care for sign/zero
7805 extending the values properly. Hopefully this won't be a real
7808 switch (TREE_CODE (loc
))
7813 case WITH_RECORD_EXPR
:
7814 /* This case involves extracting fields from an object to determine the
7815 position of other fields. We don't try to encode this here. The
7816 only user of this is Ada, which encodes the needed information using
7817 the names of types. */
7823 rtx rtl
= rtl_for_decl_location (loc
);
7824 enum machine_mode mode
= DECL_MODE (loc
);
7826 if (rtl
== NULL_RTX
)
7828 else if (CONSTANT_P (rtl
))
7830 ret
= new_loc_descr (DW_OP_addr
, 0, 0);
7831 ret
->dw_loc_oprnd1
.val_class
= dw_val_class_addr
;
7832 ret
->dw_loc_oprnd1
.v
.val_addr
= rtl
;
7833 indirect_size
= GET_MODE_SIZE (mode
);
7837 if (GET_CODE (rtl
) == MEM
)
7839 indirect_size
= GET_MODE_SIZE (mode
);
7840 rtl
= XEXP (rtl
, 0);
7842 ret
= mem_loc_descriptor (rtl
, mode
);
7848 ret
= loc_descriptor_from_tree (TREE_OPERAND (loc
, 0), 0);
7849 indirect_size
= GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (loc
)));
7854 case NON_LVALUE_EXPR
:
7856 return loc_descriptor_from_tree (TREE_OPERAND (loc
, 0), addressp
);
7861 case ARRAY_RANGE_REF
:
7864 HOST_WIDE_INT bitsize
, bitpos
, bytepos
;
7865 enum machine_mode mode
;
7867 unsigned int alignment
;
7869 obj
= get_inner_reference (loc
, &bitsize
, &bitpos
, &offset
, &mode
,
7870 &unsignedp
, &volatilep
, &alignment
);
7871 ret
= loc_descriptor_from_tree (obj
, 1);
7873 if (offset
!= NULL_TREE
)
7875 /* Variable offset. */
7876 add_loc_descr (&ret
, loc_descriptor_from_tree (offset
, 0));
7877 add_loc_descr (&ret
, new_loc_descr (DW_OP_plus
, 0, 0));
7882 /* We cannot address anything not on a unit boundary. */
7883 if (bitpos
% BITS_PER_UNIT
!= 0)
7888 if (bitpos
% BITS_PER_UNIT
!= 0
7889 || bitsize
% BITS_PER_UNIT
!= 0)
7891 /* ??? We could handle this by loading and shifting etc.
7892 Wait until someone needs it before expending the effort. */
7896 indirect_size
= bitsize
/ BITS_PER_UNIT
;
7899 bytepos
= bitpos
/ BITS_PER_UNIT
;
7901 add_loc_descr (&ret
, new_loc_descr (DW_OP_plus_uconst
, bytepos
, 0));
7902 else if (bytepos
< 0)
7904 add_loc_descr (&ret
, int_loc_descriptor (bytepos
));
7905 add_loc_descr (&ret
, new_loc_descr (DW_OP_plus
, 0, 0));
7911 if (host_integerp (loc
, 0))
7912 ret
= int_loc_descriptor (tree_low_cst (loc
, 0));
7924 case TRUNC_DIV_EXPR
:
7930 case TRUNC_MOD_EXPR
:
7940 op
= (unsignedp
? DW_OP_shr
: DW_OP_shra
);
7943 if (TREE_CODE (TREE_OPERAND (loc
, 1)) == INTEGER_CST
7944 && host_integerp (TREE_OPERAND (loc
, 1), 0))
7946 ret
= loc_descriptor_from_tree (TREE_OPERAND (loc
, 0), 0);
7947 add_loc_descr (&ret
,
7948 new_loc_descr (DW_OP_plus_uconst
,
7949 tree_low_cst (TREE_OPERAND (loc
, 1),
7957 if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc
, 0))))
7962 if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc
, 0))))
7967 if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc
, 0))))
7972 if (TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (loc
, 0))))
7984 ret
= loc_descriptor_from_tree (TREE_OPERAND (loc
, 0), 0);
7985 add_loc_descr (&ret
, loc_descriptor_from_tree (TREE_OPERAND (loc
, 1), 0));
7986 add_loc_descr (&ret
, new_loc_descr (op
, 0, 0));
8000 ret
= loc_descriptor_from_tree (TREE_OPERAND (loc
, 0), 0);
8001 add_loc_descr (&ret
, new_loc_descr (op
, 0, 0));
8005 loc
= build (COND_EXPR
, TREE_TYPE (loc
),
8006 build (LT_EXPR
, integer_type_node
,
8007 TREE_OPERAND (loc
, 0), TREE_OPERAND (loc
, 1)),
8008 TREE_OPERAND (loc
, 1), TREE_OPERAND (loc
, 0));
8013 dw_loc_descr_ref bra_node
, jump_node
, tmp
;
8015 ret
= loc_descriptor_from_tree (TREE_OPERAND (loc
, 0), 0);
8016 bra_node
= new_loc_descr (DW_OP_bra
, 0, 0);
8017 add_loc_descr (&ret
, bra_node
);
8019 tmp
= loc_descriptor_from_tree (TREE_OPERAND (loc
, 2), 0);
8020 add_loc_descr (&ret
, tmp
);
8021 jump_node
= new_loc_descr (DW_OP_skip
, 0, 0);
8022 add_loc_descr (&ret
, jump_node
);
8024 tmp
= loc_descriptor_from_tree (TREE_OPERAND (loc
, 1), 0);
8025 add_loc_descr (&ret
, tmp
);
8026 bra_node
->dw_loc_oprnd1
.val_class
= dw_val_class_loc
;
8027 bra_node
->dw_loc_oprnd1
.v
.val_loc
= tmp
;
8029 /* ??? Need a node to point the skip at. Use a nop. */
8030 tmp
= new_loc_descr (DW_OP_nop
, 0, 0);
8031 add_loc_descr (&ret
, tmp
);
8032 jump_node
->dw_loc_oprnd1
.val_class
= dw_val_class_loc
;
8033 jump_node
->dw_loc_oprnd1
.v
.val_loc
= tmp
;
8041 /* If we can't fill the request for an address, die. */
8042 if (addressp
&& indirect_size
== 0)
8045 /* If we've got an address and don't want one, dereference. */
8046 if (!addressp
&& indirect_size
> 0)
8048 if (indirect_size
> DWARF2_ADDR_SIZE
)
8050 if (indirect_size
== DWARF2_ADDR_SIZE
)
8053 op
= DW_OP_deref_size
;
8054 add_loc_descr (&ret
, new_loc_descr (op
, indirect_size
, 0));
8060 /* Given a value, round it up to the lowest multiple of `boundary'
8061 which is not less than the value itself. */
8063 static inline HOST_WIDE_INT
8064 ceiling (value
, boundary
)
8065 HOST_WIDE_INT value
;
8066 unsigned int boundary
;
8068 return (((value
+ boundary
- 1) / boundary
) * boundary
);
8071 /* Given a pointer to what is assumed to be a FIELD_DECL node, return a
8072 pointer to the declared type for the relevant field variable, or return
8073 `integer_type_node' if the given node turns out to be an
8082 if (TREE_CODE (decl
) == ERROR_MARK
)
8083 return integer_type_node
;
8085 type
= DECL_BIT_FIELD_TYPE (decl
);
8086 if (type
== NULL_TREE
)
8087 type
= TREE_TYPE (decl
);
8092 /* Given a pointer to a tree node, return the alignment in bits for
8093 it, or else return BITS_PER_WORD if the node actually turns out to
8094 be an ERROR_MARK node. */
8096 static inline unsigned
8097 simple_type_align_in_bits (type
)
8100 return (TREE_CODE (type
) != ERROR_MARK
) ? TYPE_ALIGN (type
) : BITS_PER_WORD
;
8103 static inline unsigned
8104 simple_decl_align_in_bits (decl
)
8107 return (TREE_CODE (decl
) != ERROR_MARK
) ? DECL_ALIGN (decl
) : BITS_PER_WORD
;
8110 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
8111 node, return the size in bits for the type if it is a constant, or else
8112 return the alignment for the type if the type's size is not constant, or
8113 else return BITS_PER_WORD if the type actually turns out to be an
8116 static inline unsigned HOST_WIDE_INT
8117 simple_type_size_in_bits (type
)
8120 tree type_size_tree
;
8122 if (TREE_CODE (type
) == ERROR_MARK
)
8123 return BITS_PER_WORD
;
8124 type_size_tree
= TYPE_SIZE (type
);
8126 if (type_size_tree
== NULL_TREE
)
8128 if (! host_integerp (type_size_tree
, 1))
8129 return TYPE_ALIGN (type
);
8130 return tree_low_cst (type_size_tree
, 1);
8133 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
8134 return the byte offset of the lowest addressed byte of the "containing
8135 object" for the given FIELD_DECL, or return 0 if we are unable to
8136 determine what that offset is, either because the argument turns out to
8137 be a pointer to an ERROR_MARK node, or because the offset is actually
8138 variable. (We can't handle the latter case just yet). */
8140 static HOST_WIDE_INT
8141 field_byte_offset (decl
)
8144 unsigned int type_align_in_bits
;
8145 unsigned int decl_align_in_bits
;
8146 unsigned HOST_WIDE_INT type_size_in_bits
;
8147 HOST_WIDE_INT object_offset_in_bits
;
8148 HOST_WIDE_INT object_offset_in_bytes
;
8150 tree field_size_tree
;
8151 HOST_WIDE_INT bitpos_int
;
8152 HOST_WIDE_INT deepest_bitpos
;
8153 unsigned HOST_WIDE_INT field_size_in_bits
;
8155 if (TREE_CODE (decl
) == ERROR_MARK
)
8158 if (TREE_CODE (decl
) != FIELD_DECL
)
8161 type
= field_type (decl
);
8162 field_size_tree
= DECL_SIZE (decl
);
8164 /* The size could be unspecified if there was an error, or for
8165 a flexible array member. */
8166 if (! field_size_tree
)
8167 field_size_tree
= bitsize_zero_node
;
8169 /* We cannot yet cope with fields whose positions are variable, so
8170 for now, when we see such things, we simply return 0. Someday, we may
8171 be able to handle such cases, but it will be damn difficult. */
8172 if (! host_integerp (bit_position (decl
), 0))
8175 bitpos_int
= int_bit_position (decl
);
8177 /* If we don't know the size of the field, pretend it's a full word. */
8178 if (host_integerp (field_size_tree
, 1))
8179 field_size_in_bits
= tree_low_cst (field_size_tree
, 1);
8181 field_size_in_bits
= BITS_PER_WORD
;
8183 type_size_in_bits
= simple_type_size_in_bits (type
);
8184 type_align_in_bits
= simple_type_align_in_bits (type
);
8185 decl_align_in_bits
= simple_decl_align_in_bits (decl
);
8187 /* Note that the GCC front-end doesn't make any attempt to keep track of
8188 the starting bit offset (relative to the start of the containing
8189 structure type) of the hypothetical "containing object" for a bit-
8190 field. Thus, when computing the byte offset value for the start of the
8191 "containing object" of a bit-field, we must deduce this information on
8192 our own. This can be rather tricky to do in some cases. For example,
8193 handling the following structure type definition when compiling for an
8194 i386/i486 target (which only aligns long long's to 32-bit boundaries)
8197 struct S { int field1; long long field2:31; };
8199 Fortunately, there is a simple rule-of-thumb which can be
8200 used in such cases. When compiling for an i386/i486, GCC will allocate
8201 8 bytes for the structure shown above. It decides to do this based upon
8202 one simple rule for bit-field allocation. Quite simply, GCC allocates
8203 each "containing object" for each bit-field at the first (i.e. lowest
8204 addressed) legitimate alignment boundary (based upon the required
8205 minimum alignment for the declared type of the field) which it can
8206 possibly use, subject to the condition that there is still enough
8207 available space remaining in the containing object (when allocated at
8208 the selected point) to fully accommodate all of the bits of the
8209 bit-field itself. This simple rule makes it obvious why GCC allocates
8210 8 bytes for each object of the structure type shown above. When looking
8211 for a place to allocate the "containing object" for `field2', the
8212 compiler simply tries to allocate a 64-bit "containing object" at each
8213 successive 32-bit boundary (starting at zero) until it finds a place to
8214 allocate that 64- bit field such that at least 31 contiguous (and
8215 previously unallocated) bits remain within that selected 64 bit field.
8216 (As it turns out, for the example above, the compiler finds that it is
8217 OK to allocate the "containing object" 64-bit field at bit-offset zero
8218 within the structure type.) Here we attempt to work backwards from the
8219 limited set of facts we're given, and we try to deduce from those facts,
8220 where GCC must have believed that the containing object started (within
8221 the structure type). The value we deduce is then used (by the callers of
8222 this routine) to generate DW_AT_location and DW_AT_bit_offset attributes
8223 for fields (both bit-fields and, in the case of DW_AT_location, regular
8226 /* Figure out the bit-distance from the start of the structure to the
8227 "deepest" bit of the bit-field. */
8228 deepest_bitpos
= bitpos_int
+ field_size_in_bits
;
8230 /* This is the tricky part. Use some fancy footwork to deduce where the
8231 lowest addressed bit of the containing object must be. */
8232 object_offset_in_bits
= deepest_bitpos
- type_size_in_bits
;
8234 /* Round up to type_align by default. This works best for bitfields. */
8235 object_offset_in_bits
+= type_align_in_bits
- 1;
8236 object_offset_in_bits
/= type_align_in_bits
;
8237 object_offset_in_bits
*= type_align_in_bits
;
8239 if (object_offset_in_bits
> bitpos_int
)
8241 /* Sigh, the decl must be packed. */
8242 object_offset_in_bits
= deepest_bitpos
- type_size_in_bits
;
8244 /* Round up to decl_align instead. */
8245 object_offset_in_bits
+= decl_align_in_bits
- 1;
8246 object_offset_in_bits
/= decl_align_in_bits
;
8247 object_offset_in_bits
*= decl_align_in_bits
;
8250 object_offset_in_bytes
= object_offset_in_bits
/ BITS_PER_UNIT
;
8252 return object_offset_in_bytes
;
8255 /* The following routines define various Dwarf attributes and any data
8256 associated with them. */
8258 /* Add a location description attribute value to a DIE.
8260 This emits location attributes suitable for whole variables and
8261 whole parameters. Note that the location attributes for struct fields are
8262 generated by the routine `data_member_location_attribute' below. */
8265 add_AT_location_description (die
, attr_kind
, rtl
)
8267 enum dwarf_attribute attr_kind
;
8270 /* Handle a special case. If we are about to output a location descriptor
8271 for a variable or parameter which has been optimized out of existence,
8272 don't do that. A variable which has been optimized out
8273 of existence will have a DECL_RTL value which denotes a pseudo-reg.
8274 Currently, in some rare cases, variables can have DECL_RTL values which
8275 look like (MEM (REG pseudo-reg#)). These cases are due to bugs
8276 elsewhere in the compiler. We treat such cases as if the variable(s) in
8277 question had been optimized out of existence. */
8279 if (is_pseudo_reg (rtl
)
8280 || (GET_CODE (rtl
) == MEM
8281 && is_pseudo_reg (XEXP (rtl
, 0)))
8282 /* This can happen for a PARM_DECL with a DECL_INCOMING_RTL which
8283 references the internal argument pointer (a pseudo) in a function
8284 where all references to the internal argument pointer were
8285 eliminated via the optimizers. */
8286 || (GET_CODE (rtl
) == MEM
8287 && GET_CODE (XEXP (rtl
, 0)) == PLUS
8288 && is_pseudo_reg (XEXP (XEXP (rtl
, 0), 0)))
8289 || (GET_CODE (rtl
) == CONCAT
8290 && is_pseudo_reg (XEXP (rtl
, 0))
8291 && is_pseudo_reg (XEXP (rtl
, 1))))
8294 add_AT_loc (die
, attr_kind
, loc_descriptor (rtl
));
8297 /* Attach the specialized form of location attribute used for data
8298 members of struct and union types. In the special case of a
8299 FIELD_DECL node which represents a bit-field, the "offset" part
8300 of this special location descriptor must indicate the distance
8301 in bytes from the lowest-addressed byte of the containing struct
8302 or union type to the lowest-addressed byte of the "containing
8303 object" for the bit-field. (See the `field_byte_offset' function
8304 above).. For any given bit-field, the "containing object" is a
8305 hypothetical object (of some integral or enum type) within which
8306 the given bit-field lives. The type of this hypothetical
8307 "containing object" is always the same as the declared type of
8308 the individual bit-field itself (for GCC anyway... the DWARF
8309 spec doesn't actually mandate this). Note that it is the size
8310 (in bytes) of the hypothetical "containing object" which will
8311 be given in the DW_AT_byte_size attribute for this bit-field.
8312 (See the `byte_size_attribute' function below.) It is also used
8313 when calculating the value of the DW_AT_bit_offset attribute.
8314 (See the `bit_offset_attribute' function below). */
8317 add_data_member_location_attribute (die
, decl
)
8318 register dw_die_ref die
;
8321 register unsigned long offset
;
8322 register dw_loc_descr_ref loc_descr
;
8323 register enum dwarf_location_atom op
;
8325 if (TREE_CODE (decl
) == TREE_VEC
)
8326 offset
= tree_low_cst (BINFO_OFFSET (decl
), 0);
8328 offset
= field_byte_offset (decl
);
8330 /* The DWARF2 standard says that we should assume that the structure address
8331 is already on the stack, so we can specify a structure field address
8332 by using DW_OP_plus_uconst. */
8334 #ifdef MIPS_DEBUGGING_INFO
8335 /* ??? The SGI dwarf reader does not handle the DW_OP_plus_uconst operator
8336 correctly. It works only if we leave the offset on the stack. */
8339 op
= DW_OP_plus_uconst
;
8342 loc_descr
= new_loc_descr (op
, offset
, 0);
8343 add_AT_loc (die
, DW_AT_data_member_location
, loc_descr
);
8346 /* Attach an DW_AT_const_value attribute for a variable or a parameter which
8347 does not have a "location" either in memory or in a register. These
8348 things can arise in GNU C when a constant is passed as an actual parameter
8349 to an inlined function. They can also arise in C++ where declared
8350 constants do not necessarily get memory "homes". */
8353 add_const_value_attribute (die
, rtl
)
8354 register dw_die_ref die
;
8357 switch (GET_CODE (rtl
))
8360 /* Note that a CONST_INT rtx could represent either an integer
8361 or a floating-point constant. A CONST_INT is used whenever
8362 the constant will fit into a single word. In all such
8363 cases, the original mode of the constant value is wiped
8364 out, and the CONST_INT rtx is assigned VOIDmode. */
8366 HOST_WIDE_INT val
= INTVAL (rtl
);
8368 /* ??? We really should be using HOST_WIDE_INT throughout. */
8371 if ((long) val
!= val
)
8373 add_AT_int (die
, DW_AT_const_value
, (long) val
);
8377 if ((unsigned long) val
!= (unsigned HOST_WIDE_INT
) val
)
8379 add_AT_unsigned (die
, DW_AT_const_value
, (unsigned long) val
);
8385 /* Note that a CONST_DOUBLE rtx could represent either an integer or a
8386 floating-point constant. A CONST_DOUBLE is used whenever the
8387 constant requires more than one word in order to be adequately
8388 represented. We output CONST_DOUBLEs as blocks. */
8390 register enum machine_mode mode
= GET_MODE (rtl
);
8392 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
)
8394 register unsigned length
= GET_MODE_SIZE (mode
) / 4;
8395 long *array
= (long *) xmalloc (sizeof (long) * length
);
8398 REAL_VALUE_FROM_CONST_DOUBLE (rv
, rtl
);
8402 REAL_VALUE_TO_TARGET_SINGLE (rv
, array
[0]);
8406 REAL_VALUE_TO_TARGET_DOUBLE (rv
, array
);
8411 REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv
, array
);
8418 add_AT_float (die
, DW_AT_const_value
, length
, array
);
8422 /* ??? We really should be using HOST_WIDE_INT throughout. */
8423 if (HOST_BITS_PER_LONG
!= HOST_BITS_PER_WIDE_INT
)
8425 add_AT_long_long (die
, DW_AT_const_value
,
8426 CONST_DOUBLE_HIGH (rtl
), CONST_DOUBLE_LOW (rtl
));
8432 add_AT_string (die
, DW_AT_const_value
, XSTR (rtl
, 0));
8438 add_AT_addr (die
, DW_AT_const_value
, save_rtx (rtl
));
8442 /* In cases where an inlined instance of an inline function is passed
8443 the address of an `auto' variable (which is local to the caller) we
8444 can get a situation where the DECL_RTL of the artificial local
8445 variable (for the inlining) which acts as a stand-in for the
8446 corresponding formal parameter (of the inline function) will look
8447 like (plus:SI (reg:SI FRAME_PTR) (const_int ...)). This is not
8448 exactly a compile-time constant expression, but it isn't the address
8449 of the (artificial) local variable either. Rather, it represents the
8450 *value* which the artificial local variable always has during its
8451 lifetime. We currently have no way to represent such quasi-constant
8452 values in Dwarf, so for now we just punt and generate nothing. */
8456 /* No other kinds of rtx should be possible here. */
8463 rtl_for_decl_location (decl
)
8468 /* Here we have to decide where we are going to say the parameter "lives"
8469 (as far as the debugger is concerned). We only have a couple of
8470 choices. GCC provides us with DECL_RTL and with DECL_INCOMING_RTL.
8472 DECL_RTL normally indicates where the parameter lives during most of the
8473 activation of the function. If optimization is enabled however, this
8474 could be either NULL or else a pseudo-reg. Both of those cases indicate
8475 that the parameter doesn't really live anywhere (as far as the code
8476 generation parts of GCC are concerned) during most of the function's
8477 activation. That will happen (for example) if the parameter is never
8478 referenced within the function.
8480 We could just generate a location descriptor here for all non-NULL
8481 non-pseudo values of DECL_RTL and ignore all of the rest, but we can be
8482 a little nicer than that if we also consider DECL_INCOMING_RTL in cases
8483 where DECL_RTL is NULL or is a pseudo-reg.
8485 Note however that we can only get away with using DECL_INCOMING_RTL as
8486 a backup substitute for DECL_RTL in certain limited cases. In cases
8487 where DECL_ARG_TYPE (decl) indicates the same type as TREE_TYPE (decl),
8488 we can be sure that the parameter was passed using the same type as it is
8489 declared to have within the function, and that its DECL_INCOMING_RTL
8490 points us to a place where a value of that type is passed.
8492 In cases where DECL_ARG_TYPE (decl) and TREE_TYPE (decl) are different,
8493 we cannot (in general) use DECL_INCOMING_RTL as a substitute for DECL_RTL
8494 because in these cases DECL_INCOMING_RTL points us to a value of some
8495 type which is *different* from the type of the parameter itself. Thus,
8496 if we tried to use DECL_INCOMING_RTL to generate a location attribute in
8497 such cases, the debugger would end up (for example) trying to fetch a
8498 `float' from a place which actually contains the first part of a
8499 `double'. That would lead to really incorrect and confusing
8500 output at debug-time.
8502 So, in general, we *do not* use DECL_INCOMING_RTL as a backup for DECL_RTL
8503 in cases where DECL_ARG_TYPE (decl) != TREE_TYPE (decl). There
8504 are a couple of exceptions however. On little-endian machines we can
8505 get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE (decl) is
8506 not the same as TREE_TYPE (decl), but only when DECL_ARG_TYPE (decl) is
8507 an integral type that is smaller than TREE_TYPE (decl). These cases arise
8508 when (on a little-endian machine) a non-prototyped function has a
8509 parameter declared to be of type `short' or `char'. In such cases,
8510 TREE_TYPE (decl) will be `short' or `char', DECL_ARG_TYPE (decl) will
8511 be `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
8512 passed `int' value. If the debugger then uses that address to fetch
8513 a `short' or a `char' (on a little-endian machine) the result will be
8514 the correct data, so we allow for such exceptional cases below.
8516 Note that our goal here is to describe the place where the given formal
8517 parameter lives during most of the function's activation (i.e. between
8518 the end of the prologue and the start of the epilogue). We'll do that
8519 as best as we can. Note however that if the given formal parameter is
8520 modified sometime during the execution of the function, then a stack
8521 backtrace (at debug-time) will show the function as having been
8522 called with the *new* value rather than the value which was
8523 originally passed in. This happens rarely enough that it is not
8524 a major problem, but it *is* a problem, and I'd like to fix it.
8526 A future version of dwarf2out.c may generate two additional
8527 attributes for any given DW_TAG_formal_parameter DIE which will
8528 describe the "passed type" and the "passed location" for the
8529 given formal parameter in addition to the attributes we now
8530 generate to indicate the "declared type" and the "active
8531 location" for each parameter. This additional set of attributes
8532 could be used by debuggers for stack backtraces. Separately, note
8533 that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL can be
8534 NULL also. This happens (for example) for inlined-instances of
8535 inline function formal parameters which are never referenced.
8536 This really shouldn't be happening. All PARM_DECL nodes should
8537 get valid non-NULL DECL_INCOMING_RTL values, but integrate.c
8538 doesn't currently generate these values for inlined instances of
8539 inline function parameters, so when we see such cases, we are
8540 just out-of-luck for the time being (until integrate.c
8543 /* Use DECL_RTL as the "location" unless we find something better. */
8544 rtl
= DECL_RTL_IF_SET (decl
);
8546 if (TREE_CODE (decl
) == PARM_DECL
)
8548 if (rtl
== NULL_RTX
|| is_pseudo_reg (rtl
))
8550 tree declared_type
= type_main_variant (TREE_TYPE (decl
));
8551 tree passed_type
= type_main_variant (DECL_ARG_TYPE (decl
));
8553 /* This decl represents a formal parameter which was optimized out.
8554 Note that DECL_INCOMING_RTL may be NULL in here, but we handle
8555 all* cases where (rtl == NULL_RTX) just below. */
8556 if (declared_type
== passed_type
)
8557 rtl
= DECL_INCOMING_RTL (decl
);
8558 else if (! BYTES_BIG_ENDIAN
8559 && TREE_CODE (declared_type
) == INTEGER_TYPE
8560 && (GET_MODE_SIZE (TYPE_MODE (declared_type
))
8561 <= GET_MODE_SIZE (TYPE_MODE (passed_type
))))
8562 rtl
= DECL_INCOMING_RTL (decl
);
8565 /* If the parm was passed in registers, but lives on the stack, then
8566 make a big endian correction if the mode of the type of the
8567 parameter is not the same as the mode of the rtl. */
8568 /* ??? This is the same series of checks that are made in dbxout.c before
8569 we reach the big endian correction code there. It isn't clear if all
8570 of these checks are necessary here, but keeping them all is the safe
8572 else if (GET_CODE (rtl
) == MEM
8573 && XEXP (rtl
, 0) != const0_rtx
8574 && ! CONSTANT_P (XEXP (rtl
, 0))
8575 /* Not passed in memory. */
8576 && GET_CODE (DECL_INCOMING_RTL (decl
)) != MEM
8577 /* Not passed by invisible reference. */
8578 && (GET_CODE (XEXP (rtl
, 0)) != REG
8579 || REGNO (XEXP (rtl
, 0)) == HARD_FRAME_POINTER_REGNUM
8580 || REGNO (XEXP (rtl
, 0)) == STACK_POINTER_REGNUM
8581 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
8582 || REGNO (XEXP (rtl
, 0)) == ARG_POINTER_REGNUM
8585 /* Big endian correction check. */
8587 && TYPE_MODE (TREE_TYPE (decl
)) != GET_MODE (rtl
)
8588 && (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (decl
)))
8591 int offset
= (UNITS_PER_WORD
8592 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (decl
))));
8593 rtl
= gen_rtx_MEM (TYPE_MODE (TREE_TYPE (decl
)),
8594 plus_constant (XEXP (rtl
, 0), offset
));
8598 if (rtl
!= NULL_RTX
)
8600 rtl
= eliminate_regs (rtl
, 0, NULL_RTX
);
8601 #ifdef LEAF_REG_REMAP
8602 if (current_function_uses_only_leaf_regs
)
8603 leaf_renumber_regs_insn (rtl
);
8610 /* Generate *either* an DW_AT_location attribute or else an DW_AT_const_value
8611 data attribute for a variable or a parameter. We generate the
8612 DW_AT_const_value attribute only in those cases where the given variable
8613 or parameter does not have a true "location" either in memory or in a
8614 register. This can happen (for example) when a constant is passed as an
8615 actual argument in a call to an inline function. (It's possible that
8616 these things can crop up in other ways also.) Note that one type of
8617 constant value which can be passed into an inlined function is a constant
8618 pointer. This can happen for example if an actual argument in an inlined
8619 function call evaluates to a compile-time constant address. */
8622 add_location_or_const_value_attribute (die
, decl
)
8623 register dw_die_ref die
;
8628 if (TREE_CODE (decl
) == ERROR_MARK
)
8631 if (TREE_CODE (decl
) != VAR_DECL
&& TREE_CODE (decl
) != PARM_DECL
)
8634 rtl
= rtl_for_decl_location (decl
);
8635 if (rtl
== NULL_RTX
)
8638 /* If we don't look past the constant pool, we risk emitting a
8639 reference to a constant pool entry that isn't referenced from
8640 code, and thus is not emitted. */
8641 rtl
= avoid_constant_pool_reference (rtl
);
8643 switch (GET_CODE (rtl
))
8646 /* The address of a variable that was optimized away; don't emit
8657 /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
8658 add_const_value_attribute (die
, rtl
);
8665 add_AT_location_description (die
, DW_AT_location
, rtl
);
8673 /* If we don't have a copy of this variable in memory for some reason (such
8674 as a C++ member constant that doesn't have an out-of-line definition),
8675 we should tell the debugger about the constant value. */
8678 tree_add_const_value_attribute (var_die
, decl
)
8682 tree init
= DECL_INITIAL (decl
);
8683 tree type
= TREE_TYPE (decl
);
8685 if (TREE_READONLY (decl
) && ! TREE_THIS_VOLATILE (decl
) && init
8686 && initializer_constant_valid_p (init
, type
) == null_pointer_node
)
8691 switch (TREE_CODE (type
))
8694 if (host_integerp (init
, 0))
8695 add_AT_unsigned (var_die
, DW_AT_const_value
,
8696 TREE_INT_CST_LOW (init
));
8698 add_AT_long_long (var_die
, DW_AT_const_value
,
8699 TREE_INT_CST_HIGH (init
),
8700 TREE_INT_CST_LOW (init
));
8707 /* Generate an DW_AT_name attribute given some string value to be included as
8708 the value of the attribute. */
8711 add_name_attribute (die
, name_string
)
8712 register dw_die_ref die
;
8713 register const char *name_string
;
8715 if (name_string
!= NULL
&& *name_string
!= 0)
8717 if (demangle_name_func
)
8718 name_string
= (*demangle_name_func
) (name_string
);
8720 add_AT_string (die
, DW_AT_name
, name_string
);
8724 /* Given a tree node describing an array bound (either lower or upper) output
8725 a representation for that bound. */
8728 add_bound_info (subrange_die
, bound_attr
, bound
)
8729 register dw_die_ref subrange_die
;
8730 register enum dwarf_attribute bound_attr
;
8731 register tree bound
;
8733 /* If this is an Ada unconstrained array type, then don't emit any debug
8734 info because the array bounds are unknown. They are parameterized when
8735 the type is instantiated. */
8736 if (contains_placeholder_p (bound
))
8739 switch (TREE_CODE (bound
))
8744 /* All fixed-bounds are represented by INTEGER_CST nodes. */
8746 if (! host_integerp (bound
, 0)
8747 || (bound_attr
== DW_AT_lower_bound
8748 && (((is_c_family () || is_java ()) && integer_zerop (bound
))
8749 || (is_fortran () && integer_onep (bound
)))))
8750 /* use the default */
8753 add_AT_unsigned (subrange_die
, bound_attr
, tree_low_cst (bound
, 0));
8758 case NON_LVALUE_EXPR
:
8759 add_bound_info (subrange_die
, bound_attr
, TREE_OPERAND (bound
, 0));
8763 /* If optimization is turned on, the SAVE_EXPRs that describe how to
8764 access the upper bound values may be bogus. If they refer to a
8765 register, they may only describe how to get at these values at the
8766 points in the generated code right after they have just been
8767 computed. Worse yet, in the typical case, the upper bound values
8768 will not even *be* computed in the optimized code (though the
8769 number of elements will), so these SAVE_EXPRs are entirely
8770 bogus. In order to compensate for this fact, we check here to see
8771 if optimization is enabled, and if so, we don't add an attribute
8772 for the (unknown and unknowable) upper bound. This should not
8773 cause too much trouble for existing (stupid?) debuggers because
8774 they have to deal with empty upper bounds location descriptions
8775 anyway in order to be able to deal with incomplete array types.
8776 Of course an intelligent debugger (GDB?) should be able to
8777 comprehend that a missing upper bound specification in a array
8778 type used for a storage class `auto' local array variable
8779 indicates that the upper bound is both unknown (at compile- time)
8780 and unknowable (at run-time) due to optimization.
8782 We assume that a MEM rtx is safe because gcc wouldn't put the
8783 value there unless it was going to be used repeatedly in the
8784 function, i.e. for cleanups. */
8785 if (SAVE_EXPR_RTL (bound
)
8786 && (! optimize
|| GET_CODE (SAVE_EXPR_RTL (bound
)) == MEM
))
8788 register dw_die_ref ctx
= lookup_decl_die (current_function_decl
);
8789 register dw_die_ref decl_die
= new_die (DW_TAG_variable
, ctx
);
8790 register rtx loc
= SAVE_EXPR_RTL (bound
);
8792 /* If the RTL for the SAVE_EXPR is memory, handle the case where
8793 it references an outer function's frame. */
8795 if (GET_CODE (loc
) == MEM
)
8797 rtx new_addr
= fix_lexical_addr (XEXP (loc
, 0), bound
);
8799 if (XEXP (loc
, 0) != new_addr
)
8800 loc
= gen_rtx_MEM (GET_MODE (loc
), new_addr
);
8803 add_AT_flag (decl_die
, DW_AT_artificial
, 1);
8804 add_type_attribute (decl_die
, TREE_TYPE (bound
), 1, 0, ctx
);
8805 add_AT_location_description (decl_die
, DW_AT_location
, loc
);
8806 add_AT_die_ref (subrange_die
, bound_attr
, decl_die
);
8809 /* Else leave out the attribute. */
8815 dw_die_ref decl_die
= lookup_decl_die (bound
);
8817 /* ??? Can this happen, or should the variable have been bound
8818 first? Probably it can, since I imagine that we try to create
8819 the types of parameters in the order in which they exist in
8820 the list, and won't have created a forward reference to a
8822 if (decl_die
!= NULL
)
8823 add_AT_die_ref (subrange_die
, bound_attr
, decl_die
);
8829 /* Otherwise try to create a stack operation procedure to
8830 evaluate the value of the array bound. */
8832 dw_die_ref ctx
, decl_die
;
8833 dw_loc_descr_ref loc
;
8835 loc
= loc_descriptor_from_tree (bound
, 0);
8839 ctx
= lookup_decl_die (current_function_decl
);
8841 decl_die
= new_die (DW_TAG_variable
, ctx
);
8842 add_AT_flag (decl_die
, DW_AT_artificial
, 1);
8843 add_type_attribute (decl_die
, TREE_TYPE (bound
), 1, 0, ctx
);
8844 add_AT_loc (decl_die
, DW_AT_location
, loc
);
8846 add_AT_die_ref (subrange_die
, bound_attr
, decl_die
);
8852 /* Note that the block of subscript information for an array type also
8853 includes information about the element type of type given array type. */
8856 add_subscript_info (type_die
, type
)
8857 register dw_die_ref type_die
;
8860 #ifndef MIPS_DEBUGGING_INFO
8861 register unsigned dimension_number
;
8863 register tree lower
, upper
;
8864 register dw_die_ref subrange_die
;
8866 /* The GNU compilers represent multidimensional array types as sequences of
8867 one dimensional array types whose element types are themselves array
8868 types. Here we squish that down, so that each multidimensional array
8869 type gets only one array_type DIE in the Dwarf debugging info. The draft
8870 Dwarf specification say that we are allowed to do this kind of
8871 compression in C (because there is no difference between an array or
8872 arrays and a multidimensional array in C) but for other source languages
8873 (e.g. Ada) we probably shouldn't do this. */
8875 /* ??? The SGI dwarf reader fails for multidimensional arrays with a
8876 const enum type. E.g. const enum machine_mode insn_operand_mode[2][10].
8877 We work around this by disabling this feature. See also
8878 gen_array_type_die. */
8879 #ifndef MIPS_DEBUGGING_INFO
8880 for (dimension_number
= 0;
8881 TREE_CODE (type
) == ARRAY_TYPE
;
8882 type
= TREE_TYPE (type
), dimension_number
++)
8885 register tree domain
= TYPE_DOMAIN (type
);
8887 /* Arrays come in three flavors: Unspecified bounds, fixed bounds,
8888 and (in GNU C only) variable bounds. Handle all three forms
8890 subrange_die
= new_die (DW_TAG_subrange_type
, type_die
);
8893 /* We have an array type with specified bounds. */
8894 lower
= TYPE_MIN_VALUE (domain
);
8895 upper
= TYPE_MAX_VALUE (domain
);
8897 /* define the index type. */
8898 if (TREE_TYPE (domain
))
8900 /* ??? This is probably an Ada unnamed subrange type. Ignore the
8901 TREE_TYPE field. We can't emit debug info for this
8902 because it is an unnamed integral type. */
8903 if (TREE_CODE (domain
) == INTEGER_TYPE
8904 && TYPE_NAME (domain
) == NULL_TREE
8905 && TREE_CODE (TREE_TYPE (domain
)) == INTEGER_TYPE
8906 && TYPE_NAME (TREE_TYPE (domain
)) == NULL_TREE
)
8909 add_type_attribute (subrange_die
, TREE_TYPE (domain
), 0, 0,
8913 /* ??? If upper is NULL, the array has unspecified length,
8914 but it does have a lower bound. This happens with Fortran
8916 Since the debugger is definitely going to need to know N
8917 to produce useful results, go ahead and output the lower
8918 bound solo, and hope the debugger can cope. */
8920 add_bound_info (subrange_die
, DW_AT_lower_bound
, lower
);
8922 add_bound_info (subrange_die
, DW_AT_upper_bound
, upper
);
8925 /* We have an array type with an unspecified length. The DWARF-2
8926 spec does not say how to handle this; let's just leave out the
8930 #ifndef MIPS_DEBUGGING_INFO
8936 add_byte_size_attribute (die
, tree_node
)
8938 register tree tree_node
;
8940 register unsigned size
;
8942 switch (TREE_CODE (tree_node
))
8950 case QUAL_UNION_TYPE
:
8951 size
= int_size_in_bytes (tree_node
);
8954 /* For a data member of a struct or union, the DW_AT_byte_size is
8955 generally given as the number of bytes normally allocated for an
8956 object of the *declared* type of the member itself. This is true
8957 even for bit-fields. */
8958 size
= simple_type_size_in_bits (field_type (tree_node
)) / BITS_PER_UNIT
;
8964 /* Note that `size' might be -1 when we get to this point. If it is, that
8965 indicates that the byte size of the entity in question is variable. We
8966 have no good way of expressing this fact in Dwarf at the present time,
8967 so just let the -1 pass on through. */
8969 add_AT_unsigned (die
, DW_AT_byte_size
, size
);
8972 /* For a FIELD_DECL node which represents a bit-field, output an attribute
8973 which specifies the distance in bits from the highest order bit of the
8974 "containing object" for the bit-field to the highest order bit of the
8977 For any given bit-field, the "containing object" is a hypothetical
8978 object (of some integral or enum type) within which the given bit-field
8979 lives. The type of this hypothetical "containing object" is always the
8980 same as the declared type of the individual bit-field itself. The
8981 determination of the exact location of the "containing object" for a
8982 bit-field is rather complicated. It's handled by the
8983 `field_byte_offset' function (above).
8985 Note that it is the size (in bytes) of the hypothetical "containing object"
8986 which will be given in the DW_AT_byte_size attribute for this bit-field.
8987 (See `byte_size_attribute' above). */
8990 add_bit_offset_attribute (die
, decl
)
8991 register dw_die_ref die
;
8994 HOST_WIDE_INT object_offset_in_bytes
= field_byte_offset (decl
);
8995 tree type
= DECL_BIT_FIELD_TYPE (decl
);
8996 HOST_WIDE_INT bitpos_int
;
8997 HOST_WIDE_INT highest_order_object_bit_offset
;
8998 HOST_WIDE_INT highest_order_field_bit_offset
;
8999 HOST_WIDE_INT
unsigned bit_offset
;
9001 /* Must be a field and a bit field. */
9003 || TREE_CODE (decl
) != FIELD_DECL
)
9006 /* We can't yet handle bit-fields whose offsets are variable, so if we
9007 encounter such things, just return without generating any attribute
9008 whatsoever. Likewise for variable or too large size. */
9009 if (! host_integerp (bit_position (decl
), 0)
9010 || ! host_integerp (DECL_SIZE (decl
), 1))
9013 bitpos_int
= int_bit_position (decl
);
9015 /* Note that the bit offset is always the distance (in bits) from the
9016 highest-order bit of the "containing object" to the highest-order bit of
9017 the bit-field itself. Since the "high-order end" of any object or field
9018 is different on big-endian and little-endian machines, the computation
9019 below must take account of these differences. */
9020 highest_order_object_bit_offset
= object_offset_in_bytes
* BITS_PER_UNIT
;
9021 highest_order_field_bit_offset
= bitpos_int
;
9023 if (! BYTES_BIG_ENDIAN
)
9025 highest_order_field_bit_offset
+= tree_low_cst (DECL_SIZE (decl
), 0);
9026 highest_order_object_bit_offset
+= simple_type_size_in_bits (type
);
9030 = (! BYTES_BIG_ENDIAN
9031 ? highest_order_object_bit_offset
- highest_order_field_bit_offset
9032 : highest_order_field_bit_offset
- highest_order_object_bit_offset
);
9034 add_AT_unsigned (die
, DW_AT_bit_offset
, bit_offset
);
9037 /* For a FIELD_DECL node which represents a bit field, output an attribute
9038 which specifies the length in bits of the given field. */
9041 add_bit_size_attribute (die
, decl
)
9042 register dw_die_ref die
;
9045 /* Must be a field and a bit field. */
9046 if (TREE_CODE (decl
) != FIELD_DECL
9047 || ! DECL_BIT_FIELD_TYPE (decl
))
9050 if (host_integerp (DECL_SIZE (decl
), 1))
9051 add_AT_unsigned (die
, DW_AT_bit_size
, tree_low_cst (DECL_SIZE (decl
), 1));
9054 /* If the compiled language is ANSI C, then add a 'prototyped'
9055 attribute, if arg types are given for the parameters of a function. */
9058 add_prototyped_attribute (die
, func_type
)
9059 register dw_die_ref die
;
9060 register tree func_type
;
9062 if (get_AT_unsigned (comp_unit_die
, DW_AT_language
) == DW_LANG_C89
9063 && TYPE_ARG_TYPES (func_type
) != NULL
)
9064 add_AT_flag (die
, DW_AT_prototyped
, 1);
9067 /* Add an 'abstract_origin' attribute below a given DIE. The DIE is found
9068 by looking in either the type declaration or object declaration
9072 add_abstract_origin_attribute (die
, origin
)
9073 register dw_die_ref die
;
9074 register tree origin
;
9076 dw_die_ref origin_die
= NULL
;
9078 if (TREE_CODE (origin
) != FUNCTION_DECL
)
9080 /* We may have gotten separated from the block for the inlined
9081 function, if we're in an exception handler or some such; make
9082 sure that the abstract function has been written out.
9084 Doing this for nested functions is wrong, however; functions are
9085 distinct units, and our context might not even be inline. */
9088 fn
= TYPE_STUB_DECL (fn
);
9089 fn
= decl_function_context (fn
);
9091 dwarf2out_abstract_function (fn
);
9094 if (DECL_P (origin
))
9095 origin_die
= lookup_decl_die (origin
);
9096 else if (TYPE_P (origin
))
9097 origin_die
= lookup_type_die (origin
);
9099 if (origin_die
== NULL
)
9102 add_AT_die_ref (die
, DW_AT_abstract_origin
, origin_die
);
9105 /* We do not currently support the pure_virtual attribute. */
9108 add_pure_or_virtual_attribute (die
, func_decl
)
9109 register dw_die_ref die
;
9110 register tree func_decl
;
9112 if (DECL_VINDEX (func_decl
))
9114 add_AT_unsigned (die
, DW_AT_virtuality
, DW_VIRTUALITY_virtual
);
9116 if (host_integerp (DECL_VINDEX (func_decl
), 0))
9117 add_AT_loc (die
, DW_AT_vtable_elem_location
,
9118 new_loc_descr (DW_OP_constu
,
9119 tree_low_cst (DECL_VINDEX (func_decl
), 0),
9122 /* GNU extension: Record what type this method came from originally. */
9123 if (debug_info_level
> DINFO_LEVEL_TERSE
)
9124 add_AT_die_ref (die
, DW_AT_containing_type
,
9125 lookup_type_die (DECL_CONTEXT (func_decl
)));
9129 /* Add source coordinate attributes for the given decl. */
9132 add_src_coords_attributes (die
, decl
)
9133 register dw_die_ref die
;
9136 register unsigned file_index
= lookup_filename (DECL_SOURCE_FILE (decl
));
9138 add_AT_unsigned (die
, DW_AT_decl_file
, file_index
);
9139 add_AT_unsigned (die
, DW_AT_decl_line
, DECL_SOURCE_LINE (decl
));
9142 /* Add an DW_AT_name attribute and source coordinate attribute for the
9143 given decl, but only if it actually has a name. */
9146 add_name_and_src_coords_attributes (die
, decl
)
9147 register dw_die_ref die
;
9150 register tree decl_name
;
9152 decl_name
= DECL_NAME (decl
);
9153 if (decl_name
!= NULL
&& IDENTIFIER_POINTER (decl_name
) != NULL
)
9155 add_name_attribute (die
, dwarf2_name (decl
, 0));
9156 if (! DECL_ARTIFICIAL (decl
))
9157 add_src_coords_attributes (die
, decl
);
9159 if ((TREE_CODE (decl
) == FUNCTION_DECL
|| TREE_CODE (decl
) == VAR_DECL
)
9160 && TREE_PUBLIC (decl
)
9161 && DECL_ASSEMBLER_NAME (decl
) != DECL_NAME (decl
)
9162 && !DECL_ABSTRACT (decl
))
9163 add_AT_string (die
, DW_AT_MIPS_linkage_name
,
9164 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
9168 /* Push a new declaration scope. */
9171 push_decl_scope (scope
)
9174 /* Make room in the decl_scope_table, if necessary. */
9175 if (decl_scope_table_allocated
== decl_scope_depth
)
9177 decl_scope_table_allocated
+= DECL_SCOPE_TABLE_INCREMENT
;
9179 = (tree
*) xrealloc (decl_scope_table
,
9180 decl_scope_table_allocated
* sizeof (tree
));
9183 decl_scope_table
[decl_scope_depth
] = scope
;
9187 /* Pop a declaration scope. */
9191 if (decl_scope_depth
<= 0)
9196 /* Return the DIE for the scope that immediately contains this type.
9197 Non-named types get global scope. Named types nested in other
9198 types get their containing scope if it's open, or global scope
9199 otherwise. All other types (i.e. function-local named types) get
9200 the current active scope. */
9203 scope_die_for (t
, context_die
)
9205 register dw_die_ref context_die
;
9207 register dw_die_ref scope_die
= NULL
;
9208 register tree containing_scope
;
9211 /* Non-types always go in the current scope. */
9215 containing_scope
= TYPE_CONTEXT (t
);
9217 /* Ignore namespaces for the moment. */
9218 if (containing_scope
&& TREE_CODE (containing_scope
) == NAMESPACE_DECL
)
9219 containing_scope
= NULL_TREE
;
9221 /* Ignore function type "scopes" from the C frontend. They mean that
9222 a tagged type is local to a parmlist of a function declarator, but
9223 that isn't useful to DWARF. */
9224 if (containing_scope
&& TREE_CODE (containing_scope
) == FUNCTION_TYPE
)
9225 containing_scope
= NULL_TREE
;
9227 if (containing_scope
== NULL_TREE
)
9228 scope_die
= comp_unit_die
;
9229 else if (TYPE_P (containing_scope
))
9231 /* For types, we can just look up the appropriate DIE. But
9232 first we check to see if we're in the middle of emitting it
9233 so we know where the new DIE should go. */
9235 for (i
= decl_scope_depth
- 1; i
>= 0; --i
)
9236 if (decl_scope_table
[i
] == containing_scope
)
9241 if (debug_info_level
> DINFO_LEVEL_TERSE
9242 && !TREE_ASM_WRITTEN (containing_scope
))
9245 /* If none of the current dies are suitable, we get file scope. */
9246 scope_die
= comp_unit_die
;
9249 scope_die
= lookup_type_die (containing_scope
);
9252 scope_die
= context_die
;
9257 /* Returns nonzero iff CONTEXT_DIE is internal to a function. */
9259 static inline int local_scope_p
PARAMS ((dw_die_ref
));
9261 local_scope_p (context_die
)
9262 dw_die_ref context_die
;
9264 for (; context_die
; context_die
= context_die
->die_parent
)
9265 if (context_die
->die_tag
== DW_TAG_inlined_subroutine
9266 || context_die
->die_tag
== DW_TAG_subprogram
)
9271 /* Returns nonzero iff CONTEXT_DIE is a class. */
9273 static inline int class_scope_p
PARAMS ((dw_die_ref
));
9275 class_scope_p (context_die
)
9276 dw_die_ref context_die
;
9279 && (context_die
->die_tag
== DW_TAG_structure_type
9280 || context_die
->die_tag
== DW_TAG_union_type
));
9283 /* Many forms of DIEs require a "type description" attribute. This
9284 routine locates the proper "type descriptor" die for the type given
9285 by 'type', and adds an DW_AT_type attribute below the given die. */
9288 add_type_attribute (object_die
, type
, decl_const
, decl_volatile
, context_die
)
9289 register dw_die_ref object_die
;
9291 register int decl_const
;
9292 register int decl_volatile
;
9293 register dw_die_ref context_die
;
9295 register enum tree_code code
= TREE_CODE (type
);
9296 register dw_die_ref type_die
= NULL
;
9298 /* ??? If this type is an unnamed subrange type of an integral or
9299 floating-point type, use the inner type. This is because we have no
9300 support for unnamed types in base_type_die. This can happen if this is
9301 an Ada subrange type. Correct solution is emit a subrange type die. */
9302 if ((code
== INTEGER_TYPE
|| code
== REAL_TYPE
)
9303 && TREE_TYPE (type
) != 0 && TYPE_NAME (type
) == 0)
9304 type
= TREE_TYPE (type
), code
= TREE_CODE (type
);
9306 if (code
== ERROR_MARK
)
9309 /* Handle a special case. For functions whose return type is void, we
9310 generate *no* type attribute. (Note that no object may have type
9311 `void', so this only applies to function return types). */
9312 if (code
== VOID_TYPE
)
9315 type_die
= modified_type_die (type
,
9316 decl_const
|| TYPE_READONLY (type
),
9317 decl_volatile
|| TYPE_VOLATILE (type
),
9319 if (type_die
!= NULL
)
9320 add_AT_die_ref (object_die
, DW_AT_type
, type_die
);
9323 /* Given a tree pointer to a struct, class, union, or enum type node, return
9324 a pointer to the (string) tag name for the given type, or zero if the type
9325 was declared without a tag. */
9331 register const char *name
= 0;
9333 if (TYPE_NAME (type
) != 0)
9335 register tree t
= 0;
9337 /* Find the IDENTIFIER_NODE for the type name. */
9338 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
9339 t
= TYPE_NAME (type
);
9341 /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
9342 a TYPE_DECL node, regardless of whether or not a `typedef' was
9344 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
9345 && ! DECL_IGNORED_P (TYPE_NAME (type
)))
9346 t
= DECL_NAME (TYPE_NAME (type
));
9348 /* Now get the name as a string, or invent one. */
9350 name
= IDENTIFIER_POINTER (t
);
9353 return (name
== 0 || *name
== '\0') ? 0 : name
;
9356 /* Return the type associated with a data member, make a special check
9357 for bit field types. */
9360 member_declared_type (member
)
9361 register tree member
;
9363 return (DECL_BIT_FIELD_TYPE (member
)
9364 ? DECL_BIT_FIELD_TYPE (member
)
9365 : TREE_TYPE (member
));
9368 /* Get the decl's label, as described by its RTL. This may be different
9369 from the DECL_NAME name used in the source file. */
9373 decl_start_label (decl
)
9378 x
= DECL_RTL (decl
);
9379 if (GET_CODE (x
) != MEM
)
9383 if (GET_CODE (x
) != SYMBOL_REF
)
9386 fnname
= XSTR (x
, 0);
9391 /* These routines generate the internal representation of the DIE's for
9392 the compilation unit. Debugging information is collected by walking
9393 the declaration trees passed in from dwarf2out_decl(). */
9396 gen_array_type_die (type
, context_die
)
9398 register dw_die_ref context_die
;
9400 register dw_die_ref scope_die
= scope_die_for (type
, context_die
);
9401 register dw_die_ref array_die
;
9402 register tree element_type
;
9404 /* ??? The SGI dwarf reader fails for array of array of enum types unless
9405 the inner array type comes before the outer array type. Thus we must
9406 call gen_type_die before we call new_die. See below also. */
9407 #ifdef MIPS_DEBUGGING_INFO
9408 gen_type_die (TREE_TYPE (type
), context_die
);
9411 array_die
= new_die (DW_TAG_array_type
, scope_die
);
9414 /* We default the array ordering. SDB will probably do
9415 the right things even if DW_AT_ordering is not present. It's not even
9416 an issue until we start to get into multidimensional arrays anyway. If
9417 SDB is ever caught doing the Wrong Thing for multi-dimensional arrays,
9418 then we'll have to put the DW_AT_ordering attribute back in. (But if
9419 and when we find out that we need to put these in, we will only do so
9420 for multidimensional arrays. */
9421 add_AT_unsigned (array_die
, DW_AT_ordering
, DW_ORD_row_major
);
9424 #ifdef MIPS_DEBUGGING_INFO
9425 /* The SGI compilers handle arrays of unknown bound by setting
9426 AT_declaration and not emitting any subrange DIEs. */
9427 if (! TYPE_DOMAIN (type
))
9428 add_AT_unsigned (array_die
, DW_AT_declaration
, 1);
9431 add_subscript_info (array_die
, type
);
9433 add_name_attribute (array_die
, type_tag (type
));
9434 equate_type_number_to_die (type
, array_die
);
9436 /* Add representation of the type of the elements of this array type. */
9437 element_type
= TREE_TYPE (type
);
9439 /* ??? The SGI dwarf reader fails for multidimensional arrays with a
9440 const enum type. E.g. const enum machine_mode insn_operand_mode[2][10].
9441 We work around this by disabling this feature. See also
9442 add_subscript_info. */
9443 #ifndef MIPS_DEBUGGING_INFO
9444 while (TREE_CODE (element_type
) == ARRAY_TYPE
)
9445 element_type
= TREE_TYPE (element_type
);
9447 gen_type_die (element_type
, context_die
);
9450 add_type_attribute (array_die
, element_type
, 0, 0, context_die
);
9454 gen_set_type_die (type
, context_die
)
9456 register dw_die_ref context_die
;
9458 register dw_die_ref type_die
9459 = new_die (DW_TAG_set_type
, scope_die_for (type
, context_die
));
9461 equate_type_number_to_die (type
, type_die
);
9462 add_type_attribute (type_die
, TREE_TYPE (type
), 0, 0, context_die
);
9467 gen_entry_point_die (decl
, context_die
)
9469 register dw_die_ref context_die
;
9471 register tree origin
= decl_ultimate_origin (decl
);
9472 register dw_die_ref decl_die
= new_die (DW_TAG_entry_point
, context_die
);
9474 add_abstract_origin_attribute (decl_die
, origin
);
9477 add_name_and_src_coords_attributes (decl_die
, decl
);
9478 add_type_attribute (decl_die
, TREE_TYPE (TREE_TYPE (decl
)),
9482 if (DECL_ABSTRACT (decl
))
9483 equate_decl_number_to_die (decl
, decl_die
);
9485 add_AT_lbl_id (decl_die
, DW_AT_low_pc
, decl_start_label (decl
));
9489 /* Remember a type in the incomplete_types_list. */
9492 add_incomplete_type (type
)
9495 if (incomplete_types
== incomplete_types_allocated
)
9497 incomplete_types_allocated
+= INCOMPLETE_TYPES_INCREMENT
;
9498 incomplete_types_list
9499 = (tree
*) xrealloc (incomplete_types_list
,
9500 sizeof (tree
) * incomplete_types_allocated
);
9503 incomplete_types_list
[incomplete_types
++] = type
;
9506 /* Walk through the list of incomplete types again, trying once more to
9507 emit full debugging info for them. */
9510 retry_incomplete_types ()
9514 while (incomplete_types
)
9517 type
= incomplete_types_list
[incomplete_types
];
9518 gen_type_die (type
, comp_unit_die
);
9522 /* Generate a DIE to represent an inlined instance of an enumeration type. */
9525 gen_inlined_enumeration_type_die (type
, context_die
)
9527 register dw_die_ref context_die
;
9529 register dw_die_ref type_die
= new_die (DW_TAG_enumeration_type
,
9531 /* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
9532 be incomplete and such types are not marked. */
9533 add_abstract_origin_attribute (type_die
, type
);
9536 /* Generate a DIE to represent an inlined instance of a structure type. */
9539 gen_inlined_structure_type_die (type
, context_die
)
9541 register dw_die_ref context_die
;
9543 register dw_die_ref type_die
= new_die (DW_TAG_structure_type
, context_die
);
9545 /* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
9546 be incomplete and such types are not marked. */
9547 add_abstract_origin_attribute (type_die
, type
);
9550 /* Generate a DIE to represent an inlined instance of a union type. */
9553 gen_inlined_union_type_die (type
, context_die
)
9555 register dw_die_ref context_die
;
9557 register dw_die_ref type_die
= new_die (DW_TAG_union_type
, context_die
);
9559 /* We do not check for TREE_ASM_WRITTEN (type) being set, as the type may
9560 be incomplete and such types are not marked. */
9561 add_abstract_origin_attribute (type_die
, type
);
9564 /* Generate a DIE to represent an enumeration type. Note that these DIEs
9565 include all of the information about the enumeration values also. Each
9566 enumerated type name/value is listed as a child of the enumerated type
9570 gen_enumeration_type_die (type
, context_die
)
9572 register dw_die_ref context_die
;
9574 register dw_die_ref type_die
= lookup_type_die (type
);
9576 if (type_die
== NULL
)
9578 type_die
= new_die (DW_TAG_enumeration_type
,
9579 scope_die_for (type
, context_die
));
9580 equate_type_number_to_die (type
, type_die
);
9581 add_name_attribute (type_die
, type_tag (type
));
9583 else if (! TYPE_SIZE (type
))
9586 remove_AT (type_die
, DW_AT_declaration
);
9588 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
9589 given enum type is incomplete, do not generate the DW_AT_byte_size
9590 attribute or the DW_AT_element_list attribute. */
9591 if (TYPE_SIZE (type
))
9595 TREE_ASM_WRITTEN (type
) = 1;
9596 add_byte_size_attribute (type_die
, type
);
9597 if (TYPE_STUB_DECL (type
) != NULL_TREE
)
9598 add_src_coords_attributes (type_die
, TYPE_STUB_DECL (type
));
9600 /* If the first reference to this type was as the return type of an
9601 inline function, then it may not have a parent. Fix this now. */
9602 if (type_die
->die_parent
== NULL
)
9603 add_child_die (scope_die_for (type
, context_die
), type_die
);
9605 for (link
= TYPE_FIELDS (type
);
9606 link
!= NULL
; link
= TREE_CHAIN (link
))
9608 register dw_die_ref enum_die
= new_die (DW_TAG_enumerator
, type_die
);
9610 add_name_attribute (enum_die
,
9611 IDENTIFIER_POINTER (TREE_PURPOSE (link
)));
9613 if (host_integerp (TREE_VALUE (link
), 0))
9615 if (tree_int_cst_sgn (TREE_VALUE (link
)) < 0)
9616 add_AT_int (enum_die
, DW_AT_const_value
,
9617 tree_low_cst (TREE_VALUE (link
), 0));
9619 add_AT_unsigned (enum_die
, DW_AT_const_value
,
9620 tree_low_cst (TREE_VALUE (link
), 0));
9625 add_AT_flag (type_die
, DW_AT_declaration
, 1);
9628 /* Generate a DIE to represent either a real live formal parameter decl or to
9629 represent just the type of some formal parameter position in some function
9632 Note that this routine is a bit unusual because its argument may be a
9633 ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
9634 represents an inlining of some PARM_DECL) or else some sort of a ..._TYPE
9635 node. If it's the former then this function is being called to output a
9636 DIE to represent a formal parameter object (or some inlining thereof). If
9637 it's the latter, then this function is only being called to output a
9638 DW_TAG_formal_parameter DIE to stand as a placeholder for some formal
9639 argument type of some subprogram type. */
9642 gen_formal_parameter_die (node
, context_die
)
9644 register dw_die_ref context_die
;
9646 register dw_die_ref parm_die
9647 = new_die (DW_TAG_formal_parameter
, context_die
);
9648 register tree origin
;
9650 switch (TREE_CODE_CLASS (TREE_CODE (node
)))
9653 origin
= decl_ultimate_origin (node
);
9655 add_abstract_origin_attribute (parm_die
, origin
);
9658 add_name_and_src_coords_attributes (parm_die
, node
);
9659 add_type_attribute (parm_die
, TREE_TYPE (node
),
9660 TREE_READONLY (node
),
9661 TREE_THIS_VOLATILE (node
),
9663 if (DECL_ARTIFICIAL (node
))
9664 add_AT_flag (parm_die
, DW_AT_artificial
, 1);
9667 equate_decl_number_to_die (node
, parm_die
);
9668 if (! DECL_ABSTRACT (node
))
9669 add_location_or_const_value_attribute (parm_die
, node
);
9674 /* We were called with some kind of a ..._TYPE node. */
9675 add_type_attribute (parm_die
, node
, 0, 0, context_die
);
9685 /* Generate a special type of DIE used as a stand-in for a trailing ellipsis
9686 at the end of an (ANSI prototyped) formal parameters list. */
9689 gen_unspecified_parameters_die (decl_or_type
, context_die
)
9690 register tree decl_or_type ATTRIBUTE_UNUSED
;
9691 register dw_die_ref context_die
;
9693 new_die (DW_TAG_unspecified_parameters
, context_die
);
9696 /* Generate a list of nameless DW_TAG_formal_parameter DIEs (and perhaps a
9697 DW_TAG_unspecified_parameters DIE) to represent the types of the formal
9698 parameters as specified in some function type specification (except for
9699 those which appear as part of a function *definition*). */
9702 gen_formal_types_die (function_or_method_type
, context_die
)
9703 register tree function_or_method_type
;
9704 register dw_die_ref context_die
;
9707 register tree formal_type
= NULL
;
9708 register tree first_parm_type
;
9711 if (TREE_CODE (function_or_method_type
) == FUNCTION_DECL
)
9713 arg
= DECL_ARGUMENTS (function_or_method_type
);
9714 function_or_method_type
= TREE_TYPE (function_or_method_type
);
9719 first_parm_type
= TYPE_ARG_TYPES (function_or_method_type
);
9721 /* Make our first pass over the list of formal parameter types and output a
9722 DW_TAG_formal_parameter DIE for each one. */
9723 for (link
= first_parm_type
; link
; )
9725 register dw_die_ref parm_die
;
9727 formal_type
= TREE_VALUE (link
);
9728 if (formal_type
== void_type_node
)
9731 /* Output a (nameless) DIE to represent the formal parameter itself. */
9732 parm_die
= gen_formal_parameter_die (formal_type
, context_die
);
9733 if ((TREE_CODE (function_or_method_type
) == METHOD_TYPE
9734 && link
== first_parm_type
)
9735 || (arg
&& DECL_ARTIFICIAL (arg
)))
9736 add_AT_flag (parm_die
, DW_AT_artificial
, 1);
9738 link
= TREE_CHAIN (link
);
9740 arg
= TREE_CHAIN (arg
);
9743 /* If this function type has an ellipsis, add a
9744 DW_TAG_unspecified_parameters DIE to the end of the parameter list. */
9745 if (formal_type
!= void_type_node
)
9746 gen_unspecified_parameters_die (function_or_method_type
, context_die
);
9748 /* Make our second (and final) pass over the list of formal parameter types
9749 and output DIEs to represent those types (as necessary). */
9750 for (link
= TYPE_ARG_TYPES (function_or_method_type
);
9752 link
= TREE_CHAIN (link
))
9754 formal_type
= TREE_VALUE (link
);
9755 if (formal_type
== void_type_node
)
9758 gen_type_die (formal_type
, context_die
);
9762 /* We want to generate the DIE for TYPE so that we can generate the
9763 die for MEMBER, which has been defined; we will need to refer back
9764 to the member declaration nested within TYPE. If we're trying to
9765 generate minimal debug info for TYPE, processing TYPE won't do the
9766 trick; we need to attach the member declaration by hand. */
9769 gen_type_die_for_member (type
, member
, context_die
)
9771 dw_die_ref context_die
;
9773 gen_type_die (type
, context_die
);
9775 /* If we're trying to avoid duplicate debug info, we may not have
9776 emitted the member decl for this function. Emit it now. */
9777 if (TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type
))
9778 && ! lookup_decl_die (member
))
9780 if (decl_ultimate_origin (member
))
9783 push_decl_scope (type
);
9784 if (TREE_CODE (member
) == FUNCTION_DECL
)
9785 gen_subprogram_die (member
, lookup_type_die (type
));
9787 gen_variable_die (member
, lookup_type_die (type
));
9792 /* Generate the DWARF2 info for the "abstract" instance
9793 of a function which we may later generate inlined and/or
9794 out-of-line instances of. */
9797 dwarf2out_abstract_function (decl
)
9800 register dw_die_ref old_die
;
9803 int was_abstract
= DECL_ABSTRACT (decl
);
9805 /* Make sure we have the actual abstract inline, not a clone. */
9806 decl
= DECL_ORIGIN (decl
);
9808 old_die
= lookup_decl_die (decl
);
9809 if (old_die
&& get_AT_unsigned (old_die
, DW_AT_inline
))
9810 /* We've already generated the abstract instance. */
9813 /* Be sure we've emitted the in-class declaration DIE (if any) first, so
9814 we don't get confused by DECL_ABSTRACT. */
9815 if (debug_info_level
> DINFO_LEVEL_TERSE
)
9817 context
= decl_class_context (decl
);
9819 gen_type_die_for_member
9820 (context
, decl
, decl_function_context (decl
) ? NULL
: comp_unit_die
);
9823 /* Pretend we've just finished compiling this function. */
9824 save_fn
= current_function_decl
;
9825 current_function_decl
= decl
;
9827 set_decl_abstract_flags (decl
, 1);
9828 dwarf2out_decl (decl
);
9830 set_decl_abstract_flags (decl
, 0);
9832 current_function_decl
= save_fn
;
9835 /* Generate a DIE to represent a declared function (either file-scope or
9839 gen_subprogram_die (decl
, context_die
)
9841 register dw_die_ref context_die
;
9843 char label_id
[MAX_ARTIFICIAL_LABEL_BYTES
];
9844 register tree origin
= decl_ultimate_origin (decl
);
9845 register dw_die_ref subr_die
;
9846 register rtx fp_reg
;
9847 register tree fn_arg_types
;
9848 register tree outer_scope
;
9849 register dw_die_ref old_die
= lookup_decl_die (decl
);
9850 register int declaration
= (current_function_decl
!= decl
9851 || class_scope_p (context_die
));
9853 /* Note that it is possible to have both DECL_ABSTRACT and `declaration'
9854 be true, if we started to generate the abstract instance of an inline,
9855 decided to output its containing class, and proceeded to emit the
9856 declaration of the inline from the member list for the class. In that
9857 case, `declaration' takes priority; we'll get back to the abstract
9858 instance when we're done with the class. */
9860 /* The class-scope declaration DIE must be the primary DIE. */
9861 if (origin
&& declaration
&& class_scope_p (context_die
))
9870 if (declaration
&& ! local_scope_p (context_die
))
9873 /* Fixup die_parent for the abstract instance of a nested
9875 if (old_die
&& old_die
->die_parent
== NULL
)
9876 add_child_die (context_die
, old_die
);
9878 subr_die
= new_die (DW_TAG_subprogram
, context_die
);
9879 add_abstract_origin_attribute (subr_die
, origin
);
9883 unsigned file_index
= lookup_filename (DECL_SOURCE_FILE (decl
));
9885 if (!get_AT_flag (old_die
, DW_AT_declaration
)
9886 /* We can have a normal definition following an inline one in the
9887 case of redefinition of GNU C extern inlines.
9888 It seems reasonable to use AT_specification in this case. */
9889 && !get_AT_unsigned (old_die
, DW_AT_inline
))
9891 /* ??? This can happen if there is a bug in the program, for
9892 instance, if it has duplicate function definitions. Ideally,
9893 we should detect this case and ignore it. For now, if we have
9894 already reported an error, any error at all, then assume that
9895 we got here because of a input error, not a dwarf2 bug. */
9901 /* If the definition comes from the same place as the declaration,
9902 maybe use the old DIE. We always want the DIE for this function
9903 that has the *_pc attributes to be under comp_unit_die so the
9904 debugger can find it. We also need to do this for abstract
9905 instances of inlines, since the spec requires the out-of-line copy
9906 to have the same parent. For local class methods, this doesn't
9907 apply; we just use the old DIE. */
9908 if ((old_die
->die_parent
== comp_unit_die
|| context_die
== NULL
)
9909 && (DECL_ARTIFICIAL (decl
)
9910 || (get_AT_unsigned (old_die
, DW_AT_decl_file
) == file_index
9911 && (get_AT_unsigned (old_die
, DW_AT_decl_line
)
9912 == (unsigned) DECL_SOURCE_LINE (decl
)))))
9916 /* Clear out the declaration attribute and the parm types. */
9917 remove_AT (subr_die
, DW_AT_declaration
);
9918 remove_children (subr_die
);
9922 subr_die
= new_die (DW_TAG_subprogram
, context_die
);
9923 add_AT_die_ref (subr_die
, DW_AT_specification
, old_die
);
9924 if (get_AT_unsigned (old_die
, DW_AT_decl_file
) != file_index
)
9925 add_AT_unsigned (subr_die
, DW_AT_decl_file
, file_index
);
9926 if (get_AT_unsigned (old_die
, DW_AT_decl_line
)
9927 != (unsigned) DECL_SOURCE_LINE (decl
))
9929 (subr_die
, DW_AT_decl_line
, DECL_SOURCE_LINE (decl
));
9934 subr_die
= new_die (DW_TAG_subprogram
, context_die
);
9936 if (TREE_PUBLIC (decl
))
9937 add_AT_flag (subr_die
, DW_AT_external
, 1);
9939 add_name_and_src_coords_attributes (subr_die
, decl
);
9940 if (debug_info_level
> DINFO_LEVEL_TERSE
)
9942 register tree type
= TREE_TYPE (decl
);
9944 add_prototyped_attribute (subr_die
, type
);
9945 add_type_attribute (subr_die
, TREE_TYPE (type
), 0, 0, context_die
);
9948 add_pure_or_virtual_attribute (subr_die
, decl
);
9949 if (DECL_ARTIFICIAL (decl
))
9950 add_AT_flag (subr_die
, DW_AT_artificial
, 1);
9951 if (TREE_PROTECTED (decl
))
9952 add_AT_unsigned (subr_die
, DW_AT_accessibility
, DW_ACCESS_protected
);
9953 else if (TREE_PRIVATE (decl
))
9954 add_AT_unsigned (subr_die
, DW_AT_accessibility
, DW_ACCESS_private
);
9959 if (!(old_die
&& get_AT_unsigned (old_die
, DW_AT_inline
)))
9961 add_AT_flag (subr_die
, DW_AT_declaration
, 1);
9963 /* The first time we see a member function, it is in the context of
9964 the class to which it belongs. We make sure of this by emitting
9965 the class first. The next time is the definition, which is
9966 handled above. The two may come from the same source text. */
9967 if (DECL_CONTEXT (decl
) || DECL_ABSTRACT (decl
))
9968 equate_decl_number_to_die (decl
, subr_die
);
9971 else if (DECL_ABSTRACT (decl
))
9973 if (DECL_INLINE (decl
) && !flag_no_inline
)
9975 /* ??? Checking DECL_DEFER_OUTPUT is correct for static
9976 inline functions, but not for extern inline functions.
9977 We can't get this completely correct because information
9978 about whether the function was declared inline is not
9980 if (DECL_DEFER_OUTPUT (decl
))
9981 add_AT_unsigned (subr_die
, DW_AT_inline
, DW_INL_declared_inlined
);
9983 add_AT_unsigned (subr_die
, DW_AT_inline
, DW_INL_inlined
);
9986 add_AT_unsigned (subr_die
, DW_AT_inline
, DW_INL_declared_not_inlined
);
9988 equate_decl_number_to_die (decl
, subr_die
);
9990 else if (!DECL_EXTERNAL (decl
))
9992 if (!(old_die
&& get_AT_unsigned (old_die
, DW_AT_inline
)))
9993 equate_decl_number_to_die (decl
, subr_die
);
9995 ASM_GENERATE_INTERNAL_LABEL (label_id
, FUNC_BEGIN_LABEL
,
9996 current_funcdef_number
);
9997 add_AT_lbl_id (subr_die
, DW_AT_low_pc
, label_id
);
9998 ASM_GENERATE_INTERNAL_LABEL (label_id
, FUNC_END_LABEL
,
9999 current_funcdef_number
);
10000 add_AT_lbl_id (subr_die
, DW_AT_high_pc
, label_id
);
10002 add_pubname (decl
, subr_die
);
10003 add_arange (decl
, subr_die
);
10005 #ifdef MIPS_DEBUGGING_INFO
10006 /* Add a reference to the FDE for this routine. */
10007 add_AT_fde_ref (subr_die
, DW_AT_MIPS_fde
, current_funcdef_fde
);
10010 /* Define the "frame base" location for this routine. We use the
10011 frame pointer or stack pointer registers, since the RTL for local
10012 variables is relative to one of them. */
10014 = frame_pointer_needed
? hard_frame_pointer_rtx
: stack_pointer_rtx
;
10015 add_AT_loc (subr_die
, DW_AT_frame_base
, reg_loc_descriptor (fp_reg
));
10018 /* ??? This fails for nested inline functions, because context_display
10019 is not part of the state saved/restored for inline functions. */
10020 if (current_function_needs_context
)
10021 add_AT_location_description (subr_die
, DW_AT_static_link
,
10022 lookup_static_chain (decl
));
10026 /* Now output descriptions of the arguments for this function. This gets
10027 (unnecessarily?) complex because of the fact that the DECL_ARGUMENT list
10028 for a FUNCTION_DECL doesn't indicate cases where there was a trailing
10029 `...' at the end of the formal parameter list. In order to find out if
10030 there was a trailing ellipsis or not, we must instead look at the type
10031 associated with the FUNCTION_DECL. This will be a node of type
10032 FUNCTION_TYPE. If the chain of type nodes hanging off of this
10033 FUNCTION_TYPE node ends with a void_type_node then there should *not* be
10034 an ellipsis at the end. */
10036 /* In the case where we are describing a mere function declaration, all we
10037 need to do here (and all we *can* do here) is to describe the *types* of
10038 its formal parameters. */
10039 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
10041 else if (declaration
)
10042 gen_formal_types_die (decl
, subr_die
);
10045 /* Generate DIEs to represent all known formal parameters */
10046 register tree arg_decls
= DECL_ARGUMENTS (decl
);
10047 register tree parm
;
10049 /* When generating DIEs, generate the unspecified_parameters DIE
10050 instead if we come across the arg "__builtin_va_alist" */
10051 for (parm
= arg_decls
; parm
; parm
= TREE_CHAIN (parm
))
10052 if (TREE_CODE (parm
) == PARM_DECL
)
10054 if (DECL_NAME (parm
)
10055 && !strcmp (IDENTIFIER_POINTER (DECL_NAME (parm
)),
10056 "__builtin_va_alist"))
10057 gen_unspecified_parameters_die (parm
, subr_die
);
10059 gen_decl_die (parm
, subr_die
);
10062 /* Decide whether we need a unspecified_parameters DIE at the end.
10063 There are 2 more cases to do this for: 1) the ansi ... declaration -
10064 this is detectable when the end of the arg list is not a
10065 void_type_node 2) an unprototyped function declaration (not a
10066 definition). This just means that we have no info about the
10067 parameters at all. */
10068 fn_arg_types
= TYPE_ARG_TYPES (TREE_TYPE (decl
));
10069 if (fn_arg_types
!= NULL
)
10071 /* this is the prototyped case, check for ... */
10072 if (TREE_VALUE (tree_last (fn_arg_types
)) != void_type_node
)
10073 gen_unspecified_parameters_die (decl
, subr_die
);
10075 else if (DECL_INITIAL (decl
) == NULL_TREE
)
10076 gen_unspecified_parameters_die (decl
, subr_die
);
10079 /* Output Dwarf info for all of the stuff within the body of the function
10080 (if it has one - it may be just a declaration). */
10081 outer_scope
= DECL_INITIAL (decl
);
10083 /* Note that here, `outer_scope' is a pointer to the outermost BLOCK
10084 node created to represent a function. This outermost BLOCK actually
10085 represents the outermost binding contour for the function, i.e. the
10086 contour in which the function's formal parameters and labels get
10087 declared. Curiously, it appears that the front end doesn't actually
10088 put the PARM_DECL nodes for the current function onto the BLOCK_VARS
10089 list for this outer scope. (They are strung off of the DECL_ARGUMENTS
10090 list for the function instead.) The BLOCK_VARS list for the
10091 `outer_scope' does provide us with a list of the LABEL_DECL nodes for
10092 the function however, and we output DWARF info for those in
10093 decls_for_scope. Just within the `outer_scope' there will be a BLOCK
10094 node representing the function's outermost pair of curly braces, and
10095 any blocks used for the base and member initializers of a C++
10096 constructor function. */
10097 if (! declaration
&& TREE_CODE (outer_scope
) != ERROR_MARK
)
10099 current_function_has_inlines
= 0;
10100 decls_for_scope (outer_scope
, subr_die
, 0);
10102 #if 0 && defined (MIPS_DEBUGGING_INFO)
10103 if (current_function_has_inlines
)
10105 add_AT_flag (subr_die
, DW_AT_MIPS_has_inlines
, 1);
10106 if (! comp_unit_has_inlines
)
10108 add_AT_flag (comp_unit_die
, DW_AT_MIPS_has_inlines
, 1);
10109 comp_unit_has_inlines
= 1;
10116 /* Generate a DIE to represent a declared data object. */
10119 gen_variable_die (decl
, context_die
)
10120 register tree decl
;
10121 register dw_die_ref context_die
;
10123 register tree origin
= decl_ultimate_origin (decl
);
10124 register dw_die_ref var_die
= new_die (DW_TAG_variable
, context_die
);
10126 dw_die_ref old_die
= lookup_decl_die (decl
);
10127 int declaration
= (DECL_EXTERNAL (decl
)
10128 || class_scope_p (context_die
));
10130 if (origin
!= NULL
)
10131 add_abstract_origin_attribute (var_die
, origin
);
10132 /* Loop unrolling can create multiple blocks that refer to the same
10133 static variable, so we must test for the DW_AT_declaration flag. */
10134 /* ??? Loop unrolling/reorder_blocks should perhaps be rewritten to
10135 copy decls and set the DECL_ABSTRACT flag on them instead of
10137 /* ??? Duplicated blocks have been rewritten to use .debug_ranges. */
10138 else if (old_die
&& TREE_STATIC (decl
)
10139 && get_AT_flag (old_die
, DW_AT_declaration
) == 1)
10141 /* This is a definition of a C++ class level static. */
10142 add_AT_die_ref (var_die
, DW_AT_specification
, old_die
);
10143 if (DECL_NAME (decl
))
10145 unsigned file_index
= lookup_filename (DECL_SOURCE_FILE (decl
));
10147 if (get_AT_unsigned (old_die
, DW_AT_decl_file
) != file_index
)
10148 add_AT_unsigned (var_die
, DW_AT_decl_file
, file_index
);
10150 if (get_AT_unsigned (old_die
, DW_AT_decl_line
)
10151 != (unsigned) DECL_SOURCE_LINE (decl
))
10153 add_AT_unsigned (var_die
, DW_AT_decl_line
,
10154 DECL_SOURCE_LINE (decl
));
10159 add_name_and_src_coords_attributes (var_die
, decl
);
10160 add_type_attribute (var_die
, TREE_TYPE (decl
),
10161 TREE_READONLY (decl
),
10162 TREE_THIS_VOLATILE (decl
), context_die
);
10164 if (TREE_PUBLIC (decl
))
10165 add_AT_flag (var_die
, DW_AT_external
, 1);
10167 if (DECL_ARTIFICIAL (decl
))
10168 add_AT_flag (var_die
, DW_AT_artificial
, 1);
10170 if (TREE_PROTECTED (decl
))
10171 add_AT_unsigned (var_die
, DW_AT_accessibility
, DW_ACCESS_protected
);
10173 else if (TREE_PRIVATE (decl
))
10174 add_AT_unsigned (var_die
, DW_AT_accessibility
, DW_ACCESS_private
);
10178 add_AT_flag (var_die
, DW_AT_declaration
, 1);
10180 if (class_scope_p (context_die
) || DECL_ABSTRACT (decl
))
10181 equate_decl_number_to_die (decl
, var_die
);
10183 if (! declaration
&& ! DECL_ABSTRACT (decl
))
10185 add_location_or_const_value_attribute (var_die
, decl
);
10186 add_pubname (decl
, var_die
);
10189 tree_add_const_value_attribute (var_die
, decl
);
10192 /* Generate a DIE to represent a label identifier. */
10195 gen_label_die (decl
, context_die
)
10196 register tree decl
;
10197 register dw_die_ref context_die
;
10199 register tree origin
= decl_ultimate_origin (decl
);
10200 register dw_die_ref lbl_die
= new_die (DW_TAG_label
, context_die
);
10202 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
10204 if (origin
!= NULL
)
10205 add_abstract_origin_attribute (lbl_die
, origin
);
10207 add_name_and_src_coords_attributes (lbl_die
, decl
);
10209 if (DECL_ABSTRACT (decl
))
10210 equate_decl_number_to_die (decl
, lbl_die
);
10213 insn
= DECL_RTL (decl
);
10215 /* Deleted labels are programmer specified labels which have been
10216 eliminated because of various optimisations. We still emit them
10217 here so that it is possible to put breakpoints on them. */
10218 if (GET_CODE (insn
) == CODE_LABEL
10219 || ((GET_CODE (insn
) == NOTE
10220 && NOTE_LINE_NUMBER (insn
) == NOTE_INSN_DELETED_LABEL
)))
10222 /* When optimization is enabled (via -O) some parts of the compiler
10223 (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
10224 represent source-level labels which were explicitly declared by
10225 the user. This really shouldn't be happening though, so catch
10226 it if it ever does happen. */
10227 if (INSN_DELETED_P (insn
))
10230 ASM_GENERATE_INTERNAL_LABEL (label
, "L", CODE_LABEL_NUMBER (insn
));
10231 add_AT_lbl_id (lbl_die
, DW_AT_low_pc
, label
);
10236 /* Generate a DIE for a lexical block. */
10239 gen_lexical_block_die (stmt
, context_die
, depth
)
10240 register tree stmt
;
10241 register dw_die_ref context_die
;
10244 register dw_die_ref stmt_die
= new_die (DW_TAG_lexical_block
, context_die
);
10245 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
10247 if (! BLOCK_ABSTRACT (stmt
))
10249 if (BLOCK_FRAGMENT_CHAIN (stmt
))
10253 add_AT_offset (stmt_die
, DW_AT_ranges
, add_ranges (stmt
));
10255 chain
= BLOCK_FRAGMENT_CHAIN (stmt
);
10258 add_ranges (chain
);
10259 chain
= BLOCK_FRAGMENT_CHAIN (chain
);
10266 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_BEGIN_LABEL
,
10267 BLOCK_NUMBER (stmt
));
10268 add_AT_lbl_id (stmt_die
, DW_AT_low_pc
, label
);
10269 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_END_LABEL
,
10270 BLOCK_NUMBER (stmt
));
10271 add_AT_lbl_id (stmt_die
, DW_AT_high_pc
, label
);
10275 decls_for_scope (stmt
, stmt_die
, depth
);
10278 /* Generate a DIE for an inlined subprogram. */
10281 gen_inlined_subroutine_die (stmt
, context_die
, depth
)
10282 register tree stmt
;
10283 register dw_die_ref context_die
;
10286 if (! BLOCK_ABSTRACT (stmt
))
10288 register dw_die_ref subr_die
10289 = new_die (DW_TAG_inlined_subroutine
, context_die
);
10290 register tree decl
= block_ultimate_origin (stmt
);
10291 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
10293 /* Emit info for the abstract instance first, if we haven't yet. */
10294 dwarf2out_abstract_function (decl
);
10296 add_abstract_origin_attribute (subr_die
, decl
);
10297 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_BEGIN_LABEL
,
10298 BLOCK_NUMBER (stmt
));
10299 add_AT_lbl_id (subr_die
, DW_AT_low_pc
, label
);
10300 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_END_LABEL
,
10301 BLOCK_NUMBER (stmt
));
10302 add_AT_lbl_id (subr_die
, DW_AT_high_pc
, label
);
10303 decls_for_scope (stmt
, subr_die
, depth
);
10304 current_function_has_inlines
= 1;
10308 /* Generate a DIE for a field in a record, or structure. */
10311 gen_field_die (decl
, context_die
)
10312 register tree decl
;
10313 register dw_die_ref context_die
;
10315 register dw_die_ref decl_die
= new_die (DW_TAG_member
, context_die
);
10317 add_name_and_src_coords_attributes (decl_die
, decl
);
10318 add_type_attribute (decl_die
, member_declared_type (decl
),
10319 TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
),
10322 /* If this is a bit field... */
10323 if (DECL_BIT_FIELD_TYPE (decl
))
10325 add_byte_size_attribute (decl_die
, decl
);
10326 add_bit_size_attribute (decl_die
, decl
);
10327 add_bit_offset_attribute (decl_die
, decl
);
10330 if (TREE_CODE (DECL_FIELD_CONTEXT (decl
)) != UNION_TYPE
)
10331 add_data_member_location_attribute (decl_die
, decl
);
10333 if (DECL_ARTIFICIAL (decl
))
10334 add_AT_flag (decl_die
, DW_AT_artificial
, 1);
10336 if (TREE_PROTECTED (decl
))
10337 add_AT_unsigned (decl_die
, DW_AT_accessibility
, DW_ACCESS_protected
);
10339 else if (TREE_PRIVATE (decl
))
10340 add_AT_unsigned (decl_die
, DW_AT_accessibility
, DW_ACCESS_private
);
10344 /* Don't generate either pointer_type DIEs or reference_type DIEs here.
10345 Use modified_type_die instead.
10346 We keep this code here just in case these types of DIEs may be needed to
10347 represent certain things in other languages (e.g. Pascal) someday. */
10349 gen_pointer_type_die (type
, context_die
)
10350 register tree type
;
10351 register dw_die_ref context_die
;
10353 register dw_die_ref ptr_die
10354 = new_die (DW_TAG_pointer_type
, scope_die_for (type
, context_die
));
10356 equate_type_number_to_die (type
, ptr_die
);
10357 add_type_attribute (ptr_die
, TREE_TYPE (type
), 0, 0, context_die
);
10358 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
10361 /* Don't generate either pointer_type DIEs or reference_type DIEs here.
10362 Use modified_type_die instead.
10363 We keep this code here just in case these types of DIEs may be needed to
10364 represent certain things in other languages (e.g. Pascal) someday. */
10366 gen_reference_type_die (type
, context_die
)
10367 register tree type
;
10368 register dw_die_ref context_die
;
10370 register dw_die_ref ref_die
10371 = new_die (DW_TAG_reference_type
, scope_die_for (type
, context_die
));
10373 equate_type_number_to_die (type
, ref_die
);
10374 add_type_attribute (ref_die
, TREE_TYPE (type
), 0, 0, context_die
);
10375 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
10379 /* Generate a DIE for a pointer to a member type. */
10381 gen_ptr_to_mbr_type_die (type
, context_die
)
10382 register tree type
;
10383 register dw_die_ref context_die
;
10385 register dw_die_ref ptr_die
10386 = new_die (DW_TAG_ptr_to_member_type
, scope_die_for (type
, context_die
));
10388 equate_type_number_to_die (type
, ptr_die
);
10389 add_AT_die_ref (ptr_die
, DW_AT_containing_type
,
10390 lookup_type_die (TYPE_OFFSET_BASETYPE (type
)));
10391 add_type_attribute (ptr_die
, TREE_TYPE (type
), 0, 0, context_die
);
10394 /* Generate the DIE for the compilation unit. */
10397 gen_compile_unit_die (filename
)
10398 register const char *filename
;
10400 register dw_die_ref die
;
10401 char producer
[250];
10402 const char *wd
= getpwd ();
10405 die
= new_die (DW_TAG_compile_unit
, NULL
);
10406 add_name_attribute (die
, filename
);
10408 if (wd
!= NULL
&& filename
[0] != DIR_SEPARATOR
)
10409 add_AT_string (die
, DW_AT_comp_dir
, wd
);
10411 sprintf (producer
, "%s %s", language_string
, version_string
);
10413 #ifdef MIPS_DEBUGGING_INFO
10414 /* The MIPS/SGI compilers place the 'cc' command line options in the producer
10415 string. The SGI debugger looks for -g, -g1, -g2, or -g3; if they do
10416 not appear in the producer string, the debugger reaches the conclusion
10417 that the object file is stripped and has no debugging information.
10418 To get the MIPS/SGI debugger to believe that there is debugging
10419 information in the object file, we add a -g to the producer string. */
10420 if (debug_info_level
> DINFO_LEVEL_TERSE
)
10421 strcat (producer
, " -g");
10424 add_AT_string (die
, DW_AT_producer
, producer
);
10426 if (strcmp (language_string
, "GNU C++") == 0)
10427 language
= DW_LANG_C_plus_plus
;
10428 else if (strcmp (language_string
, "GNU Ada") == 0)
10429 language
= DW_LANG_Ada83
;
10430 else if (strcmp (language_string
, "GNU F77") == 0)
10431 language
= DW_LANG_Fortran77
;
10432 else if (strcmp (language_string
, "GNU Pascal") == 0)
10433 language
= DW_LANG_Pascal83
;
10434 else if (strcmp (language_string
, "GNU Java") == 0)
10435 language
= DW_LANG_Java
;
10436 else if (flag_traditional
)
10437 language
= DW_LANG_C
;
10439 language
= DW_LANG_C89
;
10441 add_AT_unsigned (die
, DW_AT_language
, language
);
10446 /* Generate a DIE for a string type. */
10449 gen_string_type_die (type
, context_die
)
10450 register tree type
;
10451 register dw_die_ref context_die
;
10453 register dw_die_ref type_die
10454 = new_die (DW_TAG_string_type
, scope_die_for (type
, context_die
));
10456 equate_type_number_to_die (type
, type_die
);
10458 /* Fudge the string length attribute for now. */
10460 /* TODO: add string length info.
10461 string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
10462 bound_representation (upper_bound, 0, 'u'); */
10465 /* Generate the DIE for a base class. */
10468 gen_inheritance_die (binfo
, context_die
)
10469 register tree binfo
;
10470 register dw_die_ref context_die
;
10472 dw_die_ref die
= new_die (DW_TAG_inheritance
, context_die
);
10474 add_type_attribute (die
, BINFO_TYPE (binfo
), 0, 0, context_die
);
10475 add_data_member_location_attribute (die
, binfo
);
10477 if (TREE_VIA_VIRTUAL (binfo
))
10478 add_AT_unsigned (die
, DW_AT_virtuality
, DW_VIRTUALITY_virtual
);
10479 if (TREE_VIA_PUBLIC (binfo
))
10480 add_AT_unsigned (die
, DW_AT_accessibility
, DW_ACCESS_public
);
10481 else if (TREE_VIA_PROTECTED (binfo
))
10482 add_AT_unsigned (die
, DW_AT_accessibility
, DW_ACCESS_protected
);
10485 /* Generate a DIE for a class member. */
10488 gen_member_die (type
, context_die
)
10489 register tree type
;
10490 register dw_die_ref context_die
;
10492 register tree member
;
10495 /* If this is not an incomplete type, output descriptions of each of its
10496 members. Note that as we output the DIEs necessary to represent the
10497 members of this record or union type, we will also be trying to output
10498 DIEs to represent the *types* of those members. However the `type'
10499 function (above) will specifically avoid generating type DIEs for member
10500 types *within* the list of member DIEs for this (containing) type execpt
10501 for those types (of members) which are explicitly marked as also being
10502 members of this (containing) type themselves. The g++ front- end can
10503 force any given type to be treated as a member of some other
10504 (containing) type by setting the TYPE_CONTEXT of the given (member) type
10505 to point to the TREE node representing the appropriate (containing)
10508 /* First output info about the base classes. */
10509 if (TYPE_BINFO (type
) && TYPE_BINFO_BASETYPES (type
))
10511 register tree bases
= TYPE_BINFO_BASETYPES (type
);
10512 register int n_bases
= TREE_VEC_LENGTH (bases
);
10515 for (i
= 0; i
< n_bases
; i
++)
10516 gen_inheritance_die (TREE_VEC_ELT (bases
, i
), context_die
);
10519 /* Now output info about the data members and type members. */
10520 for (member
= TYPE_FIELDS (type
); member
; member
= TREE_CHAIN (member
))
10522 /* If we thought we were generating minimal debug info for TYPE
10523 and then changed our minds, some of the member declarations
10524 may have already been defined. Don't define them again, but
10525 do put them in the right order. */
10527 child
= lookup_decl_die (member
);
10529 splice_child_die (context_die
, child
);
10531 gen_decl_die (member
, context_die
);
10534 /* Now output info about the function members (if any). */
10535 for (member
= TYPE_METHODS (type
); member
; member
= TREE_CHAIN (member
))
10537 /* Don't include clones in the member list. */
10538 if (DECL_ABSTRACT_ORIGIN (member
))
10541 child
= lookup_decl_die (member
);
10543 splice_child_die (context_die
, child
);
10545 gen_decl_die (member
, context_die
);
10549 /* Generate a DIE for a structure or union type. If TYPE_DECL_SUPPRESS_DEBUG
10550 is set, we pretend that the type was never defined, so we only get the
10551 member DIEs needed by later specification DIEs. */
10554 gen_struct_or_union_type_die (type
, context_die
)
10555 register tree type
;
10556 register dw_die_ref context_die
;
10558 register dw_die_ref type_die
= lookup_type_die (type
);
10559 register dw_die_ref scope_die
= 0;
10560 register int nested
= 0;
10561 int complete
= (TYPE_SIZE (type
)
10562 && (! TYPE_STUB_DECL (type
)
10563 || ! TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (type
))));
10565 if (type_die
&& ! complete
)
10568 if (TYPE_CONTEXT (type
) != NULL_TREE
10569 && AGGREGATE_TYPE_P (TYPE_CONTEXT (type
)))
10572 scope_die
= scope_die_for (type
, context_die
);
10574 if (! type_die
|| (nested
&& scope_die
== comp_unit_die
))
10575 /* First occurrence of type or toplevel definition of nested class. */
10577 register dw_die_ref old_die
= type_die
;
10579 type_die
= new_die (TREE_CODE (type
) == RECORD_TYPE
10580 ? DW_TAG_structure_type
: DW_TAG_union_type
,
10582 equate_type_number_to_die (type
, type_die
);
10584 add_AT_die_ref (type_die
, DW_AT_specification
, old_die
);
10586 add_name_attribute (type_die
, type_tag (type
));
10589 remove_AT (type_die
, DW_AT_declaration
);
10591 /* If this type has been completed, then give it a byte_size attribute and
10592 then give a list of members. */
10595 /* Prevent infinite recursion in cases where the type of some member of
10596 this type is expressed in terms of this type itself. */
10597 TREE_ASM_WRITTEN (type
) = 1;
10598 add_byte_size_attribute (type_die
, type
);
10599 if (TYPE_STUB_DECL (type
) != NULL_TREE
)
10600 add_src_coords_attributes (type_die
, TYPE_STUB_DECL (type
));
10602 /* If the first reference to this type was as the return type of an
10603 inline function, then it may not have a parent. Fix this now. */
10604 if (type_die
->die_parent
== NULL
)
10605 add_child_die (scope_die
, type_die
);
10607 push_decl_scope (type
);
10608 gen_member_die (type
, type_die
);
10611 /* GNU extension: Record what type our vtable lives in. */
10612 if (TYPE_VFIELD (type
))
10614 tree vtype
= DECL_FCONTEXT (TYPE_VFIELD (type
));
10616 gen_type_die (vtype
, context_die
);
10617 add_AT_die_ref (type_die
, DW_AT_containing_type
,
10618 lookup_type_die (vtype
));
10623 add_AT_flag (type_die
, DW_AT_declaration
, 1);
10625 /* We don't need to do this for function-local types. */
10626 if (! decl_function_context (TYPE_STUB_DECL (type
)))
10627 add_incomplete_type (type
);
10631 /* Generate a DIE for a subroutine _type_. */
10634 gen_subroutine_type_die (type
, context_die
)
10635 register tree type
;
10636 register dw_die_ref context_die
;
10638 register tree return_type
= TREE_TYPE (type
);
10639 register dw_die_ref subr_die
10640 = new_die (DW_TAG_subroutine_type
, scope_die_for (type
, context_die
));
10642 equate_type_number_to_die (type
, subr_die
);
10643 add_prototyped_attribute (subr_die
, type
);
10644 add_type_attribute (subr_die
, return_type
, 0, 0, context_die
);
10645 gen_formal_types_die (type
, subr_die
);
10648 /* Generate a DIE for a type definition */
10651 gen_typedef_die (decl
, context_die
)
10652 register tree decl
;
10653 register dw_die_ref context_die
;
10655 register dw_die_ref type_die
;
10656 register tree origin
;
10658 if (TREE_ASM_WRITTEN (decl
))
10660 TREE_ASM_WRITTEN (decl
) = 1;
10662 type_die
= new_die (DW_TAG_typedef
, context_die
);
10663 origin
= decl_ultimate_origin (decl
);
10664 if (origin
!= NULL
)
10665 add_abstract_origin_attribute (type_die
, origin
);
10668 register tree type
;
10669 add_name_and_src_coords_attributes (type_die
, decl
);
10670 if (DECL_ORIGINAL_TYPE (decl
))
10672 type
= DECL_ORIGINAL_TYPE (decl
);
10674 if (type
== TREE_TYPE (decl
))
10677 equate_type_number_to_die (TREE_TYPE (decl
), type_die
);
10680 type
= TREE_TYPE (decl
);
10681 add_type_attribute (type_die
, type
, TREE_READONLY (decl
),
10682 TREE_THIS_VOLATILE (decl
), context_die
);
10685 if (DECL_ABSTRACT (decl
))
10686 equate_decl_number_to_die (decl
, type_die
);
10689 /* Generate a type description DIE. */
10692 gen_type_die (type
, context_die
)
10693 register tree type
;
10694 register dw_die_ref context_die
;
10698 if (type
== NULL_TREE
|| type
== error_mark_node
)
10701 /* We are going to output a DIE to represent the unqualified version of
10702 this type (i.e. without any const or volatile qualifiers) so get the
10703 main variant (i.e. the unqualified version) of this type now. */
10704 type
= type_main_variant (type
);
10706 if (TREE_ASM_WRITTEN (type
))
10709 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
10710 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
10712 TREE_ASM_WRITTEN (type
) = 1;
10713 gen_decl_die (TYPE_NAME (type
), context_die
);
10717 switch (TREE_CODE (type
))
10723 case REFERENCE_TYPE
:
10724 /* We must set TREE_ASM_WRITTEN in case this is a recursive type. This
10725 ensures that the gen_type_die recursion will terminate even if the
10726 type is recursive. Recursive types are possible in Ada. */
10727 /* ??? We could perhaps do this for all types before the switch
10729 TREE_ASM_WRITTEN (type
) = 1;
10731 /* For these types, all that is required is that we output a DIE (or a
10732 set of DIEs) to represent the "basis" type. */
10733 gen_type_die (TREE_TYPE (type
), context_die
);
10737 /* This code is used for C++ pointer-to-data-member types.
10738 Output a description of the relevant class type. */
10739 gen_type_die (TYPE_OFFSET_BASETYPE (type
), context_die
);
10741 /* Output a description of the type of the object pointed to. */
10742 gen_type_die (TREE_TYPE (type
), context_die
);
10744 /* Now output a DIE to represent this pointer-to-data-member type
10746 gen_ptr_to_mbr_type_die (type
, context_die
);
10750 gen_type_die (TYPE_DOMAIN (type
), context_die
);
10751 gen_set_type_die (type
, context_die
);
10755 gen_type_die (TREE_TYPE (type
), context_die
);
10756 abort (); /* No way to represent these in Dwarf yet! */
10759 case FUNCTION_TYPE
:
10760 /* Force out return type (in case it wasn't forced out already). */
10761 gen_type_die (TREE_TYPE (type
), context_die
);
10762 gen_subroutine_type_die (type
, context_die
);
10766 /* Force out return type (in case it wasn't forced out already). */
10767 gen_type_die (TREE_TYPE (type
), context_die
);
10768 gen_subroutine_type_die (type
, context_die
);
10772 if (TYPE_STRING_FLAG (type
) && TREE_CODE (TREE_TYPE (type
)) == CHAR_TYPE
)
10774 gen_type_die (TREE_TYPE (type
), context_die
);
10775 gen_string_type_die (type
, context_die
);
10778 gen_array_type_die (type
, context_die
);
10782 gen_type_die (TYPE_DEBUG_REPRESENTATION_TYPE (type
), context_die
);
10785 case ENUMERAL_TYPE
:
10788 case QUAL_UNION_TYPE
:
10789 /* If this is a nested type whose containing class hasn't been
10790 written out yet, writing it out will cover this one, too.
10791 This does not apply to instantiations of member class templates;
10792 they need to be added to the containing class as they are
10793 generated. FIXME: This hurts the idea of combining type decls
10794 from multiple TUs, since we can't predict what set of template
10795 instantiations we'll get. */
10796 if (TYPE_CONTEXT (type
)
10797 && AGGREGATE_TYPE_P (TYPE_CONTEXT (type
))
10798 && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type
)))
10800 gen_type_die (TYPE_CONTEXT (type
), context_die
);
10802 if (TREE_ASM_WRITTEN (type
))
10805 /* If that failed, attach ourselves to the stub. */
10806 push_decl_scope (TYPE_CONTEXT (type
));
10807 context_die
= lookup_type_die (TYPE_CONTEXT (type
));
10813 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
10814 gen_enumeration_type_die (type
, context_die
);
10816 gen_struct_or_union_type_die (type
, context_die
);
10821 /* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix
10822 it up if it is ever completed. gen_*_type_die will set it for us
10823 when appropriate. */
10832 /* No DIEs needed for fundamental types. */
10836 /* No Dwarf representation currently defined. */
10843 TREE_ASM_WRITTEN (type
) = 1;
10846 /* Generate a DIE for a tagged type instantiation. */
10849 gen_tagged_type_instantiation_die (type
, context_die
)
10850 register tree type
;
10851 register dw_die_ref context_die
;
10853 if (type
== NULL_TREE
|| type
== error_mark_node
)
10856 /* We are going to output a DIE to represent the unqualified version of
10857 this type (i.e. without any const or volatile qualifiers) so make sure
10858 that we have the main variant (i.e. the unqualified version) of this
10860 if (type
!= type_main_variant (type
))
10863 /* Do not check TREE_ASM_WRITTEN (type) as it may not be set if this is
10864 an instance of an unresolved type. */
10866 switch (TREE_CODE (type
))
10871 case ENUMERAL_TYPE
:
10872 gen_inlined_enumeration_type_die (type
, context_die
);
10876 gen_inlined_structure_type_die (type
, context_die
);
10880 case QUAL_UNION_TYPE
:
10881 gen_inlined_union_type_die (type
, context_die
);
10889 /* Generate a DW_TAG_lexical_block DIE followed by DIEs to represent all of the
10890 things which are local to the given block. */
10893 gen_block_die (stmt
, context_die
, depth
)
10894 register tree stmt
;
10895 register dw_die_ref context_die
;
10898 register int must_output_die
= 0;
10899 register tree origin
;
10900 register tree decl
;
10901 register enum tree_code origin_code
;
10903 /* Ignore blocks never really used to make RTL. */
10904 if (stmt
== NULL_TREE
|| !TREE_USED (stmt
)
10905 || (!TREE_ASM_WRITTEN (stmt
) && !BLOCK_ABSTRACT (stmt
)))
10908 /* If the block is one fragment of a non-contiguous block, do not
10909 process the variables, since they will have been done by the
10910 origin block. Do process subblocks. */
10911 if (BLOCK_FRAGMENT_ORIGIN (stmt
))
10915 for (sub
= BLOCK_SUBBLOCKS (stmt
); sub
; sub
= BLOCK_CHAIN (sub
))
10916 gen_block_die (sub
, context_die
, depth
+ 1);
10920 /* Determine the "ultimate origin" of this block. This block may be an
10921 inlined instance of an inlined instance of inline function, so we have
10922 to trace all of the way back through the origin chain to find out what
10923 sort of node actually served as the original seed for the creation of
10924 the current block. */
10925 origin
= block_ultimate_origin (stmt
);
10926 origin_code
= (origin
!= NULL
) ? TREE_CODE (origin
) : ERROR_MARK
;
10928 /* Determine if we need to output any Dwarf DIEs at all to represent this
10930 if (origin_code
== FUNCTION_DECL
)
10931 /* The outer scopes for inlinings *must* always be represented. We
10932 generate DW_TAG_inlined_subroutine DIEs for them. (See below.) */
10933 must_output_die
= 1;
10936 /* In the case where the current block represents an inlining of the
10937 "body block" of an inline function, we must *NOT* output any DIE for
10938 this block because we have already output a DIE to represent the
10939 whole inlined function scope and the "body block" of any function
10940 doesn't really represent a different scope according to ANSI C
10941 rules. So we check here to make sure that this block does not
10942 represent a "body block inlining" before trying to set the
10943 `must_output_die' flag. */
10944 if (! is_body_block (origin
? origin
: stmt
))
10946 /* Determine if this block directly contains any "significant"
10947 local declarations which we will need to output DIEs for. */
10948 if (debug_info_level
> DINFO_LEVEL_TERSE
)
10949 /* We are not in terse mode so *any* local declaration counts
10950 as being a "significant" one. */
10951 must_output_die
= (BLOCK_VARS (stmt
) != NULL
);
10953 /* We are in terse mode, so only local (nested) function
10954 definitions count as "significant" local declarations. */
10955 for (decl
= BLOCK_VARS (stmt
);
10956 decl
!= NULL
; decl
= TREE_CHAIN (decl
))
10957 if (TREE_CODE (decl
) == FUNCTION_DECL
10958 && DECL_INITIAL (decl
))
10960 must_output_die
= 1;
10966 /* It would be a waste of space to generate a Dwarf DW_TAG_lexical_block
10967 DIE for any block which contains no significant local declarations at
10968 all. Rather, in such cases we just call `decls_for_scope' so that any
10969 needed Dwarf info for any sub-blocks will get properly generated. Note
10970 that in terse mode, our definition of what constitutes a "significant"
10971 local declaration gets restricted to include only inlined function
10972 instances and local (nested) function definitions. */
10973 if (must_output_die
)
10975 if (origin_code
== FUNCTION_DECL
)
10976 gen_inlined_subroutine_die (stmt
, context_die
, depth
);
10978 gen_lexical_block_die (stmt
, context_die
, depth
);
10981 decls_for_scope (stmt
, context_die
, depth
);
10984 /* Generate all of the decls declared within a given scope and (recursively)
10985 all of its sub-blocks. */
10988 decls_for_scope (stmt
, context_die
, depth
)
10989 register tree stmt
;
10990 register dw_die_ref context_die
;
10993 register tree decl
;
10994 register tree subblocks
;
10996 /* Ignore blocks never really used to make RTL. */
10997 if (stmt
== NULL_TREE
|| ! TREE_USED (stmt
))
11000 /* Output the DIEs to represent all of the data objects and typedefs
11001 declared directly within this block but not within any nested
11002 sub-blocks. Also, nested function and tag DIEs have been
11003 generated with a parent of NULL; fix that up now. */
11004 for (decl
= BLOCK_VARS (stmt
);
11005 decl
!= NULL
; decl
= TREE_CHAIN (decl
))
11007 register dw_die_ref die
;
11009 if (TREE_CODE (decl
) == FUNCTION_DECL
)
11010 die
= lookup_decl_die (decl
);
11011 else if (TREE_CODE (decl
) == TYPE_DECL
&& TYPE_DECL_IS_STUB (decl
))
11012 die
= lookup_type_die (TREE_TYPE (decl
));
11016 if (die
!= NULL
&& die
->die_parent
== NULL
)
11017 add_child_die (context_die
, die
);
11019 gen_decl_die (decl
, context_die
);
11022 /* Output the DIEs to represent all sub-blocks (and the items declared
11023 therein) of this block. */
11024 for (subblocks
= BLOCK_SUBBLOCKS (stmt
);
11026 subblocks
= BLOCK_CHAIN (subblocks
))
11027 gen_block_die (subblocks
, context_die
, depth
+ 1);
11030 /* Is this a typedef we can avoid emitting? */
11033 is_redundant_typedef (decl
)
11034 register tree decl
;
11036 if (TYPE_DECL_IS_STUB (decl
))
11039 if (DECL_ARTIFICIAL (decl
)
11040 && DECL_CONTEXT (decl
)
11041 && is_tagged_type (DECL_CONTEXT (decl
))
11042 && TREE_CODE (TYPE_NAME (DECL_CONTEXT (decl
))) == TYPE_DECL
11043 && DECL_NAME (decl
) == DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl
))))
11044 /* Also ignore the artificial member typedef for the class name. */
11050 /* Generate Dwarf debug information for a decl described by DECL. */
11053 gen_decl_die (decl
, context_die
)
11054 register tree decl
;
11055 register dw_die_ref context_die
;
11057 register tree origin
;
11059 if (TREE_CODE (decl
) == ERROR_MARK
)
11062 /* If this ..._DECL node is marked to be ignored, then ignore it. */
11063 if (DECL_IGNORED_P (decl
))
11066 switch (TREE_CODE (decl
))
11069 /* The individual enumerators of an enum type get output when we output
11070 the Dwarf representation of the relevant enum type itself. */
11073 case FUNCTION_DECL
:
11074 /* Don't output any DIEs to represent mere function declarations,
11075 unless they are class members or explicit block externs. */
11076 if (DECL_INITIAL (decl
) == NULL_TREE
&& DECL_CONTEXT (decl
) == NULL_TREE
11077 && (current_function_decl
== NULL_TREE
|| DECL_ARTIFICIAL (decl
)))
11080 /* If we're emitting a clone, emit info for the abstract instance. */
11081 if (DECL_ORIGIN (decl
) != decl
)
11082 dwarf2out_abstract_function (DECL_ABSTRACT_ORIGIN (decl
));
11083 /* If we're emitting an out-of-line copy of an inline function,
11084 emit info for the abstract instance and set up to refer to it. */
11085 else if (DECL_INLINE (decl
) && ! DECL_ABSTRACT (decl
)
11086 && ! class_scope_p (context_die
)
11087 /* dwarf2out_abstract_function won't emit a die if this is just
11088 a declaration. We must avoid setting DECL_ABSTRACT_ORIGIN in
11089 that case, because that works only if we have a die. */
11090 && DECL_INITIAL (decl
) != NULL_TREE
)
11092 dwarf2out_abstract_function (decl
);
11093 set_decl_origin_self (decl
);
11095 /* Otherwise we're emitting the primary DIE for this decl. */
11096 else if (debug_info_level
> DINFO_LEVEL_TERSE
)
11098 /* Before we describe the FUNCTION_DECL itself, make sure that we
11099 have described its return type. */
11100 gen_type_die (TREE_TYPE (TREE_TYPE (decl
)), context_die
);
11102 /* And its virtual context. */
11103 if (DECL_VINDEX (decl
) != NULL_TREE
)
11104 gen_type_die (DECL_CONTEXT (decl
), context_die
);
11106 /* And its containing type. */
11107 origin
= decl_class_context (decl
);
11108 if (origin
!= NULL_TREE
)
11109 gen_type_die_for_member (origin
, decl
, context_die
);
11112 /* Now output a DIE to represent the function itself. */
11113 gen_subprogram_die (decl
, context_die
);
11117 /* If we are in terse mode, don't generate any DIEs to represent any
11118 actual typedefs. */
11119 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
11122 /* In the special case of a TYPE_DECL node representing the
11123 declaration of some type tag, if the given TYPE_DECL is marked as
11124 having been instantiated from some other (original) TYPE_DECL node
11125 (e.g. one which was generated within the original definition of an
11126 inline function) we have to generate a special (abbreviated)
11127 DW_TAG_structure_type, DW_TAG_union_type, or DW_TAG_enumeration_type
11129 if (TYPE_DECL_IS_STUB (decl
) && decl_ultimate_origin (decl
) != NULL_TREE
)
11131 gen_tagged_type_instantiation_die (TREE_TYPE (decl
), context_die
);
11135 if (is_redundant_typedef (decl
))
11136 gen_type_die (TREE_TYPE (decl
), context_die
);
11138 /* Output a DIE to represent the typedef itself. */
11139 gen_typedef_die (decl
, context_die
);
11143 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
11144 gen_label_die (decl
, context_die
);
11148 /* If we are in terse mode, don't generate any DIEs to represent any
11149 variable declarations or definitions. */
11150 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
11153 /* Output any DIEs that are needed to specify the type of this data
11155 gen_type_die (TREE_TYPE (decl
), context_die
);
11157 /* And its containing type. */
11158 origin
= decl_class_context (decl
);
11159 if (origin
!= NULL_TREE
)
11160 gen_type_die_for_member (origin
, decl
, context_die
);
11162 /* Now output the DIE to represent the data object itself. This gets
11163 complicated because of the possibility that the VAR_DECL really
11164 represents an inlined instance of a formal parameter for an inline
11166 origin
= decl_ultimate_origin (decl
);
11167 if (origin
!= NULL_TREE
&& TREE_CODE (origin
) == PARM_DECL
)
11168 gen_formal_parameter_die (decl
, context_die
);
11170 gen_variable_die (decl
, context_die
);
11174 /* Ignore the nameless fields that are used to skip bits, but
11175 handle C++ anonymous unions. */
11176 if (DECL_NAME (decl
) != NULL_TREE
11177 || TREE_CODE (TREE_TYPE (decl
)) == UNION_TYPE
)
11179 gen_type_die (member_declared_type (decl
), context_die
);
11180 gen_field_die (decl
, context_die
);
11185 gen_type_die (TREE_TYPE (decl
), context_die
);
11186 gen_formal_parameter_die (decl
, context_die
);
11189 case NAMESPACE_DECL
:
11190 /* Ignore for now. */
11198 /* Add Ada "use" clause information for SGI Workshop debugger. */
11201 dwarf2out_add_library_unit_info (filename
, context_list
)
11202 const char *filename
;
11203 const char *context_list
;
11205 unsigned int file_index
;
11207 if (filename
!= NULL
)
11209 dw_die_ref unit_die
= new_die (DW_TAG_module
, comp_unit_die
);
11210 tree context_list_decl
11211 = build_decl (LABEL_DECL
, get_identifier (context_list
),
11214 TREE_PUBLIC (context_list_decl
) = TRUE
;
11215 add_name_attribute (unit_die
, context_list
);
11216 file_index
= lookup_filename (filename
);
11217 add_AT_unsigned (unit_die
, DW_AT_decl_file
, file_index
);
11218 add_pubname (context_list_decl
, unit_die
);
11222 /* Debug information for a global DECL. Called from toplev.c after
11223 compilation proper has finished. */
11225 dwarf2out_global_decl (decl
)
11228 /* Output DWARF2 information for file-scope tentative data object
11229 declarations, file-scope (extern) function declarations (which
11230 had no corresponding body) and file-scope tagged type
11231 declarations and definitions which have not yet been forced out. */
11233 if (TREE_CODE (decl
) != FUNCTION_DECL
|| !DECL_INITIAL (decl
))
11234 dwarf2out_decl (decl
);
11237 /* Write the debugging output for DECL. */
11240 dwarf2out_decl (decl
)
11241 register tree decl
;
11243 register dw_die_ref context_die
= comp_unit_die
;
11245 if (TREE_CODE (decl
) == ERROR_MARK
)
11248 /* If this ..._DECL node is marked to be ignored, then ignore it. */
11249 if (DECL_IGNORED_P (decl
))
11252 switch (TREE_CODE (decl
))
11254 case FUNCTION_DECL
:
11255 /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of a
11256 builtin function. Explicit programmer-supplied declarations of
11257 these same functions should NOT be ignored however. */
11258 if (DECL_EXTERNAL (decl
) && DECL_BUILT_IN (decl
))
11261 /* What we would really like to do here is to filter out all mere
11262 file-scope declarations of file-scope functions which are never
11263 referenced later within this translation unit (and keep all of ones
11264 that *are* referenced later on) but we aren't clairvoyant, so we have
11265 no idea which functions will be referenced in the future (i.e. later
11266 on within the current translation unit). So here we just ignore all
11267 file-scope function declarations which are not also definitions. If
11268 and when the debugger needs to know something about these functions,
11269 it will have to hunt around and find the DWARF information associated
11270 with the definition of the function. Note that we can't just check
11271 `DECL_EXTERNAL' to find out which FUNCTION_DECL nodes represent
11272 definitions and which ones represent mere declarations. We have to
11273 check `DECL_INITIAL' instead. That's because the C front-end
11274 supports some weird semantics for "extern inline" function
11275 definitions. These can get inlined within the current translation
11276 unit (an thus, we need to generate DWARF info for their abstract
11277 instances so that the DWARF info for the concrete inlined instances
11278 can have something to refer to) but the compiler never generates any
11279 out-of-lines instances of such things (despite the fact that they
11280 *are* definitions). The important point is that the C front-end
11281 marks these "extern inline" functions as DECL_EXTERNAL, but we need
11282 to generate DWARF for them anyway. Note that the C++ front-end also
11283 plays some similar games for inline function definitions appearing
11284 within include files which also contain
11285 `#pragma interface' pragmas. */
11286 if (DECL_INITIAL (decl
) == NULL_TREE
)
11289 /* If we're a nested function, initially use a parent of NULL; if we're
11290 a plain function, this will be fixed up in decls_for_scope. If
11291 we're a method, it will be ignored, since we already have a DIE. */
11292 if (decl_function_context (decl
))
11293 context_die
= NULL
;
11298 /* Ignore this VAR_DECL if it refers to a file-scope extern data object
11299 declaration and if the declaration was never even referenced from
11300 within this entire compilation unit. We suppress these DIEs in
11301 order to save space in the .debug section (by eliminating entries
11302 which are probably useless). Note that we must not suppress
11303 block-local extern declarations (whether used or not) because that
11304 would screw-up the debugger's name lookup mechanism and cause it to
11305 miss things which really ought to be in scope at a given point. */
11306 if (DECL_EXTERNAL (decl
) && !TREE_USED (decl
))
11309 /* If we are in terse mode, don't generate any DIEs to represent any
11310 variable declarations or definitions. */
11311 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
11316 /* Don't emit stubs for types unless they are needed by other DIEs. */
11317 if (TYPE_DECL_SUPPRESS_DEBUG (decl
))
11320 /* Don't bother trying to generate any DIEs to represent any of the
11321 normal built-in types for the language we are compiling. */
11322 if (DECL_SOURCE_LINE (decl
) == 0)
11324 /* OK, we need to generate one for `bool' so GDB knows what type
11325 comparisons have. */
11326 if ((get_AT_unsigned (comp_unit_die
, DW_AT_language
)
11327 == DW_LANG_C_plus_plus
)
11328 && TREE_CODE (TREE_TYPE (decl
)) == BOOLEAN_TYPE
)
11329 modified_type_die (TREE_TYPE (decl
), 0, 0, NULL
);
11334 /* If we are in terse mode, don't generate any DIEs for types. */
11335 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
11338 /* If we're a function-scope tag, initially use a parent of NULL;
11339 this will be fixed up in decls_for_scope. */
11340 if (decl_function_context (decl
))
11341 context_die
= NULL
;
11349 gen_decl_die (decl
, context_die
);
11352 /* Output a marker (i.e. a label) for the beginning of the generated code for
11353 a lexical block. */
11356 dwarf2out_begin_block (line
, blocknum
)
11357 unsigned int line ATTRIBUTE_UNUSED
;
11358 unsigned int blocknum
;
11360 function_section (current_function_decl
);
11361 ASM_OUTPUT_DEBUG_LABEL (asm_out_file
, BLOCK_BEGIN_LABEL
, blocknum
);
11364 /* Output a marker (i.e. a label) for the end of the generated code for a
11368 dwarf2out_end_block (line
, blocknum
)
11369 unsigned int line ATTRIBUTE_UNUSED
;
11370 unsigned int blocknum
;
11372 function_section (current_function_decl
);
11373 ASM_OUTPUT_DEBUG_LABEL (asm_out_file
, BLOCK_END_LABEL
, blocknum
);
11376 /* Returns nonzero if it is appropriate not to emit any debugging
11377 information for BLOCK, because it doesn't contain any instructions.
11379 Don't allow this for blocks with nested functions or local classes
11380 as we would end up with orphans, and in the presence of scheduling
11381 we may end up calling them anyway. */
11384 dwarf2out_ignore_block (block
)
11388 for (decl
= BLOCK_VARS (block
); decl
; decl
= TREE_CHAIN (decl
))
11389 if (TREE_CODE (decl
) == FUNCTION_DECL
11390 || (TREE_CODE (decl
) == TYPE_DECL
&& TYPE_DECL_IS_STUB (decl
)))
11395 /* Lookup a filename (in the list of filenames that we know about here in
11396 dwarf2out.c) and return its "index". The index of each (known) filename is
11397 just a unique number which is associated with only that one filename.
11398 We need such numbers for the sake of generating labels
11399 (in the .debug_sfnames section) and references to those
11400 files numbers (in the .debug_srcinfo and.debug_macinfo sections).
11401 If the filename given as an argument is not found in our current list,
11402 add it to the list and assign it the next available unique index number.
11403 In order to speed up searches, we remember the index of the filename
11404 was looked up last. This handles the majority of all searches. */
11407 lookup_filename (file_name
)
11408 const char *file_name
;
11410 register unsigned i
;
11412 /* ??? Why isn't DECL_SOURCE_FILE left null instead. */
11413 if (strcmp (file_name
, "<internal>") == 0
11414 || strcmp (file_name
, "<built-in>") == 0)
11417 /* Check to see if the file name that was searched on the previous
11418 call matches this file name. If so, return the index. */
11419 if (file_table
.last_lookup_index
!= 0)
11420 if (strcmp (file_name
, file_table
.table
[file_table
.last_lookup_index
]) == 0)
11421 return file_table
.last_lookup_index
;
11423 /* Didn't match the previous lookup, search the table */
11424 for (i
= 1; i
< file_table
.in_use
; ++i
)
11425 if (strcmp (file_name
, file_table
.table
[i
]) == 0)
11427 file_table
.last_lookup_index
= i
;
11431 /* Prepare to add a new table entry by making sure there is enough space in
11432 the table to do so. If not, expand the current table. */
11433 if (i
== file_table
.allocated
)
11435 file_table
.allocated
= i
+ FILE_TABLE_INCREMENT
;
11436 file_table
.table
= (char **)
11437 xrealloc (file_table
.table
, file_table
.allocated
* sizeof (char *));
11440 /* Add the new entry to the end of the filename table. */
11441 file_table
.table
[i
] = xstrdup (file_name
);
11442 file_table
.in_use
= i
+ 1;
11443 file_table
.last_lookup_index
= i
;
11445 if (DWARF2_ASM_LINE_DEBUG_INFO
)
11446 fprintf (asm_out_file
, "\t.file %u \"%s\"\n", i
, file_name
);
11454 /* Allocate the initial hunk of the file_table. */
11455 file_table
.table
= (char **) xcalloc (FILE_TABLE_INCREMENT
, sizeof (char *));
11456 file_table
.allocated
= FILE_TABLE_INCREMENT
;
11458 /* Skip the first entry - file numbers begin at 1. */
11459 file_table
.in_use
= 1;
11460 file_table
.last_lookup_index
= 0;
11463 /* Output a label to mark the beginning of a source code line entry
11464 and record information relating to this source line, in
11465 'line_info_table' for later output of the .debug_line section. */
11468 dwarf2out_source_line (line
, filename
)
11470 register const char *filename
;
11472 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
11474 function_section (current_function_decl
);
11476 /* If requested, emit something human-readable. */
11477 if (flag_debug_asm
)
11478 fprintf (asm_out_file
, "\t%s %s:%d\n", ASM_COMMENT_START
,
11481 if (DWARF2_ASM_LINE_DEBUG_INFO
)
11483 unsigned file_num
= lookup_filename (filename
);
11485 /* Emit the .loc directive understood by GNU as. */
11486 fprintf (asm_out_file
, "\t.loc %d %d 0\n", file_num
, line
);
11488 /* Indicate that line number info exists. */
11489 ++line_info_table_in_use
;
11491 /* Indicate that multiple line number tables exist. */
11492 if (DECL_SECTION_NAME (current_function_decl
))
11493 ++separate_line_info_table_in_use
;
11495 else if (DECL_SECTION_NAME (current_function_decl
))
11497 register dw_separate_line_info_ref line_info
;
11498 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, SEPARATE_LINE_CODE_LABEL
,
11499 separate_line_info_table_in_use
);
11501 /* expand the line info table if necessary */
11502 if (separate_line_info_table_in_use
11503 == separate_line_info_table_allocated
)
11505 separate_line_info_table_allocated
+= LINE_INFO_TABLE_INCREMENT
;
11506 separate_line_info_table
11507 = (dw_separate_line_info_ref
)
11508 xrealloc (separate_line_info_table
,
11509 separate_line_info_table_allocated
11510 * sizeof (dw_separate_line_info_entry
));
11513 /* Add the new entry at the end of the line_info_table. */
11515 = &separate_line_info_table
[separate_line_info_table_in_use
++];
11516 line_info
->dw_file_num
= lookup_filename (filename
);
11517 line_info
->dw_line_num
= line
;
11518 line_info
->function
= current_funcdef_number
;
11522 register dw_line_info_ref line_info
;
11524 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, LINE_CODE_LABEL
,
11525 line_info_table_in_use
);
11527 /* Expand the line info table if necessary. */
11528 if (line_info_table_in_use
== line_info_table_allocated
)
11530 line_info_table_allocated
+= LINE_INFO_TABLE_INCREMENT
;
11532 = (dw_line_info_ref
)
11533 xrealloc (line_info_table
,
11534 (line_info_table_allocated
11535 * sizeof (dw_line_info_entry
)));
11538 /* Add the new entry at the end of the line_info_table. */
11539 line_info
= &line_info_table
[line_info_table_in_use
++];
11540 line_info
->dw_file_num
= lookup_filename (filename
);
11541 line_info
->dw_line_num
= line
;
11546 /* Record the beginning of a new source file. */
11549 dwarf2out_start_source_file (lineno
, filename
)
11550 register unsigned int lineno
;
11551 register const char *filename
;
11553 if (flag_eliminate_dwarf2_dups
)
11555 /* Record the beginning of the file for break_out_includes. */
11556 dw_die_ref bincl_die
= new_die (DW_TAG_GNU_BINCL
, comp_unit_die
);
11557 add_AT_string (bincl_die
, DW_AT_name
, filename
);
11559 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
11561 named_section_flags (DEBUG_MACINFO_SECTION
, SECTION_DEBUG
, 1);
11562 dw2_asm_output_data (1, DW_MACINFO_start_file
, "Start new file");
11563 dw2_asm_output_data_uleb128 (lineno
, "Included from line number %d",
11565 dw2_asm_output_data_uleb128 (lookup_filename (filename
),
11566 "Filename we just started");
11570 /* Record the end of a source file. */
11573 dwarf2out_end_source_file (lineno
)
11574 unsigned int lineno ATTRIBUTE_UNUSED
;
11576 if (flag_eliminate_dwarf2_dups
)
11578 /* Record the end of the file for break_out_includes. */
11579 new_die (DW_TAG_GNU_EINCL
, comp_unit_die
);
11581 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
11583 named_section_flags (DEBUG_MACINFO_SECTION
, SECTION_DEBUG
, 1);
11584 dw2_asm_output_data (1, DW_MACINFO_end_file
, "End file");
11588 /* Called from debug_define in toplev.c. The `buffer' parameter contains
11589 the tail part of the directive line, i.e. the part which is past the
11590 initial whitespace, #, whitespace, directive-name, whitespace part. */
11593 dwarf2out_define (lineno
, buffer
)
11594 register unsigned lineno ATTRIBUTE_UNUSED
;
11595 register const char *buffer ATTRIBUTE_UNUSED
;
11597 static int initialized
= 0;
11600 dwarf2out_start_source_file (0, primary_filename
);
11603 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
11605 named_section_flags (DEBUG_MACINFO_SECTION
, SECTION_DEBUG
, 1);
11606 dw2_asm_output_data (1, DW_MACINFO_define
, "Define macro");
11607 dw2_asm_output_data_uleb128 (lineno
, "At line number %d", lineno
);
11608 dw2_asm_output_nstring (buffer
, -1, "The macro");
11612 /* Called from debug_undef in toplev.c. The `buffer' parameter contains
11613 the tail part of the directive line, i.e. the part which is past the
11614 initial whitespace, #, whitespace, directive-name, whitespace part. */
11617 dwarf2out_undef (lineno
, buffer
)
11618 register unsigned lineno ATTRIBUTE_UNUSED
;
11619 register const char *buffer ATTRIBUTE_UNUSED
;
11621 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
11623 named_section_flags (DEBUG_MACINFO_SECTION
, SECTION_DEBUG
, 1);
11624 dw2_asm_output_data (1, DW_MACINFO_undef
, "Undefine macro");
11625 dw2_asm_output_data_uleb128 (lineno
, "At line number %d", lineno
);
11626 dw2_asm_output_nstring (buffer
, -1, "The macro");
11630 /* Set up for Dwarf output at the start of compilation. */
11633 dwarf2out_init (main_input_filename
)
11634 register const char *main_input_filename
;
11636 init_file_table ();
11638 /* Remember the name of the primary input file. */
11639 primary_filename
= main_input_filename
;
11641 /* Add it to the file table first, under the assumption that we'll
11642 be emitting line number data for it first, which avoids having
11643 to add an initial DW_LNS_set_file. */
11644 lookup_filename (main_input_filename
);
11646 /* Allocate the initial hunk of the decl_die_table. */
11648 = (dw_die_ref
*) xcalloc (DECL_DIE_TABLE_INCREMENT
, sizeof (dw_die_ref
));
11649 decl_die_table_allocated
= DECL_DIE_TABLE_INCREMENT
;
11650 decl_die_table_in_use
= 0;
11652 /* Allocate the initial hunk of the decl_scope_table. */
11654 = (tree
*) xcalloc (DECL_SCOPE_TABLE_INCREMENT
, sizeof (tree
));
11655 decl_scope_table_allocated
= DECL_SCOPE_TABLE_INCREMENT
;
11656 decl_scope_depth
= 0;
11658 /* Allocate the initial hunk of the abbrev_die_table. */
11660 = (dw_die_ref
*) xcalloc (ABBREV_DIE_TABLE_INCREMENT
,
11661 sizeof (dw_die_ref
));
11662 abbrev_die_table_allocated
= ABBREV_DIE_TABLE_INCREMENT
;
11663 /* Zero-th entry is allocated, but unused */
11664 abbrev_die_table_in_use
= 1;
11666 /* Allocate the initial hunk of the line_info_table. */
11668 = (dw_line_info_ref
) xcalloc (LINE_INFO_TABLE_INCREMENT
,
11669 sizeof (dw_line_info_entry
));
11670 line_info_table_allocated
= LINE_INFO_TABLE_INCREMENT
;
11671 /* Zero-th entry is allocated, but unused */
11672 line_info_table_in_use
= 1;
11674 /* Generate the initial DIE for the .debug section. Note that the (string)
11675 value given in the DW_AT_name attribute of the DW_TAG_compile_unit DIE
11676 will (typically) be a relative pathname and that this pathname should be
11677 taken as being relative to the directory from which the compiler was
11678 invoked when the given (base) source file was compiled. */
11679 comp_unit_die
= gen_compile_unit_die (main_input_filename
);
11681 VARRAY_RTX_INIT (used_rtx_varray
, 32, "used_rtx_varray");
11682 ggc_add_rtx_varray_root (&used_rtx_varray
, 1);
11684 ASM_GENERATE_INTERNAL_LABEL (text_end_label
, TEXT_END_LABEL
, 0);
11685 ASM_GENERATE_INTERNAL_LABEL (abbrev_section_label
,
11686 DEBUG_ABBREV_SECTION_LABEL
, 0);
11687 if (DWARF2_GENERATE_TEXT_SECTION_LABEL
)
11688 ASM_GENERATE_INTERNAL_LABEL (text_section_label
, TEXT_SECTION_LABEL
, 0);
11690 strcpy (text_section_label
, stripattributes (TEXT_SECTION
));
11691 ASM_GENERATE_INTERNAL_LABEL (debug_info_section_label
,
11692 DEBUG_INFO_SECTION_LABEL
, 0);
11693 ASM_GENERATE_INTERNAL_LABEL (debug_line_section_label
,
11694 DEBUG_LINE_SECTION_LABEL
, 0);
11695 ASM_GENERATE_INTERNAL_LABEL (loc_section_label
, DEBUG_LOC_SECTION_LABEL
, 0);
11696 named_section_flags (DEBUG_LOC_SECTION
, SECTION_DEBUG
, 1);
11697 ASM_OUTPUT_LABEL (asm_out_file
, loc_section_label
);
11698 named_section_flags (DEBUG_ABBREV_SECTION
, SECTION_DEBUG
, 1);
11699 ASM_OUTPUT_LABEL (asm_out_file
, abbrev_section_label
);
11700 named_section_flags (DEBUG_INFO_SECTION
, SECTION_DEBUG
, 1);
11701 ASM_OUTPUT_LABEL (asm_out_file
, debug_info_section_label
);
11702 named_section_flags (DEBUG_LINE_SECTION
, SECTION_DEBUG
, 1);
11703 ASM_OUTPUT_LABEL (asm_out_file
, debug_line_section_label
);
11704 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
11706 named_section_flags (DEBUG_MACINFO_SECTION
, SECTION_DEBUG
, 1);
11707 ASM_GENERATE_INTERNAL_LABEL (macinfo_section_label
,
11708 DEBUG_MACINFO_SECTION_LABEL
, 0);
11709 ASM_OUTPUT_LABEL (asm_out_file
, macinfo_section_label
);
11712 if (DWARF2_GENERATE_TEXT_SECTION_LABEL
)
11715 ASM_OUTPUT_LABEL (asm_out_file
, text_section_label
);
11719 /* Output stuff that dwarf requires at the end of every file,
11720 and generate the DWARF-2 debugging info. */
11723 dwarf2out_finish (input_filename
)
11724 register const char *input_filename ATTRIBUTE_UNUSED
;
11726 limbo_die_node
*node
, *next_node
;
11727 dw_die_ref die
= 0;
11729 /* Traverse the limbo die list, and add parent/child links. The only
11730 dies without parents that should be here are concrete instances of
11731 inline functions, and the comp_unit_die. We can ignore the comp_unit_die.
11732 For concrete instances, we can get the parent die from the abstract
11734 for (node
= limbo_die_list
; node
; node
= next_node
)
11736 next_node
= node
->next
;
11739 if (die
->die_parent
== NULL
)
11741 dw_die_ref origin
= get_AT_ref (die
, DW_AT_abstract_origin
);
11743 add_child_die (origin
->die_parent
, die
);
11744 else if (die
== comp_unit_die
)
11751 limbo_die_list
= NULL
;
11753 /* Walk through the list of incomplete types again, trying once more to
11754 emit full debugging info for them. */
11755 retry_incomplete_types ();
11757 /* We need to reverse all the dies before break_out_includes, or
11758 we'll see the end of an include file before the beginning. */
11759 reverse_all_dies (comp_unit_die
);
11761 /* Generate separate CUs for each of the include files we've seen.
11762 They will go into limbo_die_list. */
11763 if (flag_eliminate_dwarf2_dups
)
11764 break_out_includes (comp_unit_die
);
11766 /* Traverse the DIE's and add add sibling attributes to those DIE's
11767 that have children. */
11768 add_sibling_attributes (comp_unit_die
);
11769 for (node
= limbo_die_list
; node
; node
= node
->next
)
11770 add_sibling_attributes (node
->die
);
11772 /* Output a terminator label for the .text section. */
11774 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, TEXT_END_LABEL
, 0);
11776 /* Output the source line correspondence table. We must do this
11777 even if there is no line information. Otherwise, on an empty
11778 translation unit, we will generate a present, but empty,
11779 .debug_info section. IRIX 6.5 `nm' will then complain when
11780 examining the file. */
11781 if (! DWARF2_ASM_LINE_DEBUG_INFO
)
11783 named_section_flags (DEBUG_LINE_SECTION
, SECTION_DEBUG
, 1);
11784 output_line_info ();
11787 /* We can only use the low/high_pc attributes if all of the code was
11789 if (separate_line_info_table_in_use
== 0)
11791 add_AT_lbl_id (comp_unit_die
, DW_AT_low_pc
, text_section_label
);
11792 add_AT_lbl_id (comp_unit_die
, DW_AT_high_pc
, text_end_label
);
11794 /* And if it wasn't, we need to give .debug_loc and .debug_ranges
11795 an appropriate "base address". Use zero so that these addresses
11796 become absolute. */
11797 else if (have_location_lists
|| ranges_table_in_use
)
11798 add_AT_addr (comp_unit_die
, DW_AT_entry_pc
, const0_rtx
);
11800 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
11801 add_AT_lbl_offset (comp_unit_die
, DW_AT_stmt_list
,
11802 debug_line_section_label
);
11804 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
11805 add_AT_lbl_offset (comp_unit_die
, DW_AT_macro_info
, macinfo_section_label
);
11807 /* Output all of the compilation units. We put the main one last so that
11808 the offsets are available to output_pubnames. */
11809 for (node
= limbo_die_list
; node
; node
= node
->next
)
11810 output_comp_unit (node
->die
);
11811 output_comp_unit (comp_unit_die
);
11813 /* Output the abbreviation table. */
11814 named_section_flags (DEBUG_ABBREV_SECTION
, SECTION_DEBUG
, 1);
11815 output_abbrev_section ();
11817 if (pubname_table_in_use
)
11819 /* Output public names table. */
11820 named_section_flags (DEBUG_PUBNAMES_SECTION
, SECTION_DEBUG
, 1);
11821 output_pubnames ();
11824 /* We only put functions in the arange table, so don't write it out if
11825 we don't have any. */
11826 if (fde_table_in_use
)
11828 /* Output the address range information. */
11829 named_section_flags (DEBUG_ARANGES_SECTION
, SECTION_DEBUG
, 1);
11833 /* Output location list section if necessary. */
11834 if (have_location_lists
)
11836 /* Output the location lists info. */
11837 named_section_flags (DEBUG_LOC_SECTION
, SECTION_DEBUG
, 1);
11838 output_location_lists (die
);
11839 have_location_lists
= 0;
11842 /* Output ranges section if necessary. */
11843 if (ranges_table_in_use
)
11845 named_section_flags (DEBUG_RANGES_SECTION
, SECTION_DEBUG
, 1);
11849 /* Have to end the primary source file. */
11850 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
11852 named_section_flags (DEBUG_MACINFO_SECTION
, SECTION_DEBUG
, 1);
11853 dw2_asm_output_data (1, DW_MACINFO_end_file
, "End file");
11856 #endif /* DWARF2_DEBUGGING_INFO */