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 extern int flag_debug_only_used_symbols
;
98 #undef DBXOUT_DECR_NESTING
99 #define DBXOUT_DECR_NESTING \
100 if (--debug_nesting == 0 && symbol_queue_index > 0) \
101 debug_flush_symbol_queue ()
103 #undef DBXOUT_DECR_NESTING_AND_RETURN
104 #define DBXOUT_DECR_NESTING_AND_RETURN(x) \
105 do {--debug_nesting; return (x);} while (0)
108 #define ASM_STABS_OP "\t.stabs\t"
112 #define ASM_STABN_OP "\t.stabn\t"
115 #ifndef DBX_TYPE_DECL_STABS_CODE
116 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
119 #ifndef DBX_STATIC_CONST_VAR_CODE
120 #define DBX_STATIC_CONST_VAR_CODE N_FUN
123 #ifndef DBX_REGPARM_STABS_CODE
124 #define DBX_REGPARM_STABS_CODE N_RSYM
127 #ifndef DBX_REGPARM_STABS_LETTER
128 #define DBX_REGPARM_STABS_LETTER 'P'
131 /* This is used for parameters passed by invisible reference in a register. */
132 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
133 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
136 #ifndef DBX_MEMPARM_STABS_LETTER
137 #define DBX_MEMPARM_STABS_LETTER 'p'
140 #ifndef FILE_NAME_JOINER
141 #define FILE_NAME_JOINER "/"
144 /* GDB needs to know that the stabs were generated by GCC. We emit an
145 N_OPT stab at the beginning of the source file to indicate this.
146 The string is historical, and different on a very few targets. */
147 #ifndef STABS_GCC_MARKER
148 #define STABS_GCC_MARKER "gcc2_compiled."
151 enum typestatus
{TYPE_UNSEEN
, TYPE_XREF
, TYPE_DEFINED
};
153 /* Structure recording information about a C data type.
154 The status element says whether we have yet output
155 the definition of the type. TYPE_XREF says we have
156 output it as a cross-reference only.
157 The file_number and type_number elements are used if DBX_USE_BINCL
160 struct typeinfo
GTY(())
162 enum typestatus status
;
167 /* Vector recording information about C data types.
168 When we first notice a data type (a tree node),
169 we assign it a number using next_type_number.
170 That is its index in this vector. */
172 static GTY ((length ("typevec_len"))) struct typeinfo
*typevec
;
174 /* Number of elements of space allocated in `typevec'. */
176 static GTY(()) int typevec_len
;
178 /* In dbx output, each type gets a unique number.
179 This is the number for the next type output.
180 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
182 static GTY(()) int next_type_number
;
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
;
195 /* This is the top of the stack. */
197 static GTY(()) struct dbx_file
*current_file
;
199 /* This is the next file number to use. */
201 static GTY(()) int next_file_number
;
203 /* A counter for dbxout_function_end. */
205 static GTY(()) int scope_labelno
;
207 /* A counter for dbxout_source_line. */
209 static GTY(()) int dbxout_source_line_counter
;
211 /* Nonzero if we have actually used any of the GDB extensions
212 to the debugging format. The idea is that we use them for the
213 first time only if there's a strong reason, but once we have done that,
214 we use them whenever convenient. */
216 static GTY(()) int have_used_extensions
= 0;
218 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
219 for the N_SO filename stabs label. */
221 static GTY(()) int source_label_number
= 1;
223 /* Last source file name mentioned in a NOTE insn. */
225 static GTY(()) const char *lastfile
;
227 /* Used by PCH machinery to detect if 'lastfile' should be reset to
229 static GTY(()) int lastfile_is_base
;
231 /* Typical USG systems don't have stab.h, and they also have
232 no use for DBX-format debugging info. */
234 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
236 /* The original input file name. */
237 static const char *base_input_file
;
239 /* Current working directory. */
241 static const char *cwd
;
243 #ifdef DEBUG_SYMS_TEXT
244 #define FORCE_TEXT function_section (current_function_decl);
251 #define STAB_CODE_TYPE enum __stab_debug_code
253 /* 1 if PARM is passed to this function in memory. */
255 #define PARM_PASSED_IN_MEMORY(PARM) \
256 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
258 /* A C expression for the integer offset value of an automatic variable
259 (N_LSYM) having address X (an RTX). */
260 #ifndef DEBUGGER_AUTO_OFFSET
261 #define DEBUGGER_AUTO_OFFSET(X) \
262 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
265 /* A C expression for the integer offset value of an argument (N_PSYM)
266 having address X (an RTX). The nominal offset is OFFSET. */
267 #ifndef DEBUGGER_ARG_OFFSET
268 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
271 /* Stream for writing to assembler file. */
273 static FILE *asmfile
;
275 /* These variables are for dbxout_symbol to communicate to
276 dbxout_finish_symbol.
277 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
278 current_sym_value and current_sym_addr are two ways to address the
279 value to store in the symtab entry.
280 current_sym_addr if nonzero represents the value as an rtx.
281 If that is zero, current_sym_value is used. This is used
282 when the value is an offset (such as for auto variables,
283 register variables and parms). */
285 static STAB_CODE_TYPE current_sym_code
;
286 static int current_sym_value
;
287 static rtx current_sym_addr
;
289 /* Number of chars of symbol-description generated so far for the
290 current symbol. Used by CHARS and CONTIN. */
292 static int current_sym_nchars
;
294 /* Report having output N chars of the current symbol-description. */
296 #define CHARS(N) (current_sym_nchars += (N))
298 /* Break the current symbol-description, generating a continuation,
299 if it has become long. */
301 #ifndef DBX_CONTIN_LENGTH
302 #define DBX_CONTIN_LENGTH 80
305 #if DBX_CONTIN_LENGTH > 0
307 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
309 #define CONTIN do { } while (0)
312 static void dbxout_init
PARAMS ((const char *));
313 static void dbxout_finish
PARAMS ((const char *));
314 static void dbxout_start_source_file
PARAMS ((unsigned, const char *));
315 static void dbxout_end_source_file
PARAMS ((unsigned));
316 static void dbxout_typedefs
PARAMS ((tree
));
317 static void dbxout_fptype_value
PARAMS ((tree
));
318 static void dbxout_type_index
PARAMS ((tree
));
319 #if DBX_CONTIN_LENGTH > 0
320 static void dbxout_continue
PARAMS ((void));
322 static void dbxout_args
PARAMS ((tree
));
323 static void dbxout_type_fields
PARAMS ((tree
));
324 static void dbxout_type_method_1
PARAMS ((tree
, const char *));
325 static void dbxout_type_methods
PARAMS ((tree
));
326 static void dbxout_range_type
PARAMS ((tree
));
327 static void dbxout_type
PARAMS ((tree
, int));
328 static bool print_int_cst_bounds_in_octal_p
PARAMS ((tree
));
329 static void print_int_cst_octal
PARAMS ((tree
));
330 static void print_octal
PARAMS ((unsigned HOST_WIDE_INT
, int));
331 static void print_wide_int
PARAMS ((HOST_WIDE_INT
));
332 static void dbxout_type_name
PARAMS ((tree
));
333 static void dbxout_class_name_qualifiers
PARAMS ((tree
));
334 static int dbxout_symbol_location
PARAMS ((tree
, tree
, const char *, rtx
));
335 static void dbxout_symbol_name
PARAMS ((tree
, const char *, int));
336 static void dbxout_prepare_symbol
PARAMS ((tree
));
337 static void dbxout_finish_symbol
PARAMS ((tree
));
338 static void dbxout_block
PARAMS ((tree
, int, tree
));
339 static void dbxout_global_decl
PARAMS ((tree
));
340 static void dbxout_handle_pch
PARAMS ((unsigned));
342 /* The debug hooks structure. */
343 #if defined (DBX_DEBUGGING_INFO)
345 static void dbxout_source_line
PARAMS ((unsigned int, const char *));
346 static void dbxout_source_file
PARAMS ((FILE *, const char *));
347 static void dbxout_function_end
PARAMS ((void));
348 static void dbxout_begin_function
PARAMS ((tree
));
349 static void dbxout_begin_block
PARAMS ((unsigned, unsigned));
350 static void dbxout_end_block
PARAMS ((unsigned, unsigned));
351 static void dbxout_function_decl
PARAMS ((tree
));
353 const struct gcc_debug_hooks dbx_debug_hooks
=
357 debug_nothing_int_charstar
,
358 debug_nothing_int_charstar
,
359 dbxout_start_source_file
,
360 dbxout_end_source_file
,
363 debug_true_tree
, /* ignore_block */
364 dbxout_source_line
, /* source_line */
365 dbxout_source_line
, /* begin_prologue: just output line info */
366 debug_nothing_int_charstar
, /* end_prologue */
367 debug_nothing_int_charstar
, /* end_epilogue */
368 #ifdef DBX_FUNCTION_FIRST
369 dbxout_begin_function
,
371 debug_nothing_tree
, /* begin_function */
373 debug_nothing_int
, /* end_function */
374 dbxout_function_decl
,
375 dbxout_global_decl
, /* global_decl */
376 debug_nothing_tree
, /* deferred_inline_function */
377 debug_nothing_tree
, /* outlining_inline_function */
378 debug_nothing_rtx
, /* label */
379 dbxout_handle_pch
/* handle_pch */
381 #endif /* DBX_DEBUGGING_INFO */
383 #if defined (XCOFF_DEBUGGING_INFO)
384 const struct gcc_debug_hooks xcoff_debug_hooks
=
388 debug_nothing_int_charstar
,
389 debug_nothing_int_charstar
,
390 dbxout_start_source_file
,
391 dbxout_end_source_file
,
392 xcoffout_begin_block
,
394 debug_true_tree
, /* ignore_block */
395 xcoffout_source_line
,
396 xcoffout_begin_prologue
, /* begin_prologue */
397 debug_nothing_int_charstar
, /* end_prologue */
398 xcoffout_end_epilogue
,
399 debug_nothing_tree
, /* begin_function */
400 xcoffout_end_function
,
401 debug_nothing_tree
, /* function_decl */
402 dbxout_global_decl
, /* global_decl */
403 debug_nothing_tree
, /* deferred_inline_function */
404 debug_nothing_tree
, /* outlining_inline_function */
405 debug_nothing_rtx
, /* label */
406 dbxout_handle_pch
/* handle_pch */
408 #endif /* XCOFF_DEBUGGING_INFO */
410 #if defined (DBX_DEBUGGING_INFO)
412 dbxout_function_end ()
414 char lscope_label_name
[100];
415 /* Convert Ltext into the appropriate format for local labels in case
416 the system doesn't insert underscores in front of user generated
418 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name
, "Lscope", scope_labelno
);
419 (*targetm
.asm_out
.internal_label
) (asmfile
, "Lscope", scope_labelno
);
422 /* By convention, GCC will mark the end of a function with an N_FUN
423 symbol and an empty string. */
424 #ifdef DBX_OUTPUT_NFUN
425 DBX_OUTPUT_NFUN (asmfile
, lscope_label_name
, current_function_decl
);
427 fprintf (asmfile
, "%s\"\",%d,0,0,", ASM_STABS_OP
, N_FUN
);
428 assemble_name (asmfile
, lscope_label_name
);
430 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
431 fprintf (asmfile
, "\n");
434 #endif /* DBX_DEBUGGING_INFO */
436 /* At the beginning of compilation, start writing the symbol table.
437 Initialize `typevec' and output the standard data types of C. */
440 dbxout_init (input_file_name
)
441 const char *input_file_name
;
443 char ltext_label_name
[100];
444 tree syms
= (*lang_hooks
.decls
.getdecls
) ();
446 asmfile
= asm_out_file
;
449 typevec
= (struct typeinfo
*) ggc_calloc (typevec_len
, sizeof typevec
[0]);
451 /* Convert Ltext into the appropriate format for local labels in case
452 the system doesn't insert underscores in front of user generated
454 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
456 /* Put the current working directory in an N_SO symbol. */
457 if (use_gnu_debug_info_extensions
)
459 if (!cwd
&& (cwd
= getpwd ()) && (!*cwd
|| cwd
[strlen (cwd
) - 1] != '/'))
460 cwd
= concat (cwd
, FILE_NAME_JOINER
, NULL
);
463 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
464 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile
, cwd
);
465 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
466 fprintf (asmfile
, "%s", ASM_STABS_OP
);
467 output_quoted_string (asmfile
, cwd
);
468 fprintf (asmfile
, ",%d,0,0,", N_SO
);
469 assemble_name (asmfile
, ltext_label_name
);
470 fputc ('\n', asmfile
);
471 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
475 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
476 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile
, input_file_name
);
477 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
478 /* We include outputting `Ltext:' here,
479 because that gives you a way to override it. */
480 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
481 fprintf (asmfile
, "%s", ASM_STABS_OP
);
482 output_quoted_string (asmfile
, input_file_name
);
483 fprintf (asmfile
, ",%d,0,0,", N_SO
);
484 assemble_name (asmfile
, ltext_label_name
);
485 fputc ('\n', asmfile
);
487 (*targetm
.asm_out
.internal_label
) (asmfile
, "Ltext", 0);
488 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
490 #ifdef DBX_OUTPUT_GCC_MARKER
491 DBX_OUTPUT_GCC_MARKER (asmfile
);
493 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
494 fprintf (asmfile
, "%s\"%s\",%d,0,0,0\n",
495 ASM_STABS_OP
, STABS_GCC_MARKER
, N_OPT
);
498 base_input_file
= lastfile
= input_file_name
;
500 next_type_number
= 1;
503 current_file
= (struct dbx_file
*) ggc_alloc (sizeof *current_file
);
504 current_file
->next
= NULL
;
505 current_file
->file_number
= 0;
506 current_file
->next_type_number
= 1;
507 next_file_number
= 1;
510 /* Make sure that types `int' and `char' have numbers 1 and 2.
511 Definitions of other integer types will refer to those numbers.
512 (Actually it should no longer matter what their numbers are.
513 Also, if any types with tags have been defined, dbxout_symbol
514 will output them first, so the numbers won't be 1 and 2. That
515 happens in C++. So it's a good thing it should no longer matter). */
517 #ifdef DBX_OUTPUT_STANDARD_TYPES
518 DBX_OUTPUT_STANDARD_TYPES (syms
);
521 /* Get all permanent types that have typedef names,
522 and output them all, except for those already output. */
524 dbxout_typedefs (syms
);
527 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
528 in the reverse order from that which is found in SYMS. */
531 dbxout_typedefs (syms
)
536 dbxout_typedefs (TREE_CHAIN (syms
));
537 if (TREE_CODE (syms
) == TYPE_DECL
)
539 tree type
= TREE_TYPE (syms
);
541 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
542 && COMPLETE_TYPE_P (type
)
543 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
544 dbxout_symbol (TYPE_NAME (type
), 0);
549 /* Change to reading from a new source file. Generate a N_BINCL stab. */
552 dbxout_start_source_file (line
, filename
)
553 unsigned int line ATTRIBUTE_UNUSED
;
554 const char *filename ATTRIBUTE_UNUSED
;
557 struct dbx_file
*n
= (struct dbx_file
*) ggc_alloc (sizeof *n
);
559 n
->next
= current_file
;
560 n
->file_number
= next_file_number
++;
561 n
->next_type_number
= 1;
563 fprintf (asmfile
, "%s", ASM_STABS_OP
);
564 output_quoted_string (asmfile
, filename
);
565 fprintf (asmfile
, ",%d,0,0,0\n", N_BINCL
);
569 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
572 dbxout_end_source_file (line
)
573 unsigned int line ATTRIBUTE_UNUSED
;
576 fprintf (asmfile
, "%s%d,0,0,0\n", ASM_STABN_OP
, N_EINCL
);
577 current_file
= current_file
->next
;
581 /* Handle a few odd cases that occur when trying to make PCH files work. */
584 dbxout_handle_pch (unsigned at_end
)
588 /* When using the PCH, this file will be included, so we need to output
590 dbxout_start_source_file (0, lastfile
);
592 /* The base file when using the PCH won't be the same as
593 the base file when it's being generated. */
598 /* ... and an EINCL. */
599 dbxout_end_source_file (0);
601 /* Deal with cases where 'lastfile' was never actually changed. */
602 lastfile_is_base
= lastfile
== NULL
;
606 #if defined (DBX_DEBUGGING_INFO)
607 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
610 dbxout_source_file (file
, filename
)
612 const char *filename
;
614 if (lastfile
== 0 && lastfile_is_base
)
616 lastfile
= base_input_file
;
617 lastfile_is_base
= 0;
620 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
622 char ltext_label_name
[100];
624 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext",
625 source_label_number
);
626 fprintf (file
, "%s", ASM_STABS_OP
);
627 output_quoted_string (file
, filename
);
628 fprintf (asmfile
, ",%d,0,0,", N_SOL
);
629 assemble_name (asmfile
, ltext_label_name
);
630 fputc ('\n', asmfile
);
631 if (current_function_decl
!= NULL_TREE
632 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
633 ; /* Don't change section amid function. */
636 (*targetm
.asm_out
.internal_label
) (file
, "Ltext", source_label_number
);
637 source_label_number
++;
642 /* Output a line number symbol entry for source file FILENAME and line
646 dbxout_source_line (lineno
, filename
)
648 const char *filename
;
650 dbxout_source_file (asmfile
, filename
);
652 #ifdef ASM_OUTPUT_SOURCE_LINE
653 dbxout_source_line_counter
+= 1;
654 ASM_OUTPUT_SOURCE_LINE (asmfile
, lineno
, dbxout_source_line_counter
);
656 fprintf (asmfile
, "%s%d,0,%d\n", ASM_STABD_OP
, N_SLINE
, lineno
);
660 /* Describe the beginning of an internal block within a function. */
663 dbxout_begin_block (line
, n
)
664 unsigned int line ATTRIBUTE_UNUSED
;
667 (*targetm
.asm_out
.internal_label
) (asmfile
, "LBB", n
);
670 /* Describe the end line-number of an internal block within a function. */
673 dbxout_end_block (line
, n
)
674 unsigned int line ATTRIBUTE_UNUSED
;
677 (*targetm
.asm_out
.internal_label
) (asmfile
, "LBE", n
);
680 /* Output dbx data for a function definition.
681 This includes a definition of the function name itself (a symbol),
682 definitions of the parameters (locating them in the parameter list)
683 and then output the block that makes up the function's body
684 (including all the auto variables of the function). */
687 dbxout_function_decl (decl
)
690 #ifndef DBX_FUNCTION_FIRST
691 dbxout_begin_function (decl
);
693 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
694 #ifdef DBX_OUTPUT_FUNCTION_END
695 DBX_OUTPUT_FUNCTION_END (asmfile
, decl
);
697 if (use_gnu_debug_info_extensions
698 #if defined(NO_DBX_FUNCTION_END)
699 && ! NO_DBX_FUNCTION_END
701 && targetm
.have_named_sections
)
702 dbxout_function_end ();
705 #endif /* DBX_DEBUGGING_INFO */
707 /* Debug information for a global DECL. Called from toplev.c after
708 compilation proper has finished. */
710 dbxout_global_decl (decl
)
713 if (TREE_CODE (decl
) == VAR_DECL
714 && ! DECL_EXTERNAL (decl
)
715 && DECL_RTL_SET_P (decl
)) /* Not necessary? */
717 int saved_tree_used
= TREE_USED (decl
);
718 TREE_USED (decl
) = 1;
719 dbxout_symbol (decl
, 0);
720 TREE_USED (decl
) = saved_tree_used
;
724 /* At the end of compilation, finish writing the symbol table.
725 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
729 dbxout_finish (filename
)
730 const char *filename ATTRIBUTE_UNUSED
;
732 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
733 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile
, filename
);
734 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
739 /* Output floating point type values used by the 'R' stab letter.
740 These numbers come from include/aout/stab_gnu.h in binutils/gdb.
742 There are only 3 real/complex types defined, and we need 7/6.
743 We use NF_SINGLE as a generic float type, and NF_COMPLEX as a generic
744 complex type. Since we have the type size anyways, we don't really need
745 to distinguish between different FP types, we only need to distinguish
746 between float and complex. This works fine with gdb.
748 We only use this for complex types, to avoid breaking backwards
749 compatibility for real types. complex types aren't in ISO C90, so it is
750 OK if old debuggers don't understand the debug info we emit for them. */
752 /* ??? These are supposed to be IEEE types, but we don't check for that.
753 We could perhaps add additional numbers for non-IEEE types if we need
757 dbxout_fptype_value (type
)
761 enum machine_mode mode
= TYPE_MODE (type
);
763 if (TREE_CODE (type
) == REAL_TYPE
)
767 else if (mode
== DFmode
)
769 else if (mode
== TFmode
|| mode
== XFmode
)
772 /* Use NF_SINGLE as a generic real type for other sizes. */
775 else if (TREE_CODE (type
) == COMPLEX_TYPE
)
779 else if (mode
== DCmode
)
781 else if (mode
== TCmode
|| mode
== XCmode
)
784 /* Use NF_COMPLEX as a generic complex type for other sizes. */
790 putc (value
, asmfile
);
794 /* Output the index of a type. */
797 dbxout_type_index (type
)
800 #ifndef DBX_USE_BINCL
801 fprintf (asmfile
, "%d", TYPE_SYMTAB_ADDRESS (type
));
804 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
805 fprintf (asmfile
, "(%d,%d)", t
->file_number
, t
->type_number
);
810 #if DBX_CONTIN_LENGTH > 0
811 /* Continue a symbol-description that gets too big.
812 End one symbol table entry with a double-backslash
813 and start a new one, eventually producing something like
814 .stabs "start......\\",code,0,value
815 .stabs "...rest",code,0,value */
820 #ifdef DBX_CONTIN_CHAR
821 fprintf (asmfile
, "%c", DBX_CONTIN_CHAR
);
823 fprintf (asmfile
, "\\\\");
825 dbxout_finish_symbol (NULL_TREE
);
826 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
827 current_sym_nchars
= 0;
829 #endif /* DBX_CONTIN_LENGTH > 0 */
831 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
832 This must be a separate function because anonymous unions require
836 dbxout_type_fields (type
)
841 /* Output the name, type, position (in bits), size (in bits) of each
842 field that we can support. */
843 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
845 /* Omit here local type decls until we know how to support them. */
846 if (TREE_CODE (tem
) == TYPE_DECL
847 /* Omit fields whose position or size are variable or too large to
849 || (TREE_CODE (tem
) == FIELD_DECL
850 && (! host_integerp (bit_position (tem
), 0)
852 || ! host_integerp (DECL_SIZE (tem
), 1)))
853 /* Omit here the nameless fields that are used to skip bits. */
854 || DECL_IGNORED_P (tem
))
857 else if (TREE_CODE (tem
) != CONST_DECL
)
859 /* Continue the line if necessary,
860 but not before the first field. */
861 if (tem
!= TYPE_FIELDS (type
))
866 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem
)));
867 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem
)));
871 fprintf (asmfile
, ":");
875 if (use_gnu_debug_info_extensions
876 && (TREE_PRIVATE (tem
) || TREE_PROTECTED (tem
)
877 || TREE_CODE (tem
) != FIELD_DECL
))
879 have_used_extensions
= 1;
881 putc ((TREE_PRIVATE (tem
) ? '0'
882 : TREE_PROTECTED (tem
) ? '1' : '2'),
887 dbxout_type ((TREE_CODE (tem
) == FIELD_DECL
888 && DECL_BIT_FIELD_TYPE (tem
))
889 ? DECL_BIT_FIELD_TYPE (tem
) : TREE_TYPE (tem
), 0);
891 if (TREE_CODE (tem
) == VAR_DECL
)
893 if (TREE_STATIC (tem
) && use_gnu_debug_info_extensions
)
895 tree name
= DECL_ASSEMBLER_NAME (tem
);
897 have_used_extensions
= 1;
898 fprintf (asmfile
, ":%s;", IDENTIFIER_POINTER (name
));
899 CHARS (IDENTIFIER_LENGTH (name
) + 2);
903 /* If TEM is non-static, GDB won't understand it. */
904 fprintf (asmfile
, ",0,0;");
911 print_wide_int (int_bit_position (tem
));
913 print_wide_int (tree_low_cst (DECL_SIZE (tem
), 1));
921 /* Subroutine of `dbxout_type_methods'. Output debug info about the
922 method described DECL. DEBUG_NAME is an encoding of the method's
923 type signature. ??? We may be able to do without DEBUG_NAME altogether
927 dbxout_type_method_1 (decl
, debug_name
)
929 const char *debug_name
;
933 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
935 else /* it's a METHOD_TYPE. */
937 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
938 /* A for normal functions.
939 B for `const' member functions.
940 C for `volatile' member functions.
941 D for `const volatile' member functions. */
942 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
944 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
947 if (DECL_VINDEX (decl
))
953 fprintf (asmfile
, ":%s;%c%c%c", debug_name
,
954 TREE_PRIVATE (decl
) ? '0'
955 : TREE_PROTECTED (decl
) ? '1' : '2', c1
, c2
);
956 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
)) + 6
957 - (debug_name
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
))));
959 if (DECL_VINDEX (decl
) && host_integerp (DECL_VINDEX (decl
), 0))
961 print_wide_int (tree_low_cst (DECL_VINDEX (decl
), 0));
964 dbxout_type (DECL_CONTEXT (decl
), 0);
965 fprintf (asmfile
, ";");
970 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
974 dbxout_type_methods (type
)
977 /* C++: put out the method names and their parameter lists */
978 tree methods
= TYPE_METHODS (type
);
982 char formatted_type_identifier_length
[16];
983 int type_identifier_length
;
985 if (methods
== NULL_TREE
)
988 type_encoding
= DECL_NAME (TYPE_NAME (type
));
991 /* C++: Template classes break some assumptions made by this code about
992 the class names, constructor names, and encodings for assembler
993 label names. For now, disable output of dbx info for them. */
995 const char *ptr
= IDENTIFIER_POINTER (type_encoding
);
996 /* This should use index. (mrs) */
997 while (*ptr
&& *ptr
!= '<') ptr
++;
1008 type_identifier_length
= IDENTIFIER_LENGTH (type_encoding
);
1010 sprintf (formatted_type_identifier_length
, "%d", type_identifier_length
);
1012 if (TREE_CODE (methods
) != TREE_VEC
)
1014 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
1015 fndecl
= TREE_VEC_ELT (methods
, 0);
1017 fndecl
= TREE_VEC_ELT (methods
, 1);
1021 int need_prefix
= 1;
1023 /* Group together all the methods for the same operation.
1024 These differ in the types of the arguments. */
1025 for (last
= NULL_TREE
;
1026 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
1027 fndecl
= TREE_CHAIN (fndecl
))
1028 /* Output the name of the field (after overloading), as
1029 well as the name of the field before overloading, along
1030 with its parameter list */
1032 /* This is the "mangled" name of the method.
1033 It encodes the argument types. */
1034 const char *debug_name
;
1036 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1037 include TEMPLATE_DECLs.) The debugger doesn't know what
1038 to do with such entities anyhow. */
1039 if (TREE_CODE (fndecl
) != FUNCTION_DECL
)
1042 debug_name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
));
1048 /* Also ignore abstract methods; those are only interesting to
1049 the DWARF backends. */
1050 if (DECL_IGNORED_P (fndecl
) || DECL_ABSTRACT (fndecl
))
1053 /* Redundantly output the plain name, since that's what gdb
1057 tree name
= DECL_NAME (fndecl
);
1058 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
1059 CHARS (IDENTIFIER_LENGTH (name
) + 2);
1063 dbxout_type (TREE_TYPE (fndecl
), 0);
1065 dbxout_type_method_1 (fndecl
, debug_name
);
1069 putc (';', asmfile
);
1075 /* Emit a "range" type specification, which has the form:
1076 "r<index type>;<lower bound>;<upper bound>;".
1077 TYPE is an INTEGER_TYPE. */
1080 dbxout_range_type (type
)
1083 fprintf (asmfile
, "r");
1084 if (TREE_TYPE (type
))
1085 dbxout_type (TREE_TYPE (type
), 0);
1086 else if (TREE_CODE (type
) != INTEGER_TYPE
)
1087 dbxout_type (type
, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1090 /* Traditionally, we made sure 'int' was type 1, and builtin types
1091 were defined to be sub-ranges of int. Unfortunately, this
1092 does not allow us to distinguish true sub-ranges from integer
1093 types. So, instead we define integer (non-sub-range) types as
1094 sub-ranges of themselves. This matters for Chill. If this isn't
1095 a subrange type, then we want to define it in terms of itself.
1096 However, in C, this may be an anonymous integer type, and we don't
1097 want to emit debug info referring to it. Just calling
1098 dbxout_type_index won't work anyways, because the type hasn't been
1099 defined yet. We make this work for both cases by checked to see
1100 whether this is a defined type, referring to it if it is, and using
1102 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
1103 dbxout_type_index (type
);
1105 dbxout_type_index (integer_type_node
);
1108 if (TYPE_MIN_VALUE (type
) != 0
1109 && host_integerp (TYPE_MIN_VALUE (type
), 0))
1111 putc (';', asmfile
);
1113 if (print_int_cst_bounds_in_octal_p (type
))
1114 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1116 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type
), 0));
1120 fprintf (asmfile
, ";0");
1124 if (TYPE_MAX_VALUE (type
) != 0
1125 && host_integerp (TYPE_MAX_VALUE (type
), 0))
1127 putc (';', asmfile
);
1129 if (print_int_cst_bounds_in_octal_p (type
))
1130 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1132 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type
), 0));
1133 putc (';', asmfile
);
1138 fprintf (asmfile
, ";-1;");
1144 /* Output a reference to a type. If the type has not yet been
1145 described in the dbx output, output its definition now.
1146 For a type already defined, just refer to its definition
1147 using the type number.
1149 If FULL is nonzero, and the type has been described only with
1150 a forward-reference, output the definition now.
1151 If FULL is zero in this case, just refer to the forward-reference
1152 using the number previously allocated. */
1155 dbxout_type (type
, full
)
1161 static int anonymous_type_number
= 0;
1163 if (TREE_CODE (type
) == VECTOR_TYPE
)
1164 /* The frontend feeds us a representation for the vector as a struct
1165 containing an array. Pull out the array type. */
1166 type
= TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type
)));
1168 /* If there was an input error and we don't really have a type,
1169 avoid crashing and write something that is at least valid
1170 by assuming `int'. */
1171 if (type
== error_mark_node
)
1172 type
= integer_type_node
;
1175 if (TYPE_NAME (type
)
1176 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1177 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
1181 /* Try to find the "main variant" with the same name. */
1182 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1183 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1184 main_variant
= TREE_TYPE (TYPE_NAME (type
));
1186 main_variant
= TYPE_MAIN_VARIANT (type
);
1188 /* If we are not using extensions, stabs does not distinguish const and
1189 volatile, so there is no need to make them separate types. */
1190 if (!use_gnu_debug_info_extensions
)
1191 type
= main_variant
;
1193 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
1195 /* Type has no dbx number assigned. Assign next available number. */
1196 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
1198 /* Make sure type vector is long enough to record about this type. */
1200 if (next_type_number
== typevec_len
)
1203 = (struct typeinfo
*) ggc_realloc (typevec
,
1205 * sizeof typevec
[0]));
1206 memset ((char *) (typevec
+ typevec_len
), 0,
1207 typevec_len
* sizeof typevec
[0]);
1211 #ifdef DBX_USE_BINCL
1212 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
1213 = current_file
->file_number
;
1214 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
1215 = current_file
->next_type_number
++;
1219 if (flag_debug_only_used_symbols
)
1221 if ((TREE_CODE (type
) == RECORD_TYPE
1222 || TREE_CODE (type
) == UNION_TYPE
1223 || TREE_CODE (type
) == QUAL_UNION_TYPE
1224 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1225 && TYPE_STUB_DECL (type
)
1226 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (type
))) == 'd'
1227 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type
)))
1228 debug_queue_symbol (TYPE_STUB_DECL (type
));
1229 else if (TYPE_NAME (type
)
1230 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1231 debug_queue_symbol (TYPE_NAME (type
));
1234 /* Output the number of this type, to refer to it. */
1235 dbxout_type_index (type
);
1237 #ifdef DBX_TYPE_DEFINED
1238 if (DBX_TYPE_DEFINED (type
))
1242 /* If this type's definition has been output or is now being output,
1245 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
1250 /* If we have already had a cross reference,
1251 and either that's all we want or that's the best we could do,
1252 don't repeat the cross reference.
1253 Sun dbx crashes if we do. */
1254 if (! full
|| !COMPLETE_TYPE_P (type
)
1255 /* No way in DBX fmt to describe a variable size. */
1256 || ! host_integerp (TYPE_SIZE (type
), 1))
1264 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1265 leave the type-number completely undefined rather than output
1266 a cross-reference. If we have already used GNU debug info extensions,
1267 then it is OK to output a cross reference. This is necessary to get
1268 proper C++ debug output. */
1269 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1270 || TREE_CODE (type
) == QUAL_UNION_TYPE
1271 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1272 && ! use_gnu_debug_info_extensions
)
1273 /* We must use the same test here as we use twice below when deciding
1274 whether to emit a cross-reference. */
1275 if ((TYPE_NAME (type
) != 0
1276 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1277 && DECL_IGNORED_P (TYPE_NAME (type
)))
1279 || !COMPLETE_TYPE_P (type
)
1280 /* No way in DBX fmt to describe a variable size. */
1281 || ! host_integerp (TYPE_SIZE (type
), 1))
1283 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1288 /* Output a definition now. */
1290 fprintf (asmfile
, "=");
1293 /* Mark it as defined, so that if it is self-referent
1294 we will not get into an infinite recursion of definitions. */
1296 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1298 /* If this type is a variant of some other, hand off. Types with
1299 different names are usefully distinguished. We only distinguish
1300 cv-qualified types if we're using extensions. */
1301 if (TYPE_READONLY (type
) > TYPE_READONLY (main_variant
))
1303 putc ('k', asmfile
);
1305 dbxout_type (build_type_variant (type
, 0, TYPE_VOLATILE (type
)), 0);
1308 else if (TYPE_VOLATILE (type
) > TYPE_VOLATILE (main_variant
))
1310 putc ('B', asmfile
);
1312 dbxout_type (build_type_variant (type
, TYPE_READONLY (type
), 0), 0);
1315 else if (main_variant
!= TYPE_MAIN_VARIANT (type
))
1317 if (flag_debug_only_used_symbols
)
1319 tree orig_type
= DECL_ORIGINAL_TYPE (TYPE_NAME (type
));
1321 if ((TREE_CODE (orig_type
) == RECORD_TYPE
1322 || TREE_CODE (orig_type
) == UNION_TYPE
1323 || TREE_CODE (orig_type
) == QUAL_UNION_TYPE
1324 || TREE_CODE (orig_type
) == ENUMERAL_TYPE
)
1325 && TYPE_STUB_DECL (orig_type
)
1326 && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type
)))
1327 debug_queue_symbol (TYPE_STUB_DECL (orig_type
));
1329 /* 'type' is a typedef; output the type it refers to. */
1330 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0);
1333 /* else continue. */
1335 switch (TREE_CODE (type
))
1339 /* For a void type, just define it as itself; ie, "5=5".
1340 This makes us consider it defined
1341 without saying what it is. The debugger will make it
1342 a void type when the reference is seen, and nothing will
1343 ever override that default. */
1344 dbxout_type_index (type
);
1348 if (type
== char_type_node
&& ! TREE_UNSIGNED (type
))
1350 /* Output the type `char' as a subrange of itself!
1351 I don't understand this definition, just copied it
1352 from the output of pcc.
1353 This used to use `r2' explicitly and we used to
1354 take care to make sure that `char' was type number 2. */
1355 fprintf (asmfile
, "r");
1357 dbxout_type_index (type
);
1358 fprintf (asmfile
, ";0;127;");
1362 /* If this is a subtype of another integer type, always prefer to
1363 write it as a subtype. */
1364 else if (TREE_TYPE (type
) != 0
1365 && TREE_CODE (TREE_TYPE (type
)) == INTEGER_TYPE
)
1367 /* If the size is non-standard, say what it is if we can use
1370 if (use_gnu_debug_info_extensions
1371 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1373 have_used_extensions
= 1;
1374 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1378 dbxout_range_type (type
);
1383 /* If the size is non-standard, say what it is if we can use
1386 if (use_gnu_debug_info_extensions
1387 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1389 have_used_extensions
= 1;
1390 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1394 if (print_int_cst_bounds_in_octal_p (type
))
1396 fprintf (asmfile
, "r");
1399 /* If this type derives from another type, output type index of
1400 parent type. This is particularly important when parent type
1401 is an enumerated type, because not generating the parent type
1402 index would transform the definition of this enumerated type
1403 into a plain unsigned type. */
1404 if (TREE_TYPE (type
) != 0)
1405 dbxout_type_index (TREE_TYPE (type
));
1407 dbxout_type_index (type
);
1409 fprintf (asmfile
, ";");
1411 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1412 fprintf (asmfile
, ";");
1414 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1415 fprintf (asmfile
, ";");
1420 /* Output other integer types as subranges of `int'. */
1421 dbxout_range_type (type
);
1427 /* This used to say `r1' and we used to take care
1428 to make sure that `int' was type number 1. */
1429 fprintf (asmfile
, "r");
1431 dbxout_type_index (integer_type_node
);
1432 putc (';', asmfile
);
1434 print_wide_int (int_size_in_bytes (type
));
1435 fputs (";0;", asmfile
);
1440 if (use_gnu_debug_info_extensions
)
1442 have_used_extensions
= 1;
1443 fputs ("@s", asmfile
);
1445 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1446 fputs (";-20;", asmfile
);
1451 /* Output the type `char' as a subrange of itself.
1452 That is what pcc seems to do. */
1453 fprintf (asmfile
, "r");
1455 dbxout_type_index (char_type_node
);
1456 fprintf (asmfile
, ";0;%d;", TREE_UNSIGNED (type
) ? 255 : 127);
1462 if (use_gnu_debug_info_extensions
)
1464 have_used_extensions
= 1;
1465 fputs ("@s", asmfile
);
1467 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1468 fputs (";-16;", asmfile
);
1471 else /* Define as enumeral type (False, True) */
1473 fprintf (asmfile
, "eFalse:0,True:1,;");
1479 putc ('d', asmfile
);
1481 dbxout_type (TREE_TYPE (type
), 0);
1485 /* Differs from the REAL_TYPE by its new data type number */
1487 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1489 putc ('R', asmfile
);
1491 dbxout_fptype_value (type
);
1492 putc (';', asmfile
);
1494 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type
)));
1495 fputs (";0;", asmfile
);
1500 /* Output a complex integer type as a structure,
1501 pending some other way to do it. */
1502 putc ('s', asmfile
);
1504 print_wide_int (int_size_in_bytes (type
));
1505 fprintf (asmfile
, "real:");
1508 dbxout_type (TREE_TYPE (type
), 0);
1509 fprintf (asmfile
, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type
)));
1511 fprintf (asmfile
, "imag:");
1513 dbxout_type (TREE_TYPE (type
), 0);
1514 fprintf (asmfile
, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type
)),
1515 TYPE_PRECISION (TREE_TYPE (type
)));
1521 if (use_gnu_debug_info_extensions
)
1523 have_used_extensions
= 1;
1524 fputs ("@s", asmfile
);
1526 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1527 putc (';', asmfile
);
1530 /* Check if a bitstring type, which in Chill is
1531 different from a [power]set. */
1532 if (TYPE_STRING_FLAG (type
))
1534 fprintf (asmfile
, "@S;");
1538 putc ('S', asmfile
);
1540 dbxout_type (TYPE_DOMAIN (type
), 0);
1544 /* Make arrays of packed bits look like bitstrings for chill. */
1545 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1547 have_used_extensions
= 1;
1548 fputs ("@s", asmfile
);
1550 print_wide_int (BITS_PER_UNIT
* int_size_in_bytes (type
));
1551 fprintf (asmfile
, ";@S;S");
1553 dbxout_type (TYPE_DOMAIN (type
), 0);
1557 /* Output "a" followed by a range type definition
1558 for the index type of the array
1559 followed by a reference to the target-type.
1560 ar1;0;N;M for a C array of type M and size N+1. */
1561 /* Check if a character string type, which in Chill is
1562 different from an array of characters. */
1563 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
1565 have_used_extensions
= 1;
1566 fprintf (asmfile
, "@S;");
1569 tem
= TYPE_DOMAIN (type
);
1572 fprintf (asmfile
, "ar");
1574 dbxout_type_index (integer_type_node
);
1575 fprintf (asmfile
, ";0;-1;");
1580 fprintf (asmfile
, "a");
1582 dbxout_range_type (tem
);
1585 dbxout_type (TREE_TYPE (type
), 0);
1590 case QUAL_UNION_TYPE
:
1592 int i
, n_baseclasses
= 0;
1594 if (TYPE_BINFO (type
) != 0
1595 && TREE_CODE (TYPE_BINFO (type
)) == TREE_VEC
1596 && TYPE_BINFO_BASETYPES (type
) != 0)
1597 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1599 /* Output a structure type. We must use the same test here as we
1600 use in the DBX_NO_XREFS case above. */
1601 if ((TYPE_NAME (type
) != 0
1602 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1603 && DECL_IGNORED_P (TYPE_NAME (type
)))
1605 || !COMPLETE_TYPE_P (type
)
1606 /* No way in DBX fmt to describe a variable size. */
1607 || ! host_integerp (TYPE_SIZE (type
), 1))
1609 /* If the type is just a cross reference, output one
1610 and mark the type as partially described.
1611 If it later becomes defined, we will output
1612 its real definition.
1613 If the type has a name, don't nest its definition within
1614 another type's definition; instead, output an xref
1615 and let the definition come when the name is defined. */
1616 fputs ((TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu", asmfile
);
1618 #if 0 /* This assertion is legitimately false in C++. */
1619 /* We shouldn't be outputting a reference to a type before its
1620 definition unless the type has a tag name.
1621 A typedef name without a tag name should be impossible. */
1622 if (TREE_CODE (TYPE_NAME (type
)) != IDENTIFIER_NODE
)
1625 if (TYPE_NAME (type
) != 0)
1626 dbxout_type_name (type
);
1629 fprintf (asmfile
, "$$%d", anonymous_type_number
++);
1633 fprintf (asmfile
, ":");
1635 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1639 /* Identify record or union, and print its size. */
1640 putc (((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u'), asmfile
);
1642 print_wide_int (int_size_in_bytes (type
));
1644 if (use_gnu_debug_info_extensions
)
1648 have_used_extensions
= 1;
1649 fprintf (asmfile
, "!%d,", n_baseclasses
);
1653 for (i
= 0; i
< n_baseclasses
; i
++)
1655 tree binfo
= TYPE_BINFO (type
);
1656 tree child
= BINFO_BASETYPE (binfo
, i
);
1657 tree access
= (BINFO_BASEACCESSES (binfo
)
1658 ? BINFO_BASEACCESS (binfo
, i
) : access_public_node
);
1660 if (use_gnu_debug_info_extensions
)
1662 have_used_extensions
= 1;
1663 putc (TREE_VIA_VIRTUAL (child
) ? '1' : '0', asmfile
);
1664 putc (access
== access_public_node
? '2' : '0', asmfile
);
1666 if (TREE_VIA_VIRTUAL (child
)
1667 && strcmp (lang_hooks
.name
, "GNU C++") == 0)
1668 /* For a virtual base, print the (negative) offset within
1669 the vtable where we must look to find the necessary
1671 print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child
), 0)
1674 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1676 putc (',', asmfile
);
1678 dbxout_type (BINFO_TYPE (child
), 0);
1679 putc (';', asmfile
);
1684 /* Print out the base class information with fields
1685 which have the same names at the types they hold. */
1686 dbxout_type_name (BINFO_TYPE (child
));
1687 putc (':', asmfile
);
1689 dbxout_type (BINFO_TYPE (child
), full
);
1690 putc (',', asmfile
);
1692 print_wide_int (tree_low_cst (BINFO_OFFSET (child
), 0)
1694 putc (',', asmfile
);
1696 print_wide_int (tree_low_cst (DECL_SIZE
1698 (BINFO_TYPE (child
))),
1701 putc (';', asmfile
);
1707 /* Write out the field declarations. */
1708 dbxout_type_fields (type
);
1709 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
1711 have_used_extensions
= 1;
1712 dbxout_type_methods (type
);
1715 putc (';', asmfile
);
1718 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
1719 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1720 && TYPE_VFIELD (type
))
1722 have_used_extensions
= 1;
1724 /* Tell GDB+ that it may keep reading. */
1725 putc ('~', asmfile
);
1728 /* We need to write out info about what field this class
1729 uses as its "main" vtable pointer field, because if this
1730 field is inherited from a base class, GDB cannot necessarily
1731 figure out which field it's using in time. */
1732 if (TYPE_VFIELD (type
))
1734 putc ('%', asmfile
);
1736 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0);
1739 putc (';', asmfile
);
1745 /* We must use the same test here as we use in the DBX_NO_XREFS case
1746 above. We simplify it a bit since an enum will never have a variable
1748 if ((TYPE_NAME (type
) != 0
1749 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1750 && DECL_IGNORED_P (TYPE_NAME (type
)))
1752 || !COMPLETE_TYPE_P (type
))
1754 fprintf (asmfile
, "xe");
1756 dbxout_type_name (type
);
1757 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1758 putc (':', asmfile
);
1762 if (use_gnu_debug_info_extensions
1763 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1765 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1769 putc ('e', asmfile
);
1771 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1773 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1774 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem
)) + 1);
1775 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
1776 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1777 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
1778 && (HOST_WIDE_INT
) TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
1779 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1781 print_int_cst_octal (TREE_VALUE (tem
));
1783 putc (',', asmfile
);
1785 if (TREE_CHAIN (tem
) != 0)
1789 putc (';', asmfile
);
1794 putc ('*', asmfile
);
1796 dbxout_type (TREE_TYPE (type
), 0);
1800 if (use_gnu_debug_info_extensions
)
1802 have_used_extensions
= 1;
1803 putc ('#', asmfile
);
1806 /* Write the argument types out longhand. */
1807 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0);
1808 putc (',', asmfile
);
1810 dbxout_type (TREE_TYPE (type
), 0);
1811 dbxout_args (TYPE_ARG_TYPES (type
));
1812 putc (';', asmfile
);
1816 /* Treat it as a function type. */
1817 dbxout_type (TREE_TYPE (type
), 0);
1821 if (use_gnu_debug_info_extensions
)
1823 have_used_extensions
= 1;
1824 putc ('@', asmfile
);
1826 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0);
1827 putc (',', asmfile
);
1829 dbxout_type (TREE_TYPE (type
), 0);
1832 /* Should print as an int, because it is really just an offset. */
1833 dbxout_type (integer_type_node
, 0);
1836 case REFERENCE_TYPE
:
1837 if (use_gnu_debug_info_extensions
)
1838 have_used_extensions
= 1;
1839 putc (use_gnu_debug_info_extensions
? '&' : '*', asmfile
);
1841 dbxout_type (TREE_TYPE (type
), 0);
1845 putc ('f', asmfile
);
1847 dbxout_type (TREE_TYPE (type
), 0);
1855 /* Return nonzero if the given type represents an integer whose bounds
1856 should be printed in octal format. */
1859 print_int_cst_bounds_in_octal_p (type
)
1862 /* If we can use GDB extensions and the size is wider than a long
1863 (the size used by GDB to read them) or we may have trouble writing
1864 the bounds the usual way, write them in octal. Note the test is for
1865 the *target's* size of "long", not that of the host. The host test
1866 is just to make sure we can write it out in case the host wide int
1867 is narrower than the target "long".
1869 For unsigned types, we use octal if they are the same size or larger.
1870 This is because we print the bounds as signed decimal, and hence they
1871 can't span same size unsigned types. */
1873 if (use_gnu_debug_info_extensions
1874 && TYPE_MIN_VALUE (type
) != 0
1875 && TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
1876 && TYPE_MAX_VALUE (type
) != 0
1877 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
1878 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
1879 || ((TYPE_PRECISION (type
) == TYPE_PRECISION (integer_type_node
))
1880 && TREE_UNSIGNED (type
))
1881 || TYPE_PRECISION (type
) > HOST_BITS_PER_WIDE_INT
1882 || (TYPE_PRECISION (type
) == HOST_BITS_PER_WIDE_INT
1883 && TREE_UNSIGNED (type
))))
1889 /* Print the value of integer constant C, in octal,
1890 handling double precision. */
1893 print_int_cst_octal (c
)
1896 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (c
);
1897 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (c
);
1898 int excess
= (3 - (HOST_BITS_PER_WIDE_INT
% 3));
1899 unsigned int width
= TYPE_PRECISION (TREE_TYPE (c
));
1901 /* GDB wants constants with no extra leading "1" bits, so
1902 we need to remove any sign-extension that might be
1904 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
1906 else if (width
> HOST_BITS_PER_WIDE_INT
)
1907 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
1908 else if (width
== HOST_BITS_PER_WIDE_INT
)
1911 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
1913 fprintf (asmfile
, "0");
1918 print_octal (high
, HOST_BITS_PER_WIDE_INT
/ 3);
1919 print_octal (low
, HOST_BITS_PER_WIDE_INT
/ 3);
1923 unsigned HOST_WIDE_INT beg
= high
>> excess
;
1924 unsigned HOST_WIDE_INT middle
1925 = ((high
& (((HOST_WIDE_INT
) 1 << excess
) - 1)) << (3 - excess
)
1926 | (low
>> (HOST_BITS_PER_WIDE_INT
/ 3 * 3)));
1927 unsigned HOST_WIDE_INT end
1928 = low
& (((unsigned HOST_WIDE_INT
) 1
1929 << (HOST_BITS_PER_WIDE_INT
/ 3 * 3))
1932 fprintf (asmfile
, "%o%01o", (int) beg
, (int) middle
);
1934 print_octal (end
, HOST_BITS_PER_WIDE_INT
/ 3);
1939 print_octal (value
, digits
)
1940 unsigned HOST_WIDE_INT value
;
1945 for (i
= digits
- 1; i
>= 0; i
--)
1946 fprintf (asmfile
, "%01o", (int) ((value
>> (3 * i
)) & 7));
1951 /* Output C in decimal while adjusting the number of digits written. */
1959 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, c
);
1970 /* Output the name of type TYPE, with no punctuation.
1971 Such names can be set up either by typedef declarations
1972 or by struct, enum and union tags. */
1975 dbxout_type_name (type
)
1979 if (TYPE_NAME (type
) == 0)
1981 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
1983 t
= TYPE_NAME (type
);
1985 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1987 t
= DECL_NAME (TYPE_NAME (type
));
1992 fprintf (asmfile
, "%s", IDENTIFIER_POINTER (t
));
1993 CHARS (IDENTIFIER_LENGTH (t
));
1996 /* Output leading leading struct or class names needed for qualifying
1997 type whose scope is limited to a struct or class. */
2000 dbxout_class_name_qualifiers (decl
)
2003 tree context
= decl_type_context (decl
);
2005 if (context
!= NULL_TREE
2006 && TREE_CODE(context
) == RECORD_TYPE
2007 && TYPE_NAME (context
) != 0
2008 && (TREE_CODE (TYPE_NAME (context
)) == IDENTIFIER_NODE
2009 || (DECL_NAME (TYPE_NAME (context
)) != 0)))
2011 tree name
= TYPE_NAME (context
);
2013 if (TREE_CODE (name
) == TYPE_DECL
)
2015 dbxout_class_name_qualifiers (name
);
2016 name
= DECL_NAME (name
);
2018 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
2019 CHARS (IDENTIFIER_LENGTH (name
) + 2);
2023 /* Output a .stabs for the symbol defined by DECL,
2024 which must be a ..._DECL node in the normal namespace.
2025 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
2026 LOCAL is nonzero if the scope is less than the entire file.
2027 Return 1 if a stabs might have been emitted. */
2030 dbxout_symbol (decl
, local
)
2032 int local ATTRIBUTE_UNUSED
;
2034 tree type
= TREE_TYPE (decl
);
2035 tree context
= NULL_TREE
;
2038 /* "Intercept" dbxout_symbol() calls like we do all debug_hooks. */
2041 /* Cast avoids warning in old compilers. */
2042 current_sym_code
= (STAB_CODE_TYPE
) 0;
2043 current_sym_value
= 0;
2044 current_sym_addr
= 0;
2046 /* Ignore nameless syms, but don't ignore type tags. */
2048 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
2049 || DECL_IGNORED_P (decl
))
2050 DBXOUT_DECR_NESTING_AND_RETURN (0);
2052 /* If we are to generate only the symbols actualy used then such
2053 symbol nodees are flagged with TREE_USED. Ignore any that
2054 aren't flaged as TREE_USED. */
2056 if (flag_debug_only_used_symbols
)
2060 if (!TREE_USED (decl
)
2061 && (TREE_CODE (decl
) != VAR_DECL
|| !DECL_INITIAL (decl
)))
2062 DBXOUT_DECR_NESTING_AND_RETURN (0);
2064 /* We now have a used symbol. We need to generate the info for
2065 the symbol's type in addition to the symbol itself. These
2066 type symbols are queued to be generated after were done with
2067 the symbol itself (done because the symbol's info is generated
2068 with fprintf's, etc. as it determines what's needed).
2070 Note, because the TREE_TYPE(type) might be something like a
2071 pointer to a named type we need to look for the first name
2072 we see following the TREE_TYPE chain. */
2075 while (POINTER_TYPE_P (t
))
2078 /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE
2079 need special treatment. The TYPE_STUB_DECL field in these
2080 types generally represents the tag name type we want to
2081 output. In addition there could be a typedef type with
2082 a different name. In that case we also want to output
2085 if ((TREE_CODE (t
) == RECORD_TYPE
2086 || TREE_CODE (t
) == UNION_TYPE
2087 || TREE_CODE (t
) == QUAL_UNION_TYPE
2088 || TREE_CODE (t
) == ENUMERAL_TYPE
)
2089 && TYPE_STUB_DECL (t
)
2090 && TYPE_STUB_DECL (t
) != decl
2091 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (t
))) == 'd'
2092 && ! DECL_IGNORED_P (TYPE_STUB_DECL (t
)))
2094 debug_queue_symbol (TYPE_STUB_DECL (t
));
2096 && TYPE_NAME (t
) != TYPE_STUB_DECL (t
)
2097 && TYPE_NAME (t
) != decl
2098 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t
))) == 'd')
2099 debug_queue_symbol (TYPE_NAME (t
));
2101 else if (TYPE_NAME (t
)
2102 && TYPE_NAME (t
) != decl
2103 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t
))) == 'd')
2104 debug_queue_symbol (TYPE_NAME (t
));
2107 dbxout_prepare_symbol (decl
);
2109 /* The output will always start with the symbol name,
2110 so always count that in the length-output-so-far. */
2112 if (DECL_NAME (decl
) != 0)
2113 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (decl
));
2115 switch (TREE_CODE (decl
))
2118 /* Enum values are defined by defining the enum type. */
2122 if (DECL_RTL (decl
) == 0)
2123 DBXOUT_DECR_NESTING_AND_RETURN (0);
2124 if (DECL_EXTERNAL (decl
))
2126 /* Don't mention a nested function under its parent. */
2127 context
= decl_function_context (decl
);
2128 if (context
== current_function_decl
)
2130 if (GET_CODE (DECL_RTL (decl
)) != MEM
2131 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
2135 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2136 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2137 TREE_PUBLIC (decl
) ? 'F' : 'f');
2140 current_sym_code
= N_FUN
;
2141 current_sym_addr
= XEXP (DECL_RTL (decl
), 0);
2143 if (TREE_TYPE (type
))
2144 dbxout_type (TREE_TYPE (type
), 0);
2146 dbxout_type (void_type_node
, 0);
2148 /* For a nested function, when that function is compiled,
2149 mention the containing function name
2150 as well as (since dbx wants it) our own assembler-name. */
2152 fprintf (asmfile
, ",%s,%s",
2153 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
2154 IDENTIFIER_POINTER (DECL_NAME (context
)));
2156 dbxout_finish_symbol (decl
);
2160 /* Don't output the same typedef twice.
2161 And don't output what language-specific stuff doesn't want output. */
2162 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
2163 DBXOUT_DECR_NESTING_AND_RETURN (0);
2171 if (DECL_NAME (decl
))
2173 /* Nonzero means we must output a tag as well as a typedef. */
2176 /* Handle the case of a C++ structure or union
2177 where the TYPE_NAME is a TYPE_DECL
2178 which gives both a typedef name and a tag. */
2179 /* dbx requires the tag first and the typedef second. */
2180 if ((TREE_CODE (type
) == RECORD_TYPE
2181 || TREE_CODE (type
) == UNION_TYPE
2182 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2183 && TYPE_NAME (type
) == decl
2184 && !(use_gnu_debug_info_extensions
&& have_used_extensions
)
2185 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
2186 /* Distinguish the implicit typedefs of C++
2187 from explicit ones that might be found in C. */
2188 && DECL_ARTIFICIAL (decl
)
2189 /* Do not generate a tag for incomplete records. */
2190 && COMPLETE_TYPE_P (type
)
2191 /* Do not generate a tag for records of variable size,
2192 since this type can not be properly described in the
2193 DBX format, and it confuses some tools such as objdump. */
2194 && host_integerp (TYPE_SIZE (type
), 1))
2196 tree name
= TYPE_NAME (type
);
2197 if (TREE_CODE (name
) == TYPE_DECL
)
2198 name
= DECL_NAME (name
);
2200 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2201 current_sym_value
= 0;
2202 current_sym_addr
= 0;
2203 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2205 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2206 IDENTIFIER_POINTER (name
));
2207 dbxout_type (type
, 1);
2208 dbxout_finish_symbol (NULL_TREE
);
2211 /* Output .stabs (or whatever) and leading double quote. */
2212 fprintf (asmfile
, "%s\"", ASM_STABS_OP
);
2214 if (use_gnu_debug_info_extensions
)
2216 /* Output leading class/struct qualifiers. */
2217 dbxout_class_name_qualifiers (decl
);
2220 /* Output typedef name. */
2221 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl
)));
2223 /* Short cut way to output a tag also. */
2224 if ((TREE_CODE (type
) == RECORD_TYPE
2225 || TREE_CODE (type
) == UNION_TYPE
2226 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
2227 && TYPE_NAME (type
) == decl
2228 /* Distinguish the implicit typedefs of C++
2229 from explicit ones that might be found in C. */
2230 && DECL_ARTIFICIAL (decl
))
2232 if (use_gnu_debug_info_extensions
&& have_used_extensions
)
2234 putc ('T', asmfile
);
2235 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
2237 #if 0 /* Now we generate the tag for this case up above. */
2243 putc ('t', asmfile
);
2244 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2246 dbxout_type (type
, 1);
2247 dbxout_finish_symbol (decl
);
2251 /* Don't output a tag if this is an incomplete type. This prevents
2252 the sun4 Sun OS 4.x dbx from crashing. */
2254 if (tag_needed
&& TYPE_NAME (type
) != 0
2255 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
2256 || (DECL_NAME (TYPE_NAME (type
)) != 0))
2257 && COMPLETE_TYPE_P (type
)
2258 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
2260 /* For a TYPE_DECL with no name, but the type has a name,
2262 This is what represents `struct foo' with no typedef. */
2263 /* In C++, the name of a type is the corresponding typedef.
2264 In C, it is an IDENTIFIER_NODE. */
2265 tree name
= TYPE_NAME (type
);
2266 if (TREE_CODE (name
) == TYPE_DECL
)
2267 name
= DECL_NAME (name
);
2269 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2270 current_sym_value
= 0;
2271 current_sym_addr
= 0;
2272 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
2274 fprintf (asmfile
, "%s\"%s:T", ASM_STABS_OP
,
2275 IDENTIFIER_POINTER (name
));
2276 dbxout_type (type
, 1);
2277 dbxout_finish_symbol (NULL_TREE
);
2281 /* If an enum type has no name, it cannot be referred to,
2282 but we must output it anyway, since the enumeration constants
2283 can be referred to. */
2284 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
2286 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
2287 current_sym_value
= 0;
2288 current_sym_addr
= 0;
2289 current_sym_nchars
= 2;
2291 /* Some debuggers fail when given NULL names, so give this a
2292 harmless name of ` '. */
2293 fprintf (asmfile
, "%s\" :T", ASM_STABS_OP
);
2294 dbxout_type (type
, 1);
2295 dbxout_finish_symbol (NULL_TREE
);
2298 /* Prevent duplicate output of a typedef. */
2299 TREE_ASM_WRITTEN (decl
) = 1;
2304 /* Parm decls go in their own separate chains
2305 and are output by dbxout_reg_parms and dbxout_parms. */
2309 /* Named return value, treat like a VAR_DECL. */
2311 if (! DECL_RTL_SET_P (decl
))
2312 DBXOUT_DECR_NESTING_AND_RETURN (0);
2313 /* Don't mention a variable that is external.
2314 Let the file that defines it describe it. */
2315 if (DECL_EXTERNAL (decl
))
2318 /* If the variable is really a constant
2319 and not written in memory, inform the debugger. */
2320 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
2321 && DECL_INITIAL (decl
) != 0
2322 && host_integerp (DECL_INITIAL (decl
), 0)
2323 && ! TREE_ASM_WRITTEN (decl
)
2324 && (DECL_CONTEXT (decl
) == NULL_TREE
2325 || TREE_CODE (DECL_CONTEXT (decl
)) == BLOCK
))
2327 if (TREE_PUBLIC (decl
) == 0)
2329 /* The sun4 assembler does not grok this. */
2330 const char *name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2332 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
2333 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
2335 HOST_WIDE_INT ival
= tree_low_cst (DECL_INITIAL (decl
), 0);
2336 fprintf (asmfile
, "%s\"%s:c=i" HOST_WIDE_INT_PRINT_DEC
2338 ASM_STABS_OP
, name
, ival
, N_LSYM
);
2339 DBXOUT_DECR_NESTING
;
2342 else if (TREE_CODE (TREE_TYPE (decl
)) == REAL_TYPE
)
2344 /* don't know how to do this yet. */
2348 /* else it is something we handle like a normal variable. */
2351 SET_DECL_RTL (decl
, eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
));
2352 #ifdef LEAF_REG_REMAP
2353 if (current_function_uses_only_leaf_regs
)
2354 leaf_renumber_regs_insn (DECL_RTL (decl
));
2357 result
= dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
2363 DBXOUT_DECR_NESTING
;
2367 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2368 Add SUFFIX to its name, if SUFFIX is not 0.
2369 Describe the variable as residing in HOME
2370 (usually HOME is DECL_RTL (DECL), but not always).
2371 Returns 1 if the stab was really emitted. */
2374 dbxout_symbol_location (decl
, type
, suffix
, home
)
2382 /* Don't mention a variable at all
2383 if it was completely optimized into nothingness.
2385 If the decl was from an inline function, then its rtl
2386 is not identically the rtl that was used in this
2387 particular compilation. */
2388 if (GET_CODE (home
) == SUBREG
)
2392 while (GET_CODE (value
) == SUBREG
)
2393 value
= SUBREG_REG (value
);
2394 if (GET_CODE (value
) == REG
)
2396 if (REGNO (value
) >= FIRST_PSEUDO_REGISTER
)
2399 home
= alter_subreg (&home
);
2401 if (GET_CODE (home
) == REG
)
2403 regno
= REGNO (home
);
2404 if (regno
>= FIRST_PSEUDO_REGISTER
)
2408 /* The kind-of-variable letter depends on where
2409 the variable is and on the scope of its name:
2410 G and N_GSYM for static storage and global scope,
2411 S for static storage and file scope,
2412 V for static storage and local scope,
2413 for those two, use N_LCSYM if data is in bss segment,
2414 N_STSYM if in data segment, N_FUN otherwise.
2415 (We used N_FUN originally, then changed to N_STSYM
2416 to please GDB. However, it seems that confused ld.
2417 Now GDB has been fixed to like N_FUN, says Kingdon.)
2418 no letter at all, and N_LSYM, for auto variable,
2419 r and N_RSYM for register variable. */
2421 if (GET_CODE (home
) == MEM
2422 && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
2424 if (TREE_PUBLIC (decl
))
2427 current_sym_code
= N_GSYM
;
2431 current_sym_addr
= XEXP (home
, 0);
2433 letter
= decl_function_context (decl
) ? 'V' : 'S';
2435 /* This should be the same condition as in assemble_variable, but
2436 we don't have access to dont_output_data here. So, instead,
2437 we rely on the fact that error_mark_node initializers always
2438 end up in bss for C++ and never end up in bss for C. */
2439 if (DECL_INITIAL (decl
) == 0
2440 || (!strcmp (lang_hooks
.name
, "GNU C++")
2441 && DECL_INITIAL (decl
) == error_mark_node
))
2442 current_sym_code
= N_LCSYM
;
2443 else if (DECL_IN_TEXT_SECTION (decl
))
2444 /* This is not quite right, but it's the closest
2445 of all the codes that Unix defines. */
2446 current_sym_code
= DBX_STATIC_CONST_VAR_CODE
;
2449 /* Some ports can transform a symbol ref into a label ref,
2450 because the symbol ref is too far away and has to be
2451 dumped into a constant pool. Alternatively, the symbol
2452 in the constant pool might be referenced by a different
2454 if (GET_CODE (current_sym_addr
) == SYMBOL_REF
2455 && CONSTANT_POOL_ADDRESS_P (current_sym_addr
))
2457 rtx tmp
= get_pool_constant (current_sym_addr
);
2459 if (GET_CODE (tmp
) == SYMBOL_REF
2460 || GET_CODE (tmp
) == LABEL_REF
)
2461 current_sym_addr
= tmp
;
2464 /* Ultrix `as' seems to need this. */
2465 #ifdef DBX_STATIC_STAB_DATA_SECTION
2468 current_sym_code
= N_STSYM
;
2472 else if (regno
>= 0)
2475 current_sym_code
= N_RSYM
;
2476 current_sym_value
= DBX_REGISTER_NUMBER (regno
);
2478 else if (GET_CODE (home
) == MEM
2479 && (GET_CODE (XEXP (home
, 0)) == MEM
2480 || (GET_CODE (XEXP (home
, 0)) == REG
2481 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
2482 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
2483 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2484 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
2487 /* If the value is indirect by memory or by a register
2488 that isn't the frame pointer
2489 then it means the object is variable-sized and address through
2490 that register or stack slot. DBX has no way to represent this
2491 so all we can do is output the variable as a pointer.
2492 If it's not a parameter, ignore it.
2493 (VAR_DECLs like this can be made by integrate.c.) */
2495 if (GET_CODE (XEXP (home
, 0)) == REG
)
2498 current_sym_code
= N_RSYM
;
2499 if (REGNO (XEXP (home
, 0)) >= FIRST_PSEUDO_REGISTER
)
2501 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
2505 current_sym_code
= N_LSYM
;
2506 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2507 We want the value of that CONST_INT. */
2509 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2512 /* Effectively do build_pointer_type, but don't cache this type,
2513 since it might be temporary whereas the type it points to
2514 might have been saved for inlining. */
2515 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2516 type
= make_node (POINTER_TYPE
);
2517 TREE_TYPE (type
) = TREE_TYPE (decl
);
2519 else if (GET_CODE (home
) == MEM
2520 && GET_CODE (XEXP (home
, 0)) == REG
)
2522 current_sym_code
= N_LSYM
;
2523 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2525 else if (GET_CODE (home
) == MEM
2526 && GET_CODE (XEXP (home
, 0)) == PLUS
2527 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2529 current_sym_code
= N_LSYM
;
2530 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2531 We want the value of that CONST_INT. */
2532 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2534 else if (GET_CODE (home
) == MEM
2535 && GET_CODE (XEXP (home
, 0)) == CONST
)
2537 /* Handle an obscure case which can arise when optimizing and
2538 when there are few available registers. (This is *always*
2539 the case for i386/i486 targets). The RTL looks like
2540 (MEM (CONST ...)) even though this variable is a local `auto'
2541 or a local `register' variable. In effect, what has happened
2542 is that the reload pass has seen that all assignments and
2543 references for one such a local variable can be replaced by
2544 equivalent assignments and references to some static storage
2545 variable, thereby avoiding the need for a register. In such
2546 cases we're forced to lie to debuggers and tell them that
2547 this variable was itself `static'. */
2548 current_sym_code
= N_LCSYM
;
2550 current_sym_addr
= XEXP (XEXP (home
, 0), 0);
2552 else if (GET_CODE (home
) == CONCAT
)
2556 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2557 for example), then there is no easy way to figure out
2558 what SUBTYPE should be. So, we give up. */
2559 if (TREE_CODE (type
) != COMPLEX_TYPE
)
2562 subtype
= TREE_TYPE (type
);
2564 /* If the variable's storage is in two parts,
2565 output each as a separate stab with a modified name. */
2566 if (WORDS_BIG_ENDIAN
)
2567 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2569 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2571 /* Cast avoids warning in old compilers. */
2572 current_sym_code
= (STAB_CODE_TYPE
) 0;
2573 current_sym_value
= 0;
2574 current_sym_addr
= 0;
2575 dbxout_prepare_symbol (decl
);
2577 if (WORDS_BIG_ENDIAN
)
2578 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2580 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2584 /* Address might be a MEM, when DECL is a variable-sized object.
2585 Or it might be const0_rtx, meaning previous passes
2586 want us to ignore this variable. */
2589 /* Ok, start a symtab entry and output the variable name. */
2592 #ifdef DBX_STATIC_BLOCK_START
2593 DBX_STATIC_BLOCK_START (asmfile
, current_sym_code
);
2596 dbxout_symbol_name (decl
, suffix
, letter
);
2597 dbxout_type (type
, 0);
2598 dbxout_finish_symbol (decl
);
2600 #ifdef DBX_STATIC_BLOCK_END
2601 DBX_STATIC_BLOCK_END (asmfile
, current_sym_code
);
2606 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2607 Then output LETTER to indicate the kind of location the symbol has. */
2610 dbxout_symbol_name (decl
, suffix
, letter
)
2617 if (DECL_CONTEXT (decl
) && TYPE_P (DECL_CONTEXT (decl
)))
2618 /* One slight hitch: if this is a VAR_DECL which is a static
2619 class member, we must put out the mangled name instead of the
2620 DECL_NAME. Note also that static member (variable) names DO NOT begin
2621 with underscores in .stabs directives. */
2622 name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
2624 /* ...but if we're function-local, we don't want to include the junk
2625 added by ASM_FORMAT_PRIVATE_NAME. */
2626 name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
2630 fprintf (asmfile
, "%s\"%s%s:", ASM_STABS_OP
, name
,
2631 (suffix
? suffix
: ""));
2634 putc (letter
, asmfile
);
2638 dbxout_prepare_symbol (decl
)
2639 tree decl ATTRIBUTE_UNUSED
;
2642 const char *filename
= DECL_SOURCE_FILE (decl
);
2644 dbxout_source_file (asmfile
, filename
);
2649 dbxout_finish_symbol (sym
)
2652 #ifdef DBX_FINISH_SYMBOL
2653 DBX_FINISH_SYMBOL (sym
);
2656 if (use_gnu_debug_info_extensions
&& sym
!= 0)
2657 line
= DECL_SOURCE_LINE (sym
);
2659 fprintf (asmfile
, "\",%d,0,%d,", current_sym_code
, line
);
2660 if (current_sym_addr
)
2661 output_addr_const (asmfile
, current_sym_addr
);
2663 fprintf (asmfile
, "%d", current_sym_value
);
2664 putc ('\n', asmfile
);
2668 /* Output definitions of all the decls in a chain. Return nonzero if
2669 anything was output */
2678 result
+= dbxout_symbol (syms
, 1);
2679 syms
= TREE_CHAIN (syms
);
2684 /* The following two functions output definitions of function parameters.
2685 Each parameter gets a definition locating it in the parameter list.
2686 Each parameter that is a register variable gets a second definition
2687 locating it in the register.
2689 Printing or argument lists in gdb uses the definitions that
2690 locate in the parameter list. But reference to the variable in
2691 expressions uses preferentially the definition as a register. */
2693 /* Output definitions, referring to storage in the parmlist,
2694 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2697 dbxout_parms (parms
)
2702 for (; parms
; parms
= TREE_CHAIN (parms
))
2703 if (DECL_NAME (parms
) && TREE_TYPE (parms
) != error_mark_node
)
2705 dbxout_prepare_symbol (parms
);
2707 /* Perform any necessary register eliminations on the parameter's rtl,
2708 so that the debugging output will be accurate. */
2709 DECL_INCOMING_RTL (parms
)
2710 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
2711 SET_DECL_RTL (parms
, eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
));
2712 #ifdef LEAF_REG_REMAP
2713 if (current_function_uses_only_leaf_regs
)
2715 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
2716 leaf_renumber_regs_insn (DECL_RTL (parms
));
2720 if (PARM_PASSED_IN_MEMORY (parms
))
2722 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
2724 /* ??? Here we assume that the parm address is indexed
2725 off the frame pointer or arg pointer.
2726 If that is not true, we produce meaningless results,
2727 but do not crash. */
2728 if (GET_CODE (addr
) == PLUS
2729 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
2730 current_sym_value
= INTVAL (XEXP (addr
, 1));
2732 current_sym_value
= 0;
2734 current_sym_code
= N_PSYM
;
2735 current_sym_addr
= 0;
2738 if (DECL_NAME (parms
))
2740 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2742 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2743 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2744 DBX_MEMPARM_STABS_LETTER
);
2748 current_sym_nchars
= 8;
2749 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2750 DBX_MEMPARM_STABS_LETTER
);
2753 /* It is quite tempting to use:
2755 dbxout_type (TREE_TYPE (parms), 0);
2757 as the next statement, rather than using DECL_ARG_TYPE(), so
2758 that gcc reports the actual type of the parameter, rather
2759 than the promoted type. This certainly makes GDB's life
2760 easier, at least for some ports. The change is a bad idea
2761 however, since GDB expects to be able access the type without
2762 performing any conversions. So for example, if we were
2763 passing a float to an unprototyped function, gcc will store a
2764 double on the stack, but if we emit a stab saying the type is a
2765 float, then gdb will only read in a single value, and this will
2766 produce an erroneous value. */
2767 dbxout_type (DECL_ARG_TYPE (parms
), 0);
2768 current_sym_value
= DEBUGGER_ARG_OFFSET (current_sym_value
, addr
);
2769 dbxout_finish_symbol (parms
);
2771 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
2774 char regparm_letter
;
2776 /* Parm passed in registers and lives in registers or nowhere. */
2778 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2779 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2780 current_sym_addr
= 0;
2782 /* If parm lives in a register, use that register;
2783 pretend the parm was passed there. It would be more consistent
2784 to describe the register where the parm was passed,
2785 but in practice that register usually holds something else.
2787 If we use DECL_RTL, then we must use the declared type of
2788 the variable, not the type that it arrived in. */
2789 if (REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2791 best_rtl
= DECL_RTL (parms
);
2792 parm_type
= TREE_TYPE (parms
);
2794 /* If the parm lives nowhere, use the register where it was
2795 passed. It is also better to use the declared type here. */
2798 best_rtl
= DECL_INCOMING_RTL (parms
);
2799 parm_type
= TREE_TYPE (parms
);
2801 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
2804 if (DECL_NAME (parms
))
2806 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2807 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2808 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2813 current_sym_nchars
= 8;
2814 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2818 dbxout_type (parm_type
, 0);
2819 dbxout_finish_symbol (parms
);
2821 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2822 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
2823 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
2824 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
2825 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2826 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
2830 /* Parm was passed via invisible reference.
2831 That is, its address was passed in a register.
2832 Output it as if it lived in that register.
2833 The debugger will know from the type
2834 that it was actually passed by invisible reference. */
2836 char regparm_letter
;
2837 /* Parm passed in registers and lives in registers or nowhere. */
2839 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2840 if (use_gnu_debug_info_extensions
)
2841 regparm_letter
= GDB_INV_REF_REGPARM_STABS_LETTER
;
2843 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2845 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2846 If it is an unallocated pseudo-reg, then use the register where
2847 it was passed instead. */
2848 if (REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
2849 current_sym_value
= REGNO (XEXP (DECL_RTL (parms
), 0));
2851 current_sym_value
= REGNO (DECL_INCOMING_RTL (parms
));
2853 current_sym_addr
= 0;
2856 if (DECL_NAME (parms
))
2859 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2861 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2862 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2867 current_sym_nchars
= 8;
2868 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2872 dbxout_type (TREE_TYPE (parms
), 0);
2873 dbxout_finish_symbol (parms
);
2875 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2876 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
2878 /* Parm was passed via invisible reference, with the reference
2879 living on the stack. DECL_RTL looks like
2880 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2881 could look like (MEM (MEM (REG))). */
2882 const char *const decl_name
= (DECL_NAME (parms
)
2883 ? IDENTIFIER_POINTER (DECL_NAME (parms
))
2885 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms
), 0), 0)) == REG
)
2886 current_sym_value
= 0;
2889 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms
), 0), 0), 1));
2890 current_sym_addr
= 0;
2891 current_sym_code
= N_PSYM
;
2894 fprintf (asmfile
, "%s\"%s:v", ASM_STABS_OP
, decl_name
);
2897 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2898 XEXP (XEXP (DECL_RTL (parms
), 0), 0));
2899 dbxout_type (TREE_TYPE (parms
), 0);
2900 dbxout_finish_symbol (parms
);
2902 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2903 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
2904 /* ??? A constant address for a parm can happen
2905 when the reg it lives in is equiv to a constant in memory.
2906 Should make this not happen, after 2.4. */
2907 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
2909 /* Parm was passed in registers but lives on the stack. */
2911 current_sym_code
= N_PSYM
;
2912 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2913 in which case we want the value of that CONST_INT,
2915 in which case we use a value of zero. */
2916 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
)
2917 current_sym_value
= 0;
2920 = INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
2922 current_sym_addr
= 0;
2924 /* Make a big endian correction if the mode of the type of the
2925 parameter is not the same as the mode of the rtl. */
2926 if (BYTES_BIG_ENDIAN
2927 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
2928 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
2930 current_sym_value
+=
2931 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms
)))
2932 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
)));
2936 if (DECL_NAME (parms
))
2939 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2941 fprintf (asmfile
, "%s\"%s:%c", ASM_STABS_OP
,
2942 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2943 DBX_MEMPARM_STABS_LETTER
);
2947 current_sym_nchars
= 8;
2948 fprintf (asmfile
, "%s\"(anon):%c", ASM_STABS_OP
,
2949 DBX_MEMPARM_STABS_LETTER
);
2953 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2954 XEXP (DECL_RTL (parms
), 0));
2955 dbxout_type (TREE_TYPE (parms
), 0);
2956 dbxout_finish_symbol (parms
);
2959 DBXOUT_DECR_NESTING
;
2962 /* Output definitions for the places where parms live during the function,
2963 when different from where they were passed, when the parms were passed
2966 It is not useful to do this for parms passed in registers
2967 that live during the function in different registers, because it is
2968 impossible to look in the passed register for the passed value,
2969 so we use the within-the-function register to begin with.
2971 PARMS is a chain of PARM_DECL nodes. */
2974 dbxout_reg_parms (parms
)
2979 for (; parms
; parms
= TREE_CHAIN (parms
))
2980 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
2982 dbxout_prepare_symbol (parms
);
2984 /* Report parms that live in registers during the function
2985 but were passed in memory. */
2986 if (GET_CODE (DECL_RTL (parms
)) == REG
2987 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2988 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2989 0, DECL_RTL (parms
));
2990 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
2991 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2992 0, DECL_RTL (parms
));
2993 /* Report parms that live in memory but not where they were passed. */
2994 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2995 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
2996 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2997 0, DECL_RTL (parms
));
2999 DBXOUT_DECR_NESTING
;
3002 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
3003 output definitions of those names, in raw form */
3011 putc (',', asmfile
);
3012 dbxout_type (TREE_VALUE (args
), 0);
3014 args
= TREE_CHAIN (args
);
3018 /* Output everything about a symbol block (a BLOCK node
3019 that represents a scope level),
3020 including recursive output of contained blocks.
3022 BLOCK is the BLOCK node.
3023 DEPTH is its depth within containing symbol blocks.
3024 ARGS is usually zero; but for the outermost block of the
3025 body of a function, it is a chain of PARM_DECLs for the function parameters.
3026 We output definitions of all the register parms
3027 as if they were local variables of that block.
3029 If -g1 was used, we count blocks just the same, but output nothing
3030 except for the outermost block.
3032 Actually, BLOCK may be several blocks chained together.
3033 We handle them all in sequence. */
3036 dbxout_block (block
, depth
, args
)
3043 #if DBX_BLOCKS_FUNCTION_RELATIVE
3044 const char *begin_label
;
3045 if (current_function_func_begin_label
!= NULL_TREE
)
3046 begin_label
= IDENTIFIER_POINTER (current_function_func_begin_label
);
3048 begin_label
= XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0);
3053 /* Ignore blocks never expanded or otherwise marked as real. */
3054 if (TREE_USED (block
) && TREE_ASM_WRITTEN (block
))
3058 /* In dbx format, the syms of a block come before the N_LBRAC.
3059 If nothing is output, we don't need the N_LBRAC, either. */
3061 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
3062 did_output
= dbxout_syms (BLOCK_VARS (block
));
3064 dbxout_reg_parms (args
);
3066 /* Now output an N_LBRAC symbol to represent the beginning of
3067 the block. Use the block's tree-walk order to generate
3068 the assembler symbols LBBn and LBEn
3069 that final will define around the code in this block. */
3070 if (depth
> 0 && did_output
)
3073 blocknum
= BLOCK_NUMBER (block
);
3074 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
3076 if (BLOCK_HANDLER_BLOCK (block
))
3078 /* A catch block. Must precede N_LBRAC. */
3079 tree decl
= BLOCK_VARS (block
);
3082 fprintf (asmfile
, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP
,
3083 IDENTIFIER_POINTER (DECL_NAME (decl
)), N_CATCH
);
3084 assemble_name (asmfile
, buf
);
3085 fprintf (asmfile
, "\n");
3086 decl
= TREE_CHAIN (decl
);
3090 #ifdef DBX_OUTPUT_LBRAC
3091 DBX_OUTPUT_LBRAC (asmfile
, buf
);
3093 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_LBRAC
);
3094 assemble_name (asmfile
, buf
);
3095 #if DBX_BLOCKS_FUNCTION_RELATIVE
3096 putc ('-', asmfile
);
3097 assemble_name (asmfile
, begin_label
);
3099 fprintf (asmfile
, "\n");
3103 /* Output the subblocks. */
3104 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
3106 /* Refer to the marker for the end of the block. */
3107 if (depth
> 0 && did_output
)
3110 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
3111 #ifdef DBX_OUTPUT_RBRAC
3112 DBX_OUTPUT_RBRAC (asmfile
, buf
);
3114 fprintf (asmfile
, "%s%d,0,0,", ASM_STABN_OP
, N_RBRAC
);
3115 assemble_name (asmfile
, buf
);
3116 #if DBX_BLOCKS_FUNCTION_RELATIVE
3117 putc ('-', asmfile
);
3118 assemble_name (asmfile
, begin_label
);
3120 fprintf (asmfile
, "\n");
3124 block
= BLOCK_CHAIN (block
);
3128 /* Output the information about a function and its arguments and result.
3129 Usually this follows the function's code,
3130 but on some systems, it comes before. */
3132 #if defined (DBX_DEBUGGING_INFO)
3134 dbxout_begin_function (decl
)
3137 int saved_tree_used1
= TREE_USED (decl
);
3138 TREE_USED (decl
) = 1;
3139 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3141 int saved_tree_used2
= TREE_USED (DECL_RESULT (decl
));
3142 TREE_USED (DECL_RESULT (decl
)) = 1;
3143 dbxout_symbol (decl
, 0);
3144 TREE_USED (DECL_RESULT (decl
)) = saved_tree_used2
;
3147 dbxout_symbol (decl
, 0);
3148 TREE_USED (decl
) = saved_tree_used1
;
3150 dbxout_parms (DECL_ARGUMENTS (decl
));
3151 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
3152 dbxout_symbol (DECL_RESULT (decl
), 1);
3154 #endif /* DBX_DEBUGGING_INFO */
3156 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3158 #include "gt-dbxout.h"