1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /* Output dbx-format symbol table data.
24 This consists of many symbol table entries, each of them
25 a .stabs assembler pseudo-op with four operands:
26 a "name" which is really a description of one symbol and its type,
27 a "code", which is a symbol defined in stab.h whose name starts with N_,
28 an unused operand always 0,
29 and a "value" which is an address or an offset.
30 The name is enclosed in doublequote characters.
32 Each function, variable, typedef, and structure tag
33 has a symbol table entry to define it.
34 The beginning and end of each level of name scoping within
35 a function are also marked by special symbol table entries.
37 The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
38 and a data type number. The data type number may be followed by
39 "=" and a type definition; normally this will happen the first time
40 the type number is mentioned. The type definition may refer to
41 other types by number, and those type numbers may be followed
42 by "=" and nested definitions.
44 This can make the "name" quite long.
45 When a name is more than 80 characters, we split the .stabs pseudo-op
46 into two .stabs pseudo-ops, both sharing the same "code" and "value".
47 The first one is marked as continued with a double-backslash at the
50 The kind-of-symbol letter distinguished function names from global
51 variables from file-scope variables from parameters from auto
52 variables in memory from typedef names from register variables.
55 The "code" is mostly redundant with the kind-of-symbol letter
56 that goes in the "name", but not entirely: for symbols located
57 in static storage, the "code" says which segment the address is in,
58 which controls how it is relocated.
60 The "value" for a symbol in static storage
61 is the core address of the symbol (actually, the assembler
62 label for the symbol). For a symbol located in a stack slot
63 it is the stack offset; for one in a register, the register number.
64 For a typedef symbol, it is zero.
66 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
67 output while in the text section.
69 For more on data type definitions, see `dbxout_type'. */
73 #include "coretypes.h"
80 #include "insn-config.h"
82 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
90 #include "langhooks.h"
92 #ifdef XCOFF_DEBUGGING_INFO
96 #undef DBXOUT_DECR_NESTING
97 #define DBXOUT_DECR_NESTING \
98 if (--debug_nesting == 0 && symbol_queue_index > 0) \
99 { emit_pending_bincls_if_required (); debug_flush_symbol_queue (); }
101 #undef DBXOUT_DECR_NESTING_AND_RETURN
102 #define DBXOUT_DECR_NESTING_AND_RETURN(x) \
103 do {--debug_nesting; return (x);} while (0)
106 #define ASM_STABS_OP "\t.stabs\t"
110 #define ASM_STABN_OP "\t.stabn\t"
113 #ifndef DBX_TYPE_DECL_STABS_CODE
114 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
117 #ifndef DBX_STATIC_CONST_VAR_CODE
118 #define DBX_STATIC_CONST_VAR_CODE N_FUN
121 #ifndef DBX_REGPARM_STABS_CODE
122 #define DBX_REGPARM_STABS_CODE N_RSYM
125 #ifndef DBX_REGPARM_STABS_LETTER
126 #define DBX_REGPARM_STABS_LETTER 'P'
129 /* This is used for parameters passed by invisible reference in a register. */
130 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
131 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
134 #ifndef DBX_MEMPARM_STABS_LETTER
135 #define DBX_MEMPARM_STABS_LETTER 'p'
138 #ifndef FILE_NAME_JOINER
139 #define FILE_NAME_JOINER "/"
142 /* GDB needs to know that the stabs were generated by GCC. We emit an
143 N_OPT stab at the beginning of the source file to indicate this.
144 The string is historical, and different on a very few targets. */
145 #ifndef STABS_GCC_MARKER
146 #define STABS_GCC_MARKER "gcc2_compiled."
149 enum typestatus
{TYPE_UNSEEN
, TYPE_XREF
, TYPE_DEFINED
};
151 /* Structure recording information about a C data type.
152 The status element says whether we have yet output
153 the definition of the type. TYPE_XREF says we have
154 output it as a cross-reference only.
155 The file_number and type_number elements are used if DBX_USE_BINCL
158 struct typeinfo
GTY(())
160 enum typestatus status
;
165 /* Vector recording information about C data types.
166 When we first notice a data type (a tree node),
167 we assign it a number using next_type_number.
168 That is its index in this vector. */
170 static GTY ((length ("typevec_len"))) struct typeinfo
*typevec
;
172 /* Number of elements of space allocated in `typevec'. */
174 static GTY(()) int typevec_len
;
176 /* In dbx output, each type gets a unique number.
177 This is the number for the next type output.
178 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
180 static GTY(()) int next_type_number
;
182 /* The C front end may call dbxout_symbol before dbxout_init runs.
183 We save all such decls in this list and output them when we get
186 static GTY(()) tree preinit_symbols
;
188 enum binclstatus
{BINCL_NOT_REQUIRED
, BINCL_PENDING
, BINCL_PROCESSED
};
190 /* When using N_BINCL in dbx output, each type number is actually a
191 pair of the file number and the type number within the file.
192 This is a stack of input files. */
196 struct dbx_file
*next
;
198 int next_type_number
;
199 enum binclstatus bincl_status
; /* Keep track of lazy bincl. */
200 const char *pending_bincl_name
; /* Name of bincl. */
201 struct dbx_file
*prev
; /* Chain to traverse all pending bincls. */
204 /* This is the top of the stack.
206 This is not saved for PCH, because restoring a PCH should not change it.
207 next_file_number does have to be saved, because the PCH may use some
208 file numbers; however, just before restoring a PCH, next_file_number
209 should always be 0 because we should not have needed any file numbers
212 #if (defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)) \
213 && defined (DBX_USE_BINCL)
214 static struct dbx_file
*current_file
;
217 /* This is the next file number to use. */
219 static GTY(()) int next_file_number
;
221 /* A counter for dbxout_function_end. */
223 static GTY(()) int scope_labelno
;
225 /* A counter for dbxout_source_line. */
227 static GTY(()) int dbxout_source_line_counter
;
229 /* Nonzero if we have actually used any of the GDB extensions
230 to the debugging format. The idea is that we use them for the
231 first time only if there's a strong reason, but once we have done that,
232 we use them whenever convenient. */
234 static GTY(()) int have_used_extensions
= 0;
236 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
237 for the N_SO filename stabs label. */
239 static GTY(()) int source_label_number
= 1;
241 /* Last source file name mentioned in a NOTE insn. */
243 static GTY(()) const char *lastfile
;
245 /* Used by PCH machinery to detect if 'lastfile' should be reset to
247 static GTY(()) int lastfile_is_base
;
249 /* Typical USG systems don't have stab.h, and they also have
250 no use for DBX-format debugging info. */
252 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
255 /* If zero then there is no pending BINCL. */
256 static int pending_bincls
= 0;
259 /* The original input file name. */
260 static const char *base_input_file
;
262 /* Current working directory. */
264 static const char *cwd
;
266 #ifdef DEBUG_SYMS_TEXT
267 #define FORCE_TEXT function_section (current_function_decl);
274 #define STAB_CODE_TYPE enum __stab_debug_code
276 /* 1 if PARM is passed to this function in memory. */
278 #define PARM_PASSED_IN_MEMORY(PARM) \
279 (MEM_P (DECL_INCOMING_RTL (PARM)))
281 /* A C expression for the integer offset value of an automatic variable
282 (N_LSYM) having address X (an RTX). */
283 #ifndef DEBUGGER_AUTO_OFFSET
284 #define DEBUGGER_AUTO_OFFSET(X) \
285 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
288 /* A C expression for the integer offset value of an argument (N_PSYM)
289 having address X (an RTX). The nominal offset is OFFSET. */
290 #ifndef DEBUGGER_ARG_OFFSET
291 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
294 /* Stream for writing to assembler file. */
296 static FILE *asmfile
;
298 /* These variables are for dbxout_symbol to communicate to
299 dbxout_finish_symbol.
300 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
301 current_sym_value and current_sym_addr are two ways to address the
302 value to store in the symtab entry.
303 current_sym_addr if nonzero represents the value as an rtx.
304 If that is zero, current_sym_value is used. This is used
305 when the value is an offset (such as for auto variables,
306 register variables and parms). */
308 static STAB_CODE_TYPE current_sym_code
;
309 static int current_sym_value
;
310 static rtx current_sym_addr
;
312 /* Number of chars of symbol-description generated so far for the
313 current symbol. Used by CHARS and CONTIN. */
315 static int current_sym_nchars
;
317 /* Report having output N chars of the current symbol-description. */
319 #define CHARS(N) (current_sym_nchars += (N))
321 /* Break the current symbol-description, generating a continuation,
322 if it has become long. */
324 #ifndef DBX_CONTIN_LENGTH
325 #define DBX_CONTIN_LENGTH 80
328 #if DBX_CONTIN_LENGTH > 0
330 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
332 #define CONTIN do { } while (0)
336 static void emit_bincl_stab (const char *c
);
337 static void emit_pending_bincls (void);
339 static inline void emit_pending_bincls_if_required (void);
341 static void dbxout_init (const char *);
342 static void dbxout_finish (const char *);
343 static void dbxout_start_source_file (unsigned, const char *);
344 static void dbxout_end_source_file (unsigned);
345 static void dbxout_typedefs (tree
);
346 static void dbxout_type_index (tree
);
347 #if DBX_CONTIN_LENGTH > 0
348 static void dbxout_continue (void);
350 static void dbxout_args (tree
);
351 static void dbxout_type_fields (tree
);
352 static void dbxout_type_method_1 (tree
, const char *);
353 static void dbxout_type_methods (tree
);
354 static void dbxout_range_type (tree
);
355 static void dbxout_type (tree
, int);
356 static bool print_int_cst_bounds_in_octal_p (tree
);
357 static void print_int_cst_octal (tree
);
358 static void print_octal (unsigned HOST_WIDE_INT
, int);
359 static void print_wide_int (HOST_WIDE_INT
);
360 static void dbxout_type_name (tree
);
361 static void dbxout_class_name_qualifiers (tree
);
362 static int dbxout_symbol_location (tree
, tree
, const char *, rtx
);
363 static void dbxout_symbol_name (tree
, const char *, int);
364 static void dbxout_prepare_symbol (tree
);
365 static void dbxout_finish_symbol (tree
);
366 static void dbxout_block (tree
, int, tree
);
367 static void dbxout_global_decl (tree
);
368 static void dbxout_type_decl (tree
, int);
369 static void dbxout_handle_pch (unsigned);
371 /* The debug hooks structure. */
372 #if defined (DBX_DEBUGGING_INFO)
374 static void dbxout_source_line (unsigned int, const char *);
375 static void dbxout_source_file (FILE *, const char *);
376 static void dbxout_function_end (void);
377 static void dbxout_begin_function (tree
);
378 static void dbxout_begin_block (unsigned, unsigned);
379 static void dbxout_end_block (unsigned, unsigned);
380 static void dbxout_function_decl (tree
);
382 const struct gcc_debug_hooks dbx_debug_hooks
=
386 debug_nothing_int_charstar
,
387 debug_nothing_int_charstar
,
388 dbxout_start_source_file
,
389 dbxout_end_source_file
,
392 debug_true_tree
, /* ignore_block */
393 dbxout_source_line
, /* source_line */
394 dbxout_source_line
, /* begin_prologue: just output
396 debug_nothing_int_charstar
, /* end_prologue */
397 debug_nothing_int_charstar
, /* end_epilogue */
398 #ifdef DBX_FUNCTION_FIRST
399 dbxout_begin_function
,
401 debug_nothing_tree
, /* begin_function */
403 debug_nothing_int
, /* end_function */
404 dbxout_function_decl
,
405 dbxout_global_decl
, /* global_decl */
406 dbxout_type_decl
, /* type_decl */
407 debug_nothing_tree_tree
, /* imported_module_or_decl */
408 debug_nothing_tree
, /* deferred_inline_function */
409 debug_nothing_tree
, /* outlining_inline_function */
410 debug_nothing_rtx
, /* label */
411 dbxout_handle_pch
, /* handle_pch */
412 debug_nothing_rtx
/* var_location */
414 #endif /* DBX_DEBUGGING_INFO */
416 #if defined (XCOFF_DEBUGGING_INFO)
417 const struct gcc_debug_hooks xcoff_debug_hooks
=
421 debug_nothing_int_charstar
,
422 debug_nothing_int_charstar
,
423 dbxout_start_source_file
,
424 dbxout_end_source_file
,
425 xcoffout_begin_block
,
427 debug_true_tree
, /* ignore_block */
428 xcoffout_source_line
,
429 xcoffout_begin_prologue
, /* begin_prologue */
430 debug_nothing_int_charstar
, /* end_prologue */
431 xcoffout_end_epilogue
,
432 debug_nothing_tree
, /* begin_function */
433 xcoffout_end_function
,
434 debug_nothing_tree
, /* function_decl */
435 dbxout_global_decl
, /* global_decl */
436 dbxout_type_decl
, /* type_decl */
437 debug_nothing_tree_tree
, /* imported_module_or_decl */
438 debug_nothing_tree
, /* deferred_inline_function */
439 debug_nothing_tree
, /* outlining_inline_function */
440 debug_nothing_rtx
, /* label */
441 dbxout_handle_pch
, /* handle_pch */
442 debug_nothing_rtx
/* var_location */
444 #endif /* XCOFF_DEBUGGING_INFO */
446 #if defined (DBX_DEBUGGING_INFO)
448 dbxout_function_end (void)
450 char lscope_label_name
[100];
452 /* The Lscope label must be emitted even if we aren't doing anything
453 else; dbxout_block needs it. */
454 function_section (current_function_decl
);
456 /* Convert Ltext into the appropriate format for local labels in case
457 the system doesn't insert underscores in front of user generated
459 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name
, "Lscope", scope_labelno
);
460 targetm
.asm_out
.internal_label (asmfile
, "Lscope", scope_labelno
);
463 /* The N_FUN tag at the end of the function is a GNU extension,
464 which may be undesirable, and is unnecessary if we do not have
466 if (!use_gnu_debug_info_extensions
467 #if defined(NO_DBX_FUNCTION_END)
468 || NO_DBX_FUNCTION_END
470 || !targetm
.have_named_sections
)
473 /* By convention, GCC will mark the end of a function with an N_FUN
474 symbol and an empty string. */
475 #ifdef DBX_OUTPUT_NFUN
476 DBX_OUTPUT_NFUN (asmfile
, lscope_label_name
, current_function_decl
);
478 fprintf (asmfile
, "%s\"\",%d,0,0,", ASM_STABS_OP
, N_FUN
);
479 assemble_name (asmfile
, lscope_label_name
);
481 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
482 fprintf (asmfile
, "\n");
485 #endif /* DBX_DEBUGGING_INFO */
487 /* At the beginning of compilation, start writing the symbol table.
488 Initialize `typevec' and output the standard data types of C. */
491 dbxout_init (const char *input_file_name
)
493 char ltext_label_name
[100];
494 tree syms
= lang_hooks
.decls
.getdecls ();
496 asmfile
= asm_out_file
;
499 typevec
= ggc_calloc (typevec_len
, sizeof typevec
[0]);
501 /* Convert Ltext into the appropriate format for local labels in case
502 the system doesn't insert underscores in front of user generated
504 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
506 /* Put the current working directory in an N_SO symbol. */
507 if (use_gnu_debug_info_extensions
)
509 if (!cwd
&& (cwd
= get_src_pwd ())
510 && (!*cwd
|| cwd
[strlen (cwd
) - 1] != '/'))
511 cwd
= concat (cwd
, FILE_NAME_JOINER
, NULL
);
514 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
515 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile
, cwd
);
516 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
517 fprintf (asmfile
, "%s", ASM_STABS_OP
);
518 output_quoted_string (asmfile
, cwd
);
519 fprintf (asmfile
, ",%d,0,0,", N_SO
);
520 assemble_name (asmfile
, ltext_label_name
);
521 fputc ('\n', asmfile
);
522 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
526 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
527 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile
, input_file_name
);
528 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
529 /* We include outputting `Ltext:' here,
530 because that gives you a way to override it. */
531 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
532 fprintf (asmfile
, "%s", ASM_STABS_OP
);
533 output_quoted_string (asmfile
, input_file_name
);
534 fprintf (asmfile
, ",%d,0,0,", N_SO
);
535 assemble_name (asmfile
, ltext_label_name
);
536 fputc ('\n', asmfile
);
538 targetm
.asm_out
.internal_label (asmfile
, "Ltext", 0);
539 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
541 #ifdef DBX_OUTPUT_GCC_MARKER
542 DBX_OUTPUT_GCC_MARKER (asmfile
);
544 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
545 fprintf (asmfile
, "%s\"%s\",%d,0,0,0\n",
546 ASM_STABS_OP
, STABS_GCC_MARKER
, N_OPT
);
549 base_input_file
= lastfile
= input_file_name
;
551 next_type_number
= 1;
554 current_file
= xmalloc (sizeof *current_file
);
555 current_file
->next
= NULL
;
556 current_file
->file_number
= 0;
557 current_file
->next_type_number
= 1;
558 next_file_number
= 1;
559 current_file
->prev
= NULL
;
560 current_file
->bincl_status
= BINCL_NOT_REQUIRED
;
561 current_file
->pending_bincl_name
= NULL
;
564 /* Get all permanent types that have typedef names, and output them
565 all, except for those already output. Some language front ends
566 put these declarations in the top-level scope; some do not;
567 the latter are responsible for calling debug_hooks->type_decl from
568 their record_builtin_type function. */
569 dbxout_typedefs (syms
);
574 for (t
= nreverse (preinit_symbols
); t
; t
= TREE_CHAIN (t
))
575 dbxout_symbol (TREE_VALUE (t
), 0);
580 /* Output any typedef names for types described by TYPE_DECLs in SYMS. */
583 dbxout_typedefs (tree syms
)
585 for (; syms
!= NULL_TREE
; syms
= TREE_CHAIN (syms
))
587 if (TREE_CODE (syms
) == TYPE_DECL
)
589 tree type
= TREE_TYPE (syms
);
591 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
592 && COMPLETE_OR_VOID_TYPE_P (type
)
593 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
594 dbxout_symbol (TYPE_NAME (type
), 0);
600 /* Emit BINCL stab using given name. */
602 emit_bincl_stab (const char *name
)
604 fprintf (asmfile
, "%s", ASM_STABS_OP
);
605 output_quoted_string (asmfile
, name
);
606 fprintf (asmfile
, ",%d,0,0,0\n", N_BINCL
);
609 /* If there are pending bincls then it is time to emit all of them. */
612 emit_pending_bincls_if_required (void)
615 emit_pending_bincls ();
618 /* Emit all pending bincls. */
621 emit_pending_bincls (void)
623 struct dbx_file
*f
= current_file
;
625 /* Find first pending bincl. */
626 while (f
->bincl_status
== BINCL_PENDING
)
629 /* Now emit all bincls. */
634 if (f
->bincl_status
== BINCL_PENDING
)
636 emit_bincl_stab (f
->pending_bincl_name
);
638 /* Update file number and status. */
639 f
->file_number
= next_file_number
++;
640 f
->bincl_status
= BINCL_PROCESSED
;
642 if (f
== current_file
)
647 /* All pending bincls have been emitted. */
654 emit_pending_bincls_if_required (void) {}
657 /* Change to reading from a new source file. Generate a N_BINCL stab. */
660 dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED
,
661 const char *filename ATTRIBUTE_UNUSED
)
664 struct dbx_file
*n
= xmalloc (sizeof *n
);
666 n
->next
= current_file
;
667 n
->next_type_number
= 1;
668 /* Do not assign file number now.
669 Delay it until we actually emit BINCL. */
672 current_file
->prev
= n
;
673 n
->bincl_status
= BINCL_PENDING
;
674 n
->pending_bincl_name
= filename
;
680 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
683 dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED
)
686 /* Emit EINCL stab only if BINCL is not pending. */
687 if (current_file
->bincl_status
== BINCL_PROCESSED
)
688 fprintf (asmfile
, "%s%d,0,0,0\n", ASM_STABN_OP
, N_EINCL
);
689 current_file
->bincl_status
= BINCL_NOT_REQUIRED
;
690 current_file
= current_file
->next
;
694 /* Handle a few odd cases that occur when trying to make PCH files work. */
697 dbxout_handle_pch (unsigned at_end
)
701 /* When using the PCH, this file will be included, so we need to output
703 dbxout_start_source_file (0, lastfile
);
705 /* The base file when using the PCH won't be the same as
706 the base file when it's being generated. */
711 /* ... and an EINCL. */
712 dbxout_end_source_file (0);
714 /* Deal with cases where 'lastfile' was never actually changed. */
715 lastfile_is_base
= lastfile
== NULL
;
719 #if defined (DBX_DEBUGGING_INFO)
720 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
723 dbxout_source_file (FILE *file
, const char *filename
)
725 if (lastfile
== 0 && lastfile_is_base
)
727 lastfile
= base_input_file
;
728 lastfile_is_base
= 0;
731 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
733 char ltext_label_name
[100];
735 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext",
736 source_label_number
);
737 fprintf (file
, "%s", ASM_STABS_OP
);
738 output_quoted_string (file
, filename
);
739 fprintf (asmfile
, ",%d,0,0,", N_SOL
);
740 assemble_name (asmfile
, ltext_label_name
);
741 fputc ('\n', asmfile
);
742 if (current_function_decl
!= NULL_TREE
743 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
744 ; /* Don't change section amid function. */
747 if (!in_text_section () && !in_unlikely_text_section ())
750 targetm
.asm_out
.internal_label (file
, "Ltext", source_label_number
);
751 source_label_number
++;
756 /* Output a line number symbol entry for source file FILENAME and line
760 dbxout_source_line (unsigned int lineno
, const char *filename
)
762 dbxout_source_file (asmfile
, filename
);
764 #ifdef ASM_OUTPUT_SOURCE_LINE
765 dbxout_source_line_counter
+= 1;
766 ASM_OUTPUT_SOURCE_LINE (asmfile
, lineno
, dbxout_source_line_counter
);
768 fprintf (asmfile
, "%s%d,0,%d\n", ASM_STABD_OP
, N_SLINE
, lineno
);
772 /* Describe the beginning of an internal block within a function. */
775 dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED
, unsigned int n
)
777 emit_pending_bincls_if_required ();
778 targetm
.asm_out
.internal_label (asmfile
, "LBB", n
);
781 /* Describe the end line-number of an internal block within a function. */
784 dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED
, unsigned int n
)
786 emit_pending_bincls_if_required ();
787 targetm
.asm_out
.internal_label (asmfile
, "LBE", n
);
790 /* Output dbx data for a function definition.
791 This includes a definition of the function name itself (a symbol),
792 definitions of the parameters (locating them in the parameter list)
793 and then output the block that makes up the function's body
794 (including all the auto variables of the function). */
797 dbxout_function_decl (tree decl
)
799 emit_pending_bincls_if_required ();
800 #ifndef DBX_FUNCTION_FIRST
801 dbxout_begin_function (decl
);
803 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
804 #ifdef DBX_OUTPUT_FUNCTION_END
805 DBX_OUTPUT_FUNCTION_END (asmfile
, decl
);
807 dbxout_function_end ();
810 #endif /* DBX_DEBUGGING_INFO */
812 /* Debug information for a global DECL. Called from toplev.c after
813 compilation proper has finished. */
815 dbxout_global_decl (tree decl
)
817 if (TREE_CODE (decl
) == VAR_DECL
818 && ! DECL_EXTERNAL (decl
)
819 && DECL_RTL_SET_P (decl
)) /* Not necessary? */
821 int saved_tree_used
= TREE_USED (decl
);
822 TREE_USED (decl
) = 1;
823 dbxout_symbol (decl
, 0);
824 TREE_USED (decl
) = saved_tree_used
;
828 /* This is just a function-type adapter; dbxout_symbol does exactly
829 what we want but returns an int. */
831 dbxout_type_decl (tree decl
, int local
)
833 dbxout_symbol (decl
, local
);
836 /* At the end of compilation, finish writing the symbol table.
837 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
841 dbxout_finish (const char *filename ATTRIBUTE_UNUSED
)
843 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
844 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile
, filename
);
845 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
850 /* Output the index of a type. */
853 dbxout_type_index (tree type
)
855 #ifndef DBX_USE_BINCL
856 fprintf (asmfile
, "%d", TYPE_SYMTAB_ADDRESS (type
));
859 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
860 fprintf (asmfile
, "(%d,%d)", t
->file_number
, t
->type_number
);
865 #if DBX_CONTIN_LENGTH > 0
866 /* Continue a symbol-description that gets too big.
867 End one symbol table entry with a double-backslash
868 and start a new one, eventually producing something like
869 .stabs "start......\\",code,0,value
870 .stabs "...rest",code,0,value */
873 dbxout_continue (void)
875 emit_pending_bincls_if_required ();
876 #ifdef DBX_CONTIN_CHAR
877 fprintf (asmfile
, "%c", DBX_CONTIN_CHAR
);
879 fprintf (asmfile
, "\\\\");
881 dbxout_finish_symbol (NULL_TREE
);
882 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
883 current_sym_nchars
= 0;
885 #endif /* DBX_CONTIN_LENGTH > 0 */
887 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
888 This must be a separate function because anonymous unions require
892 dbxout_type_fields (tree type
)
896 /* Output the name, type, position (in bits), size (in bits) of each
897 field that we can support. */
898 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
900 /* If one of the nodes is an error_mark or its type is then
902 if (tem
== error_mark_node
|| TREE_TYPE (tem
) == error_mark_node
)
905 /* Omit here local type decls until we know how to support them. */
906 if (TREE_CODE (tem
) == TYPE_DECL
907 /* Omit fields whose position or size are variable or too large to
909 || (TREE_CODE (tem
) == FIELD_DECL
910 && (! host_integerp (bit_position (tem
), 0)
912 || ! host_integerp (DECL_SIZE (tem
), 1)))
913 /* Omit here the nameless fields that are used to skip bits. */
914 || DECL_IGNORED_P (tem
))
917 else if (TREE_CODE (tem
) != CONST_DECL
)
919 /* Continue the line if necessary,
920 but not before the first field. */
921 if (tem
!= TYPE_FIELDS (type
))
926 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem
)));
927 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem
)));
931 fprintf (asmfile
, ":");
935 if (use_gnu_debug_info_extensions
936 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
937 || TREE_CODE (tem
) != FIELD_DECL
))
939 have_used_extensions
= 1;
941 putc ((TREE_PRIVATE (tem
) ? '0'
942 : TREE_PROTECTED (tem
) ? '1' : '2'),
947 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
948 && DECL_BIT_FIELD_TYPE (tem
))
949 ? DECL_BIT_FIELD_TYPE (tem
) : TREE_TYPE (tem
), 0);
951 if (TREE_CODE (tem
) == VAR_DECL
)
953 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
955 tree name
= DECL_ASSEMBLER_NAME (tem
);
957 have_used_extensions
= 1;
958 fprintf (asmfile
, ":%s;", IDENTIFIER_POINTER (name
));
959 CHARS (IDENTIFIER_LENGTH (name
) + 2);
963 /* If TEM is non-static, GDB won't understand it. */
964 fprintf (asmfile
, ",0,0;");
971 print_wide_int (int_bit_position (tem
));
973 print_wide_int (tree_low_cst (DECL_SIZE (tem
), 1));
981 /* Subroutine of `dbxout_type_methods'. Output debug info about the
982 method described DECL. DEBUG_NAME is an encoding of the method's
983 type signature. ??? We may be able to do without DEBUG_NAME altogether
987 dbxout_type_method_1 (tree decl
, const char *debug_name
)
991 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
993 else /* it's a METHOD_TYPE. */
995 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
996 /* A for normal functions.
997 B for `const' member functions.
998 C for `volatile' member functions.
999 D for `const volatile' member functions. */
1000 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
1002 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
1005 if (DECL_VINDEX (decl
))
1011 fprintf (asmfile
, ":%s;%c%c%c", debug_name
,
1012 TREE_PRIVATE (decl
) ? '0'
1013 : TREE_PROTECTED (decl
) ? '1' : '2', c1
, c2
);
1014 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
)) + 6
1015 - (debug_name
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
))));
1017 if (DECL_VINDEX (decl
) && host_integerp (DECL_VINDEX (decl
), 0))
1019 print_wide_int (tree_low_cst (DECL_VINDEX (decl
), 0));
1020 putc (';', asmfile
);
1022 dbxout_type (DECL_CONTEXT (decl
), 0);
1023 fprintf (asmfile
, ";");
1028 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
1032 dbxout_type_methods (tree type
)
1034 /* C++: put out the method names and their parameter lists */
1035 tree methods
= TYPE_METHODS (type
);
1039 char formatted_type_identifier_length
[16];
1040 int type_identifier_length
;
1042 if (methods
== NULL_TREE
)
1045 type_encoding
= DECL_NAME (TYPE_NAME (type
));
1048 /* C++: Template classes break some assumptions made by this code about
1049 the class names, constructor names, and encodings for assembler
1050 label names. For now, disable output of dbx info for them. */
1052 const char *ptr
= IDENTIFIER_POINTER (type_encoding
);
1053 /* This should use index. (mrs) */
1054 while (*ptr
&& *ptr
!= '<') ptr
++;
1065 type_identifier_length
= IDENTIFIER_LENGTH (type_encoding
);
1067 sprintf (formatted_type_identifier_length
, "%d", type_identifier_length
);
1069 if (TREE_CODE (methods
) != TREE_VEC
)
1071 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
1072 fndecl
= TREE_VEC_ELT (methods
, 0);
1074 fndecl
= TREE_VEC_ELT (methods
, 1);
1078 int need_prefix
= 1;
1080 /* Group together all the methods for the same operation.
1081 These differ in the types of the arguments. */
1082 for (last
= NULL_TREE
;
1083 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
1084 fndecl
= TREE_CHAIN (fndecl
))
1085 /* Output the name of the field (after overloading), as
1086 well as the name of the field before overloading, along
1087 with its parameter list */
1089 /* This is the "mangled" name of the method.
1090 It encodes the argument types. */
1091 const char *debug_name
;
1093 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1094 include TEMPLATE_DECLs.) The debugger doesn't know what
1095 to do with such entities anyhow. */
1096 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
1099 debug_name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
));
1105 /* Also ignore abstract methods; those are only interesting to
1106 the DWARF backends. */
1107 if (DECL_IGNORED_P (fndecl
) || DECL_ABSTRACT (fndecl
))
1110 /* Redundantly output the plain name, since that's what gdb
1114 tree name
= DECL_NAME (fndecl
);
1115 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
1116 CHARS (IDENTIFIER_LENGTH (name
) + 2);
1120 dbxout_type (TREE_TYPE (fndecl
), 0);
1122 dbxout_type_method_1 (fndecl
, debug_name
);
1126 putc (';', asmfile
);
1132 /* Emit a "range" type specification, which has the form:
1133 "r<index type>;<lower bound>;<upper bound>;".
1134 TYPE is an INTEGER_TYPE. */
1137 dbxout_range_type (tree type
)
1139 fprintf (asmfile
, "r");
1140 if (TREE_TYPE (type
))
1141 dbxout_type (TREE_TYPE (type
), 0);
1142 else if (TREE_CODE (type
) != INTEGER_TYPE
)
1143 dbxout_type (type
, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1146 /* Traditionally, we made sure 'int' was type 1, and builtin types
1147 were defined to be sub-ranges of int. Unfortunately, this
1148 does not allow us to distinguish true sub-ranges from integer
1149 types. So, instead we define integer (non-sub-range) types as
1150 sub-ranges of themselves. This matters for Chill. If this isn't
1151 a subrange type, then we want to define it in terms of itself.
1152 However, in C, this may be an anonymous integer type, and we don't
1153 want to emit debug info referring to it. Just calling
1154 dbxout_type_index won't work anyways, because the type hasn't been
1155 defined yet. We make this work for both cases by checked to see
1156 whether this is a defined type, referring to it if it is, and using
1158 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
1159 dbxout_type_index (type
);
1161 dbxout_type_index (integer_type_node
);
1164 if (TYPE_MIN_VALUE (type
) != 0
1165 && host_integerp (TYPE_MIN_VALUE (type
), 0))
1167 putc (';', asmfile
);
1169 if (print_int_cst_bounds_in_octal_p (type
))
1170 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1172 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type
), 0));
1176 fprintf (asmfile
, ";0");
1180 if (TYPE_MAX_VALUE (type
) != 0
1181 && host_integerp (TYPE_MAX_VALUE (type
), 0))
1183 putc (';', asmfile
);
1185 if (print_int_cst_bounds_in_octal_p (type
))
1186 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1188 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type
), 0));
1189 putc (';', asmfile
);
1194 fprintf (asmfile
, ";-1;");
1200 /* Output a reference to a type. If the type has not yet been
1201 described in the dbx output, output its definition now.
1202 For a type already defined, just refer to its definition
1203 using the type number.
1205 If FULL is nonzero, and the type has been described only with
1206 a forward-reference, output the definition now.
1207 If FULL is zero in this case, just refer to the forward-reference
1208 using the number previously allocated. */
1211 dbxout_type (tree type
, int full
)
1215 static int anonymous_type_number
= 0;
1217 if (TREE_CODE (type
) == VECTOR_TYPE
)
1218 /* The frontend feeds us a representation for the vector as a struct
1219 containing an array. Pull out the array type. */
1220 type
= TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type
)));
1222 /* If there was an input error and we don't really have a type,
1223 avoid crashing and write something that is at least valid
1224 by assuming `int'. */
1225 if (type
== error_mark_node
)
1226 type
= integer_type_node
;
1229 if (TYPE_NAME (type
)
1230 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1231 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
1235 /* Try to find the "main variant" with the same name. */
1236 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1237 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1238 main_variant
= TREE_TYPE (TYPE_NAME (type
));
1240 main_variant
= TYPE_MAIN_VARIANT (type
);
1242 /* If we are not using extensions, stabs does not distinguish const and
1243 volatile, so there is no need to make them separate types. */
1244 if (!use_gnu_debug_info_extensions
)
1245 type
= main_variant
;
1247 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
1249 /* Type has no dbx number assigned. Assign next available number. */
1250 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
1252 /* Make sure type vector is long enough to record about this type. */
1254 if (next_type_number
== typevec_len
)
1257 = ggc_realloc (typevec
, (typevec_len
* 2 * sizeof typevec
[0]));
1258 memset (typevec
+ typevec_len
, 0, typevec_len
* sizeof typevec
[0]);
1262 #ifdef DBX_USE_BINCL
1263 emit_pending_bincls_if_required ();
1264 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
1265 = current_file
->file_number
;
1266 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
1267 = current_file
->next_type_number
++;
1271 if (flag_debug_only_used_symbols
)
1273 if ((TREE_CODE (type
) == RECORD_TYPE
1274 || TREE_CODE (type
) == UNION_TYPE
1275 || TREE_CODE (type
) == QUAL_UNION_TYPE
1276 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1277 && TYPE_STUB_DECL (type
)
1278 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (type
))) == 'd'
1279 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type
)))
1280 debug_queue_symbol (TYPE_STUB_DECL (type
));
1281 else if (TYPE_NAME (type
)
1282 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1283 debug_queue_symbol (TYPE_NAME (type
));
1286 /* Output the number of this type, to refer to it. */
1287 dbxout_type_index (type
);
1289 #ifdef DBX_TYPE_DEFINED
1290 if (DBX_TYPE_DEFINED (type
))
1294 /* If this type's definition has been output or is now being output,
1297 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
1302 /* If we have already had a cross reference,
1303 and either that's all we want or that's the best we could do,
1304 don't repeat the cross reference.
1305 Sun dbx crashes if we do. */
1306 if (! full
|| !COMPLETE_TYPE_P (type
)
1307 /* No way in DBX fmt to describe a variable size. */
1308 || ! host_integerp (TYPE_SIZE (type
), 1))
1316 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1317 leave the type-number completely undefined rather than output
1318 a cross-reference. If we have already used GNU debug info extensions,
1319 then it is OK to output a cross reference. This is necessary to get
1320 proper C++ debug output. */
1321 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1322 || TREE_CODE (type
) == QUAL_UNION_TYPE
1323 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1324 && ! use_gnu_debug_info_extensions
)
1325 /* We must use the same test here as we use twice below when deciding
1326 whether to emit a cross-reference. */
1327 if ((TYPE_NAME (type
) != 0
1328 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1329 && DECL_IGNORED_P (TYPE_NAME (type
)))
1331 || !COMPLETE_TYPE_P (type
)
1332 /* No way in DBX fmt to describe a variable size. */
1333 || ! host_integerp (TYPE_SIZE (type
), 1))
1335 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1340 /* Output a definition now. */
1342 fprintf (asmfile
, "=");
1345 /* Mark it as defined, so that if it is self-referent
1346 we will not get into an infinite recursion of definitions. */
1348 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1350 /* If this type is a variant of some other, hand off. Types with
1351 different names are usefully distinguished. We only distinguish
1352 cv-qualified types if we're using extensions. */
1353 if (TYPE_READONLY (type
) > TYPE_READONLY (main_variant
))
1355 putc ('k', asmfile
);
1357 dbxout_type (build_type_variant (type
, 0, TYPE_VOLATILE (type
)), 0);
1360 else if (TYPE_VOLATILE (type
) > TYPE_VOLATILE (main_variant
))
1362 putc ('B', asmfile
);
1364 dbxout_type (build_type_variant (type
, TYPE_READONLY (type
), 0), 0);
1367 else if (main_variant
!= TYPE_MAIN_VARIANT (type
))
1369 if (flag_debug_only_used_symbols
)
1371 tree orig_type
= DECL_ORIGINAL_TYPE (TYPE_NAME (type
));
1373 if ((TREE_CODE (orig_type
) == RECORD_TYPE
1374 || TREE_CODE (orig_type
) == UNION_TYPE
1375 || TREE_CODE (orig_type
) == QUAL_UNION_TYPE
1376 || TREE_CODE (orig_type
) == ENUMERAL_TYPE
)
1377 && TYPE_STUB_DECL (orig_type
)
1378 && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type
)))
1379 debug_queue_symbol (TYPE_STUB_DECL (orig_type
));
1381 /* 'type' is a typedef; output the type it refers to. */
1382 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0);
1385 /* else continue. */
1387 switch (TREE_CODE (type
))
1391 /* For a void type, just define it as itself; ie, "5=5".
1392 This makes us consider it defined
1393 without saying what it is. The debugger will make it
1394 a void type when the reference is seen, and nothing will
1395 ever override that default. */
1396 dbxout_type_index (type
);
1400 if (type
== char_type_node
&& ! TYPE_UNSIGNED (type
))
1402 /* Output the type `char' as a subrange of itself!
1403 I don't understand this definition, just copied it
1404 from the output of pcc.
1405 This used to use `r2' explicitly and we used to
1406 take care to make sure that `char' was type number 2. */
1407 fprintf (asmfile
, "r");
1409 dbxout_type_index (type
);
1410 fprintf (asmfile
, ";0;127;");
1414 /* If this is a subtype of another integer type, always prefer to
1415 write it as a subtype. */
1416 else if (TREE_TYPE (type
) != 0
1417 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_TYPE
)
1419 /* If the size is non-standard, say what it is if we can use
1422 if (use_gnu_debug_info_extensions
1423 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1425 have_used_extensions
= 1;
1426 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1430 dbxout_range_type (type
);
1435 /* If the size is non-standard, say what it is if we can use
1438 if (use_gnu_debug_info_extensions
1439 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1441 have_used_extensions
= 1;
1442 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1446 if (print_int_cst_bounds_in_octal_p (type
))
1448 fprintf (asmfile
, "r");
1451 /* If this type derives from another type, output type index of
1452 parent type. This is particularly important when parent type
1453 is an enumerated type, because not generating the parent type
1454 index would transform the definition of this enumerated type
1455 into a plain unsigned type. */
1456 if (TREE_TYPE (type
) != 0)
1457 dbxout_type_index (TREE_TYPE (type
));
1459 dbxout_type_index (type
);
1461 fprintf (asmfile
, ";");
1463 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1464 fprintf (asmfile
, ";");
1466 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1467 fprintf (asmfile
, ";");
1472 /* Output other integer types as subranges of `int'. */
1473 dbxout_range_type (type
);
1479 /* This used to say `r1' and we used to take care
1480 to make sure that `int' was type number 1. */
1481 fprintf (asmfile
, "r");
1483 dbxout_type_index (integer_type_node
);
1484 putc (';', asmfile
);
1486 print_wide_int (int_size_in_bytes (type
));
1487 fputs (";0;", asmfile
);
1492 if (use_gnu_debug_info_extensions
)
1494 have_used_extensions
= 1;
1495 fputs ("@s", asmfile
);
1497 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1498 fputs (";-20;", asmfile
);
1503 /* Output the type `char' as a subrange of itself.
1504 That is what pcc seems to do. */
1505 fprintf (asmfile
, "r");
1507 dbxout_type_index (char_type_node
);
1508 fprintf (asmfile
, ";0;%d;", TYPE_UNSIGNED (type
) ? 255 : 127);
1514 if (use_gnu_debug_info_extensions
)
1516 have_used_extensions
= 1;
1517 fputs ("@s", asmfile
);
1519 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1520 fputs (";-16;", asmfile
);
1523 else /* Define as enumeral type (False, True) */
1525 fprintf (asmfile
, "eFalse:0,True:1,;");
1531 putc ('d', asmfile
);
1533 dbxout_type (TREE_TYPE (type
), 0);
1537 /* Differs from the REAL_TYPE by its new data type number.
1538 R3 is NF_COMPLEX. We don't try to use any of the other NF_*
1539 codes since gdb doesn't care anyway. */
1541 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1543 fputs ("R3;", asmfile
);
1545 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type
)));
1546 fputs (";0;", asmfile
);
1551 /* Output a complex integer type as a structure,
1552 pending some other way to do it. */
1553 putc ('s', asmfile
);
1555 print_wide_int (int_size_in_bytes (type
));
1556 fprintf (asmfile
, "real:");
1559 dbxout_type (TREE_TYPE (type
), 0);
1560 fprintf (asmfile
, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type
)));
1562 fprintf (asmfile
, "imag:");
1564 dbxout_type (TREE_TYPE (type
), 0);
1565 fprintf (asmfile
, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type
)),
1566 TYPE_PRECISION (TREE_TYPE (type
)));
1572 if (use_gnu_debug_info_extensions
)
1574 have_used_extensions
= 1;
1575 fputs ("@s", asmfile
);
1577 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1578 putc (';', asmfile
);
1581 /* Check if a bitstring type, which in Chill is
1582 different from a [power]set. */
1583 if (TYPE_STRING_FLAG (type
))
1585 fprintf (asmfile
, "@S;");
1589 putc ('S', asmfile
);
1591 dbxout_type (TYPE_DOMAIN (type
), 0);
1595 /* Make arrays of packed bits look like bitstrings for chill. */
1596 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1598 have_used_extensions
= 1;
1599 fputs ("@s", asmfile
);
1601 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1602 fprintf (asmfile
, ";@S;S");
1604 dbxout_type (TYPE_DOMAIN (type
), 0);
1608 /* Output "a" followed by a range type definition
1609 for the index type of the array
1610 followed by a reference to the target-type.
1611 ar1;0;N;M for a C array of type M and size N+1. */
1612 /* Check if a character string type, which in Chill is
1613 different from an array of characters. */
1614 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
1616 have_used_extensions
= 1;
1617 fprintf (asmfile
, "@S;");
1620 tem
= TYPE_DOMAIN (type
);
1623 fprintf (asmfile
, "ar");
1625 dbxout_type_index (integer_type_node
);
1626 fprintf (asmfile
, ";0;-1;");
1631 fprintf (asmfile
, "a");
1633 dbxout_range_type (tem
);
1636 dbxout_type (TREE_TYPE (type
), 0);
1641 case QUAL_UNION_TYPE
:
1643 tree binfo
= TYPE_BINFO (type
);
1645 /* Output a structure type. We must use the same test here as we
1646 use in the DBX_NO_XREFS case above. */
1647 if ((TYPE_NAME (type
) != 0
1648 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1649 && DECL_IGNORED_P (TYPE_NAME (type
)))
1651 || !COMPLETE_TYPE_P (type
)
1652 /* No way in DBX fmt to describe a variable size. */
1653 || ! host_integerp (TYPE_SIZE (type
), 1))
1655 /* If the type is just a cross reference, output one
1656 and mark the type as partially described.
1657 If it later becomes defined, we will output
1658 its real definition.
1659 If the type has a name, don't nest its definition within
1660 another type's definition; instead, output an xref
1661 and let the definition come when the name is defined. */
1662 fputs ((TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu", asmfile
);
1664 #if 0 /* This assertion is legitimately false in C++. */
1665 /* We shouldn't be outputting a reference to a type before its
1666 definition unless the type has a tag name.
1667 A typedef name without a tag name should be impossible. */
1668 if (TREE_CODE (TYPE_NAME (type
)) != IDENTIFIER_NODE
)
1671 if (TYPE_NAME (type
) != 0)
1672 dbxout_type_name (type
);
1675 fprintf (asmfile
, "$$%d", anonymous_type_number
++);
1679 fprintf (asmfile
, ":");
1681 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1685 /* Identify record or union, and print its size. */
1686 putc (((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u'), asmfile
);
1688 print_wide_int (int_size_in_bytes (type
));
1694 VEC (tree
) *accesses
= BINFO_BASE_ACCESSES (binfo
);
1696 if (use_gnu_debug_info_extensions
)
1698 if (BINFO_N_BASE_BINFOS (binfo
))
1700 have_used_extensions
= 1;
1701 fprintf (asmfile
, "!%u,", BINFO_N_BASE_BINFOS (binfo
));
1705 for (i
= 0; BINFO_BASE_ITERATE (binfo
, i
, child
); i
++)
1707 tree access
= (accesses
? VEC_index (tree
, accesses
, i
)
1708 : access_public_node
);
1710 if (use_gnu_debug_info_extensions
)
1712 have_used_extensions
= 1;
1713 putc (BINFO_VIRTUAL_P (child
) ? '1' : '0', asmfile
);
1714 putc (access
== access_public_node
? '2' :
1715 (access
== access_protected_node
? '1' :'0'),
1718 if (BINFO_VIRTUAL_P (child
)
1719 && strcmp (lang_hooks
.name
, "GNU C++") == 0)
1720 /* For a virtual base, print the (negative)
1721 offset within the vtable where we must look
1722 to find the necessary adjustment. */
1724 (tree_low_cst (BINFO_VPTR_FIELD (child
), 0)
1727 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1729 putc (',', asmfile
);
1731 dbxout_type (BINFO_TYPE (child
), 0);
1732 putc (';', asmfile
);
1737 /* Print out the base class information with
1738 fields which have the same names at the types
1740 dbxout_type_name (BINFO_TYPE (child
));
1741 putc (':', asmfile
);
1743 dbxout_type (BINFO_TYPE (child
), full
);
1744 putc (',', asmfile
);
1746 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1748 putc (',', asmfile
);
1751 (tree_low_cst (TYPE_SIZE (BINFO_TYPE (child
)), 0)
1753 putc (';', asmfile
);
1760 /* Write out the field declarations. */
1761 dbxout_type_fields (type
);
1762 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
1764 have_used_extensions
= 1;
1765 dbxout_type_methods (type
);
1768 putc (';', asmfile
);
1771 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
1772 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1773 && TYPE_VFIELD (type
))
1775 have_used_extensions
= 1;
1777 /* Tell GDB+ that it may keep reading. */
1778 putc ('~', asmfile
);
1781 /* We need to write out info about what field this class
1782 uses as its "main" vtable pointer field, because if this
1783 field is inherited from a base class, GDB cannot necessarily
1784 figure out which field it's using in time. */
1785 if (TYPE_VFIELD (type
))
1787 putc ('%', asmfile
);
1789 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0);
1792 putc (';', asmfile
);
1798 /* We must use the same test here as we use in the DBX_NO_XREFS case
1799 above. We simplify it a bit since an enum will never have a variable
1801 if ((TYPE_NAME (type
) != 0
1802 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1803 && DECL_IGNORED_P (TYPE_NAME (type
)))
1805 || !COMPLETE_TYPE_P (type
))
1807 fprintf (asmfile
, "xe");
1809 dbxout_type_name (type
);
1810 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1811 putc (':', asmfile
);
1815 if (use_gnu_debug_info_extensions
1816 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1818 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1822 putc ('e', asmfile
);
1824 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1826 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1827 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem
)) + 1);
1828 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
1829 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1830 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
1831 && (HOST_WIDE_INT
) TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
1832 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1834 print_int_cst_octal (TREE_VALUE (tem
));
1836 putc (',', asmfile
);
1838 if (TREE_CHAIN (tem
) != 0)
1842 putc (';', asmfile
);
1847 putc ('*', asmfile
);
1849 dbxout_type (TREE_TYPE (type
), 0);
1853 if (use_gnu_debug_info_extensions
)
1855 have_used_extensions
= 1;
1856 putc ('#', asmfile
);
1859 /* Write the argument types out longhand. */
1860 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0);
1861 putc (',', asmfile
);
1863 dbxout_type (TREE_TYPE (type
), 0);
1864 dbxout_args (TYPE_ARG_TYPES (type
));
1865 putc (';', asmfile
);
1869 /* Treat it as a function type. */
1870 dbxout_type (TREE_TYPE (type
), 0);
1874 if (use_gnu_debug_info_extensions
)
1876 have_used_extensions
= 1;
1877 putc ('@', asmfile
);
1879 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0);
1880 putc (',', asmfile
);
1882 dbxout_type (TREE_TYPE (type
), 0);
1885 /* Should print as an int, because it is really just an offset. */
1886 dbxout_type (integer_type_node
, 0);
1889 case REFERENCE_TYPE
:
1890 if (use_gnu_debug_info_extensions
)
1891 have_used_extensions
= 1;
1892 putc (use_gnu_debug_info_extensions
? '&' : '*', asmfile
);
1894 dbxout_type (TREE_TYPE (type
), 0);
1898 putc ('f', asmfile
);
1900 dbxout_type (TREE_TYPE (type
), 0);
1908 /* Return nonzero if the given type represents an integer whose bounds
1909 should be printed in octal format. */
1912 print_int_cst_bounds_in_octal_p (tree type
)
1914 /* If we can use GDB extensions and the size is wider than a long
1915 (the size used by GDB to read them) or we may have trouble writing
1916 the bounds the usual way, write them in octal. Note the test is for
1917 the *target's* size of "long", not that of the host. The host test
1918 is just to make sure we can write it out in case the host wide int
1919 is narrower than the target "long".
1921 For unsigned types, we use octal if they are the same size or larger.
1922 This is because we print the bounds as signed decimal, and hence they
1923 can't span same size unsigned types. */
1925 if (use_gnu_debug_info_extensions
1926 && TYPE_MIN_VALUE (type
) != 0
1927 && TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
1928 && TYPE_MAX_VALUE (type
) != 0
1929 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
1930 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
1931 || ((TYPE_PRECISION (type
) == TYPE_PRECISION (integer_type_node
))
1932 && TYPE_UNSIGNED (type
))
1933 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
1934 || (TYPE_PRECISION (type
) == HOST_BITS_PER_WIDE_INT
1935 && TYPE_UNSIGNED (type
))))
1941 /* Print the value of integer constant C, in octal,
1942 handling double precision. */
1945 print_int_cst_octal (tree c
)
1947 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (c
);
1948 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (c
);
1949 int excess
= (3 - (HOST_BITS_PER_WIDE_INT
% 3));
1950 unsigned int width
= TYPE_PRECISION (TREE_TYPE (c
));
1952 /* GDB wants constants with no extra leading "1" bits, so
1953 we need to remove any sign-extension that might be
1955 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
1957 else if (width
> HOST_BITS_PER_WIDE_INT
)
1958 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
1959 else if (width
== HOST_BITS_PER_WIDE_INT
)
1962 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
1964 fprintf (asmfile
, "0");
1969 print_octal (high
, HOST_BITS_PER_WIDE_INT
/ 3);
1970 print_octal (low
, HOST_BITS_PER_WIDE_INT
/ 3);
1974 unsigned HOST_WIDE_INT beg
= high
>> excess
;
1975 unsigned HOST_WIDE_INT middle
1976 = ((high
& (((HOST_WIDE_INT
) 1 << excess
) - 1)) << (3 - excess
)
1977 | (low
>> (HOST_BITS_PER_WIDE_INT
/ 3 * 3)));
1978 unsigned HOST_WIDE_INT end
1979 = low
& (((unsigned HOST_WIDE_INT
) 1
1980 << (HOST_BITS_PER_WIDE_INT
/ 3 * 3))
1983 fprintf (asmfile
, "%o%01o", (int) beg
, (int) middle
);
1985 print_octal (end
, HOST_BITS_PER_WIDE_INT
/ 3);
1990 print_octal (unsigned HOST_WIDE_INT value
, int digits
)
1994 for (i
= digits
- 1; i
>= 0; i
--)
1995 fprintf (asmfile
, "%01o", (int) ((value
>> (3 * i
)) & 7));
2000 /* Output C in decimal while adjusting the number of digits written. */
2003 print_wide_int (HOST_WIDE_INT c
)
2007 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, c
);
2018 /* Output the name of type TYPE, with no punctuation.
2019 Such names can be set up either by typedef declarations
2020 or by struct, enum and union tags. */
2023 dbxout_type_name (tree type
)
2026 if (TYPE_NAME (type
) == 0)
2028 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
2030 t
= TYPE_NAME (type
);
2032 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
2034 t
= DECL_NAME (TYPE_NAME (type
));
2039 fprintf (asmfile
, "%s", IDENTIFIER_POINTER (t
));
2040 CHARS (IDENTIFIER_LENGTH (t
));
2043 /* Output leading leading struct or class names needed for qualifying
2044 type whose scope is limited to a struct or class. */
2047 dbxout_class_name_qualifiers (tree decl
)
2049 tree context
= decl_type_context (decl
);
2051 if (context
!= NULL_TREE
2052 && TREE_CODE(context
) == RECORD_TYPE
2053 && TYPE_NAME (context
) != 0
2054 && (TREE_CODE (TYPE_NAME (context
)) == IDENTIFIER_NODE
2055 || (DECL_NAME (TYPE_NAME (context
)) != 0)))
2057 tree name
= TYPE_NAME (context
);
2059 emit_pending_bincls_if_required ();
2061 if (TREE_CODE (name
) == TYPE_DECL
)
2063 dbxout_class_name_qualifiers (name
);
2064 name
= DECL_NAME (name
);
2066 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
2067 CHARS (IDENTIFIER_LENGTH (name
) + 2);
2071 /* Output a .stabs for the symbol defined by DECL,
2072 which must be a ..._DECL node in the normal namespace.
2073 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
2074 LOCAL is nonzero if the scope is less than the entire file.
2075 Return 1 if a stabs might have been emitted. */
2078 dbxout_symbol (tree decl
, int local ATTRIBUTE_UNUSED
)
2080 tree type
= TREE_TYPE (decl
);
2081 tree context
= NULL_TREE
;
2084 /* "Intercept" dbxout_symbol() calls like we do all debug_hooks. */
2087 /* Ignore nameless syms, but don't ignore type tags. */
2089 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
2090 || DECL_IGNORED_P (decl
))
2091 DBXOUT_DECR_NESTING_AND_RETURN (0);
2093 /* If we are to generate only the symbols actually used then such
2094 symbol nodees are flagged with TREE_USED. Ignore any that
2095 aren't flaged as TREE_USED. */
2097 if (flag_debug_only_used_symbols
2098 && (!TREE_USED (decl
)
2099 && (TREE_CODE (decl
) != VAR_DECL
|| !DECL_INITIAL (decl
))))
2100 DBXOUT_DECR_NESTING_AND_RETURN (0);
2102 /* If dbxout_init has not yet run, queue this symbol for later. */
2105 preinit_symbols
= tree_cons (0, decl
, preinit_symbols
);
2106 DBXOUT_DECR_NESTING_AND_RETURN (0);
2109 if (flag_debug_only_used_symbols
)
2113 /* We now have a used symbol. We need to generate the info for
2114 the symbol's type in addition to the symbol itself. These
2115 type symbols are queued to be generated after were done with
2116 the symbol itself (done because the symbol's info is generated
2117 with fprintf's, etc. as it determines what's needed).
2119 Note, because the TREE_TYPE(type) might be something like a
2120 pointer to a named type we need to look for the first name
2121 we see following the TREE_TYPE chain. */
2124 while (POINTER_TYPE_P (t
))
2127 /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE
2128 need special treatment. The TYPE_STUB_DECL field in these
2129 types generally represents the tag name type we want to
2130 output. In addition there could be a typedef type with
2131 a different name. In that case we also want to output
2134 if ((TREE_CODE (t
) == RECORD_TYPE
2135 || TREE_CODE (t
) == UNION_TYPE
2136 || TREE_CODE (t
) == QUAL_UNION_TYPE
2137 || TREE_CODE (t
) == ENUMERAL_TYPE
)
2138 && TYPE_STUB_DECL (t
)
2139 && TYPE_STUB_DECL (t
) != decl
2140 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (t
))) == 'd'
2141 && ! DECL_IGNORED_P (TYPE_STUB_DECL (t
)))
2143 debug_queue_symbol (TYPE_STUB_DECL (t
));
2145 && TYPE_NAME (t
) != TYPE_STUB_DECL (t
)
2146 && TYPE_NAME (t
) != decl
2147 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t
))) == 'd')
2148 debug_queue_symbol (TYPE_NAME (t
));
2150 else if (TYPE_NAME (t
)
2151 && TYPE_NAME (t
) != decl
2152 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t
))) == 'd')
2153 debug_queue_symbol (TYPE_NAME (t
));
2156 emit_pending_bincls_if_required ();
2158 dbxout_prepare_symbol (decl
);
2160 /* The output will always start with the symbol name,
2161 so always count that in the length-output-so-far. */
2163 if (DECL_NAME (decl
) != 0)
2164 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (decl
));
2166 switch (TREE_CODE (decl
))
2169 /* Enum values are defined by defining the enum type. */
2173 if (DECL_RTL (decl
) == 0)
2174 DBXOUT_DECR_NESTING_AND_RETURN (0);
2175 if (DECL_EXTERNAL (decl
))
2177 /* Don't mention a nested function under its parent. */
2178 context
= decl_function_context (decl
);
2179 if (context
== current_function_decl
)
2181 if (!MEM_P (DECL_RTL (decl
))
2182 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
2186 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2187 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2188 TREE_PUBLIC (decl
) ? 'F' : 'f');
2191 current_sym_code
= N_FUN
;
2192 current_sym_addr
= XEXP (DECL_RTL (decl
), 0);
2194 if (TREE_TYPE (type
))
2195 dbxout_type (TREE_TYPE (type
), 0);
2197 dbxout_type (void_type_node
, 0);
2199 /* For a nested function, when that function is compiled,
2200 mention the containing function name
2201 as well as (since dbx wants it) our own assembler-name. */
2203 fprintf (asmfile
, ",%s,%s",
2204 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2205 IDENTIFIER_POINTER (DECL_NAME (context
)));
2207 dbxout_finish_symbol (decl
);
2211 /* Don't output the same typedef twice.
2212 And don't output what language-specific stuff doesn't want output. */
2213 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
2214 DBXOUT_DECR_NESTING_AND_RETURN (0);
2216 /* Don't output typedefs for types with magic type numbers (XCOFF). */
2217 #ifdef DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER
2219 int fundamental_type_number
=
2220 DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER (decl
);
2222 if (fundamental_type_number
!= 0)
2224 TREE_ASM_WRITTEN (decl
) = 1;
2225 TYPE_SYMTAB_ADDRESS (TREE_TYPE (decl
)) = fundamental_type_number
;
2226 DBXOUT_DECR_NESTING_AND_RETURN (0);
2236 if (DECL_NAME (decl
))
2238 /* Nonzero means we must output a tag as well as a typedef. */
2241 /* Handle the case of a C++ structure or union
2242 where the TYPE_NAME is a TYPE_DECL
2243 which gives both a typedef name and a tag. */
2244 /* dbx requires the tag first and the typedef second. */
2245 if ((TREE_CODE (type
) == RECORD_TYPE
2246 || TREE_CODE (type
) == UNION_TYPE
2247 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2248 && TYPE_NAME (type
) == decl
2249 && !(use_gnu_debug_info_extensions
&& have_used_extensions
)
2250 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
2251 /* Distinguish the implicit typedefs of C++
2252 from explicit ones that might be found in C. */
2253 && DECL_ARTIFICIAL (decl
)
2254 /* Do not generate a tag for incomplete records. */
2255 && COMPLETE_TYPE_P (type
)
2256 /* Do not generate a tag for records of variable size,
2257 since this type can not be properly described in the
2258 DBX format, and it confuses some tools such as objdump. */
2259 && host_integerp (TYPE_SIZE (type
), 1))
2261 tree name
= TYPE_NAME (type
);
2262 if (TREE_CODE (name
) == TYPE_DECL
)
2263 name
= DECL_NAME (name
);
2265 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2266 current_sym_value
= 0;
2267 current_sym_addr
= 0;
2268 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2270 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2271 IDENTIFIER_POINTER (name
));
2272 dbxout_type (type
, 1);
2273 dbxout_finish_symbol (NULL_TREE
);
2276 /* Output .stabs (or whatever) and leading double quote. */
2277 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
2279 if (use_gnu_debug_info_extensions
)
2281 /* Output leading class/struct qualifiers. */
2282 dbxout_class_name_qualifiers (decl
);
2285 /* Output typedef name. */
2286 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl
)));
2288 /* Short cut way to output a tag also. */
2289 if ((TREE_CODE (type
) == RECORD_TYPE
2290 || TREE_CODE (type
) == UNION_TYPE
2291 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2292 && TYPE_NAME (type
) == decl
2293 /* Distinguish the implicit typedefs of C++
2294 from explicit ones that might be found in C. */
2295 && DECL_ARTIFICIAL (decl
))
2297 if (use_gnu_debug_info_extensions
&& have_used_extensions
)
2299 putc ('T', asmfile
);
2300 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
2302 #if 0 /* Now we generate the tag for this case up above. */
2308 putc ('t', asmfile
);
2309 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2311 dbxout_type (type
, 1);
2312 dbxout_finish_symbol (decl
);
2316 /* Don't output a tag if this is an incomplete type. This prevents
2317 the sun4 Sun OS 4.x dbx from crashing. */
2319 if (tag_needed
&& TYPE_NAME (type
) != 0
2320 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
2321 || (DECL_NAME (TYPE_NAME (type
)) != 0))
2322 && COMPLETE_TYPE_P (type
)
2323 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
2325 /* For a TYPE_DECL with no name, but the type has a name,
2327 This is what represents `struct foo' with no typedef. */
2328 /* In C++, the name of a type is the corresponding typedef.
2329 In C, it is an IDENTIFIER_NODE. */
2330 tree name
= TYPE_NAME (type
);
2331 if (TREE_CODE (name
) == TYPE_DECL
)
2332 name
= DECL_NAME (name
);
2334 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2335 current_sym_value
= 0;
2336 current_sym_addr
= 0;
2337 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2339 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2340 IDENTIFIER_POINTER (name
));
2341 dbxout_type (type
, 1);
2342 dbxout_finish_symbol (NULL_TREE
);
2346 /* If an enum type has no name, it cannot be referred to,
2347 but we must output it anyway, since the enumeration constants
2348 can be referred to. */
2349 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
2351 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2352 current_sym_value
= 0;
2353 current_sym_addr
= 0;
2354 current_sym_nchars
= 2;
2356 /* Some debuggers fail when given NULL names, so give this a
2357 harmless name of ` '. */
2358 fprintf (asmfile
, "%s\" :T", ASM_STABS_OP
);
2359 dbxout_type (type
, 1);
2360 dbxout_finish_symbol (NULL_TREE
);
2363 /* Prevent duplicate output of a typedef. */
2364 TREE_ASM_WRITTEN (decl
) = 1;
2369 /* Parm decls go in their own separate chains
2370 and are output by dbxout_reg_parms and dbxout_parms. */
2374 /* Named return value, treat like a VAR_DECL. */
2376 if (! DECL_RTL_SET_P (decl
))
2377 DBXOUT_DECR_NESTING_AND_RETURN (0);
2378 /* Don't mention a variable that is external.
2379 Let the file that defines it describe it. */
2380 if (DECL_EXTERNAL (decl
))
2383 /* If the variable is really a constant
2384 and not written in memory, inform the debugger. */
2385 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
2386 && DECL_INITIAL (decl
) != 0
2387 && host_integerp (DECL_INITIAL (decl
), 0)
2388 && ! TREE_ASM_WRITTEN (decl
)
2389 && (DECL_CONTEXT (decl
) == NULL_TREE
2390 || TREE_CODE (DECL_CONTEXT (decl
)) == BLOCK
))
2392 if (TREE_PUBLIC (decl
) == 0)
2394 /* The sun4 assembler does not grok this. */
2395 const char *name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2397 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
2398 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
2400 HOST_WIDE_INT ival
= tree_low_cst (DECL_INITIAL (decl
), 0);
2401 fprintf (asmfile
, "%s\"%s:c=i" HOST_WIDE_INT_PRINT_DEC
2403 ASM_STABS_OP
, name
, ival
, N_LSYM
);
2404 DBXOUT_DECR_NESTING
;
2407 else if (TREE_CODE (TREE_TYPE (decl
)) == REAL_TYPE
)
2409 /* Don't know how to do this yet. */
2413 /* else it is something we handle like a normal variable. */
2416 SET_DECL_RTL (decl
, eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
2417 #ifdef LEAF_REG_REMAP
2418 if (current_function_uses_only_leaf_regs
)
2419 leaf_renumber_regs_insn (DECL_RTL (decl
));
2422 result
= dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
2428 DBXOUT_DECR_NESTING
;
2432 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2433 Add SUFFIX to its name, if SUFFIX is not 0.
2434 Describe the variable as residing in HOME
2435 (usually HOME is DECL_RTL (DECL), but not always).
2436 Returns 1 if the stab was really emitted. */
2439 dbxout_symbol_location (tree decl
, tree type
, const char *suffix
, rtx home
)
2444 emit_pending_bincls_if_required ();
2446 /* Don't mention a variable at all
2447 if it was completely optimized into nothingness.
2449 If the decl was from an inline function, then its rtl
2450 is not identically the rtl that was used in this
2451 particular compilation. */
2452 if (GET_CODE (home
) == SUBREG
)
2456 while (GET_CODE (value
) == SUBREG
)
2457 value
= SUBREG_REG (value
);
2460 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
2463 home
= alter_subreg (&home
);
2467 regno
= REGNO (home
);
2468 if (regno
>= FIRST_PSEUDO_REGISTER
)
2472 /* The kind-of-variable letter depends on where
2473 the variable is and on the scope of its name:
2474 G and N_GSYM for static storage and global scope,
2475 S for static storage and file scope,
2476 V for static storage and local scope,
2477 for those two, use N_LCSYM if data is in bss segment,
2478 N_STSYM if in data segment, N_FUN otherwise.
2479 (We used N_FUN originally, then changed to N_STSYM
2480 to please GDB. However, it seems that confused ld.
2481 Now GDB has been fixed to like N_FUN, says Kingdon.)
2482 no letter at all, and N_LSYM, for auto variable,
2483 r and N_RSYM for register variable. */
2486 && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
2488 if (TREE_PUBLIC (decl
))
2491 current_sym_code
= N_GSYM
;
2495 current_sym_addr
= XEXP (home
, 0);
2497 letter
= decl_function_context (decl
) ? 'V' : 'S';
2499 /* This should be the same condition as in assemble_variable, but
2500 we don't have access to dont_output_data here. So, instead,
2501 we rely on the fact that error_mark_node initializers always
2502 end up in bss for C++ and never end up in bss for C. */
2503 if (DECL_INITIAL (decl
) == 0
2504 || (!strcmp (lang_hooks
.name
, "GNU C++")
2505 && DECL_INITIAL (decl
) == error_mark_node
))
2506 current_sym_code
= N_LCSYM
;
2507 else if (DECL_IN_TEXT_SECTION (decl
))
2508 /* This is not quite right, but it's the closest
2509 of all the codes that Unix defines. */
2510 current_sym_code
= DBX_STATIC_CONST_VAR_CODE
;
2513 /* Some ports can transform a symbol ref into a label ref,
2514 because the symbol ref is too far away and has to be
2515 dumped into a constant pool. Alternatively, the symbol
2516 in the constant pool might be referenced by a different
2518 if (GET_CODE (current_sym_addr
) == SYMBOL_REF
2519 && CONSTANT_POOL_ADDRESS_P (current_sym_addr
))
2522 rtx tmp
= get_pool_constant_mark (current_sym_addr
, &marked
);
2524 if (GET_CODE (tmp
) == SYMBOL_REF
)
2526 current_sym_addr
= tmp
;
2527 if (CONSTANT_POOL_ADDRESS_P (current_sym_addr
))
2528 get_pool_constant_mark (current_sym_addr
, &marked
);
2532 else if (GET_CODE (tmp
) == LABEL_REF
)
2534 current_sym_addr
= tmp
;
2538 /* If all references to the constant pool were optimized
2539 out, we just ignore the symbol. */
2544 /* Ultrix `as' seems to need this. */
2545 #ifdef DBX_STATIC_STAB_DATA_SECTION
2548 current_sym_code
= N_STSYM
;
2552 else if (regno
>= 0)
2555 current_sym_code
= N_RSYM
;
2556 current_sym_value
= DBX_REGISTER_NUMBER (regno
);
2558 else if (MEM_P (home
)
2559 && (MEM_P (XEXP (home
, 0))
2560 || (REG_P (XEXP (home
, 0))
2561 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
2562 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
2563 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2564 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
2567 /* If the value is indirect by memory or by a register
2568 that isn't the frame pointer
2569 then it means the object is variable-sized and address through
2570 that register or stack slot. DBX has no way to represent this
2571 so all we can do is output the variable as a pointer.
2572 If it's not a parameter, ignore it. */
2574 if (REG_P (XEXP (home
, 0)))
2577 current_sym_code
= N_RSYM
;
2578 if (REGNO (XEXP (home
, 0)) >= FIRST_PSEUDO_REGISTER
)
2580 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
2584 current_sym_code
= N_LSYM
;
2585 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2586 We want the value of that CONST_INT. */
2588 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2591 /* Effectively do build_pointer_type, but don't cache this type,
2592 since it might be temporary whereas the type it points to
2593 might have been saved for inlining. */
2594 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2595 type
= make_node (POINTER_TYPE
);
2596 TREE_TYPE (type
) = TREE_TYPE (decl
);
2598 else if (MEM_P (home
)
2599 && REG_P (XEXP (home
, 0)))
2601 current_sym_code
= N_LSYM
;
2602 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2604 else if (MEM_P (home
)
2605 && GET_CODE (XEXP (home
, 0)) == PLUS
2606 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2608 current_sym_code
= N_LSYM
;
2609 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2610 We want the value of that CONST_INT. */
2611 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2613 else if (MEM_P (home
)
2614 && GET_CODE (XEXP (home
, 0)) == CONST
)
2616 /* Handle an obscure case which can arise when optimizing and
2617 when there are few available registers. (This is *always*
2618 the case for i386/i486 targets). The RTL looks like
2619 (MEM (CONST ...)) even though this variable is a local `auto'
2620 or a local `register' variable. In effect, what has happened
2621 is that the reload pass has seen that all assignments and
2622 references for one such a local variable can be replaced by
2623 equivalent assignments and references to some static storage
2624 variable, thereby avoiding the need for a register. In such
2625 cases we're forced to lie to debuggers and tell them that
2626 this variable was itself `static'. */
2627 current_sym_code
= N_LCSYM
;
2629 current_sym_addr
= XEXP (XEXP (home
, 0), 0);
2631 else if (GET_CODE (home
) == CONCAT
)
2635 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2636 for example), then there is no easy way to figure out
2637 what SUBTYPE should be. So, we give up. */
2638 if (TREE_CODE (type
) != COMPLEX_TYPE
)
2641 subtype
= TREE_TYPE (type
);
2643 /* If the variable's storage is in two parts,
2644 output each as a separate stab with a modified name. */
2645 if (WORDS_BIG_ENDIAN
)
2646 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2648 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2650 dbxout_prepare_symbol (decl
);
2652 if (WORDS_BIG_ENDIAN
)
2653 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2655 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2659 /* Address might be a MEM, when DECL is a variable-sized object.
2660 Or it might be const0_rtx, meaning previous passes
2661 want us to ignore this variable. */
2664 /* Ok, start a symtab entry and output the variable name. */
2667 #ifdef DBX_STATIC_BLOCK_START
2668 DBX_STATIC_BLOCK_START (asmfile
, current_sym_code
);
2671 dbxout_symbol_name (decl
, suffix
, letter
);
2672 dbxout_type (type
, 0);
2673 dbxout_finish_symbol (decl
);
2675 #ifdef DBX_STATIC_BLOCK_END
2676 DBX_STATIC_BLOCK_END (asmfile
, current_sym_code
);
2681 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2682 Then output LETTER to indicate the kind of location the symbol has. */
2685 dbxout_symbol_name (tree decl
, const char *suffix
, int letter
)
2689 if (DECL_CONTEXT (decl
)
2690 && (TYPE_P (DECL_CONTEXT (decl
))
2691 || TREE_CODE (DECL_CONTEXT (decl
)) == NAMESPACE_DECL
))
2692 /* One slight hitch: if this is a VAR_DECL which is a class member
2693 or a namespace member, we must put out the mangled name instead of the
2694 DECL_NAME. Note also that static member (variable) names DO NOT begin
2695 with underscores in .stabs directives. */
2696 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
2698 /* ...but if we're function-local, we don't want to include the junk
2699 added by ASM_FORMAT_PRIVATE_NAME. */
2700 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2704 fprintf (asmfile
, "%s\"%s%s:", ASM_STABS_OP
, name
,
2705 (suffix
? suffix
: ""));
2708 putc (letter
, asmfile
);
2712 dbxout_prepare_symbol (tree decl ATTRIBUTE_UNUSED
)
2715 const char *filename
= DECL_SOURCE_FILE (decl
);
2717 dbxout_source_file (asmfile
, filename
);
2720 /* Initialize variables used to communicate each symbol's debug
2721 information to dbxout_finish_symbol with zeroes. */
2723 /* Cast avoids warning in old compilers. */
2724 current_sym_code
= (STAB_CODE_TYPE
) 0;
2725 current_sym_value
= 0;
2726 current_sym_addr
= 0;
2730 dbxout_finish_symbol (tree sym
)
2732 #ifdef DBX_FINISH_SYMBOL
2733 DBX_FINISH_SYMBOL (sym
);
2736 if (use_gnu_debug_info_extensions
&& sym
!= 0)
2737 line
= DECL_SOURCE_LINE (sym
);
2739 fprintf (asmfile
, "\",%d,0,%d,", current_sym_code
, line
);
2740 if (current_sym_addr
)
2741 output_addr_const (asmfile
, current_sym_addr
);
2743 fprintf (asmfile
, "%d", current_sym_value
);
2744 putc ('\n', asmfile
);
2748 /* Output definitions of all the decls in a chain. Return nonzero if
2749 anything was output */
2752 dbxout_syms (tree syms
)
2757 result
+= dbxout_symbol (syms
, 1);
2758 syms
= TREE_CHAIN (syms
);
2763 /* The following two functions output definitions of function parameters.
2764 Each parameter gets a definition locating it in the parameter list.
2765 Each parameter that is a register variable gets a second definition
2766 locating it in the register.
2768 Printing or argument lists in gdb uses the definitions that
2769 locate in the parameter list. But reference to the variable in
2770 expressions uses preferentially the definition as a register. */
2772 /* Output definitions, referring to storage in the parmlist,
2773 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2776 dbxout_parms (tree parms
)
2780 emit_pending_bincls_if_required ();
2782 for (; parms
; parms
= TREE_CHAIN (parms
))
2783 if (DECL_NAME (parms
)
2784 && TREE_TYPE (parms
) != error_mark_node
2785 && DECL_RTL_SET_P (parms
)
2786 && DECL_INCOMING_RTL (parms
))
2788 dbxout_prepare_symbol (parms
);
2790 /* Perform any necessary register eliminations on the parameter's rtl,
2791 so that the debugging output will be accurate. */
2792 DECL_INCOMING_RTL (parms
)
2793 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
2794 SET_DECL_RTL (parms
, eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
2795 #ifdef LEAF_REG_REMAP
2796 if (current_function_uses_only_leaf_regs
)
2798 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
2799 leaf_renumber_regs_insn (DECL_RTL (parms
));
2803 if (PARM_PASSED_IN_MEMORY (parms
))
2805 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
2807 /* ??? Here we assume that the parm address is indexed
2808 off the frame pointer or arg pointer.
2809 If that is not true, we produce meaningless results,
2810 but do not crash. */
2811 if (GET_CODE (addr
) == PLUS
2812 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
2813 current_sym_value
= INTVAL (XEXP (addr
, 1));
2815 current_sym_value
= 0;
2817 current_sym_code
= N_PSYM
;
2818 current_sym_addr
= 0;
2821 if (DECL_NAME (parms
))
2823 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2825 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2826 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2827 DBX_MEMPARM_STABS_LETTER
);
2831 current_sym_nchars
= 8;
2832 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2833 DBX_MEMPARM_STABS_LETTER
);
2836 /* It is quite tempting to use:
2838 dbxout_type (TREE_TYPE (parms), 0);
2840 as the next statement, rather than using DECL_ARG_TYPE(), so
2841 that gcc reports the actual type of the parameter, rather
2842 than the promoted type. This certainly makes GDB's life
2843 easier, at least for some ports. The change is a bad idea
2844 however, since GDB expects to be able access the type without
2845 performing any conversions. So for example, if we were
2846 passing a float to an unprototyped function, gcc will store a
2847 double on the stack, but if we emit a stab saying the type is a
2848 float, then gdb will only read in a single value, and this will
2849 produce an erroneous value. */
2850 dbxout_type (DECL_ARG_TYPE (parms
), 0);
2851 current_sym_value
= DEBUGGER_ARG_OFFSET (current_sym_value
, addr
);
2852 dbxout_finish_symbol (parms
);
2854 else if (REG_P (DECL_RTL (parms
)))
2857 char regparm_letter
;
2859 /* Parm passed in registers and lives in registers or nowhere. */
2861 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2862 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2863 current_sym_addr
= 0;
2865 /* If parm lives in a register, use that register;
2866 pretend the parm was passed there. It would be more consistent
2867 to describe the register where the parm was passed,
2868 but in practice that register usually holds something else.
2870 If we use DECL_RTL, then we must use the declared type of
2871 the variable, not the type that it arrived in. */
2872 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2874 best_rtl
= DECL_RTL (parms
);
2875 parm_type
= TREE_TYPE (parms
);
2877 /* If the parm lives nowhere, use the register where it was
2878 passed. It is also better to use the declared type here. */
2881 best_rtl
= DECL_INCOMING_RTL (parms
);
2882 parm_type
= TREE_TYPE (parms
);
2884 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
2887 if (DECL_NAME (parms
))
2889 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2890 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2891 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2896 current_sym_nchars
= 8;
2897 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2901 dbxout_type (parm_type
, 0);
2902 dbxout_finish_symbol (parms
);
2904 else if (MEM_P (DECL_RTL (parms
))
2905 && REG_P (XEXP (DECL_RTL (parms
), 0))
2906 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
2907 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
2908 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2909 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
2913 /* Parm was passed via invisible reference.
2914 That is, its address was passed in a register.
2915 Output it as if it lived in that register.
2916 The debugger will know from the type
2917 that it was actually passed by invisible reference. */
2919 char regparm_letter
;
2920 /* Parm passed in registers and lives in registers or nowhere. */
2922 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2923 if (use_gnu_debug_info_extensions
)
2924 regparm_letter
= GDB_INV_REF_REGPARM_STABS_LETTER
;
2926 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2928 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2929 If it is an unallocated pseudo-reg, then use the register where
2930 it was passed instead. */
2931 if (REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
2932 current_sym_value
= REGNO (XEXP (DECL_RTL (parms
), 0));
2934 current_sym_value
= REGNO (DECL_INCOMING_RTL (parms
));
2936 current_sym_addr
= 0;
2939 if (DECL_NAME (parms
))
2942 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2944 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2945 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2950 current_sym_nchars
= 8;
2951 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2955 dbxout_type (TREE_TYPE (parms
), 0);
2956 dbxout_finish_symbol (parms
);
2958 else if (MEM_P (DECL_RTL (parms
))
2959 && MEM_P (XEXP (DECL_RTL (parms
), 0)))
2961 /* Parm was passed via invisible reference, with the reference
2962 living on the stack. DECL_RTL looks like
2963 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2964 could look like (MEM (MEM (REG))). */
2965 const char *const decl_name
= (DECL_NAME (parms
)
2966 ? IDENTIFIER_POINTER (DECL_NAME (parms
))
2968 if (REG_P (XEXP (XEXP (DECL_RTL (parms
), 0), 0)))
2969 current_sym_value
= 0;
2972 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
2973 current_sym_addr
= 0;
2974 current_sym_code
= N_PSYM
;
2977 fprintf (asmfile
, "%s\"%s:v", ASM_STABS_OP
, decl_name
);
2980 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2981 XEXP (XEXP (DECL_RTL (parms
), 0), 0));
2982 dbxout_type (TREE_TYPE (parms
), 0);
2983 dbxout_finish_symbol (parms
);
2985 else if (MEM_P (DECL_RTL (parms
))
2986 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
2987 /* ??? A constant address for a parm can happen
2988 when the reg it lives in is equiv to a constant in memory.
2989 Should make this not happen, after 2.4. */
2990 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
2992 /* Parm was passed in registers but lives on the stack. */
2994 current_sym_code
= N_PSYM
;
2995 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2996 in which case we want the value of that CONST_INT,
2998 in which case we use a value of zero. */
2999 if (REG_P (XEXP (DECL_RTL (parms
), 0)))
3000 current_sym_value
= 0;
3003 = INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
3005 current_sym_addr
= 0;
3007 /* Make a big endian correction if the mode of the type of the
3008 parameter is not the same as the mode of the rtl. */
3009 if (BYTES_BIG_ENDIAN
3010 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
3011 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
3013 current_sym_value
+=
3014 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
)))
3015 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
)));
3019 if (DECL_NAME (parms
))
3022 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
3024 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
3025 IDENTIFIER_POINTER (DECL_NAME (parms
)),
3026 DBX_MEMPARM_STABS_LETTER
);
3030 current_sym_nchars
= 8;
3031 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
3032 DBX_MEMPARM_STABS_LETTER
);
3036 = DEBUGGER_ARG_OFFSET (current_sym_value
,
3037 XEXP (DECL_RTL (parms
), 0));
3038 dbxout_type (TREE_TYPE (parms
), 0);
3039 dbxout_finish_symbol (parms
);
3042 DBXOUT_DECR_NESTING
;
3045 /* Output definitions for the places where parms live during the function,
3046 when different from where they were passed, when the parms were passed
3049 It is not useful to do this for parms passed in registers
3050 that live during the function in different registers, because it is
3051 impossible to look in the passed register for the passed value,
3052 so we use the within-the-function register to begin with.
3054 PARMS is a chain of PARM_DECL nodes. */
3057 dbxout_reg_parms (tree parms
)
3061 for (; parms
; parms
= TREE_CHAIN (parms
))
3062 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
3064 dbxout_prepare_symbol (parms
);
3066 /* Report parms that live in registers during the function
3067 but were passed in memory. */
3068 if (REG_P (DECL_RTL (parms
))
3069 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
3070 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
3071 0, DECL_RTL (parms
));
3072 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
3073 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
3074 0, DECL_RTL (parms
));
3075 /* Report parms that live in memory but not where they were passed. */
3076 else if (MEM_P (DECL_RTL (parms
))
3077 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
3078 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
3079 0, DECL_RTL (parms
));
3081 DBXOUT_DECR_NESTING
;
3084 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
3085 output definitions of those names, in raw form */
3088 dbxout_args (tree args
)
3092 putc (',', asmfile
);
3093 dbxout_type (TREE_VALUE (args
), 0);
3095 args
= TREE_CHAIN (args
);
3099 /* Subroutine of dbxout_block. Emit an N_LBRAC stab referencing LABEL.
3100 BEGIN_LABEL is the name of the beginning of the function, which may
3103 dbx_output_lbrac (const char *label
,
3104 const char *begin_label ATTRIBUTE_UNUSED
)
3106 #ifdef DBX_OUTPUT_LBRAC
3107 DBX_OUTPUT_LBRAC (asmfile
, label
);
3109 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_LBRAC
);
3110 assemble_name (asmfile
, label
);
3111 #if DBX_BLOCKS_FUNCTION_RELATIVE
3112 putc ('-', asmfile
);
3113 assemble_name (asmfile
, begin_label
);
3115 fprintf (asmfile
, "\n");
3119 /* Subroutine of dbxout_block. Emit an N_RBRAC stab referencing LABEL.
3120 BEGIN_LABEL is the name of the beginning of the function, which may
3123 dbx_output_rbrac (const char *label
,
3124 const char *begin_label ATTRIBUTE_UNUSED
)
3126 #ifdef DBX_OUTPUT_RBRAC
3127 DBX_OUTPUT_RBRAC (asmfile
, label
);
3129 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_RBRAC
);
3130 assemble_name (asmfile
, label
);
3131 #if DBX_BLOCKS_FUNCTION_RELATIVE
3132 putc ('-', asmfile
);
3133 assemble_name (asmfile
, begin_label
);
3135 fprintf (asmfile
, "\n");
3139 /* Output everything about a symbol block (a BLOCK node
3140 that represents a scope level),
3141 including recursive output of contained blocks.
3143 BLOCK is the BLOCK node.
3144 DEPTH is its depth within containing symbol blocks.
3145 ARGS is usually zero; but for the outermost block of the
3146 body of a function, it is a chain of PARM_DECLs for the function parameters.
3147 We output definitions of all the register parms
3148 as if they were local variables of that block.
3150 If -g1 was used, we count blocks just the same, but output nothing
3151 except for the outermost block.
3153 Actually, BLOCK may be several blocks chained together.
3154 We handle them all in sequence. */
3157 dbxout_block (tree block
, int depth
, tree args
)
3159 const char *begin_label
;
3160 if (current_function_func_begin_label
!= NULL_TREE
)
3161 begin_label
= IDENTIFIER_POINTER (current_function_func_begin_label
);
3163 begin_label
= XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0);
3167 /* Ignore blocks never expanded or otherwise marked as real. */
3168 if (TREE_USED (block
) && TREE_ASM_WRITTEN (block
))
3171 int blocknum
= BLOCK_NUMBER (block
);
3173 /* In dbx format, the syms of a block come before the N_LBRAC.
3174 If nothing is output, we don't need the N_LBRAC, either. */
3176 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
3177 did_output
= dbxout_syms (BLOCK_VARS (block
));
3179 dbxout_reg_parms (args
);
3181 /* Now output an N_LBRAC symbol to represent the beginning of
3182 the block. Use the block's tree-walk order to generate
3183 the assembler symbols LBBn and LBEn
3184 that final will define around the code in this block. */
3188 const char *scope_start
;
3191 /* The outermost block doesn't get LBB labels; use
3192 the function symbol. */
3193 scope_start
= begin_label
;
3196 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
3200 if (BLOCK_HANDLER_BLOCK (block
))
3202 /* A catch block. Must precede N_LBRAC. */
3203 tree decl
= BLOCK_VARS (block
);
3206 fprintf (asmfile
, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP
,
3207 IDENTIFIER_POINTER (DECL_NAME (decl
)), N_CATCH
);
3208 assemble_name (asmfile
, scope_start
);
3209 fprintf (asmfile
, "\n");
3210 decl
= TREE_CHAIN (decl
);
3213 dbx_output_lbrac (scope_start
, begin_label
);
3216 /* Output the subblocks. */
3217 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
3219 /* Refer to the marker for the end of the block. */
3224 /* The outermost block doesn't get LBE labels;
3225 use the "scope" label which will be emitted
3226 by dbxout_function_end. */
3227 ASM_GENERATE_INTERNAL_LABEL (buf
, "Lscope", scope_labelno
);
3229 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
3231 dbx_output_rbrac (buf
, begin_label
);
3234 block
= BLOCK_CHAIN (block
);
3238 /* Output the information about a function and its arguments and result.
3239 Usually this follows the function's code,
3240 but on some systems, it comes before. */
3242 #if defined (DBX_DEBUGGING_INFO)
3244 dbxout_begin_function (tree decl
)
3246 int saved_tree_used1
= TREE_USED (decl
);
3247 TREE_USED (decl
) = 1;
3248 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3250 int saved_tree_used2
= TREE_USED (DECL_RESULT (decl
));
3251 TREE_USED (DECL_RESULT (decl
)) = 1;
3252 dbxout_symbol (decl
, 0);
3253 TREE_USED (DECL_RESULT (decl
)) = saved_tree_used2
;
3256 dbxout_symbol (decl
, 0);
3257 TREE_USED (decl
) = saved_tree_used1
;
3259 dbxout_parms (DECL_ARGUMENTS (decl
));
3260 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3261 dbxout_symbol (DECL_RESULT (decl
), 1);
3263 #endif /* DBX_DEBUGGING_INFO */
3265 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3267 #include "gt-dbxout.h"