1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /* Output dbx-format symbol table data.
24 This consists of many symbol table entries, each of them
25 a .stabs assembler pseudo-op with four operands:
26 a "name" which is really a description of one symbol and its type,
27 a "code", which is a symbol defined in stab.h whose name starts with N_,
28 an unused operand always 0,
29 and a "value" which is an address or an offset.
30 The name is enclosed in doublequote characters.
32 Each function, variable, typedef, and structure tag
33 has a symbol table entry to define it.
34 The beginning and end of each level of name scoping within
35 a function are also marked by special symbol table entries.
37 The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
38 and a data type number. The data type number may be followed by
39 "=" and a type definition; normally this will happen the first time
40 the type number is mentioned. The type definition may refer to
41 other types by number, and those type numbers may be followed
42 by "=" and nested definitions.
44 This can make the "name" quite long.
45 When a name is more than 80 characters, we split the .stabs pseudo-op
46 into two .stabs pseudo-ops, both sharing the same "code" and "value".
47 The first one is marked as continued with a double-backslash at the
50 The kind-of-symbol letter distinguished function names from global
51 variables from file-scope variables from parameters from auto
52 variables in memory from typedef names from register variables.
55 The "code" is mostly redundant with the kind-of-symbol letter
56 that goes in the "name", but not entirely: for symbols located
57 in static storage, the "code" says which segment the address is in,
58 which controls how it is relocated.
60 The "value" for a symbol in static storage
61 is the core address of the symbol (actually, the assembler
62 label for the symbol). For a symbol located in a stack slot
63 it is the stack offset; for one in a register, the register number.
64 For a typedef symbol, it is zero.
66 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
67 output while in the text section.
69 For more on data type definitions, see `dbxout_type'. */
73 #include "coretypes.h"
80 #include "insn-config.h"
90 #include "langhooks.h"
93 #ifdef XCOFF_DEBUGGING_INFO
97 #define DBXOUT_DECR_NESTING \
98 if (--debug_nesting == 0 && symbol_queue_index > 0) \
99 { emit_pending_bincls_if_required (); debug_flush_symbol_queue (); }
101 #define DBXOUT_DECR_NESTING_AND_RETURN(x) \
102 do {--debug_nesting; return (x);} while (0)
105 # ifdef XCOFF_DEBUGGING_INFO
106 # define ASM_STABS_OP "\t.stabx\t"
108 # define ASM_STABS_OP "\t.stabs\t"
113 #define ASM_STABN_OP "\t.stabn\t"
117 #define ASM_STABD_OP "\t.stabd\t"
120 #ifndef DBX_TYPE_DECL_STABS_CODE
121 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
124 #ifndef DBX_STATIC_CONST_VAR_CODE
125 #define DBX_STATIC_CONST_VAR_CODE N_FUN
128 #ifndef DBX_REGPARM_STABS_CODE
129 #define DBX_REGPARM_STABS_CODE N_RSYM
132 #ifndef DBX_REGPARM_STABS_LETTER
133 #define DBX_REGPARM_STABS_LETTER 'P'
136 #ifndef NO_DBX_FUNCTION_END
137 #define NO_DBX_FUNCTION_END 0
140 #ifndef NO_DBX_BNSYM_ENSYM
141 #define NO_DBX_BNSYM_ENSYM 0
144 #ifndef NO_DBX_MAIN_SOURCE_DIRECTORY
145 #define NO_DBX_MAIN_SOURCE_DIRECTORY 0
148 #ifndef DBX_BLOCKS_FUNCTION_RELATIVE
149 #define DBX_BLOCKS_FUNCTION_RELATIVE 0
152 #ifndef DBX_LINES_FUNCTION_RELATIVE
153 #define DBX_LINES_FUNCTION_RELATIVE 0
156 #ifndef DBX_CONTIN_LENGTH
157 #define DBX_CONTIN_LENGTH 80
160 #ifndef DBX_CONTIN_CHAR
161 #define DBX_CONTIN_CHAR '\\'
164 enum typestatus
{TYPE_UNSEEN
, TYPE_XREF
, TYPE_DEFINED
};
166 /* Structure recording information about a C data type.
167 The status element says whether we have yet output
168 the definition of the type. TYPE_XREF says we have
169 output it as a cross-reference only.
170 The file_number and type_number elements are used if DBX_USE_BINCL
173 struct typeinfo
GTY(())
175 enum typestatus status
;
180 /* Vector recording information about C data types.
181 When we first notice a data type (a tree node),
182 we assign it a number using next_type_number.
183 That is its index in this vector. */
185 static GTY ((length ("typevec_len"))) struct typeinfo
*typevec
;
187 /* Number of elements of space allocated in `typevec'. */
189 static GTY(()) int typevec_len
;
191 /* In dbx output, each type gets a unique number.
192 This is the number for the next type output.
193 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
195 static GTY(()) int next_type_number
;
197 /* The C front end may call dbxout_symbol before dbxout_init runs.
198 We save all such decls in this list and output them when we get
201 static GTY(()) tree preinit_symbols
;
203 enum binclstatus
{BINCL_NOT_REQUIRED
, BINCL_PENDING
, BINCL_PROCESSED
};
205 /* When using N_BINCL in dbx output, each type number is actually a
206 pair of the file number and the type number within the file.
207 This is a stack of input files. */
211 struct dbx_file
*next
;
213 int next_type_number
;
214 enum binclstatus bincl_status
; /* Keep track of lazy bincl. */
215 const char *pending_bincl_name
; /* Name of bincl. */
216 struct dbx_file
*prev
; /* Chain to traverse all pending bincls. */
219 /* This is the top of the stack.
221 This is not saved for PCH, because restoring a PCH should not change it.
222 next_file_number does have to be saved, because the PCH may use some
223 file numbers; however, just before restoring a PCH, next_file_number
224 should always be 0 because we should not have needed any file numbers
227 #if (defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)) \
228 && defined (DBX_USE_BINCL)
229 static struct dbx_file
*current_file
;
232 /* This is the next file number to use. */
234 static GTY(()) int next_file_number
;
236 /* A counter for dbxout_function_end. */
238 static GTY(()) int scope_labelno
;
240 /* A counter for dbxout_source_line. */
242 static GTY(()) int dbxout_source_line_counter
;
244 /* Nonzero if we have actually used any of the GDB extensions
245 to the debugging format. The idea is that we use them for the
246 first time only if there's a strong reason, but once we have done that,
247 we use them whenever convenient. */
249 static GTY(()) int have_used_extensions
= 0;
251 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
252 for the N_SO filename stabs label. */
254 static GTY(()) int source_label_number
= 1;
256 /* Last source file name mentioned in a NOTE insn. */
258 static GTY(()) const char *lastfile
;
260 /* Used by PCH machinery to detect if 'lastfile' should be reset to
262 static GTY(()) int lastfile_is_base
;
264 /* Typical USG systems don't have stab.h, and they also have
265 no use for DBX-format debugging info. */
267 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
270 /* If zero then there is no pending BINCL. */
271 static int pending_bincls
= 0;
274 /* The original input file name. */
275 static const char *base_input_file
;
277 #ifdef DEBUG_SYMS_TEXT
278 #define FORCE_TEXT current_function_section (current_function_decl);
285 #define STAB_CODE_TYPE enum __stab_debug_code
287 /* 1 if PARM is passed to this function in memory. */
289 #define PARM_PASSED_IN_MEMORY(PARM) \
290 (MEM_P (DECL_INCOMING_RTL (PARM)))
292 /* A C expression for the integer offset value of an automatic variable
293 (N_LSYM) having address X (an RTX). */
294 #ifndef DEBUGGER_AUTO_OFFSET
295 #define DEBUGGER_AUTO_OFFSET(X) \
296 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
299 /* A C expression for the integer offset value of an argument (N_PSYM)
300 having address X (an RTX). The nominal offset is OFFSET. */
301 #ifndef DEBUGGER_ARG_OFFSET
302 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
305 /* This obstack holds the stab string currently being constructed. We
306 build it up here, then write it out, so we can split long lines up
307 properly (see dbxout_finish_complex_stabs). */
308 static struct obstack stabstr_ob
;
309 static size_t stabstr_last_contin_point
;
312 static void emit_bincl_stab (const char *c
);
313 static void emit_pending_bincls (void);
315 static inline void emit_pending_bincls_if_required (void);
317 static void dbxout_init (const char *);
319 static void dbxout_finish (const char *);
320 static void dbxout_start_source_file (unsigned, const char *);
321 static void dbxout_end_source_file (unsigned);
322 static void dbxout_typedefs (tree
);
323 static void dbxout_type_index (tree
);
324 static void dbxout_args (tree
);
325 static void dbxout_type_fields (tree
);
326 static void dbxout_type_method_1 (tree
);
327 static void dbxout_type_methods (tree
);
328 static void dbxout_range_type (tree
);
329 static void dbxout_type (tree
, int);
330 static bool print_int_cst_bounds_in_octal_p (tree
);
331 static void dbxout_type_name (tree
);
332 static void dbxout_class_name_qualifiers (tree
);
333 static int dbxout_symbol_location (tree
, tree
, const char *, rtx
);
334 static void dbxout_symbol_name (tree
, const char *, int);
335 static void dbxout_block (tree
, int, tree
);
336 static void dbxout_global_decl (tree
);
337 static void dbxout_type_decl (tree
, int);
338 static void dbxout_handle_pch (unsigned);
340 /* The debug hooks structure. */
341 #if defined (DBX_DEBUGGING_INFO)
343 static void dbxout_source_line (unsigned int, const char *);
344 static void dbxout_begin_prologue (unsigned int, const char *);
345 static void dbxout_source_file (const char *);
346 static void dbxout_function_end (tree
);
347 static void dbxout_begin_function (tree
);
348 static void dbxout_begin_block (unsigned, unsigned);
349 static void dbxout_end_block (unsigned, unsigned);
350 static void dbxout_function_decl (tree
);
352 const struct gcc_debug_hooks dbx_debug_hooks
=
356 debug_nothing_int_charstar
,
357 debug_nothing_int_charstar
,
358 dbxout_start_source_file
,
359 dbxout_end_source_file
,
362 debug_true_tree
, /* ignore_block */
363 dbxout_source_line
, /* source_line */
364 dbxout_begin_prologue
, /* begin_prologue */
365 debug_nothing_int_charstar
, /* end_prologue */
366 debug_nothing_int_charstar
, /* end_epilogue */
367 #ifdef DBX_FUNCTION_FIRST
368 dbxout_begin_function
,
370 debug_nothing_tree
, /* begin_function */
372 debug_nothing_int
, /* end_function */
373 dbxout_function_decl
,
374 dbxout_global_decl
, /* global_decl */
375 dbxout_type_decl
, /* type_decl */
376 debug_nothing_tree_tree
, /* imported_module_or_decl */
377 debug_nothing_tree
, /* deferred_inline_function */
378 debug_nothing_tree
, /* outlining_inline_function */
379 debug_nothing_rtx
, /* label */
380 dbxout_handle_pch
, /* handle_pch */
381 debug_nothing_rtx
, /* var_location */
382 debug_nothing_void
, /* switch_text_section */
383 0 /* start_end_main_source_file */
385 #endif /* DBX_DEBUGGING_INFO */
387 #if defined (XCOFF_DEBUGGING_INFO)
388 const struct gcc_debug_hooks xcoff_debug_hooks
=
392 debug_nothing_int_charstar
,
393 debug_nothing_int_charstar
,
394 dbxout_start_source_file
,
395 dbxout_end_source_file
,
396 xcoffout_begin_block
,
398 debug_true_tree
, /* ignore_block */
399 xcoffout_source_line
,
400 xcoffout_begin_prologue
, /* begin_prologue */
401 debug_nothing_int_charstar
, /* end_prologue */
402 xcoffout_end_epilogue
,
403 debug_nothing_tree
, /* begin_function */
404 xcoffout_end_function
,
405 debug_nothing_tree
, /* function_decl */
406 dbxout_global_decl
, /* global_decl */
407 dbxout_type_decl
, /* type_decl */
408 debug_nothing_tree_tree
, /* imported_module_or_decl */
409 debug_nothing_tree
, /* deferred_inline_function */
410 debug_nothing_tree
, /* outlining_inline_function */
411 debug_nothing_rtx
, /* label */
412 dbxout_handle_pch
, /* handle_pch */
413 debug_nothing_rtx
, /* var_location */
414 debug_nothing_void
, /* switch_text_section */
415 0 /* start_end_main_source_file */
417 #endif /* XCOFF_DEBUGGING_INFO */
419 /* Numeric formatting helper macro. Note that this does not handle
421 #define NUMBER_FMT_LOOP(P, NUM, BASE) \
424 int digit = NUM % BASE; \
426 *--P = digit + '0'; \
430 /* Utility: write a decimal integer NUM to asm_out_file. */
435 char *p
= buf
+ sizeof buf
;
440 putc ('0', asm_out_file
);
445 putc ('-', asm_out_file
);
451 NUMBER_FMT_LOOP (p
, unum
, 10);
453 while (p
< buf
+ sizeof buf
)
455 putc (*p
, asm_out_file
);
461 /* Primitives for emitting simple stabs directives. All other stabs
462 routines should use these functions instead of directly emitting
463 stabs. They are exported because machine-dependent code may need
464 to invoke them, e.g. in a DBX_OUTPUT_* macro whose definition
465 forwards to code in CPU.c. */
467 /* The following functions should all be called immediately after one
468 of the dbxout_begin_stab* functions (below). They write out
469 various things as the value of a stab. */
471 /* Write out a literal zero as the value of a stab. */
473 dbxout_stab_value_zero (void)
475 fputs ("0\n", asm_out_file
);
478 /* Write out the label LABEL as the value of a stab. */
480 dbxout_stab_value_label (const char *label
)
482 assemble_name (asm_out_file
, label
);
483 putc ('\n', asm_out_file
);
486 /* Write out the difference of two labels, LABEL - BASE, as the value
489 dbxout_stab_value_label_diff (const char *label
, const char *base
)
491 assemble_name (asm_out_file
, label
);
492 putc ('-', asm_out_file
);
493 assemble_name (asm_out_file
, base
);
494 putc ('\n', asm_out_file
);
497 /* Write out an internal label as the value of a stab, and immediately
498 emit that internal label. This should be used only when
499 dbxout_stabd will not work. STEM is the name stem of the label,
500 COUNTERP is a pointer to a counter variable which will be used to
501 guarantee label uniqueness. */
503 dbxout_stab_value_internal_label (const char *stem
, int *counterp
)
506 int counter
= counterp
? (*counterp
)++ : 0;
508 ASM_GENERATE_INTERNAL_LABEL (label
, stem
, counter
);
509 dbxout_stab_value_label (label
);
510 targetm
.asm_out
.internal_label (asm_out_file
, stem
, counter
);
513 /* Write out the difference between BASE and an internal label as the
514 value of a stab, and immediately emit that internal label. STEM and
515 COUNTERP are as for dbxout_stab_value_internal_label. */
517 dbxout_stab_value_internal_label_diff (const char *stem
, int *counterp
,
521 int counter
= counterp
? (*counterp
)++ : 0;
523 ASM_GENERATE_INTERNAL_LABEL (label
, stem
, counter
);
524 dbxout_stab_value_label_diff (label
, base
);
525 targetm
.asm_out
.internal_label (asm_out_file
, stem
, counter
);
528 /* The following functions produce specific kinds of stab directives. */
530 /* Write a .stabd directive with type STYPE and desc SDESC to asm_out_file. */
532 dbxout_stabd (int stype
, int sdesc
)
534 fputs (ASM_STABD_OP
, asm_out_file
);
536 fputs (",0,", asm_out_file
);
538 putc ('\n', asm_out_file
);
541 /* Write a .stabn directive with type STYPE. This function stops
542 short of emitting the value field, which is the responsibility of
543 the caller (normally it will be either a symbol or the difference
547 dbxout_begin_stabn (int stype
)
549 fputs (ASM_STABN_OP
, asm_out_file
);
551 fputs (",0,0,", asm_out_file
);
554 /* Write a .stabn directive with type N_SLINE and desc LINE. As above,
555 the value field is the responsibility of the caller. */
557 dbxout_begin_stabn_sline (int lineno
)
559 fputs (ASM_STABN_OP
, asm_out_file
);
560 dbxout_int (N_SLINE
);
561 fputs (",0,", asm_out_file
);
563 putc (',', asm_out_file
);
566 /* Begin a .stabs directive with string "", type STYPE, and desc and
567 other fields 0. The value field is the responsibility of the
568 caller. This function cannot be used for .stabx directives. */
570 dbxout_begin_empty_stabs (int stype
)
572 fputs (ASM_STABS_OP
, asm_out_file
);
573 fputs ("\"\",", asm_out_file
);
575 fputs (",0,0,", asm_out_file
);
578 /* Begin a .stabs directive with string STR, type STYPE, and desc 0.
579 The value field is the responsibility of the caller. */
581 dbxout_begin_simple_stabs (const char *str
, int stype
)
583 fputs (ASM_STABS_OP
, asm_out_file
);
584 output_quoted_string (asm_out_file
, str
);
585 putc (',', asm_out_file
);
587 fputs (",0,0,", asm_out_file
);
590 /* As above but use SDESC for the desc field. */
592 dbxout_begin_simple_stabs_desc (const char *str
, int stype
, int sdesc
)
594 fputs (ASM_STABS_OP
, asm_out_file
);
595 output_quoted_string (asm_out_file
, str
);
596 putc (',', asm_out_file
);
598 fputs (",0,", asm_out_file
);
600 putc (',', asm_out_file
);
603 /* The next set of functions are entirely concerned with production of
604 "complex" .stabs directives: that is, .stabs directives whose
605 strings have to be constructed piecemeal. dbxout_type,
606 dbxout_symbol, etc. use these routines heavily. The string is queued
607 up in an obstack, then written out by dbxout_finish_complex_stabs, which
608 is also responsible for splitting it up if it exceeds DBX_CONTIN_LENGTH.
609 (You might think it would be more efficient to go straight to stdio
610 when DBX_CONTIN_LENGTH is 0 (i.e. no length limit) but that turns
611 out not to be the case, and anyway this needs fewer #ifdefs.) */
613 /* Begin a complex .stabs directive. If we can, write the initial
614 ASM_STABS_OP to the asm_out_file. */
617 dbxout_begin_complex_stabs (void)
619 emit_pending_bincls_if_required ();
621 fputs (ASM_STABS_OP
, asm_out_file
);
622 putc ('"', asm_out_file
);
623 gcc_assert (stabstr_last_contin_point
== 0);
626 /* As above, but do not force text or emit pending bincls. This is
627 used by dbxout_symbol_location, which needs to do something else. */
629 dbxout_begin_complex_stabs_noforcetext (void)
631 fputs (ASM_STABS_OP
, asm_out_file
);
632 putc ('"', asm_out_file
);
633 gcc_assert (stabstr_last_contin_point
== 0);
636 /* Add CHR, a single character, to the string being built. */
637 #define stabstr_C(chr) obstack_1grow (&stabstr_ob, chr)
639 /* Add STR, a normal C string, to the string being built. */
640 #define stabstr_S(str) obstack_grow (&stabstr_ob, str, strlen(str))
642 /* Add the text of ID, an IDENTIFIER_NODE, to the string being built. */
643 #define stabstr_I(id) obstack_grow (&stabstr_ob, \
644 IDENTIFIER_POINTER (id), \
645 IDENTIFIER_LENGTH (id))
647 /* Add NUM, a signed decimal number, to the string being built. */
649 stabstr_D (HOST_WIDE_INT num
)
652 char *p
= buf
+ sizeof buf
;
668 NUMBER_FMT_LOOP (p
, unum
, 10);
670 obstack_grow (&stabstr_ob
, p
, (buf
+ sizeof buf
) - p
);
673 /* Add NUM, an unsigned decimal number, to the string being built. */
675 stabstr_U (unsigned HOST_WIDE_INT num
)
678 char *p
= buf
+ sizeof buf
;
684 NUMBER_FMT_LOOP (p
, num
, 10);
685 obstack_grow (&stabstr_ob
, p
, (buf
+ sizeof buf
) - p
);
688 /* Add CST, an INTEGER_CST tree, to the string being built as an
689 unsigned octal number. This routine handles values which are
690 larger than a single HOST_WIDE_INT. */
694 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (cst
);
695 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (cst
);
698 char *p
= buf
+ sizeof buf
;
700 /* GDB wants constants with no extra leading "1" bits, so
701 we need to remove any sign-extension that might be
704 const unsigned int width
= TYPE_PRECISION (TREE_TYPE (cst
));
705 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
707 else if (width
> HOST_BITS_PER_WIDE_INT
)
708 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
709 else if (width
== HOST_BITS_PER_WIDE_INT
)
712 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
715 /* Leading zero for base indicator. */
718 /* If the value is zero, the base indicator will serve as the value
720 if (high
== 0 && low
== 0)
723 /* If the high half is zero, we need only print the low half normally. */
725 NUMBER_FMT_LOOP (p
, low
, 8);
728 /* When high != 0, we need to print enough zeroes from low to
729 give the digits from high their proper place-values. Hence
730 NUMBER_FMT_LOOP cannot be used. */
731 const int n_digits
= HOST_BITS_PER_WIDE_INT
/ 3;
734 for (i
= 1; i
<= n_digits
; i
++)
736 unsigned int digit
= low
% 8;
741 /* Octal digits carry exactly three bits of information. The
742 width of a HOST_WIDE_INT is not normally a multiple of three.
743 Therefore, the next digit printed probably needs to carry
744 information from both low and high. */
745 if (HOST_BITS_PER_WIDE_INT
% 3 != 0)
747 const int n_leftover_bits
= HOST_BITS_PER_WIDE_INT
% 3;
748 const int n_bits_from_high
= 3 - n_leftover_bits
;
750 const unsigned HOST_WIDE_INT
751 low_mask
= (((unsigned HOST_WIDE_INT
)1) << n_leftover_bits
) - 1;
752 const unsigned HOST_WIDE_INT
753 high_mask
= (((unsigned HOST_WIDE_INT
)1) << n_bits_from_high
) - 1;
757 /* At this point, only the bottom n_leftover_bits bits of low
759 gcc_assert (!(low
& ~low_mask
));
761 digit
= (low
| ((high
& high_mask
) << n_leftover_bits
));
762 high
>>= n_bits_from_high
;
767 /* Now we can format high in the normal manner. However, if
768 the only bits of high that were set were handled by the
769 digit split between low and high, high will now be zero, and
770 we don't want to print extra digits in that case. */
772 NUMBER_FMT_LOOP (p
, high
, 8);
775 obstack_grow (&stabstr_ob
, p
, (buf
+ sizeof buf
) - p
);
778 /* Called whenever it is safe to break a stabs string into multiple
779 .stabs directives. If the current string has exceeded the limit
780 set by DBX_CONTIN_LENGTH, mark the current position in the buffer
781 as a continuation point by inserting DBX_CONTIN_CHAR (doubled if
782 it is a backslash) and a null character. */
784 stabstr_continue (void)
786 if (DBX_CONTIN_LENGTH
> 0
787 && obstack_object_size (&stabstr_ob
) - stabstr_last_contin_point
790 if (DBX_CONTIN_CHAR
== '\\')
791 obstack_1grow (&stabstr_ob
, '\\');
792 obstack_1grow (&stabstr_ob
, DBX_CONTIN_CHAR
);
793 obstack_1grow (&stabstr_ob
, '\0');
794 stabstr_last_contin_point
= obstack_object_size (&stabstr_ob
);
797 #define CONTIN stabstr_continue ()
799 /* Macro subroutine of dbxout_finish_complex_stabs, which emits
800 all of the arguments to the .stabs directive after the string.
801 Overridden by xcoffout.h. CODE is the stabs code for this symbol;
802 LINE is the source line to write into the desc field (in extended
803 mode); SYM is the symbol itself.
805 ADDR, LABEL, and NUMBER are three different ways to represent the
806 stabs value field. At most one of these should be nonzero.
808 ADDR is used most of the time; it represents the value as an
809 RTL address constant.
811 LABEL is used (currently) only for N_CATCH stabs; it represents
812 the value as a string suitable for assemble_name.
814 NUMBER is used when the value is an offset from an implicit base
815 pointer (e.g. for a stack variable), or an index (e.g. for a
816 register variable). It represents the value as a decimal integer. */
818 #ifndef DBX_FINISH_STABS
819 #define DBX_FINISH_STABS(SYM, CODE, LINE, ADDR, LABEL, NUMBER) \
821 int line_ = use_gnu_debug_info_extensions ? LINE : 0; \
824 fputs (",0,", asm_out_file); \
825 dbxout_int (line_); \
826 putc (',', asm_out_file); \
828 output_addr_const (asm_out_file, ADDR); \
830 assemble_name (asm_out_file, LABEL); \
832 dbxout_int (NUMBER); \
833 putc ('\n', asm_out_file); \
837 /* Finish the emission of a complex .stabs directive. When DBX_CONTIN_LENGTH
838 is zero, this has only to emit the close quote and the remainder of
839 the arguments. When it is nonzero, the string has been marshalled in
840 stabstr_ob, and this routine is responsible for breaking it up into
841 DBX_CONTIN_LENGTH-sized chunks.
843 SYM is the DECL of the symbol under consideration; it is used only
844 for its DECL_SOURCE_LINE. The other arguments are all passed directly
845 to DBX_FINISH_STABS; see above for details. */
848 dbxout_finish_complex_stabs (tree sym
, STAB_CODE_TYPE code
,
849 rtx addr
, const char *label
, int number
)
851 int line ATTRIBUTE_UNUSED
;
855 line
= sym
? DECL_SOURCE_LINE (sym
) : 0;
856 if (DBX_CONTIN_LENGTH
> 0)
861 /* Nul-terminate the growing string, then get its size and
863 obstack_1grow (&stabstr_ob
, '\0');
865 len
= obstack_object_size (&stabstr_ob
);
866 chunk
= str
= obstack_finish (&stabstr_ob
);
868 /* Within the buffer are a sequence of NUL-separated strings,
869 each of which is to be written out as a separate stab
873 chunklen
= strlen (chunk
);
874 fwrite (chunk
, 1, chunklen
, asm_out_file
);
875 fputs ("\",", asm_out_file
);
877 /* Must add an extra byte to account for the NUL separator. */
878 chunk
+= chunklen
+ 1;
881 /* Only put a line number on the last stab in the sequence. */
882 DBX_FINISH_STABS (sym
, code
, len
== 0 ? line
: 0,
883 addr
, label
, number
);
887 fputs (ASM_STABS_OP
, asm_out_file
);
888 putc ('"', asm_out_file
);
890 stabstr_last_contin_point
= 0;
894 /* No continuations - we can put the whole string out at once.
895 It is faster to augment the string with the close quote and
896 comma than to do a two-character fputs. */
897 obstack_grow (&stabstr_ob
, "\",", 2);
898 len
= obstack_object_size (&stabstr_ob
);
899 str
= obstack_finish (&stabstr_ob
);
901 fwrite (str
, 1, len
, asm_out_file
);
902 DBX_FINISH_STABS (sym
, code
, line
, addr
, label
, number
);
904 obstack_free (&stabstr_ob
, str
);
907 #if defined (DBX_DEBUGGING_INFO)
910 dbxout_function_end (tree decl
)
912 char lscope_label_name
[100];
914 /* The Lscope label must be emitted even if we aren't doing anything
915 else; dbxout_block needs it. */
916 function_section (current_function_decl
);
918 /* Convert Lscope into the appropriate format for local labels in case
919 the system doesn't insert underscores in front of user generated
921 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name
, "Lscope", scope_labelno
);
922 targetm
.asm_out
.internal_label (asm_out_file
, "Lscope", scope_labelno
);
925 /* The N_FUN tag at the end of the function is a GNU extension,
926 which may be undesirable, and is unnecessary if we do not have
928 if (!use_gnu_debug_info_extensions
929 || NO_DBX_FUNCTION_END
930 || !targetm
.have_named_sections
931 || DECL_IGNORED_P (decl
))
934 /* By convention, GCC will mark the end of a function with an N_FUN
935 symbol and an empty string. */
936 #ifdef DBX_OUTPUT_NFUN
937 DBX_OUTPUT_NFUN (asm_out_file
, lscope_label_name
, current_function_decl
);
939 if (flag_reorder_blocks_and_partition
)
941 dbxout_begin_empty_stabs (N_FUN
);
942 dbxout_stab_value_label_diff (hot_section_end_label
, hot_section_label
);
943 dbxout_begin_empty_stabs (N_FUN
);
944 dbxout_stab_value_label_diff (cold_section_end_label
,
945 unlikely_section_label
);
949 dbxout_begin_empty_stabs (N_FUN
);
950 dbxout_stab_value_label_diff (lscope_label_name
,
951 XSTR (XEXP (DECL_RTL (current_function_decl
),
957 if (!NO_DBX_BNSYM_ENSYM
&& !flag_debug_only_used_symbols
)
958 dbxout_stabd (N_ENSYM
, 0);
960 #endif /* DBX_DEBUGGING_INFO */
962 /* Get lang description for N_SO stab. */
963 static unsigned int ATTRIBUTE_UNUSED
964 get_lang_number (void)
966 const char *language_string
= lang_hooks
.name
;
968 if (strcmp (language_string
, "GNU C") == 0)
970 else if (strcmp (language_string
, "GNU C++") == 0)
972 else if (strcmp (language_string
, "GNU F77") == 0)
974 else if (strcmp (language_string
, "GNU F95") == 0)
975 return N_SO_FORTRAN90
; /* CHECKME */
976 else if (strcmp (language_string
, "GNU Pascal") == 0)
978 else if (strcmp (language_string
, "GNU Objective-C") == 0)
985 /* At the beginning of compilation, start writing the symbol table.
986 Initialize `typevec' and output the standard data types of C. */
989 dbxout_init (const char *input_file_name
)
991 char ltext_label_name
[100];
992 bool used_ltext_label_name
= false;
993 tree syms
= lang_hooks
.decls
.getdecls ();
996 typevec
= ggc_calloc (typevec_len
, sizeof typevec
[0]);
998 /* stabstr_ob contains one string, which will be just fine with
1000 obstack_specify_allocation (&stabstr_ob
, 0, 1, xmalloc
, free
);
1002 /* Convert Ltext into the appropriate format for local labels in case
1003 the system doesn't insert underscores in front of user generated
1005 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
1007 /* Put the current working directory in an N_SO symbol. */
1008 if (use_gnu_debug_info_extensions
&& !NO_DBX_MAIN_SOURCE_DIRECTORY
)
1010 static const char *cwd
;
1014 cwd
= get_src_pwd ();
1017 else if (!IS_DIR_SEPARATOR (cwd
[strlen (cwd
) - 1]))
1018 cwd
= concat (cwd
, "/", NULL
);
1020 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
1021 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asm_out_file
, cwd
);
1022 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
1023 dbxout_begin_simple_stabs_desc (cwd
, N_SO
, get_lang_number ());
1024 dbxout_stab_value_label (ltext_label_name
);
1025 used_ltext_label_name
= true;
1026 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
1029 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
1030 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asm_out_file
, input_file_name
);
1032 dbxout_begin_simple_stabs_desc (input_file_name
, N_SO
, get_lang_number ());
1033 dbxout_stab_value_label (ltext_label_name
);
1034 used_ltext_label_name
= true;
1037 if (used_ltext_label_name
)
1040 targetm
.asm_out
.internal_label (asm_out_file
, "Ltext", 0);
1043 /* Emit an N_OPT stab to indicate that this file was compiled by GCC.
1044 The string used is historical. */
1045 #ifndef NO_DBX_GCC_MARKER
1046 dbxout_begin_simple_stabs ("gcc2_compiled.", N_OPT
);
1047 dbxout_stab_value_zero ();
1050 base_input_file
= lastfile
= input_file_name
;
1052 next_type_number
= 1;
1054 #ifdef DBX_USE_BINCL
1055 current_file
= xmalloc (sizeof *current_file
);
1056 current_file
->next
= NULL
;
1057 current_file
->file_number
= 0;
1058 current_file
->next_type_number
= 1;
1059 next_file_number
= 1;
1060 current_file
->prev
= NULL
;
1061 current_file
->bincl_status
= BINCL_NOT_REQUIRED
;
1062 current_file
->pending_bincl_name
= NULL
;
1065 /* Get all permanent types that have typedef names, and output them
1066 all, except for those already output. Some language front ends
1067 put these declarations in the top-level scope; some do not;
1068 the latter are responsible for calling debug_hooks->type_decl from
1069 their record_builtin_type function. */
1070 dbxout_typedefs (syms
);
1072 if (preinit_symbols
)
1075 for (t
= nreverse (preinit_symbols
); t
; t
= TREE_CHAIN (t
))
1076 dbxout_symbol (TREE_VALUE (t
), 0);
1077 preinit_symbols
= 0;
1081 /* Output any typedef names for types described by TYPE_DECLs in SYMS. */
1084 dbxout_typedefs (tree syms
)
1086 for (; syms
!= NULL_TREE
; syms
= TREE_CHAIN (syms
))
1088 if (TREE_CODE (syms
) == TYPE_DECL
)
1090 tree type
= TREE_TYPE (syms
);
1091 if (TYPE_NAME (type
)
1092 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1093 && COMPLETE_OR_VOID_TYPE_P (type
)
1094 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
1095 dbxout_symbol (TYPE_NAME (type
), 0);
1100 #ifdef DBX_USE_BINCL
1101 /* Emit BINCL stab using given name. */
1103 emit_bincl_stab (const char *name
)
1105 dbxout_begin_simple_stabs (name
, N_BINCL
);
1106 dbxout_stab_value_zero ();
1109 /* If there are pending bincls then it is time to emit all of them. */
1112 emit_pending_bincls_if_required (void)
1115 emit_pending_bincls ();
1118 /* Emit all pending bincls. */
1121 emit_pending_bincls (void)
1123 struct dbx_file
*f
= current_file
;
1125 /* Find first pending bincl. */
1126 while (f
->bincl_status
== BINCL_PENDING
)
1129 /* Now emit all bincls. */
1134 if (f
->bincl_status
== BINCL_PENDING
)
1136 emit_bincl_stab (f
->pending_bincl_name
);
1138 /* Update file number and status. */
1139 f
->file_number
= next_file_number
++;
1140 f
->bincl_status
= BINCL_PROCESSED
;
1142 if (f
== current_file
)
1147 /* All pending bincls have been emitted. */
1154 emit_pending_bincls_if_required (void) {}
1157 /* Change to reading from a new source file. Generate a N_BINCL stab. */
1160 dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED
,
1161 const char *filename ATTRIBUTE_UNUSED
)
1163 #ifdef DBX_USE_BINCL
1164 struct dbx_file
*n
= xmalloc (sizeof *n
);
1166 n
->next
= current_file
;
1167 n
->next_type_number
= 1;
1168 /* Do not assign file number now.
1169 Delay it until we actually emit BINCL. */
1172 current_file
->prev
= n
;
1173 n
->bincl_status
= BINCL_PENDING
;
1174 n
->pending_bincl_name
= filename
;
1180 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
1183 dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED
)
1185 #ifdef DBX_USE_BINCL
1186 /* Emit EINCL stab only if BINCL is not pending. */
1187 if (current_file
->bincl_status
== BINCL_PROCESSED
)
1189 dbxout_begin_stabn (N_EINCL
);
1190 dbxout_stab_value_zero ();
1192 current_file
->bincl_status
= BINCL_NOT_REQUIRED
;
1193 current_file
= current_file
->next
;
1197 /* Handle a few odd cases that occur when trying to make PCH files work. */
1200 dbxout_handle_pch (unsigned at_end
)
1204 /* When using the PCH, this file will be included, so we need to output
1206 dbxout_start_source_file (0, lastfile
);
1208 /* The base file when using the PCH won't be the same as
1209 the base file when it's being generated. */
1214 /* ... and an EINCL. */
1215 dbxout_end_source_file (0);
1217 /* Deal with cases where 'lastfile' was never actually changed. */
1218 lastfile_is_base
= lastfile
== NULL
;
1222 #if defined (DBX_DEBUGGING_INFO)
1223 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
1226 dbxout_source_file (const char *filename
)
1228 if (lastfile
== 0 && lastfile_is_base
)
1230 lastfile
= base_input_file
;
1231 lastfile_is_base
= 0;
1234 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
1236 /* Don't change section amid function. */
1237 if (current_function_decl
== NULL_TREE
)
1240 dbxout_begin_simple_stabs (filename
, N_SOL
);
1241 dbxout_stab_value_internal_label ("Ltext", &source_label_number
);
1242 lastfile
= filename
;
1246 /* Output N_BNSYM and line number symbol entry. */
1249 dbxout_begin_prologue (unsigned int lineno
, const char *filename
)
1251 if (use_gnu_debug_info_extensions
1252 && !NO_DBX_FUNCTION_END
1253 && !NO_DBX_BNSYM_ENSYM
1254 && !flag_debug_only_used_symbols
)
1255 dbxout_stabd (N_BNSYM
, 0);
1257 dbxout_source_line (lineno
, filename
);
1260 /* Output a line number symbol entry for source file FILENAME and line
1264 dbxout_source_line (unsigned int lineno
, const char *filename
)
1266 dbxout_source_file (filename
);
1268 #ifdef DBX_OUTPUT_SOURCE_LINE
1269 DBX_OUTPUT_SOURCE_LINE (asm_out_file
, lineno
, dbxout_source_line_counter
);
1271 if (DBX_LINES_FUNCTION_RELATIVE
)
1273 rtx begin_label
= XEXP (DECL_RTL (current_function_decl
), 0);
1274 dbxout_begin_stabn_sline (lineno
);
1275 dbxout_stab_value_internal_label_diff ("LM", &dbxout_source_line_counter
,
1276 XSTR (begin_label
, 0));
1280 dbxout_stabd (N_SLINE
, lineno
);
1284 /* Describe the beginning of an internal block within a function. */
1287 dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED
, unsigned int n
)
1289 emit_pending_bincls_if_required ();
1290 targetm
.asm_out
.internal_label (asm_out_file
, "LBB", n
);
1293 /* Describe the end line-number of an internal block within a function. */
1296 dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED
, unsigned int n
)
1298 emit_pending_bincls_if_required ();
1299 targetm
.asm_out
.internal_label (asm_out_file
, "LBE", n
);
1302 /* Output dbx data for a function definition.
1303 This includes a definition of the function name itself (a symbol),
1304 definitions of the parameters (locating them in the parameter list)
1305 and then output the block that makes up the function's body
1306 (including all the auto variables of the function). */
1309 dbxout_function_decl (tree decl
)
1311 emit_pending_bincls_if_required ();
1312 #ifndef DBX_FUNCTION_FIRST
1313 dbxout_begin_function (decl
);
1315 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
1316 dbxout_function_end (decl
);
1319 #endif /* DBX_DEBUGGING_INFO */
1321 /* Debug information for a global DECL. Called from toplev.c after
1322 compilation proper has finished. */
1324 dbxout_global_decl (tree decl
)
1326 if (TREE_CODE (decl
) == VAR_DECL
1327 && ! DECL_EXTERNAL (decl
)
1328 && DECL_RTL_SET_P (decl
)) /* Not necessary? */
1330 int saved_tree_used
= TREE_USED (decl
);
1331 TREE_USED (decl
) = 1;
1332 dbxout_symbol (decl
, 0);
1333 TREE_USED (decl
) = saved_tree_used
;
1337 /* This is just a function-type adapter; dbxout_symbol does exactly
1338 what we want but returns an int. */
1340 dbxout_type_decl (tree decl
, int local
)
1342 dbxout_symbol (decl
, local
);
1345 /* At the end of compilation, finish writing the symbol table.
1346 The default is to call debug_free_queue but do nothing else. */
1349 dbxout_finish (const char *filename ATTRIBUTE_UNUSED
)
1351 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
1352 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asm_out_file
, filename
);
1353 #elif defined DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
1356 dbxout_begin_empty_stabs (N_SO
);
1357 dbxout_stab_value_internal_label ("Letext", 0);
1360 debug_free_queue ();
1363 /* Output the index of a type. */
1366 dbxout_type_index (tree type
)
1368 #ifndef DBX_USE_BINCL
1369 stabstr_D (TYPE_SYMTAB_ADDRESS (type
));
1371 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
1373 stabstr_D (t
->file_number
);
1375 stabstr_D (t
->type_number
);
1382 /* Used in several places: evaluates to '0' for a private decl,
1383 '1' for a protected decl, '2' for a public decl. */
1384 #define DECL_ACCESSIBILITY_CHAR(DECL) \
1385 (TREE_PRIVATE (DECL) ? '0' : TREE_PROTECTED (DECL) ? '1' : '2')
1387 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
1388 This must be a separate function because anonymous unions require
1392 dbxout_type_fields (tree type
)
1396 /* Output the name, type, position (in bits), size (in bits) of each
1397 field that we can support. */
1398 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1400 /* If one of the nodes is an error_mark or its type is then
1402 if (tem
== error_mark_node
|| TREE_TYPE (tem
) == error_mark_node
)
1405 /* Omit here local type decls until we know how to support them. */
1406 if (TREE_CODE (tem
) == TYPE_DECL
1407 /* Omit here the nameless fields that are used to skip bits. */
1408 || DECL_IGNORED_P (tem
)
1409 /* Omit fields whose position or size are variable or too large to
1411 || (TREE_CODE (tem
) == FIELD_DECL
1412 && (! host_integerp (bit_position (tem
), 0)
1413 || ! DECL_SIZE (tem
)
1414 || ! host_integerp (DECL_SIZE (tem
), 1))))
1417 else if (TREE_CODE (tem
) != CONST_DECL
)
1419 /* Continue the line if necessary,
1420 but not before the first field. */
1421 if (tem
!= TYPE_FIELDS (type
))
1424 if (DECL_NAME (tem
))
1425 stabstr_I (DECL_NAME (tem
));
1428 if (use_gnu_debug_info_extensions
1429 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
1430 || TREE_CODE (tem
) != FIELD_DECL
))
1432 have_used_extensions
= 1;
1434 stabstr_C (DECL_ACCESSIBILITY_CHAR (tem
));
1437 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
1438 && DECL_BIT_FIELD_TYPE (tem
))
1439 ? DECL_BIT_FIELD_TYPE (tem
) : TREE_TYPE (tem
), 0);
1441 if (TREE_CODE (tem
) == VAR_DECL
)
1443 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
1445 tree name
= DECL_ASSEMBLER_NAME (tem
);
1447 have_used_extensions
= 1;
1453 /* If TEM is non-static, GDB won't understand it. */
1454 stabstr_S (",0,0;");
1459 stabstr_D (int_bit_position (tem
));
1461 stabstr_D (tree_low_cst (DECL_SIZE (tem
), 1));
1468 /* Subroutine of `dbxout_type_methods'. Output debug info about the
1469 method described DECL. */
1472 dbxout_type_method_1 (tree decl
)
1476 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
1478 else /* it's a METHOD_TYPE. */
1480 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
1481 /* A for normal functions.
1482 B for `const' member functions.
1483 C for `volatile' member functions.
1484 D for `const volatile' member functions. */
1485 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
1487 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
1490 if (DECL_VINDEX (decl
))
1496 /* ??? Output the mangled name, which contains an encoding of the
1497 method's type signature. May not be necessary anymore. */
1499 stabstr_I (DECL_ASSEMBLER_NAME (decl
));
1501 stabstr_C (DECL_ACCESSIBILITY_CHAR (decl
));
1505 if (DECL_VINDEX (decl
) && host_integerp (DECL_VINDEX (decl
), 0))
1507 stabstr_D (tree_low_cst (DECL_VINDEX (decl
), 0));
1509 dbxout_type (DECL_CONTEXT (decl
), 0);
1514 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
1518 dbxout_type_methods (tree type
)
1520 /* C++: put out the method names and their parameter lists */
1521 tree methods
= TYPE_METHODS (type
);
1525 if (methods
== NULL_TREE
)
1528 if (TREE_CODE (methods
) != TREE_VEC
)
1530 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
1531 fndecl
= TREE_VEC_ELT (methods
, 0);
1533 fndecl
= TREE_VEC_ELT (methods
, 1);
1537 int need_prefix
= 1;
1539 /* Group together all the methods for the same operation.
1540 These differ in the types of the arguments. */
1541 for (last
= NULL_TREE
;
1542 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
1543 fndecl
= TREE_CHAIN (fndecl
))
1544 /* Output the name of the field (after overloading), as
1545 well as the name of the field before overloading, along
1546 with its parameter list */
1548 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1549 include TEMPLATE_DECLs.) The debugger doesn't know what
1550 to do with such entities anyhow. */
1551 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
1558 /* Also ignore abstract methods; those are only interesting to
1559 the DWARF backends. */
1560 if (DECL_IGNORED_P (fndecl
) || DECL_ABSTRACT (fndecl
))
1563 /* Redundantly output the plain name, since that's what gdb
1567 stabstr_I (DECL_NAME (fndecl
));
1572 dbxout_type (TREE_TYPE (fndecl
), 0);
1573 dbxout_type_method_1 (fndecl
);
1580 /* Emit a "range" type specification, which has the form:
1581 "r<index type>;<lower bound>;<upper bound>;".
1582 TYPE is an INTEGER_TYPE. */
1585 dbxout_range_type (tree type
)
1588 if (TREE_TYPE (type
))
1589 dbxout_type (TREE_TYPE (type
), 0);
1590 else if (TREE_CODE (type
) != INTEGER_TYPE
)
1591 dbxout_type (type
, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1594 /* Traditionally, we made sure 'int' was type 1, and builtin types
1595 were defined to be sub-ranges of int. Unfortunately, this
1596 does not allow us to distinguish true sub-ranges from integer
1597 types. So, instead we define integer (non-sub-range) types as
1598 sub-ranges of themselves. This matters for Chill. If this isn't
1599 a subrange type, then we want to define it in terms of itself.
1600 However, in C, this may be an anonymous integer type, and we don't
1601 want to emit debug info referring to it. Just calling
1602 dbxout_type_index won't work anyways, because the type hasn't been
1603 defined yet. We make this work for both cases by checked to see
1604 whether this is a defined type, referring to it if it is, and using
1606 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
1607 dbxout_type_index (type
);
1609 dbxout_type_index (integer_type_node
);
1613 if (TYPE_MIN_VALUE (type
) != 0
1614 && host_integerp (TYPE_MIN_VALUE (type
), 0))
1616 if (print_int_cst_bounds_in_octal_p (type
))
1617 stabstr_O (TYPE_MIN_VALUE (type
));
1619 stabstr_D (tree_low_cst (TYPE_MIN_VALUE (type
), 0));
1625 if (TYPE_MAX_VALUE (type
) != 0
1626 && host_integerp (TYPE_MAX_VALUE (type
), 0))
1628 if (print_int_cst_bounds_in_octal_p (type
))
1629 stabstr_O (TYPE_MAX_VALUE (type
));
1631 stabstr_D (tree_low_cst (TYPE_MAX_VALUE (type
), 0));
1639 /* Output a reference to a type. If the type has not yet been
1640 described in the dbx output, output its definition now.
1641 For a type already defined, just refer to its definition
1642 using the type number.
1644 If FULL is nonzero, and the type has been described only with
1645 a forward-reference, output the definition now.
1646 If FULL is zero in this case, just refer to the forward-reference
1647 using the number previously allocated. */
1650 dbxout_type (tree type
, int full
)
1654 static int anonymous_type_number
= 0;
1656 if (TREE_CODE (type
) == VECTOR_TYPE
)
1657 /* The frontend feeds us a representation for the vector as a struct
1658 containing an array. Pull out the array type. */
1659 type
= TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type
)));
1661 /* If there was an input error and we don't really have a type,
1662 avoid crashing and write something that is at least valid
1663 by assuming `int'. */
1664 if (type
== error_mark_node
)
1665 type
= integer_type_node
;
1668 if (TYPE_NAME (type
)
1669 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1670 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
1674 /* Try to find the "main variant" with the same name. */
1675 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1676 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1677 main_variant
= TREE_TYPE (TYPE_NAME (type
));
1679 main_variant
= TYPE_MAIN_VARIANT (type
);
1681 /* If we are not using extensions, stabs does not distinguish const and
1682 volatile, so there is no need to make them separate types. */
1683 if (!use_gnu_debug_info_extensions
)
1684 type
= main_variant
;
1686 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
1688 /* Type has no dbx number assigned. Assign next available number. */
1689 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
1691 /* Make sure type vector is long enough to record about this type. */
1693 if (next_type_number
== typevec_len
)
1696 = ggc_realloc (typevec
, (typevec_len
* 2 * sizeof typevec
[0]));
1697 memset (typevec
+ typevec_len
, 0, typevec_len
* sizeof typevec
[0]);
1701 #ifdef DBX_USE_BINCL
1702 emit_pending_bincls_if_required ();
1703 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
1704 = current_file
->file_number
;
1705 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
1706 = current_file
->next_type_number
++;
1710 if (flag_debug_only_used_symbols
)
1712 if ((TREE_CODE (type
) == RECORD_TYPE
1713 || TREE_CODE (type
) == UNION_TYPE
1714 || TREE_CODE (type
) == QUAL_UNION_TYPE
1715 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1716 && TYPE_STUB_DECL (type
)
1717 && DECL_P (TYPE_STUB_DECL (type
))
1718 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type
)))
1719 debug_queue_symbol (TYPE_STUB_DECL (type
));
1720 else if (TYPE_NAME (type
)
1721 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1722 debug_queue_symbol (TYPE_NAME (type
));
1725 /* Output the number of this type, to refer to it. */
1726 dbxout_type_index (type
);
1728 #ifdef DBX_TYPE_DEFINED
1729 if (DBX_TYPE_DEFINED (type
))
1733 /* If this type's definition has been output or is now being output,
1736 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
1741 /* If we have already had a cross reference,
1742 and either that's all we want or that's the best we could do,
1743 don't repeat the cross reference.
1744 Sun dbx crashes if we do. */
1745 if (! full
|| !COMPLETE_TYPE_P (type
)
1746 /* No way in DBX fmt to describe a variable size. */
1747 || ! host_integerp (TYPE_SIZE (type
), 1))
1755 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1756 leave the type-number completely undefined rather than output
1757 a cross-reference. If we have already used GNU debug info extensions,
1758 then it is OK to output a cross reference. This is necessary to get
1759 proper C++ debug output. */
1760 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1761 || TREE_CODE (type
) == QUAL_UNION_TYPE
1762 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1763 && ! use_gnu_debug_info_extensions
)
1764 /* We must use the same test here as we use twice below when deciding
1765 whether to emit a cross-reference. */
1766 if ((TYPE_NAME (type
) != 0
1767 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1768 && DECL_IGNORED_P (TYPE_NAME (type
)))
1770 || !COMPLETE_TYPE_P (type
)
1771 /* No way in DBX fmt to describe a variable size. */
1772 || ! host_integerp (TYPE_SIZE (type
), 1))
1774 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1779 /* Output a definition now. */
1782 /* Mark it as defined, so that if it is self-referent
1783 we will not get into an infinite recursion of definitions. */
1785 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1787 /* If this type is a variant of some other, hand off. Types with
1788 different names are usefully distinguished. We only distinguish
1789 cv-qualified types if we're using extensions. */
1790 if (TYPE_READONLY (type
) > TYPE_READONLY (main_variant
))
1793 dbxout_type (build_type_variant (type
, 0, TYPE_VOLATILE (type
)), 0);
1796 else if (TYPE_VOLATILE (type
) > TYPE_VOLATILE (main_variant
))
1799 dbxout_type (build_type_variant (type
, TYPE_READONLY (type
), 0), 0);
1802 else if (main_variant
!= TYPE_MAIN_VARIANT (type
))
1804 if (flag_debug_only_used_symbols
)
1806 tree orig_type
= DECL_ORIGINAL_TYPE (TYPE_NAME (type
));
1808 if ((TREE_CODE (orig_type
) == RECORD_TYPE
1809 || TREE_CODE (orig_type
) == UNION_TYPE
1810 || TREE_CODE (orig_type
) == QUAL_UNION_TYPE
1811 || TREE_CODE (orig_type
) == ENUMERAL_TYPE
)
1812 && TYPE_STUB_DECL (orig_type
)
1813 && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type
)))
1814 debug_queue_symbol (TYPE_STUB_DECL (orig_type
));
1816 /* 'type' is a typedef; output the type it refers to. */
1817 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0);
1820 /* else continue. */
1822 switch (TREE_CODE (type
))
1826 /* For a void type, just define it as itself; i.e., "5=5".
1827 This makes us consider it defined
1828 without saying what it is. The debugger will make it
1829 a void type when the reference is seen, and nothing will
1830 ever override that default. */
1831 dbxout_type_index (type
);
1835 if (type
== char_type_node
&& ! TYPE_UNSIGNED (type
))
1837 /* Output the type `char' as a subrange of itself!
1838 I don't understand this definition, just copied it
1839 from the output of pcc.
1840 This used to use `r2' explicitly and we used to
1841 take care to make sure that `char' was type number 2. */
1843 dbxout_type_index (type
);
1844 stabstr_S (";0;127;");
1847 /* If this is a subtype of another integer type, always prefer to
1848 write it as a subtype. */
1849 else if (TREE_TYPE (type
) != 0
1850 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_TYPE
)
1852 /* If the size is non-standard, say what it is if we can use
1855 if (use_gnu_debug_info_extensions
1856 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1858 have_used_extensions
= 1;
1860 stabstr_D (TYPE_PRECISION (type
));
1864 dbxout_range_type (type
);
1869 /* If the size is non-standard, say what it is if we can use
1872 if (use_gnu_debug_info_extensions
1873 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1875 have_used_extensions
= 1;
1877 stabstr_D (TYPE_PRECISION (type
));
1881 if (print_int_cst_bounds_in_octal_p (type
))
1885 /* If this type derives from another type, output type index of
1886 parent type. This is particularly important when parent type
1887 is an enumerated type, because not generating the parent type
1888 index would transform the definition of this enumerated type
1889 into a plain unsigned type. */
1890 if (TREE_TYPE (type
) != 0)
1891 dbxout_type_index (TREE_TYPE (type
));
1893 dbxout_type_index (type
);
1896 stabstr_O (TYPE_MIN_VALUE (type
));
1898 stabstr_O (TYPE_MAX_VALUE (type
));
1903 /* Output other integer types as subranges of `int'. */
1904 dbxout_range_type (type
);
1910 /* This used to say `r1' and we used to take care
1911 to make sure that `int' was type number 1. */
1913 dbxout_type_index (integer_type_node
);
1915 stabstr_D (int_size_in_bytes (type
));
1920 if (use_gnu_debug_info_extensions
)
1922 have_used_extensions
= 1;
1924 stabstr_D (BITS_PER_UNIT
* int_size_in_bytes (type
));
1925 stabstr_S (";-20;");
1929 /* Output the type `char' as a subrange of itself.
1930 That is what pcc seems to do. */
1932 dbxout_type_index (char_type_node
);
1933 stabstr_S (TYPE_UNSIGNED (type
) ? ";0;255;" : ";0;127;");
1938 if (use_gnu_debug_info_extensions
)
1940 have_used_extensions
= 1;
1942 stabstr_D (BITS_PER_UNIT
* int_size_in_bytes (type
));
1943 stabstr_S (";-16;");
1945 else /* Define as enumeral type (False, True) */
1946 stabstr_S ("eFalse:0,True:1,;");
1950 /* Differs from the REAL_TYPE by its new data type number.
1951 R3 is NF_COMPLEX. We don't try to use any of the other NF_*
1952 codes since gdb doesn't care anyway. */
1954 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1957 stabstr_D (2 * int_size_in_bytes (TREE_TYPE (type
)));
1962 /* Output a complex integer type as a structure,
1963 pending some other way to do it. */
1965 stabstr_D (int_size_in_bytes (type
));
1967 stabstr_S ("real:");
1968 dbxout_type (TREE_TYPE (type
), 0);
1970 stabstr_D (TYPE_PRECISION (TREE_TYPE (type
)));
1972 stabstr_S (";imag:");
1973 dbxout_type (TREE_TYPE (type
), 0);
1975 stabstr_D (TYPE_PRECISION (TREE_TYPE (type
)));
1977 stabstr_D (TYPE_PRECISION (TREE_TYPE (type
)));
1983 /* Make arrays of packed bits look like bitstrings for chill. */
1984 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1986 have_used_extensions
= 1;
1988 stabstr_D (BITS_PER_UNIT
* int_size_in_bytes (type
));
1989 stabstr_S (";@S;S");
1990 dbxout_type (TYPE_DOMAIN (type
), 0);
1994 /* Output "a" followed by a range type definition
1995 for the index type of the array
1996 followed by a reference to the target-type.
1997 ar1;0;N;M for a C array of type M and size N+1. */
1998 /* Check if a character string type, which in Chill is
1999 different from an array of characters. */
2000 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
2002 have_used_extensions
= 1;
2005 tem
= TYPE_DOMAIN (type
);
2009 dbxout_type_index (integer_type_node
);
2010 stabstr_S (";0;-1;");
2015 dbxout_range_type (tem
);
2018 dbxout_type (TREE_TYPE (type
), 0);
2023 case QUAL_UNION_TYPE
:
2025 tree binfo
= TYPE_BINFO (type
);
2027 /* Output a structure type. We must use the same test here as we
2028 use in the DBX_NO_XREFS case above. */
2029 if ((TYPE_NAME (type
) != 0
2030 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
2031 && DECL_IGNORED_P (TYPE_NAME (type
)))
2033 || !COMPLETE_TYPE_P (type
)
2034 /* No way in DBX fmt to describe a variable size. */
2035 || ! host_integerp (TYPE_SIZE (type
), 1))
2037 /* If the type is just a cross reference, output one
2038 and mark the type as partially described.
2039 If it later becomes defined, we will output
2040 its real definition.
2041 If the type has a name, don't nest its definition within
2042 another type's definition; instead, output an xref
2043 and let the definition come when the name is defined. */
2044 stabstr_S ((TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu");
2045 if (TYPE_NAME (type
) != 0)
2046 dbxout_type_name (type
);
2050 stabstr_D (anonymous_type_number
++);
2054 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
2058 /* Identify record or union, and print its size. */
2059 stabstr_C ((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u');
2060 stabstr_D (int_size_in_bytes (type
));
2066 VEC (tree
) *accesses
= BINFO_BASE_ACCESSES (binfo
);
2068 if (use_gnu_debug_info_extensions
)
2070 if (BINFO_N_BASE_BINFOS (binfo
))
2072 have_used_extensions
= 1;
2074 stabstr_U (BINFO_N_BASE_BINFOS (binfo
));
2078 for (i
= 0; BINFO_BASE_ITERATE (binfo
, i
, child
); i
++)
2080 tree access
= (accesses
? VEC_index (tree
, accesses
, i
)
2081 : access_public_node
);
2083 if (use_gnu_debug_info_extensions
)
2085 have_used_extensions
= 1;
2086 stabstr_C (BINFO_VIRTUAL_P (child
) ? '1' : '0');
2087 stabstr_C (access
== access_public_node
? '2' :
2088 access
== access_protected_node
2090 if (BINFO_VIRTUAL_P (child
)
2091 && strcmp (lang_hooks
.name
, "GNU C++") == 0)
2092 /* For a virtual base, print the (negative)
2093 offset within the vtable where we must look
2094 to find the necessary adjustment. */
2096 (tree_low_cst (BINFO_VPTR_FIELD (child
), 0)
2099 stabstr_D (tree_low_cst (BINFO_OFFSET (child
), 0)
2102 dbxout_type (BINFO_TYPE (child
), 0);
2107 /* Print out the base class information with
2108 fields which have the same names at the types
2110 dbxout_type_name (BINFO_TYPE (child
));
2112 dbxout_type (BINFO_TYPE (child
), full
);
2114 stabstr_D (tree_low_cst (BINFO_OFFSET (child
), 0)
2118 (tree_low_cst (TYPE_SIZE (BINFO_TYPE (child
)), 0)
2126 /* Write out the field declarations. */
2127 dbxout_type_fields (type
);
2128 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
2130 have_used_extensions
= 1;
2131 dbxout_type_methods (type
);
2136 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
2137 /* Avoid the ~ if we don't really need it--it confuses dbx. */
2138 && TYPE_VFIELD (type
))
2140 have_used_extensions
= 1;
2142 /* We need to write out info about what field this class
2143 uses as its "main" vtable pointer field, because if this
2144 field is inherited from a base class, GDB cannot necessarily
2145 figure out which field it's using in time. */
2147 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0);
2153 /* We must use the same test here as we use in the DBX_NO_XREFS case
2154 above. We simplify it a bit since an enum will never have a variable
2156 if ((TYPE_NAME (type
) != 0
2157 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
2158 && DECL_IGNORED_P (TYPE_NAME (type
)))
2160 || !COMPLETE_TYPE_P (type
))
2163 dbxout_type_name (type
);
2164 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
2168 if (use_gnu_debug_info_extensions
2169 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
2171 have_used_extensions
= 1;
2173 stabstr_D (TYPE_PRECISION (type
));
2178 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
2180 stabstr_I (TREE_PURPOSE (tem
));
2183 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
2184 stabstr_D (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
2185 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
2186 && (HOST_WIDE_INT
) TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
2187 stabstr_D (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
2189 stabstr_O (TREE_VALUE (tem
));
2192 if (TREE_CHAIN (tem
) != 0)
2201 dbxout_type (TREE_TYPE (type
), 0);
2205 if (use_gnu_debug_info_extensions
)
2207 have_used_extensions
= 1;
2210 /* Write the argument types out longhand. */
2211 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0);
2213 dbxout_type (TREE_TYPE (type
), 0);
2214 dbxout_args (TYPE_ARG_TYPES (type
));
2218 /* Treat it as a function type. */
2219 dbxout_type (TREE_TYPE (type
), 0);
2223 if (use_gnu_debug_info_extensions
)
2225 have_used_extensions
= 1;
2227 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0);
2229 dbxout_type (TREE_TYPE (type
), 0);
2232 /* Should print as an int, because it is really just an offset. */
2233 dbxout_type (integer_type_node
, 0);
2236 case REFERENCE_TYPE
:
2237 if (use_gnu_debug_info_extensions
)
2239 have_used_extensions
= 1;
2244 dbxout_type (TREE_TYPE (type
), 0);
2249 dbxout_type (TREE_TYPE (type
), 0);
2257 /* Return nonzero if the given type represents an integer whose bounds
2258 should be printed in octal format. */
2261 print_int_cst_bounds_in_octal_p (tree type
)
2263 /* If we can use GDB extensions and the size is wider than a long
2264 (the size used by GDB to read them) or we may have trouble writing
2265 the bounds the usual way, write them in octal. Note the test is for
2266 the *target's* size of "long", not that of the host. The host test
2267 is just to make sure we can write it out in case the host wide int
2268 is narrower than the target "long".
2270 For unsigned types, we use octal if they are the same size or larger.
2271 This is because we print the bounds as signed decimal, and hence they
2272 can't span same size unsigned types. */
2274 if (use_gnu_debug_info_extensions
2275 && TYPE_MIN_VALUE (type
) != 0
2276 && TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
2277 && TYPE_MAX_VALUE (type
) != 0
2278 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
2279 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
2280 || ((TYPE_PRECISION (type
) == TYPE_PRECISION (integer_type_node
))
2281 && TYPE_UNSIGNED (type
))
2282 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
2283 || (TYPE_PRECISION (type
) == HOST_BITS_PER_WIDE_INT
2284 && TYPE_UNSIGNED (type
))))
2290 /* Output the name of type TYPE, with no punctuation.
2291 Such names can be set up either by typedef declarations
2292 or by struct, enum and union tags. */
2295 dbxout_type_name (tree type
)
2297 tree t
= TYPE_NAME (type
);
2300 switch (TREE_CODE (t
))
2302 case IDENTIFIER_NODE
:
2314 /* Output leading leading struct or class names needed for qualifying
2315 type whose scope is limited to a struct or class. */
2318 dbxout_class_name_qualifiers (tree decl
)
2320 tree context
= decl_type_context (decl
);
2322 if (context
!= NULL_TREE
2323 && TREE_CODE(context
) == RECORD_TYPE
2324 && TYPE_NAME (context
) != 0
2325 && (TREE_CODE (TYPE_NAME (context
)) == IDENTIFIER_NODE
2326 || (DECL_NAME (TYPE_NAME (context
)) != 0)))
2328 tree name
= TYPE_NAME (context
);
2330 if (TREE_CODE (name
) == TYPE_DECL
)
2332 dbxout_class_name_qualifiers (name
);
2333 name
= DECL_NAME (name
);
2340 /* Output a .stabs for the symbol defined by DECL,
2341 which must be a ..._DECL node in the normal namespace.
2342 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
2343 LOCAL is nonzero if the scope is less than the entire file.
2344 Return 1 if a stabs might have been emitted. */
2347 dbxout_symbol (tree decl
, int local ATTRIBUTE_UNUSED
)
2349 tree type
= TREE_TYPE (decl
);
2350 tree context
= NULL_TREE
;
2353 /* "Intercept" dbxout_symbol() calls like we do all debug_hooks. */
2356 /* Ignore nameless syms, but don't ignore type tags. */
2358 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
2359 || DECL_IGNORED_P (decl
))
2360 DBXOUT_DECR_NESTING_AND_RETURN (0);
2362 /* If we are to generate only the symbols actually used then such
2363 symbol nodes are flagged with TREE_USED. Ignore any that
2364 aren't flaged as TREE_USED. */
2366 if (flag_debug_only_used_symbols
2367 && (!TREE_USED (decl
)
2368 && (TREE_CODE (decl
) != VAR_DECL
|| !DECL_INITIAL (decl
))))
2369 DBXOUT_DECR_NESTING_AND_RETURN (0);
2371 /* If dbxout_init has not yet run, queue this symbol for later. */
2374 preinit_symbols
= tree_cons (0, decl
, preinit_symbols
);
2375 DBXOUT_DECR_NESTING_AND_RETURN (0);
2378 if (flag_debug_only_used_symbols
)
2382 /* We now have a used symbol. We need to generate the info for
2383 the symbol's type in addition to the symbol itself. These
2384 type symbols are queued to be generated after were done with
2385 the symbol itself (otherwise they would fight over the
2388 Note, because the TREE_TYPE(type) might be something like a
2389 pointer to a named type we need to look for the first name
2390 we see following the TREE_TYPE chain. */
2393 while (POINTER_TYPE_P (t
))
2396 /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE
2397 need special treatment. The TYPE_STUB_DECL field in these
2398 types generally represents the tag name type we want to
2399 output. In addition there could be a typedef type with
2400 a different name. In that case we also want to output
2403 if (TREE_CODE (t
) == RECORD_TYPE
2404 || TREE_CODE (t
) == UNION_TYPE
2405 || TREE_CODE (t
) == QUAL_UNION_TYPE
2406 || TREE_CODE (t
) == ENUMERAL_TYPE
)
2408 if (TYPE_STUB_DECL (t
)
2409 && TYPE_STUB_DECL (t
) != decl
2410 && DECL_P (TYPE_STUB_DECL (t
))
2411 && ! DECL_IGNORED_P (TYPE_STUB_DECL (t
)))
2413 debug_queue_symbol (TYPE_STUB_DECL (t
));
2415 && TYPE_NAME (t
) != TYPE_STUB_DECL (t
)
2416 && TYPE_NAME (t
) != decl
2417 && DECL_P (TYPE_NAME (t
)))
2418 debug_queue_symbol (TYPE_NAME (t
));
2421 else if (TYPE_NAME (t
)
2422 && TYPE_NAME (t
) != decl
2423 && DECL_P (TYPE_NAME (t
)))
2424 debug_queue_symbol (TYPE_NAME (t
));
2427 emit_pending_bincls_if_required ();
2429 switch (TREE_CODE (decl
))
2432 /* Enum values are defined by defining the enum type. */
2436 if (DECL_RTL (decl
) == 0)
2437 DBXOUT_DECR_NESTING_AND_RETURN (0);
2438 if (DECL_EXTERNAL (decl
))
2440 /* Don't mention a nested function under its parent. */
2441 context
= decl_function_context (decl
);
2442 if (context
== current_function_decl
)
2444 /* Don't mention an inline instance of a nested function. */
2445 if (context
&& DECL_FROM_INLINE (decl
))
2447 if (!MEM_P (DECL_RTL (decl
))
2448 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
2451 dbxout_begin_complex_stabs ();
2452 stabstr_I (DECL_ASSEMBLER_NAME (decl
));
2453 stabstr_S (TREE_PUBLIC (decl
) ? ":F" : ":f");
2456 if (TREE_TYPE (type
))
2457 dbxout_type (TREE_TYPE (type
), 0);
2459 dbxout_type (void_type_node
, 0);
2461 /* For a nested function, when that function is compiled,
2462 mention the containing function name
2463 as well as (since dbx wants it) our own assembler-name. */
2467 stabstr_I (DECL_ASSEMBLER_NAME (decl
));
2469 stabstr_I (DECL_NAME (context
));
2472 dbxout_finish_complex_stabs (decl
, N_FUN
, XEXP (DECL_RTL (decl
), 0),
2477 /* Don't output the same typedef twice.
2478 And don't output what language-specific stuff doesn't want output. */
2479 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
2480 DBXOUT_DECR_NESTING_AND_RETURN (0);
2482 /* Don't output typedefs for types with magic type numbers (XCOFF). */
2483 #ifdef DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER
2485 int fundamental_type_number
=
2486 DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER (decl
);
2488 if (fundamental_type_number
!= 0)
2490 TREE_ASM_WRITTEN (decl
) = 1;
2491 TYPE_SYMTAB_ADDRESS (TREE_TYPE (decl
)) = fundamental_type_number
;
2492 DBXOUT_DECR_NESTING_AND_RETURN (0);
2502 if (DECL_NAME (decl
))
2504 /* Nonzero means we must output a tag as well as a typedef. */
2507 /* Handle the case of a C++ structure or union
2508 where the TYPE_NAME is a TYPE_DECL
2509 which gives both a typedef name and a tag. */
2510 /* dbx requires the tag first and the typedef second. */
2511 if ((TREE_CODE (type
) == RECORD_TYPE
2512 || TREE_CODE (type
) == UNION_TYPE
2513 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2514 && TYPE_NAME (type
) == decl
2515 && !(use_gnu_debug_info_extensions
&& have_used_extensions
)
2516 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
2517 /* Distinguish the implicit typedefs of C++
2518 from explicit ones that might be found in C. */
2519 && DECL_ARTIFICIAL (decl
)
2520 /* Do not generate a tag for incomplete records. */
2521 && COMPLETE_TYPE_P (type
)
2522 /* Do not generate a tag for records of variable size,
2523 since this type can not be properly described in the
2524 DBX format, and it confuses some tools such as objdump. */
2525 && host_integerp (TYPE_SIZE (type
), 1))
2527 tree name
= TYPE_NAME (type
);
2528 if (TREE_CODE (name
) == TYPE_DECL
)
2529 name
= DECL_NAME (name
);
2531 dbxout_begin_complex_stabs ();
2534 dbxout_type (type
, 1);
2535 dbxout_finish_complex_stabs (0, DBX_TYPE_DECL_STABS_CODE
,
2539 dbxout_begin_complex_stabs ();
2541 /* Output leading class/struct qualifiers.
2542 ??? why not set have_used_extensions here ... because
2543 then the test of it below would always be true, I
2544 guess. But it's not clear to me why we shouldn't do
2545 that always in extended mode. */
2546 if (use_gnu_debug_info_extensions
)
2547 dbxout_class_name_qualifiers (decl
);
2549 /* Output typedef name. */
2550 stabstr_I (DECL_NAME (decl
));
2553 /* Short cut way to output a tag also. */
2554 if ((TREE_CODE (type
) == RECORD_TYPE
2555 || TREE_CODE (type
) == UNION_TYPE
2556 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2557 && TYPE_NAME (type
) == decl
2558 /* Distinguish the implicit typedefs of C++
2559 from explicit ones that might be found in C. */
2560 && DECL_ARTIFICIAL (decl
))
2562 if (use_gnu_debug_info_extensions
&& have_used_extensions
)
2565 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
2570 dbxout_type (type
, 1);
2571 dbxout_finish_complex_stabs (decl
, DBX_TYPE_DECL_STABS_CODE
,
2576 /* Don't output a tag if this is an incomplete type. This prevents
2577 the sun4 Sun OS 4.x dbx from crashing. */
2579 if (tag_needed
&& TYPE_NAME (type
) != 0
2580 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
2581 || (DECL_NAME (TYPE_NAME (type
)) != 0))
2582 && COMPLETE_TYPE_P (type
)
2583 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
2585 /* For a TYPE_DECL with no name, but the type has a name,
2587 This is what represents `struct foo' with no typedef. */
2588 /* In C++, the name of a type is the corresponding typedef.
2589 In C, it is an IDENTIFIER_NODE. */
2590 tree name
= TYPE_NAME (type
);
2591 if (TREE_CODE (name
) == TYPE_DECL
)
2592 name
= DECL_NAME (name
);
2594 dbxout_begin_complex_stabs ();
2597 dbxout_type (type
, 1);
2598 dbxout_finish_complex_stabs (0, DBX_TYPE_DECL_STABS_CODE
, 0, 0, 0);
2602 /* If an enum type has no name, it cannot be referred to, but
2603 we must output it anyway, to record the enumeration
2606 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
2608 dbxout_begin_complex_stabs ();
2609 /* Some debuggers fail when given NULL names, so give this a
2610 harmless name of " " (Why not "(anon)"?). */
2612 dbxout_type (type
, 1);
2613 dbxout_finish_complex_stabs (0, DBX_TYPE_DECL_STABS_CODE
, 0, 0, 0);
2616 /* Prevent duplicate output of a typedef. */
2617 TREE_ASM_WRITTEN (decl
) = 1;
2622 /* Parm decls go in their own separate chains
2623 and are output by dbxout_reg_parms and dbxout_parms. */
2627 /* Named return value, treat like a VAR_DECL. */
2629 if (! DECL_RTL_SET_P (decl
))
2630 DBXOUT_DECR_NESTING_AND_RETURN (0);
2631 /* Don't mention a variable that is external.
2632 Let the file that defines it describe it. */
2633 if (DECL_EXTERNAL (decl
))
2636 /* If the variable is really a constant
2637 and not written in memory, inform the debugger.
2639 ??? Why do we skip emitting the type and location in this case? */
2640 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
2641 && DECL_INITIAL (decl
) != 0
2642 && host_integerp (DECL_INITIAL (decl
), 0)
2643 && ! TREE_ASM_WRITTEN (decl
)
2644 && (DECL_CONTEXT (decl
) == NULL_TREE
2645 || TREE_CODE (DECL_CONTEXT (decl
)) == BLOCK
)
2646 && TREE_PUBLIC (decl
) == 0)
2648 /* The sun4 assembler does not grok this. */
2650 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
2651 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
2653 HOST_WIDE_INT ival
= TREE_INT_CST_LOW (DECL_INITIAL (decl
));
2655 dbxout_begin_complex_stabs ();
2656 stabstr_I (DECL_NAME (decl
));
2659 dbxout_finish_complex_stabs (0, N_LSYM
, 0, 0, 0);
2660 DBXOUT_DECR_NESTING
;
2666 /* else it is something we handle like a normal variable. */
2668 SET_DECL_RTL (decl
, eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
2669 #ifdef LEAF_REG_REMAP
2670 if (current_function_uses_only_leaf_regs
)
2671 leaf_renumber_regs_insn (DECL_RTL (decl
));
2674 result
= dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
2680 DBXOUT_DECR_NESTING
;
2684 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2685 Add SUFFIX to its name, if SUFFIX is not 0.
2686 Describe the variable as residing in HOME
2687 (usually HOME is DECL_RTL (DECL), but not always).
2688 Returns 1 if the stab was really emitted. */
2691 dbxout_symbol_location (tree decl
, tree type
, const char *suffix
, rtx home
)
2694 STAB_CODE_TYPE code
;
2699 /* Don't mention a variable at all
2700 if it was completely optimized into nothingness.
2702 If the decl was from an inline function, then its rtl
2703 is not identically the rtl that was used in this
2704 particular compilation. */
2705 if (GET_CODE (home
) == SUBREG
)
2709 while (GET_CODE (value
) == SUBREG
)
2710 value
= SUBREG_REG (value
);
2713 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
2716 home
= alter_subreg (&home
);
2720 regno
= REGNO (home
);
2721 if (regno
>= FIRST_PSEUDO_REGISTER
)
2725 /* The kind-of-variable letter depends on where
2726 the variable is and on the scope of its name:
2727 G and N_GSYM for static storage and global scope,
2728 S for static storage and file scope,
2729 V for static storage and local scope,
2730 for those two, use N_LCSYM if data is in bss segment,
2731 N_STSYM if in data segment, N_FUN otherwise.
2732 (We used N_FUN originally, then changed to N_STSYM
2733 to please GDB. However, it seems that confused ld.
2734 Now GDB has been fixed to like N_FUN, says Kingdon.)
2735 no letter at all, and N_LSYM, for auto variable,
2736 r and N_RSYM for register variable. */
2738 if (MEM_P (home
) && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
2740 if (TREE_PUBLIC (decl
))
2747 addr
= XEXP (home
, 0);
2749 letter
= decl_function_context (decl
) ? 'V' : 'S';
2751 /* Some ports can transform a symbol ref into a label ref,
2752 because the symbol ref is too far away and has to be
2753 dumped into a constant pool. Alternatively, the symbol
2754 in the constant pool might be referenced by a different
2756 if (GET_CODE (addr
) == SYMBOL_REF
2757 && CONSTANT_POOL_ADDRESS_P (addr
))
2760 rtx tmp
= get_pool_constant_mark (addr
, &marked
);
2762 if (GET_CODE (tmp
) == SYMBOL_REF
)
2765 if (CONSTANT_POOL_ADDRESS_P (addr
))
2766 get_pool_constant_mark (addr
, &marked
);
2770 else if (GET_CODE (tmp
) == LABEL_REF
)
2776 /* If all references to the constant pool were optimized
2777 out, we just ignore the symbol. */
2782 /* This should be the same condition as in assemble_variable, but
2783 we don't have access to dont_output_data here. So, instead,
2784 we rely on the fact that error_mark_node initializers always
2785 end up in bss for C++ and never end up in bss for C. */
2786 if (DECL_INITIAL (decl
) == 0
2787 || (!strcmp (lang_hooks
.name
, "GNU C++")
2788 && DECL_INITIAL (decl
) == error_mark_node
))
2790 else if (DECL_IN_TEXT_SECTION (decl
))
2791 /* This is not quite right, but it's the closest
2792 of all the codes that Unix defines. */
2793 code
= DBX_STATIC_CONST_VAR_CODE
;
2796 /* Ultrix `as' seems to need this. */
2797 #ifdef DBX_STATIC_STAB_DATA_SECTION
2804 else if (regno
>= 0)
2808 number
= DBX_REGISTER_NUMBER (regno
);
2810 else if (MEM_P (home
)
2811 && (MEM_P (XEXP (home
, 0))
2812 || (REG_P (XEXP (home
, 0))
2813 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
2814 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
2815 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2816 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
2819 /* If the value is indirect by memory or by a register
2820 that isn't the frame pointer
2821 then it means the object is variable-sized and address through
2822 that register or stack slot. DBX has no way to represent this
2823 so all we can do is output the variable as a pointer.
2824 If it's not a parameter, ignore it. */
2826 if (REG_P (XEXP (home
, 0)))
2830 if (REGNO (XEXP (home
, 0)) >= FIRST_PSEUDO_REGISTER
)
2832 number
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
2837 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2838 We want the value of that CONST_INT. */
2839 number
= DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2842 /* Effectively do build_pointer_type, but don't cache this type,
2843 since it might be temporary whereas the type it points to
2844 might have been saved for inlining. */
2845 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2846 type
= make_node (POINTER_TYPE
);
2847 TREE_TYPE (type
) = TREE_TYPE (decl
);
2849 else if (MEM_P (home
)
2850 && REG_P (XEXP (home
, 0)))
2853 number
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2855 else if (MEM_P (home
)
2856 && GET_CODE (XEXP (home
, 0)) == PLUS
2857 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2860 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2861 We want the value of that CONST_INT. */
2862 number
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2864 else if (MEM_P (home
)
2865 && GET_CODE (XEXP (home
, 0)) == CONST
)
2867 /* Handle an obscure case which can arise when optimizing and
2868 when there are few available registers. (This is *always*
2869 the case for i386/i486 targets). The RTL looks like
2870 (MEM (CONST ...)) even though this variable is a local `auto'
2871 or a local `register' variable. In effect, what has happened
2872 is that the reload pass has seen that all assignments and
2873 references for one such a local variable can be replaced by
2874 equivalent assignments and references to some static storage
2875 variable, thereby avoiding the need for a register. In such
2876 cases we're forced to lie to debuggers and tell them that
2877 this variable was itself `static'. */
2880 addr
= XEXP (XEXP (home
, 0), 0);
2882 else if (GET_CODE (home
) == CONCAT
)
2886 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2887 for example), then there is no easy way to figure out
2888 what SUBTYPE should be. So, we give up. */
2889 if (TREE_CODE (type
) != COMPLEX_TYPE
)
2892 subtype
= TREE_TYPE (type
);
2894 /* If the variable's storage is in two parts,
2895 output each as a separate stab with a modified name. */
2896 if (WORDS_BIG_ENDIAN
)
2897 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2899 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2901 if (WORDS_BIG_ENDIAN
)
2902 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2904 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2908 /* Address might be a MEM, when DECL is a variable-sized object.
2909 Or it might be const0_rtx, meaning previous passes
2910 want us to ignore this variable. */
2913 /* Ok, start a symtab entry and output the variable name. */
2914 emit_pending_bincls_if_required ();
2917 #ifdef DBX_STATIC_BLOCK_START
2918 DBX_STATIC_BLOCK_START (asm_out_file
, code
);
2921 dbxout_begin_complex_stabs_noforcetext ();
2922 dbxout_symbol_name (decl
, suffix
, letter
);
2923 dbxout_type (type
, 0);
2924 dbxout_finish_complex_stabs (decl
, code
, addr
, 0, number
);
2926 #ifdef DBX_STATIC_BLOCK_END
2927 DBX_STATIC_BLOCK_END (asm_out_file
, code
);
2932 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2933 Then output LETTER to indicate the kind of location the symbol has. */
2936 dbxout_symbol_name (tree decl
, const char *suffix
, int letter
)
2940 if (DECL_CONTEXT (decl
)
2941 && (TYPE_P (DECL_CONTEXT (decl
))
2942 || TREE_CODE (DECL_CONTEXT (decl
)) == NAMESPACE_DECL
))
2943 /* One slight hitch: if this is a VAR_DECL which is a class member
2944 or a namespace member, we must put out the mangled name instead of the
2945 DECL_NAME. Note also that static member (variable) names DO NOT begin
2946 with underscores in .stabs directives. */
2947 name
= DECL_ASSEMBLER_NAME (decl
);
2949 /* ...but if we're function-local, we don't want to include the junk
2950 added by ASM_FORMAT_PRIVATE_NAME. */
2951 name
= DECL_NAME (decl
);
2956 stabstr_S ("(anon)");
2965 /* Output definitions of all the decls in a chain. Return nonzero if
2966 anything was output */
2969 dbxout_syms (tree syms
)
2974 result
+= dbxout_symbol (syms
, 1);
2975 syms
= TREE_CHAIN (syms
);
2980 /* The following two functions output definitions of function parameters.
2981 Each parameter gets a definition locating it in the parameter list.
2982 Each parameter that is a register variable gets a second definition
2983 locating it in the register.
2985 Printing or argument lists in gdb uses the definitions that
2986 locate in the parameter list. But reference to the variable in
2987 expressions uses preferentially the definition as a register. */
2989 /* Output definitions, referring to storage in the parmlist,
2990 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2993 dbxout_parms (tree parms
)
2996 emit_pending_bincls_if_required ();
2998 for (; parms
; parms
= TREE_CHAIN (parms
))
2999 if (DECL_NAME (parms
)
3000 && TREE_TYPE (parms
) != error_mark_node
3001 && DECL_RTL_SET_P (parms
)
3002 && DECL_INCOMING_RTL (parms
))
3006 STAB_CODE_TYPE code
;
3009 /* Perform any necessary register eliminations on the parameter's rtl,
3010 so that the debugging output will be accurate. */
3011 DECL_INCOMING_RTL (parms
)
3012 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
3013 SET_DECL_RTL (parms
, eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
3014 #ifdef LEAF_REG_REMAP
3015 if (current_function_uses_only_leaf_regs
)
3017 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
3018 leaf_renumber_regs_insn (DECL_RTL (parms
));
3022 if (PARM_PASSED_IN_MEMORY (parms
))
3024 rtx inrtl
= XEXP (DECL_INCOMING_RTL (parms
), 0);
3026 /* ??? Here we assume that the parm address is indexed
3027 off the frame pointer or arg pointer.
3028 If that is not true, we produce meaningless results,
3029 but do not crash. */
3030 if (GET_CODE (inrtl
) == PLUS
3031 && GET_CODE (XEXP (inrtl
, 1)) == CONST_INT
)
3032 number
= INTVAL (XEXP (inrtl
, 1));
3037 number
= DEBUGGER_ARG_OFFSET (number
, inrtl
);
3040 /* It is quite tempting to use TREE_TYPE (parms) instead
3041 of DECL_ARG_TYPE (parms) for the eff_type, so that gcc
3042 reports the actual type of the parameter, rather than
3043 the promoted type. This certainly makes GDB's life
3044 easier, at least for some ports. The change is a bad
3045 idea however, since GDB expects to be able access the
3046 type without performing any conversions. So for
3047 example, if we were passing a float to an unprototyped
3048 function, gcc will store a double on the stack, but if
3049 we emit a stab saying the type is a float, then gdb
3050 will only read in a single value, and this will produce
3051 an erroneous value. */
3052 eff_type
= DECL_ARG_TYPE (parms
);
3054 else if (REG_P (DECL_RTL (parms
)))
3058 /* Parm passed in registers and lives in registers or nowhere. */
3059 code
= DBX_REGPARM_STABS_CODE
;
3060 letter
= DBX_REGPARM_STABS_LETTER
;
3062 /* For parms passed in registers, it is better to use the
3063 declared type of the variable, not the type it arrived in. */
3064 eff_type
= TREE_TYPE (parms
);
3066 /* If parm lives in a register, use that register; pretend
3067 the parm was passed there. It would be more consistent
3068 to describe the register where the parm was passed, but
3069 in practice that register usually holds something else.
3070 If the parm lives nowhere, use the register where it
3072 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
3073 best_rtl
= DECL_RTL (parms
);
3075 best_rtl
= DECL_INCOMING_RTL (parms
);
3077 number
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
3079 else if (MEM_P (DECL_RTL (parms
))
3080 && REG_P (XEXP (DECL_RTL (parms
), 0))
3081 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
3082 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
3083 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
3084 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
3088 /* Parm was passed via invisible reference.
3089 That is, its address was passed in a register.
3090 Output it as if it lived in that register.
3091 The debugger will know from the type
3092 that it was actually passed by invisible reference. */
3094 code
= DBX_REGPARM_STABS_CODE
;
3096 /* GDB likes this marked with a special letter. */
3097 letter
= (use_gnu_debug_info_extensions
3098 ? 'a' : DBX_REGPARM_STABS_LETTER
);
3099 eff_type
= TREE_TYPE (parms
);
3101 /* DECL_RTL looks like (MEM (REG...). Get the register number.
3102 If it is an unallocated pseudo-reg, then use the register where
3103 it was passed instead.
3104 ??? Why is DBX_REGISTER_NUMBER not used here? */
3106 if (REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
3107 number
= REGNO (XEXP (DECL_RTL (parms
), 0));
3109 number
= REGNO (DECL_INCOMING_RTL (parms
));
3111 else if (MEM_P (DECL_RTL (parms
))
3112 && MEM_P (XEXP (DECL_RTL (parms
), 0)))
3114 /* Parm was passed via invisible reference, with the reference
3115 living on the stack. DECL_RTL looks like
3116 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
3117 could look like (MEM (MEM (REG))). */
3121 eff_type
= TREE_TYPE (parms
);
3123 if (!REG_P (XEXP (XEXP (DECL_RTL (parms
), 0), 0)))
3124 number
= INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
3128 number
= DEBUGGER_ARG_OFFSET (number
,
3129 XEXP (XEXP (DECL_RTL (parms
), 0), 0));
3131 else if (MEM_P (DECL_RTL (parms
))
3132 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
3133 /* ??? A constant address for a parm can happen
3134 when the reg it lives in is equiv to a constant in memory.
3135 Should make this not happen, after 2.4. */
3136 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
3138 /* Parm was passed in registers but lives on the stack. */
3142 eff_type
= TREE_TYPE (parms
);
3144 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
3145 in which case we want the value of that CONST_INT,
3147 in which case we use a value of zero. */
3148 if (!REG_P (XEXP (DECL_RTL (parms
), 0)))
3149 number
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
3153 /* Make a big endian correction if the mode of the type of the
3154 parameter is not the same as the mode of the rtl. */
3155 if (BYTES_BIG_ENDIAN
3156 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
3157 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
3158 number
+= (GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
)))
3159 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))));
3162 /* ??? We don't know how to represent this argument. */
3165 dbxout_begin_complex_stabs ();
3167 if (DECL_NAME (parms
))
3169 stabstr_I (DECL_NAME (parms
));
3173 stabstr_S ("(anon):");
3175 dbxout_type (eff_type
, 0);
3176 dbxout_finish_complex_stabs (parms
, code
, 0, 0, number
);
3178 DBXOUT_DECR_NESTING
;
3181 /* Output definitions for the places where parms live during the function,
3182 when different from where they were passed, when the parms were passed
3185 It is not useful to do this for parms passed in registers
3186 that live during the function in different registers, because it is
3187 impossible to look in the passed register for the passed value,
3188 so we use the within-the-function register to begin with.
3190 PARMS is a chain of PARM_DECL nodes. */
3193 dbxout_reg_parms (tree parms
)
3197 for (; parms
; parms
= TREE_CHAIN (parms
))
3198 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
3200 /* Report parms that live in registers during the function
3201 but were passed in memory. */
3202 if (REG_P (DECL_RTL (parms
))
3203 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
3204 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
3205 0, DECL_RTL (parms
));
3206 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
3207 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
3208 0, DECL_RTL (parms
));
3209 /* Report parms that live in memory but not where they were passed. */
3210 else if (MEM_P (DECL_RTL (parms
))
3211 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
3212 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
3213 0, DECL_RTL (parms
));
3215 DBXOUT_DECR_NESTING
;
3218 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
3219 output definitions of those names, in raw form */
3222 dbxout_args (tree args
)
3227 dbxout_type (TREE_VALUE (args
), 0);
3228 args
= TREE_CHAIN (args
);
3232 /* Subroutine of dbxout_block. Emit an N_LBRAC stab referencing LABEL.
3233 BEGIN_LABEL is the name of the beginning of the function, which may
3236 dbx_output_lbrac (const char *label
,
3237 const char *begin_label ATTRIBUTE_UNUSED
)
3239 #ifdef DBX_OUTPUT_LBRAC
3240 DBX_OUTPUT_LBRAC (asm_out_file
, label
);
3242 dbxout_begin_stabn (N_LBRAC
);
3243 if (DBX_BLOCKS_FUNCTION_RELATIVE
)
3244 dbxout_stab_value_label_diff (label
, begin_label
);
3246 dbxout_stab_value_label (label
);
3250 /* Subroutine of dbxout_block. Emit an N_RBRAC stab referencing LABEL.
3251 BEGIN_LABEL is the name of the beginning of the function, which may
3254 dbx_output_rbrac (const char *label
,
3255 const char *begin_label ATTRIBUTE_UNUSED
)
3257 #ifdef DBX_OUTPUT_RBRAC
3258 DBX_OUTPUT_RBRAC (asm_out_file
, label
);
3260 dbxout_begin_stabn (N_RBRAC
);
3261 if (DBX_BLOCKS_FUNCTION_RELATIVE
)
3262 dbxout_stab_value_label_diff (label
, begin_label
);
3264 dbxout_stab_value_label (label
);
3268 /* Output everything about a symbol block (a BLOCK node
3269 that represents a scope level),
3270 including recursive output of contained blocks.
3272 BLOCK is the BLOCK node.
3273 DEPTH is its depth within containing symbol blocks.
3274 ARGS is usually zero; but for the outermost block of the
3275 body of a function, it is a chain of PARM_DECLs for the function parameters.
3276 We output definitions of all the register parms
3277 as if they were local variables of that block.
3279 If -g1 was used, we count blocks just the same, but output nothing
3280 except for the outermost block.
3282 Actually, BLOCK may be several blocks chained together.
3283 We handle them all in sequence. */
3286 dbxout_block (tree block
, int depth
, tree args
)
3288 const char *begin_label
3289 = XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0);
3293 /* Ignore blocks never expanded or otherwise marked as real. */
3294 if (TREE_USED (block
) && TREE_ASM_WRITTEN (block
))
3297 int blocknum
= BLOCK_NUMBER (block
);
3299 /* In dbx format, the syms of a block come before the N_LBRAC.
3300 If nothing is output, we don't need the N_LBRAC, either. */
3302 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
3303 did_output
= dbxout_syms (BLOCK_VARS (block
));
3305 dbxout_reg_parms (args
);
3307 /* Now output an N_LBRAC symbol to represent the beginning of
3308 the block. Use the block's tree-walk order to generate
3309 the assembler symbols LBBn and LBEn
3310 that final will define around the code in this block. */
3314 const char *scope_start
;
3317 /* The outermost block doesn't get LBB labels; use
3318 the function symbol. */
3319 scope_start
= begin_label
;
3322 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
3326 if (BLOCK_HANDLER_BLOCK (block
))
3328 /* A catch block. Must precede N_LBRAC. */
3329 tree decl
= BLOCK_VARS (block
);
3332 dbxout_begin_complex_stabs ();
3333 stabstr_I (DECL_NAME (decl
));
3335 dbxout_finish_complex_stabs (0, N_CATCH
, 0,
3337 decl
= TREE_CHAIN (decl
);
3340 dbx_output_lbrac (scope_start
, begin_label
);
3343 /* Output the subblocks. */
3344 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
3346 /* Refer to the marker for the end of the block. */
3351 /* The outermost block doesn't get LBE labels;
3352 use the "scope" label which will be emitted
3353 by dbxout_function_end. */
3354 ASM_GENERATE_INTERNAL_LABEL (buf
, "Lscope", scope_labelno
);
3356 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
3358 dbx_output_rbrac (buf
, begin_label
);
3361 block
= BLOCK_CHAIN (block
);
3365 /* Output the information about a function and its arguments and result.
3366 Usually this follows the function's code,
3367 but on some systems, it comes before. */
3369 #if defined (DBX_DEBUGGING_INFO)
3371 dbxout_begin_function (tree decl
)
3373 int saved_tree_used1
;
3375 if (DECL_IGNORED_P (decl
))
3378 saved_tree_used1
= TREE_USED (decl
);
3379 TREE_USED (decl
) = 1;
3380 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3382 int saved_tree_used2
= TREE_USED (DECL_RESULT (decl
));
3383 TREE_USED (DECL_RESULT (decl
)) = 1;
3384 dbxout_symbol (decl
, 0);
3385 TREE_USED (DECL_RESULT (decl
)) = saved_tree_used2
;
3388 dbxout_symbol (decl
, 0);
3389 TREE_USED (decl
) = saved_tree_used1
;
3391 dbxout_parms (DECL_ARGUMENTS (decl
));
3392 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3393 dbxout_symbol (DECL_RESULT (decl
), 1);
3395 #endif /* DBX_DEBUGGING_INFO */
3397 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3399 #include "gt-dbxout.h"