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 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 enum binclstatus
{BINCL_NOT_REQUIRED
, BINCL_PENDING
, BINCL_PROCESSED
};
184 /* When using N_BINCL in dbx output, each type number is actually a
185 pair of the file number and the type number within the file.
186 This is a stack of input files. */
188 struct dbx_file
GTY(())
190 struct dbx_file
*next
;
192 int next_type_number
;
193 enum binclstatus bincl_status
; /* Keep track of lazy bincl. */
194 const char *pending_bincl_name
; /* Name of bincl. */
195 struct dbx_file
*prev
; /* Chain to traverse all pending bincls. */
198 /* This is the top of the stack. */
200 static GTY(()) struct dbx_file
*current_file
;
202 /* This is the next file number to use. */
204 static GTY(()) int next_file_number
;
206 /* A counter for dbxout_function_end. */
208 static GTY(()) int scope_labelno
;
210 /* A counter for dbxout_source_line. */
212 static GTY(()) int dbxout_source_line_counter
;
214 /* Nonzero if we have actually used any of the GDB extensions
215 to the debugging format. The idea is that we use them for the
216 first time only if there's a strong reason, but once we have done that,
217 we use them whenever convenient. */
219 static GTY(()) int have_used_extensions
= 0;
221 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
222 for the N_SO filename stabs label. */
224 static GTY(()) int source_label_number
= 1;
226 /* Last source file name mentioned in a NOTE insn. */
228 static GTY(()) const char *lastfile
;
230 /* Used by PCH machinery to detect if 'lastfile' should be reset to
232 static GTY(()) int lastfile_is_base
;
234 /* Typical USG systems don't have stab.h, and they also have
235 no use for DBX-format debugging info. */
237 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
240 /* If zero then there is no pending BINCL. */
241 static int pending_bincls
= 0;
244 /* The original input file name. */
245 static const char *base_input_file
;
247 /* Current working directory. */
249 static const char *cwd
;
251 #ifdef DEBUG_SYMS_TEXT
252 #define FORCE_TEXT function_section (current_function_decl);
259 #define STAB_CODE_TYPE enum __stab_debug_code
261 /* 1 if PARM is passed to this function in memory. */
263 #define PARM_PASSED_IN_MEMORY(PARM) \
264 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
266 /* A C expression for the integer offset value of an automatic variable
267 (N_LSYM) having address X (an RTX). */
268 #ifndef DEBUGGER_AUTO_OFFSET
269 #define DEBUGGER_AUTO_OFFSET(X) \
270 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
273 /* A C expression for the integer offset value of an argument (N_PSYM)
274 having address X (an RTX). The nominal offset is OFFSET. */
275 #ifndef DEBUGGER_ARG_OFFSET
276 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
279 /* Stream for writing to assembler file. */
281 static FILE *asmfile
;
283 /* These variables are for dbxout_symbol to communicate to
284 dbxout_finish_symbol.
285 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
286 current_sym_value and current_sym_addr are two ways to address the
287 value to store in the symtab entry.
288 current_sym_addr if nonzero represents the value as an rtx.
289 If that is zero, current_sym_value is used. This is used
290 when the value is an offset (such as for auto variables,
291 register variables and parms). */
293 static STAB_CODE_TYPE current_sym_code
;
294 static int current_sym_value
;
295 static rtx current_sym_addr
;
297 /* Number of chars of symbol-description generated so far for the
298 current symbol. Used by CHARS and CONTIN. */
300 static int current_sym_nchars
;
302 /* Report having output N chars of the current symbol-description. */
304 #define CHARS(N) (current_sym_nchars += (N))
306 /* Break the current symbol-description, generating a continuation,
307 if it has become long. */
309 #ifndef DBX_CONTIN_LENGTH
310 #define DBX_CONTIN_LENGTH 80
313 #if DBX_CONTIN_LENGTH > 0
315 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
317 #define CONTIN do { } while (0)
321 static void emit_bincl_stab (const char *c
);
322 static void emit_pending_bincls (void);
324 static inline void emit_pending_bincls_if_required (void);
326 static void dbxout_init (const char *);
327 static void dbxout_finish (const char *);
328 static void dbxout_start_source_file (unsigned, const char *);
329 static void dbxout_end_source_file (unsigned);
330 static void dbxout_typedefs (tree
);
331 static void dbxout_fptype_value (tree
);
332 static void dbxout_type_index (tree
);
333 #if DBX_CONTIN_LENGTH > 0
334 static void dbxout_continue (void);
336 static void dbxout_args (tree
);
337 static void dbxout_type_fields (tree
);
338 static void dbxout_type_method_1 (tree
, const char *);
339 static void dbxout_type_methods (tree
);
340 static void dbxout_range_type (tree
);
341 static void dbxout_type (tree
, int);
342 static bool print_int_cst_bounds_in_octal_p (tree
);
343 static void print_int_cst_octal (tree
);
344 static void print_octal (unsigned HOST_WIDE_INT
, int);
345 static void print_wide_int (HOST_WIDE_INT
);
346 static void dbxout_type_name (tree
);
347 static void dbxout_class_name_qualifiers (tree
);
348 static int dbxout_symbol_location (tree
, tree
, const char *, rtx
);
349 static void dbxout_symbol_name (tree
, const char *, int);
350 static void dbxout_prepare_symbol (tree
);
351 static void dbxout_finish_symbol (tree
);
352 static void dbxout_block (tree
, int, tree
);
353 static void dbxout_global_decl (tree
);
354 static void dbxout_handle_pch (unsigned);
356 /* The debug hooks structure. */
357 #if defined (DBX_DEBUGGING_INFO)
359 static void dbxout_source_line (unsigned int, const char *);
360 static void dbxout_source_file (FILE *, const char *);
361 static void dbxout_function_end (void);
362 static void dbxout_begin_function (tree
);
363 static void dbxout_begin_block (unsigned, unsigned);
364 static void dbxout_end_block (unsigned, unsigned);
365 static void dbxout_function_decl (tree
);
367 const struct gcc_debug_hooks dbx_debug_hooks
=
371 debug_nothing_int_charstar
,
372 debug_nothing_int_charstar
,
373 dbxout_start_source_file
,
374 dbxout_end_source_file
,
377 debug_true_tree
, /* ignore_block */
378 dbxout_source_line
, /* source_line */
379 dbxout_source_line
, /* begin_prologue: just output line info */
380 debug_nothing_int_charstar
, /* end_prologue */
381 debug_nothing_int_charstar
, /* end_epilogue */
382 #ifdef DBX_FUNCTION_FIRST
383 dbxout_begin_function
,
385 debug_nothing_tree
, /* begin_function */
387 debug_nothing_int
, /* end_function */
388 dbxout_function_decl
,
389 dbxout_global_decl
, /* global_decl */
390 debug_nothing_tree
, /* deferred_inline_function */
391 debug_nothing_tree
, /* outlining_inline_function */
392 debug_nothing_rtx
, /* label */
393 dbxout_handle_pch
/* handle_pch */
395 #endif /* DBX_DEBUGGING_INFO */
397 #if defined (XCOFF_DEBUGGING_INFO)
398 const struct gcc_debug_hooks xcoff_debug_hooks
=
402 debug_nothing_int_charstar
,
403 debug_nothing_int_charstar
,
404 dbxout_start_source_file
,
405 dbxout_end_source_file
,
406 xcoffout_begin_block
,
408 debug_true_tree
, /* ignore_block */
409 xcoffout_source_line
,
410 xcoffout_begin_prologue
, /* begin_prologue */
411 debug_nothing_int_charstar
, /* end_prologue */
412 xcoffout_end_epilogue
,
413 debug_nothing_tree
, /* begin_function */
414 xcoffout_end_function
,
415 debug_nothing_tree
, /* function_decl */
416 dbxout_global_decl
, /* global_decl */
417 debug_nothing_tree
, /* deferred_inline_function */
418 debug_nothing_tree
, /* outlining_inline_function */
419 debug_nothing_rtx
, /* label */
420 dbxout_handle_pch
/* handle_pch */
422 #endif /* XCOFF_DEBUGGING_INFO */
424 #if defined (DBX_DEBUGGING_INFO)
426 dbxout_function_end (void)
428 char lscope_label_name
[100];
429 /* Convert Ltext into the appropriate format for local labels in case
430 the system doesn't insert underscores in front of user generated
432 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name
, "Lscope", scope_labelno
);
433 (*targetm
.asm_out
.internal_label
) (asmfile
, "Lscope", scope_labelno
);
436 /* By convention, GCC will mark the end of a function with an N_FUN
437 symbol and an empty string. */
438 #ifdef DBX_OUTPUT_NFUN
439 DBX_OUTPUT_NFUN (asmfile
, lscope_label_name
, current_function_decl
);
441 fprintf (asmfile
, "%s\"\",%d,0,0,", ASM_STABS_OP
, N_FUN
);
442 assemble_name (asmfile
, lscope_label_name
);
444 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
445 fprintf (asmfile
, "\n");
448 #endif /* DBX_DEBUGGING_INFO */
450 /* At the beginning of compilation, start writing the symbol table.
451 Initialize `typevec' and output the standard data types of C. */
454 dbxout_init (const char *input_file_name
)
456 char ltext_label_name
[100];
457 tree syms
= (*lang_hooks
.decls
.getdecls
) ();
459 asmfile
= asm_out_file
;
462 typevec
= ggc_calloc (typevec_len
, sizeof typevec
[0]);
464 /* Convert Ltext into the appropriate format for local labels in case
465 the system doesn't insert underscores in front of user generated
467 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
469 /* Put the current working directory in an N_SO symbol. */
470 if (use_gnu_debug_info_extensions
)
472 if (!cwd
&& (cwd
= get_src_pwd ())
473 && (!*cwd
|| cwd
[strlen (cwd
) - 1] != '/'))
474 cwd
= concat (cwd
, FILE_NAME_JOINER
, NULL
);
477 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
478 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile
, cwd
);
479 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
480 fprintf (asmfile
, "%s", ASM_STABS_OP
);
481 output_quoted_string (asmfile
, cwd
);
482 fprintf (asmfile
, ",%d,0,0,", N_SO
);
483 assemble_name (asmfile
, ltext_label_name
);
484 fputc ('\n', asmfile
);
485 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
489 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
490 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile
, input_file_name
);
491 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
492 /* We include outputting `Ltext:' here,
493 because that gives you a way to override it. */
494 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
495 fprintf (asmfile
, "%s", ASM_STABS_OP
);
496 output_quoted_string (asmfile
, input_file_name
);
497 fprintf (asmfile
, ",%d,0,0,", N_SO
);
498 assemble_name (asmfile
, ltext_label_name
);
499 fputc ('\n', asmfile
);
501 (*targetm
.asm_out
.internal_label
) (asmfile
, "Ltext", 0);
502 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
504 #ifdef DBX_OUTPUT_GCC_MARKER
505 DBX_OUTPUT_GCC_MARKER (asmfile
);
507 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
508 fprintf (asmfile
, "%s\"%s\",%d,0,0,0\n",
509 ASM_STABS_OP
, STABS_GCC_MARKER
, N_OPT
);
512 base_input_file
= lastfile
= input_file_name
;
514 next_type_number
= 1;
517 current_file
= ggc_alloc (sizeof *current_file
);
518 current_file
->next
= NULL
;
519 current_file
->file_number
= 0;
520 current_file
->next_type_number
= 1;
521 next_file_number
= 1;
522 current_file
->prev
= NULL
;
523 current_file
->bincl_status
= BINCL_NOT_REQUIRED
;
524 current_file
->pending_bincl_name
= NULL
;
527 /* Make sure that types `int' and `char' have numbers 1 and 2.
528 Definitions of other integer types will refer to those numbers.
529 (Actually it should no longer matter what their numbers are.
530 Also, if any types with tags have been defined, dbxout_symbol
531 will output them first, so the numbers won't be 1 and 2. That
532 happens in C++. So it's a good thing it should no longer matter). */
534 #ifdef DBX_OUTPUT_STANDARD_TYPES
535 DBX_OUTPUT_STANDARD_TYPES (syms
);
538 /* Get all permanent types that have typedef names, and output them
539 all, except for those already output. Some language front ends
540 put these declarations in the top-level scope; some do not. */
541 dbxout_typedefs ((*lang_hooks
.decls
.builtin_type_decls
) ());
542 dbxout_typedefs (syms
);
545 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
546 in the reverse order from that which is found in SYMS. */
549 dbxout_typedefs (tree syms
)
553 dbxout_typedefs (TREE_CHAIN (syms
));
554 if (TREE_CODE (syms
) == TYPE_DECL
)
556 tree type
= TREE_TYPE (syms
);
558 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
559 && COMPLETE_TYPE_P (type
)
560 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
561 dbxout_symbol (TYPE_NAME (type
), 0);
567 /* Emit BINCL stab using given name. */
569 emit_bincl_stab (const char *name
)
571 fprintf (asmfile
, "%s", ASM_STABS_OP
);
572 output_quoted_string (asmfile
, name
);
573 fprintf (asmfile
, ",%d,0,0,0\n", N_BINCL
);
576 /* If there are pending bincls then it is time to emit all of them. */
579 emit_pending_bincls_if_required (void)
582 emit_pending_bincls ();
585 /* Emit all pending bincls. */
588 emit_pending_bincls (void)
590 struct dbx_file
*f
= current_file
;
592 /* Find first pending bincl. */
593 while (f
->bincl_status
== BINCL_PENDING
)
596 /* Now emit all bincls. */
601 if (f
->bincl_status
== BINCL_PENDING
)
603 emit_bincl_stab (f
->pending_bincl_name
);
605 /* Update file number and status. */
606 f
->file_number
= next_file_number
++;
607 f
->bincl_status
= BINCL_PROCESSED
;
609 if (f
== current_file
)
614 /* All pending bincls have been emitted. */
621 emit_pending_bincls_if_required (void) {}
624 /* Change to reading from a new source file. Generate a N_BINCL stab. */
627 dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED
,
628 const char *filename ATTRIBUTE_UNUSED
)
631 struct dbx_file
*n
= ggc_alloc (sizeof *n
);
633 n
->next
= current_file
;
634 n
->next_type_number
= 1;
635 /* Do not assign file number now.
636 Delay it until we actually emit BINCL. */
639 current_file
->prev
= n
;
640 n
->bincl_status
= BINCL_PENDING
;
641 n
->pending_bincl_name
= filename
;
647 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
650 dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED
)
653 /* Emit EINCL stab only if BINCL is not pending. */
654 if (current_file
->bincl_status
== BINCL_PROCESSED
)
655 fprintf (asmfile
, "%s%d,0,0,0\n", ASM_STABN_OP
, N_EINCL
);
656 current_file
->bincl_status
= BINCL_NOT_REQUIRED
;
657 current_file
= current_file
->next
;
661 /* Handle a few odd cases that occur when trying to make PCH files work. */
664 dbxout_handle_pch (unsigned at_end
)
668 /* When using the PCH, this file will be included, so we need to output
670 dbxout_start_source_file (0, lastfile
);
672 /* The base file when using the PCH won't be the same as
673 the base file when it's being generated. */
678 /* ... and an EINCL. */
679 dbxout_end_source_file (0);
681 /* Deal with cases where 'lastfile' was never actually changed. */
682 lastfile_is_base
= lastfile
== NULL
;
686 #if defined (DBX_DEBUGGING_INFO)
687 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
690 dbxout_source_file (FILE *file
, const char *filename
)
692 if (lastfile
== 0 && lastfile_is_base
)
694 lastfile
= base_input_file
;
695 lastfile_is_base
= 0;
698 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
700 char ltext_label_name
[100];
702 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext",
703 source_label_number
);
704 fprintf (file
, "%s", ASM_STABS_OP
);
705 output_quoted_string (file
, filename
);
706 fprintf (asmfile
, ",%d,0,0,", N_SOL
);
707 assemble_name (asmfile
, ltext_label_name
);
708 fputc ('\n', asmfile
);
709 if (current_function_decl
!= NULL_TREE
710 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
711 ; /* Don't change section amid function. */
714 (*targetm
.asm_out
.internal_label
) (file
, "Ltext", source_label_number
);
715 source_label_number
++;
720 /* Output a line number symbol entry for source file FILENAME and line
724 dbxout_source_line (unsigned int lineno
, const char *filename
)
726 dbxout_source_file (asmfile
, filename
);
728 #ifdef ASM_OUTPUT_SOURCE_LINE
729 dbxout_source_line_counter
+= 1;
730 ASM_OUTPUT_SOURCE_LINE (asmfile
, lineno
, dbxout_source_line_counter
);
732 fprintf (asmfile
, "%s%d,0,%d\n", ASM_STABD_OP
, N_SLINE
, lineno
);
736 /* Describe the beginning of an internal block within a function. */
739 dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED
, unsigned int n
)
741 emit_pending_bincls_if_required ();
742 (*targetm
.asm_out
.internal_label
) (asmfile
, "LBB", n
);
745 /* Describe the end line-number of an internal block within a function. */
748 dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED
, unsigned int n
)
750 emit_pending_bincls_if_required ();
751 (*targetm
.asm_out
.internal_label
) (asmfile
, "LBE", n
);
754 /* Output dbx data for a function definition.
755 This includes a definition of the function name itself (a symbol),
756 definitions of the parameters (locating them in the parameter list)
757 and then output the block that makes up the function's body
758 (including all the auto variables of the function). */
761 dbxout_function_decl (tree decl
)
763 emit_pending_bincls_if_required ();
764 #ifndef DBX_FUNCTION_FIRST
765 dbxout_begin_function (decl
);
767 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
768 #ifdef DBX_OUTPUT_FUNCTION_END
769 DBX_OUTPUT_FUNCTION_END (asmfile
, decl
);
771 if (use_gnu_debug_info_extensions
772 #if defined(NO_DBX_FUNCTION_END)
773 && ! NO_DBX_FUNCTION_END
775 && targetm
.have_named_sections
)
776 dbxout_function_end ();
779 #endif /* DBX_DEBUGGING_INFO */
781 /* Debug information for a global DECL. Called from toplev.c after
782 compilation proper has finished. */
784 dbxout_global_decl (tree decl
)
786 if (TREE_CODE (decl
) == VAR_DECL
787 && ! DECL_EXTERNAL (decl
)
788 && DECL_RTL_SET_P (decl
)) /* Not necessary? */
790 int saved_tree_used
= TREE_USED (decl
);
791 TREE_USED (decl
) = 1;
792 dbxout_symbol (decl
, 0);
793 TREE_USED (decl
) = saved_tree_used
;
797 /* At the end of compilation, finish writing the symbol table.
798 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
802 dbxout_finish (const char *filename ATTRIBUTE_UNUSED
)
804 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
805 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile
, filename
);
806 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
811 /* Output floating point type values used by the 'R' stab letter.
812 These numbers come from include/aout/stab_gnu.h in binutils/gdb.
814 There are only 3 real/complex types defined, and we need 7/6.
815 We use NF_SINGLE as a generic float type, and NF_COMPLEX as a generic
816 complex type. Since we have the type size anyways, we don't really need
817 to distinguish between different FP types, we only need to distinguish
818 between float and complex. This works fine with gdb.
820 We only use this for complex types, to avoid breaking backwards
821 compatibility for real types. complex types aren't in ISO C90, so it is
822 OK if old debuggers don't understand the debug info we emit for them. */
824 /* ??? These are supposed to be IEEE types, but we don't check for that.
825 We could perhaps add additional numbers for non-IEEE types if we need
829 dbxout_fptype_value (tree type
)
832 enum machine_mode mode
= TYPE_MODE (type
);
834 if (TREE_CODE (type
) == REAL_TYPE
)
838 else if (mode
== DFmode
)
840 else if (mode
== TFmode
|| mode
== XFmode
)
843 /* Use NF_SINGLE as a generic real type for other sizes. */
846 else if (TREE_CODE (type
) == COMPLEX_TYPE
)
850 else if (mode
== DCmode
)
852 else if (mode
== TCmode
|| mode
== XCmode
)
855 /* Use NF_COMPLEX as a generic complex type for other sizes. */
861 putc (value
, asmfile
);
865 /* Output the index of a type. */
868 dbxout_type_index (tree type
)
870 #ifndef DBX_USE_BINCL
871 fprintf (asmfile
, "%d", TYPE_SYMTAB_ADDRESS (type
));
874 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
875 fprintf (asmfile
, "(%d,%d)", t
->file_number
, t
->type_number
);
880 #if DBX_CONTIN_LENGTH > 0
881 /* Continue a symbol-description that gets too big.
882 End one symbol table entry with a double-backslash
883 and start a new one, eventually producing something like
884 .stabs "start......\\",code,0,value
885 .stabs "...rest",code,0,value */
888 dbxout_continue (void)
890 emit_pending_bincls_if_required ();
891 #ifdef DBX_CONTIN_CHAR
892 fprintf (asmfile
, "%c", DBX_CONTIN_CHAR
);
894 fprintf (asmfile
, "\\\\");
896 dbxout_finish_symbol (NULL_TREE
);
897 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
898 current_sym_nchars
= 0;
900 #endif /* DBX_CONTIN_LENGTH > 0 */
902 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
903 This must be a separate function because anonymous unions require
907 dbxout_type_fields (tree type
)
911 /* Output the name, type, position (in bits), size (in bits) of each
912 field that we can support. */
913 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
915 /* Omit here local type decls until we know how to support them. */
916 if (TREE_CODE (tem
) == TYPE_DECL
917 /* Omit fields whose position or size are variable or too large to
919 || (TREE_CODE (tem
) == FIELD_DECL
920 && (! host_integerp (bit_position (tem
), 0)
922 || ! host_integerp (DECL_SIZE (tem
), 1)))
923 /* Omit here the nameless fields that are used to skip bits. */
924 || DECL_IGNORED_P (tem
))
927 else if (TREE_CODE (tem
) != CONST_DECL
)
929 /* Continue the line if necessary,
930 but not before the first field. */
931 if (tem
!= TYPE_FIELDS (type
))
936 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem
)));
937 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem
)));
941 fprintf (asmfile
, ":");
945 if (use_gnu_debug_info_extensions
946 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
947 || TREE_CODE (tem
) != FIELD_DECL
))
949 have_used_extensions
= 1;
951 putc ((TREE_PRIVATE (tem
) ? '0'
952 : TREE_PROTECTED (tem
) ? '1' : '2'),
957 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
958 && DECL_BIT_FIELD_TYPE (tem
))
959 ? DECL_BIT_FIELD_TYPE (tem
) : TREE_TYPE (tem
), 0);
961 if (TREE_CODE (tem
) == VAR_DECL
)
963 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
965 tree name
= DECL_ASSEMBLER_NAME (tem
);
967 have_used_extensions
= 1;
968 fprintf (asmfile
, ":%s;", IDENTIFIER_POINTER (name
));
969 CHARS (IDENTIFIER_LENGTH (name
) + 2);
973 /* If TEM is non-static, GDB won't understand it. */
974 fprintf (asmfile
, ",0,0;");
981 print_wide_int (int_bit_position (tem
));
983 print_wide_int (tree_low_cst (DECL_SIZE (tem
), 1));
991 /* Subroutine of `dbxout_type_methods'. Output debug info about the
992 method described DECL. DEBUG_NAME is an encoding of the method's
993 type signature. ??? We may be able to do without DEBUG_NAME altogether
997 dbxout_type_method_1 (tree decl
, const char *debug_name
)
1001 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
1003 else /* it's a METHOD_TYPE. */
1005 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
1006 /* A for normal functions.
1007 B for `const' member functions.
1008 C for `volatile' member functions.
1009 D for `const volatile' member functions. */
1010 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
1012 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
1015 if (DECL_VINDEX (decl
))
1021 fprintf (asmfile
, ":%s;%c%c%c", debug_name
,
1022 TREE_PRIVATE (decl
) ? '0'
1023 : TREE_PROTECTED (decl
) ? '1' : '2', c1
, c2
);
1024 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
)) + 6
1025 - (debug_name
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
))));
1027 if (DECL_VINDEX (decl
) && host_integerp (DECL_VINDEX (decl
), 0))
1029 print_wide_int (tree_low_cst (DECL_VINDEX (decl
), 0));
1030 putc (';', asmfile
);
1032 dbxout_type (DECL_CONTEXT (decl
), 0);
1033 fprintf (asmfile
, ";");
1038 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
1042 dbxout_type_methods (tree type
)
1044 /* C++: put out the method names and their parameter lists */
1045 tree methods
= TYPE_METHODS (type
);
1049 char formatted_type_identifier_length
[16];
1050 int type_identifier_length
;
1052 if (methods
== NULL_TREE
)
1055 type_encoding
= DECL_NAME (TYPE_NAME (type
));
1058 /* C++: Template classes break some assumptions made by this code about
1059 the class names, constructor names, and encodings for assembler
1060 label names. For now, disable output of dbx info for them. */
1062 const char *ptr
= IDENTIFIER_POINTER (type_encoding
);
1063 /* This should use index. (mrs) */
1064 while (*ptr
&& *ptr
!= '<') ptr
++;
1075 type_identifier_length
= IDENTIFIER_LENGTH (type_encoding
);
1077 sprintf (formatted_type_identifier_length
, "%d", type_identifier_length
);
1079 if (TREE_CODE (methods
) != TREE_VEC
)
1081 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
1082 fndecl
= TREE_VEC_ELT (methods
, 0);
1084 fndecl
= TREE_VEC_ELT (methods
, 1);
1088 int need_prefix
= 1;
1090 /* Group together all the methods for the same operation.
1091 These differ in the types of the arguments. */
1092 for (last
= NULL_TREE
;
1093 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
1094 fndecl
= TREE_CHAIN (fndecl
))
1095 /* Output the name of the field (after overloading), as
1096 well as the name of the field before overloading, along
1097 with its parameter list */
1099 /* This is the "mangled" name of the method.
1100 It encodes the argument types. */
1101 const char *debug_name
;
1103 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1104 include TEMPLATE_DECLs.) The debugger doesn't know what
1105 to do with such entities anyhow. */
1106 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
1109 debug_name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
));
1115 /* Also ignore abstract methods; those are only interesting to
1116 the DWARF backends. */
1117 if (DECL_IGNORED_P (fndecl
) || DECL_ABSTRACT (fndecl
))
1120 /* Redundantly output the plain name, since that's what gdb
1124 tree name
= DECL_NAME (fndecl
);
1125 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
1126 CHARS (IDENTIFIER_LENGTH (name
) + 2);
1130 dbxout_type (TREE_TYPE (fndecl
), 0);
1132 dbxout_type_method_1 (fndecl
, debug_name
);
1136 putc (';', asmfile
);
1142 /* Emit a "range" type specification, which has the form:
1143 "r<index type>;<lower bound>;<upper bound>;".
1144 TYPE is an INTEGER_TYPE. */
1147 dbxout_range_type (tree type
)
1149 fprintf (asmfile
, "r");
1150 if (TREE_TYPE (type
))
1151 dbxout_type (TREE_TYPE (type
), 0);
1152 else if (TREE_CODE (type
) != INTEGER_TYPE
)
1153 dbxout_type (type
, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1156 /* Traditionally, we made sure 'int' was type 1, and builtin types
1157 were defined to be sub-ranges of int. Unfortunately, this
1158 does not allow us to distinguish true sub-ranges from integer
1159 types. So, instead we define integer (non-sub-range) types as
1160 sub-ranges of themselves. This matters for Chill. If this isn't
1161 a subrange type, then we want to define it in terms of itself.
1162 However, in C, this may be an anonymous integer type, and we don't
1163 want to emit debug info referring to it. Just calling
1164 dbxout_type_index won't work anyways, because the type hasn't been
1165 defined yet. We make this work for both cases by checked to see
1166 whether this is a defined type, referring to it if it is, and using
1168 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
1169 dbxout_type_index (type
);
1171 dbxout_type_index (integer_type_node
);
1174 if (TYPE_MIN_VALUE (type
) != 0
1175 && host_integerp (TYPE_MIN_VALUE (type
), 0))
1177 putc (';', asmfile
);
1179 if (print_int_cst_bounds_in_octal_p (type
))
1180 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1182 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type
), 0));
1186 fprintf (asmfile
, ";0");
1190 if (TYPE_MAX_VALUE (type
) != 0
1191 && host_integerp (TYPE_MAX_VALUE (type
), 0))
1193 putc (';', asmfile
);
1195 if (print_int_cst_bounds_in_octal_p (type
))
1196 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1198 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type
), 0));
1199 putc (';', asmfile
);
1204 fprintf (asmfile
, ";-1;");
1210 /* Output a reference to a type. If the type has not yet been
1211 described in the dbx output, output its definition now.
1212 For a type already defined, just refer to its definition
1213 using the type number.
1215 If FULL is nonzero, and the type has been described only with
1216 a forward-reference, output the definition now.
1217 If FULL is zero in this case, just refer to the forward-reference
1218 using the number previously allocated. */
1221 dbxout_type (tree type
, int full
)
1225 static int anonymous_type_number
= 0;
1227 if (TREE_CODE (type
) == VECTOR_TYPE
)
1228 /* The frontend feeds us a representation for the vector as a struct
1229 containing an array. Pull out the array type. */
1230 type
= TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type
)));
1232 /* If there was an input error and we don't really have a type,
1233 avoid crashing and write something that is at least valid
1234 by assuming `int'. */
1235 if (type
== error_mark_node
)
1236 type
= integer_type_node
;
1239 if (TYPE_NAME (type
)
1240 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1241 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
1245 /* Try to find the "main variant" with the same name. */
1246 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1247 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1248 main_variant
= TREE_TYPE (TYPE_NAME (type
));
1250 main_variant
= TYPE_MAIN_VARIANT (type
);
1252 /* If we are not using extensions, stabs does not distinguish const and
1253 volatile, so there is no need to make them separate types. */
1254 if (!use_gnu_debug_info_extensions
)
1255 type
= main_variant
;
1257 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
1259 /* Type has no dbx number assigned. Assign next available number. */
1260 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
1262 /* Make sure type vector is long enough to record about this type. */
1264 if (next_type_number
== typevec_len
)
1267 = ggc_realloc (typevec
, (typevec_len
* 2 * sizeof typevec
[0]));
1268 memset (typevec
+ typevec_len
, 0, typevec_len
* sizeof typevec
[0]);
1272 #ifdef DBX_USE_BINCL
1273 emit_pending_bincls_if_required ();
1274 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
1275 = current_file
->file_number
;
1276 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
1277 = current_file
->next_type_number
++;
1281 if (flag_debug_only_used_symbols
)
1283 if ((TREE_CODE (type
) == RECORD_TYPE
1284 || TREE_CODE (type
) == UNION_TYPE
1285 || TREE_CODE (type
) == QUAL_UNION_TYPE
1286 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1287 && TYPE_STUB_DECL (type
)
1288 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (type
))) == 'd'
1289 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type
)))
1290 debug_queue_symbol (TYPE_STUB_DECL (type
));
1291 else if (TYPE_NAME (type
)
1292 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1293 debug_queue_symbol (TYPE_NAME (type
));
1296 /* Output the number of this type, to refer to it. */
1297 dbxout_type_index (type
);
1299 #ifdef DBX_TYPE_DEFINED
1300 if (DBX_TYPE_DEFINED (type
))
1304 /* If this type's definition has been output or is now being output,
1307 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
1312 /* If we have already had a cross reference,
1313 and either that's all we want or that's the best we could do,
1314 don't repeat the cross reference.
1315 Sun dbx crashes if we do. */
1316 if (! full
|| !COMPLETE_TYPE_P (type
)
1317 /* No way in DBX fmt to describe a variable size. */
1318 || ! host_integerp (TYPE_SIZE (type
), 1))
1326 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1327 leave the type-number completely undefined rather than output
1328 a cross-reference. If we have already used GNU debug info extensions,
1329 then it is OK to output a cross reference. This is necessary to get
1330 proper C++ debug output. */
1331 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1332 || TREE_CODE (type
) == QUAL_UNION_TYPE
1333 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1334 && ! use_gnu_debug_info_extensions
)
1335 /* We must use the same test here as we use twice below when deciding
1336 whether to emit a cross-reference. */
1337 if ((TYPE_NAME (type
) != 0
1338 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1339 && DECL_IGNORED_P (TYPE_NAME (type
)))
1341 || !COMPLETE_TYPE_P (type
)
1342 /* No way in DBX fmt to describe a variable size. */
1343 || ! host_integerp (TYPE_SIZE (type
), 1))
1345 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1350 /* Output a definition now. */
1352 fprintf (asmfile
, "=");
1355 /* Mark it as defined, so that if it is self-referent
1356 we will not get into an infinite recursion of definitions. */
1358 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1360 /* If this type is a variant of some other, hand off. Types with
1361 different names are usefully distinguished. We only distinguish
1362 cv-qualified types if we're using extensions. */
1363 if (TYPE_READONLY (type
) > TYPE_READONLY (main_variant
))
1365 putc ('k', asmfile
);
1367 dbxout_type (build_type_variant (type
, 0, TYPE_VOLATILE (type
)), 0);
1370 else if (TYPE_VOLATILE (type
) > TYPE_VOLATILE (main_variant
))
1372 putc ('B', asmfile
);
1374 dbxout_type (build_type_variant (type
, TYPE_READONLY (type
), 0), 0);
1377 else if (main_variant
!= TYPE_MAIN_VARIANT (type
))
1379 if (flag_debug_only_used_symbols
)
1381 tree orig_type
= DECL_ORIGINAL_TYPE (TYPE_NAME (type
));
1383 if ((TREE_CODE (orig_type
) == RECORD_TYPE
1384 || TREE_CODE (orig_type
) == UNION_TYPE
1385 || TREE_CODE (orig_type
) == QUAL_UNION_TYPE
1386 || TREE_CODE (orig_type
) == ENUMERAL_TYPE
)
1387 && TYPE_STUB_DECL (orig_type
)
1388 && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type
)))
1389 debug_queue_symbol (TYPE_STUB_DECL (orig_type
));
1391 /* 'type' is a typedef; output the type it refers to. */
1392 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0);
1395 /* else continue. */
1397 switch (TREE_CODE (type
))
1401 /* For a void type, just define it as itself; ie, "5=5".
1402 This makes us consider it defined
1403 without saying what it is. The debugger will make it
1404 a void type when the reference is seen, and nothing will
1405 ever override that default. */
1406 dbxout_type_index (type
);
1410 if (type
== char_type_node
&& ! TREE_UNSIGNED (type
))
1412 /* Output the type `char' as a subrange of itself!
1413 I don't understand this definition, just copied it
1414 from the output of pcc.
1415 This used to use `r2' explicitly and we used to
1416 take care to make sure that `char' was type number 2. */
1417 fprintf (asmfile
, "r");
1419 dbxout_type_index (type
);
1420 fprintf (asmfile
, ";0;127;");
1424 /* If this is a subtype of another integer type, always prefer to
1425 write it as a subtype. */
1426 else if (TREE_TYPE (type
) != 0
1427 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_TYPE
)
1429 /* If the size is non-standard, say what it is if we can use
1432 if (use_gnu_debug_info_extensions
1433 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1435 have_used_extensions
= 1;
1436 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1440 dbxout_range_type (type
);
1445 /* If the size is non-standard, say what it is if we can use
1448 if (use_gnu_debug_info_extensions
1449 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1451 have_used_extensions
= 1;
1452 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1456 if (print_int_cst_bounds_in_octal_p (type
))
1458 fprintf (asmfile
, "r");
1461 /* If this type derives from another type, output type index of
1462 parent type. This is particularly important when parent type
1463 is an enumerated type, because not generating the parent type
1464 index would transform the definition of this enumerated type
1465 into a plain unsigned type. */
1466 if (TREE_TYPE (type
) != 0)
1467 dbxout_type_index (TREE_TYPE (type
));
1469 dbxout_type_index (type
);
1471 fprintf (asmfile
, ";");
1473 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1474 fprintf (asmfile
, ";");
1476 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1477 fprintf (asmfile
, ";");
1482 /* Output other integer types as subranges of `int'. */
1483 dbxout_range_type (type
);
1489 /* This used to say `r1' and we used to take care
1490 to make sure that `int' was type number 1. */
1491 fprintf (asmfile
, "r");
1493 dbxout_type_index (integer_type_node
);
1494 putc (';', asmfile
);
1496 print_wide_int (int_size_in_bytes (type
));
1497 fputs (";0;", asmfile
);
1502 if (use_gnu_debug_info_extensions
)
1504 have_used_extensions
= 1;
1505 fputs ("@s", asmfile
);
1507 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1508 fputs (";-20;", asmfile
);
1513 /* Output the type `char' as a subrange of itself.
1514 That is what pcc seems to do. */
1515 fprintf (asmfile
, "r");
1517 dbxout_type_index (char_type_node
);
1518 fprintf (asmfile
, ";0;%d;", TREE_UNSIGNED (type
) ? 255 : 127);
1524 if (use_gnu_debug_info_extensions
)
1526 have_used_extensions
= 1;
1527 fputs ("@s", asmfile
);
1529 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1530 fputs (";-16;", asmfile
);
1533 else /* Define as enumeral type (False, True) */
1535 fprintf (asmfile
, "eFalse:0,True:1,;");
1541 putc ('d', asmfile
);
1543 dbxout_type (TREE_TYPE (type
), 0);
1547 /* Differs from the REAL_TYPE by its new data type number */
1549 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1551 putc ('R', asmfile
);
1553 dbxout_fptype_value (type
);
1554 putc (';', asmfile
);
1556 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type
)));
1557 fputs (";0;", asmfile
);
1562 /* Output a complex integer type as a structure,
1563 pending some other way to do it. */
1564 putc ('s', asmfile
);
1566 print_wide_int (int_size_in_bytes (type
));
1567 fprintf (asmfile
, "real:");
1570 dbxout_type (TREE_TYPE (type
), 0);
1571 fprintf (asmfile
, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type
)));
1573 fprintf (asmfile
, "imag:");
1575 dbxout_type (TREE_TYPE (type
), 0);
1576 fprintf (asmfile
, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type
)),
1577 TYPE_PRECISION (TREE_TYPE (type
)));
1583 if (use_gnu_debug_info_extensions
)
1585 have_used_extensions
= 1;
1586 fputs ("@s", asmfile
);
1588 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1589 putc (';', asmfile
);
1592 /* Check if a bitstring type, which in Chill is
1593 different from a [power]set. */
1594 if (TYPE_STRING_FLAG (type
))
1596 fprintf (asmfile
, "@S;");
1600 putc ('S', asmfile
);
1602 dbxout_type (TYPE_DOMAIN (type
), 0);
1606 /* Make arrays of packed bits look like bitstrings for chill. */
1607 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1609 have_used_extensions
= 1;
1610 fputs ("@s", asmfile
);
1612 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1613 fprintf (asmfile
, ";@S;S");
1615 dbxout_type (TYPE_DOMAIN (type
), 0);
1619 /* Output "a" followed by a range type definition
1620 for the index type of the array
1621 followed by a reference to the target-type.
1622 ar1;0;N;M for a C array of type M and size N+1. */
1623 /* Check if a character string type, which in Chill is
1624 different from an array of characters. */
1625 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
1627 have_used_extensions
= 1;
1628 fprintf (asmfile
, "@S;");
1631 tem
= TYPE_DOMAIN (type
);
1634 fprintf (asmfile
, "ar");
1636 dbxout_type_index (integer_type_node
);
1637 fprintf (asmfile
, ";0;-1;");
1642 fprintf (asmfile
, "a");
1644 dbxout_range_type (tem
);
1647 dbxout_type (TREE_TYPE (type
), 0);
1652 case QUAL_UNION_TYPE
:
1654 int i
, n_baseclasses
= 0;
1656 if (TYPE_BINFO (type
) != 0
1657 && TREE_CODE (TYPE_BINFO (type
)) == TREE_VEC
1658 && TYPE_BINFO_BASETYPES (type
) != 0)
1659 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1661 /* Output a structure type. We must use the same test here as we
1662 use in the DBX_NO_XREFS case above. */
1663 if ((TYPE_NAME (type
) != 0
1664 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1665 && DECL_IGNORED_P (TYPE_NAME (type
)))
1667 || !COMPLETE_TYPE_P (type
)
1668 /* No way in DBX fmt to describe a variable size. */
1669 || ! host_integerp (TYPE_SIZE (type
), 1))
1671 /* If the type is just a cross reference, output one
1672 and mark the type as partially described.
1673 If it later becomes defined, we will output
1674 its real definition.
1675 If the type has a name, don't nest its definition within
1676 another type's definition; instead, output an xref
1677 and let the definition come when the name is defined. */
1678 fputs ((TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu", asmfile
);
1680 #if 0 /* This assertion is legitimately false in C++. */
1681 /* We shouldn't be outputting a reference to a type before its
1682 definition unless the type has a tag name.
1683 A typedef name without a tag name should be impossible. */
1684 if (TREE_CODE (TYPE_NAME (type
)) != IDENTIFIER_NODE
)
1687 if (TYPE_NAME (type
) != 0)
1688 dbxout_type_name (type
);
1691 fprintf (asmfile
, "$$%d", anonymous_type_number
++);
1695 fprintf (asmfile
, ":");
1697 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1701 /* Identify record or union, and print its size. */
1702 putc (((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u'), asmfile
);
1704 print_wide_int (int_size_in_bytes (type
));
1706 if (use_gnu_debug_info_extensions
)
1710 have_used_extensions
= 1;
1711 fprintf (asmfile
, "!%d,", n_baseclasses
);
1715 for (i
= 0; i
< n_baseclasses
; i
++)
1717 tree binfo
= TYPE_BINFO (type
);
1718 tree child
= BINFO_BASETYPE (binfo
, i
);
1719 tree access
= (BINFO_BASEACCESSES (binfo
)
1720 ? BINFO_BASEACCESS (binfo
, i
) : access_public_node
);
1722 if (use_gnu_debug_info_extensions
)
1724 have_used_extensions
= 1;
1725 putc (TREE_VIA_VIRTUAL (child
) ? '1' : '0', asmfile
);
1726 putc (access
== access_public_node
? '2' : '0', asmfile
);
1728 if (TREE_VIA_VIRTUAL (child
)
1729 && strcmp (lang_hooks
.name
, "GNU C++") == 0)
1730 /* For a virtual base, print the (negative) offset within
1731 the vtable where we must look to find the necessary
1733 print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child
), 0)
1736 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1738 putc (',', asmfile
);
1740 dbxout_type (BINFO_TYPE (child
), 0);
1741 putc (';', asmfile
);
1746 /* Print out the base class information with fields
1747 which have the same names at the types they hold. */
1748 dbxout_type_name (BINFO_TYPE (child
));
1749 putc (':', asmfile
);
1751 dbxout_type (BINFO_TYPE (child
), full
);
1752 putc (',', asmfile
);
1754 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1756 putc (',', asmfile
);
1758 print_wide_int (tree_low_cst (TYPE_SIZE (BINFO_TYPE (child
)),
1761 putc (';', asmfile
);
1767 /* Write out the field declarations. */
1768 dbxout_type_fields (type
);
1769 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
1771 have_used_extensions
= 1;
1772 dbxout_type_methods (type
);
1775 putc (';', asmfile
);
1778 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
1779 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1780 && TYPE_VFIELD (type
))
1782 have_used_extensions
= 1;
1784 /* Tell GDB+ that it may keep reading. */
1785 putc ('~', asmfile
);
1788 /* We need to write out info about what field this class
1789 uses as its "main" vtable pointer field, because if this
1790 field is inherited from a base class, GDB cannot necessarily
1791 figure out which field it's using in time. */
1792 if (TYPE_VFIELD (type
))
1794 putc ('%', asmfile
);
1796 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0);
1799 putc (';', asmfile
);
1805 /* We must use the same test here as we use in the DBX_NO_XREFS case
1806 above. We simplify it a bit since an enum will never have a variable
1808 if ((TYPE_NAME (type
) != 0
1809 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1810 && DECL_IGNORED_P (TYPE_NAME (type
)))
1812 || !COMPLETE_TYPE_P (type
))
1814 fprintf (asmfile
, "xe");
1816 dbxout_type_name (type
);
1817 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1818 putc (':', asmfile
);
1822 if (use_gnu_debug_info_extensions
1823 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1825 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1829 putc ('e', asmfile
);
1831 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1833 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1834 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem
)) + 1);
1835 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
1836 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1837 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
1838 && (HOST_WIDE_INT
) TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
1839 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1841 print_int_cst_octal (TREE_VALUE (tem
));
1843 putc (',', asmfile
);
1845 if (TREE_CHAIN (tem
) != 0)
1849 putc (';', asmfile
);
1854 putc ('*', asmfile
);
1856 dbxout_type (TREE_TYPE (type
), 0);
1860 if (use_gnu_debug_info_extensions
)
1862 have_used_extensions
= 1;
1863 putc ('#', asmfile
);
1866 /* Write the argument types out longhand. */
1867 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0);
1868 putc (',', asmfile
);
1870 dbxout_type (TREE_TYPE (type
), 0);
1871 dbxout_args (TYPE_ARG_TYPES (type
));
1872 putc (';', asmfile
);
1876 /* Treat it as a function type. */
1877 dbxout_type (TREE_TYPE (type
), 0);
1881 if (use_gnu_debug_info_extensions
)
1883 have_used_extensions
= 1;
1884 putc ('@', asmfile
);
1886 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0);
1887 putc (',', asmfile
);
1889 dbxout_type (TREE_TYPE (type
), 0);
1892 /* Should print as an int, because it is really just an offset. */
1893 dbxout_type (integer_type_node
, 0);
1896 case REFERENCE_TYPE
:
1897 if (use_gnu_debug_info_extensions
)
1898 have_used_extensions
= 1;
1899 putc (use_gnu_debug_info_extensions
? '&' : '*', asmfile
);
1901 dbxout_type (TREE_TYPE (type
), 0);
1905 putc ('f', asmfile
);
1907 dbxout_type (TREE_TYPE (type
), 0);
1915 /* Return nonzero if the given type represents an integer whose bounds
1916 should be printed in octal format. */
1919 print_int_cst_bounds_in_octal_p (tree type
)
1921 /* If we can use GDB extensions and the size is wider than a long
1922 (the size used by GDB to read them) or we may have trouble writing
1923 the bounds the usual way, write them in octal. Note the test is for
1924 the *target's* size of "long", not that of the host. The host test
1925 is just to make sure we can write it out in case the host wide int
1926 is narrower than the target "long".
1928 For unsigned types, we use octal if they are the same size or larger.
1929 This is because we print the bounds as signed decimal, and hence they
1930 can't span same size unsigned types. */
1932 if (use_gnu_debug_info_extensions
1933 && TYPE_MIN_VALUE (type
) != 0
1934 && TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
1935 && TYPE_MAX_VALUE (type
) != 0
1936 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
1937 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
1938 || ((TYPE_PRECISION (type
) == TYPE_PRECISION (integer_type_node
))
1939 && TREE_UNSIGNED (type
))
1940 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
1941 || (TYPE_PRECISION (type
) == HOST_BITS_PER_WIDE_INT
1942 && TREE_UNSIGNED (type
))))
1948 /* Print the value of integer constant C, in octal,
1949 handling double precision. */
1952 print_int_cst_octal (tree c
)
1954 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (c
);
1955 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (c
);
1956 int excess
= (3 - (HOST_BITS_PER_WIDE_INT
% 3));
1957 unsigned int width
= TYPE_PRECISION (TREE_TYPE (c
));
1959 /* GDB wants constants with no extra leading "1" bits, so
1960 we need to remove any sign-extension that might be
1962 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
1964 else if (width
> HOST_BITS_PER_WIDE_INT
)
1965 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
1966 else if (width
== HOST_BITS_PER_WIDE_INT
)
1969 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
1971 fprintf (asmfile
, "0");
1976 print_octal (high
, HOST_BITS_PER_WIDE_INT
/ 3);
1977 print_octal (low
, HOST_BITS_PER_WIDE_INT
/ 3);
1981 unsigned HOST_WIDE_INT beg
= high
>> excess
;
1982 unsigned HOST_WIDE_INT middle
1983 = ((high
& (((HOST_WIDE_INT
) 1 << excess
) - 1)) << (3 - excess
)
1984 | (low
>> (HOST_BITS_PER_WIDE_INT
/ 3 * 3)));
1985 unsigned HOST_WIDE_INT end
1986 = low
& (((unsigned HOST_WIDE_INT
) 1
1987 << (HOST_BITS_PER_WIDE_INT
/ 3 * 3))
1990 fprintf (asmfile
, "%o%01o", (int) beg
, (int) middle
);
1992 print_octal (end
, HOST_BITS_PER_WIDE_INT
/ 3);
1997 print_octal (unsigned HOST_WIDE_INT value
, int digits
)
2001 for (i
= digits
- 1; i
>= 0; i
--)
2002 fprintf (asmfile
, "%01o", (int) ((value
>> (3 * i
)) & 7));
2007 /* Output C in decimal while adjusting the number of digits written. */
2010 print_wide_int (HOST_WIDE_INT c
)
2014 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, c
);
2025 /* Output the name of type TYPE, with no punctuation.
2026 Such names can be set up either by typedef declarations
2027 or by struct, enum and union tags. */
2030 dbxout_type_name (tree type
)
2033 if (TYPE_NAME (type
) == 0)
2035 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
2037 t
= TYPE_NAME (type
);
2039 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
2041 t
= DECL_NAME (TYPE_NAME (type
));
2046 fprintf (asmfile
, "%s", IDENTIFIER_POINTER (t
));
2047 CHARS (IDENTIFIER_LENGTH (t
));
2050 /* Output leading leading struct or class names needed for qualifying
2051 type whose scope is limited to a struct or class. */
2054 dbxout_class_name_qualifiers (tree decl
)
2056 tree context
= decl_type_context (decl
);
2058 if (context
!= NULL_TREE
2059 && TREE_CODE(context
) == RECORD_TYPE
2060 && TYPE_NAME (context
) != 0
2061 && (TREE_CODE (TYPE_NAME (context
)) == IDENTIFIER_NODE
2062 || (DECL_NAME (TYPE_NAME (context
)) != 0)))
2064 tree name
= TYPE_NAME (context
);
2066 emit_pending_bincls_if_required ();
2068 if (TREE_CODE (name
) == TYPE_DECL
)
2070 dbxout_class_name_qualifiers (name
);
2071 name
= DECL_NAME (name
);
2073 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
2074 CHARS (IDENTIFIER_LENGTH (name
) + 2);
2078 /* Output a .stabs for the symbol defined by DECL,
2079 which must be a ..._DECL node in the normal namespace.
2080 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
2081 LOCAL is nonzero if the scope is less than the entire file.
2082 Return 1 if a stabs might have been emitted. */
2085 dbxout_symbol (tree decl
, int local ATTRIBUTE_UNUSED
)
2087 tree type
= TREE_TYPE (decl
);
2088 tree context
= NULL_TREE
;
2091 /* "Intercept" dbxout_symbol() calls like we do all debug_hooks. */
2094 /* Cast avoids warning in old compilers. */
2095 current_sym_code
= (STAB_CODE_TYPE
) 0;
2096 current_sym_value
= 0;
2097 current_sym_addr
= 0;
2099 /* Ignore nameless syms, but don't ignore type tags. */
2101 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
2102 || DECL_IGNORED_P (decl
))
2103 DBXOUT_DECR_NESTING_AND_RETURN (0);
2105 /* If we are to generate only the symbols actually used then such
2106 symbol nodees are flagged with TREE_USED. Ignore any that
2107 aren't flaged as TREE_USED. */
2109 if (flag_debug_only_used_symbols
)
2113 if (!TREE_USED (decl
)
2114 && (TREE_CODE (decl
) != VAR_DECL
|| !DECL_INITIAL (decl
)))
2115 DBXOUT_DECR_NESTING_AND_RETURN (0);
2117 /* We now have a used symbol. We need to generate the info for
2118 the symbol's type in addition to the symbol itself. These
2119 type symbols are queued to be generated after were done with
2120 the symbol itself (done because the symbol's info is generated
2121 with fprintf's, etc. as it determines what's needed).
2123 Note, because the TREE_TYPE(type) might be something like a
2124 pointer to a named type we need to look for the first name
2125 we see following the TREE_TYPE chain. */
2128 while (POINTER_TYPE_P (t
))
2131 /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE
2132 need special treatment. The TYPE_STUB_DECL field in these
2133 types generally represents the tag name type we want to
2134 output. In addition there could be a typedef type with
2135 a different name. In that case we also want to output
2138 if ((TREE_CODE (t
) == RECORD_TYPE
2139 || TREE_CODE (t
) == UNION_TYPE
2140 || TREE_CODE (t
) == QUAL_UNION_TYPE
2141 || TREE_CODE (t
) == ENUMERAL_TYPE
)
2142 && TYPE_STUB_DECL (t
)
2143 && TYPE_STUB_DECL (t
) != decl
2144 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (t
))) == 'd'
2145 && ! DECL_IGNORED_P (TYPE_STUB_DECL (t
)))
2147 debug_queue_symbol (TYPE_STUB_DECL (t
));
2149 && TYPE_NAME (t
) != TYPE_STUB_DECL (t
)
2150 && TYPE_NAME (t
) != decl
2151 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t
))) == 'd')
2152 debug_queue_symbol (TYPE_NAME (t
));
2154 else if (TYPE_NAME (t
)
2155 && TYPE_NAME (t
) != decl
2156 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t
))) == 'd')
2157 debug_queue_symbol (TYPE_NAME (t
));
2160 emit_pending_bincls_if_required ();
2162 dbxout_prepare_symbol (decl
);
2164 /* The output will always start with the symbol name,
2165 so always count that in the length-output-so-far. */
2167 if (DECL_NAME (decl
) != 0)
2168 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (decl
));
2170 switch (TREE_CODE (decl
))
2173 /* Enum values are defined by defining the enum type. */
2177 if (DECL_RTL (decl
) == 0)
2178 DBXOUT_DECR_NESTING_AND_RETURN (0);
2179 if (DECL_EXTERNAL (decl
))
2181 /* Don't mention a nested function under its parent. */
2182 context
= decl_function_context (decl
);
2183 if (context
== current_function_decl
)
2185 if (GET_CODE (DECL_RTL (decl
)) != MEM
2186 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
2190 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2191 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2192 TREE_PUBLIC (decl
) ? 'F' : 'f');
2195 current_sym_code
= N_FUN
;
2196 current_sym_addr
= XEXP (DECL_RTL (decl
), 0);
2198 if (TREE_TYPE (type
))
2199 dbxout_type (TREE_TYPE (type
), 0);
2201 dbxout_type (void_type_node
, 0);
2203 /* For a nested function, when that function is compiled,
2204 mention the containing function name
2205 as well as (since dbx wants it) our own assembler-name. */
2207 fprintf (asmfile
, ",%s,%s",
2208 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2209 IDENTIFIER_POINTER (DECL_NAME (context
)));
2211 dbxout_finish_symbol (decl
);
2215 /* Don't output the same typedef twice.
2216 And don't output what language-specific stuff doesn't want output. */
2217 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
2218 DBXOUT_DECR_NESTING_AND_RETURN (0);
2226 if (DECL_NAME (decl
))
2228 /* Nonzero means we must output a tag as well as a typedef. */
2231 /* Handle the case of a C++ structure or union
2232 where the TYPE_NAME is a TYPE_DECL
2233 which gives both a typedef name and a tag. */
2234 /* dbx requires the tag first and the typedef second. */
2235 if ((TREE_CODE (type
) == RECORD_TYPE
2236 || TREE_CODE (type
) == UNION_TYPE
2237 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2238 && TYPE_NAME (type
) == decl
2239 && !(use_gnu_debug_info_extensions
&& have_used_extensions
)
2240 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
2241 /* Distinguish the implicit typedefs of C++
2242 from explicit ones that might be found in C. */
2243 && DECL_ARTIFICIAL (decl
)
2244 /* Do not generate a tag for incomplete records. */
2245 && COMPLETE_TYPE_P (type
)
2246 /* Do not generate a tag for records of variable size,
2247 since this type can not be properly described in the
2248 DBX format, and it confuses some tools such as objdump. */
2249 && host_integerp (TYPE_SIZE (type
), 1))
2251 tree name
= TYPE_NAME (type
);
2252 if (TREE_CODE (name
) == TYPE_DECL
)
2253 name
= DECL_NAME (name
);
2255 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2256 current_sym_value
= 0;
2257 current_sym_addr
= 0;
2258 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2260 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2261 IDENTIFIER_POINTER (name
));
2262 dbxout_type (type
, 1);
2263 dbxout_finish_symbol (NULL_TREE
);
2266 /* Output .stabs (or whatever) and leading double quote. */
2267 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
2269 if (use_gnu_debug_info_extensions
)
2271 /* Output leading class/struct qualifiers. */
2272 dbxout_class_name_qualifiers (decl
);
2275 /* Output typedef name. */
2276 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl
)));
2278 /* Short cut way to output a tag also. */
2279 if ((TREE_CODE (type
) == RECORD_TYPE
2280 || TREE_CODE (type
) == UNION_TYPE
2281 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2282 && TYPE_NAME (type
) == decl
2283 /* Distinguish the implicit typedefs of C++
2284 from explicit ones that might be found in C. */
2285 && DECL_ARTIFICIAL (decl
))
2287 if (use_gnu_debug_info_extensions
&& have_used_extensions
)
2289 putc ('T', asmfile
);
2290 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
2292 #if 0 /* Now we generate the tag for this case up above. */
2298 putc ('t', asmfile
);
2299 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2301 dbxout_type (type
, 1);
2302 dbxout_finish_symbol (decl
);
2306 /* Don't output a tag if this is an incomplete type. This prevents
2307 the sun4 Sun OS 4.x dbx from crashing. */
2309 if (tag_needed
&& TYPE_NAME (type
) != 0
2310 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
2311 || (DECL_NAME (TYPE_NAME (type
)) != 0))
2312 && COMPLETE_TYPE_P (type
)
2313 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
2315 /* For a TYPE_DECL with no name, but the type has a name,
2317 This is what represents `struct foo' with no typedef. */
2318 /* In C++, the name of a type is the corresponding typedef.
2319 In C, it is an IDENTIFIER_NODE. */
2320 tree name
= TYPE_NAME (type
);
2321 if (TREE_CODE (name
) == TYPE_DECL
)
2322 name
= DECL_NAME (name
);
2324 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2325 current_sym_value
= 0;
2326 current_sym_addr
= 0;
2327 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2329 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2330 IDENTIFIER_POINTER (name
));
2331 dbxout_type (type
, 1);
2332 dbxout_finish_symbol (NULL_TREE
);
2336 /* If an enum type has no name, it cannot be referred to,
2337 but we must output it anyway, since the enumeration constants
2338 can be referred to. */
2339 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
2341 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2342 current_sym_value
= 0;
2343 current_sym_addr
= 0;
2344 current_sym_nchars
= 2;
2346 /* Some debuggers fail when given NULL names, so give this a
2347 harmless name of ` '. */
2348 fprintf (asmfile
, "%s\" :T", ASM_STABS_OP
);
2349 dbxout_type (type
, 1);
2350 dbxout_finish_symbol (NULL_TREE
);
2353 /* Prevent duplicate output of a typedef. */
2354 TREE_ASM_WRITTEN (decl
) = 1;
2359 /* Parm decls go in their own separate chains
2360 and are output by dbxout_reg_parms and dbxout_parms. */
2364 /* Named return value, treat like a VAR_DECL. */
2366 if (! DECL_RTL_SET_P (decl
))
2367 DBXOUT_DECR_NESTING_AND_RETURN (0);
2368 /* Don't mention a variable that is external.
2369 Let the file that defines it describe it. */
2370 if (DECL_EXTERNAL (decl
))
2373 /* If the variable is really a constant
2374 and not written in memory, inform the debugger. */
2375 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
2376 && DECL_INITIAL (decl
) != 0
2377 && host_integerp (DECL_INITIAL (decl
), 0)
2378 && ! TREE_ASM_WRITTEN (decl
)
2379 && (DECL_CONTEXT (decl
) == NULL_TREE
2380 || TREE_CODE (DECL_CONTEXT (decl
)) == BLOCK
))
2382 if (TREE_PUBLIC (decl
) == 0)
2384 /* The sun4 assembler does not grok this. */
2385 const char *name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2387 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
2388 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
2390 HOST_WIDE_INT ival
= tree_low_cst (DECL_INITIAL (decl
), 0);
2391 fprintf (asmfile
, "%s\"%s:c=i" HOST_WIDE_INT_PRINT_DEC
2393 ASM_STABS_OP
, name
, ival
, N_LSYM
);
2394 DBXOUT_DECR_NESTING
;
2397 else if (TREE_CODE (TREE_TYPE (decl
)) == REAL_TYPE
)
2399 /* don't know how to do this yet. */
2403 /* else it is something we handle like a normal variable. */
2406 SET_DECL_RTL (decl
, eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
2407 #ifdef LEAF_REG_REMAP
2408 if (current_function_uses_only_leaf_regs
)
2409 leaf_renumber_regs_insn (DECL_RTL (decl
));
2412 result
= dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
2418 DBXOUT_DECR_NESTING
;
2422 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2423 Add SUFFIX to its name, if SUFFIX is not 0.
2424 Describe the variable as residing in HOME
2425 (usually HOME is DECL_RTL (DECL), but not always).
2426 Returns 1 if the stab was really emitted. */
2429 dbxout_symbol_location (tree decl
, tree type
, const char *suffix
, rtx home
)
2434 emit_pending_bincls_if_required ();
2436 /* Don't mention a variable at all
2437 if it was completely optimized into nothingness.
2439 If the decl was from an inline function, then its rtl
2440 is not identically the rtl that was used in this
2441 particular compilation. */
2442 if (GET_CODE (home
) == SUBREG
)
2446 while (GET_CODE (value
) == SUBREG
)
2447 value
= SUBREG_REG (value
);
2448 if (GET_CODE (value
) == REG
)
2450 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
2453 home
= alter_subreg (&home
);
2455 if (GET_CODE (home
) == REG
)
2457 regno
= REGNO (home
);
2458 if (regno
>= FIRST_PSEUDO_REGISTER
)
2462 /* The kind-of-variable letter depends on where
2463 the variable is and on the scope of its name:
2464 G and N_GSYM for static storage and global scope,
2465 S for static storage and file scope,
2466 V for static storage and local scope,
2467 for those two, use N_LCSYM if data is in bss segment,
2468 N_STSYM if in data segment, N_FUN otherwise.
2469 (We used N_FUN originally, then changed to N_STSYM
2470 to please GDB. However, it seems that confused ld.
2471 Now GDB has been fixed to like N_FUN, says Kingdon.)
2472 no letter at all, and N_LSYM, for auto variable,
2473 r and N_RSYM for register variable. */
2475 if (GET_CODE (home
) == MEM
2476 && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
2478 if (TREE_PUBLIC (decl
))
2481 current_sym_code
= N_GSYM
;
2485 current_sym_addr
= XEXP (home
, 0);
2487 letter
= decl_function_context (decl
) ? 'V' : 'S';
2489 /* This should be the same condition as in assemble_variable, but
2490 we don't have access to dont_output_data here. So, instead,
2491 we rely on the fact that error_mark_node initializers always
2492 end up in bss for C++ and never end up in bss for C. */
2493 if (DECL_INITIAL (decl
) == 0
2494 || (!strcmp (lang_hooks
.name
, "GNU C++")
2495 && DECL_INITIAL (decl
) == error_mark_node
))
2496 current_sym_code
= N_LCSYM
;
2497 else if (DECL_IN_TEXT_SECTION (decl
))
2498 /* This is not quite right, but it's the closest
2499 of all the codes that Unix defines. */
2500 current_sym_code
= DBX_STATIC_CONST_VAR_CODE
;
2503 /* Some ports can transform a symbol ref into a label ref,
2504 because the symbol ref is too far away and has to be
2505 dumped into a constant pool. Alternatively, the symbol
2506 in the constant pool might be referenced by a different
2508 if (GET_CODE (current_sym_addr
) == SYMBOL_REF
2509 && CONSTANT_POOL_ADDRESS_P (current_sym_addr
))
2511 rtx tmp
= get_pool_constant (current_sym_addr
);
2513 if (GET_CODE (tmp
) == SYMBOL_REF
2514 || GET_CODE (tmp
) == LABEL_REF
)
2515 current_sym_addr
= tmp
;
2518 /* Ultrix `as' seems to need this. */
2519 #ifdef DBX_STATIC_STAB_DATA_SECTION
2522 current_sym_code
= N_STSYM
;
2526 else if (regno
>= 0)
2529 current_sym_code
= N_RSYM
;
2530 current_sym_value
= DBX_REGISTER_NUMBER (regno
);
2532 else if (GET_CODE (home
) == MEM
2533 && (GET_CODE (XEXP (home
, 0)) == MEM
2534 || (GET_CODE (XEXP (home
, 0)) == REG
2535 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
2536 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
2537 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2538 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
2541 /* If the value is indirect by memory or by a register
2542 that isn't the frame pointer
2543 then it means the object is variable-sized and address through
2544 that register or stack slot. DBX has no way to represent this
2545 so all we can do is output the variable as a pointer.
2546 If it's not a parameter, ignore it.
2547 (VAR_DECLs like this can be made by integrate.c.) */
2549 if (GET_CODE (XEXP (home
, 0)) == REG
)
2552 current_sym_code
= N_RSYM
;
2553 if (REGNO (XEXP (home
, 0)) >= FIRST_PSEUDO_REGISTER
)
2555 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
2559 current_sym_code
= N_LSYM
;
2560 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2561 We want the value of that CONST_INT. */
2563 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2566 /* Effectively do build_pointer_type, but don't cache this type,
2567 since it might be temporary whereas the type it points to
2568 might have been saved for inlining. */
2569 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2570 type
= make_node (POINTER_TYPE
);
2571 TREE_TYPE (type
) = TREE_TYPE (decl
);
2573 else if (GET_CODE (home
) == MEM
2574 && GET_CODE (XEXP (home
, 0)) == REG
)
2576 current_sym_code
= N_LSYM
;
2577 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2579 else if (GET_CODE (home
) == MEM
2580 && GET_CODE (XEXP (home
, 0)) == PLUS
2581 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2583 current_sym_code
= N_LSYM
;
2584 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2585 We want the value of that CONST_INT. */
2586 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2588 else if (GET_CODE (home
) == MEM
2589 && GET_CODE (XEXP (home
, 0)) == CONST
)
2591 /* Handle an obscure case which can arise when optimizing and
2592 when there are few available registers. (This is *always*
2593 the case for i386/i486 targets). The RTL looks like
2594 (MEM (CONST ...)) even though this variable is a local `auto'
2595 or a local `register' variable. In effect, what has happened
2596 is that the reload pass has seen that all assignments and
2597 references for one such a local variable can be replaced by
2598 equivalent assignments and references to some static storage
2599 variable, thereby avoiding the need for a register. In such
2600 cases we're forced to lie to debuggers and tell them that
2601 this variable was itself `static'. */
2602 current_sym_code
= N_LCSYM
;
2604 current_sym_addr
= XEXP (XEXP (home
, 0), 0);
2606 else if (GET_CODE (home
) == CONCAT
)
2610 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2611 for example), then there is no easy way to figure out
2612 what SUBTYPE should be. So, we give up. */
2613 if (TREE_CODE (type
) != COMPLEX_TYPE
)
2616 subtype
= TREE_TYPE (type
);
2618 /* If the variable's storage is in two parts,
2619 output each as a separate stab with a modified name. */
2620 if (WORDS_BIG_ENDIAN
)
2621 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2623 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2625 /* Cast avoids warning in old compilers. */
2626 current_sym_code
= (STAB_CODE_TYPE
) 0;
2627 current_sym_value
= 0;
2628 current_sym_addr
= 0;
2629 dbxout_prepare_symbol (decl
);
2631 if (WORDS_BIG_ENDIAN
)
2632 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2634 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2638 /* Address might be a MEM, when DECL is a variable-sized object.
2639 Or it might be const0_rtx, meaning previous passes
2640 want us to ignore this variable. */
2643 /* Ok, start a symtab entry and output the variable name. */
2646 #ifdef DBX_STATIC_BLOCK_START
2647 DBX_STATIC_BLOCK_START (asmfile
, current_sym_code
);
2650 dbxout_symbol_name (decl
, suffix
, letter
);
2651 dbxout_type (type
, 0);
2652 dbxout_finish_symbol (decl
);
2654 #ifdef DBX_STATIC_BLOCK_END
2655 DBX_STATIC_BLOCK_END (asmfile
, current_sym_code
);
2660 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2661 Then output LETTER to indicate the kind of location the symbol has. */
2664 dbxout_symbol_name (tree decl
, const char *suffix
, int letter
)
2668 if (DECL_CONTEXT (decl
) && TYPE_P (DECL_CONTEXT (decl
)))
2669 /* One slight hitch: if this is a VAR_DECL which is a static
2670 class member, we must put out the mangled name instead of the
2671 DECL_NAME. Note also that static member (variable) names DO NOT begin
2672 with underscores in .stabs directives. */
2673 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
2675 /* ...but if we're function-local, we don't want to include the junk
2676 added by ASM_FORMAT_PRIVATE_NAME. */
2677 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2681 fprintf (asmfile
, "%s\"%s%s:", ASM_STABS_OP
, name
,
2682 (suffix
? suffix
: ""));
2685 putc (letter
, asmfile
);
2689 dbxout_prepare_symbol (tree decl ATTRIBUTE_UNUSED
)
2692 const char *filename
= DECL_SOURCE_FILE (decl
);
2694 dbxout_source_file (asmfile
, filename
);
2699 dbxout_finish_symbol (tree sym
)
2701 #ifdef DBX_FINISH_SYMBOL
2702 DBX_FINISH_SYMBOL (sym
);
2705 if (use_gnu_debug_info_extensions
&& sym
!= 0)
2706 line
= DECL_SOURCE_LINE (sym
);
2708 fprintf (asmfile
, "\",%d,0,%d,", current_sym_code
, line
);
2709 if (current_sym_addr
)
2710 output_addr_const (asmfile
, current_sym_addr
);
2712 fprintf (asmfile
, "%d", current_sym_value
);
2713 putc ('\n', asmfile
);
2717 /* Output definitions of all the decls in a chain. Return nonzero if
2718 anything was output */
2721 dbxout_syms (tree syms
)
2726 result
+= dbxout_symbol (syms
, 1);
2727 syms
= TREE_CHAIN (syms
);
2732 /* The following two functions output definitions of function parameters.
2733 Each parameter gets a definition locating it in the parameter list.
2734 Each parameter that is a register variable gets a second definition
2735 locating it in the register.
2737 Printing or argument lists in gdb uses the definitions that
2738 locate in the parameter list. But reference to the variable in
2739 expressions uses preferentially the definition as a register. */
2741 /* Output definitions, referring to storage in the parmlist,
2742 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2745 dbxout_parms (tree parms
)
2749 emit_pending_bincls_if_required ();
2751 for (; parms
; parms
= TREE_CHAIN (parms
))
2752 if (DECL_NAME (parms
) && TREE_TYPE (parms
) != error_mark_node
)
2754 dbxout_prepare_symbol (parms
);
2756 /* Perform any necessary register eliminations on the parameter's rtl,
2757 so that the debugging output will be accurate. */
2758 DECL_INCOMING_RTL (parms
)
2759 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
2760 SET_DECL_RTL (parms
, eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
2761 #ifdef LEAF_REG_REMAP
2762 if (current_function_uses_only_leaf_regs
)
2764 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
2765 leaf_renumber_regs_insn (DECL_RTL (parms
));
2769 if (PARM_PASSED_IN_MEMORY (parms
))
2771 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
2773 /* ??? Here we assume that the parm address is indexed
2774 off the frame pointer or arg pointer.
2775 If that is not true, we produce meaningless results,
2776 but do not crash. */
2777 if (GET_CODE (addr
) == PLUS
2778 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
2779 current_sym_value
= INTVAL (XEXP (addr
, 1));
2781 current_sym_value
= 0;
2783 current_sym_code
= N_PSYM
;
2784 current_sym_addr
= 0;
2787 if (DECL_NAME (parms
))
2789 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2791 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2792 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2793 DBX_MEMPARM_STABS_LETTER
);
2797 current_sym_nchars
= 8;
2798 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2799 DBX_MEMPARM_STABS_LETTER
);
2802 /* It is quite tempting to use:
2804 dbxout_type (TREE_TYPE (parms), 0);
2806 as the next statement, rather than using DECL_ARG_TYPE(), so
2807 that gcc reports the actual type of the parameter, rather
2808 than the promoted type. This certainly makes GDB's life
2809 easier, at least for some ports. The change is a bad idea
2810 however, since GDB expects to be able access the type without
2811 performing any conversions. So for example, if we were
2812 passing a float to an unprototyped function, gcc will store a
2813 double on the stack, but if we emit a stab saying the type is a
2814 float, then gdb will only read in a single value, and this will
2815 produce an erroneous value. */
2816 dbxout_type (DECL_ARG_TYPE (parms
), 0);
2817 current_sym_value
= DEBUGGER_ARG_OFFSET (current_sym_value
, addr
);
2818 dbxout_finish_symbol (parms
);
2820 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
2823 char regparm_letter
;
2825 /* Parm passed in registers and lives in registers or nowhere. */
2827 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2828 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2829 current_sym_addr
= 0;
2831 /* If parm lives in a register, use that register;
2832 pretend the parm was passed there. It would be more consistent
2833 to describe the register where the parm was passed,
2834 but in practice that register usually holds something else.
2836 If we use DECL_RTL, then we must use the declared type of
2837 the variable, not the type that it arrived in. */
2838 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2840 best_rtl
= DECL_RTL (parms
);
2841 parm_type
= TREE_TYPE (parms
);
2843 /* If the parm lives nowhere, use the register where it was
2844 passed. It is also better to use the declared type here. */
2847 best_rtl
= DECL_INCOMING_RTL (parms
);
2848 parm_type
= TREE_TYPE (parms
);
2850 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
2853 if (DECL_NAME (parms
))
2855 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2856 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2857 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2862 current_sym_nchars
= 8;
2863 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2867 dbxout_type (parm_type
, 0);
2868 dbxout_finish_symbol (parms
);
2870 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2871 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
2872 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
2873 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
2874 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2875 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
2879 /* Parm was passed via invisible reference.
2880 That is, its address was passed in a register.
2881 Output it as if it lived in that register.
2882 The debugger will know from the type
2883 that it was actually passed by invisible reference. */
2885 char regparm_letter
;
2886 /* Parm passed in registers and lives in registers or nowhere. */
2888 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2889 if (use_gnu_debug_info_extensions
)
2890 regparm_letter
= GDB_INV_REF_REGPARM_STABS_LETTER
;
2892 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2894 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2895 If it is an unallocated pseudo-reg, then use the register where
2896 it was passed instead. */
2897 if (REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
2898 current_sym_value
= REGNO (XEXP (DECL_RTL (parms
), 0));
2900 current_sym_value
= REGNO (DECL_INCOMING_RTL (parms
));
2902 current_sym_addr
= 0;
2905 if (DECL_NAME (parms
))
2908 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2910 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2911 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2916 current_sym_nchars
= 8;
2917 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2921 dbxout_type (TREE_TYPE (parms
), 0);
2922 dbxout_finish_symbol (parms
);
2924 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2925 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
2927 /* Parm was passed via invisible reference, with the reference
2928 living on the stack. DECL_RTL looks like
2929 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2930 could look like (MEM (MEM (REG))). */
2931 const char *const decl_name
= (DECL_NAME (parms
)
2932 ? IDENTIFIER_POINTER (DECL_NAME (parms
))
2934 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 0)) == REG
)
2935 current_sym_value
= 0;
2938 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
2939 current_sym_addr
= 0;
2940 current_sym_code
= N_PSYM
;
2943 fprintf (asmfile
, "%s\"%s:v", ASM_STABS_OP
, decl_name
);
2946 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2947 XEXP (XEXP (DECL_RTL (parms
), 0), 0));
2948 dbxout_type (TREE_TYPE (parms
), 0);
2949 dbxout_finish_symbol (parms
);
2951 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2952 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
2953 /* ??? A constant address for a parm can happen
2954 when the reg it lives in is equiv to a constant in memory.
2955 Should make this not happen, after 2.4. */
2956 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
2958 /* Parm was passed in registers but lives on the stack. */
2960 current_sym_code
= N_PSYM
;
2961 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2962 in which case we want the value of that CONST_INT,
2964 in which case we use a value of zero. */
2965 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
)
2966 current_sym_value
= 0;
2969 = INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
2971 current_sym_addr
= 0;
2973 /* Make a big endian correction if the mode of the type of the
2974 parameter is not the same as the mode of the rtl. */
2975 if (BYTES_BIG_ENDIAN
2976 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
2977 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
2979 current_sym_value
+=
2980 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
)))
2981 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
)));
2985 if (DECL_NAME (parms
))
2988 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2990 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2991 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2992 DBX_MEMPARM_STABS_LETTER
);
2996 current_sym_nchars
= 8;
2997 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2998 DBX_MEMPARM_STABS_LETTER
);
3002 = DEBUGGER_ARG_OFFSET (current_sym_value
,
3003 XEXP (DECL_RTL (parms
), 0));
3004 dbxout_type (TREE_TYPE (parms
), 0);
3005 dbxout_finish_symbol (parms
);
3008 DBXOUT_DECR_NESTING
;
3011 /* Output definitions for the places where parms live during the function,
3012 when different from where they were passed, when the parms were passed
3015 It is not useful to do this for parms passed in registers
3016 that live during the function in different registers, because it is
3017 impossible to look in the passed register for the passed value,
3018 so we use the within-the-function register to begin with.
3020 PARMS is a chain of PARM_DECL nodes. */
3023 dbxout_reg_parms (tree parms
)
3027 for (; parms
; parms
= TREE_CHAIN (parms
))
3028 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
3030 dbxout_prepare_symbol (parms
);
3032 /* Report parms that live in registers during the function
3033 but were passed in memory. */
3034 if (GET_CODE (DECL_RTL (parms
)) == REG
3035 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
3036 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
3037 0, DECL_RTL (parms
));
3038 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
3039 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
3040 0, DECL_RTL (parms
));
3041 /* Report parms that live in memory but not where they were passed. */
3042 else if (GET_CODE (DECL_RTL (parms
)) == MEM
3043 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
3044 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
3045 0, DECL_RTL (parms
));
3047 DBXOUT_DECR_NESTING
;
3050 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
3051 output definitions of those names, in raw form */
3054 dbxout_args (tree args
)
3058 putc (',', asmfile
);
3059 dbxout_type (TREE_VALUE (args
), 0);
3061 args
= TREE_CHAIN (args
);
3065 /* Output everything about a symbol block (a BLOCK node
3066 that represents a scope level),
3067 including recursive output of contained blocks.
3069 BLOCK is the BLOCK node.
3070 DEPTH is its depth within containing symbol blocks.
3071 ARGS is usually zero; but for the outermost block of the
3072 body of a function, it is a chain of PARM_DECLs for the function parameters.
3073 We output definitions of all the register parms
3074 as if they were local variables of that block.
3076 If -g1 was used, we count blocks just the same, but output nothing
3077 except for the outermost block.
3079 Actually, BLOCK may be several blocks chained together.
3080 We handle them all in sequence. */
3083 dbxout_block (tree block
, int depth
, tree args
)
3087 #if DBX_BLOCKS_FUNCTION_RELATIVE
3088 const char *begin_label
;
3089 if (current_function_func_begin_label
!= NULL_TREE
)
3090 begin_label
= IDENTIFIER_POINTER (current_function_func_begin_label
);
3092 begin_label
= XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0);
3097 /* Ignore blocks never expanded or otherwise marked as real. */
3098 if (TREE_USED (block
) && TREE_ASM_WRITTEN (block
))
3102 /* In dbx format, the syms of a block come before the N_LBRAC.
3103 If nothing is output, we don't need the N_LBRAC, either. */
3105 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
3106 did_output
= dbxout_syms (BLOCK_VARS (block
));
3108 dbxout_reg_parms (args
);
3110 /* Now output an N_LBRAC symbol to represent the beginning of
3111 the block. Use the block's tree-walk order to generate
3112 the assembler symbols LBBn and LBEn
3113 that final will define around the code in this block. */
3114 if (depth
> 0 && did_output
)
3117 blocknum
= BLOCK_NUMBER (block
);
3118 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
3120 if (BLOCK_HANDLER_BLOCK (block
))
3122 /* A catch block. Must precede N_LBRAC. */
3123 tree decl
= BLOCK_VARS (block
);
3126 fprintf (asmfile
, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP
,
3127 IDENTIFIER_POINTER (DECL_NAME (decl
)), N_CATCH
);
3128 assemble_name (asmfile
, buf
);
3129 fprintf (asmfile
, "\n");
3130 decl
= TREE_CHAIN (decl
);
3134 #ifdef DBX_OUTPUT_LBRAC
3135 DBX_OUTPUT_LBRAC (asmfile
, buf
);
3137 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_LBRAC
);
3138 assemble_name (asmfile
, buf
);
3139 #if DBX_BLOCKS_FUNCTION_RELATIVE
3140 putc ('-', asmfile
);
3141 assemble_name (asmfile
, begin_label
);
3143 fprintf (asmfile
, "\n");
3147 /* Output the subblocks. */
3148 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
3150 /* Refer to the marker for the end of the block. */
3151 if (depth
> 0 && did_output
)
3154 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
3155 #ifdef DBX_OUTPUT_RBRAC
3156 DBX_OUTPUT_RBRAC (asmfile
, buf
);
3158 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_RBRAC
);
3159 assemble_name (asmfile
, buf
);
3160 #if DBX_BLOCKS_FUNCTION_RELATIVE
3161 putc ('-', asmfile
);
3162 assemble_name (asmfile
, begin_label
);
3164 fprintf (asmfile
, "\n");
3168 block
= BLOCK_CHAIN (block
);
3172 /* Output the information about a function and its arguments and result.
3173 Usually this follows the function's code,
3174 but on some systems, it comes before. */
3176 #if defined (DBX_DEBUGGING_INFO)
3178 dbxout_begin_function (tree decl
)
3180 int saved_tree_used1
= TREE_USED (decl
);
3181 TREE_USED (decl
) = 1;
3182 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3184 int saved_tree_used2
= TREE_USED (DECL_RESULT (decl
));
3185 TREE_USED (DECL_RESULT (decl
)) = 1;
3186 dbxout_symbol (decl
, 0);
3187 TREE_USED (DECL_RESULT (decl
)) = saved_tree_used2
;
3190 dbxout_symbol (decl
, 0);
3191 TREE_USED (decl
) = saved_tree_used1
;
3193 dbxout_parms (DECL_ARGUMENTS (decl
));
3194 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3195 dbxout_symbol (DECL_RESULT (decl
), 1);
3197 #endif /* DBX_DEBUGGING_INFO */
3199 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3201 #include "gt-dbxout.h"