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 /* Decide whether we want to emit frame unwind information for the current
50 return (write_symbols
== DWARF2_DEBUG
51 #ifdef DWARF2_UNWIND_INFO
52 || (flag_exceptions
&& ! exceptions_via_longjmp
)
57 #if defined (DWARF2_DEBUGGING_INFO) || defined (DWARF2_UNWIND_INFO)
63 /* How to start an assembler comment. */
64 #ifndef ASM_COMMENT_START
65 #define ASM_COMMENT_START ";#"
68 typedef struct dw_cfi_struct
*dw_cfi_ref
;
69 typedef struct dw_fde_struct
*dw_fde_ref
;
70 typedef union dw_cfi_oprnd_struct
*dw_cfi_oprnd_ref
;
72 /* Call frames are described using a sequence of Call Frame
73 Information instructions. The register number, offset
74 and address fields are provided as possible operands;
75 their use is selected by the opcode field. */
77 typedef union dw_cfi_oprnd_struct
79 unsigned long dw_cfi_reg_num
;
80 long int dw_cfi_offset
;
85 typedef struct dw_cfi_struct
87 dw_cfi_ref dw_cfi_next
;
88 enum dwarf_call_frame_info dw_cfi_opc
;
89 dw_cfi_oprnd dw_cfi_oprnd1
;
90 dw_cfi_oprnd dw_cfi_oprnd2
;
94 /* All call frame descriptions (FDE's) in the GCC generated DWARF
95 refer to a single Common Information Entry (CIE), defined at
96 the beginning of the .debug_frame section. This used of a single
97 CIE obviates the need to keep track of multiple CIE's
98 in the DWARF generation routines below. */
100 typedef struct dw_fde_struct
103 char *dw_fde_current_label
;
105 dw_cfi_ref dw_fde_cfi
;
109 /* Maximum size (in bytes) of an artificially generated label. */
110 #define MAX_ARTIFICIAL_LABEL_BYTES 30
112 /* Make sure we know the sizes of the various types dwarf can describe. These
113 are only defaults. If the sizes are different for your target, you should
114 override these values by defining the appropriate symbols in your tm.h
117 #ifndef CHAR_TYPE_SIZE
118 #define CHAR_TYPE_SIZE BITS_PER_UNIT
121 #define PTR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
124 /* The size in bytes of a DWARF field indicating an offset or length
125 relative to a debug info section, specified to be 4 bytes in the DWARF-2
126 specification. The SGI/MIPS ABI defines it to be the same as PTR_SIZE. */
128 #ifndef DWARF_OFFSET_SIZE
129 #define DWARF_OFFSET_SIZE 4
132 #define DWARF_VERSION 2
134 /* Round SIZE up to the nearest BOUNDARY. */
135 #define DWARF_ROUND(SIZE,BOUNDARY) \
136 (((SIZE) + (BOUNDARY) - 1) & ~((BOUNDARY) - 1))
138 /* Offsets recorded in opcodes are a multiple of this alignment factor. */
139 #ifdef STACK_GROWS_DOWNWARD
140 #define DWARF_CIE_DATA_ALIGNMENT (-UNITS_PER_WORD)
142 #define DWARF_CIE_DATA_ALIGNMENT UNITS_PER_WORD
145 /* A pointer to the base of a table that contains frame description
146 information for each routine. */
147 static dw_fde_ref fde_table
;
149 /* Number of elements currently allocated for fde_table. */
150 static unsigned fde_table_allocated
;
152 /* Number of elements in fde_table currently in use. */
153 static unsigned fde_table_in_use
;
155 /* Size (in elements) of increments by which we may expand the
157 #define FDE_TABLE_INCREMENT 256
159 /* A list of call frame insns for the CIE. */
160 static dw_cfi_ref cie_cfi_head
;
162 /* The number of the current function definition for which debugging
163 information is being generated. These numbers range from 1 up to the
164 maximum number of function definitions contained within the current
165 compilation unit. These numbers are used to create unique label id's
166 unique to each function definition. */
167 static unsigned current_funcdef_number
= 0;
169 /* Some DWARF extensions (e.g., MIPS/SGI) implement a subprogram
170 attribute that accelerates the lookup of the FDE associated
171 with the subprogram. This variable holds the table index of the FDE
172 associated with the current function (body) definition. */
173 static unsigned current_funcdef_fde
;
175 /* Forward declarations for functions defined in this file. */
177 static char *stripattributes
PROTO((char *));
178 static char *dwarf_cfi_name
PROTO((unsigned));
179 static dw_cfi_ref new_cfi
PROTO((void));
180 static void add_cfi
PROTO((dw_cfi_ref
*, dw_cfi_ref
));
181 static unsigned long size_of_uleb128
PROTO((unsigned long));
182 static unsigned long size_of_sleb128
PROTO((long));
183 static void output_uleb128
PROTO((unsigned long));
184 static void output_sleb128
PROTO((long));
185 static void add_fde_cfi
PROTO((char *, dw_cfi_ref
));
186 static void lookup_cfa_1
PROTO((dw_cfi_ref
, unsigned long *,
188 static void lookup_cfa
PROTO((unsigned long *, long *));
189 static void reg_save
PROTO((char *, unsigned, unsigned,
191 static void initial_return_save
PROTO((rtx
));
192 static void output_cfi
PROTO((dw_cfi_ref
, dw_fde_ref
));
193 static void output_call_frame_info
PROTO((int));
194 static unsigned reg_number
PROTO((rtx
));
196 /* Definitions of defaults for assembler-dependent names of various
197 pseudo-ops and section names.
198 Theses may be overridden in the tm.h file (if necessary) for a particular
201 #ifdef OBJECT_FORMAT_ELF
202 #ifndef UNALIGNED_SHORT_ASM_OP
203 #define UNALIGNED_SHORT_ASM_OP ".2byte"
205 #ifndef UNALIGNED_INT_ASM_OP
206 #define UNALIGNED_INT_ASM_OP ".4byte"
208 #ifndef UNALIGNED_DOUBLE_INT_ASM_OP
209 #define UNALIGNED_DOUBLE_INT_ASM_OP ".8byte"
211 #endif /* OBJECT_FORMAT_ELF */
214 #define ASM_BYTE_OP ".byte"
217 /* Data and reference forms for relocatable data. */
218 #define DW_FORM_data (DWARF_OFFSET_SIZE == 8 ? DW_FORM_data8 : DW_FORM_data4)
219 #define DW_FORM_ref (DWARF_OFFSET_SIZE == 8 ? DW_FORM_ref8 : DW_FORM_ref4)
221 /* Pseudo-op for defining a new section. */
222 #ifndef SECTION_ASM_OP
223 #define SECTION_ASM_OP ".section"
226 /* The default format used by the ASM_OUTPUT_SECTION macro (see below) to
227 print the SECTION_ASM_OP and the section name. The default here works for
228 almost all svr4 assemblers, except for the sparc, where the section name
229 must be enclosed in double quotes. (See sparcv4.h). */
230 #ifndef SECTION_FORMAT
231 #ifdef PUSHSECTION_FORMAT
232 #define SECTION_FORMAT PUSHSECTION_FORMAT
234 #define SECTION_FORMAT "\t%s\t%s\n"
238 #ifndef FRAME_SECTION
239 #define FRAME_SECTION ".debug_frame"
242 #ifndef FUNC_BEGIN_LABEL
243 #define FUNC_BEGIN_LABEL "LFB"
245 #ifndef FUNC_END_LABEL
246 #define FUNC_END_LABEL "LFE"
248 #define CIE_AFTER_SIZE_LABEL "LSCIE"
249 #define CIE_END_LABEL "LECIE"
250 #define FDE_AFTER_SIZE_LABEL "LSFDE"
251 #define FDE_END_LABEL "LEFDE"
253 /* Definitions of defaults for various types of primitive assembly language
254 output operations. These may be overridden from within the tm.h file,
255 but typically, that is unecessary. */
257 #ifndef ASM_OUTPUT_SECTION
258 #define ASM_OUTPUT_SECTION(FILE, SECTION) \
259 fprintf ((FILE), SECTION_FORMAT, SECTION_ASM_OP, SECTION)
262 #ifndef ASM_OUTPUT_DWARF_DATA1
263 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
264 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, VALUE)
267 #ifdef UNALIGNED_INT_ASM_OP
269 #ifndef UNALIGNED_OFFSET_ASM_OP
270 #define UNALIGNED_OFFSET_ASM_OP \
271 (DWARF_OFFSET_SIZE == 8 ? UNALIGNED_DOUBLE_INT_ASM_OP : UNALIGNED_INT_ASM_OP)
274 #ifndef UNALIGNED_WORD_ASM_OP
275 #define UNALIGNED_WORD_ASM_OP \
276 (PTR_SIZE == 8 ? UNALIGNED_DOUBLE_INT_ASM_OP : UNALIGNED_INT_ASM_OP)
279 #ifndef ASM_OUTPUT_DWARF_DELTA2
280 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
281 do { fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \
282 assemble_name (FILE, LABEL1); \
283 fprintf (FILE, "-"); \
284 assemble_name (FILE, LABEL2); \
288 #ifndef ASM_OUTPUT_DWARF_DELTA4
289 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
290 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
291 assemble_name (FILE, LABEL1); \
292 fprintf (FILE, "-"); \
293 assemble_name (FILE, LABEL2); \
297 #ifndef ASM_OUTPUT_DWARF_DELTA
298 #define ASM_OUTPUT_DWARF_DELTA(FILE,LABEL1,LABEL2) \
299 do { fprintf ((FILE), "\t%s\t", UNALIGNED_OFFSET_ASM_OP); \
300 assemble_name (FILE, LABEL1); \
301 fprintf (FILE, "-"); \
302 assemble_name (FILE, LABEL2); \
306 #ifndef ASM_OUTPUT_DWARF_ADDR_DELTA
307 #define ASM_OUTPUT_DWARF_ADDR_DELTA(FILE,LABEL1,LABEL2) \
308 do { fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP); \
309 assemble_name (FILE, LABEL1); \
310 fprintf (FILE, "-"); \
311 assemble_name (FILE, LABEL2); \
315 #ifndef ASM_OUTPUT_DWARF_ADDR
316 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
317 do { fprintf ((FILE), "\t%s\t", UNALIGNED_WORD_ASM_OP); \
318 assemble_name (FILE, LABEL); \
322 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
323 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,ADDR) \
324 fprintf ((FILE), "\t%s\t%s", UNALIGNED_WORD_ASM_OP, (ADDR))
327 #ifndef ASM_OUTPUT_DWARF_OFFSET
328 #define ASM_OUTPUT_DWARF_OFFSET(FILE,LABEL) \
329 do { fprintf ((FILE), "\t%s\t", UNALIGNED_OFFSET_ASM_OP); \
330 assemble_name (FILE, LABEL); \
334 #ifndef ASM_OUTPUT_DWARF_DATA2
335 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
336 fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_SHORT_ASM_OP, (unsigned) VALUE)
339 #ifndef ASM_OUTPUT_DWARF_DATA4
340 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
341 fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_INT_ASM_OP, (unsigned) VALUE)
344 #ifndef ASM_OUTPUT_DWARF_DATA
345 #define ASM_OUTPUT_DWARF_DATA(FILE,VALUE) \
346 fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_OFFSET_ASM_OP, \
347 (unsigned long) VALUE)
350 #ifndef ASM_OUTPUT_DWARF_ADDR_DATA
351 #define ASM_OUTPUT_DWARF_ADDR_DATA(FILE,VALUE) \
352 fprintf ((FILE), "\t%s\t0x%lx", UNALIGNED_WORD_ASM_OP, \
353 (unsigned long) VALUE)
356 #ifndef ASM_OUTPUT_DWARF_DATA8
357 #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \
359 if (WORDS_BIG_ENDIAN) \
361 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
362 fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
366 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
367 fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
372 #else /* UNALIGNED_INT_ASM_OP */
374 /* We don't have unaligned support, let's hope the normal output works for
377 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
378 assemble_integer (gen_rtx (SYMBOL_REF, Pmode, LABEL), PTR_SIZE, 1)
380 #define ASM_OUTPUT_DWARF_OFFSET(FILE,LABEL) \
381 assemble_integer (gen_rtx (SYMBOL_REF, SImode, LABEL), 4, 1)
383 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
384 assemble_integer (gen_rtx (MINUS, HImode, \
385 gen_rtx (SYMBOL_REF, Pmode, LABEL1), \
386 gen_rtx (SYMBOL_REF, Pmode, LABEL2)), \
389 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
390 assemble_integer (gen_rtx (MINUS, SImode, \
391 gen_rtx (SYMBOL_REF, Pmode, LABEL1), \
392 gen_rtx (SYMBOL_REF, Pmode, LABEL2)), \
395 #define ASM_OUTPUT_DWARF_ADDR_DELTA(FILE,LABEL1,LABEL2) \
396 assemble_integer (gen_rtx (MINUS, Pmode, \
397 gen_rtx (SYMBOL_REF, Pmode, LABEL1), \
398 gen_rtx (SYMBOL_REF, Pmode, LABEL2)), \
401 #define ASM_OUTPUT_DWARF_DELTA(FILE,LABEL1,LABEL2) \
402 ASM_OUTPUT_DWARF_DELTA4 (FILE,LABEL1,LABEL2)
404 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
405 assemble_integer (GEN_INT (VALUE), 4, 1)
407 #endif /* UNALIGNED_INT_ASM_OP */
409 /* This is similar to the default ASM_OUTPUT_ASCII, except that no trailing
410 newline is produced. When flag_debug_asm is asserted, we add commnetary
411 at the end of the line, so we must avoid output of a newline here. */
412 #ifndef ASM_OUTPUT_DWARF_STRING
413 #define ASM_OUTPUT_DWARF_STRING(FILE,P) \
415 register int slen = strlen(P); \
416 register char *p = (P); \
418 fprintf (FILE, "\t.ascii \""); \
419 for (i = 0; i < slen; i++) \
421 register int c = p[i]; \
422 if (c == '\"' || c == '\\') \
424 if (c >= ' ' && c < 0177) \
428 fprintf (FILE, "\\%o", c); \
431 fprintf (FILE, "\\0\""); \
436 /* The DWARF 2 CFA column which tracks the return address. Normally this
437 is the column for PC, or the first column after all of the hard
439 #ifndef DWARF_FRAME_RETURN_COLUMN
441 #define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (PC_REGNUM)
443 #define DWARF_FRAME_RETURN_COLUMN FIRST_PSEUDO_REGISTER
447 /* The mapping from gcc register number to DWARF 2 CFA column number. By
448 default, we just provide columns for all registers. */
449 #ifndef DWARF_FRAME_REGNUM
450 #define DWARF_FRAME_REGNUM(REG) DBX_REGISTER_NUMBER (REG)
453 /* Hook used by __throw. */
456 expand_builtin_dwarf_fp_regnum ()
458 return GEN_INT (DWARF_FRAME_REGNUM (HARD_FRAME_POINTER_REGNUM
));
461 /* The offset from the incoming value of %sp to the top of the stack frame
462 for the current function. */
463 #ifndef INCOMING_FRAME_SP_OFFSET
464 #define INCOMING_FRAME_SP_OFFSET 0
467 /* Return a pointer to a copy of the section string name S with all
468 attributes stripped off. */
474 char *stripped
= xstrdup (s
);
477 while (*p
&& *p
!= ',')
484 /* Return the register number described by a given RTL node. */
490 register unsigned regno
= REGNO (rtl
);
492 if (regno
>= FIRST_PSEUDO_REGISTER
)
494 warning ("internal regno botch: regno = %d\n", regno
);
498 regno
= DBX_REGISTER_NUMBER (regno
);
502 struct reg_size_range
509 /* Given a register number in REG_TREE, return an rtx for its size in bytes.
510 We do this in kind of a roundabout way, by building up a list of
511 register size ranges and seeing where our register falls in one of those
512 ranges. We need to do it this way because REG_TREE is not a constant,
513 and the target macros were not designed to make this task easy. */
516 expand_builtin_dwarf_reg_size (reg_tree
, target
)
520 enum machine_mode mode
;
522 struct reg_size_range ranges
[5];
529 for (; i
< FIRST_PSEUDO_REGISTER
; ++i
)
531 /* The return address is out of order on the MIPS, and we don't use
532 copy_reg for it anyway, so we don't care here how large it is. */
533 if (DWARF_FRAME_REGNUM (i
) == DWARF_FRAME_RETURN_COLUMN
)
536 mode
= reg_raw_mode
[i
];
537 /* CCmode is arbitrarily given a size of 4 bytes. It is more useful
538 to use the same size as word_mode, since that reduces the number
539 of ranges we need. It should not matter, since the result should
540 never be used for a condition code register anyways. */
543 size
= GET_MODE_SIZE (mode
);
545 if (size
!= last_size
)
547 ranges
[n_ranges
].beg
= i
;
548 ranges
[n_ranges
].size
= last_size
= GET_MODE_SIZE (reg_raw_mode
[i
]);
553 ranges
[n_ranges
-1].end
= i
;
556 /* The usual case: fp regs surrounded by general regs. */
557 if (n_ranges
== 3 && ranges
[0].size
== ranges
[2].size
)
559 if ((DWARF_FRAME_REGNUM (ranges
[1].end
)
560 - DWARF_FRAME_REGNUM (ranges
[1].beg
))
561 != ranges
[1].end
- ranges
[1].beg
)
563 t
= fold (build (GE_EXPR
, integer_type_node
, reg_tree
,
564 build_int_2 (DWARF_FRAME_REGNUM (ranges
[1].beg
), 0)));
565 t2
= fold (build (LE_EXPR
, integer_type_node
, reg_tree
,
566 build_int_2 (DWARF_FRAME_REGNUM (ranges
[1].end
), 0)));
567 t
= fold (build (TRUTH_ANDIF_EXPR
, integer_type_node
, t
, t2
));
568 t
= fold (build (COND_EXPR
, integer_type_node
, t
,
569 build_int_2 (ranges
[1].size
, 0),
570 build_int_2 (ranges
[0].size
, 0)));
575 t
= build_int_2 (ranges
[n_ranges
].size
, 0);
576 size
= DWARF_FRAME_REGNUM (ranges
[n_ranges
].beg
);
579 if ((DWARF_FRAME_REGNUM (ranges
[n_ranges
].end
)
580 - DWARF_FRAME_REGNUM (ranges
[n_ranges
].beg
))
581 != ranges
[n_ranges
].end
- ranges
[n_ranges
].beg
)
583 if (DWARF_FRAME_REGNUM (ranges
[n_ranges
].beg
) >= size
)
585 size
= DWARF_FRAME_REGNUM (ranges
[n_ranges
].beg
);
586 t2
= fold (build (LE_EXPR
, integer_type_node
, reg_tree
,
587 build_int_2 (DWARF_FRAME_REGNUM
588 (ranges
[n_ranges
].end
), 0)));
589 t
= fold (build (COND_EXPR
, integer_type_node
, t2
,
590 build_int_2 (ranges
[n_ranges
].size
, 0), t
));
593 return expand_expr (t
, target
, Pmode
, 0);
596 /* Convert a DWARF call frame info. operation to its string name */
599 dwarf_cfi_name (cfi_opc
)
600 register unsigned cfi_opc
;
604 case DW_CFA_advance_loc
:
605 return "DW_CFA_advance_loc";
607 return "DW_CFA_offset";
609 return "DW_CFA_restore";
613 return "DW_CFA_set_loc";
614 case DW_CFA_advance_loc1
:
615 return "DW_CFA_advance_loc1";
616 case DW_CFA_advance_loc2
:
617 return "DW_CFA_advance_loc2";
618 case DW_CFA_advance_loc4
:
619 return "DW_CFA_advance_loc4";
620 case DW_CFA_offset_extended
:
621 return "DW_CFA_offset_extended";
622 case DW_CFA_restore_extended
:
623 return "DW_CFA_restore_extended";
624 case DW_CFA_undefined
:
625 return "DW_CFA_undefined";
626 case DW_CFA_same_value
:
627 return "DW_CFA_same_value";
628 case DW_CFA_register
:
629 return "DW_CFA_register";
630 case DW_CFA_remember_state
:
631 return "DW_CFA_remember_state";
632 case DW_CFA_restore_state
:
633 return "DW_CFA_restore_state";
635 return "DW_CFA_def_cfa";
636 case DW_CFA_def_cfa_register
:
637 return "DW_CFA_def_cfa_register";
638 case DW_CFA_def_cfa_offset
:
639 return "DW_CFA_def_cfa_offset";
641 /* SGI/MIPS specific */
642 case DW_CFA_MIPS_advance_loc8
:
643 return "DW_CFA_MIPS_advance_loc8";
646 case DW_CFA_GNU_window_save
:
647 return "DW_CFA_GNU_window_save";
648 case DW_CFA_GNU_args_size
:
649 return "DW_CFA_GNU_args_size";
652 return "DW_CFA_<unknown>";
656 /* Return a pointer to a newly allocated Call Frame Instruction. */
658 static inline dw_cfi_ref
661 register dw_cfi_ref cfi
= (dw_cfi_ref
) xmalloc (sizeof (dw_cfi_node
));
663 cfi
->dw_cfi_next
= NULL
;
664 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= 0;
665 cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
= 0;
670 /* Add a Call Frame Instruction to list of instructions. */
673 add_cfi (list_head
, cfi
)
674 register dw_cfi_ref
*list_head
;
675 register dw_cfi_ref cfi
;
677 register dw_cfi_ref
*p
;
679 /* Find the end of the chain. */
680 for (p
= list_head
; (*p
) != NULL
; p
= &(*p
)->dw_cfi_next
)
686 /* Generate a new label for the CFI info to refer to. */
689 dwarf2out_cfi_label ()
691 static char label
[20];
692 static unsigned long label_num
= 0;
694 ASM_GENERATE_INTERNAL_LABEL (label
, "LCFI", label_num
++);
695 ASM_OUTPUT_LABEL (asm_out_file
, label
);
700 /* Add CFI to the current fde at the PC value indicated by LABEL if specified,
701 or to the CIE if LABEL is NULL. */
704 add_fde_cfi (label
, cfi
)
705 register char *label
;
706 register dw_cfi_ref cfi
;
710 register dw_fde_ref fde
= &fde_table
[fde_table_in_use
- 1];
713 label
= dwarf2out_cfi_label ();
715 if (fde
->dw_fde_current_label
== NULL
716 || strcmp (label
, fde
->dw_fde_current_label
) != 0)
718 register dw_cfi_ref xcfi
;
720 fde
->dw_fde_current_label
= label
= xstrdup (label
);
722 /* Set the location counter to the new label. */
724 xcfi
->dw_cfi_opc
= DW_CFA_advance_loc4
;
725 xcfi
->dw_cfi_oprnd1
.dw_cfi_addr
= label
;
726 add_cfi (&fde
->dw_fde_cfi
, xcfi
);
729 add_cfi (&fde
->dw_fde_cfi
, cfi
);
733 add_cfi (&cie_cfi_head
, cfi
);
736 /* Subroutine of lookup_cfa. */
739 lookup_cfa_1 (cfi
, regp
, offsetp
)
740 register dw_cfi_ref cfi
;
741 register unsigned long *regp
;
742 register long *offsetp
;
744 switch (cfi
->dw_cfi_opc
)
746 case DW_CFA_def_cfa_offset
:
747 *offsetp
= cfi
->dw_cfi_oprnd1
.dw_cfi_offset
;
749 case DW_CFA_def_cfa_register
:
750 *regp
= cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
;
753 *regp
= cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
;
754 *offsetp
= cfi
->dw_cfi_oprnd2
.dw_cfi_offset
;
761 /* Find the previous value for the CFA. */
764 lookup_cfa (regp
, offsetp
)
765 register unsigned long *regp
;
766 register long *offsetp
;
768 register dw_cfi_ref cfi
;
770 *regp
= (unsigned long) -1;
773 for (cfi
= cie_cfi_head
; cfi
; cfi
= cfi
->dw_cfi_next
)
774 lookup_cfa_1 (cfi
, regp
, offsetp
);
776 if (fde_table_in_use
)
778 register dw_fde_ref fde
= &fde_table
[fde_table_in_use
- 1];
779 for (cfi
= fde
->dw_fde_cfi
; cfi
; cfi
= cfi
->dw_cfi_next
)
780 lookup_cfa_1 (cfi
, regp
, offsetp
);
784 /* The current rule for calculating the DWARF2 canonical frame address. */
785 static unsigned long cfa_reg
;
786 static long cfa_offset
;
788 /* The register used for saving registers to the stack, and its offset
790 static unsigned cfa_store_reg
;
791 static long cfa_store_offset
;
793 /* The running total of the size of arguments pushed onto the stack. */
794 static long args_size
;
796 /* Entry point to update the canonical frame address (CFA).
797 LABEL is passed to add_fde_cfi. The value of CFA is now to be
798 calculated from REG+OFFSET. */
801 dwarf2out_def_cfa (label
, reg
, offset
)
802 register char *label
;
803 register unsigned reg
;
804 register long offset
;
806 register dw_cfi_ref cfi
;
807 unsigned long old_reg
;
812 if (cfa_store_reg
== reg
)
813 cfa_store_offset
= offset
;
815 reg
= DWARF_FRAME_REGNUM (reg
);
816 lookup_cfa (&old_reg
, &old_offset
);
818 if (reg
== old_reg
&& offset
== old_offset
)
825 cfi
->dw_cfi_opc
= DW_CFA_def_cfa_offset
;
826 cfi
->dw_cfi_oprnd1
.dw_cfi_offset
= offset
;
829 #ifndef MIPS_DEBUGGING_INFO /* SGI dbx thinks this means no offset. */
830 else if (offset
== old_offset
&& old_reg
!= (unsigned long) -1)
832 cfi
->dw_cfi_opc
= DW_CFA_def_cfa_register
;
833 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= reg
;
839 cfi
->dw_cfi_opc
= DW_CFA_def_cfa
;
840 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= reg
;
841 cfi
->dw_cfi_oprnd2
.dw_cfi_offset
= offset
;
844 add_fde_cfi (label
, cfi
);
847 /* Add the CFI for saving a register. REG is the CFA column number.
848 LABEL is passed to add_fde_cfi.
849 If SREG is -1, the register is saved at OFFSET from the CFA;
850 otherwise it is saved in SREG. */
853 reg_save (label
, reg
, sreg
, offset
)
854 register char * label
;
855 register unsigned reg
;
856 register unsigned sreg
;
857 register long offset
;
859 register dw_cfi_ref cfi
= new_cfi ();
861 cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
= reg
;
866 /* The register number won't fit in 6 bits, so we have to use
868 cfi
->dw_cfi_opc
= DW_CFA_offset_extended
;
870 cfi
->dw_cfi_opc
= DW_CFA_offset
;
872 offset
/= DWARF_CIE_DATA_ALIGNMENT
;
875 cfi
->dw_cfi_oprnd2
.dw_cfi_offset
= offset
;
879 cfi
->dw_cfi_opc
= DW_CFA_register
;
880 cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
= sreg
;
883 add_fde_cfi (label
, cfi
);
886 /* Add the CFI for saving a register window. LABEL is passed to reg_save.
887 This CFI tells the unwinder that it needs to restore the window registers
888 from the previous frame's window save area.
890 ??? Perhaps we should note in the CIE where windows are saved (instead of
891 assuming 0(cfa)) and what registers are in the window. */
894 dwarf2out_window_save (label
)
895 register char * label
;
897 register dw_cfi_ref cfi
= new_cfi ();
898 cfi
->dw_cfi_opc
= DW_CFA_GNU_window_save
;
899 add_fde_cfi (label
, cfi
);
902 /* Add a CFI to update the running total of the size of arguments
903 pushed onto the stack. */
906 dwarf2out_args_size (label
, size
)
910 register dw_cfi_ref cfi
= new_cfi ();
911 cfi
->dw_cfi_opc
= DW_CFA_GNU_args_size
;
912 cfi
->dw_cfi_oprnd1
.dw_cfi_offset
= size
;
913 add_fde_cfi (label
, cfi
);
916 /* Entry point for saving a register to the stack. REG is the GCC register
917 number. LABEL and OFFSET are passed to reg_save. */
920 dwarf2out_reg_save (label
, reg
, offset
)
921 register char * label
;
922 register unsigned reg
;
923 register long offset
;
925 reg_save (label
, DWARF_FRAME_REGNUM (reg
), -1, offset
);
928 /* Entry point for saving the return address in the stack.
929 LABEL and OFFSET are passed to reg_save. */
932 dwarf2out_return_save (label
, offset
)
933 register char * label
;
934 register long offset
;
936 reg_save (label
, DWARF_FRAME_RETURN_COLUMN
, -1, offset
);
939 /* Entry point for saving the return address in a register.
940 LABEL and SREG are passed to reg_save. */
943 dwarf2out_return_reg (label
, sreg
)
944 register char * label
;
945 register unsigned sreg
;
947 reg_save (label
, DWARF_FRAME_RETURN_COLUMN
, sreg
, 0);
950 /* Record the initial position of the return address. RTL is
951 INCOMING_RETURN_ADDR_RTX. */
954 initial_return_save (rtl
)
960 switch (GET_CODE (rtl
))
963 /* RA is in a register. */
964 reg
= reg_number (rtl
);
967 /* RA is on the stack. */
969 switch (GET_CODE (rtl
))
972 if (REGNO (rtl
) != STACK_POINTER_REGNUM
)
977 if (REGNO (XEXP (rtl
, 0)) != STACK_POINTER_REGNUM
)
979 offset
= INTVAL (XEXP (rtl
, 1));
982 if (REGNO (XEXP (rtl
, 0)) != STACK_POINTER_REGNUM
)
984 offset
= -INTVAL (XEXP (rtl
, 1));
991 /* The return address is at some offset from any value we can
992 actually load. For instance, on the SPARC it is in %i7+8. Just
993 ignore the offset for now; it doesn't matter for unwinding frames. */
994 if (GET_CODE (XEXP (rtl
, 1)) != CONST_INT
)
996 initial_return_save (XEXP (rtl
, 0));
1002 reg_save (NULL
, DWARF_FRAME_RETURN_COLUMN
, reg
, offset
- cfa_offset
);
1005 /* Check INSN to see if it looks like a push or a stack adjustment, and
1006 make a note of it if it does. EH uses this information to find out how
1007 much extra space it needs to pop off the stack. */
1010 dwarf2out_stack_adjust (insn
)
1016 if (GET_CODE (insn
) == BARRIER
)
1018 /* When we see a BARRIER, we know to reset args_size to 0. Usually
1019 the compiler will have already emitted a stack adjustment, but
1020 doesn't bother for calls to noreturn functions. */
1021 #ifdef STACK_GROWS_DOWNWARD
1022 offset
= -args_size
;
1027 else if (GET_CODE (PATTERN (insn
)) == SET
)
1032 insn
= PATTERN (insn
);
1033 src
= SET_SRC (insn
);
1034 dest
= SET_DEST (insn
);
1036 if (dest
== stack_pointer_rtx
)
1038 /* (set (reg sp) (plus (reg sp) (const_int))) */
1039 code
= GET_CODE (src
);
1040 if (! (code
== PLUS
|| code
== MINUS
)
1041 || XEXP (src
, 0) != stack_pointer_rtx
1042 || GET_CODE (XEXP (src
, 1)) != CONST_INT
)
1045 offset
= INTVAL (XEXP (src
, 1));
1047 else if (GET_CODE (dest
) == MEM
)
1049 /* (set (mem (pre_dec (reg sp))) (foo)) */
1050 src
= XEXP (dest
, 0);
1051 code
= GET_CODE (src
);
1053 if (! (code
== PRE_DEC
|| code
== PRE_INC
)
1054 || XEXP (src
, 0) != stack_pointer_rtx
)
1057 offset
= GET_MODE_SIZE (GET_MODE (dest
));
1062 if (code
== PLUS
|| code
== PRE_INC
)
1071 if (cfa_reg
== STACK_POINTER_REGNUM
)
1072 cfa_offset
+= offset
;
1074 #ifndef STACK_GROWS_DOWNWARD
1077 args_size
+= offset
;
1081 label
= dwarf2out_cfi_label ();
1082 dwarf2out_def_cfa (label
, cfa_reg
, cfa_offset
);
1083 dwarf2out_args_size (label
, args_size
);
1086 /* Record call frame debugging information for INSN, which either
1087 sets SP or FP (adjusting how we calculate the frame address) or saves a
1088 register to the stack. If INSN is NULL_RTX, initialize our state. */
1091 dwarf2out_frame_debug (insn
)
1098 /* A temporary register used in adjusting SP or setting up the store_reg. */
1099 static unsigned cfa_temp_reg
;
1100 static long cfa_temp_value
;
1102 if (insn
== NULL_RTX
)
1104 /* Set up state for generating call frame debug info. */
1105 lookup_cfa (&cfa_reg
, &cfa_offset
);
1106 if (cfa_reg
!= DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM
))
1108 cfa_reg
= STACK_POINTER_REGNUM
;
1109 cfa_store_reg
= cfa_reg
;
1110 cfa_store_offset
= cfa_offset
;
1116 if (! RTX_FRAME_RELATED_P (insn
))
1118 dwarf2out_stack_adjust (insn
);
1122 label
= dwarf2out_cfi_label ();
1124 insn
= PATTERN (insn
);
1125 /* Assume that in a PARALLEL prologue insn, only the first elt is
1126 significant. Currently this is true. */
1127 if (GET_CODE (insn
) == PARALLEL
)
1128 insn
= XVECEXP (insn
, 0, 0);
1129 if (GET_CODE (insn
) != SET
)
1132 src
= SET_SRC (insn
);
1133 dest
= SET_DEST (insn
);
1135 switch (GET_CODE (dest
))
1138 /* Update the CFA rule wrt SP or FP. Make sure src is
1139 relative to the current CFA register. */
1140 switch (GET_CODE (src
))
1142 /* Setting FP from SP. */
1144 if (cfa_reg
!= REGNO (src
))
1146 if (REGNO (dest
) != STACK_POINTER_REGNUM
1147 && !(frame_pointer_needed
1148 && REGNO (dest
) == HARD_FRAME_POINTER_REGNUM
))
1150 cfa_reg
= REGNO (dest
);
1155 if (dest
== stack_pointer_rtx
)
1158 switch (GET_CODE (XEXP (src
, 1)))
1161 offset
= INTVAL (XEXP (src
, 1));
1164 if (REGNO (XEXP (src
, 1)) != cfa_temp_reg
)
1166 offset
= cfa_temp_value
;
1172 if (XEXP (src
, 0) == hard_frame_pointer_rtx
)
1174 /* Restoring SP from FP in the epilogue. */
1175 if (cfa_reg
!= HARD_FRAME_POINTER_REGNUM
)
1177 cfa_reg
= STACK_POINTER_REGNUM
;
1179 else if (XEXP (src
, 0) != stack_pointer_rtx
)
1182 if (GET_CODE (src
) == PLUS
)
1184 if (cfa_reg
== STACK_POINTER_REGNUM
)
1185 cfa_offset
+= offset
;
1186 if (cfa_store_reg
== STACK_POINTER_REGNUM
)
1187 cfa_store_offset
+= offset
;
1191 if (GET_CODE (src
) != PLUS
1192 || XEXP (src
, 1) != stack_pointer_rtx
)
1194 if (GET_CODE (XEXP (src
, 0)) != REG
1195 || REGNO (XEXP (src
, 0)) != cfa_temp_reg
)
1197 cfa_store_reg
= REGNO (dest
);
1198 cfa_store_offset
-= cfa_temp_value
;
1203 cfa_temp_reg
= REGNO (dest
);
1204 cfa_temp_value
= INTVAL (src
);
1208 if (GET_CODE (XEXP (src
, 0)) != REG
1209 || REGNO (XEXP (src
, 0)) != cfa_temp_reg
1210 || REGNO (dest
) != cfa_temp_reg
1211 || GET_CODE (XEXP (src
, 1)) != CONST_INT
)
1213 cfa_temp_value
|= INTVAL (XEXP (src
, 1));
1219 dwarf2out_def_cfa (label
, cfa_reg
, cfa_offset
);
1223 /* Saving a register to the stack. Make sure dest is relative to the
1225 if (GET_CODE (src
) != REG
)
1227 switch (GET_CODE (XEXP (dest
, 0)))
1232 offset
= GET_MODE_SIZE (GET_MODE (dest
));
1233 if (GET_CODE (XEXP (dest
, 0)) == PRE_INC
)
1236 if (REGNO (XEXP (XEXP (dest
, 0), 0)) != STACK_POINTER_REGNUM
1237 || cfa_store_reg
!= STACK_POINTER_REGNUM
)
1239 cfa_store_offset
+= offset
;
1240 if (cfa_reg
== STACK_POINTER_REGNUM
)
1241 cfa_offset
= cfa_store_offset
;
1243 offset
= -cfa_store_offset
;
1246 /* With an offset. */
1249 offset
= INTVAL (XEXP (XEXP (dest
, 0), 1));
1250 if (GET_CODE (src
) == MINUS
)
1253 if (cfa_store_reg
!= REGNO (XEXP (XEXP (dest
, 0), 0)))
1255 offset
-= cfa_store_offset
;
1261 dwarf2out_def_cfa (label
, cfa_reg
, cfa_offset
);
1262 dwarf2out_reg_save (label
, REGNO (src
), offset
);
1270 /* Return the size of an unsigned LEB128 quantity. */
1272 static inline unsigned long
1273 size_of_uleb128 (value
)
1274 register unsigned long value
;
1276 register unsigned long size
= 0;
1277 register unsigned byte
;
1281 byte
= (value
& 0x7f);
1290 /* Return the size of a signed LEB128 quantity. */
1292 static inline unsigned long
1293 size_of_sleb128 (value
)
1294 register long value
;
1296 register unsigned long size
= 0;
1297 register unsigned byte
;
1301 byte
= (value
& 0x7f);
1305 while (!(((value
== 0) && ((byte
& 0x40) == 0))
1306 || ((value
== -1) && ((byte
& 0x40) != 0))));
1311 /* Output an unsigned LEB128 quantity. */
1314 output_uleb128 (value
)
1315 register unsigned long value
;
1317 unsigned long save_value
= value
;
1319 fprintf (asm_out_file
, "\t%s\t", ASM_BYTE_OP
);
1322 register unsigned byte
= (value
& 0x7f);
1325 /* More bytes to follow. */
1328 fprintf (asm_out_file
, "0x%x", byte
);
1330 fprintf (asm_out_file
, ",");
1335 fprintf (asm_out_file
, "\t%s ULEB128 0x%x", ASM_COMMENT_START
, save_value
);
1338 /* Output an signed LEB128 quantity. */
1341 output_sleb128 (value
)
1342 register long value
;
1345 register unsigned byte
;
1346 long save_value
= value
;
1348 fprintf (asm_out_file
, "\t%s\t", ASM_BYTE_OP
);
1351 byte
= (value
& 0x7f);
1352 /* arithmetic shift */
1354 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
1355 || ((value
== -1) && ((byte
& 0x40) != 0))));
1359 fprintf (asm_out_file
, "0x%x", byte
);
1361 fprintf (asm_out_file
, ",");
1366 fprintf (asm_out_file
, "\t%s SLEB128 %d", ASM_COMMENT_START
, save_value
);
1369 /* Output a Call Frame Information opcode and its operand(s). */
1372 output_cfi (cfi
, fde
)
1373 register dw_cfi_ref cfi
;
1374 register dw_fde_ref fde
;
1376 if (cfi
->dw_cfi_opc
== DW_CFA_advance_loc
)
1378 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
1380 | (cfi
->dw_cfi_oprnd1
.dw_cfi_offset
& 0x3f));
1382 fprintf (asm_out_file
, "\t%s DW_CFA_advance_loc 0x%x",
1383 ASM_COMMENT_START
, cfi
->dw_cfi_oprnd1
.dw_cfi_offset
);
1384 fputc ('\n', asm_out_file
);
1387 else if (cfi
->dw_cfi_opc
== DW_CFA_offset
)
1389 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
1391 | (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
& 0x3f));
1393 fprintf (asm_out_file
, "\t%s DW_CFA_offset, column 0x%x",
1394 ASM_COMMENT_START
, cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1396 fputc ('\n', asm_out_file
);
1397 output_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_offset
);
1398 fputc ('\n', asm_out_file
);
1400 else if (cfi
->dw_cfi_opc
== DW_CFA_restore
)
1402 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
1404 | (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
& 0x3f));
1406 fprintf (asm_out_file
, "\t%s DW_CFA_restore, column 0x%x",
1407 ASM_COMMENT_START
, cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1409 fputc ('\n', asm_out_file
);
1413 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, cfi
->dw_cfi_opc
);
1415 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
,
1416 dwarf_cfi_name (cfi
->dw_cfi_opc
));
1418 fputc ('\n', asm_out_file
);
1419 switch (cfi
->dw_cfi_opc
)
1421 case DW_CFA_set_loc
:
1422 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, cfi
->dw_cfi_oprnd1
.dw_cfi_addr
);
1423 fputc ('\n', asm_out_file
);
1425 case DW_CFA_advance_loc1
:
1426 /* TODO: not currently implemented. */
1429 case DW_CFA_advance_loc2
:
1430 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
,
1431 cfi
->dw_cfi_oprnd1
.dw_cfi_addr
,
1432 fde
->dw_fde_current_label
);
1433 fputc ('\n', asm_out_file
);
1434 fde
->dw_fde_current_label
= cfi
->dw_cfi_oprnd1
.dw_cfi_addr
;
1436 case DW_CFA_advance_loc4
:
1437 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
,
1438 cfi
->dw_cfi_oprnd1
.dw_cfi_addr
,
1439 fde
->dw_fde_current_label
);
1440 fputc ('\n', asm_out_file
);
1441 fde
->dw_fde_current_label
= cfi
->dw_cfi_oprnd1
.dw_cfi_addr
;
1443 #ifdef MIPS_DEBUGGING_INFO
1444 case DW_CFA_MIPS_advance_loc8
:
1445 /* TODO: not currently implemented. */
1449 case DW_CFA_offset_extended
:
1450 case DW_CFA_def_cfa
:
1451 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1452 fputc ('\n', asm_out_file
);
1453 output_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_offset
);
1454 fputc ('\n', asm_out_file
);
1456 case DW_CFA_restore_extended
:
1457 case DW_CFA_undefined
:
1458 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1459 fputc ('\n', asm_out_file
);
1461 case DW_CFA_same_value
:
1462 case DW_CFA_def_cfa_register
:
1463 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1464 fputc ('\n', asm_out_file
);
1466 case DW_CFA_register
:
1467 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_reg_num
);
1468 fputc ('\n', asm_out_file
);
1469 output_uleb128 (cfi
->dw_cfi_oprnd2
.dw_cfi_reg_num
);
1470 fputc ('\n', asm_out_file
);
1472 case DW_CFA_def_cfa_offset
:
1473 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_offset
);
1474 fputc ('\n', asm_out_file
);
1476 case DW_CFA_GNU_window_save
:
1478 case DW_CFA_GNU_args_size
:
1479 output_uleb128 (cfi
->dw_cfi_oprnd1
.dw_cfi_offset
);
1480 fputc ('\n', asm_out_file
);
1488 #if !defined (EH_FRAME_SECTION)
1489 #if defined (EH_FRAME_SECTION_ASM_OP)
1490 #define EH_FRAME_SECTION() eh_frame_section();
1492 #if defined (ASM_OUTPUT_SECTION_NAME)
1493 #define EH_FRAME_SECTION() \
1495 named_section (NULL_TREE, ".eh_frame", 0); \
1501 /* Output the call frame information used to used to record information
1502 that relates to calculating the frame pointer, and records the
1503 location of saved registers. */
1506 output_call_frame_info (for_eh
)
1509 register unsigned long i
, j
;
1510 register dw_fde_ref fde
;
1511 register unsigned long fde_size
;
1512 register dw_cfi_ref cfi
;
1513 unsigned long fde_pad
;
1514 char l1
[20], l2
[20];
1516 /* Do we want to include a pointer to the exception table? */
1517 int eh_ptr
= for_eh
&& exception_table_p ();
1519 fputc ('\n', asm_out_file
);
1521 /* We're going to be generating comments, so turn on app. */
1527 #ifdef EH_FRAME_SECTION
1528 EH_FRAME_SECTION ();
1530 tree label
= get_file_function_name ('F');
1533 ASM_GLOBALIZE_LABEL (asm_out_file
, IDENTIFIER_POINTER (label
));
1534 ASM_OUTPUT_LABEL (asm_out_file
, IDENTIFIER_POINTER (label
));
1536 assemble_label ("__FRAME_BEGIN__");
1539 ASM_OUTPUT_SECTION (asm_out_file
, FRAME_SECTION
);
1541 /* Output the CIE. */
1542 ASM_GENERATE_INTERNAL_LABEL (l1
, CIE_AFTER_SIZE_LABEL
, for_eh
);
1543 ASM_GENERATE_INTERNAL_LABEL (l2
, CIE_END_LABEL
, for_eh
);
1545 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, l2
, l1
);
1547 ASM_OUTPUT_DWARF_DELTA (asm_out_file
, l2
, l1
);
1549 fprintf (asm_out_file
, "\t%s Length of Common Information Entry",
1552 fputc ('\n', asm_out_file
);
1553 ASM_OUTPUT_LABEL (asm_out_file
, l1
);
1556 /* Now that the CIE pointer is PC-relative for EH,
1557 use 0 to identify the CIE. */
1558 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
1560 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, DW_CIE_ID
);
1563 fprintf (asm_out_file
, "\t%s CIE Identifier Tag", ASM_COMMENT_START
);
1565 fputc ('\n', asm_out_file
);
1566 if (! for_eh
&& DWARF_OFFSET_SIZE
== 8)
1568 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, DW_CIE_ID
);
1569 fputc ('\n', asm_out_file
);
1572 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_CIE_VERSION
);
1574 fprintf (asm_out_file
, "\t%s CIE Version", ASM_COMMENT_START
);
1576 fputc ('\n', asm_out_file
);
1579 /* The CIE contains a pointer to the exception region info for the
1580 frame. Make the augmentation string three bytes (including the
1581 trailing null) so the pointer is 4-byte aligned. The Solaris ld
1582 can't handle unaligned relocs. */
1585 ASM_OUTPUT_DWARF_STRING (asm_out_file
, "eh");
1586 fprintf (asm_out_file
, "\t%s CIE Augmentation", ASM_COMMENT_START
);
1590 ASM_OUTPUT_ASCII (asm_out_file
, "eh", 3);
1592 fputc ('\n', asm_out_file
);
1594 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, "__EXCEPTION_TABLE__");
1596 fprintf (asm_out_file
, "\t%s pointer to exception region info",
1601 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
1603 fprintf (asm_out_file
, "\t%s CIE Augmentation (none)",
1607 fputc ('\n', asm_out_file
);
1610 fprintf (asm_out_file
, " (CIE Code Alignment Factor)");
1612 fputc ('\n', asm_out_file
);
1613 output_sleb128 (DWARF_CIE_DATA_ALIGNMENT
);
1615 fprintf (asm_out_file
, " (CIE Data Alignment Factor)");
1617 fputc ('\n', asm_out_file
);
1618 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DWARF_FRAME_RETURN_COLUMN
);
1620 fprintf (asm_out_file
, "\t%s CIE RA Column", ASM_COMMENT_START
);
1622 fputc ('\n', asm_out_file
);
1624 for (cfi
= cie_cfi_head
; cfi
!= NULL
; cfi
= cfi
->dw_cfi_next
)
1625 output_cfi (cfi
, NULL
);
1627 /* Pad the CIE out to an address sized boundary. */
1628 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (PTR_SIZE
));
1629 ASM_OUTPUT_LABEL (asm_out_file
, l2
);
1631 /* Loop through all of the FDE's. */
1632 for (i
= 0; i
< fde_table_in_use
; ++i
)
1634 fde
= &fde_table
[i
];
1636 ASM_GENERATE_INTERNAL_LABEL (l1
, FDE_AFTER_SIZE_LABEL
, for_eh
+ i
*2);
1637 ASM_GENERATE_INTERNAL_LABEL (l2
, FDE_END_LABEL
, for_eh
+ i
*2);
1639 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file
, l2
, l1
);
1641 ASM_OUTPUT_DWARF_DELTA (asm_out_file
, l2
, l1
);
1643 fprintf (asm_out_file
, "\t%s FDE Length", ASM_COMMENT_START
);
1644 fputc ('\n', asm_out_file
);
1645 ASM_OUTPUT_LABEL (asm_out_file
, l1
);
1648 ASM_OUTPUT_DWARF_DELTA (asm_out_file
, l1
, "__FRAME_BEGIN__");
1650 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, stripattributes (FRAME_SECTION
));
1652 fprintf (asm_out_file
, "\t%s FDE CIE offset", ASM_COMMENT_START
);
1654 fputc ('\n', asm_out_file
);
1655 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, fde
->dw_fde_begin
);
1657 fprintf (asm_out_file
, "\t%s FDE initial location", ASM_COMMENT_START
);
1659 fputc ('\n', asm_out_file
);
1660 ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file
,
1661 fde
->dw_fde_end
, fde
->dw_fde_begin
);
1663 fprintf (asm_out_file
, "\t%s FDE address range", ASM_COMMENT_START
);
1665 fputc ('\n', asm_out_file
);
1667 /* Loop through the Call Frame Instructions associated with
1669 fde
->dw_fde_current_label
= fde
->dw_fde_begin
;
1670 for (cfi
= fde
->dw_fde_cfi
; cfi
!= NULL
; cfi
= cfi
->dw_cfi_next
)
1671 output_cfi (cfi
, fde
);
1673 /* Pad the FDE out to an address sized boundary. */
1674 ASM_OUTPUT_ALIGN (asm_out_file
, floor_log2 (PTR_SIZE
));
1675 ASM_OUTPUT_LABEL (asm_out_file
, l2
);
1677 #ifndef EH_FRAME_SECTION
1680 /* Emit terminating zero for table. */
1681 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 0);
1682 fputc ('\n', asm_out_file
);
1685 #ifdef MIPS_DEBUGGING_INFO
1686 /* Work around Irix 6 assembler bug whereby labels at the end of a section
1687 get a value of 0. Putting .align 0 after the label fixes it. */
1688 ASM_OUTPUT_ALIGN (asm_out_file
, 0);
1691 /* Turn off app to make assembly quicker. */
1696 /* Output a marker (i.e. a label) for the beginning of a function, before
1700 dwarf2out_begin_prologue ()
1702 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1703 register dw_fde_ref fde
;
1705 ++current_funcdef_number
;
1707 function_section (current_function_decl
);
1708 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_BEGIN_LABEL
,
1709 current_funcdef_number
);
1710 ASM_OUTPUT_LABEL (asm_out_file
, label
);
1712 /* Expand the fde table if necessary. */
1713 if (fde_table_in_use
== fde_table_allocated
)
1715 fde_table_allocated
+= FDE_TABLE_INCREMENT
;
1717 = (dw_fde_ref
) xrealloc (fde_table
,
1718 fde_table_allocated
* sizeof (dw_fde_node
));
1721 /* Record the FDE associated with this function. */
1722 current_funcdef_fde
= fde_table_in_use
;
1724 /* Add the new FDE at the end of the fde_table. */
1725 fde
= &fde_table
[fde_table_in_use
++];
1726 fde
->dw_fde_begin
= xstrdup (label
);
1727 fde
->dw_fde_current_label
= NULL
;
1728 fde
->dw_fde_end
= NULL
;
1729 fde
->dw_fde_cfi
= NULL
;
1734 /* Output a marker (i.e. a label) for the absolute end of the generated code
1735 for a function definition. This gets called *after* the epilogue code has
1739 dwarf2out_end_epilogue ()
1742 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
1744 /* Output a label to mark the endpoint of the code generated for this
1746 ASM_GENERATE_INTERNAL_LABEL (label
, FUNC_END_LABEL
, current_funcdef_number
);
1747 ASM_OUTPUT_LABEL (asm_out_file
, label
);
1748 fde
= &fde_table
[fde_table_in_use
- 1];
1749 fde
->dw_fde_end
= xstrdup (label
);
1753 dwarf2out_frame_init ()
1755 /* Allocate the initial hunk of the fde_table. */
1757 = (dw_fde_ref
) xmalloc (FDE_TABLE_INCREMENT
* sizeof (dw_fde_node
));
1758 bzero ((char *) fde_table
, FDE_TABLE_INCREMENT
* sizeof (dw_fde_node
));
1759 fde_table_allocated
= FDE_TABLE_INCREMENT
;
1760 fde_table_in_use
= 0;
1762 /* Generate the CFA instructions common to all FDE's. Do it now for the
1763 sake of lookup_cfa. */
1765 #ifdef DWARF2_UNWIND_INFO
1766 /* On entry, the Canonical Frame Address is at SP. */
1767 dwarf2out_def_cfa (NULL
, STACK_POINTER_REGNUM
, INCOMING_FRAME_SP_OFFSET
);
1768 initial_return_save (INCOMING_RETURN_ADDR_RTX
);
1773 dwarf2out_frame_finish ()
1775 /* Output call frame information. */
1776 #ifdef MIPS_DEBUGGING_INFO
1777 if (write_symbols
== DWARF2_DEBUG
)
1778 output_call_frame_info (0);
1779 if (flag_exceptions
&& ! exceptions_via_longjmp
)
1780 output_call_frame_info (1);
1782 if (write_symbols
== DWARF2_DEBUG
1783 || (flag_exceptions
&& ! exceptions_via_longjmp
))
1784 output_call_frame_info (1);
1788 #endif /* .debug_frame support */
1790 /* And now, the support for symbolic debugging information. */
1791 #ifdef DWARF2_DEBUGGING_INFO
1793 extern char *getpwd ();
1795 /* NOTE: In the comments in this file, many references are made to
1796 "Debugging Information Entries". This term is abbreviated as `DIE'
1797 throughout the remainder of this file. */
1799 /* An internal representation of the DWARF output is built, and then
1800 walked to generate the DWARF debugging info. The walk of the internal
1801 representation is done after the entire program has been compiled.
1802 The types below are used to describe the internal representation. */
1804 /* Each DIE may have a series of attribute/value pairs. Values
1805 can take on several forms. The forms that are used in this
1806 implementation are listed below. */
1813 dw_val_class_unsigned_const
,
1814 dw_val_class_long_long
,
1817 dw_val_class_die_ref
,
1818 dw_val_class_fde_ref
,
1819 dw_val_class_lbl_id
,
1820 dw_val_class_section_offset
,
1825 /* Various DIE's use offsets relative to the beginning of the
1826 .debug_info section to refer to each other. */
1828 typedef long int dw_offset
;
1830 /* Define typedefs here to avoid circular dependencies. */
1832 typedef struct die_struct
*dw_die_ref
;
1833 typedef struct dw_attr_struct
*dw_attr_ref
;
1834 typedef struct dw_val_struct
*dw_val_ref
;
1835 typedef struct dw_line_info_struct
*dw_line_info_ref
;
1836 typedef struct dw_separate_line_info_struct
*dw_separate_line_info_ref
;
1837 typedef struct dw_loc_descr_struct
*dw_loc_descr_ref
;
1838 typedef struct pubname_struct
*pubname_ref
;
1839 typedef dw_die_ref
*arange_ref
;
1841 /* Describe a double word constant value. */
1843 typedef struct dw_long_long_struct
1850 /* Describe a floating point constant value. */
1852 typedef struct dw_fp_struct
1859 /* Each entry in the line_info_table maintains the file and
1860 line nuber associated with the label generated for that
1861 entry. The label gives the PC value associated with
1862 the line number entry. */
1864 typedef struct dw_line_info_struct
1866 unsigned long dw_file_num
;
1867 unsigned long dw_line_num
;
1871 /* Line information for functions in separate sections; each one gets its
1873 typedef struct dw_separate_line_info_struct
1875 unsigned long dw_file_num
;
1876 unsigned long dw_line_num
;
1877 unsigned long function
;
1879 dw_separate_line_info_entry
;
1881 /* The dw_val_node describes an attibute's value, as it is
1882 represented internally. */
1884 typedef struct dw_val_struct
1886 dw_val_class val_class
;
1890 dw_loc_descr_ref val_loc
;
1892 long unsigned val_unsigned
;
1893 dw_long_long_const val_long_long
;
1894 dw_float_const val_float
;
1895 dw_die_ref val_die_ref
;
1896 unsigned val_fde_index
;
1900 unsigned char val_flag
;
1906 /* Locations in memory are described using a sequence of stack machine
1909 typedef struct dw_loc_descr_struct
1911 dw_loc_descr_ref dw_loc_next
;
1912 enum dwarf_location_atom dw_loc_opc
;
1913 dw_val_node dw_loc_oprnd1
;
1914 dw_val_node dw_loc_oprnd2
;
1918 /* Each DIE attribute has a field specifying the attribute kind,
1919 a link to the next attribute in the chain, and an attribute value.
1920 Attributes are typically linked below the DIE they modify. */
1922 typedef struct dw_attr_struct
1924 enum dwarf_attribute dw_attr
;
1925 dw_attr_ref dw_attr_next
;
1926 dw_val_node dw_attr_val
;
1930 /* The Debugging Information Entry (DIE) structure */
1932 typedef struct die_struct
1934 enum dwarf_tag die_tag
;
1935 dw_attr_ref die_attr
;
1936 dw_attr_ref die_attr_last
;
1937 dw_die_ref die_parent
;
1938 dw_die_ref die_child
;
1939 dw_die_ref die_child_last
;
1941 dw_offset die_offset
;
1942 unsigned long die_abbrev
;
1946 /* The pubname structure */
1948 typedef struct pubname_struct
1955 /* The limbo die list structure. */
1956 typedef struct limbo_die_struct
1959 struct limbo_die_struct
*next
;
1963 /* How to start an assembler comment. */
1964 #ifndef ASM_COMMENT_START
1965 #define ASM_COMMENT_START ";#"
1968 /* Define a macro which returns non-zero for a TYPE_DECL which was
1969 implicitly generated for a tagged type.
1971 Note that unlike the gcc front end (which generates a NULL named
1972 TYPE_DECL node for each complete tagged type, each array type, and
1973 each function type node created) the g++ front end generates a
1974 _named_ TYPE_DECL node for each tagged type node created.
1975 These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
1976 generate a DW_TAG_typedef DIE for them. */
1978 #define TYPE_DECL_IS_STUB(decl) \
1979 (DECL_NAME (decl) == NULL_TREE \
1980 || (DECL_ARTIFICIAL (decl) \
1981 && is_tagged_type (TREE_TYPE (decl)) \
1982 && ((decl == TYPE_STUB_DECL (TREE_TYPE (decl))) \
1983 /* This is necessary for stub decls that \
1984 appear in nested inline functions. */ \
1985 || (DECL_ABSTRACT_ORIGIN (decl) != NULL_TREE \
1986 && (decl_ultimate_origin (decl) \
1987 == TYPE_STUB_DECL (TREE_TYPE (decl)))))))
1989 /* Information concerning the compilation unit's programming
1990 language, and compiler version. */
1992 extern int flag_traditional
;
1993 extern char *version_string
;
1994 extern char *language_string
;
1996 /* Fixed size portion of the DWARF compilation unit header. */
1997 #define DWARF_COMPILE_UNIT_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 3)
1999 /* Fixed size portion of debugging line information prolog. */
2000 #define DWARF_LINE_PROLOG_HEADER_SIZE 5
2002 /* Fixed size portion of public names info. */
2003 #define DWARF_PUBNAMES_HEADER_SIZE (2 * DWARF_OFFSET_SIZE + 2)
2005 /* Fixed size portion of the address range info. */
2006 #define DWARF_ARANGES_HEADER_SIZE \
2007 (DWARF_ROUND (2 * DWARF_OFFSET_SIZE + 4, PTR_SIZE * 2) - DWARF_OFFSET_SIZE)
2009 /* Define the architecture-dependent minimum instruction length (in bytes).
2010 In this implementation of DWARF, this field is used for information
2011 purposes only. Since GCC generates assembly language, we have
2012 no a priori knowledge of how many instruction bytes are generated
2013 for each source line, and therefore can use only the DW_LNE_set_address
2014 and DW_LNS_fixed_advance_pc line information commands. */
2016 #ifndef DWARF_LINE_MIN_INSTR_LENGTH
2017 #define DWARF_LINE_MIN_INSTR_LENGTH 4
2020 /* Minimum line offset in a special line info. opcode.
2021 This value was chosen to give a reasonable range of values. */
2022 #define DWARF_LINE_BASE -10
2024 /* First special line opcde - leave room for the standard opcodes. */
2025 #define DWARF_LINE_OPCODE_BASE 10
2027 /* Range of line offsets in a special line info. opcode. */
2028 #define DWARF_LINE_RANGE (254-DWARF_LINE_OPCODE_BASE+1)
2030 /* Flag that indicates the initial value of the is_stmt_start flag.
2031 In the present implementation, we do not mark any lines as
2032 the beginning of a source statement, because that information
2033 is not made available by the GCC front-end. */
2034 #define DWARF_LINE_DEFAULT_IS_STMT_START 1
2036 /* This location is used by calc_die_sizes() to keep track
2037 the offset of each DIE within the .debug_info section. */
2038 static unsigned long next_die_offset
;
2040 /* Record the root of the DIE's built for the current compilation unit. */
2041 static dw_die_ref comp_unit_die
;
2043 /* A list of DIEs with a NULL parent waiting to be relocated. */
2044 static limbo_die_node
*limbo_die_list
= 0;
2046 /* Pointer to an array of filenames referenced by this compilation unit. */
2047 static char **file_table
;
2049 /* Total number of entries in the table (i.e. array) pointed to by
2050 `file_table'. This is the *total* and includes both used and unused
2052 static unsigned file_table_allocated
;
2054 /* Number of entries in the file_table which are actually in use. */
2055 static unsigned file_table_in_use
;
2057 /* Size (in elements) of increments by which we may expand the filename
2059 #define FILE_TABLE_INCREMENT 64
2061 /* Local pointer to the name of the main input file. Initialized in
2063 static char *primary_filename
;
2065 /* For Dwarf output, we must assign lexical-blocks id numbers in the order in
2066 which their beginnings are encountered. We output Dwarf debugging info
2067 that refers to the beginnings and ends of the ranges of code for each
2068 lexical block. The labels themselves are generated in final.c, which
2069 assigns numbers to the blocks in the same way. */
2070 static unsigned next_block_number
= 2;
2072 /* A pointer to the base of a table of references to DIE's that describe
2073 declarations. The table is indexed by DECL_UID() which is a unique
2074 number, indentifying each decl. */
2075 static dw_die_ref
*decl_die_table
;
2077 /* Number of elements currently allocated for the decl_die_table. */
2078 static unsigned decl_die_table_allocated
;
2080 /* Number of elements in decl_die_table currently in use. */
2081 static unsigned decl_die_table_in_use
;
2083 /* Size (in elements) of increments by which we may expand the
2085 #define DECL_DIE_TABLE_INCREMENT 256
2087 /* A pointer to the base of a table of references to declaration
2088 scopes. This table is a display which tracks the nesting
2089 of declaration scopes at the current scope and containing
2090 scopes. This table is used to find the proper place to
2091 define type declaration DIE's. */
2092 static tree
*decl_scope_table
;
2094 /* Number of elements currently allocated for the decl_scope_table. */
2095 static unsigned decl_scope_table_allocated
;
2097 /* Current level of nesting of declataion scopes. */
2098 static unsigned decl_scope_depth
;
2100 /* Size (in elements) of increments by which we may expand the
2101 decl_scope_table. */
2102 #define DECL_SCOPE_TABLE_INCREMENT 64
2104 /* A pointer to the base of a list of references to DIE's that
2105 are uniquely identified by their tag, presence/absence of
2106 children DIE's, and list of attribute/value pairs. */
2107 static dw_die_ref
*abbrev_die_table
;
2109 /* Number of elements currently allocated for abbrev_die_table. */
2110 static unsigned abbrev_die_table_allocated
;
2112 /* Number of elements in type_die_table currently in use. */
2113 static unsigned abbrev_die_table_in_use
;
2115 /* Size (in elements) of increments by which we may expand the
2116 abbrev_die_table. */
2117 #define ABBREV_DIE_TABLE_INCREMENT 256
2119 /* A pointer to the base of a table that contains line information
2120 for each source code line in .text in the compilation unit. */
2121 static dw_line_info_ref line_info_table
;
2123 /* Number of elements currently allocated for line_info_table. */
2124 static unsigned line_info_table_allocated
;
2126 /* Number of elements in separate_line_info_table currently in use. */
2127 static unsigned separate_line_info_table_in_use
;
2129 /* A pointer to the base of a table that contains line information
2130 for each source code line outside of .text in the compilation unit. */
2131 static dw_separate_line_info_ref separate_line_info_table
;
2133 /* Number of elements currently allocated for separate_line_info_table. */
2134 static unsigned separate_line_info_table_allocated
;
2136 /* Number of elements in line_info_table currently in use. */
2137 static unsigned line_info_table_in_use
;
2139 /* Size (in elements) of increments by which we may expand the
2141 #define LINE_INFO_TABLE_INCREMENT 1024
2143 /* A pointer to the base of a table that contains a list of publicly
2144 accessible names. */
2145 static pubname_ref pubname_table
;
2147 /* Number of elements currently allocated for pubname_table. */
2148 static unsigned pubname_table_allocated
;
2150 /* Number of elements in pubname_table currently in use. */
2151 static unsigned pubname_table_in_use
;
2153 /* Size (in elements) of increments by which we may expand the
2155 #define PUBNAME_TABLE_INCREMENT 64
2157 /* A pointer to the base of a table that contains a list of publicly
2158 accessible names. */
2159 static arange_ref arange_table
;
2161 /* Number of elements currently allocated for arange_table. */
2162 static unsigned arange_table_allocated
;
2164 /* Number of elements in arange_table currently in use. */
2165 static unsigned arange_table_in_use
;
2167 /* Size (in elements) of increments by which we may expand the
2169 #define ARANGE_TABLE_INCREMENT 64
2171 /* A pointer to the base of a list of pending types which we haven't
2172 generated DIEs for yet, but which we will have to come back to
2175 static tree
*pending_types_list
;
2177 /* Number of elements currently allocated for the pending_types_list. */
2178 static unsigned pending_types_allocated
;
2180 /* Number of elements of pending_types_list currently in use. */
2181 static unsigned pending_types
;
2183 /* Size (in elements) of increments by which we may expand the pending
2184 types list. Actually, a single hunk of space of this size should
2185 be enough for most typical programs. */
2186 #define PENDING_TYPES_INCREMENT 64
2188 /* Record whether the function being analyzed contains inlined functions. */
2189 static int current_function_has_inlines
;
2190 static int comp_unit_has_inlines
;
2192 /* A pointer to the ..._DECL node which we have most recently been working
2193 on. We keep this around just in case something about it looks screwy and
2194 we want to tell the user what the source coordinates for the actual
2196 static tree dwarf_last_decl
;
2198 /* Forward declarations for functions defined in this file. */
2200 static void addr_const_to_string
PROTO((char *, rtx
));
2201 static char *addr_to_string
PROTO((rtx
));
2202 static int is_pseudo_reg
PROTO((rtx
));
2203 static tree type_main_variant
PROTO((tree
));
2204 static int is_tagged_type
PROTO((tree
));
2205 static char *dwarf_tag_name
PROTO((unsigned));
2206 static char *dwarf_attr_name
PROTO((unsigned));
2207 static char *dwarf_form_name
PROTO((unsigned));
2208 static char *dwarf_stack_op_name
PROTO((unsigned));
2209 static char *dwarf_type_encoding_name
PROTO((unsigned));
2210 static tree decl_ultimate_origin
PROTO((tree
));
2211 static tree block_ultimate_origin
PROTO((tree
));
2212 static tree decl_class_context
PROTO((tree
));
2213 static void add_dwarf_attr
PROTO((dw_die_ref
, dw_attr_ref
));
2214 static void add_AT_flag
PROTO((dw_die_ref
,
2215 enum dwarf_attribute
,
2217 static void add_AT_int
PROTO((dw_die_ref
,
2218 enum dwarf_attribute
, long));
2219 static void add_AT_unsigned
PROTO((dw_die_ref
,
2220 enum dwarf_attribute
,
2222 static void add_AT_long_long
PROTO((dw_die_ref
,
2223 enum dwarf_attribute
,
2224 unsigned long, unsigned long));
2225 static void add_AT_float
PROTO((dw_die_ref
,
2226 enum dwarf_attribute
,
2228 static void add_AT_string
PROTO((dw_die_ref
,
2229 enum dwarf_attribute
, char *));
2230 static void add_AT_die_ref
PROTO((dw_die_ref
,
2231 enum dwarf_attribute
,
2233 static void add_AT_fde_ref
PROTO((dw_die_ref
,
2234 enum dwarf_attribute
,
2236 static void add_AT_loc
PROTO((dw_die_ref
,
2237 enum dwarf_attribute
,
2239 static void add_AT_addr
PROTO((dw_die_ref
,
2240 enum dwarf_attribute
, char *));
2241 static void add_AT_lbl_id
PROTO((dw_die_ref
,
2242 enum dwarf_attribute
, char *));
2243 static void add_AT_setion_offset
PROTO((dw_die_ref
,
2244 enum dwarf_attribute
, char *));
2245 static int is_extern_subr_die
PROTO((dw_die_ref
));
2246 static dw_attr_ref get_AT
PROTO((dw_die_ref
,
2247 enum dwarf_attribute
));
2248 static char *get_AT_low_pc
PROTO((dw_die_ref
));
2249 static char *get_AT_hi_pc
PROTO((dw_die_ref
));
2250 static char *get_AT_string
PROTO((dw_die_ref
,
2251 enum dwarf_attribute
));
2252 static int get_AT_flag
PROTO((dw_die_ref
,
2253 enum dwarf_attribute
));
2254 static unsigned get_AT_unsigned
PROTO((dw_die_ref
,
2255 enum dwarf_attribute
));
2256 static int is_c_family
PROTO((void));
2257 static int is_fortran
PROTO((void));
2258 static void remove_AT
PROTO((dw_die_ref
,
2259 enum dwarf_attribute
));
2260 static void remove_children
PROTO((dw_die_ref
));
2261 static void add_child_die
PROTO((dw_die_ref
, dw_die_ref
));
2262 static dw_die_ref new_die
PROTO((enum dwarf_tag
, dw_die_ref
));
2263 static dw_die_ref lookup_type_die
PROTO((tree
));
2264 static void equate_type_number_to_die
PROTO((tree
, dw_die_ref
));
2265 static dw_die_ref lookup_decl_die
PROTO((tree
));
2266 static void equate_decl_number_to_die
PROTO((tree
, dw_die_ref
));
2267 static dw_loc_descr_ref new_loc_descr
PROTO((enum dwarf_location_atom
,
2268 unsigned long, unsigned long));
2269 static void add_loc_descr
PROTO((dw_loc_descr_ref
*,
2271 static void print_spaces
PROTO((FILE *));
2272 static void print_die
PROTO((dw_die_ref
, FILE *));
2273 static void print_dwarf_line_table
PROTO((FILE *));
2274 static void add_sibling_atttributes
PROTO((dw_die_ref
));
2275 static void build_abbrev_table
PROTO((dw_die_ref
));
2276 static unsigned long size_of_string
PROTO((char *));
2277 static unsigned long size_of_loc_descr
PROTO((dw_loc_descr_ref
));
2278 static unsigned long size_of_locs
PROTO((dw_loc_descr_ref
));
2279 static int constant_size
PROTO((long unsigned));
2280 static unsigned long size_of_die
PROTO((dw_die_ref
));
2281 static void calc_die_sizes
PROTO((dw_die_ref
));
2282 static unsigned long size_of_prolog
PROTO((void));
2283 static unsigned long size_of_line_info
PROTO((void));
2284 static unsigned long size_of_pubnames
PROTO((void));
2285 static unsigned long size_of_aranges
PROTO((void));
2286 static enum dwarf_form value_format
PROTO((dw_val_ref
));
2287 static void output_value_format
PROTO((dw_val_ref
));
2288 static void output_abbrev_section
PROTO((void));
2289 static void output_loc_operands
PROTO((dw_loc_descr_ref
));
2290 static unsigned long sibling_offset
PROTO((dw_die_ref
));
2291 static void output_die
PROTO((dw_die_ref
));
2292 static void output_compilation_unit_header
PROTO((void));
2293 static char *dwarf2_name
PROTO((tree
, int));
2294 static void add_pubname
PROTO((tree
, dw_die_ref
));
2295 static void output_pubnames
PROTO((void));
2296 static void add_arrange
PROTO((tree
, dw_die_ref
));
2297 static void output_arranges
PROTO((void));
2298 static void output_line_info
PROTO((void));
2299 static int is_body_block
PROTO((tree
));
2300 static dw_die_ref base_type_die
PROTO((tree
));
2301 static tree root_type
PROTO((tree
));
2302 static int is_base_type
PROTO((tree
));
2303 static dw_die_ref modified_type_die
PROTO((tree
, int, int, dw_die_ref
));
2304 static int type_is_enum
PROTO((tree
));
2305 static dw_loc_descr_ref reg_loc_descriptor
PROTO((rtx
));
2306 static dw_loc_descr_ref based_loc_descr
PROTO((unsigned, long));
2307 static int is_based_loc
PROTO((rtx
));
2308 static dw_loc_descr_ref mem_loc_descriptor
PROTO((rtx
));
2309 static dw_loc_descr_ref concat_loc_descriptor
PROTO((rtx
, rtx
));
2310 static dw_loc_descr_ref loc_descriptor
PROTO((rtx
));
2311 static unsigned ceiling
PROTO((unsigned, unsigned));
2312 static tree field_type
PROTO((tree
));
2313 static unsigned simple_type_align_in_bits
PROTO((tree
));
2314 static unsigned simple_type_size_in_bits
PROTO((tree
));
2315 static unsigned field_byte_offset
PROTO((tree
));
2316 static void add_AT_location_description
PROTO((dw_die_ref
,
2317 enum dwarf_attribute
, rtx
));
2318 static void add_data_member_location_attribute
PROTO((dw_die_ref
, tree
));
2319 static void add_const_value_attribute
PROTO((dw_die_ref
, rtx
));
2320 static void add_location_or_const_value_attribute
PROTO((dw_die_ref
, tree
));
2321 static void add_name_attribute
PROTO((dw_die_ref
, char *));
2322 static void add_bound_info
PROTO((dw_die_ref
,
2323 enum dwarf_attribute
, tree
));
2324 static void add_subscript_info
PROTO((dw_die_ref
, tree
));
2325 static void add_byte_size_attribute
PROTO((dw_die_ref
, tree
));
2326 static void add_bit_offset_attribute
PROTO((dw_die_ref
, tree
));
2327 static void add_bit_size_attribute
PROTO((dw_die_ref
, tree
));
2328 static void add_prototyped_attribute
PROTO((dw_die_ref
, tree
));
2329 static void add_abstract_origin_attribute
PROTO((dw_die_ref
, tree
));
2330 static void add_pure_or_virtual_attribute
PROTO((dw_die_ref
, tree
));
2331 static void add_src_coords_attributes
PROTO((dw_die_ref
, tree
));
2332 static void ad_name_and_src_coords_attributes
PROTO((dw_die_ref
, tree
));
2333 static void push_decl_scope
PROTO((tree
));
2334 static dw_die_ref scope_die_for
PROTO((tree
, dw_die_ref
));
2335 static void pop_decl_scope
PROTO((void));
2336 static void add_type_attribute
PROTO((dw_die_ref
, tree
, int, int,
2338 static char *type_tag
PROTO((tree
));
2339 static tree member_declared_type
PROTO((tree
));
2340 static char *decl_start_label
PROTO((tree
));
2341 static void gen_arrqay_type_die
PROTO((tree
, dw_die_ref
));
2342 static void gen_set_type_die
PROTO((tree
, dw_die_ref
));
2343 static void gen_entry_point_die
PROTO((tree
, dw_die_ref
));
2344 static void pend_type
PROTO((tree
));
2345 static void output_pending_types_for_scope
PROTO((dw_die_ref
));
2346 static void gen_inlined_enumeration_type_die
PROTO((tree
, dw_die_ref
));
2347 static void gen_inlined_structure_type_die
PROTO((tree
, dw_die_ref
));
2348 static void gen_inlined_union_type_die
PROTO((tree
, dw_die_ref
));
2349 static void gen_enumeration_type_die
PROTO((tree
, dw_die_ref
));
2350 static dw_die_ref gen_formal_parameter_die
PROTO((tree
, dw_die_ref
));
2351 static void gen_unspecified_parameters_die
PROTO((tree
, dw_die_ref
));
2352 static void gen_formal_types_die
PROTO((tree
, dw_die_ref
));
2353 static void gen_subprogram_die
PROTO((tree
, dw_die_ref
));
2354 static void gen_variable_die
PROTO((tree
, dw_die_ref
));
2355 static void gen_label_die
PROTO((tree
, dw_die_ref
));
2356 static void gen_lexical_block_die
PROTO((tree
, dw_die_ref
, int));
2357 static void gen_inlined_subprogram_die
PROTO((tree
, dw_die_ref
, int));
2358 static void gen_field_die
PROTO((tree
, dw_die_ref
));
2359 static void gen_ptr_to_mbr_type_die
PROTO((tree
, dw_die_ref
));
2360 static void gen_compile_unit_die
PROTO((char *));
2361 static void gen_string_type_die
PROTO((tree
, dw_die_ref
));
2362 static void gen_inheritance_die
PROTO((tree
, dw_die_ref
));
2363 static void gen_member_die
PROTO((tree
, dw_die_ref
));
2364 static void gen_struct_or_union_type_die
PROTO((tree
, dw_die_ref
));
2365 static void gen_subroutine_type_die
PROTO((tree
, dw_die_ref
));
2366 static void gen_typedef_die
PROTO((tree
, dw_die_ref
));
2367 static void gen_type_die
PROTO((tree
, dw_die_ref
));
2368 static void gen_tagged_type_instantiation_die
PROTO((tree
, dw_die_ref
));
2369 static void gen_block_die
PROTO((tree
, dw_die_ref
, int));
2370 static void decls_for_scope
PROTO((tree
, dw_die_ref
, int));
2371 static int is_redundant_typedef
PROTO((tree
));
2372 static void gen_decl_die
PROTO((tree
, dw_die_ref
));
2373 static unsigned lookup_filename
PROTO((char *));
2375 /* Section names used to hold DWARF debugging information. */
2376 #ifndef DEBUG_INFO_SECTION
2377 #define DEBUG_INFO_SECTION ".debug_info"
2379 #ifndef ABBREV_SECTION
2380 #define ABBREV_SECTION ".debug_abbrev"
2382 #ifndef ARANGES_SECTION
2383 #define ARANGES_SECTION ".debug_aranges"
2385 #ifndef DW_MACINFO_SECTION
2386 #define DW_MACINFO_SECTION ".debug_macinfo"
2388 #ifndef DEBUG_LINE_SECTION
2389 #define DEBUG_LINE_SECTION ".debug_line"
2392 #define LOC_SECTION ".debug_loc"
2394 #ifndef PUBNAMES_SECTION
2395 #define PUBNAMES_SECTION ".debug_pubnames"
2398 #define STR_SECTION ".debug_str"
2401 /* Standerd ELF section names for compiled code and data. */
2402 #ifndef TEXT_SECTION
2403 #define TEXT_SECTION ".text"
2405 #ifndef DATA_SECTION
2406 #define DATA_SECTION ".data"
2409 #define BSS_SECTION ".bss"
2413 /* Definitions of defaults for formats and names of various special
2414 (artificial) labels which may be generated within this file (when the -g
2415 options is used and DWARF_DEBUGGING_INFO is in effect.
2416 If necessary, these may be overridden from within the tm.h file, but
2417 typically, overriding these defaults is unnecessary. */
2419 static char text_end_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
2421 #ifndef TEXT_END_LABEL
2422 #define TEXT_END_LABEL "Letext"
2424 #ifndef DATA_END_LABEL
2425 #define DATA_END_LABEL "Ledata"
2427 #ifndef BSS_END_LABEL
2428 #define BSS_END_LABEL "Lebss"
2430 #ifndef INSN_LABEL_FMT
2431 #define INSN_LABEL_FMT "LI%u_"
2433 #ifndef BLOCK_BEGIN_LABEL
2434 #define BLOCK_BEGIN_LABEL "LBB"
2436 #ifndef BLOCK_END_LABEL
2437 #define BLOCK_END_LABEL "LBE"
2439 #ifndef BODY_BEGIN_LABEL
2440 #define BODY_BEGIN_LABEL "Lbb"
2442 #ifndef BODY_END_LABEL
2443 #define BODY_END_LABEL "Lbe"
2445 #ifndef LINE_CODE_LABEL
2446 #define LINE_CODE_LABEL "LM"
2448 #ifndef SEPARATE_LINE_CODE_LABEL
2449 #define SEPARATE_LINE_CODE_LABEL "LSM"
2452 /* Convert a reference to the assembler name of a C-level name. This
2453 macro has the same effect as ASM_OUTPUT_LABELREF, but copies to
2454 a string rather than writing to a file. */
2455 #ifndef ASM_NAME_TO_STRING
2456 #define ASM_NAME_TO_STRING(STR, NAME) \
2458 if ((NAME)[0] == '*') \
2459 strcpy (STR, NAME+1); \
2461 strcpy (STR, NAME); \
2466 /* Convert an integer constant expression into assembler syntax. Addition
2467 and subtraction are the only arithmetic that may appear in these
2468 expressions. This is an adaptation of output_addr_const in final.c.
2469 Here, the target of the conversion is a string buffer. We can't use
2470 output_addr_const directly, because it writes to a file. */
2473 addr_const_to_string (str
, x
)
2482 switch (GET_CODE (x
))
2492 ASM_NAME_TO_STRING (buf1
, XSTR (x
, 0));
2497 ASM_GENERATE_INTERNAL_LABEL (buf1
, "L", CODE_LABEL_NUMBER (XEXP (x
, 0)));
2498 ASM_NAME_TO_STRING (buf2
, buf1
);
2503 ASM_GENERATE_INTERNAL_LABEL (buf1
, "L", CODE_LABEL_NUMBER (x
));
2504 ASM_NAME_TO_STRING (buf2
, buf1
);
2509 sprintf (buf1
, HOST_WIDE_INT_PRINT_DEC
, INTVAL (x
));
2514 /* This used to output parentheses around the expression, but that does
2515 not work on the 386 (either ATT or BSD assembler). */
2516 addr_const_to_string (buf1
, XEXP (x
, 0));
2521 if (GET_MODE (x
) == VOIDmode
)
2523 /* We can use %d if the number is one word and positive. */
2524 if (CONST_DOUBLE_HIGH (x
))
2525 sprintf (buf1
, HOST_WIDE_INT_PRINT_DOUBLE_HEX
,
2526 CONST_DOUBLE_HIGH (x
), CONST_DOUBLE_LOW (x
));
2527 else if (CONST_DOUBLE_LOW (x
) < 0)
2528 sprintf (buf1
, HOST_WIDE_INT_PRINT_HEX
, CONST_DOUBLE_LOW (x
));
2530 sprintf (buf1
, HOST_WIDE_INT_PRINT_DEC
,
2531 CONST_DOUBLE_LOW (x
));
2535 /* We can't handle floating point constants; PRINT_OPERAND must
2537 output_operand_lossage ("floating constant misused");
2541 /* Some assemblers need integer constants to appear last (eg masm). */
2542 if (GET_CODE (XEXP (x
, 0)) == CONST_INT
)
2544 addr_const_to_string (buf1
, XEXP (x
, 1));
2546 if (INTVAL (XEXP (x
, 0)) >= 0)
2549 addr_const_to_string (buf1
, XEXP (x
, 0));
2554 addr_const_to_string (buf1
, XEXP (x
, 0));
2556 if (INTVAL (XEXP (x
, 1)) >= 0)
2559 addr_const_to_string (buf1
, XEXP (x
, 1));
2565 /* Avoid outputting things like x-x or x+5-x, since some assemblers
2566 can't handle that. */
2567 x
= simplify_subtraction (x
);
2568 if (GET_CODE (x
) != MINUS
)
2571 addr_const_to_string (buf1
, XEXP (x
, 0));
2574 if (GET_CODE (XEXP (x
, 1)) == CONST_INT
2575 && INTVAL (XEXP (x
, 1)) < 0)
2577 strcat (str
, ASM_OPEN_PAREN
);
2578 addr_const_to_string (buf1
, XEXP (x
, 1));
2580 strcat (str
, ASM_CLOSE_PAREN
);
2584 addr_const_to_string (buf1
, XEXP (x
, 1));
2591 addr_const_to_string (buf1
, XEXP (x
, 0));
2596 output_operand_lossage ("invalid expression as operand");
2600 /* Convert an address constant to a string, and return a pointer to
2601 a copy of the result, located on the heap. */
2608 addr_const_to_string (buf
, x
);
2609 return xstrdup (buf
);
2612 /* Test if rtl node points to a psuedo register. */
2618 return (((GET_CODE (rtl
) == REG
) && (REGNO (rtl
) >= FIRST_PSEUDO_REGISTER
))
2619 || ((GET_CODE (rtl
) == SUBREG
)
2620 && (REGNO (XEXP (rtl
, 0)) >= FIRST_PSEUDO_REGISTER
)));
2623 /* Return a reference to a type, with its const and volatile qualifiers
2627 type_main_variant (type
)
2630 type
= TYPE_MAIN_VARIANT (type
);
2632 /* There really should be only one main variant among any group of variants
2633 of a given type (and all of the MAIN_VARIANT values for all members of
2634 the group should point to that one type) but sometimes the C front-end
2635 messes this up for array types, so we work around that bug here. */
2637 if (TREE_CODE (type
) == ARRAY_TYPE
)
2638 while (type
!= TYPE_MAIN_VARIANT (type
))
2639 type
= TYPE_MAIN_VARIANT (type
);
2644 /* Return non-zero if the given type node represents a tagged type. */
2647 is_tagged_type (type
)
2650 register enum tree_code code
= TREE_CODE (type
);
2652 return (code
== RECORD_TYPE
|| code
== UNION_TYPE
2653 || code
== QUAL_UNION_TYPE
|| code
== ENUMERAL_TYPE
);
2656 /* Convert a DIE tag into its string name. */
2659 dwarf_tag_name (tag
)
2660 register unsigned tag
;
2664 case DW_TAG_padding
:
2665 return "DW_TAG_padding";
2666 case DW_TAG_array_type
:
2667 return "DW_TAG_array_type";
2668 case DW_TAG_class_type
:
2669 return "DW_TAG_class_type";
2670 case DW_TAG_entry_point
:
2671 return "DW_TAG_entry_point";
2672 case DW_TAG_enumeration_type
:
2673 return "DW_TAG_enumeration_type";
2674 case DW_TAG_formal_parameter
:
2675 return "DW_TAG_formal_parameter";
2676 case DW_TAG_imported_declaration
:
2677 return "DW_TAG_imported_declaration";
2679 return "DW_TAG_label";
2680 case DW_TAG_lexical_block
:
2681 return "DW_TAG_lexical_block";
2683 return "DW_TAG_member";
2684 case DW_TAG_pointer_type
:
2685 return "DW_TAG_pointer_type";
2686 case DW_TAG_reference_type
:
2687 return "DW_TAG_reference_type";
2688 case DW_TAG_compile_unit
:
2689 return "DW_TAG_compile_unit";
2690 case DW_TAG_string_type
:
2691 return "DW_TAG_string_type";
2692 case DW_TAG_structure_type
:
2693 return "DW_TAG_structure_type";
2694 case DW_TAG_subroutine_type
:
2695 return "DW_TAG_subroutine_type";
2696 case DW_TAG_typedef
:
2697 return "DW_TAG_typedef";
2698 case DW_TAG_union_type
:
2699 return "DW_TAG_union_type";
2700 case DW_TAG_unspecified_parameters
:
2701 return "DW_TAG_unspecified_parameters";
2702 case DW_TAG_variant
:
2703 return "DW_TAG_variant";
2704 case DW_TAG_common_block
:
2705 return "DW_TAG_common_block";
2706 case DW_TAG_common_inclusion
:
2707 return "DW_TAG_common_inclusion";
2708 case DW_TAG_inheritance
:
2709 return "DW_TAG_inheritance";
2710 case DW_TAG_inlined_subroutine
:
2711 return "DW_TAG_inlined_subroutine";
2713 return "DW_TAG_module";
2714 case DW_TAG_ptr_to_member_type
:
2715 return "DW_TAG_ptr_to_member_type";
2716 case DW_TAG_set_type
:
2717 return "DW_TAG_set_type";
2718 case DW_TAG_subrange_type
:
2719 return "DW_TAG_subrange_type";
2720 case DW_TAG_with_stmt
:
2721 return "DW_TAG_with_stmt";
2722 case DW_TAG_access_declaration
:
2723 return "DW_TAG_access_declaration";
2724 case DW_TAG_base_type
:
2725 return "DW_TAG_base_type";
2726 case DW_TAG_catch_block
:
2727 return "DW_TAG_catch_block";
2728 case DW_TAG_const_type
:
2729 return "DW_TAG_const_type";
2730 case DW_TAG_constant
:
2731 return "DW_TAG_constant";
2732 case DW_TAG_enumerator
:
2733 return "DW_TAG_enumerator";
2734 case DW_TAG_file_type
:
2735 return "DW_TAG_file_type";
2737 return "DW_TAG_friend";
2738 case DW_TAG_namelist
:
2739 return "DW_TAG_namelist";
2740 case DW_TAG_namelist_item
:
2741 return "DW_TAG_namelist_item";
2742 case DW_TAG_packed_type
:
2743 return "DW_TAG_packed_type";
2744 case DW_TAG_subprogram
:
2745 return "DW_TAG_subprogram";
2746 case DW_TAG_template_type_param
:
2747 return "DW_TAG_template_type_param";
2748 case DW_TAG_template_value_param
:
2749 return "DW_TAG_template_value_param";
2750 case DW_TAG_thrown_type
:
2751 return "DW_TAG_thrown_type";
2752 case DW_TAG_try_block
:
2753 return "DW_TAG_try_block";
2754 case DW_TAG_variant_part
:
2755 return "DW_TAG_variant_part";
2756 case DW_TAG_variable
:
2757 return "DW_TAG_variable";
2758 case DW_TAG_volatile_type
:
2759 return "DW_TAG_volatile_type";
2760 case DW_TAG_MIPS_loop
:
2761 return "DW_TAG_MIPS_loop";
2762 case DW_TAG_format_label
:
2763 return "DW_TAG_format_label";
2764 case DW_TAG_function_template
:
2765 return "DW_TAG_function_template";
2766 case DW_TAG_class_template
:
2767 return "DW_TAG_class_template";
2769 return "DW_TAG_<unknown>";
2773 /* Convert a DWARF attribute code into its string name. */
2776 dwarf_attr_name (attr
)
2777 register unsigned attr
;
2782 return "DW_AT_sibling";
2783 case DW_AT_location
:
2784 return "DW_AT_location";
2786 return "DW_AT_name";
2787 case DW_AT_ordering
:
2788 return "DW_AT_ordering";
2789 case DW_AT_subscr_data
:
2790 return "DW_AT_subscr_data";
2791 case DW_AT_byte_size
:
2792 return "DW_AT_byte_size";
2793 case DW_AT_bit_offset
:
2794 return "DW_AT_bit_offset";
2795 case DW_AT_bit_size
:
2796 return "DW_AT_bit_size";
2797 case DW_AT_element_list
:
2798 return "DW_AT_element_list";
2799 case DW_AT_stmt_list
:
2800 return "DW_AT_stmt_list";
2802 return "DW_AT_low_pc";
2804 return "DW_AT_high_pc";
2805 case DW_AT_language
:
2806 return "DW_AT_language";
2808 return "DW_AT_member";
2810 return "DW_AT_discr";
2811 case DW_AT_discr_value
:
2812 return "DW_AT_discr_value";
2813 case DW_AT_visibility
:
2814 return "DW_AT_visibility";
2816 return "DW_AT_import";
2817 case DW_AT_string_length
:
2818 return "DW_AT_string_length";
2819 case DW_AT_common_reference
:
2820 return "DW_AT_common_reference";
2821 case DW_AT_comp_dir
:
2822 return "DW_AT_comp_dir";
2823 case DW_AT_const_value
:
2824 return "DW_AT_const_value";
2825 case DW_AT_containing_type
:
2826 return "DW_AT_containing_type";
2827 case DW_AT_default_value
:
2828 return "DW_AT_default_value";
2830 return "DW_AT_inline";
2831 case DW_AT_is_optional
:
2832 return "DW_AT_is_optional";
2833 case DW_AT_lower_bound
:
2834 return "DW_AT_lower_bound";
2835 case DW_AT_producer
:
2836 return "DW_AT_producer";
2837 case DW_AT_prototyped
:
2838 return "DW_AT_prototyped";
2839 case DW_AT_return_addr
:
2840 return "DW_AT_return_addr";
2841 case DW_AT_start_scope
:
2842 return "DW_AT_start_scope";
2843 case DW_AT_stride_size
:
2844 return "DW_AT_stride_size";
2845 case DW_AT_upper_bound
:
2846 return "DW_AT_upper_bound";
2847 case DW_AT_abstract_origin
:
2848 return "DW_AT_abstract_origin";
2849 case DW_AT_accessibility
:
2850 return "DW_AT_accessibility";
2851 case DW_AT_address_class
:
2852 return "DW_AT_address_class";
2853 case DW_AT_artificial
:
2854 return "DW_AT_artificial";
2855 case DW_AT_base_types
:
2856 return "DW_AT_base_types";
2857 case DW_AT_calling_convention
:
2858 return "DW_AT_calling_convention";
2860 return "DW_AT_count";
2861 case DW_AT_data_member_location
:
2862 return "DW_AT_data_member_location";
2863 case DW_AT_decl_column
:
2864 return "DW_AT_decl_column";
2865 case DW_AT_decl_file
:
2866 return "DW_AT_decl_file";
2867 case DW_AT_decl_line
:
2868 return "DW_AT_decl_line";
2869 case DW_AT_declaration
:
2870 return "DW_AT_declaration";
2871 case DW_AT_discr_list
:
2872 return "DW_AT_discr_list";
2873 case DW_AT_encoding
:
2874 return "DW_AT_encoding";
2875 case DW_AT_external
:
2876 return "DW_AT_external";
2877 case DW_AT_frame_base
:
2878 return "DW_AT_frame_base";
2880 return "DW_AT_friend";
2881 case DW_AT_identifier_case
:
2882 return "DW_AT_identifier_case";
2883 case DW_AT_macro_info
:
2884 return "DW_AT_macro_info";
2885 case DW_AT_namelist_items
:
2886 return "DW_AT_namelist_items";
2887 case DW_AT_priority
:
2888 return "DW_AT_priority";
2890 return "DW_AT_segment";
2891 case DW_AT_specification
:
2892 return "DW_AT_specification";
2893 case DW_AT_static_link
:
2894 return "DW_AT_static_link";
2896 return "DW_AT_type";
2897 case DW_AT_use_location
:
2898 return "DW_AT_use_location";
2899 case DW_AT_variable_parameter
:
2900 return "DW_AT_variable_parameter";
2901 case DW_AT_virtuality
:
2902 return "DW_AT_virtuality";
2903 case DW_AT_vtable_elem_location
:
2904 return "DW_AT_vtable_elem_location";
2906 case DW_AT_MIPS_fde
:
2907 return "DW_AT_MIPS_fde";
2908 case DW_AT_MIPS_loop_begin
:
2909 return "DW_AT_MIPS_loop_begin";
2910 case DW_AT_MIPS_tail_loop_begin
:
2911 return "DW_AT_MIPS_tail_loop_begin";
2912 case DW_AT_MIPS_epilog_begin
:
2913 return "DW_AT_MIPS_epilog_begin";
2914 case DW_AT_MIPS_loop_unroll_factor
:
2915 return "DW_AT_MIPS_loop_unroll_factor";
2916 case DW_AT_MIPS_software_pipeline_depth
:
2917 return "DW_AT_MIPS_software_pipeline_depth";
2918 case DW_AT_MIPS_linkage_name
:
2919 return "DW_AT_MIPS_linkage_name";
2920 case DW_AT_MIPS_stride
:
2921 return "DW_AT_MIPS_stride";
2922 case DW_AT_MIPS_abstract_name
:
2923 return "DW_AT_MIPS_abstract_name";
2924 case DW_AT_MIPS_clone_origin
:
2925 return "DW_AT_MIPS_clone_origin";
2926 case DW_AT_MIPS_has_inlines
:
2927 return "DW_AT_MIPS_has_inlines";
2929 case DW_AT_sf_names
:
2930 return "DW_AT_sf_names";
2931 case DW_AT_src_info
:
2932 return "DW_AT_src_info";
2933 case DW_AT_mac_info
:
2934 return "DW_AT_mac_info";
2935 case DW_AT_src_coords
:
2936 return "DW_AT_src_coords";
2937 case DW_AT_body_begin
:
2938 return "DW_AT_body_begin";
2939 case DW_AT_body_end
:
2940 return "DW_AT_body_end";
2942 return "DW_AT_<unknown>";
2946 /* Convert a DWARF value form code into its string name. */
2949 dwarf_form_name (form
)
2950 register unsigned form
;
2955 return "DW_FORM_addr";
2956 case DW_FORM_block2
:
2957 return "DW_FORM_block2";
2958 case DW_FORM_block4
:
2959 return "DW_FORM_block4";
2961 return "DW_FORM_data2";
2963 return "DW_FORM_data4";
2965 return "DW_FORM_data8";
2966 case DW_FORM_string
:
2967 return "DW_FORM_string";
2969 return "DW_FORM_block";
2970 case DW_FORM_block1
:
2971 return "DW_FORM_block1";
2973 return "DW_FORM_data1";
2975 return "DW_FORM_flag";
2977 return "DW_FORM_sdata";
2979 return "DW_FORM_strp";
2981 return "DW_FORM_udata";
2982 case DW_FORM_ref_addr
:
2983 return "DW_FORM_ref_addr";
2985 return "DW_FORM_ref1";
2987 return "DW_FORM_ref2";
2989 return "DW_FORM_ref4";
2991 return "DW_FORM_ref8";
2992 case DW_FORM_ref_udata
:
2993 return "DW_FORM_ref_udata";
2994 case DW_FORM_indirect
:
2995 return "DW_FORM_indirect";
2997 return "DW_FORM_<unknown>";
3001 /* Convert a DWARF stack opcode into its string name. */
3004 dwarf_stack_op_name (op
)
3005 register unsigned op
;
3010 return "DW_OP_addr";
3012 return "DW_OP_deref";
3014 return "DW_OP_const1u";
3016 return "DW_OP_const1s";
3018 return "DW_OP_const2u";
3020 return "DW_OP_const2s";
3022 return "DW_OP_const4u";
3024 return "DW_OP_const4s";
3026 return "DW_OP_const8u";
3028 return "DW_OP_const8s";
3030 return "DW_OP_constu";
3032 return "DW_OP_consts";
3036 return "DW_OP_drop";
3038 return "DW_OP_over";
3040 return "DW_OP_pick";
3042 return "DW_OP_swap";
3046 return "DW_OP_xderef";
3054 return "DW_OP_minus";
3066 return "DW_OP_plus";
3067 case DW_OP_plus_uconst
:
3068 return "DW_OP_plus_uconst";
3074 return "DW_OP_shra";
3092 return "DW_OP_skip";
3094 return "DW_OP_lit0";
3096 return "DW_OP_lit1";
3098 return "DW_OP_lit2";
3100 return "DW_OP_lit3";
3102 return "DW_OP_lit4";
3104 return "DW_OP_lit5";
3106 return "DW_OP_lit6";
3108 return "DW_OP_lit7";
3110 return "DW_OP_lit8";
3112 return "DW_OP_lit9";
3114 return "DW_OP_lit10";
3116 return "DW_OP_lit11";
3118 return "DW_OP_lit12";
3120 return "DW_OP_lit13";
3122 return "DW_OP_lit14";
3124 return "DW_OP_lit15";
3126 return "DW_OP_lit16";
3128 return "DW_OP_lit17";
3130 return "DW_OP_lit18";
3132 return "DW_OP_lit19";
3134 return "DW_OP_lit20";
3136 return "DW_OP_lit21";
3138 return "DW_OP_lit22";
3140 return "DW_OP_lit23";
3142 return "DW_OP_lit24";
3144 return "DW_OP_lit25";
3146 return "DW_OP_lit26";
3148 return "DW_OP_lit27";
3150 return "DW_OP_lit28";
3152 return "DW_OP_lit29";
3154 return "DW_OP_lit30";
3156 return "DW_OP_lit31";
3158 return "DW_OP_reg0";
3160 return "DW_OP_reg1";
3162 return "DW_OP_reg2";
3164 return "DW_OP_reg3";
3166 return "DW_OP_reg4";
3168 return "DW_OP_reg5";
3170 return "DW_OP_reg6";
3172 return "DW_OP_reg7";
3174 return "DW_OP_reg8";
3176 return "DW_OP_reg9";
3178 return "DW_OP_reg10";
3180 return "DW_OP_reg11";
3182 return "DW_OP_reg12";
3184 return "DW_OP_reg13";
3186 return "DW_OP_reg14";
3188 return "DW_OP_reg15";
3190 return "DW_OP_reg16";
3192 return "DW_OP_reg17";
3194 return "DW_OP_reg18";
3196 return "DW_OP_reg19";
3198 return "DW_OP_reg20";
3200 return "DW_OP_reg21";
3202 return "DW_OP_reg22";
3204 return "DW_OP_reg23";
3206 return "DW_OP_reg24";
3208 return "DW_OP_reg25";
3210 return "DW_OP_reg26";
3212 return "DW_OP_reg27";
3214 return "DW_OP_reg28";
3216 return "DW_OP_reg29";
3218 return "DW_OP_reg30";
3220 return "DW_OP_reg31";
3222 return "DW_OP_breg0";
3224 return "DW_OP_breg1";
3226 return "DW_OP_breg2";
3228 return "DW_OP_breg3";
3230 return "DW_OP_breg4";
3232 return "DW_OP_breg5";
3234 return "DW_OP_breg6";
3236 return "DW_OP_breg7";
3238 return "DW_OP_breg8";
3240 return "DW_OP_breg9";
3242 return "DW_OP_breg10";
3244 return "DW_OP_breg11";
3246 return "DW_OP_breg12";
3248 return "DW_OP_breg13";
3250 return "DW_OP_breg14";
3252 return "DW_OP_breg15";
3254 return "DW_OP_breg16";
3256 return "DW_OP_breg17";
3258 return "DW_OP_breg18";
3260 return "DW_OP_breg19";
3262 return "DW_OP_breg20";
3264 return "DW_OP_breg21";
3266 return "DW_OP_breg22";
3268 return "DW_OP_breg23";
3270 return "DW_OP_breg24";
3272 return "DW_OP_breg25";
3274 return "DW_OP_breg26";
3276 return "DW_OP_breg27";
3278 return "DW_OP_breg28";
3280 return "DW_OP_breg29";
3282 return "DW_OP_breg30";
3284 return "DW_OP_breg31";
3286 return "DW_OP_regx";
3288 return "DW_OP_fbreg";
3290 return "DW_OP_bregx";
3292 return "DW_OP_piece";
3293 case DW_OP_deref_size
:
3294 return "DW_OP_deref_size";
3295 case DW_OP_xderef_size
:
3296 return "DW_OP_xderef_size";
3300 return "OP_<unknown>";
3304 /* Convert a DWARF type code into its string name. */
3307 dwarf_type_encoding_name (enc
)
3308 register unsigned enc
;
3312 case DW_ATE_address
:
3313 return "DW_ATE_address";
3314 case DW_ATE_boolean
:
3315 return "DW_ATE_boolean";
3316 case DW_ATE_complex_float
:
3317 return "DW_ATE_complex_float";
3319 return "DW_ATE_float";
3321 return "DW_ATE_signed";
3322 case DW_ATE_signed_char
:
3323 return "DW_ATE_signed_char";
3324 case DW_ATE_unsigned
:
3325 return "DW_ATE_unsigned";
3326 case DW_ATE_unsigned_char
:
3327 return "DW_ATE_unsigned_char";
3329 return "DW_ATE_<unknown>";
3333 /* Determine the "ultimate origin" of a decl. The decl may be an inlined
3334 instance of an inlined instance of a decl which is local to an inline
3335 function, so we have to trace all of the way back through the origin chain
3336 to find out what sort of node actually served as the original seed for the
3340 decl_ultimate_origin (decl
)
3343 register tree immediate_origin
= DECL_ABSTRACT_ORIGIN (decl
);
3345 if (immediate_origin
== NULL_TREE
)
3349 register tree ret_val
;
3350 register tree lookahead
= immediate_origin
;
3354 ret_val
= lookahead
;
3355 lookahead
= DECL_ABSTRACT_ORIGIN (ret_val
);
3357 while (lookahead
!= NULL
&& lookahead
!= ret_val
);
3363 /* Determine the "ultimate origin" of a block. The block may be an inlined
3364 instance of an inlined instance of a block which is local to an inline
3365 function, so we have to trace all of the way back through the origin chain
3366 to find out what sort of node actually served as the original seed for the
3370 block_ultimate_origin (block
)
3371 register tree block
;
3373 register tree immediate_origin
= BLOCK_ABSTRACT_ORIGIN (block
);
3375 if (immediate_origin
== NULL_TREE
)
3379 register tree ret_val
;
3380 register tree lookahead
= immediate_origin
;
3384 ret_val
= lookahead
;
3385 lookahead
= (TREE_CODE (ret_val
) == BLOCK
)
3386 ? BLOCK_ABSTRACT_ORIGIN (ret_val
)
3389 while (lookahead
!= NULL
&& lookahead
!= ret_val
);
3395 /* Get the class to which DECL belongs, if any. In g++, the DECL_CONTEXT
3396 of a virtual function may refer to a base class, so we check the 'this'
3400 decl_class_context (decl
)
3403 tree context
= NULL_TREE
;
3405 if (TREE_CODE (decl
) != FUNCTION_DECL
|| ! DECL_VINDEX (decl
))
3406 context
= DECL_CONTEXT (decl
);
3408 context
= TYPE_MAIN_VARIANT
3409 (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)))));
3411 if (context
&& TREE_CODE_CLASS (TREE_CODE (context
)) != 't')
3412 context
= NULL_TREE
;
3417 /* Add an attribute/value pair to a DIE */
3420 add_dwarf_attr (die
, attr
)
3421 register dw_die_ref die
;
3422 register dw_attr_ref attr
;
3424 if (die
!= NULL
&& attr
!= NULL
)
3426 if (die
->die_attr
== NULL
)
3428 die
->die_attr
= attr
;
3429 die
->die_attr_last
= attr
;
3433 die
->die_attr_last
->dw_attr_next
= attr
;
3434 die
->die_attr_last
= attr
;
3439 /* Add a flag value attribute to a DIE. */
3442 add_AT_flag (die
, attr_kind
, flag
)
3443 register dw_die_ref die
;
3444 register enum dwarf_attribute attr_kind
;
3445 register unsigned flag
;
3447 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3449 attr
->dw_attr_next
= NULL
;
3450 attr
->dw_attr
= attr_kind
;
3451 attr
->dw_attr_val
.val_class
= dw_val_class_flag
;
3452 attr
->dw_attr_val
.v
.val_flag
= flag
;
3453 add_dwarf_attr (die
, attr
);
3456 /* Add a signed integer attribute value to a DIE. */
3459 add_AT_int (die
, attr_kind
, int_val
)
3460 register dw_die_ref die
;
3461 register enum dwarf_attribute attr_kind
;
3462 register long int int_val
;
3464 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3466 attr
->dw_attr_next
= NULL
;
3467 attr
->dw_attr
= attr_kind
;
3468 attr
->dw_attr_val
.val_class
= dw_val_class_const
;
3469 attr
->dw_attr_val
.v
.val_int
= int_val
;
3470 add_dwarf_attr (die
, attr
);
3473 /* Add an unsigned integer attribute value to a DIE. */
3476 add_AT_unsigned (die
, attr_kind
, unsigned_val
)
3477 register dw_die_ref die
;
3478 register enum dwarf_attribute attr_kind
;
3479 register unsigned long unsigned_val
;
3481 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3483 attr
->dw_attr_next
= NULL
;
3484 attr
->dw_attr
= attr_kind
;
3485 attr
->dw_attr_val
.val_class
= dw_val_class_unsigned_const
;
3486 attr
->dw_attr_val
.v
.val_unsigned
= unsigned_val
;
3487 add_dwarf_attr (die
, attr
);
3490 /* Add an unsigned double integer attribute value to a DIE. */
3493 add_AT_long_long (die
, attr_kind
, val_hi
, val_low
)
3494 register dw_die_ref die
;
3495 register enum dwarf_attribute attr_kind
;
3496 register unsigned long val_hi
;
3497 register unsigned long val_low
;
3499 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3501 attr
->dw_attr_next
= NULL
;
3502 attr
->dw_attr
= attr_kind
;
3503 attr
->dw_attr_val
.val_class
= dw_val_class_long_long
;
3504 attr
->dw_attr_val
.v
.val_long_long
.hi
= val_hi
;
3505 attr
->dw_attr_val
.v
.val_long_long
.low
= val_low
;
3506 add_dwarf_attr (die
, attr
);
3509 /* Add a floating point attribute value to a DIE and return it. */
3512 add_AT_float (die
, attr_kind
, length
, array
)
3513 register dw_die_ref die
;
3514 register enum dwarf_attribute attr_kind
;
3515 register unsigned length
;
3516 register long *array
;
3518 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3520 attr
->dw_attr_next
= NULL
;
3521 attr
->dw_attr
= attr_kind
;
3522 attr
->dw_attr_val
.val_class
= dw_val_class_float
;
3523 attr
->dw_attr_val
.v
.val_float
.length
= length
;
3524 attr
->dw_attr_val
.v
.val_float
.array
= array
;
3525 add_dwarf_attr (die
, attr
);
3528 /* Add a string attribute value to a DIE. */
3531 add_AT_string (die
, attr_kind
, str
)
3532 register dw_die_ref die
;
3533 register enum dwarf_attribute attr_kind
;
3536 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3538 attr
->dw_attr_next
= NULL
;
3539 attr
->dw_attr
= attr_kind
;
3540 attr
->dw_attr_val
.val_class
= dw_val_class_str
;
3541 attr
->dw_attr_val
.v
.val_str
= xstrdup (str
);
3542 add_dwarf_attr (die
, attr
);
3545 /* Add a DIE reference attribute value to a DIE. */
3548 add_AT_die_ref (die
, attr_kind
, targ_die
)
3549 register dw_die_ref die
;
3550 register enum dwarf_attribute attr_kind
;
3551 register dw_die_ref targ_die
;
3553 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3555 attr
->dw_attr_next
= NULL
;
3556 attr
->dw_attr
= attr_kind
;
3557 attr
->dw_attr_val
.val_class
= dw_val_class_die_ref
;
3558 attr
->dw_attr_val
.v
.val_die_ref
= targ_die
;
3559 add_dwarf_attr (die
, attr
);
3562 /* Add an FDE reference attribute value to a DIE. */
3565 add_AT_fde_ref (die
, attr_kind
, targ_fde
)
3566 register dw_die_ref die
;
3567 register enum dwarf_attribute attr_kind
;
3568 register unsigned targ_fde
;
3570 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3572 attr
->dw_attr_next
= NULL
;
3573 attr
->dw_attr
= attr_kind
;
3574 attr
->dw_attr_val
.val_class
= dw_val_class_fde_ref
;
3575 attr
->dw_attr_val
.v
.val_fde_index
= targ_fde
;
3576 add_dwarf_attr (die
, attr
);
3579 /* Add a location description attribute value to a DIE. */
3582 add_AT_loc (die
, attr_kind
, loc
)
3583 register dw_die_ref die
;
3584 register enum dwarf_attribute attr_kind
;
3585 register dw_loc_descr_ref loc
;
3587 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3589 attr
->dw_attr_next
= NULL
;
3590 attr
->dw_attr
= attr_kind
;
3591 attr
->dw_attr_val
.val_class
= dw_val_class_loc
;
3592 attr
->dw_attr_val
.v
.val_loc
= loc
;
3593 add_dwarf_attr (die
, attr
);
3596 /* Add an address constant attribute value to a DIE. */
3599 add_AT_addr (die
, attr_kind
, addr
)
3600 register dw_die_ref die
;
3601 register enum dwarf_attribute attr_kind
;
3604 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3606 attr
->dw_attr_next
= NULL
;
3607 attr
->dw_attr
= attr_kind
;
3608 attr
->dw_attr_val
.val_class
= dw_val_class_addr
;
3609 attr
->dw_attr_val
.v
.val_addr
= addr
;
3610 add_dwarf_attr (die
, attr
);
3613 /* Add a label identifier attribute value to a DIE. */
3616 add_AT_lbl_id (die
, attr_kind
, lbl_id
)
3617 register dw_die_ref die
;
3618 register enum dwarf_attribute attr_kind
;
3619 register char *lbl_id
;
3621 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3623 attr
->dw_attr_next
= NULL
;
3624 attr
->dw_attr
= attr_kind
;
3625 attr
->dw_attr_val
.val_class
= dw_val_class_lbl_id
;
3626 attr
->dw_attr_val
.v
.val_lbl_id
= xstrdup (lbl_id
);
3627 add_dwarf_attr (die
, attr
);
3630 /* Add a section offset attribute value to a DIE. */
3633 add_AT_section_offset (die
, attr_kind
, section
)
3634 register dw_die_ref die
;
3635 register enum dwarf_attribute attr_kind
;
3636 register char *section
;
3638 register dw_attr_ref attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
3640 attr
->dw_attr_next
= NULL
;
3641 attr
->dw_attr
= attr_kind
;
3642 attr
->dw_attr_val
.val_class
= dw_val_class_section_offset
;
3643 attr
->dw_attr_val
.v
.val_section
= section
;
3644 add_dwarf_attr (die
, attr
);
3648 /* Test if die refers to an external subroutine. */
3651 is_extern_subr_die (die
)
3652 register dw_die_ref die
;
3654 register dw_attr_ref a
;
3655 register int is_subr
= FALSE
;
3656 register int is_extern
= FALSE
;
3658 if (die
!= NULL
&& die
->die_tag
== DW_TAG_subprogram
)
3661 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
3663 if (a
->dw_attr
== DW_AT_external
3664 && a
->dw_attr_val
.val_class
== dw_val_class_flag
3665 && a
->dw_attr_val
.v
.val_flag
!= 0)
3673 return is_subr
&& is_extern
;
3676 /* Get the attribute of type attr_kind. */
3678 static inline dw_attr_ref
3679 get_AT (die
, attr_kind
)
3680 register dw_die_ref die
;
3681 register enum dwarf_attribute attr_kind
;
3683 register dw_attr_ref a
;
3684 register dw_die_ref spec
= NULL
;
3688 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
3690 if (a
->dw_attr
== attr_kind
)
3693 if (a
->dw_attr
== DW_AT_specification
3694 || a
->dw_attr
== DW_AT_abstract_origin
)
3695 spec
= a
->dw_attr_val
.v
.val_die_ref
;
3699 return get_AT (spec
, attr_kind
);
3705 /* Return the "low pc" attribute value, typically associated with
3706 a subprogram DIE. Return null if the "low pc" attribute is
3707 either not prsent, or if it cannot be represented as an
3708 assembler label identifier. */
3710 static inline char *
3712 register dw_die_ref die
;
3714 register dw_attr_ref a
= get_AT (die
, DW_AT_low_pc
);
3716 if (a
&& a
->dw_attr_val
.val_class
== dw_val_class_lbl_id
)
3717 return a
->dw_attr_val
.v
.val_lbl_id
;
3722 /* Return the "high pc" attribute value, typically associated with
3723 a subprogram DIE. Return null if the "high pc" attribute is
3724 either not prsent, or if it cannot be represented as an
3725 assembler label identifier. */
3727 static inline char *
3729 register dw_die_ref die
;
3731 register dw_attr_ref a
= get_AT (die
, DW_AT_high_pc
);
3733 if (a
&& a
->dw_attr_val
.val_class
== dw_val_class_lbl_id
)
3734 return a
->dw_attr_val
.v
.val_lbl_id
;
3739 /* Return the value of the string attribute designated by ATTR_KIND, or
3740 NULL if it is not present. */
3742 static inline char *
3743 get_AT_string (die
, attr_kind
)
3744 register dw_die_ref die
;
3745 register enum dwarf_attribute attr_kind
;
3747 register dw_attr_ref a
= get_AT (die
, attr_kind
);
3749 if (a
&& a
->dw_attr_val
.val_class
== dw_val_class_str
)
3750 return a
->dw_attr_val
.v
.val_str
;
3755 /* Return the value of the flag attribute designated by ATTR_KIND, or -1
3756 if it is not present. */
3759 get_AT_flag (die
, attr_kind
)
3760 register dw_die_ref die
;
3761 register enum dwarf_attribute attr_kind
;
3763 register dw_attr_ref a
= get_AT (die
, attr_kind
);
3765 if (a
&& a
->dw_attr_val
.val_class
== dw_val_class_flag
)
3766 return a
->dw_attr_val
.v
.val_flag
;
3771 /* Return the value of the unsigned attribute designated by ATTR_KIND, or 0
3772 if it is not present. */
3774 static inline unsigned
3775 get_AT_unsigned (die
, attr_kind
)
3776 register dw_die_ref die
;
3777 register enum dwarf_attribute attr_kind
;
3779 register dw_attr_ref a
= get_AT (die
, attr_kind
);
3781 if (a
&& a
->dw_attr_val
.val_class
== dw_val_class_unsigned_const
)
3782 return a
->dw_attr_val
.v
.val_unsigned
;
3790 register unsigned lang
= get_AT_unsigned (comp_unit_die
, DW_AT_language
);
3792 return (lang
== DW_LANG_C
|| lang
== DW_LANG_C89
3793 || lang
== DW_LANG_C_plus_plus
);
3799 register unsigned lang
= get_AT_unsigned (comp_unit_die
, DW_AT_language
);
3801 return (lang
== DW_LANG_Fortran77
|| lang
== DW_LANG_Fortran90
);
3804 /* Remove the specified attribute if present. */
3807 remove_AT (die
, attr_kind
)
3808 register dw_die_ref die
;
3809 register enum dwarf_attribute attr_kind
;
3811 register dw_attr_ref a
;
3812 register dw_attr_ref removed
= NULL
;;
3816 if (die
->die_attr
->dw_attr
== attr_kind
)
3818 removed
= die
->die_attr
;
3819 if (die
->die_attr_last
== die
->die_attr
)
3820 die
->die_attr_last
= NULL
;
3822 die
->die_attr
= die
->die_attr
->dw_attr_next
;
3826 for (a
= die
->die_attr
; a
->dw_attr_next
!= NULL
;
3827 a
= a
->dw_attr_next
)
3828 if (a
->dw_attr_next
->dw_attr
== attr_kind
)
3830 removed
= a
->dw_attr_next
;
3831 if (die
->die_attr_last
== a
->dw_attr_next
)
3832 die
->die_attr_last
= a
;
3834 a
->dw_attr_next
= a
->dw_attr_next
->dw_attr_next
;
3843 /* Discard the children of this DIE. */
3846 remove_children (die
)
3847 register dw_die_ref die
;
3849 register dw_die_ref child_die
= die
->die_child
;
3851 die
->die_child
= NULL
;
3852 die
->die_child_last
= NULL
;
3854 while (child_die
!= NULL
)
3856 register dw_die_ref tmp_die
= child_die
;
3857 register dw_attr_ref a
;
3859 child_die
= child_die
->die_sib
;
3861 for (a
= tmp_die
->die_attr
; a
!= NULL
; )
3863 register dw_attr_ref tmp_a
= a
;
3865 a
= a
->dw_attr_next
;
3873 /* Add a child DIE below its parent. */
3876 add_child_die (die
, child_die
)
3877 register dw_die_ref die
;
3878 register dw_die_ref child_die
;
3880 if (die
!= NULL
&& child_die
!= NULL
)
3882 if (die
== child_die
)
3884 child_die
->die_parent
= die
;
3885 child_die
->die_sib
= NULL
;
3887 if (die
->die_child
== NULL
)
3889 die
->die_child
= child_die
;
3890 die
->die_child_last
= child_die
;
3894 die
->die_child_last
->die_sib
= child_die
;
3895 die
->die_child_last
= child_die
;
3900 /* Return a pointer to a newly created DIE node. */
3902 static inline dw_die_ref
3903 new_die (tag_value
, parent_die
)
3904 register enum dwarf_tag tag_value
;
3905 register dw_die_ref parent_die
;
3907 register dw_die_ref die
= (dw_die_ref
) xmalloc (sizeof (die_node
));
3909 die
->die_tag
= tag_value
;
3910 die
->die_abbrev
= 0;
3911 die
->die_offset
= 0;
3912 die
->die_child
= NULL
;
3913 die
->die_parent
= NULL
;
3914 die
->die_sib
= NULL
;
3915 die
->die_child_last
= NULL
;
3916 die
->die_attr
= NULL
;
3917 die
->die_attr_last
= NULL
;
3919 if (parent_die
!= NULL
)
3920 add_child_die (parent_die
, die
);
3923 limbo_die_node
*limbo_node
;
3925 limbo_node
= (limbo_die_node
*) xmalloc (sizeof (limbo_die_node
));
3926 limbo_node
->die
= die
;
3927 limbo_node
->next
= limbo_die_list
;
3928 limbo_die_list
= limbo_node
;
3934 /* Return the DIE associated with the given type specifier. */
3936 static inline dw_die_ref
3937 lookup_type_die (type
)
3940 return (dw_die_ref
) TYPE_SYMTAB_POINTER (type
);
3943 /* Equate a DIE to a given type specifier. */
3946 equate_type_number_to_die (type
, type_die
)
3948 register dw_die_ref type_die
;
3950 TYPE_SYMTAB_POINTER (type
) = (char *) type_die
;
3953 /* Return the DIE associated with a given declaration. */
3955 static inline dw_die_ref
3956 lookup_decl_die (decl
)
3959 register unsigned decl_id
= DECL_UID (decl
);
3961 return (decl_id
< decl_die_table_in_use
3962 ? decl_die_table
[decl_id
] : NULL
);
3965 /* Equate a DIE to a particular declaration. */
3968 equate_decl_number_to_die (decl
, decl_die
)
3970 register dw_die_ref decl_die
;
3972 register unsigned decl_id
= DECL_UID (decl
);
3973 register unsigned i
;
3974 register unsigned num_allocated
;
3976 if (decl_id
>= decl_die_table_allocated
)
3979 = ((decl_id
+ 1 + DECL_DIE_TABLE_INCREMENT
- 1)
3980 / DECL_DIE_TABLE_INCREMENT
)
3981 * DECL_DIE_TABLE_INCREMENT
;
3984 = (dw_die_ref
*) xrealloc (decl_die_table
,
3985 sizeof (dw_die_ref
) * num_allocated
);
3987 bzero ((char *) &decl_die_table
[decl_die_table_allocated
],
3988 (num_allocated
- decl_die_table_allocated
) * sizeof (dw_die_ref
));
3989 decl_die_table_allocated
= num_allocated
;
3992 if (decl_id
>= decl_die_table_in_use
)
3993 decl_die_table_in_use
= (decl_id
+ 1);
3995 decl_die_table
[decl_id
] = decl_die
;
3998 /* Return a pointer to a newly allocated location description. Location
3999 descriptions are simple expression terms that can be strung
4000 together to form more complicated location (address) descriptions. */
4002 static inline dw_loc_descr_ref
4003 new_loc_descr (op
, oprnd1
, oprnd2
)
4004 register enum dwarf_location_atom op
;
4005 register unsigned long oprnd1
;
4006 register unsigned long oprnd2
;
4008 register dw_loc_descr_ref descr
4009 = (dw_loc_descr_ref
) xmalloc (sizeof (dw_loc_descr_node
));
4011 descr
->dw_loc_next
= NULL
;
4012 descr
->dw_loc_opc
= op
;
4013 descr
->dw_loc_oprnd1
.val_class
= dw_val_class_unsigned_const
;
4014 descr
->dw_loc_oprnd1
.v
.val_unsigned
= oprnd1
;
4015 descr
->dw_loc_oprnd2
.val_class
= dw_val_class_unsigned_const
;
4016 descr
->dw_loc_oprnd2
.v
.val_unsigned
= oprnd2
;
4021 /* Add a location description term to a location description expression. */
4024 add_loc_descr (list_head
, descr
)
4025 register dw_loc_descr_ref
*list_head
;
4026 register dw_loc_descr_ref descr
;
4028 register dw_loc_descr_ref
*d
;
4030 /* Find the end of the chain. */
4031 for (d
= list_head
; (*d
) != NULL
; d
= &(*d
)->dw_loc_next
)
4037 /* Keep track of the number of spaces used to indent the
4038 output of the debugging routines that print the structure of
4039 the DIE internal representation. */
4040 static int print_indent
;
4042 /* Indent the line the number of spaces given by print_indent. */
4045 print_spaces (outfile
)
4048 fprintf (outfile
, "%*s", print_indent
, "");
4051 /* Print the information assoaciated with a given DIE, and its children.
4052 This routine is a debugging aid only. */
4055 print_die (die
, outfile
)
4059 register dw_attr_ref a
;
4060 register dw_die_ref c
;
4062 print_spaces (outfile
);
4063 fprintf (outfile
, "DIE %4u: %s\n",
4064 die
->die_offset
, dwarf_tag_name (die
->die_tag
));
4065 print_spaces (outfile
);
4066 fprintf (outfile
, " abbrev id: %u", die
->die_abbrev
);
4067 fprintf (outfile
, " offset: %u\n", die
->die_offset
);
4069 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
4071 print_spaces (outfile
);
4072 fprintf (outfile
, " %s: ", dwarf_attr_name (a
->dw_attr
));
4074 switch (a
->dw_attr_val
.val_class
)
4076 case dw_val_class_addr
:
4077 fprintf (outfile
, "address");
4079 case dw_val_class_loc
:
4080 fprintf (outfile
, "location descriptor");
4082 case dw_val_class_const
:
4083 fprintf (outfile
, "%d", a
->dw_attr_val
.v
.val_int
);
4085 case dw_val_class_unsigned_const
:
4086 fprintf (outfile
, "%u", a
->dw_attr_val
.v
.val_unsigned
);
4088 case dw_val_class_long_long
:
4089 fprintf (outfile
, "constant (%u,%u)",
4090 a
->dw_attr_val
.v
.val_long_long
.hi
,
4091 a
->dw_attr_val
.v
.val_long_long
.low
);
4093 case dw_val_class_float
:
4094 fprintf (outfile
, "floating-point constant");
4096 case dw_val_class_flag
:
4097 fprintf (outfile
, "%u", a
->dw_attr_val
.v
.val_flag
);
4099 case dw_val_class_die_ref
:
4100 if (a
->dw_attr_val
.v
.val_die_ref
!= NULL
)
4101 fprintf (outfile
, "die -> %u",
4102 a
->dw_attr_val
.v
.val_die_ref
->die_offset
);
4104 fprintf (outfile
, "die -> <null>");
4106 case dw_val_class_lbl_id
:
4107 fprintf (outfile
, "label: %s", a
->dw_attr_val
.v
.val_lbl_id
);
4109 case dw_val_class_section_offset
:
4110 fprintf (outfile
, "section: %s", a
->dw_attr_val
.v
.val_section
);
4112 case dw_val_class_str
:
4113 if (a
->dw_attr_val
.v
.val_str
!= NULL
)
4114 fprintf (outfile
, "\"%s\"", a
->dw_attr_val
.v
.val_str
);
4116 fprintf (outfile
, "<null>");
4122 fprintf (outfile
, "\n");
4125 if (die
->die_child
!= NULL
)
4128 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
4129 print_die (c
, outfile
);
4135 /* Print the contents of the source code line number correspondence table.
4136 This routine is a debugging aid only. */
4139 print_dwarf_line_table (outfile
)
4142 register unsigned i
;
4143 register dw_line_info_ref line_info
;
4145 fprintf (outfile
, "\n\nDWARF source line information\n");
4146 for (i
= 1; i
< line_info_table_in_use
; ++i
)
4148 line_info
= &line_info_table
[i
];
4149 fprintf (outfile
, "%5d: ", i
);
4150 fprintf (outfile
, "%-20s", file_table
[line_info
->dw_file_num
]);
4151 fprintf (outfile
, "%6d", line_info
->dw_line_num
);
4152 fprintf (outfile
, "\n");
4155 fprintf (outfile
, "\n\n");
4158 /* Print the information collected for a given DIE. */
4161 debug_dwarf_die (die
)
4164 print_die (die
, stderr
);
4167 /* Print all DWARF information collected for the compilation unit.
4168 This routine is a debugging aid only. */
4174 print_die (comp_unit_die
, stderr
);
4175 print_dwarf_line_table (stderr
);
4178 /* Traverse the DIE, and add a sibling attribute if it may have the
4179 effect of speeding up access to siblings. To save some space,
4180 avoid generating sibling attributes for DIE's without children. */
4183 add_sibling_attributes(die
)
4184 register dw_die_ref die
;
4186 register dw_die_ref c
;
4187 register dw_attr_ref attr
;
4188 if (die
!= comp_unit_die
&& die
->die_child
!= NULL
)
4190 attr
= (dw_attr_ref
) xmalloc (sizeof (dw_attr_node
));
4191 attr
->dw_attr_next
= NULL
;
4192 attr
->dw_attr
= DW_AT_sibling
;
4193 attr
->dw_attr_val
.val_class
= dw_val_class_die_ref
;
4194 attr
->dw_attr_val
.v
.val_die_ref
= die
->die_sib
;
4196 /* Add the sibling link to the front of the attribute list. */
4197 attr
->dw_attr_next
= die
->die_attr
;
4198 if (die
->die_attr
== NULL
)
4199 die
->die_attr_last
= attr
;
4201 die
->die_attr
= attr
;
4204 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
4205 add_sibling_attributes (c
);
4208 /* The format of each DIE (and its attribute value pairs)
4209 is encoded in an abbreviation table. This routine builds the
4210 abbreviation table and assigns a unique abbreviation id for
4211 each abbreviation entry. The children of each die are visited
4215 build_abbrev_table (die
)
4216 register dw_die_ref die
;
4218 register unsigned long abbrev_id
;
4219 register unsigned long n_alloc
;
4220 register dw_die_ref c
;
4221 register dw_attr_ref d_attr
, a_attr
;
4222 for (abbrev_id
= 1; abbrev_id
< abbrev_die_table_in_use
; ++abbrev_id
)
4224 register dw_die_ref abbrev
= abbrev_die_table
[abbrev_id
];
4226 if (abbrev
->die_tag
== die
->die_tag
)
4228 if ((abbrev
->die_child
!= NULL
) == (die
->die_child
!= NULL
))
4230 a_attr
= abbrev
->die_attr
;
4231 d_attr
= die
->die_attr
;
4233 while (a_attr
!= NULL
&& d_attr
!= NULL
)
4235 if ((a_attr
->dw_attr
!= d_attr
->dw_attr
)
4236 || (value_format (&a_attr
->dw_attr_val
)
4237 != value_format (&d_attr
->dw_attr_val
)))
4240 a_attr
= a_attr
->dw_attr_next
;
4241 d_attr
= d_attr
->dw_attr_next
;
4244 if (a_attr
== NULL
&& d_attr
== NULL
)
4250 if (abbrev_id
>= abbrev_die_table_in_use
)
4252 if (abbrev_die_table_in_use
>= abbrev_die_table_allocated
)
4254 n_alloc
= abbrev_die_table_allocated
+ ABBREV_DIE_TABLE_INCREMENT
;
4256 = (dw_die_ref
*) xrealloc (abbrev_die_table
,
4257 sizeof (dw_die_ref
) * n_alloc
);
4259 bzero ((char *) &abbrev_die_table
[abbrev_die_table_allocated
],
4260 (n_alloc
- abbrev_die_table_allocated
) * sizeof (dw_die_ref
));
4261 abbrev_die_table_allocated
= n_alloc
;
4264 ++abbrev_die_table_in_use
;
4265 abbrev_die_table
[abbrev_id
] = die
;
4268 die
->die_abbrev
= abbrev_id
;
4269 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
4270 build_abbrev_table (c
);
4273 /* Return the size of a string, including the null byte. */
4275 static unsigned long
4276 size_of_string (str
)
4279 register unsigned long size
= 0;
4280 register unsigned long slen
= strlen (str
);
4281 register unsigned long i
;
4282 register unsigned c
;
4284 for (i
= 0; i
< slen
; ++i
)
4293 /* Null terminator. */
4298 /* Return the size of a location descriptor. */
4300 static unsigned long
4301 size_of_loc_descr (loc
)
4302 register dw_loc_descr_ref loc
;
4304 register unsigned long size
= 1;
4306 switch (loc
->dw_loc_opc
)
4328 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
4331 size
+= size_of_sleb128 (loc
->dw_loc_oprnd1
.v
.val_int
);
4336 case DW_OP_plus_uconst
:
4337 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
4375 size
+= size_of_sleb128 (loc
->dw_loc_oprnd1
.v
.val_int
);
4378 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
4381 size
+= size_of_sleb128 (loc
->dw_loc_oprnd1
.v
.val_int
);
4384 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
4385 size
+= size_of_sleb128 (loc
->dw_loc_oprnd2
.v
.val_int
);
4388 size
+= size_of_uleb128 (loc
->dw_loc_oprnd1
.v
.val_unsigned
);
4390 case DW_OP_deref_size
:
4391 case DW_OP_xderef_size
:
4401 /* Return the size of a series of location descriptors. */
4403 static unsigned long
4405 register dw_loc_descr_ref loc
;
4407 register unsigned long size
= 0;
4409 for (; loc
!= NULL
; loc
= loc
->dw_loc_next
)
4410 size
+= size_of_loc_descr (loc
);
4415 /* Return the power-of-two number of bytes necessary to represent VALUE. */
4418 constant_size (value
)
4419 long unsigned value
;
4426 log
= floor_log2 (value
);
4429 log
= 1 << (floor_log2 (log
) + 1);
4434 /* Return the size of a DIE, as it is represented in the
4435 .debug_info section. */
4437 static unsigned long
4439 register dw_die_ref die
;
4441 register unsigned long size
= 0;
4442 register dw_attr_ref a
;
4444 size
+= size_of_uleb128 (die
->die_abbrev
);
4445 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
4447 switch (a
->dw_attr_val
.val_class
)
4449 case dw_val_class_addr
:
4452 case dw_val_class_loc
:
4454 register unsigned long lsize
4455 = size_of_locs (a
->dw_attr_val
.v
.val_loc
);
4458 size
+= constant_size (lsize
);
4462 case dw_val_class_const
:
4465 case dw_val_class_unsigned_const
:
4466 size
+= constant_size (a
->dw_attr_val
.v
.val_unsigned
);
4468 case dw_val_class_long_long
:
4469 size
+= 1 + 8; /* block */
4471 case dw_val_class_float
:
4472 size
+= 1 + a
->dw_attr_val
.v
.val_float
.length
* 4; /* block */
4474 case dw_val_class_flag
:
4477 case dw_val_class_die_ref
:
4478 size
+= DWARF_OFFSET_SIZE
;
4480 case dw_val_class_fde_ref
:
4481 size
+= DWARF_OFFSET_SIZE
;
4483 case dw_val_class_lbl_id
:
4486 case dw_val_class_section_offset
:
4487 size
+= DWARF_OFFSET_SIZE
;
4489 case dw_val_class_str
:
4490 size
+= size_of_string (a
->dw_attr_val
.v
.val_str
);
4500 /* Size the debgging information associted with a given DIE.
4501 Visits the DIE's children recursively. Updates the global
4502 variable next_die_offset, on each time through. Uses the
4503 current value of next_die_offset to updete the die_offset
4504 field in each DIE. */
4507 calc_die_sizes (die
)
4510 register dw_die_ref c
;
4511 die
->die_offset
= next_die_offset
;
4512 next_die_offset
+= size_of_die (die
);
4514 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
4517 if (die
->die_child
!= NULL
)
4518 /* Count the null byte used to terminate sibling lists. */
4519 next_die_offset
+= 1;
4522 /* Return the size of the line information prolog generated for the
4523 compilation unit. */
4525 static unsigned long
4526 size_of_line_prolog ()
4528 register unsigned long size
;
4529 register unsigned long ft_index
;
4531 size
= DWARF_LINE_PROLOG_HEADER_SIZE
;
4533 /* Count the size of the table giving number of args for each
4535 size
+= DWARF_LINE_OPCODE_BASE
- 1;
4537 /* Include directory table is empty (at present). Count only the
4538 the null byte used to terminate the table. */
4541 for (ft_index
= 1; ft_index
< file_table_in_use
; ++ft_index
)
4543 /* File name entry. */
4544 size
+= size_of_string (file_table
[ft_index
]);
4546 /* Include directory index. */
4547 size
+= size_of_uleb128 (0);
4549 /* Modification time. */
4550 size
+= size_of_uleb128 (0);
4552 /* File length in bytes. */
4553 size
+= size_of_uleb128 (0);
4556 /* Count the file table terminator. */
4561 /* Return the size of the line information generated for this
4562 compilation unit. */
4564 static unsigned long
4565 size_of_line_info ()
4567 register unsigned long size
;
4568 register unsigned long lt_index
;
4569 register unsigned long current_line
;
4570 register long line_offset
;
4571 register long line_delta
;
4572 register unsigned long current_file
;
4573 register unsigned long function
;
4574 unsigned long size_of_set_address
;
4576 /* Size of a DW_LNE_set_address instruction. */
4577 size_of_set_address
= 1 + size_of_uleb128 (1 + PTR_SIZE
) + 1 + PTR_SIZE
;
4579 /* Version number. */
4582 /* Prolog length specifier. */
4583 size
+= DWARF_OFFSET_SIZE
;
4586 size
+= size_of_line_prolog ();
4588 /* Set address register instruction. */
4589 size
+= size_of_set_address
;
4593 for (lt_index
= 1; lt_index
< line_info_table_in_use
; ++lt_index
)
4595 register dw_line_info_ref line_info
;
4597 /* Advance pc instruction. */
4598 /* ??? See the DW_LNS_advance_pc comment in output_line_info. */
4602 size
+= size_of_set_address
;
4604 line_info
= &line_info_table
[lt_index
];
4605 if (line_info
->dw_file_num
!= current_file
)
4607 /* Set file number instruction. */
4609 current_file
= line_info
->dw_file_num
;
4610 size
+= size_of_uleb128 (current_file
);
4613 if (line_info
->dw_line_num
!= current_line
)
4615 line_offset
= line_info
->dw_line_num
- current_line
;
4616 line_delta
= line_offset
- DWARF_LINE_BASE
;
4617 current_line
= line_info
->dw_line_num
;
4618 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
4619 /* 1-byte special line number instruction. */
4623 /* Advance line instruction. */
4625 size
+= size_of_sleb128 (line_offset
);
4626 /* Generate line entry instruction. */
4632 /* Advance pc instruction. */
4636 size
+= size_of_set_address
;
4638 /* End of line number info. marker. */
4639 size
+= 1 + size_of_uleb128 (1) + 1;
4644 for (lt_index
= 0; lt_index
< separate_line_info_table_in_use
; )
4646 register dw_separate_line_info_ref line_info
4647 = &separate_line_info_table
[lt_index
];
4648 if (function
!= line_info
->function
)
4650 function
= line_info
->function
;
4651 /* Set address register instruction. */
4652 size
+= size_of_set_address
;
4656 /* Advance pc instruction. */
4660 size
+= size_of_set_address
;
4663 if (line_info
->dw_file_num
!= current_file
)
4665 /* Set file number instruction. */
4667 current_file
= line_info
->dw_file_num
;
4668 size
+= size_of_uleb128 (current_file
);
4671 if (line_info
->dw_line_num
!= current_line
)
4673 line_offset
= line_info
->dw_line_num
- current_line
;
4674 line_delta
= line_offset
- DWARF_LINE_BASE
;
4675 current_line
= line_info
->dw_line_num
;
4676 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
4677 /* 1-byte special line number instruction. */
4681 /* Advance line instruction. */
4683 size
+= size_of_sleb128 (line_offset
);
4685 /* Generate line entry instruction. */
4692 /* If we're done with a function, end its sequence. */
4693 if (lt_index
== separate_line_info_table_in_use
4694 || separate_line_info_table
[lt_index
].function
!= function
)
4699 /* Advance pc instruction. */
4703 size
+= size_of_set_address
;
4705 /* End of line number info. marker. */
4706 size
+= 1 + size_of_uleb128 (1) + 1;
4713 /* Return the size of the .debug_pubnames table generated for the
4714 compilation unit. */
4716 static unsigned long
4719 register unsigned long size
;
4720 register unsigned i
;
4722 size
= DWARF_PUBNAMES_HEADER_SIZE
;
4723 for (i
= 0; i
< pubname_table_in_use
; ++i
)
4725 register pubname_ref p
= &pubname_table
[i
];
4726 size
+= DWARF_OFFSET_SIZE
+ size_of_string (p
->name
);
4729 size
+= DWARF_OFFSET_SIZE
;
4733 /* Return the size of the information in the .debug_aranges seciton. */
4735 static unsigned long
4738 register unsigned long size
;
4740 size
= DWARF_ARANGES_HEADER_SIZE
;
4742 /* Count the address/length pair for this compilation unit. */
4743 size
+= 2 * PTR_SIZE
;
4744 size
+= 2 * PTR_SIZE
* arange_table_in_use
;
4746 /* Count the two zero words used to terminated the address range table. */
4747 size
+= 2 * PTR_SIZE
;
4751 /* Select the encoding of an attribute value. */
4753 static enum dwarf_form
4757 switch (v
->val_class
)
4759 case dw_val_class_addr
:
4760 return DW_FORM_addr
;
4761 case dw_val_class_loc
:
4762 switch (constant_size (size_of_locs (v
->v
.val_loc
)))
4765 return DW_FORM_block1
;
4767 return DW_FORM_block2
;
4771 case dw_val_class_const
:
4772 return DW_FORM_data4
;
4773 case dw_val_class_unsigned_const
:
4774 switch (constant_size (v
->v
.val_unsigned
))
4777 return DW_FORM_data1
;
4779 return DW_FORM_data2
;
4781 return DW_FORM_data4
;
4783 return DW_FORM_data8
;
4787 case dw_val_class_long_long
:
4788 return DW_FORM_block1
;
4789 case dw_val_class_float
:
4790 return DW_FORM_block1
;
4791 case dw_val_class_flag
:
4792 return DW_FORM_flag
;
4793 case dw_val_class_die_ref
:
4795 case dw_val_class_fde_ref
:
4796 return DW_FORM_data
;
4797 case dw_val_class_lbl_id
:
4798 return DW_FORM_addr
;
4799 case dw_val_class_section_offset
:
4800 return DW_FORM_data
;
4801 case dw_val_class_str
:
4802 return DW_FORM_string
;
4808 /* Output the encoding of an attribute value. */
4811 output_value_format (v
)
4814 enum dwarf_form form
= value_format (v
);
4816 output_uleb128 (form
);
4818 fprintf (asm_out_file
, " (%s)", dwarf_form_name (form
));
4820 fputc ('\n', asm_out_file
);
4823 /* Output the .debug_abbrev section which defines the DIE abbreviation
4827 output_abbrev_section ()
4829 unsigned long abbrev_id
;
4832 for (abbrev_id
= 1; abbrev_id
< abbrev_die_table_in_use
; ++abbrev_id
)
4834 register dw_die_ref abbrev
= abbrev_die_table
[abbrev_id
];
4836 output_uleb128 (abbrev_id
);
4838 fprintf (asm_out_file
, " (abbrev code)");
4840 fputc ('\n', asm_out_file
);
4841 output_uleb128 (abbrev
->die_tag
);
4843 fprintf (asm_out_file
, " (TAG: %s)",
4844 dwarf_tag_name (abbrev
->die_tag
));
4846 fputc ('\n', asm_out_file
);
4847 fprintf (asm_out_file
, "\t%s\t0x%x", ASM_BYTE_OP
,
4848 abbrev
->die_child
!= NULL
? DW_children_yes
: DW_children_no
);
4851 fprintf (asm_out_file
, "\t%s %s",
4853 (abbrev
->die_child
!= NULL
4854 ? "DW_children_yes" : "DW_children_no"));
4856 fputc ('\n', asm_out_file
);
4858 for (a_attr
= abbrev
->die_attr
; a_attr
!= NULL
;
4859 a_attr
= a_attr
->dw_attr_next
)
4861 output_uleb128 (a_attr
->dw_attr
);
4863 fprintf (asm_out_file
, " (%s)",
4864 dwarf_attr_name (a_attr
->dw_attr
));
4866 fputc ('\n', asm_out_file
);
4867 output_value_format (&a_attr
->dw_attr_val
);
4870 fprintf (asm_out_file
, "\t%s\t0,0\n", ASM_BYTE_OP
);
4874 /* Output location description stack opcode's operands (if any). */
4877 output_loc_operands (loc
)
4878 register dw_loc_descr_ref loc
;
4880 register dw_val_ref val1
= &loc
->dw_loc_oprnd1
;
4881 register dw_val_ref val2
= &loc
->dw_loc_oprnd2
;
4883 switch (loc
->dw_loc_opc
)
4886 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file
, val1
->v
.val_addr
);
4887 fputc ('\n', asm_out_file
);
4891 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, val1
->v
.val_flag
);
4892 fputc ('\n', asm_out_file
);
4896 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, val1
->v
.val_int
);
4897 fputc ('\n', asm_out_file
);
4901 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, val1
->v
.val_int
);
4902 fputc ('\n', asm_out_file
);
4907 fputc ('\n', asm_out_file
);
4910 output_uleb128 (val1
->v
.val_unsigned
);
4911 fputc ('\n', asm_out_file
);
4914 output_sleb128 (val1
->v
.val_int
);
4915 fputc ('\n', asm_out_file
);
4918 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, val1
->v
.val_int
);
4919 fputc ('\n', asm_out_file
);
4921 case DW_OP_plus_uconst
:
4922 output_uleb128 (val1
->v
.val_unsigned
);
4923 fputc ('\n', asm_out_file
);
4927 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, val1
->v
.val_int
);
4928 fputc ('\n', asm_out_file
);
4962 output_sleb128 (val1
->v
.val_int
);
4963 fputc ('\n', asm_out_file
);
4966 output_uleb128 (val1
->v
.val_unsigned
);
4967 fputc ('\n', asm_out_file
);
4970 output_sleb128 (val1
->v
.val_int
);
4971 fputc ('\n', asm_out_file
);
4974 output_uleb128 (val1
->v
.val_unsigned
);
4975 fputc ('\n', asm_out_file
);
4976 output_sleb128 (val2
->v
.val_int
);
4977 fputc ('\n', asm_out_file
);
4980 output_uleb128 (val1
->v
.val_unsigned
);
4981 fputc ('\n', asm_out_file
);
4983 case DW_OP_deref_size
:
4984 case DW_OP_xderef_size
:
4985 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, val1
->v
.val_flag
);
4986 fputc ('\n', asm_out_file
);
4993 /* Compute the offset of a sibling. */
4995 static unsigned long
4996 sibling_offset (die
)
4999 unsigned long offset
;
5001 if (die
->die_child_last
== NULL
)
5002 offset
= die
->die_offset
+ size_of_die (die
);
5004 offset
= sibling_offset (die
->die_child_last
) + 1;
5009 /* Output the DIE and its attributes. Called recursively to generate
5010 the definitions of each child DIE. */
5014 register dw_die_ref die
;
5016 register dw_attr_ref a
;
5017 register dw_die_ref c
;
5018 register unsigned long ref_offset
;
5019 register unsigned long size
;
5020 register dw_loc_descr_ref loc
;
5023 output_uleb128 (die
->die_abbrev
);
5025 fprintf (asm_out_file
, " (DIE (0x%x) %s)",
5026 die
->die_offset
, dwarf_tag_name (die
->die_tag
));
5028 fputc ('\n', asm_out_file
);
5030 for (a
= die
->die_attr
; a
!= NULL
; a
= a
->dw_attr_next
)
5032 switch (a
->dw_attr_val
.val_class
)
5034 case dw_val_class_addr
:
5035 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file
,
5036 a
->dw_attr_val
.v
.val_addr
);
5039 case dw_val_class_loc
:
5040 size
= size_of_locs (a
->dw_attr_val
.v
.val_loc
);
5042 /* Output the block length for this list of location operations. */
5043 switch (constant_size (size
))
5046 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, size
);
5049 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, size
);
5056 fprintf (asm_out_file
, "\t%s %s",
5057 ASM_COMMENT_START
, dwarf_attr_name (a
->dw_attr
));
5059 fputc ('\n', asm_out_file
);
5060 for (loc
= a
->dw_attr_val
.v
.val_loc
; loc
!= NULL
;
5061 loc
= loc
->dw_loc_next
)
5063 /* Output the opcode. */
5064 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, loc
->dw_loc_opc
);
5066 fprintf (asm_out_file
, "\t%s %s", ASM_COMMENT_START
,
5067 dwarf_stack_op_name (loc
->dw_loc_opc
));
5069 fputc ('\n', asm_out_file
);
5071 /* Output the operand(s) (if any). */
5072 output_loc_operands (loc
);
5076 case dw_val_class_const
:
5077 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, a
->dw_attr_val
.v
.val_int
);
5080 case dw_val_class_unsigned_const
:
5081 switch (constant_size (a
->dw_attr_val
.v
.val_unsigned
))
5084 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
5085 a
->dw_attr_val
.v
.val_unsigned
);
5088 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
,
5089 a
->dw_attr_val
.v
.val_unsigned
);
5092 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
5093 a
->dw_attr_val
.v
.val_unsigned
);
5096 ASM_OUTPUT_DWARF_DATA8 (asm_out_file
,
5097 a
->dw_attr_val
.v
.val_long_long
.hi
,
5098 a
->dw_attr_val
.v
.val_long_long
.low
);
5105 case dw_val_class_long_long
:
5106 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 8);
5108 fprintf (asm_out_file
, "\t%s %s",
5109 ASM_COMMENT_START
, dwarf_attr_name (a
->dw_attr
));
5111 fputc ('\n', asm_out_file
);
5112 ASM_OUTPUT_DWARF_DATA8 (asm_out_file
,
5113 a
->dw_attr_val
.v
.val_long_long
.hi
,
5114 a
->dw_attr_val
.v
.val_long_long
.low
);
5117 fprintf (asm_out_file
,
5118 "\t%s long long constant", ASM_COMMENT_START
);
5120 fputc ('\n', asm_out_file
);
5123 case dw_val_class_float
:
5124 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
5125 a
->dw_attr_val
.v
.val_float
.length
* 4);
5127 fprintf (asm_out_file
, "\t%s %s",
5128 ASM_COMMENT_START
, dwarf_attr_name (a
->dw_attr
));
5130 fputc ('\n', asm_out_file
);
5131 for (i
= 0; i
< a
->dw_attr_val
.v
.val_float
.length
; ++i
)
5133 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
,
5134 a
->dw_attr_val
.v
.val_float
.array
[i
]);
5136 fprintf (asm_out_file
, "\t%s fp constant word %d",
5137 ASM_COMMENT_START
, i
);
5139 fputc ('\n', asm_out_file
);
5143 case dw_val_class_flag
:
5144 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, a
->dw_attr_val
.v
.val_flag
);
5147 case dw_val_class_die_ref
:
5148 if (a
->dw_attr_val
.v
.val_die_ref
!= NULL
)
5149 ref_offset
= a
->dw_attr_val
.v
.val_die_ref
->die_offset
;
5150 else if (a
->dw_attr
== DW_AT_sibling
)
5151 ref_offset
= sibling_offset(die
);
5155 ASM_OUTPUT_DWARF_DATA (asm_out_file
, ref_offset
);
5158 case dw_val_class_fde_ref
:
5161 ASM_GENERATE_INTERNAL_LABEL
5162 (l1
, FDE_AFTER_SIZE_LABEL
, a
->dw_attr_val
.v
.val_fde_index
* 2);
5163 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, l1
);
5164 fprintf (asm_out_file
, " - %d", DWARF_OFFSET_SIZE
);
5168 case dw_val_class_lbl_id
:
5169 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, a
->dw_attr_val
.v
.val_lbl_id
);
5172 case dw_val_class_section_offset
:
5173 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
,
5175 (a
->dw_attr_val
.v
.val_section
));
5178 case dw_val_class_str
:
5180 ASM_OUTPUT_DWARF_STRING (asm_out_file
, a
->dw_attr_val
.v
.val_str
);
5182 ASM_OUTPUT_ASCII (asm_out_file
,
5183 a
->dw_attr_val
.v
.val_str
,
5184 strlen (a
->dw_attr_val
.v
.val_str
) + 1);
5191 if (a
->dw_attr_val
.val_class
!= dw_val_class_loc
5192 && a
->dw_attr_val
.val_class
!= dw_val_class_long_long
5193 && a
->dw_attr_val
.val_class
!= dw_val_class_float
)
5196 fprintf (asm_out_file
, "\t%s %s",
5197 ASM_COMMENT_START
, dwarf_attr_name (a
->dw_attr
));
5199 fputc ('\n', asm_out_file
);
5203 for (c
= die
->die_child
; c
!= NULL
; c
= c
->die_sib
)
5206 if (die
->die_child
!= NULL
)
5208 /* Add null byte to terminate sibling list. */
5209 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5211 fprintf (asm_out_file
, "\t%s end of children of DIE 0x%x",
5212 ASM_COMMENT_START
, die
->die_offset
);
5214 fputc ('\n', asm_out_file
);
5218 /* Output the compilation unit that appears at the beginning of the
5219 .debug_info section, and precedes the DIE descriptions. */
5222 output_compilation_unit_header ()
5224 ASM_OUTPUT_DWARF_DATA (asm_out_file
, next_die_offset
- DWARF_OFFSET_SIZE
);
5226 fprintf (asm_out_file
, "\t%s Length of Compilation Unit Info.",
5229 fputc ('\n', asm_out_file
);
5230 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, DWARF_VERSION
);
5232 fprintf (asm_out_file
, "\t%s DWARF version number", ASM_COMMENT_START
);
5234 fputc ('\n', asm_out_file
);
5235 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, stripattributes (ABBREV_SECTION
));
5237 fprintf (asm_out_file
, "\t%s Offset Into Abbrev. Section",
5240 fputc ('\n', asm_out_file
);
5241 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, PTR_SIZE
);
5243 fprintf (asm_out_file
, "\t%s Pointer Size (in bytes)", ASM_COMMENT_START
);
5245 fputc ('\n', asm_out_file
);
5248 /* The DWARF2 pubname for a nested thingy looks like "A::f". The output
5249 of decl_printable_name for C++ looks like "A::f(int)". Let's drop the
5250 argument list, and maybe the scope. */
5253 dwarf2_name (decl
, scope
)
5257 return (*decl_printable_name
) (decl
, scope
? 1 : 0);
5260 /* Add a new entry to .debug_pubnames if appropriate. */
5263 add_pubname (decl
, die
)
5269 if (! TREE_PUBLIC (decl
))
5272 if (pubname_table_in_use
== pubname_table_allocated
)
5274 pubname_table_allocated
+= PUBNAME_TABLE_INCREMENT
;
5275 pubname_table
= (pubname_ref
) xrealloc
5276 (pubname_table
, pubname_table_allocated
* sizeof (pubname_entry
));
5279 p
= &pubname_table
[pubname_table_in_use
++];
5282 p
->name
= xstrdup (dwarf2_name (decl
, 1));
5285 /* Output the public names table used to speed up access to externally
5286 visible names. For now, only generate entries for externally
5287 visible procedures. */
5292 register unsigned i
;
5293 register unsigned long pubnames_length
= size_of_pubnames ();
5295 ASM_OUTPUT_DWARF_DATA (asm_out_file
, pubnames_length
);
5298 fprintf (asm_out_file
, "\t%s Length of Public Names Info.",
5301 fputc ('\n', asm_out_file
);
5302 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, DWARF_VERSION
);
5305 fprintf (asm_out_file
, "\t%s DWARF Version", ASM_COMMENT_START
);
5307 fputc ('\n', asm_out_file
);
5308 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, stripattributes (DEBUG_INFO_SECTION
));
5310 fprintf (asm_out_file
, "\t%s Offset of Compilation Unit Info.",
5313 fputc ('\n', asm_out_file
);
5314 ASM_OUTPUT_DWARF_DATA (asm_out_file
, next_die_offset
);
5316 fprintf (asm_out_file
, "\t%s Compilation Unit Length", ASM_COMMENT_START
);
5318 fputc ('\n', asm_out_file
);
5319 for (i
= 0; i
< pubname_table_in_use
; ++i
)
5321 register pubname_ref pub
= &pubname_table
[i
];
5323 ASM_OUTPUT_DWARF_DATA (asm_out_file
, pub
->die
->die_offset
);
5325 fprintf (asm_out_file
, "\t%s DIE offset", ASM_COMMENT_START
);
5327 fputc ('\n', asm_out_file
);
5331 ASM_OUTPUT_DWARF_STRING (asm_out_file
, pub
->name
);
5332 fprintf (asm_out_file
, "%s external name", ASM_COMMENT_START
);
5336 ASM_OUTPUT_ASCII (asm_out_file
, pub
->name
, strlen (pub
->name
) + 1);
5339 fputc ('\n', asm_out_file
);
5342 ASM_OUTPUT_DWARF_DATA (asm_out_file
, 0);
5343 fputc ('\n', asm_out_file
);
5346 /* Add a new entry to .debug_aranges if appropriate. */
5349 add_arange (decl
, die
)
5353 if (! DECL_SECTION_NAME (decl
))
5356 if (arange_table_in_use
== arange_table_allocated
)
5358 arange_table_allocated
+= ARANGE_TABLE_INCREMENT
;
5360 = (arange_ref
) xrealloc (arange_table
,
5361 arange_table_allocated
* sizeof (dw_die_ref
));
5364 arange_table
[arange_table_in_use
++] = die
;
5367 /* Output the information that goes into the .debug_aranges table.
5368 Namely, define the beginning and ending address range of the
5369 text section generated for this compilation unit. */
5374 register unsigned i
;
5375 register unsigned long aranges_length
= size_of_aranges ();
5377 ASM_OUTPUT_DWARF_DATA (asm_out_file
, aranges_length
);
5379 fprintf (asm_out_file
, "\t%s Length of Address Ranges Info.",
5382 fputc ('\n', asm_out_file
);
5383 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, DWARF_VERSION
);
5385 fprintf (asm_out_file
, "\t%s DWARF Version", ASM_COMMENT_START
);
5387 fputc ('\n', asm_out_file
);
5388 ASM_OUTPUT_DWARF_OFFSET (asm_out_file
, stripattributes (DEBUG_INFO_SECTION
));
5390 fprintf (asm_out_file
, "\t%s Offset of Compilation Unit Info.",
5393 fputc ('\n', asm_out_file
);
5394 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, PTR_SIZE
);
5396 fprintf (asm_out_file
, "\t%s Size of Address", ASM_COMMENT_START
);
5398 fputc ('\n', asm_out_file
);
5399 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5401 fprintf (asm_out_file
, "\t%s Size of Segment Descriptor",
5404 fputc ('\n', asm_out_file
);
5405 ASM_OUTPUT_DWARF_DATA4 (asm_out_file
, 4);
5407 fprintf (asm_out_file
, ",0,0");
5410 fprintf (asm_out_file
, "\t%s Pad to %d byte boundary",
5411 ASM_COMMENT_START
, 2 * PTR_SIZE
);
5413 fputc ('\n', asm_out_file
);
5414 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_SECTION
);
5416 fprintf (asm_out_file
, "\t%s Address", ASM_COMMENT_START
);
5418 fputc ('\n', asm_out_file
);
5419 ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file
, text_end_label
, TEXT_SECTION
);
5421 fprintf (asm_out_file
, "%s Length", ASM_COMMENT_START
);
5423 fputc ('\n', asm_out_file
);
5424 for (i
= 0; i
< arange_table_in_use
; ++i
)
5426 dw_die_ref a
= arange_table
[i
];
5428 if (a
->die_tag
== DW_TAG_subprogram
)
5429 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, get_AT_low_pc (a
));
5432 char *name
= get_AT_string (a
, DW_AT_MIPS_linkage_name
);
5434 name
= get_AT_string (a
, DW_AT_name
);
5436 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, name
);
5440 fprintf (asm_out_file
, "\t%s Address", ASM_COMMENT_START
);
5442 fputc ('\n', asm_out_file
);
5443 if (a
->die_tag
== DW_TAG_subprogram
)
5444 ASM_OUTPUT_DWARF_ADDR_DELTA (asm_out_file
, get_AT_hi_pc (a
),
5447 ASM_OUTPUT_DWARF_ADDR_DATA (asm_out_file
,
5448 get_AT_unsigned (a
, DW_AT_byte_size
));
5451 fprintf (asm_out_file
, "%s Length", ASM_COMMENT_START
);
5453 fputc ('\n', asm_out_file
);
5456 /* Output the terminator words. */
5457 ASM_OUTPUT_DWARF_ADDR_DATA (asm_out_file
, 0);
5458 fputc ('\n', asm_out_file
);
5459 ASM_OUTPUT_DWARF_ADDR_DATA (asm_out_file
, 0);
5460 fputc ('\n', asm_out_file
);
5463 /* Output the source line number correspondence information. This
5464 information goes into the .debug_line section.
5466 If the format of this data changes, then the function size_of_line_info
5467 must also be adjusted the same way. */
5472 char line_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5473 char prev_line_label
[MAX_ARTIFICIAL_LABEL_BYTES
];
5474 register unsigned opc
;
5475 register unsigned n_op_args
;
5476 register unsigned long ft_index
;
5477 register unsigned long lt_index
;
5478 register unsigned long current_line
;
5479 register long line_offset
;
5480 register long line_delta
;
5481 register unsigned long current_file
;
5482 register unsigned long function
;
5484 ASM_OUTPUT_DWARF_DATA (asm_out_file
, size_of_line_info ());
5486 fprintf (asm_out_file
, "\t%s Length of Source Line Info.",
5489 fputc ('\n', asm_out_file
);
5490 ASM_OUTPUT_DWARF_DATA2 (asm_out_file
, DWARF_VERSION
);
5492 fprintf (asm_out_file
, "\t%s DWARF Version", ASM_COMMENT_START
);
5494 fputc ('\n', asm_out_file
);
5495 ASM_OUTPUT_DWARF_DATA (asm_out_file
, size_of_line_prolog ());
5497 fprintf (asm_out_file
, "\t%s Prolog Length", ASM_COMMENT_START
);
5499 fputc ('\n', asm_out_file
);
5500 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DWARF_LINE_MIN_INSTR_LENGTH
);
5502 fprintf (asm_out_file
, "\t%s Minimum Instruction Length",
5505 fputc ('\n', asm_out_file
);
5506 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DWARF_LINE_DEFAULT_IS_STMT_START
);
5508 fprintf (asm_out_file
, "\t%s Default is_stmt_start flag",
5511 fputc ('\n', asm_out_file
);
5512 fprintf (asm_out_file
, "\t%s\t%d", ASM_BYTE_OP
, DWARF_LINE_BASE
);
5514 fprintf (asm_out_file
, "\t%s Line Base Value (Special Opcodes)",
5517 fputc ('\n', asm_out_file
);
5518 fprintf (asm_out_file
, "\t%s\t%u", ASM_BYTE_OP
, DWARF_LINE_RANGE
);
5520 fprintf (asm_out_file
, "\t%s Line Range Value (Special Opcodes)",
5523 fputc ('\n', asm_out_file
);
5524 fprintf (asm_out_file
, "\t%s\t%u", ASM_BYTE_OP
, DWARF_LINE_OPCODE_BASE
);
5526 fprintf (asm_out_file
, "\t%s Special Opcode Base", ASM_COMMENT_START
);
5528 fputc ('\n', asm_out_file
);
5529 for (opc
= 1; opc
< DWARF_LINE_OPCODE_BASE
; ++opc
)
5533 case DW_LNS_advance_pc
:
5534 case DW_LNS_advance_line
:
5535 case DW_LNS_set_file
:
5536 case DW_LNS_set_column
:
5537 case DW_LNS_fixed_advance_pc
:
5544 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, n_op_args
);
5546 fprintf (asm_out_file
, "\t%s opcode: 0x%x has %d args",
5547 ASM_COMMENT_START
, opc
, n_op_args
);
5548 fputc ('\n', asm_out_file
);
5552 fprintf (asm_out_file
, "%s Include Directory Table\n", ASM_COMMENT_START
);
5554 /* Include directory table is empty, at present */
5555 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5556 fputc ('\n', asm_out_file
);
5558 fprintf (asm_out_file
, "%s File Name Table\n", ASM_COMMENT_START
);
5560 for (ft_index
= 1; ft_index
< file_table_in_use
; ++ft_index
)
5564 ASM_OUTPUT_DWARF_STRING (asm_out_file
, file_table
[ft_index
]);
5565 fprintf (asm_out_file
, "%s File Entry: 0x%x",
5566 ASM_COMMENT_START
, ft_index
);
5570 ASM_OUTPUT_ASCII (asm_out_file
,
5571 file_table
[ft_index
],
5572 strlen (file_table
[ft_index
]) + 1);
5575 fputc ('\n', asm_out_file
);
5577 /* Include directory index */
5579 fputc ('\n', asm_out_file
);
5581 /* Modification time */
5583 fputc ('\n', asm_out_file
);
5585 /* File length in bytes */
5587 fputc ('\n', asm_out_file
);
5590 /* Terminate the file name table */
5591 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5592 fputc ('\n', asm_out_file
);
5594 /* Set the address register to the first location in the text section */
5595 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5597 fprintf (asm_out_file
, "\t%s DW_LNE_set_address", ASM_COMMENT_START
);
5599 fputc ('\n', asm_out_file
);
5600 output_uleb128 (1 + PTR_SIZE
);
5601 fputc ('\n', asm_out_file
);
5602 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_set_address
);
5603 fputc ('\n', asm_out_file
);
5604 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, TEXT_SECTION
);
5605 fputc ('\n', asm_out_file
);
5607 /* Generate the line number to PC correspondence table, encoded as
5608 a series of state machine operations. */
5611 strcpy (prev_line_label
, TEXT_SECTION
);
5612 for (lt_index
= 1; lt_index
< line_info_table_in_use
; ++lt_index
)
5614 register dw_line_info_ref line_info
;
5616 /* Emit debug info for the address of the current line, choosing
5617 the encoding that uses the least amount of space. */
5618 /* ??? Unfortunately, we have little choice here currently, and must
5619 always use the most general form. Gcc does not know the address
5620 delta itself, so we can't use DW_LNS_advance_pc. There are no known
5621 dwarf2 aware assemblers at this time, so we can't use any special
5622 pseudo ops that would allow the assembler to optimally encode this for
5623 us. Many ports do have length attributes which will give an upper
5624 bound on the address range. We could perhaps use length attributes
5625 to determine when it is safe to use DW_LNS_fixed_advance_pc. */
5626 ASM_GENERATE_INTERNAL_LABEL (line_label
, LINE_CODE_LABEL
, lt_index
);
5629 /* This can handle deltas up to 0xffff. This takes 3 bytes. */
5630 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_fixed_advance_pc
);
5632 fprintf (asm_out_file
, "\t%s DW_LNS_fixed_advance_pc",
5635 fputc ('\n', asm_out_file
);
5636 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, line_label
, prev_line_label
);
5637 fputc ('\n', asm_out_file
);
5641 /* This can handle any delta. This takes 4+PTR_SIZE bytes. */
5642 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5644 fprintf (asm_out_file
, "\t%s DW_LNE_set_address",
5646 fputc ('\n', asm_out_file
);
5647 output_uleb128 (1 + PTR_SIZE
);
5648 fputc ('\n', asm_out_file
);
5649 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_set_address
);
5650 fputc ('\n', asm_out_file
);
5651 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, line_label
);
5652 fputc ('\n', asm_out_file
);
5654 strcpy (prev_line_label
, line_label
);
5656 /* Emit debug info for the source file of the current line, if
5657 different from the previous line. */
5658 line_info
= &line_info_table
[lt_index
];
5659 if (line_info
->dw_file_num
!= current_file
)
5661 current_file
= line_info
->dw_file_num
;
5662 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_set_file
);
5664 fprintf (asm_out_file
, "\t%s DW_LNS_set_file", ASM_COMMENT_START
);
5666 fputc ('\n', asm_out_file
);
5667 output_uleb128 (current_file
);
5669 fprintf (asm_out_file
, " (\"%s\")", file_table
[current_file
]);
5671 fputc ('\n', asm_out_file
);
5674 /* Emit debug info for the current line number, choosing the encoding
5675 that uses the least amount of space. */
5676 line_offset
= line_info
->dw_line_num
- current_line
;
5677 line_delta
= line_offset
- DWARF_LINE_BASE
;
5678 current_line
= line_info
->dw_line_num
;
5679 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
5681 /* This can handle deltas from -10 to 234, using the current
5682 definitions of DWARF_LINE_BASE and DWARF_LINE_RANGE. This
5684 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
5685 DWARF_LINE_OPCODE_BASE
+ line_delta
);
5687 fprintf (asm_out_file
,
5688 "\t%s line %d", ASM_COMMENT_START
, current_line
);
5690 fputc ('\n', asm_out_file
);
5694 /* This can handle any delta. This takes at least 4 bytes, depending
5695 on the value being encoded. */
5696 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_advance_line
);
5698 fprintf (asm_out_file
, "\t%s advance to line %d",
5699 ASM_COMMENT_START
, current_line
);
5701 fputc ('\n', asm_out_file
);
5702 output_sleb128 (line_offset
);
5703 fputc ('\n', asm_out_file
);
5704 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_copy
);
5705 fputc ('\n', asm_out_file
);
5709 /* Emit debug info for the address of the end of the function. */
5712 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_fixed_advance_pc
);
5714 fprintf (asm_out_file
, "\t%s DW_LNS_fixed_advance_pc",
5717 fputc ('\n', asm_out_file
);
5718 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, text_end_label
, prev_line_label
);
5719 fputc ('\n', asm_out_file
);
5723 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5725 fprintf (asm_out_file
, "\t%s DW_LNE_set_address", ASM_COMMENT_START
);
5726 fputc ('\n', asm_out_file
);
5727 output_uleb128 (1 + PTR_SIZE
);
5728 fputc ('\n', asm_out_file
);
5729 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_set_address
);
5730 fputc ('\n', asm_out_file
);
5731 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, text_end_label
);
5732 fputc ('\n', asm_out_file
);
5735 /* Output the marker for the end of the line number info. */
5736 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5738 fprintf (asm_out_file
, "\t%s DW_LNE_end_sequence", ASM_COMMENT_START
);
5740 fputc ('\n', asm_out_file
);
5742 fputc ('\n', asm_out_file
);
5743 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_end_sequence
);
5744 fputc ('\n', asm_out_file
);
5749 for (lt_index
= 0; lt_index
< separate_line_info_table_in_use
; )
5751 register dw_separate_line_info_ref line_info
5752 = &separate_line_info_table
[lt_index
];
5754 /* Emit debug info for the address of the current line. If this is
5755 a new function, or the first line of a function, then we need
5756 to handle it differently. */
5757 ASM_GENERATE_INTERNAL_LABEL (line_label
, SEPARATE_LINE_CODE_LABEL
,
5759 if (function
!= line_info
->function
)
5761 function
= line_info
->function
;
5763 /* Set the address register to the first line in the function */
5764 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5766 fprintf (asm_out_file
, "\t%s DW_LNE_set_address",
5769 fputc ('\n', asm_out_file
);
5770 output_uleb128 (1 + PTR_SIZE
);
5771 fputc ('\n', asm_out_file
);
5772 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_set_address
);
5773 fputc ('\n', asm_out_file
);
5774 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, line_label
);
5775 fputc ('\n', asm_out_file
);
5779 /* ??? See the DW_LNS_advance_pc comment above. */
5782 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_fixed_advance_pc
);
5784 fprintf (asm_out_file
, "\t%s DW_LNS_fixed_advance_pc",
5787 fputc ('\n', asm_out_file
);
5788 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, line_label
,
5790 fputc ('\n', asm_out_file
);
5794 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5796 fprintf (asm_out_file
, "\t%s DW_LNE_set_address",
5798 fputc ('\n', asm_out_file
);
5799 output_uleb128 (1 + PTR_SIZE
);
5800 fputc ('\n', asm_out_file
);
5801 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_set_address
);
5802 fputc ('\n', asm_out_file
);
5803 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, line_label
);
5804 fputc ('\n', asm_out_file
);
5807 strcpy (prev_line_label
, line_label
);
5809 /* Emit debug info for the source file of the current line, if
5810 different from the previous line. */
5811 if (line_info
->dw_file_num
!= current_file
)
5813 current_file
= line_info
->dw_file_num
;
5814 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_set_file
);
5816 fprintf (asm_out_file
, "\t%s DW_LNS_set_file", ASM_COMMENT_START
);
5818 fputc ('\n', asm_out_file
);
5819 output_uleb128 (current_file
);
5821 fprintf (asm_out_file
, " (\"%s\")", file_table
[current_file
]);
5823 fputc ('\n', asm_out_file
);
5826 /* Emit debug info for the current line number, choosing the encoding
5827 that uses the least amount of space. */
5828 if (line_info
->dw_line_num
!= current_line
)
5830 line_offset
= line_info
->dw_line_num
- current_line
;
5831 line_delta
= line_offset
- DWARF_LINE_BASE
;
5832 current_line
= line_info
->dw_line_num
;
5833 if (line_delta
>= 0 && line_delta
< (DWARF_LINE_RANGE
- 1))
5835 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
,
5836 DWARF_LINE_OPCODE_BASE
+ line_delta
);
5838 fprintf (asm_out_file
,
5839 "\t%s line %d", ASM_COMMENT_START
, current_line
);
5841 fputc ('\n', asm_out_file
);
5845 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_advance_line
);
5847 fprintf (asm_out_file
, "\t%s advance to line %d",
5848 ASM_COMMENT_START
, current_line
);
5850 fputc ('\n', asm_out_file
);
5851 output_sleb128 (line_offset
);
5852 fputc ('\n', asm_out_file
);
5853 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_copy
);
5854 fputc ('\n', asm_out_file
);
5860 /* If we're done with a function, end its sequence. */
5861 if (lt_index
== separate_line_info_table_in_use
5862 || separate_line_info_table
[lt_index
].function
!= function
)
5867 /* Emit debug info for the address of the end of the function. */
5868 ASM_GENERATE_INTERNAL_LABEL (line_label
, FUNC_END_LABEL
, function
);
5871 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNS_fixed_advance_pc
);
5873 fprintf (asm_out_file
, "\t%s DW_LNS_fixed_advance_pc",
5876 fputc ('\n', asm_out_file
);
5877 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file
, line_label
,
5879 fputc ('\n', asm_out_file
);
5883 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5885 fprintf (asm_out_file
, "\t%s DW_LNE_set_address",
5887 fputc ('\n', asm_out_file
);
5888 output_uleb128 (1 + PTR_SIZE
);
5889 fputc ('\n', asm_out_file
);
5890 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_set_address
);
5891 fputc ('\n', asm_out_file
);
5892 ASM_OUTPUT_DWARF_ADDR (asm_out_file
, line_label
);
5893 fputc ('\n', asm_out_file
);
5896 /* Output the marker for the end of this sequence. */
5897 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, 0);
5899 fprintf (asm_out_file
, "\t%s DW_LNE_end_sequence",
5902 fputc ('\n', asm_out_file
);
5904 fputc ('\n', asm_out_file
);
5905 ASM_OUTPUT_DWARF_DATA1 (asm_out_file
, DW_LNE_end_sequence
);
5906 fputc ('\n', asm_out_file
);
5911 /* Given a pointer to a BLOCK node return non-zero if (and only if) the node
5912 in question represents the outermost pair of curly braces (i.e. the "body
5913 block") of a function or method.
5915 For any BLOCK node representing a "body block" of a function or method, the
5916 BLOCK_SUPERCONTEXT of the node will point to another BLOCK node which
5917 represents the outermost (function) scope for the function or method (i.e.
5918 the one which includes the formal parameters). The BLOCK_SUPERCONTEXT of
5919 *that* node in turn will point to the relevant FUNCTION_DECL node. */
5922 is_body_block (stmt
)
5925 if (TREE_CODE (stmt
) == BLOCK
)
5927 register tree parent
= BLOCK_SUPERCONTEXT (stmt
);
5929 if (TREE_CODE (parent
) == BLOCK
)
5931 register tree grandparent
= BLOCK_SUPERCONTEXT (parent
);
5933 if (TREE_CODE (grandparent
) == FUNCTION_DECL
)
5941 /* Given a pointer to a tree node for some base type, return a pointer to
5942 a DIE that describes the given type.
5944 This routine must only be called for GCC type nodes that correspond to
5945 Dwarf base (fundamental) types. */
5948 base_type_die (type
)
5951 register dw_die_ref base_type_result
;
5952 register char *type_name
;
5953 register enum dwarf_type encoding
;
5954 register tree name
= TYPE_NAME (type
);
5956 if (TREE_CODE (type
) == ERROR_MARK
5957 || TREE_CODE (type
) == VOID_TYPE
)
5960 if (TREE_CODE (name
) == TYPE_DECL
)
5961 name
= DECL_NAME (name
);
5962 type_name
= IDENTIFIER_POINTER (name
);
5964 switch (TREE_CODE (type
))
5967 /* Carefully distinguish the C character types, without messing
5968 up if the language is not C. Note that we check only for the names
5969 that contain spaces; other names might occur by coincidence in other
5971 if (! (TYPE_PRECISION (type
) == CHAR_TYPE_SIZE
5972 && (type
== char_type_node
5973 || ! strcmp (type_name
, "signed char")
5974 || ! strcmp (type_name
, "unsigned char"))))
5976 if (TREE_UNSIGNED (type
))
5977 encoding
= DW_ATE_unsigned
;
5979 encoding
= DW_ATE_signed
;
5982 /* else fall through */
5985 /* GNU Pascal/Ada CHAR type. Not used in C. */
5986 if (TREE_UNSIGNED (type
))
5987 encoding
= DW_ATE_unsigned_char
;
5989 encoding
= DW_ATE_signed_char
;
5993 encoding
= DW_ATE_float
;
5997 encoding
= DW_ATE_complex_float
;
6001 /* GNU FORTRAN/Ada/C++ BOOLEAN type. */
6002 encoding
= DW_ATE_boolean
;
6006 abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
6009 base_type_result
= new_die (DW_TAG_base_type
, comp_unit_die
);
6010 add_AT_string (base_type_result
, DW_AT_name
, type_name
);
6011 add_AT_unsigned (base_type_result
, DW_AT_byte_size
,
6012 TYPE_PRECISION (type
) / BITS_PER_UNIT
);
6013 add_AT_unsigned (base_type_result
, DW_AT_encoding
, encoding
);
6015 return base_type_result
;
6018 /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
6019 the Dwarf "root" type for the given input type. The Dwarf "root" type of
6020 a given type is generally the same as the given type, except that if the
6021 given type is a pointer or reference type, then the root type of the given
6022 type is the root type of the "basis" type for the pointer or reference
6023 type. (This definition of the "root" type is recursive.) Also, the root
6024 type of a `const' qualified type or a `volatile' qualified type is the
6025 root type of the given type without the qualifiers. */
6031 if (TREE_CODE (type
) == ERROR_MARK
)
6032 return error_mark_node
;
6034 switch (TREE_CODE (type
))
6037 return error_mark_node
;
6040 case REFERENCE_TYPE
:
6041 return type_main_variant (root_type (TREE_TYPE (type
)));
6044 return type_main_variant (type
);
6048 /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
6049 given input type is a Dwarf "fundamental" type. Otherwise return null. */
6055 switch (TREE_CODE (type
))
6070 case QUAL_UNION_TYPE
:
6075 case REFERENCE_TYPE
:
6088 /* Given a pointer to an arbitrary ..._TYPE tree node, return a debugging
6089 entry that chains various modifiers in front of the given type. */
6092 modified_type_die (type
, is_const_type
, is_volatile_type
, context_die
)
6094 register int is_const_type
;
6095 register int is_volatile_type
;
6096 register dw_die_ref context_die
;
6098 register enum tree_code code
= TREE_CODE (type
);
6099 register dw_die_ref mod_type_die
= NULL
;
6100 register dw_die_ref sub_die
= NULL
;
6101 register tree item_type
= NULL
;
6103 if (code
!= ERROR_MARK
)
6105 type
= build_type_variant (type
, is_const_type
, is_volatile_type
);
6107 mod_type_die
= lookup_type_die (type
);
6109 return mod_type_die
;
6111 /* Handle C typedef types. */
6112 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
6113 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
6115 tree dtype
= TREE_TYPE (TYPE_NAME (type
));
6118 /* For a named type, use the typedef. */
6119 gen_type_die (type
, context_die
);
6120 mod_type_die
= lookup_type_die (type
);
6123 else if (is_const_type
< TYPE_READONLY (dtype
)
6124 || is_volatile_type
< TYPE_VOLATILE (dtype
))
6125 /* cv-unqualified version of named type. Just use the unnamed
6126 type to which it refers. */
6128 = modified_type_die (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)),
6129 is_const_type
, is_volatile_type
,
6131 /* Else cv-qualified version of named type; fall through. */
6136 else if (is_const_type
)
6138 mod_type_die
= new_die (DW_TAG_const_type
, comp_unit_die
);
6139 sub_die
= modified_type_die (type
, 0, is_volatile_type
, context_die
);
6141 else if (is_volatile_type
)
6143 mod_type_die
= new_die (DW_TAG_volatile_type
, comp_unit_die
);
6144 sub_die
= modified_type_die (type
, 0, 0, context_die
);
6146 else if (code
== POINTER_TYPE
)
6148 mod_type_die
= new_die (DW_TAG_pointer_type
, comp_unit_die
);
6149 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
6151 add_AT_unsigned (mod_type_die
, DW_AT_address_class
, 0);
6153 item_type
= TREE_TYPE (type
);
6155 else if (code
== REFERENCE_TYPE
)
6157 mod_type_die
= new_die (DW_TAG_reference_type
, comp_unit_die
);
6158 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
6160 add_AT_unsigned (mod_type_die
, DW_AT_address_class
, 0);
6162 item_type
= TREE_TYPE (type
);
6164 else if (is_base_type (type
))
6165 mod_type_die
= base_type_die (type
);
6168 gen_type_die (type
, context_die
);
6170 /* We have to get the type_main_variant here (and pass that to the
6171 `lookup_type_die' routine) because the ..._TYPE node we have
6172 might simply be a *copy* of some original type node (where the
6173 copy was created to help us keep track of typedef names) and
6174 that copy might have a different TYPE_UID from the original
6176 mod_type_die
= lookup_type_die (type_main_variant (type
));
6177 if (mod_type_die
== NULL
)
6182 equate_type_number_to_die (type
, mod_type_die
);
6184 /* We must do this after the equate_type_number_to_die call, in case
6185 this is a recursive type. This ensures that the modified_type_die
6186 recursion will terminate even if the type is recursive. Recursive
6187 types are possible in Ada. */
6188 sub_die
= modified_type_die (item_type
,
6189 TYPE_READONLY (item_type
),
6190 TYPE_VOLATILE (item_type
),
6193 if (sub_die
!= NULL
)
6194 add_AT_die_ref (mod_type_die
, DW_AT_type
, sub_die
);
6196 return mod_type_die
;
6199 /* Given a pointer to an arbitrary ..._TYPE tree node, return true if it is
6200 an enumerated type. */
6206 return TREE_CODE (type
) == ENUMERAL_TYPE
;
6209 /* Return a location descriptor that designates a machine register. */
6211 static dw_loc_descr_ref
6212 reg_loc_descriptor (rtl
)
6215 register dw_loc_descr_ref loc_result
= NULL
;
6216 register unsigned reg
= reg_number (rtl
);
6218 if (reg
>= 0 && reg
<= 31)
6219 loc_result
= new_loc_descr (DW_OP_reg0
+ reg
, 0, 0);
6221 loc_result
= new_loc_descr (DW_OP_regx
, reg
, 0);
6226 /* Return a location descriptor that designates a base+offset location. */
6228 static dw_loc_descr_ref
6229 based_loc_descr (reg
, offset
)
6233 register dw_loc_descr_ref loc_result
;
6234 /* For the "frame base", we use the frame pointer or stack pointer
6235 registers, since the RTL for local variables is relative to one of
6237 register unsigned fp_reg
= DBX_REGISTER_NUMBER (frame_pointer_needed
6238 ? HARD_FRAME_POINTER_REGNUM
6239 : STACK_POINTER_REGNUM
);
6242 loc_result
= new_loc_descr (DW_OP_fbreg
, offset
, 0);
6243 else if (reg
>= 0 && reg
<= 31)
6244 loc_result
= new_loc_descr (DW_OP_breg0
+ reg
, offset
, 0);
6246 loc_result
= new_loc_descr (DW_OP_bregx
, reg
, offset
);
6251 /* Return true if this RTL expression describes a base+offset calculation. */
6257 return (GET_CODE (rtl
) == PLUS
6258 && ((GET_CODE (XEXP (rtl
, 0)) == REG
6259 && GET_CODE (XEXP (rtl
, 1)) == CONST_INT
)));
6262 /* The following routine converts the RTL for a variable or parameter
6263 (resident in memory) into an equivalent Dwarf representation of a
6264 mechanism for getting the address of that same variable onto the top of a
6265 hypothetical "address evaluation" stack.
6267 When creating memory location descriptors, we are effectively transforming
6268 the RTL for a memory-resident object into its Dwarf postfix expression
6269 equivalent. This routine recursively descends an RTL tree, turning
6270 it into Dwarf postfix code as it goes. */
6272 static dw_loc_descr_ref
6273 mem_loc_descriptor (rtl
)
6276 dw_loc_descr_ref mem_loc_result
= NULL
;
6277 /* Note that for a dynamically sized array, the location we will generate a
6278 description of here will be the lowest numbered location which is
6279 actually within the array. That's *not* necessarily the same as the
6280 zeroth element of the array. */
6282 switch (GET_CODE (rtl
))
6285 /* The case of a subreg may arise when we have a local (register)
6286 variable or a formal (register) parameter which doesn't quite fill
6287 up an entire register. For now, just assume that it is
6288 legitimate to make the Dwarf info refer to the whole register which
6289 contains the given subreg. */
6290 rtl
= XEXP (rtl
, 0);
6292 /* ... fall through ... */
6295 /* Whenever a register number forms a part of the description of the
6296 method for calculating the (dynamic) address of a memory resident
6297 object, DWARF rules require the register number be referred to as
6298 a "base register". This distinction is not based in any way upon
6299 what category of register the hardware believes the given register
6300 belongs to. This is strictly DWARF terminology we're dealing with
6301 here. Note that in cases where the location of a memory-resident
6302 data object could be expressed as: OP_ADD (OP_BASEREG (basereg),
6303 OP_CONST (0)) the actual DWARF location descriptor that we generate
6304 may just be OP_BASEREG (basereg). This may look deceptively like
6305 the object in question was allocated to a register (rather than in
6306 memory) so DWARF consumers need to be aware of the subtle
6307 distinction between OP_REG and OP_BASEREG. */
6308 mem_loc_result
= based_loc_descr (reg_number (rtl
), 0);
6312 mem_loc_result
= mem_loc_descriptor (XEXP (rtl
, 0));
6313 add_loc_descr (&mem_loc_result
, new_loc_descr (DW_OP_deref
, 0, 0));
6318 mem_loc_result
= new_loc_descr (DW_OP_addr
, 0, 0);
6319 mem_loc_result
->dw_loc_oprnd1
.val_class
= dw_val_class_addr
;
6320 mem_loc_result
->dw_loc_oprnd1
.v
.val_addr
= addr_to_string (rtl
);
6324 if (is_based_loc (rtl
))
6325 mem_loc_result
= based_loc_descr (reg_number (XEXP (rtl
, 0)),
6326 INTVAL (XEXP (rtl
, 1)));
6329 add_loc_descr (&mem_loc_result
, mem_loc_descriptor (XEXP (rtl
, 0)));
6330 add_loc_descr (&mem_loc_result
, mem_loc_descriptor (XEXP (rtl
, 1)));
6331 add_loc_descr (&mem_loc_result
, new_loc_descr (DW_OP_plus
, 0, 0));
6336 /* If a pseudo-reg is optimized away, it is possible for it to
6337 be replaced with a MEM containing a multiply. */
6338 add_loc_descr (&mem_loc_result
, mem_loc_descriptor (XEXP (rtl
, 0)));
6339 add_loc_descr (&mem_loc_result
, mem_loc_descriptor (XEXP (rtl
, 1)));
6340 add_loc_descr (&mem_loc_result
, new_loc_descr (DW_OP_mul
, 0, 0));
6344 mem_loc_result
= new_loc_descr (DW_OP_constu
, INTVAL (rtl
), 0);
6351 return mem_loc_result
;
6354 /* Return a descriptor that describes the concatination of two locations.
6355 This is typically a complex variable. */
6357 static dw_loc_descr_ref
6358 concat_loc_descriptor (x0
, x1
)
6359 register rtx x0
, x1
;
6361 dw_loc_descr_ref cc_loc_result
= NULL
;
6363 if (!is_pseudo_reg (x0
)
6364 && (GET_CODE (x0
) != MEM
|| !is_pseudo_reg (XEXP (x0
, 0))))
6365 add_loc_descr (&cc_loc_result
, loc_descriptor (x0
));
6366 add_loc_descr (&cc_loc_result
,
6367 new_loc_descr (DW_OP_piece
, GET_MODE_SIZE (GET_MODE (x0
)), 0));
6369 if (!is_pseudo_reg (x1
)
6370 && (GET_CODE (x1
) != MEM
|| !is_pseudo_reg (XEXP (x1
, 0))))
6371 add_loc_descr (&cc_loc_result
, loc_descriptor (x1
));
6372 add_loc_descr (&cc_loc_result
,
6373 new_loc_descr (DW_OP_piece
, GET_MODE_SIZE (GET_MODE (x1
)), 0));
6375 return cc_loc_result
;
6378 /* Output a proper Dwarf location descriptor for a variable or parameter
6379 which is either allocated in a register or in a memory location. For a
6380 register, we just generate an OP_REG and the register number. For a
6381 memory location we provide a Dwarf postfix expression describing how to
6382 generate the (dynamic) address of the object onto the address stack. */
6384 static dw_loc_descr_ref
6385 loc_descriptor (rtl
)
6388 dw_loc_descr_ref loc_result
= NULL
;
6389 switch (GET_CODE (rtl
))
6392 /* The case of a subreg may arise when we have a local (register)
6393 variable or a formal (register) parameter which doesn't quite fill
6394 up an entire register. For now, just assume that it is
6395 legitimate to make the Dwarf info refer to the whole register which
6396 contains the given subreg. */
6397 rtl
= XEXP (rtl
, 0);
6399 /* ... fall through ... */
6402 loc_result
= reg_loc_descriptor (rtl
);
6406 loc_result
= mem_loc_descriptor (XEXP (rtl
, 0));
6410 loc_result
= concat_loc_descriptor (XEXP (rtl
, 0), XEXP (rtl
, 1));
6420 /* Given an unsigned value, round it up to the lowest multiple of `boundary'
6421 which is not less than the value itself. */
6423 static inline unsigned
6424 ceiling (value
, boundary
)
6425 register unsigned value
;
6426 register unsigned boundary
;
6428 return (((value
+ boundary
- 1) / boundary
) * boundary
);
6431 /* Given a pointer to what is assumed to be a FIELD_DECL node, return a
6432 pointer to the declared type for the relevant field variable, or return
6433 `integer_type_node' if the given node turns out to be an
6442 if (TREE_CODE (decl
) == ERROR_MARK
)
6443 return integer_type_node
;
6445 type
= DECL_BIT_FIELD_TYPE (decl
);
6446 if (type
== NULL_TREE
)
6447 type
= TREE_TYPE (decl
);
6452 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
6453 node, return the alignment in bits for the type, or else return
6454 BITS_PER_WORD if the node actually turns out to be an
6457 static inline unsigned
6458 simple_type_align_in_bits (type
)
6461 return (TREE_CODE (type
) != ERROR_MARK
) ? TYPE_ALIGN (type
) : BITS_PER_WORD
;
6464 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
6465 node, return the size in bits for the type if it is a constant, or else
6466 return the alignment for the type if the type's size is not constant, or
6467 else return BITS_PER_WORD if the type actually turns out to be an
6470 static inline unsigned
6471 simple_type_size_in_bits (type
)
6474 if (TREE_CODE (type
) == ERROR_MARK
)
6475 return BITS_PER_WORD
;
6478 register tree type_size_tree
= TYPE_SIZE (type
);
6480 if (TREE_CODE (type_size_tree
) != INTEGER_CST
)
6481 return TYPE_ALIGN (type
);
6483 return (unsigned) TREE_INT_CST_LOW (type_size_tree
);
6487 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
6488 return the byte offset of the lowest addressed byte of the "containing
6489 object" for the given FIELD_DECL, or return 0 if we are unable to
6490 determine what that offset is, either because the argument turns out to
6491 be a pointer to an ERROR_MARK node, or because the offset is actually
6492 variable. (We can't handle the latter case just yet). */
6495 field_byte_offset (decl
)
6498 register unsigned type_align_in_bytes
;
6499 register unsigned type_align_in_bits
;
6500 register unsigned type_size_in_bits
;
6501 register unsigned object_offset_in_align_units
;
6502 register unsigned object_offset_in_bits
;
6503 register unsigned object_offset_in_bytes
;
6505 register tree bitpos_tree
;
6506 register tree field_size_tree
;
6507 register unsigned bitpos_int
;
6508 register unsigned deepest_bitpos
;
6509 register unsigned field_size_in_bits
;
6511 if (TREE_CODE (decl
) == ERROR_MARK
)
6514 if (TREE_CODE (decl
) != FIELD_DECL
)
6517 type
= field_type (decl
);
6519 bitpos_tree
= DECL_FIELD_BITPOS (decl
);
6520 field_size_tree
= DECL_SIZE (decl
);
6522 /* We cannot yet cope with fields whose positions or sizes are variable, so
6523 for now, when we see such things, we simply return 0. Someday, we may
6524 be able to handle such cases, but it will be damn difficult. */
6525 if (TREE_CODE (bitpos_tree
) != INTEGER_CST
)
6527 bitpos_int
= (unsigned) TREE_INT_CST_LOW (bitpos_tree
);
6529 if (TREE_CODE (field_size_tree
) != INTEGER_CST
)
6532 field_size_in_bits
= (unsigned) TREE_INT_CST_LOW (field_size_tree
);
6533 type_size_in_bits
= simple_type_size_in_bits (type
);
6534 type_align_in_bits
= simple_type_align_in_bits (type
);
6535 type_align_in_bytes
= type_align_in_bits
/ BITS_PER_UNIT
;
6537 /* Note that the GCC front-end doesn't make any attempt to keep track of
6538 the starting bit offset (relative to the start of the containing
6539 structure type) of the hypothetical "containing object" for a bit-
6540 field. Thus, when computing the byte offset value for the start of the
6541 "containing object" of a bit-field, we must deduce this information on
6542 our own. This can be rather tricky to do in some cases. For example,
6543 handling the following structure type definition when compiling for an
6544 i386/i486 target (which only aligns long long's to 32-bit boundaries)
6547 struct S { int field1; long long field2:31; };
6549 Fortunately, there is a simple rule-of-thumb which can be
6550 used in such cases. When compiling for an i386/i486, GCC will allocate
6551 8 bytes for the structure shown above. It decides to do this based upon
6552 one simple rule for bit-field allocation. Quite simply, GCC allocates
6553 each "containing object" for each bit-field at the first (i.e. lowest
6554 addressed) legitimate alignment boundary (based upon the required
6555 minimum alignment for the declared type of the field) which it can
6556 possibly use, subject to the condition that there is still enough
6557 available space remaining in the containing object (when allocated at
6558 the selected point) to fully accommodate all of the bits of the
6559 bit-field itself. This simple rule makes it obvious why GCC allocates
6560 8 bytes for each object of the structure type shown above. When looking
6561 for a place to allocate the "containing object" for `field2', the
6562 compiler simply tries to allocate a 64-bit "containing object" at each
6563 successive 32-bit boundary (starting at zero) until it finds a place to
6564 allocate that 64- bit field such that at least 31 contiguous (and
6565 previously unallocated) bits remain within that selected 64 bit field.
6566 (As it turns out, for the example above, the compiler finds that it is
6567 OK to allocate the "containing object" 64-bit field at bit-offset zero
6568 within the structure type.) Here we attempt to work backwards from the
6569 limited set of facts we're given, and we try to deduce from those facts,
6570 where GCC must have believed that the containing object started (within
6571 the structure type). The value we deduce is then used (by the callers of
6572 this routine) to generate DW_AT_location and DW_AT_bit_offset attributes
6573 for fields (both bit-fields and, in the case of DW_AT_location, regular
6576 /* Figure out the bit-distance from the start of the structure to the
6577 "deepest" bit of the bit-field. */
6578 deepest_bitpos
= bitpos_int
+ field_size_in_bits
;
6580 /* This is the tricky part. Use some fancy footwork to deduce where the
6581 lowest addressed bit of the containing object must be. */
6582 object_offset_in_bits
6583 = ceiling (deepest_bitpos
, type_align_in_bits
) - type_size_in_bits
;
6585 /* Compute the offset of the containing object in "alignment units". */
6586 object_offset_in_align_units
= object_offset_in_bits
/ type_align_in_bits
;
6588 /* Compute the offset of the containing object in bytes. */
6589 object_offset_in_bytes
= object_offset_in_align_units
* type_align_in_bytes
;
6591 return object_offset_in_bytes
;
6594 /* The following routines define various Dwarf attributes and any data
6595 associated with them. */
6597 /* Add a location description attribute value to a DIE.
6599 This emits location attributes suitable for whole variables and
6600 whole parameters. Note that the location attributes for struct fields are
6601 generated by the routine `data_member_location_attribute' below. */
6604 add_AT_location_description (die
, attr_kind
, rtl
)
6606 enum dwarf_attribute attr_kind
;
6609 /* Handle a special case. If we are about to output a location descriptor
6610 for a variable or parameter which has been optimized out of existence,
6611 don't do that. A variable which has been optimized out
6612 of existence will have a DECL_RTL value which denotes a pseudo-reg.
6613 Currently, in some rare cases, variables can have DECL_RTL values which
6614 look like (MEM (REG pseudo-reg#)). These cases are due to bugs
6615 elsewhere in the compiler. We treat such cases as if the variable(s) in
6616 question had been optimized out of existence. */
6618 if (is_pseudo_reg (rtl
)
6619 || (GET_CODE (rtl
) == MEM
6620 && is_pseudo_reg (XEXP (rtl
, 0)))
6621 || (GET_CODE (rtl
) == CONCAT
6622 && is_pseudo_reg (XEXP (rtl
, 0))
6623 && is_pseudo_reg (XEXP (rtl
, 1))))
6626 add_AT_loc (die
, attr_kind
, loc_descriptor (rtl
));
6629 /* Attach the specialized form of location attribute used for data
6630 members of struct and union types. In the special case of a
6631 FIELD_DECL node which represents a bit-field, the "offset" part
6632 of this special location descriptor must indicate the distance
6633 in bytes from the lowest-addressed byte of the containing struct
6634 or union type to the lowest-addressed byte of the "containing
6635 object" for the bit-field. (See the `field_byte_offset' function
6636 above).. For any given bit-field, the "containing object" is a
6637 hypothetical object (of some integral or enum type) within which
6638 the given bit-field lives. The type of this hypothetical
6639 "containing object" is always the same as the declared type of
6640 the individual bit-field itself (for GCC anyway... the DWARF
6641 spec doesn't actually mandate this). Note that it is the size
6642 (in bytes) of the hypothetical "containing object" which will
6643 be given in the DW_AT_byte_size attribute for this bit-field.
6644 (See the `byte_size_attribute' function below.) It is also used
6645 when calculating the value of the DW_AT_bit_offset attribute.
6646 (See the `bit_offset_attribute' function below). */
6649 add_data_member_location_attribute (die
, decl
)
6650 register dw_die_ref die
;
6653 register unsigned long offset
;
6654 register dw_loc_descr_ref loc_descr
;
6655 register enum dwarf_location_atom op
;
6657 if (TREE_CODE (decl
) == TREE_VEC
)
6658 offset
= TREE_INT_CST_LOW (BINFO_OFFSET (decl
));
6660 offset
= field_byte_offset (decl
);
6662 /* The DWARF2 standard says that we should assume that the structure address
6663 is already on the stack, so we can specify a structure field address
6664 by using DW_OP_plus_uconst. */
6666 #ifdef MIPS_DEBUGGING_INFO
6667 /* ??? The SGI dwarf reader does not handle the DW_OP_plus_uconst operator
6668 correctly. It works only if we leave the offset on the stack. */
6671 op
= DW_OP_plus_uconst
;
6674 loc_descr
= new_loc_descr (op
, offset
, 0);
6675 add_AT_loc (die
, DW_AT_data_member_location
, loc_descr
);
6678 /* Attach an DW_AT_const_value attribute for a variable or a parameter which
6679 does not have a "location" either in memory or in a register. These
6680 things can arise in GNU C when a constant is passed as an actual parameter
6681 to an inlined function. They can also arise in C++ where declared
6682 constants do not necessarily get memory "homes". */
6685 add_const_value_attribute (die
, rtl
)
6686 register dw_die_ref die
;
6689 switch (GET_CODE (rtl
))
6692 /* Note that a CONST_INT rtx could represent either an integer or a
6693 floating-point constant. A CONST_INT is used whenever the constant
6694 will fit into a single word. In all such cases, the original mode
6695 of the constant value is wiped out, and the CONST_INT rtx is
6696 assigned VOIDmode. */
6697 add_AT_unsigned (die
, DW_AT_const_value
, (unsigned) INTVAL (rtl
));
6701 /* Note that a CONST_DOUBLE rtx could represent either an integer or a
6702 floating-point constant. A CONST_DOUBLE is used whenever the
6703 constant requires more than one word in order to be adequately
6704 represented. We output CONST_DOUBLEs as blocks. */
6706 register enum machine_mode mode
= GET_MODE (rtl
);
6708 if (GET_MODE_CLASS (mode
) == MODE_FLOAT
)
6710 register unsigned length
= GET_MODE_SIZE (mode
) / sizeof (long);
6714 REAL_VALUE_FROM_CONST_DOUBLE (rv
, rtl
);
6718 REAL_VALUE_TO_TARGET_SINGLE (rv
, array
[0]);
6722 REAL_VALUE_TO_TARGET_DOUBLE (rv
, array
);
6727 REAL_VALUE_TO_TARGET_LONG_DOUBLE (rv
, array
);
6734 add_AT_float (die
, DW_AT_const_value
, length
, array
);
6737 add_AT_long_long (die
, DW_AT_const_value
,
6738 CONST_DOUBLE_HIGH (rtl
), CONST_DOUBLE_LOW (rtl
));
6743 add_AT_string (die
, DW_AT_const_value
, XSTR (rtl
, 0));
6749 add_AT_addr (die
, DW_AT_const_value
, addr_to_string (rtl
));
6753 /* In cases where an inlined instance of an inline function is passed
6754 the address of an `auto' variable (which is local to the caller) we
6755 can get a situation where the DECL_RTL of the artificial local
6756 variable (for the inlining) which acts as a stand-in for the
6757 corresponding formal parameter (of the inline function) will look
6758 like (plus:SI (reg:SI FRAME_PTR) (const_int ...)). This is not
6759 exactly a compile-time constant expression, but it isn't the address
6760 of the (artificial) local variable either. Rather, it represents the
6761 *value* which the artificial local variable always has during its
6762 lifetime. We currently have no way to represent such quasi-constant
6763 values in Dwarf, so for now we just punt and generate nothing. */
6767 /* No other kinds of rtx should be possible here. */
6773 /* Generate *either* an DW_AT_location attribute or else an DW_AT_const_value
6774 data attribute for a variable or a parameter. We generate the
6775 DW_AT_const_value attribute only in those cases where the given variable
6776 or parameter does not have a true "location" either in memory or in a
6777 register. This can happen (for example) when a constant is passed as an
6778 actual argument in a call to an inline function. (It's possible that
6779 these things can crop up in other ways also.) Note that one type of
6780 constant value which can be passed into an inlined function is a constant
6781 pointer. This can happen for example if an actual argument in an inlined
6782 function call evaluates to a compile-time constant address. */
6785 add_location_or_const_value_attribute (die
, decl
)
6786 register dw_die_ref die
;
6790 register tree declared_type
;
6791 register tree passed_type
;
6793 if (TREE_CODE (decl
) == ERROR_MARK
)
6796 if (TREE_CODE (decl
) != VAR_DECL
&& TREE_CODE (decl
) != PARM_DECL
)
6799 /* Here we have to decide where we are going to say the parameter "lives"
6800 (as far as the debugger is concerned). We only have a couple of
6801 choices. GCC provides us with DECL_RTL and with DECL_INCOMING_RTL.
6803 DECL_RTL normally indicates where the parameter lives during most of the
6804 activation of the function. If optimization is enabled however, this
6805 could be either NULL or else a pseudo-reg. Both of those cases indicate
6806 that the parameter doesn't really live anywhere (as far as the code
6807 generation parts of GCC are concerned) during most of the function's
6808 activation. That will happen (for example) if the parameter is never
6809 referenced within the function.
6811 We could just generate a location descriptor here for all non-NULL
6812 non-pseudo values of DECL_RTL and ignore all of the rest, but we can be
6813 a little nicer than that if we also consider DECL_INCOMING_RTL in cases
6814 where DECL_RTL is NULL or is a pseudo-reg.
6816 Note however that we can only get away with using DECL_INCOMING_RTL as
6817 a backup substitute for DECL_RTL in certain limited cases. In cases
6818 where DECL_ARG_TYPE (decl) indicates the same type as TREE_TYPE (decl),
6819 we can be sure that the parameter was passed using the same type as it is
6820 declared to have within the function, and that its DECL_INCOMING_RTL
6821 points us to a place where a value of that type is passed.
6823 In cases where DECL_ARG_TYPE (decl) and TREE_TYPE (decl) are different,
6824 we cannot (in general) use DECL_INCOMING_RTL as a substitute for DECL_RTL
6825 because in these cases DECL_INCOMING_RTL points us to a value of some
6826 type which is *different* from the type of the parameter itself. Thus,
6827 if we tried to use DECL_INCOMING_RTL to generate a location attribute in
6828 such cases, the debugger would end up (for example) trying to fetch a
6829 `float' from a place which actually contains the first part of a
6830 `double'. That would lead to really incorrect and confusing
6831 output at debug-time.
6833 So, in general, we *do not* use DECL_INCOMING_RTL as a backup for DECL_RTL
6834 in cases where DECL_ARG_TYPE (decl) != TREE_TYPE (decl). There
6835 are a couple of exceptions however. On little-endian machines we can
6836 get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE (decl) is
6837 not the same as TREE_TYPE (decl), but only when DECL_ARG_TYPE (decl) is
6838 an integral type that is smaller than TREE_TYPE (decl). These cases arise
6839 when (on a little-endian machine) a non-prototyped function has a
6840 parameter declared to be of type `short' or `char'. In such cases,
6841 TREE_TYPE (decl) will be `short' or `char', DECL_ARG_TYPE (decl) will
6842 be `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
6843 passed `int' value. If the debugger then uses that address to fetch
6844 a `short' or a `char' (on a little-endian machine) the result will be
6845 the correct data, so we allow for such exceptional cases below.
6847 Note that our goal here is to describe the place where the given formal
6848 parameter lives during most of the function's activation (i.e. between
6849 the end of the prologue and the start of the epilogue). We'll do that
6850 as best as we can. Note however that if the given formal parameter is
6851 modified sometime during the execution of the function, then a stack
6852 backtrace (at debug-time) will show the function as having been
6853 called with the *new* value rather than the value which was
6854 originally passed in. This happens rarely enough that it is not
6855 a major problem, but it *is* a problem, and I'd like to fix it.
6857 A future version of dwarf2out.c may generate two additional
6858 attributes for any given DW_TAG_formal_parameter DIE which will
6859 describe the "passed type" and the "passed location" for the
6860 given formal parameter in addition to the attributes we now
6861 generate to indicate the "declared type" and the "active
6862 location" for each parameter. This additional set of attributes
6863 could be used by debuggers for stack backtraces. Separately, note
6864 that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL can be
6865 NULL also. This happens (for example) for inlined-instances of
6866 inline function formal parameters which are never referenced.
6867 This really shouldn't be happening. All PARM_DECL nodes should
6868 get valid non-NULL DECL_INCOMING_RTL values, but integrate.c
6869 doesn't currently generate these values for inlined instances of
6870 inline function parameters, so when we see such cases, we are
6871 just SOL (shit-out-of-luck) for the time being (until integrate.c
6874 /* Use DECL_RTL as the "location" unless we find something better. */
6875 rtl
= DECL_RTL (decl
);
6877 if (TREE_CODE (decl
) == PARM_DECL
)
6879 if (rtl
== NULL_RTX
|| is_pseudo_reg (rtl
))
6881 declared_type
= type_main_variant (TREE_TYPE (decl
));
6882 passed_type
= type_main_variant (DECL_ARG_TYPE (decl
));
6884 /* This decl represents a formal parameter which was optimized out.
6885 Note that DECL_INCOMING_RTL may be NULL in here, but we handle
6886 all* cases where (rtl == NULL_RTX) just below. */
6887 if (declared_type
== passed_type
)
6888 rtl
= DECL_INCOMING_RTL (decl
);
6889 else if (! BYTES_BIG_ENDIAN
6890 && TREE_CODE (declared_type
) == INTEGER_TYPE
6891 && TYPE_SIZE (declared_type
) <= TYPE_SIZE (passed_type
))
6892 rtl
= DECL_INCOMING_RTL (decl
);
6896 if (rtl
== NULL_RTX
)
6899 rtl
= eliminate_regs (rtl
, 0, NULL_RTX
, 0);
6900 #ifdef LEAF_REG_REMAP
6902 leaf_renumber_regs_insn (rtl
);
6905 switch (GET_CODE (rtl
))
6908 /* The address of a variable that was optimized away; don't emit
6919 /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
6920 add_const_value_attribute (die
, rtl
);
6927 add_AT_location_description (die
, DW_AT_location
, rtl
);
6935 /* Generate an DW_AT_name attribute given some string value to be included as
6936 the value of the attribute. */
6939 add_name_attribute (die
, name_string
)
6940 register dw_die_ref die
;
6941 register char *name_string
;
6943 if (name_string
!= NULL
&& *name_string
!= 0)
6944 add_AT_string (die
, DW_AT_name
, name_string
);
6947 /* Given a tree node describing an array bound (either lower or upper) output
6948 a representation for that bound. */
6951 add_bound_info (subrange_die
, bound_attr
, bound
)
6952 register dw_die_ref subrange_die
;
6953 register enum dwarf_attribute bound_attr
;
6954 register tree bound
;
6956 register unsigned bound_value
= 0;
6958 /* If this is an Ada unconstrained array type, then don't emit any debug
6959 info because the array bounds are unknown. They are parameterized when
6960 the type is instantiated. */
6961 if (contains_placeholder_p (bound
))
6964 switch (TREE_CODE (bound
))
6969 /* All fixed-bounds are represented by INTEGER_CST nodes. */
6971 bound_value
= TREE_INT_CST_LOW (bound
);
6972 if (bound_attr
== DW_AT_lower_bound
6973 && ((is_c_family () && bound_value
== 0)
6974 || (is_fortran () && bound_value
== 1)))
6975 /* use the default */;
6977 add_AT_unsigned (subrange_die
, bound_attr
, bound_value
);
6982 case NON_LVALUE_EXPR
:
6983 add_bound_info (subrange_die
, bound_attr
, TREE_OPERAND (bound
, 0));
6987 /* If optimization is turned on, the SAVE_EXPRs that describe how to
6988 access the upper bound values may be bogus. If they refer to a
6989 register, they may only describe how to get at these values at the
6990 points in the generated code right after they have just been
6991 computed. Worse yet, in the typical case, the upper bound values
6992 will not even *be* computed in the optimized code (though the
6993 number of elements will), so these SAVE_EXPRs are entirely
6994 bogus. In order to compensate for this fact, we check here to see
6995 if optimization is enabled, and if so, we don't add an attribute
6996 for the (unknown and unknowable) upper bound. This should not
6997 cause too much trouble for existing (stupid?) debuggers because
6998 they have to deal with empty upper bounds location descriptions
6999 anyway in order to be able to deal with incomplete array types.
7000 Of course an intelligent debugger (GDB?) should be able to
7001 comprehend that a missing upper bound specification in a array
7002 type used for a storage class `auto' local array variable
7003 indicates that the upper bound is both unknown (at compile- time)
7004 and unknowable (at run-time) due to optimization.
7006 We assume that a MEM rtx is safe because gcc wouldn't put the
7007 value there unless it was going to be used repeatedly in the
7008 function, i.e. for cleanups. */
7009 if (! optimize
|| GET_CODE (SAVE_EXPR_RTL (bound
)) == MEM
)
7011 register dw_die_ref ctx
= lookup_decl_die (current_function_decl
);
7012 register dw_die_ref decl_die
= new_die (DW_TAG_variable
, ctx
);
7013 add_AT_flag (decl_die
, DW_AT_artificial
, 1);
7014 add_type_attribute (decl_die
, TREE_TYPE (bound
), 1, 0, ctx
);
7015 add_AT_location_description (decl_die
, DW_AT_location
,
7016 SAVE_EXPR_RTL (bound
));
7017 add_AT_die_ref (subrange_die
, bound_attr
, decl_die
);
7020 /* Else leave out the attribute. */
7025 /* ??? These types of bounds can be created by the Ada front end,
7026 and it isn't clear how to emit debug info for them. */
7034 /* Note that the block of subscript information for an array type also
7035 includes information about the element type of type given array type. */
7038 add_subscript_info (type_die
, type
)
7039 register dw_die_ref type_die
;
7042 register unsigned dimension_number
;
7043 register tree lower
, upper
;
7044 register dw_die_ref subrange_die
;
7046 /* The GNU compilers represent multidimensional array types as sequences of
7047 one dimensional array types whose element types are themselves array
7048 types. Here we squish that down, so that each multidimensional array
7049 type gets only one array_type DIE in the Dwarf debugging info. The draft
7050 Dwarf specification say that we are allowed to do this kind of
7051 compression in C (because there is no difference between an array or
7052 arrays and a multidimensional array in C) but for other source languages
7053 (e.g. Ada) we probably shouldn't do this. */
7055 /* ??? The SGI dwarf reader fails for multidimensional arrays with a
7056 const enum type. E.g. const enum machine_mode insn_operand_mode[2][10].
7057 We work around this by disabling this feature. See also
7058 gen_array_type_die. */
7059 #ifndef MIPS_DEBUGGING_INFO
7060 for (dimension_number
= 0;
7061 TREE_CODE (type
) == ARRAY_TYPE
;
7062 type
= TREE_TYPE (type
), dimension_number
++)
7065 register tree domain
= TYPE_DOMAIN (type
);
7067 /* Arrays come in three flavors: Unspecified bounds, fixed bounds,
7068 and (in GNU C only) variable bounds. Handle all three forms
7070 subrange_die
= new_die (DW_TAG_subrange_type
, type_die
);
7073 /* We have an array type with specified bounds. */
7074 lower
= TYPE_MIN_VALUE (domain
);
7075 upper
= TYPE_MAX_VALUE (domain
);
7077 /* define the index type. */
7078 if (TREE_TYPE (domain
))
7080 /* ??? This is probably an Ada unnamed subrange type. Ignore the
7081 TREE_TYPE field. We can't emit debug info for this
7082 because it is an unnamed integral type. */
7083 if (TREE_CODE (domain
) == INTEGER_TYPE
7084 && TYPE_NAME (domain
) == NULL_TREE
7085 && TREE_CODE (TREE_TYPE (domain
)) == INTEGER_TYPE
7086 && TYPE_NAME (TREE_TYPE (domain
)) == NULL_TREE
)
7089 add_type_attribute (subrange_die
, TREE_TYPE (domain
), 0, 0,
7093 add_bound_info (subrange_die
, DW_AT_lower_bound
, lower
);
7094 add_bound_info (subrange_die
, DW_AT_upper_bound
, upper
);
7097 /* We have an array type with an unspecified length. The DWARF-2
7098 spec does not say how to handle this; let's just leave out the
7102 #ifndef MIPS_DEBUGGING_INFO
7108 add_byte_size_attribute (die
, tree_node
)
7110 register tree tree_node
;
7112 register unsigned size
;
7114 switch (TREE_CODE (tree_node
))
7122 case QUAL_UNION_TYPE
:
7123 size
= int_size_in_bytes (tree_node
);
7126 /* For a data member of a struct or union, the DW_AT_byte_size is
7127 generally given as the number of bytes normally allocated for an
7128 object of the *declared* type of the member itself. This is true
7129 even for bit-fields. */
7130 size
= simple_type_size_in_bits (field_type (tree_node
)) / BITS_PER_UNIT
;
7136 /* Note that `size' might be -1 when we get to this point. If it is, that
7137 indicates that the byte size of the entity in question is variable. We
7138 have no good way of expressing this fact in Dwarf at the present time,
7139 so just let the -1 pass on through. */
7141 add_AT_unsigned (die
, DW_AT_byte_size
, size
);
7144 /* For a FIELD_DECL node which represents a bit-field, output an attribute
7145 which specifies the distance in bits from the highest order bit of the
7146 "containing object" for the bit-field to the highest order bit of the
7149 For any given bit-field, the "containing object" is a hypothetical
7150 object (of some integral or enum type) within which the given bit-field
7151 lives. The type of this hypothetical "containing object" is always the
7152 same as the declared type of the individual bit-field itself. The
7153 determination of the exact location of the "containing object" for a
7154 bit-field is rather complicated. It's handled by the
7155 `field_byte_offset' function (above).
7157 Note that it is the size (in bytes) of the hypothetical "containing object"
7158 which will be given in the DW_AT_byte_size attribute for this bit-field.
7159 (See `byte_size_attribute' above). */
7162 add_bit_offset_attribute (die
, decl
)
7163 register dw_die_ref die
;
7166 register unsigned object_offset_in_bytes
= field_byte_offset (decl
);
7167 register tree type
= DECL_BIT_FIELD_TYPE (decl
);
7168 register tree bitpos_tree
= DECL_FIELD_BITPOS (decl
);
7169 register unsigned bitpos_int
;
7170 register unsigned highest_order_object_bit_offset
;
7171 register unsigned highest_order_field_bit_offset
;
7172 register unsigned bit_offset
;
7174 /* Must be a field and a bit field. */
7176 || TREE_CODE (decl
) != FIELD_DECL
)
7179 /* We can't yet handle bit-fields whose offsets are variable, so if we
7180 encounter such things, just return without generating any attribute
7182 if (TREE_CODE (bitpos_tree
) != INTEGER_CST
)
7185 bitpos_int
= (unsigned) TREE_INT_CST_LOW (bitpos_tree
);
7187 /* Note that the bit offset is always the distance (in bits) from the
7188 highest-order bit of the "containing object" to the highest-order bit of
7189 the bit-field itself. Since the "high-order end" of any object or field
7190 is different on big-endian and little-endian machines, the computation
7191 below must take account of these differences. */
7192 highest_order_object_bit_offset
= object_offset_in_bytes
* BITS_PER_UNIT
;
7193 highest_order_field_bit_offset
= bitpos_int
;
7195 if (! BYTES_BIG_ENDIAN
)
7197 highest_order_field_bit_offset
7198 += (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl
));
7200 highest_order_object_bit_offset
+= simple_type_size_in_bits (type
);
7204 = (! BYTES_BIG_ENDIAN
7205 ? highest_order_object_bit_offset
- highest_order_field_bit_offset
7206 : highest_order_field_bit_offset
- highest_order_object_bit_offset
);
7208 add_AT_unsigned (die
, DW_AT_bit_offset
, bit_offset
);
7211 /* For a FIELD_DECL node which represents a bit field, output an attribute
7212 which specifies the length in bits of the given field. */
7215 add_bit_size_attribute (die
, decl
)
7216 register dw_die_ref die
;
7219 /* Must be a field and a bit field. */
7220 if (TREE_CODE (decl
) != FIELD_DECL
7221 || ! DECL_BIT_FIELD_TYPE (decl
))
7223 add_AT_unsigned (die
, DW_AT_bit_size
,
7224 (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl
)));
7227 /* If the compiled language is ANSI C, then add a 'prototyped'
7228 attribute, if arg types are given for the parameters of a function. */
7231 add_prototyped_attribute (die
, func_type
)
7232 register dw_die_ref die
;
7233 register tree func_type
;
7235 if (get_AT_unsigned (comp_unit_die
, DW_AT_language
) == DW_LANG_C89
7236 && TYPE_ARG_TYPES (func_type
) != NULL
)
7237 add_AT_flag (die
, DW_AT_prototyped
, 1);
7241 /* Add an 'abstract_origin' attribute below a given DIE. The DIE is found
7242 by looking in either the type declaration or object declaration
7246 add_abstract_origin_attribute (die
, origin
)
7247 register dw_die_ref die
;
7248 register tree origin
;
7250 dw_die_ref origin_die
= NULL
;
7251 if (TREE_CODE_CLASS (TREE_CODE (origin
)) == 'd')
7252 origin_die
= lookup_decl_die (origin
);
7253 else if (TREE_CODE_CLASS (TREE_CODE (origin
)) == 't')
7254 origin_die
= lookup_type_die (origin
);
7256 add_AT_die_ref (die
, DW_AT_abstract_origin
, origin_die
);
7259 /* We do not currently support the pure_virtual attribute. */
7262 add_pure_or_virtual_attribute (die
, func_decl
)
7263 register dw_die_ref die
;
7264 register tree func_decl
;
7266 if (DECL_VINDEX (func_decl
))
7268 add_AT_unsigned (die
, DW_AT_virtuality
, DW_VIRTUALITY_virtual
);
7269 add_AT_loc (die
, DW_AT_vtable_elem_location
,
7270 new_loc_descr (DW_OP_constu
,
7271 TREE_INT_CST_LOW (DECL_VINDEX (func_decl
)),
7274 /* GNU extension: Record what type this method came from originally. */
7275 if (debug_info_level
> DINFO_LEVEL_TERSE
)
7276 add_AT_die_ref (die
, DW_AT_containing_type
,
7277 lookup_type_die (DECL_CONTEXT (func_decl
)));
7281 /* Add source coordinate attributes for the given decl. */
7284 add_src_coords_attributes (die
, decl
)
7285 register dw_die_ref die
;
7288 register unsigned file_index
= lookup_filename (DECL_SOURCE_FILE (decl
));
7290 add_AT_unsigned (die
, DW_AT_decl_file
, file_index
);
7291 add_AT_unsigned (die
, DW_AT_decl_line
, DECL_SOURCE_LINE (decl
));
7294 /* Add an DW_AT_name attribute and source coordinate attribute for the
7295 given decl, but only if it actually has a name. */
7298 add_name_and_src_coords_attributes (die
, decl
)
7299 register dw_die_ref die
;
7302 register tree decl_name
;
7304 decl_name
= DECL_NAME (decl
);
7305 if (decl_name
!= NULL
&& IDENTIFIER_POINTER (decl_name
) != NULL
)
7307 add_name_attribute (die
, dwarf2_name (decl
, 0));
7308 add_src_coords_attributes (die
, decl
);
7309 if ((TREE_CODE (decl
) == FUNCTION_DECL
|| TREE_CODE (decl
) == VAR_DECL
)
7310 && DECL_ASSEMBLER_NAME (decl
) != DECL_NAME (decl
))
7311 add_AT_string (die
, DW_AT_MIPS_linkage_name
,
7312 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)));
7316 /* Push a new declaration scope. */
7319 push_decl_scope (scope
)
7322 /* Make room in the decl_scope_table, if necessary. */
7323 if (decl_scope_table_allocated
== decl_scope_depth
)
7325 decl_scope_table_allocated
+= DECL_SCOPE_TABLE_INCREMENT
;
7327 = (tree
*) xrealloc (decl_scope_table
,
7328 decl_scope_table_allocated
* sizeof (tree
));
7331 decl_scope_table
[decl_scope_depth
++] = scope
;
7334 /* Return the DIE for the scope the immediately contains this declaration. */
7337 scope_die_for (t
, context_die
)
7339 register dw_die_ref context_die
;
7341 register dw_die_ref scope_die
= NULL
;
7342 register tree containing_scope
;
7343 register unsigned long i
;
7345 /* Walk back up the declaration tree looking for a place to define
7347 if (TREE_CODE_CLASS (TREE_CODE (t
)) == 't')
7348 containing_scope
= TYPE_CONTEXT (t
);
7349 else if (TREE_CODE (t
) == FUNCTION_DECL
&& DECL_VINDEX (t
))
7350 containing_scope
= decl_class_context (t
);
7352 containing_scope
= DECL_CONTEXT (t
);
7354 /* Function-local tags and functions get stuck in limbo until they are
7355 fixed up by decls_for_scope. */
7356 if (context_die
== NULL
&& containing_scope
!= NULL_TREE
7357 && (TREE_CODE (t
) == FUNCTION_DECL
|| is_tagged_type (t
)))
7360 if (containing_scope
== NULL_TREE
)
7361 scope_die
= comp_unit_die
;
7364 for (i
= decl_scope_depth
, scope_die
= context_die
;
7365 i
> 0 && decl_scope_table
[i
- 1] != containing_scope
;
7366 scope_die
= scope_die
->die_parent
, --i
)
7371 if (scope_die
!= comp_unit_die
7372 || TREE_CODE_CLASS (TREE_CODE (containing_scope
)) != 't')
7374 if (debug_info_level
> DINFO_LEVEL_TERSE
7375 && !TREE_ASM_WRITTEN (containing_scope
))
7383 /* Pop a declaration scope. */
7387 if (decl_scope_depth
<= 0)
7392 /* Many forms of DIEs require a "type description" attribute. This
7393 routine locates the proper "type descriptor" die for the type given
7394 by 'type', and adds an DW_AT_type attribute below the given die. */
7397 add_type_attribute (object_die
, type
, decl_const
, decl_volatile
, context_die
)
7398 register dw_die_ref object_die
;
7400 register int decl_const
;
7401 register int decl_volatile
;
7402 register dw_die_ref context_die
;
7404 register enum tree_code code
= TREE_CODE (type
);
7405 register dw_die_ref type_die
= NULL
;
7407 /* ??? If this type is an unnamed subrange type of an integral or
7408 floating-point type, use the inner type. This is because we have no
7409 support for unnamed types in base_type_die. This can happen if this is
7410 an Ada subrange type. Correct solution is emit a subrange type die. */
7411 if ((code
== INTEGER_TYPE
|| code
== REAL_TYPE
)
7412 && TREE_TYPE (type
) != 0 && TYPE_NAME (type
) == 0)
7413 type
= TREE_TYPE (type
), code
= TREE_CODE (type
);
7415 if (code
== ERROR_MARK
)
7418 /* Handle a special case. For functions whose return type is void, we
7419 generate *no* type attribute. (Note that no object may have type
7420 `void', so this only applies to function return types). */
7421 if (code
== VOID_TYPE
)
7424 type_die
= modified_type_die (type
,
7425 decl_const
|| TYPE_READONLY (type
),
7426 decl_volatile
|| TYPE_VOLATILE (type
),
7428 if (type_die
!= NULL
)
7429 add_AT_die_ref (object_die
, DW_AT_type
, type_die
);
7432 /* Given a tree pointer to a struct, class, union, or enum type node, return
7433 a pointer to the (string) tag name for the given type, or zero if the type
7434 was declared without a tag. */
7440 register char *name
= 0;
7442 if (TYPE_NAME (type
) != 0)
7444 register tree t
= 0;
7446 /* Find the IDENTIFIER_NODE for the type name. */
7447 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
7448 t
= TYPE_NAME (type
);
7450 /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
7451 a TYPE_DECL node, regardless of whether or not a `typedef' was
7453 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
7454 && ! DECL_IGNORED_P (TYPE_NAME (type
)))
7455 t
= DECL_NAME (TYPE_NAME (type
));
7457 /* Now get the name as a string, or invent one. */
7459 name
= IDENTIFIER_POINTER (t
);
7462 return (name
== 0 || *name
== '\0') ? 0 : name
;
7465 /* Return the type associated with a data member, make a special check
7466 for bit field types. */
7469 member_declared_type (member
)
7470 register tree member
;
7472 return (DECL_BIT_FIELD_TYPE (member
)
7473 ? DECL_BIT_FIELD_TYPE (member
)
7474 : TREE_TYPE (member
));
7477 /* Get the decl's label, as described by its RTL. This may be different
7478 from the DECL_NAME name used in the source file. */
7481 decl_start_label (decl
)
7486 x
= DECL_RTL (decl
);
7487 if (GET_CODE (x
) != MEM
)
7491 if (GET_CODE (x
) != SYMBOL_REF
)
7494 fnname
= XSTR (x
, 0);
7498 /* These routines generate the internnal representation of the DIE's for
7499 the compilation unit. Debugging information is collected by walking
7500 the declaration trees passed in from dwarf2out_decl(). */
7503 gen_array_type_die (type
, context_die
)
7505 register dw_die_ref context_die
;
7507 register dw_die_ref scope_die
= scope_die_for (type
, context_die
);
7508 register dw_die_ref array_die
;
7509 register tree element_type
;
7511 /* ??? The SGI dwarf reader fails for array of array of enum types unless
7512 the inner array type comes before the outer array type. Thus we must
7513 call gen_type_die before we call new_die. See below also. */
7514 #ifdef MIPS_DEBUGGING_INFO
7515 gen_type_die (TREE_TYPE (type
), context_die
);
7518 array_die
= new_die (DW_TAG_array_type
, scope_die
);
7521 /* We default the array ordering. SDB will probably do
7522 the right things even if DW_AT_ordering is not present. It's not even
7523 an issue until we start to get into multidimensional arrays anyway. If
7524 SDB is ever caught doing the Wrong Thing for multi-dimensional arrays,
7525 then we'll have to put the DW_AT_ordering attribute back in. (But if
7526 and when we find out that we need to put these in, we will only do so
7527 for multidimensional arrays. */
7528 add_AT_unsigned (array_die
, DW_AT_ordering
, DW_ORD_row_major
);
7531 #ifdef MIPS_DEBUGGING_INFO
7532 /* The SGI compilers handle arrays of unknown bound by setting
7533 AT_declaration and not emitting any subrange DIEs. */
7534 if (! TYPE_DOMAIN (type
))
7535 add_AT_unsigned (array_die
, DW_AT_declaration
, 1);
7538 add_subscript_info (array_die
, type
);
7540 equate_type_number_to_die (type
, array_die
);
7542 /* Add representation of the type of the elements of this array type. */
7543 element_type
= TREE_TYPE (type
);
7545 /* ??? The SGI dwarf reader fails for multidimensional arrays with a
7546 const enum type. E.g. const enum machine_mode insn_operand_mode[2][10].
7547 We work around this by disabling this feature. See also
7548 add_subscript_info. */
7549 #ifndef MIPS_DEBUGGING_INFO
7550 while (TREE_CODE (element_type
) == ARRAY_TYPE
)
7551 element_type
= TREE_TYPE (element_type
);
7553 gen_type_die (element_type
, context_die
);
7556 add_type_attribute (array_die
, element_type
, 0, 0, context_die
);
7560 gen_set_type_die (type
, context_die
)
7562 register dw_die_ref context_die
;
7564 register dw_die_ref type_die
7565 = new_die (DW_TAG_set_type
, scope_die_for (type
, context_die
));
7567 equate_type_number_to_die (type
, type_die
);
7568 add_type_attribute (type_die
, TREE_TYPE (type
), 0, 0, context_die
);
7572 gen_entry_point_die (decl
, context_die
)
7574 register dw_die_ref context_die
;
7576 register tree origin
= decl_ultimate_origin (decl
);
7577 register dw_die_ref decl_die
= new_die (DW_TAG_entry_point
, context_die
);
7579 add_abstract_origin_attribute (decl_die
, origin
);
7582 add_name_and_src_coords_attributes (decl_die
, decl
);
7583 add_type_attribute (decl_die
, TREE_TYPE (TREE_TYPE (decl
)),
7587 if (DECL_ABSTRACT (decl
))
7588 equate_decl_number_to_die (decl
, decl_die
);
7590 add_AT_lbl_id (decl_die
, DW_AT_low_pc
, decl_start_label (decl
));
7593 /* Remember a type in the pending_types_list. */
7599 if (pending_types
== pending_types_allocated
)
7601 pending_types_allocated
+= PENDING_TYPES_INCREMENT
;
7603 = (tree
*) xrealloc (pending_types_list
,
7604 sizeof (tree
) * pending_types_allocated
);
7607 pending_types_list
[pending_types
++] = type
;
7610 /* Output any pending types (from the pending_types list) which we can output
7611 now (taking into account the scope that we are working on now).
7613 For each type output, remove the given type from the pending_types_list
7614 *before* we try to output it. */
7617 output_pending_types_for_scope (context_die
)
7618 register dw_die_ref context_die
;
7622 while (pending_types
)
7625 type
= pending_types_list
[pending_types
];
7626 gen_type_die (type
, context_die
);
7627 if (!TREE_ASM_WRITTEN (type
))
7632 /* Generate a DIE to represent an inlined instance of an enumeration type. */
7635 gen_inlined_enumeration_type_die (type
, context_die
)
7637 register dw_die_ref context_die
;
7639 register dw_die_ref type_die
= new_die (DW_TAG_enumeration_type
,
7640 scope_die_for (type
, context_die
));
7642 if (!TREE_ASM_WRITTEN (type
))
7644 add_abstract_origin_attribute (type_die
, type
);
7647 /* Generate a DIE to represent an inlined instance of a structure type. */
7650 gen_inlined_structure_type_die (type
, context_die
)
7652 register dw_die_ref context_die
;
7654 register dw_die_ref type_die
= new_die (DW_TAG_structure_type
,
7655 scope_die_for (type
, context_die
));
7657 if (!TREE_ASM_WRITTEN (type
))
7659 add_abstract_origin_attribute (type_die
, type
);
7662 /* Generate a DIE to represent an inlined instance of a union type. */
7665 gen_inlined_union_type_die (type
, context_die
)
7667 register dw_die_ref context_die
;
7669 register dw_die_ref type_die
= new_die (DW_TAG_union_type
,
7670 scope_die_for (type
, context_die
));
7672 if (!TREE_ASM_WRITTEN (type
))
7674 add_abstract_origin_attribute (type_die
, type
);
7677 /* Generate a DIE to represent an enumeration type. Note that these DIEs
7678 include all of the information about the enumeration values also. Each
7679 enumerated type name/value is listed as a child of the enumerated type
7683 gen_enumeration_type_die (type
, context_die
)
7685 register dw_die_ref context_die
;
7687 register dw_die_ref type_die
= lookup_type_die (type
);
7689 if (type_die
== NULL
)
7691 type_die
= new_die (DW_TAG_enumeration_type
,
7692 scope_die_for (type
, context_die
));
7693 equate_type_number_to_die (type
, type_die
);
7694 add_name_attribute (type_die
, type_tag (type
));
7696 else if (! TYPE_SIZE (type
))
7699 remove_AT (type_die
, DW_AT_declaration
);
7701 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
7702 given enum type is incomplete, do not generate the DW_AT_byte_size
7703 attribute or the DW_AT_element_list attribute. */
7704 if (TYPE_SIZE (type
))
7708 TREE_ASM_WRITTEN (type
) = 1;
7709 add_byte_size_attribute (type_die
, type
);
7710 if (TYPE_STUB_DECL (type
) != NULL_TREE
)
7711 add_src_coords_attributes (type_die
, TYPE_STUB_DECL (type
));
7713 /* If the first reference to this type was as the return type of an
7714 inline function, then it may not have a parent. Fix this now. */
7715 if (type_die
->die_parent
== NULL
)
7716 add_child_die (scope_die_for (type
, context_die
), type_die
);
7718 for (link
= TYPE_FIELDS (type
);
7719 link
!= NULL
; link
= TREE_CHAIN (link
))
7721 register dw_die_ref enum_die
= new_die (DW_TAG_enumerator
, type_die
);
7723 add_name_attribute (enum_die
,
7724 IDENTIFIER_POINTER (TREE_PURPOSE (link
)));
7725 add_AT_unsigned (enum_die
, DW_AT_const_value
,
7726 (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link
)));
7730 add_AT_flag (type_die
, DW_AT_declaration
, 1);
7734 /* Generate a DIE to represent either a real live formal parameter decl or to
7735 represent just the type of some formal parameter position in some function
7738 Note that this routine is a bit unusual because its argument may be a
7739 ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
7740 represents an inlining of some PARM_DECL) or else some sort of a ..._TYPE
7741 node. If it's the former then this function is being called to output a
7742 DIE to represent a formal parameter object (or some inlining thereof). If
7743 it's the latter, then this function is only being called to output a
7744 DW_TAG_formal_parameter DIE to stand as a placeholder for some formal
7745 argument type of some subprogram type. */
7748 gen_formal_parameter_die (node
, context_die
)
7750 register dw_die_ref context_die
;
7752 register dw_die_ref parm_die
7753 = new_die (DW_TAG_formal_parameter
, context_die
);
7754 register tree origin
;
7756 switch (TREE_CODE_CLASS (TREE_CODE (node
)))
7759 origin
= decl_ultimate_origin (node
);
7761 add_abstract_origin_attribute (parm_die
, origin
);
7764 add_name_and_src_coords_attributes (parm_die
, node
);
7765 add_type_attribute (parm_die
, TREE_TYPE (node
),
7766 TREE_READONLY (node
),
7767 TREE_THIS_VOLATILE (node
),
7769 if (DECL_ARTIFICIAL (node
))
7770 add_AT_flag (parm_die
, DW_AT_artificial
, 1);
7773 equate_decl_number_to_die (node
, parm_die
);
7774 if (! DECL_ABSTRACT (node
))
7775 add_location_or_const_value_attribute (parm_die
, node
);
7780 /* We were called with some kind of a ..._TYPE node. */
7781 add_type_attribute (parm_die
, node
, 0, 0, context_die
);
7791 /* Generate a special type of DIE used as a stand-in for a trailing ellipsis
7792 at the end of an (ANSI prototyped) formal parameters list. */
7795 gen_unspecified_parameters_die (decl_or_type
, context_die
)
7796 register tree decl_or_type
;
7797 register dw_die_ref context_die
;
7799 register dw_die_ref parm_die
= new_die (DW_TAG_unspecified_parameters
,
7803 /* Generate a list of nameless DW_TAG_formal_parameter DIEs (and perhaps a
7804 DW_TAG_unspecified_parameters DIE) to represent the types of the formal
7805 parameters as specified in some function type specification (except for
7806 those which appear as part of a function *definition*).
7808 Note we must be careful here to output all of the parameter DIEs before*
7809 we output any DIEs needed to represent the types of the formal parameters.
7810 This keeps svr4 SDB happy because it (incorrectly) thinks that the first
7811 non-parameter DIE it sees ends the formal parameter list. */
7814 gen_formal_types_die (function_or_method_type
, context_die
)
7815 register tree function_or_method_type
;
7816 register dw_die_ref context_die
;
7819 register tree formal_type
= NULL
;
7820 register tree first_parm_type
= TYPE_ARG_TYPES (function_or_method_type
);
7823 /* In the case where we are generating a formal types list for a C++
7824 non-static member function type, skip over the first thing on the
7825 TYPE_ARG_TYPES list because it only represents the type of the hidden
7826 `this pointer'. The debugger should be able to figure out (without
7827 being explicitly told) that this non-static member function type takes a
7828 `this pointer' and should be able to figure what the type of that hidden
7829 parameter is from the DW_AT_member attribute of the parent
7830 DW_TAG_subroutine_type DIE. */
7831 if (TREE_CODE (function_or_method_type
) == METHOD_TYPE
)
7832 first_parm_type
= TREE_CHAIN (first_parm_type
);
7835 /* Make our first pass over the list of formal parameter types and output a
7836 DW_TAG_formal_parameter DIE for each one. */
7837 for (link
= first_parm_type
; link
; link
= TREE_CHAIN (link
))
7839 register dw_die_ref parm_die
;
7841 formal_type
= TREE_VALUE (link
);
7842 if (formal_type
== void_type_node
)
7845 /* Output a (nameless) DIE to represent the formal parameter itself. */
7846 parm_die
= gen_formal_parameter_die (formal_type
, context_die
);
7847 if (TREE_CODE (function_or_method_type
) == METHOD_TYPE
7848 && link
== first_parm_type
)
7849 add_AT_flag (parm_die
, DW_AT_artificial
, 1);
7852 /* If this function type has an ellipsis, add a
7853 DW_TAG_unspecified_parameters DIE to the end of the parameter list. */
7854 if (formal_type
!= void_type_node
)
7855 gen_unspecified_parameters_die (function_or_method_type
, context_die
);
7857 /* Make our second (and final) pass over the list of formal parameter types
7858 and output DIEs to represent those types (as necessary). */
7859 for (link
= TYPE_ARG_TYPES (function_or_method_type
);
7861 link
= TREE_CHAIN (link
))
7863 formal_type
= TREE_VALUE (link
);
7864 if (formal_type
== void_type_node
)
7867 gen_type_die (formal_type
, context_die
);
7871 /* Generate a DIE to represent a declared function (either file-scope or
7875 gen_subprogram_die (decl
, context_die
)
7877 register dw_die_ref context_die
;
7879 char label_id
[MAX_ARTIFICIAL_LABEL_BYTES
];
7880 register tree origin
= decl_ultimate_origin (decl
);
7881 register dw_die_ref subr_die
;
7882 register dw_loc_descr_ref fp_loc
= NULL
;
7883 register rtx fp_reg
;
7884 register tree fn_arg_types
;
7885 register tree outer_scope
;
7886 register dw_die_ref old_die
= lookup_decl_die (decl
);
7887 register int declaration
7888 = (current_function_decl
!= decl
7890 && (context_die
->die_tag
== DW_TAG_structure_type
7891 || context_die
->die_tag
== DW_TAG_union_type
)));
7895 subr_die
= new_die (DW_TAG_subprogram
, context_die
);
7896 add_abstract_origin_attribute (subr_die
, origin
);
7898 else if (old_die
&& DECL_ABSTRACT (decl
)
7899 && get_AT_unsigned (old_die
, DW_AT_inline
))
7901 /* This must be a redefinition of an extern inline function.
7902 We can just reuse the old die here. */
7905 /* Clear out the inlined attribute and parm types. */
7906 remove_AT (subr_die
, DW_AT_inline
);
7907 remove_children (subr_die
);
7911 register unsigned file_index
7912 = lookup_filename (DECL_SOURCE_FILE (decl
));
7914 if (get_AT_flag (old_die
, DW_AT_declaration
) != 1)
7917 /* If the definition comes from the same place as the declaration,
7918 maybe use the old DIE. We always want the DIE for this function
7919 that has the *_pc attributes to be under comp_unit_die so the
7920 debugger can find it. For inlines, that is the concrete instance,
7921 so we can use the old DIE here. For non-inline methods, we want a
7922 specification DIE at toplevel, so we need a new DIE. For local
7923 class methods, this does not apply. */
7924 if ((DECL_ABSTRACT (decl
) || old_die
->die_parent
== comp_unit_die
7925 || context_die
== NULL
)
7926 && get_AT_unsigned (old_die
, DW_AT_decl_file
) == file_index
7927 && (get_AT_unsigned (old_die
, DW_AT_decl_line
)
7928 == DECL_SOURCE_LINE (decl
)))
7932 /* Clear out the declaration attribute and the parm types. */
7933 remove_AT (subr_die
, DW_AT_declaration
);
7934 remove_children (subr_die
);
7938 subr_die
= new_die (DW_TAG_subprogram
, context_die
);
7939 add_AT_die_ref (subr_die
, DW_AT_specification
, old_die
);
7940 if (get_AT_unsigned (old_die
, DW_AT_decl_file
) != file_index
)
7941 add_AT_unsigned (subr_die
, DW_AT_decl_file
, file_index
);
7942 if (get_AT_unsigned (old_die
, DW_AT_decl_line
)
7943 != DECL_SOURCE_LINE (decl
))
7945 (subr_die
, DW_AT_decl_line
, DECL_SOURCE_LINE (decl
));
7950 register dw_die_ref scope_die
;
7952 if (DECL_CONTEXT (decl
))
7953 scope_die
= scope_die_for (decl
, context_die
);
7955 /* Don't put block extern declarations under comp_unit_die. */
7956 scope_die
= context_die
;
7958 subr_die
= new_die (DW_TAG_subprogram
, scope_die
);
7960 if (TREE_PUBLIC (decl
))
7961 add_AT_flag (subr_die
, DW_AT_external
, 1);
7963 add_name_and_src_coords_attributes (subr_die
, decl
);
7964 if (debug_info_level
> DINFO_LEVEL_TERSE
)
7966 register tree type
= TREE_TYPE (decl
);
7968 add_prototyped_attribute (subr_die
, type
);
7969 add_type_attribute (subr_die
, TREE_TYPE (type
), 0, 0, context_die
);
7972 add_pure_or_virtual_attribute (subr_die
, decl
);
7973 if (DECL_ARTIFICIAL (decl
))
7974 add_AT_flag (subr_die
, DW_AT_artificial
, 1);
7975 if (TREE_PROTECTED (decl
))
7976 add_AT_unsigned (subr_die
, DW_AT_accessibility
, DW_ACCESS_protected
);
7977 else if (TREE_PRIVATE (decl
))
7978 add_AT_unsigned (subr_die
, DW_AT_accessibility
, DW_ACCESS_private
);
7983 add_AT_flag (subr_die
, DW_AT_declaration
, 1);
7985 /* The first time we see a member function, it is in the context of
7986 the class to which it belongs. We make sure of this by emitting
7987 the class first. The next time is the definition, which is
7988 handled above. The two may come from the same source text. */
7989 if (DECL_CONTEXT (decl
))
7990 equate_decl_number_to_die (decl
, subr_die
);
7992 else if (DECL_ABSTRACT (decl
))
7994 /* ??? Checking DECL_DEFER_OUTPUT is correct for static inline functions,
7995 but not for extern inline functions. We can't get this completely
7996 correct because information about whether the function was declared
7997 inline is not saved anywhere. */
7998 if (DECL_DEFER_OUTPUT (decl
))
8000 if (DECL_INLINE (decl
))
8001 add_AT_unsigned (subr_die
, DW_AT_inline
, DW_INL_declared_inlined
);
8003 add_AT_unsigned (subr_die
, DW_AT_inline
,
8004 DW_INL_declared_not_inlined
);
8006 else if (DECL_INLINE (decl
))
8007 add_AT_unsigned (subr_die
, DW_AT_inline
, DW_INL_inlined
);
8011 equate_decl_number_to_die (decl
, subr_die
);
8013 else if (!DECL_EXTERNAL (decl
))
8015 if (origin
== NULL_TREE
)
8016 equate_decl_number_to_die (decl
, subr_die
);
8018 ASM_GENERATE_INTERNAL_LABEL (label_id
, FUNC_BEGIN_LABEL
,
8019 current_funcdef_number
);
8020 add_AT_lbl_id (subr_die
, DW_AT_low_pc
, label_id
);
8021 ASM_GENERATE_INTERNAL_LABEL (label_id
, FUNC_END_LABEL
,
8022 current_funcdef_number
);
8023 add_AT_lbl_id (subr_die
, DW_AT_high_pc
, label_id
);
8025 add_pubname (decl
, subr_die
);
8026 add_arange (decl
, subr_die
);
8028 #ifdef MIPS_DEBUGGING_INFO
8029 /* Add a reference to the FDE for this routine. */
8030 add_AT_fde_ref (subr_die
, DW_AT_MIPS_fde
, current_funcdef_fde
);
8033 /* Define the "frame base" location for this routine. We use the
8034 frame pointer or stack pointer registers, since the RTL for local
8035 variables is relative to one of them. */
8037 = frame_pointer_needed
? hard_frame_pointer_rtx
: stack_pointer_rtx
;
8038 add_AT_loc (subr_die
, DW_AT_frame_base
, reg_loc_descriptor (fp_reg
));
8041 /* ??? This fails for nested inline functions, because context_display
8042 is not part of the state saved/restored for inline functions. */
8043 if (current_function_needs_context
)
8044 add_AT_location_description (subr_die
, DW_AT_static_link
,
8045 lookup_static_chain (decl
));
8049 /* Now output descriptions of the arguments for this function. This gets
8050 (unnecessarily?) complex because of the fact that the DECL_ARGUMENT list
8051 for a FUNCTION_DECL doesn't indicate cases where there was a trailing
8052 `...' at the end of the formal parameter list. In order to find out if
8053 there was a trailing ellipsis or not, we must instead look at the type
8054 associated with the FUNCTION_DECL. This will be a node of type
8055 FUNCTION_TYPE. If the chain of type nodes hanging off of this
8056 FUNCTION_TYPE node ends with a void_type_node then there should *not* be
8057 an ellipsis at the end. */
8058 push_decl_scope (decl
);
8060 /* In the case where we are describing a mere function declaration, all we
8061 need to do here (and all we *can* do here) is to describe the *types* of
8062 its formal parameters. */
8063 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
8065 else if (declaration
)
8066 gen_formal_types_die (TREE_TYPE (decl
), subr_die
);
8069 /* Generate DIEs to represent all known formal parameters */
8070 register tree arg_decls
= DECL_ARGUMENTS (decl
);
8073 /* When generating DIEs, generate the unspecified_parameters DIE
8074 instead if we come across the arg "__builtin_va_alist" */
8075 for (parm
= arg_decls
; parm
; parm
= TREE_CHAIN (parm
))
8076 if (TREE_CODE (parm
) == PARM_DECL
)
8078 if (DECL_NAME (parm
)
8079 && !strcmp (IDENTIFIER_POINTER (DECL_NAME (parm
)),
8080 "__builtin_va_alist"))
8081 gen_unspecified_parameters_die (parm
, subr_die
);
8083 gen_decl_die (parm
, subr_die
);
8086 /* Decide whether we need a unspecified_parameters DIE at the end.
8087 There are 2 more cases to do this for: 1) the ansi ... declaration -
8088 this is detectable when the end of the arg list is not a
8089 void_type_node 2) an unprototyped function declaration (not a
8090 definition). This just means that we have no info about the
8091 parameters at all. */
8092 fn_arg_types
= TYPE_ARG_TYPES (TREE_TYPE (decl
));
8093 if (fn_arg_types
!= NULL
)
8095 /* this is the prototyped case, check for ... */
8096 if (TREE_VALUE (tree_last (fn_arg_types
)) != void_type_node
)
8097 gen_unspecified_parameters_die (decl
, subr_die
);
8099 else if (DECL_INITIAL (decl
) == NULL_TREE
)
8100 gen_unspecified_parameters_die (decl
, subr_die
);
8103 /* Output Dwarf info for all of the stuff within the body of the function
8104 (if it has one - it may be just a declaration). */
8105 outer_scope
= DECL_INITIAL (decl
);
8107 /* Note that here, `outer_scope' is a pointer to the outermost BLOCK
8108 node created to represent a function. This outermost BLOCK actually
8109 represents the outermost binding contour for the function, i.e. the
8110 contour in which the function's formal parameters and labels get
8111 declared. Curiously, it appears that the front end doesn't actually
8112 put the PARM_DECL nodes for the current function onto the BLOCK_VARS
8113 list for this outer scope. (They are strung off of the DECL_ARGUMENTS
8114 list for the function instead.) The BLOCK_VARS list for the
8115 `outer_scope' does provide us with a list of the LABEL_DECL nodes for
8116 the function however, and we output DWARF info for those in
8117 decls_for_scope. Just within the `outer_scope' there will be a BLOCK
8118 node representing the function's outermost pair of curly braces, and
8119 any blocks used for the base and member initializers of a C++
8120 constructor function. */
8121 if (! declaration
&& TREE_CODE (outer_scope
) != ERROR_MARK
)
8123 current_function_has_inlines
= 0;
8124 decls_for_scope (outer_scope
, subr_die
, 0);
8126 #if 0 && defined (MIPS_DEBUGGING_INFO)
8127 if (current_function_has_inlines
)
8129 add_AT_flag (subr_die
, DW_AT_MIPS_has_inlines
, 1);
8130 if (! comp_unit_has_inlines
)
8132 add_AT_flag (comp_unit_die
, DW_AT_MIPS_has_inlines
, 1);
8133 comp_unit_has_inlines
= 1;
8142 /* Generate a DIE to represent a declared data object. */
8145 gen_variable_die (decl
, context_die
)
8147 register dw_die_ref context_die
;
8149 register tree origin
= decl_ultimate_origin (decl
);
8150 register dw_die_ref var_die
= new_die (DW_TAG_variable
, context_die
);
8152 dw_die_ref old_die
= lookup_decl_die (decl
);
8154 = (DECL_EXTERNAL (decl
)
8155 || current_function_decl
!= decl_function_context (decl
)
8156 || context_die
->die_tag
== DW_TAG_structure_type
8157 || context_die
->die_tag
== DW_TAG_union_type
);
8160 add_abstract_origin_attribute (var_die
, origin
);
8161 /* Loop unrolling can create multiple blocks that refer to the same
8162 static variable, so we must test for the DW_AT_declaration flag. */
8163 /* ??? Loop unrolling/reorder_blocks should perhaps be rewritten to
8164 copy decls and set the DECL_ABSTRACT flag on them instead of
8166 else if (old_die
&& TREE_STATIC (decl
)
8167 && get_AT_flag (old_die
, DW_AT_declaration
) == 1)
8169 /* ??? This is an instantiation of a C++ class level static. */
8170 add_AT_die_ref (var_die
, DW_AT_specification
, old_die
);
8171 if (DECL_NAME (decl
))
8173 register unsigned file_index
8174 = lookup_filename (DECL_SOURCE_FILE (decl
));
8176 if (get_AT_unsigned (old_die
, DW_AT_decl_file
) != file_index
)
8177 add_AT_unsigned (var_die
, DW_AT_decl_file
, file_index
);
8179 if (get_AT_unsigned (old_die
, DW_AT_decl_line
)
8180 != DECL_SOURCE_LINE (decl
))
8182 add_AT_unsigned (var_die
, DW_AT_decl_line
,
8183 DECL_SOURCE_LINE (decl
));
8188 add_name_and_src_coords_attributes (var_die
, decl
);
8189 add_type_attribute (var_die
, TREE_TYPE (decl
),
8190 TREE_READONLY (decl
),
8191 TREE_THIS_VOLATILE (decl
), context_die
);
8193 if (TREE_PUBLIC (decl
))
8194 add_AT_flag (var_die
, DW_AT_external
, 1);
8196 if (DECL_ARTIFICIAL (decl
))
8197 add_AT_flag (var_die
, DW_AT_artificial
, 1);
8199 if (TREE_PROTECTED (decl
))
8200 add_AT_unsigned (var_die
, DW_AT_accessibility
, DW_ACCESS_protected
);
8202 else if (TREE_PRIVATE (decl
))
8203 add_AT_unsigned (var_die
, DW_AT_accessibility
, DW_ACCESS_private
);
8207 add_AT_flag (var_die
, DW_AT_declaration
, 1);
8209 if ((declaration
&& decl_class_context (decl
)) || DECL_ABSTRACT (decl
))
8210 equate_decl_number_to_die (decl
, var_die
);
8212 if (! declaration
&& ! DECL_ABSTRACT (decl
))
8214 equate_decl_number_to_die (decl
, var_die
);
8215 add_location_or_const_value_attribute (var_die
, decl
);
8216 add_pubname (decl
, var_die
);
8220 /* Generate a DIE to represent a label identifier. */
8223 gen_label_die (decl
, context_die
)
8225 register dw_die_ref context_die
;
8227 register tree origin
= decl_ultimate_origin (decl
);
8228 register dw_die_ref lbl_die
= new_die (DW_TAG_label
, context_die
);
8230 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
8231 char label2
[MAX_ARTIFICIAL_LABEL_BYTES
];
8234 add_abstract_origin_attribute (lbl_die
, origin
);
8236 add_name_and_src_coords_attributes (lbl_die
, decl
);
8238 if (DECL_ABSTRACT (decl
))
8239 equate_decl_number_to_die (decl
, lbl_die
);
8242 insn
= DECL_RTL (decl
);
8243 if (GET_CODE (insn
) == CODE_LABEL
)
8245 /* When optimization is enabled (via -O) some parts of the compiler
8246 (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
8247 represent source-level labels which were explicitly declared by
8248 the user. This really shouldn't be happening though, so catch
8249 it if it ever does happen. */
8250 if (INSN_DELETED_P (insn
))
8253 sprintf (label2
, INSN_LABEL_FMT
, current_funcdef_number
);
8254 ASM_GENERATE_INTERNAL_LABEL (label
, label2
,
8255 (unsigned) INSN_UID (insn
));
8256 add_AT_lbl_id (lbl_die
, DW_AT_low_pc
, label
);
8261 /* Generate a DIE for a lexical block. */
8264 gen_lexical_block_die (stmt
, context_die
, depth
)
8266 register dw_die_ref context_die
;
8269 register dw_die_ref stmt_die
= new_die (DW_TAG_lexical_block
, context_die
);
8270 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
8272 if (! BLOCK_ABSTRACT (stmt
))
8274 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_BEGIN_LABEL
,
8276 add_AT_lbl_id (stmt_die
, DW_AT_low_pc
, label
);
8277 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_END_LABEL
, next_block_number
);
8278 add_AT_lbl_id (stmt_die
, DW_AT_high_pc
, label
);
8281 push_decl_scope (stmt
);
8282 decls_for_scope (stmt
, stmt_die
, depth
);
8286 /* Generate a DIE for an inlined subprogram. */
8289 gen_inlined_subroutine_die (stmt
, context_die
, depth
)
8291 register dw_die_ref context_die
;
8294 if (! BLOCK_ABSTRACT (stmt
))
8296 register dw_die_ref subr_die
8297 = new_die (DW_TAG_inlined_subroutine
, context_die
);
8298 register tree decl
= block_ultimate_origin (stmt
);
8299 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
8301 add_abstract_origin_attribute (subr_die
, decl
);
8302 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_BEGIN_LABEL
,
8304 add_AT_lbl_id (subr_die
, DW_AT_low_pc
, label
);
8305 ASM_GENERATE_INTERNAL_LABEL (label
, BLOCK_END_LABEL
, next_block_number
);
8306 add_AT_lbl_id (subr_die
, DW_AT_high_pc
, label
);
8307 push_decl_scope (decl
);
8308 decls_for_scope (stmt
, subr_die
, depth
);
8310 current_function_has_inlines
= 1;
8314 /* Generate a DIE for a field in a record, or structure. */
8317 gen_field_die (decl
, context_die
)
8319 register dw_die_ref context_die
;
8321 register dw_die_ref decl_die
= new_die (DW_TAG_member
, context_die
);
8323 add_name_and_src_coords_attributes (decl_die
, decl
);
8324 add_type_attribute (decl_die
, member_declared_type (decl
),
8325 TREE_READONLY (decl
), TREE_THIS_VOLATILE (decl
),
8328 /* If this is a bit field... */
8329 if (DECL_BIT_FIELD_TYPE (decl
))
8331 add_byte_size_attribute (decl_die
, decl
);
8332 add_bit_size_attribute (decl_die
, decl
);
8333 add_bit_offset_attribute (decl_die
, decl
);
8336 if (TREE_CODE (DECL_FIELD_CONTEXT (decl
)) != UNION_TYPE
)
8337 add_data_member_location_attribute (decl_die
, decl
);
8339 if (DECL_ARTIFICIAL (decl
))
8340 add_AT_flag (decl_die
, DW_AT_artificial
, 1);
8342 if (TREE_PROTECTED (decl
))
8343 add_AT_unsigned (decl_die
, DW_AT_accessibility
, DW_ACCESS_protected
);
8345 else if (TREE_PRIVATE (decl
))
8346 add_AT_unsigned (decl_die
, DW_AT_accessibility
, DW_ACCESS_private
);
8350 /* Don't generate either pointer_type DIEs or reference_type DIEs here.
8351 Use modified_type_die instead.
8352 We keep this code here just in case these types of DIEs may be needed to
8353 represent certain things in other languages (e.g. Pascal) someday. */
8355 gen_pointer_type_die (type
, context_die
)
8357 register dw_die_ref context_die
;
8359 register dw_die_ref ptr_die
8360 = new_die (DW_TAG_pointer_type
, scope_die_for (type
, context_die
));
8362 equate_type_number_to_die (type
, ptr_die
);
8363 add_type_attribute (ptr_die
, TREE_TYPE (type
), 0, 0, context_die
);
8364 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
8367 /* Don't generate either pointer_type DIEs or reference_type DIEs here.
8368 Use modified_type_die instead.
8369 We keep this code here just in case these types of DIEs may be needed to
8370 represent certain things in other languages (e.g. Pascal) someday. */
8372 gen_reference_type_die (type
, context_die
)
8374 register dw_die_ref context_die
;
8376 register dw_die_ref ref_die
8377 = new_die (DW_TAG_reference_type
, scope_die_for (type
, context_die
));
8379 equate_type_number_to_die (type
, ref_die
);
8380 add_type_attribute (ref_die
, TREE_TYPE (type
), 0, 0, context_die
);
8381 add_AT_unsigned (mod_type_die
, DW_AT_byte_size
, PTR_SIZE
);
8385 /* Generate a DIE for a pointer to a member type. */
8387 gen_ptr_to_mbr_type_die (type
, context_die
)
8389 register dw_die_ref context_die
;
8391 register dw_die_ref ptr_die
8392 = new_die (DW_TAG_ptr_to_member_type
, scope_die_for (type
, context_die
));
8394 equate_type_number_to_die (type
, ptr_die
);
8395 add_AT_die_ref (ptr_die
, DW_AT_containing_type
,
8396 lookup_type_die (TYPE_OFFSET_BASETYPE (type
)));
8397 add_type_attribute (ptr_die
, TREE_TYPE (type
), 0, 0, context_die
);
8400 /* Generate the DIE for the compilation unit. */
8403 gen_compile_unit_die (main_input_filename
)
8404 register char *main_input_filename
;
8407 char *wd
= getpwd ();
8409 comp_unit_die
= new_die (DW_TAG_compile_unit
, NULL
);
8410 add_name_attribute (comp_unit_die
, main_input_filename
);
8413 add_AT_string (comp_unit_die
, DW_AT_comp_dir
, wd
);
8415 sprintf (producer
, "%s %s", language_string
, version_string
);
8417 #ifdef MIPS_DEBUGGING_INFO
8418 /* The MIPS/SGI compilers place the 'cc' command line options in the producer
8419 string. The SGI debugger looks for -g, -g1, -g2, or -g3; if they do
8420 not appear in the producer string, the debugger reaches the conclusion
8421 that the object file is stripped and has no debugging information.
8422 To get the MIPS/SGI debugger to believe that there is debugging
8423 information in the object file, we add a -g to the producer string. */
8424 if (debug_info_level
> DINFO_LEVEL_TERSE
)
8425 strcat (producer
, " -g");
8428 add_AT_string (comp_unit_die
, DW_AT_producer
, producer
);
8430 if (strcmp (language_string
, "GNU C++") == 0)
8431 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_C_plus_plus
);
8433 else if (strcmp (language_string
, "GNU Ada") == 0)
8434 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_Ada83
);
8436 else if (strcmp (language_string
, "GNU F77") == 0)
8437 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_Fortran77
);
8439 else if (strcmp (language_string
, "GNU Pascal") == 0)
8440 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_Pascal83
);
8442 else if (flag_traditional
)
8443 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_C
);
8446 add_AT_unsigned (comp_unit_die
, DW_AT_language
, DW_LANG_C89
);
8448 #if 0 /* unimplemented */
8449 if (debug_info_level
>= DINFO_LEVEL_VERBOSE
)
8450 add_AT_unsigned (comp_unit_die
, DW_AT_macro_info
, 0);
8454 /* Generate a DIE for a string type. */
8457 gen_string_type_die (type
, context_die
)
8459 register dw_die_ref context_die
;
8461 register dw_die_ref type_die
8462 = new_die (DW_TAG_string_type
, scope_die_for (type
, context_die
));
8464 equate_type_number_to_die (type
, type_die
);
8466 /* Fudge the string length attribute for now. */
8468 /* TODO: add string length info.
8469 string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
8470 bound_representation (upper_bound, 0, 'u'); */
8473 /* Generate the DIE for a base class. */
8476 gen_inheritance_die (binfo
, context_die
)
8477 register tree binfo
;
8478 register dw_die_ref context_die
;
8480 dw_die_ref die
= new_die (DW_TAG_inheritance
, context_die
);
8482 add_type_attribute (die
, BINFO_TYPE (binfo
), 0, 0, context_die
);
8483 add_data_member_location_attribute (die
, binfo
);
8485 if (TREE_VIA_VIRTUAL (binfo
))
8486 add_AT_unsigned (die
, DW_AT_virtuality
, DW_VIRTUALITY_virtual
);
8487 if (TREE_VIA_PUBLIC (binfo
))
8488 add_AT_unsigned (die
, DW_AT_accessibility
, DW_ACCESS_public
);
8489 else if (TREE_VIA_PROTECTED (binfo
))
8490 add_AT_unsigned (die
, DW_AT_accessibility
, DW_ACCESS_protected
);
8493 /* Genearate a DIE for a class member. */
8496 gen_member_die (type
, context_die
)
8498 register dw_die_ref context_die
;
8500 register tree member
;
8502 /* If this is not an incomplete type, output descriptions of each of its
8503 members. Note that as we output the DIEs necessary to represent the
8504 members of this record or union type, we will also be trying to output
8505 DIEs to represent the *types* of those members. However the `type'
8506 function (above) will specifically avoid generating type DIEs for member
8507 types *within* the list of member DIEs for this (containing) type execpt
8508 for those types (of members) which are explicitly marked as also being
8509 members of this (containing) type themselves. The g++ front- end can
8510 force any given type to be treated as a member of some other
8511 (containing) type by setting the TYPE_CONTEXT of the given (member) type
8512 to point to the TREE node representing the appropriate (containing)
8515 /* First output info about the base classes. */
8516 if (TYPE_BINFO (type
) && TYPE_BINFO_BASETYPES (type
))
8518 register tree bases
= TYPE_BINFO_BASETYPES (type
);
8519 register int n_bases
= TREE_VEC_LENGTH (bases
);
8522 for (i
= 0; i
< n_bases
; i
++)
8523 gen_inheritance_die (TREE_VEC_ELT (bases
, i
), context_die
);
8526 /* Now output info about the data members and type members. */
8527 for (member
= TYPE_FIELDS (type
); member
; member
= TREE_CHAIN (member
))
8528 gen_decl_die (member
, context_die
);
8530 /* Now output info about the function members (if any). */
8531 for (member
= TYPE_METHODS (type
); member
; member
= TREE_CHAIN (member
))
8532 gen_decl_die (member
, context_die
);
8535 /* Generate a DIE for a structure or union type. */
8538 gen_struct_or_union_type_die (type
, context_die
)
8540 register dw_die_ref context_die
;
8542 register dw_die_ref type_die
= lookup_type_die (type
);
8543 register dw_die_ref scope_die
= 0;
8544 register int nested
= 0;
8546 if (type_die
&& ! TYPE_SIZE (type
))
8549 if (TYPE_CONTEXT (type
) != NULL_TREE
8550 && TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type
))) == 't')
8553 scope_die
= scope_die_for (type
, context_die
);
8555 if (! type_die
|| (nested
&& scope_die
== comp_unit_die
))
8556 /* First occurrence of type or toplevel definition of nested class. */
8558 register dw_die_ref old_die
= type_die
;
8560 type_die
= new_die (TREE_CODE (type
) == RECORD_TYPE
8561 ? DW_TAG_structure_type
: DW_TAG_union_type
,
8563 equate_type_number_to_die (type
, type_die
);
8564 add_name_attribute (type_die
, type_tag (type
));
8566 add_AT_die_ref (type_die
, DW_AT_specification
, old_die
);
8569 remove_AT (type_die
, DW_AT_declaration
);
8571 /* If we're not in the right context to be defining this type, defer to
8572 avoid tricky recursion. */
8573 if (TYPE_SIZE (type
) && decl_scope_depth
> 0 && scope_die
== comp_unit_die
)
8575 add_AT_flag (type_die
, DW_AT_declaration
, 1);
8578 /* If this type has been completed, then give it a byte_size attribute and
8579 then give a list of members. */
8580 else if (TYPE_SIZE (type
))
8582 /* Prevent infinite recursion in cases where the type of some member of
8583 this type is expressed in terms of this type itself. */
8584 TREE_ASM_WRITTEN (type
) = 1;
8585 add_byte_size_attribute (type_die
, type
);
8586 if (TYPE_STUB_DECL (type
) != NULL_TREE
)
8587 add_src_coords_attributes (type_die
, TYPE_STUB_DECL (type
));
8589 /* If the first reference to this type was as the return type of an
8590 inline function, then it may not have a parent. Fix this now. */
8591 if (type_die
->die_parent
== NULL
)
8592 add_child_die (scope_die
, type_die
);
8594 push_decl_scope (type
);
8595 gen_member_die (type
, type_die
);
8598 /* GNU extension: Record what type our vtable lives in. */
8599 if (TYPE_VFIELD (type
))
8601 tree vtype
= DECL_FCONTEXT (TYPE_VFIELD (type
));
8603 gen_type_die (vtype
, context_die
);
8604 add_AT_die_ref (type_die
, DW_AT_containing_type
,
8605 lookup_type_die (vtype
));
8609 add_AT_flag (type_die
, DW_AT_declaration
, 1);
8612 /* Generate a DIE for a subroutine _type_. */
8615 gen_subroutine_type_die (type
, context_die
)
8617 register dw_die_ref context_die
;
8619 register tree return_type
= TREE_TYPE (type
);
8620 register dw_die_ref subr_die
8621 = new_die (DW_TAG_subroutine_type
, scope_die_for (type
, context_die
));
8623 equate_type_number_to_die (type
, subr_die
);
8624 add_prototyped_attribute (subr_die
, type
);
8625 add_type_attribute (subr_die
, return_type
, 0, 0, context_die
);
8626 gen_formal_types_die (type
, subr_die
);
8629 /* Generate a DIE for a type definition */
8632 gen_typedef_die (decl
, context_die
)
8634 register dw_die_ref context_die
;
8636 register dw_die_ref type_die
;
8637 register tree origin
;
8639 if (TREE_ASM_WRITTEN (decl
))
8641 TREE_ASM_WRITTEN (decl
) = 1;
8643 type_die
= new_die (DW_TAG_typedef
, scope_die_for (decl
, context_die
));
8644 origin
= decl_ultimate_origin (decl
);
8646 add_abstract_origin_attribute (type_die
, origin
);
8650 add_name_and_src_coords_attributes (type_die
, decl
);
8651 if (DECL_ORIGINAL_TYPE (decl
))
8653 type
= DECL_ORIGINAL_TYPE (decl
);
8654 equate_type_number_to_die (TREE_TYPE (decl
), type_die
);
8657 type
= TREE_TYPE (decl
);
8658 add_type_attribute (type_die
, type
, TREE_READONLY (decl
),
8659 TREE_THIS_VOLATILE (decl
), context_die
);
8662 if (DECL_ABSTRACT (decl
))
8663 equate_decl_number_to_die (decl
, type_die
);
8666 /* Generate a type description DIE. */
8669 gen_type_die (type
, context_die
)
8671 register dw_die_ref context_die
;
8673 if (type
== NULL_TREE
|| type
== error_mark_node
)
8676 /* We are going to output a DIE to represent the unqualified version of of
8677 this type (i.e. without any const or volatile qualifiers) so get the
8678 main variant (i.e. the unqualified version) of this type now. */
8679 type
= type_main_variant (type
);
8681 if (TREE_ASM_WRITTEN (type
))
8684 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
8685 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
8687 TREE_ASM_WRITTEN (type
) = 1;
8688 gen_decl_die (TYPE_NAME (type
), context_die
);
8692 switch (TREE_CODE (type
))
8698 case REFERENCE_TYPE
:
8699 /* For these types, all that is required is that we output a DIE (or a
8700 set of DIEs) to represent the "basis" type. */
8701 gen_type_die (TREE_TYPE (type
), context_die
);
8705 /* This code is used for C++ pointer-to-data-member types.
8706 Output a description of the relevant class type. */
8707 gen_type_die (TYPE_OFFSET_BASETYPE (type
), context_die
);
8709 /* Output a description of the type of the object pointed to. */
8710 gen_type_die (TREE_TYPE (type
), context_die
);
8712 /* Now output a DIE to represent this pointer-to-data-member type
8714 gen_ptr_to_mbr_type_die (type
, context_die
);
8718 gen_type_die (TYPE_DOMAIN (type
), context_die
);
8719 gen_set_type_die (type
, context_die
);
8723 gen_type_die (TREE_TYPE (type
), context_die
);
8724 abort (); /* No way to represent these in Dwarf yet! */
8728 /* Force out return type (in case it wasn't forced out already). */
8729 gen_type_die (TREE_TYPE (type
), context_die
);
8730 gen_subroutine_type_die (type
, context_die
);
8734 /* Force out return type (in case it wasn't forced out already). */
8735 gen_type_die (TREE_TYPE (type
), context_die
);
8736 gen_subroutine_type_die (type
, context_die
);
8740 if (TYPE_STRING_FLAG (type
) && TREE_CODE (TREE_TYPE (type
)) == CHAR_TYPE
)
8742 gen_type_die (TREE_TYPE (type
), context_die
);
8743 gen_string_type_die (type
, context_die
);
8746 gen_array_type_die (type
, context_die
);
8752 case QUAL_UNION_TYPE
:
8753 /* If this is a nested type whose containing class hasn't been
8754 written out yet, writing it out will cover this one, too. */
8755 if (TYPE_CONTEXT (type
)
8756 && TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type
))) == 't'
8757 && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type
)))
8759 gen_type_die (TYPE_CONTEXT (type
), context_die
);
8761 if (TREE_ASM_WRITTEN (TYPE_CONTEXT (type
)))
8764 /* If that failed, attach ourselves to the stub. */
8765 push_decl_scope (TYPE_CONTEXT (type
));
8766 context_die
= lookup_type_die (TYPE_CONTEXT (type
));
8769 if (TREE_CODE (type
) == ENUMERAL_TYPE
)
8770 gen_enumeration_type_die (type
, context_die
);
8772 gen_struct_or_union_type_die (type
, context_die
);
8774 if (TYPE_CONTEXT (type
)
8775 && TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type
))) == 't'
8776 && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type
)))
8779 /* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix
8780 it up if it is ever completed. gen_*_type_die will set it for us
8781 when appropriate. */
8790 /* No DIEs needed for fundamental types. */
8794 /* No Dwarf representation currently defined. */
8801 TREE_ASM_WRITTEN (type
) = 1;
8804 /* Generate a DIE for a tagged type instantiation. */
8807 gen_tagged_type_instantiation_die (type
, context_die
)
8809 register dw_die_ref context_die
;
8811 if (type
== NULL_TREE
|| type
== error_mark_node
)
8814 /* We are going to output a DIE to represent the unqualified version of of
8815 this type (i.e. without any const or volatile qualifiers) so make sure
8816 that we have the main variant (i.e. the unqualified version) of this
8818 if (type
!= type_main_variant (type
)
8819 || !TREE_ASM_WRITTEN (type
))
8822 switch (TREE_CODE (type
))
8828 gen_inlined_enumeration_type_die (type
, context_die
);
8832 gen_inlined_structure_type_die (type
, context_die
);
8836 case QUAL_UNION_TYPE
:
8837 gen_inlined_union_type_die (type
, context_die
);
8845 /* Generate a DW_TAG_lexical_block DIE followed by DIEs to represent all of the
8846 things which are local to the given block. */
8849 gen_block_die (stmt
, context_die
, depth
)
8851 register dw_die_ref context_die
;
8854 register int must_output_die
= 0;
8855 register tree origin
;
8857 register enum tree_code origin_code
;
8859 /* Ignore blocks never really used to make RTL. */
8861 if (stmt
== NULL_TREE
|| !TREE_USED (stmt
))
8864 /* Determine the "ultimate origin" of this block. This block may be an
8865 inlined instance of an inlined instance of inline function, so we have
8866 to trace all of the way back through the origin chain to find out what
8867 sort of node actually served as the original seed for the creation of
8868 the current block. */
8869 origin
= block_ultimate_origin (stmt
);
8870 origin_code
= (origin
!= NULL
) ? TREE_CODE (origin
) : ERROR_MARK
;
8872 /* Determine if we need to output any Dwarf DIEs at all to represent this
8874 if (origin_code
== FUNCTION_DECL
)
8875 /* The outer scopes for inlinings *must* always be represented. We
8876 generate DW_TAG_inlined_subroutine DIEs for them. (See below.) */
8877 must_output_die
= 1;
8880 /* In the case where the current block represents an inlining of the
8881 "body block" of an inline function, we must *NOT* output any DIE for
8882 this block because we have already output a DIE to represent the
8883 whole inlined function scope and the "body block" of any function
8884 doesn't really represent a different scope according to ANSI C
8885 rules. So we check here to make sure that this block does not
8886 represent a "body block inlining" before trying to set the
8887 `must_output_die' flag. */
8888 if (! is_body_block (origin
? origin
: stmt
))
8890 /* Determine if this block directly contains any "significant"
8891 local declarations which we will need to output DIEs for. */
8892 if (debug_info_level
> DINFO_LEVEL_TERSE
)
8893 /* We are not in terse mode so *any* local declaration counts
8894 as being a "significant" one. */
8895 must_output_die
= (BLOCK_VARS (stmt
) != NULL
);
8897 /* We are in terse mode, so only local (nested) function
8898 definitions count as "significant" local declarations. */
8899 for (decl
= BLOCK_VARS (stmt
);
8900 decl
!= NULL
; decl
= TREE_CHAIN (decl
))
8901 if (TREE_CODE (decl
) == FUNCTION_DECL
8902 && DECL_INITIAL (decl
))
8904 must_output_die
= 1;
8910 /* It would be a waste of space to generate a Dwarf DW_TAG_lexical_block
8911 DIE for any block which contains no significant local declarations at
8912 all. Rather, in such cases we just call `decls_for_scope' so that any
8913 needed Dwarf info for any sub-blocks will get properly generated. Note
8914 that in terse mode, our definition of what constitutes a "significant"
8915 local declaration gets restricted to include only inlined function
8916 instances and local (nested) function definitions. */
8917 if (must_output_die
)
8919 if (origin_code
== FUNCTION_DECL
)
8920 gen_inlined_subroutine_die (stmt
, context_die
, depth
);
8922 gen_lexical_block_die (stmt
, context_die
, depth
);
8925 decls_for_scope (stmt
, context_die
, depth
);
8928 /* Generate all of the decls declared within a given scope and (recursively)
8929 all of it's sub-blocks. */
8932 decls_for_scope (stmt
, context_die
, depth
)
8934 register dw_die_ref context_die
;
8938 register tree subblocks
;
8940 /* Ignore blocks never really used to make RTL. */
8941 if (stmt
== NULL_TREE
|| ! TREE_USED (stmt
))
8944 if (!BLOCK_ABSTRACT (stmt
) && depth
> 0)
8945 next_block_number
++;
8947 /* Output the DIEs to represent all of the data objects and typedefs
8948 declared directly within this block but not within any nested
8949 sub-blocks. Also, nested function and tag DIEs have been
8950 generated with a parent of NULL; fix that up now. */
8951 for (decl
= BLOCK_VARS (stmt
);
8952 decl
!= NULL
; decl
= TREE_CHAIN (decl
))
8954 register dw_die_ref die
;
8956 if (TREE_CODE (decl
) == FUNCTION_DECL
)
8957 die
= lookup_decl_die (decl
);
8958 else if (TREE_CODE (decl
) == TYPE_DECL
&& TYPE_DECL_IS_STUB (decl
))
8959 die
= lookup_type_die (TREE_TYPE (decl
));
8963 if (die
!= NULL
&& die
->die_parent
== NULL
)
8964 add_child_die (context_die
, die
);
8966 gen_decl_die (decl
, context_die
);
8969 /* Output the DIEs to represent all sub-blocks (and the items declared
8970 therein) of this block. */
8971 for (subblocks
= BLOCK_SUBBLOCKS (stmt
);
8973 subblocks
= BLOCK_CHAIN (subblocks
))
8974 gen_block_die (subblocks
, context_die
, depth
+ 1);
8977 /* Is this a typedef we can avoid emitting? */
8980 is_redundant_typedef (decl
)
8983 if (TYPE_DECL_IS_STUB (decl
))
8986 if (DECL_ARTIFICIAL (decl
)
8987 && DECL_CONTEXT (decl
)
8988 && is_tagged_type (DECL_CONTEXT (decl
))
8989 && TREE_CODE (TYPE_NAME (DECL_CONTEXT (decl
))) == TYPE_DECL
8990 && DECL_NAME (decl
) == DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl
))))
8991 /* Also ignore the artificial member typedef for the class name. */
8997 /* Generate Dwarf debug information for a decl described by DECL. */
9000 gen_decl_die (decl
, context_die
)
9002 register dw_die_ref context_die
;
9004 register tree origin
;
9006 /* Make a note of the decl node we are going to be working on. We may need
9007 to give the user the source coordinates of where it appeared in case we
9008 notice (later on) that something about it looks screwy. */
9009 dwarf_last_decl
= decl
;
9011 if (TREE_CODE (decl
) == ERROR_MARK
)
9014 /* If this ..._DECL node is marked to be ignored, then ignore it. But don't
9015 ignore a function definition, since that would screw up our count of
9016 blocks, and that it turn will completely screw up the the labels we will
9017 reference in subsequent DW_AT_low_pc and DW_AT_high_pc attributes (for
9018 subsequent blocks). */
9019 if (DECL_IGNORED_P (decl
) && TREE_CODE (decl
) != FUNCTION_DECL
)
9022 switch (TREE_CODE (decl
))
9025 /* The individual enumerators of an enum type get output when we output
9026 the Dwarf representation of the relevant enum type itself. */
9030 /* Don't output any DIEs to represent mere function declarations,
9031 unless they are class members or explicit block externs. */
9032 if (DECL_INITIAL (decl
) == NULL_TREE
&& DECL_CONTEXT (decl
) == NULL_TREE
9033 && (current_function_decl
== NULL_TREE
|| ! DECL_ARTIFICIAL (decl
)))
9036 if (debug_info_level
> DINFO_LEVEL_TERSE
)
9038 /* Before we describe the FUNCTION_DECL itself, make sure that we
9039 have described its return type. */
9040 gen_type_die (TREE_TYPE (TREE_TYPE (decl
)), context_die
);
9042 /* And its containing type. */
9043 origin
= decl_class_context (decl
);
9044 if (origin
!= NULL_TREE
)
9045 gen_type_die (origin
, context_die
);
9047 /* And its virtual context. */
9048 if (DECL_VINDEX (decl
) != NULL_TREE
)
9049 gen_type_die (DECL_CONTEXT (decl
), context_die
);
9052 /* Now output a DIE to represent the function itself. */
9053 gen_subprogram_die (decl
, context_die
);
9057 /* If we are in terse mode, don't generate any DIEs to represent any
9059 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
9062 /* In the special case of a TYPE_DECL node representing the
9063 declaration of some type tag, if the given TYPE_DECL is marked as
9064 having been instantiated from some other (original) TYPE_DECL node
9065 (e.g. one which was generated within the original definition of an
9066 inline function) we have to generate a special (abbreviated)
9067 DW_TAG_structure_type, DW_TAG_union_type, or DW_TAG_enumeration_type
9069 if (TYPE_DECL_IS_STUB (decl
) && DECL_ABSTRACT_ORIGIN (decl
) != NULL_TREE
)
9071 gen_tagged_type_instantiation_die (TREE_TYPE (decl
), context_die
);
9075 if (is_redundant_typedef (decl
))
9076 gen_type_die (TREE_TYPE (decl
), context_die
);
9078 /* Output a DIE to represent the typedef itself. */
9079 gen_typedef_die (decl
, context_die
);
9083 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
9084 gen_label_die (decl
, context_die
);
9088 /* If we are in terse mode, don't generate any DIEs to represent any
9089 variable declarations or definitions. */
9090 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
9093 /* Output any DIEs that are needed to specify the type of this data
9095 gen_type_die (TREE_TYPE (decl
), context_die
);
9097 /* And its containing type. */
9098 origin
= decl_class_context (decl
);
9099 if (origin
!= NULL_TREE
)
9100 gen_type_die (origin
, context_die
);
9102 /* Now output the DIE to represent the data object itself. This gets
9103 complicated because of the possibility that the VAR_DECL really
9104 represents an inlined instance of a formal parameter for an inline
9106 origin
= decl_ultimate_origin (decl
);
9107 if (origin
!= NULL_TREE
&& TREE_CODE (origin
) == PARM_DECL
)
9108 gen_formal_parameter_die (decl
, context_die
);
9110 gen_variable_die (decl
, context_die
);
9114 /* Ignore the nameless fields that are used to skip bits, but
9115 handle C++ anonymous unions. */
9116 if (DECL_NAME (decl
) != NULL_TREE
9117 || TREE_CODE (TREE_TYPE (decl
)) == UNION_TYPE
)
9119 gen_type_die (member_declared_type (decl
), context_die
);
9120 gen_field_die (decl
, context_die
);
9125 gen_type_die (TREE_TYPE (decl
), context_die
);
9126 gen_formal_parameter_die (decl
, context_die
);
9134 /* Write the debugging output for DECL. */
9137 dwarf2out_decl (decl
)
9140 register dw_die_ref context_die
= comp_unit_die
;
9142 if (TREE_CODE (decl
) == ERROR_MARK
)
9145 /* If this ..._DECL node is marked to be ignored, then ignore it. We gotta
9146 hope that the node in question doesn't represent a function definition.
9147 If it does, then totally ignoring it is bound to screw up our count of
9148 blocks, and that it turn will completely screw up the the labels we will
9149 reference in subsequent DW_AT_low_pc and DW_AT_high_pc attributes (for
9150 subsequent blocks). (It's too bad that BLOCK nodes don't carry their
9151 own sequence numbers with them!) */
9152 if (DECL_IGNORED_P (decl
))
9154 if (TREE_CODE (decl
) == FUNCTION_DECL
9155 && DECL_INITIAL (decl
) != NULL
)
9161 switch (TREE_CODE (decl
))
9164 /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of a
9165 builtin function. Explicit programmer-supplied declarations of
9166 these same functions should NOT be ignored however. */
9167 if (DECL_EXTERNAL (decl
) && DECL_FUNCTION_CODE (decl
))
9170 /* What we would really like to do here is to filter out all mere
9171 file-scope declarations of file-scope functions which are never
9172 referenced later within this translation unit (and keep all of ones
9173 that *are* referenced later on) but we aren't clarvoiant, so we have
9174 no idea which functions will be referenced in the future (i.e. later
9175 on within the current translation unit). So here we just ignore all
9176 file-scope function declarations which are not also definitions. If
9177 and when the debugger needs to know something about these funcstion,
9178 it wil have to hunt around and find the DWARF information associated
9179 with the definition of the function. Note that we can't just check
9180 `DECL_EXTERNAL' to find out which FUNCTION_DECL nodes represent
9181 definitions and which ones represent mere declarations. We have to
9182 check `DECL_INITIAL' instead. That's because the C front-end
9183 supports some weird semantics for "extern inline" function
9184 definitions. These can get inlined within the current translation
9185 unit (an thus, we need to generate DWARF info for their abstract
9186 instances so that the DWARF info for the concrete inlined instances
9187 can have something to refer to) but the compiler never generates any
9188 out-of-lines instances of such things (despite the fact that they
9189 *are* definitions). The important point is that the C front-end
9190 marks these "extern inline" functions as DECL_EXTERNAL, but we need
9191 to generate DWARF for them anyway. Note that the C++ front-end also
9192 plays some similar games for inline function definitions appearing
9193 within include files which also contain
9194 `#pragma interface' pragmas. */
9195 if (DECL_INITIAL (decl
) == NULL_TREE
)
9198 /* If we're a nested function, initially use a parent of NULL; if we're
9199 a plain function, this will be fixed up in decls_for_scope. If
9200 we're a method, it will be ignored, since we already have a DIE. */
9201 if (decl_function_context (decl
))
9207 /* Ignore this VAR_DECL if it refers to a file-scope extern data object
9208 declaration and if the declaration was never even referenced from
9209 within this entire compilation unit. We suppress these DIEs in
9210 order to save space in the .debug section (by eliminating entries
9211 which are probably useless). Note that we must not suppress
9212 block-local extern declarations (whether used or not) because that
9213 would screw-up the debugger's name lookup mechanism and cause it to
9214 miss things which really ought to be in scope at a given point. */
9215 if (DECL_EXTERNAL (decl
) && !TREE_USED (decl
))
9218 /* If we are in terse mode, don't generate any DIEs to represent any
9219 variable declarations or definitions. */
9220 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
9225 /* Don't bother trying to generate any DIEs to represent any of the
9226 normal built-in types for the language we are compiling. */
9227 if (DECL_SOURCE_LINE (decl
) == 0)
9229 /* OK, we need to generate one for `bool' so GDB knows what type
9230 comparisons have. */
9231 if ((get_AT_unsigned (comp_unit_die
, DW_AT_language
)
9232 == DW_LANG_C_plus_plus
)
9233 && TREE_CODE (TREE_TYPE (decl
)) == BOOLEAN_TYPE
)
9234 modified_type_die (TREE_TYPE (decl
), 0, 0, NULL
);
9239 /* If we are in terse mode, don't generate any DIEs for types. */
9240 if (debug_info_level
<= DINFO_LEVEL_TERSE
)
9243 /* If we're a function-scope tag, initially use a parent of NULL;
9244 this will be fixed up in decls_for_scope. */
9245 if (decl_function_context (decl
))
9254 gen_decl_die (decl
, context_die
);
9255 output_pending_types_for_scope (comp_unit_die
);
9258 /* Output a marker (i.e. a label) for the beginning of the generated code for
9262 dwarf2out_begin_block (blocknum
)
9263 register unsigned blocknum
;
9265 function_section (current_function_decl
);
9266 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, BLOCK_BEGIN_LABEL
, blocknum
);
9269 /* Output a marker (i.e. a label) for the end of the generated code for a
9273 dwarf2out_end_block (blocknum
)
9274 register unsigned blocknum
;
9276 function_section (current_function_decl
);
9277 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, BLOCK_END_LABEL
, blocknum
);
9280 /* Output a marker (i.e. a label) at a point in the assembly code which
9281 corresponds to a given source level label. */
9284 dwarf2out_label (insn
)
9287 char label
[MAX_ARTIFICIAL_LABEL_BYTES
];
9289 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
9291 function_section (current_function_decl
);
9292 sprintf (label
, INSN_LABEL_FMT
, current_funcdef_number
);
9293 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, label
,
9294 (unsigned) INSN_UID (insn
));
9298 /* Lookup a filename (in the list of filenames that we know about here in
9299 dwarf2out.c) and return its "index". The index of each (known) filename is
9300 just a unique number which is associated with only that one filename.
9301 We need such numbers for the sake of generating labels
9302 (in the .debug_sfnames section) and references to those
9303 files numbers (in the .debug_srcinfo and.debug_macinfo sections).
9304 If the filename given as an argument is not found in our current list,
9305 add it to the list and assign it the next available unique index number.
9306 In order to speed up searches, we remember the index of the filename
9307 was looked up last. This handles the majority of all searches. */
9310 lookup_filename (file_name
)
9313 static unsigned last_file_lookup_index
= 0;
9314 register unsigned i
;
9316 /* Check to see if the file name that was searched on the previous call
9317 matches this file name. If so, return the index. */
9318 if (last_file_lookup_index
!= 0)
9319 if (strcmp (file_name
, file_table
[last_file_lookup_index
]) == 0)
9320 return last_file_lookup_index
;
9322 /* Didn't match the previous lookup, search the table */
9323 for (i
= 1; i
< file_table_in_use
; ++i
)
9324 if (strcmp (file_name
, file_table
[i
]) == 0)
9326 last_file_lookup_index
= i
;
9330 /* Prepare to add a new table entry by making sure there is enough space in
9331 the table to do so. If not, expand the current table. */
9332 if (file_table_in_use
== file_table_allocated
)
9334 file_table_allocated
+= FILE_TABLE_INCREMENT
;
9336 = (char **) xrealloc (file_table
,
9337 file_table_allocated
* sizeof (char *));
9340 /* Add the new entry to the end of the filename table. */
9341 file_table
[file_table_in_use
] = xstrdup (file_name
);
9342 last_file_lookup_index
= file_table_in_use
++;
9344 return last_file_lookup_index
;
9347 /* Output a label to mark the beginning of a source code line entry
9348 and record information relating to this source line, in
9349 'line_info_table' for later output of the .debug_line section. */
9352 dwarf2out_line (filename
, line
)
9353 register char *filename
;
9354 register unsigned line
;
9356 if (debug_info_level
>= DINFO_LEVEL_NORMAL
)
9358 function_section (current_function_decl
);
9360 if (DECL_SECTION_NAME (current_function_decl
))
9362 register dw_separate_line_info_ref line_info
;
9363 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, SEPARATE_LINE_CODE_LABEL
,
9364 separate_line_info_table_in_use
);
9365 fputc ('\n', asm_out_file
);
9367 /* expand the line info table if necessary */
9368 if (separate_line_info_table_in_use
9369 == separate_line_info_table_allocated
)
9371 separate_line_info_table_allocated
+= LINE_INFO_TABLE_INCREMENT
;
9372 separate_line_info_table
9373 = (dw_separate_line_info_ref
)
9374 xrealloc (separate_line_info_table
,
9375 separate_line_info_table_allocated
9376 * sizeof (dw_separate_line_info_entry
));
9379 /* Add the new entry at the end of the line_info_table. */
9381 = &separate_line_info_table
[separate_line_info_table_in_use
++];
9382 line_info
->dw_file_num
= lookup_filename (filename
);
9383 line_info
->dw_line_num
= line
;
9384 line_info
->function
= current_funcdef_number
;
9388 register dw_line_info_ref line_info
;
9390 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, LINE_CODE_LABEL
,
9391 line_info_table_in_use
);
9392 fputc ('\n', asm_out_file
);
9394 /* Expand the line info table if necessary. */
9395 if (line_info_table_in_use
== line_info_table_allocated
)
9397 line_info_table_allocated
+= LINE_INFO_TABLE_INCREMENT
;
9399 = (dw_line_info_ref
)
9400 xrealloc (line_info_table
,
9401 (line_info_table_allocated
9402 * sizeof (dw_line_info_entry
)));
9405 /* Add the new entry at the end of the line_info_table. */
9406 line_info
= &line_info_table
[line_info_table_in_use
++];
9407 line_info
->dw_file_num
= lookup_filename (filename
);
9408 line_info
->dw_line_num
= line
;
9413 /* Record the beginning of a new source file, for later output
9414 of the .debug_macinfo section. At present, unimplemented. */
9417 dwarf2out_start_source_file (filename
)
9418 register char *filename
;
9422 /* Record the end of a source file, for later output
9423 of the .debug_macinfo section. At present, unimplemented. */
9426 dwarf2out_end_source_file ()
9430 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
9431 the tail part of the directive line, i.e. the part which is past the
9432 initial whitespace, #, whitespace, directive-name, whitespace part. */
9435 dwarf2out_define (lineno
, buffer
)
9436 register unsigned lineno
;
9437 register char *buffer
;
9439 static int initialized
= 0;
9442 dwarf2out_start_source_file (primary_filename
);
9447 /* Called from check_newline in c-parse.y. The `buffer' parameter contains
9448 the tail part of the directive line, i.e. the part which is past the
9449 initial whitespace, #, whitespace, directive-name, whitespace part. */
9452 dwarf2out_undef (lineno
, buffer
)
9453 register unsigned lineno
;
9454 register char *buffer
;
9458 /* Set up for Dwarf output at the start of compilation. */
9461 dwarf2out_init (asm_out_file
, main_input_filename
)
9462 register FILE *asm_out_file
;
9463 register char *main_input_filename
;
9465 /* Remember the name of the primary input file. */
9466 primary_filename
= main_input_filename
;
9468 /* Allocate the initial hunk of the file_table. */
9469 file_table
= (char **) xmalloc (FILE_TABLE_INCREMENT
* sizeof (char *));
9470 bzero ((char *) file_table
, FILE_TABLE_INCREMENT
* sizeof (char *));
9471 file_table_allocated
= FILE_TABLE_INCREMENT
;
9473 /* Skip the first entry - file numbers begin at 1. */
9474 file_table_in_use
= 1;
9476 /* Allocate the initial hunk of the decl_die_table. */
9478 = (dw_die_ref
*) xmalloc (DECL_DIE_TABLE_INCREMENT
* sizeof (dw_die_ref
));
9479 bzero ((char *) decl_die_table
,
9480 DECL_DIE_TABLE_INCREMENT
* sizeof (dw_die_ref
));
9481 decl_die_table_allocated
= DECL_DIE_TABLE_INCREMENT
;
9482 decl_die_table_in_use
= 0;
9484 /* Allocate the initial hunk of the decl_scope_table. */
9486 = (tree
*) xmalloc (DECL_SCOPE_TABLE_INCREMENT
* sizeof (tree
));
9487 bzero ((char *) decl_scope_table
,
9488 DECL_SCOPE_TABLE_INCREMENT
* sizeof (tree
));
9489 decl_scope_table_allocated
= DECL_SCOPE_TABLE_INCREMENT
;
9490 decl_scope_depth
= 0;
9492 /* Allocate the initial hunk of the abbrev_die_table. */
9494 = (dw_die_ref
*) xmalloc (ABBREV_DIE_TABLE_INCREMENT
9495 * sizeof (dw_die_ref
));
9496 bzero ((char *) abbrev_die_table
,
9497 ABBREV_DIE_TABLE_INCREMENT
* sizeof (dw_die_ref
));
9498 abbrev_die_table_allocated
= ABBREV_DIE_TABLE_INCREMENT
;
9499 /* Zero-th entry is allocated, but unused */
9500 abbrev_die_table_in_use
= 1;
9502 /* Allocate the initial hunk of the line_info_table. */
9504 = (dw_line_info_ref
) xmalloc (LINE_INFO_TABLE_INCREMENT
9505 * sizeof (dw_line_info_entry
));
9506 bzero ((char *) line_info_table
,
9507 LINE_INFO_TABLE_INCREMENT
* sizeof (dw_line_info_entry
));
9508 line_info_table_allocated
= LINE_INFO_TABLE_INCREMENT
;
9509 /* Zero-th entry is allocated, but unused */
9510 line_info_table_in_use
= 1;
9512 /* Generate the initial DIE for the .debug section. Note that the (string)
9513 value given in the DW_AT_name attribute of the DW_TAG_compile_unit DIE
9514 will (typically) be a relative pathname and that this pathname should be
9515 taken as being relative to the directory from which the compiler was
9516 invoked when the given (base) source file was compiled. */
9517 gen_compile_unit_die (main_input_filename
);
9519 ASM_GENERATE_INTERNAL_LABEL (text_end_label
, TEXT_END_LABEL
, 0);
9522 /* Output stuff that dwarf requires at the end of every file,
9523 and generate the DWARF-2 debugging info. */
9528 limbo_die_node
*node
, *next_node
;
9532 /* Traverse the limbo die list, and add parent/child links. The only
9533 dies without parents that should be here are concrete instances of
9534 inline functions, and the comp_unit_die. We can ignore the comp_unit_die.
9535 For concrete instances, we can get the parent die from the abstract
9537 for (node
= limbo_die_list
; node
; node
= next_node
)
9539 next_node
= node
->next
;
9542 if (die
->die_parent
== NULL
)
9544 a
= get_AT (die
, DW_AT_abstract_origin
);
9546 add_child_die (a
->dw_attr_val
.v
.val_die_ref
->die_parent
, die
);
9547 else if (die
== comp_unit_die
)
9555 /* Traverse the DIE tree and add sibling attributes to those DIE's
9556 that have children. */
9557 add_sibling_attributes (comp_unit_die
);
9559 /* Output a terminator label for the .text section. */
9560 fputc ('\n', asm_out_file
);
9561 ASM_OUTPUT_SECTION (asm_out_file
, TEXT_SECTION
);
9562 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, TEXT_END_LABEL
, 0);
9565 /* Output a terminator label for the .data section. */
9566 fputc ('\n', asm_out_file
);
9567 ASM_OUTPUT_SECTION (asm_out_file
, DATA_SECTION
);
9568 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, DATA_END_LABEL
, 0);
9570 /* Output a terminator label for the .bss section. */
9571 fputc ('\n', asm_out_file
);
9572 ASM_OUTPUT_SECTION (asm_out_file
, BSS_SECTION
);
9573 ASM_OUTPUT_INTERNAL_LABEL (asm_out_file
, BSS_END_LABEL
, 0);
9576 /* Output the source line correspondence table. */
9577 if (line_info_table_in_use
> 1 || separate_line_info_table_in_use
)
9579 fputc ('\n', asm_out_file
);
9580 ASM_OUTPUT_SECTION (asm_out_file
, DEBUG_LINE_SECTION
);
9581 output_line_info ();
9583 /* We can only use the low/high_pc attributes if all of the code
9585 if (separate_line_info_table_in_use
== 0)
9587 add_AT_lbl_id (comp_unit_die
, DW_AT_low_pc
, TEXT_SECTION
);
9588 add_AT_lbl_id (comp_unit_die
, DW_AT_high_pc
, text_end_label
);
9591 add_AT_section_offset (comp_unit_die
, DW_AT_stmt_list
, DEBUG_LINE_SECTION
);
9594 /* Output the abbreviation table. */
9595 fputc ('\n', asm_out_file
);
9596 ASM_OUTPUT_SECTION (asm_out_file
, ABBREV_SECTION
);
9597 build_abbrev_table (comp_unit_die
);
9598 output_abbrev_section ();
9600 /* Initialize the beginning DIE offset - and calculate sizes/offsets. */
9601 next_die_offset
= DWARF_COMPILE_UNIT_HEADER_SIZE
;
9602 calc_die_sizes (comp_unit_die
);
9604 /* Output debugging information. */
9605 fputc ('\n', asm_out_file
);
9606 ASM_OUTPUT_SECTION (asm_out_file
, DEBUG_INFO_SECTION
);
9607 output_compilation_unit_header ();
9608 output_die (comp_unit_die
);
9610 if (pubname_table_in_use
)
9612 /* Output public names table. */
9613 fputc ('\n', asm_out_file
);
9614 ASM_OUTPUT_SECTION (asm_out_file
, PUBNAMES_SECTION
);
9618 if (fde_table_in_use
)
9620 /* Output the address range information. */
9621 fputc ('\n', asm_out_file
);
9622 ASM_OUTPUT_SECTION (asm_out_file
, ARANGES_SECTION
);
9626 #endif /* DWARF2_DEBUGGING_INFO */