1 /* Output Dwarf2 format symbol table information from the GNU C compiler.
2 Copyright (C) 1992, 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
3 Contributed by Gary Funck (gary@intrepid.com).
4 Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.com).
5 Extensively modified by Jason Merrill (jason@cygnus.com).
7 This file is part of GNU CC.
9 GNU CC is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2, or (at your option)
14 GNU CC is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with GNU CC; see the file COPYING. If not, write to
21 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
23 /* The first part of this file deals with the DWARF 2 frame unwind
24 information, which is also used by the GCC efficient exception handling
25 mechanism. The second part, controlled only by an #ifdef
26 DWARF2_DEBUGGING_INFO, deals with the other DWARF 2 debugging
35 #include "hard-reg-set.h"
37 #include "insn-config.h"
44 /* #define NDEBUG 1 */
47 /* Decide whether we want to emit frame unwind information for the current
53 return (write_symbols
== DWARF2_DEBUG
54 #ifdef DWARF2_UNWIND_INFO
55 || (flag_exceptions
&& ! exceptions_via_longjmp
)
60 #if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
66 /* How to start an assembler comment. */
67 #ifndef ASM_COMMENT_START
68 #define ASM_COMMENT_START ";#"
71 typedef struct dw_cfi_struct
*dw_cfi_ref
;
72 typedef struct dw_fde_struct
*dw_fde_ref
;
73 typedef union dw_cfi_oprnd_struct
*dw_cfi_oprnd_ref
;
75 /* Call frames are described using a sequence of Call Frame
76 Information instructions. The register number, offset
77 and address fields are provided as possible operands;
78 their use is selected by the opcode field. */
80 typedef union dw_cfi_oprnd_struct
82 unsigned long dw_cfi_reg_num
;
83 long int dw_cfi_offset
;
88 typedef struct dw_cfi_struct
90 dw_cfi_ref dw_cfi_next
;
91 enum dwarf_call_frame_info dw_cfi_opc
;
92 dw_cfi_oprnd dw_cfi_oprnd1
;
93 dw_cfi_oprnd dw_cfi_oprnd2
;
97 /* All call frame descriptions (FDE's) in the GCC generated DWARF
98 refer to a single Common Information Entry (CIE), defined at
99 the beginning of the .debug_frame section. This used of a single
100 CIE obviates the need to keep track of multiple CIE's
101 in the DWARF generation routines below. */
103 typedef struct dw_fde_struct
106 char *dw_fde_current_label
;
108 dw_cfi_ref dw_fde_cfi
;
112 /* Maximum size (in bytes) of an artificially generated label. */
113 #define MAX_ARTIFICIAL_LABEL_BYTES 30
115 /* Make sure we know the sizes of the various types dwarf can describe. These
116 are only defaults. If the sizes are different for your target, you should
117 override these values by defining the appropriate symbols in your tm.h
120 #ifndef CHAR_TYPE_SIZE
121 #define CHAR_TYPE_SIZE BITS_PER_UNIT
124 #define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
127 /* The size in bytes of a DWARF field indicating an offset or length
128 relative to a debug info section, specified to be 4 bytes in the DWARF-2
129 specification. The SGI/MIPS ABI defines it to be the same as PTR_SIZE. */
131 #ifndef DWARF_OFFSET_SIZE
132 #define DWARF_OFFSET_SIZE 4
135 #define DWARF_VERSION 2
137 /* Round SIZE up to the nearest BOUNDARY. */
138 #define DWARF_ROUND(SIZE,BOUNDARY) \
139 (((SIZE) + (BOUNDARY) - 1) & ~((BOUNDARY) - 1))
141 /* Offsets recorded in opcodes are a multiple of this alignment factor. */
142 #ifdef STACK_GROWS_DOWNWARD
143 #define DWARF_CIE_DATA_ALIGNMENT (-UNITS_PER_WORD)
145 #define DWARF_CIE_DATA_ALIGNMENT UNITS_PER_WORD
148 /* A pointer to the base of a table that contains frame description
149 information for each routine. */
150 static dw_fde_ref fde_table
;
152 /* Number of elements currently allocated for fde_table. */
153 static unsigned fde_table_allocated
;
155 /* Number of elements in fde_table currently in use. */
156 static unsigned fde_table_in_use
;
158 /* Size (in elements) of increments by which we may expand the
160 #define FDE_TABLE_INCREMENT 256
162 /* A list of call frame insns for the CIE. */
163 static dw_cfi_ref cie_cfi_head
;
165 /* The number of the current function definition for which debugging
166 information is being generated. These numbers range from 1 up to the
167 maximum number of function definitions contained within the current
168 compilation unit. These numbers are used to create unique label id's
169 unique to each function definition. */
170 static unsigned current_funcdef_number
= 0;
172 /* Some DWARF extensions (e.g., MIPS/SGI) implement a subprogram
173 attribute that accelerates the lookup of the FDE associated
174 with the subprogram. This variable holds the table index of the FDE
175 associated with the current function (body) definition. */
176 static unsigned current_funcdef_fde
;
178 /* Forward declarations for functions defined in this file. */
180 static char *stripattributes
PROTO((char *));
181 static char *dwarf_cfi_name
PROTO((unsigned));
182 static dw_cfi_ref new_cfi
PROTO((void));
183 static void add_cfi
PROTO((dw_cfi_ref
*, dw_cfi_ref
));
184 static unsigned long size_of_uleb128
PROTO((unsigned long));
185 static unsigned long size_of_sleb128
PROTO((long));
186 static void output_uleb128
PROTO((unsigned long));
187 static void output_sleb128
PROTO((long));
188 static void add_fde_cfi
PROTO((char *, dw_cfi_ref
));
189 static void lookup_cfa_1
PROTO((dw_cfi_ref
, unsigned long *,
191 static void lookup_cfa
PROTO((unsigned long *, long *));
192 static void reg_save
PROTO((char *, unsigned, unsigned,
194 static void initial_return_save
PROTO((rtx
));
195 static void output_cfi
PROTO((dw_cfi_ref
, dw_fde_ref
));
196 static void output_call_frame_info
PROTO((int));
197 static unsigned reg_number
PROTO((rtx
));
199 /* Definitions of defaults for assembler-dependent names of various
200 pseudo-ops and section names.
201 Theses may be overridden in the tm.h file (if necessary) for a particular
204 #ifdef OBJECT_FORMAT_ELF
205 #ifndef UNALIGNED_SHORT_ASM_OP
206 #define UNALIGNED_SHORT_ASM_OP ".2byte"
208 #ifndef UNALIGNED_INT_ASM_OP
209 #define UNALIGNED_INT_ASM_OP ".4byte"
211 #ifndef UNALIGNED_DOUBLE_INT_ASM_OP
212 #define UNALIGNED_DOUBLE_INT_ASM_OP ".8byte"
214 #endif /* OBJECT_FORMAT_ELF */
217 #define ASM_BYTE_OP ".byte"
220 /* Data and reference forms for relocatable data. */
221 #define DW_FORM_data (DWARF_OFFSET_SIZE == 8 ? DW_FORM_data8 : DW_FORM_data4)
222 #define DW_FORM_ref (DWARF_OFFSET_SIZE == 8 ? DW_FORM_ref8 : DW_FORM_ref4)
224 /* Pseudo-op for defining a new section. */
225 #ifndef SECTION_ASM_OP
226 #define SECTION_ASM_OP ".section"
229 /* The default format used by the ASM_OUTPUT_SECTION macro (see below) to
230 print the SECTION_ASM_OP and the section name. The default here works for
231 almost all svr4 assemblers, except for the sparc, where the section name
232 must be enclosed in double quotes. (See sparcv4.h). */
233 #ifndef SECTION_FORMAT
234 #ifdef PUSHSECTION_FORMAT
235 #define SECTION_FORMAT PUSHSECTION_FORMAT
237 #define SECTION_FORMAT "\t%s\t%s\n"
241 #ifndef FRAME_SECTION
242 #define FRAME_SECTION ".debug_frame"
245 #ifndef FUNC_BEGIN_LABEL
246 #define FUNC_BEGIN_LABEL "LFB"
248 #ifndef FUNC_END_LABEL
249 #define FUNC_END_LABEL "LFE"
251 #define CIE_AFTER_SIZE_LABEL "LSCIE"
252 #define CIE_END_LABEL "LECIE"
253 #define FDE_AFTER_SIZE_LABEL "LSFDE"
254 #define FDE_END_LABEL "LEFDE"
256 /* Definitions of defaults for various types of primitive assembly language
257 output operations. These may be overridden from within the tm.h file,
258 but typically, that is unecessary. */
260 #ifndef ASM_OUTPUT_SECTION
261 #define ASM_OUTPUT_SECTION(FILE, SECTION) \
262 fprintf ((FILE), SECTION_FORMAT, SECTION_ASM_OP, SECTION)
265 #ifndef ASM_OUTPUT_DWARF_DATA1
266 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
267 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, VALUE)
270 #ifdef UNALIGNED_INT_ASM_OP
272 #ifndef UNALIGNED_OFFSET_ASM_OP
273 #define UNALIGNED_OFFSET_ASM_OP \
274 (DWARF_OFFSET_SIZE == 8 ? UNALIGNED_DOUBLE_INT_ASM_OP : UNALIGNED_INT_ASM_OP)
277 #ifndef UNALIGNED_WORD_ASM_OP
278 #define UNALIGNED_WORD_ASM_OP \
279 (PTR_SIZE == 8 ? UNALIGNED_DOUBLE_INT_ASM_OP : UNALIGNED_INT_ASM_OP)
282 #ifndef ASM_OUTPUT_DWARF_DELTA2
283 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
284 do { fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \
285 assemble_name (FILE, LABEL1); \
286 fprintf (FILE, "-"); \
287 assemble_name (FILE, LABEL2); \
291 #ifndef ASM_OUTPUT_DWARF_DELTA4
292 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
293 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
294 assemble_name (FILE, LABEL1); \
295 fprintf (FILE, "-"); \
296 assemble_name (FILE, LABEL2); \
300 #ifndef ASM_OUTPUT_DWARF_DELTA
301 #define ASM_OUTPUT_DWARF_DELTA(FILE,LABEL1,LABEL2) \
302 do { fprintf ((FILE), "\t%s\t", UNALIGNED_OFFSET_ASM_OP); \
303 assemble_name (FILE, LABEL1); \
304 fprintf (FILE, "-"); \
305 assemble_name (FILE, LABEL2); \
309 #ifndef ASM_OUTPUT_DWARF_ADDR_DELTA
310 #define ASM_OUTPUT_DWARF_ADDR_DELTA(FILE,LABEL1,LABEL2) \
311 do { fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP); \
312 assemble_name (FILE, LABEL1); \
313 fprintf (FILE, "-"); \
314 assemble_name (FILE, LABEL2); \
318 #ifndef ASM_OUTPUT_DWARF_ADDR
319 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
320 do { fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP); \
321 assemble_name (FILE, LABEL); \
325 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
326 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,ADDR) \
327 fprintf ((FILE), "\t%s\t%s", UNALIGNED_WORD_ASM_OP, (ADDR))
330 #ifndef ASM_OUTPUT_DWARF_OFFSET
331 #define ASM_OUTPUT_DWARF_OFFSET(FILE,LABEL) \
332 do { fprintf ((FILE), "\t%s\t", UNALIGNED_OFFSET_ASM_OP); \
333 assemble_name (FILE, LABEL); \
337 #ifndef ASM_OUTPUT_DWARF_DATA2
338 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
339 fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_SHORT_ASM_OP, (unsigned) VALUE)
342 #ifndef ASM_OUTPUT_DWARF_DATA4
343 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
344 fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_INT_ASM_OP, (unsigned) VALUE)
347 #ifndef ASM_OUTPUT_DWARF_DATA
348 #define ASM_OUTPUT_DWARF_DATA(FILE,VALUE) \
349 fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_OFFSET_ASM_OP, \
350 (unsigned long) VALUE)
353 #ifndef ASM_OUTPUT_DWARF_ADDR_DATA
354 #define ASM_OUTPUT_DWARF_ADDR_DATA(FILE,VALUE) \
355 fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_WORD_ASM_OP, \
356 (unsigned long) VALUE)
359 #ifndef ASM_OUTPUT_DWARF_DATA8
360 #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \
362 if (WORDS_BIG_ENDIAN) \
364 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
365 fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
369 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
370 fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
375 #else /* UNALIGNED_INT_ASM_OP */
377 /* We don't have unaligned support, let's hope the normal output works for
380 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
381 assemble_integer (gen_rtx (SYMBOL_REF, Pmode, LABEL), PTR_SIZE, 1)
383 #define ASM_OUTPUT_DWARF_OFFSET(FILE,LABEL) \
384 assemble_integer (gen_rtx (SYMBOL_REF, SImode, LABEL), 4, 1)
386 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
387 assemble_integer (gen_rtx (MINUS, HImode, \
388 gen_rtx (SYMBOL_REF, Pmode, LABEL1), \
389 gen_rtx (SYMBOL_REF, Pmode, LABEL2)), \
392 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
393 assemble_integer (gen_rtx (MINUS, SImode, \
394 gen_rtx (SYMBOL_REF, Pmode, LABEL1), \
395 gen_rtx (SYMBOL_REF, Pmode, LABEL2)), \
398 #define ASM_OUTPUT_DWARF_ADDR_DELTA(FILE,LABEL1,LABEL2) \
399 assemble_integer (gen_rtx (MINUS, Pmode, \
400 gen_rtx (SYMBOL_REF, Pmode, LABEL1), \
401 gen_rtx (SYMBOL_REF, Pmode, LABEL2)), \
404 #define ASM_OUTPUT_DWARF_DELTA(FILE,LABEL1,LABEL2) \
405 ASM_OUTPUT_DWARF_DELTA4 (FILE,LABEL1,LABEL2)
407 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
408 assemble_integer (GEN_INT (VALUE), 4, 1)
410 #endif /* UNALIGNED_INT_ASM_OP */
412 /* This is similar to the default ASM_OUTPUT_ASCII, except that no trailing
413 newline is produced. When flag_debug_asm is asserted, we add commnetary
414 at the end of the line, so we must avoid output of a newline here. */
415 #ifndef ASM_OUTPUT_DWARF_STRING
416 #define ASM_OUTPUT_DWARF_STRING(FILE,P) \
418 register int slen = strlen(P); \
419 register char *p = (P); \
421 fprintf (FILE, "\t.ascii \""); \
422 for (i = 0; i < slen; i++) \
424 register int c = p[i]; \
425 if (c == '\"' || c == '\\') \
427 if (c >= ' ' && c < 0177) \
431 fprintf (FILE, "\\%o", c); \
434 fprintf (FILE, "\\0\""); \
439 /* The DWARF 2 CFA column which tracks the return address. Normally this
440 is the column for PC, or the first column after all of the hard
442 #ifndef DWARF_FRAME_RETURN_COLUMN
444 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (PC_REGNUM)
446 #define DWARF_FRAME_RETURN_COLUMN FIRST_PSEUDO_REGISTER
450 /* The mapping from gcc register number to DWARF 2 CFA column number. By
451 default, we just provide columns for all registers. */
452 #ifndef DWARF_FRAME_REGNUM
453 #define DWARF_FRAME_REGNUM(REG) DBX_REGISTER_NUMBER (REG)
456 /* Hook used by __throw. */
459 expand_builtin_dwarf_fp_regnum ()
461 return GEN_INT (DWARF_FRAME_REGNUM (HARD_FRAME_POINTER_REGNUM
));
464 /* The offset from the incoming value of %sp to the top of the stack frame
465 for the current function. */
466 #ifndef INCOMING_FRAME_SP_OFFSET
467 #define INCOMING_FRAME_SP_OFFSET 0
470 /* Return a pointer to a copy of the section string name S with all
471 attributes stripped off. */
477 char *stripped
= xstrdup (s
);
480 while (*p
&& *p
!= ',')
487 /* Return the register number described by a given RTL node. */
493 register unsigned regno
= REGNO (rtl
);
495 if (regno
>= FIRST_PSEUDO_REGISTER
)
497 warning ("internal regno botch: regno = %d\n", regno
);
501 regno
= DBX_REGISTER_NUMBER (regno
);
505 struct reg_size_range
512 /* Given a register number in REG_TREE, return an rtx for its size in bytes.
513 We do this in kind of a roundabout way, by building up a list of
514 register size ranges and seeing where our register falls in one of those
515 ranges. We need to do it this way because REG_TREE is not a constant,
516 and the target macros were not designed to make this task easy. */
519 expand_builtin_dwarf_reg_size (reg_tree
, target
)
524 struct reg_size_range ranges
[5];
531 for (; i
< FIRST_PSEUDO_REGISTER
; ++i
)
533 /* The return address is out of order on the MIPS, and we don't use
534 copy_reg for it anyway, so we don't care here how large it is. */
535 if (DWARF_FRAME_REGNUM (i
) == DWARF_FRAME_RETURN_COLUMN
)
538 size
= GET_MODE_SIZE (reg_raw_mode
[i
]);
539 if (size
!= last_size
)
541 ranges
[n_ranges
].beg
= i
;
542 ranges
[n_ranges
].size
= last_size
= GET_MODE_SIZE (reg_raw_mode
[i
]);
544 assert (n_ranges
< 5);
546 ranges
[n_ranges
-1].end
= i
;
549 /* The usual case: fp regs surrounded by general regs. */
550 if (n_ranges
== 3 && ranges
[0].size
== ranges
[2].size
)
552 assert ((DWARF_FRAME_REGNUM (ranges
[1].end
)
553 - DWARF_FRAME_REGNUM (ranges
[1].beg
))
554 == ranges
[1].end
- ranges
[1].beg
);
555 t
= fold (build (GE_EXPR
, integer_type_node
, reg_tree
,
556 build_int_2 (DWARF_FRAME_REGNUM (ranges
[1].beg
), 0)));
557 t2
= fold (build (LE_EXPR
, integer_type_node
, reg_tree
,
558 build_int_2 (DWARF_FRAME_REGNUM (ranges
[1].end
), 0)));
559 t
= fold (build (TRUTH_ANDIF_EXPR
, integer_type_node
, t
, t2
));
560 t
= fold (build (COND_EXPR
, integer_type_node
, t
,
561 build_int_2 (ranges
[1].size
, 0),
562 build_int_2 (ranges
[0].size
, 0)));
567 t
= build_int_2 (ranges
[n_ranges
].size
, 0);
568 size
= DWARF_FRAME_REGNUM (ranges
[n_ranges
].beg
);
571 assert ((DWARF_FRAME_REGNUM (ranges
[n_ranges
].end
)
572 - DWARF_FRAME_REGNUM (ranges
[n_ranges
].beg
))
573 == ranges
[n_ranges
].end
- ranges
[n_ranges
].beg
);
574 assert (DWARF_FRAME_REGNUM (ranges
[n_ranges
].beg
) < size
);
575 size
= DWARF_FRAME_REGNUM (ranges
[n_ranges
].beg
);
576 t2
= fold (build (LE_EXPR
, integer_type_node
, reg_tree
,
577 build_int_2 (DWARF_FRAME_REGNUM
578 (ranges
[n_ranges
].end
), 0)));
579 t
= fold (build (COND_EXPR
, integer_type_node
, t2
,
580 build_int_2 (ranges
[n_ranges
].size
, 0), t
));
583 return expand_expr (t
, target
, Pmode
, 0);
586 /* Convert a DWARF call frame info. operation to its string name */
589 dwarf_cfi_name (cfi_opc
)
590 register unsigned cfi_opc
;
594 case DW_CFA_advance_loc
:
595 return "DW_CFA_advance_loc";
597 return "DW_CFA_offset";
599 return "DW_CFA_restore";
603 return "DW_CFA_set_loc";
604 case DW_CFA_advance_loc1
:
605 return "DW_CFA_advance_loc1";
606 case DW_CFA_advance_loc2
:
607 return "DW_CFA_advance_loc2";
608 case DW_CFA_advance_loc4
:
609 return "DW_CFA_advance_loc4";
610 case DW_CFA_offset_extended
:
611 return "DW_CFA_offset_extended";
612 case DW_CFA_restore_extended
:
613 return "DW_CFA_restore_extended";
614 case DW_CFA_undefined
:
615 return "DW_CFA_undefined";
616 case DW_CFA_same_value
:
617 return "DW_CFA_same_value";
618 case DW_CFA_register
:
619 return "DW_CFA_register";
620 case DW_CFA_remember_state
:
621 return "DW_CFA_remember_state";
622 case DW_CFA_restore_state
:
623 return "DW_CFA_restore_state";
625 return "DW_CFA_def_cfa";
626 case DW_CFA_def_cfa_register
:
627 return "DW_CFA_def_cfa_register";
628 case DW_CFA_def_cfa_offset
:
629 return "DW_CFA_def_cfa_offset";
631 /* SGI/MIPS specific */
632 case DW_CFA_MIPS_advance_loc8
:
633 return "DW_CFA_MIPS_advance_loc8";
636 case DW_CFA_GNU_window_save
:
637 return "DW_CFA_GNU_window_save";
638 case DW_CFA_GNU_args_size
:
639 return "DW_CFA_GNU_args_size";
642 return "DW_CFA_<unknown>";
646 /* Return a pointer to a newly allocated Call Frame Instruction. */
648 static inline dw_cfi_ref
651 register dw_cfi_ref cfi
= (dw_cfi_ref
) xmalloc (sizeof (dw_cfi_node
));
653 cfi
->dw_cfi_next
= NULL
;
654 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= 0;
655 cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
= 0;
660 /* Add a Call Frame Instruction to list of instructions. */
663 add_cfi (list_head
, cfi
)
664 register dw_cfi_ref
*list_head
;
665 register dw_cfi_ref cfi
;
667 register dw_cfi_ref
*p
;
669 /* Find the end of the chain. */
670 for (p
= list_head
; (*p
) != NULL
; p
= &(*p
)->dw_cfi_next
)
676 /* Generate a new label for the CFI info to refer to. */
679 dwarf2out_cfi_label ()
681 static char label
[20];
682 static unsigned long label_num
= 0;
684 ASM_GENERATE_INTERNAL_LABEL (label
, "LCFI", label_num
++);
685 ASM_OUTPUT_LABEL (asm_out_file
, label
);
690 /* Add CFI to the current fde at the PC value indicated by LABEL if specified,
691 or to the CIE if LABEL is NULL. */
694 add_fde_cfi (label
, cfi
)
695 register char *label
;
696 register dw_cfi_ref cfi
;
700 register dw_fde_ref fde
= &fde_table
[fde_table_in_use
- 1];
703 label
= dwarf2out_cfi_label ();
705 if (fde
->dw_fde_current_label
== NULL
706 || strcmp (label
, fde
->dw_fde_current_label
) != 0)
708 register dw_cfi_ref xcfi
;
710 fde
->dw_fde_current_label
= label
= xstrdup (label
);
712 /* Set the location counter to the new label. */
714 xcfi
->dw_cfi_opc
= DW_CFA_advance_loc4
;
715 xcfi
->dw_cfi_oprnd1
.dw_cfi_addr
= label
;
716 add_cfi (&fde
->dw_fde_cfi
, xcfi
);
719 add_cfi (&fde
->dw_fde_cfi
, cfi
);
723 add_cfi (&cie_cfi_head
, cfi
);
726 /* Subroutine of lookup_cfa. */
729 lookup_cfa_1 (cfi
, regp
, offsetp
)
730 register dw_cfi_ref cfi
;
731 register unsigned long *regp
;
732 register long *offsetp
;
734 switch (cfi
->dw_cfi_opc
)
736 case DW_CFA_def_cfa_offset
:
737 *offsetp
= cfi
->dw_cfi_oprnd1
.dw_cfi_offset
;
739 case DW_CFA_def_cfa_register
:
740 *regp
= cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
;
743 *regp
= cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
;
744 *offsetp
= cfi
->dw_cfi_oprnd2
.dw_cfi_offset
;
751 /* Find the previous value for the CFA. */
754 lookup_cfa (regp
, offsetp
)
755 register unsigned long *regp
;
756 register long *offsetp
;
758 register dw_cfi_ref cfi
;
760 *regp
= (unsigned long) -1;
763 for (cfi
= cie_cfi_head
; cfi
; cfi
= cfi
->dw_cfi_next
)
764 lookup_cfa_1 (cfi
, regp
, offsetp
);
766 if (fde_table_in_use
)
768 register dw_fde_ref fde
= &fde_table
[fde_table_in_use
- 1];
769 for (cfi
= fde
->dw_fde_cfi
; cfi
; cfi
= cfi
->dw_cfi_next
)
770 lookup_cfa_1 (cfi
, regp
, offsetp
);
774 /* The current rule for calculating the DWARF2 canonical frame address. */
775 static unsigned long cfa_reg
;
776 static long cfa_offset
;
778 /* The register used for saving registers to the stack, and its offset
780 static unsigned cfa_store_reg
;
781 static long cfa_store_offset
;
783 /* The running total of the size of arguments pushed onto the stack. */
784 static long args_size
;
786 /* Entry point to update the canonical frame address (CFA).
787 LABEL is passed to add_fde_cfi. The value of CFA is now to be
788 calculated from REG+OFFSET. */
791 dwarf2out_def_cfa (label
, reg
, offset
)
792 register char *label
;
793 register unsigned reg
;
794 register long offset
;
796 register dw_cfi_ref cfi
;
797 unsigned long old_reg
;
802 if (cfa_store_reg
== reg
)
803 cfa_store_offset
= offset
;
805 reg
= DWARF_FRAME_REGNUM (reg
);
806 lookup_cfa (&old_reg
, &old_offset
);
808 if (reg
== old_reg
&& offset
== old_offset
)
815 cfi
->dw_cfi_opc
= DW_CFA_def_cfa_offset
;
816 cfi
->dw_cfi_oprnd1
.dw_cfi_offset
= offset
;
819 #ifndef MIPS_DEBUGGING_INFO /* SGI dbx thinks this means no offset. */
820 else if (offset
== old_offset
&& old_reg
!= (unsigned long) -1)
822 cfi
->dw_cfi_opc
= DW_CFA_def_cfa_register
;
823 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= reg
;
829 cfi
->dw_cfi_opc
= DW_CFA_def_cfa
;
830 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= reg
;
831 cfi
->dw_cfi_oprnd2
.dw_cfi_offset
= offset
;
834 add_fde_cfi (label
, cfi
);
837 /* Add the CFI for saving a register. REG is the CFA column number.
838 LABEL is passed to add_fde_cfi.
839 If SREG is -1, the register is saved at OFFSET from the CFA;
840 otherwise it is saved in SREG. */
843 reg_save (label
, reg
, sreg
, offset
)
844 register char * label
;
845 register unsigned reg
;
846 register unsigned sreg
;
847 register long offset
;
849 register dw_cfi_ref cfi
= new_cfi ();
851 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= reg
;
856 /* The register number won't fit in 6 bits, so we have to use
858 cfi
->dw_cfi_opc
= DW_CFA_offset_extended
;
860 cfi
->dw_cfi_opc
= DW_CFA_offset
;
862 offset
/= DWARF_CIE_DATA_ALIGNMENT
;
863 assert (offset
>= 0);
864 cfi
->dw_cfi_oprnd2
.dw_cfi_offset
= offset
;
868 cfi
->dw_cfi_opc
= DW_CFA_register
;
869 cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
= sreg
;
872 add_fde_cfi (label
, cfi
);
875 /* Add the CFI for saving a register window. LABEL is passed to reg_save.
876 This CFI tells the unwinder that it needs to restore the window registers
877 from the previous frame's window save area.
879 ??? Perhaps we should note in the CIE where windows are saved (instead of
880 assuming 0(cfa)) and what registers are in the window. */
883 dwarf2out_window_save (label
)
884 register char * label
;
886 register dw_cfi_ref cfi
= new_cfi ();
887 cfi
->dw_cfi_opc
= DW_CFA_GNU_window_save
;
888 add_fde_cfi (label
, cfi
);
891 /* Add a CFI to update the running total of the size of arguments
892 pushed onto the stack. */
895 dwarf2out_args_size (label
, size
)
899 register dw_cfi_ref cfi
= new_cfi ();
900 cfi
->dw_cfi_opc
= DW_CFA_GNU_args_size
;
901 cfi
->dw_cfi_oprnd1
.dw_cfi_offset
= size
;
902 add_fde_cfi (label
, cfi
);
905 /* Entry point for saving a register to the stack. REG is the GCC register
906 number. LABEL and OFFSET are passed to reg_save. */
909 dwarf2out_reg_save (label
, reg
, offset
)
910 register char * label
;
911 register unsigned reg
;
912 register long offset
;
914 reg_save (label
, DWARF_FRAME_REGNUM (reg
), -1, offset
);
917 /* Entry point for saving the return address in the stack.
918 LABEL and OFFSET are passed to reg_save. */
921 dwarf2out_return_save (label
, offset
)
922 register char * label
;
923 register long offset
;
925 reg_save (label
, DWARF_FRAME_RETURN_COLUMN
, -1, offset
);
928 /* Entry point for saving the return address in a register.
929 LABEL and SREG are passed to reg_save. */
932 dwarf2out_return_reg (label
, sreg
)
933 register char * label
;
934 register unsigned sreg
;
936 reg_save (label
, DWARF_FRAME_RETURN_COLUMN
, sreg
, 0);
939 /* Record the initial position of the return address. RTL is
940 INCOMING_RETURN_ADDR_RTX. */
943 initial_return_save (rtl
)
949 switch (GET_CODE (rtl
))
952 /* RA is in a register. */
953 reg
= reg_number (rtl
);
956 /* RA is on the stack. */
958 switch (GET_CODE (rtl
))
961 assert (REGNO (rtl
) == STACK_POINTER_REGNUM
);
965 assert (REGNO (XEXP (rtl
, 0)) == STACK_POINTER_REGNUM
);
966 offset
= INTVAL (XEXP (rtl
, 1));
969 assert (REGNO (XEXP (rtl
, 0)) == STACK_POINTER_REGNUM
);
970 offset
= -INTVAL (XEXP (rtl
, 1));
977 /* The return address is at some offset from any value we can
978 actually load. For instance, on the SPARC it is in %i7+8. Just
979 ignore the offset for now; it doesn't matter for unwinding frames. */
980 assert (GET_CODE (XEXP (rtl
, 1)) == CONST_INT
);
981 initial_return_save (XEXP (rtl
, 0));
987 reg_save (NULL
, DWARF_FRAME_RETURN_COLUMN
, reg
, offset
- cfa_offset
);
990 /* Check INSN to see if it looks like a push or a stack adjustment, and
991 make a note of it if it does. EH uses this information to find out how
992 much extra space it needs to pop off the stack. */
995 dwarf2out_stack_adjust (insn
)
1001 if (GET_CODE (insn
) == BARRIER
)
1003 /* When we see a BARRIER, we know to reset args_size to 0. Usually
1004 the compiler will have already emitted a stack adjustment, but
1005 doesn't bother for calls to noreturn functions. */
1006 #ifdef STACK_GROWS_DOWNWARD
1007 offset
= -args_size
;
1012 else if (GET_CODE (PATTERN (insn
)) == SET
)
1017 insn
= PATTERN (insn
);
1018 src
= SET_SRC (insn
);
1019 dest
= SET_DEST (insn
);
1021 if (dest
== stack_pointer_rtx
)
1023 /* (set (reg sp) (plus (reg sp) (const_int))) */
1024 code
= GET_CODE (src
);
1025 if (! (code
== PLUS
|| code
== MINUS
)
1026 || XEXP (src
, 0) != stack_pointer_rtx
1027 || GET_CODE (XEXP (src
, 1)) != CONST_INT
)
1030 offset
= INTVAL (XEXP (src
, 1));
1032 else if (GET_CODE (dest
) == MEM
)
1034 /* (set (mem (pre_dec (reg sp))) (foo)) */
1035 src
= XEXP (dest
, 0);
1036 code
= GET_CODE (src
);
1038 if (! (code
== PRE_DEC
|| code
== PRE_INC
)
1039 || XEXP (src
, 0) != stack_pointer_rtx
)
1042 offset
= GET_MODE_SIZE (GET_MODE (dest
));
1047 if (code
== PLUS
|| code
== PRE_INC
)
1056 if (cfa_reg
== STACK_POINTER_REGNUM
)
1057 cfa_offset
+= offset
;
1059 #ifndef STACK_GROWS_DOWNWARD
1062 args_size
+= offset
;
1066 label
= dwarf2out_cfi_label ();
1067 dwarf2out_def_cfa (label
, cfa_reg
, cfa_offset
);
1068 dwarf2out_args_size (label
, args_size
);
1071 /* Record call frame debugging information for INSN, which either
1072 sets SP or FP (adjusting how we calculate the frame address) or saves a
1073 register to the stack. If INSN is NULL_RTX, initialize our state. */
1076 dwarf2out_frame_debug (insn
)
1083 /* A temporary register used in adjusting SP or setting up the store_reg. */
1084 static unsigned cfa_temp_reg
;
1085 static long cfa_temp_value
;
1087 if (insn
== NULL_RTX
)
1089 /* Set up state for generating call frame debug info. */
1090 lookup_cfa (&cfa_reg
, &cfa_offset
);
1091 assert (cfa_reg
== DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM
));
1092 cfa_reg
= STACK_POINTER_REGNUM
;
1093 cfa_store_reg
= cfa_reg
;
1094 cfa_store_offset
= cfa_offset
;
1100 if (! RTX_FRAME_RELATED_P (insn
))
1102 dwarf2out_stack_adjust (insn
);
1106 label
= dwarf2out_cfi_label ();
1108 insn
= PATTERN (insn
);
1109 /* Assume that in a PARALLEL prologue insn, only the first elt is
1110 significant. Currently this is true. */
1111 if (GET_CODE (insn
) == PARALLEL
)
1112 insn
= XVECEXP (insn
, 0, 0);
1113 assert (GET_CODE (insn
) == SET
);
1115 src
= SET_SRC (insn
);
1116 dest
= SET_DEST (insn
);
1118 switch (GET_CODE (dest
))
1121 /* Update the CFA rule wrt SP or FP. Make sure src is
1122 relative to the current CFA register. */
1123 switch (GET_CODE (src
))
1125 /* Setting FP from SP. */
1127 assert (cfa_reg
== REGNO (src
));
1128 assert (REGNO (dest
) == STACK_POINTER_REGNUM
1129 || (frame_pointer_needed
1130 && REGNO (dest
) == HARD_FRAME_POINTER_REGNUM
));
1131 cfa_reg
= REGNO (dest
);
1136 if (dest
== stack_pointer_rtx
)
1139 switch (GET_CODE (XEXP (src
, 1)))
1142 offset
= INTVAL (XEXP (src
, 1));
1145 assert (REGNO (XEXP (src
, 1)) == cfa_temp_reg
);
1146 offset
= cfa_temp_value
;
1152 if (XEXP (src
, 0) == hard_frame_pointer_rtx
)
1154 /* Restoring SP from FP in the epilogue. */
1155 assert (cfa_reg
== HARD_FRAME_POINTER_REGNUM
);
1156 cfa_reg
= STACK_POINTER_REGNUM
;
1159 assert (XEXP (src
, 0) == stack_pointer_rtx
);
1161 if (GET_CODE (src
) == PLUS
)
1163 if (cfa_reg
== STACK_POINTER_REGNUM
)
1164 cfa_offset
+= offset
;
1165 if (cfa_store_reg
== STACK_POINTER_REGNUM
)
1166 cfa_store_offset
+= offset
;
1170 /* Initializing the store base register. */
1171 assert (GET_CODE (src
) == PLUS
);
1172 assert (XEXP (src
, 1) == stack_pointer_rtx
);
1173 assert (GET_CODE (XEXP (src
, 0)) == REG
1174 && REGNO (XEXP (src
, 0)) == cfa_temp_reg
);
1175 cfa_store_reg
= REGNO (dest
);
1176 cfa_store_offset
-= cfa_temp_value
;
1181 cfa_temp_reg
= REGNO (dest
);
1182 cfa_temp_value
= INTVAL (src
);
1186 assert (GET_CODE (XEXP (src
, 0)) == REG
1187 && REGNO (XEXP (src
, 0)) == cfa_temp_reg
);
1188 assert (REGNO (dest
) == cfa_temp_reg
);
1189 assert (GET_CODE (XEXP (src
, 1)) == CONST_INT
);
1190 cfa_temp_value
|= INTVAL (XEXP (src
, 1));
1196 dwarf2out_def_cfa (label
, cfa_reg
, cfa_offset
);
1200 /* Saving a register to the stack. Make sure dest is relative to the
1202 assert (GET_CODE (src
) == REG
);
1203 switch (GET_CODE (XEXP (dest
, 0)))
1208 offset
= GET_MODE_SIZE (GET_MODE (dest
));
1209 if (GET_CODE (XEXP (dest
, 0)) == PRE_INC
)
1212 assert (REGNO (XEXP (XEXP (dest
, 0), 0)) == STACK_POINTER_REGNUM
);
1213 assert (cfa_store_reg
== STACK_POINTER_REGNUM
);
1214 cfa_store_offset
+= offset
;
1215 if (cfa_reg
== STACK_POINTER_REGNUM
)
1216 cfa_offset
= cfa_store_offset
;
1218 offset
= -cfa_store_offset
;
1221 /* With an offset. */
1224 offset
= INTVAL (XEXP (XEXP (dest
, 0), 1));
1225 if (GET_CODE (src
) == MINUS
)
1228 assert (cfa_store_reg
== REGNO (XEXP (XEXP (dest
, 0), 0)));
1229 offset
-= cfa_store_offset
;
1235 dwarf2out_def_cfa (label
, cfa_reg
, cfa_offset
);
1236 dwarf2out_reg_save (label
, REGNO (src
), offset
);
1244 /* Return the size of an unsigned LEB128 quantity. */
1246 static inline unsigned long
1247 size_of_uleb128 (value
)
1248 register unsigned long value
;
1250 register unsigned long size
= 0;
1251 register unsigned byte
;
1255 byte
= (value
& 0x7f);
1264 /* Return the size of a signed LEB128 quantity. */
1266 static inline unsigned long
1267 size_of_sleb128 (value
)
1268 register long value
;
1270 register unsigned long size
= 0;
1271 register unsigned byte
;
1275 byte
= (value
& 0x7f);
1279 while (!(((value
== 0) && ((byte
& 0x40) == 0))
1280 || ((value
== -1) && ((byte
& 0x40) != 0))));
1285 /* Output an unsigned LEB128 quantity. */
1288 output_uleb128 (value
)
1289 register unsigned long value
;
1291 unsigned long save_value
= value
;
1293 fprintf (asm_out_file
, "\t%s\t", ASM_BYTE_OP
);
1296 register unsigned byte
= (value
& 0x7f);
1299 /* More bytes to follow. */
1302 fprintf (asm_out_file
, "0x%x", byte
);
1304 fprintf (asm_out_file
, ",");
1309 fprintf (asm_out_file
, "\t%s ULEB128 0x%x", ASM_COMMENT_START
, save_value
);
1312 /* Output an signed LEB128 quantity. */
1315 output_sleb128 (value
)
1316 register long value
;
1319 register unsigned byte
;
1320 long save_value
= value
;
1322 fprintf (asm_out_file
, "\t%s\t", ASM_BYTE_OP
);
1325 byte
= (value
& 0x7f);
1326 /* arithmetic shift */
1328 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
1329 || ((value
== -1) && ((byte
& 0x40) != 0))));
1333 fprintf (asm_out_file
, "0x%x", byte
);
1335 fprintf (asm_out_file
, ",");
1340 fprintf (asm_out_file
, "\t%s SLEB128 %d", ASM_COMMENT_START
, save_value
);
1343 /* Output a Call Frame Information opcode and its operand(s). */
1346 output_cfi (cfi
, fde
)
1347 register dw_cfi_ref cfi
;
1348 register dw_fde_ref fde
;
1350 if (cfi
->dw_cfi_opc
== DW_CFA_advance_loc
)
1352 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
1354 | (cfi
->dw_cfi_oprnd1
.dw_cfi_offset
& 0x3f));
1356 fprintf (asm_out_file
, "\t%s DW_CFA_advance_loc 0x%x",
1357 ASM_COMMENT_START
, cfi
->dw_cfi_oprnd1
.dw_cfi_offset
);
1358 fputc ('\n', asm_out_file
);
1361 else if (cfi
->dw_cfi_opc
== DW_CFA_offset
)
1363 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
1365 | (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
& 0x3f));
1367 fprintf (asm_out_file
, "\t%s DW_CFA_offset, column 0x%x",
1368 ASM_COMMENT_START
, cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1370 fputc ('\n', asm_out_file
);
1371 output_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_offset
);
1372 fputc ('\n', asm_out_file
);
1374 else if (cfi
->dw_cfi_opc
== DW_CFA_restore
)
1376 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
1378 | (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
& 0x3f));
1380 fprintf (asm_out_file
, "\t%s DW_CFA_restore, column 0x%x",
1381 ASM_COMMENT_START
, cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1383 fputc ('\n', asm_out_file
);
1387 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, cfi
->dw_cfi_opc
);
1389 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
,
1390 dwarf_cfi_name (cfi
->dw_cfi_opc
));
1392 fputc ('\n', asm_out_file
);
1393 switch (cfi
->dw_cfi_opc
)
1395 case DW_CFA_set_loc
:
1396 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, cfi
->dw_cfi_oprnd1
.dw_cfi_addr
);
1397 fputc ('\n', asm_out_file
);
1399 case DW_CFA_advance_loc1
:
1400 /* TODO: not currently implemented. */
1403 case DW_CFA_advance_loc2
:
1404 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
,
1405 cfi
->dw_cfi_oprnd1
.dw_cfi_addr
,
1406 fde
->dw_fde_current_label
);
1407 fputc ('\n', asm_out_file
);
1408 fde
->dw_fde_current_label
= cfi
->dw_cfi_oprnd1
.dw_cfi_addr
;
1410 case DW_CFA_advance_loc4
:
1411 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
,
1412 cfi
->dw_cfi_oprnd1
.dw_cfi_addr
,
1413 fde
->dw_fde_current_label
);
1414 fputc ('\n', asm_out_file
);
1415 fde
->dw_fde_current_label
= cfi
->dw_cfi_oprnd1
.dw_cfi_addr
;
1417 #ifdef MIPS_DEBUGGING_INFO
1418 case DW_CFA_MIPS_advance_loc8
:
1419 /* TODO: not currently implemented. */
1423 case DW_CFA_offset_extended
:
1424 case DW_CFA_def_cfa
:
1425 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1426 fputc ('\n', asm_out_file
);
1427 output_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_offset
);
1428 fputc ('\n', asm_out_file
);
1430 case DW_CFA_restore_extended
:
1431 case DW_CFA_undefined
:
1432 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1433 fputc ('\n', asm_out_file
);
1435 case DW_CFA_same_value
:
1436 case DW_CFA_def_cfa_register
:
1437 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1438 fputc ('\n', asm_out_file
);
1440 case DW_CFA_register
:
1441 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1442 fputc ('\n', asm_out_file
);
1443 output_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
);
1444 fputc ('\n', asm_out_file
);
1446 case DW_CFA_def_cfa_offset
:
1447 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_offset
);
1448 fputc ('\n', asm_out_file
);
1450 case DW_CFA_GNU_window_save
:
1452 case DW_CFA_GNU_args_size
:
1453 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_offset
);
1454 fputc ('\n', asm_out_file
);
1462 #if !defined (EH_FRAME_SECTION)
1463 #if defined (EH_FRAME_SECTION_ASM_OP)
1464 #define EH_FRAME_SECTION() eh_frame_section();
1466 #if defined (ASM_OUTPUT_SECTION_NAME)
1467 #define EH_FRAME_SECTION() \
1469 named_section (NULL_TREE, ".eh_frame", 0); \
1475 /* Output the call frame information used to used to record information
1476 that relates to calculating the frame pointer, and records the
1477 location of saved registers. */
1480 output_call_frame_info (for_eh
)
1483 register unsigned long i
, j
;
1484 register dw_fde_ref fde
;
1485 register unsigned long fde_size
;
1486 register dw_cfi_ref cfi
;
1487 unsigned long fde_pad
;
1488 char l1
[20], l2
[20];
1490 /* Do we want to include a pointer to the exception table? */
1491 int eh_ptr
= for_eh
&& exception_table_p ();
1493 fputc ('\n', asm_out_file
);
1495 /* We're going to be generating comments, so turn on app. */
1501 #ifdef EH_FRAME_SECTION
1502 EH_FRAME_SECTION ();
1504 tree label
= get_file_function_name ('F');
1507 ASM_GLOBALIZE_LABEL (asm_out_file
, IDENTIFIER_POINTER (label
));
1508 ASM_OUTPUT_LABEL (asm_out_file
, IDENTIFIER_POINTER (label
));
1510 assemble_label ("__FRAME_BEGIN__");
1513 ASM_OUTPUT_SECTION (asm_out_file
, FRAME_SECTION
);
1515 /* Output the CIE. */
1516 ASM_GENERATE_INTERNAL_LABEL (l1
, CIE_AFTER_SIZE_LABEL
, for_eh
);
1517 ASM_GENERATE_INTERNAL_LABEL (l2
, CIE_END_LABEL
, for_eh
);
1519 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, l2
, l1
);
1521 ASM_OUTPUT_DWARF_DELTA (asm_out_file
, l2
, l1
);
1523 fprintf (asm_out_file
, "\t%s Length of Common Information Entry",
1526 fputc ('\n', asm_out_file
);
1527 ASM_OUTPUT_LABEL (asm_out_file
, l1
);
1530 /* Now that the CIE pointer is PC-relative for EH,
1531 use 0 to identify the CIE. */
1532 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
1534 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, DW_CIE_ID
);
1537 fprintf (asm_out_file
, "\t%s CIE Identifier Tag", ASM_COMMENT_START
);
1539 fputc ('\n', asm_out_file
);
1540 if (! for_eh
&& DWARF_OFFSET_SIZE
== 8)
1542 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, DW_CIE_ID
);
1543 fputc ('\n', asm_out_file
);
1546 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_CIE_VERSION
);
1548 fprintf (asm_out_file
, "\t%s CIE Version", ASM_COMMENT_START
);
1550 fputc ('\n', asm_out_file
);
1553 /* The CIE contains a pointer to the exception region info for the
1554 frame. Make the augmentation string three bytes (including the
1555 trailing null) so the pointer is 4-byte aligned. The Solaris ld
1556 can't handle unaligned relocs. */
1559 ASM_OUTPUT_DWARF_STRING (asm_out_file
, "eh");
1560 fprintf (asm_out_file
, "\t%s CIE Augmentation", ASM_COMMENT_START
);
1564 ASM_OUTPUT_ASCII (asm_out_file
, "eh", 3);
1566 fputc ('\n', asm_out_file
);
1568 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, "__EXCEPTION_TABLE__");
1570 fprintf (asm_out_file
, "\t%s pointer to exception region info",
1575 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
1577 fprintf (asm_out_file
, "\t%s CIE Augmentation (none)",
1581 fputc ('\n', asm_out_file
);
1584 fprintf (asm_out_file
, " (CIE Code Alignment Factor)");
1586 fputc ('\n', asm_out_file
);
1587 output_sleb128 (DWARF_CIE_DATA_ALIGNMENT
);
1589 fprintf (asm_out_file
, " (CIE Data Alignment Factor)");
1591 fputc ('\n', asm_out_file
);
1592 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DWARF_FRAME_RETURN_COLUMN
);
1594 fprintf (asm_out_file
, "\t%s CIE RA Column", ASM_COMMENT_START
);
1596 fputc ('\n', asm_out_file
);
1598 for (cfi
= cie_cfi_head
; cfi
!= NULL
; cfi
= cfi
->dw_cfi_next
)
1599 output_cfi (cfi
, NULL
);
1601 /* Pad the CIE out to an address sized boundary. */
1602 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (PTR_SIZE
));
1603 ASM_OUTPUT_LABEL (asm_out_file
, l2
);
1605 /* Loop through all of the FDE's. */
1606 for (i
= 0; i
< fde_table_in_use
; ++i
)
1608 fde
= &fde_table
[i
];
1610 ASM_GENERATE_INTERNAL_LABEL (l1
, FDE_AFTER_SIZE_LABEL
, for_eh
+ i
*2);
1611 ASM_GENERATE_INTERNAL_LABEL (l2
, FDE_END_LABEL
, for_eh
+ i
*2);
1613 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, l2
, l1
);
1615 ASM_OUTPUT_DWARF_DELTA (asm_out_file
, l2
, l1
);
1617 fprintf (asm_out_file
, "\t%s FDE Length", ASM_COMMENT_START
);
1618 fputc ('\n', asm_out_file
);
1619 ASM_OUTPUT_LABEL (asm_out_file
, l1
);
1622 ASM_OUTPUT_DWARF_DELTA (asm_out_file
, l1
, "__FRAME_BEGIN__");
1624 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, stripattributes (FRAME_SECTION
));
1626 fprintf (asm_out_file
, "\t%s FDE CIE offset", ASM_COMMENT_START
);
1628 fputc ('\n', asm_out_file
);
1629 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, fde
->dw_fde_begin
);
1631 fprintf (asm_out_file
, "\t%s FDE initial location", ASM_COMMENT_START
);
1633 fputc ('\n', asm_out_file
);
1634 ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file
,
1635 fde
->dw_fde_end
, fde
->dw_fde_begin
);
1637 fprintf (asm_out_file
, "\t%s FDE address range", ASM_COMMENT_START
);
1639 fputc ('\n', asm_out_file
);
1641 /* Loop through the Call Frame Instructions associated with
1643 fde
->dw_fde_current_label
= fde
->dw_fde_begin
;
1644 for (cfi
= fde
->dw_fde_cfi
; cfi
!= NULL
; cfi
= cfi
->dw_cfi_next
)
1645 output_cfi (cfi
, fde
);
1647 /* Pad the FDE out to an address sized boundary. */
1648 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (PTR_SIZE
));
1649 ASM_OUTPUT_LABEL (asm_out_file
, l2
);
1651 #ifndef EH_FRAME_SECTION
1654 /* Emit terminating zero for table. */
1655 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
1656 fputc ('\n', asm_out_file
);
1659 #ifdef MIPS_DEBUGGING_INFO
1660 /* Work around Irix 6 assembler bug whereby labels at the end of a section
1661 get a value of 0. Putting .align 0 after the label fixes it. */
1662 ASM_OUTPUT_ALIGN (asm_out_file
, 0);
1665 /* Turn off app to make assembly quicker. */
1670 /* Output a marker (i.e. a label) for the beginning of a function, before
1674 dwarf2out_begin_prologue ()
1676 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1677 register dw_fde_ref fde
;
1679 ++current_funcdef_number
;
1681 function_section (current_function_decl
);
1682 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_BEGIN_LABEL
,
1683 current_funcdef_number
);
1684 ASM_OUTPUT_LABEL (asm_out_file
, label
);
1686 /* Expand the fde table if necessary. */
1687 if (fde_table_in_use
== fde_table_allocated
)
1689 fde_table_allocated
+= FDE_TABLE_INCREMENT
;
1691 = (dw_fde_ref
) xrealloc (fde_table
,
1692 fde_table_allocated
* sizeof (dw_fde_node
));
1695 /* Record the FDE associated with this function. */
1696 current_funcdef_fde
= fde_table_in_use
;
1698 /* Add the new FDE at the end of the fde_table. */
1699 fde
= &fde_table
[fde_table_in_use
++];
1700 fde
->dw_fde_begin
= xstrdup (label
);
1701 fde
->dw_fde_current_label
= NULL
;
1702 fde
->dw_fde_end
= NULL
;
1703 fde
->dw_fde_cfi
= NULL
;
1708 /* Output a marker (i.e. a label) for the absolute end of the generated code
1709 for a function definition. This gets called *after* the epilogue code has
1713 dwarf2out_end_epilogue ()
1716 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1718 /* Output a label to mark the endpoint of the code generated for this
1720 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_END_LABEL
, current_funcdef_number
);
1721 ASM_OUTPUT_LABEL (asm_out_file
, label
);
1722 fde
= &fde_table
[fde_table_in_use
- 1];
1723 fde
->dw_fde_end
= xstrdup (label
);
1727 dwarf2out_frame_init ()
1729 /* Allocate the initial hunk of the fde_table. */
1731 = (dw_fde_ref
) xmalloc (FDE_TABLE_INCREMENT
* sizeof (dw_fde_node
));
1732 bzero ((char *) fde_table
, FDE_TABLE_INCREMENT
* sizeof (dw_fde_node
));
1733 fde_table_allocated
= FDE_TABLE_INCREMENT
;
1734 fde_table_in_use
= 0;
1736 /* Generate the CFA instructions common to all FDE's. Do it now for the
1737 sake of lookup_cfa. */
1739 #ifdef DWARF2_UNWIND_INFO
1740 /* On entry, the Canonical Frame Address is at SP. */
1741 dwarf2out_def_cfa (NULL
, STACK_POINTER_REGNUM
, INCOMING_FRAME_SP_OFFSET
);
1742 initial_return_save (INCOMING_RETURN_ADDR_RTX
);
1747 dwarf2out_frame_finish ()
1749 /* Output call frame information. */
1750 #ifdef MIPS_DEBUGGING_INFO
1751 if (write_symbols
== DWARF2_DEBUG
)
1752 output_call_frame_info (0);
1753 if (flag_exceptions
&& ! exceptions_via_longjmp
)
1754 output_call_frame_info (1);
1756 if (write_symbols
== DWARF2_DEBUG
1757 || (flag_exceptions
&& ! exceptions_via_longjmp
))
1758 output_call_frame_info (1);
1762 #endif /* .debug_frame support */
1764 /* And now, the support for symbolic debugging information. */
1765 #ifdef DWARF2_DEBUGGING_INFO
1767 extern char *getpwd ();
1769 /* NOTE: In the comments in this file, many references are made to
1770 "Debugging Information Entries". This term is abbreviated as `DIE'
1771 throughout the remainder of this file. */
1773 /* An internal representation of the DWARF output is built, and then
1774 walked to generate the DWARF debugging info. The walk of the internal
1775 representation is done after the entire program has been compiled.
1776 The types below are used to describe the internal representation. */
1778 /* Each DIE may have a series of attribute/value pairs. Values
1779 can take on several forms. The forms that are used in this
1780 implementation are listed below. */
1787 dw_val_class_unsigned_const
,
1788 dw_val_class_long_long
,
1791 dw_val_class_die_ref
,
1792 dw_val_class_fde_ref
,
1793 dw_val_class_lbl_id
,
1794 dw_val_class_section_offset
,
1799 /* Various DIE's use offsets relative to the beginning of the
1800 .debug_info section to refer to each other. */
1802 typedef long int dw_offset
;
1804 /* Define typedefs here to avoid circular dependencies. */
1806 typedef struct die_struct
*dw_die_ref
;
1807 typedef struct dw_attr_struct
*dw_attr_ref
;
1808 typedef struct dw_val_struct
*dw_val_ref
;
1809 typedef struct dw_line_info_struct
*dw_line_info_ref
;
1810 typedef struct dw_separate_line_info_struct
*dw_separate_line_info_ref
;
1811 typedef struct dw_loc_descr_struct
*dw_loc_descr_ref
;
1812 typedef struct pubname_struct
*pubname_ref
;
1813 typedef dw_die_ref
*arange_ref
;
1815 /* Describe a double word constant value. */
1817 typedef struct dw_long_long_struct
1824 /* Describe a floating point constant value. */
1826 typedef struct dw_fp_struct
1833 /* Each entry in the line_info_table maintains the file and
1834 line nuber associated with the label generated for that
1835 entry. The label gives the PC value associated with
1836 the line number entry. */
1838 typedef struct dw_line_info_struct
1840 unsigned long dw_file_num
;
1841 unsigned long dw_line_num
;
1845 /* Line information for functions in separate sections; each one gets its
1847 typedef struct dw_separate_line_info_struct
1849 unsigned long dw_file_num
;
1850 unsigned long dw_line_num
;
1851 unsigned long function
;
1853 dw_separate_line_info_entry
;
1855 /* The dw_val_node describes an attibute's value, as it is
1856 represented internally. */
1858 typedef struct dw_val_struct
1860 dw_val_class val_class
;
1864 dw_loc_descr_ref val_loc
;
1866 long unsigned val_unsigned
;
1867 dw_long_long_const val_long_long
;
1868 dw_float_const val_float
;
1869 dw_die_ref val_die_ref
;
1870 unsigned val_fde_index
;
1874 unsigned char val_flag
;
1880 /* Locations in memory are described using a sequence of stack machine
1883 typedef struct dw_loc_descr_struct
1885 dw_loc_descr_ref dw_loc_next
;
1886 enum dwarf_location_atom dw_loc_opc
;
1887 dw_val_node dw_loc_oprnd1
;
1888 dw_val_node dw_loc_oprnd2
;
1892 /* Each DIE attribute has a field specifying the attribute kind,
1893 a link to the next attribute in the chain, and an attribute value.
1894 Attributes are typically linked below the DIE they modify. */
1896 typedef struct dw_attr_struct
1898 enum dwarf_attribute dw_attr
;
1899 dw_attr_ref dw_attr_next
;
1900 dw_val_node dw_attr_val
;
1904 /* The Debugging Information Entry (DIE) structure */
1906 typedef struct die_struct
1908 enum dwarf_tag die_tag
;
1909 dw_attr_ref die_attr
;
1910 dw_attr_ref die_attr_last
;
1911 dw_die_ref die_parent
;
1912 dw_die_ref die_child
;
1913 dw_die_ref die_child_last
;
1915 dw_offset die_offset
;
1916 unsigned long die_abbrev
;
1920 /* The pubname structure */
1922 typedef struct pubname_struct
1929 /* The limbo die list structure. */
1930 typedef struct limbo_die_struct
1933 struct limbo_die_struct
*next
;
1937 /* How to start an assembler comment. */
1938 #ifndef ASM_COMMENT_START
1939 #define ASM_COMMENT_START ";#"
1942 /* Define a macro which returns non-zero for a TYPE_DECL which was
1943 implicitly generated for a tagged type.
1945 Note that unlike the gcc front end (which generates a NULL named
1946 TYPE_DECL node for each complete tagged type, each array type, and
1947 each function type node created) the g++ front end generates a
1948 _named_ TYPE_DECL node for each tagged type node created.
1949 These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
1950 generate a DW_TAG_typedef DIE for them. */
1952 #define TYPE_DECL_IS_STUB(decl) \
1953 (DECL_NAME (decl) == NULL_TREE \
1954 || (DECL_ARTIFICIAL (decl) \
1955 && is_tagged_type (TREE_TYPE (decl)) \
1956 && ((decl == TYPE_STUB_DECL (TREE_TYPE (decl))) \
1957 /* This is necessary for stub decls that \
1958 appear in nested inline functions. */ \
1959 || (DECL_ABSTRACT_ORIGIN (decl) != NULL_TREE \
1960 && (decl_ultimate_origin (decl) \
1961 == TYPE_STUB_DECL (TREE_TYPE (decl)))))))
1963 /* Information concerning the compilation unit's programming
1964 language, and compiler version. */
1966 extern int flag_traditional
;
1967 extern char *version_string
;
1968 extern char *language_string
;
1970 /* Fixed size portion of the DWARF compilation unit header. */
1971 #define DWARF_COMPILE_UNIT_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 3)
1973 /* Fixed size portion of debugging line information prolog. */
1974 #define DWARF_LINE_PROLOG_HEADER_SIZE 5
1976 /* Fixed size portion of public names info. */
1977 #define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
1979 /* Fixed size portion of the address range info. */
1980 #define DWARF_ARANGES_HEADER_SIZE \
1981 (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, PTR_SIZE * 2) - DWARF_OFFSET_SIZE)
1983 /* Define the architecture-dependent minimum instruction length (in bytes).
1984 In this implementation of DWARF, this field is used for information
1985 purposes only. Since GCC generates assembly language, we have
1986 no a priori knowledge of how many instruction bytes are generated
1987 for each source line, and therefore can use only the DW_LNE_set_address
1988 and DW_LNS_fixed_advance_pc line information commands. */
1990 #ifndef DWARF_LINE_MIN_INSTR_LENGTH
1991 #define DWARF_LINE_MIN_INSTR_LENGTH 4
1994 /* Minimum line offset in a special line info. opcode.
1995 This value was chosen to give a reasonable range of values. */
1996 #define DWARF_LINE_BASE -10
1998 /* First special line opcde - leave room for the standard opcodes. */
1999 #define DWARF_LINE_OPCODE_BASE 10
2001 /* Range of line offsets in a special line info. opcode. */
2002 #define DWARF_LINE_RANGE (254-DWARF_LINE_OPCODE_BASE+1)
2004 /* Flag that indicates the initial value of the is_stmt_start flag.
2005 In the present implementation, we do not mark any lines as
2006 the beginning of a source statement, because that information
2007 is not made available by the GCC front-end. */
2008 #define DWARF_LINE_DEFAULT_IS_STMT_START 1
2010 /* This location is used by calc_die_sizes() to keep track
2011 the offset of each DIE within the .debug_info section. */
2012 static unsigned long next_die_offset
;
2014 /* Record the root of the DIE's built for the current compilation unit. */
2015 static dw_die_ref comp_unit_die
;
2017 /* A list of DIEs with a NULL parent waiting to be relocated. */
2018 static limbo_die_node
*limbo_die_list
= 0;
2020 /* Pointer to an array of filenames referenced by this compilation unit. */
2021 static char **file_table
;
2023 /* Total number of entries in the table (i.e. array) pointed to by
2024 `file_table'. This is the *total* and includes both used and unused
2026 static unsigned file_table_allocated
;
2028 /* Number of entries in the file_table which are actually in use. */
2029 static unsigned file_table_in_use
;
2031 /* Size (in elements) of increments by which we may expand the filename
2033 #define FILE_TABLE_INCREMENT 64
2035 /* Local pointer to the name of the main input file. Initialized in
2037 static char *primary_filename
;
2039 /* For Dwarf output, we must assign lexical-blocks id numbers in the order in
2040 which their beginnings are encountered. We output Dwarf debugging info
2041 that refers to the beginnings and ends of the ranges of code for each
2042 lexical block. The labels themselves are generated in final.c, which
2043 assigns numbers to the blocks in the same way. */
2044 static unsigned next_block_number
= 2;
2046 /* A pointer to the base of a table of references to DIE's that describe
2047 declarations. The table is indexed by DECL_UID() which is a unique
2048 number, indentifying each decl. */
2049 static dw_die_ref
*decl_die_table
;
2051 /* Number of elements currently allocated for the decl_die_table. */
2052 static unsigned decl_die_table_allocated
;
2054 /* Number of elements in decl_die_table currently in use. */
2055 static unsigned decl_die_table_in_use
;
2057 /* Size (in elements) of increments by which we may expand the
2059 #define DECL_DIE_TABLE_INCREMENT 256
2061 /* A pointer to the base of a table of references to declaration
2062 scopes. This table is a display which tracks the nesting
2063 of declaration scopes at the current scope and containing
2064 scopes. This table is used to find the proper place to
2065 define type declaration DIE's. */
2066 static tree
*decl_scope_table
;
2068 /* Number of elements currently allocated for the decl_scope_table. */
2069 static unsigned decl_scope_table_allocated
;
2071 /* Current level of nesting of declataion scopes. */
2072 static unsigned decl_scope_depth
;
2074 /* Size (in elements) of increments by which we may expand the
2075 decl_scope_table. */
2076 #define DECL_SCOPE_TABLE_INCREMENT 64
2078 /* A pointer to the base of a list of references to DIE's that
2079 are uniquely identified by their tag, presence/absence of
2080 children DIE's, and list of attribute/value pairs. */
2081 static dw_die_ref
*abbrev_die_table
;
2083 /* Number of elements currently allocated for abbrev_die_table. */
2084 static unsigned abbrev_die_table_allocated
;
2086 /* Number of elements in type_die_table currently in use. */
2087 static unsigned abbrev_die_table_in_use
;
2089 /* Size (in elements) of increments by which we may expand the
2090 abbrev_die_table. */
2091 #define ABBREV_DIE_TABLE_INCREMENT 256
2093 /* A pointer to the base of a table that contains line information
2094 for each source code line in .text in the compilation unit. */
2095 static dw_line_info_ref line_info_table
;
2097 /* Number of elements currently allocated for line_info_table. */
2098 static unsigned line_info_table_allocated
;
2100 /* Number of elements in separate_line_info_table currently in use. */
2101 static unsigned separate_line_info_table_in_use
;
2103 /* A pointer to the base of a table that contains line information
2104 for each source code line outside of .text in the compilation unit. */
2105 static dw_separate_line_info_ref separate_line_info_table
;
2107 /* Number of elements currently allocated for separate_line_info_table. */
2108 static unsigned separate_line_info_table_allocated
;
2110 /* Number of elements in line_info_table currently in use. */
2111 static unsigned line_info_table_in_use
;
2113 /* Size (in elements) of increments by which we may expand the
2115 #define LINE_INFO_TABLE_INCREMENT 1024
2117 /* A pointer to the base of a table that contains a list of publicly
2118 accessible names. */
2119 static pubname_ref pubname_table
;
2121 /* Number of elements currently allocated for pubname_table. */
2122 static unsigned pubname_table_allocated
;
2124 /* Number of elements in pubname_table currently in use. */
2125 static unsigned pubname_table_in_use
;
2127 /* Size (in elements) of increments by which we may expand the
2129 #define PUBNAME_TABLE_INCREMENT 64
2131 /* A pointer to the base of a table that contains a list of publicly
2132 accessible names. */
2133 static arange_ref arange_table
;
2135 /* Number of elements currently allocated for arange_table. */
2136 static unsigned arange_table_allocated
;
2138 /* Number of elements in arange_table currently in use. */
2139 static unsigned arange_table_in_use
;
2141 /* Size (in elements) of increments by which we may expand the
2143 #define ARANGE_TABLE_INCREMENT 64
2145 /* A pointer to the base of a list of pending types which we haven't
2146 generated DIEs for yet, but which we will have to come back to
2149 static tree
*pending_types_list
;
2151 /* Number of elements currently allocated for the pending_types_list. */
2152 static unsigned pending_types_allocated
;
2154 /* Number of elements of pending_types_list currently in use. */
2155 static unsigned pending_types
;
2157 /* Size (in elements) of increments by which we may expand the pending
2158 types list. Actually, a single hunk of space of this size should
2159 be enough for most typical programs. */
2160 #define PENDING_TYPES_INCREMENT 64
2162 /* Record whether the function being analyzed contains inlined functions. */
2163 static int current_function_has_inlines
;
2164 static int comp_unit_has_inlines
;
2166 /* A pointer to the ..._DECL node which we have most recently been working
2167 on. We keep this around just in case something about it looks screwy and
2168 we want to tell the user what the source coordinates for the actual
2170 static tree dwarf_last_decl
;
2172 /* Forward declarations for functions defined in this file. */
2174 static void addr_const_to_string
PROTO((char *, rtx
));
2175 static char *addr_to_string
PROTO((rtx
));
2176 static int is_pseudo_reg
PROTO((rtx
));
2177 static tree type_main_variant
PROTO((tree
));
2178 static int is_tagged_type
PROTO((tree
));
2179 static char *dwarf_tag_name
PROTO((unsigned));
2180 static char *dwarf_attr_name
PROTO((unsigned));
2181 static char *dwarf_form_name
PROTO((unsigned));
2182 static char *dwarf_stack_op_name
PROTO((unsigned));
2183 static char *dwarf_type_encoding_name
PROTO((unsigned));
2184 static tree decl_ultimate_origin
PROTO((tree
));
2185 static tree block_ultimate_origin
PROTO((tree
));
2186 static tree decl_class_context
PROTO((tree
));
2187 static void add_dwarf_attr
PROTO((dw_die_ref
, dw_attr_ref
));
2188 static void add_AT_flag
PROTO((dw_die_ref
,
2189 enum dwarf_attribute
,
2191 static void add_AT_int
PROTO((dw_die_ref
,
2192 enum dwarf_attribute
, long));
2193 static void add_AT_unsigned
PROTO((dw_die_ref
,
2194 enum dwarf_attribute
,
2196 static void add_AT_long_long
PROTO((dw_die_ref
,
2197 enum dwarf_attribute
,
2198 unsigned long, unsigned long));
2199 static void add_AT_float
PROTO((dw_die_ref
,
2200 enum dwarf_attribute
,
2202 static void add_AT_string
PROTO((dw_die_ref
,
2203 enum dwarf_attribute
, char *));
2204 static void add_AT_die_ref
PROTO((dw_die_ref
,
2205 enum dwarf_attribute
,
2207 static void add_AT_fde_ref
PROTO((dw_die_ref
,
2208 enum dwarf_attribute
,
2210 static void add_AT_loc
PROTO((dw_die_ref
,
2211 enum dwarf_attribute
,
2213 static void add_AT_addr
PROTO((dw_die_ref
,
2214 enum dwarf_attribute
, char *));
2215 static void add_AT_lbl_id
PROTO((dw_die_ref
,
2216 enum dwarf_attribute
, char *));
2217 static void add_AT_setion_offset
PROTO((dw_die_ref
,
2218 enum dwarf_attribute
, char *));
2219 static int is_extern_subr_die
PROTO((dw_die_ref
));
2220 static dw_attr_ref get_AT
PROTO((dw_die_ref
,
2221 enum dwarf_attribute
));
2222 static char *get_AT_low_pc
PROTO((dw_die_ref
));
2223 static char *get_AT_hi_pc
PROTO((dw_die_ref
));
2224 static char *get_AT_string
PROTO((dw_die_ref
,
2225 enum dwarf_attribute
));
2226 static int get_AT_flag
PROTO((dw_die_ref
,
2227 enum dwarf_attribute
));
2228 static unsigned get_AT_unsigned
PROTO((dw_die_ref
,
2229 enum dwarf_attribute
));
2230 static int is_c_family
PROTO((void));
2231 static int is_fortran
PROTO((void));
2232 static void remove_AT
PROTO((dw_die_ref
,
2233 enum dwarf_attribute
));
2234 static void remove_children
PROTO((dw_die_ref
));
2235 static void add_child_die
PROTO((dw_die_ref
, dw_die_ref
));
2236 static dw_die_ref new_die
PROTO((enum dwarf_tag
, dw_die_ref
));
2237 static dw_die_ref lookup_type_die
PROTO((tree
));
2238 static void equate_type_number_to_die
PROTO((tree
, dw_die_ref
));
2239 static dw_die_ref lookup_decl_die
PROTO((tree
));
2240 static void equate_decl_number_to_die
PROTO((tree
, dw_die_ref
));
2241 static dw_loc_descr_ref new_loc_descr
PROTO((enum dwarf_location_atom
,
2242 unsigned long, unsigned long));
2243 static void add_loc_descr
PROTO((dw_loc_descr_ref
*,
2245 static void print_spaces
PROTO((FILE *));
2246 static void print_die
PROTO((dw_die_ref
, FILE *));
2247 static void print_dwarf_line_table
PROTO((FILE *));
2248 static void add_sibling_atttributes
PROTO((dw_die_ref
));
2249 static void build_abbrev_table
PROTO((dw_die_ref
));
2250 static unsigned long size_of_string
PROTO((char *));
2251 static unsigned long size_of_loc_descr
PROTO((dw_loc_descr_ref
));
2252 static unsigned long size_of_locs
PROTO((dw_loc_descr_ref
));
2253 static int constant_size
PROTO((long unsigned));
2254 static unsigned long size_of_die
PROTO((dw_die_ref
));
2255 static void calc_die_sizes
PROTO((dw_die_ref
));
2256 static unsigned long size_of_prolog
PROTO((void));
2257 static unsigned long size_of_line_info
PROTO((void));
2258 static unsigned long size_of_pubnames
PROTO((void));
2259 static unsigned long size_of_aranges
PROTO((void));
2260 static enum dwarf_form value_format
PROTO((dw_val_ref
));
2261 static void output_value_format
PROTO((dw_val_ref
));
2262 static void output_abbrev_section
PROTO((void));
2263 static void output_loc_operands
PROTO((dw_loc_descr_ref
));
2264 static unsigned long sibling_offset
PROTO((dw_die_ref
));
2265 static void output_die
PROTO((dw_die_ref
));
2266 static void output_compilation_unit_header
PROTO((void));
2267 static char *dwarf2_name
PROTO((tree
, int));
2268 static void add_pubname
PROTO((tree
, dw_die_ref
));
2269 static void output_pubnames
PROTO((void));
2270 static void add_arrange
PROTO((tree
, dw_die_ref
));
2271 static void output_arranges
PROTO((void));
2272 static void output_line_info
PROTO((void));
2273 static int is_body_block
PROTO((tree
));
2274 static dw_die_ref base_type_die
PROTO((tree
));
2275 static tree root_type
PROTO((tree
));
2276 static int is_base_type
PROTO((tree
));
2277 static dw_die_ref modified_type_die
PROTO((tree
, int, int, dw_die_ref
));
2278 static int type_is_enum
PROTO((tree
));
2279 static dw_loc_descr_ref reg_loc_descriptor
PROTO((rtx
));
2280 static dw_loc_descr_ref based_loc_descr
PROTO((unsigned, long));
2281 static int is_based_loc
PROTO((rtx
));
2282 static dw_loc_descr_ref mem_loc_descriptor
PROTO((rtx
));
2283 static dw_loc_descr_ref concat_loc_descriptor
PROTO((rtx
, rtx
));
2284 static dw_loc_descr_ref loc_descriptor
PROTO((rtx
));
2285 static unsigned ceiling
PROTO((unsigned, unsigned));
2286 static tree field_type
PROTO((tree
));
2287 static unsigned simple_type_align_in_bits
PROTO((tree
));
2288 static unsigned simple_type_size_in_bits
PROTO((tree
));
2289 static unsigned field_byte_offset
PROTO((tree
));
2290 static void add_AT_location_description
PROTO((dw_die_ref
,
2291 enum dwarf_attribute
, rtx
));
2292 static void add_data_member_location_attribute
PROTO((dw_die_ref
, tree
));
2293 static void add_const_value_attribute
PROTO((dw_die_ref
, rtx
));
2294 static void add_location_or_const_value_attribute
PROTO((dw_die_ref
, tree
));
2295 static void add_name_attribute
PROTO((dw_die_ref
, char *));
2296 static void add_bound_info
PROTO((dw_die_ref
,
2297 enum dwarf_attribute
, tree
));
2298 static void add_subscript_info
PROTO((dw_die_ref
, tree
));
2299 static void add_byte_size_attribute
PROTO((dw_die_ref
, tree
));
2300 static void add_bit_offset_attribute
PROTO((dw_die_ref
, tree
));
2301 static void add_bit_size_attribute
PROTO((dw_die_ref
, tree
));
2302 static void add_prototyped_attribute
PROTO((dw_die_ref
, tree
));
2303 static void add_abstract_origin_attribute
PROTO((dw_die_ref
, tree
));
2304 static void add_pure_or_virtual_attribute
PROTO((dw_die_ref
, tree
));
2305 static void add_src_coords_attributes
PROTO((dw_die_ref
, tree
));
2306 static void ad_name_and_src_coords_attributes
PROTO((dw_die_ref
, tree
));
2307 static void push_decl_scope
PROTO((tree
));
2308 static dw_die_ref scope_die_for
PROTO((tree
, dw_die_ref
));
2309 static void pop_decl_scope
PROTO((void));
2310 static void add_type_attribute
PROTO((dw_die_ref
, tree
, int, int,
2312 static char *type_tag
PROTO((tree
));
2313 static tree member_declared_type
PROTO((tree
));
2314 static char *decl_start_label
PROTO((tree
));
2315 static void gen_arrqay_type_die
PROTO((tree
, dw_die_ref
));
2316 static void gen_set_type_die
PROTO((tree
, dw_die_ref
));
2317 static void gen_entry_point_die
PROTO((tree
, dw_die_ref
));
2318 static void pend_type
PROTO((tree
));
2319 static void output_pending_types_for_scope
PROTO((dw_die_ref
));
2320 static void gen_inlined_enumeration_type_die
PROTO((tree
, dw_die_ref
));
2321 static void gen_inlined_structure_type_die
PROTO((tree
, dw_die_ref
));
2322 static void gen_inlined_union_type_die
PROTO((tree
, dw_die_ref
));
2323 static void gen_enumeration_type_die
PROTO((tree
, dw_die_ref
));
2324 static dw_die_ref gen_formal_parameter_die
PROTO((tree
, dw_die_ref
));
2325 static void gen_unspecified_parameters_die
PROTO((tree
, dw_die_ref
));
2326 static void gen_formal_types_die
PROTO((tree
, dw_die_ref
));
2327 static void gen_subprogram_die
PROTO((tree
, dw_die_ref
));
2328 static void gen_variable_die
PROTO((tree
, dw_die_ref
));
2329 static void gen_label_die
PROTO((tree
, dw_die_ref
));
2330 static void gen_lexical_block_die
PROTO((tree
, dw_die_ref
, int));
2331 static void gen_inlined_subprogram_die
PROTO((tree
, dw_die_ref
, int));
2332 static void gen_field_die
PROTO((tree
, dw_die_ref
));
2333 static void gen_ptr_to_mbr_type_die
PROTO((tree
, dw_die_ref
));
2334 static void gen_compile_unit_die
PROTO((char *));
2335 static void gen_string_type_die
PROTO((tree
, dw_die_ref
));
2336 static void gen_inheritance_die
PROTO((tree
, dw_die_ref
));
2337 static void gen_member_die
PROTO((tree
, dw_die_ref
));
2338 static void gen_struct_or_union_type_die
PROTO((tree
, dw_die_ref
));
2339 static void gen_subroutine_type_die
PROTO((tree
, dw_die_ref
));
2340 static void gen_typedef_die
PROTO((tree
, dw_die_ref
));
2341 static void gen_type_die
PROTO((tree
, dw_die_ref
));
2342 static void gen_tagged_type_instantiation_die
PROTO((tree
, dw_die_ref
));
2343 static void gen_block_die
PROTO((tree
, dw_die_ref
, int));
2344 static void decls_for_scope
PROTO((tree
, dw_die_ref
, int));
2345 static int is_redundant_typedef
PROTO((tree
));
2346 static void gen_decl_die
PROTO((tree
, dw_die_ref
));
2347 static unsigned lookup_filename
PROTO((char *));
2349 /* Section names used to hold DWARF debugging information. */
2350 #ifndef DEBUG_INFO_SECTION
2351 #define DEBUG_INFO_SECTION ".debug_info"
2353 #ifndef ABBREV_SECTION
2354 #define ABBREV_SECTION ".debug_abbrev"
2356 #ifndef ARANGES_SECTION
2357 #define ARANGES_SECTION ".debug_aranges"
2359 #ifndef DW_MACINFO_SECTION
2360 #define DW_MACINFO_SECTION ".debug_macinfo"
2362 #ifndef DEBUG_LINE_SECTION
2363 #define DEBUG_LINE_SECTION ".debug_line"
2366 #define LOC_SECTION ".debug_loc"
2368 #ifndef PUBNAMES_SECTION
2369 #define PUBNAMES_SECTION ".debug_pubnames"
2372 #define STR_SECTION ".debug_str"
2375 /* Standerd ELF section names for compiled code and data. */
2376 #ifndef TEXT_SECTION
2377 #define TEXT_SECTION ".text"
2379 #ifndef DATA_SECTION
2380 #define DATA_SECTION ".data"
2383 #define BSS_SECTION ".bss"
2387 /* Definitions of defaults for formats and names of various special
2388 (artificial) labels which may be generated within this file (when the -g
2389 options is used and DWARF_DEBUGGING_INFO is in effect.
2390 If necessary, these may be overridden from within the tm.h file, but
2391 typically, overriding these defaults is unnecessary. */
2393 static char text_end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2395 #ifndef TEXT_END_LABEL
2396 #define TEXT_END_LABEL "Letext"
2398 #ifndef DATA_END_LABEL
2399 #define DATA_END_LABEL "Ledata"
2401 #ifndef BSS_END_LABEL
2402 #define BSS_END_LABEL "Lebss"
2404 #ifndef INSN_LABEL_FMT
2405 #define INSN_LABEL_FMT "LI%u_"
2407 #ifndef BLOCK_BEGIN_LABEL
2408 #define BLOCK_BEGIN_LABEL "LBB"
2410 #ifndef BLOCK_END_LABEL
2411 #define BLOCK_END_LABEL "LBE"
2413 #ifndef BODY_BEGIN_LABEL
2414 #define BODY_BEGIN_LABEL "Lbb"
2416 #ifndef BODY_END_LABEL
2417 #define BODY_END_LABEL "Lbe"
2419 #ifndef LINE_CODE_LABEL
2420 #define LINE_CODE_LABEL "LM"
2422 #ifndef SEPARATE_LINE_CODE_LABEL
2423 #define SEPARATE_LINE_CODE_LABEL "LSM"
2426 /* Convert a reference to the assembler name of a C-level name. This
2427 macro has the same effect as ASM_OUTPUT_LABELREF, but copies to
2428 a string rather than writing to a file. */
2429 #ifndef ASM_NAME_TO_STRING
2430 #define ASM_NAME_TO_STRING(STR, NAME) \
2432 if ((NAME)[0] == '*') \
2433 strcpy (STR, NAME+1); \
2435 strcpy (STR, NAME); \
2440 /* Convert an integer constant expression into assembler syntax. Addition
2441 and subtraction are the only arithmetic that may appear in these
2442 expressions. This is an adaptation of output_addr_const in final.c.
2443 Here, the target of the conversion is a string buffer. We can't use
2444 output_addr_const directly, because it writes to a file. */
2447 addr_const_to_string (str
, x
)
2456 switch (GET_CODE (x
))
2466 ASM_NAME_TO_STRING (buf1
, XSTR (x
, 0));
2471 ASM_GENERATE_INTERNAL_LABEL (buf1
, "L", CODE_LABEL_NUMBER (XEXP (x
, 0)));
2472 ASM_NAME_TO_STRING (buf2
, buf1
);
2477 ASM_GENERATE_INTERNAL_LABEL (buf1
, "L", CODE_LABEL_NUMBER (x
));
2478 ASM_NAME_TO_STRING (buf2
, buf1
);
2483 sprintf (buf1
, HOST_WIDE_INT_PRINT_DEC
, INTVAL (x
));
2488 /* This used to output parentheses around the expression, but that does
2489 not work on the 386 (either ATT or BSD assembler). */
2490 addr_const_to_string (buf1
, XEXP (x
, 0));
2495 if (GET_MODE (x
) == VOIDmode
)
2497 /* We can use %d if the number is one word and positive. */
2498 if (CONST_DOUBLE_HIGH (x
))
2499 sprintf (buf1
, HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
2500 CONST_DOUBLE_HIGH (x
), CONST_DOUBLE_LOW (x
));
2501 else if (CONST_DOUBLE_LOW (x
) < 0)
2502 sprintf (buf1
, HOST_WIDE_INT_PRINT_HEX
, CONST_DOUBLE_LOW (x
));
2504 sprintf (buf1
, HOST_WIDE_INT_PRINT_DEC
,
2505 CONST_DOUBLE_LOW (x
));
2509 /* We can't handle floating point constants; PRINT_OPERAND must
2511 output_operand_lossage ("floating constant misused");
2515 /* Some assemblers need integer constants to appear last (eg masm). */
2516 if (GET_CODE (XEXP (x
, 0)) == CONST_INT
)
2518 addr_const_to_string (buf1
, XEXP (x
, 1));
2520 if (INTVAL (XEXP (x
, 0)) >= 0)
2523 addr_const_to_string (buf1
, XEXP (x
, 0));
2528 addr_const_to_string (buf1
, XEXP (x
, 0));
2530 if (INTVAL (XEXP (x
, 1)) >= 0)
2533 addr_const_to_string (buf1
, XEXP (x
, 1));
2539 /* Avoid outputting things like x-x or x+5-x, since some assemblers
2540 can't handle that. */
2541 x
= simplify_subtraction (x
);
2542 if (GET_CODE (x
) != MINUS
)
2545 addr_const_to_string (buf1
, XEXP (x
, 0));
2548 if (GET_CODE (XEXP (x
, 1)) == CONST_INT
2549 && INTVAL (XEXP (x
, 1)) < 0)
2551 strcat (str
, ASM_OPEN_PAREN
);
2552 addr_const_to_string (buf1
, XEXP (x
, 1));
2554 strcat (str
, ASM_CLOSE_PAREN
);
2558 addr_const_to_string (buf1
, XEXP (x
, 1));
2565 addr_const_to_string (buf1
, XEXP (x
, 0));
2570 output_operand_lossage ("invalid expression as operand");
2574 /* Convert an address constant to a string, and return a pointer to
2575 a copy of the result, located on the heap. */
2582 addr_const_to_string (buf
, x
);
2583 return xstrdup (buf
);
2586 /* Test if rtl node points to a psuedo register. */
2592 return (((GET_CODE (rtl
) == REG
) && (REGNO (rtl
) >= FIRST_PSEUDO_REGISTER
))
2593 || ((GET_CODE (rtl
) == SUBREG
)
2594 && (REGNO (XEXP (rtl
, 0)) >= FIRST_PSEUDO_REGISTER
)));
2597 /* Return a reference to a type, with its const and volatile qualifiers
2601 type_main_variant (type
)
2604 type
= TYPE_MAIN_VARIANT (type
);
2606 /* There really should be only one main variant among any group of variants
2607 of a given type (and all of the MAIN_VARIANT values for all members of
2608 the group should point to that one type) but sometimes the C front-end
2609 messes this up for array types, so we work around that bug here. */
2611 if (TREE_CODE (type
) == ARRAY_TYPE
)
2612 while (type
!= TYPE_MAIN_VARIANT (type
))
2613 type
= TYPE_MAIN_VARIANT (type
);
2618 /* Return non-zero if the given type node represents a tagged type. */
2621 is_tagged_type (type
)
2624 register enum tree_code code
= TREE_CODE (type
);
2626 return (code
== RECORD_TYPE
|| code
== UNION_TYPE
2627 || code
== QUAL_UNION_TYPE
|| code
== ENUMERAL_TYPE
);
2630 /* Convert a DIE tag into its string name. */
2633 dwarf_tag_name (tag
)
2634 register unsigned tag
;
2638 case DW_TAG_padding
:
2639 return "DW_TAG_padding";
2640 case DW_TAG_array_type
:
2641 return "DW_TAG_array_type";
2642 case DW_TAG_class_type
:
2643 return "DW_TAG_class_type";
2644 case DW_TAG_entry_point
:
2645 return "DW_TAG_entry_point";
2646 case DW_TAG_enumeration_type
:
2647 return "DW_TAG_enumeration_type";
2648 case DW_TAG_formal_parameter
:
2649 return "DW_TAG_formal_parameter";
2650 case DW_TAG_imported_declaration
:
2651 return "DW_TAG_imported_declaration";
2653 return "DW_TAG_label";
2654 case DW_TAG_lexical_block
:
2655 return "DW_TAG_lexical_block";
2657 return "DW_TAG_member";
2658 case DW_TAG_pointer_type
:
2659 return "DW_TAG_pointer_type";
2660 case DW_TAG_reference_type
:
2661 return "DW_TAG_reference_type";
2662 case DW_TAG_compile_unit
:
2663 return "DW_TAG_compile_unit";
2664 case DW_TAG_string_type
:
2665 return "DW_TAG_string_type";
2666 case DW_TAG_structure_type
:
2667 return "DW_TAG_structure_type";
2668 case DW_TAG_subroutine_type
:
2669 return "DW_TAG_subroutine_type";
2670 case DW_TAG_typedef
:
2671 return "DW_TAG_typedef";
2672 case DW_TAG_union_type
:
2673 return "DW_TAG_union_type";
2674 case DW_TAG_unspecified_parameters
:
2675 return "DW_TAG_unspecified_parameters";
2676 case DW_TAG_variant
:
2677 return "DW_TAG_variant";
2678 case DW_TAG_common_block
:
2679 return "DW_TAG_common_block";
2680 case DW_TAG_common_inclusion
:
2681 return "DW_TAG_common_inclusion";
2682 case DW_TAG_inheritance
:
2683 return "DW_TAG_inheritance";
2684 case DW_TAG_inlined_subroutine
:
2685 return "DW_TAG_inlined_subroutine";
2687 return "DW_TAG_module";
2688 case DW_TAG_ptr_to_member_type
:
2689 return "DW_TAG_ptr_to_member_type";
2690 case DW_TAG_set_type
:
2691 return "DW_TAG_set_type";
2692 case DW_TAG_subrange_type
:
2693 return "DW_TAG_subrange_type";
2694 case DW_TAG_with_stmt
:
2695 return "DW_TAG_with_stmt";
2696 case DW_TAG_access_declaration
:
2697 return "DW_TAG_access_declaration";
2698 case DW_TAG_base_type
:
2699 return "DW_TAG_base_type";
2700 case DW_TAG_catch_block
:
2701 return "DW_TAG_catch_block";
2702 case DW_TAG_const_type
:
2703 return "DW_TAG_const_type";
2704 case DW_TAG_constant
:
2705 return "DW_TAG_constant";
2706 case DW_TAG_enumerator
:
2707 return "DW_TAG_enumerator";
2708 case DW_TAG_file_type
:
2709 return "DW_TAG_file_type";
2711 return "DW_TAG_friend";
2712 case DW_TAG_namelist
:
2713 return "DW_TAG_namelist";
2714 case DW_TAG_namelist_item
:
2715 return "DW_TAG_namelist_item";
2716 case DW_TAG_packed_type
:
2717 return "DW_TAG_packed_type";
2718 case DW_TAG_subprogram
:
2719 return "DW_TAG_subprogram";
2720 case DW_TAG_template_type_param
:
2721 return "DW_TAG_template_type_param";
2722 case DW_TAG_template_value_param
:
2723 return "DW_TAG_template_value_param";
2724 case DW_TAG_thrown_type
:
2725 return "DW_TAG_thrown_type";
2726 case DW_TAG_try_block
:
2727 return "DW_TAG_try_block";
2728 case DW_TAG_variant_part
:
2729 return "DW_TAG_variant_part";
2730 case DW_TAG_variable
:
2731 return "DW_TAG_variable";
2732 case DW_TAG_volatile_type
:
2733 return "DW_TAG_volatile_type";
2734 case DW_TAG_MIPS_loop
:
2735 return "DW_TAG_MIPS_loop";
2736 case DW_TAG_format_label
:
2737 return "DW_TAG_format_label";
2738 case DW_TAG_function_template
:
2739 return "DW_TAG_function_template";
2740 case DW_TAG_class_template
:
2741 return "DW_TAG_class_template";
2743 return "DW_TAG_<unknown>";
2747 /* Convert a DWARF attribute code into its string name. */
2750 dwarf_attr_name (attr
)
2751 register unsigned attr
;
2756 return "DW_AT_sibling";
2757 case DW_AT_location
:
2758 return "DW_AT_location";
2760 return "DW_AT_name";
2761 case DW_AT_ordering
:
2762 return "DW_AT_ordering";
2763 case DW_AT_subscr_data
:
2764 return "DW_AT_subscr_data";
2765 case DW_AT_byte_size
:
2766 return "DW_AT_byte_size";
2767 case DW_AT_bit_offset
:
2768 return "DW_AT_bit_offset";
2769 case DW_AT_bit_size
:
2770 return "DW_AT_bit_size";
2771 case DW_AT_element_list
:
2772 return "DW_AT_element_list";
2773 case DW_AT_stmt_list
:
2774 return "DW_AT_stmt_list";
2776 return "DW_AT_low_pc";
2778 return "DW_AT_high_pc";
2779 case DW_AT_language
:
2780 return "DW_AT_language";
2782 return "DW_AT_member";
2784 return "DW_AT_discr";
2785 case DW_AT_discr_value
:
2786 return "DW_AT_discr_value";
2787 case DW_AT_visibility
:
2788 return "DW_AT_visibility";
2790 return "DW_AT_import";
2791 case DW_AT_string_length
:
2792 return "DW_AT_string_length";
2793 case DW_AT_common_reference
:
2794 return "DW_AT_common_reference";
2795 case DW_AT_comp_dir
:
2796 return "DW_AT_comp_dir";
2797 case DW_AT_const_value
:
2798 return "DW_AT_const_value";
2799 case DW_AT_containing_type
:
2800 return "DW_AT_containing_type";
2801 case DW_AT_default_value
:
2802 return "DW_AT_default_value";
2804 return "DW_AT_inline";
2805 case DW_AT_is_optional
:
2806 return "DW_AT_is_optional";
2807 case DW_AT_lower_bound
:
2808 return "DW_AT_lower_bound";
2809 case DW_AT_producer
:
2810 return "DW_AT_producer";
2811 case DW_AT_prototyped
:
2812 return "DW_AT_prototyped";
2813 case DW_AT_return_addr
:
2814 return "DW_AT_return_addr";
2815 case DW_AT_start_scope
:
2816 return "DW_AT_start_scope";
2817 case DW_AT_stride_size
:
2818 return "DW_AT_stride_size";
2819 case DW_AT_upper_bound
:
2820 return "DW_AT_upper_bound";
2821 case DW_AT_abstract_origin
:
2822 return "DW_AT_abstract_origin";
2823 case DW_AT_accessibility
:
2824 return "DW_AT_accessibility";
2825 case DW_AT_address_class
:
2826 return "DW_AT_address_class";
2827 case DW_AT_artificial
:
2828 return "DW_AT_artificial";
2829 case DW_AT_base_types
:
2830 return "DW_AT_base_types";
2831 case DW_AT_calling_convention
:
2832 return "DW_AT_calling_convention";
2834 return "DW_AT_count";
2835 case DW_AT_data_member_location
:
2836 return "DW_AT_data_member_location";
2837 case DW_AT_decl_column
:
2838 return "DW_AT_decl_column";
2839 case DW_AT_decl_file
:
2840 return "DW_AT_decl_file";
2841 case DW_AT_decl_line
:
2842 return "DW_AT_decl_line";
2843 case DW_AT_declaration
:
2844 return "DW_AT_declaration";
2845 case DW_AT_discr_list
:
2846 return "DW_AT_discr_list";
2847 case DW_AT_encoding
:
2848 return "DW_AT_encoding";
2849 case DW_AT_external
:
2850 return "DW_AT_external";
2851 case DW_AT_frame_base
:
2852 return "DW_AT_frame_base";
2854 return "DW_AT_friend";
2855 case DW_AT_identifier_case
:
2856 return "DW_AT_identifier_case";
2857 case DW_AT_macro_info
:
2858 return "DW_AT_macro_info";
2859 case DW_AT_namelist_items
:
2860 return "DW_AT_namelist_items";
2861 case DW_AT_priority
:
2862 return "DW_AT_priority";
2864 return "DW_AT_segment";
2865 case DW_AT_specification
:
2866 return "DW_AT_specification";
2867 case DW_AT_static_link
:
2868 return "DW_AT_static_link";
2870 return "DW_AT_type";
2871 case DW_AT_use_location
:
2872 return "DW_AT_use_location";
2873 case DW_AT_variable_parameter
:
2874 return "DW_AT_variable_parameter";
2875 case DW_AT_virtuality
:
2876 return "DW_AT_virtuality";
2877 case DW_AT_vtable_elem_location
:
2878 return "DW_AT_vtable_elem_location";
2880 case DW_AT_MIPS_fde
:
2881 return "DW_AT_MIPS_fde";
2882 case DW_AT_MIPS_loop_begin
:
2883 return "DW_AT_MIPS_loop_begin";
2884 case DW_AT_MIPS_tail_loop_begin
:
2885 return "DW_AT_MIPS_tail_loop_begin";
2886 case DW_AT_MIPS_epilog_begin
:
2887 return "DW_AT_MIPS_epilog_begin";
2888 case DW_AT_MIPS_loop_unroll_factor
:
2889 return "DW_AT_MIPS_loop_unroll_factor";
2890 case DW_AT_MIPS_software_pipeline_depth
:
2891 return "DW_AT_MIPS_software_pipeline_depth";
2892 case DW_AT_MIPS_linkage_name
:
2893 return "DW_AT_MIPS_linkage_name";
2894 case DW_AT_MIPS_stride
:
2895 return "DW_AT_MIPS_stride";
2896 case DW_AT_MIPS_abstract_name
:
2897 return "DW_AT_MIPS_abstract_name";
2898 case DW_AT_MIPS_clone_origin
:
2899 return "DW_AT_MIPS_clone_origin";
2900 case DW_AT_MIPS_has_inlines
:
2901 return "DW_AT_MIPS_has_inlines";
2903 case DW_AT_sf_names
:
2904 return "DW_AT_sf_names";
2905 case DW_AT_src_info
:
2906 return "DW_AT_src_info";
2907 case DW_AT_mac_info
:
2908 return "DW_AT_mac_info";
2909 case DW_AT_src_coords
:
2910 return "DW_AT_src_coords";
2911 case DW_AT_body_begin
:
2912 return "DW_AT_body_begin";
2913 case DW_AT_body_end
:
2914 return "DW_AT_body_end";
2916 return "DW_AT_<unknown>";
2920 /* Convert a DWARF value form code into its string name. */
2923 dwarf_form_name (form
)
2924 register unsigned form
;
2929 return "DW_FORM_addr";
2930 case DW_FORM_block2
:
2931 return "DW_FORM_block2";
2932 case DW_FORM_block4
:
2933 return "DW_FORM_block4";
2935 return "DW_FORM_data2";
2937 return "DW_FORM_data4";
2939 return "DW_FORM_data8";
2940 case DW_FORM_string
:
2941 return "DW_FORM_string";
2943 return "DW_FORM_block";
2944 case DW_FORM_block1
:
2945 return "DW_FORM_block1";
2947 return "DW_FORM_data1";
2949 return "DW_FORM_flag";
2951 return "DW_FORM_sdata";
2953 return "DW_FORM_strp";
2955 return "DW_FORM_udata";
2956 case DW_FORM_ref_addr
:
2957 return "DW_FORM_ref_addr";
2959 return "DW_FORM_ref1";
2961 return "DW_FORM_ref2";
2963 return "DW_FORM_ref4";
2965 return "DW_FORM_ref8";
2966 case DW_FORM_ref_udata
:
2967 return "DW_FORM_ref_udata";
2968 case DW_FORM_indirect
:
2969 return "DW_FORM_indirect";
2971 return "DW_FORM_<unknown>";
2975 /* Convert a DWARF stack opcode into its string name. */
2978 dwarf_stack_op_name (op
)
2979 register unsigned op
;
2984 return "DW_OP_addr";
2986 return "DW_OP_deref";
2988 return "DW_OP_const1u";
2990 return "DW_OP_const1s";
2992 return "DW_OP_const2u";
2994 return "DW_OP_const2s";
2996 return "DW_OP_const4u";
2998 return "DW_OP_const4s";
3000 return "DW_OP_const8u";
3002 return "DW_OP_const8s";
3004 return "DW_OP_constu";
3006 return "DW_OP_consts";
3010 return "DW_OP_drop";
3012 return "DW_OP_over";
3014 return "DW_OP_pick";
3016 return "DW_OP_swap";
3020 return "DW_OP_xderef";
3028 return "DW_OP_minus";
3040 return "DW_OP_plus";
3041 case DW_OP_plus_uconst
:
3042 return "DW_OP_plus_uconst";
3048 return "DW_OP_shra";
3066 return "DW_OP_skip";
3068 return "DW_OP_lit0";
3070 return "DW_OP_lit1";
3072 return "DW_OP_lit2";
3074 return "DW_OP_lit3";
3076 return "DW_OP_lit4";
3078 return "DW_OP_lit5";
3080 return "DW_OP_lit6";
3082 return "DW_OP_lit7";
3084 return "DW_OP_lit8";
3086 return "DW_OP_lit9";
3088 return "DW_OP_lit10";
3090 return "DW_OP_lit11";
3092 return "DW_OP_lit12";
3094 return "DW_OP_lit13";
3096 return "DW_OP_lit14";
3098 return "DW_OP_lit15";
3100 return "DW_OP_lit16";
3102 return "DW_OP_lit17";
3104 return "DW_OP_lit18";
3106 return "DW_OP_lit19";
3108 return "DW_OP_lit20";
3110 return "DW_OP_lit21";
3112 return "DW_OP_lit22";
3114 return "DW_OP_lit23";
3116 return "DW_OP_lit24";
3118 return "DW_OP_lit25";
3120 return "DW_OP_lit26";
3122 return "DW_OP_lit27";
3124 return "DW_OP_lit28";
3126 return "DW_OP_lit29";
3128 return "DW_OP_lit30";
3130 return "DW_OP_lit31";
3132 return "DW_OP_reg0";
3134 return "DW_OP_reg1";
3136 return "DW_OP_reg2";
3138 return "DW_OP_reg3";
3140 return "DW_OP_reg4";
3142 return "DW_OP_reg5";
3144 return "DW_OP_reg6";
3146 return "DW_OP_reg7";
3148 return "DW_OP_reg8";
3150 return "DW_OP_reg9";
3152 return "DW_OP_reg10";
3154 return "DW_OP_reg11";
3156 return "DW_OP_reg12";
3158 return "DW_OP_reg13";
3160 return "DW_OP_reg14";
3162 return "DW_OP_reg15";
3164 return "DW_OP_reg16";
3166 return "DW_OP_reg17";
3168 return "DW_OP_reg18";
3170 return "DW_OP_reg19";
3172 return "DW_OP_reg20";
3174 return "DW_OP_reg21";
3176 return "DW_OP_reg22";
3178 return "DW_OP_reg23";
3180 return "DW_OP_reg24";
3182 return "DW_OP_reg25";
3184 return "DW_OP_reg26";
3186 return "DW_OP_reg27";
3188 return "DW_OP_reg28";
3190 return "DW_OP_reg29";
3192 return "DW_OP_reg30";
3194 return "DW_OP_reg31";
3196 return "DW_OP_breg0";
3198 return "DW_OP_breg1";
3200 return "DW_OP_breg2";
3202 return "DW_OP_breg3";
3204 return "DW_OP_breg4";
3206 return "DW_OP_breg5";
3208 return "DW_OP_breg6";
3210 return "DW_OP_breg7";
3212 return "DW_OP_breg8";
3214 return "DW_OP_breg9";
3216 return "DW_OP_breg10";
3218 return "DW_OP_breg11";
3220 return "DW_OP_breg12";
3222 return "DW_OP_breg13";
3224 return "DW_OP_breg14";
3226 return "DW_OP_breg15";
3228 return "DW_OP_breg16";
3230 return "DW_OP_breg17";
3232 return "DW_OP_breg18";
3234 return "DW_OP_breg19";
3236 return "DW_OP_breg20";
3238 return "DW_OP_breg21";
3240 return "DW_OP_breg22";
3242 return "DW_OP_breg23";
3244 return "DW_OP_breg24";
3246 return "DW_OP_breg25";
3248 return "DW_OP_breg26";
3250 return "DW_OP_breg27";
3252 return "DW_OP_breg28";
3254 return "DW_OP_breg29";
3256 return "DW_OP_breg30";
3258 return "DW_OP_breg31";
3260 return "DW_OP_regx";
3262 return "DW_OP_fbreg";
3264 return "DW_OP_bregx";
3266 return "DW_OP_piece";
3267 case DW_OP_deref_size
:
3268 return "DW_OP_deref_size";
3269 case DW_OP_xderef_size
:
3270 return "DW_OP_xderef_size";
3274 return "OP_<unknown>";
3278 /* Convert a DWARF type code into its string name. */
3281 dwarf_type_encoding_name (enc
)
3282 register unsigned enc
;
3286 case DW_ATE_address
:
3287 return "DW_ATE_address";
3288 case DW_ATE_boolean
:
3289 return "DW_ATE_boolean";
3290 case DW_ATE_complex_float
:
3291 return "DW_ATE_complex_float";
3293 return "DW_ATE_float";
3295 return "DW_ATE_signed";
3296 case DW_ATE_signed_char
:
3297 return "DW_ATE_signed_char";
3298 case DW_ATE_unsigned
:
3299 return "DW_ATE_unsigned";
3300 case DW_ATE_unsigned_char
:
3301 return "DW_ATE_unsigned_char";
3303 return "DW_ATE_<unknown>";
3307 /* Determine the "ultimate origin" of a decl. The decl may be an inlined
3308 instance of an inlined instance of a decl which is local to an inline
3309 function, so we have to trace all of the way back through the origin chain
3310 to find out what sort of node actually served as the original seed for the
3314 decl_ultimate_origin (decl
)
3317 register tree immediate_origin
= DECL_ABSTRACT_ORIGIN (decl
);
3319 if (immediate_origin
== NULL_TREE
)
3323 register tree ret_val
;
3324 register tree lookahead
= immediate_origin
;
3328 ret_val
= lookahead
;
3329 lookahead
= DECL_ABSTRACT_ORIGIN (ret_val
);
3331 while (lookahead
!= NULL
&& lookahead
!= ret_val
);
3337 /* Determine the "ultimate origin" of a block. The block may be an inlined
3338 instance of an inlined instance of a block which is local to an inline
3339 function, so we have to trace all of the way back through the origin chain
3340 to find out what sort of node actually served as the original seed for the
3344 block_ultimate_origin (block
)
3345 register tree block
;
3347 register tree immediate_origin
= BLOCK_ABSTRACT_ORIGIN (block
);
3349 if (immediate_origin
== NULL_TREE
)
3353 register tree ret_val
;
3354 register tree lookahead
= immediate_origin
;
3358 ret_val
= lookahead
;
3359 lookahead
= (TREE_CODE (ret_val
) == BLOCK
)
3360 ? BLOCK_ABSTRACT_ORIGIN (ret_val
)
3363 while (lookahead
!= NULL
&& lookahead
!= ret_val
);
3369 /* Get the class to which DECL belongs, if any. In g++, the DECL_CONTEXT
3370 of a virtual function may refer to a base class, so we check the 'this'
3374 decl_class_context (decl
)
3377 tree context
= NULL_TREE
;
3379 if (TREE_CODE (decl
) != FUNCTION_DECL
|| ! DECL_VINDEX (decl
))
3380 context
= DECL_CONTEXT (decl
);
3382 context
= TYPE_MAIN_VARIANT
3383 (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)))));
3385 if (context
&& TREE_CODE_CLASS (TREE_CODE (context
)) != 't')
3386 context
= NULL_TREE
;
3391 /* Add an attribute/value pair to a DIE */
3394 add_dwarf_attr (die
, attr
)
3395 register dw_die_ref die
;
3396 register dw_attr_ref attr
;
3398 if (die
!= NULL
&& attr
!= NULL
)
3400 if (die
->die_attr
== NULL
)
3402 die
->die_attr
= attr
;
3403 die
->die_attr_last
= attr
;
3407 die
->die_attr_last
->dw_attr_next
= attr
;
3408 die
->die_attr_last
= attr
;
3413 /* Add a flag value attribute to a DIE. */
3416 add_AT_flag (die
, attr_kind
, flag
)
3417 register dw_die_ref die
;
3418 register enum dwarf_attribute attr_kind
;
3419 register unsigned flag
;
3421 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3423 attr
->dw_attr_next
= NULL
;
3424 attr
->dw_attr
= attr_kind
;
3425 attr
->dw_attr_val
.val_class
= dw_val_class_flag
;
3426 attr
->dw_attr_val
.v
.val_flag
= flag
;
3427 add_dwarf_attr (die
, attr
);
3430 /* Add a signed integer attribute value to a DIE. */
3433 add_AT_int (die
, attr_kind
, int_val
)
3434 register dw_die_ref die
;
3435 register enum dwarf_attribute attr_kind
;
3436 register long int int_val
;
3438 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3440 attr
->dw_attr_next
= NULL
;
3441 attr
->dw_attr
= attr_kind
;
3442 attr
->dw_attr_val
.val_class
= dw_val_class_const
;
3443 attr
->dw_attr_val
.v
.val_int
= int_val
;
3444 add_dwarf_attr (die
, attr
);
3447 /* Add an unsigned integer attribute value to a DIE. */
3450 add_AT_unsigned (die
, attr_kind
, unsigned_val
)
3451 register dw_die_ref die
;
3452 register enum dwarf_attribute attr_kind
;
3453 register unsigned long unsigned_val
;
3455 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3457 attr
->dw_attr_next
= NULL
;
3458 attr
->dw_attr
= attr_kind
;
3459 attr
->dw_attr_val
.val_class
= dw_val_class_unsigned_const
;
3460 attr
->dw_attr_val
.v
.val_unsigned
= unsigned_val
;
3461 add_dwarf_attr (die
, attr
);
3464 /* Add an unsigned double integer attribute value to a DIE. */
3467 add_AT_long_long (die
, attr_kind
, val_hi
, val_low
)
3468 register dw_die_ref die
;
3469 register enum dwarf_attribute attr_kind
;
3470 register unsigned long val_hi
;
3471 register unsigned long val_low
;
3473 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3475 attr
->dw_attr_next
= NULL
;
3476 attr
->dw_attr
= attr_kind
;
3477 attr
->dw_attr_val
.val_class
= dw_val_class_long_long
;
3478 attr
->dw_attr_val
.v
.val_long_long
.hi
= val_hi
;
3479 attr
->dw_attr_val
.v
.val_long_long
.low
= val_low
;
3480 add_dwarf_attr (die
, attr
);
3483 /* Add a floating point attribute value to a DIE and return it. */
3486 add_AT_float (die
, attr_kind
, length
, array
)
3487 register dw_die_ref die
;
3488 register enum dwarf_attribute attr_kind
;
3489 register unsigned length
;
3490 register long *array
;
3492 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3494 attr
->dw_attr_next
= NULL
;
3495 attr
->dw_attr
= attr_kind
;
3496 attr
->dw_attr_val
.val_class
= dw_val_class_float
;
3497 attr
->dw_attr_val
.v
.val_float
.length
= length
;
3498 attr
->dw_attr_val
.v
.val_float
.array
= array
;
3499 add_dwarf_attr (die
, attr
);
3502 /* Add a string attribute value to a DIE. */
3505 add_AT_string (die
, attr_kind
, str
)
3506 register dw_die_ref die
;
3507 register enum dwarf_attribute attr_kind
;
3510 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3512 attr
->dw_attr_next
= NULL
;
3513 attr
->dw_attr
= attr_kind
;
3514 attr
->dw_attr_val
.val_class
= dw_val_class_str
;
3515 attr
->dw_attr_val
.v
.val_str
= xstrdup (str
);
3516 add_dwarf_attr (die
, attr
);
3519 /* Add a DIE reference attribute value to a DIE. */
3522 add_AT_die_ref (die
, attr_kind
, targ_die
)
3523 register dw_die_ref die
;
3524 register enum dwarf_attribute attr_kind
;
3525 register dw_die_ref targ_die
;
3527 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3529 attr
->dw_attr_next
= NULL
;
3530 attr
->dw_attr
= attr_kind
;
3531 attr
->dw_attr_val
.val_class
= dw_val_class_die_ref
;
3532 attr
->dw_attr_val
.v
.val_die_ref
= targ_die
;
3533 add_dwarf_attr (die
, attr
);
3536 /* Add an FDE reference attribute value to a DIE. */
3539 add_AT_fde_ref (die
, attr_kind
, targ_fde
)
3540 register dw_die_ref die
;
3541 register enum dwarf_attribute attr_kind
;
3542 register unsigned targ_fde
;
3544 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3546 attr
->dw_attr_next
= NULL
;
3547 attr
->dw_attr
= attr_kind
;
3548 attr
->dw_attr_val
.val_class
= dw_val_class_fde_ref
;
3549 attr
->dw_attr_val
.v
.val_fde_index
= targ_fde
;
3550 add_dwarf_attr (die
, attr
);
3553 /* Add a location description attribute value to a DIE. */
3556 add_AT_loc (die
, attr_kind
, loc
)
3557 register dw_die_ref die
;
3558 register enum dwarf_attribute attr_kind
;
3559 register dw_loc_descr_ref loc
;
3561 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3563 attr
->dw_attr_next
= NULL
;
3564 attr
->dw_attr
= attr_kind
;
3565 attr
->dw_attr_val
.val_class
= dw_val_class_loc
;
3566 attr
->dw_attr_val
.v
.val_loc
= loc
;
3567 add_dwarf_attr (die
, attr
);
3570 /* Add an address constant attribute value to a DIE. */
3573 add_AT_addr (die
, attr_kind
, addr
)
3574 register dw_die_ref die
;
3575 register enum dwarf_attribute attr_kind
;
3578 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3580 attr
->dw_attr_next
= NULL
;
3581 attr
->dw_attr
= attr_kind
;
3582 attr
->dw_attr_val
.val_class
= dw_val_class_addr
;
3583 attr
->dw_attr_val
.v
.val_addr
= addr
;
3584 add_dwarf_attr (die
, attr
);
3587 /* Add a label identifier attribute value to a DIE. */
3590 add_AT_lbl_id (die
, attr_kind
, lbl_id
)
3591 register dw_die_ref die
;
3592 register enum dwarf_attribute attr_kind
;
3593 register char *lbl_id
;
3595 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3597 attr
->dw_attr_next
= NULL
;
3598 attr
->dw_attr
= attr_kind
;
3599 attr
->dw_attr_val
.val_class
= dw_val_class_lbl_id
;
3600 attr
->dw_attr_val
.v
.val_lbl_id
= xstrdup (lbl_id
);
3601 add_dwarf_attr (die
, attr
);
3604 /* Add a section offset attribute value to a DIE. */
3607 add_AT_section_offset (die
, attr_kind
, section
)
3608 register dw_die_ref die
;
3609 register enum dwarf_attribute attr_kind
;
3610 register char *section
;
3612 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3614 attr
->dw_attr_next
= NULL
;
3615 attr
->dw_attr
= attr_kind
;
3616 attr
->dw_attr_val
.val_class
= dw_val_class_section_offset
;
3617 attr
->dw_attr_val
.v
.val_section
= section
;
3618 add_dwarf_attr (die
, attr
);
3622 /* Test if die refers to an external subroutine. */
3625 is_extern_subr_die (die
)
3626 register dw_die_ref die
;
3628 register dw_attr_ref a
;
3629 register int is_subr
= FALSE
;
3630 register int is_extern
= FALSE
;
3632 if (die
!= NULL
&& die
->die_tag
== DW_TAG_subprogram
)
3635 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
3637 if (a
->dw_attr
== DW_AT_external
3638 && a
->dw_attr_val
.val_class
== dw_val_class_flag
3639 && a
->dw_attr_val
.v
.val_flag
!= 0)
3647 return is_subr
&& is_extern
;
3650 /* Get the attribute of type attr_kind. */
3652 static inline dw_attr_ref
3653 get_AT (die
, attr_kind
)
3654 register dw_die_ref die
;
3655 register enum dwarf_attribute attr_kind
;
3657 register dw_attr_ref a
;
3658 register dw_die_ref spec
= NULL
;
3662 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
3664 if (a
->dw_attr
== attr_kind
)
3667 if (a
->dw_attr
== DW_AT_specification
3668 || a
->dw_attr
== DW_AT_abstract_origin
)
3669 spec
= a
->dw_attr_val
.v
.val_die_ref
;
3673 return get_AT (spec
, attr_kind
);
3679 /* Return the "low pc" attribute value, typically associated with
3680 a subprogram DIE. Return null if the "low pc" attribute is
3681 either not prsent, or if it cannot be represented as an
3682 assembler label identifier. */
3684 static inline char *
3686 register dw_die_ref die
;
3688 register dw_attr_ref a
= get_AT (die
, DW_AT_low_pc
);
3690 if (a
&& a
->dw_attr_val
.val_class
== dw_val_class_lbl_id
)
3691 return a
->dw_attr_val
.v
.val_lbl_id
;
3696 /* Return the "high pc" attribute value, typically associated with
3697 a subprogram DIE. Return null if the "high pc" attribute is
3698 either not prsent, or if it cannot be represented as an
3699 assembler label identifier. */
3701 static inline char *
3703 register dw_die_ref die
;
3705 register dw_attr_ref a
= get_AT (die
, DW_AT_high_pc
);
3707 if (a
&& a
->dw_attr_val
.val_class
== dw_val_class_lbl_id
)
3708 return a
->dw_attr_val
.v
.val_lbl_id
;
3713 /* Return the value of the string attribute designated by ATTR_KIND, or
3714 NULL if it is not present. */
3716 static inline char *
3717 get_AT_string (die
, attr_kind
)
3718 register dw_die_ref die
;
3719 register enum dwarf_attribute attr_kind
;
3721 register dw_attr_ref a
= get_AT (die
, attr_kind
);
3723 if (a
&& a
->dw_attr_val
.val_class
== dw_val_class_str
)
3724 return a
->dw_attr_val
.v
.val_str
;
3729 /* Return the value of the flag attribute designated by ATTR_KIND, or -1
3730 if it is not present. */
3733 get_AT_flag (die
, attr_kind
)
3734 register dw_die_ref die
;
3735 register enum dwarf_attribute attr_kind
;
3737 register dw_attr_ref a
= get_AT (die
, attr_kind
);
3739 if (a
&& a
->dw_attr_val
.val_class
== dw_val_class_flag
)
3740 return a
->dw_attr_val
.v
.val_flag
;
3745 /* Return the value of the unsigned attribute designated by ATTR_KIND, or 0
3746 if it is not present. */
3748 static inline unsigned
3749 get_AT_unsigned (die
, attr_kind
)
3750 register dw_die_ref die
;
3751 register enum dwarf_attribute attr_kind
;
3753 register dw_attr_ref a
= get_AT (die
, attr_kind
);
3755 if (a
&& a
->dw_attr_val
.val_class
== dw_val_class_unsigned_const
)
3756 return a
->dw_attr_val
.v
.val_unsigned
;
3764 register unsigned lang
= get_AT_unsigned (comp_unit_die
, DW_AT_language
);
3766 return (lang
== DW_LANG_C
|| lang
== DW_LANG_C89
3767 || lang
== DW_LANG_C_plus_plus
);
3773 register unsigned lang
= get_AT_unsigned (comp_unit_die
, DW_AT_language
);
3775 return (lang
== DW_LANG_Fortran77
|| lang
== DW_LANG_Fortran90
);
3778 /* Remove the specified attribute if present. */
3781 remove_AT (die
, attr_kind
)
3782 register dw_die_ref die
;
3783 register enum dwarf_attribute attr_kind
;
3785 register dw_attr_ref a
;
3786 register dw_attr_ref removed
= NULL
;;
3790 if (die
->die_attr
->dw_attr
== attr_kind
)
3792 removed
= die
->die_attr
;
3793 if (die
->die_attr_last
== die
->die_attr
)
3794 die
->die_attr_last
= NULL
;
3796 die
->die_attr
= die
->die_attr
->dw_attr_next
;
3800 for (a
= die
->die_attr
; a
->dw_attr_next
!= NULL
;
3801 a
= a
->dw_attr_next
)
3802 if (a
->dw_attr_next
->dw_attr
== attr_kind
)
3804 removed
= a
->dw_attr_next
;
3805 if (die
->die_attr_last
== a
->dw_attr_next
)
3806 die
->die_attr_last
= a
;
3808 a
->dw_attr_next
= a
->dw_attr_next
->dw_attr_next
;
3817 /* Discard the children of this DIE. */
3820 remove_children (die
)
3821 register dw_die_ref die
;
3823 register dw_die_ref child_die
= die
->die_child
;
3825 die
->die_child
= NULL
;
3826 die
->die_child_last
= NULL
;
3828 while (child_die
!= NULL
)
3830 register dw_die_ref tmp_die
= child_die
;
3831 register dw_attr_ref a
;
3833 child_die
= child_die
->die_sib
;
3835 for (a
= tmp_die
->die_attr
; a
!= NULL
; )
3837 register dw_attr_ref tmp_a
= a
;
3839 a
= a
->dw_attr_next
;
3847 /* Add a child DIE below its parent. */
3850 add_child_die (die
, child_die
)
3851 register dw_die_ref die
;
3852 register dw_die_ref child_die
;
3854 if (die
!= NULL
&& child_die
!= NULL
)
3856 assert (die
!= child_die
);
3857 child_die
->die_parent
= die
;
3858 child_die
->die_sib
= NULL
;
3860 if (die
->die_child
== NULL
)
3862 die
->die_child
= child_die
;
3863 die
->die_child_last
= child_die
;
3867 die
->die_child_last
->die_sib
= child_die
;
3868 die
->die_child_last
= child_die
;
3873 /* Return a pointer to a newly created DIE node. */
3875 static inline dw_die_ref
3876 new_die (tag_value
, parent_die
)
3877 register enum dwarf_tag tag_value
;
3878 register dw_die_ref parent_die
;
3880 register dw_die_ref die
= (dw_die_ref
) xmalloc (sizeof (die_node
));
3882 die
->die_tag
= tag_value
;
3883 die
->die_abbrev
= 0;
3884 die
->die_offset
= 0;
3885 die
->die_child
= NULL
;
3886 die
->die_parent
= NULL
;
3887 die
->die_sib
= NULL
;
3888 die
->die_child_last
= NULL
;
3889 die
->die_attr
= NULL
;
3890 die
->die_attr_last
= NULL
;
3892 if (parent_die
!= NULL
)
3893 add_child_die (parent_die
, die
);
3896 limbo_die_node
*limbo_node
;
3898 limbo_node
= (limbo_die_node
*) xmalloc (sizeof (limbo_die_node
));
3899 limbo_node
->die
= die
;
3900 limbo_node
->next
= limbo_die_list
;
3901 limbo_die_list
= limbo_node
;
3907 /* Return the DIE associated with the given type specifier. */
3909 static inline dw_die_ref
3910 lookup_type_die (type
)
3913 return (dw_die_ref
) TYPE_SYMTAB_POINTER (type
);
3916 /* Equate a DIE to a given type specifier. */
3919 equate_type_number_to_die (type
, type_die
)
3921 register dw_die_ref type_die
;
3923 TYPE_SYMTAB_POINTER (type
) = (char *) type_die
;
3926 /* Return the DIE associated with a given declaration. */
3928 static inline dw_die_ref
3929 lookup_decl_die (decl
)
3932 register unsigned decl_id
= DECL_UID (decl
);
3934 return (decl_id
< decl_die_table_in_use
3935 ? decl_die_table
[decl_id
] : NULL
);
3938 /* Equate a DIE to a particular declaration. */
3941 equate_decl_number_to_die (decl
, decl_die
)
3943 register dw_die_ref decl_die
;
3945 register unsigned decl_id
= DECL_UID (decl
);
3946 register unsigned i
;
3947 register unsigned num_allocated
;
3949 if (decl_id
>= decl_die_table_allocated
)
3952 = ((decl_id
+ 1 + DECL_DIE_TABLE_INCREMENT
- 1)
3953 / DECL_DIE_TABLE_INCREMENT
)
3954 * DECL_DIE_TABLE_INCREMENT
;
3957 = (dw_die_ref
*) xrealloc (decl_die_table
,
3958 sizeof (dw_die_ref
) * num_allocated
);
3960 bzero ((char *) &decl_die_table
[decl_die_table_allocated
],
3961 (num_allocated
- decl_die_table_allocated
) * sizeof (dw_die_ref
));
3962 decl_die_table_allocated
= num_allocated
;
3965 if (decl_id
>= decl_die_table_in_use
)
3966 decl_die_table_in_use
= (decl_id
+ 1);
3968 decl_die_table
[decl_id
] = decl_die
;
3971 /* Return a pointer to a newly allocated location description. Location
3972 descriptions are simple expression terms that can be strung
3973 together to form more complicated location (address) descriptions. */
3975 static inline dw_loc_descr_ref
3976 new_loc_descr (op
, oprnd1
, oprnd2
)
3977 register enum dwarf_location_atom op
;
3978 register unsigned long oprnd1
;
3979 register unsigned long oprnd2
;
3981 register dw_loc_descr_ref descr
3982 = (dw_loc_descr_ref
) xmalloc (sizeof (dw_loc_descr_node
));
3984 descr
->dw_loc_next
= NULL
;
3985 descr
->dw_loc_opc
= op
;
3986 descr
->dw_loc_oprnd1
.val_class
= dw_val_class_unsigned_const
;
3987 descr
->dw_loc_oprnd1
.v
.val_unsigned
= oprnd1
;
3988 descr
->dw_loc_oprnd2
.val_class
= dw_val_class_unsigned_const
;
3989 descr
->dw_loc_oprnd2
.v
.val_unsigned
= oprnd2
;
3994 /* Add a location description term to a location description expression. */
3997 add_loc_descr (list_head
, descr
)
3998 register dw_loc_descr_ref
*list_head
;
3999 register dw_loc_descr_ref descr
;
4001 register dw_loc_descr_ref
*d
;
4003 /* Find the end of the chain. */
4004 for (d
= list_head
; (*d
) != NULL
; d
= &(*d
)->dw_loc_next
)
4010 /* Keep track of the number of spaces used to indent the
4011 output of the debugging routines that print the structure of
4012 the DIE internal representation. */
4013 static int print_indent
;
4015 /* Indent the line the number of spaces given by print_indent. */
4018 print_spaces (outfile
)
4021 fprintf (outfile
, "%*s", print_indent
, "");
4024 /* Print the information assoaciated with a given DIE, and its children.
4025 This routine is a debugging aid only. */
4028 print_die (die
, outfile
)
4032 register dw_attr_ref a
;
4033 register dw_die_ref c
;
4035 print_spaces (outfile
);
4036 fprintf (outfile
, "DIE %4u: %s\n",
4037 die
->die_offset
, dwarf_tag_name (die
->die_tag
));
4038 print_spaces (outfile
);
4039 fprintf (outfile
, " abbrev id: %u", die
->die_abbrev
);
4040 fprintf (outfile
, " offset: %u\n", die
->die_offset
);
4042 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
4044 print_spaces (outfile
);
4045 fprintf (outfile
, " %s: ", dwarf_attr_name (a
->dw_attr
));
4047 switch (a
->dw_attr_val
.val_class
)
4049 case dw_val_class_addr
:
4050 fprintf (outfile
, "address");
4052 case dw_val_class_loc
:
4053 fprintf (outfile
, "location descriptor");
4055 case dw_val_class_const
:
4056 fprintf (outfile
, "%d", a
->dw_attr_val
.v
.val_int
);
4058 case dw_val_class_unsigned_const
:
4059 fprintf (outfile
, "%u", a
->dw_attr_val
.v
.val_unsigned
);
4061 case dw_val_class_long_long
:
4062 fprintf (outfile
, "constant (%u,%u)",
4063 a
->dw_attr_val
.v
.val_long_long
.hi
,
4064 a
->dw_attr_val
.v
.val_long_long
.low
);
4066 case dw_val_class_float
:
4067 fprintf (outfile
, "floating-point constant");
4069 case dw_val_class_flag
:
4070 fprintf (outfile
, "%u", a
->dw_attr_val
.v
.val_flag
);
4072 case dw_val_class_die_ref
:
4073 if (a
->dw_attr_val
.v
.val_die_ref
!= NULL
)
4074 fprintf (outfile
, "die -> %u",
4075 a
->dw_attr_val
.v
.val_die_ref
->die_offset
);
4077 fprintf (outfile
, "die -> <null>");
4079 case dw_val_class_lbl_id
:
4080 fprintf (outfile
, "label: %s", a
->dw_attr_val
.v
.val_lbl_id
);
4082 case dw_val_class_section_offset
:
4083 fprintf (outfile
, "section: %s", a
->dw_attr_val
.v
.val_section
);
4085 case dw_val_class_str
:
4086 if (a
->dw_attr_val
.v
.val_str
!= NULL
)
4087 fprintf (outfile
, "\"%s\"", a
->dw_attr_val
.v
.val_str
);
4089 fprintf (outfile
, "<null>");
4095 fprintf (outfile
, "\n");
4098 if (die
->die_child
!= NULL
)
4101 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
4102 print_die (c
, outfile
);
4108 /* Print the contents of the source code line number correspondence table.
4109 This routine is a debugging aid only. */
4112 print_dwarf_line_table (outfile
)
4115 register unsigned i
;
4116 register dw_line_info_ref line_info
;
4118 fprintf (outfile
, "\n\nDWARF source line information\n");
4119 for (i
= 1; i
< line_info_table_in_use
; ++i
)
4121 line_info
= &line_info_table
[i
];
4122 fprintf (outfile
, "%5d: ", i
);
4123 fprintf (outfile
, "%-20s", file_table
[line_info
->dw_file_num
]);
4124 fprintf (outfile
, "%6d", line_info
->dw_line_num
);
4125 fprintf (outfile
, "\n");
4128 fprintf (outfile
, "\n\n");
4131 /* Print the information collected for a given DIE. */
4134 debug_dwarf_die (die
)
4137 print_die (die
, stderr
);
4140 /* Print all DWARF information collected for the compilation unit.
4141 This routine is a debugging aid only. */
4147 print_die (comp_unit_die
, stderr
);
4148 print_dwarf_line_table (stderr
);
4151 /* Traverse the DIE, and add a sibling attribute if it may have the
4152 effect of speeding up access to siblings. To save some space,
4153 avoid generating sibling attributes for DIE's without children. */
4156 add_sibling_attributes(die
)
4157 register dw_die_ref die
;
4159 register dw_die_ref c
;
4160 register dw_attr_ref attr
;
4161 if (die
!= comp_unit_die
&& die
->die_child
!= NULL
)
4163 attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4164 attr
->dw_attr_next
= NULL
;
4165 attr
->dw_attr
= DW_AT_sibling
;
4166 attr
->dw_attr_val
.val_class
= dw_val_class_die_ref
;
4167 attr
->dw_attr_val
.v
.val_die_ref
= die
->die_sib
;
4169 /* Add the sibling link to the front of the attribute list. */
4170 attr
->dw_attr_next
= die
->die_attr
;
4171 if (die
->die_attr
== NULL
)
4172 die
->die_attr_last
= attr
;
4174 die
->die_attr
= attr
;
4177 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
4178 add_sibling_attributes (c
);
4181 /* The format of each DIE (and its attribute value pairs)
4182 is encoded in an abbreviation table. This routine builds the
4183 abbreviation table and assigns a unique abbreviation id for
4184 each abbreviation entry. The children of each die are visited
4188 build_abbrev_table (die
)
4189 register dw_die_ref die
;
4191 register unsigned long abbrev_id
;
4192 register unsigned long n_alloc
;
4193 register dw_die_ref c
;
4194 register dw_attr_ref d_attr
, a_attr
;
4195 for (abbrev_id
= 1; abbrev_id
< abbrev_die_table_in_use
; ++abbrev_id
)
4197 register dw_die_ref abbrev
= abbrev_die_table
[abbrev_id
];
4199 if (abbrev
->die_tag
== die
->die_tag
)
4201 if ((abbrev
->die_child
!= NULL
) == (die
->die_child
!= NULL
))
4203 a_attr
= abbrev
->die_attr
;
4204 d_attr
= die
->die_attr
;
4206 while (a_attr
!= NULL
&& d_attr
!= NULL
)
4208 if ((a_attr
->dw_attr
!= d_attr
->dw_attr
)
4209 || (value_format (&a_attr
->dw_attr_val
)
4210 != value_format (&d_attr
->dw_attr_val
)))
4213 a_attr
= a_attr
->dw_attr_next
;
4214 d_attr
= d_attr
->dw_attr_next
;
4217 if (a_attr
== NULL
&& d_attr
== NULL
)
4223 if (abbrev_id
>= abbrev_die_table_in_use
)
4225 if (abbrev_die_table_in_use
>= abbrev_die_table_allocated
)
4227 n_alloc
= abbrev_die_table_allocated
+ ABBREV_DIE_TABLE_INCREMENT
;
4229 = (dw_die_ref
*) xrealloc (abbrev_die_table
,
4230 sizeof (dw_die_ref
) * n_alloc
);
4232 bzero ((char *) &abbrev_die_table
[abbrev_die_table_allocated
],
4233 (n_alloc
- abbrev_die_table_allocated
) * sizeof (dw_die_ref
));
4234 abbrev_die_table_allocated
= n_alloc
;
4237 ++abbrev_die_table_in_use
;
4238 abbrev_die_table
[abbrev_id
] = die
;
4241 die
->die_abbrev
= abbrev_id
;
4242 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
4243 build_abbrev_table (c
);
4246 /* Return the size of a string, including the null byte. */
4248 static unsigned long
4249 size_of_string (str
)
4252 register unsigned long size
= 0;
4253 register unsigned long slen
= strlen (str
);
4254 register unsigned long i
;
4255 register unsigned c
;
4257 for (i
= 0; i
< slen
; ++i
)
4266 /* Null terminator. */
4271 /* Return the size of a location descriptor. */
4273 static unsigned long
4274 size_of_loc_descr (loc
)
4275 register dw_loc_descr_ref loc
;
4277 register unsigned long size
= 1;
4279 switch (loc
->dw_loc_opc
)
4301 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
4304 size
+= size_of_sleb128 (loc
->dw_loc_oprnd1
.v
.val_int
);
4309 case DW_OP_plus_uconst
:
4310 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
4348 size
+= size_of_sleb128 (loc
->dw_loc_oprnd1
.v
.val_int
);
4351 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
4354 size
+= size_of_sleb128 (loc
->dw_loc_oprnd1
.v
.val_int
);
4357 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
4358 size
+= size_of_sleb128 (loc
->dw_loc_oprnd2
.v
.val_int
);
4361 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
4363 case DW_OP_deref_size
:
4364 case DW_OP_xderef_size
:
4374 /* Return the size of a series of location descriptors. */
4376 static unsigned long
4378 register dw_loc_descr_ref loc
;
4380 register unsigned long size
= 0;
4382 for (; loc
!= NULL
; loc
= loc
->dw_loc_next
)
4383 size
+= size_of_loc_descr (loc
);
4388 /* Return the power-of-two number of bytes necessary to represent VALUE. */
4391 constant_size (value
)
4392 long unsigned value
;
4399 log
= floor_log2 (value
);
4402 log
= 1 << (floor_log2 (log
) + 1);
4407 /* Return the size of a DIE, as it is represented in the
4408 .debug_info section. */
4410 static unsigned long
4412 register dw_die_ref die
;
4414 register unsigned long size
= 0;
4415 register dw_attr_ref a
;
4417 size
+= size_of_uleb128 (die
->die_abbrev
);
4418 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
4420 switch (a
->dw_attr_val
.val_class
)
4422 case dw_val_class_addr
:
4425 case dw_val_class_loc
:
4427 register unsigned long lsize
4428 = size_of_locs (a
->dw_attr_val
.v
.val_loc
);
4431 size
+= constant_size (lsize
);
4435 case dw_val_class_const
:
4438 case dw_val_class_unsigned_const
:
4439 size
+= constant_size (a
->dw_attr_val
.v
.val_unsigned
);
4441 case dw_val_class_long_long
:
4442 size
+= 1 + 8; /* block */
4444 case dw_val_class_float
:
4445 size
+= 1 + a
->dw_attr_val
.v
.val_float
.length
* 4; /* block */
4447 case dw_val_class_flag
:
4450 case dw_val_class_die_ref
:
4451 size
+= DWARF_OFFSET_SIZE
;
4453 case dw_val_class_fde_ref
:
4454 size
+= DWARF_OFFSET_SIZE
;
4456 case dw_val_class_lbl_id
:
4459 case dw_val_class_section_offset
:
4460 size
+= DWARF_OFFSET_SIZE
;
4462 case dw_val_class_str
:
4463 size
+= size_of_string (a
->dw_attr_val
.v
.val_str
);
4473 /* Size the debgging information associted with a given DIE.
4474 Visits the DIE's children recursively. Updates the global
4475 variable next_die_offset, on each time through. Uses the
4476 current value of next_die_offset to updete the die_offset
4477 field in each DIE. */
4480 calc_die_sizes (die
)
4483 register dw_die_ref c
;
4484 die
->die_offset
= next_die_offset
;
4485 next_die_offset
+= size_of_die (die
);
4487 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
4490 if (die
->die_child
!= NULL
)
4491 /* Count the null byte used to terminate sibling lists. */
4492 next_die_offset
+= 1;
4495 /* Return the size of the line information prolog generated for the
4496 compilation unit. */
4498 static unsigned long
4499 size_of_line_prolog ()
4501 register unsigned long size
;
4502 register unsigned long ft_index
;
4504 size
= DWARF_LINE_PROLOG_HEADER_SIZE
;
4506 /* Count the size of the table giving number of args for each
4508 size
+= DWARF_LINE_OPCODE_BASE
- 1;
4510 /* Include directory table is empty (at present). Count only the
4511 the null byte used to terminate the table. */
4514 for (ft_index
= 1; ft_index
< file_table_in_use
; ++ft_index
)
4516 /* File name entry. */
4517 size
+= size_of_string (file_table
[ft_index
]);
4519 /* Include directory index. */
4520 size
+= size_of_uleb128 (0);
4522 /* Modification time. */
4523 size
+= size_of_uleb128 (0);
4525 /* File length in bytes. */
4526 size
+= size_of_uleb128 (0);
4529 /* Count the file table terminator. */
4534 /* Return the size of the line information generated for this
4535 compilation unit. */
4537 static unsigned long
4538 size_of_line_info ()
4540 register unsigned long size
;
4541 register unsigned long lt_index
;
4542 register unsigned long current_line
;
4543 register long line_offset
;
4544 register long line_delta
;
4545 register unsigned long current_file
;
4546 register unsigned long function
;
4547 unsigned long size_of_set_address
;
4549 /* Size of a DW_LNE_set_address instruction. */
4550 size_of_set_address
= 1 + size_of_uleb128 (1 + PTR_SIZE
) + 1 + PTR_SIZE
;
4552 /* Version number. */
4555 /* Prolog length specifier. */
4556 size
+= DWARF_OFFSET_SIZE
;
4559 size
+= size_of_line_prolog ();
4561 /* Set address register instruction. */
4562 size
+= size_of_set_address
;
4566 for (lt_index
= 1; lt_index
< line_info_table_in_use
; ++lt_index
)
4568 register dw_line_info_ref line_info
;
4570 /* Advance pc instruction. */
4571 /* ??? See the DW_LNS_advance_pc comment in output_line_info. */
4575 size
+= size_of_set_address
;
4577 line_info
= &line_info_table
[lt_index
];
4578 if (line_info
->dw_file_num
!= current_file
)
4580 /* Set file number instruction. */
4582 current_file
= line_info
->dw_file_num
;
4583 size
+= size_of_uleb128 (current_file
);
4586 if (line_info
->dw_line_num
!= current_line
)
4588 line_offset
= line_info
->dw_line_num
- current_line
;
4589 line_delta
= line_offset
- DWARF_LINE_BASE
;
4590 current_line
= line_info
->dw_line_num
;
4591 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
4592 /* 1-byte special line number instruction. */
4596 /* Advance line instruction. */
4598 size
+= size_of_sleb128 (line_offset
);
4599 /* Generate line entry instruction. */
4605 /* Advance pc instruction. */
4609 size
+= size_of_set_address
;
4611 /* End of line number info. marker. */
4612 size
+= 1 + size_of_uleb128 (1) + 1;
4617 for (lt_index
= 0; lt_index
< separate_line_info_table_in_use
; )
4619 register dw_separate_line_info_ref line_info
4620 = &separate_line_info_table
[lt_index
];
4621 if (function
!= line_info
->function
)
4623 function
= line_info
->function
;
4624 /* Set address register instruction. */
4625 size
+= size_of_set_address
;
4629 /* Advance pc instruction. */
4633 size
+= size_of_set_address
;
4636 if (line_info
->dw_file_num
!= current_file
)
4638 /* Set file number instruction. */
4640 current_file
= line_info
->dw_file_num
;
4641 size
+= size_of_uleb128 (current_file
);
4644 if (line_info
->dw_line_num
!= current_line
)
4646 line_offset
= line_info
->dw_line_num
- current_line
;
4647 line_delta
= line_offset
- DWARF_LINE_BASE
;
4648 current_line
= line_info
->dw_line_num
;
4649 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
4650 /* 1-byte special line number instruction. */
4654 /* Advance line instruction. */
4656 size
+= size_of_sleb128 (line_offset
);
4658 /* Generate line entry instruction. */
4665 /* If we're done with a function, end its sequence. */
4666 if (lt_index
== separate_line_info_table_in_use
4667 || separate_line_info_table
[lt_index
].function
!= function
)
4672 /* Advance pc instruction. */
4676 size
+= size_of_set_address
;
4678 /* End of line number info. marker. */
4679 size
+= 1 + size_of_uleb128 (1) + 1;
4686 /* Return the size of the .debug_pubnames table generated for the
4687 compilation unit. */
4689 static unsigned long
4692 register unsigned long size
;
4693 register unsigned i
;
4695 size
= DWARF_PUBNAMES_HEADER_SIZE
;
4696 for (i
= 0; i
< pubname_table_in_use
; ++i
)
4698 register pubname_ref p
= &pubname_table
[i
];
4699 size
+= DWARF_OFFSET_SIZE
+ size_of_string (p
->name
);
4702 size
+= DWARF_OFFSET_SIZE
;
4706 /* Return the size of the information in the .debug_aranges seciton. */
4708 static unsigned long
4711 register unsigned long size
;
4713 size
= DWARF_ARANGES_HEADER_SIZE
;
4715 /* Count the address/length pair for this compilation unit. */
4716 size
+= 2 * PTR_SIZE
;
4717 size
+= 2 * PTR_SIZE
* arange_table_in_use
;
4719 /* Count the two zero words used to terminated the address range table. */
4720 size
+= 2 * PTR_SIZE
;
4724 /* Select the encoding of an attribute value. */
4726 static enum dwarf_form
4730 switch (v
->val_class
)
4732 case dw_val_class_addr
:
4733 return DW_FORM_addr
;
4734 case dw_val_class_loc
:
4735 switch (constant_size (size_of_locs (v
->v
.val_loc
)))
4738 return DW_FORM_block1
;
4740 return DW_FORM_block2
;
4744 case dw_val_class_const
:
4745 return DW_FORM_data4
;
4746 case dw_val_class_unsigned_const
:
4747 switch (constant_size (v
->v
.val_unsigned
))
4750 return DW_FORM_data1
;
4752 return DW_FORM_data2
;
4754 return DW_FORM_data4
;
4756 return DW_FORM_data8
;
4760 case dw_val_class_long_long
:
4761 return DW_FORM_block1
;
4762 case dw_val_class_float
:
4763 return DW_FORM_block1
;
4764 case dw_val_class_flag
:
4765 return DW_FORM_flag
;
4766 case dw_val_class_die_ref
:
4768 case dw_val_class_fde_ref
:
4769 return DW_FORM_data
;
4770 case dw_val_class_lbl_id
:
4771 return DW_FORM_addr
;
4772 case dw_val_class_section_offset
:
4773 return DW_FORM_data
;
4774 case dw_val_class_str
:
4775 return DW_FORM_string
;
4781 /* Output the encoding of an attribute value. */
4784 output_value_format (v
)
4787 enum dwarf_form form
= value_format (v
);
4789 output_uleb128 (form
);
4791 fprintf (asm_out_file
, " (%s)", dwarf_form_name (form
));
4793 fputc ('\n', asm_out_file
);
4796 /* Output the .debug_abbrev section which defines the DIE abbreviation
4800 output_abbrev_section ()
4802 unsigned long abbrev_id
;
4805 for (abbrev_id
= 1; abbrev_id
< abbrev_die_table_in_use
; ++abbrev_id
)
4807 register dw_die_ref abbrev
= abbrev_die_table
[abbrev_id
];
4809 output_uleb128 (abbrev_id
);
4811 fprintf (asm_out_file
, " (abbrev code)");
4813 fputc ('\n', asm_out_file
);
4814 output_uleb128 (abbrev
->die_tag
);
4816 fprintf (asm_out_file
, " (TAG: %s)",
4817 dwarf_tag_name (abbrev
->die_tag
));
4819 fputc ('\n', asm_out_file
);
4820 fprintf (asm_out_file
, "\t%s\t0x%x", ASM_BYTE_OP
,
4821 abbrev
->die_child
!= NULL
? DW_children_yes
: DW_children_no
);
4824 fprintf (asm_out_file
, "\t%s %s",
4826 (abbrev
->die_child
!= NULL
4827 ? "DW_children_yes" : "DW_children_no"));
4829 fputc ('\n', asm_out_file
);
4831 for (a_attr
= abbrev
->die_attr
; a_attr
!= NULL
;
4832 a_attr
= a_attr
->dw_attr_next
)
4834 output_uleb128 (a_attr
->dw_attr
);
4836 fprintf (asm_out_file
, " (%s)",
4837 dwarf_attr_name (a_attr
->dw_attr
));
4839 fputc ('\n', asm_out_file
);
4840 output_value_format (&a_attr
->dw_attr_val
);
4843 fprintf (asm_out_file
, "\t%s\t0,0\n", ASM_BYTE_OP
);
4847 /* Output location description stack opcode's operands (if any). */
4850 output_loc_operands (loc
)
4851 register dw_loc_descr_ref loc
;
4853 register dw_val_ref val1
= &loc
->dw_loc_oprnd1
;
4854 register dw_val_ref val2
= &loc
->dw_loc_oprnd2
;
4856 switch (loc
->dw_loc_opc
)
4859 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file
, val1
->v
.val_addr
);
4860 fputc ('\n', asm_out_file
);
4864 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, val1
->v
.val_flag
);
4865 fputc ('\n', asm_out_file
);
4869 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, val1
->v
.val_int
);
4870 fputc ('\n', asm_out_file
);
4874 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, val1
->v
.val_int
);
4875 fputc ('\n', asm_out_file
);
4880 fputc ('\n', asm_out_file
);
4883 output_uleb128 (val1
->v
.val_unsigned
);
4884 fputc ('\n', asm_out_file
);
4887 output_sleb128 (val1
->v
.val_int
);
4888 fputc ('\n', asm_out_file
);
4891 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, val1
->v
.val_int
);
4892 fputc ('\n', asm_out_file
);
4894 case DW_OP_plus_uconst
:
4895 output_uleb128 (val1
->v
.val_unsigned
);
4896 fputc ('\n', asm_out_file
);
4900 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, val1
->v
.val_int
);
4901 fputc ('\n', asm_out_file
);
4935 output_sleb128 (val1
->v
.val_int
);
4936 fputc ('\n', asm_out_file
);
4939 output_uleb128 (val1
->v
.val_unsigned
);
4940 fputc ('\n', asm_out_file
);
4943 output_sleb128 (val1
->v
.val_int
);
4944 fputc ('\n', asm_out_file
);
4947 output_uleb128 (val1
->v
.val_unsigned
);
4948 fputc ('\n', asm_out_file
);
4949 output_sleb128 (val2
->v
.val_int
);
4950 fputc ('\n', asm_out_file
);
4953 output_uleb128 (val1
->v
.val_unsigned
);
4954 fputc ('\n', asm_out_file
);
4956 case DW_OP_deref_size
:
4957 case DW_OP_xderef_size
:
4958 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, val1
->v
.val_flag
);
4959 fputc ('\n', asm_out_file
);
4966 /* Compute the offset of a sibling. */
4968 static unsigned long
4969 sibling_offset (die
)
4972 unsigned long offset
;
4974 if (die
->die_child_last
== NULL
)
4975 offset
= die
->die_offset
+ size_of_die (die
);
4977 offset
= sibling_offset (die
->die_child_last
) + 1;
4982 /* Output the DIE and its attributes. Called recursively to generate
4983 the definitions of each child DIE. */
4987 register dw_die_ref die
;
4989 register dw_attr_ref a
;
4990 register dw_die_ref c
;
4991 register unsigned long ref_offset
;
4992 register unsigned long size
;
4993 register dw_loc_descr_ref loc
;
4996 output_uleb128 (die
->die_abbrev
);
4998 fprintf (asm_out_file
, " (DIE (0x%x) %s)",
4999 die
->die_offset
, dwarf_tag_name (die
->die_tag
));
5001 fputc ('\n', asm_out_file
);
5003 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
5005 switch (a
->dw_attr_val
.val_class
)
5007 case dw_val_class_addr
:
5008 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file
,
5009 a
->dw_attr_val
.v
.val_addr
);
5012 case dw_val_class_loc
:
5013 size
= size_of_locs (a
->dw_attr_val
.v
.val_loc
);
5015 /* Output the block length for this list of location operations. */
5016 switch (constant_size (size
))
5019 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, size
);
5022 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, size
);
5029 fprintf (asm_out_file
, "\t%s %s",
5030 ASM_COMMENT_START
, dwarf_attr_name (a
->dw_attr
));
5032 fputc ('\n', asm_out_file
);
5033 for (loc
= a
->dw_attr_val
.v
.val_loc
; loc
!= NULL
;
5034 loc
= loc
->dw_loc_next
)
5036 /* Output the opcode. */
5037 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, loc
->dw_loc_opc
);
5039 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
,
5040 dwarf_stack_op_name (loc
->dw_loc_opc
));
5042 fputc ('\n', asm_out_file
);
5044 /* Output the operand(s) (if any). */
5045 output_loc_operands (loc
);
5049 case dw_val_class_const
:
5050 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, a
->dw_attr_val
.v
.val_int
);
5053 case dw_val_class_unsigned_const
:
5054 switch (constant_size (a
->dw_attr_val
.v
.val_unsigned
))
5057 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
5058 a
->dw_attr_val
.v
.val_unsigned
);
5061 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
,
5062 a
->dw_attr_val
.v
.val_unsigned
);
5065 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
5066 a
->dw_attr_val
.v
.val_unsigned
);
5069 ASM_OUTPUT_DWARF_DATA8 (asm_out_file
,
5070 a
->dw_attr_val
.v
.val_long_long
.hi
,
5071 a
->dw_attr_val
.v
.val_long_long
.low
);
5078 case dw_val_class_long_long
:
5079 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 8);
5081 fprintf (asm_out_file
, "\t%s %s",
5082 ASM_COMMENT_START
, dwarf_attr_name (a
->dw_attr
));
5084 fputc ('\n', asm_out_file
);
5085 ASM_OUTPUT_DWARF_DATA8 (asm_out_file
,
5086 a
->dw_attr_val
.v
.val_long_long
.hi
,
5087 a
->dw_attr_val
.v
.val_long_long
.low
);
5090 fprintf (asm_out_file
,
5091 "\t%s long long constant", ASM_COMMENT_START
);
5093 fputc ('\n', asm_out_file
);
5096 case dw_val_class_float
:
5097 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
5098 a
->dw_attr_val
.v
.val_float
.length
* 4);
5100 fprintf (asm_out_file
, "\t%s %s",
5101 ASM_COMMENT_START
, dwarf_attr_name (a
->dw_attr
));
5103 fputc ('\n', asm_out_file
);
5104 for (i
= 0; i
< a
->dw_attr_val
.v
.val_float
.length
; ++i
)
5106 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
5107 a
->dw_attr_val
.v
.val_float
.array
[i
]);
5109 fprintf (asm_out_file
, "\t%s fp constant word %d",
5110 ASM_COMMENT_START
, i
);
5112 fputc ('\n', asm_out_file
);
5116 case dw_val_class_flag
:
5117 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, a
->dw_attr_val
.v
.val_flag
);
5120 case dw_val_class_die_ref
:
5121 if (a
->dw_attr_val
.v
.val_die_ref
!= NULL
)
5122 ref_offset
= a
->dw_attr_val
.v
.val_die_ref
->die_offset
;
5123 else if (a
->dw_attr
== DW_AT_sibling
)
5124 ref_offset
= sibling_offset(die
);
5128 ASM_OUTPUT_DWARF_DATA (asm_out_file
, ref_offset
);
5131 case dw_val_class_fde_ref
:
5134 ASM_GENERATE_INTERNAL_LABEL
5135 (l1
, FDE_AFTER_SIZE_LABEL
, a
->dw_attr_val
.v
.val_fde_index
* 2);
5136 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, l1
);
5137 fprintf (asm_out_file
, " - %d", DWARF_OFFSET_SIZE
);
5141 case dw_val_class_lbl_id
:
5142 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, a
->dw_attr_val
.v
.val_lbl_id
);
5145 case dw_val_class_section_offset
:
5146 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
,
5148 (a
->dw_attr_val
.v
.val_section
));
5151 case dw_val_class_str
:
5153 ASM_OUTPUT_DWARF_STRING (asm_out_file
, a
->dw_attr_val
.v
.val_str
);
5155 ASM_OUTPUT_ASCII (asm_out_file
,
5156 a
->dw_attr_val
.v
.val_str
,
5157 strlen (a
->dw_attr_val
.v
.val_str
) + 1);
5164 if (a
->dw_attr_val
.val_class
!= dw_val_class_loc
5165 && a
->dw_attr_val
.val_class
!= dw_val_class_long_long
5166 && a
->dw_attr_val
.val_class
!= dw_val_class_float
)
5169 fprintf (asm_out_file
, "\t%s %s",
5170 ASM_COMMENT_START
, dwarf_attr_name (a
->dw_attr
));
5172 fputc ('\n', asm_out_file
);
5176 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
5179 if (die
->die_child
!= NULL
)
5181 /* Add null byte to terminate sibling list. */
5182 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5184 fprintf (asm_out_file
, "\t%s end of children of DIE 0x%x",
5185 ASM_COMMENT_START
, die
->die_offset
);
5187 fputc ('\n', asm_out_file
);
5191 /* Output the compilation unit that appears at the beginning of the
5192 .debug_info section, and precedes the DIE descriptions. */
5195 output_compilation_unit_header ()
5197 ASM_OUTPUT_DWARF_DATA (asm_out_file
, next_die_offset
- DWARF_OFFSET_SIZE
);
5199 fprintf (asm_out_file
, "\t%s Length of Compilation Unit Info.",
5202 fputc ('\n', asm_out_file
);
5203 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, DWARF_VERSION
);
5205 fprintf (asm_out_file
, "\t%s DWARF version number", ASM_COMMENT_START
);
5207 fputc ('\n', asm_out_file
);
5208 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, stripattributes (ABBREV_SECTION
));
5210 fprintf (asm_out_file
, "\t%s Offset Into Abbrev. Section",
5213 fputc ('\n', asm_out_file
);
5214 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, PTR_SIZE
);
5216 fprintf (asm_out_file
, "\t%s Pointer Size (in bytes)", ASM_COMMENT_START
);
5218 fputc ('\n', asm_out_file
);
5221 /* The DWARF2 pubname for a nested thingy looks like "A::f". The output
5222 of decl_printable_name for C++ looks like "A::f(int)". Let's drop the
5223 argument list, and maybe the scope. */
5226 dwarf2_name (decl
, scope
)
5230 return (*decl_printable_name
) (decl
, scope
? 1 : 0);
5233 /* Add a new entry to .debug_pubnames if appropriate. */
5236 add_pubname (decl
, die
)
5242 if (! TREE_PUBLIC (decl
))
5245 if (pubname_table_in_use
== pubname_table_allocated
)
5247 pubname_table_allocated
+= PUBNAME_TABLE_INCREMENT
;
5248 pubname_table
= (pubname_ref
) xrealloc
5249 (pubname_table
, pubname_table_allocated
* sizeof (pubname_entry
));
5252 p
= &pubname_table
[pubname_table_in_use
++];
5255 p
->name
= xstrdup (dwarf2_name (decl
, 1));
5258 /* Output the public names table used to speed up access to externally
5259 visible names. For now, only generate entries for externally
5260 visible procedures. */
5265 register unsigned i
;
5266 register unsigned long pubnames_length
= size_of_pubnames ();
5268 ASM_OUTPUT_DWARF_DATA (asm_out_file
, pubnames_length
);
5271 fprintf (asm_out_file
, "\t%s Length of Public Names Info.",
5274 fputc ('\n', asm_out_file
);
5275 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, DWARF_VERSION
);
5278 fprintf (asm_out_file
, "\t%s DWARF Version", ASM_COMMENT_START
);
5280 fputc ('\n', asm_out_file
);
5281 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, stripattributes (DEBUG_INFO_SECTION
));
5283 fprintf (asm_out_file
, "\t%s Offset of Compilation Unit Info.",
5286 fputc ('\n', asm_out_file
);
5287 ASM_OUTPUT_DWARF_DATA (asm_out_file
, next_die_offset
);
5289 fprintf (asm_out_file
, "\t%s Compilation Unit Length", ASM_COMMENT_START
);
5291 fputc ('\n', asm_out_file
);
5292 for (i
= 0; i
< pubname_table_in_use
; ++i
)
5294 register pubname_ref pub
= &pubname_table
[i
];
5296 ASM_OUTPUT_DWARF_DATA (asm_out_file
, pub
->die
->die_offset
);
5298 fprintf (asm_out_file
, "\t%s DIE offset", ASM_COMMENT_START
);
5300 fputc ('\n', asm_out_file
);
5304 ASM_OUTPUT_DWARF_STRING (asm_out_file
, pub
->name
);
5305 fprintf (asm_out_file
, "%s external name", ASM_COMMENT_START
);
5309 ASM_OUTPUT_ASCII (asm_out_file
, pub
->name
, strlen (pub
->name
) + 1);
5312 fputc ('\n', asm_out_file
);
5315 ASM_OUTPUT_DWARF_DATA (asm_out_file
, 0);
5316 fputc ('\n', asm_out_file
);
5319 /* Add a new entry to .debug_aranges if appropriate. */
5322 add_arange (decl
, die
)
5326 if (! DECL_SECTION_NAME (decl
))
5329 if (arange_table_in_use
== arange_table_allocated
)
5331 arange_table_allocated
+= ARANGE_TABLE_INCREMENT
;
5333 = (arange_ref
) xrealloc (arange_table
,
5334 arange_table_allocated
* sizeof (dw_die_ref
));
5337 arange_table
[arange_table_in_use
++] = die
;
5340 /* Output the information that goes into the .debug_aranges table.
5341 Namely, define the beginning and ending address range of the
5342 text section generated for this compilation unit. */
5347 register unsigned i
;
5348 register unsigned long aranges_length
= size_of_aranges ();
5350 ASM_OUTPUT_DWARF_DATA (asm_out_file
, aranges_length
);
5352 fprintf (asm_out_file
, "\t%s Length of Address Ranges Info.",
5355 fputc ('\n', asm_out_file
);
5356 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, DWARF_VERSION
);
5358 fprintf (asm_out_file
, "\t%s DWARF Version", ASM_COMMENT_START
);
5360 fputc ('\n', asm_out_file
);
5361 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, stripattributes (DEBUG_INFO_SECTION
));
5363 fprintf (asm_out_file
, "\t%s Offset of Compilation Unit Info.",
5366 fputc ('\n', asm_out_file
);
5367 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, PTR_SIZE
);
5369 fprintf (asm_out_file
, "\t%s Size of Address", ASM_COMMENT_START
);
5371 fputc ('\n', asm_out_file
);
5372 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5374 fprintf (asm_out_file
, "\t%s Size of Segment Descriptor",
5377 fputc ('\n', asm_out_file
);
5378 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 4);
5380 fprintf (asm_out_file
, ",0,0");
5383 fprintf (asm_out_file
, "\t%s Pad to %d byte boundary",
5384 ASM_COMMENT_START
, 2 * PTR_SIZE
);
5386 fputc ('\n', asm_out_file
);
5387 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_SECTION
);
5389 fprintf (asm_out_file
, "\t%s Address", ASM_COMMENT_START
);
5391 fputc ('\n', asm_out_file
);
5392 ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file
, text_end_label
, TEXT_SECTION
);
5394 fprintf (asm_out_file
, "%s Length", ASM_COMMENT_START
);
5396 fputc ('\n', asm_out_file
);
5397 for (i
= 0; i
< arange_table_in_use
; ++i
)
5399 dw_die_ref a
= arange_table
[i
];
5401 if (a
->die_tag
== DW_TAG_subprogram
)
5402 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, get_AT_low_pc (a
));
5405 char *name
= get_AT_string (a
, DW_AT_MIPS_linkage_name
);
5407 name
= get_AT_string (a
, DW_AT_name
);
5409 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, name
);
5413 fprintf (asm_out_file
, "\t%s Address", ASM_COMMENT_START
);
5415 fputc ('\n', asm_out_file
);
5416 if (a
->die_tag
== DW_TAG_subprogram
)
5417 ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file
, get_AT_hi_pc (a
),
5420 ASM_OUTPUT_DWARF_ADDR_DATA (asm_out_file
,
5421 get_AT_unsigned (a
, DW_AT_byte_size
));
5424 fprintf (asm_out_file
, "%s Length", ASM_COMMENT_START
);
5426 fputc ('\n', asm_out_file
);
5429 /* Output the terminator words. */
5430 ASM_OUTPUT_DWARF_ADDR_DATA (asm_out_file
, 0);
5431 fputc ('\n', asm_out_file
);
5432 ASM_OUTPUT_DWARF_ADDR_DATA (asm_out_file
, 0);
5433 fputc ('\n', asm_out_file
);
5436 /* Output the source line number correspondence information. This
5437 information goes into the .debug_line section.
5439 If the format of this data changes, then the function size_of_line_info
5440 must also be adjusted the same way. */
5445 char line_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5446 char prev_line_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5447 register unsigned opc
;
5448 register unsigned n_op_args
;
5449 register unsigned long ft_index
;
5450 register unsigned long lt_index
;
5451 register unsigned long current_line
;
5452 register long line_offset
;
5453 register long line_delta
;
5454 register unsigned long current_file
;
5455 register unsigned long function
;
5457 ASM_OUTPUT_DWARF_DATA (asm_out_file
, size_of_line_info ());
5459 fprintf (asm_out_file
, "\t%s Length of Source Line Info.",
5462 fputc ('\n', asm_out_file
);
5463 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, DWARF_VERSION
);
5465 fprintf (asm_out_file
, "\t%s DWARF Version", ASM_COMMENT_START
);
5467 fputc ('\n', asm_out_file
);
5468 ASM_OUTPUT_DWARF_DATA (asm_out_file
, size_of_line_prolog ());
5470 fprintf (asm_out_file
, "\t%s Prolog Length", ASM_COMMENT_START
);
5472 fputc ('\n', asm_out_file
);
5473 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DWARF_LINE_MIN_INSTR_LENGTH
);
5475 fprintf (asm_out_file
, "\t%s Minimum Instruction Length",
5478 fputc ('\n', asm_out_file
);
5479 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DWARF_LINE_DEFAULT_IS_STMT_START
);
5481 fprintf (asm_out_file
, "\t%s Default is_stmt_start flag",
5484 fputc ('\n', asm_out_file
);
5485 fprintf (asm_out_file
, "\t%s\t%d", ASM_BYTE_OP
, DWARF_LINE_BASE
);
5487 fprintf (asm_out_file
, "\t%s Line Base Value (Special Opcodes)",
5490 fputc ('\n', asm_out_file
);
5491 fprintf (asm_out_file
, "\t%s\t%u", ASM_BYTE_OP
, DWARF_LINE_RANGE
);
5493 fprintf (asm_out_file
, "\t%s Line Range Value (Special Opcodes)",
5496 fputc ('\n', asm_out_file
);
5497 fprintf (asm_out_file
, "\t%s\t%u", ASM_BYTE_OP
, DWARF_LINE_OPCODE_BASE
);
5499 fprintf (asm_out_file
, "\t%s Special Opcode Base", ASM_COMMENT_START
);
5501 fputc ('\n', asm_out_file
);
5502 for (opc
= 1; opc
< DWARF_LINE_OPCODE_BASE
; ++opc
)
5506 case DW_LNS_advance_pc
:
5507 case DW_LNS_advance_line
:
5508 case DW_LNS_set_file
:
5509 case DW_LNS_set_column
:
5510 case DW_LNS_fixed_advance_pc
:
5517 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, n_op_args
);
5519 fprintf (asm_out_file
, "\t%s opcode: 0x%x has %d args",
5520 ASM_COMMENT_START
, opc
, n_op_args
);
5521 fputc ('\n', asm_out_file
);
5525 fprintf (asm_out_file
, "%s Include Directory Table\n", ASM_COMMENT_START
);
5527 /* Include directory table is empty, at present */
5528 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5529 fputc ('\n', asm_out_file
);
5531 fprintf (asm_out_file
, "%s File Name Table\n", ASM_COMMENT_START
);
5533 for (ft_index
= 1; ft_index
< file_table_in_use
; ++ft_index
)
5537 ASM_OUTPUT_DWARF_STRING (asm_out_file
, file_table
[ft_index
]);
5538 fprintf (asm_out_file
, "%s File Entry: 0x%x",
5539 ASM_COMMENT_START
, ft_index
);
5543 ASM_OUTPUT_ASCII (asm_out_file
,
5544 file_table
[ft_index
],
5545 strlen (file_table
[ft_index
]) + 1);
5548 fputc ('\n', asm_out_file
);
5550 /* Include directory index */
5552 fputc ('\n', asm_out_file
);
5554 /* Modification time */
5556 fputc ('\n', asm_out_file
);
5558 /* File length in bytes */
5560 fputc ('\n', asm_out_file
);
5563 /* Terminate the file name table */
5564 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5565 fputc ('\n', asm_out_file
);
5567 /* Set the address register to the first location in the text section */
5568 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5570 fprintf (asm_out_file
, "\t%s DW_LNE_set_address", ASM_COMMENT_START
);
5572 fputc ('\n', asm_out_file
);
5573 output_uleb128 (1 + PTR_SIZE
);
5574 fputc ('\n', asm_out_file
);
5575 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_set_address
);
5576 fputc ('\n', asm_out_file
);
5577 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_SECTION
);
5578 fputc ('\n', asm_out_file
);
5580 /* Generate the line number to PC correspondence table, encoded as
5581 a series of state machine operations. */
5584 strcpy (prev_line_label
, TEXT_SECTION
);
5585 for (lt_index
= 1; lt_index
< line_info_table_in_use
; ++lt_index
)
5587 register dw_line_info_ref line_info
;
5589 /* Emit debug info for the address of the current line, choosing
5590 the encoding that uses the least amount of space. */
5591 /* ??? Unfortunately, we have little choice here currently, and must
5592 always use the most general form. Gcc does not know the address
5593 delta itself, so we can't use DW_LNS_advance_pc. There are no known
5594 dwarf2 aware assemblers at this time, so we can't use any special
5595 pseudo ops that would allow the assembler to optimally encode this for
5596 us. Many ports do have length attributes which will give an upper
5597 bound on the address range. We could perhaps use length attributes
5598 to determine when it is safe to use DW_LNS_fixed_advance_pc. */
5599 ASM_GENERATE_INTERNAL_LABEL (line_label
, LINE_CODE_LABEL
, lt_index
);
5602 /* This can handle deltas up to 0xffff. This takes 3 bytes. */
5603 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_fixed_advance_pc
);
5605 fprintf (asm_out_file
, "\t%s DW_LNS_fixed_advance_pc",
5608 fputc ('\n', asm_out_file
);
5609 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, line_label
, prev_line_label
);
5610 fputc ('\n', asm_out_file
);
5614 /* This can handle any delta. This takes 4+PTR_SIZE bytes. */
5615 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5617 fprintf (asm_out_file
, "\t%s DW_LNE_set_address",
5619 fputc ('\n', asm_out_file
);
5620 output_uleb128 (1 + PTR_SIZE
);
5621 fputc ('\n', asm_out_file
);
5622 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_set_address
);
5623 fputc ('\n', asm_out_file
);
5624 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, line_label
);
5625 fputc ('\n', asm_out_file
);
5627 strcpy (prev_line_label
, line_label
);
5629 /* Emit debug info for the source file of the current line, if
5630 different from the previous line. */
5631 line_info
= &line_info_table
[lt_index
];
5632 if (line_info
->dw_file_num
!= current_file
)
5634 current_file
= line_info
->dw_file_num
;
5635 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_set_file
);
5637 fprintf (asm_out_file
, "\t%s DW_LNS_set_file", ASM_COMMENT_START
);
5639 fputc ('\n', asm_out_file
);
5640 output_uleb128 (current_file
);
5642 fprintf (asm_out_file
, " (\"%s\")", file_table
[current_file
]);
5644 fputc ('\n', asm_out_file
);
5647 /* Emit debug info for the current line number, choosing the encoding
5648 that uses the least amount of space. */
5649 line_offset
= line_info
->dw_line_num
- current_line
;
5650 line_delta
= line_offset
- DWARF_LINE_BASE
;
5651 current_line
= line_info
->dw_line_num
;
5652 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
5654 /* This can handle deltas from -10 to 234, using the current
5655 definitions of DWARF_LINE_BASE and DWARF_LINE_RANGE. This
5657 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
5658 DWARF_LINE_OPCODE_BASE
+ line_delta
);
5660 fprintf (asm_out_file
,
5661 "\t%s line %d", ASM_COMMENT_START
, current_line
);
5663 fputc ('\n', asm_out_file
);
5667 /* This can handle any delta. This takes at least 4 bytes, depending
5668 on the value being encoded. */
5669 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_advance_line
);
5671 fprintf (asm_out_file
, "\t%s advance to line %d",
5672 ASM_COMMENT_START
, current_line
);
5674 fputc ('\n', asm_out_file
);
5675 output_sleb128 (line_offset
);
5676 fputc ('\n', asm_out_file
);
5677 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_copy
);
5678 fputc ('\n', asm_out_file
);
5682 /* Emit debug info for the address of the end of the function. */
5685 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_fixed_advance_pc
);
5687 fprintf (asm_out_file
, "\t%s DW_LNS_fixed_advance_pc",
5690 fputc ('\n', asm_out_file
);
5691 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, text_end_label
, prev_line_label
);
5692 fputc ('\n', asm_out_file
);
5696 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5698 fprintf (asm_out_file
, "\t%s DW_LNE_set_address", ASM_COMMENT_START
);
5699 fputc ('\n', asm_out_file
);
5700 output_uleb128 (1 + PTR_SIZE
);
5701 fputc ('\n', asm_out_file
);
5702 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_set_address
);
5703 fputc ('\n', asm_out_file
);
5704 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, text_end_label
);
5705 fputc ('\n', asm_out_file
);
5708 /* Output the marker for the end of the line number info. */
5709 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5711 fprintf (asm_out_file
, "\t%s DW_LNE_end_sequence", ASM_COMMENT_START
);
5713 fputc ('\n', asm_out_file
);
5715 fputc ('\n', asm_out_file
);
5716 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_end_sequence
);
5717 fputc ('\n', asm_out_file
);
5722 for (lt_index
= 0; lt_index
< separate_line_info_table_in_use
; )
5724 register dw_separate_line_info_ref line_info
5725 = &separate_line_info_table
[lt_index
];
5727 /* Emit debug info for the address of the current line. If this is
5728 a new function, or the first line of a function, then we need
5729 to handle it differently. */
5730 ASM_GENERATE_INTERNAL_LABEL (line_label
, SEPARATE_LINE_CODE_LABEL
,
5732 if (function
!= line_info
->function
)
5734 function
= line_info
->function
;
5736 /* Set the address register to the first line in the function */
5737 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5739 fprintf (asm_out_file
, "\t%s DW_LNE_set_address",
5742 fputc ('\n', asm_out_file
);
5743 output_uleb128 (1 + PTR_SIZE
);
5744 fputc ('\n', asm_out_file
);
5745 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_set_address
);
5746 fputc ('\n', asm_out_file
);
5747 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, line_label
);
5748 fputc ('\n', asm_out_file
);
5752 /* ??? See the DW_LNS_advance_pc comment above. */
5755 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_fixed_advance_pc
);
5757 fprintf (asm_out_file
, "\t%s DW_LNS_fixed_advance_pc",
5760 fputc ('\n', asm_out_file
);
5761 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, line_label
,
5763 fputc ('\n', asm_out_file
);
5767 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5769 fprintf (asm_out_file
, "\t%s DW_LNE_set_address",
5771 fputc ('\n', asm_out_file
);
5772 output_uleb128 (1 + PTR_SIZE
);
5773 fputc ('\n', asm_out_file
);
5774 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_set_address
);
5775 fputc ('\n', asm_out_file
);
5776 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, line_label
);
5777 fputc ('\n', asm_out_file
);
5780 strcpy (prev_line_label
, line_label
);
5782 /* Emit debug info for the source file of the current line, if
5783 different from the previous line. */
5784 if (line_info
->dw_file_num
!= current_file
)
5786 current_file
= line_info
->dw_file_num
;
5787 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_set_file
);
5789 fprintf (asm_out_file
, "\t%s DW_LNS_set_file", ASM_COMMENT_START
);
5791 fputc ('\n', asm_out_file
);
5792 output_uleb128 (current_file
);
5794 fprintf (asm_out_file
, " (\"%s\")", file_table
[current_file
]);
5796 fputc ('\n', asm_out_file
);
5799 /* Emit debug info for the current line number, choosing the encoding
5800 that uses the least amount of space. */
5801 if (line_info
->dw_line_num
!= current_line
)
5803 line_offset
= line_info
->dw_line_num
- current_line
;
5804 line_delta
= line_offset
- DWARF_LINE_BASE
;
5805 current_line
= line_info
->dw_line_num
;
5806 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
5808 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
5809 DWARF_LINE_OPCODE_BASE
+ line_delta
);
5811 fprintf (asm_out_file
,
5812 "\t%s line %d", ASM_COMMENT_START
, current_line
);
5814 fputc ('\n', asm_out_file
);
5818 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_advance_line
);
5820 fprintf (asm_out_file
, "\t%s advance to line %d",
5821 ASM_COMMENT_START
, current_line
);
5823 fputc ('\n', asm_out_file
);
5824 output_sleb128 (line_offset
);
5825 fputc ('\n', asm_out_file
);
5826 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_copy
);
5827 fputc ('\n', asm_out_file
);
5833 /* If we're done with a function, end its sequence. */
5834 if (lt_index
== separate_line_info_table_in_use
5835 || separate_line_info_table
[lt_index
].function
!= function
)
5840 /* Emit debug info for the address of the end of the function. */
5841 ASM_GENERATE_INTERNAL_LABEL (line_label
, FUNC_END_LABEL
, function
);
5844 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_fixed_advance_pc
);
5846 fprintf (asm_out_file
, "\t%s DW_LNS_fixed_advance_pc",
5849 fputc ('\n', asm_out_file
);
5850 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, line_label
,
5852 fputc ('\n', asm_out_file
);
5856 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5858 fprintf (asm_out_file
, "\t%s DW_LNE_set_address",
5860 fputc ('\n', asm_out_file
);
5861 output_uleb128 (1 + PTR_SIZE
);
5862 fputc ('\n', asm_out_file
);
5863 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_set_address
);
5864 fputc ('\n', asm_out_file
);
5865 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, line_label
);
5866 fputc ('\n', asm_out_file
);
5869 /* Output the marker for the end of this sequence. */
5870 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5872 fprintf (asm_out_file
, "\t%s DW_LNE_end_sequence",
5875 fputc ('\n', asm_out_file
);
5877 fputc ('\n', asm_out_file
);
5878 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_end_sequence
);
5879 fputc ('\n', asm_out_file
);
5884 /* Given a pointer to a BLOCK node return non-zero if (and only if) the node
5885 in question represents the outermost pair of curly braces (i.e. the "body
5886 block") of a function or method.
5888 For any BLOCK node representing a "body block" of a function or method, the
5889 BLOCK_SUPERCONTEXT of the node will point to another BLOCK node which
5890 represents the outermost (function) scope for the function or method (i.e.
5891 the one which includes the formal parameters). The BLOCK_SUPERCONTEXT of
5892 *that* node in turn will point to the relevant FUNCTION_DECL node. */
5895 is_body_block (stmt
)
5898 if (TREE_CODE (stmt
) == BLOCK
)
5900 register tree parent
= BLOCK_SUPERCONTEXT (stmt
);
5902 if (TREE_CODE (parent
) == BLOCK
)
5904 register tree grandparent
= BLOCK_SUPERCONTEXT (parent
);
5906 if (TREE_CODE (grandparent
) == FUNCTION_DECL
)
5914 /* Given a pointer to a tree node for some base type, return a pointer to
5915 a DIE that describes the given type.
5917 This routine must only be called for GCC type nodes that correspond to
5918 Dwarf base (fundamental) types. */
5921 base_type_die (type
)
5924 register dw_die_ref base_type_result
;
5925 register char *type_name
;
5926 register enum dwarf_type encoding
;
5927 register tree name
= TYPE_NAME (type
);
5929 if (TREE_CODE (type
) == ERROR_MARK
5930 || TREE_CODE (type
) == VOID_TYPE
)
5933 if (TREE_CODE (name
) == TYPE_DECL
)
5934 name
= DECL_NAME (name
);
5935 type_name
= IDENTIFIER_POINTER (name
);
5937 switch (TREE_CODE (type
))
5940 /* Carefully distinguish the C character types, without messing
5941 up if the language is not C. Note that we check only for the names
5942 that contain spaces; other names might occur by coincidence in other
5944 if (! (TYPE_PRECISION (type
) == CHAR_TYPE_SIZE
5945 && (type
== char_type_node
5946 || ! strcmp (type_name
, "signed char")
5947 || ! strcmp (type_name
, "unsigned char"))))
5949 if (TREE_UNSIGNED (type
))
5950 encoding
= DW_ATE_unsigned
;
5952 encoding
= DW_ATE_signed
;
5955 /* else fall through */
5958 /* GNU Pascal/Ada CHAR type. Not used in C. */
5959 if (TREE_UNSIGNED (type
))
5960 encoding
= DW_ATE_unsigned_char
;
5962 encoding
= DW_ATE_signed_char
;
5966 encoding
= DW_ATE_float
;
5970 encoding
= DW_ATE_complex_float
;
5974 /* GNU FORTRAN/Ada/C++ BOOLEAN type. */
5975 encoding
= DW_ATE_boolean
;
5979 abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
5982 base_type_result
= new_die (DW_TAG_base_type
, comp_unit_die
);
5983 add_AT_string (base_type_result
, DW_AT_name
, type_name
);
5984 add_AT_unsigned (base_type_result
, DW_AT_byte_size
,
5985 TYPE_PRECISION (type
) / BITS_PER_UNIT
);
5986 add_AT_unsigned (base_type_result
, DW_AT_encoding
, encoding
);
5988 return base_type_result
;
5991 /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
5992 the Dwarf "root" type for the given input type. The Dwarf "root" type of
5993 a given type is generally the same as the given type, except that if the
5994 given type is a pointer or reference type, then the root type of the given
5995 type is the root type of the "basis" type for the pointer or reference
5996 type. (This definition of the "root" type is recursive.) Also, the root
5997 type of a `const' qualified type or a `volatile' qualified type is the
5998 root type of the given type without the qualifiers. */
6004 if (TREE_CODE (type
) == ERROR_MARK
)
6005 return error_mark_node
;
6007 switch (TREE_CODE (type
))
6010 return error_mark_node
;
6013 case REFERENCE_TYPE
:
6014 return type_main_variant (root_type (TREE_TYPE (type
)));
6017 return type_main_variant (type
);
6021 /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
6022 given input type is a Dwarf "fundamental" type. Otherwise return null. */
6028 switch (TREE_CODE (type
))
6043 case QUAL_UNION_TYPE
:
6048 case REFERENCE_TYPE
:
6061 /* Given a pointer to an arbitrary ..._TYPE tree node, return a debugging
6062 entry that chains various modifiers in front of the given type. */
6065 modified_type_die (type
, is_const_type
, is_volatile_type
, context_die
)
6067 register int is_const_type
;
6068 register int is_volatile_type
;
6069 register dw_die_ref context_die
;
6071 register enum tree_code code
= TREE_CODE (type
);
6072 register dw_die_ref mod_type_die
= NULL
;
6073 register dw_die_ref sub_die
= NULL
;
6074 register tree item_type
= NULL
;
6076 if (code
!= ERROR_MARK
)
6078 type
= build_type_variant (type
, is_const_type
, is_volatile_type
);
6080 mod_type_die
= lookup_type_die (type
);
6082 return mod_type_die
;
6084 /* Handle C typedef types. */
6085 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
6086 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
6088 tree dtype
= TREE_TYPE (TYPE_NAME (type
));
6091 /* For a named type, use the typedef. */
6092 gen_type_die (type
, context_die
);
6093 mod_type_die
= lookup_type_die (type
);
6096 else if (is_const_type
< TYPE_READONLY (dtype
)
6097 || is_volatile_type
< TYPE_VOLATILE (dtype
))
6098 /* cv-unqualified version of named type. Just use the unnamed
6099 type to which it refers. */
6101 = modified_type_die (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)),
6102 is_const_type
, is_volatile_type
,
6104 /* Else cv-qualified version of named type; fall through. */
6109 else if (is_const_type
)
6111 mod_type_die
= new_die (DW_TAG_const_type
, comp_unit_die
);
6112 sub_die
= modified_type_die (type
, 0, is_volatile_type
, context_die
);
6114 else if (is_volatile_type
)
6116 mod_type_die
= new_die (DW_TAG_volatile_type
, comp_unit_die
);
6117 sub_die
= modified_type_die (type
, 0, 0, context_die
);
6119 else if (code
== POINTER_TYPE
)
6121 mod_type_die
= new_die (DW_TAG_pointer_type
, comp_unit_die
);
6122 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
6124 add_AT_unsigned (mod_type_die
, DW_AT_address_class
, 0);
6126 item_type
= TREE_TYPE (type
);
6128 else if (code
== REFERENCE_TYPE
)
6130 mod_type_die
= new_die (DW_TAG_reference_type
, comp_unit_die
);
6131 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
6133 add_AT_unsigned (mod_type_die
, DW_AT_address_class
, 0);
6135 item_type
= TREE_TYPE (type
);
6137 else if (is_base_type (type
))
6138 mod_type_die
= base_type_die (type
);
6141 gen_type_die (type
, context_die
);
6143 /* We have to get the type_main_variant here (and pass that to the
6144 `lookup_type_die' routine) because the ..._TYPE node we have
6145 might simply be a *copy* of some original type node (where the
6146 copy was created to help us keep track of typedef names) and
6147 that copy might have a different TYPE_UID from the original
6149 mod_type_die
= lookup_type_die (type_main_variant (type
));
6150 assert (mod_type_die
!= NULL
);
6154 equate_type_number_to_die (type
, mod_type_die
);
6156 /* We must do this after the equate_type_number_to_die call, in case
6157 this is a recursive type. This ensures that the modified_type_die
6158 recursion will terminate even if the type is recursive. Recursive
6159 types are possible in Ada. */
6160 sub_die
= modified_type_die (item_type
,
6161 TYPE_READONLY (item_type
),
6162 TYPE_VOLATILE (item_type
),
6165 if (sub_die
!= NULL
)
6166 add_AT_die_ref (mod_type_die
, DW_AT_type
, sub_die
);
6168 return mod_type_die
;
6171 /* Given a pointer to an arbitrary ..._TYPE tree node, return true if it is
6172 an enumerated type. */
6178 return TREE_CODE (type
) == ENUMERAL_TYPE
;
6181 /* Return a location descriptor that designates a machine register. */
6183 static dw_loc_descr_ref
6184 reg_loc_descriptor (rtl
)
6187 register dw_loc_descr_ref loc_result
= NULL
;
6188 register unsigned reg
= reg_number (rtl
);
6190 if (reg
>= 0 && reg
<= 31)
6191 loc_result
= new_loc_descr (DW_OP_reg0
+ reg
, 0, 0);
6193 loc_result
= new_loc_descr (DW_OP_regx
, reg
, 0);
6198 /* Return a location descriptor that designates a base+offset location. */
6200 static dw_loc_descr_ref
6201 based_loc_descr (reg
, offset
)
6205 register dw_loc_descr_ref loc_result
;
6206 /* For the "frame base", we use the frame pointer or stack pointer
6207 registers, since the RTL for local variables is relative to one of
6209 register unsigned fp_reg
= DBX_REGISTER_NUMBER (frame_pointer_needed
6210 ? HARD_FRAME_POINTER_REGNUM
6211 : STACK_POINTER_REGNUM
);
6214 loc_result
= new_loc_descr (DW_OP_fbreg
, offset
, 0);
6215 else if (reg
>= 0 && reg
<= 31)
6216 loc_result
= new_loc_descr (DW_OP_breg0
+ reg
, offset
, 0);
6218 loc_result
= new_loc_descr (DW_OP_bregx
, reg
, offset
);
6223 /* Return true if this RTL expression describes a base+offset calculation. */
6229 return (GET_CODE (rtl
) == PLUS
6230 && ((GET_CODE (XEXP (rtl
, 0)) == REG
6231 && GET_CODE (XEXP (rtl
, 1)) == CONST_INT
)));
6234 /* The following routine converts the RTL for a variable or parameter
6235 (resident in memory) into an equivalent Dwarf representation of a
6236 mechanism for getting the address of that same variable onto the top of a
6237 hypothetical "address evaluation" stack.
6239 When creating memory location descriptors, we are effectively transforming
6240 the RTL for a memory-resident object into its Dwarf postfix expression
6241 equivalent. This routine recursively descends an RTL tree, turning
6242 it into Dwarf postfix code as it goes. */
6244 static dw_loc_descr_ref
6245 mem_loc_descriptor (rtl
)
6248 dw_loc_descr_ref mem_loc_result
= NULL
;
6249 /* Note that for a dynamically sized array, the location we will generate a
6250 description of here will be the lowest numbered location which is
6251 actually within the array. That's *not* necessarily the same as the
6252 zeroth element of the array. */
6254 switch (GET_CODE (rtl
))
6257 /* The case of a subreg may arise when we have a local (register)
6258 variable or a formal (register) parameter which doesn't quite fill
6259 up an entire register. For now, just assume that it is
6260 legitimate to make the Dwarf info refer to the whole register which
6261 contains the given subreg. */
6262 rtl
= XEXP (rtl
, 0);
6264 /* ... fall through ... */
6267 /* Whenever a register number forms a part of the description of the
6268 method for calculating the (dynamic) address of a memory resident
6269 object, DWARF rules require the register number be referred to as
6270 a "base register". This distinction is not based in any way upon
6271 what category of register the hardware believes the given register
6272 belongs to. This is strictly DWARF terminology we're dealing with
6273 here. Note that in cases where the location of a memory-resident
6274 data object could be expressed as: OP_ADD (OP_BASEREG (basereg),
6275 OP_CONST (0)) the actual DWARF location descriptor that we generate
6276 may just be OP_BASEREG (basereg). This may look deceptively like
6277 the object in question was allocated to a register (rather than in
6278 memory) so DWARF consumers need to be aware of the subtle
6279 distinction between OP_REG and OP_BASEREG. */
6280 mem_loc_result
= based_loc_descr (reg_number (rtl
), 0);
6284 mem_loc_result
= mem_loc_descriptor (XEXP (rtl
, 0));
6285 add_loc_descr (&mem_loc_result
, new_loc_descr (DW_OP_deref
, 0, 0));
6290 mem_loc_result
= new_loc_descr (DW_OP_addr
, 0, 0);
6291 mem_loc_result
->dw_loc_oprnd1
.val_class
= dw_val_class_addr
;
6292 mem_loc_result
->dw_loc_oprnd1
.v
.val_addr
= addr_to_string (rtl
);
6296 if (is_based_loc (rtl
))
6297 mem_loc_result
= based_loc_descr (reg_number (XEXP (rtl
, 0)),
6298 INTVAL (XEXP (rtl
, 1)));
6301 add_loc_descr (&mem_loc_result
, mem_loc_descriptor (XEXP (rtl
, 0)));
6302 add_loc_descr (&mem_loc_result
, mem_loc_descriptor (XEXP (rtl
, 1)));
6303 add_loc_descr (&mem_loc_result
, new_loc_descr (DW_OP_plus
, 0, 0));
6308 /* If a pseudo-reg is optimized away, it is possible for it to
6309 be replaced with a MEM containing a multiply. */
6310 add_loc_descr (&mem_loc_result
, mem_loc_descriptor (XEXP (rtl
, 0)));
6311 add_loc_descr (&mem_loc_result
, mem_loc_descriptor (XEXP (rtl
, 1)));
6312 add_loc_descr (&mem_loc_result
, new_loc_descr (DW_OP_mul
, 0, 0));
6316 mem_loc_result
= new_loc_descr (DW_OP_constu
, INTVAL (rtl
), 0);
6323 return mem_loc_result
;
6326 /* Return a descriptor that describes the concatination of two locations.
6327 This is typically a complex variable. */
6329 static dw_loc_descr_ref
6330 concat_loc_descriptor (x0
, x1
)
6331 register rtx x0
, x1
;
6333 dw_loc_descr_ref cc_loc_result
= NULL
;
6335 if (!is_pseudo_reg (x0
)
6336 && (GET_CODE (x0
) != MEM
|| !is_pseudo_reg (XEXP (x0
, 0))))
6337 add_loc_descr (&cc_loc_result
, loc_descriptor (x0
));
6338 add_loc_descr (&cc_loc_result
,
6339 new_loc_descr (DW_OP_piece
, GET_MODE_SIZE (GET_MODE (x0
)), 0));
6341 if (!is_pseudo_reg (x1
)
6342 && (GET_CODE (x1
) != MEM
|| !is_pseudo_reg (XEXP (x1
, 0))))
6343 add_loc_descr (&cc_loc_result
, loc_descriptor (x1
));
6344 add_loc_descr (&cc_loc_result
,
6345 new_loc_descr (DW_OP_piece
, GET_MODE_SIZE (GET_MODE (x1
)), 0));
6347 return cc_loc_result
;
6350 /* Output a proper Dwarf location descriptor for a variable or parameter
6351 which is either allocated in a register or in a memory location. For a
6352 register, we just generate an OP_REG and the register number. For a
6353 memory location we provide a Dwarf postfix expression describing how to
6354 generate the (dynamic) address of the object onto the address stack. */
6356 static dw_loc_descr_ref
6357 loc_descriptor (rtl
)
6360 dw_loc_descr_ref loc_result
= NULL
;
6361 switch (GET_CODE (rtl
))
6364 /* The case of a subreg may arise when we have a local (register)
6365 variable or a formal (register) parameter which doesn't quite fill
6366 up an entire register. For now, just assume that it is
6367 legitimate to make the Dwarf info refer to the whole register which
6368 contains the given subreg. */
6369 rtl
= XEXP (rtl
, 0);
6371 /* ... fall through ... */
6374 loc_result
= reg_loc_descriptor (rtl
);
6378 loc_result
= mem_loc_descriptor (XEXP (rtl
, 0));
6382 loc_result
= concat_loc_descriptor (XEXP (rtl
, 0), XEXP (rtl
, 1));
6392 /* Given an unsigned value, round it up to the lowest multiple of `boundary'
6393 which is not less than the value itself. */
6395 static inline unsigned
6396 ceiling (value
, boundary
)
6397 register unsigned value
;
6398 register unsigned boundary
;
6400 return (((value
+ boundary
- 1) / boundary
) * boundary
);
6403 /* Given a pointer to what is assumed to be a FIELD_DECL node, return a
6404 pointer to the declared type for the relevant field variable, or return
6405 `integer_type_node' if the given node turns out to be an
6414 if (TREE_CODE (decl
) == ERROR_MARK
)
6415 return integer_type_node
;
6417 type
= DECL_BIT_FIELD_TYPE (decl
);
6418 if (type
== NULL_TREE
)
6419 type
= TREE_TYPE (decl
);
6424 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
6425 node, return the alignment in bits for the type, or else return
6426 BITS_PER_WORD if the node actually turns out to be an
6429 static inline unsigned
6430 simple_type_align_in_bits (type
)
6433 return (TREE_CODE (type
) != ERROR_MARK
) ? TYPE_ALIGN (type
) : BITS_PER_WORD
;
6436 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
6437 node, return the size in bits for the type if it is a constant, or else
6438 return the alignment for the type if the type's size is not constant, or
6439 else return BITS_PER_WORD if the type actually turns out to be an
6442 static inline unsigned
6443 simple_type_size_in_bits (type
)
6446 if (TREE_CODE (type
) == ERROR_MARK
)
6447 return BITS_PER_WORD
;
6450 register tree type_size_tree
= TYPE_SIZE (type
);
6452 if (TREE_CODE (type_size_tree
) != INTEGER_CST
)
6453 return TYPE_ALIGN (type
);
6455 return (unsigned) TREE_INT_CST_LOW (type_size_tree
);
6459 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
6460 return the byte offset of the lowest addressed byte of the "containing
6461 object" for the given FIELD_DECL, or return 0 if we are unable to
6462 determine what that offset is, either because the argument turns out to
6463 be a pointer to an ERROR_MARK node, or because the offset is actually
6464 variable. (We can't handle the latter case just yet). */
6467 field_byte_offset (decl
)
6470 register unsigned type_align_in_bytes
;
6471 register unsigned type_align_in_bits
;
6472 register unsigned type_size_in_bits
;
6473 register unsigned object_offset_in_align_units
;
6474 register unsigned object_offset_in_bits
;
6475 register unsigned object_offset_in_bytes
;
6477 register tree bitpos_tree
;
6478 register tree field_size_tree
;
6479 register unsigned bitpos_int
;
6480 register unsigned deepest_bitpos
;
6481 register unsigned field_size_in_bits
;
6483 if (TREE_CODE (decl
) == ERROR_MARK
)
6486 if (TREE_CODE (decl
) != FIELD_DECL
)
6489 type
= field_type (decl
);
6491 bitpos_tree
= DECL_FIELD_BITPOS (decl
);
6492 field_size_tree
= DECL_SIZE (decl
);
6494 /* We cannot yet cope with fields whose positions or sizes are variable, so
6495 for now, when we see such things, we simply return 0. Someday, we may
6496 be able to handle such cases, but it will be damn difficult. */
6497 if (TREE_CODE (bitpos_tree
) != INTEGER_CST
)
6499 bitpos_int
= (unsigned) TREE_INT_CST_LOW (bitpos_tree
);
6501 if (TREE_CODE (field_size_tree
) != INTEGER_CST
)
6504 field_size_in_bits
= (unsigned) TREE_INT_CST_LOW (field_size_tree
);
6505 type_size_in_bits
= simple_type_size_in_bits (type
);
6506 type_align_in_bits
= simple_type_align_in_bits (type
);
6507 type_align_in_bytes
= type_align_in_bits
/ BITS_PER_UNIT
;
6509 /* Note that the GCC front-end doesn't make any attempt to keep track of
6510 the starting bit offset (relative to the start of the containing
6511 structure type) of the hypothetical "containing object" for a bit-
6512 field. Thus, when computing the byte offset value for the start of the
6513 "containing object" of a bit-field, we must deduce this information on
6514 our own. This can be rather tricky to do in some cases. For example,
6515 handling the following structure type definition when compiling for an
6516 i386/i486 target (which only aligns long long's to 32-bit boundaries)
6519 struct S { int field1; long long field2:31; };
6521 Fortunately, there is a simple rule-of-thumb which can be
6522 used in such cases. When compiling for an i386/i486, GCC will allocate
6523 8 bytes for the structure shown above. It decides to do this based upon
6524 one simple rule for bit-field allocation. Quite simply, GCC allocates
6525 each "containing object" for each bit-field at the first (i.e. lowest
6526 addressed) legitimate alignment boundary (based upon the required
6527 minimum alignment for the declared type of the field) which it can
6528 possibly use, subject to the condition that there is still enough
6529 available space remaining in the containing object (when allocated at
6530 the selected point) to fully accommodate all of the bits of the
6531 bit-field itself. This simple rule makes it obvious why GCC allocates
6532 8 bytes for each object of the structure type shown above. When looking
6533 for a place to allocate the "containing object" for `field2', the
6534 compiler simply tries to allocate a 64-bit "containing object" at each
6535 successive 32-bit boundary (starting at zero) until it finds a place to
6536 allocate that 64- bit field such that at least 31 contiguous (and
6537 previously unallocated) bits remain within that selected 64 bit field.
6538 (As it turns out, for the example above, the compiler finds that it is
6539 OK to allocate the "containing object" 64-bit field at bit-offset zero
6540 within the structure type.) Here we attempt to work backwards from the
6541 limited set of facts we're given, and we try to deduce from those facts,
6542 where GCC must have believed that the containing object started (within
6543 the structure type). The value we deduce is then used (by the callers of
6544 this routine) to generate DW_AT_location and DW_AT_bit_offset attributes
6545 for fields (both bit-fields and, in the case of DW_AT_location, regular
6548 /* Figure out the bit-distance from the start of the structure to the
6549 "deepest" bit of the bit-field. */
6550 deepest_bitpos
= bitpos_int
+ field_size_in_bits
;
6552 /* This is the tricky part. Use some fancy footwork to deduce where the
6553 lowest addressed bit of the containing object must be. */
6554 object_offset_in_bits
6555 = ceiling (deepest_bitpos
, type_align_in_bits
) - type_size_in_bits
;
6557 /* Compute the offset of the containing object in "alignment units". */
6558 object_offset_in_align_units
= object_offset_in_bits
/ type_align_in_bits
;
6560 /* Compute the offset of the containing object in bytes. */
6561 object_offset_in_bytes
= object_offset_in_align_units
* type_align_in_bytes
;
6563 return object_offset_in_bytes
;
6566 /* The following routines define various Dwarf attributes and any data
6567 associated with them. */
6569 /* Add a location description attribute value to a DIE.
6571 This emits location attributes suitable for whole variables and
6572 whole parameters. Note that the location attributes for struct fields are
6573 generated by the routine `data_member_location_attribute' below. */
6576 add_AT_location_description (die
, attr_kind
, rtl
)
6578 enum dwarf_attribute attr_kind
;
6581 /* Handle a special case. If we are about to output a location descriptor
6582 for a variable or parameter which has been optimized out of existence,
6583 don't do that. A variable which has been optimized out
6584 of existence will have a DECL_RTL value which denotes a pseudo-reg.
6585 Currently, in some rare cases, variables can have DECL_RTL values which
6586 look like (MEM (REG pseudo-reg#)). These cases are due to bugs
6587 elsewhere in the compiler. We treat such cases as if the variable(s) in
6588 question had been optimized out of existence. */
6590 if (is_pseudo_reg (rtl
)
6591 || (GET_CODE (rtl
) == MEM
6592 && is_pseudo_reg (XEXP (rtl
, 0)))
6593 || (GET_CODE (rtl
) == CONCAT
6594 && is_pseudo_reg (XEXP (rtl
, 0))
6595 && is_pseudo_reg (XEXP (rtl
, 1))))
6598 add_AT_loc (die
, attr_kind
, loc_descriptor (rtl
));
6601 /* Attach the specialized form of location attribute used for data
6602 members of struct and union types. In the special case of a
6603 FIELD_DECL node which represents a bit-field, the "offset" part
6604 of this special location descriptor must indicate the distance
6605 in bytes from the lowest-addressed byte of the containing struct
6606 or union type to the lowest-addressed byte of the "containing
6607 object" for the bit-field. (See the `field_byte_offset' function
6608 above).. For any given bit-field, the "containing object" is a
6609 hypothetical object (of some integral or enum type) within which
6610 the given bit-field lives. The type of this hypothetical
6611 "containing object" is always the same as the declared type of
6612 the individual bit-field itself (for GCC anyway... the DWARF
6613 spec doesn't actually mandate this). Note that it is the size
6614 (in bytes) of the hypothetical "containing object" which will
6615 be given in the DW_AT_byte_size attribute for this bit-field.
6616 (See the `byte_size_attribute' function below.) It is also used
6617 when calculating the value of the DW_AT_bit_offset attribute.
6618 (See the `bit_offset_attribute' function below). */
6621 add_data_member_location_attribute (die
, decl
)
6622 register dw_die_ref die
;
6625 register unsigned long offset
;
6626 register dw_loc_descr_ref loc_descr
;
6627 register enum dwarf_location_atom op
;
6629 if (TREE_CODE (decl
) == TREE_VEC
)
6630 offset
= TREE_INT_CST_LOW (BINFO_OFFSET (decl
));
6632 offset
= field_byte_offset (decl
);
6634 /* The DWARF2 standard says that we should assume that the structure address
6635 is already on the stack, so we can specify a structure field address
6636 by using DW_OP_plus_uconst. */
6638 #ifdef MIPS_DEBUGGING_INFO
6639 /* ??? The SGI dwarf reader does not handle the DW_OP_plus_uconst operator
6640 correctly. It works only if we leave the offset on the stack. */
6643 op
= DW_OP_plus_uconst
;
6646 loc_descr
= new_loc_descr (op
, offset
, 0);
6647 add_AT_loc (die
, DW_AT_data_member_location
, loc_descr
);
6650 /* Attach an DW_AT_const_value attribute for a variable or a parameter which
6651 does not have a "location" either in memory or in a register. These
6652 things can arise in GNU C when a constant is passed as an actual parameter
6653 to an inlined function. They can also arise in C++ where declared
6654 constants do not necessarily get memory "homes". */
6657 add_const_value_attribute (die
, rtl
)
6658 register dw_die_ref die
;
6661 switch (GET_CODE (rtl
))
6664 /* Note that a CONST_INT rtx could represent either an integer or a
6665 floating-point constant. A CONST_INT is used whenever the constant
6666 will fit into a single word. In all such cases, the original mode
6667 of the constant value is wiped out, and the CONST_INT rtx is
6668 assigned VOIDmode. */
6669 add_AT_unsigned (die
, DW_AT_const_value
, (unsigned) INTVAL (rtl
));
6673 /* Note that a CONST_DOUBLE rtx could represent either an integer or a
6674 floating-point constant. A CONST_DOUBLE is used whenever the
6675 constant requires more than one word in order to be adequately
6676 represented. We output CONST_DOUBLEs as blocks. */
6678 register enum machine_mode mode
= GET_MODE (rtl
);
6680 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
)
6682 register unsigned length
= GET_MODE_SIZE (mode
) / sizeof (long);
6686 REAL_VALUE_FROM_CONST_DOUBLE (rv
, rtl
);
6690 REAL_VALUE_TO_TARGET_SINGLE (rv
, array
[0]);
6694 REAL_VALUE_TO_TARGET_DOUBLE (rv
, array
);
6699 REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv
, array
);
6706 add_AT_float (die
, DW_AT_const_value
, length
, array
);
6709 add_AT_long_long (die
, DW_AT_const_value
,
6710 CONST_DOUBLE_HIGH (rtl
), CONST_DOUBLE_LOW (rtl
));
6715 add_AT_string (die
, DW_AT_const_value
, XSTR (rtl
, 0));
6721 add_AT_addr (die
, DW_AT_const_value
, addr_to_string (rtl
));
6725 /* In cases where an inlined instance of an inline function is passed
6726 the address of an `auto' variable (which is local to the caller) we
6727 can get a situation where the DECL_RTL of the artificial local
6728 variable (for the inlining) which acts as a stand-in for the
6729 corresponding formal parameter (of the inline function) will look
6730 like (plus:SI (reg:SI FRAME_PTR) (const_int ...)). This is not
6731 exactly a compile-time constant expression, but it isn't the address
6732 of the (artificial) local variable either. Rather, it represents the
6733 *value* which the artificial local variable always has during its
6734 lifetime. We currently have no way to represent such quasi-constant
6735 values in Dwarf, so for now we just punt and generate nothing. */
6739 /* No other kinds of rtx should be possible here. */
6745 /* Generate *either* an DW_AT_location attribute or else an DW_AT_const_value
6746 data attribute for a variable or a parameter. We generate the
6747 DW_AT_const_value attribute only in those cases where the given variable
6748 or parameter does not have a true "location" either in memory or in a
6749 register. This can happen (for example) when a constant is passed as an
6750 actual argument in a call to an inline function. (It's possible that
6751 these things can crop up in other ways also.) Note that one type of
6752 constant value which can be passed into an inlined function is a constant
6753 pointer. This can happen for example if an actual argument in an inlined
6754 function call evaluates to a compile-time constant address. */
6757 add_location_or_const_value_attribute (die
, decl
)
6758 register dw_die_ref die
;
6762 register tree declared_type
;
6763 register tree passed_type
;
6765 if (TREE_CODE (decl
) == ERROR_MARK
)
6768 if (TREE_CODE (decl
) != VAR_DECL
&& TREE_CODE (decl
) != PARM_DECL
)
6771 /* Here we have to decide where we are going to say the parameter "lives"
6772 (as far as the debugger is concerned). We only have a couple of
6773 choices. GCC provides us with DECL_RTL and with DECL_INCOMING_RTL.
6775 DECL_RTL normally indicates where the parameter lives during most of the
6776 activation of the function. If optimization is enabled however, this
6777 could be either NULL or else a pseudo-reg. Both of those cases indicate
6778 that the parameter doesn't really live anywhere (as far as the code
6779 generation parts of GCC are concerned) during most of the function's
6780 activation. That will happen (for example) if the parameter is never
6781 referenced within the function.
6783 We could just generate a location descriptor here for all non-NULL
6784 non-pseudo values of DECL_RTL and ignore all of the rest, but we can be
6785 a little nicer than that if we also consider DECL_INCOMING_RTL in cases
6786 where DECL_RTL is NULL or is a pseudo-reg.
6788 Note however that we can only get away with using DECL_INCOMING_RTL as
6789 a backup substitute for DECL_RTL in certain limited cases. In cases
6790 where DECL_ARG_TYPE (decl) indicates the same type as TREE_TYPE (decl),
6791 we can be sure that the parameter was passed using the same type as it is
6792 declared to have within the function, and that its DECL_INCOMING_RTL
6793 points us to a place where a value of that type is passed.
6795 In cases where DECL_ARG_TYPE (decl) and TREE_TYPE (decl) are different,
6796 we cannot (in general) use DECL_INCOMING_RTL as a substitute for DECL_RTL
6797 because in these cases DECL_INCOMING_RTL points us to a value of some
6798 type which is *different* from the type of the parameter itself. Thus,
6799 if we tried to use DECL_INCOMING_RTL to generate a location attribute in
6800 such cases, the debugger would end up (for example) trying to fetch a
6801 `float' from a place which actually contains the first part of a
6802 `double'. That would lead to really incorrect and confusing
6803 output at debug-time.
6805 So, in general, we *do not* use DECL_INCOMING_RTL as a backup for DECL_RTL
6806 in cases where DECL_ARG_TYPE (decl) != TREE_TYPE (decl). There
6807 are a couple of exceptions however. On little-endian machines we can
6808 get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE (decl) is
6809 not the same as TREE_TYPE (decl), but only when DECL_ARG_TYPE (decl) is
6810 an integral type that is smaller than TREE_TYPE (decl). These cases arise
6811 when (on a little-endian machine) a non-prototyped function has a
6812 parameter declared to be of type `short' or `char'. In such cases,
6813 TREE_TYPE (decl) will be `short' or `char', DECL_ARG_TYPE (decl) will
6814 be `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
6815 passed `int' value. If the debugger then uses that address to fetch
6816 a `short' or a `char' (on a little-endian machine) the result will be
6817 the correct data, so we allow for such exceptional cases below.
6819 Note that our goal here is to describe the place where the given formal
6820 parameter lives during most of the function's activation (i.e. between
6821 the end of the prologue and the start of the epilogue). We'll do that
6822 as best as we can. Note however that if the given formal parameter is
6823 modified sometime during the execution of the function, then a stack
6824 backtrace (at debug-time) will show the function as having been
6825 called with the *new* value rather than the value which was
6826 originally passed in. This happens rarely enough that it is not
6827 a major problem, but it *is* a problem, and I'd like to fix it.
6829 A future version of dwarf2out.c may generate two additional
6830 attributes for any given DW_TAG_formal_parameter DIE which will
6831 describe the "passed type" and the "passed location" for the
6832 given formal parameter in addition to the attributes we now
6833 generate to indicate the "declared type" and the "active
6834 location" for each parameter. This additional set of attributes
6835 could be used by debuggers for stack backtraces. Separately, note
6836 that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL can be
6837 NULL also. This happens (for example) for inlined-instances of
6838 inline function formal parameters which are never referenced.
6839 This really shouldn't be happening. All PARM_DECL nodes should
6840 get valid non-NULL DECL_INCOMING_RTL values, but integrate.c
6841 doesn't currently generate these values for inlined instances of
6842 inline function parameters, so when we see such cases, we are
6843 just SOL (shit-out-of-luck) for the time being (until integrate.c
6846 /* Use DECL_RTL as the "location" unless we find something better. */
6847 rtl
= DECL_RTL (decl
);
6849 if (TREE_CODE (decl
) == PARM_DECL
)
6851 if (rtl
== NULL_RTX
|| is_pseudo_reg (rtl
))
6853 declared_type
= type_main_variant (TREE_TYPE (decl
));
6854 passed_type
= type_main_variant (DECL_ARG_TYPE (decl
));
6856 /* This decl represents a formal parameter which was optimized out.
6857 Note that DECL_INCOMING_RTL may be NULL in here, but we handle
6858 all* cases where (rtl == NULL_RTX) just below. */
6859 if (declared_type
== passed_type
)
6860 rtl
= DECL_INCOMING_RTL (decl
);
6861 else if (! BYTES_BIG_ENDIAN
6862 && TREE_CODE (declared_type
) == INTEGER_TYPE
6863 && TYPE_SIZE (declared_type
) <= TYPE_SIZE (passed_type
))
6864 rtl
= DECL_INCOMING_RTL (decl
);
6868 if (rtl
== NULL_RTX
)
6871 rtl
= eliminate_regs (rtl
, 0, NULL_RTX
, 0);
6872 #ifdef LEAF_REG_REMAP
6874 leaf_renumber_regs_insn (rtl
);
6877 switch (GET_CODE (rtl
))
6880 /* The address of a variable that was optimized away; don't emit
6891 /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
6892 add_const_value_attribute (die
, rtl
);
6899 add_AT_location_description (die
, DW_AT_location
, rtl
);
6907 /* Generate an DW_AT_name attribute given some string value to be included as
6908 the value of the attribute. */
6911 add_name_attribute (die
, name_string
)
6912 register dw_die_ref die
;
6913 register char *name_string
;
6915 if (name_string
!= NULL
&& *name_string
!= 0)
6916 add_AT_string (die
, DW_AT_name
, name_string
);
6919 /* Given a tree node describing an array bound (either lower or upper) output
6920 a representation for that bound. */
6923 add_bound_info (subrange_die
, bound_attr
, bound
)
6924 register dw_die_ref subrange_die
;
6925 register enum dwarf_attribute bound_attr
;
6926 register tree bound
;
6928 register unsigned bound_value
= 0;
6930 /* If this is an Ada unconstrained array type, then don't emit any debug
6931 info because the array bounds are unknown. They are parameterized when
6932 the type is instantiated. */
6933 if (contains_placeholder_p (bound
))
6936 switch (TREE_CODE (bound
))
6941 /* All fixed-bounds are represented by INTEGER_CST nodes. */
6943 bound_value
= TREE_INT_CST_LOW (bound
);
6944 if (bound_attr
== DW_AT_lower_bound
6945 && ((is_c_family () && bound_value
== 0)
6946 || (is_fortran () && bound_value
== 1)))
6947 /* use the default */;
6949 add_AT_unsigned (subrange_die
, bound_attr
, bound_value
);
6954 case NON_LVALUE_EXPR
:
6955 add_bound_info (subrange_die
, bound_attr
, TREE_OPERAND (bound
, 0));
6959 /* If optimization is turned on, the SAVE_EXPRs that describe how to
6960 access the upper bound values may be bogus. If they refer to a
6961 register, they may only describe how to get at these values at the
6962 points in the generated code right after they have just been
6963 computed. Worse yet, in the typical case, the upper bound values
6964 will not even *be* computed in the optimized code (though the
6965 number of elements will), so these SAVE_EXPRs are entirely
6966 bogus. In order to compensate for this fact, we check here to see
6967 if optimization is enabled, and if so, we don't add an attribute
6968 for the (unknown and unknowable) upper bound. This should not
6969 cause too much trouble for existing (stupid?) debuggers because
6970 they have to deal with empty upper bounds location descriptions
6971 anyway in order to be able to deal with incomplete array types.
6972 Of course an intelligent debugger (GDB?) should be able to
6973 comprehend that a missing upper bound specification in a array
6974 type used for a storage class `auto' local array variable
6975 indicates that the upper bound is both unknown (at compile- time)
6976 and unknowable (at run-time) due to optimization.
6978 We assume that a MEM rtx is safe because gcc wouldn't put the
6979 value there unless it was going to be used repeatedly in the
6980 function, i.e. for cleanups. */
6981 if (! optimize
|| GET_CODE (SAVE_EXPR_RTL (bound
)) == MEM
)
6983 register dw_die_ref ctx
= lookup_decl_die (current_function_decl
);
6984 register dw_die_ref decl_die
= new_die (DW_TAG_variable
, ctx
);
6985 add_AT_flag (decl_die
, DW_AT_artificial
, 1);
6986 add_type_attribute (decl_die
, TREE_TYPE (bound
), 1, 0, ctx
);
6987 add_AT_location_description (decl_die
, DW_AT_location
,
6988 SAVE_EXPR_RTL (bound
));
6989 add_AT_die_ref (subrange_die
, bound_attr
, decl_die
);
6992 /* Else leave out the attribute. */
6997 /* ??? These types of bounds can be created by the Ada front end,
6998 and it isn't clear how to emit debug info for them. */
7006 /* Note that the block of subscript information for an array type also
7007 includes information about the element type of type given array type. */
7010 add_subscript_info (type_die
, type
)
7011 register dw_die_ref type_die
;
7014 register unsigned dimension_number
;
7015 register tree lower
, upper
;
7016 register dw_die_ref subrange_die
;
7018 /* The GNU compilers represent multidimensional array types as sequences of
7019 one dimensional array types whose element types are themselves array
7020 types. Here we squish that down, so that each multidimensional array
7021 type gets only one array_type DIE in the Dwarf debugging info. The draft
7022 Dwarf specification say that we are allowed to do this kind of
7023 compression in C (because there is no difference between an array or
7024 arrays and a multidimensional array in C) but for other source languages
7025 (e.g. Ada) we probably shouldn't do this. */
7027 /* ??? The SGI dwarf reader fails for multidimensional arrays with a
7028 const enum type. E.g. const enum machine_mode insn_operand_mode[2][10].
7029 We work around this by disabling this feature. See also
7030 gen_array_type_die. */
7031 #ifndef MIPS_DEBUGGING_INFO
7032 for (dimension_number
= 0;
7033 TREE_CODE (type
) == ARRAY_TYPE
;
7034 type
= TREE_TYPE (type
), dimension_number
++)
7037 register tree domain
= TYPE_DOMAIN (type
);
7039 /* Arrays come in three flavors: Unspecified bounds, fixed bounds,
7040 and (in GNU C only) variable bounds. Handle all three forms
7042 subrange_die
= new_die (DW_TAG_subrange_type
, type_die
);
7045 /* We have an array type with specified bounds. */
7046 lower
= TYPE_MIN_VALUE (domain
);
7047 upper
= TYPE_MAX_VALUE (domain
);
7049 /* define the index type. */
7050 if (TREE_TYPE (domain
))
7052 /* ??? This is probably an Ada unnamed subrange type. Ignore the
7053 TREE_TYPE field. We can't emit debug info for this
7054 because it is an unnamed integral type. */
7055 if (TREE_CODE (domain
) == INTEGER_TYPE
7056 && TYPE_NAME (domain
) == NULL_TREE
7057 && TREE_CODE (TREE_TYPE (domain
)) == INTEGER_TYPE
7058 && TYPE_NAME (TREE_TYPE (domain
)) == NULL_TREE
)
7061 add_type_attribute (subrange_die
, TREE_TYPE (domain
), 0, 0,
7065 add_bound_info (subrange_die
, DW_AT_lower_bound
, lower
);
7066 add_bound_info (subrange_die
, DW_AT_upper_bound
, upper
);
7069 /* We have an array type with an unspecified length. The DWARF-2
7070 spec does not say how to handle this; let's just leave out the
7074 #ifndef MIPS_DEBUGGING_INFO
7080 add_byte_size_attribute (die
, tree_node
)
7082 register tree tree_node
;
7084 register unsigned size
;
7086 switch (TREE_CODE (tree_node
))
7094 case QUAL_UNION_TYPE
:
7095 size
= int_size_in_bytes (tree_node
);
7098 /* For a data member of a struct or union, the DW_AT_byte_size is
7099 generally given as the number of bytes normally allocated for an
7100 object of the *declared* type of the member itself. This is true
7101 even for bit-fields. */
7102 size
= simple_type_size_in_bits (field_type (tree_node
)) / BITS_PER_UNIT
;
7108 /* Note that `size' might be -1 when we get to this point. If it is, that
7109 indicates that the byte size of the entity in question is variable. We
7110 have no good way of expressing this fact in Dwarf at the present time,
7111 so just let the -1 pass on through. */
7113 add_AT_unsigned (die
, DW_AT_byte_size
, size
);
7116 /* For a FIELD_DECL node which represents a bit-field, output an attribute
7117 which specifies the distance in bits from the highest order bit of the
7118 "containing object" for the bit-field to the highest order bit of the
7121 For any given bit-field, the "containing object" is a hypothetical
7122 object (of some integral or enum type) within which the given bit-field
7123 lives. The type of this hypothetical "containing object" is always the
7124 same as the declared type of the individual bit-field itself. The
7125 determination of the exact location of the "containing object" for a
7126 bit-field is rather complicated. It's handled by the
7127 `field_byte_offset' function (above).
7129 Note that it is the size (in bytes) of the hypothetical "containing object"
7130 which will be given in the DW_AT_byte_size attribute for this bit-field.
7131 (See `byte_size_attribute' above). */
7134 add_bit_offset_attribute (die
, decl
)
7135 register dw_die_ref die
;
7138 register unsigned object_offset_in_bytes
= field_byte_offset (decl
);
7139 register tree type
= DECL_BIT_FIELD_TYPE (decl
);
7140 register tree bitpos_tree
= DECL_FIELD_BITPOS (decl
);
7141 register unsigned bitpos_int
;
7142 register unsigned highest_order_object_bit_offset
;
7143 register unsigned highest_order_field_bit_offset
;
7144 register unsigned bit_offset
;
7146 assert (TREE_CODE (decl
) == FIELD_DECL
); /* Must be a field. */
7147 assert (type
); /* Must be a bit field. */
7149 /* We can't yet handle bit-fields whose offsets are variable, so if we
7150 encounter such things, just return without generating any attribute
7152 if (TREE_CODE (bitpos_tree
) != INTEGER_CST
)
7155 bitpos_int
= (unsigned) TREE_INT_CST_LOW (bitpos_tree
);
7157 /* Note that the bit offset is always the distance (in bits) from the
7158 highest-order bit of the "containing object" to the highest-order bit of
7159 the bit-field itself. Since the "high-order end" of any object or field
7160 is different on big-endian and little-endian machines, the computation
7161 below must take account of these differences. */
7162 highest_order_object_bit_offset
= object_offset_in_bytes
* BITS_PER_UNIT
;
7163 highest_order_field_bit_offset
= bitpos_int
;
7165 if (! BYTES_BIG_ENDIAN
)
7167 highest_order_field_bit_offset
7168 += (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl
));
7170 highest_order_object_bit_offset
+= simple_type_size_in_bits (type
);
7174 = (! BYTES_BIG_ENDIAN
7175 ? highest_order_object_bit_offset
- highest_order_field_bit_offset
7176 : highest_order_field_bit_offset
- highest_order_object_bit_offset
);
7178 add_AT_unsigned (die
, DW_AT_bit_offset
, bit_offset
);
7181 /* For a FIELD_DECL node which represents a bit field, output an attribute
7182 which specifies the length in bits of the given field. */
7185 add_bit_size_attribute (die
, decl
)
7186 register dw_die_ref die
;
7189 assert (TREE_CODE (decl
) == FIELD_DECL
); /* Must be a field. */
7190 assert (DECL_BIT_FIELD_TYPE (decl
)); /* Must be a bit field. */
7191 add_AT_unsigned (die
, DW_AT_bit_size
,
7192 (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl
)));
7195 /* If the compiled language is ANSI C, then add a 'prototyped'
7196 attribute, if arg types are given for the parameters of a function. */
7199 add_prototyped_attribute (die
, func_type
)
7200 register dw_die_ref die
;
7201 register tree func_type
;
7203 if (get_AT_unsigned (comp_unit_die
, DW_AT_language
) == DW_LANG_C89
7204 && TYPE_ARG_TYPES (func_type
) != NULL
)
7205 add_AT_flag (die
, DW_AT_prototyped
, 1);
7209 /* Add an 'abstract_origin' attribute below a given DIE. The DIE is found
7210 by looking in either the type declaration or object declaration
7214 add_abstract_origin_attribute (die
, origin
)
7215 register dw_die_ref die
;
7216 register tree origin
;
7218 dw_die_ref origin_die
= NULL
;
7219 if (TREE_CODE_CLASS (TREE_CODE (origin
)) == 'd')
7220 origin_die
= lookup_decl_die (origin
);
7221 else if (TREE_CODE_CLASS (TREE_CODE (origin
)) == 't')
7222 origin_die
= lookup_type_die (origin
);
7224 add_AT_die_ref (die
, DW_AT_abstract_origin
, origin_die
);
7227 /* We do not currently support the pure_virtual attribute. */
7230 add_pure_or_virtual_attribute (die
, func_decl
)
7231 register dw_die_ref die
;
7232 register tree func_decl
;
7234 if (DECL_VINDEX (func_decl
))
7236 add_AT_unsigned (die
, DW_AT_virtuality
, DW_VIRTUALITY_virtual
);
7237 add_AT_loc (die
, DW_AT_vtable_elem_location
,
7238 new_loc_descr (DW_OP_constu
,
7239 TREE_INT_CST_LOW (DECL_VINDEX (func_decl
)),
7242 /* GNU extension: Record what type this method came from originally. */
7243 if (debug_info_level
> DINFO_LEVEL_TERSE
)
7244 add_AT_die_ref (die
, DW_AT_containing_type
,
7245 lookup_type_die (DECL_CONTEXT (func_decl
)));
7249 /* Add source coordinate attributes for the given decl. */
7252 add_src_coords_attributes (die
, decl
)
7253 register dw_die_ref die
;
7256 register unsigned file_index
= lookup_filename (DECL_SOURCE_FILE (decl
));
7258 add_AT_unsigned (die
, DW_AT_decl_file
, file_index
);
7259 add_AT_unsigned (die
, DW_AT_decl_line
, DECL_SOURCE_LINE (decl
));
7262 /* Add an DW_AT_name attribute and source coordinate attribute for the
7263 given decl, but only if it actually has a name. */
7266 add_name_and_src_coords_attributes (die
, decl
)
7267 register dw_die_ref die
;
7270 register tree decl_name
;
7272 decl_name
= DECL_NAME (decl
);
7273 if (decl_name
!= NULL
&& IDENTIFIER_POINTER (decl_name
) != NULL
)
7275 add_name_attribute (die
, dwarf2_name (decl
, 0));
7276 add_src_coords_attributes (die
, decl
);
7277 if ((TREE_CODE (decl
) == FUNCTION_DECL
|| TREE_CODE (decl
) == VAR_DECL
)
7278 && DECL_ASSEMBLER_NAME (decl
) != DECL_NAME (decl
))
7279 add_AT_string (die
, DW_AT_MIPS_linkage_name
,
7280 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
7284 /* Push a new declaration scope. */
7287 push_decl_scope (scope
)
7290 /* Make room in the decl_scope_table, if necessary. */
7291 if (decl_scope_table_allocated
== decl_scope_depth
)
7293 decl_scope_table_allocated
+= DECL_SCOPE_TABLE_INCREMENT
;
7295 = (tree
*) xrealloc (decl_scope_table
,
7296 decl_scope_table_allocated
* sizeof (tree
));
7299 decl_scope_table
[decl_scope_depth
++] = scope
;
7302 /* Return the DIE for the scope the immediately contains this declaration. */
7305 scope_die_for (t
, context_die
)
7307 register dw_die_ref context_die
;
7309 register dw_die_ref scope_die
= NULL
;
7310 register tree containing_scope
;
7311 register unsigned long i
;
7313 /* Walk back up the declaration tree looking for a place to define
7315 if (TREE_CODE_CLASS (TREE_CODE (t
)) == 't')
7316 containing_scope
= TYPE_CONTEXT (t
);
7317 else if (TREE_CODE (t
) == FUNCTION_DECL
&& DECL_VINDEX (t
))
7318 containing_scope
= decl_class_context (t
);
7320 containing_scope
= DECL_CONTEXT (t
);
7322 /* Function-local tags and functions get stuck in limbo until they are
7323 fixed up by decls_for_scope. */
7324 if (context_die
== NULL
&& containing_scope
!= NULL_TREE
7325 && (TREE_CODE (t
) == FUNCTION_DECL
|| is_tagged_type (t
)))
7328 if (containing_scope
== NULL_TREE
)
7329 scope_die
= comp_unit_die
;
7332 for (i
= decl_scope_depth
, scope_die
= context_die
;
7333 i
> 0 && decl_scope_table
[i
- 1] != containing_scope
;
7334 scope_die
= scope_die
->die_parent
, --i
)
7339 assert (scope_die
== comp_unit_die
);
7340 assert (TREE_CODE_CLASS (TREE_CODE (containing_scope
)) == 't');
7341 if (debug_info_level
> DINFO_LEVEL_TERSE
)
7342 assert (TREE_ASM_WRITTEN (containing_scope
));
7349 /* Pop a declaration scope. */
7353 assert (decl_scope_depth
> 0);
7357 /* Many forms of DIEs require a "type description" attribute. This
7358 routine locates the proper "type descriptor" die for the type given
7359 by 'type', and adds an DW_AT_type attribute below the given die. */
7362 add_type_attribute (object_die
, type
, decl_const
, decl_volatile
, context_die
)
7363 register dw_die_ref object_die
;
7365 register int decl_const
;
7366 register int decl_volatile
;
7367 register dw_die_ref context_die
;
7369 register enum tree_code code
= TREE_CODE (type
);
7370 register dw_die_ref type_die
= NULL
;
7372 /* ??? If this type is an unnamed subrange type of an integral or
7373 floating-point type, use the inner type. This is because we have no
7374 support for unnamed types in base_type_die. This can happen if this is
7375 an Ada subrange type. Correct solution is emit a subrange type die. */
7376 if ((code
== INTEGER_TYPE
|| code
== REAL_TYPE
)
7377 && TREE_TYPE (type
) != 0 && TYPE_NAME (type
) == 0)
7378 type
= TREE_TYPE (type
), code
= TREE_CODE (type
);
7380 if (code
== ERROR_MARK
)
7383 /* Handle a special case. For functions whose return type is void, we
7384 generate *no* type attribute. (Note that no object may have type
7385 `void', so this only applies to function return types). */
7386 if (code
== VOID_TYPE
)
7389 type_die
= modified_type_die (type
,
7390 decl_const
|| TYPE_READONLY (type
),
7391 decl_volatile
|| TYPE_VOLATILE (type
),
7393 if (type_die
!= NULL
)
7394 add_AT_die_ref (object_die
, DW_AT_type
, type_die
);
7397 /* Given a tree pointer to a struct, class, union, or enum type node, return
7398 a pointer to the (string) tag name for the given type, or zero if the type
7399 was declared without a tag. */
7405 register char *name
= 0;
7407 if (TYPE_NAME (type
) != 0)
7409 register tree t
= 0;
7411 /* Find the IDENTIFIER_NODE for the type name. */
7412 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
7413 t
= TYPE_NAME (type
);
7415 /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
7416 a TYPE_DECL node, regardless of whether or not a `typedef' was
7418 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
7419 && ! DECL_IGNORED_P (TYPE_NAME (type
)))
7420 t
= DECL_NAME (TYPE_NAME (type
));
7422 /* Now get the name as a string, or invent one. */
7424 name
= IDENTIFIER_POINTER (t
);
7427 return (name
== 0 || *name
== '\0') ? 0 : name
;
7430 /* Return the type associated with a data member, make a special check
7431 for bit field types. */
7434 member_declared_type (member
)
7435 register tree member
;
7437 return (DECL_BIT_FIELD_TYPE (member
)
7438 ? DECL_BIT_FIELD_TYPE (member
)
7439 : TREE_TYPE (member
));
7442 /* Get the decl's label, as described by its RTL. This may be different
7443 from the DECL_NAME name used in the source file. */
7446 decl_start_label (decl
)
7451 x
= DECL_RTL (decl
);
7452 if (GET_CODE (x
) != MEM
)
7456 if (GET_CODE (x
) != SYMBOL_REF
)
7459 fnname
= XSTR (x
, 0);
7463 /* These routines generate the internnal representation of the DIE's for
7464 the compilation unit. Debugging information is collected by walking
7465 the declaration trees passed in from dwarf2out_decl(). */
7468 gen_array_type_die (type
, context_die
)
7470 register dw_die_ref context_die
;
7472 register dw_die_ref scope_die
= scope_die_for (type
, context_die
);
7473 register dw_die_ref array_die
;
7474 register tree element_type
;
7476 /* ??? The SGI dwarf reader fails for array of array of enum types unless
7477 the inner array type comes before the outer array type. Thus we must
7478 call gen_type_die before we call new_die. See below also. */
7479 #ifdef MIPS_DEBUGGING_INFO
7480 gen_type_die (TREE_TYPE (type
), context_die
);
7483 array_die
= new_die (DW_TAG_array_type
, scope_die
);
7486 /* We default the array ordering. SDB will probably do
7487 the right things even if DW_AT_ordering is not present. It's not even
7488 an issue until we start to get into multidimensional arrays anyway. If
7489 SDB is ever caught doing the Wrong Thing for multi-dimensional arrays,
7490 then we'll have to put the DW_AT_ordering attribute back in. (But if
7491 and when we find out that we need to put these in, we will only do so
7492 for multidimensional arrays. */
7493 add_AT_unsigned (array_die
, DW_AT_ordering
, DW_ORD_row_major
);
7496 #ifdef MIPS_DEBUGGING_INFO
7497 /* The SGI compilers handle arrays of unknown bound by setting
7498 AT_declaration and not emitting any subrange DIEs. */
7499 if (! TYPE_DOMAIN (type
))
7500 add_AT_unsigned (array_die
, DW_AT_declaration
, 1);
7503 add_subscript_info (array_die
, type
);
7505 equate_type_number_to_die (type
, array_die
);
7507 /* Add representation of the type of the elements of this array type. */
7508 element_type
= TREE_TYPE (type
);
7510 /* ??? The SGI dwarf reader fails for multidimensional arrays with a
7511 const enum type. E.g. const enum machine_mode insn_operand_mode[2][10].
7512 We work around this by disabling this feature. See also
7513 add_subscript_info. */
7514 #ifndef MIPS_DEBUGGING_INFO
7515 while (TREE_CODE (element_type
) == ARRAY_TYPE
)
7516 element_type
= TREE_TYPE (element_type
);
7518 gen_type_die (element_type
, context_die
);
7521 add_type_attribute (array_die
, element_type
, 0, 0, context_die
);
7525 gen_set_type_die (type
, context_die
)
7527 register dw_die_ref context_die
;
7529 register dw_die_ref type_die
7530 = new_die (DW_TAG_set_type
, scope_die_for (type
, context_die
));
7532 equate_type_number_to_die (type
, type_die
);
7533 add_type_attribute (type_die
, TREE_TYPE (type
), 0, 0, context_die
);
7537 gen_entry_point_die (decl
, context_die
)
7539 register dw_die_ref context_die
;
7541 register tree origin
= decl_ultimate_origin (decl
);
7542 register dw_die_ref decl_die
= new_die (DW_TAG_entry_point
, context_die
);
7544 add_abstract_origin_attribute (decl_die
, origin
);
7547 add_name_and_src_coords_attributes (decl_die
, decl
);
7548 add_type_attribute (decl_die
, TREE_TYPE (TREE_TYPE (decl
)),
7552 if (DECL_ABSTRACT (decl
))
7553 equate_decl_number_to_die (decl
, decl_die
);
7555 add_AT_lbl_id (decl_die
, DW_AT_low_pc
, decl_start_label (decl
));
7558 /* Remember a type in the pending_types_list. */
7564 if (pending_types
== pending_types_allocated
)
7566 pending_types_allocated
+= PENDING_TYPES_INCREMENT
;
7568 = (tree
*) xrealloc (pending_types_list
,
7569 sizeof (tree
) * pending_types_allocated
);
7572 pending_types_list
[pending_types
++] = type
;
7575 /* Output any pending types (from the pending_types list) which we can output
7576 now (taking into account the scope that we are working on now).
7578 For each type output, remove the given type from the pending_types_list
7579 *before* we try to output it. */
7582 output_pending_types_for_scope (context_die
)
7583 register dw_die_ref context_die
;
7587 while (pending_types
)
7590 type
= pending_types_list
[pending_types
];
7591 gen_type_die (type
, context_die
);
7592 assert (TREE_ASM_WRITTEN (type
));
7596 /* Generate a DIE to represent an inlined instance of an enumeration type. */
7599 gen_inlined_enumeration_type_die (type
, context_die
)
7601 register dw_die_ref context_die
;
7603 register dw_die_ref type_die
= new_die (DW_TAG_enumeration_type
,
7604 scope_die_for (type
, context_die
));
7606 assert (TREE_ASM_WRITTEN (type
));
7607 add_abstract_origin_attribute (type_die
, type
);
7610 /* Generate a DIE to represent an inlined instance of a structure type. */
7613 gen_inlined_structure_type_die (type
, context_die
)
7615 register dw_die_ref context_die
;
7617 register dw_die_ref type_die
= new_die (DW_TAG_structure_type
,
7618 scope_die_for (type
, context_die
));
7620 assert (TREE_ASM_WRITTEN (type
));
7621 add_abstract_origin_attribute (type_die
, type
);
7624 /* Generate a DIE to represent an inlined instance of a union type. */
7627 gen_inlined_union_type_die (type
, context_die
)
7629 register dw_die_ref context_die
;
7631 register dw_die_ref type_die
= new_die (DW_TAG_union_type
,
7632 scope_die_for (type
, context_die
));
7634 assert (TREE_ASM_WRITTEN (type
));
7635 add_abstract_origin_attribute (type_die
, type
);
7638 /* Generate a DIE to represent an enumeration type. Note that these DIEs
7639 include all of the information about the enumeration values also. Each
7640 enumerated type name/value is listed as a child of the enumerated type
7644 gen_enumeration_type_die (type
, context_die
)
7646 register dw_die_ref context_die
;
7648 register dw_die_ref type_die
= lookup_type_die (type
);
7650 if (type_die
== NULL
)
7652 type_die
= new_die (DW_TAG_enumeration_type
,
7653 scope_die_for (type
, context_die
));
7654 equate_type_number_to_die (type
, type_die
);
7655 add_name_attribute (type_die
, type_tag (type
));
7657 else if (! TYPE_SIZE (type
))
7660 remove_AT (type_die
, DW_AT_declaration
);
7662 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
7663 given enum type is incomplete, do not generate the DW_AT_byte_size
7664 attribute or the DW_AT_element_list attribute. */
7665 if (TYPE_SIZE (type
))
7669 TREE_ASM_WRITTEN (type
) = 1;
7670 add_byte_size_attribute (type_die
, type
);
7671 if (TYPE_STUB_DECL (type
) != NULL_TREE
)
7672 add_src_coords_attributes (type_die
, TYPE_STUB_DECL (type
));
7674 /* If the first reference to this type was as the return type of an
7675 inline function, then it may not have a parent. Fix this now. */
7676 if (type_die
->die_parent
== NULL
)
7677 add_child_die (scope_die_for (type
, context_die
), type_die
);
7679 for (link
= TYPE_FIELDS (type
);
7680 link
!= NULL
; link
= TREE_CHAIN (link
))
7682 register dw_die_ref enum_die
= new_die (DW_TAG_enumerator
, type_die
);
7684 add_name_attribute (enum_die
,
7685 IDENTIFIER_POINTER (TREE_PURPOSE (link
)));
7686 add_AT_unsigned (enum_die
, DW_AT_const_value
,
7687 (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link
)));
7691 add_AT_flag (type_die
, DW_AT_declaration
, 1);
7695 /* Generate a DIE to represent either a real live formal parameter decl or to
7696 represent just the type of some formal parameter position in some function
7699 Note that this routine is a bit unusual because its argument may be a
7700 ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
7701 represents an inlining of some PARM_DECL) or else some sort of a ..._TYPE
7702 node. If it's the former then this function is being called to output a
7703 DIE to represent a formal parameter object (or some inlining thereof). If
7704 it's the latter, then this function is only being called to output a
7705 DW_TAG_formal_parameter DIE to stand as a placeholder for some formal
7706 argument type of some subprogram type. */
7709 gen_formal_parameter_die (node
, context_die
)
7711 register dw_die_ref context_die
;
7713 register dw_die_ref parm_die
7714 = new_die (DW_TAG_formal_parameter
, context_die
);
7715 register tree origin
;
7717 switch (TREE_CODE_CLASS (TREE_CODE (node
)))
7720 origin
= decl_ultimate_origin (node
);
7722 add_abstract_origin_attribute (parm_die
, origin
);
7725 add_name_and_src_coords_attributes (parm_die
, node
);
7726 add_type_attribute (parm_die
, TREE_TYPE (node
),
7727 TREE_READONLY (node
),
7728 TREE_THIS_VOLATILE (node
),
7730 if (DECL_ARTIFICIAL (node
))
7731 add_AT_flag (parm_die
, DW_AT_artificial
, 1);
7734 equate_decl_number_to_die (node
, parm_die
);
7735 if (! DECL_ABSTRACT (node
))
7736 add_location_or_const_value_attribute (parm_die
, node
);
7741 /* We were called with some kind of a ..._TYPE node. */
7742 add_type_attribute (parm_die
, node
, 0, 0, context_die
);
7752 /* Generate a special type of DIE used as a stand-in for a trailing ellipsis
7753 at the end of an (ANSI prototyped) formal parameters list. */
7756 gen_unspecified_parameters_die (decl_or_type
, context_die
)
7757 register tree decl_or_type
;
7758 register dw_die_ref context_die
;
7760 register dw_die_ref parm_die
= new_die (DW_TAG_unspecified_parameters
,
7764 /* Generate a list of nameless DW_TAG_formal_parameter DIEs (and perhaps a
7765 DW_TAG_unspecified_parameters DIE) to represent the types of the formal
7766 parameters as specified in some function type specification (except for
7767 those which appear as part of a function *definition*).
7769 Note we must be careful here to output all of the parameter DIEs before*
7770 we output any DIEs needed to represent the types of the formal parameters.
7771 This keeps svr4 SDB happy because it (incorrectly) thinks that the first
7772 non-parameter DIE it sees ends the formal parameter list. */
7775 gen_formal_types_die (function_or_method_type
, context_die
)
7776 register tree function_or_method_type
;
7777 register dw_die_ref context_die
;
7780 register tree formal_type
= NULL
;
7781 register tree first_parm_type
= TYPE_ARG_TYPES (function_or_method_type
);
7784 /* In the case where we are generating a formal types list for a C++
7785 non-static member function type, skip over the first thing on the
7786 TYPE_ARG_TYPES list because it only represents the type of the hidden
7787 `this pointer'. The debugger should be able to figure out (without
7788 being explicitly told) that this non-static member function type takes a
7789 `this pointer' and should be able to figure what the type of that hidden
7790 parameter is from the DW_AT_member attribute of the parent
7791 DW_TAG_subroutine_type DIE. */
7792 if (TREE_CODE (function_or_method_type
) == METHOD_TYPE
)
7793 first_parm_type
= TREE_CHAIN (first_parm_type
);
7796 /* Make our first pass over the list of formal parameter types and output a
7797 DW_TAG_formal_parameter DIE for each one. */
7798 for (link
= first_parm_type
; link
; link
= TREE_CHAIN (link
))
7800 register dw_die_ref parm_die
;
7802 formal_type
= TREE_VALUE (link
);
7803 if (formal_type
== void_type_node
)
7806 /* Output a (nameless) DIE to represent the formal parameter itself. */
7807 parm_die
= gen_formal_parameter_die (formal_type
, context_die
);
7808 if (TREE_CODE (function_or_method_type
) == METHOD_TYPE
7809 && link
== first_parm_type
)
7810 add_AT_flag (parm_die
, DW_AT_artificial
, 1);
7813 /* If this function type has an ellipsis, add a
7814 DW_TAG_unspecified_parameters DIE to the end of the parameter list. */
7815 if (formal_type
!= void_type_node
)
7816 gen_unspecified_parameters_die (function_or_method_type
, context_die
);
7818 /* Make our second (and final) pass over the list of formal parameter types
7819 and output DIEs to represent those types (as necessary). */
7820 for (link
= TYPE_ARG_TYPES (function_or_method_type
);
7822 link
= TREE_CHAIN (link
))
7824 formal_type
= TREE_VALUE (link
);
7825 if (formal_type
== void_type_node
)
7828 gen_type_die (formal_type
, context_die
);
7832 /* Generate a DIE to represent a declared function (either file-scope or
7836 gen_subprogram_die (decl
, context_die
)
7838 register dw_die_ref context_die
;
7840 char label_id
[MAX_ARTIFICIAL_LABEL_BYTES
];
7841 register tree origin
= decl_ultimate_origin (decl
);
7842 register dw_die_ref subr_die
;
7843 register dw_loc_descr_ref fp_loc
= NULL
;
7844 register rtx fp_reg
;
7845 register tree fn_arg_types
;
7846 register tree outer_scope
;
7847 register dw_die_ref old_die
= lookup_decl_die (decl
);
7848 register int declaration
7849 = (current_function_decl
!= decl
7851 && (context_die
->die_tag
== DW_TAG_structure_type
7852 || context_die
->die_tag
== DW_TAG_union_type
)));
7856 subr_die
= new_die (DW_TAG_subprogram
, context_die
);
7857 add_abstract_origin_attribute (subr_die
, origin
);
7859 else if (old_die
&& DECL_ABSTRACT (decl
)
7860 && get_AT_unsigned (old_die
, DW_AT_inline
))
7862 /* This must be a redefinition of an extern inline function.
7863 We can just reuse the old die here. */
7866 /* Clear out the inlined attribute and parm types. */
7867 remove_AT (subr_die
, DW_AT_inline
);
7868 remove_children (subr_die
);
7872 register unsigned file_index
7873 = lookup_filename (DECL_SOURCE_FILE (decl
));
7875 assert (get_AT_flag (old_die
, DW_AT_declaration
) == 1);
7877 /* If the definition comes from the same place as the declaration,
7878 maybe use the old DIE. We always want the DIE for this function
7879 that has the *_pc attributes to be under comp_unit_die so the
7880 debugger can find it. For inlines, that is the concrete instance,
7881 so we can use the old DIE here. For non-inline methods, we want a
7882 specification DIE at toplevel, so we need a new DIE. For local
7883 class methods, this does not apply. */
7884 if ((DECL_ABSTRACT (decl
) || old_die
->die_parent
== comp_unit_die
7885 || context_die
== NULL
)
7886 && get_AT_unsigned (old_die
, DW_AT_decl_file
) == file_index
7887 && (get_AT_unsigned (old_die
, DW_AT_decl_line
)
7888 == DECL_SOURCE_LINE (decl
)))
7892 /* Clear out the declaration attribute and the parm types. */
7893 remove_AT (subr_die
, DW_AT_declaration
);
7894 remove_children (subr_die
);
7898 subr_die
= new_die (DW_TAG_subprogram
, context_die
);
7899 add_AT_die_ref (subr_die
, DW_AT_specification
, old_die
);
7900 if (get_AT_unsigned (old_die
, DW_AT_decl_file
) != file_index
)
7901 add_AT_unsigned (subr_die
, DW_AT_decl_file
, file_index
);
7902 if (get_AT_unsigned (old_die
, DW_AT_decl_line
)
7903 != DECL_SOURCE_LINE (decl
))
7905 (subr_die
, DW_AT_decl_line
, DECL_SOURCE_LINE (decl
));
7910 register dw_die_ref scope_die
;
7912 if (DECL_CONTEXT (decl
))
7913 scope_die
= scope_die_for (decl
, context_die
);
7915 /* Don't put block extern declarations under comp_unit_die. */
7916 scope_die
= context_die
;
7918 subr_die
= new_die (DW_TAG_subprogram
, scope_die
);
7920 if (TREE_PUBLIC (decl
))
7921 add_AT_flag (subr_die
, DW_AT_external
, 1);
7923 add_name_and_src_coords_attributes (subr_die
, decl
);
7924 if (debug_info_level
> DINFO_LEVEL_TERSE
)
7926 register tree type
= TREE_TYPE (decl
);
7928 add_prototyped_attribute (subr_die
, type
);
7929 add_type_attribute (subr_die
, TREE_TYPE (type
), 0, 0, context_die
);
7932 add_pure_or_virtual_attribute (subr_die
, decl
);
7933 if (DECL_ARTIFICIAL (decl
))
7934 add_AT_flag (subr_die
, DW_AT_artificial
, 1);
7935 if (TREE_PROTECTED (decl
))
7936 add_AT_unsigned (subr_die
, DW_AT_accessibility
, DW_ACCESS_protected
);
7937 else if (TREE_PRIVATE (decl
))
7938 add_AT_unsigned (subr_die
, DW_AT_accessibility
, DW_ACCESS_private
);
7943 add_AT_flag (subr_die
, DW_AT_declaration
, 1);
7945 /* The first time we see a member function, it is in the context of
7946 the class to which it belongs. We make sure of this by emitting
7947 the class first. The next time is the definition, which is
7948 handled above. The two may come from the same source text. */
7949 if (DECL_CONTEXT (decl
))
7950 equate_decl_number_to_die (decl
, subr_die
);
7952 else if (DECL_ABSTRACT (decl
))
7954 /* ??? Checking DECL_DEFER_OUTPUT is correct for static inline functions,
7955 but not for extern inline functions. We can't get this completely
7956 correct because information about whether the function was declared
7957 inline is not saved anywhere. */
7958 if (DECL_DEFER_OUTPUT (decl
))
7960 if (DECL_INLINE (decl
))
7961 add_AT_unsigned (subr_die
, DW_AT_inline
, DW_INL_declared_inlined
);
7963 add_AT_unsigned (subr_die
, DW_AT_inline
,
7964 DW_INL_declared_not_inlined
);
7966 else if (DECL_INLINE (decl
))
7967 add_AT_unsigned (subr_die
, DW_AT_inline
, DW_INL_inlined
);
7971 equate_decl_number_to_die (decl
, subr_die
);
7973 else if (!DECL_EXTERNAL (decl
))
7975 if (origin
== NULL_TREE
)
7976 equate_decl_number_to_die (decl
, subr_die
);
7978 ASM_GENERATE_INTERNAL_LABEL (label_id
, FUNC_BEGIN_LABEL
,
7979 current_funcdef_number
);
7980 add_AT_lbl_id (subr_die
, DW_AT_low_pc
, label_id
);
7981 ASM_GENERATE_INTERNAL_LABEL (label_id
, FUNC_END_LABEL
,
7982 current_funcdef_number
);
7983 add_AT_lbl_id (subr_die
, DW_AT_high_pc
, label_id
);
7985 add_pubname (decl
, subr_die
);
7986 add_arange (decl
, subr_die
);
7988 #ifdef MIPS_DEBUGGING_INFO
7989 /* Add a reference to the FDE for this routine. */
7990 add_AT_fde_ref (subr_die
, DW_AT_MIPS_fde
, current_funcdef_fde
);
7993 /* Define the "frame base" location for this routine. We use the
7994 frame pointer or stack pointer registers, since the RTL for local
7995 variables is relative to one of them. */
7997 = frame_pointer_needed
? hard_frame_pointer_rtx
: stack_pointer_rtx
;
7998 add_AT_loc (subr_die
, DW_AT_frame_base
, reg_loc_descriptor (fp_reg
));
8001 /* ??? This fails for nested inline functions, because context_display
8002 is not part of the state saved/restored for inline functions. */
8003 if (current_function_needs_context
)
8004 add_AT_location_description (subr_die
, DW_AT_static_link
,
8005 lookup_static_chain (decl
));
8009 /* Now output descriptions of the arguments for this function. This gets
8010 (unnecessarily?) complex because of the fact that the DECL_ARGUMENT list
8011 for a FUNCTION_DECL doesn't indicate cases where there was a trailing
8012 `...' at the end of the formal parameter list. In order to find out if
8013 there was a trailing ellipsis or not, we must instead look at the type
8014 associated with the FUNCTION_DECL. This will be a node of type
8015 FUNCTION_TYPE. If the chain of type nodes hanging off of this
8016 FUNCTION_TYPE node ends with a void_type_node then there should *not* be
8017 an ellipsis at the end. */
8018 push_decl_scope (decl
);
8020 /* In the case where we are describing a mere function declaration, all we
8021 need to do here (and all we *can* do here) is to describe the *types* of
8022 its formal parameters. */
8023 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
8025 else if (declaration
)
8026 gen_formal_types_die (TREE_TYPE (decl
), subr_die
);
8029 /* Generate DIEs to represent all known formal parameters */
8030 register tree arg_decls
= DECL_ARGUMENTS (decl
);
8033 /* When generating DIEs, generate the unspecified_parameters DIE
8034 instead if we come across the arg "__builtin_va_alist" */
8035 for (parm
= arg_decls
; parm
; parm
= TREE_CHAIN (parm
))
8036 if (TREE_CODE (parm
) == PARM_DECL
)
8038 if (DECL_NAME (parm
)
8039 && !strcmp (IDENTIFIER_POINTER (DECL_NAME (parm
)),
8040 "__builtin_va_alist"))
8041 gen_unspecified_parameters_die (parm
, subr_die
);
8043 gen_decl_die (parm
, subr_die
);
8046 /* Decide whether we need a unspecified_parameters DIE at the end.
8047 There are 2 more cases to do this for: 1) the ansi ... declaration -
8048 this is detectable when the end of the arg list is not a
8049 void_type_node 2) an unprototyped function declaration (not a
8050 definition). This just means that we have no info about the
8051 parameters at all. */
8052 fn_arg_types
= TYPE_ARG_TYPES (TREE_TYPE (decl
));
8053 if (fn_arg_types
!= NULL
)
8055 /* this is the prototyped case, check for ... */
8056 if (TREE_VALUE (tree_last (fn_arg_types
)) != void_type_node
)
8057 gen_unspecified_parameters_die (decl
, subr_die
);
8059 else if (DECL_INITIAL (decl
) == NULL_TREE
)
8060 gen_unspecified_parameters_die (decl
, subr_die
);
8063 /* Output Dwarf info for all of the stuff within the body of the function
8064 (if it has one - it may be just a declaration). */
8065 outer_scope
= DECL_INITIAL (decl
);
8067 /* Note that here, `outer_scope' is a pointer to the outermost BLOCK
8068 node created to represent a function. This outermost BLOCK actually
8069 represents the outermost binding contour for the function, i.e. the
8070 contour in which the function's formal parameters and labels get
8071 declared. Curiously, it appears that the front end doesn't actually
8072 put the PARM_DECL nodes for the current function onto the BLOCK_VARS
8073 list for this outer scope. (They are strung off of the DECL_ARGUMENTS
8074 list for the function instead.) The BLOCK_VARS list for the
8075 `outer_scope' does provide us with a list of the LABEL_DECL nodes for
8076 the function however, and we output DWARF info for those in
8077 decls_for_scope. Just within the `outer_scope' there will be a BLOCK
8078 node representing the function's outermost pair of curly braces, and
8079 any blocks used for the base and member initializers of a C++
8080 constructor function. */
8081 if (! declaration
&& TREE_CODE (outer_scope
) != ERROR_MARK
)
8083 current_function_has_inlines
= 0;
8084 decls_for_scope (outer_scope
, subr_die
, 0);
8086 #if 0 && defined (MIPS_DEBUGGING_INFO)
8087 if (current_function_has_inlines
)
8089 add_AT_flag (subr_die
, DW_AT_MIPS_has_inlines
, 1);
8090 if (! comp_unit_has_inlines
)
8092 add_AT_flag (comp_unit_die
, DW_AT_MIPS_has_inlines
, 1);
8093 comp_unit_has_inlines
= 1;
8102 /* Generate a DIE to represent a declared data object. */
8105 gen_variable_die (decl
, context_die
)
8107 register dw_die_ref context_die
;
8109 register tree origin
= decl_ultimate_origin (decl
);
8110 register dw_die_ref var_die
= new_die (DW_TAG_variable
, context_die
);
8112 dw_die_ref old_die
= lookup_decl_die (decl
);
8114 = (DECL_EXTERNAL (decl
)
8115 || current_function_decl
!= decl_function_context (decl
)
8116 || context_die
->die_tag
== DW_TAG_structure_type
8117 || context_die
->die_tag
== DW_TAG_union_type
);
8120 add_abstract_origin_attribute (var_die
, origin
);
8121 /* Loop unrolling can create multiple blocks that refer to the same
8122 static variable, so we must test for the DW_AT_declaration flag. */
8123 /* ??? Loop unrolling/reorder_blocks should perhaps be rewritten to
8124 copy decls and set the DECL_ABSTRACT flag on them instead of
8126 else if (old_die
&& TREE_STATIC (decl
)
8127 && get_AT_flag (old_die
, DW_AT_declaration
) == 1)
8129 /* ??? This is an instantiation of a C++ class level static. */
8130 add_AT_die_ref (var_die
, DW_AT_specification
, old_die
);
8131 if (DECL_NAME (decl
))
8133 register unsigned file_index
8134 = lookup_filename (DECL_SOURCE_FILE (decl
));
8136 if (get_AT_unsigned (old_die
, DW_AT_decl_file
) != file_index
)
8137 add_AT_unsigned (var_die
, DW_AT_decl_file
, file_index
);
8139 if (get_AT_unsigned (old_die
, DW_AT_decl_line
)
8140 != DECL_SOURCE_LINE (decl
))
8142 add_AT_unsigned (var_die
, DW_AT_decl_line
,
8143 DECL_SOURCE_LINE (decl
));
8148 add_name_and_src_coords_attributes (var_die
, decl
);
8149 add_type_attribute (var_die
, TREE_TYPE (decl
),
8150 TREE_READONLY (decl
),
8151 TREE_THIS_VOLATILE (decl
), context_die
);
8153 if (TREE_PUBLIC (decl
))
8154 add_AT_flag (var_die
, DW_AT_external
, 1);
8156 if (DECL_ARTIFICIAL (decl
))
8157 add_AT_flag (var_die
, DW_AT_artificial
, 1);
8159 if (TREE_PROTECTED (decl
))
8160 add_AT_unsigned (var_die
, DW_AT_accessibility
, DW_ACCESS_protected
);
8162 else if (TREE_PRIVATE (decl
))
8163 add_AT_unsigned (var_die
, DW_AT_accessibility
, DW_ACCESS_private
);
8167 add_AT_flag (var_die
, DW_AT_declaration
, 1);
8169 if ((declaration
&& decl_class_context (decl
)) || DECL_ABSTRACT (decl
))
8170 equate_decl_number_to_die (decl
, var_die
);
8172 if (! declaration
&& ! DECL_ABSTRACT (decl
))
8174 equate_decl_number_to_die (decl
, var_die
);
8175 add_location_or_const_value_attribute (var_die
, decl
);
8176 add_pubname (decl
, var_die
);
8180 /* Generate a DIE to represent a label identifier. */
8183 gen_label_die (decl
, context_die
)
8185 register dw_die_ref context_die
;
8187 register tree origin
= decl_ultimate_origin (decl
);
8188 register dw_die_ref lbl_die
= new_die (DW_TAG_label
, context_die
);
8190 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
8191 char label2
[MAX_ARTIFICIAL_LABEL_BYTES
];
8194 add_abstract_origin_attribute (lbl_die
, origin
);
8196 add_name_and_src_coords_attributes (lbl_die
, decl
);
8198 if (DECL_ABSTRACT (decl
))
8199 equate_decl_number_to_die (decl
, lbl_die
);
8202 insn
= DECL_RTL (decl
);
8203 if (GET_CODE (insn
) == CODE_LABEL
)
8205 /* When optimization is enabled (via -O) some parts of the compiler
8206 (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
8207 represent source-level labels which were explicitly declared by
8208 the user. This really shouldn't be happening though, so catch
8209 it if it ever does happen. */
8210 if (INSN_DELETED_P (insn
))
8213 sprintf (label2
, INSN_LABEL_FMT
, current_funcdef_number
);
8214 ASM_GENERATE_INTERNAL_LABEL (label
, label2
,
8215 (unsigned) INSN_UID (insn
));
8216 add_AT_lbl_id (lbl_die
, DW_AT_low_pc
, label
);
8221 /* Generate a DIE for a lexical block. */
8224 gen_lexical_block_die (stmt
, context_die
, depth
)
8226 register dw_die_ref context_die
;
8229 register dw_die_ref stmt_die
= new_die (DW_TAG_lexical_block
, context_die
);
8230 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
8232 if (! BLOCK_ABSTRACT (stmt
))
8234 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_BEGIN_LABEL
,
8236 add_AT_lbl_id (stmt_die
, DW_AT_low_pc
, label
);
8237 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_END_LABEL
, next_block_number
);
8238 add_AT_lbl_id (stmt_die
, DW_AT_high_pc
, label
);
8241 push_decl_scope (stmt
);
8242 decls_for_scope (stmt
, stmt_die
, depth
);
8246 /* Generate a DIE for an inlined subprogram. */
8249 gen_inlined_subroutine_die (stmt
, context_die
, depth
)
8251 register dw_die_ref context_die
;
8254 if (! BLOCK_ABSTRACT (stmt
))
8256 register dw_die_ref subr_die
8257 = new_die (DW_TAG_inlined_subroutine
, context_die
);
8258 register tree decl
= block_ultimate_origin (stmt
);
8259 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
8261 add_abstract_origin_attribute (subr_die
, decl
);
8262 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_BEGIN_LABEL
,
8264 add_AT_lbl_id (subr_die
, DW_AT_low_pc
, label
);
8265 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_END_LABEL
, next_block_number
);
8266 add_AT_lbl_id (subr_die
, DW_AT_high_pc
, label
);
8267 push_decl_scope (decl
);
8268 decls_for_scope (stmt
, subr_die
, depth
);
8270 current_function_has_inlines
= 1;
8274 /* Generate a DIE for a field in a record, or structure. */
8277 gen_field_die (decl
, context_die
)
8279 register dw_die_ref context_die
;
8281 register dw_die_ref decl_die
= new_die (DW_TAG_member
, context_die
);
8283 add_name_and_src_coords_attributes (decl_die
, decl
);
8284 add_type_attribute (decl_die
, member_declared_type (decl
),
8285 TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
),
8288 /* If this is a bit field... */
8289 if (DECL_BIT_FIELD_TYPE (decl
))
8291 add_byte_size_attribute (decl_die
, decl
);
8292 add_bit_size_attribute (decl_die
, decl
);
8293 add_bit_offset_attribute (decl_die
, decl
);
8296 if (TREE_CODE (DECL_FIELD_CONTEXT (decl
)) != UNION_TYPE
)
8297 add_data_member_location_attribute (decl_die
, decl
);
8299 if (DECL_ARTIFICIAL (decl
))
8300 add_AT_flag (decl_die
, DW_AT_artificial
, 1);
8302 if (TREE_PROTECTED (decl
))
8303 add_AT_unsigned (decl_die
, DW_AT_accessibility
, DW_ACCESS_protected
);
8305 else if (TREE_PRIVATE (decl
))
8306 add_AT_unsigned (decl_die
, DW_AT_accessibility
, DW_ACCESS_private
);
8310 /* Don't generate either pointer_type DIEs or reference_type DIEs here.
8311 Use modified_type_die instead.
8312 We keep this code here just in case these types of DIEs may be needed to
8313 represent certain things in other languages (e.g. Pascal) someday. */
8315 gen_pointer_type_die (type
, context_die
)
8317 register dw_die_ref context_die
;
8319 register dw_die_ref ptr_die
8320 = new_die (DW_TAG_pointer_type
, scope_die_for (type
, context_die
));
8322 equate_type_number_to_die (type
, ptr_die
);
8323 add_type_attribute (ptr_die
, TREE_TYPE (type
), 0, 0, context_die
);
8324 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
8327 /* Don't generate either pointer_type DIEs or reference_type DIEs here.
8328 Use modified_type_die instead.
8329 We keep this code here just in case these types of DIEs may be needed to
8330 represent certain things in other languages (e.g. Pascal) someday. */
8332 gen_reference_type_die (type
, context_die
)
8334 register dw_die_ref context_die
;
8336 register dw_die_ref ref_die
8337 = new_die (DW_TAG_reference_type
, scope_die_for (type
, context_die
));
8339 equate_type_number_to_die (type
, ref_die
);
8340 add_type_attribute (ref_die
, TREE_TYPE (type
), 0, 0, context_die
);
8341 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
8345 /* Generate a DIE for a pointer to a member type. */
8347 gen_ptr_to_mbr_type_die (type
, context_die
)
8349 register dw_die_ref context_die
;
8351 register dw_die_ref ptr_die
8352 = new_die (DW_TAG_ptr_to_member_type
, scope_die_for (type
, context_die
));
8354 equate_type_number_to_die (type
, ptr_die
);
8355 add_AT_die_ref (ptr_die
, DW_AT_containing_type
,
8356 lookup_type_die (TYPE_OFFSET_BASETYPE (type
)));
8357 add_type_attribute (ptr_die
, TREE_TYPE (type
), 0, 0, context_die
);
8360 /* Generate the DIE for the compilation unit. */
8363 gen_compile_unit_die (main_input_filename
)
8364 register char *main_input_filename
;
8367 char *wd
= getpwd ();
8369 comp_unit_die
= new_die (DW_TAG_compile_unit
, NULL
);
8370 add_name_attribute (comp_unit_die
, main_input_filename
);
8373 add_AT_string (comp_unit_die
, DW_AT_comp_dir
, wd
);
8375 sprintf (producer
, "%s %s", language_string
, version_string
);
8377 #ifdef MIPS_DEBUGGING_INFO
8378 /* The MIPS/SGI compilers place the 'cc' command line options in the producer
8379 string. The SGI debugger looks for -g, -g1, -g2, or -g3; if they do
8380 not appear in the producer string, the debugger reaches the conclusion
8381 that the object file is stripped and has no debugging information.
8382 To get the MIPS/SGI debugger to believe that there is debugging
8383 information in the object file, we add a -g to the producer string. */
8384 if (debug_info_level
> DINFO_LEVEL_TERSE
)
8385 strcat (producer
, " -g");
8388 add_AT_string (comp_unit_die
, DW_AT_producer
, producer
);
8390 if (strcmp (language_string
, "GNU C++") == 0)
8391 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_C_plus_plus
);
8393 else if (strcmp (language_string
, "GNU Ada") == 0)
8394 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_Ada83
);
8396 else if (strcmp (language_string
, "GNU F77") == 0)
8397 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_Fortran77
);
8399 else if (strcmp (language_string
, "GNU Pascal") == 0)
8400 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_Pascal83
);
8402 else if (flag_traditional
)
8403 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_C
);
8406 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_C89
);
8408 #if 0 /* unimplemented */
8409 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
8410 add_AT_unsigned (comp_unit_die
, DW_AT_macro_info
, 0);
8414 /* Generate a DIE for a string type. */
8417 gen_string_type_die (type
, context_die
)
8419 register dw_die_ref context_die
;
8421 register dw_die_ref type_die
8422 = new_die (DW_TAG_string_type
, scope_die_for (type
, context_die
));
8424 equate_type_number_to_die (type
, type_die
);
8426 /* Fudge the string length attribute for now. */
8428 /* TODO: add string length info.
8429 string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
8430 bound_representation (upper_bound, 0, 'u'); */
8433 /* Generate the DIE for a base class. */
8436 gen_inheritance_die (binfo
, context_die
)
8437 register tree binfo
;
8438 register dw_die_ref context_die
;
8440 dw_die_ref die
= new_die (DW_TAG_inheritance
, context_die
);
8442 add_type_attribute (die
, BINFO_TYPE (binfo
), 0, 0, context_die
);
8443 add_data_member_location_attribute (die
, binfo
);
8445 if (TREE_VIA_VIRTUAL (binfo
))
8446 add_AT_unsigned (die
, DW_AT_virtuality
, DW_VIRTUALITY_virtual
);
8447 if (TREE_VIA_PUBLIC (binfo
))
8448 add_AT_unsigned (die
, DW_AT_accessibility
, DW_ACCESS_public
);
8449 else if (TREE_VIA_PROTECTED (binfo
))
8450 add_AT_unsigned (die
, DW_AT_accessibility
, DW_ACCESS_protected
);
8453 /* Genearate a DIE for a class member. */
8456 gen_member_die (type
, context_die
)
8458 register dw_die_ref context_die
;
8460 register tree member
;
8462 /* If this is not an incomplete type, output descriptions of each of its
8463 members. Note that as we output the DIEs necessary to represent the
8464 members of this record or union type, we will also be trying to output
8465 DIEs to represent the *types* of those members. However the `type'
8466 function (above) will specifically avoid generating type DIEs for member
8467 types *within* the list of member DIEs for this (containing) type execpt
8468 for those types (of members) which are explicitly marked as also being
8469 members of this (containing) type themselves. The g++ front- end can
8470 force any given type to be treated as a member of some other
8471 (containing) type by setting the TYPE_CONTEXT of the given (member) type
8472 to point to the TREE node representing the appropriate (containing)
8475 /* First output info about the base classes. */
8476 if (TYPE_BINFO (type
) && TYPE_BINFO_BASETYPES (type
))
8478 register tree bases
= TYPE_BINFO_BASETYPES (type
);
8479 register int n_bases
= TREE_VEC_LENGTH (bases
);
8482 for (i
= 0; i
< n_bases
; i
++)
8483 gen_inheritance_die (TREE_VEC_ELT (bases
, i
), context_die
);
8486 /* Now output info about the data members and type members. */
8487 for (member
= TYPE_FIELDS (type
); member
; member
= TREE_CHAIN (member
))
8488 gen_decl_die (member
, context_die
);
8490 /* Now output info about the function members (if any). */
8491 for (member
= TYPE_METHODS (type
); member
; member
= TREE_CHAIN (member
))
8492 gen_decl_die (member
, context_die
);
8495 /* Generate a DIE for a structure or union type. */
8498 gen_struct_or_union_type_die (type
, context_die
)
8500 register dw_die_ref context_die
;
8502 register dw_die_ref type_die
= lookup_type_die (type
);
8503 register dw_die_ref scope_die
= 0;
8504 register int nested
= 0;
8506 if (type_die
&& ! TYPE_SIZE (type
))
8509 if (TYPE_CONTEXT (type
) != NULL_TREE
8510 && TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type
))) == 't')
8513 scope_die
= scope_die_for (type
, context_die
);
8515 if (! type_die
|| (nested
&& scope_die
== comp_unit_die
))
8516 /* First occurrence of type or toplevel definition of nested class. */
8518 register dw_die_ref old_die
= type_die
;
8520 type_die
= new_die (TREE_CODE (type
) == RECORD_TYPE
8521 ? DW_TAG_structure_type
: DW_TAG_union_type
,
8523 equate_type_number_to_die (type
, type_die
);
8524 add_name_attribute (type_die
, type_tag (type
));
8526 add_AT_die_ref (type_die
, DW_AT_specification
, old_die
);
8529 remove_AT (type_die
, DW_AT_declaration
);
8531 /* If we're not in the right context to be defining this type, defer to
8532 avoid tricky recursion. */
8533 if (TYPE_SIZE (type
) && decl_scope_depth
> 0 && scope_die
== comp_unit_die
)
8535 add_AT_flag (type_die
, DW_AT_declaration
, 1);
8538 /* If this type has been completed, then give it a byte_size attribute and
8539 then give a list of members. */
8540 else if (TYPE_SIZE (type
))
8542 /* Prevent infinite recursion in cases where the type of some member of
8543 this type is expressed in terms of this type itself. */
8544 TREE_ASM_WRITTEN (type
) = 1;
8545 add_byte_size_attribute (type_die
, type
);
8546 if (TYPE_STUB_DECL (type
) != NULL_TREE
)
8547 add_src_coords_attributes (type_die
, TYPE_STUB_DECL (type
));
8549 /* If the first reference to this type was as the return type of an
8550 inline function, then it may not have a parent. Fix this now. */
8551 if (type_die
->die_parent
== NULL
)
8552 add_child_die (scope_die
, type_die
);
8554 push_decl_scope (type
);
8555 gen_member_die (type
, type_die
);
8558 /* GNU extension: Record what type our vtable lives in. */
8559 if (TYPE_VFIELD (type
))
8561 tree vtype
= DECL_FCONTEXT (TYPE_VFIELD (type
));
8563 gen_type_die (vtype
, context_die
);
8564 add_AT_die_ref (type_die
, DW_AT_containing_type
,
8565 lookup_type_die (vtype
));
8569 add_AT_flag (type_die
, DW_AT_declaration
, 1);
8572 /* Generate a DIE for a subroutine _type_. */
8575 gen_subroutine_type_die (type
, context_die
)
8577 register dw_die_ref context_die
;
8579 register tree return_type
= TREE_TYPE (type
);
8580 register dw_die_ref subr_die
8581 = new_die (DW_TAG_subroutine_type
, scope_die_for (type
, context_die
));
8583 equate_type_number_to_die (type
, subr_die
);
8584 add_prototyped_attribute (subr_die
, type
);
8585 add_type_attribute (subr_die
, return_type
, 0, 0, context_die
);
8586 gen_formal_types_die (type
, subr_die
);
8589 /* Generate a DIE for a type definition */
8592 gen_typedef_die (decl
, context_die
)
8594 register dw_die_ref context_die
;
8596 register dw_die_ref type_die
;
8597 register tree origin
;
8599 if (TREE_ASM_WRITTEN (decl
))
8601 TREE_ASM_WRITTEN (decl
) = 1;
8603 type_die
= new_die (DW_TAG_typedef
, scope_die_for (decl
, context_die
));
8604 origin
= decl_ultimate_origin (decl
);
8606 add_abstract_origin_attribute (type_die
, origin
);
8610 add_name_and_src_coords_attributes (type_die
, decl
);
8611 if (DECL_ORIGINAL_TYPE (decl
))
8613 type
= DECL_ORIGINAL_TYPE (decl
);
8614 equate_type_number_to_die (TREE_TYPE (decl
), type_die
);
8617 type
= TREE_TYPE (decl
);
8618 add_type_attribute (type_die
, type
, TREE_READONLY (decl
),
8619 TREE_THIS_VOLATILE (decl
), context_die
);
8622 if (DECL_ABSTRACT (decl
))
8623 equate_decl_number_to_die (decl
, type_die
);
8626 /* Generate a type description DIE. */
8629 gen_type_die (type
, context_die
)
8631 register dw_die_ref context_die
;
8633 if (type
== NULL_TREE
|| type
== error_mark_node
)
8636 /* We are going to output a DIE to represent the unqualified version of of
8637 this type (i.e. without any const or volatile qualifiers) so get the
8638 main variant (i.e. the unqualified version) of this type now. */
8639 type
= type_main_variant (type
);
8641 if (TREE_ASM_WRITTEN (type
))
8644 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
8645 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
8647 TREE_ASM_WRITTEN (type
) = 1;
8648 gen_decl_die (TYPE_NAME (type
), context_die
);
8652 switch (TREE_CODE (type
))
8658 case REFERENCE_TYPE
:
8659 /* For these types, all that is required is that we output a DIE (or a
8660 set of DIEs) to represent the "basis" type. */
8661 gen_type_die (TREE_TYPE (type
), context_die
);
8665 /* This code is used for C++ pointer-to-data-member types.
8666 Output a description of the relevant class type. */
8667 gen_type_die (TYPE_OFFSET_BASETYPE (type
), context_die
);
8669 /* Output a description of the type of the object pointed to. */
8670 gen_type_die (TREE_TYPE (type
), context_die
);
8672 /* Now output a DIE to represent this pointer-to-data-member type
8674 gen_ptr_to_mbr_type_die (type
, context_die
);
8678 gen_type_die (TYPE_DOMAIN (type
), context_die
);
8679 gen_set_type_die (type
, context_die
);
8683 gen_type_die (TREE_TYPE (type
), context_die
);
8684 abort (); /* No way to represent these in Dwarf yet! */
8688 /* Force out return type (in case it wasn't forced out already). */
8689 gen_type_die (TREE_TYPE (type
), context_die
);
8690 gen_subroutine_type_die (type
, context_die
);
8694 /* Force out return type (in case it wasn't forced out already). */
8695 gen_type_die (TREE_TYPE (type
), context_die
);
8696 gen_subroutine_type_die (type
, context_die
);
8700 if (TYPE_STRING_FLAG (type
) && TREE_CODE (TREE_TYPE (type
)) == CHAR_TYPE
)
8702 gen_type_die (TREE_TYPE (type
), context_die
);
8703 gen_string_type_die (type
, context_die
);
8706 gen_array_type_die (type
, context_die
);
8712 case QUAL_UNION_TYPE
:
8713 /* If this is a nested type whose containing class hasn't been
8714 written out yet, writing it out will cover this one, too. */
8715 if (TYPE_CONTEXT (type
)
8716 && TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type
))) == 't'
8717 && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type
)))
8719 gen_type_die (TYPE_CONTEXT (type
), context_die
);
8721 if (TREE_ASM_WRITTEN (TYPE_CONTEXT (type
)))
8724 /* If that failed, attach ourselves to the stub. */
8725 push_decl_scope (TYPE_CONTEXT (type
));
8726 context_die
= lookup_type_die (TYPE_CONTEXT (type
));
8729 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
8730 gen_enumeration_type_die (type
, context_die
);
8732 gen_struct_or_union_type_die (type
, context_die
);
8734 if (TYPE_CONTEXT (type
)
8735 && TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type
))) == 't'
8736 && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type
)))
8739 /* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix
8740 it up if it is ever completed. gen_*_type_die will set it for us
8741 when appropriate. */
8750 /* No DIEs needed for fundamental types. */
8754 /* No Dwarf representation currently defined. */
8761 TREE_ASM_WRITTEN (type
) = 1;
8764 /* Generate a DIE for a tagged type instantiation. */
8767 gen_tagged_type_instantiation_die (type
, context_die
)
8769 register dw_die_ref context_die
;
8771 if (type
== NULL_TREE
|| type
== error_mark_node
)
8774 /* We are going to output a DIE to represent the unqualified version of of
8775 this type (i.e. without any const or volatile qualifiers) so make sure
8776 that we have the main variant (i.e. the unqualified version) of this
8778 assert (type
== type_main_variant (type
));
8779 assert (TREE_ASM_WRITTEN (type
));
8781 switch (TREE_CODE (type
))
8787 gen_inlined_enumeration_type_die (type
, context_die
);
8791 gen_inlined_structure_type_die (type
, context_die
);
8795 case QUAL_UNION_TYPE
:
8796 gen_inlined_union_type_die (type
, context_die
);
8804 /* Generate a DW_TAG_lexical_block DIE followed by DIEs to represent all of the
8805 things which are local to the given block. */
8808 gen_block_die (stmt
, context_die
, depth
)
8810 register dw_die_ref context_die
;
8813 register int must_output_die
= 0;
8814 register tree origin
;
8816 register enum tree_code origin_code
;
8818 /* Ignore blocks never really used to make RTL. */
8820 if (stmt
== NULL_TREE
|| !TREE_USED (stmt
))
8823 /* Determine the "ultimate origin" of this block. This block may be an
8824 inlined instance of an inlined instance of inline function, so we have
8825 to trace all of the way back through the origin chain to find out what
8826 sort of node actually served as the original seed for the creation of
8827 the current block. */
8828 origin
= block_ultimate_origin (stmt
);
8829 origin_code
= (origin
!= NULL
) ? TREE_CODE (origin
) : ERROR_MARK
;
8831 /* Determine if we need to output any Dwarf DIEs at all to represent this
8833 if (origin_code
== FUNCTION_DECL
)
8834 /* The outer scopes for inlinings *must* always be represented. We
8835 generate DW_TAG_inlined_subroutine DIEs for them. (See below.) */
8836 must_output_die
= 1;
8839 /* In the case where the current block represents an inlining of the
8840 "body block" of an inline function, we must *NOT* output any DIE for
8841 this block because we have already output a DIE to represent the
8842 whole inlined function scope and the "body block" of any function
8843 doesn't really represent a different scope according to ANSI C
8844 rules. So we check here to make sure that this block does not
8845 represent a "body block inlining" before trying to set the
8846 `must_output_die' flag. */
8847 if (! is_body_block (origin
? origin
: stmt
))
8849 /* Determine if this block directly contains any "significant"
8850 local declarations which we will need to output DIEs for. */
8851 if (debug_info_level
> DINFO_LEVEL_TERSE
)
8852 /* We are not in terse mode so *any* local declaration counts
8853 as being a "significant" one. */
8854 must_output_die
= (BLOCK_VARS (stmt
) != NULL
);
8856 /* We are in terse mode, so only local (nested) function
8857 definitions count as "significant" local declarations. */
8858 for (decl
= BLOCK_VARS (stmt
);
8859 decl
!= NULL
; decl
= TREE_CHAIN (decl
))
8860 if (TREE_CODE (decl
) == FUNCTION_DECL
8861 && DECL_INITIAL (decl
))
8863 must_output_die
= 1;
8869 /* It would be a waste of space to generate a Dwarf DW_TAG_lexical_block
8870 DIE for any block which contains no significant local declarations at
8871 all. Rather, in such cases we just call `decls_for_scope' so that any
8872 needed Dwarf info for any sub-blocks will get properly generated. Note
8873 that in terse mode, our definition of what constitutes a "significant"
8874 local declaration gets restricted to include only inlined function
8875 instances and local (nested) function definitions. */
8876 if (must_output_die
)
8878 if (origin_code
== FUNCTION_DECL
)
8879 gen_inlined_subroutine_die (stmt
, context_die
, depth
);
8881 gen_lexical_block_die (stmt
, context_die
, depth
);
8884 decls_for_scope (stmt
, context_die
, depth
);
8887 /* Generate all of the decls declared within a given scope and (recursively)
8888 all of it's sub-blocks. */
8891 decls_for_scope (stmt
, context_die
, depth
)
8893 register dw_die_ref context_die
;
8897 register tree subblocks
;
8899 /* Ignore blocks never really used to make RTL. */
8900 if (stmt
== NULL_TREE
|| ! TREE_USED (stmt
))
8903 if (!BLOCK_ABSTRACT (stmt
) && depth
> 0)
8904 next_block_number
++;
8906 /* Output the DIEs to represent all of the data objects and typedefs
8907 declared directly within this block but not within any nested
8908 sub-blocks. Also, nested function and tag DIEs have been
8909 generated with a parent of NULL; fix that up now. */
8910 for (decl
= BLOCK_VARS (stmt
);
8911 decl
!= NULL
; decl
= TREE_CHAIN (decl
))
8913 register dw_die_ref die
;
8915 if (TREE_CODE (decl
) == FUNCTION_DECL
)
8916 die
= lookup_decl_die (decl
);
8917 else if (TREE_CODE (decl
) == TYPE_DECL
&& TYPE_DECL_IS_STUB (decl
))
8918 die
= lookup_type_die (TREE_TYPE (decl
));
8922 if (die
!= NULL
&& die
->die_parent
== NULL
)
8923 add_child_die (context_die
, die
);
8925 gen_decl_die (decl
, context_die
);
8928 /* Output the DIEs to represent all sub-blocks (and the items declared
8929 therein) of this block. */
8930 for (subblocks
= BLOCK_SUBBLOCKS (stmt
);
8932 subblocks
= BLOCK_CHAIN (subblocks
))
8933 gen_block_die (subblocks
, context_die
, depth
+ 1);
8936 /* Is this a typedef we can avoid emitting? */
8939 is_redundant_typedef (decl
)
8942 if (TYPE_DECL_IS_STUB (decl
))
8945 if (DECL_ARTIFICIAL (decl
)
8946 && DECL_CONTEXT (decl
)
8947 && is_tagged_type (DECL_CONTEXT (decl
))
8948 && TREE_CODE (TYPE_NAME (DECL_CONTEXT (decl
))) == TYPE_DECL
8949 && DECL_NAME (decl
) == DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl
))))
8950 /* Also ignore the artificial member typedef for the class name. */
8956 /* Generate Dwarf debug information for a decl described by DECL. */
8959 gen_decl_die (decl
, context_die
)
8961 register dw_die_ref context_die
;
8963 register tree origin
;
8965 /* Make a note of the decl node we are going to be working on. We may need
8966 to give the user the source coordinates of where it appeared in case we
8967 notice (later on) that something about it looks screwy. */
8968 dwarf_last_decl
= decl
;
8970 if (TREE_CODE (decl
) == ERROR_MARK
)
8973 /* If this ..._DECL node is marked to be ignored, then ignore it. But don't
8974 ignore a function definition, since that would screw up our count of
8975 blocks, and that it turn will completely screw up the the labels we will
8976 reference in subsequent DW_AT_low_pc and DW_AT_high_pc attributes (for
8977 subsequent blocks). */
8978 if (DECL_IGNORED_P (decl
) && TREE_CODE (decl
) != FUNCTION_DECL
)
8981 switch (TREE_CODE (decl
))
8984 /* The individual enumerators of an enum type get output when we output
8985 the Dwarf representation of the relevant enum type itself. */
8989 /* Don't output any DIEs to represent mere function declarations,
8990 unless they are class members or explicit block externs. */
8991 if (DECL_INITIAL (decl
) == NULL_TREE
&& DECL_CONTEXT (decl
) == NULL_TREE
8992 && (current_function_decl
== NULL_TREE
|| ! DECL_ARTIFICIAL (decl
)))
8995 if (debug_info_level
> DINFO_LEVEL_TERSE
)
8997 /* Before we describe the FUNCTION_DECL itself, make sure that we
8998 have described its return type. */
8999 gen_type_die (TREE_TYPE (TREE_TYPE (decl
)), context_die
);
9001 /* And its containing type. */
9002 origin
= decl_class_context (decl
);
9003 if (origin
!= NULL_TREE
)
9004 gen_type_die (origin
, context_die
);
9006 /* And its virtual context. */
9007 if (DECL_VINDEX (decl
) != NULL_TREE
)
9008 gen_type_die (DECL_CONTEXT (decl
), context_die
);
9011 /* Now output a DIE to represent the function itself. */
9012 gen_subprogram_die (decl
, context_die
);
9016 /* If we are in terse mode, don't generate any DIEs to represent any
9018 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
9021 /* In the special case of a TYPE_DECL node representing the
9022 declaration of some type tag, if the given TYPE_DECL is marked as
9023 having been instantiated from some other (original) TYPE_DECL node
9024 (e.g. one which was generated within the original definition of an
9025 inline function) we have to generate a special (abbreviated)
9026 DW_TAG_structure_type, DW_TAG_union_type, or DW_TAG_enumeration_type
9028 if (TYPE_DECL_IS_STUB (decl
) && DECL_ABSTRACT_ORIGIN (decl
) != NULL_TREE
)
9030 gen_tagged_type_instantiation_die (TREE_TYPE (decl
), context_die
);
9034 if (is_redundant_typedef (decl
))
9035 gen_type_die (TREE_TYPE (decl
), context_die
);
9037 /* Output a DIE to represent the typedef itself. */
9038 gen_typedef_die (decl
, context_die
);
9042 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
9043 gen_label_die (decl
, context_die
);
9047 /* If we are in terse mode, don't generate any DIEs to represent any
9048 variable declarations or definitions. */
9049 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
9052 /* Output any DIEs that are needed to specify the type of this data
9054 gen_type_die (TREE_TYPE (decl
), context_die
);
9056 /* And its containing type. */
9057 origin
= decl_class_context (decl
);
9058 if (origin
!= NULL_TREE
)
9059 gen_type_die (origin
, context_die
);
9061 /* Now output the DIE to represent the data object itself. This gets
9062 complicated because of the possibility that the VAR_DECL really
9063 represents an inlined instance of a formal parameter for an inline
9065 origin
= decl_ultimate_origin (decl
);
9066 if (origin
!= NULL_TREE
&& TREE_CODE (origin
) == PARM_DECL
)
9067 gen_formal_parameter_die (decl
, context_die
);
9069 gen_variable_die (decl
, context_die
);
9073 /* Ignore the nameless fields that are used to skip bits, but
9074 handle C++ anonymous unions. */
9075 if (DECL_NAME (decl
) != NULL_TREE
9076 || TREE_CODE (TREE_TYPE (decl
)) == UNION_TYPE
)
9078 gen_type_die (member_declared_type (decl
), context_die
);
9079 gen_field_die (decl
, context_die
);
9084 gen_type_die (TREE_TYPE (decl
), context_die
);
9085 gen_formal_parameter_die (decl
, context_die
);
9093 /* Write the debugging output for DECL. */
9096 dwarf2out_decl (decl
)
9099 register dw_die_ref context_die
= comp_unit_die
;
9101 if (TREE_CODE (decl
) == ERROR_MARK
)
9104 /* If this ..._DECL node is marked to be ignored, then ignore it. We gotta
9105 hope that the node in question doesn't represent a function definition.
9106 If it does, then totally ignoring it is bound to screw up our count of
9107 blocks, and that it turn will completely screw up the the labels we will
9108 reference in subsequent DW_AT_low_pc and DW_AT_high_pc attributes (for
9109 subsequent blocks). (It's too bad that BLOCK nodes don't carry their
9110 own sequence numbers with them!) */
9111 if (DECL_IGNORED_P (decl
))
9113 if (TREE_CODE (decl
) == FUNCTION_DECL
9114 && DECL_INITIAL (decl
) != NULL
)
9120 switch (TREE_CODE (decl
))
9123 /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of a
9124 builtin function. Explicit programmer-supplied declarations of
9125 these same functions should NOT be ignored however. */
9126 if (DECL_EXTERNAL (decl
) && DECL_FUNCTION_CODE (decl
))
9129 /* What we would really like to do here is to filter out all mere
9130 file-scope declarations of file-scope functions which are never
9131 referenced later within this translation unit (and keep all of ones
9132 that *are* referenced later on) but we aren't clarvoiant, so we have
9133 no idea which functions will be referenced in the future (i.e. later
9134 on within the current translation unit). So here we just ignore all
9135 file-scope function declarations which are not also definitions. If
9136 and when the debugger needs to know something about these funcstion,
9137 it wil have to hunt around and find the DWARF information associated
9138 with the definition of the function. Note that we can't just check
9139 `DECL_EXTERNAL' to find out which FUNCTION_DECL nodes represent
9140 definitions and which ones represent mere declarations. We have to
9141 check `DECL_INITIAL' instead. That's because the C front-end
9142 supports some weird semantics for "extern inline" function
9143 definitions. These can get inlined within the current translation
9144 unit (an thus, we need to generate DWARF info for their abstract
9145 instances so that the DWARF info for the concrete inlined instances
9146 can have something to refer to) but the compiler never generates any
9147 out-of-lines instances of such things (despite the fact that they
9148 *are* definitions). The important point is that the C front-end
9149 marks these "extern inline" functions as DECL_EXTERNAL, but we need
9150 to generate DWARF for them anyway. Note that the C++ front-end also
9151 plays some similar games for inline function definitions appearing
9152 within include files which also contain
9153 `#pragma interface' pragmas. */
9154 if (DECL_INITIAL (decl
) == NULL_TREE
)
9157 /* If we're a nested function, initially use a parent of NULL; if we're
9158 a plain function, this will be fixed up in decls_for_scope. If
9159 we're a method, it will be ignored, since we already have a DIE. */
9160 if (decl_function_context (decl
))
9166 /* Ignore this VAR_DECL if it refers to a file-scope extern data object
9167 declaration and if the declaration was never even referenced from
9168 within this entire compilation unit. We suppress these DIEs in
9169 order to save space in the .debug section (by eliminating entries
9170 which are probably useless). Note that we must not suppress
9171 block-local extern declarations (whether used or not) because that
9172 would screw-up the debugger's name lookup mechanism and cause it to
9173 miss things which really ought to be in scope at a given point. */
9174 if (DECL_EXTERNAL (decl
) && !TREE_USED (decl
))
9177 /* If we are in terse mode, don't generate any DIEs to represent any
9178 variable declarations or definitions. */
9179 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
9184 /* Don't bother trying to generate any DIEs to represent any of the
9185 normal built-in types for the language we are compiling. */
9186 if (DECL_SOURCE_LINE (decl
) == 0)
9188 /* OK, we need to generate one for `bool' so GDB knows what type
9189 comparisons have. */
9190 if ((get_AT_unsigned (comp_unit_die
, DW_AT_language
)
9191 == DW_LANG_C_plus_plus
)
9192 && TREE_CODE (TREE_TYPE (decl
)) == BOOLEAN_TYPE
)
9193 modified_type_die (TREE_TYPE (decl
), 0, 0, NULL
);
9198 /* If we are in terse mode, don't generate any DIEs for types. */
9199 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
9202 /* If we're a function-scope tag, initially use a parent of NULL;
9203 this will be fixed up in decls_for_scope. */
9204 if (decl_function_context (decl
))
9213 gen_decl_die (decl
, context_die
);
9214 output_pending_types_for_scope (comp_unit_die
);
9217 /* Output a marker (i.e. a label) for the beginning of the generated code for
9221 dwarf2out_begin_block (blocknum
)
9222 register unsigned blocknum
;
9224 function_section (current_function_decl
);
9225 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, BLOCK_BEGIN_LABEL
, blocknum
);
9228 /* Output a marker (i.e. a label) for the end of the generated code for a
9232 dwarf2out_end_block (blocknum
)
9233 register unsigned blocknum
;
9235 function_section (current_function_decl
);
9236 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, BLOCK_END_LABEL
, blocknum
);
9239 /* Output a marker (i.e. a label) at a point in the assembly code which
9240 corresponds to a given source level label. */
9243 dwarf2out_label (insn
)
9246 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
9248 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
9250 function_section (current_function_decl
);
9251 sprintf (label
, INSN_LABEL_FMT
, current_funcdef_number
);
9252 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, label
,
9253 (unsigned) INSN_UID (insn
));
9257 /* Lookup a filename (in the list of filenames that we know about here in
9258 dwarf2out.c) and return its "index". The index of each (known) filename is
9259 just a unique number which is associated with only that one filename.
9260 We need such numbers for the sake of generating labels
9261 (in the .debug_sfnames section) and references to those
9262 files numbers (in the .debug_srcinfo and.debug_macinfo sections).
9263 If the filename given as an argument is not found in our current list,
9264 add it to the list and assign it the next available unique index number.
9265 In order to speed up searches, we remember the index of the filename
9266 was looked up last. This handles the majority of all searches. */
9269 lookup_filename (file_name
)
9272 static unsigned last_file_lookup_index
= 0;
9273 register unsigned i
;
9275 /* Check to see if the file name that was searched on the previous call
9276 matches this file name. If so, return the index. */
9277 if (last_file_lookup_index
!= 0)
9278 if (strcmp (file_name
, file_table
[last_file_lookup_index
]) == 0)
9279 return last_file_lookup_index
;
9281 /* Didn't match the previous lookup, search the table */
9282 for (i
= 1; i
< file_table_in_use
; ++i
)
9283 if (strcmp (file_name
, file_table
[i
]) == 0)
9285 last_file_lookup_index
= i
;
9289 /* Prepare to add a new table entry by making sure there is enough space in
9290 the table to do so. If not, expand the current table. */
9291 if (file_table_in_use
== file_table_allocated
)
9293 file_table_allocated
+= FILE_TABLE_INCREMENT
;
9295 = (char **) xrealloc (file_table
,
9296 file_table_allocated
* sizeof (char *));
9299 /* Add the new entry to the end of the filename table. */
9300 file_table
[file_table_in_use
] = xstrdup (file_name
);
9301 last_file_lookup_index
= file_table_in_use
++;
9303 return last_file_lookup_index
;
9306 /* Output a label to mark the beginning of a source code line entry
9307 and record information relating to this source line, in
9308 'line_info_table' for later output of the .debug_line section. */
9311 dwarf2out_line (filename
, line
)
9312 register char *filename
;
9313 register unsigned line
;
9315 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
9317 function_section (current_function_decl
);
9319 if (DECL_SECTION_NAME (current_function_decl
))
9321 register dw_separate_line_info_ref line_info
;
9322 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, SEPARATE_LINE_CODE_LABEL
,
9323 separate_line_info_table_in_use
);
9324 fputc ('\n', asm_out_file
);
9326 /* expand the line info table if necessary */
9327 if (separate_line_info_table_in_use
9328 == separate_line_info_table_allocated
)
9330 separate_line_info_table_allocated
+= LINE_INFO_TABLE_INCREMENT
;
9331 separate_line_info_table
9332 = (dw_separate_line_info_ref
)
9333 xrealloc (separate_line_info_table
,
9334 separate_line_info_table_allocated
9335 * sizeof (dw_separate_line_info_entry
));
9338 /* Add the new entry at the end of the line_info_table. */
9340 = &separate_line_info_table
[separate_line_info_table_in_use
++];
9341 line_info
->dw_file_num
= lookup_filename (filename
);
9342 line_info
->dw_line_num
= line
;
9343 line_info
->function
= current_funcdef_number
;
9347 register dw_line_info_ref line_info
;
9349 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, LINE_CODE_LABEL
,
9350 line_info_table_in_use
);
9351 fputc ('\n', asm_out_file
);
9353 /* Expand the line info table if necessary. */
9354 if (line_info_table_in_use
== line_info_table_allocated
)
9356 line_info_table_allocated
+= LINE_INFO_TABLE_INCREMENT
;
9358 = (dw_line_info_ref
)
9359 xrealloc (line_info_table
,
9360 (line_info_table_allocated
9361 * sizeof (dw_line_info_entry
)));
9364 /* Add the new entry at the end of the line_info_table. */
9365 line_info
= &line_info_table
[line_info_table_in_use
++];
9366 line_info
->dw_file_num
= lookup_filename (filename
);
9367 line_info
->dw_line_num
= line
;
9372 /* Record the beginning of a new source file, for later output
9373 of the .debug_macinfo section. At present, unimplemented. */
9376 dwarf2out_start_source_file (filename
)
9377 register char *filename
;
9381 /* Record the end of a source file, for later output
9382 of the .debug_macinfo section. At present, unimplemented. */
9385 dwarf2out_end_source_file ()
9389 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
9390 the tail part of the directive line, i.e. the part which is past the
9391 initial whitespace, #, whitespace, directive-name, whitespace part. */
9394 dwarf2out_define (lineno
, buffer
)
9395 register unsigned lineno
;
9396 register char *buffer
;
9398 static int initialized
= 0;
9401 dwarf2out_start_source_file (primary_filename
);
9406 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
9407 the tail part of the directive line, i.e. the part which is past the
9408 initial whitespace, #, whitespace, directive-name, whitespace part. */
9411 dwarf2out_undef (lineno
, buffer
)
9412 register unsigned lineno
;
9413 register char *buffer
;
9417 /* Set up for Dwarf output at the start of compilation. */
9420 dwarf2out_init (asm_out_file
, main_input_filename
)
9421 register FILE *asm_out_file
;
9422 register char *main_input_filename
;
9424 /* Remember the name of the primary input file. */
9425 primary_filename
= main_input_filename
;
9427 /* Allocate the initial hunk of the file_table. */
9428 file_table
= (char **) xmalloc (FILE_TABLE_INCREMENT
* sizeof (char *));
9429 bzero ((char *) file_table
, FILE_TABLE_INCREMENT
* sizeof (char *));
9430 file_table_allocated
= FILE_TABLE_INCREMENT
;
9432 /* Skip the first entry - file numbers begin at 1. */
9433 file_table_in_use
= 1;
9435 /* Allocate the initial hunk of the decl_die_table. */
9437 = (dw_die_ref
*) xmalloc (DECL_DIE_TABLE_INCREMENT
* sizeof (dw_die_ref
));
9438 bzero ((char *) decl_die_table
,
9439 DECL_DIE_TABLE_INCREMENT
* sizeof (dw_die_ref
));
9440 decl_die_table_allocated
= DECL_DIE_TABLE_INCREMENT
;
9441 decl_die_table_in_use
= 0;
9443 /* Allocate the initial hunk of the decl_scope_table. */
9445 = (tree
*) xmalloc (DECL_SCOPE_TABLE_INCREMENT
* sizeof (tree
));
9446 bzero ((char *) decl_scope_table
,
9447 DECL_SCOPE_TABLE_INCREMENT
* sizeof (tree
));
9448 decl_scope_table_allocated
= DECL_SCOPE_TABLE_INCREMENT
;
9449 decl_scope_depth
= 0;
9451 /* Allocate the initial hunk of the abbrev_die_table. */
9453 = (dw_die_ref
*) xmalloc (ABBREV_DIE_TABLE_INCREMENT
9454 * sizeof (dw_die_ref
));
9455 bzero ((char *) abbrev_die_table
,
9456 ABBREV_DIE_TABLE_INCREMENT
* sizeof (dw_die_ref
));
9457 abbrev_die_table_allocated
= ABBREV_DIE_TABLE_INCREMENT
;
9458 /* Zero-th entry is allocated, but unused */
9459 abbrev_die_table_in_use
= 1;
9461 /* Allocate the initial hunk of the line_info_table. */
9463 = (dw_line_info_ref
) xmalloc (LINE_INFO_TABLE_INCREMENT
9464 * sizeof (dw_line_info_entry
));
9465 bzero ((char *) line_info_table
,
9466 LINE_INFO_TABLE_INCREMENT
* sizeof (dw_line_info_entry
));
9467 line_info_table_allocated
= LINE_INFO_TABLE_INCREMENT
;
9468 /* Zero-th entry is allocated, but unused */
9469 line_info_table_in_use
= 1;
9471 /* Generate the initial DIE for the .debug section. Note that the (string)
9472 value given in the DW_AT_name attribute of the DW_TAG_compile_unit DIE
9473 will (typically) be a relative pathname and that this pathname should be
9474 taken as being relative to the directory from which the compiler was
9475 invoked when the given (base) source file was compiled. */
9476 gen_compile_unit_die (main_input_filename
);
9478 ASM_GENERATE_INTERNAL_LABEL (text_end_label
, TEXT_END_LABEL
, 0);
9481 /* Output stuff that dwarf requires at the end of every file,
9482 and generate the DWARF-2 debugging info. */
9487 limbo_die_node
*node
, *next_node
;
9491 /* Traverse the limbo die list, and add parent/child links. The only
9492 dies without parents that should be here are concrete instances of
9493 inline functions, and the comp_unit_die. We can ignore the comp_unit_die.
9494 For concrete instances, we can get the parent die from the abstract
9496 for (node
= limbo_die_list
; node
; node
= next_node
)
9498 next_node
= node
->next
;
9501 if (die
->die_parent
== NULL
)
9503 a
= get_AT (die
, DW_AT_abstract_origin
);
9505 add_child_die (a
->dw_attr_val
.v
.val_die_ref
->die_parent
, die
);
9506 else if (die
== comp_unit_die
)
9514 /* Traverse the DIE tree and add sibling attributes to those DIE's
9515 that have children. */
9516 add_sibling_attributes (comp_unit_die
);
9518 /* Output a terminator label for the .text section. */
9519 fputc ('\n', asm_out_file
);
9520 ASM_OUTPUT_SECTION (asm_out_file
, TEXT_SECTION
);
9521 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, TEXT_END_LABEL
, 0);
9524 /* Output a terminator label for the .data section. */
9525 fputc ('\n', asm_out_file
);
9526 ASM_OUTPUT_SECTION (asm_out_file
, DATA_SECTION
);
9527 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, DATA_END_LABEL
, 0);
9529 /* Output a terminator label for the .bss section. */
9530 fputc ('\n', asm_out_file
);
9531 ASM_OUTPUT_SECTION (asm_out_file
, BSS_SECTION
);
9532 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, BSS_END_LABEL
, 0);
9535 /* Output the source line correspondence table. */
9536 if (line_info_table_in_use
> 1 || separate_line_info_table_in_use
)
9538 fputc ('\n', asm_out_file
);
9539 ASM_OUTPUT_SECTION (asm_out_file
, DEBUG_LINE_SECTION
);
9540 output_line_info ();
9542 /* We can only use the low/high_pc attributes if all of the code
9544 if (separate_line_info_table_in_use
== 0)
9546 add_AT_lbl_id (comp_unit_die
, DW_AT_low_pc
, TEXT_SECTION
);
9547 add_AT_lbl_id (comp_unit_die
, DW_AT_high_pc
, text_end_label
);
9550 add_AT_section_offset (comp_unit_die
, DW_AT_stmt_list
, DEBUG_LINE_SECTION
);
9553 /* Output the abbreviation table. */
9554 fputc ('\n', asm_out_file
);
9555 ASM_OUTPUT_SECTION (asm_out_file
, ABBREV_SECTION
);
9556 build_abbrev_table (comp_unit_die
);
9557 output_abbrev_section ();
9559 /* Initialize the beginning DIE offset - and calculate sizes/offsets. */
9560 next_die_offset
= DWARF_COMPILE_UNIT_HEADER_SIZE
;
9561 calc_die_sizes (comp_unit_die
);
9563 /* Output debugging information. */
9564 fputc ('\n', asm_out_file
);
9565 ASM_OUTPUT_SECTION (asm_out_file
, DEBUG_INFO_SECTION
);
9566 output_compilation_unit_header ();
9567 output_die (comp_unit_die
);
9569 if (pubname_table_in_use
)
9571 /* Output public names table. */
9572 fputc ('\n', asm_out_file
);
9573 ASM_OUTPUT_SECTION (asm_out_file
, PUBNAMES_SECTION
);
9577 if (fde_table_in_use
)
9579 /* Output the address range information. */
9580 fputc ('\n', asm_out_file
);
9581 ASM_OUTPUT_SECTION (asm_out_file
, ARANGES_SECTION
);
9585 #endif /* DWARF2_DEBUGGING_INFO */