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 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
245 for the N_SO filename stabs label. */
247 static GTY(()) int source_label_number
= 1;
249 /* Last source file name mentioned in a NOTE insn. */
251 static GTY(()) const char *lastfile
;
253 /* Used by PCH machinery to detect if 'lastfile' should be reset to
255 static GTY(()) int lastfile_is_base
;
257 /* Typical USG systems don't have stab.h, and they also have
258 no use for DBX-format debugging info. */
260 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
263 /* If zero then there is no pending BINCL. */
264 static int pending_bincls
= 0;
267 /* The original input file name. */
268 static const char *base_input_file
;
270 #ifdef DEBUG_SYMS_TEXT
271 #define FORCE_TEXT current_function_section (current_function_decl);
278 #define STAB_CODE_TYPE enum __stab_debug_code
280 /* 1 if PARM is passed to this function in memory. */
282 #define PARM_PASSED_IN_MEMORY(PARM) \
283 (MEM_P (DECL_INCOMING_RTL (PARM)))
285 /* A C expression for the integer offset value of an automatic variable
286 (N_LSYM) having address X (an RTX). */
287 #ifndef DEBUGGER_AUTO_OFFSET
288 #define DEBUGGER_AUTO_OFFSET(X) \
289 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
292 /* A C expression for the integer offset value of an argument (N_PSYM)
293 having address X (an RTX). The nominal offset is OFFSET. */
294 #ifndef DEBUGGER_ARG_OFFSET
295 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
298 /* This obstack holds the stab string currently being constructed. We
299 build it up here, then write it out, so we can split long lines up
300 properly (see dbxout_finish_complex_stabs). */
301 static struct obstack stabstr_ob
;
302 static size_t stabstr_last_contin_point
;
305 static void emit_bincl_stab (const char *c
);
306 static void emit_pending_bincls (void);
308 static inline void emit_pending_bincls_if_required (void);
310 static void dbxout_init (const char *);
312 static void dbxout_finish (const char *);
313 static void dbxout_start_source_file (unsigned, const char *);
314 static void dbxout_end_source_file (unsigned);
315 static void dbxout_typedefs (tree
);
316 static void dbxout_type_index (tree
);
317 static void dbxout_args (tree
);
318 static void dbxout_type_fields (tree
);
319 static void dbxout_type_method_1 (tree
);
320 static void dbxout_type_methods (tree
);
321 static void dbxout_range_type (tree
);
322 static void dbxout_type (tree
, int);
323 static bool print_int_cst_bounds_in_octal_p (tree
);
324 static void dbxout_type_name (tree
);
325 static void dbxout_class_name_qualifiers (tree
);
326 static int dbxout_symbol_location (tree
, tree
, const char *, rtx
);
327 static void dbxout_symbol_name (tree
, const char *, int);
328 static void dbxout_block (tree
, int, tree
);
329 static void dbxout_global_decl (tree
);
330 static void dbxout_type_decl (tree
, int);
331 static void dbxout_handle_pch (unsigned);
333 /* The debug hooks structure. */
334 #if defined (DBX_DEBUGGING_INFO)
336 static void dbxout_source_line (unsigned int, const char *);
337 static void dbxout_begin_prologue (unsigned int, const char *);
338 static void dbxout_source_file (const char *);
339 static void dbxout_function_end (tree
);
340 static void dbxout_begin_function (tree
);
341 static void dbxout_begin_block (unsigned, unsigned);
342 static void dbxout_end_block (unsigned, unsigned);
343 static void dbxout_function_decl (tree
);
345 const struct gcc_debug_hooks dbx_debug_hooks
=
349 debug_nothing_int_charstar
,
350 debug_nothing_int_charstar
,
351 dbxout_start_source_file
,
352 dbxout_end_source_file
,
355 debug_true_tree
, /* ignore_block */
356 dbxout_source_line
, /* source_line */
357 dbxout_begin_prologue
, /* begin_prologue */
358 debug_nothing_int_charstar
, /* end_prologue */
359 debug_nothing_int_charstar
, /* end_epilogue */
360 #ifdef DBX_FUNCTION_FIRST
361 dbxout_begin_function
,
363 debug_nothing_tree
, /* begin_function */
365 debug_nothing_int
, /* end_function */
366 dbxout_function_decl
,
367 dbxout_global_decl
, /* global_decl */
368 dbxout_type_decl
, /* type_decl */
369 debug_nothing_tree_tree
, /* imported_module_or_decl */
370 debug_nothing_tree
, /* deferred_inline_function */
371 debug_nothing_tree
, /* outlining_inline_function */
372 debug_nothing_rtx
, /* label */
373 dbxout_handle_pch
, /* handle_pch */
374 debug_nothing_rtx
, /* var_location */
375 debug_nothing_void
, /* switch_text_section */
376 0 /* start_end_main_source_file */
378 #endif /* DBX_DEBUGGING_INFO */
380 #if defined (XCOFF_DEBUGGING_INFO)
381 const struct gcc_debug_hooks xcoff_debug_hooks
=
385 debug_nothing_int_charstar
,
386 debug_nothing_int_charstar
,
387 dbxout_start_source_file
,
388 dbxout_end_source_file
,
389 xcoffout_begin_block
,
391 debug_true_tree
, /* ignore_block */
392 xcoffout_source_line
,
393 xcoffout_begin_prologue
, /* begin_prologue */
394 debug_nothing_int_charstar
, /* end_prologue */
395 xcoffout_end_epilogue
,
396 debug_nothing_tree
, /* begin_function */
397 xcoffout_end_function
,
398 debug_nothing_tree
, /* function_decl */
399 dbxout_global_decl
, /* global_decl */
400 dbxout_type_decl
, /* type_decl */
401 debug_nothing_tree_tree
, /* imported_module_or_decl */
402 debug_nothing_tree
, /* deferred_inline_function */
403 debug_nothing_tree
, /* outlining_inline_function */
404 debug_nothing_rtx
, /* label */
405 dbxout_handle_pch
, /* handle_pch */
406 debug_nothing_rtx
, /* var_location */
407 debug_nothing_void
, /* switch_text_section */
408 0 /* start_end_main_source_file */
410 #endif /* XCOFF_DEBUGGING_INFO */
412 /* Numeric formatting helper macro. Note that this does not handle
414 #define NUMBER_FMT_LOOP(P, NUM, BASE) \
417 int digit = NUM % BASE; \
419 *--P = digit + '0'; \
423 /* Utility: write a decimal integer NUM to asm_out_file. */
428 char *p
= buf
+ sizeof buf
;
433 putc ('0', asm_out_file
);
438 putc ('-', asm_out_file
);
444 NUMBER_FMT_LOOP (p
, unum
, 10);
446 while (p
< buf
+ sizeof buf
)
448 putc (*p
, asm_out_file
);
454 /* Primitives for emitting simple stabs directives. All other stabs
455 routines should use these functions instead of directly emitting
456 stabs. They are exported because machine-dependent code may need
457 to invoke them, e.g. in a DBX_OUTPUT_* macro whose definition
458 forwards to code in CPU.c. */
460 /* The following functions should all be called immediately after one
461 of the dbxout_begin_stab* functions (below). They write out
462 various things as the value of a stab. */
464 /* Write out a literal zero as the value of a stab. */
466 dbxout_stab_value_zero (void)
468 fputs ("0\n", asm_out_file
);
471 /* Write out the label LABEL as the value of a stab. */
473 dbxout_stab_value_label (const char *label
)
475 assemble_name (asm_out_file
, label
);
476 putc ('\n', asm_out_file
);
479 /* Write out the difference of two labels, LABEL - BASE, as the value
482 dbxout_stab_value_label_diff (const char *label
, const char *base
)
484 assemble_name (asm_out_file
, label
);
485 putc ('-', asm_out_file
);
486 assemble_name (asm_out_file
, base
);
487 putc ('\n', asm_out_file
);
490 /* Write out an internal label as the value of a stab, and immediately
491 emit that internal label. This should be used only when
492 dbxout_stabd will not work. STEM is the name stem of the label,
493 COUNTERP is a pointer to a counter variable which will be used to
494 guarantee label uniqueness. */
496 dbxout_stab_value_internal_label (const char *stem
, int *counterp
)
499 int counter
= counterp
? (*counterp
)++ : 0;
501 ASM_GENERATE_INTERNAL_LABEL (label
, stem
, counter
);
502 dbxout_stab_value_label (label
);
503 targetm
.asm_out
.internal_label (asm_out_file
, stem
, counter
);
506 /* Write out the difference between BASE and an internal label as the
507 value of a stab, and immediately emit that internal label. STEM and
508 COUNTERP are as for dbxout_stab_value_internal_label. */
510 dbxout_stab_value_internal_label_diff (const char *stem
, int *counterp
,
514 int counter
= counterp
? (*counterp
)++ : 0;
516 ASM_GENERATE_INTERNAL_LABEL (label
, stem
, counter
);
517 dbxout_stab_value_label_diff (label
, base
);
518 targetm
.asm_out
.internal_label (asm_out_file
, stem
, counter
);
521 /* The following functions produce specific kinds of stab directives. */
523 /* Write a .stabd directive with type STYPE and desc SDESC to asm_out_file. */
525 dbxout_stabd (int stype
, int sdesc
)
527 fputs (ASM_STABD_OP
, asm_out_file
);
529 fputs (",0,", asm_out_file
);
531 putc ('\n', asm_out_file
);
534 /* Write a .stabn directive with type STYPE. This function stops
535 short of emitting the value field, which is the responsibility of
536 the caller (normally it will be either a symbol or the difference
540 dbxout_begin_stabn (int stype
)
542 fputs (ASM_STABN_OP
, asm_out_file
);
544 fputs (",0,0,", asm_out_file
);
547 /* Write a .stabn directive with type N_SLINE and desc LINE. As above,
548 the value field is the responsibility of the caller. */
550 dbxout_begin_stabn_sline (int lineno
)
552 fputs (ASM_STABN_OP
, asm_out_file
);
553 dbxout_int (N_SLINE
);
554 fputs (",0,", asm_out_file
);
556 putc (',', asm_out_file
);
559 /* Begin a .stabs directive with string "", type STYPE, and desc and
560 other fields 0. The value field is the responsibility of the
561 caller. This function cannot be used for .stabx directives. */
563 dbxout_begin_empty_stabs (int stype
)
565 fputs (ASM_STABS_OP
, asm_out_file
);
566 fputs ("\"\",", asm_out_file
);
568 fputs (",0,0,", asm_out_file
);
571 /* Begin a .stabs directive with string STR, type STYPE, and desc 0.
572 The value field is the responsibility of the caller. */
574 dbxout_begin_simple_stabs (const char *str
, int stype
)
576 fputs (ASM_STABS_OP
, asm_out_file
);
577 output_quoted_string (asm_out_file
, str
);
578 putc (',', asm_out_file
);
580 fputs (",0,0,", asm_out_file
);
583 /* As above but use SDESC for the desc field. */
585 dbxout_begin_simple_stabs_desc (const char *str
, int stype
, int sdesc
)
587 fputs (ASM_STABS_OP
, asm_out_file
);
588 output_quoted_string (asm_out_file
, str
);
589 putc (',', asm_out_file
);
591 fputs (",0,", asm_out_file
);
593 putc (',', asm_out_file
);
596 /* The next set of functions are entirely concerned with production of
597 "complex" .stabs directives: that is, .stabs directives whose
598 strings have to be constructed piecemeal. dbxout_type,
599 dbxout_symbol, etc. use these routines heavily. The string is queued
600 up in an obstack, then written out by dbxout_finish_complex_stabs, which
601 is also responsible for splitting it up if it exceeds DBX_CONTIN_LENGTH.
602 (You might think it would be more efficient to go straight to stdio
603 when DBX_CONTIN_LENGTH is 0 (i.e. no length limit) but that turns
604 out not to be the case, and anyway this needs fewer #ifdefs.) */
606 /* Begin a complex .stabs directive. If we can, write the initial
607 ASM_STABS_OP to the asm_out_file. */
610 dbxout_begin_complex_stabs (void)
612 emit_pending_bincls_if_required ();
614 fputs (ASM_STABS_OP
, asm_out_file
);
615 putc ('"', asm_out_file
);
616 gcc_assert (stabstr_last_contin_point
== 0);
619 /* As above, but do not force text or emit pending bincls. This is
620 used by dbxout_symbol_location, which needs to do something else. */
622 dbxout_begin_complex_stabs_noforcetext (void)
624 fputs (ASM_STABS_OP
, asm_out_file
);
625 putc ('"', asm_out_file
);
626 gcc_assert (stabstr_last_contin_point
== 0);
629 /* Add CHR, a single character, to the string being built. */
630 #define stabstr_C(chr) obstack_1grow (&stabstr_ob, chr)
632 /* Add STR, a normal C string, to the string being built. */
633 #define stabstr_S(str) obstack_grow (&stabstr_ob, str, strlen(str))
635 /* Add the text of ID, an IDENTIFIER_NODE, to the string being built. */
636 #define stabstr_I(id) obstack_grow (&stabstr_ob, \
637 IDENTIFIER_POINTER (id), \
638 IDENTIFIER_LENGTH (id))
640 /* Add NUM, a signed decimal number, to the string being built. */
642 stabstr_D (HOST_WIDE_INT num
)
645 char *p
= buf
+ sizeof buf
;
661 NUMBER_FMT_LOOP (p
, unum
, 10);
663 obstack_grow (&stabstr_ob
, p
, (buf
+ sizeof buf
) - p
);
666 /* Add NUM, an unsigned decimal number, to the string being built. */
668 stabstr_U (unsigned HOST_WIDE_INT num
)
671 char *p
= buf
+ sizeof buf
;
677 NUMBER_FMT_LOOP (p
, num
, 10);
678 obstack_grow (&stabstr_ob
, p
, (buf
+ sizeof buf
) - p
);
681 /* Add CST, an INTEGER_CST tree, to the string being built as an
682 unsigned octal number. This routine handles values which are
683 larger than a single HOST_WIDE_INT. */
687 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (cst
);
688 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (cst
);
691 char *p
= buf
+ sizeof buf
;
693 /* GDB wants constants with no extra leading "1" bits, so
694 we need to remove any sign-extension that might be
697 const unsigned int width
= TYPE_PRECISION (TREE_TYPE (cst
));
698 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
700 else if (width
> HOST_BITS_PER_WIDE_INT
)
701 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
702 else if (width
== HOST_BITS_PER_WIDE_INT
)
705 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
708 /* Leading zero for base indicator. */
711 /* If the value is zero, the base indicator will serve as the value
713 if (high
== 0 && low
== 0)
716 /* If the high half is zero, we need only print the low half normally. */
718 NUMBER_FMT_LOOP (p
, low
, 8);
721 /* When high != 0, we need to print enough zeroes from low to
722 give the digits from high their proper place-values. Hence
723 NUMBER_FMT_LOOP cannot be used. */
724 const int n_digits
= HOST_BITS_PER_WIDE_INT
/ 3;
727 for (i
= 1; i
<= n_digits
; i
++)
729 unsigned int digit
= low
% 8;
734 /* Octal digits carry exactly three bits of information. The
735 width of a HOST_WIDE_INT is not normally a multiple of three.
736 Therefore, the next digit printed probably needs to carry
737 information from both low and high. */
738 if (HOST_BITS_PER_WIDE_INT
% 3 != 0)
740 const int n_leftover_bits
= HOST_BITS_PER_WIDE_INT
% 3;
741 const int n_bits_from_high
= 3 - n_leftover_bits
;
743 const unsigned HOST_WIDE_INT
744 low_mask
= (((unsigned HOST_WIDE_INT
)1) << n_leftover_bits
) - 1;
745 const unsigned HOST_WIDE_INT
746 high_mask
= (((unsigned HOST_WIDE_INT
)1) << n_bits_from_high
) - 1;
750 /* At this point, only the bottom n_leftover_bits bits of low
752 gcc_assert (!(low
& ~low_mask
));
754 digit
= (low
| ((high
& high_mask
) << n_leftover_bits
));
755 high
>>= n_bits_from_high
;
760 /* Now we can format high in the normal manner. However, if
761 the only bits of high that were set were handled by the
762 digit split between low and high, high will now be zero, and
763 we don't want to print extra digits in that case. */
765 NUMBER_FMT_LOOP (p
, high
, 8);
768 obstack_grow (&stabstr_ob
, p
, (buf
+ sizeof buf
) - p
);
771 /* Called whenever it is safe to break a stabs string into multiple
772 .stabs directives. If the current string has exceeded the limit
773 set by DBX_CONTIN_LENGTH, mark the current position in the buffer
774 as a continuation point by inserting DBX_CONTIN_CHAR (doubled if
775 it is a backslash) and a null character. */
777 stabstr_continue (void)
779 if (DBX_CONTIN_LENGTH
> 0
780 && obstack_object_size (&stabstr_ob
) - stabstr_last_contin_point
783 if (DBX_CONTIN_CHAR
== '\\')
784 obstack_1grow (&stabstr_ob
, '\\');
785 obstack_1grow (&stabstr_ob
, DBX_CONTIN_CHAR
);
786 obstack_1grow (&stabstr_ob
, '\0');
787 stabstr_last_contin_point
= obstack_object_size (&stabstr_ob
);
790 #define CONTIN stabstr_continue ()
792 /* Macro subroutine of dbxout_finish_complex_stabs, which emits
793 all of the arguments to the .stabs directive after the string.
794 Overridden by xcoffout.h. CODE is the stabs code for this symbol;
795 LINE is the source line to write into the desc field (in extended
796 mode); SYM is the symbol itself.
798 ADDR, LABEL, and NUMBER are three different ways to represent the
799 stabs value field. At most one of these should be nonzero.
801 ADDR is used most of the time; it represents the value as an
802 RTL address constant.
804 LABEL is used (currently) only for N_CATCH stabs; it represents
805 the value as a string suitable for assemble_name.
807 NUMBER is used when the value is an offset from an implicit base
808 pointer (e.g. for a stack variable), or an index (e.g. for a
809 register variable). It represents the value as a decimal integer. */
811 #ifndef DBX_FINISH_STABS
812 #define DBX_FINISH_STABS(SYM, CODE, LINE, ADDR, LABEL, NUMBER) \
814 int line_ = use_gnu_debug_info_extensions ? LINE : 0; \
817 fputs (",0,", asm_out_file); \
818 dbxout_int (line_); \
819 putc (',', asm_out_file); \
821 output_addr_const (asm_out_file, ADDR); \
823 assemble_name (asm_out_file, LABEL); \
825 dbxout_int (NUMBER); \
826 putc ('\n', asm_out_file); \
830 /* Finish the emission of a complex .stabs directive. When DBX_CONTIN_LENGTH
831 is zero, this has only to emit the close quote and the remainder of
832 the arguments. When it is nonzero, the string has been marshalled in
833 stabstr_ob, and this routine is responsible for breaking it up into
834 DBX_CONTIN_LENGTH-sized chunks.
836 SYM is the DECL of the symbol under consideration; it is used only
837 for its DECL_SOURCE_LINE. The other arguments are all passed directly
838 to DBX_FINISH_STABS; see above for details. */
841 dbxout_finish_complex_stabs (tree sym
, STAB_CODE_TYPE code
,
842 rtx addr
, const char *label
, int number
)
844 int line ATTRIBUTE_UNUSED
;
848 line
= sym
? DECL_SOURCE_LINE (sym
) : 0;
849 if (DBX_CONTIN_LENGTH
> 0)
854 /* Nul-terminate the growing string, then get its size and
856 obstack_1grow (&stabstr_ob
, '\0');
858 len
= obstack_object_size (&stabstr_ob
);
859 chunk
= str
= obstack_finish (&stabstr_ob
);
861 /* Within the buffer are a sequence of NUL-separated strings,
862 each of which is to be written out as a separate stab
866 chunklen
= strlen (chunk
);
867 fwrite (chunk
, 1, chunklen
, asm_out_file
);
868 fputs ("\",", asm_out_file
);
870 /* Must add an extra byte to account for the NUL separator. */
871 chunk
+= chunklen
+ 1;
874 /* Only put a line number on the last stab in the sequence. */
875 DBX_FINISH_STABS (sym
, code
, len
== 0 ? line
: 0,
876 addr
, label
, number
);
880 fputs (ASM_STABS_OP
, asm_out_file
);
881 putc ('"', asm_out_file
);
883 stabstr_last_contin_point
= 0;
887 /* No continuations - we can put the whole string out at once.
888 It is faster to augment the string with the close quote and
889 comma than to do a two-character fputs. */
890 obstack_grow (&stabstr_ob
, "\",", 2);
891 len
= obstack_object_size (&stabstr_ob
);
892 str
= obstack_finish (&stabstr_ob
);
894 fwrite (str
, 1, len
, asm_out_file
);
895 DBX_FINISH_STABS (sym
, code
, line
, addr
, label
, number
);
897 obstack_free (&stabstr_ob
, str
);
900 #if defined (DBX_DEBUGGING_INFO)
903 dbxout_function_end (tree decl
)
905 char lscope_label_name
[100];
907 /* The Lscope label must be emitted even if we aren't doing anything
908 else; dbxout_block needs it. */
909 function_section (current_function_decl
);
911 /* Convert Lscope into the appropriate format for local labels in case
912 the system doesn't insert underscores in front of user generated
914 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name
, "Lscope", scope_labelno
);
915 targetm
.asm_out
.internal_label (asm_out_file
, "Lscope", scope_labelno
);
918 /* The N_FUN tag at the end of the function is a GNU extension,
919 which may be undesirable, and is unnecessary if we do not have
921 if (!use_gnu_debug_info_extensions
922 || NO_DBX_FUNCTION_END
923 || !targetm
.have_named_sections
924 || DECL_IGNORED_P (decl
))
927 /* By convention, GCC will mark the end of a function with an N_FUN
928 symbol and an empty string. */
929 #ifdef DBX_OUTPUT_NFUN
930 DBX_OUTPUT_NFUN (asm_out_file
, lscope_label_name
, current_function_decl
);
932 if (flag_reorder_blocks_and_partition
)
934 dbxout_begin_empty_stabs (N_FUN
);
935 dbxout_stab_value_label_diff (cfun
->hot_section_end_label
,
936 cfun
->hot_section_label
);
937 dbxout_begin_empty_stabs (N_FUN
);
938 dbxout_stab_value_label_diff (cfun
->cold_section_end_label
,
939 cfun
->cold_section_label
);
943 dbxout_begin_empty_stabs (N_FUN
);
944 dbxout_stab_value_label_diff (lscope_label_name
,
945 XSTR (XEXP (DECL_RTL (current_function_decl
),
951 if (!NO_DBX_BNSYM_ENSYM
&& !flag_debug_only_used_symbols
)
952 dbxout_stabd (N_ENSYM
, 0);
954 #endif /* DBX_DEBUGGING_INFO */
956 /* Get lang description for N_SO stab. */
957 static unsigned int ATTRIBUTE_UNUSED
958 get_lang_number (void)
960 const char *language_string
= lang_hooks
.name
;
962 if (strcmp (language_string
, "GNU C") == 0)
964 else if (strcmp (language_string
, "GNU C++") == 0)
966 else if (strcmp (language_string
, "GNU F77") == 0)
968 else if (strcmp (language_string
, "GNU F95") == 0)
969 return N_SO_FORTRAN90
; /* CHECKME */
970 else if (strcmp (language_string
, "GNU Pascal") == 0)
972 else if (strcmp (language_string
, "GNU Objective-C") == 0)
974 else if (strcmp (language_string
, "GNU Objective-C++") == 0)
975 return N_SO_OBJCPLUS
;
981 /* At the beginning of compilation, start writing the symbol table.
982 Initialize `typevec' and output the standard data types of C. */
985 dbxout_init (const char *input_file_name
)
987 char ltext_label_name
[100];
988 bool used_ltext_label_name
= false;
989 tree syms
= lang_hooks
.decls
.getdecls ();
992 typevec
= ggc_calloc (typevec_len
, sizeof typevec
[0]);
994 /* stabstr_ob contains one string, which will be just fine with
996 obstack_specify_allocation (&stabstr_ob
, 0, 1, xmalloc
, free
);
998 /* Convert Ltext into the appropriate format for local labels in case
999 the system doesn't insert underscores in front of user generated
1001 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
1003 /* Put the current working directory in an N_SO symbol. */
1004 if (use_gnu_debug_info_extensions
&& !NO_DBX_MAIN_SOURCE_DIRECTORY
)
1006 static const char *cwd
;
1010 cwd
= get_src_pwd ();
1013 else if (!IS_DIR_SEPARATOR (cwd
[strlen (cwd
) - 1]))
1014 cwd
= concat (cwd
, "/", NULL
);
1016 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
1017 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asm_out_file
, cwd
);
1018 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
1019 dbxout_begin_simple_stabs_desc (cwd
, N_SO
, get_lang_number ());
1020 dbxout_stab_value_label (ltext_label_name
);
1021 used_ltext_label_name
= true;
1022 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
1025 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
1026 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asm_out_file
, input_file_name
);
1028 dbxout_begin_simple_stabs_desc (input_file_name
, N_SO
, get_lang_number ());
1029 dbxout_stab_value_label (ltext_label_name
);
1030 used_ltext_label_name
= true;
1033 if (used_ltext_label_name
)
1036 targetm
.asm_out
.internal_label (asm_out_file
, "Ltext", 0);
1039 /* Emit an N_OPT stab to indicate that this file was compiled by GCC.
1040 The string used is historical. */
1041 #ifndef NO_DBX_GCC_MARKER
1042 dbxout_begin_simple_stabs ("gcc2_compiled.", N_OPT
);
1043 dbxout_stab_value_zero ();
1046 base_input_file
= lastfile
= input_file_name
;
1048 next_type_number
= 1;
1050 #ifdef DBX_USE_BINCL
1051 current_file
= xmalloc (sizeof *current_file
);
1052 current_file
->next
= NULL
;
1053 current_file
->file_number
= 0;
1054 current_file
->next_type_number
= 1;
1055 next_file_number
= 1;
1056 current_file
->prev
= NULL
;
1057 current_file
->bincl_status
= BINCL_NOT_REQUIRED
;
1058 current_file
->pending_bincl_name
= NULL
;
1061 /* Get all permanent types that have typedef names, and output them
1062 all, except for those already output. Some language front ends
1063 put these declarations in the top-level scope; some do not;
1064 the latter are responsible for calling debug_hooks->type_decl from
1065 their record_builtin_type function. */
1066 dbxout_typedefs (syms
);
1068 if (preinit_symbols
)
1071 for (t
= nreverse (preinit_symbols
); t
; t
= TREE_CHAIN (t
))
1072 dbxout_symbol (TREE_VALUE (t
), 0);
1073 preinit_symbols
= 0;
1077 /* Output any typedef names for types described by TYPE_DECLs in SYMS. */
1080 dbxout_typedefs (tree syms
)
1082 for (; syms
!= NULL_TREE
; syms
= TREE_CHAIN (syms
))
1084 if (TREE_CODE (syms
) == TYPE_DECL
)
1086 tree type
= TREE_TYPE (syms
);
1087 if (TYPE_NAME (type
)
1088 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1089 && COMPLETE_OR_VOID_TYPE_P (type
)
1090 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
1091 dbxout_symbol (TYPE_NAME (type
), 0);
1096 #ifdef DBX_USE_BINCL
1097 /* Emit BINCL stab using given name. */
1099 emit_bincl_stab (const char *name
)
1101 dbxout_begin_simple_stabs (name
, N_BINCL
);
1102 dbxout_stab_value_zero ();
1105 /* If there are pending bincls then it is time to emit all of them. */
1108 emit_pending_bincls_if_required (void)
1111 emit_pending_bincls ();
1114 /* Emit all pending bincls. */
1117 emit_pending_bincls (void)
1119 struct dbx_file
*f
= current_file
;
1121 /* Find first pending bincl. */
1122 while (f
->bincl_status
== BINCL_PENDING
)
1125 /* Now emit all bincls. */
1130 if (f
->bincl_status
== BINCL_PENDING
)
1132 emit_bincl_stab (f
->pending_bincl_name
);
1134 /* Update file number and status. */
1135 f
->file_number
= next_file_number
++;
1136 f
->bincl_status
= BINCL_PROCESSED
;
1138 if (f
== current_file
)
1143 /* All pending bincls have been emitted. */
1150 emit_pending_bincls_if_required (void) {}
1153 /* Change to reading from a new source file. Generate a N_BINCL stab. */
1156 dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED
,
1157 const char *filename ATTRIBUTE_UNUSED
)
1159 #ifdef DBX_USE_BINCL
1160 struct dbx_file
*n
= xmalloc (sizeof *n
);
1162 n
->next
= current_file
;
1163 n
->next_type_number
= 1;
1164 /* Do not assign file number now.
1165 Delay it until we actually emit BINCL. */
1168 current_file
->prev
= n
;
1169 n
->bincl_status
= BINCL_PENDING
;
1170 n
->pending_bincl_name
= filename
;
1176 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
1179 dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED
)
1181 #ifdef DBX_USE_BINCL
1182 /* Emit EINCL stab only if BINCL is not pending. */
1183 if (current_file
->bincl_status
== BINCL_PROCESSED
)
1185 dbxout_begin_stabn (N_EINCL
);
1186 dbxout_stab_value_zero ();
1188 current_file
->bincl_status
= BINCL_NOT_REQUIRED
;
1189 current_file
= current_file
->next
;
1193 /* Handle a few odd cases that occur when trying to make PCH files work. */
1196 dbxout_handle_pch (unsigned at_end
)
1200 /* When using the PCH, this file will be included, so we need to output
1202 dbxout_start_source_file (0, lastfile
);
1204 /* The base file when using the PCH won't be the same as
1205 the base file when it's being generated. */
1210 /* ... and an EINCL. */
1211 dbxout_end_source_file (0);
1213 /* Deal with cases where 'lastfile' was never actually changed. */
1214 lastfile_is_base
= lastfile
== NULL
;
1218 #if defined (DBX_DEBUGGING_INFO)
1219 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
1222 dbxout_source_file (const char *filename
)
1224 if (lastfile
== 0 && lastfile_is_base
)
1226 lastfile
= base_input_file
;
1227 lastfile_is_base
= 0;
1230 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
1232 /* Don't change section amid function. */
1233 if (current_function_decl
== NULL_TREE
)
1236 dbxout_begin_simple_stabs (filename
, N_SOL
);
1237 dbxout_stab_value_internal_label ("Ltext", &source_label_number
);
1238 lastfile
= filename
;
1242 /* Output N_BNSYM and line number symbol entry. */
1245 dbxout_begin_prologue (unsigned int lineno
, const char *filename
)
1247 if (use_gnu_debug_info_extensions
1248 && !NO_DBX_FUNCTION_END
1249 && !NO_DBX_BNSYM_ENSYM
1250 && !flag_debug_only_used_symbols
)
1251 dbxout_stabd (N_BNSYM
, 0);
1253 dbxout_source_line (lineno
, filename
);
1256 /* Output a line number symbol entry for source file FILENAME and line
1260 dbxout_source_line (unsigned int lineno
, const char *filename
)
1262 dbxout_source_file (filename
);
1264 #ifdef DBX_OUTPUT_SOURCE_LINE
1265 DBX_OUTPUT_SOURCE_LINE (asm_out_file
, lineno
, dbxout_source_line_counter
);
1267 if (DBX_LINES_FUNCTION_RELATIVE
)
1269 rtx begin_label
= XEXP (DECL_RTL (current_function_decl
), 0);
1270 dbxout_begin_stabn_sline (lineno
);
1271 dbxout_stab_value_internal_label_diff ("LM", &dbxout_source_line_counter
,
1272 XSTR (begin_label
, 0));
1276 dbxout_stabd (N_SLINE
, lineno
);
1280 /* Describe the beginning of an internal block within a function. */
1283 dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED
, unsigned int n
)
1285 emit_pending_bincls_if_required ();
1286 targetm
.asm_out
.internal_label (asm_out_file
, "LBB", n
);
1289 /* Describe the end line-number of an internal block within a function. */
1292 dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED
, unsigned int n
)
1294 emit_pending_bincls_if_required ();
1295 targetm
.asm_out
.internal_label (asm_out_file
, "LBE", n
);
1298 /* Output dbx data for a function definition.
1299 This includes a definition of the function name itself (a symbol),
1300 definitions of the parameters (locating them in the parameter list)
1301 and then output the block that makes up the function's body
1302 (including all the auto variables of the function). */
1305 dbxout_function_decl (tree decl
)
1307 emit_pending_bincls_if_required ();
1308 #ifndef DBX_FUNCTION_FIRST
1309 dbxout_begin_function (decl
);
1311 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
1312 dbxout_function_end (decl
);
1315 #endif /* DBX_DEBUGGING_INFO */
1317 /* Debug information for a global DECL. Called from toplev.c after
1318 compilation proper has finished. */
1320 dbxout_global_decl (tree decl
)
1322 if (TREE_CODE (decl
) == VAR_DECL
1323 && ! DECL_EXTERNAL (decl
)
1324 && DECL_RTL_SET_P (decl
)) /* Not necessary? */
1326 int saved_tree_used
= TREE_USED (decl
);
1327 TREE_USED (decl
) = 1;
1328 dbxout_symbol (decl
, 0);
1329 TREE_USED (decl
) = saved_tree_used
;
1333 /* This is just a function-type adapter; dbxout_symbol does exactly
1334 what we want but returns an int. */
1336 dbxout_type_decl (tree decl
, int local
)
1338 dbxout_symbol (decl
, local
);
1341 /* At the end of compilation, finish writing the symbol table.
1342 The default is to call debug_free_queue but do nothing else. */
1345 dbxout_finish (const char *filename ATTRIBUTE_UNUSED
)
1347 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
1348 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asm_out_file
, filename
);
1349 #elif defined DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
1352 dbxout_begin_empty_stabs (N_SO
);
1353 dbxout_stab_value_internal_label ("Letext", 0);
1356 debug_free_queue ();
1359 /* Output the index of a type. */
1362 dbxout_type_index (tree type
)
1364 #ifndef DBX_USE_BINCL
1365 stabstr_D (TYPE_SYMTAB_ADDRESS (type
));
1367 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
1369 stabstr_D (t
->file_number
);
1371 stabstr_D (t
->type_number
);
1378 /* Used in several places: evaluates to '0' for a private decl,
1379 '1' for a protected decl, '2' for a public decl. */
1380 #define DECL_ACCESSIBILITY_CHAR(DECL) \
1381 (TREE_PRIVATE (DECL) ? '0' : TREE_PROTECTED (DECL) ? '1' : '2')
1383 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
1384 This must be a separate function because anonymous unions require
1388 dbxout_type_fields (tree type
)
1392 /* Output the name, type, position (in bits), size (in bits) of each
1393 field that we can support. */
1394 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
1396 /* If one of the nodes is an error_mark or its type is then
1398 if (tem
== error_mark_node
|| TREE_TYPE (tem
) == error_mark_node
)
1401 /* Omit here local type decls until we know how to support them. */
1402 if (TREE_CODE (tem
) == TYPE_DECL
1403 /* Omit here the nameless fields that are used to skip bits. */
1404 || DECL_IGNORED_P (tem
)
1405 /* Omit fields whose position or size are variable or too large to
1407 || (TREE_CODE (tem
) == FIELD_DECL
1408 && (! host_integerp (bit_position (tem
), 0)
1409 || ! DECL_SIZE (tem
)
1410 || ! host_integerp (DECL_SIZE (tem
), 1))))
1413 else if (TREE_CODE (tem
) != CONST_DECL
)
1415 /* Continue the line if necessary,
1416 but not before the first field. */
1417 if (tem
!= TYPE_FIELDS (type
))
1420 if (DECL_NAME (tem
))
1421 stabstr_I (DECL_NAME (tem
));
1424 if (use_gnu_debug_info_extensions
1425 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
1426 || TREE_CODE (tem
) != FIELD_DECL
))
1429 stabstr_C (DECL_ACCESSIBILITY_CHAR (tem
));
1432 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
1433 && DECL_BIT_FIELD_TYPE (tem
))
1434 ? DECL_BIT_FIELD_TYPE (tem
) : TREE_TYPE (tem
), 0);
1436 if (TREE_CODE (tem
) == VAR_DECL
)
1438 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
1440 tree name
= DECL_ASSEMBLER_NAME (tem
);
1447 /* If TEM is non-static, GDB won't understand it. */
1448 stabstr_S (",0,0;");
1453 stabstr_D (int_bit_position (tem
));
1455 stabstr_D (tree_low_cst (DECL_SIZE (tem
), 1));
1462 /* Subroutine of `dbxout_type_methods'. Output debug info about the
1463 method described DECL. */
1466 dbxout_type_method_1 (tree decl
)
1470 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
1472 else /* it's a METHOD_TYPE. */
1474 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
1475 /* A for normal functions.
1476 B for `const' member functions.
1477 C for `volatile' member functions.
1478 D for `const volatile' member functions. */
1479 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
1481 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
1484 if (DECL_VINDEX (decl
))
1490 /* ??? Output the mangled name, which contains an encoding of the
1491 method's type signature. May not be necessary anymore. */
1493 stabstr_I (DECL_ASSEMBLER_NAME (decl
));
1495 stabstr_C (DECL_ACCESSIBILITY_CHAR (decl
));
1499 if (DECL_VINDEX (decl
) && host_integerp (DECL_VINDEX (decl
), 0))
1501 stabstr_D (tree_low_cst (DECL_VINDEX (decl
), 0));
1503 dbxout_type (DECL_CONTEXT (decl
), 0);
1508 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
1512 dbxout_type_methods (tree type
)
1514 /* C++: put out the method names and their parameter lists */
1515 tree methods
= TYPE_METHODS (type
);
1519 if (methods
== NULL_TREE
)
1522 if (TREE_CODE (methods
) != TREE_VEC
)
1524 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
1525 fndecl
= TREE_VEC_ELT (methods
, 0);
1527 fndecl
= TREE_VEC_ELT (methods
, 1);
1531 int need_prefix
= 1;
1533 /* Group together all the methods for the same operation.
1534 These differ in the types of the arguments. */
1535 for (last
= NULL_TREE
;
1536 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
1537 fndecl
= TREE_CHAIN (fndecl
))
1538 /* Output the name of the field (after overloading), as
1539 well as the name of the field before overloading, along
1540 with its parameter list */
1542 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1543 include TEMPLATE_DECLs.) The debugger doesn't know what
1544 to do with such entities anyhow. */
1545 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
1552 /* Also ignore abstract methods; those are only interesting to
1553 the DWARF backends. */
1554 if (DECL_IGNORED_P (fndecl
) || DECL_ABSTRACT (fndecl
))
1557 /* Redundantly output the plain name, since that's what gdb
1561 stabstr_I (DECL_NAME (fndecl
));
1566 dbxout_type (TREE_TYPE (fndecl
), 0);
1567 dbxout_type_method_1 (fndecl
);
1574 /* Emit a "range" type specification, which has the form:
1575 "r<index type>;<lower bound>;<upper bound>;".
1576 TYPE is an INTEGER_TYPE. */
1579 dbxout_range_type (tree type
)
1582 if (TREE_TYPE (type
))
1583 dbxout_type (TREE_TYPE (type
), 0);
1584 else if (TREE_CODE (type
) != INTEGER_TYPE
)
1585 dbxout_type (type
, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1588 /* Traditionally, we made sure 'int' was type 1, and builtin types
1589 were defined to be sub-ranges of int. Unfortunately, this
1590 does not allow us to distinguish true sub-ranges from integer
1591 types. So, instead we define integer (non-sub-range) types as
1592 sub-ranges of themselves. This matters for Chill. If this isn't
1593 a subrange type, then we want to define it in terms of itself.
1594 However, in C, this may be an anonymous integer type, and we don't
1595 want to emit debug info referring to it. Just calling
1596 dbxout_type_index won't work anyways, because the type hasn't been
1597 defined yet. We make this work for both cases by checked to see
1598 whether this is a defined type, referring to it if it is, and using
1600 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
1601 dbxout_type_index (type
);
1603 dbxout_type_index (integer_type_node
);
1607 if (TYPE_MIN_VALUE (type
) != 0
1608 && host_integerp (TYPE_MIN_VALUE (type
), 0))
1610 if (print_int_cst_bounds_in_octal_p (type
))
1611 stabstr_O (TYPE_MIN_VALUE (type
));
1613 stabstr_D (tree_low_cst (TYPE_MIN_VALUE (type
), 0));
1619 if (TYPE_MAX_VALUE (type
) != 0
1620 && host_integerp (TYPE_MAX_VALUE (type
), 0))
1622 if (print_int_cst_bounds_in_octal_p (type
))
1623 stabstr_O (TYPE_MAX_VALUE (type
));
1625 stabstr_D (tree_low_cst (TYPE_MAX_VALUE (type
), 0));
1633 /* Output a reference to a type. If the type has not yet been
1634 described in the dbx output, output its definition now.
1635 For a type already defined, just refer to its definition
1636 using the type number.
1638 If FULL is nonzero, and the type has been described only with
1639 a forward-reference, output the definition now.
1640 If FULL is zero in this case, just refer to the forward-reference
1641 using the number previously allocated. */
1644 dbxout_type (tree type
, int full
)
1648 static int anonymous_type_number
= 0;
1649 bool vector_type
= false;
1651 if (TREE_CODE (type
) == VECTOR_TYPE
)
1653 /* The frontend feeds us a representation for the vector as a struct
1654 containing an array. Pull out the array type. */
1655 type
= TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type
)));
1659 /* If there was an input error and we don't really have a type,
1660 avoid crashing and write something that is at least valid
1661 by assuming `int'. */
1662 if (type
== error_mark_node
)
1663 type
= integer_type_node
;
1666 if (TYPE_NAME (type
)
1667 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1668 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
1672 /* Try to find the "main variant" with the same name. */
1673 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1674 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1675 main_variant
= TREE_TYPE (TYPE_NAME (type
));
1677 main_variant
= TYPE_MAIN_VARIANT (type
);
1679 /* If we are not using extensions, stabs does not distinguish const and
1680 volatile, so there is no need to make them separate types. */
1681 if (!use_gnu_debug_info_extensions
)
1682 type
= main_variant
;
1684 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
1686 /* Type has no dbx number assigned. Assign next available number. */
1687 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
1689 /* Make sure type vector is long enough to record about this type. */
1691 if (next_type_number
== typevec_len
)
1694 = ggc_realloc (typevec
, (typevec_len
* 2 * sizeof typevec
[0]));
1695 memset (typevec
+ typevec_len
, 0, typevec_len
* sizeof typevec
[0]);
1699 #ifdef DBX_USE_BINCL
1700 emit_pending_bincls_if_required ();
1701 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
1702 = current_file
->file_number
;
1703 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
1704 = current_file
->next_type_number
++;
1708 if (flag_debug_only_used_symbols
)
1710 if ((TREE_CODE (type
) == RECORD_TYPE
1711 || TREE_CODE (type
) == UNION_TYPE
1712 || TREE_CODE (type
) == QUAL_UNION_TYPE
1713 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1714 && TYPE_STUB_DECL (type
)
1715 && DECL_P (TYPE_STUB_DECL (type
))
1716 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type
)))
1717 debug_queue_symbol (TYPE_STUB_DECL (type
));
1718 else if (TYPE_NAME (type
)
1719 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1720 debug_queue_symbol (TYPE_NAME (type
));
1723 /* Output the number of this type, to refer to it. */
1724 dbxout_type_index (type
);
1726 #ifdef DBX_TYPE_DEFINED
1727 if (DBX_TYPE_DEFINED (type
))
1731 /* If this type's definition has been output or is now being output,
1734 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
1739 /* If we have already had a cross reference,
1740 and either that's all we want or that's the best we could do,
1741 don't repeat the cross reference.
1742 Sun dbx crashes if we do. */
1743 if (! full
|| !COMPLETE_TYPE_P (type
)
1744 /* No way in DBX fmt to describe a variable size. */
1745 || ! host_integerp (TYPE_SIZE (type
), 1))
1753 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1754 leave the type-number completely undefined rather than output
1755 a cross-reference. If we have already used GNU debug info extensions,
1756 then it is OK to output a cross reference. This is necessary to get
1757 proper C++ debug output. */
1758 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1759 || TREE_CODE (type
) == QUAL_UNION_TYPE
1760 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1761 && ! use_gnu_debug_info_extensions
)
1762 /* We must use the same test here as we use twice below when deciding
1763 whether to emit a cross-reference. */
1764 if ((TYPE_NAME (type
) != 0
1765 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1766 && DECL_IGNORED_P (TYPE_NAME (type
)))
1768 || !COMPLETE_TYPE_P (type
)
1769 /* No way in DBX fmt to describe a variable size. */
1770 || ! host_integerp (TYPE_SIZE (type
), 1))
1772 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1777 /* Output a definition now. */
1780 /* Mark it as defined, so that if it is self-referent
1781 we will not get into an infinite recursion of definitions. */
1783 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1785 /* If this type is a variant of some other, hand off. Types with
1786 different names are usefully distinguished. We only distinguish
1787 cv-qualified types if we're using extensions. */
1788 if (TYPE_READONLY (type
) > TYPE_READONLY (main_variant
))
1791 dbxout_type (build_type_variant (type
, 0, TYPE_VOLATILE (type
)), 0);
1794 else if (TYPE_VOLATILE (type
) > TYPE_VOLATILE (main_variant
))
1797 dbxout_type (build_type_variant (type
, TYPE_READONLY (type
), 0), 0);
1800 else if (main_variant
!= TYPE_MAIN_VARIANT (type
))
1802 if (flag_debug_only_used_symbols
)
1804 tree orig_type
= DECL_ORIGINAL_TYPE (TYPE_NAME (type
));
1806 if ((TREE_CODE (orig_type
) == RECORD_TYPE
1807 || TREE_CODE (orig_type
) == UNION_TYPE
1808 || TREE_CODE (orig_type
) == QUAL_UNION_TYPE
1809 || TREE_CODE (orig_type
) == ENUMERAL_TYPE
)
1810 && TYPE_STUB_DECL (orig_type
)
1811 && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type
)))
1812 debug_queue_symbol (TYPE_STUB_DECL (orig_type
));
1814 /* 'type' is a typedef; output the type it refers to. */
1815 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0);
1818 /* else continue. */
1820 switch (TREE_CODE (type
))
1824 /* For a void type, just define it as itself; i.e., "5=5".
1825 This makes us consider it defined
1826 without saying what it is. The debugger will make it
1827 a void type when the reference is seen, and nothing will
1828 ever override that default. */
1829 dbxout_type_index (type
);
1833 if (type
== char_type_node
&& ! TYPE_UNSIGNED (type
))
1835 /* Output the type `char' as a subrange of itself!
1836 I don't understand this definition, just copied it
1837 from the output of pcc.
1838 This used to use `r2' explicitly and we used to
1839 take care to make sure that `char' was type number 2. */
1841 dbxout_type_index (type
);
1842 stabstr_S (";0;127;");
1845 /* If this is a subtype of another integer type, always prefer to
1846 write it as a subtype. */
1847 else if (TREE_TYPE (type
) != 0
1848 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_TYPE
)
1850 /* If the size is non-standard, say what it is if we can use
1853 if (use_gnu_debug_info_extensions
1854 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1857 stabstr_D (TYPE_PRECISION (type
));
1861 dbxout_range_type (type
);
1866 /* If the size is non-standard, say what it is if we can use
1869 if (use_gnu_debug_info_extensions
1870 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1873 stabstr_D (TYPE_PRECISION (type
));
1877 if (print_int_cst_bounds_in_octal_p (type
))
1881 /* If this type derives from another type, output type index of
1882 parent type. This is particularly important when parent type
1883 is an enumerated type, because not generating the parent type
1884 index would transform the definition of this enumerated type
1885 into a plain unsigned type. */
1886 if (TREE_TYPE (type
) != 0)
1887 dbxout_type_index (TREE_TYPE (type
));
1889 dbxout_type_index (type
);
1892 stabstr_O (TYPE_MIN_VALUE (type
));
1894 stabstr_O (TYPE_MAX_VALUE (type
));
1899 /* Output other integer types as subranges of `int'. */
1900 dbxout_range_type (type
);
1906 /* This used to say `r1' and we used to take care
1907 to make sure that `int' was type number 1. */
1909 dbxout_type_index (integer_type_node
);
1911 stabstr_D (int_size_in_bytes (type
));
1916 if (use_gnu_debug_info_extensions
)
1919 stabstr_D (BITS_PER_UNIT
* int_size_in_bytes (type
));
1920 stabstr_S (";-20;");
1924 /* Output the type `char' as a subrange of itself.
1925 That is what pcc seems to do. */
1927 dbxout_type_index (char_type_node
);
1928 stabstr_S (TYPE_UNSIGNED (type
) ? ";0;255;" : ";0;127;");
1933 if (use_gnu_debug_info_extensions
)
1936 stabstr_D (BITS_PER_UNIT
* int_size_in_bytes (type
));
1937 stabstr_S (";-16;");
1939 else /* Define as enumeral type (False, True) */
1940 stabstr_S ("eFalse:0,True:1,;");
1944 /* Differs from the REAL_TYPE by its new data type number.
1945 R3 is NF_COMPLEX. We don't try to use any of the other NF_*
1946 codes since gdb doesn't care anyway. */
1948 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1951 stabstr_D (2 * int_size_in_bytes (TREE_TYPE (type
)));
1956 /* Output a complex integer type as a structure,
1957 pending some other way to do it. */
1959 stabstr_D (int_size_in_bytes (type
));
1961 stabstr_S ("real:");
1962 dbxout_type (TREE_TYPE (type
), 0);
1964 stabstr_D (TYPE_PRECISION (TREE_TYPE (type
)));
1966 stabstr_S (";imag:");
1967 dbxout_type (TREE_TYPE (type
), 0);
1969 stabstr_D (TYPE_PRECISION (TREE_TYPE (type
)));
1971 stabstr_D (TYPE_PRECISION (TREE_TYPE (type
)));
1977 /* Make arrays of packed bits look like bitstrings for chill. */
1978 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1981 stabstr_D (BITS_PER_UNIT
* int_size_in_bytes (type
));
1982 stabstr_S (";@S;S");
1983 dbxout_type (TYPE_DOMAIN (type
), 0);
1987 if (use_gnu_debug_info_extensions
&& vector_type
)
1990 /* Output "a" followed by a range type definition
1991 for the index type of the array
1992 followed by a reference to the target-type.
1993 ar1;0;N;M for a C array of type M and size N+1. */
1994 /* Check if a character string type, which in Chill is
1995 different from an array of characters. */
1996 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
2000 tem
= TYPE_DOMAIN (type
);
2004 dbxout_type_index (integer_type_node
);
2005 stabstr_S (";0;-1;");
2010 dbxout_range_type (tem
);
2013 dbxout_type (TREE_TYPE (type
), 0);
2018 case QUAL_UNION_TYPE
:
2020 tree binfo
= TYPE_BINFO (type
);
2022 /* Output a structure type. We must use the same test here as we
2023 use in the DBX_NO_XREFS case above. */
2024 if ((TYPE_NAME (type
) != 0
2025 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
2026 && DECL_IGNORED_P (TYPE_NAME (type
)))
2028 || !COMPLETE_TYPE_P (type
)
2029 /* No way in DBX fmt to describe a variable size. */
2030 || ! host_integerp (TYPE_SIZE (type
), 1))
2032 /* If the type is just a cross reference, output one
2033 and mark the type as partially described.
2034 If it later becomes defined, we will output
2035 its real definition.
2036 If the type has a name, don't nest its definition within
2037 another type's definition; instead, output an xref
2038 and let the definition come when the name is defined. */
2039 stabstr_S ((TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu");
2040 if (TYPE_NAME (type
) != 0)
2041 dbxout_type_name (type
);
2045 stabstr_D (anonymous_type_number
++);
2049 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
2053 /* Identify record or union, and print its size. */
2054 stabstr_C ((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u');
2055 stabstr_D (int_size_in_bytes (type
));
2061 VEC(tree
,gc
) *accesses
= BINFO_BASE_ACCESSES (binfo
);
2063 if (use_gnu_debug_info_extensions
)
2065 if (BINFO_N_BASE_BINFOS (binfo
))
2068 stabstr_U (BINFO_N_BASE_BINFOS (binfo
));
2072 for (i
= 0; BINFO_BASE_ITERATE (binfo
, i
, child
); i
++)
2074 tree access
= (accesses
? VEC_index (tree
, accesses
, i
)
2075 : access_public_node
);
2077 if (use_gnu_debug_info_extensions
)
2079 stabstr_C (BINFO_VIRTUAL_P (child
) ? '1' : '0');
2080 stabstr_C (access
== access_public_node
? '2' :
2081 access
== access_protected_node
2083 if (BINFO_VIRTUAL_P (child
)
2084 && strcmp (lang_hooks
.name
, "GNU C++") == 0)
2085 /* For a virtual base, print the (negative)
2086 offset within the vtable where we must look
2087 to find the necessary adjustment. */
2089 (tree_low_cst (BINFO_VPTR_FIELD (child
), 0)
2092 stabstr_D (tree_low_cst (BINFO_OFFSET (child
), 0)
2095 dbxout_type (BINFO_TYPE (child
), 0);
2100 /* Print out the base class information with
2101 fields which have the same names at the types
2103 dbxout_type_name (BINFO_TYPE (child
));
2105 dbxout_type (BINFO_TYPE (child
), full
);
2107 stabstr_D (tree_low_cst (BINFO_OFFSET (child
), 0)
2111 (tree_low_cst (TYPE_SIZE (BINFO_TYPE (child
)), 0)
2119 /* Write out the field declarations. */
2120 dbxout_type_fields (type
);
2121 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
2123 dbxout_type_methods (type
);
2128 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
2129 /* Avoid the ~ if we don't really need it--it confuses dbx. */
2130 && TYPE_VFIELD (type
))
2133 /* We need to write out info about what field this class
2134 uses as its "main" vtable pointer field, because if this
2135 field is inherited from a base class, GDB cannot necessarily
2136 figure out which field it's using in time. */
2138 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0);
2144 /* We must use the same test here as we use in the DBX_NO_XREFS case
2145 above. We simplify it a bit since an enum will never have a variable
2147 if ((TYPE_NAME (type
) != 0
2148 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
2149 && DECL_IGNORED_P (TYPE_NAME (type
)))
2151 || !COMPLETE_TYPE_P (type
))
2154 dbxout_type_name (type
);
2155 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
2159 if (use_gnu_debug_info_extensions
2160 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
2163 stabstr_D (TYPE_PRECISION (type
));
2168 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
2170 stabstr_I (TREE_PURPOSE (tem
));
2173 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
2174 stabstr_D (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
2175 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
2176 && (HOST_WIDE_INT
) TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
2177 stabstr_D (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
2179 stabstr_O (TREE_VALUE (tem
));
2182 if (TREE_CHAIN (tem
) != 0)
2191 dbxout_type (TREE_TYPE (type
), 0);
2195 if (use_gnu_debug_info_extensions
)
2199 /* Write the argument types out longhand. */
2200 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0);
2202 dbxout_type (TREE_TYPE (type
), 0);
2203 dbxout_args (TYPE_ARG_TYPES (type
));
2207 /* Treat it as a function type. */
2208 dbxout_type (TREE_TYPE (type
), 0);
2212 if (use_gnu_debug_info_extensions
)
2215 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0);
2217 dbxout_type (TREE_TYPE (type
), 0);
2220 /* Should print as an int, because it is really just an offset. */
2221 dbxout_type (integer_type_node
, 0);
2224 case REFERENCE_TYPE
:
2225 if (use_gnu_debug_info_extensions
)
2231 dbxout_type (TREE_TYPE (type
), 0);
2236 dbxout_type (TREE_TYPE (type
), 0);
2244 /* Return nonzero if the given type represents an integer whose bounds
2245 should be printed in octal format. */
2248 print_int_cst_bounds_in_octal_p (tree type
)
2250 /* If we can use GDB extensions and the size is wider than a long
2251 (the size used by GDB to read them) or we may have trouble writing
2252 the bounds the usual way, write them in octal. Note the test is for
2253 the *target's* size of "long", not that of the host. The host test
2254 is just to make sure we can write it out in case the host wide int
2255 is narrower than the target "long".
2257 For unsigned types, we use octal if they are the same size or larger.
2258 This is because we print the bounds as signed decimal, and hence they
2259 can't span same size unsigned types. */
2261 if (use_gnu_debug_info_extensions
2262 && TYPE_MIN_VALUE (type
) != 0
2263 && TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
2264 && TYPE_MAX_VALUE (type
) != 0
2265 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
2266 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
2267 || ((TYPE_PRECISION (type
) == TYPE_PRECISION (integer_type_node
))
2268 && TYPE_UNSIGNED (type
))
2269 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
2270 || (TYPE_PRECISION (type
) == HOST_BITS_PER_WIDE_INT
2271 && TYPE_UNSIGNED (type
))))
2277 /* Output the name of type TYPE, with no punctuation.
2278 Such names can be set up either by typedef declarations
2279 or by struct, enum and union tags. */
2282 dbxout_type_name (tree type
)
2284 tree t
= TYPE_NAME (type
);
2287 switch (TREE_CODE (t
))
2289 case IDENTIFIER_NODE
:
2301 /* Output leading leading struct or class names needed for qualifying
2302 type whose scope is limited to a struct or class. */
2305 dbxout_class_name_qualifiers (tree decl
)
2307 tree context
= decl_type_context (decl
);
2309 if (context
!= NULL_TREE
2310 && TREE_CODE(context
) == RECORD_TYPE
2311 && TYPE_NAME (context
) != 0
2312 && (TREE_CODE (TYPE_NAME (context
)) == IDENTIFIER_NODE
2313 || (DECL_NAME (TYPE_NAME (context
)) != 0)))
2315 tree name
= TYPE_NAME (context
);
2317 if (TREE_CODE (name
) == TYPE_DECL
)
2319 dbxout_class_name_qualifiers (name
);
2320 name
= DECL_NAME (name
);
2327 /* Output a .stabs for the symbol defined by DECL,
2328 which must be a ..._DECL node in the normal namespace.
2329 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
2330 LOCAL is nonzero if the scope is less than the entire file.
2331 Return 1 if a stabs might have been emitted. */
2334 dbxout_symbol (tree decl
, int local ATTRIBUTE_UNUSED
)
2336 tree type
= TREE_TYPE (decl
);
2337 tree context
= NULL_TREE
;
2340 /* "Intercept" dbxout_symbol() calls like we do all debug_hooks. */
2343 /* Ignore nameless syms, but don't ignore type tags. */
2345 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
2346 || DECL_IGNORED_P (decl
))
2347 DBXOUT_DECR_NESTING_AND_RETURN (0);
2349 /* If we are to generate only the symbols actually used then such
2350 symbol nodes are flagged with TREE_USED. Ignore any that
2351 aren't flaged as TREE_USED. */
2353 if (flag_debug_only_used_symbols
2354 && (!TREE_USED (decl
)
2355 && (TREE_CODE (decl
) != VAR_DECL
|| !DECL_INITIAL (decl
))))
2356 DBXOUT_DECR_NESTING_AND_RETURN (0);
2358 /* If dbxout_init has not yet run, queue this symbol for later. */
2361 preinit_symbols
= tree_cons (0, decl
, preinit_symbols
);
2362 DBXOUT_DECR_NESTING_AND_RETURN (0);
2365 if (flag_debug_only_used_symbols
)
2369 /* We now have a used symbol. We need to generate the info for
2370 the symbol's type in addition to the symbol itself. These
2371 type symbols are queued to be generated after were done with
2372 the symbol itself (otherwise they would fight over the
2375 Note, because the TREE_TYPE(type) might be something like a
2376 pointer to a named type we need to look for the first name
2377 we see following the TREE_TYPE chain. */
2380 while (POINTER_TYPE_P (t
))
2383 /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE
2384 need special treatment. The TYPE_STUB_DECL field in these
2385 types generally represents the tag name type we want to
2386 output. In addition there could be a typedef type with
2387 a different name. In that case we also want to output
2390 if (TREE_CODE (t
) == RECORD_TYPE
2391 || TREE_CODE (t
) == UNION_TYPE
2392 || TREE_CODE (t
) == QUAL_UNION_TYPE
2393 || TREE_CODE (t
) == ENUMERAL_TYPE
)
2395 if (TYPE_STUB_DECL (t
)
2396 && TYPE_STUB_DECL (t
) != decl
2397 && DECL_P (TYPE_STUB_DECL (t
))
2398 && ! DECL_IGNORED_P (TYPE_STUB_DECL (t
)))
2400 debug_queue_symbol (TYPE_STUB_DECL (t
));
2402 && TYPE_NAME (t
) != TYPE_STUB_DECL (t
)
2403 && TYPE_NAME (t
) != decl
2404 && DECL_P (TYPE_NAME (t
)))
2405 debug_queue_symbol (TYPE_NAME (t
));
2408 else if (TYPE_NAME (t
)
2409 && TYPE_NAME (t
) != decl
2410 && DECL_P (TYPE_NAME (t
)))
2411 debug_queue_symbol (TYPE_NAME (t
));
2414 emit_pending_bincls_if_required ();
2416 switch (TREE_CODE (decl
))
2419 /* Enum values are defined by defining the enum type. */
2423 if (DECL_RTL (decl
) == 0)
2424 DBXOUT_DECR_NESTING_AND_RETURN (0);
2425 if (DECL_EXTERNAL (decl
))
2427 /* Don't mention a nested function under its parent. */
2428 context
= decl_function_context (decl
);
2429 if (context
== current_function_decl
)
2431 /* Don't mention an inline instance of a nested function. */
2432 if (context
&& DECL_FROM_INLINE (decl
))
2434 if (!MEM_P (DECL_RTL (decl
))
2435 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
2438 dbxout_begin_complex_stabs ();
2439 stabstr_I (DECL_ASSEMBLER_NAME (decl
));
2440 stabstr_S (TREE_PUBLIC (decl
) ? ":F" : ":f");
2443 if (TREE_TYPE (type
))
2444 dbxout_type (TREE_TYPE (type
), 0);
2446 dbxout_type (void_type_node
, 0);
2448 /* For a nested function, when that function is compiled,
2449 mention the containing function name
2450 as well as (since dbx wants it) our own assembler-name. */
2454 stabstr_I (DECL_ASSEMBLER_NAME (decl
));
2456 stabstr_I (DECL_NAME (context
));
2459 dbxout_finish_complex_stabs (decl
, N_FUN
, XEXP (DECL_RTL (decl
), 0),
2464 /* Don't output the same typedef twice.
2465 And don't output what language-specific stuff doesn't want output. */
2466 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
2467 DBXOUT_DECR_NESTING_AND_RETURN (0);
2469 /* Don't output typedefs for types with magic type numbers (XCOFF). */
2470 #ifdef DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER
2472 int fundamental_type_number
=
2473 DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER (decl
);
2475 if (fundamental_type_number
!= 0)
2477 TREE_ASM_WRITTEN (decl
) = 1;
2478 TYPE_SYMTAB_ADDRESS (TREE_TYPE (decl
)) = fundamental_type_number
;
2479 DBXOUT_DECR_NESTING_AND_RETURN (0);
2489 if (DECL_NAME (decl
))
2491 /* Nonzero means we must output a tag as well as a typedef. */
2494 /* Handle the case of a C++ structure or union
2495 where the TYPE_NAME is a TYPE_DECL
2496 which gives both a typedef name and a tag. */
2497 /* dbx requires the tag first and the typedef second. */
2498 if ((TREE_CODE (type
) == RECORD_TYPE
2499 || TREE_CODE (type
) == UNION_TYPE
2500 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2501 && TYPE_NAME (type
) == decl
2502 && !use_gnu_debug_info_extensions
2503 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
2504 /* Distinguish the implicit typedefs of C++
2505 from explicit ones that might be found in C. */
2506 && DECL_ARTIFICIAL (decl
)
2507 /* Do not generate a tag for incomplete records. */
2508 && COMPLETE_TYPE_P (type
)
2509 /* Do not generate a tag for records of variable size,
2510 since this type can not be properly described in the
2511 DBX format, and it confuses some tools such as objdump. */
2512 && host_integerp (TYPE_SIZE (type
), 1))
2514 tree name
= TYPE_NAME (type
);
2515 if (TREE_CODE (name
) == TYPE_DECL
)
2516 name
= DECL_NAME (name
);
2518 dbxout_begin_complex_stabs ();
2521 dbxout_type (type
, 1);
2522 dbxout_finish_complex_stabs (0, DBX_TYPE_DECL_STABS_CODE
,
2526 dbxout_begin_complex_stabs ();
2528 /* Output leading class/struct qualifiers. */
2529 if (use_gnu_debug_info_extensions
)
2530 dbxout_class_name_qualifiers (decl
);
2532 /* Output typedef name. */
2533 stabstr_I (DECL_NAME (decl
));
2536 /* Short cut way to output a tag also. */
2537 if ((TREE_CODE (type
) == RECORD_TYPE
2538 || TREE_CODE (type
) == UNION_TYPE
2539 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2540 && TYPE_NAME (type
) == decl
2541 /* Distinguish the implicit typedefs of C++
2542 from explicit ones that might be found in C. */
2543 && DECL_ARTIFICIAL (decl
))
2545 if (use_gnu_debug_info_extensions
)
2548 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
2553 dbxout_type (type
, 1);
2554 dbxout_finish_complex_stabs (decl
, DBX_TYPE_DECL_STABS_CODE
,
2559 /* Don't output a tag if this is an incomplete type. This prevents
2560 the sun4 Sun OS 4.x dbx from crashing. */
2562 if (tag_needed
&& TYPE_NAME (type
) != 0
2563 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
2564 || (DECL_NAME (TYPE_NAME (type
)) != 0))
2565 && COMPLETE_TYPE_P (type
)
2566 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
2568 /* For a TYPE_DECL with no name, but the type has a name,
2570 This is what represents `struct foo' with no typedef. */
2571 /* In C++, the name of a type is the corresponding typedef.
2572 In C, it is an IDENTIFIER_NODE. */
2573 tree name
= TYPE_NAME (type
);
2574 if (TREE_CODE (name
) == TYPE_DECL
)
2575 name
= DECL_NAME (name
);
2577 dbxout_begin_complex_stabs ();
2580 dbxout_type (type
, 1);
2581 dbxout_finish_complex_stabs (0, DBX_TYPE_DECL_STABS_CODE
, 0, 0, 0);
2585 /* If an enum type has no name, it cannot be referred to, but
2586 we must output it anyway, to record the enumeration
2589 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
2591 dbxout_begin_complex_stabs ();
2592 /* Some debuggers fail when given NULL names, so give this a
2593 harmless name of " " (Why not "(anon)"?). */
2595 dbxout_type (type
, 1);
2596 dbxout_finish_complex_stabs (0, DBX_TYPE_DECL_STABS_CODE
, 0, 0, 0);
2599 /* Prevent duplicate output of a typedef. */
2600 TREE_ASM_WRITTEN (decl
) = 1;
2605 /* Parm decls go in their own separate chains
2606 and are output by dbxout_reg_parms and dbxout_parms. */
2610 /* Named return value, treat like a VAR_DECL. */
2612 if (! DECL_RTL_SET_P (decl
))
2613 DBXOUT_DECR_NESTING_AND_RETURN (0);
2614 /* Don't mention a variable that is external.
2615 Let the file that defines it describe it. */
2616 if (DECL_EXTERNAL (decl
))
2619 /* If the variable is really a constant
2620 and not written in memory, inform the debugger.
2622 ??? Why do we skip emitting the type and location in this case? */
2623 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
2624 && DECL_INITIAL (decl
) != 0
2625 && host_integerp (DECL_INITIAL (decl
), 0)
2626 && ! TREE_ASM_WRITTEN (decl
)
2627 && (DECL_CONTEXT (decl
) == NULL_TREE
2628 || TREE_CODE (DECL_CONTEXT (decl
)) == BLOCK
)
2629 && TREE_PUBLIC (decl
) == 0)
2631 /* The sun4 assembler does not grok this. */
2633 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
2634 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
2636 HOST_WIDE_INT ival
= TREE_INT_CST_LOW (DECL_INITIAL (decl
));
2638 dbxout_begin_complex_stabs ();
2639 stabstr_I (DECL_NAME (decl
));
2642 dbxout_finish_complex_stabs (0, N_LSYM
, 0, 0, 0);
2643 DBXOUT_DECR_NESTING
;
2649 /* else it is something we handle like a normal variable. */
2651 SET_DECL_RTL (decl
, eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
2652 #ifdef LEAF_REG_REMAP
2653 if (current_function_uses_only_leaf_regs
)
2654 leaf_renumber_regs_insn (DECL_RTL (decl
));
2657 result
= dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
2663 DBXOUT_DECR_NESTING
;
2667 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2668 Add SUFFIX to its name, if SUFFIX is not 0.
2669 Describe the variable as residing in HOME
2670 (usually HOME is DECL_RTL (DECL), but not always).
2671 Returns 1 if the stab was really emitted. */
2674 dbxout_symbol_location (tree decl
, tree type
, const char *suffix
, rtx home
)
2677 STAB_CODE_TYPE code
;
2682 /* Don't mention a variable at all
2683 if it was completely optimized into nothingness.
2685 If the decl was from an inline function, then its rtl
2686 is not identically the rtl that was used in this
2687 particular compilation. */
2688 if (GET_CODE (home
) == SUBREG
)
2692 while (GET_CODE (value
) == SUBREG
)
2693 value
= SUBREG_REG (value
);
2696 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
2699 home
= alter_subreg (&home
);
2703 regno
= REGNO (home
);
2704 if (regno
>= FIRST_PSEUDO_REGISTER
)
2708 /* The kind-of-variable letter depends on where
2709 the variable is and on the scope of its name:
2710 G and N_GSYM for static storage and global scope,
2711 S for static storage and file scope,
2712 V for static storage and local scope,
2713 for those two, use N_LCSYM if data is in bss segment,
2714 N_STSYM if in data segment, N_FUN otherwise.
2715 (We used N_FUN originally, then changed to N_STSYM
2716 to please GDB. However, it seems that confused ld.
2717 Now GDB has been fixed to like N_FUN, says Kingdon.)
2718 no letter at all, and N_LSYM, for auto variable,
2719 r and N_RSYM for register variable. */
2721 if (MEM_P (home
) && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
2723 if (TREE_PUBLIC (decl
))
2730 addr
= XEXP (home
, 0);
2732 letter
= decl_function_context (decl
) ? 'V' : 'S';
2734 /* Some ports can transform a symbol ref into a label ref,
2735 because the symbol ref is too far away and has to be
2736 dumped into a constant pool. Alternatively, the symbol
2737 in the constant pool might be referenced by a different
2739 if (GET_CODE (addr
) == SYMBOL_REF
2740 && CONSTANT_POOL_ADDRESS_P (addr
))
2743 rtx tmp
= get_pool_constant_mark (addr
, &marked
);
2745 if (GET_CODE (tmp
) == SYMBOL_REF
)
2748 if (CONSTANT_POOL_ADDRESS_P (addr
))
2749 get_pool_constant_mark (addr
, &marked
);
2753 else if (GET_CODE (tmp
) == LABEL_REF
)
2759 /* If all references to the constant pool were optimized
2760 out, we just ignore the symbol. */
2765 /* This should be the same condition as in assemble_variable, but
2766 we don't have access to dont_output_data here. So, instead,
2767 we rely on the fact that error_mark_node initializers always
2768 end up in bss for C++ and never end up in bss for C. */
2769 if (DECL_INITIAL (decl
) == 0
2770 || (!strcmp (lang_hooks
.name
, "GNU C++")
2771 && DECL_INITIAL (decl
) == error_mark_node
))
2773 else if (DECL_IN_TEXT_SECTION (decl
))
2774 /* This is not quite right, but it's the closest
2775 of all the codes that Unix defines. */
2776 code
= DBX_STATIC_CONST_VAR_CODE
;
2779 /* Ultrix `as' seems to need this. */
2780 #ifdef DBX_STATIC_STAB_DATA_SECTION
2787 else if (regno
>= 0)
2791 number
= DBX_REGISTER_NUMBER (regno
);
2793 else if (MEM_P (home
)
2794 && (MEM_P (XEXP (home
, 0))
2795 || (REG_P (XEXP (home
, 0))
2796 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
2797 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
2798 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2799 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
2802 /* If the value is indirect by memory or by a register
2803 that isn't the frame pointer
2804 then it means the object is variable-sized and address through
2805 that register or stack slot. DBX has no way to represent this
2806 so all we can do is output the variable as a pointer.
2807 If it's not a parameter, ignore it. */
2809 if (REG_P (XEXP (home
, 0)))
2813 if (REGNO (XEXP (home
, 0)) >= FIRST_PSEUDO_REGISTER
)
2815 number
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
2820 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2821 We want the value of that CONST_INT. */
2822 number
= DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2825 /* Effectively do build_pointer_type, but don't cache this type,
2826 since it might be temporary whereas the type it points to
2827 might have been saved for inlining. */
2828 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2829 type
= make_node (POINTER_TYPE
);
2830 TREE_TYPE (type
) = TREE_TYPE (decl
);
2832 else if (MEM_P (home
)
2833 && REG_P (XEXP (home
, 0)))
2836 number
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2838 else if (MEM_P (home
)
2839 && GET_CODE (XEXP (home
, 0)) == PLUS
2840 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2843 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2844 We want the value of that CONST_INT. */
2845 number
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2847 else if (MEM_P (home
)
2848 && GET_CODE (XEXP (home
, 0)) == CONST
)
2850 /* Handle an obscure case which can arise when optimizing and
2851 when there are few available registers. (This is *always*
2852 the case for i386/i486 targets). The RTL looks like
2853 (MEM (CONST ...)) even though this variable is a local `auto'
2854 or a local `register' variable. In effect, what has happened
2855 is that the reload pass has seen that all assignments and
2856 references for one such a local variable can be replaced by
2857 equivalent assignments and references to some static storage
2858 variable, thereby avoiding the need for a register. In such
2859 cases we're forced to lie to debuggers and tell them that
2860 this variable was itself `static'. */
2863 addr
= XEXP (XEXP (home
, 0), 0);
2865 else if (GET_CODE (home
) == CONCAT
)
2869 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2870 for example), then there is no easy way to figure out
2871 what SUBTYPE should be. So, we give up. */
2872 if (TREE_CODE (type
) != COMPLEX_TYPE
)
2875 subtype
= TREE_TYPE (type
);
2877 /* If the variable's storage is in two parts,
2878 output each as a separate stab with a modified name. */
2879 if (WORDS_BIG_ENDIAN
)
2880 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2882 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2884 if (WORDS_BIG_ENDIAN
)
2885 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2887 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2891 /* Address might be a MEM, when DECL is a variable-sized object.
2892 Or it might be const0_rtx, meaning previous passes
2893 want us to ignore this variable. */
2896 /* Ok, start a symtab entry and output the variable name. */
2897 emit_pending_bincls_if_required ();
2900 #ifdef DBX_STATIC_BLOCK_START
2901 DBX_STATIC_BLOCK_START (asm_out_file
, code
);
2904 dbxout_begin_complex_stabs_noforcetext ();
2905 dbxout_symbol_name (decl
, suffix
, letter
);
2906 dbxout_type (type
, 0);
2907 dbxout_finish_complex_stabs (decl
, code
, addr
, 0, number
);
2909 #ifdef DBX_STATIC_BLOCK_END
2910 DBX_STATIC_BLOCK_END (asm_out_file
, code
);
2915 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2916 Then output LETTER to indicate the kind of location the symbol has. */
2919 dbxout_symbol_name (tree decl
, const char *suffix
, int letter
)
2923 if (DECL_CONTEXT (decl
)
2924 && (TYPE_P (DECL_CONTEXT (decl
))
2925 || TREE_CODE (DECL_CONTEXT (decl
)) == NAMESPACE_DECL
))
2926 /* One slight hitch: if this is a VAR_DECL which is a class member
2927 or a namespace member, we must put out the mangled name instead of the
2928 DECL_NAME. Note also that static member (variable) names DO NOT begin
2929 with underscores in .stabs directives. */
2930 name
= DECL_ASSEMBLER_NAME (decl
);
2932 /* ...but if we're function-local, we don't want to include the junk
2933 added by ASM_FORMAT_PRIVATE_NAME. */
2934 name
= DECL_NAME (decl
);
2939 stabstr_S ("(anon)");
2948 /* Output definitions of all the decls in a chain. Return nonzero if
2949 anything was output */
2952 dbxout_syms (tree syms
)
2957 result
+= dbxout_symbol (syms
, 1);
2958 syms
= TREE_CHAIN (syms
);
2963 /* The following two functions output definitions of function parameters.
2964 Each parameter gets a definition locating it in the parameter list.
2965 Each parameter that is a register variable gets a second definition
2966 locating it in the register.
2968 Printing or argument lists in gdb uses the definitions that
2969 locate in the parameter list. But reference to the variable in
2970 expressions uses preferentially the definition as a register. */
2972 /* Output definitions, referring to storage in the parmlist,
2973 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2976 dbxout_parms (tree parms
)
2979 emit_pending_bincls_if_required ();
2981 for (; parms
; parms
= TREE_CHAIN (parms
))
2982 if (DECL_NAME (parms
)
2983 && TREE_TYPE (parms
) != error_mark_node
2984 && DECL_RTL_SET_P (parms
)
2985 && DECL_INCOMING_RTL (parms
))
2989 STAB_CODE_TYPE code
;
2992 /* Perform any necessary register eliminations on the parameter's rtl,
2993 so that the debugging output will be accurate. */
2994 DECL_INCOMING_RTL (parms
)
2995 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
2996 SET_DECL_RTL (parms
, eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
2997 #ifdef LEAF_REG_REMAP
2998 if (current_function_uses_only_leaf_regs
)
3000 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
3001 leaf_renumber_regs_insn (DECL_RTL (parms
));
3005 if (PARM_PASSED_IN_MEMORY (parms
))
3007 rtx inrtl
= XEXP (DECL_INCOMING_RTL (parms
), 0);
3009 /* ??? Here we assume that the parm address is indexed
3010 off the frame pointer or arg pointer.
3011 If that is not true, we produce meaningless results,
3012 but do not crash. */
3013 if (GET_CODE (inrtl
) == PLUS
3014 && GET_CODE (XEXP (inrtl
, 1)) == CONST_INT
)
3015 number
= INTVAL (XEXP (inrtl
, 1));
3020 number
= DEBUGGER_ARG_OFFSET (number
, inrtl
);
3023 /* It is quite tempting to use TREE_TYPE (parms) instead
3024 of DECL_ARG_TYPE (parms) for the eff_type, so that gcc
3025 reports the actual type of the parameter, rather than
3026 the promoted type. This certainly makes GDB's life
3027 easier, at least for some ports. The change is a bad
3028 idea however, since GDB expects to be able access the
3029 type without performing any conversions. So for
3030 example, if we were passing a float to an unprototyped
3031 function, gcc will store a double on the stack, but if
3032 we emit a stab saying the type is a float, then gdb
3033 will only read in a single value, and this will produce
3034 an erroneous value. */
3035 eff_type
= DECL_ARG_TYPE (parms
);
3037 else if (REG_P (DECL_RTL (parms
)))
3041 /* Parm passed in registers and lives in registers or nowhere. */
3042 code
= DBX_REGPARM_STABS_CODE
;
3043 letter
= DBX_REGPARM_STABS_LETTER
;
3045 /* For parms passed in registers, it is better to use the
3046 declared type of the variable, not the type it arrived in. */
3047 eff_type
= TREE_TYPE (parms
);
3049 /* If parm lives in a register, use that register; pretend
3050 the parm was passed there. It would be more consistent
3051 to describe the register where the parm was passed, but
3052 in practice that register usually holds something else.
3053 If the parm lives nowhere, use the register where it
3055 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
3056 best_rtl
= DECL_RTL (parms
);
3058 best_rtl
= DECL_INCOMING_RTL (parms
);
3060 number
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
3062 else if (MEM_P (DECL_RTL (parms
))
3063 && REG_P (XEXP (DECL_RTL (parms
), 0))
3064 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
3065 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
3066 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
3067 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
3071 /* Parm was passed via invisible reference.
3072 That is, its address was passed in a register.
3073 Output it as if it lived in that register.
3074 The debugger will know from the type
3075 that it was actually passed by invisible reference. */
3077 code
= DBX_REGPARM_STABS_CODE
;
3079 /* GDB likes this marked with a special letter. */
3080 letter
= (use_gnu_debug_info_extensions
3081 ? 'a' : DBX_REGPARM_STABS_LETTER
);
3082 eff_type
= TREE_TYPE (parms
);
3084 /* DECL_RTL looks like (MEM (REG...). Get the register number.
3085 If it is an unallocated pseudo-reg, then use the register where
3086 it was passed instead.
3087 ??? Why is DBX_REGISTER_NUMBER not used here? */
3089 if (REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
3090 number
= REGNO (XEXP (DECL_RTL (parms
), 0));
3092 number
= REGNO (DECL_INCOMING_RTL (parms
));
3094 else if (MEM_P (DECL_RTL (parms
))
3095 && MEM_P (XEXP (DECL_RTL (parms
), 0)))
3097 /* Parm was passed via invisible reference, with the reference
3098 living on the stack. DECL_RTL looks like
3099 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
3100 could look like (MEM (MEM (REG))). */
3104 eff_type
= TREE_TYPE (parms
);
3106 if (!REG_P (XEXP (XEXP (DECL_RTL (parms
), 0), 0)))
3107 number
= INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
3111 number
= DEBUGGER_ARG_OFFSET (number
,
3112 XEXP (XEXP (DECL_RTL (parms
), 0), 0));
3114 else if (MEM_P (DECL_RTL (parms
))
3115 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
3116 /* ??? A constant address for a parm can happen
3117 when the reg it lives in is equiv to a constant in memory.
3118 Should make this not happen, after 2.4. */
3119 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
3121 /* Parm was passed in registers but lives on the stack. */
3125 eff_type
= TREE_TYPE (parms
);
3127 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
3128 in which case we want the value of that CONST_INT,
3130 in which case we use a value of zero. */
3131 if (!REG_P (XEXP (DECL_RTL (parms
), 0)))
3132 number
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
3136 /* Make a big endian correction if the mode of the type of the
3137 parameter is not the same as the mode of the rtl. */
3138 if (BYTES_BIG_ENDIAN
3139 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
3140 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
3141 number
+= (GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
)))
3142 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))));
3145 /* ??? We don't know how to represent this argument. */
3148 dbxout_begin_complex_stabs ();
3150 if (DECL_NAME (parms
))
3152 stabstr_I (DECL_NAME (parms
));
3156 stabstr_S ("(anon):");
3158 dbxout_type (eff_type
, 0);
3159 dbxout_finish_complex_stabs (parms
, code
, 0, 0, number
);
3161 DBXOUT_DECR_NESTING
;
3164 /* Output definitions for the places where parms live during the function,
3165 when different from where they were passed, when the parms were passed
3168 It is not useful to do this for parms passed in registers
3169 that live during the function in different registers, because it is
3170 impossible to look in the passed register for the passed value,
3171 so we use the within-the-function register to begin with.
3173 PARMS is a chain of PARM_DECL nodes. */
3176 dbxout_reg_parms (tree parms
)
3180 for (; parms
; parms
= TREE_CHAIN (parms
))
3181 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
3183 /* Report parms that live in registers during the function
3184 but were passed in memory. */
3185 if (REG_P (DECL_RTL (parms
))
3186 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
3187 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
3188 0, DECL_RTL (parms
));
3189 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
3190 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
3191 0, DECL_RTL (parms
));
3192 /* Report parms that live in memory but not where they were passed. */
3193 else if (MEM_P (DECL_RTL (parms
))
3194 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
3195 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
3196 0, DECL_RTL (parms
));
3198 DBXOUT_DECR_NESTING
;
3201 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
3202 output definitions of those names, in raw form */
3205 dbxout_args (tree args
)
3210 dbxout_type (TREE_VALUE (args
), 0);
3211 args
= TREE_CHAIN (args
);
3215 /* Subroutine of dbxout_block. Emit an N_LBRAC stab referencing LABEL.
3216 BEGIN_LABEL is the name of the beginning of the function, which may
3219 dbx_output_lbrac (const char *label
,
3220 const char *begin_label ATTRIBUTE_UNUSED
)
3222 #ifdef DBX_OUTPUT_LBRAC
3223 DBX_OUTPUT_LBRAC (asm_out_file
, label
);
3225 dbxout_begin_stabn (N_LBRAC
);
3226 if (DBX_BLOCKS_FUNCTION_RELATIVE
)
3227 dbxout_stab_value_label_diff (label
, begin_label
);
3229 dbxout_stab_value_label (label
);
3233 /* Subroutine of dbxout_block. Emit an N_RBRAC stab referencing LABEL.
3234 BEGIN_LABEL is the name of the beginning of the function, which may
3237 dbx_output_rbrac (const char *label
,
3238 const char *begin_label ATTRIBUTE_UNUSED
)
3240 #ifdef DBX_OUTPUT_RBRAC
3241 DBX_OUTPUT_RBRAC (asm_out_file
, label
);
3243 dbxout_begin_stabn (N_RBRAC
);
3244 if (DBX_BLOCKS_FUNCTION_RELATIVE
)
3245 dbxout_stab_value_label_diff (label
, begin_label
);
3247 dbxout_stab_value_label (label
);
3251 /* Output everything about a symbol block (a BLOCK node
3252 that represents a scope level),
3253 including recursive output of contained blocks.
3255 BLOCK is the BLOCK node.
3256 DEPTH is its depth within containing symbol blocks.
3257 ARGS is usually zero; but for the outermost block of the
3258 body of a function, it is a chain of PARM_DECLs for the function parameters.
3259 We output definitions of all the register parms
3260 as if they were local variables of that block.
3262 If -g1 was used, we count blocks just the same, but output nothing
3263 except for the outermost block.
3265 Actually, BLOCK may be several blocks chained together.
3266 We handle them all in sequence. */
3269 dbxout_block (tree block
, int depth
, tree args
)
3271 const char *begin_label
3272 = XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0);
3276 /* Ignore blocks never expanded or otherwise marked as real. */
3277 if (TREE_USED (block
) && TREE_ASM_WRITTEN (block
))
3280 int blocknum
= BLOCK_NUMBER (block
);
3282 /* In dbx format, the syms of a block come before the N_LBRAC.
3283 If nothing is output, we don't need the N_LBRAC, either. */
3285 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
3286 did_output
= dbxout_syms (BLOCK_VARS (block
));
3288 dbxout_reg_parms (args
);
3290 /* Now output an N_LBRAC symbol to represent the beginning of
3291 the block. Use the block's tree-walk order to generate
3292 the assembler symbols LBBn and LBEn
3293 that final will define around the code in this block. */
3297 const char *scope_start
;
3300 /* The outermost block doesn't get LBB labels; use
3301 the function symbol. */
3302 scope_start
= begin_label
;
3305 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
3309 if (BLOCK_HANDLER_BLOCK (block
))
3311 /* A catch block. Must precede N_LBRAC. */
3312 tree decl
= BLOCK_VARS (block
);
3315 dbxout_begin_complex_stabs ();
3316 stabstr_I (DECL_NAME (decl
));
3318 dbxout_finish_complex_stabs (0, N_CATCH
, 0,
3320 decl
= TREE_CHAIN (decl
);
3323 dbx_output_lbrac (scope_start
, begin_label
);
3326 /* Output the subblocks. */
3327 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
3329 /* Refer to the marker for the end of the block. */
3334 /* The outermost block doesn't get LBE labels;
3335 use the "scope" label which will be emitted
3336 by dbxout_function_end. */
3337 ASM_GENERATE_INTERNAL_LABEL (buf
, "Lscope", scope_labelno
);
3339 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
3341 dbx_output_rbrac (buf
, begin_label
);
3344 block
= BLOCK_CHAIN (block
);
3348 /* Output the information about a function and its arguments and result.
3349 Usually this follows the function's code,
3350 but on some systems, it comes before. */
3352 #if defined (DBX_DEBUGGING_INFO)
3354 dbxout_begin_function (tree decl
)
3356 int saved_tree_used1
;
3358 if (DECL_IGNORED_P (decl
))
3361 saved_tree_used1
= TREE_USED (decl
);
3362 TREE_USED (decl
) = 1;
3363 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3365 int saved_tree_used2
= TREE_USED (DECL_RESULT (decl
));
3366 TREE_USED (DECL_RESULT (decl
)) = 1;
3367 dbxout_symbol (decl
, 0);
3368 TREE_USED (DECL_RESULT (decl
)) = saved_tree_used2
;
3371 dbxout_symbol (decl
, 0);
3372 TREE_USED (decl
) = saved_tree_used1
;
3374 dbxout_parms (DECL_ARGUMENTS (decl
));
3375 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3376 dbxout_symbol (DECL_RESULT (decl
), 1);
3378 #endif /* DBX_DEBUGGING_INFO */
3380 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3382 #include "gt-dbxout.h"