1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987-2018 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
21 /* Output dbx-format symbol table data.
22 This consists of many symbol table entries, each of them
23 a .stabs assembler pseudo-op with four operands:
24 a "name" which is really a description of one symbol and its type,
25 a "code", which is a symbol defined in stab.h whose name starts with N_,
26 an unused operand always 0,
27 and a "value" which is an address or an offset.
28 The name is enclosed in doublequote characters.
30 Each function, variable, typedef, and structure tag
31 has a symbol table entry to define it.
32 The beginning and end of each level of name scoping within
33 a function are also marked by special symbol table entries.
35 The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
36 and a data type number. The data type number may be followed by
37 "=" and a type definition; normally this will happen the first time
38 the type number is mentioned. The type definition may refer to
39 other types by number, and those type numbers may be followed
40 by "=" and nested definitions.
42 This can make the "name" quite long.
43 When a name is more than 80 characters, we split the .stabs pseudo-op
44 into two .stabs pseudo-ops, both sharing the same "code" and "value".
45 The first one is marked as continued with a double-backslash at the
48 The kind-of-symbol letter distinguished function names from global
49 variables from file-scope variables from parameters from auto
50 variables in memory from typedef names from register variables.
53 The "code" is mostly redundant with the kind-of-symbol letter
54 that goes in the "name", but not entirely: for symbols located
55 in static storage, the "code" says which segment the address is in,
56 which controls how it is relocated.
58 The "value" for a symbol in static storage
59 is the core address of the symbol (actually, the assembler
60 label for the symbol). For a symbol located in a stack slot
61 it is the stack offset; for one in a register, the register number.
62 For a typedef symbol, it is zero.
64 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
65 output while in the text section.
67 For more on data type definitions, see `dbxout_type'. */
71 #include "coretypes.h"
78 #include "stringpool.h"
79 #include "insn-config.h"
82 #include "diagnostic-core.h"
83 #include "fold-const.h"
85 #include "stor-layout.h"
91 #include "common/common-target.h"
92 #include "langhooks.h"
94 #include "file-prefix-map.h" /* remap_debug_filename() */
96 #ifdef XCOFF_DEBUGGING_INFO
101 # ifdef XCOFF_DEBUGGING_INFO
102 # define ASM_STABS_OP "\t.stabx\t"
104 # define ASM_STABS_OP "\t.stabs\t"
109 #define ASM_STABN_OP "\t.stabn\t"
113 #define ASM_STABD_OP "\t.stabd\t"
116 #ifndef DBX_TYPE_DECL_STABS_CODE
117 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
120 #ifndef DBX_STATIC_CONST_VAR_CODE
121 #define DBX_STATIC_CONST_VAR_CODE N_FUN
124 #ifndef DBX_REGPARM_STABS_CODE
125 #define DBX_REGPARM_STABS_CODE N_RSYM
128 #ifndef DBX_REGPARM_STABS_LETTER
129 #define DBX_REGPARM_STABS_LETTER 'P'
132 #ifndef NO_DBX_FUNCTION_END
133 #define NO_DBX_FUNCTION_END 0
136 #ifndef NO_DBX_BNSYM_ENSYM
137 #define NO_DBX_BNSYM_ENSYM 0
140 #ifndef NO_DBX_MAIN_SOURCE_DIRECTORY
141 #define NO_DBX_MAIN_SOURCE_DIRECTORY 0
144 #ifndef DBX_BLOCKS_FUNCTION_RELATIVE
145 #define DBX_BLOCKS_FUNCTION_RELATIVE 0
148 #ifndef DBX_LINES_FUNCTION_RELATIVE
149 #define DBX_LINES_FUNCTION_RELATIVE 0
152 #ifndef DBX_CONTIN_LENGTH
153 #define DBX_CONTIN_LENGTH 80
156 #ifndef DBX_CONTIN_CHAR
157 #define DBX_CONTIN_CHAR '\\'
160 enum typestatus
{TYPE_UNSEEN
, TYPE_XREF
, TYPE_DEFINED
};
162 /* Structure recording information about a C data type.
163 The status element says whether we have yet output
164 the definition of the type. TYPE_XREF says we have
165 output it as a cross-reference only.
166 The file_number and type_number elements are used if DBX_USE_BINCL
169 struct GTY(()) typeinfo
{
170 enum typestatus status
;
175 /* Vector recording information about C data types.
176 When we first notice a data type (a tree node),
177 we assign it a number using next_type_number.
178 That is its index in this vector. */
180 static GTY ((length ("typevec_len"))) struct typeinfo
*typevec
;
182 /* Number of elements of space allocated in `typevec'. */
184 static GTY(()) int typevec_len
;
186 /* In dbx output, each type gets a unique number.
187 This is the number for the next type output.
188 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
190 static GTY(()) int next_type_number
;
192 /* The C front end may call dbxout_symbol before dbxout_init runs.
193 We save all such decls in this list and output them when we get
196 static GTY(()) tree preinit_symbols
;
198 enum binclstatus
{BINCL_NOT_REQUIRED
, BINCL_PENDING
, BINCL_PROCESSED
};
200 /* When using N_BINCL in dbx output, each type number is actually a
201 pair of the file number and the type number within the file.
202 This is a stack of input files. */
206 struct dbx_file
*next
;
208 int next_type_number
;
209 enum binclstatus bincl_status
; /* Keep track of lazy bincl. */
210 const char *pending_bincl_name
; /* Name of bincl. */
211 struct dbx_file
*prev
; /* Chain to traverse all pending bincls. */
214 /* This is the top of the stack.
216 This is not saved for PCH, because restoring a PCH should not change it.
217 next_file_number does have to be saved, because the PCH may use some
218 file numbers; however, just before restoring a PCH, next_file_number
219 should always be 0 because we should not have needed any file numbers
222 #if (defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)) \
223 && defined (DBX_USE_BINCL)
224 static struct dbx_file
*current_file
;
227 /* This is the next file number to use. */
229 static GTY(()) int next_file_number
;
231 /* A counter for dbxout_function_end. */
233 static GTY(()) int scope_labelno
;
235 /* A counter for dbxout_source_line. */
237 static GTY(()) int dbxout_source_line_counter
;
239 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
240 for the N_SO filename stabs label. */
242 static GTY(()) int source_label_number
= 1;
244 /* Last source file name mentioned in a NOTE insn. */
246 static GTY(()) const char *lastfile
;
248 /* Last line number mentioned in a NOTE insn. */
250 static GTY(()) unsigned int lastlineno
;
252 /* Used by PCH machinery to detect if 'lastfile' should be reset to
254 static GTY(()) int lastfile_is_base
;
256 /* Typical USG systems don't have stab.h, and they also have
257 no use for DBX-format debugging info. */
259 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
262 /* If zero then there is no pending BINCL. */
263 static int pending_bincls
= 0;
266 /* The original input file name. */
267 static const char *base_input_file
;
269 #ifdef DEBUG_SYMS_TEXT
270 #define FORCE_TEXT switch_to_section (current_function_section ())
277 /* 1 if PARM is passed to this function in memory. */
279 #define PARM_PASSED_IN_MEMORY(PARM) \
280 (MEM_P (DECL_INCOMING_RTL (PARM)))
282 /* A C expression for the integer offset value of an automatic variable
283 (N_LSYM) having address X (an RTX). */
284 #ifndef DEBUGGER_AUTO_OFFSET
285 #define DEBUGGER_AUTO_OFFSET(X) \
286 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
289 /* A C expression for the integer offset value of an argument (N_PSYM)
290 having address X (an RTX). The nominal offset is OFFSET.
291 Note that we use OFFSET + 0 here to avoid the self-assign warning
292 when the macro is called in a context like
293 number = DEBUGGER_ARG_OFFSET(number, X) */
294 #ifndef DEBUGGER_ARG_OFFSET
295 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET + 0)
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
, tree
, tree
);
322 static void dbxout_type (tree
, int);
323 static bool print_int_cst_bounds_in_octal_p (tree
, tree
, tree
);
324 static bool is_fortran (void);
325 static void dbxout_type_name (tree
);
326 static void dbxout_class_name_qualifiers (tree
);
327 static int dbxout_symbol_location (tree
, tree
, const char *, rtx
);
328 static void dbxout_symbol_name (tree
, const char *, int);
329 static void dbxout_common_name (tree
, const char *, stab_code_type
);
330 static const char *dbxout_common_check (tree
, int *);
331 static void dbxout_early_global_decl (tree
);
332 static void dbxout_late_global_decl (tree
);
333 static void dbxout_type_decl (tree
, int);
334 static void dbxout_handle_pch (unsigned);
335 static void debug_free_queue (void);
337 /* The debug hooks structure. */
338 #if defined (DBX_DEBUGGING_INFO)
340 static void dbxout_source_line (unsigned int, unsigned int, const char *,
342 static void dbxout_switch_text_section (void);
343 static void dbxout_begin_prologue (unsigned int, unsigned int, const char *);
344 static void dbxout_source_file (const char *);
345 static void dbxout_function_end (tree
);
346 static void dbxout_begin_function (tree
);
347 static void dbxout_begin_block (unsigned, unsigned);
348 static void dbxout_end_block (unsigned, unsigned);
349 static void dbxout_function_decl (tree
);
351 const struct gcc_debug_hooks dbx_debug_hooks
=
355 debug_nothing_charstar
,
357 debug_nothing_int_charstar
,
358 debug_nothing_int_charstar
,
359 dbxout_start_source_file
,
360 dbxout_end_source_file
,
363 debug_true_const_tree
, /* ignore_block */
364 dbxout_source_line
, /* source_line */
365 dbxout_begin_prologue
, /* begin_prologue */
366 debug_nothing_int_charstar
, /* end_prologue */
367 debug_nothing_int_charstar
, /* begin_epilogue */
368 debug_nothing_int_charstar
, /* end_epilogue */
369 #ifdef DBX_FUNCTION_FIRST
370 dbxout_begin_function
,
372 debug_nothing_tree
, /* begin_function */
374 debug_nothing_int
, /* end_function */
375 debug_nothing_tree
, /* register_main_translation_unit */
376 dbxout_function_decl
,
377 dbxout_early_global_decl
, /* early_global_decl */
378 dbxout_late_global_decl
, /* late_global_decl */
379 dbxout_type_decl
, /* type_decl */
380 debug_nothing_tree_tree_tree_bool_bool
,/* imported_module_or_decl */
381 debug_false_tree_charstarstar_uhwistar
,/* die_ref_for_decl */
382 debug_nothing_tree_charstar_uhwi
, /* register_external_die */
383 debug_nothing_tree
, /* deferred_inline_function */
384 debug_nothing_tree
, /* outlining_inline_function */
385 debug_nothing_rtx_code_label
, /* label */
386 dbxout_handle_pch
, /* handle_pch */
387 debug_nothing_rtx_insn
, /* var_location */
388 debug_nothing_tree
, /* inline_entry */
389 debug_nothing_tree
, /* size_function */
390 dbxout_switch_text_section
, /* switch_text_section */
391 debug_nothing_tree_tree
, /* set_name */
392 0, /* start_end_main_source_file */
393 TYPE_SYMTAB_IS_ADDRESS
/* tree_type_symtab_field */
395 #endif /* DBX_DEBUGGING_INFO */
397 #if defined (XCOFF_DEBUGGING_INFO)
398 const struct gcc_debug_hooks xcoff_debug_hooks
=
402 debug_nothing_charstar
,
404 debug_nothing_int_charstar
,
405 debug_nothing_int_charstar
,
406 dbxout_start_source_file
,
407 dbxout_end_source_file
,
408 xcoffout_begin_block
,
410 debug_true_const_tree
, /* ignore_block */
411 xcoffout_source_line
,
412 xcoffout_begin_prologue
, /* begin_prologue */
413 debug_nothing_int_charstar
, /* end_prologue */
414 debug_nothing_int_charstar
, /* begin_epilogue */
415 xcoffout_end_epilogue
,
416 debug_nothing_tree
, /* begin_function */
417 xcoffout_end_function
,
418 debug_nothing_tree
, /* register_main_translation_unit */
419 debug_nothing_tree
, /* function_decl */
420 dbxout_early_global_decl
, /* early_global_decl */
421 dbxout_late_global_decl
, /* late_global_decl */
422 dbxout_type_decl
, /* type_decl */
423 debug_nothing_tree_tree_tree_bool_bool
,/* imported_module_or_decl */
424 debug_false_tree_charstarstar_uhwistar
,/* die_ref_for_decl */
425 debug_nothing_tree_charstar_uhwi
, /* register_external_die */
426 debug_nothing_tree
, /* deferred_inline_function */
427 debug_nothing_tree
, /* outlining_inline_function */
428 debug_nothing_rtx_code_label
, /* label */
429 dbxout_handle_pch
, /* handle_pch */
430 debug_nothing_rtx_insn
, /* var_location */
431 debug_nothing_tree
, /* inline_entry */
432 debug_nothing_tree
, /* size_function */
433 debug_nothing_void
, /* switch_text_section */
434 debug_nothing_tree_tree
, /* set_name */
435 0, /* start_end_main_source_file */
436 TYPE_SYMTAB_IS_ADDRESS
/* tree_type_symtab_field */
438 #endif /* XCOFF_DEBUGGING_INFO */
440 /* Numeric formatting helper macro. Note that this does not handle
442 #define NUMBER_FMT_LOOP(P, NUM, BASE) \
445 int digit = NUM % BASE; \
447 *--P = digit + '0'; \
451 /* Utility: write a decimal integer NUM to asm_out_file. */
456 char *p
= buf
+ sizeof buf
;
461 putc ('0', asm_out_file
);
466 putc ('-', asm_out_file
);
472 NUMBER_FMT_LOOP (p
, unum
, 10);
474 while (p
< buf
+ sizeof buf
)
476 putc (*p
, asm_out_file
);
482 /* Primitives for emitting simple stabs directives. All other stabs
483 routines should use these functions instead of directly emitting
484 stabs. They are exported because machine-dependent code may need
485 to invoke them, e.g. in a DBX_OUTPUT_* macro whose definition
486 forwards to code in CPU.c. */
488 /* The following functions should all be called immediately after one
489 of the dbxout_begin_stab* functions (below). They write out
490 various things as the value of a stab. */
492 /* Write out a literal zero as the value of a stab. */
494 dbxout_stab_value_zero (void)
496 fputs ("0\n", asm_out_file
);
499 /* Write out the label LABEL as the value of a stab. */
501 dbxout_stab_value_label (const char *label
)
503 assemble_name (asm_out_file
, label
);
504 putc ('\n', asm_out_file
);
507 /* Write out the difference of two labels, LABEL - BASE, as the value
510 dbxout_stab_value_label_diff (const char *label
, const char *base
)
512 assemble_name (asm_out_file
, label
);
513 putc ('-', asm_out_file
);
514 assemble_name (asm_out_file
, base
);
515 putc ('\n', asm_out_file
);
518 /* Write out an internal label as the value of a stab, and immediately
519 emit that internal label. This should be used only when
520 dbxout_stabd will not work. STEM is the name stem of the label,
521 COUNTERP is a pointer to a counter variable which will be used to
522 guarantee label uniqueness. */
524 dbxout_stab_value_internal_label (const char *stem
, int *counterp
)
527 int counter
= counterp
? (*counterp
)++ : 0;
529 ASM_GENERATE_INTERNAL_LABEL (label
, stem
, counter
);
530 dbxout_stab_value_label (label
);
531 targetm
.asm_out
.internal_label (asm_out_file
, stem
, counter
);
534 /* Write out the difference between BASE and an internal label as the
535 value of a stab, and immediately emit that internal label. STEM and
536 COUNTERP are as for dbxout_stab_value_internal_label. */
538 dbxout_stab_value_internal_label_diff (const char *stem
, int *counterp
,
542 int counter
= counterp
? (*counterp
)++ : 0;
544 ASM_GENERATE_INTERNAL_LABEL (label
, stem
, counter
);
545 dbxout_stab_value_label_diff (label
, base
);
546 targetm
.asm_out
.internal_label (asm_out_file
, stem
, counter
);
549 /* The following functions produce specific kinds of stab directives. */
551 /* Write a .stabd directive with type STYPE and desc SDESC to asm_out_file. */
553 dbxout_stabd (int stype
, int sdesc
)
555 fputs (ASM_STABD_OP
, asm_out_file
);
557 fputs (",0,", asm_out_file
);
559 putc ('\n', asm_out_file
);
562 /* Write a .stabn directive with type STYPE. This function stops
563 short of emitting the value field, which is the responsibility of
564 the caller (normally it will be either a symbol or the difference
568 dbxout_begin_stabn (int stype
)
570 fputs (ASM_STABN_OP
, asm_out_file
);
572 fputs (",0,0,", asm_out_file
);
575 /* Write a .stabn directive with type N_SLINE and desc LINE. As above,
576 the value field is the responsibility of the caller. */
578 dbxout_begin_stabn_sline (int lineno
)
580 fputs (ASM_STABN_OP
, asm_out_file
);
581 dbxout_int (N_SLINE
);
582 fputs (",0,", asm_out_file
);
584 putc (',', asm_out_file
);
587 /* Begin a .stabs directive with string "", type STYPE, and desc and
588 other fields 0. The value field is the responsibility of the
589 caller. This function cannot be used for .stabx directives. */
591 dbxout_begin_empty_stabs (int stype
)
593 fputs (ASM_STABS_OP
, asm_out_file
);
594 fputs ("\"\",", asm_out_file
);
596 fputs (",0,0,", asm_out_file
);
599 /* Begin a .stabs directive with string STR, type STYPE, and desc 0.
600 The value field is the responsibility of the caller. */
602 dbxout_begin_simple_stabs (const char *str
, int stype
)
604 fputs (ASM_STABS_OP
, asm_out_file
);
605 output_quoted_string (asm_out_file
, str
);
606 putc (',', asm_out_file
);
608 fputs (",0,0,", asm_out_file
);
611 /* As above but use SDESC for the desc field. */
613 dbxout_begin_simple_stabs_desc (const char *str
, int stype
, int sdesc
)
615 fputs (ASM_STABS_OP
, asm_out_file
);
616 output_quoted_string (asm_out_file
, str
);
617 putc (',', asm_out_file
);
619 fputs (",0,", asm_out_file
);
621 putc (',', asm_out_file
);
624 /* The next set of functions are entirely concerned with production of
625 "complex" .stabs directives: that is, .stabs directives whose
626 strings have to be constructed piecemeal. dbxout_type,
627 dbxout_symbol, etc. use these routines heavily. The string is queued
628 up in an obstack, then written out by dbxout_finish_complex_stabs, which
629 is also responsible for splitting it up if it exceeds DBX_CONTIN_LENGTH.
630 (You might think it would be more efficient to go straight to stdio
631 when DBX_CONTIN_LENGTH is 0 (i.e. no length limit) but that turns
632 out not to be the case, and anyway this needs fewer #ifdefs.) */
634 /* Begin a complex .stabs directive. If we can, write the initial
635 ASM_STABS_OP to the asm_out_file. */
638 dbxout_begin_complex_stabs (void)
640 emit_pending_bincls_if_required ();
642 fputs (ASM_STABS_OP
, asm_out_file
);
643 putc ('"', asm_out_file
);
644 gcc_assert (stabstr_last_contin_point
== 0);
647 /* As above, but do not force text or emit pending bincls. This is
648 used by dbxout_symbol_location, which needs to do something else. */
650 dbxout_begin_complex_stabs_noforcetext (void)
652 fputs (ASM_STABS_OP
, asm_out_file
);
653 putc ('"', asm_out_file
);
654 gcc_assert (stabstr_last_contin_point
== 0);
657 /* Add CHR, a single character, to the string being built. */
658 #define stabstr_C(chr) obstack_1grow (&stabstr_ob, chr)
660 /* Add STR, a normal C string, to the string being built. */
661 #define stabstr_S(str) obstack_grow (&stabstr_ob, str, strlen (str))
663 /* Add the text of ID, an IDENTIFIER_NODE, to the string being built. */
664 #define stabstr_I(id) obstack_grow (&stabstr_ob, \
665 IDENTIFIER_POINTER (id), \
666 IDENTIFIER_LENGTH (id))
668 /* Add NUM, a signed decimal number, to the string being built. */
670 stabstr_D (HOST_WIDE_INT num
)
673 char *p
= buf
+ sizeof buf
;
689 NUMBER_FMT_LOOP (p
, unum
, 10);
691 obstack_grow (&stabstr_ob
, p
, (buf
+ sizeof buf
) - p
);
694 /* Add NUM, an unsigned decimal number, to the string being built. */
696 stabstr_U (unsigned HOST_WIDE_INT num
)
699 char *p
= buf
+ sizeof buf
;
705 NUMBER_FMT_LOOP (p
, num
, 10);
706 obstack_grow (&stabstr_ob
, p
, (buf
+ sizeof buf
) - p
);
709 /* Add CST, an INTEGER_CST tree, to the string being built as an
710 unsigned octal number. This routine handles values which are
711 larger than a single HOST_WIDE_INT. */
715 int prec
= TYPE_PRECISION (TREE_TYPE (cst
));
716 int res_pres
= prec
% 3;
720 /* Leading zero for base indicator. */
723 /* If the value is zero, the base indicator will serve as the value
725 if (wi::to_wide (cst
) == 0)
728 /* GDB wants constants with no extra leading "1" bits, so
729 we need to remove any sign-extension that might be
733 digit
= wi::extract_uhwi (wi::to_wide (cst
), prec
- 1, 1);
734 stabstr_C ('0' + digit
);
736 else if (res_pres
== 2)
738 digit
= wi::extract_uhwi (wi::to_wide (cst
), prec
- 2, 2);
739 stabstr_C ('0' + digit
);
743 for (i
= prec
- 3; i
>= 0; i
= i
- 3)
745 digit
= wi::extract_uhwi (wi::to_wide (cst
), i
, 3);
746 stabstr_C ('0' + digit
);
750 /* Called whenever it is safe to break a stabs string into multiple
751 .stabs directives. If the current string has exceeded the limit
752 set by DBX_CONTIN_LENGTH, mark the current position in the buffer
753 as a continuation point by inserting DBX_CONTIN_CHAR (doubled if
754 it is a backslash) and a null character. */
756 stabstr_continue (void)
758 if (DBX_CONTIN_LENGTH
> 0
759 && obstack_object_size (&stabstr_ob
) - stabstr_last_contin_point
762 if (DBX_CONTIN_CHAR
== '\\')
763 obstack_1grow (&stabstr_ob
, '\\');
764 obstack_1grow (&stabstr_ob
, DBX_CONTIN_CHAR
);
765 obstack_1grow (&stabstr_ob
, '\0');
766 stabstr_last_contin_point
= obstack_object_size (&stabstr_ob
);
769 #define CONTIN stabstr_continue ()
771 /* Macro subroutine of dbxout_finish_complex_stabs, which emits
772 all of the arguments to the .stabs directive after the string.
773 Overridden by xcoffout.h. CODE is the stabs code for this symbol;
774 LINE is the source line to write into the desc field (in extended
775 mode); SYM is the symbol itself.
777 ADDR, LABEL, and NUMBER are three different ways to represent the
778 stabs value field. At most one of these should be nonzero.
780 ADDR is used most of the time; it represents the value as an
781 RTL address constant.
783 LABEL is used (currently) only for N_CATCH stabs; it represents
784 the value as a string suitable for assemble_name.
786 NUMBER is used when the value is an offset from an implicit base
787 pointer (e.g. for a stack variable), or an index (e.g. for a
788 register variable). It represents the value as a decimal integer. */
790 #ifndef DBX_FINISH_STABS
791 #define DBX_FINISH_STABS(SYM, CODE, LINE, ADDR, LABEL, NUMBER) \
793 int line_ = use_gnu_debug_info_extensions ? LINE : 0; \
796 fputs (",0,", asm_out_file); \
797 dbxout_int (line_); \
798 putc (',', asm_out_file); \
800 output_addr_const (asm_out_file, ADDR); \
802 assemble_name (asm_out_file, LABEL); \
804 dbxout_int (NUMBER); \
805 putc ('\n', asm_out_file); \
809 /* Finish the emission of a complex .stabs directive. When DBX_CONTIN_LENGTH
810 is zero, this has only to emit the close quote and the remainder of
811 the arguments. When it is nonzero, the string has been marshalled in
812 stabstr_ob, and this routine is responsible for breaking it up into
813 DBX_CONTIN_LENGTH-sized chunks.
815 SYM is the DECL of the symbol under consideration; it is used only
816 for its DECL_SOURCE_LINE. The other arguments are all passed directly
817 to DBX_FINISH_STABS; see above for details. */
820 dbxout_finish_complex_stabs (tree sym
, stab_code_type code
,
821 rtx addr
, const char *label
, int number
)
823 int line ATTRIBUTE_UNUSED
;
827 line
= sym
? DECL_SOURCE_LINE (sym
) : 0;
828 if (DBX_CONTIN_LENGTH
> 0)
833 /* Nul-terminate the growing string, then get its size and
835 obstack_1grow (&stabstr_ob
, '\0');
837 len
= obstack_object_size (&stabstr_ob
);
838 chunk
= str
= XOBFINISH (&stabstr_ob
, char *);
840 /* Within the buffer are a sequence of NUL-separated strings,
841 each of which is to be written out as a separate stab
845 chunklen
= strlen (chunk
);
846 fwrite (chunk
, 1, chunklen
, asm_out_file
);
847 fputs ("\",", asm_out_file
);
849 /* Must add an extra byte to account for the NUL separator. */
850 chunk
+= chunklen
+ 1;
853 /* Only put a line number on the last stab in the sequence. */
854 DBX_FINISH_STABS (sym
, code
, len
== 0 ? line
: 0,
855 addr
, label
, number
);
859 fputs (ASM_STABS_OP
, asm_out_file
);
860 putc ('"', asm_out_file
);
862 stabstr_last_contin_point
= 0;
866 /* No continuations - we can put the whole string out at once.
867 It is faster to augment the string with the close quote and
868 comma than to do a two-character fputs. */
869 obstack_grow (&stabstr_ob
, "\",", 2);
870 len
= obstack_object_size (&stabstr_ob
);
871 str
= XOBFINISH (&stabstr_ob
, char *);
873 fwrite (str
, 1, len
, asm_out_file
);
874 DBX_FINISH_STABS (sym
, code
, line
, addr
, label
, number
);
876 obstack_free (&stabstr_ob
, str
);
879 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
881 /* When -gused is used, emit debug info for only used symbols. But in
882 addition to the standard intercepted debug_hooks there are some
883 direct calls into this file, i.e., dbxout_symbol, dbxout_parms, and
884 dbxout_reg_params. Those routines may also be called from a higher
885 level intercepted routine. So to prevent recording data for an inner
886 call to one of these for an intercept, we maintain an intercept
887 nesting counter (debug_nesting). We only save the intercepted
888 arguments if the nesting is 1. */
889 static int debug_nesting
= 0;
891 static tree
*symbol_queue
;
892 static int symbol_queue_index
= 0;
893 static int symbol_queue_size
= 0;
895 #define DBXOUT_DECR_NESTING \
896 if (--debug_nesting == 0 && symbol_queue_index > 0) \
897 { emit_pending_bincls_if_required (); debug_flush_symbol_queue (); }
899 #define DBXOUT_DECR_NESTING_AND_RETURN(x) \
900 do {--debug_nesting; return (x);} while (0)
902 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
904 #if defined (DBX_DEBUGGING_INFO)
907 dbxout_function_end (tree decl ATTRIBUTE_UNUSED
)
909 char lscope_label_name
[100];
911 /* The Lscope label must be emitted even if we aren't doing anything
912 else; dbxout_block needs it. */
913 switch_to_section (current_function_section ());
915 /* Convert Lscope into the appropriate format for local labels in case
916 the system doesn't insert underscores in front of user generated
918 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name
, "Lscope", scope_labelno
);
919 targetm
.asm_out
.internal_label (asm_out_file
, "Lscope", scope_labelno
);
921 /* The N_FUN tag at the end of the function is a GNU extension,
922 which may be undesirable, and is unnecessary if we do not have
924 if (!use_gnu_debug_info_extensions
925 || NO_DBX_FUNCTION_END
926 || !targetm_common
.have_named_sections
)
929 /* By convention, GCC will mark the end of a function with an N_FUN
930 symbol and an empty string. */
931 if (crtl
->has_bb_partition
)
933 dbxout_begin_empty_stabs (N_FUN
);
934 if (in_cold_section_p
)
935 dbxout_stab_value_label_diff (crtl
->subsections
.cold_section_end_label
,
936 crtl
->subsections
.cold_section_label
);
938 dbxout_stab_value_label_diff (crtl
->subsections
.hot_section_end_label
,
939 crtl
->subsections
.hot_section_label
);
943 char begin_label
[20];
944 /* Reference current function start using LFBB. */
945 ASM_GENERATE_INTERNAL_LABEL (begin_label
, "LFBB", scope_labelno
);
946 dbxout_begin_empty_stabs (N_FUN
);
947 dbxout_stab_value_label_diff (lscope_label_name
, begin_label
);
950 if (!NO_DBX_BNSYM_ENSYM
&& !flag_debug_only_used_symbols
)
951 dbxout_stabd (N_ENSYM
, 0);
953 #endif /* DBX_DEBUGGING_INFO */
955 /* Get lang description for N_SO stab. */
956 static unsigned int ATTRIBUTE_UNUSED
957 get_lang_number (void)
959 const char *language_string
= lang_hooks
.name
;
962 else if (lang_GNU_CXX ())
964 else if (strcmp (language_string
, "GNU F77") == 0)
966 else if (lang_GNU_Fortran ())
967 return N_SO_FORTRAN90
; /* CHECKME */
968 else if (strcmp (language_string
, "GNU Objective-C") == 0)
970 else if (strcmp (language_string
, "GNU Objective-C++") == 0)
971 return N_SO_OBJCPLUS
;
980 unsigned int lang
= get_lang_number ();
982 return (lang
== N_SO_FORTRAN
) || (lang
== N_SO_FORTRAN90
);
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 ();
994 const char *mapped_name
;
997 typevec
= ggc_cleared_vec_alloc
<typeinfo
> (typevec_len
);
999 /* stabstr_ob contains one string, which will be just fine with
1000 1-byte alignment. */
1001 obstack_specify_allocation (&stabstr_ob
, 0, 1, xmalloc
, free
);
1003 /* Convert Ltext into the appropriate format for local labels in case
1004 the system doesn't insert underscores in front of user generated
1006 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
1008 /* Put the current working directory in an N_SO symbol. */
1009 if (use_gnu_debug_info_extensions
&& !NO_DBX_MAIN_SOURCE_DIRECTORY
)
1011 static const char *cwd
;
1015 cwd
= get_src_pwd ();
1018 else if (!IS_DIR_SEPARATOR (cwd
[strlen (cwd
) - 1]))
1019 cwd
= concat (cwd
, "/", NULL
);
1020 cwd
= remap_debug_filename (cwd
);
1022 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
1023 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asm_out_file
, cwd
);
1024 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
1025 dbxout_begin_simple_stabs_desc (cwd
, N_SO
, get_lang_number ());
1026 dbxout_stab_value_label (ltext_label_name
);
1027 used_ltext_label_name
= true;
1028 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
1031 mapped_name
= remap_debug_filename (input_file_name
);
1032 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
1033 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asm_out_file
, mapped_name
);
1035 dbxout_begin_simple_stabs_desc (mapped_name
, N_SO
, get_lang_number ());
1036 dbxout_stab_value_label (ltext_label_name
);
1037 used_ltext_label_name
= true;
1040 if (used_ltext_label_name
)
1042 switch_to_section (text_section
);
1043 targetm
.asm_out
.internal_label (asm_out_file
, "Ltext", 0);
1046 /* Emit an N_OPT stab to indicate that this file was compiled by GCC.
1047 The string used is historical. */
1048 #ifndef NO_DBX_GCC_MARKER
1049 dbxout_begin_simple_stabs ("gcc2_compiled.", N_OPT
);
1050 dbxout_stab_value_zero ();
1053 base_input_file
= lastfile
= input_file_name
;
1055 next_type_number
= 1;
1057 #ifdef DBX_USE_BINCL
1058 current_file
= XNEW (struct dbx_file
);
1059 current_file
->next
= NULL
;
1060 current_file
->file_number
= 0;
1061 current_file
->next_type_number
= 1;
1062 next_file_number
= 1;
1063 current_file
->prev
= NULL
;
1064 current_file
->bincl_status
= BINCL_NOT_REQUIRED
;
1065 current_file
->pending_bincl_name
= NULL
;
1068 /* Get all permanent types that have typedef names, and output them
1069 all, except for those already output. Some language front ends
1070 put these declarations in the top-level scope; some do not;
1071 the latter are responsible for calling debug_hooks->type_decl from
1072 their record_builtin_type function. */
1073 dbxout_typedefs (syms
);
1075 if (preinit_symbols
)
1078 for (t
= nreverse (preinit_symbols
); t
; t
= TREE_CHAIN (t
))
1079 dbxout_symbol (TREE_VALUE (t
), 0);
1080 preinit_symbols
= 0;
1084 /* Output any typedef names for types described by TYPE_DECLs in SYMS. */
1087 dbxout_typedefs (tree syms
)
1089 for (; syms
!= NULL_TREE
; syms
= DECL_CHAIN (syms
))
1091 if (TREE_CODE (syms
) == TYPE_DECL
)
1093 tree type
= TREE_TYPE (syms
);
1094 if (TYPE_NAME (type
)
1095 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1096 && COMPLETE_OR_VOID_TYPE_P (type
)
1097 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
1098 dbxout_symbol (TYPE_NAME (type
), 0);
1103 #ifdef DBX_USE_BINCL
1104 /* Emit BINCL stab using given name. */
1106 emit_bincl_stab (const char *name
)
1108 dbxout_begin_simple_stabs (name
, N_BINCL
);
1109 dbxout_stab_value_zero ();
1112 /* If there are pending bincls then it is time to emit all of them. */
1115 emit_pending_bincls_if_required (void)
1118 emit_pending_bincls ();
1121 /* Emit all pending bincls. */
1124 emit_pending_bincls (void)
1126 struct dbx_file
*f
= current_file
;
1128 /* Find first pending bincl. */
1129 while (f
->bincl_status
== BINCL_PENDING
)
1132 /* Now emit all bincls. */
1137 if (f
->bincl_status
== BINCL_PENDING
)
1139 emit_bincl_stab (f
->pending_bincl_name
);
1141 /* Update file number and status. */
1142 f
->file_number
= next_file_number
++;
1143 f
->bincl_status
= BINCL_PROCESSED
;
1145 if (f
== current_file
)
1150 /* All pending bincls have been emitted. */
1157 emit_pending_bincls_if_required (void) {}
1160 /* Change to reading from a new source file. Generate a N_BINCL stab. */
1163 dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED
,
1164 const char *filename ATTRIBUTE_UNUSED
)
1166 #ifdef DBX_USE_BINCL
1167 struct dbx_file
*n
= XNEW (struct dbx_file
);
1169 n
->next
= current_file
;
1170 n
->next_type_number
= 1;
1171 /* Do not assign file number now.
1172 Delay it until we actually emit BINCL. */
1175 current_file
->prev
= n
;
1176 n
->bincl_status
= BINCL_PENDING
;
1177 n
->pending_bincl_name
= remap_debug_filename (filename
);
1183 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
1186 dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED
)
1188 #ifdef DBX_USE_BINCL
1189 /* Emit EINCL stab only if BINCL is not pending. */
1190 if (current_file
->bincl_status
== BINCL_PROCESSED
)
1192 dbxout_begin_stabn (N_EINCL
);
1193 dbxout_stab_value_zero ();
1195 current_file
->bincl_status
= BINCL_NOT_REQUIRED
;
1196 current_file
= current_file
->next
;
1200 /* Handle a few odd cases that occur when trying to make PCH files work. */
1203 dbxout_handle_pch (unsigned at_end
)
1207 /* When using the PCH, this file will be included, so we need to output
1209 dbxout_start_source_file (0, lastfile
);
1211 /* The base file when using the PCH won't be the same as
1212 the base file when it's being generated. */
1217 /* ... and an EINCL. */
1218 dbxout_end_source_file (0);
1220 /* Deal with cases where 'lastfile' was never actually changed. */
1221 lastfile_is_base
= lastfile
== NULL
;
1225 #if defined (DBX_DEBUGGING_INFO)
1227 static bool dbxout_block (tree
, int, tree
, int);
1229 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
1232 dbxout_source_file (const char *filename
)
1234 if (lastfile
== 0 && lastfile_is_base
)
1236 lastfile
= base_input_file
;
1237 lastfile_is_base
= 0;
1240 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
1242 /* Don't change section amid function. */
1243 if (current_function_decl
== NULL_TREE
)
1244 switch_to_section (text_section
);
1246 dbxout_begin_simple_stabs (remap_debug_filename (filename
), N_SOL
);
1247 dbxout_stab_value_internal_label ("Ltext", &source_label_number
);
1248 lastfile
= filename
;
1252 /* Output N_BNSYM, line number symbol entry, and local symbol at
1256 dbxout_begin_prologue (unsigned int lineno
,
1257 unsigned int column ATTRIBUTE_UNUSED
,
1258 const char *filename
)
1260 if (use_gnu_debug_info_extensions
1261 && !NO_DBX_FUNCTION_END
1262 && !NO_DBX_BNSYM_ENSYM
1263 && !flag_debug_only_used_symbols
)
1264 dbxout_stabd (N_BNSYM
, 0);
1266 /* pre-increment the scope counter */
1269 dbxout_source_line (lineno
, 0, filename
, 0, true);
1270 /* Output function begin block at function scope, referenced
1271 by dbxout_block, dbxout_source_line and dbxout_function_end. */
1272 emit_pending_bincls_if_required ();
1273 targetm
.asm_out
.internal_label (asm_out_file
, "LFBB", scope_labelno
);
1276 /* Output a line number symbol entry for source file FILENAME and line
1280 dbxout_source_line (unsigned int lineno
, unsigned int column ATTRIBUTE_UNUSED
,
1281 const char *filename
, int discriminator ATTRIBUTE_UNUSED
,
1282 bool is_stmt ATTRIBUTE_UNUSED
)
1284 dbxout_source_file (filename
);
1286 #ifdef DBX_OUTPUT_SOURCE_LINE
1287 DBX_OUTPUT_SOURCE_LINE (asm_out_file
, lineno
, dbxout_source_line_counter
);
1289 if (DBX_LINES_FUNCTION_RELATIVE
)
1291 char begin_label
[20];
1292 dbxout_begin_stabn_sline (lineno
);
1293 /* Reference current function start using LFBB. */
1294 ASM_GENERATE_INTERNAL_LABEL (begin_label
, "LFBB", scope_labelno
);
1295 dbxout_stab_value_internal_label_diff ("LM", &dbxout_source_line_counter
,
1299 dbxout_stabd (N_SLINE
, lineno
);
1301 lastlineno
= lineno
;
1304 /* Unfortunately, at least when emitting relative addresses, STABS
1305 has no way to express multiple partitions. Represent a function
1306 as two functions in this case. */
1309 dbxout_switch_text_section (void)
1311 /* The N_FUN tag at the end of the function is a GNU extension,
1312 which may be undesirable, and is unnecessary if we do not have
1314 in_cold_section_p
= !in_cold_section_p
;
1315 switch_to_section (current_function_section ());
1316 dbxout_block (DECL_INITIAL (current_function_decl
), 0,
1317 DECL_ARGUMENTS (current_function_decl
), -1);
1318 dbxout_function_end (current_function_decl
);
1319 in_cold_section_p
= !in_cold_section_p
;
1321 switch_to_section (current_function_section ());
1323 tree context
= decl_function_context (current_function_decl
);
1324 extern tree cold_function_name
;
1326 dbxout_begin_complex_stabs ();
1327 stabstr_I (cold_function_name
);
1330 tree type
= TREE_TYPE (current_function_decl
);
1331 if (TREE_TYPE (type
))
1332 dbxout_type (TREE_TYPE (type
), 0);
1334 dbxout_type (void_type_node
, 0);
1339 stabstr_I (cold_function_name
);
1341 stabstr_I (DECL_NAME (context
));
1344 dbxout_finish_complex_stabs (current_function_decl
, N_FUN
, 0,
1345 crtl
->subsections
.cold_section_label
, 0);
1347 /* pre-increment the scope counter */
1350 dbxout_source_line (lastlineno
, 0, lastfile
, 0, true);
1351 /* Output function begin block at function scope, referenced
1352 by dbxout_block, dbxout_source_line and dbxout_function_end. */
1353 emit_pending_bincls_if_required ();
1354 targetm
.asm_out
.internal_label (asm_out_file
, "LFBB", scope_labelno
);
1357 /* Describe the beginning of an internal block within a function. */
1360 dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED
, unsigned int n
)
1362 emit_pending_bincls_if_required ();
1363 targetm
.asm_out
.internal_label (asm_out_file
, "LBB", n
);
1366 /* Describe the end line-number of an internal block within a function. */
1369 dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED
, unsigned int n
)
1371 emit_pending_bincls_if_required ();
1372 targetm
.asm_out
.internal_label (asm_out_file
, "LBE", n
);
1375 /* Output dbx data for a function definition.
1376 This includes a definition of the function name itself (a symbol),
1377 definitions of the parameters (locating them in the parameter list)
1378 and then output the block that makes up the function's body
1379 (including all the auto variables of the function). */
1382 dbxout_function_decl (tree decl
)
1384 emit_pending_bincls_if_required ();
1385 #ifndef DBX_FUNCTION_FIRST
1386 dbxout_begin_function (decl
);
1388 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
), -1);
1389 dbxout_function_end (decl
);
1392 #endif /* DBX_DEBUGGING_INFO */
1395 dbxout_early_global_decl (tree decl ATTRIBUTE_UNUSED
)
1397 /* NYI for non-dwarf. */
1400 /* Debug information for a global DECL. Called from toplev.c after
1401 compilation proper has finished. */
1403 dbxout_late_global_decl (tree decl
)
1405 if (VAR_P (decl
) && !DECL_EXTERNAL (decl
))
1407 int saved_tree_used
= TREE_USED (decl
);
1408 TREE_USED (decl
) = 1;
1409 dbxout_symbol (decl
, 0);
1410 TREE_USED (decl
) = saved_tree_used
;
1414 /* This is just a function-type adapter; dbxout_symbol does exactly
1415 what we want but returns an int. */
1417 dbxout_type_decl (tree decl
, int local
)
1419 dbxout_symbol (decl
, local
);
1422 /* At the end of compilation, finish writing the symbol table.
1423 The default is to call debug_free_queue but do nothing else. */
1426 dbxout_finish (const char *filename ATTRIBUTE_UNUSED
)
1428 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
1429 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asm_out_file
, filename
);
1430 #elif defined DBX_OUTPUT_NULL_N_SO_AT_MAIN_SOURCE_FILE_END
1432 switch_to_section (text_section
);
1433 dbxout_begin_empty_stabs (N_SO
);
1434 dbxout_stab_value_internal_label ("Letext", 0);
1437 debug_free_queue ();
1440 /* Output the index of a type. */
1443 dbxout_type_index (tree type
)
1445 #ifndef DBX_USE_BINCL
1446 stabstr_D (TYPE_SYMTAB_ADDRESS (type
));
1448 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
1450 stabstr_D (t
->file_number
);
1452 stabstr_D (t
->type_number
);
1458 /* Generate the symbols for any queued up type symbols we encountered
1459 while generating the type info for some originally used symbol.
1460 This might generate additional entries in the queue. Only when
1461 the nesting depth goes to 0 is this routine called. */
1464 debug_flush_symbol_queue (void)
1468 /* Make sure that additionally queued items are not flushed
1473 for (i
= 0; i
< symbol_queue_index
; ++i
)
1475 /* If we pushed queued symbols then such symbols must be
1476 output no matter what anyone else says. Specifically,
1477 we need to make sure dbxout_symbol() thinks the symbol was
1478 used and also we need to override TYPE_DECL_SUPPRESS_DEBUG
1479 which may be set for outside reasons. */
1480 int saved_tree_used
= TREE_USED (symbol_queue
[i
]);
1481 int saved_suppress_debug
= TYPE_DECL_SUPPRESS_DEBUG (symbol_queue
[i
]);
1482 TREE_USED (symbol_queue
[i
]) = 1;
1483 TYPE_DECL_SUPPRESS_DEBUG (symbol_queue
[i
]) = 0;
1485 #ifdef DBX_DEBUGGING_INFO
1486 dbxout_symbol (symbol_queue
[i
], 0);
1489 TREE_USED (symbol_queue
[i
]) = saved_tree_used
;
1490 TYPE_DECL_SUPPRESS_DEBUG (symbol_queue
[i
]) = saved_suppress_debug
;
1493 symbol_queue_index
= 0;
1497 /* Queue a type symbol needed as part of the definition of a decl
1498 symbol. These symbols are generated when debug_flush_symbol_queue()
1502 debug_queue_symbol (tree decl
)
1504 if (symbol_queue_index
>= symbol_queue_size
)
1506 symbol_queue_size
+= 10;
1507 symbol_queue
= XRESIZEVEC (tree
, symbol_queue
, symbol_queue_size
);
1510 symbol_queue
[symbol_queue_index
++] = decl
;
1513 /* Free symbol queue. */
1515 debug_free_queue (void)
1519 free (symbol_queue
);
1520 symbol_queue
= NULL
;
1521 symbol_queue_size
= 0;
1525 /* Used in several places: evaluates to '0' for a private decl,
1526 '1' for a protected decl, '2' for a public decl. */
1527 #define DECL_ACCESSIBILITY_CHAR(DECL) \
1528 (TREE_PRIVATE (DECL) ? '0' : TREE_PROTECTED (DECL) ? '1' : '2')
1530 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
1531 This must be a separate function because anonymous unions require
1535 dbxout_type_fields (tree type
)
1539 /* Output the name, type, position (in bits), size (in bits) of each
1540 field that we can support. */
1541 for (tem
= TYPE_FIELDS (type
); tem
; tem
= DECL_CHAIN (tem
))
1543 /* If one of the nodes is an error_mark or its type is then
1545 if (error_operand_p (tem
))
1548 /* Omit here local type decls until we know how to support them. */
1549 if (TREE_CODE (tem
) == TYPE_DECL
1550 || TREE_CODE (tem
) == TEMPLATE_DECL
1551 /* Member functions emitted after fields. */
1552 || TREE_CODE (tem
) == FUNCTION_DECL
1553 /* Omit here the nameless fields that are used to skip bits. */
1554 || DECL_IGNORED_P (tem
)
1555 /* Omit fields whose position or size are variable or too large to
1557 || (TREE_CODE (tem
) == FIELD_DECL
1558 && (! tree_fits_shwi_p (bit_position (tem
))
1559 || ! DECL_SIZE (tem
)
1560 || ! tree_fits_uhwi_p (DECL_SIZE (tem
)))))
1563 else if (TREE_CODE (tem
) != CONST_DECL
)
1565 /* Continue the line if necessary,
1566 but not before the first field. */
1567 if (tem
!= TYPE_FIELDS (type
))
1570 if (DECL_NAME (tem
))
1571 stabstr_I (DECL_NAME (tem
));
1574 if (use_gnu_debug_info_extensions
1575 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
1576 || TREE_CODE (tem
) != FIELD_DECL
))
1579 stabstr_C (DECL_ACCESSIBILITY_CHAR (tem
));
1582 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
1583 && DECL_BIT_FIELD_TYPE (tem
))
1584 ? DECL_BIT_FIELD_TYPE (tem
) : TREE_TYPE (tem
), 0);
1588 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
1590 tree name
= DECL_ASSEMBLER_NAME (tem
);
1597 /* If TEM is non-static, GDB won't understand it. */
1598 stabstr_S (",0,0;");
1603 stabstr_D (int_bit_position (tem
));
1605 stabstr_D (tree_to_uhwi (DECL_SIZE (tem
)));
1612 /* Subroutine of `dbxout_type_methods'. Output debug info about the
1613 method described DECL. */
1616 dbxout_type_method_1 (tree decl
)
1620 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
1622 else /* it's a METHOD_TYPE. */
1624 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
1625 /* A for normal functions.
1626 B for `const' member functions.
1627 C for `volatile' member functions.
1628 D for `const volatile' member functions. */
1629 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
1631 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
1634 if (DECL_VINDEX (decl
))
1640 /* ??? Output the mangled name, which contains an encoding of the
1641 method's type signature. May not be necessary anymore. */
1643 stabstr_I (DECL_ASSEMBLER_NAME (decl
));
1645 stabstr_C (DECL_ACCESSIBILITY_CHAR (decl
));
1649 if (DECL_VINDEX (decl
) && tree_fits_shwi_p (DECL_VINDEX (decl
)))
1651 stabstr_D (tree_to_shwi (DECL_VINDEX (decl
)));
1653 dbxout_type (DECL_CONTEXT (decl
), 0);
1658 /* Subroutine of `dbxout_type'. Output debug info about the member
1659 functions defined in TYPE. */
1662 dbxout_type_methods (tree type
)
1664 for (tree fndecl
= TYPE_FIELDS (type
); fndecl
;)
1666 int need_prefix
= 1;
1668 /* Group together all the methods for the same operation.
1669 These differ in the types of the arguments. */
1670 for (tree last
= NULL_TREE
;
1671 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
1672 fndecl
= DECL_CHAIN (fndecl
))
1673 /* Output the name of the field (after overloading), as
1674 well as the name of the field before overloading, along
1675 with its parameter list */
1677 /* Skip non-functions. */
1678 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
1681 /* Also ignore abstract methods; those are only interesting to
1682 the DWARF backends. */
1683 if (DECL_IGNORED_P (fndecl
) || DECL_ABSTRACT_P (fndecl
))
1690 /* Redundantly output the plain name, since that's what gdb
1694 stabstr_I (DECL_NAME (fndecl
));
1699 dbxout_type (TREE_TYPE (fndecl
), 0);
1700 dbxout_type_method_1 (fndecl
);
1707 /* Emit a "range" type specification, which has the form:
1708 "r<index type>;<lower bound>;<upper bound>;".
1709 TYPE is an INTEGER_TYPE, LOW and HIGH are the bounds. */
1712 dbxout_range_type (tree type
, tree low
, tree high
)
1715 if (TREE_TYPE (type
))
1716 dbxout_type (TREE_TYPE (type
), 0);
1717 else if (TREE_CODE (type
) != INTEGER_TYPE
)
1718 dbxout_type (type
, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1721 /* Traditionally, we made sure 'int' was type 1, and builtin types
1722 were defined to be sub-ranges of int. Unfortunately, this
1723 does not allow us to distinguish true sub-ranges from integer
1724 types. So, instead we define integer (non-sub-range) types as
1725 sub-ranges of themselves. This matters for Chill. If this isn't
1726 a subrange type, then we want to define it in terms of itself.
1727 However, in C, this may be an anonymous integer type, and we don't
1728 want to emit debug info referring to it. Just calling
1729 dbxout_type_index won't work anyways, because the type hasn't been
1730 defined yet. We make this work for both cases by checked to see
1731 whether this is a defined type, referring to it if it is, and using
1733 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
1734 dbxout_type_index (type
);
1736 dbxout_type_index (integer_type_node
);
1740 if (low
&& tree_fits_shwi_p (low
))
1742 if (print_int_cst_bounds_in_octal_p (type
, low
, high
))
1745 stabstr_D (tree_to_shwi (low
));
1751 if (high
&& tree_fits_shwi_p (high
))
1753 if (print_int_cst_bounds_in_octal_p (type
, low
, high
))
1756 stabstr_D (tree_to_shwi (high
));
1764 /* Output a reference to a type. If the type has not yet been
1765 described in the dbx output, output its definition now.
1766 For a type already defined, just refer to its definition
1767 using the type number.
1769 If FULL is nonzero, and the type has been described only with
1770 a forward-reference, output the definition now.
1771 If FULL is zero in this case, just refer to the forward-reference
1772 using the number previously allocated. */
1775 dbxout_type (tree type
, int full
)
1777 static int anonymous_type_number
= 0;
1778 tree tem
, main_variant
, low
, high
;
1780 if (TREE_CODE (type
) == INTEGER_TYPE
)
1782 if (TREE_TYPE (type
) == 0)
1784 low
= TYPE_MIN_VALUE (type
);
1785 high
= TYPE_MAX_VALUE (type
);
1788 else if (subrange_type_for_debug_p (type
, &low
, &high
))
1791 /* If this is a subtype that should not be emitted as a subrange type,
1792 use the base type. */
1795 type
= TREE_TYPE (type
);
1796 low
= TYPE_MIN_VALUE (type
);
1797 high
= TYPE_MAX_VALUE (type
);
1801 /* If there was an input error and we don't really have a type,
1802 avoid crashing and write something that is at least valid
1803 by assuming `int'. */
1804 if (type
== error_mark_node
)
1805 type
= integer_type_node
;
1808 if (TYPE_NAME (type
)
1809 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1810 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
1814 /* Try to find the "main variant" with the same name. */
1815 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1816 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1817 main_variant
= TREE_TYPE (TYPE_NAME (type
));
1819 main_variant
= TYPE_MAIN_VARIANT (type
);
1821 /* If we are not using extensions, stabs does not distinguish const and
1822 volatile, so there is no need to make them separate types. */
1823 if (!use_gnu_debug_info_extensions
)
1824 type
= main_variant
;
1826 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
1828 /* Type has no dbx number assigned. Assign next available number. */
1829 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
1831 /* Make sure type vector is long enough to record about this type. */
1833 if (next_type_number
== typevec_len
)
1835 typevec
= GGC_RESIZEVEC (struct typeinfo
, typevec
, typevec_len
* 2);
1836 memset (typevec
+ typevec_len
, 0, typevec_len
* sizeof typevec
[0]);
1840 #ifdef DBX_USE_BINCL
1841 emit_pending_bincls_if_required ();
1842 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
1843 = current_file
->file_number
;
1844 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
1845 = current_file
->next_type_number
++;
1849 if (flag_debug_only_used_symbols
)
1851 if ((TREE_CODE (type
) == RECORD_TYPE
1852 || TREE_CODE (type
) == UNION_TYPE
1853 || TREE_CODE (type
) == QUAL_UNION_TYPE
1854 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1855 && TYPE_STUB_DECL (type
)
1856 && DECL_P (TYPE_STUB_DECL (type
))
1857 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type
)))
1858 debug_queue_symbol (TYPE_STUB_DECL (type
));
1859 else if (TYPE_NAME (type
)
1860 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1861 debug_queue_symbol (TYPE_NAME (type
));
1864 /* Output the number of this type, to refer to it. */
1865 dbxout_type_index (type
);
1867 #ifdef DBX_TYPE_DEFINED
1868 if (DBX_TYPE_DEFINED (type
))
1872 /* If this type's definition has been output or is now being output,
1875 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
1880 /* If we have already had a cross reference,
1881 and either that's all we want or that's the best we could do,
1882 don't repeat the cross reference.
1883 Sun dbx crashes if we do. */
1884 if (! full
|| !COMPLETE_TYPE_P (type
)
1885 /* No way in DBX fmt to describe a variable size. */
1886 || ! tree_fits_uhwi_p (TYPE_SIZE (type
)))
1894 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1895 leave the type-number completely undefined rather than output
1896 a cross-reference. If we have already used GNU debug info extensions,
1897 then it is OK to output a cross reference. This is necessary to get
1898 proper C++ debug output. */
1899 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1900 || TREE_CODE (type
) == QUAL_UNION_TYPE
1901 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1902 && ! use_gnu_debug_info_extensions
)
1903 /* We must use the same test here as we use twice below when deciding
1904 whether to emit a cross-reference. */
1905 if ((TYPE_NAME (type
) != 0
1906 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1907 && DECL_IGNORED_P (TYPE_NAME (type
)))
1909 || !COMPLETE_TYPE_P (type
)
1910 /* No way in DBX fmt to describe a variable size. */
1911 || ! tree_fits_uhwi_p (TYPE_SIZE (type
)))
1913 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1918 /* Output a definition now. */
1921 /* Mark it as defined, so that if it is self-referent
1922 we will not get into an infinite recursion of definitions. */
1924 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1926 /* If this type is a variant of some other, hand off. Types with
1927 different names are usefully distinguished. We only distinguish
1928 cv-qualified types if we're using extensions. */
1929 if (TYPE_READONLY (type
) > TYPE_READONLY (main_variant
))
1932 dbxout_type (build_type_variant (type
, 0, TYPE_VOLATILE (type
)), 0);
1935 else if (TYPE_VOLATILE (type
) > TYPE_VOLATILE (main_variant
))
1938 dbxout_type (build_type_variant (type
, TYPE_READONLY (type
), 0), 0);
1941 else if (main_variant
!= TYPE_MAIN_VARIANT (type
))
1943 if (flag_debug_only_used_symbols
)
1945 tree orig_type
= DECL_ORIGINAL_TYPE (TYPE_NAME (type
));
1947 if ((TREE_CODE (orig_type
) == RECORD_TYPE
1948 || TREE_CODE (orig_type
) == UNION_TYPE
1949 || TREE_CODE (orig_type
) == QUAL_UNION_TYPE
1950 || TREE_CODE (orig_type
) == ENUMERAL_TYPE
)
1951 && TYPE_STUB_DECL (orig_type
)
1952 && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type
)))
1953 debug_queue_symbol (TYPE_STUB_DECL (orig_type
));
1955 /* 'type' is a typedef; output the type it refers to. */
1956 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0);
1959 /* else continue. */
1961 switch (TREE_CODE (type
))
1966 /* For a void type, just define it as itself; i.e., "5=5".
1967 This makes us consider it defined
1968 without saying what it is. The debugger will make it
1969 a void type when the reference is seen, and nothing will
1970 ever override that default. */
1971 dbxout_type_index (type
);
1975 if (type
== char_type_node
&& ! TYPE_UNSIGNED (type
))
1977 /* Output the type `char' as a subrange of itself!
1978 I don't understand this definition, just copied it
1979 from the output of pcc.
1980 This used to use `r2' explicitly and we used to
1981 take care to make sure that `char' was type number 2. */
1983 dbxout_type_index (type
);
1984 stabstr_S (";0;127;");
1987 /* If this is a subtype of another integer type, always prefer to
1988 write it as a subtype. */
1989 else if (TREE_TYPE (type
) != 0
1990 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_TYPE
)
1992 /* If the size is non-standard, say what it is if we can use
1995 if (use_gnu_debug_info_extensions
1996 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1999 stabstr_D (TYPE_PRECISION (type
));
2003 dbxout_range_type (type
, low
, high
);
2008 /* If the size is non-standard, say what it is if we can use
2011 if (use_gnu_debug_info_extensions
2012 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
2015 stabstr_D (TYPE_PRECISION (type
));
2019 if (print_int_cst_bounds_in_octal_p (type
, low
, high
))
2023 /* If this type derives from another type, output type index of
2024 parent type. This is particularly important when parent type
2025 is an enumerated type, because not generating the parent type
2026 index would transform the definition of this enumerated type
2027 into a plain unsigned type. */
2028 if (TREE_TYPE (type
) != 0)
2029 dbxout_type_index (TREE_TYPE (type
));
2031 dbxout_type_index (type
);
2041 /* Output other integer types as subranges of `int'. */
2042 dbxout_range_type (type
, low
, high
);
2048 case FIXED_POINT_TYPE
:
2049 /* This used to say `r1' and we used to take care
2050 to make sure that `int' was type number 1. */
2052 dbxout_type_index (integer_type_node
);
2054 stabstr_D (int_size_in_bytes (type
));
2059 if (use_gnu_debug_info_extensions
)
2062 stabstr_D (BITS_PER_UNIT
* int_size_in_bytes (type
));
2063 stabstr_S (";-16;");
2065 else /* Define as enumeral type (False, True) */
2066 stabstr_S ("eFalse:0,True:1,;");
2070 /* Differs from the REAL_TYPE by its new data type number.
2071 R3 is NF_COMPLEX. We don't try to use any of the other NF_*
2072 codes since gdb doesn't care anyway. */
2074 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
2077 stabstr_D (2 * int_size_in_bytes (TREE_TYPE (type
)));
2082 /* Output a complex integer type as a structure,
2083 pending some other way to do it. */
2085 stabstr_D (int_size_in_bytes (type
));
2087 stabstr_S ("real:");
2088 dbxout_type (TREE_TYPE (type
), 0);
2090 stabstr_D (TYPE_PRECISION (TREE_TYPE (type
)));
2092 stabstr_S (";imag:");
2093 dbxout_type (TREE_TYPE (type
), 0);
2095 stabstr_D (TYPE_PRECISION (TREE_TYPE (type
)));
2097 stabstr_D (TYPE_PRECISION (TREE_TYPE (type
)));
2103 /* Make arrays of packed bits look like bitstrings for chill. */
2104 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
2107 stabstr_D (BITS_PER_UNIT
* int_size_in_bytes (type
));
2108 stabstr_S (";@S;S");
2109 dbxout_type (TYPE_DOMAIN (type
), 0);
2113 /* Output "a" followed by a range type definition
2114 for the index type of the array
2115 followed by a reference to the target-type.
2116 ar1;0;N;M for a C array of type M and size N+1. */
2117 /* Check if a character string type, which in Chill is
2118 different from an array of characters. */
2119 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
2123 tem
= TYPE_DOMAIN (type
);
2127 dbxout_type_index (integer_type_node
);
2128 stabstr_S (";0;-1;");
2133 dbxout_range_type (tem
, TYPE_MIN_VALUE (tem
), TYPE_MAX_VALUE (tem
));
2136 dbxout_type (TREE_TYPE (type
), 0);
2140 /* Make vectors look like an array. */
2141 if (use_gnu_debug_info_extensions
)
2144 /* Output "a" followed by a range type definition
2145 for the index type of the array
2146 followed by a reference to the target-type.
2147 ar1;0;N;M for a C array of type M and size N+1. */
2149 dbxout_range_type (integer_type_node
, size_zero_node
,
2150 size_int (TYPE_VECTOR_SUBPARTS (type
) - 1));
2152 dbxout_type (TREE_TYPE (type
), 0);
2157 case QUAL_UNION_TYPE
:
2159 tree binfo
= TYPE_BINFO (type
);
2161 /* Output a structure type. We must use the same test here as we
2162 use in the DBX_NO_XREFS case above. */
2163 if ((TYPE_NAME (type
) != 0
2164 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
2165 && DECL_IGNORED_P (TYPE_NAME (type
)))
2167 || !COMPLETE_TYPE_P (type
)
2168 /* No way in DBX fmt to describe a variable size. */
2169 || ! tree_fits_uhwi_p (TYPE_SIZE (type
)))
2171 /* If the type is just a cross reference, output one
2172 and mark the type as partially described.
2173 If it later becomes defined, we will output
2174 its real definition.
2175 If the type has a name, don't nest its definition within
2176 another type's definition; instead, output an xref
2177 and let the definition come when the name is defined. */
2178 stabstr_S ((TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu");
2179 if (TYPE_IDENTIFIER (type
))
2181 /* Note that the C frontend creates for anonymous variable
2182 length records/unions TYPE_NAME with DECL_NAME NULL. */
2183 dbxout_type_name (type
);
2188 stabstr_D (anonymous_type_number
++);
2192 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
2196 /* Identify record or union, and print its size. */
2197 stabstr_C ((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u');
2198 stabstr_D (int_size_in_bytes (type
));
2204 vec
<tree
, va_gc
> *accesses
= BINFO_BASE_ACCESSES (binfo
);
2206 if (use_gnu_debug_info_extensions
)
2208 if (BINFO_N_BASE_BINFOS (binfo
))
2211 stabstr_U (BINFO_N_BASE_BINFOS (binfo
));
2215 for (i
= 0; BINFO_BASE_ITERATE (binfo
, i
, child
); i
++)
2217 tree access
= (accesses
? (*accesses
)[i
] : access_public_node
);
2219 if (use_gnu_debug_info_extensions
)
2221 stabstr_C (BINFO_VIRTUAL_P (child
) ? '1' : '0');
2222 stabstr_C (access
== access_public_node
? '2' :
2223 access
== access_protected_node
2225 if (BINFO_VIRTUAL_P (child
)
2227 || strcmp (lang_hooks
.name
, "GNU Objective-C++") == 0))
2228 /* For a virtual base, print the (negative)
2229 offset within the vtable where we must look
2230 to find the necessary adjustment. */
2232 (tree_to_shwi (BINFO_VPTR_FIELD (child
))
2235 stabstr_D (tree_to_shwi (BINFO_OFFSET (child
))
2238 dbxout_type (BINFO_TYPE (child
), 0);
2243 /* Print out the base class information with
2244 fields which have the same names at the types
2246 dbxout_type_name (BINFO_TYPE (child
));
2248 dbxout_type (BINFO_TYPE (child
), full
);
2250 stabstr_D (tree_to_shwi (BINFO_OFFSET (child
))
2254 (tree_to_shwi (TYPE_SIZE (BINFO_TYPE (child
)))
2262 /* Write out the field declarations. */
2263 dbxout_type_fields (type
);
2264 if (use_gnu_debug_info_extensions
)
2265 dbxout_type_methods (type
);
2269 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
2270 /* Avoid the ~ if we don't really need it--it confuses dbx. */
2271 && TYPE_VFIELD (type
))
2274 /* We need to write out info about what field this class
2275 uses as its "main" vtable pointer field, because if this
2276 field is inherited from a base class, GDB cannot necessarily
2277 figure out which field it's using in time. */
2279 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0);
2285 /* We must use the same test here as we use in the DBX_NO_XREFS case
2286 above. We simplify it a bit since an enum will never have a variable
2288 if ((TYPE_NAME (type
) != 0
2289 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
2290 && DECL_IGNORED_P (TYPE_NAME (type
)))
2292 || !COMPLETE_TYPE_P (type
))
2295 dbxout_type_name (type
);
2296 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
2300 if (use_gnu_debug_info_extensions
2301 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
2304 stabstr_D (TYPE_PRECISION (type
));
2309 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
2311 tree value
= TREE_VALUE (tem
);
2313 stabstr_I (TREE_PURPOSE (tem
));
2316 if (TREE_CODE (value
) == CONST_DECL
)
2317 value
= DECL_INITIAL (value
);
2319 if (cst_and_fits_in_hwi (value
))
2320 stabstr_D (TREE_INT_CST_LOW (value
));
2325 if (TREE_CHAIN (tem
) != 0)
2334 dbxout_type (TREE_TYPE (type
), 0);
2338 if (use_gnu_debug_info_extensions
)
2342 /* Write the argument types out longhand. */
2343 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0);
2345 dbxout_type (TREE_TYPE (type
), 0);
2346 dbxout_args (TYPE_ARG_TYPES (type
));
2350 /* Treat it as a function type. */
2351 dbxout_type (TREE_TYPE (type
), 0);
2355 if (use_gnu_debug_info_extensions
)
2358 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0);
2360 dbxout_type (TREE_TYPE (type
), 0);
2363 /* Should print as an int, because it is really just an offset. */
2364 dbxout_type (integer_type_node
, 0);
2367 case REFERENCE_TYPE
:
2368 if (use_gnu_debug_info_extensions
)
2374 dbxout_type (TREE_TYPE (type
), 0);
2379 dbxout_type (TREE_TYPE (type
), 0);
2382 case POINTER_BOUNDS_TYPE
:
2383 /* No debug info for pointer bounds type supported yet. */
2387 /* A C++ function with deduced return type can have a TEMPLATE_TYPE_PARM
2388 named 'auto' in its type.
2389 No debug info for TEMPLATE_TYPE_PARM type supported yet. */
2390 if (lang_GNU_CXX ())
2392 tree name
= TYPE_IDENTIFIER (type
);
2393 if (name
== get_identifier ("auto")
2394 || name
== get_identifier ("decltype(auto)"))
2402 /* Return nonzero if the given type represents an integer whose bounds
2403 should be printed in octal format. */
2406 print_int_cst_bounds_in_octal_p (tree type
, tree low
, tree high
)
2408 /* If we can use GDB extensions and the size is wider than a long
2409 (the size used by GDB to read them) or we may have trouble writing
2410 the bounds the usual way, write them in octal. Note the test is for
2411 the *target's* size of "long", not that of the host. The host test
2412 is just to make sure we can write it out in case the host wide int
2413 is narrower than the target "long".
2415 For unsigned types, we use octal if they are the same size or larger.
2416 This is because we print the bounds as signed decimal, and hence they
2417 can't span same size unsigned types. */
2419 if (use_gnu_debug_info_extensions
2420 && low
&& TREE_CODE (low
) == INTEGER_CST
2421 && high
&& TREE_CODE (high
) == INTEGER_CST
2422 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
2423 || ((TYPE_PRECISION (type
) == TYPE_PRECISION (integer_type_node
))
2424 && TYPE_UNSIGNED (type
))
2425 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
2426 || (TYPE_PRECISION (type
) == HOST_BITS_PER_WIDE_INT
2427 && TYPE_UNSIGNED (type
))))
2433 /* Output the name of type TYPE, with no punctuation.
2434 Such names can be set up either by typedef declarations
2435 or by struct, enum and union tags. */
2438 dbxout_type_name (tree type
)
2440 tree t
= TYPE_NAME (type
);
2443 switch (TREE_CODE (t
))
2445 case IDENTIFIER_NODE
:
2457 /* Output leading struct or class names needed for qualifying type
2458 whose scope is limited to a struct or class. */
2461 dbxout_class_name_qualifiers (tree decl
)
2463 tree context
= decl_type_context (decl
);
2465 if (context
!= NULL_TREE
2466 && TREE_CODE (context
) == RECORD_TYPE
2467 && TYPE_NAME (context
) != 0
2468 && (TREE_CODE (TYPE_NAME (context
)) == IDENTIFIER_NODE
2469 || (DECL_NAME (TYPE_NAME (context
)) != 0)))
2471 tree name
= TYPE_NAME (context
);
2473 if (TREE_CODE (name
) == TYPE_DECL
)
2475 dbxout_class_name_qualifiers (name
);
2476 name
= DECL_NAME (name
);
2483 /* This is a specialized subset of expand_expr for use by dbxout_symbol in
2484 evaluating DECL_VALUE_EXPR. In particular, we stop if we find decls that
2485 haven't been expanded, or if the expression is getting so complex we won't
2486 be able to represent it in stabs anyway. Returns NULL on failure. */
2489 dbxout_expand_expr (tree expr
)
2491 switch (TREE_CODE (expr
))
2494 /* We can't handle emulated tls variables, because the address is an
2495 offset to the return value of __emutls_get_address, and there is no
2496 way to express that in stabs. Also, there are name mangling issues
2497 here. We end up with references to undefined symbols if we don't
2498 disable debug info for these variables. */
2499 if (!targetm
.have_tls
&& DECL_THREAD_LOCAL_P (expr
))
2501 if (TREE_STATIC (expr
)
2502 && !TREE_ASM_WRITTEN (expr
)
2503 && !DECL_HAS_VALUE_EXPR_P (expr
)
2504 && !TREE_PUBLIC (expr
)
2505 && DECL_RTL_SET_P (expr
)
2506 && MEM_P (DECL_RTL (expr
)))
2508 /* If this is a var that might not be actually output,
2509 return NULL, otherwise stabs might reference an undefined
2511 varpool_node
*node
= varpool_node::get (expr
);
2512 if (!node
|| !node
->definition
)
2519 if (DECL_HAS_VALUE_EXPR_P (expr
))
2520 return dbxout_expand_expr (DECL_VALUE_EXPR (expr
));
2524 return DECL_RTL_IF_SET (expr
);
2527 return expand_expr (expr
, NULL_RTX
, VOIDmode
, EXPAND_INITIALIZER
);
2531 case ARRAY_RANGE_REF
:
2535 poly_int64 bitsize
, bitpos
;
2537 int unsignedp
, reversep
, volatilep
= 0;
2540 tem
= get_inner_reference (expr
, &bitsize
, &bitpos
, &offset
, &mode
,
2541 &unsignedp
, &reversep
, &volatilep
);
2543 x
= dbxout_expand_expr (tem
);
2544 if (x
== NULL
|| !MEM_P (x
))
2548 if (!tree_fits_shwi_p (offset
))
2550 x
= adjust_address_nv (x
, mode
, tree_to_shwi (offset
));
2552 if (maybe_ne (bitpos
, 0))
2553 x
= adjust_address_nv (x
, mode
, bits_to_bytes_round_down (bitpos
));
2563 /* Helper function for output_used_types. Queue one entry from the
2564 used types hash to be output. */
2567 output_used_types_helper (tree
const &type
, vec
<tree
> *types_p
)
2569 if ((TREE_CODE (type
) == RECORD_TYPE
2570 || TREE_CODE (type
) == UNION_TYPE
2571 || TREE_CODE (type
) == QUAL_UNION_TYPE
2572 || TREE_CODE (type
) == ENUMERAL_TYPE
)
2573 && TYPE_STUB_DECL (type
)
2574 && DECL_P (TYPE_STUB_DECL (type
))
2575 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type
)))
2576 types_p
->quick_push (TYPE_STUB_DECL (type
));
2577 else if (TYPE_NAME (type
)
2578 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
2579 types_p
->quick_push (TYPE_NAME (type
));
2584 /* This is a qsort callback which sorts types and declarations into a
2585 predictable order (types, then declarations, sorted by UID
2589 output_types_sort (const void *pa
, const void *pb
)
2591 const tree lhs
= *((const tree
*)pa
);
2592 const tree rhs
= *((const tree
*)pb
);
2597 return TYPE_UID (lhs
) - TYPE_UID (rhs
);
2606 return DECL_UID (lhs
) - DECL_UID (rhs
);
2611 /* Force all types used by this function to be output in debug
2615 output_used_types (void)
2617 if (cfun
&& cfun
->used_types_hash
)
2623 types
.create (cfun
->used_types_hash
->elements ());
2624 cfun
->used_types_hash
->traverse
<vec
<tree
> *, output_used_types_helper
>
2627 /* Sort by UID to prevent dependence on hash table ordering. */
2628 types
.qsort (output_types_sort
);
2630 FOR_EACH_VEC_ELT (types
, i
, type
)
2631 debug_queue_symbol (type
);
2637 /* Output a .stabs for the symbol defined by DECL,
2638 which must be a ..._DECL node in the normal namespace.
2639 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
2640 LOCAL is nonzero if the scope is less than the entire file.
2641 Return 1 if a stabs might have been emitted. */
2644 dbxout_symbol (tree decl
, int local ATTRIBUTE_UNUSED
)
2646 tree type
= TREE_TYPE (decl
);
2647 tree context
= NULL_TREE
;
2651 /* "Intercept" dbxout_symbol() calls like we do all debug_hooks. */
2654 /* Ignore nameless syms, but don't ignore type tags. */
2656 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
2657 || DECL_IGNORED_P (decl
))
2658 DBXOUT_DECR_NESTING_AND_RETURN (0);
2660 /* If we are to generate only the symbols actually used then such
2661 symbol nodes are flagged with TREE_USED. Ignore any that
2662 aren't flagged as TREE_USED. */
2664 if (flag_debug_only_used_symbols
2665 && (!TREE_USED (decl
)
2666 && (!VAR_P (decl
) || !DECL_INITIAL (decl
))))
2667 DBXOUT_DECR_NESTING_AND_RETURN (0);
2669 /* If dbxout_init has not yet run, queue this symbol for later. */
2672 preinit_symbols
= tree_cons (0, decl
, preinit_symbols
);
2673 DBXOUT_DECR_NESTING_AND_RETURN (0);
2676 if (flag_debug_only_used_symbols
)
2680 /* We now have a used symbol. We need to generate the info for
2681 the symbol's type in addition to the symbol itself. These
2682 type symbols are queued to be generated after were done with
2683 the symbol itself (otherwise they would fight over the
2686 Note, because the TREE_TYPE(type) might be something like a
2687 pointer to a named type we need to look for the first name
2688 we see following the TREE_TYPE chain. */
2691 while (POINTER_TYPE_P (t
))
2694 /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE
2695 need special treatment. The TYPE_STUB_DECL field in these
2696 types generally represents the tag name type we want to
2697 output. In addition there could be a typedef type with
2698 a different name. In that case we also want to output
2701 if (TREE_CODE (t
) == RECORD_TYPE
2702 || TREE_CODE (t
) == UNION_TYPE
2703 || TREE_CODE (t
) == QUAL_UNION_TYPE
2704 || TREE_CODE (t
) == ENUMERAL_TYPE
)
2706 if (TYPE_STUB_DECL (t
)
2707 && TYPE_STUB_DECL (t
) != decl
2708 && DECL_P (TYPE_STUB_DECL (t
))
2709 && ! DECL_IGNORED_P (TYPE_STUB_DECL (t
)))
2711 debug_queue_symbol (TYPE_STUB_DECL (t
));
2713 && TYPE_NAME (t
) != TYPE_STUB_DECL (t
)
2714 && TYPE_NAME (t
) != decl
2715 && DECL_P (TYPE_NAME (t
)))
2716 debug_queue_symbol (TYPE_NAME (t
));
2719 else if (TYPE_NAME (t
)
2720 && TYPE_NAME (t
) != decl
2721 && DECL_P (TYPE_NAME (t
)))
2722 debug_queue_symbol (TYPE_NAME (t
));
2725 emit_pending_bincls_if_required ();
2727 switch (TREE_CODE (decl
))
2730 /* Enum values are defined by defining the enum type. */
2734 decl_rtl
= DECL_RTL_IF_SET (decl
);
2736 DBXOUT_DECR_NESTING_AND_RETURN (0);
2737 if (DECL_EXTERNAL (decl
))
2739 /* Don't mention a nested function under its parent. */
2740 context
= decl_function_context (decl
);
2741 if (context
== current_function_decl
)
2743 /* Don't mention an inline instance of a nested function. */
2744 if (context
&& DECL_FROM_INLINE (decl
))
2746 if (!MEM_P (decl_rtl
)
2747 || GET_CODE (XEXP (decl_rtl
, 0)) != SYMBOL_REF
)
2750 if (flag_debug_only_used_symbols
)
2751 output_used_types ();
2753 dbxout_begin_complex_stabs ();
2754 stabstr_I (DECL_ASSEMBLER_NAME (decl
));
2755 stabstr_S (TREE_PUBLIC (decl
) ? ":F" : ":f");
2758 if (TREE_TYPE (type
))
2759 dbxout_type (TREE_TYPE (type
), 0);
2761 dbxout_type (void_type_node
, 0);
2763 /* For a nested function, when that function is compiled,
2764 mention the containing function name
2765 as well as (since dbx wants it) our own assembler-name. */
2769 stabstr_I (DECL_ASSEMBLER_NAME (decl
));
2771 stabstr_I (DECL_NAME (context
));
2774 dbxout_finish_complex_stabs (decl
, N_FUN
, XEXP (decl_rtl
, 0), 0, 0);
2778 /* Don't output the same typedef twice.
2779 And don't output what language-specific stuff doesn't want output. */
2780 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
2781 DBXOUT_DECR_NESTING_AND_RETURN (0);
2783 /* Don't output typedefs for types with magic type numbers (XCOFF). */
2784 #ifdef DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER
2786 int fundamental_type_number
=
2787 DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER (decl
);
2789 if (fundamental_type_number
!= 0)
2791 TREE_ASM_WRITTEN (decl
) = 1;
2792 TYPE_SYMTAB_ADDRESS (TREE_TYPE (decl
)) = fundamental_type_number
;
2793 DBXOUT_DECR_NESTING_AND_RETURN (0);
2803 if (DECL_NAME (decl
))
2805 /* Nonzero means we must output a tag as well as a typedef. */
2808 /* Handle the case of a C++ structure or union
2809 where the TYPE_NAME is a TYPE_DECL
2810 which gives both a typedef name and a tag. */
2811 /* dbx requires the tag first and the typedef second. */
2812 if ((TREE_CODE (type
) == RECORD_TYPE
2813 || TREE_CODE (type
) == UNION_TYPE
2814 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2815 && TYPE_NAME (type
) == decl
2816 && !use_gnu_debug_info_extensions
2817 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
2818 /* Distinguish the implicit typedefs of C++
2819 from explicit ones that might be found in C. */
2820 && DECL_ARTIFICIAL (decl
)
2821 /* Do not generate a tag for incomplete records. */
2822 && COMPLETE_TYPE_P (type
)
2823 /* Do not generate a tag for records of variable size,
2824 since this type can not be properly described in the
2825 DBX format, and it confuses some tools such as objdump. */
2826 && tree_fits_uhwi_p (TYPE_SIZE (type
)))
2828 tree name
= TYPE_IDENTIFIER (type
);
2830 dbxout_begin_complex_stabs ();
2833 dbxout_type (type
, 1);
2834 dbxout_finish_complex_stabs (0, DBX_TYPE_DECL_STABS_CODE
,
2838 dbxout_begin_complex_stabs ();
2840 /* Output leading class/struct qualifiers. */
2841 if (use_gnu_debug_info_extensions
)
2842 dbxout_class_name_qualifiers (decl
);
2844 /* Output typedef name. */
2845 stabstr_I (DECL_NAME (decl
));
2848 /* Short cut way to output a tag also. */
2849 if ((TREE_CODE (type
) == RECORD_TYPE
2850 || TREE_CODE (type
) == UNION_TYPE
2851 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2852 && TYPE_NAME (type
) == decl
2853 /* Distinguish the implicit typedefs of C++
2854 from explicit ones that might be found in C. */
2855 && DECL_ARTIFICIAL (decl
))
2857 if (use_gnu_debug_info_extensions
)
2860 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
2865 dbxout_type (type
, 1);
2866 dbxout_finish_complex_stabs (decl
, DBX_TYPE_DECL_STABS_CODE
,
2871 /* Don't output a tag if this is an incomplete type. This prevents
2872 the sun4 Sun OS 4.x dbx from crashing. */
2874 if (tag_needed
&& TYPE_NAME (type
) != 0
2875 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
2876 || (DECL_NAME (TYPE_NAME (type
)) != 0))
2877 && COMPLETE_TYPE_P (type
)
2878 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
2880 /* For a TYPE_DECL with no name, but the type has a name,
2882 This is what represents `struct foo' with no typedef. */
2883 /* In C++, the name of a type is the corresponding typedef.
2884 In C, it is an IDENTIFIER_NODE. */
2885 tree name
= TYPE_IDENTIFIER (type
);
2887 dbxout_begin_complex_stabs ();
2890 dbxout_type (type
, 1);
2891 dbxout_finish_complex_stabs (0, DBX_TYPE_DECL_STABS_CODE
, 0, 0, 0);
2895 /* If an enum type has no name, it cannot be referred to, but
2896 we must output it anyway, to record the enumeration
2899 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
2901 dbxout_begin_complex_stabs ();
2902 /* Some debuggers fail when given NULL names, so give this a
2903 harmless name of " " (Why not "(anon)"?). */
2905 dbxout_type (type
, 1);
2906 dbxout_finish_complex_stabs (0, DBX_TYPE_DECL_STABS_CODE
, 0, 0, 0);
2909 /* Prevent duplicate output of a typedef. */
2910 TREE_ASM_WRITTEN (decl
) = 1;
2915 if (DECL_HAS_VALUE_EXPR_P (decl
))
2916 decl
= DECL_VALUE_EXPR (decl
);
2918 /* PARM_DECLs go in their own separate chain and are output by
2919 dbxout_reg_parms and dbxout_parms, except for those that are
2920 disguised VAR_DECLs like Out parameters in Ada. */
2921 gcc_assert (VAR_P (decl
));
2927 /* Don't mention a variable that is external.
2928 Let the file that defines it describe it. */
2929 if (DECL_EXTERNAL (decl
))
2932 /* If the variable is really a constant
2933 and not written in memory, inform the debugger.
2935 ??? Why do we skip emitting the type and location in this case? */
2936 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
2937 && DECL_INITIAL (decl
) != 0
2938 && tree_fits_shwi_p (DECL_INITIAL (decl
))
2939 && ! TREE_ASM_WRITTEN (decl
)
2940 && (DECL_FILE_SCOPE_P (decl
)
2941 || TREE_CODE (DECL_CONTEXT (decl
)) == BLOCK
2942 || TREE_CODE (DECL_CONTEXT (decl
)) == NAMESPACE_DECL
)
2943 && TREE_PUBLIC (decl
) == 0)
2945 /* The sun4 assembler does not grok this. */
2947 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
2948 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
2950 HOST_WIDE_INT ival
= tree_to_shwi (DECL_INITIAL (decl
));
2952 dbxout_begin_complex_stabs ();
2953 dbxout_symbol_name (decl
, NULL
, 'c');
2956 dbxout_finish_complex_stabs (0, N_LSYM
, 0, 0, 0);
2957 DBXOUT_DECR_NESTING
;
2963 /* else it is something we handle like a normal variable. */
2965 decl_rtl
= dbxout_expand_expr (decl
);
2967 DBXOUT_DECR_NESTING_AND_RETURN (0);
2969 if (!is_global_var (decl
))
2970 decl_rtl
= eliminate_regs (decl_rtl
, VOIDmode
, NULL_RTX
);
2971 #ifdef LEAF_REG_REMAP
2972 if (crtl
->uses_only_leaf_regs
)
2973 leaf_renumber_regs_insn (decl_rtl
);
2976 result
= dbxout_symbol_location (decl
, type
, 0, decl_rtl
);
2982 DBXOUT_DECR_NESTING
;
2986 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2987 Add SUFFIX to its name, if SUFFIX is not 0.
2988 Describe the variable as residing in HOME
2989 (usually HOME is DECL_RTL (DECL), but not always).
2990 Returns 1 if the stab was really emitted. */
2993 dbxout_symbol_location (tree decl
, tree type
, const char *suffix
, rtx home
)
2996 stab_code_type code
;
3001 /* Don't mention a variable at all
3002 if it was completely optimized into nothingness.
3004 If the decl was from an inline function, then its rtl
3005 is not identically the rtl that was used in this
3006 particular compilation. */
3007 if (GET_CODE (home
) == SUBREG
)
3011 while (GET_CODE (value
) == SUBREG
)
3012 value
= SUBREG_REG (value
);
3015 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
3018 home
= alter_subreg (&home
, true);
3022 regno
= REGNO (home
);
3023 if (regno
>= FIRST_PSEUDO_REGISTER
)
3027 /* The kind-of-variable letter depends on where
3028 the variable is and on the scope of its name:
3029 G and N_GSYM for static storage and global scope,
3030 S for static storage and file scope,
3031 V for static storage and local scope,
3032 for those two, use N_LCSYM if data is in bss segment,
3033 N_STSYM if in data segment, N_FUN otherwise.
3034 (We used N_FUN originally, then changed to N_STSYM
3035 to please GDB. However, it seems that confused ld.
3036 Now GDB has been fixed to like N_FUN, says Kingdon.)
3037 no letter at all, and N_LSYM, for auto variable,
3038 r and N_RSYM for register variable. */
3040 if (MEM_P (home
) && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
3042 if (TREE_PUBLIC (decl
))
3047 if (dbxout_common_check (decl
, &offs
) != NULL
)
3056 addr
= XEXP (home
, 0);
3058 letter
= decl_function_context (decl
) ? 'V' : 'S';
3060 /* Some ports can transform a symbol ref into a label ref,
3061 because the symbol ref is too far away and has to be
3062 dumped into a constant pool. Alternatively, the symbol
3063 in the constant pool might be referenced by a different
3065 if (GET_CODE (addr
) == SYMBOL_REF
3066 && CONSTANT_POOL_ADDRESS_P (addr
))
3069 rtx tmp
= get_pool_constant_mark (addr
, &marked
);
3071 if (GET_CODE (tmp
) == SYMBOL_REF
)
3074 if (CONSTANT_POOL_ADDRESS_P (addr
))
3075 get_pool_constant_mark (addr
, &marked
);
3079 else if (GET_CODE (tmp
) == LABEL_REF
)
3085 /* If all references to the constant pool were optimized
3086 out, we just ignore the symbol. */
3091 /* This should be the same condition as in assemble_variable, but
3092 we don't have access to dont_output_data here. So, instead,
3093 we rely on the fact that error_mark_node initializers always
3094 end up in bss for C++ and never end up in bss for C. */
3095 if (DECL_INITIAL (decl
) == 0
3097 && DECL_INITIAL (decl
) == error_mark_node
))
3101 if (dbxout_common_check (decl
, &offs
) != NULL
)
3109 else if (DECL_IN_TEXT_SECTION (decl
))
3110 /* This is not quite right, but it's the closest
3111 of all the codes that Unix defines. */
3112 code
= DBX_STATIC_CONST_VAR_CODE
;
3115 /* Ultrix `as' seems to need this. */
3116 #ifdef DBX_STATIC_STAB_DATA_SECTION
3117 switch_to_section (data_section
);
3123 else if (regno
>= 0)
3127 number
= DBX_REGISTER_NUMBER (regno
);
3129 else if (MEM_P (home
)
3130 && (MEM_P (XEXP (home
, 0))
3131 || (REG_P (XEXP (home
, 0))
3132 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
3133 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
3134 #if !HARD_FRAME_POINTER_IS_ARG_POINTER
3135 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
3138 /* If the value is indirect by memory or by a register
3139 that isn't the frame pointer
3140 then it means the object is variable-sized and address through
3141 that register or stack slot. DBX has no way to represent this
3142 so all we can do is output the variable as a pointer.
3143 If it's not a parameter, ignore it. */
3145 if (REG_P (XEXP (home
, 0)))
3149 if (REGNO (XEXP (home
, 0)) >= FIRST_PSEUDO_REGISTER
)
3151 number
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
3156 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
3157 We want the value of that CONST_INT. */
3158 number
= DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
3161 /* Effectively do build_pointer_type, but don't cache this type,
3162 since it might be temporary whereas the type it points to
3163 might have been saved for inlining. */
3164 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
3165 type
= make_node (POINTER_TYPE
);
3166 TREE_TYPE (type
) = TREE_TYPE (decl
);
3168 else if (MEM_P (home
)
3169 && REG_P (XEXP (home
, 0)))
3172 number
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
3174 else if (MEM_P (home
)
3175 && GET_CODE (XEXP (home
, 0)) == PLUS
3176 && CONST_INT_P (XEXP (XEXP (home
, 0), 1)))
3179 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
3180 We want the value of that CONST_INT. */
3181 number
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
3183 else if (MEM_P (home
)
3184 && GET_CODE (XEXP (home
, 0)) == CONST
)
3186 /* Handle an obscure case which can arise when optimizing and
3187 when there are few available registers. (This is *always*
3188 the case for i386/i486 targets). The RTL looks like
3189 (MEM (CONST ...)) even though this variable is a local `auto'
3190 or a local `register' variable. In effect, what has happened
3191 is that the reload pass has seen that all assignments and
3192 references for one such a local variable can be replaced by
3193 equivalent assignments and references to some static storage
3194 variable, thereby avoiding the need for a register. In such
3195 cases we're forced to lie to debuggers and tell them that
3196 this variable was itself `static'. */
3200 if (dbxout_common_check (decl
, &offs
) == NULL
)
3201 addr
= XEXP (XEXP (home
, 0), 0);
3209 else if (GET_CODE (home
) == CONCAT
)
3213 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
3214 for example), then there is no easy way to figure out
3215 what SUBTYPE should be. So, we give up. */
3216 if (TREE_CODE (type
) != COMPLEX_TYPE
)
3219 subtype
= TREE_TYPE (type
);
3221 /* If the variable's storage is in two parts,
3222 output each as a separate stab with a modified name. */
3223 if (WORDS_BIG_ENDIAN
)
3224 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
3226 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
3228 if (WORDS_BIG_ENDIAN
)
3229 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
3231 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
3235 /* Address might be a MEM, when DECL is a variable-sized object.
3236 Or it might be const0_rtx, meaning previous passes
3237 want us to ignore this variable. */
3240 /* Ok, start a symtab entry and output the variable name. */
3241 emit_pending_bincls_if_required ();
3244 #ifdef DBX_STATIC_BLOCK_START
3245 DBX_STATIC_BLOCK_START (asm_out_file
, code
);
3248 dbxout_begin_complex_stabs_noforcetext ();
3249 dbxout_symbol_name (decl
, suffix
, letter
);
3250 dbxout_type (type
, 0);
3251 dbxout_finish_complex_stabs (decl
, code
, addr
, 0, number
);
3253 #ifdef DBX_STATIC_BLOCK_END
3254 DBX_STATIC_BLOCK_END (asm_out_file
, code
);
3259 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
3260 Then output LETTER to indicate the kind of location the symbol has. */
3263 dbxout_symbol_name (tree decl
, const char *suffix
, int letter
)
3267 if (DECL_CONTEXT (decl
)
3268 && (TYPE_P (DECL_CONTEXT (decl
))
3269 || TREE_CODE (DECL_CONTEXT (decl
)) == NAMESPACE_DECL
))
3270 /* One slight hitch: if this is a VAR_DECL which is a class member
3271 or a namespace member, we must put out the mangled name instead of the
3272 DECL_NAME. Note also that static member (variable) names DO NOT begin
3273 with underscores in .stabs directives. */
3274 name
= DECL_ASSEMBLER_NAME (decl
);
3276 /* ...but if we're function-local, we don't want to include the junk
3277 added by ASM_FORMAT_PRIVATE_NAME. */
3278 name
= DECL_NAME (decl
);
3283 stabstr_S ("(anon)");
3293 /* Output the common block name for DECL in a stabs.
3295 Symbols in global common (.comm) get wrapped with an N_BCOMM/N_ECOMM pair
3296 around each group of symbols in the same .comm area. The N_GSYM stabs
3297 that are emitted only contain the offset in the common area. This routine
3298 emits the N_BCOMM and N_ECOMM stabs. */
3301 dbxout_common_name (tree decl
, const char *name
, stab_code_type op
)
3303 dbxout_begin_complex_stabs ();
3305 dbxout_finish_complex_stabs (decl
, op
, NULL_RTX
, NULL
, 0);
3308 /* Check decl to determine whether it is a VAR_DECL destined for storage in a
3309 common area. If it is, the return value will be a non-null string giving
3310 the name of the common storage block it will go into. If non-null, the
3311 value is the offset into the common block for that symbol's storage. */
3314 dbxout_common_check (tree decl
, int *value
)
3318 const char *name
= NULL
;
3320 /* If the decl isn't a VAR_DECL, or if it isn't static, or if
3321 it does not have a value (the offset into the common area), or if it
3322 is thread local (as opposed to global) then it isn't common, and shouldn't
3325 ??? DECL_THREAD_LOCAL_P check prevents problems with improper .stabs
3326 for thread-local symbols. Can be handled via same mechanism as used
3329 || !TREE_STATIC (decl
)
3330 || !DECL_HAS_VALUE_EXPR_P (decl
)
3331 || DECL_THREAD_LOCAL_P (decl
)
3335 home
= DECL_RTL (decl
);
3336 if (home
== NULL_RTX
|| GET_CODE (home
) != MEM
)
3339 sym_addr
= dbxout_expand_expr (DECL_VALUE_EXPR (decl
));
3340 if (sym_addr
== NULL_RTX
|| GET_CODE (sym_addr
) != MEM
)
3343 sym_addr
= XEXP (sym_addr
, 0);
3344 if (GET_CODE (sym_addr
) == CONST
)
3345 sym_addr
= XEXP (sym_addr
, 0);
3346 if ((GET_CODE (sym_addr
) == SYMBOL_REF
|| GET_CODE (sym_addr
) == PLUS
)
3347 && DECL_INITIAL (decl
) == 0)
3350 /* We have a sym that will go into a common area, meaning that it
3351 will get storage reserved with a .comm/.lcomm assembler pseudo-op.
3353 Determine name of common area this symbol will be an offset into,
3354 and offset into that area. Also retrieve the decl for the area
3355 that the symbol is offset into. */
3358 switch (GET_CODE (sym_addr
))
3361 if (CONST_INT_P (XEXP (sym_addr
, 0)))
3364 targetm
.strip_name_encoding (XSTR (XEXP (sym_addr
, 1), 0));
3365 *value
= INTVAL (XEXP (sym_addr
, 0));
3366 cdecl = SYMBOL_REF_DECL (XEXP (sym_addr
, 1));
3371 targetm
.strip_name_encoding (XSTR (XEXP (sym_addr
, 0), 0));
3372 *value
= INTVAL (XEXP (sym_addr
, 1));
3373 cdecl = SYMBOL_REF_DECL (XEXP (sym_addr
, 0));
3378 name
= targetm
.strip_name_encoding (XSTR (sym_addr
, 0));
3380 cdecl = SYMBOL_REF_DECL (sym_addr
);
3384 error ("common symbol debug info is not structured as "
3388 /* Check area common symbol is offset into. If this is not public, then
3389 it is not a symbol in a common block. It must be a .lcomm symbol, not
3391 if (cdecl == NULL
|| !TREE_PUBLIC (cdecl))
3400 /* Output definitions of all the decls in a chain. Return nonzero if
3401 anything was output */
3404 dbxout_syms (tree syms
)
3407 const char *comm_prev
= NULL
;
3408 tree syms_prev
= NULL
;
3412 int temp
, copen
, cclos
;
3413 const char *comm_new
;
3415 /* Check for common symbol, and then progression into a new/different
3416 block of common symbols. Emit closing/opening common bracket if
3418 comm_new
= dbxout_common_check (syms
, &temp
);
3419 copen
= comm_new
!= NULL
3420 && (comm_prev
== NULL
|| strcmp (comm_new
, comm_prev
));
3421 cclos
= comm_prev
!= NULL
3422 && (comm_new
== NULL
|| strcmp (comm_new
, comm_prev
));
3424 dbxout_common_name (syms_prev
, comm_prev
, N_ECOMM
);
3427 dbxout_common_name (syms
, comm_new
, N_BCOMM
);
3430 comm_prev
= comm_new
;
3432 result
+= dbxout_symbol (syms
, 1);
3433 syms
= DECL_CHAIN (syms
);
3436 if (comm_prev
!= NULL
)
3437 dbxout_common_name (syms_prev
, comm_prev
, N_ECOMM
);
3442 /* The following two functions output definitions of function parameters.
3443 Each parameter gets a definition locating it in the parameter list.
3444 Each parameter that is a register variable gets a second definition
3445 locating it in the register.
3447 Printing or argument lists in gdb uses the definitions that
3448 locate in the parameter list. But reference to the variable in
3449 expressions uses preferentially the definition as a register. */
3451 /* Output definitions, referring to storage in the parmlist,
3452 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
3455 dbxout_parms (tree parms
)
3458 emit_pending_bincls_if_required ();
3459 fixed_size_mode rtl_mode
, type_mode
;
3461 for (; parms
; parms
= DECL_CHAIN (parms
))
3462 if (DECL_NAME (parms
)
3463 && TREE_TYPE (parms
) != error_mark_node
3464 && DECL_RTL_SET_P (parms
)
3465 && DECL_INCOMING_RTL (parms
)
3466 /* We can't represent variable-sized types in this format. */
3467 && is_a
<fixed_size_mode
> (TYPE_MODE (TREE_TYPE (parms
)), &type_mode
)
3468 && is_a
<fixed_size_mode
> (GET_MODE (DECL_RTL (parms
)), &rtl_mode
))
3472 stab_code_type code
;
3475 /* Perform any necessary register eliminations on the parameter's rtl,
3476 so that the debugging output will be accurate. */
3477 DECL_INCOMING_RTL (parms
)
3478 = eliminate_regs (DECL_INCOMING_RTL (parms
), VOIDmode
, NULL_RTX
);
3479 SET_DECL_RTL (parms
,
3480 eliminate_regs (DECL_RTL (parms
), VOIDmode
, NULL_RTX
));
3481 #ifdef LEAF_REG_REMAP
3482 if (crtl
->uses_only_leaf_regs
)
3484 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
3485 leaf_renumber_regs_insn (DECL_RTL (parms
));
3489 if (PARM_PASSED_IN_MEMORY (parms
))
3491 rtx inrtl
= XEXP (DECL_INCOMING_RTL (parms
), 0);
3493 /* ??? Here we assume that the parm address is indexed
3494 off the frame pointer or arg pointer.
3495 If that is not true, we produce meaningless results,
3496 but do not crash. */
3497 if (GET_CODE (inrtl
) == PLUS
3498 && CONST_INT_P (XEXP (inrtl
, 1)))
3499 number
= INTVAL (XEXP (inrtl
, 1));
3504 number
= DEBUGGER_ARG_OFFSET (number
, inrtl
);
3507 /* It is quite tempting to use TREE_TYPE (parms) instead
3508 of DECL_ARG_TYPE (parms) for the eff_type, so that gcc
3509 reports the actual type of the parameter, rather than
3510 the promoted type. This certainly makes GDB's life
3511 easier, at least for some ports. The change is a bad
3512 idea however, since GDB expects to be able access the
3513 type without performing any conversions. So for
3514 example, if we were passing a float to an unprototyped
3515 function, gcc will store a double on the stack, but if
3516 we emit a stab saying the type is a float, then gdb
3517 will only read in a single value, and this will produce
3518 an erroneous value. */
3519 eff_type
= DECL_ARG_TYPE (parms
);
3521 else if (REG_P (DECL_RTL (parms
)))
3525 /* Parm passed in registers and lives in registers or nowhere. */
3526 code
= DBX_REGPARM_STABS_CODE
;
3527 letter
= DBX_REGPARM_STABS_LETTER
;
3529 /* For parms passed in registers, it is better to use the
3530 declared type of the variable, not the type it arrived in. */
3531 eff_type
= TREE_TYPE (parms
);
3533 /* If parm lives in a register, use that register; pretend
3534 the parm was passed there. It would be more consistent
3535 to describe the register where the parm was passed, but
3536 in practice that register usually holds something else.
3537 If the parm lives nowhere, use the register where it
3539 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
3540 best_rtl
= DECL_RTL (parms
);
3541 else if (GET_CODE (DECL_INCOMING_RTL (parms
)) == PARALLEL
)
3542 best_rtl
= XEXP (XVECEXP (DECL_INCOMING_RTL (parms
), 0, 0), 0);
3544 best_rtl
= DECL_INCOMING_RTL (parms
);
3546 number
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
3548 else if (MEM_P (DECL_RTL (parms
))
3549 && REG_P (XEXP (DECL_RTL (parms
), 0))
3550 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
3551 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
3552 #if !HARD_FRAME_POINTER_IS_ARG_POINTER
3553 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
3557 /* Parm was passed via invisible reference.
3558 That is, its address was passed in a register.
3559 Output it as if it lived in that register.
3560 The debugger will know from the type
3561 that it was actually passed by invisible reference. */
3563 code
= DBX_REGPARM_STABS_CODE
;
3565 /* GDB likes this marked with a special letter. */
3566 letter
= (use_gnu_debug_info_extensions
3567 ? 'a' : DBX_REGPARM_STABS_LETTER
);
3568 eff_type
= TREE_TYPE (parms
);
3570 /* DECL_RTL looks like (MEM (REG...). Get the register number.
3571 If it is an unallocated pseudo-reg, then use the register where
3572 it was passed instead.
3573 ??? Why is DBX_REGISTER_NUMBER not used here? */
3575 if (REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
3576 number
= REGNO (XEXP (DECL_RTL (parms
), 0));
3578 number
= REGNO (DECL_INCOMING_RTL (parms
));
3580 else if (MEM_P (DECL_RTL (parms
))
3581 && MEM_P (XEXP (DECL_RTL (parms
), 0)))
3583 /* Parm was passed via invisible reference, with the reference
3584 living on the stack. DECL_RTL looks like
3585 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
3586 could look like (MEM (MEM (REG))). */
3590 eff_type
= TREE_TYPE (parms
);
3592 if (!REG_P (XEXP (XEXP (DECL_RTL (parms
), 0), 0)))
3593 number
= INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
3597 number
= DEBUGGER_ARG_OFFSET (number
,
3598 XEXP (XEXP (DECL_RTL (parms
), 0), 0));
3600 else if (MEM_P (DECL_RTL (parms
))
3601 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
3602 /* ??? A constant address for a parm can happen
3603 when the reg it lives in is equiv to a constant in memory.
3604 Should make this not happen, after 2.4. */
3605 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
3607 /* Parm was passed in registers but lives on the stack. */
3611 eff_type
= TREE_TYPE (parms
);
3613 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
3614 in which case we want the value of that CONST_INT,
3616 in which case we use a value of zero. */
3617 if (!REG_P (XEXP (DECL_RTL (parms
), 0)))
3618 number
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
3622 /* Make a big endian correction if the mode of the type of the
3623 parameter is not the same as the mode of the rtl. */
3624 if (BYTES_BIG_ENDIAN
3625 && type_mode
!= rtl_mode
3626 && GET_MODE_SIZE (type_mode
) < UNITS_PER_WORD
)
3627 number
+= GET_MODE_SIZE (rtl_mode
) - GET_MODE_SIZE (type_mode
);
3630 /* ??? We don't know how to represent this argument. */
3633 dbxout_begin_complex_stabs ();
3635 if (DECL_NAME (parms
))
3637 stabstr_I (DECL_NAME (parms
));
3641 stabstr_S ("(anon):");
3643 dbxout_type (eff_type
, 0);
3644 dbxout_finish_complex_stabs (parms
, code
, 0, 0, number
);
3646 DBXOUT_DECR_NESTING
;
3649 /* Output definitions for the places where parms live during the function,
3650 when different from where they were passed, when the parms were passed
3653 It is not useful to do this for parms passed in registers
3654 that live during the function in different registers, because it is
3655 impossible to look in the passed register for the passed value,
3656 so we use the within-the-function register to begin with.
3658 PARMS is a chain of PARM_DECL nodes. */
3661 dbxout_reg_parms (tree parms
)
3665 for (; parms
; parms
= DECL_CHAIN (parms
))
3666 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
3668 /* Report parms that live in registers during the function
3669 but were passed in memory. */
3670 if (REG_P (DECL_RTL (parms
))
3671 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
3672 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
3673 0, DECL_RTL (parms
));
3674 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
3675 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
3676 0, DECL_RTL (parms
));
3677 /* Report parms that live in memory but not where they were passed. */
3678 else if (MEM_P (DECL_RTL (parms
))
3679 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
3680 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
3681 0, DECL_RTL (parms
));
3683 DBXOUT_DECR_NESTING
;
3686 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
3687 output definitions of those names, in raw form */
3690 dbxout_args (tree args
)
3695 dbxout_type (TREE_VALUE (args
), 0);
3696 args
= TREE_CHAIN (args
);
3700 #if defined (DBX_DEBUGGING_INFO)
3702 /* Subroutine of dbxout_block. Emit an N_LBRAC stab referencing LABEL.
3703 BEGIN_LABEL is the name of the beginning of the function, which may
3706 dbx_output_lbrac (const char *label
,
3707 const char *begin_label ATTRIBUTE_UNUSED
)
3709 dbxout_begin_stabn (N_LBRAC
);
3710 if (DBX_BLOCKS_FUNCTION_RELATIVE
)
3711 dbxout_stab_value_label_diff (label
, begin_label
);
3713 dbxout_stab_value_label (label
);
3716 /* Subroutine of dbxout_block. Emit an N_RBRAC stab referencing LABEL.
3717 BEGIN_LABEL is the name of the beginning of the function, which may
3720 dbx_output_rbrac (const char *label
,
3721 const char *begin_label ATTRIBUTE_UNUSED
)
3723 dbxout_begin_stabn (N_RBRAC
);
3724 if (DBX_BLOCKS_FUNCTION_RELATIVE
)
3725 dbxout_stab_value_label_diff (label
, begin_label
);
3727 dbxout_stab_value_label (label
);
3730 /* Return true if at least one block among BLOCK, its children or siblings
3731 has TREE_USED, TREE_ASM_WRITTEN and BLOCK_IN_COLD_SECTION_P
3732 set. If there is none, clear TREE_USED bit on such blocks. */
3735 dbx_block_with_cold_children (tree block
)
3738 for (; block
; block
= BLOCK_CHAIN (block
))
3739 if (TREE_USED (block
) && TREE_ASM_WRITTEN (block
))
3741 bool children
= dbx_block_with_cold_children (BLOCK_SUBBLOCKS (block
));
3742 if (BLOCK_IN_COLD_SECTION_P (block
) || children
)
3745 TREE_USED (block
) = false;
3750 /* Output everything about a symbol block (a BLOCK node
3751 that represents a scope level),
3752 including recursive output of contained blocks.
3754 BLOCK is the BLOCK node.
3755 DEPTH is its depth within containing symbol blocks.
3756 ARGS is usually zero; but for the outermost block of the
3757 body of a function, it is a chain of PARM_DECLs for the function parameters.
3758 We output definitions of all the register parms
3759 as if they were local variables of that block.
3761 If -g1 was used, we count blocks just the same, but output nothing
3762 except for the outermost block.
3764 Actually, BLOCK may be several blocks chained together.
3765 We handle them all in sequence.
3767 Return true if we emitted any LBRAC/RBRAC. */
3770 dbxout_block (tree block
, int depth
, tree args
, int parent_blocknum
)
3773 char begin_label
[20];
3774 /* Reference current function start using LFBB. */
3775 ASM_GENERATE_INTERNAL_LABEL (begin_label
, "LFBB", scope_labelno
);
3777 /* If called for the second partition, ignore blocks that don't have
3778 any children in the second partition. */
3779 if (crtl
->has_bb_partition
&& in_cold_section_p
&& depth
== 0)
3780 dbx_block_with_cold_children (block
);
3782 for (; block
; block
= BLOCK_CHAIN (block
))
3784 /* Ignore blocks never expanded or otherwise marked as real. */
3785 if (TREE_USED (block
) && TREE_ASM_WRITTEN (block
))
3788 int blocknum
= BLOCK_NUMBER (block
);
3789 int this_parent
= parent_blocknum
;
3791 /* In dbx format, the syms of a block come before the N_LBRAC.
3792 If nothing is output, we don't need the N_LBRAC, either. */
3794 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
3795 did_output
= dbxout_syms (BLOCK_VARS (block
));
3797 dbxout_reg_parms (args
);
3799 /* Now output an N_LBRAC symbol to represent the beginning of
3800 the block. Use the block's tree-walk order to generate
3801 the assembler symbols LBBn and LBEn
3802 that final will define around the code in this block. */
3804 && BLOCK_IN_COLD_SECTION_P (block
) == in_cold_section_p
)
3807 const char *scope_start
;
3811 /* The outermost block doesn't get LBB labels; use
3812 the LFBB local symbol emitted by dbxout_begin_prologue. */
3813 scope_start
= begin_label
;
3816 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
3818 this_parent
= blocknum
;
3821 dbx_output_lbrac (scope_start
, begin_label
);
3824 /* Output the subblocks. */
3826 = dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
,
3830 /* Refer to the marker for the end of the block. */
3832 && BLOCK_IN_COLD_SECTION_P (block
) == in_cold_section_p
)
3836 /* The outermost block doesn't get LBE labels;
3837 use the "scope" label which will be emitted
3838 by dbxout_function_end. */
3839 ASM_GENERATE_INTERNAL_LABEL (buf
, "Lscope", scope_labelno
);
3841 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
3843 dbx_output_rbrac (buf
, begin_label
);
3845 else if (did_output
&& !children
)
3847 /* If we emitted any vars and didn't output any LBRAC/RBRAC,
3848 either at this level or any lower level, we need to emit
3849 an empty LBRAC/RBRAC pair now. */
3851 const char *scope_start
;
3854 if (parent_blocknum
== -1)
3855 scope_start
= begin_label
;
3858 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", parent_blocknum
);
3862 dbx_output_lbrac (scope_start
, begin_label
);
3863 dbx_output_rbrac (scope_start
, begin_label
);
3870 /* Output the information about a function and its arguments and result.
3871 Usually this follows the function's code,
3872 but on some systems, it comes before. */
3875 dbxout_begin_function (tree decl
)
3877 int saved_tree_used1
;
3879 saved_tree_used1
= TREE_USED (decl
);
3880 TREE_USED (decl
) = 1;
3881 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3883 int saved_tree_used2
= TREE_USED (DECL_RESULT (decl
));
3884 TREE_USED (DECL_RESULT (decl
)) = 1;
3885 dbxout_symbol (decl
, 0);
3886 TREE_USED (DECL_RESULT (decl
)) = saved_tree_used2
;
3889 dbxout_symbol (decl
, 0);
3890 TREE_USED (decl
) = saved_tree_used1
;
3892 dbxout_parms (DECL_ARGUMENTS (decl
));
3893 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3894 dbxout_symbol (DECL_RESULT (decl
), 1);
3896 #endif /* DBX_DEBUGGING_INFO */
3898 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3900 /* Record an element in the table of global destructors. SYMBOL is
3901 a SYMBOL_REF of the function to be called; PRIORITY is a number
3902 between 0 and MAX_INIT_PRIORITY. */
3905 default_stabs_asm_out_destructor (rtx symbol ATTRIBUTE_UNUSED
,
3906 int priority ATTRIBUTE_UNUSED
)
3908 #if defined DBX_DEBUGGING_INFO || defined XCOFF_DEBUGGING_INFO
3909 /* Tell GNU LD that this is part of the static destructor set.
3910 This will work for any system that uses stabs, most usefully
3912 dbxout_begin_simple_stabs ("___DTOR_LIST__", 22 /* N_SETT */);
3913 dbxout_stab_value_label (XSTR (symbol
, 0));
3915 sorry ("global destructors not supported on this target");
3919 /* Likewise for global constructors. */
3922 default_stabs_asm_out_constructor (rtx symbol ATTRIBUTE_UNUSED
,
3923 int priority ATTRIBUTE_UNUSED
)
3925 #if defined DBX_DEBUGGING_INFO || defined XCOFF_DEBUGGING_INFO
3926 /* Tell GNU LD that this is part of the static destructor set.
3927 This will work for any system that uses stabs, most usefully
3929 dbxout_begin_simple_stabs ("___CTOR_LIST__", 22 /* N_SETT */);
3930 dbxout_stab_value_label (XSTR (symbol
, 0));
3932 sorry ("global constructors not supported on this target");
3936 #include "gt-dbxout.h"