1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /* Output dbx-format symbol table data.
24 This consists of many symbol table entries, each of them
25 a .stabs assembler pseudo-op with four operands:
26 a "name" which is really a description of one symbol and its type,
27 a "code", which is a symbol defined in stab.h whose name starts with N_,
28 an unused operand always 0,
29 and a "value" which is an address or an offset.
30 The name is enclosed in doublequote characters.
32 Each function, variable, typedef, and structure tag
33 has a symbol table entry to define it.
34 The beginning and end of each level of name scoping within
35 a function are also marked by special symbol table entries.
37 The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
38 and a data type number. The data type number may be followed by
39 "=" and a type definition; normally this will happen the first time
40 the type number is mentioned. The type definition may refer to
41 other types by number, and those type numbers may be followed
42 by "=" and nested definitions.
44 This can make the "name" quite long.
45 When a name is more than 80 characters, we split the .stabs pseudo-op
46 into two .stabs pseudo-ops, both sharing the same "code" and "value".
47 The first one is marked as continued with a double-backslash at the
50 The kind-of-symbol letter distinguished function names from global
51 variables from file-scope variables from parameters from auto
52 variables in memory from typedef names from register variables.
55 The "code" is mostly redundant with the kind-of-symbol letter
56 that goes in the "name", but not entirely: for symbols located
57 in static storage, the "code" says which segment the address is in,
58 which controls how it is relocated.
60 The "value" for a symbol in static storage
61 is the core address of the symbol (actually, the assembler
62 label for the symbol). For a symbol located in a stack slot
63 it is the stack offset; for one in a register, the register number.
64 For a typedef symbol, it is zero.
66 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
67 output while in the text section.
69 For more on data type definitions, see `dbxout_type'. */
73 #include "coretypes.h"
80 #include "insn-config.h"
82 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
90 #include "langhooks.h"
92 #ifdef XCOFF_DEBUGGING_INFO
96 #undef DBXOUT_DECR_NESTING
97 #define DBXOUT_DECR_NESTING \
98 if (--debug_nesting == 0 && symbol_queue_index > 0) \
99 { emit_pending_bincls_if_required (); debug_flush_symbol_queue (); }
101 #undef DBXOUT_DECR_NESTING_AND_RETURN
102 #define DBXOUT_DECR_NESTING_AND_RETURN(x) \
103 do {--debug_nesting; return (x);} while (0)
106 #define ASM_STABS_OP "\t.stabs\t"
110 #define ASM_STABN_OP "\t.stabn\t"
113 #ifndef DBX_TYPE_DECL_STABS_CODE
114 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
117 #ifndef DBX_STATIC_CONST_VAR_CODE
118 #define DBX_STATIC_CONST_VAR_CODE N_FUN
121 #ifndef DBX_REGPARM_STABS_CODE
122 #define DBX_REGPARM_STABS_CODE N_RSYM
125 #ifndef DBX_REGPARM_STABS_LETTER
126 #define DBX_REGPARM_STABS_LETTER 'P'
129 /* This is used for parameters passed by invisible reference in a register. */
130 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
131 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
134 #ifndef DBX_MEMPARM_STABS_LETTER
135 #define DBX_MEMPARM_STABS_LETTER 'p'
138 #ifndef FILE_NAME_JOINER
139 #define FILE_NAME_JOINER "/"
142 /* GDB needs to know that the stabs were generated by GCC. We emit an
143 N_OPT stab at the beginning of the source file to indicate this.
144 The string is historical, and different on a very few targets. */
145 #ifndef STABS_GCC_MARKER
146 #define STABS_GCC_MARKER "gcc2_compiled."
149 enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
151 /* Structure recording information about a C data type.
152 The status element says whether we have yet output
153 the definition of the type. TYPE_XREF says we have
154 output it as a cross-reference only.
155 The file_number and type_number elements are used if DBX_USE_BINCL
158 struct typeinfo GTY(())
160 enum typestatus status;
165 /* Vector recording information about C data types.
166 When we first notice a data type (a tree node),
167 we assign it a number using next_type_number.
168 That is its index in this vector. */
170 static GTY ((length ("typevec_len"))) struct typeinfo *typevec;
172 /* Number of elements of space allocated in `typevec'. */
174 static GTY(()) int typevec_len;
176 /* In dbx output, each type gets a unique number.
177 This is the number for the next type output.
178 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
180 static GTY(()) int next_type_number;
182 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. */
190 struct dbx_file *next;
192 int next_type_number;
193 enum binclstatus bincl_status; /* Keep track of lazy bincl. */
194 const char *pending_bincl_name; /* Name of bincl. */
195 struct dbx_file *prev; /* Chain to traverse all pending bincls. */
198 /* This is the top of the stack.
200 This is not saved for PCH, because restoring a PCH should not change it.
201 next_file_number does have to be saved, because the PCH may use some
202 file numbers; however, just before restoring a PCH, next_file_number
203 should always be 0 because we should not have needed any file numbers
206 #if (defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)) \
207 && defined (DBX_USE_BINCL)
208 static struct dbx_file *current_file;
211 /* This is the next file number to use. */
213 static GTY(()) int next_file_number;
215 /* A counter for dbxout_function_end. */
217 static GTY(()) int scope_labelno;
219 /* A counter for dbxout_source_line. */
221 static GTY(()) int dbxout_source_line_counter;
223 /* Nonzero if we have actually used any of the GDB extensions
224 to the debugging format. The idea is that we use them for the
225 first time only if there's a strong reason, but once we have done that,
226 we use them whenever convenient. */
228 static GTY(()) int have_used_extensions = 0;
230 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
231 for the N_SO filename stabs label. */
233 static GTY(()) int source_label_number = 1;
235 /* Last source file name mentioned in a NOTE insn. */
237 static GTY(()) const char *lastfile;
239 /* Used by PCH machinery to detect if 'lastfile' should be reset to
241 static GTY(()) int lastfile_is_base;
243 /* Typical USG systems don't have stab.h, and they also have
244 no use for DBX-format debugging info. */
246 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
249 /* If zero then there is no pending BINCL. */
250 static int pending_bincls = 0;
253 /* The original input file name. */
254 static const char *base_input_file;
256 /* Current working directory. */
258 static const char *cwd;
260 #ifdef DEBUG_SYMS_TEXT
261 #define FORCE_TEXT function_section (current_function_decl);
268 #define STAB_CODE_TYPE enum __stab_debug_code
270 /* 1 if PARM is passed to this function in memory. */
272 #define PARM_PASSED_IN_MEMORY(PARM) \
273 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
275 /* A C expression for the integer offset value of an automatic variable
276 (N_LSYM) having address X (an RTX). */
277 #ifndef DEBUGGER_AUTO_OFFSET
278 #define DEBUGGER_AUTO_OFFSET(X) \
279 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
282 /* A C expression for the integer offset value of an argument (N_PSYM)
283 having address X (an RTX). The nominal offset is OFFSET. */
284 #ifndef DEBUGGER_ARG_OFFSET
285 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
288 /* Stream for writing to assembler file. */
290 static FILE *asmfile;
292 /* These variables are for dbxout_symbol to communicate to
293 dbxout_finish_symbol.
294 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
295 current_sym_value and current_sym_addr are two ways to address the
296 value to store in the symtab entry.
297 current_sym_addr if nonzero represents the value as an rtx.
298 If that is zero, current_sym_value is used. This is used
299 when the value is an offset (such as for auto variables,
300 register variables and parms). */
302 static STAB_CODE_TYPE current_sym_code;
303 static int current_sym_value;
304 static rtx current_sym_addr;
306 /* Number of chars of symbol-description generated so far for the
307 current symbol. Used by CHARS and CONTIN. */
309 static int current_sym_nchars;
311 /* Report having output N chars of the current symbol-description. */
313 #define CHARS(N) (current_sym_nchars += (N))
315 /* Break the current symbol-description, generating a continuation,
316 if it has become long. */
318 #ifndef DBX_CONTIN_LENGTH
319 #define DBX_CONTIN_LENGTH 80
322 #if DBX_CONTIN_LENGTH > 0
324 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
326 #define CONTIN do { } while (0)
330 static void emit_bincl_stab (const char *c);
331 static void emit_pending_bincls (void);
333 static inline void emit_pending_bincls_if_required (void);
335 static void dbxout_init (const char *);
336 static void dbxout_finish (const char *);
337 static void dbxout_start_source_file (unsigned, const char *);
338 static void dbxout_end_source_file (unsigned);
339 static void dbxout_typedefs (tree);
340 static void dbxout_type_index (tree);
341 #if DBX_CONTIN_LENGTH > 0
342 static void dbxout_continue (void);
344 static void dbxout_args (tree);
345 static void dbxout_type_fields (tree);
346 static void dbxout_type_method_1 (tree, const char *);
347 static void dbxout_type_methods (tree);
348 static void dbxout_range_type (tree);
349 static void dbxout_type (tree, int);
350 static bool print_int_cst_bounds_in_octal_p (tree);
351 static void print_int_cst_octal (tree);
352 static void print_octal (unsigned HOST_WIDE_INT, int);
353 static void print_wide_int (HOST_WIDE_INT);
354 static void dbxout_type_name (tree);
355 static void dbxout_class_name_qualifiers (tree);
356 static int dbxout_symbol_location (tree, tree, const char *, rtx);
357 static void dbxout_symbol_name (tree, const char *, int);
358 static void dbxout_prepare_symbol (tree);
359 static void dbxout_finish_symbol (tree);
360 static void dbxout_block (tree, int, tree);
361 static void dbxout_global_decl (tree);
362 static void dbxout_handle_pch (unsigned);
364 /* The debug hooks structure. */
365 #if defined (DBX_DEBUGGING_INFO)
367 static void dbxout_source_line (unsigned int, const char *);
368 static void dbxout_source_file (FILE *, const char *);
369 static void dbxout_function_end (void);
370 static void dbxout_begin_function (tree);
371 static void dbxout_begin_block (unsigned, unsigned);
372 static void dbxout_end_block (unsigned, unsigned);
373 static void dbxout_function_decl (tree);
375 const struct gcc_debug_hooks dbx_debug_hooks =
379 debug_nothing_int_charstar,
380 debug_nothing_int_charstar,
381 dbxout_start_source_file,
382 dbxout_end_source_file,
385 debug_true_tree, /* ignore_block */
386 dbxout_source_line, /* source_line */
387 dbxout_source_line, /* begin_prologue: just output
389 debug_nothing_int_charstar, /* end_prologue */
390 debug_nothing_int_charstar, /* end_epilogue */
391 #ifdef DBX_FUNCTION_FIRST
392 dbxout_begin_function,
394 debug_nothing_tree, /* begin_function */
396 debug_nothing_int, /* end_function */
397 dbxout_function_decl,
398 dbxout_global_decl, /* global_decl */
399 debug_nothing_tree_tree, /* imported_module_or_decl */
400 debug_nothing_tree, /* deferred_inline_function */
401 debug_nothing_tree, /* outlining_inline_function */
402 debug_nothing_rtx, /* label */
403 dbxout_handle_pch /* handle_pch */
405 #endif /* DBX_DEBUGGING_INFO */
407 #if defined (XCOFF_DEBUGGING_INFO)
408 const struct gcc_debug_hooks xcoff_debug_hooks =
412 debug_nothing_int_charstar,
413 debug_nothing_int_charstar,
414 dbxout_start_source_file,
415 dbxout_end_source_file,
416 xcoffout_begin_block,
418 debug_true_tree, /* ignore_block */
419 xcoffout_source_line,
420 xcoffout_begin_prologue, /* begin_prologue */
421 debug_nothing_int_charstar, /* end_prologue */
422 xcoffout_end_epilogue,
423 debug_nothing_tree, /* begin_function */
424 xcoffout_end_function,
425 debug_nothing_tree, /* function_decl */
426 dbxout_global_decl, /* global_decl */
427 debug_nothing_tree_tree, /* imported_module_or_decl */
428 debug_nothing_tree, /* deferred_inline_function */
429 debug_nothing_tree, /* outlining_inline_function */
430 debug_nothing_rtx, /* label */
431 dbxout_handle_pch /* handle_pch */
433 #endif /* XCOFF_DEBUGGING_INFO */
435 #if defined (DBX_DEBUGGING_INFO)
437 dbxout_function_end (void)
439 char lscope_label_name[100];
440 /* Convert Ltext into the appropriate format for local labels in case
441 the system doesn't insert underscores in front of user generated
443 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
444 (*targetm.asm_out.internal_label) (asmfile, "Lscope", scope_labelno);
447 /* By convention, GCC will mark the end of a function with an N_FUN
448 symbol and an empty string. */
449 #ifdef DBX_OUTPUT_NFUN
450 DBX_OUTPUT_NFUN (asmfile, lscope_label_name, current_function_decl);
452 fprintf (asmfile, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN);
453 assemble_name (asmfile, lscope_label_name);
455 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
456 fprintf (asmfile, "\n");
459 #endif /* DBX_DEBUGGING_INFO */
461 /* At the beginning of compilation, start writing the symbol table.
462 Initialize `typevec' and output the standard data types of C. */
465 dbxout_init (const char *input_file_name)
467 char ltext_label_name[100];
468 tree syms = (*lang_hooks.decls.getdecls) ();
470 asmfile = asm_out_file;
473 typevec = ggc_calloc (typevec_len, sizeof typevec[0]);
475 /* Convert Ltext into the appropriate format for local labels in case
476 the system doesn't insert underscores in front of user generated
478 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
480 /* Put the current working directory in an N_SO symbol. */
481 if (use_gnu_debug_info_extensions)
483 if (!cwd && (cwd = get_src_pwd ())
484 && (!*cwd || cwd[strlen (cwd) - 1] != '/'))
485 cwd = concat (cwd, FILE_NAME_JOINER, NULL);
488 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
489 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
490 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
491 fprintf (asmfile, "%s", ASM_STABS_OP);
492 output_quoted_string (asmfile, cwd);
493 fprintf (asmfile, ",%d,0,0,", N_SO);
494 assemble_name (asmfile, ltext_label_name);
495 fputc ('\n', asmfile);
496 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
500 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
501 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
502 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
503 /* We include outputting `Ltext:' here,
504 because that gives you a way to override it. */
505 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
506 fprintf (asmfile, "%s", ASM_STABS_OP);
507 output_quoted_string (asmfile, input_file_name);
508 fprintf (asmfile, ",%d,0,0,", N_SO);
509 assemble_name (asmfile, ltext_label_name);
510 fputc ('\n', asmfile);
512 (*targetm.asm_out.internal_label) (asmfile, "Ltext", 0);
513 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
515 #ifdef DBX_OUTPUT_GCC_MARKER
516 DBX_OUTPUT_GCC_MARKER (asmfile);
518 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
519 fprintf (asmfile, "%s\"%s\",%d,0,0,0\n",
520 ASM_STABS_OP, STABS_GCC_MARKER, N_OPT);
523 base_input_file = lastfile = input_file_name;
525 next_type_number = 1;
528 current_file = xmalloc (sizeof *current_file);
529 current_file->next = NULL;
530 current_file->file_number = 0;
531 current_file->next_type_number = 1;
532 next_file_number = 1;
533 current_file->prev = NULL;
534 current_file->bincl_status = BINCL_NOT_REQUIRED;
535 current_file->pending_bincl_name = NULL;
538 /* Make sure that types `int' and `char' have numbers 1 and 2.
539 Definitions of other integer types will refer to those numbers.
540 (Actually it should no longer matter what their numbers are.
541 Also, if any types with tags have been defined, dbxout_symbol
542 will output them first, so the numbers won't be 1 and 2. That
543 happens in C++. So it's a good thing it should no longer matter). */
545 #ifdef DBX_OUTPUT_STANDARD_TYPES
546 DBX_OUTPUT_STANDARD_TYPES (syms);
549 /* Get all permanent types that have typedef names, and output them
550 all, except for those already output. Some language front ends
551 put these declarations in the top-level scope; some do not. */
552 dbxout_typedefs ((*lang_hooks.decls.builtin_type_decls) ());
553 dbxout_typedefs (syms);
556 /* Output any typedef names for types described by TYPE_DECLs in SYMS. */
559 dbxout_typedefs (tree syms)
561 for (; syms != NULL_TREE; syms = TREE_CHAIN (syms))
563 if (TREE_CODE (syms) == TYPE_DECL)
565 tree type = TREE_TYPE (syms);
567 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
568 && COMPLETE_OR_VOID_TYPE_P (type)
569 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
570 dbxout_symbol (TYPE_NAME (type), 0);
576 /* Emit BINCL stab using given name. */
578 emit_bincl_stab (const char *name)
580 fprintf (asmfile, "%s", ASM_STABS_OP);
581 output_quoted_string (asmfile, name);
582 fprintf (asmfile, ",%d,0,0,0\n", N_BINCL);
585 /* If there are pending bincls then it is time to emit all of them. */
588 emit_pending_bincls_if_required (void)
591 emit_pending_bincls ();
594 /* Emit all pending bincls. */
597 emit_pending_bincls (void)
599 struct dbx_file *f = current_file;
601 /* Find first pending bincl. */
602 while (f->bincl_status == BINCL_PENDING)
605 /* Now emit all bincls. */
610 if (f->bincl_status == BINCL_PENDING)
612 emit_bincl_stab (f->pending_bincl_name);
614 /* Update file number and status. */
615 f->file_number = next_file_number++;
616 f->bincl_status = BINCL_PROCESSED;
618 if (f == current_file)
623 /* All pending bincls have been emitted. */
630 emit_pending_bincls_if_required (void) {}
633 /* Change to reading from a new source file. Generate a N_BINCL stab. */
636 dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
637 const char *filename ATTRIBUTE_UNUSED)
640 struct dbx_file *n = xmalloc (sizeof *n);
642 n->next = current_file;
643 n->next_type_number = 1;
644 /* Do not assign file number now.
645 Delay it until we actually emit BINCL. */
648 current_file->prev = n;
649 n->bincl_status = BINCL_PENDING;
650 n->pending_bincl_name = filename;
656 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
659 dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED)
662 /* Emit EINCL stab only if BINCL is not pending. */
663 if (current_file->bincl_status == BINCL_PROCESSED)
664 fprintf (asmfile, "%s%d,0,0,0\n", ASM_STABN_OP, N_EINCL);
665 current_file->bincl_status = BINCL_NOT_REQUIRED;
666 current_file = current_file->next;
670 /* Handle a few odd cases that occur when trying to make PCH files work. */
673 dbxout_handle_pch (unsigned at_end)
677 /* When using the PCH, this file will be included, so we need to output
679 dbxout_start_source_file (0, lastfile);
681 /* The base file when using the PCH won't be the same as
682 the base file when it's being generated. */
687 /* ... and an EINCL. */
688 dbxout_end_source_file (0);
690 /* Deal with cases where 'lastfile' was never actually changed. */
691 lastfile_is_base = lastfile == NULL;
695 #if defined (DBX_DEBUGGING_INFO)
696 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
699 dbxout_source_file (FILE *file, const char *filename)
701 if (lastfile == 0 && lastfile_is_base)
703 lastfile = base_input_file;
704 lastfile_is_base = 0;
707 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
709 char ltext_label_name[100];
711 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
712 source_label_number);
713 fprintf (file, "%s", ASM_STABS_OP);
714 output_quoted_string (file, filename);
715 fprintf (asmfile, ",%d,0,0,", N_SOL);
716 assemble_name (asmfile, ltext_label_name);
717 fputc ('\n', asmfile);
718 if (current_function_decl != NULL_TREE
719 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
720 ; /* Don't change section amid function. */
723 (*targetm.asm_out.internal_label) (file, "Ltext", source_label_number);
724 source_label_number++;
729 /* Output a line number symbol entry for source file FILENAME and line
733 dbxout_source_line (unsigned int lineno, const char *filename)
735 dbxout_source_file (asmfile, filename);
737 #ifdef ASM_OUTPUT_SOURCE_LINE
738 dbxout_source_line_counter += 1;
739 ASM_OUTPUT_SOURCE_LINE (asmfile, lineno, dbxout_source_line_counter);
741 fprintf (asmfile, "%s%d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
745 /* Describe the beginning of an internal block within a function. */
748 dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
750 emit_pending_bincls_if_required ();
751 (*targetm.asm_out.internal_label) (asmfile, "LBB", n);
754 /* Describe the end line-number of an internal block within a function. */
757 dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
759 emit_pending_bincls_if_required ();
760 (*targetm.asm_out.internal_label) (asmfile, "LBE", n);
763 /* Output dbx data for a function definition.
764 This includes a definition of the function name itself (a symbol),
765 definitions of the parameters (locating them in the parameter list)
766 and then output the block that makes up the function's body
767 (including all the auto variables of the function). */
770 dbxout_function_decl (tree decl)
772 emit_pending_bincls_if_required ();
773 #ifndef DBX_FUNCTION_FIRST
774 dbxout_begin_function (decl);
776 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
777 #ifdef DBX_OUTPUT_FUNCTION_END
778 DBX_OUTPUT_FUNCTION_END (asmfile, decl);
780 if (use_gnu_debug_info_extensions
781 #if defined(NO_DBX_FUNCTION_END)
782 && ! NO_DBX_FUNCTION_END
784 && targetm.have_named_sections)
785 dbxout_function_end ();
788 #endif /* DBX_DEBUGGING_INFO */
790 /* Debug information for a global DECL. Called from toplev.c after
791 compilation proper has finished. */
793 dbxout_global_decl (tree decl)
795 if (TREE_CODE (decl) == VAR_DECL
796 && ! DECL_EXTERNAL (decl)
797 && DECL_RTL_SET_P (decl)) /* Not necessary? */
799 int saved_tree_used = TREE_USED (decl);
800 TREE_USED (decl) = 1;
801 dbxout_symbol (decl, 0);
802 TREE_USED (decl) = saved_tree_used;
806 /* At the end of compilation, finish writing the symbol table.
807 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
811 dbxout_finish (const char *filename ATTRIBUTE_UNUSED)
813 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
814 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile, filename);
815 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
820 /* Output the index of a type. */
823 dbxout_type_index (tree type)
825 #ifndef DBX_USE_BINCL
826 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
829 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
830 fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number);
835 #if DBX_CONTIN_LENGTH > 0
836 /* Continue a symbol-description that gets too big.
837 End one symbol table entry with a double-backslash
838 and start a new one, eventually producing something like
839 .stabs "start......\\",code,0,value
840 .stabs "...rest",code,0,value */
843 dbxout_continue (void)
845 emit_pending_bincls_if_required ();
846 #ifdef DBX_CONTIN_CHAR
847 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
849 fprintf (asmfile, "\\\\");
851 dbxout_finish_symbol (NULL_TREE);
852 fprintf (asmfile, "%s\"", ASM_STABS_OP);
853 current_sym_nchars = 0;
855 #endif /* DBX_CONTIN_LENGTH > 0 */
857 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
858 This must be a separate function because anonymous unions require
862 dbxout_type_fields (tree type)
866 /* Output the name, type, position (in bits), size (in bits) of each
867 field that we can support. */
868 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
871 /* If on of the nodes is an error_mark or its type is then return early. */
872 if (tem == error_mark_node || TREE_TYPE (tem) == error_mark_node)
875 /* Omit here local type decls until we know how to support them. */
876 if (TREE_CODE (tem) == TYPE_DECL
877 /* Omit fields whose position or size are variable or too large to
879 || (TREE_CODE (tem) == FIELD_DECL
880 && (! host_integerp (bit_position (tem), 0)
882 || ! host_integerp (DECL_SIZE (tem), 1)))
883 /* Omit here the nameless fields that are used to skip bits. */
884 || DECL_IGNORED_P (tem))
887 else if (TREE_CODE (tem) != CONST_DECL)
889 /* Continue the line if necessary,
890 but not before the first field. */
891 if (tem != TYPE_FIELDS (type))
896 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
897 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
901 fprintf (asmfile, ":");
905 if (use_gnu_debug_info_extensions
906 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
907 || TREE_CODE (tem) != FIELD_DECL))
909 have_used_extensions = 1;
911 putc ((TREE_PRIVATE (tem) ? '0'
912 : TREE_PROTECTED (tem) ? '1' : '2'),
917 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
918 && DECL_BIT_FIELD_TYPE (tem))
919 ? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0);
921 if (TREE_CODE (tem) == VAR_DECL)
923 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
925 tree name = DECL_ASSEMBLER_NAME (tem);
927 have_used_extensions = 1;
928 fprintf (asmfile, ":%s;", IDENTIFIER_POINTER (name));
929 CHARS (IDENTIFIER_LENGTH (name) + 2);
933 /* If TEM is non-static, GDB won't understand it. */
934 fprintf (asmfile, ",0,0;");
941 print_wide_int (int_bit_position (tem));
943 print_wide_int (tree_low_cst (DECL_SIZE (tem), 1));
951 /* Subroutine of `dbxout_type_methods'. Output debug info about the
952 method described DECL. DEBUG_NAME is an encoding of the method's
953 type signature. ??? We may be able to do without DEBUG_NAME altogether
957 dbxout_type_method_1 (tree decl, const char *debug_name)
961 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
963 else /* it's a METHOD_TYPE. */
965 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
966 /* A for normal functions.
967 B for `const' member functions.
968 C for `volatile' member functions.
969 D for `const volatile' member functions. */
970 if (TYPE_READONLY (TREE_TYPE (firstarg)))
972 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
975 if (DECL_VINDEX (decl))
981 fprintf (asmfile, ":%s;%c%c%c", debug_name,
982 TREE_PRIVATE (decl) ? '0'
983 : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
984 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
985 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
987 if (DECL_VINDEX (decl) && host_integerp (DECL_VINDEX (decl), 0))
989 print_wide_int (tree_low_cst (DECL_VINDEX (decl), 0));
992 dbxout_type (DECL_CONTEXT (decl), 0);
993 fprintf (asmfile, ";");
998 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
1002 dbxout_type_methods (tree type)
1004 /* C++: put out the method names and their parameter lists */
1005 tree methods = TYPE_METHODS (type);
1009 char formatted_type_identifier_length[16];
1010 int type_identifier_length;
1012 if (methods == NULL_TREE)
1015 type_encoding = DECL_NAME (TYPE_NAME (type));
1018 /* C++: Template classes break some assumptions made by this code about
1019 the class names, constructor names, and encodings for assembler
1020 label names. For now, disable output of dbx info for them. */
1022 const char *ptr = IDENTIFIER_POINTER (type_encoding);
1023 /* This should use index. (mrs) */
1024 while (*ptr && *ptr != '<') ptr++;
1035 type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
1037 sprintf (formatted_type_identifier_length, "%d", type_identifier_length);
1039 if (TREE_CODE (methods) != TREE_VEC)
1041 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
1042 fndecl = TREE_VEC_ELT (methods, 0);
1044 fndecl = TREE_VEC_ELT (methods, 1);
1048 int need_prefix = 1;
1050 /* Group together all the methods for the same operation.
1051 These differ in the types of the arguments. */
1052 for (last = NULL_TREE;
1053 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
1054 fndecl = TREE_CHAIN (fndecl))
1055 /* Output the name of the field (after overloading), as
1056 well as the name of the field before overloading, along
1057 with its parameter list */
1059 /* This is the "mangled" name of the method.
1060 It encodes the argument types. */
1061 const char *debug_name;
1063 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1064 include TEMPLATE_DECLs.) The debugger doesn't know what
1065 to do with such entities anyhow. */
1066 if (TREE_CODE (fndecl) != FUNCTION_DECL)
1069 debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
1075 /* Also ignore abstract methods; those are only interesting to
1076 the DWARF backends. */
1077 if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT (fndecl))
1080 /* Redundantly output the plain name, since that's what gdb
1084 tree name = DECL_NAME (fndecl);
1085 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
1086 CHARS (IDENTIFIER_LENGTH (name) + 2);
1090 dbxout_type (TREE_TYPE (fndecl), 0);
1092 dbxout_type_method_1 (fndecl, debug_name);
1096 putc (';', asmfile);
1102 /* Emit a "range" type specification, which has the form:
1103 "r<index type>;<lower bound>;<upper bound>;".
1104 TYPE is an INTEGER_TYPE. */
1107 dbxout_range_type (tree type)
1109 fprintf (asmfile, "r");
1110 if (TREE_TYPE (type))
1111 dbxout_type (TREE_TYPE (type), 0);
1112 else if (TREE_CODE (type) != INTEGER_TYPE)
1113 dbxout_type (type, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1116 /* Traditionally, we made sure 'int' was type 1, and builtin types
1117 were defined to be sub-ranges of int. Unfortunately, this
1118 does not allow us to distinguish true sub-ranges from integer
1119 types. So, instead we define integer (non-sub-range) types as
1120 sub-ranges of themselves. This matters for Chill. If this isn't
1121 a subrange type, then we want to define it in terms of itself.
1122 However, in C, this may be an anonymous integer type, and we don't
1123 want to emit debug info referring to it. Just calling
1124 dbxout_type_index won't work anyways, because the type hasn't been
1125 defined yet. We make this work for both cases by checked to see
1126 whether this is a defined type, referring to it if it is, and using
1128 if (TYPE_SYMTAB_ADDRESS (type) != 0)
1129 dbxout_type_index (type);
1131 dbxout_type_index (integer_type_node);
1134 if (TYPE_MIN_VALUE (type) != 0
1135 && host_integerp (TYPE_MIN_VALUE (type), 0))
1137 putc (';', asmfile);
1139 if (print_int_cst_bounds_in_octal_p (type))
1140 print_int_cst_octal (TYPE_MIN_VALUE (type));
1142 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type), 0));
1146 fprintf (asmfile, ";0");
1150 if (TYPE_MAX_VALUE (type) != 0
1151 && host_integerp (TYPE_MAX_VALUE (type), 0))
1153 putc (';', asmfile);
1155 if (print_int_cst_bounds_in_octal_p (type))
1156 print_int_cst_octal (TYPE_MAX_VALUE (type));
1158 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type), 0));
1159 putc (';', asmfile);
1164 fprintf (asmfile, ";-1;");
1170 /* Output a reference to a type. If the type has not yet been
1171 described in the dbx output, output its definition now.
1172 For a type already defined, just refer to its definition
1173 using the type number.
1175 If FULL is nonzero, and the type has been described only with
1176 a forward-reference, output the definition now.
1177 If FULL is zero in this case, just refer to the forward-reference
1178 using the number previously allocated. */
1181 dbxout_type (tree type, int full)
1185 static int anonymous_type_number = 0;
1187 if (TREE_CODE (type) == VECTOR_TYPE)
1188 /* The frontend feeds us a representation for the vector as a struct
1189 containing an array. Pull out the array type. */
1190 type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type)));
1192 /* If there was an input error and we don't really have a type,
1193 avoid crashing and write something that is at least valid
1194 by assuming `int'. */
1195 if (type == error_mark_node)
1196 type = integer_type_node;
1199 if (TYPE_NAME (type)
1200 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1201 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1205 /* Try to find the "main variant" with the same name. */
1206 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1207 && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1208 main_variant = TREE_TYPE (TYPE_NAME (type));
1210 main_variant = TYPE_MAIN_VARIANT (type);
1212 /* If we are not using extensions, stabs does not distinguish const and
1213 volatile, so there is no need to make them separate types. */
1214 if (!use_gnu_debug_info_extensions)
1215 type = main_variant;
1217 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1219 /* Type has no dbx number assigned. Assign next available number. */
1220 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1222 /* Make sure type vector is long enough to record about this type. */
1224 if (next_type_number == typevec_len)
1227 = ggc_realloc (typevec, (typevec_len * 2 * sizeof typevec[0]));
1228 memset (typevec + typevec_len, 0, typevec_len * sizeof typevec[0]);
1232 #ifdef DBX_USE_BINCL
1233 emit_pending_bincls_if_required ();
1234 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1235 = current_file->file_number;
1236 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1237 = current_file->next_type_number++;
1241 if (flag_debug_only_used_symbols)
1243 if ((TREE_CODE (type) == RECORD_TYPE
1244 || TREE_CODE (type) == UNION_TYPE
1245 || TREE_CODE (type) == QUAL_UNION_TYPE
1246 || TREE_CODE (type) == ENUMERAL_TYPE)
1247 && TYPE_STUB_DECL (type)
1248 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (type))) == 'd'
1249 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type)))
1250 debug_queue_symbol (TYPE_STUB_DECL (type));
1251 else if (TYPE_NAME (type)
1252 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1253 debug_queue_symbol (TYPE_NAME (type));
1256 /* Output the number of this type, to refer to it. */
1257 dbxout_type_index (type);
1259 #ifdef DBX_TYPE_DEFINED
1260 if (DBX_TYPE_DEFINED (type))
1264 /* If this type's definition has been output or is now being output,
1267 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1272 /* If we have already had a cross reference,
1273 and either that's all we want or that's the best we could do,
1274 don't repeat the cross reference.
1275 Sun dbx crashes if we do. */
1276 if (! full || !COMPLETE_TYPE_P (type)
1277 /* No way in DBX fmt to describe a variable size. */
1278 || ! host_integerp (TYPE_SIZE (type), 1))
1286 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1287 leave the type-number completely undefined rather than output
1288 a cross-reference. If we have already used GNU debug info extensions,
1289 then it is OK to output a cross reference. This is necessary to get
1290 proper C++ debug output. */
1291 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1292 || TREE_CODE (type) == QUAL_UNION_TYPE
1293 || TREE_CODE (type) == ENUMERAL_TYPE)
1294 && ! use_gnu_debug_info_extensions)
1295 /* We must use the same test here as we use twice below when deciding
1296 whether to emit a cross-reference. */
1297 if ((TYPE_NAME (type) != 0
1298 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1299 && DECL_IGNORED_P (TYPE_NAME (type)))
1301 || !COMPLETE_TYPE_P (type)
1302 /* No way in DBX fmt to describe a variable size. */
1303 || ! host_integerp (TYPE_SIZE (type), 1))
1305 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1310 /* Output a definition now. */
1312 fprintf (asmfile, "=");
1315 /* Mark it as defined, so that if it is self-referent
1316 we will not get into an infinite recursion of definitions. */
1318 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1320 /* If this type is a variant of some other, hand off. Types with
1321 different names are usefully distinguished. We only distinguish
1322 cv-qualified types if we're using extensions. */
1323 if (TYPE_READONLY (type) > TYPE_READONLY (main_variant))
1325 putc ('k', asmfile);
1327 dbxout_type (build_type_variant (type, 0, TYPE_VOLATILE (type)), 0);
1330 else if (TYPE_VOLATILE (type) > TYPE_VOLATILE (main_variant))
1332 putc ('B', asmfile);
1334 dbxout_type (build_type_variant (type, TYPE_READONLY (type), 0), 0);
1337 else if (main_variant != TYPE_MAIN_VARIANT (type))
1339 if (flag_debug_only_used_symbols)
1341 tree orig_type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
1343 if ((TREE_CODE (orig_type) == RECORD_TYPE
1344 || TREE_CODE (orig_type) == UNION_TYPE
1345 || TREE_CODE (orig_type) == QUAL_UNION_TYPE
1346 || TREE_CODE (orig_type) == ENUMERAL_TYPE)
1347 && TYPE_STUB_DECL (orig_type)
1348 && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type)))
1349 debug_queue_symbol (TYPE_STUB_DECL (orig_type));
1351 /* 'type' is a typedef; output the type it refers to. */
1352 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0);
1355 /* else continue. */
1357 switch (TREE_CODE (type))
1361 /* For a void type, just define it as itself; ie, "5=5".
1362 This makes us consider it defined
1363 without saying what it is. The debugger will make it
1364 a void type when the reference is seen, and nothing will
1365 ever override that default. */
1366 dbxout_type_index (type);
1370 if (type == char_type_node && ! TREE_UNSIGNED (type))
1372 /* Output the type `char' as a subrange of itself!
1373 I don't understand this definition, just copied it
1374 from the output of pcc.
1375 This used to use `r2' explicitly and we used to
1376 take care to make sure that `char' was type number 2. */
1377 fprintf (asmfile, "r");
1379 dbxout_type_index (type);
1380 fprintf (asmfile, ";0;127;");
1384 /* If this is a subtype of another integer type, always prefer to
1385 write it as a subtype. */
1386 else if (TREE_TYPE (type) != 0
1387 && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
1389 /* If the size is non-standard, say what it is if we can use
1392 if (use_gnu_debug_info_extensions
1393 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1395 have_used_extensions = 1;
1396 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1400 dbxout_range_type (type);
1405 /* If the size is non-standard, say what it is if we can use
1408 if (use_gnu_debug_info_extensions
1409 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1411 have_used_extensions = 1;
1412 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1416 if (print_int_cst_bounds_in_octal_p (type))
1418 fprintf (asmfile, "r");
1421 /* If this type derives from another type, output type index of
1422 parent type. This is particularly important when parent type
1423 is an enumerated type, because not generating the parent type
1424 index would transform the definition of this enumerated type
1425 into a plain unsigned type. */
1426 if (TREE_TYPE (type) != 0)
1427 dbxout_type_index (TREE_TYPE (type));
1429 dbxout_type_index (type);
1431 fprintf (asmfile, ";");
1433 print_int_cst_octal (TYPE_MIN_VALUE (type));
1434 fprintf (asmfile, ";");
1436 print_int_cst_octal (TYPE_MAX_VALUE (type));
1437 fprintf (asmfile, ";");
1442 /* Output other integer types as subranges of `int'. */
1443 dbxout_range_type (type);
1449 /* This used to say `r1' and we used to take care
1450 to make sure that `int' was type number 1. */
1451 fprintf (asmfile, "r");
1453 dbxout_type_index (integer_type_node);
1454 putc (';', asmfile);
1456 print_wide_int (int_size_in_bytes (type));
1457 fputs (";0;", asmfile);
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 (";-20;", asmfile);
1473 /* Output the type `char' as a subrange of itself.
1474 That is what pcc seems to do. */
1475 fprintf (asmfile, "r");
1477 dbxout_type_index (char_type_node);
1478 fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1484 if (use_gnu_debug_info_extensions)
1486 have_used_extensions = 1;
1487 fputs ("@s", asmfile);
1489 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1490 fputs (";-16;", asmfile);
1493 else /* Define as enumeral type (False, True) */
1495 fprintf (asmfile, "eFalse:0,True:1,;");
1501 putc ('d', asmfile);
1503 dbxout_type (TREE_TYPE (type), 0);
1507 /* Differs from the REAL_TYPE by its new data type number.
1508 R3 is NF_COMPLEX. We don't try to use any of the other NF_*
1509 codes since gdb doesn't care anyway. */
1511 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1513 fputs ("R3;", asmfile);
1515 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type)));
1516 fputs (";0;", asmfile);
1521 /* Output a complex integer type as a structure,
1522 pending some other way to do it. */
1523 putc ('s', asmfile);
1525 print_wide_int (int_size_in_bytes (type));
1526 fprintf (asmfile, "real:");
1529 dbxout_type (TREE_TYPE (type), 0);
1530 fprintf (asmfile, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type)));
1532 fprintf (asmfile, "imag:");
1534 dbxout_type (TREE_TYPE (type), 0);
1535 fprintf (asmfile, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type)),
1536 TYPE_PRECISION (TREE_TYPE (type)));
1542 if (use_gnu_debug_info_extensions)
1544 have_used_extensions = 1;
1545 fputs ("@s", asmfile);
1547 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1548 putc (';', asmfile);
1551 /* Check if a bitstring type, which in Chill is
1552 different from a [power]set. */
1553 if (TYPE_STRING_FLAG (type))
1555 fprintf (asmfile, "@S;");
1559 putc ('S', asmfile);
1561 dbxout_type (TYPE_DOMAIN (type), 0);
1565 /* Make arrays of packed bits look like bitstrings for chill. */
1566 if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
1568 have_used_extensions = 1;
1569 fputs ("@s", asmfile);
1571 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1572 fprintf (asmfile, ";@S;S");
1574 dbxout_type (TYPE_DOMAIN (type), 0);
1578 /* Output "a" followed by a range type definition
1579 for the index type of the array
1580 followed by a reference to the target-type.
1581 ar1;0;N;M for a C array of type M and size N+1. */
1582 /* Check if a character string type, which in Chill is
1583 different from an array of characters. */
1584 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1586 have_used_extensions = 1;
1587 fprintf (asmfile, "@S;");
1590 tem = TYPE_DOMAIN (type);
1593 fprintf (asmfile, "ar");
1595 dbxout_type_index (integer_type_node);
1596 fprintf (asmfile, ";0;-1;");
1601 fprintf (asmfile, "a");
1603 dbxout_range_type (tem);
1606 dbxout_type (TREE_TYPE (type), 0);
1611 case QUAL_UNION_TYPE:
1613 int i, n_baseclasses = 0;
1615 if (TYPE_BINFO (type) != 0
1616 && TREE_CODE (TYPE_BINFO (type)) == TREE_VEC
1617 && TYPE_BINFO_BASETYPES (type) != 0)
1618 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1620 /* Output a structure type. We must use the same test here as we
1621 use in the DBX_NO_XREFS case above. */
1622 if ((TYPE_NAME (type) != 0
1623 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1624 && DECL_IGNORED_P (TYPE_NAME (type)))
1626 || !COMPLETE_TYPE_P (type)
1627 /* No way in DBX fmt to describe a variable size. */
1628 || ! host_integerp (TYPE_SIZE (type), 1))
1630 /* If the type is just a cross reference, output one
1631 and mark the type as partially described.
1632 If it later becomes defined, we will output
1633 its real definition.
1634 If the type has a name, don't nest its definition within
1635 another type's definition; instead, output an xref
1636 and let the definition come when the name is defined. */
1637 fputs ((TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu", asmfile);
1639 #if 0 /* This assertion is legitimately false in C++. */
1640 /* We shouldn't be outputting a reference to a type before its
1641 definition unless the type has a tag name.
1642 A typedef name without a tag name should be impossible. */
1643 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1646 if (TYPE_NAME (type) != 0)
1647 dbxout_type_name (type);
1650 fprintf (asmfile, "$$%d", anonymous_type_number++);
1654 fprintf (asmfile, ":");
1656 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1660 /* Identify record or union, and print its size. */
1661 putc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asmfile);
1663 print_wide_int (int_size_in_bytes (type));
1665 if (use_gnu_debug_info_extensions)
1669 have_used_extensions = 1;
1670 fprintf (asmfile, "!%d,", n_baseclasses);
1674 for (i = 0; i < n_baseclasses; i++)
1676 tree binfo = TYPE_BINFO (type);
1677 tree child = BINFO_BASETYPE (binfo, i);
1678 tree access = (BINFO_BASEACCESSES (binfo)
1679 ? BINFO_BASEACCESS (binfo, i) : access_public_node);
1681 if (use_gnu_debug_info_extensions)
1683 have_used_extensions = 1;
1684 putc (TREE_VIA_VIRTUAL (child) ? '1' : '0', asmfile);
1685 putc (access == access_public_node ? '2' :
1686 (access == access_protected_node ? '1' :'0'),
1689 if (TREE_VIA_VIRTUAL (child)
1690 && strcmp (lang_hooks.name, "GNU C++") == 0)
1691 /* For a virtual base, print the (negative) offset within
1692 the vtable where we must look to find the necessary
1694 print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child), 0)
1697 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1699 putc (',', asmfile);
1701 dbxout_type (BINFO_TYPE (child), 0);
1702 putc (';', asmfile);
1707 /* Print out the base class information with fields
1708 which have the same names at the types they hold. */
1709 dbxout_type_name (BINFO_TYPE (child));
1710 putc (':', asmfile);
1712 dbxout_type (BINFO_TYPE (child), full);
1713 putc (',', asmfile);
1715 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1717 putc (',', asmfile);
1719 print_wide_int (tree_low_cst (TYPE_SIZE (BINFO_TYPE (child)),
1722 putc (';', asmfile);
1728 /* Write out the field declarations. */
1729 dbxout_type_fields (type);
1730 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1732 have_used_extensions = 1;
1733 dbxout_type_methods (type);
1736 putc (';', asmfile);
1739 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1740 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1741 && TYPE_VFIELD (type))
1743 have_used_extensions = 1;
1745 /* Tell GDB+ that it may keep reading. */
1746 putc ('~', asmfile);
1749 /* We need to write out info about what field this class
1750 uses as its "main" vtable pointer field, because if this
1751 field is inherited from a base class, GDB cannot necessarily
1752 figure out which field it's using in time. */
1753 if (TYPE_VFIELD (type))
1755 putc ('%', asmfile);
1757 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0);
1760 putc (';', asmfile);
1766 /* We must use the same test here as we use in the DBX_NO_XREFS case
1767 above. We simplify it a bit since an enum will never have a variable
1769 if ((TYPE_NAME (type) != 0
1770 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1771 && DECL_IGNORED_P (TYPE_NAME (type)))
1773 || !COMPLETE_TYPE_P (type))
1775 fprintf (asmfile, "xe");
1777 dbxout_type_name (type);
1778 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1779 putc (':', asmfile);
1783 if (use_gnu_debug_info_extensions
1784 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1786 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1790 putc ('e', asmfile);
1792 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1794 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1795 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem)) + 1);
1796 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1797 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1798 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1799 && (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1800 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1802 print_int_cst_octal (TREE_VALUE (tem));
1804 putc (',', asmfile);
1806 if (TREE_CHAIN (tem) != 0)
1810 putc (';', asmfile);
1815 putc ('*', asmfile);
1817 dbxout_type (TREE_TYPE (type), 0);
1821 if (use_gnu_debug_info_extensions)
1823 have_used_extensions = 1;
1824 putc ('#', asmfile);
1827 /* Write the argument types out longhand. */
1828 dbxout_type (TYPE_METHOD_BASETYPE (type), 0);
1829 putc (',', asmfile);
1831 dbxout_type (TREE_TYPE (type), 0);
1832 dbxout_args (TYPE_ARG_TYPES (type));
1833 putc (';', asmfile);
1837 /* Treat it as a function type. */
1838 dbxout_type (TREE_TYPE (type), 0);
1842 if (use_gnu_debug_info_extensions)
1844 have_used_extensions = 1;
1845 putc ('@', asmfile);
1847 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0);
1848 putc (',', asmfile);
1850 dbxout_type (TREE_TYPE (type), 0);
1853 /* Should print as an int, because it is really just an offset. */
1854 dbxout_type (integer_type_node, 0);
1857 case REFERENCE_TYPE:
1858 if (use_gnu_debug_info_extensions)
1859 have_used_extensions = 1;
1860 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1862 dbxout_type (TREE_TYPE (type), 0);
1866 putc ('f', asmfile);
1868 dbxout_type (TREE_TYPE (type), 0);
1876 /* Return nonzero if the given type represents an integer whose bounds
1877 should be printed in octal format. */
1880 print_int_cst_bounds_in_octal_p (tree type)
1882 /* If we can use GDB extensions and the size is wider than a long
1883 (the size used by GDB to read them) or we may have trouble writing
1884 the bounds the usual way, write them in octal. Note the test is for
1885 the *target's* size of "long", not that of the host. The host test
1886 is just to make sure we can write it out in case the host wide int
1887 is narrower than the target "long".
1889 For unsigned types, we use octal if they are the same size or larger.
1890 This is because we print the bounds as signed decimal, and hence they
1891 can't span same size unsigned types. */
1893 if (use_gnu_debug_info_extensions
1894 && TYPE_MIN_VALUE (type) != 0
1895 && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
1896 && TYPE_MAX_VALUE (type) != 0
1897 && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
1898 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1899 || ((TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
1900 && TREE_UNSIGNED (type))
1901 || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT
1902 || (TYPE_PRECISION (type) == HOST_BITS_PER_WIDE_INT
1903 && TREE_UNSIGNED (type))))
1909 /* Print the value of integer constant C, in octal,
1910 handling double precision. */
1913 print_int_cst_octal (tree c)
1915 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1916 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1917 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1918 unsigned int width = TYPE_PRECISION (TREE_TYPE (c));
1920 /* GDB wants constants with no extra leading "1" bits, so
1921 we need to remove any sign-extension that might be
1923 if (width == HOST_BITS_PER_WIDE_INT * 2)
1925 else if (width > HOST_BITS_PER_WIDE_INT)
1926 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1927 else if (width == HOST_BITS_PER_WIDE_INT)
1930 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1932 fprintf (asmfile, "0");
1937 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1938 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1942 unsigned HOST_WIDE_INT beg = high >> excess;
1943 unsigned HOST_WIDE_INT middle
1944 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1945 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1946 unsigned HOST_WIDE_INT end
1947 = low & (((unsigned HOST_WIDE_INT) 1
1948 << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1951 fprintf (asmfile, "%o%01o", (int) beg, (int) middle);
1953 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1958 print_octal (unsigned HOST_WIDE_INT value, int digits)
1962 for (i = digits - 1; i >= 0; i--)
1963 fprintf (asmfile, "%01o", (int) ((value >> (3 * i)) & 7));
1968 /* Output C in decimal while adjusting the number of digits written. */
1971 print_wide_int (HOST_WIDE_INT c)
1975 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, c);
1986 /* Output the name of type TYPE, with no punctuation.
1987 Such names can be set up either by typedef declarations
1988 or by struct, enum and union tags. */
1991 dbxout_type_name (tree type)
1994 if (TYPE_NAME (type) == 0)
1996 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
1998 t = TYPE_NAME (type);
2000 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
2002 t = DECL_NAME (TYPE_NAME (type));
2007 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
2008 CHARS (IDENTIFIER_LENGTH (t));
2011 /* Output leading leading struct or class names needed for qualifying
2012 type whose scope is limited to a struct or class. */
2015 dbxout_class_name_qualifiers (tree decl)
2017 tree context = decl_type_context (decl);
2019 if (context != NULL_TREE
2020 && TREE_CODE(context) == RECORD_TYPE
2021 && TYPE_NAME (context) != 0
2022 && (TREE_CODE (TYPE_NAME (context)) == IDENTIFIER_NODE
2023 || (DECL_NAME (TYPE_NAME (context)) != 0)))
2025 tree name = TYPE_NAME (context);
2027 emit_pending_bincls_if_required ();
2029 if (TREE_CODE (name) == TYPE_DECL)
2031 dbxout_class_name_qualifiers (name);
2032 name = DECL_NAME (name);
2034 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
2035 CHARS (IDENTIFIER_LENGTH (name) + 2);
2039 /* Output a .stabs for the symbol defined by DECL,
2040 which must be a ..._DECL node in the normal namespace.
2041 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
2042 LOCAL is nonzero if the scope is less than the entire file.
2043 Return 1 if a stabs might have been emitted. */
2046 dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
2048 tree type = TREE_TYPE (decl);
2049 tree context = NULL_TREE;
2052 /* "Intercept" dbxout_symbol() calls like we do all debug_hooks. */
2055 /* Ignore nameless syms, but don't ignore type tags. */
2057 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
2058 || DECL_IGNORED_P (decl))
2059 DBXOUT_DECR_NESTING_AND_RETURN (0);
2061 /* If we are to generate only the symbols actually used then such
2062 symbol nodees are flagged with TREE_USED. Ignore any that
2063 aren't flaged as TREE_USED. */
2065 if (flag_debug_only_used_symbols)
2069 if (!TREE_USED (decl)
2070 && (TREE_CODE (decl) != VAR_DECL || !DECL_INITIAL (decl)))
2071 DBXOUT_DECR_NESTING_AND_RETURN (0);
2073 /* We now have a used symbol. We need to generate the info for
2074 the symbol's type in addition to the symbol itself. These
2075 type symbols are queued to be generated after were done with
2076 the symbol itself (done because the symbol's info is generated
2077 with fprintf's, etc. as it determines what's needed).
2079 Note, because the TREE_TYPE(type) might be something like a
2080 pointer to a named type we need to look for the first name
2081 we see following the TREE_TYPE chain. */
2084 while (POINTER_TYPE_P (t))
2087 /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE
2088 need special treatment. The TYPE_STUB_DECL field in these
2089 types generally represents the tag name type we want to
2090 output. In addition there could be a typedef type with
2091 a different name. In that case we also want to output
2094 if ((TREE_CODE (t) == RECORD_TYPE
2095 || TREE_CODE (t) == UNION_TYPE
2096 || TREE_CODE (t) == QUAL_UNION_TYPE
2097 || TREE_CODE (t) == ENUMERAL_TYPE)
2098 && TYPE_STUB_DECL (t)
2099 && TYPE_STUB_DECL (t) != decl
2100 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (t))) == 'd'
2101 && ! DECL_IGNORED_P (TYPE_STUB_DECL (t)))
2103 debug_queue_symbol (TYPE_STUB_DECL (t));
2105 && TYPE_NAME (t) != TYPE_STUB_DECL (t)
2106 && TYPE_NAME (t) != decl
2107 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t))) == 'd')
2108 debug_queue_symbol (TYPE_NAME (t));
2110 else if (TYPE_NAME (t)
2111 && TYPE_NAME (t) != decl
2112 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t))) == 'd')
2113 debug_queue_symbol (TYPE_NAME (t));
2116 emit_pending_bincls_if_required ();
2118 dbxout_prepare_symbol (decl);
2120 /* The output will always start with the symbol name,
2121 so always count that in the length-output-so-far. */
2123 if (DECL_NAME (decl) != 0)
2124 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
2126 switch (TREE_CODE (decl))
2129 /* Enum values are defined by defining the enum type. */
2133 if (DECL_RTL (decl) == 0)
2134 DBXOUT_DECR_NESTING_AND_RETURN (0);
2135 if (DECL_EXTERNAL (decl))
2137 /* Don't mention a nested function under its parent. */
2138 context = decl_function_context (decl);
2139 if (context == current_function_decl)
2141 if (GET_CODE (DECL_RTL (decl)) != MEM
2142 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
2146 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2147 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
2148 TREE_PUBLIC (decl) ? 'F' : 'f');
2151 current_sym_code = N_FUN;
2152 current_sym_addr = XEXP (DECL_RTL (decl), 0);
2154 if (TREE_TYPE (type))
2155 dbxout_type (TREE_TYPE (type), 0);
2157 dbxout_type (void_type_node, 0);
2159 /* For a nested function, when that function is compiled,
2160 mention the containing function name
2161 as well as (since dbx wants it) our own assembler-name. */
2163 fprintf (asmfile, ",%s,%s",
2164 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
2165 IDENTIFIER_POINTER (DECL_NAME (context)));
2167 dbxout_finish_symbol (decl);
2171 /* Don't output the same typedef twice.
2172 And don't output what language-specific stuff doesn't want output. */
2173 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
2174 DBXOUT_DECR_NESTING_AND_RETURN (0);
2182 if (DECL_NAME (decl))
2184 /* Nonzero means we must output a tag as well as a typedef. */
2187 /* Handle the case of a C++ structure or union
2188 where the TYPE_NAME is a TYPE_DECL
2189 which gives both a typedef name and a tag. */
2190 /* dbx requires the tag first and the typedef second. */
2191 if ((TREE_CODE (type) == RECORD_TYPE
2192 || TREE_CODE (type) == UNION_TYPE
2193 || TREE_CODE (type) == QUAL_UNION_TYPE)
2194 && TYPE_NAME (type) == decl
2195 && !(use_gnu_debug_info_extensions && have_used_extensions)
2196 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
2197 /* Distinguish the implicit typedefs of C++
2198 from explicit ones that might be found in C. */
2199 && DECL_ARTIFICIAL (decl)
2200 /* Do not generate a tag for incomplete records. */
2201 && COMPLETE_TYPE_P (type)
2202 /* Do not generate a tag for records of variable size,
2203 since this type can not be properly described in the
2204 DBX format, and it confuses some tools such as objdump. */
2205 && host_integerp (TYPE_SIZE (type), 1))
2207 tree name = TYPE_NAME (type);
2208 if (TREE_CODE (name) == TYPE_DECL)
2209 name = DECL_NAME (name);
2211 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2212 current_sym_value = 0;
2213 current_sym_addr = 0;
2214 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2216 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
2217 IDENTIFIER_POINTER (name));
2218 dbxout_type (type, 1);
2219 dbxout_finish_symbol (NULL_TREE);
2222 /* Output .stabs (or whatever) and leading double quote. */
2223 fprintf (asmfile, "%s\"", ASM_STABS_OP);
2225 if (use_gnu_debug_info_extensions)
2227 /* Output leading class/struct qualifiers. */
2228 dbxout_class_name_qualifiers (decl);
2231 /* Output typedef name. */
2232 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl)));
2234 /* Short cut way to output a tag also. */
2235 if ((TREE_CODE (type) == RECORD_TYPE
2236 || TREE_CODE (type) == UNION_TYPE
2237 || TREE_CODE (type) == QUAL_UNION_TYPE)
2238 && TYPE_NAME (type) == decl
2239 /* Distinguish the implicit typedefs of C++
2240 from explicit ones that might be found in C. */
2241 && DECL_ARTIFICIAL (decl))
2243 if (use_gnu_debug_info_extensions && have_used_extensions)
2245 putc ('T', asmfile);
2246 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
2248 #if 0 /* Now we generate the tag for this case up above. */
2254 putc ('t', asmfile);
2255 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2257 dbxout_type (type, 1);
2258 dbxout_finish_symbol (decl);
2262 /* Don't output a tag if this is an incomplete type. This prevents
2263 the sun4 Sun OS 4.x dbx from crashing. */
2265 if (tag_needed && TYPE_NAME (type) != 0
2266 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
2267 || (DECL_NAME (TYPE_NAME (type)) != 0))
2268 && COMPLETE_TYPE_P (type)
2269 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
2271 /* For a TYPE_DECL with no name, but the type has a name,
2273 This is what represents `struct foo' with no typedef. */
2274 /* In C++, the name of a type is the corresponding typedef.
2275 In C, it is an IDENTIFIER_NODE. */
2276 tree name = TYPE_NAME (type);
2277 if (TREE_CODE (name) == TYPE_DECL)
2278 name = DECL_NAME (name);
2280 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2281 current_sym_value = 0;
2282 current_sym_addr = 0;
2283 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2285 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
2286 IDENTIFIER_POINTER (name));
2287 dbxout_type (type, 1);
2288 dbxout_finish_symbol (NULL_TREE);
2292 /* If an enum type has no name, it cannot be referred to,
2293 but we must output it anyway, since the enumeration constants
2294 can be referred to. */
2295 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
2297 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2298 current_sym_value = 0;
2299 current_sym_addr = 0;
2300 current_sym_nchars = 2;
2302 /* Some debuggers fail when given NULL names, so give this a
2303 harmless name of ` '. */
2304 fprintf (asmfile, "%s\" :T", ASM_STABS_OP);
2305 dbxout_type (type, 1);
2306 dbxout_finish_symbol (NULL_TREE);
2309 /* Prevent duplicate output of a typedef. */
2310 TREE_ASM_WRITTEN (decl) = 1;
2315 /* Parm decls go in their own separate chains
2316 and are output by dbxout_reg_parms and dbxout_parms. */
2320 /* Named return value, treat like a VAR_DECL. */
2322 if (! DECL_RTL_SET_P (decl))
2323 DBXOUT_DECR_NESTING_AND_RETURN (0);
2324 /* Don't mention a variable that is external.
2325 Let the file that defines it describe it. */
2326 if (DECL_EXTERNAL (decl))
2329 /* If the variable is really a constant
2330 and not written in memory, inform the debugger. */
2331 if (TREE_STATIC (decl) && TREE_READONLY (decl)
2332 && DECL_INITIAL (decl) != 0
2333 && host_integerp (DECL_INITIAL (decl), 0)
2334 && ! TREE_ASM_WRITTEN (decl)
2335 && (DECL_CONTEXT (decl) == NULL_TREE
2336 || TREE_CODE (DECL_CONTEXT (decl)) == BLOCK))
2338 if (TREE_PUBLIC (decl) == 0)
2340 /* The sun4 assembler does not grok this. */
2341 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
2343 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
2344 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
2346 HOST_WIDE_INT ival = tree_low_cst (DECL_INITIAL (decl), 0);
2347 fprintf (asmfile, "%s\"%s:c=i" HOST_WIDE_INT_PRINT_DEC
2349 ASM_STABS_OP, name, ival, N_LSYM);
2350 DBXOUT_DECR_NESTING;
2353 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
2355 /* Don't know how to do this yet. */
2359 /* else it is something we handle like a normal variable. */
2362 SET_DECL_RTL (decl, eliminate_regs (DECL_RTL (decl), 0, NULL_RTX));
2363 #ifdef LEAF_REG_REMAP
2364 if (current_function_uses_only_leaf_regs)
2365 leaf_renumber_regs_insn (DECL_RTL (decl));
2368 result = dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
2374 DBXOUT_DECR_NESTING;
2378 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2379 Add SUFFIX to its name, if SUFFIX is not 0.
2380 Describe the variable as residing in HOME
2381 (usually HOME is DECL_RTL (DECL), but not always).
2382 Returns 1 if the stab was really emitted. */
2385 dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
2390 emit_pending_bincls_if_required ();
2392 /* Don't mention a variable at all
2393 if it was completely optimized into nothingness.
2395 If the decl was from an inline function, then its rtl
2396 is not identically the rtl that was used in this
2397 particular compilation. */
2398 if (GET_CODE (home) == SUBREG)
2402 while (GET_CODE (value) == SUBREG)
2403 value = SUBREG_REG (value);
2404 if (GET_CODE (value) == REG)
2406 if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
2409 home = alter_subreg (&home);
2411 if (GET_CODE (home) == REG)
2413 regno = REGNO (home);
2414 if (regno >= FIRST_PSEUDO_REGISTER)
2418 /* The kind-of-variable letter depends on where
2419 the variable is and on the scope of its name:
2420 G and N_GSYM for static storage and global scope,
2421 S for static storage and file scope,
2422 V for static storage and local scope,
2423 for those two, use N_LCSYM if data is in bss segment,
2424 N_STSYM if in data segment, N_FUN otherwise.
2425 (We used N_FUN originally, then changed to N_STSYM
2426 to please GDB. However, it seems that confused ld.
2427 Now GDB has been fixed to like N_FUN, says Kingdon.)
2428 no letter at all, and N_LSYM, for auto variable,
2429 r and N_RSYM for register variable. */
2431 if (GET_CODE (home) == MEM
2432 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
2434 if (TREE_PUBLIC (decl))
2437 current_sym_code = N_GSYM;
2441 current_sym_addr = XEXP (home, 0);
2443 letter = decl_function_context (decl) ? 'V' : 'S';
2445 /* This should be the same condition as in assemble_variable, but
2446 we don't have access to dont_output_data here. So, instead,
2447 we rely on the fact that error_mark_node initializers always
2448 end up in bss for C++ and never end up in bss for C. */
2449 if (DECL_INITIAL (decl) == 0
2450 || (!strcmp (lang_hooks.name, "GNU C++")
2451 && DECL_INITIAL (decl) == error_mark_node))
2452 current_sym_code = N_LCSYM;
2453 else if (DECL_IN_TEXT_SECTION (decl))
2454 /* This is not quite right, but it's the closest
2455 of all the codes that Unix defines. */
2456 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
2459 /* Some ports can transform a symbol ref into a label ref,
2460 because the symbol ref is too far away and has to be
2461 dumped into a constant pool. Alternatively, the symbol
2462 in the constant pool might be referenced by a different
2464 if (GET_CODE (current_sym_addr) == SYMBOL_REF
2465 && CONSTANT_POOL_ADDRESS_P (current_sym_addr))
2467 rtx tmp = get_pool_constant (current_sym_addr);
2469 if (GET_CODE (tmp) == SYMBOL_REF
2470 || GET_CODE (tmp) == LABEL_REF)
2471 current_sym_addr = tmp;
2474 /* Ultrix `as' seems to need this. */
2475 #ifdef DBX_STATIC_STAB_DATA_SECTION
2478 current_sym_code = N_STSYM;
2482 else if (regno >= 0)
2485 current_sym_code = N_RSYM;
2486 current_sym_value = DBX_REGISTER_NUMBER (regno);
2488 else if (GET_CODE (home) == MEM
2489 && (GET_CODE (XEXP (home, 0)) == MEM
2490 || (GET_CODE (XEXP (home, 0)) == REG
2491 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
2492 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
2493 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2494 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
2497 /* If the value is indirect by memory or by a register
2498 that isn't the frame pointer
2499 then it means the object is variable-sized and address through
2500 that register or stack slot. DBX has no way to represent this
2501 so all we can do is output the variable as a pointer.
2502 If it's not a parameter, ignore it.
2503 (VAR_DECLs like this can be made by integrate.c.) */
2505 if (GET_CODE (XEXP (home, 0)) == REG)
2508 current_sym_code = N_RSYM;
2509 if (REGNO (XEXP (home, 0)) >= FIRST_PSEUDO_REGISTER)
2511 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2515 current_sym_code = N_LSYM;
2516 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2517 We want the value of that CONST_INT. */
2519 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2522 /* Effectively do build_pointer_type, but don't cache this type,
2523 since it might be temporary whereas the type it points to
2524 might have been saved for inlining. */
2525 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2526 type = make_node (POINTER_TYPE);
2527 TREE_TYPE (type) = TREE_TYPE (decl);
2529 else if (GET_CODE (home) == MEM
2530 && GET_CODE (XEXP (home, 0)) == REG)
2532 current_sym_code = N_LSYM;
2533 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2535 else if (GET_CODE (home) == MEM
2536 && GET_CODE (XEXP (home, 0)) == PLUS
2537 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2539 current_sym_code = N_LSYM;
2540 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2541 We want the value of that CONST_INT. */
2542 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2544 else if (GET_CODE (home) == MEM
2545 && GET_CODE (XEXP (home, 0)) == CONST)
2547 /* Handle an obscure case which can arise when optimizing and
2548 when there are few available registers. (This is *always*
2549 the case for i386/i486 targets). The RTL looks like
2550 (MEM (CONST ...)) even though this variable is a local `auto'
2551 or a local `register' variable. In effect, what has happened
2552 is that the reload pass has seen that all assignments and
2553 references for one such a local variable can be replaced by
2554 equivalent assignments and references to some static storage
2555 variable, thereby avoiding the need for a register. In such
2556 cases we're forced to lie to debuggers and tell them that
2557 this variable was itself `static'. */
2558 current_sym_code = N_LCSYM;
2560 current_sym_addr = XEXP (XEXP (home, 0), 0);
2562 else if (GET_CODE (home) == CONCAT)
2566 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2567 for example), then there is no easy way to figure out
2568 what SUBTYPE should be. So, we give up. */
2569 if (TREE_CODE (type) != COMPLEX_TYPE)
2572 subtype = TREE_TYPE (type);
2574 /* If the variable's storage is in two parts,
2575 output each as a separate stab with a modified name. */
2576 if (WORDS_BIG_ENDIAN)
2577 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2579 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2581 dbxout_prepare_symbol (decl);
2583 if (WORDS_BIG_ENDIAN)
2584 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2586 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2590 /* Address might be a MEM, when DECL is a variable-sized object.
2591 Or it might be const0_rtx, meaning previous passes
2592 want us to ignore this variable. */
2595 /* Ok, start a symtab entry and output the variable name. */
2598 #ifdef DBX_STATIC_BLOCK_START
2599 DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2602 dbxout_symbol_name (decl, suffix, letter);
2603 dbxout_type (type, 0);
2604 dbxout_finish_symbol (decl);
2606 #ifdef DBX_STATIC_BLOCK_END
2607 DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2612 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2613 Then output LETTER to indicate the kind of location the symbol has. */
2616 dbxout_symbol_name (tree decl, const char *suffix, int letter)
2620 if (DECL_CONTEXT (decl)
2621 && (TYPE_P (DECL_CONTEXT (decl))
2622 || TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL))
2623 /* One slight hitch: if this is a VAR_DECL which is a class member
2624 or a namespace member, we must put out the mangled name instead of the
2625 DECL_NAME. Note also that static member (variable) names DO NOT begin
2626 with underscores in .stabs directives. */
2627 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2629 /* ...but if we're function-local, we don't want to include the junk
2630 added by ASM_FORMAT_PRIVATE_NAME. */
2631 name = IDENTIFIER_POINTER (DECL_NAME (decl));
2635 fprintf (asmfile, "%s\"%s%s:", ASM_STABS_OP, name,
2636 (suffix ? suffix : ""));
2639 putc (letter, asmfile);
2643 dbxout_prepare_symbol (tree decl ATTRIBUTE_UNUSED)
2646 const char *filename = DECL_SOURCE_FILE (decl);
2648 dbxout_source_file (asmfile, filename);
2651 /* Initialize variables used to communicate each symbol's debug
2652 information to dbxout_finish_symbol with zeroes. */
2654 /* Cast avoids warning in old compilers. */
2655 current_sym_code = (STAB_CODE_TYPE) 0;
2656 current_sym_value = 0;
2657 current_sym_addr = 0;
2661 dbxout_finish_symbol (tree sym)
2663 #ifdef DBX_FINISH_SYMBOL
2664 DBX_FINISH_SYMBOL (sym);
2667 if (use_gnu_debug_info_extensions && sym != 0)
2668 line = DECL_SOURCE_LINE (sym);
2670 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2671 if (current_sym_addr)
2672 output_addr_const (asmfile, current_sym_addr);
2674 fprintf (asmfile, "%d", current_sym_value);
2675 putc ('\n', asmfile);
2679 /* Output definitions of all the decls in a chain. Return nonzero if
2680 anything was output */
2683 dbxout_syms (tree syms)
2688 result += dbxout_symbol (syms, 1);
2689 syms = TREE_CHAIN (syms);
2694 /* The following two functions output definitions of function parameters.
2695 Each parameter gets a definition locating it in the parameter list.
2696 Each parameter that is a register variable gets a second definition
2697 locating it in the register.
2699 Printing or argument lists in gdb uses the definitions that
2700 locate in the parameter list. But reference to the variable in
2701 expressions uses preferentially the definition as a register. */
2703 /* Output definitions, referring to storage in the parmlist,
2704 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2707 dbxout_parms (tree parms)
2711 emit_pending_bincls_if_required ();
2713 for (; parms; parms = TREE_CHAIN (parms))
2714 if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2716 dbxout_prepare_symbol (parms);
2718 /* Perform any necessary register eliminations on the parameter's rtl,
2719 so that the debugging output will be accurate. */
2720 DECL_INCOMING_RTL (parms)
2721 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2722 SET_DECL_RTL (parms, eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
2723 #ifdef LEAF_REG_REMAP
2724 if (current_function_uses_only_leaf_regs)
2726 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2727 leaf_renumber_regs_insn (DECL_RTL (parms));
2731 if (PARM_PASSED_IN_MEMORY (parms))
2733 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2735 /* ??? Here we assume that the parm address is indexed
2736 off the frame pointer or arg pointer.
2737 If that is not true, we produce meaningless results,
2738 but do not crash. */
2739 if (GET_CODE (addr) == PLUS
2740 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2741 current_sym_value = INTVAL (XEXP (addr, 1));
2743 current_sym_value = 0;
2745 current_sym_code = N_PSYM;
2746 current_sym_addr = 0;
2749 if (DECL_NAME (parms))
2751 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2753 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2754 IDENTIFIER_POINTER (DECL_NAME (parms)),
2755 DBX_MEMPARM_STABS_LETTER);
2759 current_sym_nchars = 8;
2760 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2761 DBX_MEMPARM_STABS_LETTER);
2764 /* It is quite tempting to use:
2766 dbxout_type (TREE_TYPE (parms), 0);
2768 as the next statement, rather than using DECL_ARG_TYPE(), so
2769 that gcc reports the actual type of the parameter, rather
2770 than the promoted type. This certainly makes GDB's life
2771 easier, at least for some ports. The change is a bad idea
2772 however, since GDB expects to be able access the type without
2773 performing any conversions. So for example, if we were
2774 passing a float to an unprototyped function, gcc will store a
2775 double on the stack, but if we emit a stab saying the type is a
2776 float, then gdb will only read in a single value, and this will
2777 produce an erroneous value. */
2778 dbxout_type (DECL_ARG_TYPE (parms), 0);
2779 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2780 dbxout_finish_symbol (parms);
2782 else if (GET_CODE (DECL_RTL (parms)) == REG)
2785 char regparm_letter;
2787 /* Parm passed in registers and lives in registers or nowhere. */
2789 current_sym_code = DBX_REGPARM_STABS_CODE;
2790 regparm_letter = DBX_REGPARM_STABS_LETTER;
2791 current_sym_addr = 0;
2793 /* If parm lives in a register, use that register;
2794 pretend the parm was passed there. It would be more consistent
2795 to describe the register where the parm was passed,
2796 but in practice that register usually holds something else.
2798 If we use DECL_RTL, then we must use the declared type of
2799 the variable, not the type that it arrived in. */
2800 if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2802 best_rtl = DECL_RTL (parms);
2803 parm_type = TREE_TYPE (parms);
2805 /* If the parm lives nowhere, use the register where it was
2806 passed. It is also better to use the declared type here. */
2809 best_rtl = DECL_INCOMING_RTL (parms);
2810 parm_type = TREE_TYPE (parms);
2812 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2815 if (DECL_NAME (parms))
2817 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2818 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2819 IDENTIFIER_POINTER (DECL_NAME (parms)),
2824 current_sym_nchars = 8;
2825 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2829 dbxout_type (parm_type, 0);
2830 dbxout_finish_symbol (parms);
2832 else if (GET_CODE (DECL_RTL (parms)) == MEM
2833 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2834 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2835 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2836 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2837 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2841 /* Parm was passed via invisible reference.
2842 That is, its address was passed in a register.
2843 Output it as if it lived in that register.
2844 The debugger will know from the type
2845 that it was actually passed by invisible reference. */
2847 char regparm_letter;
2848 /* Parm passed in registers and lives in registers or nowhere. */
2850 current_sym_code = DBX_REGPARM_STABS_CODE;
2851 if (use_gnu_debug_info_extensions)
2852 regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2854 regparm_letter = DBX_REGPARM_STABS_LETTER;
2856 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2857 If it is an unallocated pseudo-reg, then use the register where
2858 it was passed instead. */
2859 if (REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2860 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2862 current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2864 current_sym_addr = 0;
2867 if (DECL_NAME (parms))
2870 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2872 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2873 IDENTIFIER_POINTER (DECL_NAME (parms)),
2878 current_sym_nchars = 8;
2879 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2883 dbxout_type (TREE_TYPE (parms), 0);
2884 dbxout_finish_symbol (parms);
2886 else if (GET_CODE (DECL_RTL (parms)) == MEM
2887 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2889 /* Parm was passed via invisible reference, with the reference
2890 living on the stack. DECL_RTL looks like
2891 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2892 could look like (MEM (MEM (REG))). */
2893 const char *const decl_name = (DECL_NAME (parms)
2894 ? IDENTIFIER_POINTER (DECL_NAME (parms))
2896 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 0)) == REG)
2897 current_sym_value = 0;
2900 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1));
2901 current_sym_addr = 0;
2902 current_sym_code = N_PSYM;
2905 fprintf (asmfile, "%s\"%s:v", ASM_STABS_OP, decl_name);
2908 = DEBUGGER_ARG_OFFSET (current_sym_value,
2909 XEXP (XEXP (DECL_RTL (parms), 0), 0));
2910 dbxout_type (TREE_TYPE (parms), 0);
2911 dbxout_finish_symbol (parms);
2913 else if (GET_CODE (DECL_RTL (parms)) == MEM
2914 && XEXP (DECL_RTL (parms), 0) != const0_rtx
2915 /* ??? A constant address for a parm can happen
2916 when the reg it lives in is equiv to a constant in memory.
2917 Should make this not happen, after 2.4. */
2918 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2920 /* Parm was passed in registers but lives on the stack. */
2922 current_sym_code = N_PSYM;
2923 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2924 in which case we want the value of that CONST_INT,
2926 in which case we use a value of zero. */
2927 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG)
2928 current_sym_value = 0;
2931 = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2933 current_sym_addr = 0;
2935 /* Make a big endian correction if the mode of the type of the
2936 parameter is not the same as the mode of the rtl. */
2937 if (BYTES_BIG_ENDIAN
2938 && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms))
2939 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD)
2941 current_sym_value +=
2942 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))
2943 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms)));
2947 if (DECL_NAME (parms))
2950 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2952 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2953 IDENTIFIER_POINTER (DECL_NAME (parms)),
2954 DBX_MEMPARM_STABS_LETTER);
2958 current_sym_nchars = 8;
2959 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2960 DBX_MEMPARM_STABS_LETTER);
2964 = DEBUGGER_ARG_OFFSET (current_sym_value,
2965 XEXP (DECL_RTL (parms), 0));
2966 dbxout_type (TREE_TYPE (parms), 0);
2967 dbxout_finish_symbol (parms);
2970 DBXOUT_DECR_NESTING;
2973 /* Output definitions for the places where parms live during the function,
2974 when different from where they were passed, when the parms were passed
2977 It is not useful to do this for parms passed in registers
2978 that live during the function in different registers, because it is
2979 impossible to look in the passed register for the passed value,
2980 so we use the within-the-function register to begin with.
2982 PARMS is a chain of PARM_DECL nodes. */
2985 dbxout_reg_parms (tree parms)
2989 for (; parms; parms = TREE_CHAIN (parms))
2990 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
2992 dbxout_prepare_symbol (parms);
2994 /* Report parms that live in registers during the function
2995 but were passed in memory. */
2996 if (GET_CODE (DECL_RTL (parms)) == REG
2997 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2998 dbxout_symbol_location (parms, TREE_TYPE (parms),
2999 0, DECL_RTL (parms));
3000 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
3001 dbxout_symbol_location (parms, TREE_TYPE (parms),
3002 0, DECL_RTL (parms));
3003 /* Report parms that live in memory but not where they were passed. */
3004 else if (GET_CODE (DECL_RTL (parms)) == MEM
3005 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
3006 dbxout_symbol_location (parms, TREE_TYPE (parms),
3007 0, DECL_RTL (parms));
3009 DBXOUT_DECR_NESTING;
3012 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
3013 output definitions of those names, in raw form */
3016 dbxout_args (tree args)
3020 putc (',', asmfile);
3021 dbxout_type (TREE_VALUE (args), 0);
3023 args = TREE_CHAIN (args);
3027 /* Output everything about a symbol block (a BLOCK node
3028 that represents a scope level),
3029 including recursive output of contained blocks.
3031 BLOCK is the BLOCK node.
3032 DEPTH is its depth within containing symbol blocks.
3033 ARGS is usually zero; but for the outermost block of the
3034 body of a function, it is a chain of PARM_DECLs for the function parameters.
3035 We output definitions of all the register parms
3036 as if they were local variables of that block.
3038 If -g1 was used, we count blocks just the same, but output nothing
3039 except for the outermost block.
3041 Actually, BLOCK may be several blocks chained together.
3042 We handle them all in sequence. */
3045 dbxout_block (tree block, int depth, tree args)
3049 #if DBX_BLOCKS_FUNCTION_RELATIVE
3050 const char *begin_label;
3051 if (current_function_func_begin_label != NULL_TREE)
3052 begin_label = IDENTIFIER_POINTER (current_function_func_begin_label);
3054 begin_label = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
3059 /* Ignore blocks never expanded or otherwise marked as real. */
3060 if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
3064 /* In dbx format, the syms of a block come before the N_LBRAC.
3065 If nothing is output, we don't need the N_LBRAC, either. */
3067 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
3068 did_output = dbxout_syms (BLOCK_VARS (block));
3070 dbxout_reg_parms (args);
3072 /* Now output an N_LBRAC symbol to represent the beginning of
3073 the block. Use the block's tree-walk order to generate
3074 the assembler symbols LBBn and LBEn
3075 that final will define around the code in this block. */
3076 if (depth > 0 && did_output)
3079 blocknum = BLOCK_NUMBER (block);
3080 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
3082 if (BLOCK_HANDLER_BLOCK (block))
3084 /* A catch block. Must precede N_LBRAC. */
3085 tree decl = BLOCK_VARS (block);
3088 fprintf (asmfile, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP,
3089 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
3090 assemble_name (asmfile, buf);
3091 fprintf (asmfile, "\n");
3092 decl = TREE_CHAIN (decl);
3096 #ifdef DBX_OUTPUT_LBRAC
3097 DBX_OUTPUT_LBRAC (asmfile, buf);
3099 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
3100 assemble_name (asmfile, buf);
3101 #if DBX_BLOCKS_FUNCTION_RELATIVE
3102 putc ('-', asmfile);
3103 assemble_name (asmfile, begin_label);
3105 fprintf (asmfile, "\n");
3109 /* Output the subblocks. */
3110 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
3112 /* Refer to the marker for the end of the block. */
3113 if (depth > 0 && did_output)
3116 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
3117 #ifdef DBX_OUTPUT_RBRAC
3118 DBX_OUTPUT_RBRAC (asmfile, buf);
3120 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC);
3121 assemble_name (asmfile, buf);
3122 #if DBX_BLOCKS_FUNCTION_RELATIVE
3123 putc ('-', asmfile);
3124 assemble_name (asmfile, begin_label);
3126 fprintf (asmfile, "\n");
3130 block = BLOCK_CHAIN (block);
3134 /* Output the information about a function and its arguments and result.
3135 Usually this follows the function's code,
3136 but on some systems, it comes before. */
3138 #if defined (DBX_DEBUGGING_INFO)
3140 dbxout_begin_function (tree decl)
3142 int saved_tree_used1 = TREE_USED (decl);
3143 TREE_USED (decl) = 1;
3144 if (DECL_NAME (DECL_RESULT (decl)) != 0)
3146 int saved_tree_used2 = TREE_USED (DECL_RESULT (decl));
3147 TREE_USED (DECL_RESULT (decl)) = 1;
3148 dbxout_symbol (decl, 0);
3149 TREE_USED (DECL_RESULT (decl)) = saved_tree_used2;
3152 dbxout_symbol (decl, 0);
3153 TREE_USED (decl) = saved_tree_used1;
3155 dbxout_parms (DECL_ARGUMENTS (decl));
3156 if (DECL_NAME (DECL_RESULT (decl)) != 0)
3157 dbxout_symbol (DECL_RESULT (decl), 1);
3159 #endif /* DBX_DEBUGGING_INFO */
3161 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3163 #include "gt-dbxout.h"