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 /* If zero then there is no pending BINCL. */
199 static int pending_bincls = 0;
201 /* This is the top of the stack. */
203 static GTY(()) struct dbx_file *current_file;
205 /* This is the next file number to use. */
207 static GTY(()) int next_file_number;
209 /* A counter for dbxout_function_end. */
211 static GTY(()) int scope_labelno;
213 /* A counter for dbxout_source_line. */
215 static GTY(()) int dbxout_source_line_counter;
217 /* Nonzero if we have actually used any of the GDB extensions
218 to the debugging format. The idea is that we use them for the
219 first time only if there's a strong reason, but once we have done that,
220 we use them whenever convenient. */
222 static GTY(()) int have_used_extensions = 0;
224 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
225 for the N_SO filename stabs label. */
227 static GTY(()) int source_label_number = 1;
229 /* Last source file name mentioned in a NOTE insn. */
231 static GTY(()) const char *lastfile;
233 /* Used by PCH machinery to detect if 'lastfile' should be reset to
235 static GTY(()) int lastfile_is_base;
237 /* Typical USG systems don't have stab.h, and they also have
238 no use for DBX-format debugging info. */
240 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
242 /* The original input file name. */
243 static const char *base_input_file;
245 /* Current working directory. */
247 static const char *cwd;
249 #ifdef DEBUG_SYMS_TEXT
250 #define FORCE_TEXT function_section (current_function_decl);
257 #define STAB_CODE_TYPE enum __stab_debug_code
259 /* 1 if PARM is passed to this function in memory. */
261 #define PARM_PASSED_IN_MEMORY(PARM) \
262 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
264 /* A C expression for the integer offset value of an automatic variable
265 (N_LSYM) having address X (an RTX). */
266 #ifndef DEBUGGER_AUTO_OFFSET
267 #define DEBUGGER_AUTO_OFFSET(X) \
268 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
271 /* A C expression for the integer offset value of an argument (N_PSYM)
272 having address X (an RTX). The nominal offset is OFFSET. */
273 #ifndef DEBUGGER_ARG_OFFSET
274 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
277 /* Stream for writing to assembler file. */
279 static FILE *asmfile;
281 /* These variables are for dbxout_symbol to communicate to
282 dbxout_finish_symbol.
283 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
284 current_sym_value and current_sym_addr are two ways to address the
285 value to store in the symtab entry.
286 current_sym_addr if nonzero represents the value as an rtx.
287 If that is zero, current_sym_value is used. This is used
288 when the value is an offset (such as for auto variables,
289 register variables and parms). */
291 static STAB_CODE_TYPE current_sym_code;
292 static int current_sym_value;
293 static rtx current_sym_addr;
295 /* Number of chars of symbol-description generated so far for the
296 current symbol. Used by CHARS and CONTIN. */
298 static int current_sym_nchars;
300 /* Report having output N chars of the current symbol-description. */
302 #define CHARS(N) (current_sym_nchars += (N))
304 /* Break the current symbol-description, generating a continuation,
305 if it has become long. */
307 #ifndef DBX_CONTIN_LENGTH
308 #define DBX_CONTIN_LENGTH 80
311 #if DBX_CONTIN_LENGTH > 0
313 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
315 #define CONTIN do { } while (0)
318 static void emit_bincl_stab (const char *c);
319 static void emit_pending_bincls (void);
320 static inline void emit_pending_bincls_if_required (void);
322 static void dbxout_init (const char *);
323 static void dbxout_finish (const char *);
324 static void dbxout_start_source_file (unsigned, const char *);
325 static void dbxout_end_source_file (unsigned);
326 static void dbxout_typedefs (tree);
327 static void dbxout_fptype_value (tree);
328 static void dbxout_type_index (tree);
329 #if DBX_CONTIN_LENGTH > 0
330 static void dbxout_continue (void);
332 static void dbxout_args (tree);
333 static void dbxout_type_fields (tree);
334 static void dbxout_type_method_1 (tree, const char *);
335 static void dbxout_type_methods (tree);
336 static void dbxout_range_type (tree);
337 static void dbxout_type (tree, int);
338 static bool print_int_cst_bounds_in_octal_p (tree);
339 static void print_int_cst_octal (tree);
340 static void print_octal (unsigned HOST_WIDE_INT, int);
341 static void print_wide_int (HOST_WIDE_INT);
342 static void dbxout_type_name (tree);
343 static void dbxout_class_name_qualifiers (tree);
344 static int dbxout_symbol_location (tree, tree, const char *, rtx);
345 static void dbxout_symbol_name (tree, const char *, int);
346 static void dbxout_prepare_symbol (tree);
347 static void dbxout_finish_symbol (tree);
348 static void dbxout_block (tree, int, tree);
349 static void dbxout_global_decl (tree);
350 static void dbxout_handle_pch (unsigned);
352 /* The debug hooks structure. */
353 #if defined (DBX_DEBUGGING_INFO)
355 static void dbxout_source_line (unsigned int, const char *);
356 static void dbxout_source_file (FILE *, const char *);
357 static void dbxout_function_end (void);
358 static void dbxout_begin_function (tree);
359 static void dbxout_begin_block (unsigned, unsigned);
360 static void dbxout_end_block (unsigned, unsigned);
361 static void dbxout_function_decl (tree);
363 const struct gcc_debug_hooks dbx_debug_hooks =
367 debug_nothing_int_charstar,
368 debug_nothing_int_charstar,
369 dbxout_start_source_file,
370 dbxout_end_source_file,
373 debug_true_tree, /* ignore_block */
374 dbxout_source_line, /* source_line */
375 dbxout_source_line, /* begin_prologue: just output line info */
376 debug_nothing_int_charstar, /* end_prologue */
377 debug_nothing_int_charstar, /* end_epilogue */
378 #ifdef DBX_FUNCTION_FIRST
379 dbxout_begin_function,
381 debug_nothing_tree, /* begin_function */
383 debug_nothing_int, /* end_function */
384 dbxout_function_decl,
385 dbxout_global_decl, /* global_decl */
386 debug_nothing_tree, /* deferred_inline_function */
387 debug_nothing_tree, /* outlining_inline_function */
388 debug_nothing_rtx, /* label */
389 dbxout_handle_pch /* handle_pch */
391 #endif /* DBX_DEBUGGING_INFO */
393 #if defined (XCOFF_DEBUGGING_INFO)
394 const struct gcc_debug_hooks xcoff_debug_hooks =
398 debug_nothing_int_charstar,
399 debug_nothing_int_charstar,
400 dbxout_start_source_file,
401 dbxout_end_source_file,
402 xcoffout_begin_block,
404 debug_true_tree, /* ignore_block */
405 xcoffout_source_line,
406 xcoffout_begin_prologue, /* begin_prologue */
407 debug_nothing_int_charstar, /* end_prologue */
408 xcoffout_end_epilogue,
409 debug_nothing_tree, /* begin_function */
410 xcoffout_end_function,
411 debug_nothing_tree, /* function_decl */
412 dbxout_global_decl, /* global_decl */
413 debug_nothing_tree, /* deferred_inline_function */
414 debug_nothing_tree, /* outlining_inline_function */
415 debug_nothing_rtx, /* label */
416 dbxout_handle_pch /* handle_pch */
418 #endif /* XCOFF_DEBUGGING_INFO */
420 #if defined (DBX_DEBUGGING_INFO)
422 dbxout_function_end (void)
424 char lscope_label_name[100];
425 /* Convert Ltext into the appropriate format for local labels in case
426 the system doesn't insert underscores in front of user generated
428 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
429 (*targetm.asm_out.internal_label) (asmfile, "Lscope", scope_labelno);
432 /* By convention, GCC will mark the end of a function with an N_FUN
433 symbol and an empty string. */
434 #ifdef DBX_OUTPUT_NFUN
435 DBX_OUTPUT_NFUN (asmfile, lscope_label_name, current_function_decl);
437 fprintf (asmfile, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN);
438 assemble_name (asmfile, lscope_label_name);
440 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
441 fprintf (asmfile, "\n");
444 #endif /* DBX_DEBUGGING_INFO */
446 /* At the beginning of compilation, start writing the symbol table.
447 Initialize `typevec' and output the standard data types of C. */
450 dbxout_init (const char *input_file_name)
452 char ltext_label_name[100];
453 tree syms = (*lang_hooks.decls.getdecls) ();
455 asmfile = asm_out_file;
458 typevec = (struct typeinfo *) ggc_calloc (typevec_len, sizeof typevec[0]);
460 /* Convert Ltext into the appropriate format for local labels in case
461 the system doesn't insert underscores in front of user generated
463 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
465 /* Put the current working directory in an N_SO symbol. */
466 if (use_gnu_debug_info_extensions)
468 if (!cwd && (cwd = getpwd ()) && (!*cwd || cwd[strlen (cwd) - 1] != '/'))
469 cwd = concat (cwd, FILE_NAME_JOINER, NULL);
472 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
473 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
474 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
475 fprintf (asmfile, "%s", ASM_STABS_OP);
476 output_quoted_string (asmfile, cwd);
477 fprintf (asmfile, ",%d,0,0,", N_SO);
478 assemble_name (asmfile, ltext_label_name);
479 fputc ('\n', asmfile);
480 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
484 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
485 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
486 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
487 /* We include outputting `Ltext:' here,
488 because that gives you a way to override it. */
489 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
490 fprintf (asmfile, "%s", ASM_STABS_OP);
491 output_quoted_string (asmfile, input_file_name);
492 fprintf (asmfile, ",%d,0,0,", N_SO);
493 assemble_name (asmfile, ltext_label_name);
494 fputc ('\n', asmfile);
496 (*targetm.asm_out.internal_label) (asmfile, "Ltext", 0);
497 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
499 #ifdef DBX_OUTPUT_GCC_MARKER
500 DBX_OUTPUT_GCC_MARKER (asmfile);
502 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
503 fprintf (asmfile, "%s\"%s\",%d,0,0,0\n",
504 ASM_STABS_OP, STABS_GCC_MARKER, N_OPT);
507 base_input_file = lastfile = input_file_name;
509 next_type_number = 1;
512 current_file = (struct dbx_file *) ggc_alloc (sizeof *current_file);
513 current_file->next = NULL;
514 current_file->file_number = 0;
515 current_file->next_type_number = 1;
516 next_file_number = 1;
517 current_file->prev = NULL;
518 current_file->bincl_status = BINCL_NOT_REQUIRED;
519 current_file->pending_bincl_name = NULL;
522 /* Make sure that types `int' and `char' have numbers 1 and 2.
523 Definitions of other integer types will refer to those numbers.
524 (Actually it should no longer matter what their numbers are.
525 Also, if any types with tags have been defined, dbxout_symbol
526 will output them first, so the numbers won't be 1 and 2. That
527 happens in C++. So it's a good thing it should no longer matter). */
529 #ifdef DBX_OUTPUT_STANDARD_TYPES
530 DBX_OUTPUT_STANDARD_TYPES (syms);
533 /* Get all permanent types that have typedef names,
534 and output them all, except for those already output. */
536 dbxout_typedefs (syms);
539 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
540 in the reverse order from that which is found in SYMS. */
543 dbxout_typedefs (tree syms)
547 dbxout_typedefs (TREE_CHAIN (syms));
548 if (TREE_CODE (syms) == TYPE_DECL)
550 tree type = TREE_TYPE (syms);
552 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
553 && COMPLETE_TYPE_P (type)
554 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
555 dbxout_symbol (TYPE_NAME (type), 0);
560 /* Emit BINCL stab using given name. */
562 emit_bincl_stab (const char *name)
564 fprintf (asmfile, "%s", ASM_STABS_OP);
565 output_quoted_string (asmfile, name);
566 fprintf (asmfile, ",%d,0,0,0\n", N_BINCL);
569 /* If there are pending bincls then it is time to emit all of them. */
572 emit_pending_bincls_if_required ()
576 emit_pending_bincls ();
580 /* Emit all pending bincls. */
583 emit_pending_bincls ()
585 struct dbx_file *f = current_file;
587 /* Find first pending bincl. */
588 while (f->bincl_status == BINCL_PENDING)
591 /* Now emit all bincls. */
596 if (f->bincl_status == BINCL_PENDING)
598 emit_bincl_stab (f->pending_bincl_name);
600 /* Update file number and status. */
601 f->file_number = next_file_number++;
602 f->bincl_status = BINCL_PROCESSED;
604 if (f == current_file)
609 /* All pending bincls have been emitted. */
613 /* Change to reading from a new source file. Generate a N_BINCL stab. */
616 dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
617 const char *filename ATTRIBUTE_UNUSED)
620 struct dbx_file *n = (struct dbx_file *) ggc_alloc (sizeof *n);
622 n->next = current_file;
623 n->next_type_number = 1;
624 /* Do not assign file number now.
625 Delay it until we actually emit BINCL. */
628 current_file->prev = n;
629 n->bincl_status = BINCL_PENDING;
630 n->pending_bincl_name = filename;
636 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
639 dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED)
642 /* Emit EINCL stab only if BINCL is not pending. */
643 if (current_file->bincl_status == BINCL_PROCESSED)
644 fprintf (asmfile, "%s%d,0,0,0\n", ASM_STABN_OP, N_EINCL);
645 current_file->bincl_status = BINCL_NOT_REQUIRED;
646 current_file = current_file->next;
650 /* Handle a few odd cases that occur when trying to make PCH files work. */
653 dbxout_handle_pch (unsigned at_end)
657 /* When using the PCH, this file will be included, so we need to output
659 dbxout_start_source_file (0, lastfile);
661 /* The base file when using the PCH won't be the same as
662 the base file when it's being generated. */
667 /* ... and an EINCL. */
668 dbxout_end_source_file (0);
670 /* Deal with cases where 'lastfile' was never actually changed. */
671 lastfile_is_base = lastfile == NULL;
675 #if defined (DBX_DEBUGGING_INFO)
676 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
679 dbxout_source_file (FILE *file, const char *filename)
681 if (lastfile == 0 && lastfile_is_base)
683 lastfile = base_input_file;
684 lastfile_is_base = 0;
687 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
689 char ltext_label_name[100];
691 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
692 source_label_number);
693 fprintf (file, "%s", ASM_STABS_OP);
694 output_quoted_string (file, filename);
695 fprintf (asmfile, ",%d,0,0,", N_SOL);
696 assemble_name (asmfile, ltext_label_name);
697 fputc ('\n', asmfile);
698 if (current_function_decl != NULL_TREE
699 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
700 ; /* Don't change section amid function. */
703 (*targetm.asm_out.internal_label) (file, "Ltext", source_label_number);
704 source_label_number++;
709 /* Output a line number symbol entry for source file FILENAME and line
713 dbxout_source_line (unsigned int lineno, const char *filename)
715 dbxout_source_file (asmfile, filename);
717 #ifdef ASM_OUTPUT_SOURCE_LINE
718 dbxout_source_line_counter += 1;
719 ASM_OUTPUT_SOURCE_LINE (asmfile, lineno, dbxout_source_line_counter);
721 fprintf (asmfile, "%s%d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
725 /* Describe the beginning of an internal block within a function. */
728 dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
730 emit_pending_bincls_if_required ();
731 (*targetm.asm_out.internal_label) (asmfile, "LBB", n);
734 /* Describe the end line-number of an internal block within a function. */
737 dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
739 emit_pending_bincls_if_required ();
740 (*targetm.asm_out.internal_label) (asmfile, "LBE", n);
743 /* Output dbx data for a function definition.
744 This includes a definition of the function name itself (a symbol),
745 definitions of the parameters (locating them in the parameter list)
746 and then output the block that makes up the function's body
747 (including all the auto variables of the function). */
750 dbxout_function_decl (tree decl)
752 emit_pending_bincls_if_required ();
753 #ifndef DBX_FUNCTION_FIRST
754 dbxout_begin_function (decl);
756 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
757 #ifdef DBX_OUTPUT_FUNCTION_END
758 DBX_OUTPUT_FUNCTION_END (asmfile, decl);
760 if (use_gnu_debug_info_extensions
761 #if defined(NO_DBX_FUNCTION_END)
762 && ! NO_DBX_FUNCTION_END
764 && targetm.have_named_sections)
765 dbxout_function_end ();
768 #endif /* DBX_DEBUGGING_INFO */
770 /* Debug information for a global DECL. Called from toplev.c after
771 compilation proper has finished. */
773 dbxout_global_decl (tree decl)
775 if (TREE_CODE (decl) == VAR_DECL
776 && ! DECL_EXTERNAL (decl)
777 && DECL_RTL_SET_P (decl)) /* Not necessary? */
779 int saved_tree_used = TREE_USED (decl);
780 TREE_USED (decl) = 1;
781 dbxout_symbol (decl, 0);
782 TREE_USED (decl) = saved_tree_used;
786 /* At the end of compilation, finish writing the symbol table.
787 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
791 dbxout_finish (const char *filename ATTRIBUTE_UNUSED)
793 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
794 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile, filename);
795 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
800 /* Output floating point type values used by the 'R' stab letter.
801 These numbers come from include/aout/stab_gnu.h in binutils/gdb.
803 There are only 3 real/complex types defined, and we need 7/6.
804 We use NF_SINGLE as a generic float type, and NF_COMPLEX as a generic
805 complex type. Since we have the type size anyways, we don't really need
806 to distinguish between different FP types, we only need to distinguish
807 between float and complex. This works fine with gdb.
809 We only use this for complex types, to avoid breaking backwards
810 compatibility for real types. complex types aren't in ISO C90, so it is
811 OK if old debuggers don't understand the debug info we emit for them. */
813 /* ??? These are supposed to be IEEE types, but we don't check for that.
814 We could perhaps add additional numbers for non-IEEE types if we need
818 dbxout_fptype_value (tree type)
821 enum machine_mode mode = TYPE_MODE (type);
823 if (TREE_CODE (type) == REAL_TYPE)
827 else if (mode == DFmode)
829 else if (mode == TFmode || mode == XFmode)
832 /* Use NF_SINGLE as a generic real type for other sizes. */
835 else if (TREE_CODE (type) == COMPLEX_TYPE)
839 else if (mode == DCmode)
841 else if (mode == TCmode || mode == XCmode)
844 /* Use NF_COMPLEX as a generic complex type for other sizes. */
850 putc (value, asmfile);
854 /* Output the index of a type. */
857 dbxout_type_index (tree type)
859 #ifndef DBX_USE_BINCL
860 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
863 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
864 fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number);
869 #if DBX_CONTIN_LENGTH > 0
870 /* Continue a symbol-description that gets too big.
871 End one symbol table entry with a double-backslash
872 and start a new one, eventually producing something like
873 .stabs "start......\\",code,0,value
874 .stabs "...rest",code,0,value */
877 dbxout_continue (void)
879 emit_pending_bincls_if_required ();
880 #ifdef DBX_CONTIN_CHAR
881 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
883 fprintf (asmfile, "\\\\");
885 dbxout_finish_symbol (NULL_TREE);
886 fprintf (asmfile, "%s\"", ASM_STABS_OP);
887 current_sym_nchars = 0;
889 #endif /* DBX_CONTIN_LENGTH > 0 */
891 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
892 This must be a separate function because anonymous unions require
896 dbxout_type_fields (tree type)
900 /* Output the name, type, position (in bits), size (in bits) of each
901 field that we can support. */
902 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
904 /* Omit here local type decls until we know how to support them. */
905 if (TREE_CODE (tem) == TYPE_DECL
906 /* Omit fields whose position or size are variable or too large to
908 || (TREE_CODE (tem) == FIELD_DECL
909 && (! host_integerp (bit_position (tem), 0)
911 || ! host_integerp (DECL_SIZE (tem), 1)))
912 /* Omit here the nameless fields that are used to skip bits. */
913 || DECL_IGNORED_P (tem))
916 else if (TREE_CODE (tem) != CONST_DECL)
918 /* Continue the line if necessary,
919 but not before the first field. */
920 if (tem != TYPE_FIELDS (type))
925 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
926 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
930 fprintf (asmfile, ":");
934 if (use_gnu_debug_info_extensions
935 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
936 || TREE_CODE (tem) != FIELD_DECL))
938 have_used_extensions = 1;
940 putc ((TREE_PRIVATE (tem) ? '0'
941 : TREE_PROTECTED (tem) ? '1' : '2'),
946 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
947 && DECL_BIT_FIELD_TYPE (tem))
948 ? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0);
950 if (TREE_CODE (tem) == VAR_DECL)
952 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
954 tree name = DECL_ASSEMBLER_NAME (tem);
956 have_used_extensions = 1;
957 fprintf (asmfile, ":%s;", IDENTIFIER_POINTER (name));
958 CHARS (IDENTIFIER_LENGTH (name) + 2);
962 /* If TEM is non-static, GDB won't understand it. */
963 fprintf (asmfile, ",0,0;");
970 print_wide_int (int_bit_position (tem));
972 print_wide_int (tree_low_cst (DECL_SIZE (tem), 1));
980 /* Subroutine of `dbxout_type_methods'. Output debug info about the
981 method described DECL. DEBUG_NAME is an encoding of the method's
982 type signature. ??? We may be able to do without DEBUG_NAME altogether
986 dbxout_type_method_1 (tree decl, const char *debug_name)
990 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
992 else /* it's a METHOD_TYPE. */
994 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
995 /* A for normal functions.
996 B for `const' member functions.
997 C for `volatile' member functions.
998 D for `const volatile' member functions. */
999 if (TYPE_READONLY (TREE_TYPE (firstarg)))
1001 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
1004 if (DECL_VINDEX (decl))
1010 fprintf (asmfile, ":%s;%c%c%c", debug_name,
1011 TREE_PRIVATE (decl) ? '0'
1012 : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
1013 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
1014 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
1016 if (DECL_VINDEX (decl) && host_integerp (DECL_VINDEX (decl), 0))
1018 print_wide_int (tree_low_cst (DECL_VINDEX (decl), 0));
1019 putc (';', asmfile);
1021 dbxout_type (DECL_CONTEXT (decl), 0);
1022 fprintf (asmfile, ";");
1027 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
1031 dbxout_type_methods (tree type)
1033 /* C++: put out the method names and their parameter lists */
1034 tree methods = TYPE_METHODS (type);
1038 char formatted_type_identifier_length[16];
1039 int type_identifier_length;
1041 if (methods == NULL_TREE)
1044 type_encoding = DECL_NAME (TYPE_NAME (type));
1047 /* C++: Template classes break some assumptions made by this code about
1048 the class names, constructor names, and encodings for assembler
1049 label names. For now, disable output of dbx info for them. */
1051 const char *ptr = IDENTIFIER_POINTER (type_encoding);
1052 /* This should use index. (mrs) */
1053 while (*ptr && *ptr != '<') ptr++;
1064 type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
1066 sprintf (formatted_type_identifier_length, "%d", type_identifier_length);
1068 if (TREE_CODE (methods) != TREE_VEC)
1070 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
1071 fndecl = TREE_VEC_ELT (methods, 0);
1073 fndecl = TREE_VEC_ELT (methods, 1);
1077 int need_prefix = 1;
1079 /* Group together all the methods for the same operation.
1080 These differ in the types of the arguments. */
1081 for (last = NULL_TREE;
1082 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
1083 fndecl = TREE_CHAIN (fndecl))
1084 /* Output the name of the field (after overloading), as
1085 well as the name of the field before overloading, along
1086 with its parameter list */
1088 /* This is the "mangled" name of the method.
1089 It encodes the argument types. */
1090 const char *debug_name;
1092 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1093 include TEMPLATE_DECLs.) The debugger doesn't know what
1094 to do with such entities anyhow. */
1095 if (TREE_CODE (fndecl) != FUNCTION_DECL)
1098 debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
1104 /* Also ignore abstract methods; those are only interesting to
1105 the DWARF backends. */
1106 if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT (fndecl))
1109 /* Redundantly output the plain name, since that's what gdb
1113 tree name = DECL_NAME (fndecl);
1114 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
1115 CHARS (IDENTIFIER_LENGTH (name) + 2);
1119 dbxout_type (TREE_TYPE (fndecl), 0);
1121 dbxout_type_method_1 (fndecl, debug_name);
1125 putc (';', asmfile);
1131 /* Emit a "range" type specification, which has the form:
1132 "r<index type>;<lower bound>;<upper bound>;".
1133 TYPE is an INTEGER_TYPE. */
1136 dbxout_range_type (tree type)
1138 fprintf (asmfile, "r");
1139 if (TREE_TYPE (type))
1140 dbxout_type (TREE_TYPE (type), 0);
1141 else if (TREE_CODE (type) != INTEGER_TYPE)
1142 dbxout_type (type, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1145 /* Traditionally, we made sure 'int' was type 1, and builtin types
1146 were defined to be sub-ranges of int. Unfortunately, this
1147 does not allow us to distinguish true sub-ranges from integer
1148 types. So, instead we define integer (non-sub-range) types as
1149 sub-ranges of themselves. This matters for Chill. If this isn't
1150 a subrange type, then we want to define it in terms of itself.
1151 However, in C, this may be an anonymous integer type, and we don't
1152 want to emit debug info referring to it. Just calling
1153 dbxout_type_index won't work anyways, because the type hasn't been
1154 defined yet. We make this work for both cases by checked to see
1155 whether this is a defined type, referring to it if it is, and using
1157 if (TYPE_SYMTAB_ADDRESS (type) != 0)
1158 dbxout_type_index (type);
1160 dbxout_type_index (integer_type_node);
1163 if (TYPE_MIN_VALUE (type) != 0
1164 && host_integerp (TYPE_MIN_VALUE (type), 0))
1166 putc (';', asmfile);
1168 if (print_int_cst_bounds_in_octal_p (type))
1169 print_int_cst_octal (TYPE_MIN_VALUE (type));
1171 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type), 0));
1175 fprintf (asmfile, ";0");
1179 if (TYPE_MAX_VALUE (type) != 0
1180 && host_integerp (TYPE_MAX_VALUE (type), 0))
1182 putc (';', asmfile);
1184 if (print_int_cst_bounds_in_octal_p (type))
1185 print_int_cst_octal (TYPE_MAX_VALUE (type));
1187 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type), 0));
1188 putc (';', asmfile);
1193 fprintf (asmfile, ";-1;");
1199 /* Output a reference to a type. If the type has not yet been
1200 described in the dbx output, output its definition now.
1201 For a type already defined, just refer to its definition
1202 using the type number.
1204 If FULL is nonzero, and the type has been described only with
1205 a forward-reference, output the definition now.
1206 If FULL is zero in this case, just refer to the forward-reference
1207 using the number previously allocated. */
1210 dbxout_type (tree type, int full)
1214 static int anonymous_type_number = 0;
1216 if (TREE_CODE (type) == VECTOR_TYPE)
1217 /* The frontend feeds us a representation for the vector as a struct
1218 containing an array. Pull out the array type. */
1219 type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type)));
1221 /* If there was an input error and we don't really have a type,
1222 avoid crashing and write something that is at least valid
1223 by assuming `int'. */
1224 if (type == error_mark_node)
1225 type = integer_type_node;
1228 if (TYPE_NAME (type)
1229 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1230 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1234 /* Try to find the "main variant" with the same name. */
1235 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1236 && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1237 main_variant = TREE_TYPE (TYPE_NAME (type));
1239 main_variant = TYPE_MAIN_VARIANT (type);
1241 /* If we are not using extensions, stabs does not distinguish const and
1242 volatile, so there is no need to make them separate types. */
1243 if (!use_gnu_debug_info_extensions)
1244 type = main_variant;
1246 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1248 /* Type has no dbx number assigned. Assign next available number. */
1249 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1251 /* Make sure type vector is long enough to record about this type. */
1253 if (next_type_number == typevec_len)
1256 = (struct typeinfo *) ggc_realloc (typevec,
1258 * sizeof typevec[0]));
1259 memset ((char *) (typevec + typevec_len), 0,
1260 typevec_len * sizeof typevec[0]);
1264 #ifdef DBX_USE_BINCL
1265 emit_pending_bincls_if_required ();
1266 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1267 = current_file->file_number;
1268 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1269 = current_file->next_type_number++;
1273 if (flag_debug_only_used_symbols)
1275 if ((TREE_CODE (type) == RECORD_TYPE
1276 || TREE_CODE (type) == UNION_TYPE
1277 || TREE_CODE (type) == QUAL_UNION_TYPE
1278 || TREE_CODE (type) == ENUMERAL_TYPE)
1279 && TYPE_STUB_DECL (type)
1280 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (type))) == 'd'
1281 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type)))
1282 debug_queue_symbol (TYPE_STUB_DECL (type));
1283 else if (TYPE_NAME (type)
1284 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1285 debug_queue_symbol (TYPE_NAME (type));
1288 /* Output the number of this type, to refer to it. */
1289 dbxout_type_index (type);
1291 #ifdef DBX_TYPE_DEFINED
1292 if (DBX_TYPE_DEFINED (type))
1296 /* If this type's definition has been output or is now being output,
1299 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1304 /* If we have already had a cross reference,
1305 and either that's all we want or that's the best we could do,
1306 don't repeat the cross reference.
1307 Sun dbx crashes if we do. */
1308 if (! full || !COMPLETE_TYPE_P (type)
1309 /* No way in DBX fmt to describe a variable size. */
1310 || ! host_integerp (TYPE_SIZE (type), 1))
1318 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1319 leave the type-number completely undefined rather than output
1320 a cross-reference. If we have already used GNU debug info extensions,
1321 then it is OK to output a cross reference. This is necessary to get
1322 proper C++ debug output. */
1323 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1324 || TREE_CODE (type) == QUAL_UNION_TYPE
1325 || TREE_CODE (type) == ENUMERAL_TYPE)
1326 && ! use_gnu_debug_info_extensions)
1327 /* We must use the same test here as we use twice below when deciding
1328 whether to emit a cross-reference. */
1329 if ((TYPE_NAME (type) != 0
1330 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1331 && DECL_IGNORED_P (TYPE_NAME (type)))
1333 || !COMPLETE_TYPE_P (type)
1334 /* No way in DBX fmt to describe a variable size. */
1335 || ! host_integerp (TYPE_SIZE (type), 1))
1337 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1342 /* Output a definition now. */
1344 fprintf (asmfile, "=");
1347 /* Mark it as defined, so that if it is self-referent
1348 we will not get into an infinite recursion of definitions. */
1350 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1352 /* If this type is a variant of some other, hand off. Types with
1353 different names are usefully distinguished. We only distinguish
1354 cv-qualified types if we're using extensions. */
1355 if (TYPE_READONLY (type) > TYPE_READONLY (main_variant))
1357 putc ('k', asmfile);
1359 dbxout_type (build_type_variant (type, 0, TYPE_VOLATILE (type)), 0);
1362 else if (TYPE_VOLATILE (type) > TYPE_VOLATILE (main_variant))
1364 putc ('B', asmfile);
1366 dbxout_type (build_type_variant (type, TYPE_READONLY (type), 0), 0);
1369 else if (main_variant != TYPE_MAIN_VARIANT (type))
1371 if (flag_debug_only_used_symbols)
1373 tree orig_type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
1375 if ((TREE_CODE (orig_type) == RECORD_TYPE
1376 || TREE_CODE (orig_type) == UNION_TYPE
1377 || TREE_CODE (orig_type) == QUAL_UNION_TYPE
1378 || TREE_CODE (orig_type) == ENUMERAL_TYPE)
1379 && TYPE_STUB_DECL (orig_type)
1380 && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type)))
1381 debug_queue_symbol (TYPE_STUB_DECL (orig_type));
1383 /* 'type' is a typedef; output the type it refers to. */
1384 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0);
1387 /* else continue. */
1389 switch (TREE_CODE (type))
1393 /* For a void type, just define it as itself; ie, "5=5".
1394 This makes us consider it defined
1395 without saying what it is. The debugger will make it
1396 a void type when the reference is seen, and nothing will
1397 ever override that default. */
1398 dbxout_type_index (type);
1402 if (type == char_type_node && ! TREE_UNSIGNED (type))
1404 /* Output the type `char' as a subrange of itself!
1405 I don't understand this definition, just copied it
1406 from the output of pcc.
1407 This used to use `r2' explicitly and we used to
1408 take care to make sure that `char' was type number 2. */
1409 fprintf (asmfile, "r");
1411 dbxout_type_index (type);
1412 fprintf (asmfile, ";0;127;");
1416 /* If this is a subtype of another integer type, always prefer to
1417 write it as a subtype. */
1418 else if (TREE_TYPE (type) != 0
1419 && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
1421 /* If the size is non-standard, say what it is if we can use
1424 if (use_gnu_debug_info_extensions
1425 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1427 have_used_extensions = 1;
1428 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1432 dbxout_range_type (type);
1437 /* If the size is non-standard, say what it is if we can use
1440 if (use_gnu_debug_info_extensions
1441 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1443 have_used_extensions = 1;
1444 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1448 if (print_int_cst_bounds_in_octal_p (type))
1450 fprintf (asmfile, "r");
1453 /* If this type derives from another type, output type index of
1454 parent type. This is particularly important when parent type
1455 is an enumerated type, because not generating the parent type
1456 index would transform the definition of this enumerated type
1457 into a plain unsigned type. */
1458 if (TREE_TYPE (type) != 0)
1459 dbxout_type_index (TREE_TYPE (type));
1461 dbxout_type_index (type);
1463 fprintf (asmfile, ";");
1465 print_int_cst_octal (TYPE_MIN_VALUE (type));
1466 fprintf (asmfile, ";");
1468 print_int_cst_octal (TYPE_MAX_VALUE (type));
1469 fprintf (asmfile, ";");
1474 /* Output other integer types as subranges of `int'. */
1475 dbxout_range_type (type);
1481 /* This used to say `r1' and we used to take care
1482 to make sure that `int' was type number 1. */
1483 fprintf (asmfile, "r");
1485 dbxout_type_index (integer_type_node);
1486 putc (';', asmfile);
1488 print_wide_int (int_size_in_bytes (type));
1489 fputs (";0;", asmfile);
1494 if (use_gnu_debug_info_extensions)
1496 have_used_extensions = 1;
1497 fputs ("@s", asmfile);
1499 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1500 fputs (";-20;", asmfile);
1505 /* Output the type `char' as a subrange of itself.
1506 That is what pcc seems to do. */
1507 fprintf (asmfile, "r");
1509 dbxout_type_index (char_type_node);
1510 fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1516 if (use_gnu_debug_info_extensions)
1518 have_used_extensions = 1;
1519 fputs ("@s", asmfile);
1521 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1522 fputs (";-16;", asmfile);
1525 else /* Define as enumeral type (False, True) */
1527 fprintf (asmfile, "eFalse:0,True:1,;");
1533 putc ('d', asmfile);
1535 dbxout_type (TREE_TYPE (type), 0);
1539 /* Differs from the REAL_TYPE by its new data type number */
1541 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1543 putc ('R', asmfile);
1545 dbxout_fptype_value (type);
1546 putc (';', asmfile);
1548 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type)));
1549 fputs (";0;", asmfile);
1554 /* Output a complex integer type as a structure,
1555 pending some other way to do it. */
1556 putc ('s', asmfile);
1558 print_wide_int (int_size_in_bytes (type));
1559 fprintf (asmfile, "real:");
1562 dbxout_type (TREE_TYPE (type), 0);
1563 fprintf (asmfile, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type)));
1565 fprintf (asmfile, "imag:");
1567 dbxout_type (TREE_TYPE (type), 0);
1568 fprintf (asmfile, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type)),
1569 TYPE_PRECISION (TREE_TYPE (type)));
1575 if (use_gnu_debug_info_extensions)
1577 have_used_extensions = 1;
1578 fputs ("@s", asmfile);
1580 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1581 putc (';', asmfile);
1584 /* Check if a bitstring type, which in Chill is
1585 different from a [power]set. */
1586 if (TYPE_STRING_FLAG (type))
1588 fprintf (asmfile, "@S;");
1592 putc ('S', asmfile);
1594 dbxout_type (TYPE_DOMAIN (type), 0);
1598 /* Make arrays of packed bits look like bitstrings for chill. */
1599 if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
1601 have_used_extensions = 1;
1602 fputs ("@s", asmfile);
1604 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1605 fprintf (asmfile, ";@S;S");
1607 dbxout_type (TYPE_DOMAIN (type), 0);
1611 /* Output "a" followed by a range type definition
1612 for the index type of the array
1613 followed by a reference to the target-type.
1614 ar1;0;N;M for a C array of type M and size N+1. */
1615 /* Check if a character string type, which in Chill is
1616 different from an array of characters. */
1617 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1619 have_used_extensions = 1;
1620 fprintf (asmfile, "@S;");
1623 tem = TYPE_DOMAIN (type);
1626 fprintf (asmfile, "ar");
1628 dbxout_type_index (integer_type_node);
1629 fprintf (asmfile, ";0;-1;");
1634 fprintf (asmfile, "a");
1636 dbxout_range_type (tem);
1639 dbxout_type (TREE_TYPE (type), 0);
1644 case QUAL_UNION_TYPE:
1646 int i, n_baseclasses = 0;
1648 if (TYPE_BINFO (type) != 0
1649 && TREE_CODE (TYPE_BINFO (type)) == TREE_VEC
1650 && TYPE_BINFO_BASETYPES (type) != 0)
1651 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1653 /* Output a structure type. We must use the same test here as we
1654 use in the DBX_NO_XREFS case above. */
1655 if ((TYPE_NAME (type) != 0
1656 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1657 && DECL_IGNORED_P (TYPE_NAME (type)))
1659 || !COMPLETE_TYPE_P (type)
1660 /* No way in DBX fmt to describe a variable size. */
1661 || ! host_integerp (TYPE_SIZE (type), 1))
1663 /* If the type is just a cross reference, output one
1664 and mark the type as partially described.
1665 If it later becomes defined, we will output
1666 its real definition.
1667 If the type has a name, don't nest its definition within
1668 another type's definition; instead, output an xref
1669 and let the definition come when the name is defined. */
1670 fputs ((TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu", asmfile);
1672 #if 0 /* This assertion is legitimately false in C++. */
1673 /* We shouldn't be outputting a reference to a type before its
1674 definition unless the type has a tag name.
1675 A typedef name without a tag name should be impossible. */
1676 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1679 if (TYPE_NAME (type) != 0)
1680 dbxout_type_name (type);
1683 fprintf (asmfile, "$$%d", anonymous_type_number++);
1687 fprintf (asmfile, ":");
1689 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1693 /* Identify record or union, and print its size. */
1694 putc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asmfile);
1696 print_wide_int (int_size_in_bytes (type));
1698 if (use_gnu_debug_info_extensions)
1702 have_used_extensions = 1;
1703 fprintf (asmfile, "!%d,", n_baseclasses);
1707 for (i = 0; i < n_baseclasses; i++)
1709 tree binfo = TYPE_BINFO (type);
1710 tree child = BINFO_BASETYPE (binfo, i);
1711 tree access = (BINFO_BASEACCESSES (binfo)
1712 ? BINFO_BASEACCESS (binfo, i) : access_public_node);
1714 if (use_gnu_debug_info_extensions)
1716 have_used_extensions = 1;
1717 putc (TREE_VIA_VIRTUAL (child) ? '1' : '0', asmfile);
1718 putc (access == access_public_node ? '2' : '0', asmfile);
1720 if (TREE_VIA_VIRTUAL (child)
1721 && strcmp (lang_hooks.name, "GNU C++") == 0)
1722 /* For a virtual base, print the (negative) offset within
1723 the vtable where we must look to find the necessary
1725 print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child), 0)
1728 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1730 putc (',', asmfile);
1732 dbxout_type (BINFO_TYPE (child), 0);
1733 putc (';', asmfile);
1738 /* Print out the base class information with fields
1739 which have the same names at the types they hold. */
1740 dbxout_type_name (BINFO_TYPE (child));
1741 putc (':', asmfile);
1743 dbxout_type (BINFO_TYPE (child), full);
1744 putc (',', asmfile);
1746 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1748 putc (',', asmfile);
1750 print_wide_int (tree_low_cst (DECL_SIZE
1752 (BINFO_TYPE (child))),
1755 putc (';', asmfile);
1761 /* Write out the field declarations. */
1762 dbxout_type_fields (type);
1763 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1765 have_used_extensions = 1;
1766 dbxout_type_methods (type);
1769 putc (';', asmfile);
1772 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1773 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1774 && TYPE_VFIELD (type))
1776 have_used_extensions = 1;
1778 /* Tell GDB+ that it may keep reading. */
1779 putc ('~', asmfile);
1782 /* We need to write out info about what field this class
1783 uses as its "main" vtable pointer field, because if this
1784 field is inherited from a base class, GDB cannot necessarily
1785 figure out which field it's using in time. */
1786 if (TYPE_VFIELD (type))
1788 putc ('%', asmfile);
1790 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0);
1793 putc (';', asmfile);
1799 /* We must use the same test here as we use in the DBX_NO_XREFS case
1800 above. We simplify it a bit since an enum will never have a variable
1802 if ((TYPE_NAME (type) != 0
1803 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1804 && DECL_IGNORED_P (TYPE_NAME (type)))
1806 || !COMPLETE_TYPE_P (type))
1808 fprintf (asmfile, "xe");
1810 dbxout_type_name (type);
1811 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1812 putc (':', asmfile);
1816 if (use_gnu_debug_info_extensions
1817 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1819 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1823 putc ('e', asmfile);
1825 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1827 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1828 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem)) + 1);
1829 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1830 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1831 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1832 && (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1833 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1835 print_int_cst_octal (TREE_VALUE (tem));
1837 putc (',', asmfile);
1839 if (TREE_CHAIN (tem) != 0)
1843 putc (';', asmfile);
1848 putc ('*', asmfile);
1850 dbxout_type (TREE_TYPE (type), 0);
1854 if (use_gnu_debug_info_extensions)
1856 have_used_extensions = 1;
1857 putc ('#', asmfile);
1860 /* Write the argument types out longhand. */
1861 dbxout_type (TYPE_METHOD_BASETYPE (type), 0);
1862 putc (',', asmfile);
1864 dbxout_type (TREE_TYPE (type), 0);
1865 dbxout_args (TYPE_ARG_TYPES (type));
1866 putc (';', asmfile);
1870 /* Treat it as a function type. */
1871 dbxout_type (TREE_TYPE (type), 0);
1875 if (use_gnu_debug_info_extensions)
1877 have_used_extensions = 1;
1878 putc ('@', asmfile);
1880 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0);
1881 putc (',', asmfile);
1883 dbxout_type (TREE_TYPE (type), 0);
1886 /* Should print as an int, because it is really just an offset. */
1887 dbxout_type (integer_type_node, 0);
1890 case REFERENCE_TYPE:
1891 if (use_gnu_debug_info_extensions)
1892 have_used_extensions = 1;
1893 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1895 dbxout_type (TREE_TYPE (type), 0);
1899 putc ('f', asmfile);
1901 dbxout_type (TREE_TYPE (type), 0);
1909 /* Return nonzero if the given type represents an integer whose bounds
1910 should be printed in octal format. */
1913 print_int_cst_bounds_in_octal_p (tree type)
1915 /* If we can use GDB extensions and the size is wider than a long
1916 (the size used by GDB to read them) or we may have trouble writing
1917 the bounds the usual way, write them in octal. Note the test is for
1918 the *target's* size of "long", not that of the host. The host test
1919 is just to make sure we can write it out in case the host wide int
1920 is narrower than the target "long".
1922 For unsigned types, we use octal if they are the same size or larger.
1923 This is because we print the bounds as signed decimal, and hence they
1924 can't span same size unsigned types. */
1926 if (use_gnu_debug_info_extensions
1927 && TYPE_MIN_VALUE (type) != 0
1928 && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
1929 && TYPE_MAX_VALUE (type) != 0
1930 && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
1931 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1932 || ((TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
1933 && TREE_UNSIGNED (type))
1934 || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT
1935 || (TYPE_PRECISION (type) == HOST_BITS_PER_WIDE_INT
1936 && TREE_UNSIGNED (type))))
1942 /* Print the value of integer constant C, in octal,
1943 handling double precision. */
1946 print_int_cst_octal (tree c)
1948 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1949 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1950 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1951 unsigned int width = TYPE_PRECISION (TREE_TYPE (c));
1953 /* GDB wants constants with no extra leading "1" bits, so
1954 we need to remove any sign-extension that might be
1956 if (width == HOST_BITS_PER_WIDE_INT * 2)
1958 else if (width > HOST_BITS_PER_WIDE_INT)
1959 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1960 else if (width == HOST_BITS_PER_WIDE_INT)
1963 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1965 fprintf (asmfile, "0");
1970 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1971 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1975 unsigned HOST_WIDE_INT beg = high >> excess;
1976 unsigned HOST_WIDE_INT middle
1977 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1978 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1979 unsigned HOST_WIDE_INT end
1980 = low & (((unsigned HOST_WIDE_INT) 1
1981 << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1984 fprintf (asmfile, "%o%01o", (int) beg, (int) middle);
1986 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1991 print_octal (unsigned HOST_WIDE_INT value, int digits)
1995 for (i = digits - 1; i >= 0; i--)
1996 fprintf (asmfile, "%01o", (int) ((value >> (3 * i)) & 7));
2001 /* Output C in decimal while adjusting the number of digits written. */
2004 print_wide_int (HOST_WIDE_INT c)
2008 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, c);
2019 /* Output the name of type TYPE, with no punctuation.
2020 Such names can be set up either by typedef declarations
2021 or by struct, enum and union tags. */
2024 dbxout_type_name (tree type)
2027 if (TYPE_NAME (type) == 0)
2029 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
2031 t = TYPE_NAME (type);
2033 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
2035 t = DECL_NAME (TYPE_NAME (type));
2040 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
2041 CHARS (IDENTIFIER_LENGTH (t));
2044 /* Output leading leading struct or class names needed for qualifying
2045 type whose scope is limited to a struct or class. */
2048 dbxout_class_name_qualifiers (tree decl)
2050 tree context = decl_type_context (decl);
2052 if (context != NULL_TREE
2053 && TREE_CODE(context) == RECORD_TYPE
2054 && TYPE_NAME (context) != 0
2055 && (TREE_CODE (TYPE_NAME (context)) == IDENTIFIER_NODE
2056 || (DECL_NAME (TYPE_NAME (context)) != 0)))
2058 tree name = TYPE_NAME (context);
2060 emit_pending_bincls_if_required ();
2062 if (TREE_CODE (name) == TYPE_DECL)
2064 dbxout_class_name_qualifiers (name);
2065 name = DECL_NAME (name);
2067 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
2068 CHARS (IDENTIFIER_LENGTH (name) + 2);
2072 /* Output a .stabs for the symbol defined by DECL,
2073 which must be a ..._DECL node in the normal namespace.
2074 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
2075 LOCAL is nonzero if the scope is less than the entire file.
2076 Return 1 if a stabs might have been emitted. */
2079 dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
2081 tree type = TREE_TYPE (decl);
2082 tree context = NULL_TREE;
2085 /* "Intercept" dbxout_symbol() calls like we do all debug_hooks. */
2088 /* Cast avoids warning in old compilers. */
2089 current_sym_code = (STAB_CODE_TYPE) 0;
2090 current_sym_value = 0;
2091 current_sym_addr = 0;
2093 /* Ignore nameless syms, but don't ignore type tags. */
2095 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
2096 || DECL_IGNORED_P (decl))
2097 DBXOUT_DECR_NESTING_AND_RETURN (0);
2099 /* If we are to generate only the symbols actually used then such
2100 symbol nodees are flagged with TREE_USED. Ignore any that
2101 aren't flaged as TREE_USED. */
2103 if (flag_debug_only_used_symbols)
2107 if (!TREE_USED (decl)
2108 && (TREE_CODE (decl) != VAR_DECL || !DECL_INITIAL (decl)))
2109 DBXOUT_DECR_NESTING_AND_RETURN (0);
2111 /* We now have a used symbol. We need to generate the info for
2112 the symbol's type in addition to the symbol itself. These
2113 type symbols are queued to be generated after were done with
2114 the symbol itself (done because the symbol's info is generated
2115 with fprintf's, etc. as it determines what's needed).
2117 Note, because the TREE_TYPE(type) might be something like a
2118 pointer to a named type we need to look for the first name
2119 we see following the TREE_TYPE chain. */
2122 while (POINTER_TYPE_P (t))
2125 /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE
2126 need special treatment. The TYPE_STUB_DECL field in these
2127 types generally represents the tag name type we want to
2128 output. In addition there could be a typedef type with
2129 a different name. In that case we also want to output
2132 if ((TREE_CODE (t) == RECORD_TYPE
2133 || TREE_CODE (t) == UNION_TYPE
2134 || TREE_CODE (t) == QUAL_UNION_TYPE
2135 || TREE_CODE (t) == ENUMERAL_TYPE)
2136 && TYPE_STUB_DECL (t)
2137 && TYPE_STUB_DECL (t) != decl
2138 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (t))) == 'd'
2139 && ! DECL_IGNORED_P (TYPE_STUB_DECL (t)))
2141 debug_queue_symbol (TYPE_STUB_DECL (t));
2143 && TYPE_NAME (t) != TYPE_STUB_DECL (t)
2144 && TYPE_NAME (t) != decl
2145 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t))) == 'd')
2146 debug_queue_symbol (TYPE_NAME (t));
2148 else if (TYPE_NAME (t)
2149 && TYPE_NAME (t) != decl
2150 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t))) == 'd')
2151 debug_queue_symbol (TYPE_NAME (t));
2154 emit_pending_bincls_if_required ();
2156 dbxout_prepare_symbol (decl);
2158 /* The output will always start with the symbol name,
2159 so always count that in the length-output-so-far. */
2161 if (DECL_NAME (decl) != 0)
2162 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
2164 switch (TREE_CODE (decl))
2167 /* Enum values are defined by defining the enum type. */
2171 if (DECL_RTL (decl) == 0)
2172 DBXOUT_DECR_NESTING_AND_RETURN (0);
2173 if (DECL_EXTERNAL (decl))
2175 /* Don't mention a nested function under its parent. */
2176 context = decl_function_context (decl);
2177 if (context == current_function_decl)
2179 if (GET_CODE (DECL_RTL (decl)) != MEM
2180 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
2184 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2185 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
2186 TREE_PUBLIC (decl) ? 'F' : 'f');
2189 current_sym_code = N_FUN;
2190 current_sym_addr = XEXP (DECL_RTL (decl), 0);
2192 if (TREE_TYPE (type))
2193 dbxout_type (TREE_TYPE (type), 0);
2195 dbxout_type (void_type_node, 0);
2197 /* For a nested function, when that function is compiled,
2198 mention the containing function name
2199 as well as (since dbx wants it) our own assembler-name. */
2201 fprintf (asmfile, ",%s,%s",
2202 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
2203 IDENTIFIER_POINTER (DECL_NAME (context)));
2205 dbxout_finish_symbol (decl);
2209 /* Don't output the same typedef twice.
2210 And don't output what language-specific stuff doesn't want output. */
2211 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
2212 DBXOUT_DECR_NESTING_AND_RETURN (0);
2220 if (DECL_NAME (decl))
2222 /* Nonzero means we must output a tag as well as a typedef. */
2225 /* Handle the case of a C++ structure or union
2226 where the TYPE_NAME is a TYPE_DECL
2227 which gives both a typedef name and a tag. */
2228 /* dbx requires the tag first and the typedef second. */
2229 if ((TREE_CODE (type) == RECORD_TYPE
2230 || TREE_CODE (type) == UNION_TYPE
2231 || TREE_CODE (type) == QUAL_UNION_TYPE)
2232 && TYPE_NAME (type) == decl
2233 && !(use_gnu_debug_info_extensions && have_used_extensions)
2234 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
2235 /* Distinguish the implicit typedefs of C++
2236 from explicit ones that might be found in C. */
2237 && DECL_ARTIFICIAL (decl)
2238 /* Do not generate a tag for incomplete records. */
2239 && COMPLETE_TYPE_P (type)
2240 /* Do not generate a tag for records of variable size,
2241 since this type can not be properly described in the
2242 DBX format, and it confuses some tools such as objdump. */
2243 && host_integerp (TYPE_SIZE (type), 1))
2245 tree name = TYPE_NAME (type);
2246 if (TREE_CODE (name) == TYPE_DECL)
2247 name = DECL_NAME (name);
2249 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2250 current_sym_value = 0;
2251 current_sym_addr = 0;
2252 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2254 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
2255 IDENTIFIER_POINTER (name));
2256 dbxout_type (type, 1);
2257 dbxout_finish_symbol (NULL_TREE);
2260 /* Output .stabs (or whatever) and leading double quote. */
2261 fprintf (asmfile, "%s\"", ASM_STABS_OP);
2263 if (use_gnu_debug_info_extensions)
2265 /* Output leading class/struct qualifiers. */
2266 dbxout_class_name_qualifiers (decl);
2269 /* Output typedef name. */
2270 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl)));
2272 /* Short cut way to output a tag also. */
2273 if ((TREE_CODE (type) == RECORD_TYPE
2274 || TREE_CODE (type) == UNION_TYPE
2275 || TREE_CODE (type) == QUAL_UNION_TYPE)
2276 && TYPE_NAME (type) == decl
2277 /* Distinguish the implicit typedefs of C++
2278 from explicit ones that might be found in C. */
2279 && DECL_ARTIFICIAL (decl))
2281 if (use_gnu_debug_info_extensions && have_used_extensions)
2283 putc ('T', asmfile);
2284 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
2286 #if 0 /* Now we generate the tag for this case up above. */
2292 putc ('t', asmfile);
2293 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2295 dbxout_type (type, 1);
2296 dbxout_finish_symbol (decl);
2300 /* Don't output a tag if this is an incomplete type. This prevents
2301 the sun4 Sun OS 4.x dbx from crashing. */
2303 if (tag_needed && TYPE_NAME (type) != 0
2304 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
2305 || (DECL_NAME (TYPE_NAME (type)) != 0))
2306 && COMPLETE_TYPE_P (type)
2307 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
2309 /* For a TYPE_DECL with no name, but the type has a name,
2311 This is what represents `struct foo' with no typedef. */
2312 /* In C++, the name of a type is the corresponding typedef.
2313 In C, it is an IDENTIFIER_NODE. */
2314 tree name = TYPE_NAME (type);
2315 if (TREE_CODE (name) == TYPE_DECL)
2316 name = DECL_NAME (name);
2318 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2319 current_sym_value = 0;
2320 current_sym_addr = 0;
2321 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2323 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
2324 IDENTIFIER_POINTER (name));
2325 dbxout_type (type, 1);
2326 dbxout_finish_symbol (NULL_TREE);
2330 /* If an enum type has no name, it cannot be referred to,
2331 but we must output it anyway, since the enumeration constants
2332 can be referred to. */
2333 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
2335 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2336 current_sym_value = 0;
2337 current_sym_addr = 0;
2338 current_sym_nchars = 2;
2340 /* Some debuggers fail when given NULL names, so give this a
2341 harmless name of ` '. */
2342 fprintf (asmfile, "%s\" :T", ASM_STABS_OP);
2343 dbxout_type (type, 1);
2344 dbxout_finish_symbol (NULL_TREE);
2347 /* Prevent duplicate output of a typedef. */
2348 TREE_ASM_WRITTEN (decl) = 1;
2353 /* Parm decls go in their own separate chains
2354 and are output by dbxout_reg_parms and dbxout_parms. */
2358 /* Named return value, treat like a VAR_DECL. */
2360 if (! DECL_RTL_SET_P (decl))
2361 DBXOUT_DECR_NESTING_AND_RETURN (0);
2362 /* Don't mention a variable that is external.
2363 Let the file that defines it describe it. */
2364 if (DECL_EXTERNAL (decl))
2367 /* If the variable is really a constant
2368 and not written in memory, inform the debugger. */
2369 if (TREE_STATIC (decl) && TREE_READONLY (decl)
2370 && DECL_INITIAL (decl) != 0
2371 && host_integerp (DECL_INITIAL (decl), 0)
2372 && ! TREE_ASM_WRITTEN (decl)
2373 && (DECL_CONTEXT (decl) == NULL_TREE
2374 || TREE_CODE (DECL_CONTEXT (decl)) == BLOCK))
2376 if (TREE_PUBLIC (decl) == 0)
2378 /* The sun4 assembler does not grok this. */
2379 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
2381 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
2382 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
2384 HOST_WIDE_INT ival = tree_low_cst (DECL_INITIAL (decl), 0);
2385 fprintf (asmfile, "%s\"%s:c=i" HOST_WIDE_INT_PRINT_DEC
2387 ASM_STABS_OP, name, ival, N_LSYM);
2388 DBXOUT_DECR_NESTING;
2391 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
2393 /* don't know how to do this yet. */
2397 /* else it is something we handle like a normal variable. */
2400 SET_DECL_RTL (decl, eliminate_regs (DECL_RTL (decl), 0, NULL_RTX));
2401 #ifdef LEAF_REG_REMAP
2402 if (current_function_uses_only_leaf_regs)
2403 leaf_renumber_regs_insn (DECL_RTL (decl));
2406 result = dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
2412 DBXOUT_DECR_NESTING;
2416 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2417 Add SUFFIX to its name, if SUFFIX is not 0.
2418 Describe the variable as residing in HOME
2419 (usually HOME is DECL_RTL (DECL), but not always).
2420 Returns 1 if the stab was really emitted. */
2423 dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
2428 emit_pending_bincls_if_required ();
2430 /* Don't mention a variable at all
2431 if it was completely optimized into nothingness.
2433 If the decl was from an inline function, then its rtl
2434 is not identically the rtl that was used in this
2435 particular compilation. */
2436 if (GET_CODE (home) == SUBREG)
2440 while (GET_CODE (value) == SUBREG)
2441 value = SUBREG_REG (value);
2442 if (GET_CODE (value) == REG)
2444 if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
2447 home = alter_subreg (&home);
2449 if (GET_CODE (home) == REG)
2451 regno = REGNO (home);
2452 if (regno >= FIRST_PSEUDO_REGISTER)
2456 /* The kind-of-variable letter depends on where
2457 the variable is and on the scope of its name:
2458 G and N_GSYM for static storage and global scope,
2459 S for static storage and file scope,
2460 V for static storage and local scope,
2461 for those two, use N_LCSYM if data is in bss segment,
2462 N_STSYM if in data segment, N_FUN otherwise.
2463 (We used N_FUN originally, then changed to N_STSYM
2464 to please GDB. However, it seems that confused ld.
2465 Now GDB has been fixed to like N_FUN, says Kingdon.)
2466 no letter at all, and N_LSYM, for auto variable,
2467 r and N_RSYM for register variable. */
2469 if (GET_CODE (home) == MEM
2470 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
2472 if (TREE_PUBLIC (decl))
2475 current_sym_code = N_GSYM;
2479 current_sym_addr = XEXP (home, 0);
2481 letter = decl_function_context (decl) ? 'V' : 'S';
2483 /* This should be the same condition as in assemble_variable, but
2484 we don't have access to dont_output_data here. So, instead,
2485 we rely on the fact that error_mark_node initializers always
2486 end up in bss for C++ and never end up in bss for C. */
2487 if (DECL_INITIAL (decl) == 0
2488 || (!strcmp (lang_hooks.name, "GNU C++")
2489 && DECL_INITIAL (decl) == error_mark_node))
2490 current_sym_code = N_LCSYM;
2491 else if (DECL_IN_TEXT_SECTION (decl))
2492 /* This is not quite right, but it's the closest
2493 of all the codes that Unix defines. */
2494 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
2497 /* Some ports can transform a symbol ref into a label ref,
2498 because the symbol ref is too far away and has to be
2499 dumped into a constant pool. Alternatively, the symbol
2500 in the constant pool might be referenced by a different
2502 if (GET_CODE (current_sym_addr) == SYMBOL_REF
2503 && CONSTANT_POOL_ADDRESS_P (current_sym_addr))
2505 rtx tmp = get_pool_constant (current_sym_addr);
2507 if (GET_CODE (tmp) == SYMBOL_REF
2508 || GET_CODE (tmp) == LABEL_REF)
2509 current_sym_addr = tmp;
2512 /* Ultrix `as' seems to need this. */
2513 #ifdef DBX_STATIC_STAB_DATA_SECTION
2516 current_sym_code = N_STSYM;
2520 else if (regno >= 0)
2523 current_sym_code = N_RSYM;
2524 current_sym_value = DBX_REGISTER_NUMBER (regno);
2526 else if (GET_CODE (home) == MEM
2527 && (GET_CODE (XEXP (home, 0)) == MEM
2528 || (GET_CODE (XEXP (home, 0)) == REG
2529 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
2530 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
2531 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2532 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
2535 /* If the value is indirect by memory or by a register
2536 that isn't the frame pointer
2537 then it means the object is variable-sized and address through
2538 that register or stack slot. DBX has no way to represent this
2539 so all we can do is output the variable as a pointer.
2540 If it's not a parameter, ignore it.
2541 (VAR_DECLs like this can be made by integrate.c.) */
2543 if (GET_CODE (XEXP (home, 0)) == REG)
2546 current_sym_code = N_RSYM;
2547 if (REGNO (XEXP (home, 0)) >= FIRST_PSEUDO_REGISTER)
2549 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2553 current_sym_code = N_LSYM;
2554 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2555 We want the value of that CONST_INT. */
2557 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2560 /* Effectively do build_pointer_type, but don't cache this type,
2561 since it might be temporary whereas the type it points to
2562 might have been saved for inlining. */
2563 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2564 type = make_node (POINTER_TYPE);
2565 TREE_TYPE (type) = TREE_TYPE (decl);
2567 else if (GET_CODE (home) == MEM
2568 && GET_CODE (XEXP (home, 0)) == REG)
2570 current_sym_code = N_LSYM;
2571 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2573 else if (GET_CODE (home) == MEM
2574 && GET_CODE (XEXP (home, 0)) == PLUS
2575 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2577 current_sym_code = N_LSYM;
2578 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2579 We want the value of that CONST_INT. */
2580 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2582 else if (GET_CODE (home) == MEM
2583 && GET_CODE (XEXP (home, 0)) == CONST)
2585 /* Handle an obscure case which can arise when optimizing and
2586 when there are few available registers. (This is *always*
2587 the case for i386/i486 targets). The RTL looks like
2588 (MEM (CONST ...)) even though this variable is a local `auto'
2589 or a local `register' variable. In effect, what has happened
2590 is that the reload pass has seen that all assignments and
2591 references for one such a local variable can be replaced by
2592 equivalent assignments and references to some static storage
2593 variable, thereby avoiding the need for a register. In such
2594 cases we're forced to lie to debuggers and tell them that
2595 this variable was itself `static'. */
2596 current_sym_code = N_LCSYM;
2598 current_sym_addr = XEXP (XEXP (home, 0), 0);
2600 else if (GET_CODE (home) == CONCAT)
2604 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2605 for example), then there is no easy way to figure out
2606 what SUBTYPE should be. So, we give up. */
2607 if (TREE_CODE (type) != COMPLEX_TYPE)
2610 subtype = TREE_TYPE (type);
2612 /* If the variable's storage is in two parts,
2613 output each as a separate stab with a modified name. */
2614 if (WORDS_BIG_ENDIAN)
2615 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2617 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2619 /* Cast avoids warning in old compilers. */
2620 current_sym_code = (STAB_CODE_TYPE) 0;
2621 current_sym_value = 0;
2622 current_sym_addr = 0;
2623 dbxout_prepare_symbol (decl);
2625 if (WORDS_BIG_ENDIAN)
2626 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2628 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2632 /* Address might be a MEM, when DECL is a variable-sized object.
2633 Or it might be const0_rtx, meaning previous passes
2634 want us to ignore this variable. */
2637 /* Ok, start a symtab entry and output the variable name. */
2640 #ifdef DBX_STATIC_BLOCK_START
2641 DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2644 dbxout_symbol_name (decl, suffix, letter);
2645 dbxout_type (type, 0);
2646 dbxout_finish_symbol (decl);
2648 #ifdef DBX_STATIC_BLOCK_END
2649 DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2654 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2655 Then output LETTER to indicate the kind of location the symbol has. */
2658 dbxout_symbol_name (tree decl, const char *suffix, int letter)
2662 if (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl)))
2663 /* One slight hitch: if this is a VAR_DECL which is a static
2664 class member, we must put out the mangled name instead of the
2665 DECL_NAME. Note also that static member (variable) names DO NOT begin
2666 with underscores in .stabs directives. */
2667 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2669 /* ...but if we're function-local, we don't want to include the junk
2670 added by ASM_FORMAT_PRIVATE_NAME. */
2671 name = IDENTIFIER_POINTER (DECL_NAME (decl));
2675 fprintf (asmfile, "%s\"%s%s:", ASM_STABS_OP, name,
2676 (suffix ? suffix : ""));
2679 putc (letter, asmfile);
2683 dbxout_prepare_symbol (tree decl ATTRIBUTE_UNUSED)
2686 const char *filename = DECL_SOURCE_FILE (decl);
2688 dbxout_source_file (asmfile, filename);
2693 dbxout_finish_symbol (tree sym)
2695 #ifdef DBX_FINISH_SYMBOL
2696 DBX_FINISH_SYMBOL (sym);
2699 if (use_gnu_debug_info_extensions && sym != 0)
2700 line = DECL_SOURCE_LINE (sym);
2702 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2703 if (current_sym_addr)
2704 output_addr_const (asmfile, current_sym_addr);
2706 fprintf (asmfile, "%d", current_sym_value);
2707 putc ('\n', asmfile);
2711 /* Output definitions of all the decls in a chain. Return nonzero if
2712 anything was output */
2715 dbxout_syms (tree syms)
2720 result += dbxout_symbol (syms, 1);
2721 syms = TREE_CHAIN (syms);
2726 /* The following two functions output definitions of function parameters.
2727 Each parameter gets a definition locating it in the parameter list.
2728 Each parameter that is a register variable gets a second definition
2729 locating it in the register.
2731 Printing or argument lists in gdb uses the definitions that
2732 locate in the parameter list. But reference to the variable in
2733 expressions uses preferentially the definition as a register. */
2735 /* Output definitions, referring to storage in the parmlist,
2736 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2739 dbxout_parms (tree parms)
2743 emit_pending_bincls_if_required ();
2745 for (; parms; parms = TREE_CHAIN (parms))
2746 if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2748 dbxout_prepare_symbol (parms);
2750 /* Perform any necessary register eliminations on the parameter's rtl,
2751 so that the debugging output will be accurate. */
2752 DECL_INCOMING_RTL (parms)
2753 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2754 SET_DECL_RTL (parms, eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
2755 #ifdef LEAF_REG_REMAP
2756 if (current_function_uses_only_leaf_regs)
2758 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2759 leaf_renumber_regs_insn (DECL_RTL (parms));
2763 if (PARM_PASSED_IN_MEMORY (parms))
2765 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2767 /* ??? Here we assume that the parm address is indexed
2768 off the frame pointer or arg pointer.
2769 If that is not true, we produce meaningless results,
2770 but do not crash. */
2771 if (GET_CODE (addr) == PLUS
2772 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2773 current_sym_value = INTVAL (XEXP (addr, 1));
2775 current_sym_value = 0;
2777 current_sym_code = N_PSYM;
2778 current_sym_addr = 0;
2781 if (DECL_NAME (parms))
2783 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2785 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2786 IDENTIFIER_POINTER (DECL_NAME (parms)),
2787 DBX_MEMPARM_STABS_LETTER);
2791 current_sym_nchars = 8;
2792 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2793 DBX_MEMPARM_STABS_LETTER);
2796 /* It is quite tempting to use:
2798 dbxout_type (TREE_TYPE (parms), 0);
2800 as the next statement, rather than using DECL_ARG_TYPE(), so
2801 that gcc reports the actual type of the parameter, rather
2802 than the promoted type. This certainly makes GDB's life
2803 easier, at least for some ports. The change is a bad idea
2804 however, since GDB expects to be able access the type without
2805 performing any conversions. So for example, if we were
2806 passing a float to an unprototyped function, gcc will store a
2807 double on the stack, but if we emit a stab saying the type is a
2808 float, then gdb will only read in a single value, and this will
2809 produce an erroneous value. */
2810 dbxout_type (DECL_ARG_TYPE (parms), 0);
2811 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2812 dbxout_finish_symbol (parms);
2814 else if (GET_CODE (DECL_RTL (parms)) == REG)
2817 char regparm_letter;
2819 /* Parm passed in registers and lives in registers or nowhere. */
2821 current_sym_code = DBX_REGPARM_STABS_CODE;
2822 regparm_letter = DBX_REGPARM_STABS_LETTER;
2823 current_sym_addr = 0;
2825 /* If parm lives in a register, use that register;
2826 pretend the parm was passed there. It would be more consistent
2827 to describe the register where the parm was passed,
2828 but in practice that register usually holds something else.
2830 If we use DECL_RTL, then we must use the declared type of
2831 the variable, not the type that it arrived in. */
2832 if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2834 best_rtl = DECL_RTL (parms);
2835 parm_type = TREE_TYPE (parms);
2837 /* If the parm lives nowhere, use the register where it was
2838 passed. It is also better to use the declared type here. */
2841 best_rtl = DECL_INCOMING_RTL (parms);
2842 parm_type = TREE_TYPE (parms);
2844 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2847 if (DECL_NAME (parms))
2849 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2850 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2851 IDENTIFIER_POINTER (DECL_NAME (parms)),
2856 current_sym_nchars = 8;
2857 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2861 dbxout_type (parm_type, 0);
2862 dbxout_finish_symbol (parms);
2864 else if (GET_CODE (DECL_RTL (parms)) == MEM
2865 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2866 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2867 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2868 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2869 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2873 /* Parm was passed via invisible reference.
2874 That is, its address was passed in a register.
2875 Output it as if it lived in that register.
2876 The debugger will know from the type
2877 that it was actually passed by invisible reference. */
2879 char regparm_letter;
2880 /* Parm passed in registers and lives in registers or nowhere. */
2882 current_sym_code = DBX_REGPARM_STABS_CODE;
2883 if (use_gnu_debug_info_extensions)
2884 regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2886 regparm_letter = DBX_REGPARM_STABS_LETTER;
2888 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2889 If it is an unallocated pseudo-reg, then use the register where
2890 it was passed instead. */
2891 if (REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2892 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2894 current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2896 current_sym_addr = 0;
2899 if (DECL_NAME (parms))
2902 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2904 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2905 IDENTIFIER_POINTER (DECL_NAME (parms)),
2910 current_sym_nchars = 8;
2911 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2915 dbxout_type (TREE_TYPE (parms), 0);
2916 dbxout_finish_symbol (parms);
2918 else if (GET_CODE (DECL_RTL (parms)) == MEM
2919 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2921 /* Parm was passed via invisible reference, with the reference
2922 living on the stack. DECL_RTL looks like
2923 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2924 could look like (MEM (MEM (REG))). */
2925 const char *const decl_name = (DECL_NAME (parms)
2926 ? IDENTIFIER_POINTER (DECL_NAME (parms))
2928 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 0)) == REG)
2929 current_sym_value = 0;
2932 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1));
2933 current_sym_addr = 0;
2934 current_sym_code = N_PSYM;
2937 fprintf (asmfile, "%s\"%s:v", ASM_STABS_OP, decl_name);
2940 = DEBUGGER_ARG_OFFSET (current_sym_value,
2941 XEXP (XEXP (DECL_RTL (parms), 0), 0));
2942 dbxout_type (TREE_TYPE (parms), 0);
2943 dbxout_finish_symbol (parms);
2945 else if (GET_CODE (DECL_RTL (parms)) == MEM
2946 && XEXP (DECL_RTL (parms), 0) != const0_rtx
2947 /* ??? A constant address for a parm can happen
2948 when the reg it lives in is equiv to a constant in memory.
2949 Should make this not happen, after 2.4. */
2950 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2952 /* Parm was passed in registers but lives on the stack. */
2954 current_sym_code = N_PSYM;
2955 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2956 in which case we want the value of that CONST_INT,
2958 in which case we use a value of zero. */
2959 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG)
2960 current_sym_value = 0;
2963 = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2965 current_sym_addr = 0;
2967 /* Make a big endian correction if the mode of the type of the
2968 parameter is not the same as the mode of the rtl. */
2969 if (BYTES_BIG_ENDIAN
2970 && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms))
2971 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD)
2973 current_sym_value +=
2974 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))
2975 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms)));
2979 if (DECL_NAME (parms))
2982 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2984 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2985 IDENTIFIER_POINTER (DECL_NAME (parms)),
2986 DBX_MEMPARM_STABS_LETTER);
2990 current_sym_nchars = 8;
2991 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2992 DBX_MEMPARM_STABS_LETTER);
2996 = DEBUGGER_ARG_OFFSET (current_sym_value,
2997 XEXP (DECL_RTL (parms), 0));
2998 dbxout_type (TREE_TYPE (parms), 0);
2999 dbxout_finish_symbol (parms);
3002 DBXOUT_DECR_NESTING;
3005 /* Output definitions for the places where parms live during the function,
3006 when different from where they were passed, when the parms were passed
3009 It is not useful to do this for parms passed in registers
3010 that live during the function in different registers, because it is
3011 impossible to look in the passed register for the passed value,
3012 so we use the within-the-function register to begin with.
3014 PARMS is a chain of PARM_DECL nodes. */
3017 dbxout_reg_parms (tree parms)
3021 for (; parms; parms = TREE_CHAIN (parms))
3022 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
3024 dbxout_prepare_symbol (parms);
3026 /* Report parms that live in registers during the function
3027 but were passed in memory. */
3028 if (GET_CODE (DECL_RTL (parms)) == REG
3029 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
3030 dbxout_symbol_location (parms, TREE_TYPE (parms),
3031 0, DECL_RTL (parms));
3032 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
3033 dbxout_symbol_location (parms, TREE_TYPE (parms),
3034 0, DECL_RTL (parms));
3035 /* Report parms that live in memory but not where they were passed. */
3036 else if (GET_CODE (DECL_RTL (parms)) == MEM
3037 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
3038 dbxout_symbol_location (parms, TREE_TYPE (parms),
3039 0, DECL_RTL (parms));
3041 DBXOUT_DECR_NESTING;
3044 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
3045 output definitions of those names, in raw form */
3048 dbxout_args (tree args)
3052 putc (',', asmfile);
3053 dbxout_type (TREE_VALUE (args), 0);
3055 args = TREE_CHAIN (args);
3059 /* Output everything about a symbol block (a BLOCK node
3060 that represents a scope level),
3061 including recursive output of contained blocks.
3063 BLOCK is the BLOCK node.
3064 DEPTH is its depth within containing symbol blocks.
3065 ARGS is usually zero; but for the outermost block of the
3066 body of a function, it is a chain of PARM_DECLs for the function parameters.
3067 We output definitions of all the register parms
3068 as if they were local variables of that block.
3070 If -g1 was used, we count blocks just the same, but output nothing
3071 except for the outermost block.
3073 Actually, BLOCK may be several blocks chained together.
3074 We handle them all in sequence. */
3077 dbxout_block (tree block, int depth, tree args)
3081 #if DBX_BLOCKS_FUNCTION_RELATIVE
3082 const char *begin_label;
3083 if (current_function_func_begin_label != NULL_TREE)
3084 begin_label = IDENTIFIER_POINTER (current_function_func_begin_label);
3086 begin_label = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
3091 /* Ignore blocks never expanded or otherwise marked as real. */
3092 if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
3096 /* In dbx format, the syms of a block come before the N_LBRAC.
3097 If nothing is output, we don't need the N_LBRAC, either. */
3099 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
3100 did_output = dbxout_syms (BLOCK_VARS (block));
3102 dbxout_reg_parms (args);
3104 /* Now output an N_LBRAC symbol to represent the beginning of
3105 the block. Use the block's tree-walk order to generate
3106 the assembler symbols LBBn and LBEn
3107 that final will define around the code in this block. */
3108 if (depth > 0 && did_output)
3111 blocknum = BLOCK_NUMBER (block);
3112 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
3114 if (BLOCK_HANDLER_BLOCK (block))
3116 /* A catch block. Must precede N_LBRAC. */
3117 tree decl = BLOCK_VARS (block);
3120 fprintf (asmfile, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP,
3121 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
3122 assemble_name (asmfile, buf);
3123 fprintf (asmfile, "\n");
3124 decl = TREE_CHAIN (decl);
3128 #ifdef DBX_OUTPUT_LBRAC
3129 DBX_OUTPUT_LBRAC (asmfile, buf);
3131 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
3132 assemble_name (asmfile, buf);
3133 #if DBX_BLOCKS_FUNCTION_RELATIVE
3134 putc ('-', asmfile);
3135 assemble_name (asmfile, begin_label);
3137 fprintf (asmfile, "\n");
3141 /* Output the subblocks. */
3142 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
3144 /* Refer to the marker for the end of the block. */
3145 if (depth > 0 && did_output)
3148 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
3149 #ifdef DBX_OUTPUT_RBRAC
3150 DBX_OUTPUT_RBRAC (asmfile, buf);
3152 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC);
3153 assemble_name (asmfile, buf);
3154 #if DBX_BLOCKS_FUNCTION_RELATIVE
3155 putc ('-', asmfile);
3156 assemble_name (asmfile, begin_label);
3158 fprintf (asmfile, "\n");
3162 block = BLOCK_CHAIN (block);
3166 /* Output the information about a function and its arguments and result.
3167 Usually this follows the function's code,
3168 but on some systems, it comes before. */
3170 #if defined (DBX_DEBUGGING_INFO)
3172 dbxout_begin_function (tree decl)
3174 int saved_tree_used1 = TREE_USED (decl);
3175 TREE_USED (decl) = 1;
3176 if (DECL_NAME (DECL_RESULT (decl)) != 0)
3178 int saved_tree_used2 = TREE_USED (DECL_RESULT (decl));
3179 TREE_USED (DECL_RESULT (decl)) = 1;
3180 dbxout_symbol (decl, 0);
3181 TREE_USED (DECL_RESULT (decl)) = saved_tree_used2;
3184 dbxout_symbol (decl, 0);
3185 TREE_USED (decl) = saved_tree_used1;
3187 dbxout_parms (DECL_ARGUMENTS (decl));
3188 if (DECL_NAME (DECL_RESULT (decl)) != 0)
3189 dbxout_symbol (DECL_RESULT (decl), 1);
3191 #endif /* DBX_DEBUGGING_INFO */
3193 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3195 #include "gt-dbxout.h"