1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 /* Output dbx-format symbol table data.
24 This consists of many symbol table entries, each of them
25 a .stabs assembler pseudo-op with four operands:
26 a "name" which is really a description of one symbol and its type,
27 a "code", which is a symbol defined in stab.h whose name starts with N_,
28 an unused operand always 0,
29 and a "value" which is an address or an offset.
30 The name is enclosed in doublequote characters.
32 Each function, variable, typedef, and structure tag
33 has a symbol table entry to define it.
34 The beginning and end of each level of name scoping within
35 a function are also marked by special symbol table entries.
37 The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
38 and a data type number. The data type number may be followed by
39 "=" and a type definition; normally this will happen the first time
40 the type number is mentioned. The type definition may refer to
41 other types by number, and those type numbers may be followed
42 by "=" and nested definitions.
44 This can make the "name" quite long.
45 When a name is more than 80 characters, we split the .stabs pseudo-op
46 into two .stabs pseudo-ops, both sharing the same "code" and "value".
47 The first one is marked as continued with a double-backslash at the
50 The kind-of-symbol letter distinguished function names from global
51 variables from file-scope variables from parameters from auto
52 variables in memory from typedef names from register variables.
55 The "code" is mostly redundant with the kind-of-symbol letter
56 that goes in the "name", but not entirely: for symbols located
57 in static storage, the "code" says which segment the address is in,
58 which controls how it is relocated.
60 The "value" for a symbol in static storage
61 is the core address of the symbol (actually, the assembler
62 label for the symbol). For a symbol located in a stack slot
63 it is the stack offset; for one in a register, the register number.
64 For a typedef symbol, it is zero.
66 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
67 output while in the text section.
69 For more on data type definitions, see `dbxout_type'. */
73 #include "coretypes.h"
80 #include "insn-config.h"
82 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
90 #include "langhooks.h"
92 #ifdef XCOFF_DEBUGGING_INFO
96 #undef DBXOUT_DECR_NESTING
97 #define DBXOUT_DECR_NESTING \
98 if (--debug_nesting == 0 && symbol_queue_index > 0) \
99 { emit_pending_bincls_if_required (); debug_flush_symbol_queue (); }
101 #undef DBXOUT_DECR_NESTING_AND_RETURN
102 #define DBXOUT_DECR_NESTING_AND_RETURN(x) \
103 do {--debug_nesting; return (x);} while (0)
106 #define ASM_STABS_OP "\t.stabs\t"
110 #define ASM_STABN_OP "\t.stabn\t"
113 #ifndef DBX_TYPE_DECL_STABS_CODE
114 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
117 #ifndef DBX_STATIC_CONST_VAR_CODE
118 #define DBX_STATIC_CONST_VAR_CODE N_FUN
121 #ifndef DBX_REGPARM_STABS_CODE
122 #define DBX_REGPARM_STABS_CODE N_RSYM
125 #ifndef DBX_REGPARM_STABS_LETTER
126 #define DBX_REGPARM_STABS_LETTER 'P'
129 /* This is used for parameters passed by invisible reference in a register. */
130 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
131 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
134 #ifndef DBX_MEMPARM_STABS_LETTER
135 #define DBX_MEMPARM_STABS_LETTER 'p'
138 #ifndef FILE_NAME_JOINER
139 #define FILE_NAME_JOINER "/"
142 /* GDB needs to know that the stabs were generated by GCC. We emit an
143 N_OPT stab at the beginning of the source file to indicate this.
144 The string is historical, and different on a very few targets. */
145 #ifndef STABS_GCC_MARKER
146 #define STABS_GCC_MARKER "gcc2_compiled."
149 enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
151 /* Structure recording information about a C data type.
152 The status element says whether we have yet output
153 the definition of the type. TYPE_XREF says we have
154 output it as a cross-reference only.
155 The file_number and type_number elements are used if DBX_USE_BINCL
158 struct typeinfo GTY(())
160 enum typestatus status;
165 /* Vector recording information about C data types.
166 When we first notice a data type (a tree node),
167 we assign it a number using next_type_number.
168 That is its index in this vector. */
170 static GTY ((length ("typevec_len"))) struct typeinfo *typevec;
172 /* Number of elements of space allocated in `typevec'. */
174 static GTY(()) int typevec_len;
176 /* In dbx output, each type gets a unique number.
177 This is the number for the next type output.
178 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
180 static GTY(()) int next_type_number;
182 /* The C front end may call dbxout_symbol before dbxout_init runs.
183 We save all such decls in this list and output them when we get
186 static GTY(()) tree preinit_symbols;
188 enum binclstatus {BINCL_NOT_REQUIRED, BINCL_PENDING, BINCL_PROCESSED};
190 /* When using N_BINCL in dbx output, each type number is actually a
191 pair of the file number and the type number within the file.
192 This is a stack of input files. */
196 struct dbx_file *next;
198 int next_type_number;
199 enum binclstatus bincl_status; /* Keep track of lazy bincl. */
200 const char *pending_bincl_name; /* Name of bincl. */
201 struct dbx_file *prev; /* Chain to traverse all pending bincls. */
204 /* This is the top of the stack.
206 This is not saved for PCH, because restoring a PCH should not change it.
207 next_file_number does have to be saved, because the PCH may use some
208 file numbers; however, just before restoring a PCH, next_file_number
209 should always be 0 because we should not have needed any file numbers
212 #if (defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)) \
213 && defined (DBX_USE_BINCL)
214 static struct dbx_file *current_file;
217 /* This is the next file number to use. */
219 static GTY(()) int next_file_number;
221 /* A counter for dbxout_function_end. */
223 static GTY(()) int scope_labelno;
225 /* A counter for dbxout_source_line. */
227 static GTY(()) int dbxout_source_line_counter;
229 /* Nonzero if we have actually used any of the GDB extensions
230 to the debugging format. The idea is that we use them for the
231 first time only if there's a strong reason, but once we have done that,
232 we use them whenever convenient. */
234 static GTY(()) int have_used_extensions = 0;
236 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
237 for the N_SO filename stabs label. */
239 static GTY(()) int source_label_number = 1;
241 /* Last source file name mentioned in a NOTE insn. */
243 static GTY(()) const char *lastfile;
245 /* Used by PCH machinery to detect if 'lastfile' should be reset to
247 static GTY(()) int lastfile_is_base;
249 /* Typical USG systems don't have stab.h, and they also have
250 no use for DBX-format debugging info. */
252 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
255 /* If zero then there is no pending BINCL. */
256 static int pending_bincls = 0;
259 /* The original input file name. */
260 static const char *base_input_file;
262 /* Current working directory. */
264 static const char *cwd;
266 #ifdef DEBUG_SYMS_TEXT
267 #define FORCE_TEXT function_section (current_function_decl);
274 #define STAB_CODE_TYPE enum __stab_debug_code
276 /* 1 if PARM is passed to this function in memory. */
278 #define PARM_PASSED_IN_MEMORY(PARM) \
279 (MEM_P (DECL_INCOMING_RTL (PARM)))
281 /* A C expression for the integer offset value of an automatic variable
282 (N_LSYM) having address X (an RTX). */
283 #ifndef DEBUGGER_AUTO_OFFSET
284 #define DEBUGGER_AUTO_OFFSET(X) \
285 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
288 /* A C expression for the integer offset value of an argument (N_PSYM)
289 having address X (an RTX). The nominal offset is OFFSET. */
290 #ifndef DEBUGGER_ARG_OFFSET
291 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
294 /* Stream for writing to assembler file. */
296 static FILE *asmfile;
298 /* These variables are for dbxout_symbol to communicate to
299 dbxout_finish_symbol.
300 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
301 current_sym_value and current_sym_addr are two ways to address the
302 value to store in the symtab entry.
303 current_sym_addr if nonzero represents the value as an rtx.
304 If that is zero, current_sym_value is used. This is used
305 when the value is an offset (such as for auto variables,
306 register variables and parms). */
308 static STAB_CODE_TYPE current_sym_code;
309 static int current_sym_value;
310 static rtx current_sym_addr;
312 /* Number of chars of symbol-description generated so far for the
313 current symbol. Used by CHARS and CONTIN. */
315 static int current_sym_nchars;
317 /* Report having output N chars of the current symbol-description. */
319 #define CHARS(N) (current_sym_nchars += (N))
321 /* Break the current symbol-description, generating a continuation,
322 if it has become long. */
324 #ifndef DBX_CONTIN_LENGTH
325 #define DBX_CONTIN_LENGTH 80
328 #if DBX_CONTIN_LENGTH > 0
330 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
332 #define CONTIN do { } while (0)
336 static void emit_bincl_stab (const char *c);
337 static void emit_pending_bincls (void);
339 static inline void emit_pending_bincls_if_required (void);
341 static void dbxout_init (const char *);
342 static void dbxout_finish (const char *);
343 static void dbxout_start_source_file (unsigned, const char *);
344 static void dbxout_end_source_file (unsigned);
345 static void dbxout_typedefs (tree);
346 static void dbxout_type_index (tree);
347 #if DBX_CONTIN_LENGTH > 0
348 static void dbxout_continue (void);
350 static void dbxout_args (tree);
351 static void dbxout_type_fields (tree);
352 static void dbxout_type_method_1 (tree, const char *);
353 static void dbxout_type_methods (tree);
354 static void dbxout_range_type (tree);
355 static void dbxout_type (tree, int);
356 static bool print_int_cst_bounds_in_octal_p (tree);
357 static void print_int_cst_octal (tree);
358 static void print_octal (unsigned HOST_WIDE_INT, int);
359 static void print_wide_int (HOST_WIDE_INT);
360 static void dbxout_type_name (tree);
361 static void dbxout_class_name_qualifiers (tree);
362 static int dbxout_symbol_location (tree, tree, const char *, rtx);
363 static void dbxout_symbol_name (tree, const char *, int);
364 static void dbxout_prepare_symbol (tree);
365 static void dbxout_finish_symbol (tree);
366 static void dbxout_block (tree, int, tree);
367 static void dbxout_global_decl (tree);
368 static void dbxout_type_decl (tree, int);
369 static void dbxout_handle_pch (unsigned);
371 /* The debug hooks structure. */
372 #if defined (DBX_DEBUGGING_INFO)
374 static void dbxout_source_line (unsigned int, const char *);
375 static void dbxout_source_file (FILE *, const char *);
376 static void dbxout_function_end (void);
377 static void dbxout_begin_function (tree);
378 static void dbxout_begin_block (unsigned, unsigned);
379 static void dbxout_end_block (unsigned, unsigned);
380 static void dbxout_function_decl (tree);
382 const struct gcc_debug_hooks dbx_debug_hooks =
386 debug_nothing_int_charstar,
387 debug_nothing_int_charstar,
388 dbxout_start_source_file,
389 dbxout_end_source_file,
392 debug_true_tree, /* ignore_block */
393 dbxout_source_line, /* source_line */
394 dbxout_source_line, /* begin_prologue: just output
396 debug_nothing_int_charstar, /* end_prologue */
397 debug_nothing_int_charstar, /* end_epilogue */
398 #ifdef DBX_FUNCTION_FIRST
399 dbxout_begin_function,
401 debug_nothing_tree, /* begin_function */
403 debug_nothing_int, /* end_function */
404 dbxout_function_decl,
405 dbxout_global_decl, /* global_decl */
406 dbxout_type_decl, /* type_decl */
407 debug_nothing_tree_tree, /* imported_module_or_decl */
408 debug_nothing_tree, /* deferred_inline_function */
409 debug_nothing_tree, /* outlining_inline_function */
410 debug_nothing_rtx, /* label */
411 dbxout_handle_pch, /* handle_pch */
412 debug_nothing_rtx /* var_location */
414 #endif /* DBX_DEBUGGING_INFO */
416 #if defined (XCOFF_DEBUGGING_INFO)
417 const struct gcc_debug_hooks xcoff_debug_hooks =
421 debug_nothing_int_charstar,
422 debug_nothing_int_charstar,
423 dbxout_start_source_file,
424 dbxout_end_source_file,
425 xcoffout_begin_block,
427 debug_true_tree, /* ignore_block */
428 xcoffout_source_line,
429 xcoffout_begin_prologue, /* begin_prologue */
430 debug_nothing_int_charstar, /* end_prologue */
431 xcoffout_end_epilogue,
432 debug_nothing_tree, /* begin_function */
433 xcoffout_end_function,
434 debug_nothing_tree, /* function_decl */
435 dbxout_global_decl, /* global_decl */
436 dbxout_type_decl, /* type_decl */
437 debug_nothing_tree_tree, /* imported_module_or_decl */
438 debug_nothing_tree, /* deferred_inline_function */
439 debug_nothing_tree, /* outlining_inline_function */
440 debug_nothing_rtx, /* label */
441 dbxout_handle_pch, /* handle_pch */
442 debug_nothing_rtx /* var_location */
444 #endif /* XCOFF_DEBUGGING_INFO */
446 #if defined (DBX_DEBUGGING_INFO)
448 dbxout_function_end (void)
450 char lscope_label_name[100];
452 function_section (current_function_decl);
454 /* Convert Ltext into the appropriate format for local labels in case
455 the system doesn't insert underscores in front of user generated
457 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
458 targetm.asm_out.internal_label (asmfile, "Lscope", scope_labelno);
461 /* By convention, GCC will mark the end of a function with an N_FUN
462 symbol and an empty string. */
463 #ifdef DBX_OUTPUT_NFUN
464 DBX_OUTPUT_NFUN (asmfile, lscope_label_name, current_function_decl);
466 fprintf (asmfile, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN);
467 assemble_name (asmfile, lscope_label_name);
469 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
470 fprintf (asmfile, "\n");
473 #endif /* DBX_DEBUGGING_INFO */
475 /* At the beginning of compilation, start writing the symbol table.
476 Initialize `typevec' and output the standard data types of C. */
479 dbxout_init (const char *input_file_name)
481 char ltext_label_name[100];
482 tree syms = lang_hooks.decls.getdecls ();
484 asmfile = asm_out_file;
487 typevec = ggc_calloc (typevec_len, sizeof typevec[0]);
489 /* Convert Ltext into the appropriate format for local labels in case
490 the system doesn't insert underscores in front of user generated
492 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
494 /* Put the current working directory in an N_SO symbol. */
495 if (use_gnu_debug_info_extensions)
497 if (!cwd && (cwd = get_src_pwd ())
498 && (!*cwd || cwd[strlen (cwd) - 1] != '/'))
499 cwd = concat (cwd, FILE_NAME_JOINER, NULL);
502 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
503 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
504 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
505 fprintf (asmfile, "%s", ASM_STABS_OP);
506 output_quoted_string (asmfile, cwd);
507 fprintf (asmfile, ",%d,0,0,", N_SO);
508 assemble_name (asmfile, ltext_label_name);
509 fputc ('\n', asmfile);
510 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
514 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
515 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
516 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
517 /* We include outputting `Ltext:' here,
518 because that gives you a way to override it. */
519 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
520 fprintf (asmfile, "%s", ASM_STABS_OP);
521 output_quoted_string (asmfile, input_file_name);
522 fprintf (asmfile, ",%d,0,0,", N_SO);
523 assemble_name (asmfile, ltext_label_name);
524 fputc ('\n', asmfile);
526 targetm.asm_out.internal_label (asmfile, "Ltext", 0);
527 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
529 #ifdef DBX_OUTPUT_GCC_MARKER
530 DBX_OUTPUT_GCC_MARKER (asmfile);
532 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
533 fprintf (asmfile, "%s\"%s\",%d,0,0,0\n",
534 ASM_STABS_OP, STABS_GCC_MARKER, N_OPT);
537 base_input_file = lastfile = input_file_name;
539 next_type_number = 1;
542 current_file = xmalloc (sizeof *current_file);
543 current_file->next = NULL;
544 current_file->file_number = 0;
545 current_file->next_type_number = 1;
546 next_file_number = 1;
547 current_file->prev = NULL;
548 current_file->bincl_status = BINCL_NOT_REQUIRED;
549 current_file->pending_bincl_name = NULL;
552 /* Get all permanent types that have typedef names, and output them
553 all, except for those already output. Some language front ends
554 put these declarations in the top-level scope; some do not;
555 the latter are responsible for calling debug_hooks->type_decl from
556 their record_builtin_type function. */
557 dbxout_typedefs (syms);
562 for (t = nreverse (preinit_symbols); t; t = TREE_CHAIN (t))
563 dbxout_symbol (TREE_VALUE (t), 0);
568 /* Output any typedef names for types described by TYPE_DECLs in SYMS. */
571 dbxout_typedefs (tree syms)
573 for (; syms != NULL_TREE; syms = TREE_CHAIN (syms))
575 if (TREE_CODE (syms) == TYPE_DECL)
577 tree type = TREE_TYPE (syms);
579 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
580 && COMPLETE_OR_VOID_TYPE_P (type)
581 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
582 dbxout_symbol (TYPE_NAME (type), 0);
588 /* Emit BINCL stab using given name. */
590 emit_bincl_stab (const char *name)
592 fprintf (asmfile, "%s", ASM_STABS_OP);
593 output_quoted_string (asmfile, name);
594 fprintf (asmfile, ",%d,0,0,0\n", N_BINCL);
597 /* If there are pending bincls then it is time to emit all of them. */
600 emit_pending_bincls_if_required (void)
603 emit_pending_bincls ();
606 /* Emit all pending bincls. */
609 emit_pending_bincls (void)
611 struct dbx_file *f = current_file;
613 /* Find first pending bincl. */
614 while (f->bincl_status == BINCL_PENDING)
617 /* Now emit all bincls. */
622 if (f->bincl_status == BINCL_PENDING)
624 emit_bincl_stab (f->pending_bincl_name);
626 /* Update file number and status. */
627 f->file_number = next_file_number++;
628 f->bincl_status = BINCL_PROCESSED;
630 if (f == current_file)
635 /* All pending bincls have been emitted. */
642 emit_pending_bincls_if_required (void) {}
645 /* Change to reading from a new source file. Generate a N_BINCL stab. */
648 dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
649 const char *filename ATTRIBUTE_UNUSED)
652 struct dbx_file *n = xmalloc (sizeof *n);
654 n->next = current_file;
655 n->next_type_number = 1;
656 /* Do not assign file number now.
657 Delay it until we actually emit BINCL. */
660 current_file->prev = n;
661 n->bincl_status = BINCL_PENDING;
662 n->pending_bincl_name = filename;
668 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
671 dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED)
674 /* Emit EINCL stab only if BINCL is not pending. */
675 if (current_file->bincl_status == BINCL_PROCESSED)
676 fprintf (asmfile, "%s%d,0,0,0\n", ASM_STABN_OP, N_EINCL);
677 current_file->bincl_status = BINCL_NOT_REQUIRED;
678 current_file = current_file->next;
682 /* Handle a few odd cases that occur when trying to make PCH files work. */
685 dbxout_handle_pch (unsigned at_end)
689 /* When using the PCH, this file will be included, so we need to output
691 dbxout_start_source_file (0, lastfile);
693 /* The base file when using the PCH won't be the same as
694 the base file when it's being generated. */
699 /* ... and an EINCL. */
700 dbxout_end_source_file (0);
702 /* Deal with cases where 'lastfile' was never actually changed. */
703 lastfile_is_base = lastfile == NULL;
707 #if defined (DBX_DEBUGGING_INFO)
708 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
711 dbxout_source_file (FILE *file, const char *filename)
713 if (lastfile == 0 && lastfile_is_base)
715 lastfile = base_input_file;
716 lastfile_is_base = 0;
719 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
721 char ltext_label_name[100];
723 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
724 source_label_number);
725 fprintf (file, "%s", ASM_STABS_OP);
726 output_quoted_string (file, filename);
727 fprintf (asmfile, ",%d,0,0,", N_SOL);
728 assemble_name (asmfile, ltext_label_name);
729 fputc ('\n', asmfile);
730 if (current_function_decl != NULL_TREE
731 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
732 ; /* Don't change section amid function. */
735 if (!in_text_section () && !in_unlikely_text_section ())
738 targetm.asm_out.internal_label (file, "Ltext", source_label_number);
739 source_label_number++;
744 /* Output a line number symbol entry for source file FILENAME and line
748 dbxout_source_line (unsigned int lineno, const char *filename)
750 dbxout_source_file (asmfile, filename);
752 #ifdef ASM_OUTPUT_SOURCE_LINE
753 dbxout_source_line_counter += 1;
754 ASM_OUTPUT_SOURCE_LINE (asmfile, lineno, dbxout_source_line_counter);
756 fprintf (asmfile, "%s%d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
760 /* Describe the beginning of an internal block within a function. */
763 dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
765 emit_pending_bincls_if_required ();
766 targetm.asm_out.internal_label (asmfile, "LBB", n);
769 /* Describe the end line-number of an internal block within a function. */
772 dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
774 emit_pending_bincls_if_required ();
775 targetm.asm_out.internal_label (asmfile, "LBE", n);
778 /* Output dbx data for a function definition.
779 This includes a definition of the function name itself (a symbol),
780 definitions of the parameters (locating them in the parameter list)
781 and then output the block that makes up the function's body
782 (including all the auto variables of the function). */
785 dbxout_function_decl (tree decl)
787 emit_pending_bincls_if_required ();
788 #ifndef DBX_FUNCTION_FIRST
789 dbxout_begin_function (decl);
791 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
792 #ifdef DBX_OUTPUT_FUNCTION_END
793 DBX_OUTPUT_FUNCTION_END (asmfile, decl);
795 if (use_gnu_debug_info_extensions
796 #if defined(NO_DBX_FUNCTION_END)
797 && ! NO_DBX_FUNCTION_END
799 && targetm.have_named_sections)
800 dbxout_function_end ();
803 #endif /* DBX_DEBUGGING_INFO */
805 /* Debug information for a global DECL. Called from toplev.c after
806 compilation proper has finished. */
808 dbxout_global_decl (tree decl)
810 if (TREE_CODE (decl) == VAR_DECL
811 && ! DECL_EXTERNAL (decl)
812 && DECL_RTL_SET_P (decl)) /* Not necessary? */
814 int saved_tree_used = TREE_USED (decl);
815 TREE_USED (decl) = 1;
816 dbxout_symbol (decl, 0);
817 TREE_USED (decl) = saved_tree_used;
821 /* This is just a function-type adapter; dbxout_symbol does exactly
822 what we want but returns an int. */
824 dbxout_type_decl (tree decl, int local)
826 dbxout_symbol (decl, local);
829 /* At the end of compilation, finish writing the symbol table.
830 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
834 dbxout_finish (const char *filename ATTRIBUTE_UNUSED)
836 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
837 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile, filename);
838 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
843 /* Output the index of a type. */
846 dbxout_type_index (tree type)
848 #ifndef DBX_USE_BINCL
849 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
852 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
853 fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number);
858 #if DBX_CONTIN_LENGTH > 0
859 /* Continue a symbol-description that gets too big.
860 End one symbol table entry with a double-backslash
861 and start a new one, eventually producing something like
862 .stabs "start......\\",code,0,value
863 .stabs "...rest",code,0,value */
866 dbxout_continue (void)
868 emit_pending_bincls_if_required ();
869 #ifdef DBX_CONTIN_CHAR
870 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
872 fprintf (asmfile, "\\\\");
874 dbxout_finish_symbol (NULL_TREE);
875 fprintf (asmfile, "%s\"", ASM_STABS_OP);
876 current_sym_nchars = 0;
878 #endif /* DBX_CONTIN_LENGTH > 0 */
880 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
881 This must be a separate function because anonymous unions require
885 dbxout_type_fields (tree type)
889 /* Output the name, type, position (in bits), size (in bits) of each
890 field that we can support. */
891 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
893 /* If one of the nodes is an error_mark or its type is then
895 if (tem == error_mark_node || TREE_TYPE (tem) == error_mark_node)
898 /* Omit here local type decls until we know how to support them. */
899 if (TREE_CODE (tem) == TYPE_DECL
900 /* Omit fields whose position or size are variable or too large to
902 || (TREE_CODE (tem) == FIELD_DECL
903 && (! host_integerp (bit_position (tem), 0)
905 || ! host_integerp (DECL_SIZE (tem), 1)))
906 /* Omit here the nameless fields that are used to skip bits. */
907 || DECL_IGNORED_P (tem))
910 else if (TREE_CODE (tem) != CONST_DECL)
912 /* Continue the line if necessary,
913 but not before the first field. */
914 if (tem != TYPE_FIELDS (type))
919 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
920 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
924 fprintf (asmfile, ":");
928 if (use_gnu_debug_info_extensions
929 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
930 || TREE_CODE (tem) != FIELD_DECL))
932 have_used_extensions = 1;
934 putc ((TREE_PRIVATE (tem) ? '0'
935 : TREE_PROTECTED (tem) ? '1' : '2'),
940 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
941 && DECL_BIT_FIELD_TYPE (tem))
942 ? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0);
944 if (TREE_CODE (tem) == VAR_DECL)
946 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
948 tree name = DECL_ASSEMBLER_NAME (tem);
950 have_used_extensions = 1;
951 fprintf (asmfile, ":%s;", IDENTIFIER_POINTER (name));
952 CHARS (IDENTIFIER_LENGTH (name) + 2);
956 /* If TEM is non-static, GDB won't understand it. */
957 fprintf (asmfile, ",0,0;");
964 print_wide_int (int_bit_position (tem));
966 print_wide_int (tree_low_cst (DECL_SIZE (tem), 1));
974 /* Subroutine of `dbxout_type_methods'. Output debug info about the
975 method described DECL. DEBUG_NAME is an encoding of the method's
976 type signature. ??? We may be able to do without DEBUG_NAME altogether
980 dbxout_type_method_1 (tree decl, const char *debug_name)
984 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
986 else /* it's a METHOD_TYPE. */
988 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
989 /* A for normal functions.
990 B for `const' member functions.
991 C for `volatile' member functions.
992 D for `const volatile' member functions. */
993 if (TYPE_READONLY (TREE_TYPE (firstarg)))
995 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
998 if (DECL_VINDEX (decl))
1004 fprintf (asmfile, ":%s;%c%c%c", debug_name,
1005 TREE_PRIVATE (decl) ? '0'
1006 : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
1007 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
1008 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
1010 if (DECL_VINDEX (decl) && host_integerp (DECL_VINDEX (decl), 0))
1012 print_wide_int (tree_low_cst (DECL_VINDEX (decl), 0));
1013 putc (';', asmfile);
1015 dbxout_type (DECL_CONTEXT (decl), 0);
1016 fprintf (asmfile, ";");
1021 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
1025 dbxout_type_methods (tree type)
1027 /* C++: put out the method names and their parameter lists */
1028 tree methods = TYPE_METHODS (type);
1032 char formatted_type_identifier_length[16];
1033 int type_identifier_length;
1035 if (methods == NULL_TREE)
1038 type_encoding = DECL_NAME (TYPE_NAME (type));
1041 /* C++: Template classes break some assumptions made by this code about
1042 the class names, constructor names, and encodings for assembler
1043 label names. For now, disable output of dbx info for them. */
1045 const char *ptr = IDENTIFIER_POINTER (type_encoding);
1046 /* This should use index. (mrs) */
1047 while (*ptr && *ptr != '<') ptr++;
1058 type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
1060 sprintf (formatted_type_identifier_length, "%d", type_identifier_length);
1062 if (TREE_CODE (methods) != TREE_VEC)
1064 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
1065 fndecl = TREE_VEC_ELT (methods, 0);
1067 fndecl = TREE_VEC_ELT (methods, 1);
1071 int need_prefix = 1;
1073 /* Group together all the methods for the same operation.
1074 These differ in the types of the arguments. */
1075 for (last = NULL_TREE;
1076 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
1077 fndecl = TREE_CHAIN (fndecl))
1078 /* Output the name of the field (after overloading), as
1079 well as the name of the field before overloading, along
1080 with its parameter list */
1082 /* This is the "mangled" name of the method.
1083 It encodes the argument types. */
1084 const char *debug_name;
1086 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1087 include TEMPLATE_DECLs.) The debugger doesn't know what
1088 to do with such entities anyhow. */
1089 if (TREE_CODE (fndecl) != FUNCTION_DECL)
1092 debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
1098 /* Also ignore abstract methods; those are only interesting to
1099 the DWARF backends. */
1100 if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT (fndecl))
1103 /* Redundantly output the plain name, since that's what gdb
1107 tree name = DECL_NAME (fndecl);
1108 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
1109 CHARS (IDENTIFIER_LENGTH (name) + 2);
1113 dbxout_type (TREE_TYPE (fndecl), 0);
1115 dbxout_type_method_1 (fndecl, debug_name);
1119 putc (';', asmfile);
1125 /* Emit a "range" type specification, which has the form:
1126 "r<index type>;<lower bound>;<upper bound>;".
1127 TYPE is an INTEGER_TYPE. */
1130 dbxout_range_type (tree type)
1132 fprintf (asmfile, "r");
1133 if (TREE_TYPE (type))
1134 dbxout_type (TREE_TYPE (type), 0);
1135 else if (TREE_CODE (type) != INTEGER_TYPE)
1136 dbxout_type (type, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1139 /* Traditionally, we made sure 'int' was type 1, and builtin types
1140 were defined to be sub-ranges of int. Unfortunately, this
1141 does not allow us to distinguish true sub-ranges from integer
1142 types. So, instead we define integer (non-sub-range) types as
1143 sub-ranges of themselves. This matters for Chill. If this isn't
1144 a subrange type, then we want to define it in terms of itself.
1145 However, in C, this may be an anonymous integer type, and we don't
1146 want to emit debug info referring to it. Just calling
1147 dbxout_type_index won't work anyways, because the type hasn't been
1148 defined yet. We make this work for both cases by checked to see
1149 whether this is a defined type, referring to it if it is, and using
1151 if (TYPE_SYMTAB_ADDRESS (type) != 0)
1152 dbxout_type_index (type);
1154 dbxout_type_index (integer_type_node);
1157 if (TYPE_MIN_VALUE (type) != 0
1158 && host_integerp (TYPE_MIN_VALUE (type), 0))
1160 putc (';', asmfile);
1162 if (print_int_cst_bounds_in_octal_p (type))
1163 print_int_cst_octal (TYPE_MIN_VALUE (type));
1165 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type), 0));
1169 fprintf (asmfile, ";0");
1173 if (TYPE_MAX_VALUE (type) != 0
1174 && host_integerp (TYPE_MAX_VALUE (type), 0))
1176 putc (';', asmfile);
1178 if (print_int_cst_bounds_in_octal_p (type))
1179 print_int_cst_octal (TYPE_MAX_VALUE (type));
1181 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type), 0));
1182 putc (';', asmfile);
1187 fprintf (asmfile, ";-1;");
1193 /* Output a reference to a type. If the type has not yet been
1194 described in the dbx output, output its definition now.
1195 For a type already defined, just refer to its definition
1196 using the type number.
1198 If FULL is nonzero, and the type has been described only with
1199 a forward-reference, output the definition now.
1200 If FULL is zero in this case, just refer to the forward-reference
1201 using the number previously allocated. */
1204 dbxout_type (tree type, int full)
1208 static int anonymous_type_number = 0;
1210 if (TREE_CODE (type) == VECTOR_TYPE)
1211 /* The frontend feeds us a representation for the vector as a struct
1212 containing an array. Pull out the array type. */
1213 type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type)));
1215 /* If there was an input error and we don't really have a type,
1216 avoid crashing and write something that is at least valid
1217 by assuming `int'. */
1218 if (type == error_mark_node)
1219 type = integer_type_node;
1222 if (TYPE_NAME (type)
1223 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1224 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1228 /* Try to find the "main variant" with the same name. */
1229 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1230 && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1231 main_variant = TREE_TYPE (TYPE_NAME (type));
1233 main_variant = TYPE_MAIN_VARIANT (type);
1235 /* If we are not using extensions, stabs does not distinguish const and
1236 volatile, so there is no need to make them separate types. */
1237 if (!use_gnu_debug_info_extensions)
1238 type = main_variant;
1240 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1242 /* Type has no dbx number assigned. Assign next available number. */
1243 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1245 /* Make sure type vector is long enough to record about this type. */
1247 if (next_type_number == typevec_len)
1250 = ggc_realloc (typevec, (typevec_len * 2 * sizeof typevec[0]));
1251 memset (typevec + typevec_len, 0, typevec_len * sizeof typevec[0]);
1255 #ifdef DBX_USE_BINCL
1256 emit_pending_bincls_if_required ();
1257 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1258 = current_file->file_number;
1259 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1260 = current_file->next_type_number++;
1264 if (flag_debug_only_used_symbols)
1266 if ((TREE_CODE (type) == RECORD_TYPE
1267 || TREE_CODE (type) == UNION_TYPE
1268 || TREE_CODE (type) == QUAL_UNION_TYPE
1269 || TREE_CODE (type) == ENUMERAL_TYPE)
1270 && TYPE_STUB_DECL (type)
1271 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (type))) == 'd'
1272 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type)))
1273 debug_queue_symbol (TYPE_STUB_DECL (type));
1274 else if (TYPE_NAME (type)
1275 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1276 debug_queue_symbol (TYPE_NAME (type));
1279 /* Output the number of this type, to refer to it. */
1280 dbxout_type_index (type);
1282 #ifdef DBX_TYPE_DEFINED
1283 if (DBX_TYPE_DEFINED (type))
1287 /* If this type's definition has been output or is now being output,
1290 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1295 /* If we have already had a cross reference,
1296 and either that's all we want or that's the best we could do,
1297 don't repeat the cross reference.
1298 Sun dbx crashes if we do. */
1299 if (! full || !COMPLETE_TYPE_P (type)
1300 /* No way in DBX fmt to describe a variable size. */
1301 || ! host_integerp (TYPE_SIZE (type), 1))
1309 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1310 leave the type-number completely undefined rather than output
1311 a cross-reference. If we have already used GNU debug info extensions,
1312 then it is OK to output a cross reference. This is necessary to get
1313 proper C++ debug output. */
1314 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1315 || TREE_CODE (type) == QUAL_UNION_TYPE
1316 || TREE_CODE (type) == ENUMERAL_TYPE)
1317 && ! use_gnu_debug_info_extensions)
1318 /* We must use the same test here as we use twice below when deciding
1319 whether to emit a cross-reference. */
1320 if ((TYPE_NAME (type) != 0
1321 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1322 && DECL_IGNORED_P (TYPE_NAME (type)))
1324 || !COMPLETE_TYPE_P (type)
1325 /* No way in DBX fmt to describe a variable size. */
1326 || ! host_integerp (TYPE_SIZE (type), 1))
1328 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1333 /* Output a definition now. */
1335 fprintf (asmfile, "=");
1338 /* Mark it as defined, so that if it is self-referent
1339 we will not get into an infinite recursion of definitions. */
1341 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1343 /* If this type is a variant of some other, hand off. Types with
1344 different names are usefully distinguished. We only distinguish
1345 cv-qualified types if we're using extensions. */
1346 if (TYPE_READONLY (type) > TYPE_READONLY (main_variant))
1348 putc ('k', asmfile);
1350 dbxout_type (build_type_variant (type, 0, TYPE_VOLATILE (type)), 0);
1353 else if (TYPE_VOLATILE (type) > TYPE_VOLATILE (main_variant))
1355 putc ('B', asmfile);
1357 dbxout_type (build_type_variant (type, TYPE_READONLY (type), 0), 0);
1360 else if (main_variant != TYPE_MAIN_VARIANT (type))
1362 if (flag_debug_only_used_symbols)
1364 tree orig_type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
1366 if ((TREE_CODE (orig_type) == RECORD_TYPE
1367 || TREE_CODE (orig_type) == UNION_TYPE
1368 || TREE_CODE (orig_type) == QUAL_UNION_TYPE
1369 || TREE_CODE (orig_type) == ENUMERAL_TYPE)
1370 && TYPE_STUB_DECL (orig_type)
1371 && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type)))
1372 debug_queue_symbol (TYPE_STUB_DECL (orig_type));
1374 /* 'type' is a typedef; output the type it refers to. */
1375 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0);
1378 /* else continue. */
1380 switch (TREE_CODE (type))
1384 /* For a void type, just define it as itself; ie, "5=5".
1385 This makes us consider it defined
1386 without saying what it is. The debugger will make it
1387 a void type when the reference is seen, and nothing will
1388 ever override that default. */
1389 dbxout_type_index (type);
1393 if (type == char_type_node && ! TYPE_UNSIGNED (type))
1395 /* Output the type `char' as a subrange of itself!
1396 I don't understand this definition, just copied it
1397 from the output of pcc.
1398 This used to use `r2' explicitly and we used to
1399 take care to make sure that `char' was type number 2. */
1400 fprintf (asmfile, "r");
1402 dbxout_type_index (type);
1403 fprintf (asmfile, ";0;127;");
1407 /* If this is a subtype of another integer type, always prefer to
1408 write it as a subtype. */
1409 else if (TREE_TYPE (type) != 0
1410 && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
1412 /* If the size is non-standard, say what it is if we can use
1415 if (use_gnu_debug_info_extensions
1416 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1418 have_used_extensions = 1;
1419 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1423 dbxout_range_type (type);
1428 /* If the size is non-standard, say what it is if we can use
1431 if (use_gnu_debug_info_extensions
1432 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1434 have_used_extensions = 1;
1435 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1439 if (print_int_cst_bounds_in_octal_p (type))
1441 fprintf (asmfile, "r");
1444 /* If this type derives from another type, output type index of
1445 parent type. This is particularly important when parent type
1446 is an enumerated type, because not generating the parent type
1447 index would transform the definition of this enumerated type
1448 into a plain unsigned type. */
1449 if (TREE_TYPE (type) != 0)
1450 dbxout_type_index (TREE_TYPE (type));
1452 dbxout_type_index (type);
1454 fprintf (asmfile, ";");
1456 print_int_cst_octal (TYPE_MIN_VALUE (type));
1457 fprintf (asmfile, ";");
1459 print_int_cst_octal (TYPE_MAX_VALUE (type));
1460 fprintf (asmfile, ";");
1465 /* Output other integer types as subranges of `int'. */
1466 dbxout_range_type (type);
1472 /* This used to say `r1' and we used to take care
1473 to make sure that `int' was type number 1. */
1474 fprintf (asmfile, "r");
1476 dbxout_type_index (integer_type_node);
1477 putc (';', asmfile);
1479 print_wide_int (int_size_in_bytes (type));
1480 fputs (";0;", asmfile);
1485 if (use_gnu_debug_info_extensions)
1487 have_used_extensions = 1;
1488 fputs ("@s", asmfile);
1490 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1491 fputs (";-20;", asmfile);
1496 /* Output the type `char' as a subrange of itself.
1497 That is what pcc seems to do. */
1498 fprintf (asmfile, "r");
1500 dbxout_type_index (char_type_node);
1501 fprintf (asmfile, ";0;%d;", TYPE_UNSIGNED (type) ? 255 : 127);
1507 if (use_gnu_debug_info_extensions)
1509 have_used_extensions = 1;
1510 fputs ("@s", asmfile);
1512 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1513 fputs (";-16;", asmfile);
1516 else /* Define as enumeral type (False, True) */
1518 fprintf (asmfile, "eFalse:0,True:1,;");
1524 putc ('d', asmfile);
1526 dbxout_type (TREE_TYPE (type), 0);
1530 /* Differs from the REAL_TYPE by its new data type number.
1531 R3 is NF_COMPLEX. We don't try to use any of the other NF_*
1532 codes since gdb doesn't care anyway. */
1534 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1536 fputs ("R3;", asmfile);
1538 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type)));
1539 fputs (";0;", asmfile);
1544 /* Output a complex integer type as a structure,
1545 pending some other way to do it. */
1546 putc ('s', asmfile);
1548 print_wide_int (int_size_in_bytes (type));
1549 fprintf (asmfile, "real:");
1552 dbxout_type (TREE_TYPE (type), 0);
1553 fprintf (asmfile, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type)));
1555 fprintf (asmfile, "imag:");
1557 dbxout_type (TREE_TYPE (type), 0);
1558 fprintf (asmfile, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type)),
1559 TYPE_PRECISION (TREE_TYPE (type)));
1565 if (use_gnu_debug_info_extensions)
1567 have_used_extensions = 1;
1568 fputs ("@s", asmfile);
1570 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1571 putc (';', asmfile);
1574 /* Check if a bitstring type, which in Chill is
1575 different from a [power]set. */
1576 if (TYPE_STRING_FLAG (type))
1578 fprintf (asmfile, "@S;");
1582 putc ('S', asmfile);
1584 dbxout_type (TYPE_DOMAIN (type), 0);
1588 /* Make arrays of packed bits look like bitstrings for chill. */
1589 if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
1591 have_used_extensions = 1;
1592 fputs ("@s", asmfile);
1594 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1595 fprintf (asmfile, ";@S;S");
1597 dbxout_type (TYPE_DOMAIN (type), 0);
1601 /* Output "a" followed by a range type definition
1602 for the index type of the array
1603 followed by a reference to the target-type.
1604 ar1;0;N;M for a C array of type M and size N+1. */
1605 /* Check if a character string type, which in Chill is
1606 different from an array of characters. */
1607 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1609 have_used_extensions = 1;
1610 fprintf (asmfile, "@S;");
1613 tem = TYPE_DOMAIN (type);
1616 fprintf (asmfile, "ar");
1618 dbxout_type_index (integer_type_node);
1619 fprintf (asmfile, ";0;-1;");
1624 fprintf (asmfile, "a");
1626 dbxout_range_type (tem);
1629 dbxout_type (TREE_TYPE (type), 0);
1634 case QUAL_UNION_TYPE:
1636 int i, n_baseclasses = 0;
1638 if (TYPE_BINFO (type) && BINFO_BASE_BINFOS (TYPE_BINFO (type)))
1639 n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (type));
1641 /* Output a structure type. We must use the same test here as we
1642 use in the DBX_NO_XREFS case above. */
1643 if ((TYPE_NAME (type) != 0
1644 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1645 && DECL_IGNORED_P (TYPE_NAME (type)))
1647 || !COMPLETE_TYPE_P (type)
1648 /* No way in DBX fmt to describe a variable size. */
1649 || ! host_integerp (TYPE_SIZE (type), 1))
1651 /* If the type is just a cross reference, output one
1652 and mark the type as partially described.
1653 If it later becomes defined, we will output
1654 its real definition.
1655 If the type has a name, don't nest its definition within
1656 another type's definition; instead, output an xref
1657 and let the definition come when the name is defined. */
1658 fputs ((TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu", asmfile);
1660 #if 0 /* This assertion is legitimately false in C++. */
1661 /* We shouldn't be outputting a reference to a type before its
1662 definition unless the type has a tag name.
1663 A typedef name without a tag name should be impossible. */
1664 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1667 if (TYPE_NAME (type) != 0)
1668 dbxout_type_name (type);
1671 fprintf (asmfile, "$$%d", anonymous_type_number++);
1675 fprintf (asmfile, ":");
1677 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1681 /* Identify record or union, and print its size. */
1682 putc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asmfile);
1684 print_wide_int (int_size_in_bytes (type));
1686 if (use_gnu_debug_info_extensions)
1690 have_used_extensions = 1;
1691 fprintf (asmfile, "!%d,", n_baseclasses);
1695 for (i = 0; i < n_baseclasses; i++)
1697 tree binfo = TYPE_BINFO (type);
1698 tree child = BINFO_BASE_BINFO (binfo, i);
1699 tree access = (BINFO_BASE_ACCESSES (binfo)
1700 ? BINFO_BASE_ACCESS (binfo, i) : access_public_node);
1702 if (use_gnu_debug_info_extensions)
1704 have_used_extensions = 1;
1705 putc (BINFO_VIRTUAL_P (child) ? '1' : '0', asmfile);
1706 putc (access == access_public_node ? '2' :
1707 (access == access_protected_node ? '1' :'0'),
1710 if (BINFO_VIRTUAL_P (child)
1711 && strcmp (lang_hooks.name, "GNU C++") == 0)
1712 /* For a virtual base, print the (negative) offset within
1713 the vtable where we must look to find the necessary
1715 print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child), 0)
1718 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1720 putc (',', asmfile);
1722 dbxout_type (BINFO_TYPE (child), 0);
1723 putc (';', asmfile);
1728 /* Print out the base class information with fields
1729 which have the same names at the types they hold. */
1730 dbxout_type_name (BINFO_TYPE (child));
1731 putc (':', asmfile);
1733 dbxout_type (BINFO_TYPE (child), full);
1734 putc (',', asmfile);
1736 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1738 putc (',', asmfile);
1740 print_wide_int (tree_low_cst (TYPE_SIZE (BINFO_TYPE (child)),
1743 putc (';', asmfile);
1749 /* Write out the field declarations. */
1750 dbxout_type_fields (type);
1751 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1753 have_used_extensions = 1;
1754 dbxout_type_methods (type);
1757 putc (';', asmfile);
1760 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1761 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1762 && TYPE_VFIELD (type))
1764 have_used_extensions = 1;
1766 /* Tell GDB+ that it may keep reading. */
1767 putc ('~', asmfile);
1770 /* We need to write out info about what field this class
1771 uses as its "main" vtable pointer field, because if this
1772 field is inherited from a base class, GDB cannot necessarily
1773 figure out which field it's using in time. */
1774 if (TYPE_VFIELD (type))
1776 putc ('%', asmfile);
1778 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0);
1781 putc (';', asmfile);
1787 /* We must use the same test here as we use in the DBX_NO_XREFS case
1788 above. We simplify it a bit since an enum will never have a variable
1790 if ((TYPE_NAME (type) != 0
1791 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1792 && DECL_IGNORED_P (TYPE_NAME (type)))
1794 || !COMPLETE_TYPE_P (type))
1796 fprintf (asmfile, "xe");
1798 dbxout_type_name (type);
1799 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1800 putc (':', asmfile);
1804 if (use_gnu_debug_info_extensions
1805 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1807 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1811 putc ('e', asmfile);
1813 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1815 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1816 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem)) + 1);
1817 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1818 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1819 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1820 && (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1821 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1823 print_int_cst_octal (TREE_VALUE (tem));
1825 putc (',', asmfile);
1827 if (TREE_CHAIN (tem) != 0)
1831 putc (';', asmfile);
1836 putc ('*', asmfile);
1838 dbxout_type (TREE_TYPE (type), 0);
1842 if (use_gnu_debug_info_extensions)
1844 have_used_extensions = 1;
1845 putc ('#', asmfile);
1848 /* Write the argument types out longhand. */
1849 dbxout_type (TYPE_METHOD_BASETYPE (type), 0);
1850 putc (',', asmfile);
1852 dbxout_type (TREE_TYPE (type), 0);
1853 dbxout_args (TYPE_ARG_TYPES (type));
1854 putc (';', asmfile);
1858 /* Treat it as a function type. */
1859 dbxout_type (TREE_TYPE (type), 0);
1863 if (use_gnu_debug_info_extensions)
1865 have_used_extensions = 1;
1866 putc ('@', asmfile);
1868 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0);
1869 putc (',', asmfile);
1871 dbxout_type (TREE_TYPE (type), 0);
1874 /* Should print as an int, because it is really just an offset. */
1875 dbxout_type (integer_type_node, 0);
1878 case REFERENCE_TYPE:
1879 if (use_gnu_debug_info_extensions)
1880 have_used_extensions = 1;
1881 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1883 dbxout_type (TREE_TYPE (type), 0);
1887 putc ('f', asmfile);
1889 dbxout_type (TREE_TYPE (type), 0);
1897 /* Return nonzero if the given type represents an integer whose bounds
1898 should be printed in octal format. */
1901 print_int_cst_bounds_in_octal_p (tree type)
1903 /* If we can use GDB extensions and the size is wider than a long
1904 (the size used by GDB to read them) or we may have trouble writing
1905 the bounds the usual way, write them in octal. Note the test is for
1906 the *target's* size of "long", not that of the host. The host test
1907 is just to make sure we can write it out in case the host wide int
1908 is narrower than the target "long".
1910 For unsigned types, we use octal if they are the same size or larger.
1911 This is because we print the bounds as signed decimal, and hence they
1912 can't span same size unsigned types. */
1914 if (use_gnu_debug_info_extensions
1915 && TYPE_MIN_VALUE (type) != 0
1916 && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
1917 && TYPE_MAX_VALUE (type) != 0
1918 && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
1919 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1920 || ((TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
1921 && TYPE_UNSIGNED (type))
1922 || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT
1923 || (TYPE_PRECISION (type) == HOST_BITS_PER_WIDE_INT
1924 && TYPE_UNSIGNED (type))))
1930 /* Print the value of integer constant C, in octal,
1931 handling double precision. */
1934 print_int_cst_octal (tree c)
1936 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1937 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1938 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1939 unsigned int width = TYPE_PRECISION (TREE_TYPE (c));
1941 /* GDB wants constants with no extra leading "1" bits, so
1942 we need to remove any sign-extension that might be
1944 if (width == HOST_BITS_PER_WIDE_INT * 2)
1946 else if (width > HOST_BITS_PER_WIDE_INT)
1947 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1948 else if (width == HOST_BITS_PER_WIDE_INT)
1951 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1953 fprintf (asmfile, "0");
1958 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1959 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1963 unsigned HOST_WIDE_INT beg = high >> excess;
1964 unsigned HOST_WIDE_INT middle
1965 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1966 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1967 unsigned HOST_WIDE_INT end
1968 = low & (((unsigned HOST_WIDE_INT) 1
1969 << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1972 fprintf (asmfile, "%o%01o", (int) beg, (int) middle);
1974 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1979 print_octal (unsigned HOST_WIDE_INT value, int digits)
1983 for (i = digits - 1; i >= 0; i--)
1984 fprintf (asmfile, "%01o", (int) ((value >> (3 * i)) & 7));
1989 /* Output C in decimal while adjusting the number of digits written. */
1992 print_wide_int (HOST_WIDE_INT c)
1996 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, c);
2007 /* Output the name of type TYPE, with no punctuation.
2008 Such names can be set up either by typedef declarations
2009 or by struct, enum and union tags. */
2012 dbxout_type_name (tree type)
2015 if (TYPE_NAME (type) == 0)
2017 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
2019 t = TYPE_NAME (type);
2021 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
2023 t = DECL_NAME (TYPE_NAME (type));
2028 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
2029 CHARS (IDENTIFIER_LENGTH (t));
2032 /* Output leading leading struct or class names needed for qualifying
2033 type whose scope is limited to a struct or class. */
2036 dbxout_class_name_qualifiers (tree decl)
2038 tree context = decl_type_context (decl);
2040 if (context != NULL_TREE
2041 && TREE_CODE(context) == RECORD_TYPE
2042 && TYPE_NAME (context) != 0
2043 && (TREE_CODE (TYPE_NAME (context)) == IDENTIFIER_NODE
2044 || (DECL_NAME (TYPE_NAME (context)) != 0)))
2046 tree name = TYPE_NAME (context);
2048 emit_pending_bincls_if_required ();
2050 if (TREE_CODE (name) == TYPE_DECL)
2052 dbxout_class_name_qualifiers (name);
2053 name = DECL_NAME (name);
2055 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
2056 CHARS (IDENTIFIER_LENGTH (name) + 2);
2060 /* Output a .stabs for the symbol defined by DECL,
2061 which must be a ..._DECL node in the normal namespace.
2062 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
2063 LOCAL is nonzero if the scope is less than the entire file.
2064 Return 1 if a stabs might have been emitted. */
2067 dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
2069 tree type = TREE_TYPE (decl);
2070 tree context = NULL_TREE;
2073 /* "Intercept" dbxout_symbol() calls like we do all debug_hooks. */
2076 /* Ignore nameless syms, but don't ignore type tags. */
2078 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
2079 || DECL_IGNORED_P (decl))
2080 DBXOUT_DECR_NESTING_AND_RETURN (0);
2082 /* If we are to generate only the symbols actually used then such
2083 symbol nodees are flagged with TREE_USED. Ignore any that
2084 aren't flaged as TREE_USED. */
2086 if (flag_debug_only_used_symbols
2087 && (!TREE_USED (decl)
2088 && (TREE_CODE (decl) != VAR_DECL || !DECL_INITIAL (decl))))
2089 DBXOUT_DECR_NESTING_AND_RETURN (0);
2091 /* If dbxout_init has not yet run, queue this symbol for later. */
2094 preinit_symbols = tree_cons (0, decl, preinit_symbols);
2095 DBXOUT_DECR_NESTING_AND_RETURN (0);
2098 if (flag_debug_only_used_symbols)
2102 /* We now have a used symbol. We need to generate the info for
2103 the symbol's type in addition to the symbol itself. These
2104 type symbols are queued to be generated after were done with
2105 the symbol itself (done because the symbol's info is generated
2106 with fprintf's, etc. as it determines what's needed).
2108 Note, because the TREE_TYPE(type) might be something like a
2109 pointer to a named type we need to look for the first name
2110 we see following the TREE_TYPE chain. */
2113 while (POINTER_TYPE_P (t))
2116 /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE
2117 need special treatment. The TYPE_STUB_DECL field in these
2118 types generally represents the tag name type we want to
2119 output. In addition there could be a typedef type with
2120 a different name. In that case we also want to output
2123 if ((TREE_CODE (t) == RECORD_TYPE
2124 || TREE_CODE (t) == UNION_TYPE
2125 || TREE_CODE (t) == QUAL_UNION_TYPE
2126 || TREE_CODE (t) == ENUMERAL_TYPE)
2127 && TYPE_STUB_DECL (t)
2128 && TYPE_STUB_DECL (t) != decl
2129 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (t))) == 'd'
2130 && ! DECL_IGNORED_P (TYPE_STUB_DECL (t)))
2132 debug_queue_symbol (TYPE_STUB_DECL (t));
2134 && TYPE_NAME (t) != TYPE_STUB_DECL (t)
2135 && TYPE_NAME (t) != decl
2136 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t))) == 'd')
2137 debug_queue_symbol (TYPE_NAME (t));
2139 else if (TYPE_NAME (t)
2140 && TYPE_NAME (t) != decl
2141 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t))) == 'd')
2142 debug_queue_symbol (TYPE_NAME (t));
2145 emit_pending_bincls_if_required ();
2147 dbxout_prepare_symbol (decl);
2149 /* The output will always start with the symbol name,
2150 so always count that in the length-output-so-far. */
2152 if (DECL_NAME (decl) != 0)
2153 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
2155 switch (TREE_CODE (decl))
2158 /* Enum values are defined by defining the enum type. */
2162 if (DECL_RTL (decl) == 0)
2163 DBXOUT_DECR_NESTING_AND_RETURN (0);
2164 if (DECL_EXTERNAL (decl))
2166 /* Don't mention a nested function under its parent. */
2167 context = decl_function_context (decl);
2168 if (context == current_function_decl)
2170 if (!MEM_P (DECL_RTL (decl))
2171 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
2175 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2176 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
2177 TREE_PUBLIC (decl) ? 'F' : 'f');
2180 current_sym_code = N_FUN;
2181 current_sym_addr = XEXP (DECL_RTL (decl), 0);
2183 if (TREE_TYPE (type))
2184 dbxout_type (TREE_TYPE (type), 0);
2186 dbxout_type (void_type_node, 0);
2188 /* For a nested function, when that function is compiled,
2189 mention the containing function name
2190 as well as (since dbx wants it) our own assembler-name. */
2192 fprintf (asmfile, ",%s,%s",
2193 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
2194 IDENTIFIER_POINTER (DECL_NAME (context)));
2196 dbxout_finish_symbol (decl);
2200 /* Don't output the same typedef twice.
2201 And don't output what language-specific stuff doesn't want output. */
2202 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
2203 DBXOUT_DECR_NESTING_AND_RETURN (0);
2205 /* Don't output typedefs for types with magic type numbers (XCOFF). */
2206 #ifdef DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER
2208 int fundamental_type_number =
2209 DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER (decl);
2211 if (fundamental_type_number != 0)
2213 TREE_ASM_WRITTEN (decl) = 1;
2214 TYPE_SYMTAB_ADDRESS (TREE_TYPE (decl)) = fundamental_type_number;
2215 DBXOUT_DECR_NESTING_AND_RETURN (0);
2225 if (DECL_NAME (decl))
2227 /* Nonzero means we must output a tag as well as a typedef. */
2230 /* Handle the case of a C++ structure or union
2231 where the TYPE_NAME is a TYPE_DECL
2232 which gives both a typedef name and a tag. */
2233 /* dbx requires the tag first and the typedef second. */
2234 if ((TREE_CODE (type) == RECORD_TYPE
2235 || TREE_CODE (type) == UNION_TYPE
2236 || TREE_CODE (type) == QUAL_UNION_TYPE)
2237 && TYPE_NAME (type) == decl
2238 && !(use_gnu_debug_info_extensions && have_used_extensions)
2239 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
2240 /* Distinguish the implicit typedefs of C++
2241 from explicit ones that might be found in C. */
2242 && DECL_ARTIFICIAL (decl)
2243 /* Do not generate a tag for incomplete records. */
2244 && COMPLETE_TYPE_P (type)
2245 /* Do not generate a tag for records of variable size,
2246 since this type can not be properly described in the
2247 DBX format, and it confuses some tools such as objdump. */
2248 && host_integerp (TYPE_SIZE (type), 1))
2250 tree name = TYPE_NAME (type);
2251 if (TREE_CODE (name) == TYPE_DECL)
2252 name = DECL_NAME (name);
2254 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2255 current_sym_value = 0;
2256 current_sym_addr = 0;
2257 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2259 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
2260 IDENTIFIER_POINTER (name));
2261 dbxout_type (type, 1);
2262 dbxout_finish_symbol (NULL_TREE);
2265 /* Output .stabs (or whatever) and leading double quote. */
2266 fprintf (asmfile, "%s\"", ASM_STABS_OP);
2268 if (use_gnu_debug_info_extensions)
2270 /* Output leading class/struct qualifiers. */
2271 dbxout_class_name_qualifiers (decl);
2274 /* Output typedef name. */
2275 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl)));
2277 /* Short cut way to output a tag also. */
2278 if ((TREE_CODE (type) == RECORD_TYPE
2279 || TREE_CODE (type) == UNION_TYPE
2280 || TREE_CODE (type) == QUAL_UNION_TYPE)
2281 && TYPE_NAME (type) == decl
2282 /* Distinguish the implicit typedefs of C++
2283 from explicit ones that might be found in C. */
2284 && DECL_ARTIFICIAL (decl))
2286 if (use_gnu_debug_info_extensions && have_used_extensions)
2288 putc ('T', asmfile);
2289 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
2291 #if 0 /* Now we generate the tag for this case up above. */
2297 putc ('t', asmfile);
2298 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2300 dbxout_type (type, 1);
2301 dbxout_finish_symbol (decl);
2305 /* Don't output a tag if this is an incomplete type. This prevents
2306 the sun4 Sun OS 4.x dbx from crashing. */
2308 if (tag_needed && TYPE_NAME (type) != 0
2309 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
2310 || (DECL_NAME (TYPE_NAME (type)) != 0))
2311 && COMPLETE_TYPE_P (type)
2312 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
2314 /* For a TYPE_DECL with no name, but the type has a name,
2316 This is what represents `struct foo' with no typedef. */
2317 /* In C++, the name of a type is the corresponding typedef.
2318 In C, it is an IDENTIFIER_NODE. */
2319 tree name = TYPE_NAME (type);
2320 if (TREE_CODE (name) == TYPE_DECL)
2321 name = DECL_NAME (name);
2323 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2324 current_sym_value = 0;
2325 current_sym_addr = 0;
2326 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2328 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
2329 IDENTIFIER_POINTER (name));
2330 dbxout_type (type, 1);
2331 dbxout_finish_symbol (NULL_TREE);
2335 /* If an enum type has no name, it cannot be referred to,
2336 but we must output it anyway, since the enumeration constants
2337 can be referred to. */
2338 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
2340 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2341 current_sym_value = 0;
2342 current_sym_addr = 0;
2343 current_sym_nchars = 2;
2345 /* Some debuggers fail when given NULL names, so give this a
2346 harmless name of ` '. */
2347 fprintf (asmfile, "%s\" :T", ASM_STABS_OP);
2348 dbxout_type (type, 1);
2349 dbxout_finish_symbol (NULL_TREE);
2352 /* Prevent duplicate output of a typedef. */
2353 TREE_ASM_WRITTEN (decl) = 1;
2358 /* Parm decls go in their own separate chains
2359 and are output by dbxout_reg_parms and dbxout_parms. */
2363 /* Named return value, treat like a VAR_DECL. */
2365 if (! DECL_RTL_SET_P (decl))
2366 DBXOUT_DECR_NESTING_AND_RETURN (0);
2367 /* Don't mention a variable that is external.
2368 Let the file that defines it describe it. */
2369 if (DECL_EXTERNAL (decl))
2372 /* If the variable is really a constant
2373 and not written in memory, inform the debugger. */
2374 if (TREE_STATIC (decl) && TREE_READONLY (decl)
2375 && DECL_INITIAL (decl) != 0
2376 && host_integerp (DECL_INITIAL (decl), 0)
2377 && ! TREE_ASM_WRITTEN (decl)
2378 && (DECL_CONTEXT (decl) == NULL_TREE
2379 || TREE_CODE (DECL_CONTEXT (decl)) == BLOCK))
2381 if (TREE_PUBLIC (decl) == 0)
2383 /* The sun4 assembler does not grok this. */
2384 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
2386 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
2387 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
2389 HOST_WIDE_INT ival = tree_low_cst (DECL_INITIAL (decl), 0);
2390 fprintf (asmfile, "%s\"%s:c=i" HOST_WIDE_INT_PRINT_DEC
2392 ASM_STABS_OP, name, ival, N_LSYM);
2393 DBXOUT_DECR_NESTING;
2396 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
2398 /* Don't know how to do this yet. */
2402 /* else it is something we handle like a normal variable. */
2405 SET_DECL_RTL (decl, eliminate_regs (DECL_RTL (decl), 0, NULL_RTX));
2406 #ifdef LEAF_REG_REMAP
2407 if (current_function_uses_only_leaf_regs)
2408 leaf_renumber_regs_insn (DECL_RTL (decl));
2411 result = dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
2417 DBXOUT_DECR_NESTING;
2421 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2422 Add SUFFIX to its name, if SUFFIX is not 0.
2423 Describe the variable as residing in HOME
2424 (usually HOME is DECL_RTL (DECL), but not always).
2425 Returns 1 if the stab was really emitted. */
2428 dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
2433 emit_pending_bincls_if_required ();
2435 /* Don't mention a variable at all
2436 if it was completely optimized into nothingness.
2438 If the decl was from an inline function, then its rtl
2439 is not identically the rtl that was used in this
2440 particular compilation. */
2441 if (GET_CODE (home) == SUBREG)
2445 while (GET_CODE (value) == SUBREG)
2446 value = SUBREG_REG (value);
2449 if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
2452 home = alter_subreg (&home);
2456 regno = REGNO (home);
2457 if (regno >= FIRST_PSEUDO_REGISTER)
2461 /* The kind-of-variable letter depends on where
2462 the variable is and on the scope of its name:
2463 G and N_GSYM for static storage and global scope,
2464 S for static storage and file scope,
2465 V for static storage and local scope,
2466 for those two, use N_LCSYM if data is in bss segment,
2467 N_STSYM if in data segment, N_FUN otherwise.
2468 (We used N_FUN originally, then changed to N_STSYM
2469 to please GDB. However, it seems that confused ld.
2470 Now GDB has been fixed to like N_FUN, says Kingdon.)
2471 no letter at all, and N_LSYM, for auto variable,
2472 r and N_RSYM for register variable. */
2475 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
2477 if (TREE_PUBLIC (decl))
2480 current_sym_code = N_GSYM;
2484 current_sym_addr = XEXP (home, 0);
2486 letter = decl_function_context (decl) ? 'V' : 'S';
2488 /* This should be the same condition as in assemble_variable, but
2489 we don't have access to dont_output_data here. So, instead,
2490 we rely on the fact that error_mark_node initializers always
2491 end up in bss for C++ and never end up in bss for C. */
2492 if (DECL_INITIAL (decl) == 0
2493 || (!strcmp (lang_hooks.name, "GNU C++")
2494 && DECL_INITIAL (decl) == error_mark_node))
2495 current_sym_code = N_LCSYM;
2496 else if (DECL_IN_TEXT_SECTION (decl))
2497 /* This is not quite right, but it's the closest
2498 of all the codes that Unix defines. */
2499 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
2502 /* Some ports can transform a symbol ref into a label ref,
2503 because the symbol ref is too far away and has to be
2504 dumped into a constant pool. Alternatively, the symbol
2505 in the constant pool might be referenced by a different
2507 if (GET_CODE (current_sym_addr) == SYMBOL_REF
2508 && CONSTANT_POOL_ADDRESS_P (current_sym_addr))
2511 rtx tmp = get_pool_constant_mark (current_sym_addr, &marked);
2513 if (GET_CODE (tmp) == SYMBOL_REF)
2515 current_sym_addr = tmp;
2516 if (CONSTANT_POOL_ADDRESS_P (current_sym_addr))
2517 get_pool_constant_mark (current_sym_addr, &marked);
2521 else if (GET_CODE (tmp) == LABEL_REF)
2523 current_sym_addr = tmp;
2527 /* If all references to the constant pool were optimized
2528 out, we just ignore the symbol. */
2533 /* Ultrix `as' seems to need this. */
2534 #ifdef DBX_STATIC_STAB_DATA_SECTION
2537 current_sym_code = N_STSYM;
2541 else if (regno >= 0)
2544 current_sym_code = N_RSYM;
2545 current_sym_value = DBX_REGISTER_NUMBER (regno);
2547 else if (MEM_P (home)
2548 && (MEM_P (XEXP (home, 0))
2549 || (REG_P (XEXP (home, 0))
2550 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
2551 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
2552 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2553 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
2556 /* If the value is indirect by memory or by a register
2557 that isn't the frame pointer
2558 then it means the object is variable-sized and address through
2559 that register or stack slot. DBX has no way to represent this
2560 so all we can do is output the variable as a pointer.
2561 If it's not a parameter, ignore it. */
2563 if (REG_P (XEXP (home, 0)))
2566 current_sym_code = N_RSYM;
2567 if (REGNO (XEXP (home, 0)) >= FIRST_PSEUDO_REGISTER)
2569 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2573 current_sym_code = N_LSYM;
2574 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2575 We want the value of that CONST_INT. */
2577 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2580 /* Effectively do build_pointer_type, but don't cache this type,
2581 since it might be temporary whereas the type it points to
2582 might have been saved for inlining. */
2583 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2584 type = make_node (POINTER_TYPE);
2585 TREE_TYPE (type) = TREE_TYPE (decl);
2587 else if (MEM_P (home)
2588 && REG_P (XEXP (home, 0)))
2590 current_sym_code = N_LSYM;
2591 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2593 else if (MEM_P (home)
2594 && GET_CODE (XEXP (home, 0)) == PLUS
2595 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2597 current_sym_code = N_LSYM;
2598 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2599 We want the value of that CONST_INT. */
2600 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2602 else if (MEM_P (home)
2603 && GET_CODE (XEXP (home, 0)) == CONST)
2605 /* Handle an obscure case which can arise when optimizing and
2606 when there are few available registers. (This is *always*
2607 the case for i386/i486 targets). The RTL looks like
2608 (MEM (CONST ...)) even though this variable is a local `auto'
2609 or a local `register' variable. In effect, what has happened
2610 is that the reload pass has seen that all assignments and
2611 references for one such a local variable can be replaced by
2612 equivalent assignments and references to some static storage
2613 variable, thereby avoiding the need for a register. In such
2614 cases we're forced to lie to debuggers and tell them that
2615 this variable was itself `static'. */
2616 current_sym_code = N_LCSYM;
2618 current_sym_addr = XEXP (XEXP (home, 0), 0);
2620 else if (GET_CODE (home) == CONCAT)
2624 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2625 for example), then there is no easy way to figure out
2626 what SUBTYPE should be. So, we give up. */
2627 if (TREE_CODE (type) != COMPLEX_TYPE)
2630 subtype = TREE_TYPE (type);
2632 /* If the variable's storage is in two parts,
2633 output each as a separate stab with a modified name. */
2634 if (WORDS_BIG_ENDIAN)
2635 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2637 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2639 dbxout_prepare_symbol (decl);
2641 if (WORDS_BIG_ENDIAN)
2642 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2644 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2648 /* Address might be a MEM, when DECL is a variable-sized object.
2649 Or it might be const0_rtx, meaning previous passes
2650 want us to ignore this variable. */
2653 /* Ok, start a symtab entry and output the variable name. */
2656 #ifdef DBX_STATIC_BLOCK_START
2657 DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2660 dbxout_symbol_name (decl, suffix, letter);
2661 dbxout_type (type, 0);
2662 dbxout_finish_symbol (decl);
2664 #ifdef DBX_STATIC_BLOCK_END
2665 DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2670 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2671 Then output LETTER to indicate the kind of location the symbol has. */
2674 dbxout_symbol_name (tree decl, const char *suffix, int letter)
2678 if (DECL_CONTEXT (decl)
2679 && (TYPE_P (DECL_CONTEXT (decl))
2680 || TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL))
2681 /* One slight hitch: if this is a VAR_DECL which is a class member
2682 or a namespace member, we must put out the mangled name instead of the
2683 DECL_NAME. Note also that static member (variable) names DO NOT begin
2684 with underscores in .stabs directives. */
2685 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2687 /* ...but if we're function-local, we don't want to include the junk
2688 added by ASM_FORMAT_PRIVATE_NAME. */
2689 name = IDENTIFIER_POINTER (DECL_NAME (decl));
2693 fprintf (asmfile, "%s\"%s%s:", ASM_STABS_OP, name,
2694 (suffix ? suffix : ""));
2697 putc (letter, asmfile);
2701 dbxout_prepare_symbol (tree decl ATTRIBUTE_UNUSED)
2704 const char *filename = DECL_SOURCE_FILE (decl);
2706 dbxout_source_file (asmfile, filename);
2709 /* Initialize variables used to communicate each symbol's debug
2710 information to dbxout_finish_symbol with zeroes. */
2712 /* Cast avoids warning in old compilers. */
2713 current_sym_code = (STAB_CODE_TYPE) 0;
2714 current_sym_value = 0;
2715 current_sym_addr = 0;
2719 dbxout_finish_symbol (tree sym)
2721 #ifdef DBX_FINISH_SYMBOL
2722 DBX_FINISH_SYMBOL (sym);
2725 if (use_gnu_debug_info_extensions && sym != 0)
2726 line = DECL_SOURCE_LINE (sym);
2728 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2729 if (current_sym_addr)
2730 output_addr_const (asmfile, current_sym_addr);
2732 fprintf (asmfile, "%d", current_sym_value);
2733 putc ('\n', asmfile);
2737 /* Output definitions of all the decls in a chain. Return nonzero if
2738 anything was output */
2741 dbxout_syms (tree syms)
2746 result += dbxout_symbol (syms, 1);
2747 syms = TREE_CHAIN (syms);
2752 /* The following two functions output definitions of function parameters.
2753 Each parameter gets a definition locating it in the parameter list.
2754 Each parameter that is a register variable gets a second definition
2755 locating it in the register.
2757 Printing or argument lists in gdb uses the definitions that
2758 locate in the parameter list. But reference to the variable in
2759 expressions uses preferentially the definition as a register. */
2761 /* Output definitions, referring to storage in the parmlist,
2762 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2765 dbxout_parms (tree parms)
2769 emit_pending_bincls_if_required ();
2771 for (; parms; parms = TREE_CHAIN (parms))
2772 if (DECL_NAME (parms)
2773 && TREE_TYPE (parms) != error_mark_node
2774 && DECL_RTL_SET_P (parms)
2775 && DECL_INCOMING_RTL (parms))
2777 dbxout_prepare_symbol (parms);
2779 /* Perform any necessary register eliminations on the parameter's rtl,
2780 so that the debugging output will be accurate. */
2781 DECL_INCOMING_RTL (parms)
2782 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2783 SET_DECL_RTL (parms, eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
2784 #ifdef LEAF_REG_REMAP
2785 if (current_function_uses_only_leaf_regs)
2787 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2788 leaf_renumber_regs_insn (DECL_RTL (parms));
2792 if (PARM_PASSED_IN_MEMORY (parms))
2794 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2796 /* ??? Here we assume that the parm address is indexed
2797 off the frame pointer or arg pointer.
2798 If that is not true, we produce meaningless results,
2799 but do not crash. */
2800 if (GET_CODE (addr) == PLUS
2801 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2802 current_sym_value = INTVAL (XEXP (addr, 1));
2804 current_sym_value = 0;
2806 current_sym_code = N_PSYM;
2807 current_sym_addr = 0;
2810 if (DECL_NAME (parms))
2812 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2814 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2815 IDENTIFIER_POINTER (DECL_NAME (parms)),
2816 DBX_MEMPARM_STABS_LETTER);
2820 current_sym_nchars = 8;
2821 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2822 DBX_MEMPARM_STABS_LETTER);
2825 /* It is quite tempting to use:
2827 dbxout_type (TREE_TYPE (parms), 0);
2829 as the next statement, rather than using DECL_ARG_TYPE(), so
2830 that gcc reports the actual type of the parameter, rather
2831 than the promoted type. This certainly makes GDB's life
2832 easier, at least for some ports. The change is a bad idea
2833 however, since GDB expects to be able access the type without
2834 performing any conversions. So for example, if we were
2835 passing a float to an unprototyped function, gcc will store a
2836 double on the stack, but if we emit a stab saying the type is a
2837 float, then gdb will only read in a single value, and this will
2838 produce an erroneous value. */
2839 dbxout_type (DECL_ARG_TYPE (parms), 0);
2840 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2841 dbxout_finish_symbol (parms);
2843 else if (REG_P (DECL_RTL (parms)))
2846 char regparm_letter;
2848 /* Parm passed in registers and lives in registers or nowhere. */
2850 current_sym_code = DBX_REGPARM_STABS_CODE;
2851 regparm_letter = DBX_REGPARM_STABS_LETTER;
2852 current_sym_addr = 0;
2854 /* If parm lives in a register, use that register;
2855 pretend the parm was passed there. It would be more consistent
2856 to describe the register where the parm was passed,
2857 but in practice that register usually holds something else.
2859 If we use DECL_RTL, then we must use the declared type of
2860 the variable, not the type that it arrived in. */
2861 if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2863 best_rtl = DECL_RTL (parms);
2864 parm_type = TREE_TYPE (parms);
2866 /* If the parm lives nowhere, use the register where it was
2867 passed. It is also better to use the declared type here. */
2870 best_rtl = DECL_INCOMING_RTL (parms);
2871 parm_type = TREE_TYPE (parms);
2873 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2876 if (DECL_NAME (parms))
2878 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2879 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2880 IDENTIFIER_POINTER (DECL_NAME (parms)),
2885 current_sym_nchars = 8;
2886 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2890 dbxout_type (parm_type, 0);
2891 dbxout_finish_symbol (parms);
2893 else if (MEM_P (DECL_RTL (parms))
2894 && REG_P (XEXP (DECL_RTL (parms), 0))
2895 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2896 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2897 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2898 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2902 /* Parm was passed via invisible reference.
2903 That is, its address was passed in a register.
2904 Output it as if it lived in that register.
2905 The debugger will know from the type
2906 that it was actually passed by invisible reference. */
2908 char regparm_letter;
2909 /* Parm passed in registers and lives in registers or nowhere. */
2911 current_sym_code = DBX_REGPARM_STABS_CODE;
2912 if (use_gnu_debug_info_extensions)
2913 regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2915 regparm_letter = DBX_REGPARM_STABS_LETTER;
2917 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2918 If it is an unallocated pseudo-reg, then use the register where
2919 it was passed instead. */
2920 if (REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2921 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2923 current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2925 current_sym_addr = 0;
2928 if (DECL_NAME (parms))
2931 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2933 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2934 IDENTIFIER_POINTER (DECL_NAME (parms)),
2939 current_sym_nchars = 8;
2940 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2944 dbxout_type (TREE_TYPE (parms), 0);
2945 dbxout_finish_symbol (parms);
2947 else if (MEM_P (DECL_RTL (parms))
2948 && MEM_P (XEXP (DECL_RTL (parms), 0)))
2950 /* Parm was passed via invisible reference, with the reference
2951 living on the stack. DECL_RTL looks like
2952 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2953 could look like (MEM (MEM (REG))). */
2954 const char *const decl_name = (DECL_NAME (parms)
2955 ? IDENTIFIER_POINTER (DECL_NAME (parms))
2957 if (REG_P (XEXP (XEXP (DECL_RTL (parms), 0), 0)))
2958 current_sym_value = 0;
2961 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1));
2962 current_sym_addr = 0;
2963 current_sym_code = N_PSYM;
2966 fprintf (asmfile, "%s\"%s:v", ASM_STABS_OP, decl_name);
2969 = DEBUGGER_ARG_OFFSET (current_sym_value,
2970 XEXP (XEXP (DECL_RTL (parms), 0), 0));
2971 dbxout_type (TREE_TYPE (parms), 0);
2972 dbxout_finish_symbol (parms);
2974 else if (MEM_P (DECL_RTL (parms))
2975 && XEXP (DECL_RTL (parms), 0) != const0_rtx
2976 /* ??? A constant address for a parm can happen
2977 when the reg it lives in is equiv to a constant in memory.
2978 Should make this not happen, after 2.4. */
2979 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2981 /* Parm was passed in registers but lives on the stack. */
2983 current_sym_code = N_PSYM;
2984 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2985 in which case we want the value of that CONST_INT,
2987 in which case we use a value of zero. */
2988 if (REG_P (XEXP (DECL_RTL (parms), 0)))
2989 current_sym_value = 0;
2992 = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2994 current_sym_addr = 0;
2996 /* Make a big endian correction if the mode of the type of the
2997 parameter is not the same as the mode of the rtl. */
2998 if (BYTES_BIG_ENDIAN
2999 && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms))
3000 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD)
3002 current_sym_value +=
3003 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))
3004 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms)));
3008 if (DECL_NAME (parms))
3011 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
3013 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
3014 IDENTIFIER_POINTER (DECL_NAME (parms)),
3015 DBX_MEMPARM_STABS_LETTER);
3019 current_sym_nchars = 8;
3020 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
3021 DBX_MEMPARM_STABS_LETTER);
3025 = DEBUGGER_ARG_OFFSET (current_sym_value,
3026 XEXP (DECL_RTL (parms), 0));
3027 dbxout_type (TREE_TYPE (parms), 0);
3028 dbxout_finish_symbol (parms);
3031 DBXOUT_DECR_NESTING;
3034 /* Output definitions for the places where parms live during the function,
3035 when different from where they were passed, when the parms were passed
3038 It is not useful to do this for parms passed in registers
3039 that live during the function in different registers, because it is
3040 impossible to look in the passed register for the passed value,
3041 so we use the within-the-function register to begin with.
3043 PARMS is a chain of PARM_DECL nodes. */
3046 dbxout_reg_parms (tree parms)
3050 for (; parms; parms = TREE_CHAIN (parms))
3051 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
3053 dbxout_prepare_symbol (parms);
3055 /* Report parms that live in registers during the function
3056 but were passed in memory. */
3057 if (REG_P (DECL_RTL (parms))
3058 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
3059 dbxout_symbol_location (parms, TREE_TYPE (parms),
3060 0, DECL_RTL (parms));
3061 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
3062 dbxout_symbol_location (parms, TREE_TYPE (parms),
3063 0, DECL_RTL (parms));
3064 /* Report parms that live in memory but not where they were passed. */
3065 else if (MEM_P (DECL_RTL (parms))
3066 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
3067 dbxout_symbol_location (parms, TREE_TYPE (parms),
3068 0, DECL_RTL (parms));
3070 DBXOUT_DECR_NESTING;
3073 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
3074 output definitions of those names, in raw form */
3077 dbxout_args (tree args)
3081 putc (',', asmfile);
3082 dbxout_type (TREE_VALUE (args), 0);
3084 args = TREE_CHAIN (args);
3088 /* Output everything about a symbol block (a BLOCK node
3089 that represents a scope level),
3090 including recursive output of contained blocks.
3092 BLOCK is the BLOCK node.
3093 DEPTH is its depth within containing symbol blocks.
3094 ARGS is usually zero; but for the outermost block of the
3095 body of a function, it is a chain of PARM_DECLs for the function parameters.
3096 We output definitions of all the register parms
3097 as if they were local variables of that block.
3099 If -g1 was used, we count blocks just the same, but output nothing
3100 except for the outermost block.
3102 Actually, BLOCK may be several blocks chained together.
3103 We handle them all in sequence. */
3106 dbxout_block (tree block, int depth, tree args)
3110 #if DBX_BLOCKS_FUNCTION_RELATIVE
3111 const char *begin_label;
3112 if (current_function_func_begin_label != NULL_TREE)
3113 begin_label = IDENTIFIER_POINTER (current_function_func_begin_label);
3115 begin_label = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
3120 /* Ignore blocks never expanded or otherwise marked as real. */
3121 if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
3125 /* In dbx format, the syms of a block come before the N_LBRAC.
3126 If nothing is output, we don't need the N_LBRAC, either. */
3128 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
3129 did_output = dbxout_syms (BLOCK_VARS (block));
3131 dbxout_reg_parms (args);
3133 /* Now output an N_LBRAC symbol to represent the beginning of
3134 the block. Use the block's tree-walk order to generate
3135 the assembler symbols LBBn and LBEn
3136 that final will define around the code in this block. */
3137 if (depth > 0 && did_output)
3140 blocknum = BLOCK_NUMBER (block);
3141 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
3143 if (BLOCK_HANDLER_BLOCK (block))
3145 /* A catch block. Must precede N_LBRAC. */
3146 tree decl = BLOCK_VARS (block);
3149 fprintf (asmfile, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP,
3150 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
3151 assemble_name (asmfile, buf);
3152 fprintf (asmfile, "\n");
3153 decl = TREE_CHAIN (decl);
3157 #ifdef DBX_OUTPUT_LBRAC
3158 DBX_OUTPUT_LBRAC (asmfile, buf);
3160 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
3161 assemble_name (asmfile, buf);
3162 #if DBX_BLOCKS_FUNCTION_RELATIVE
3163 putc ('-', asmfile);
3164 assemble_name (asmfile, begin_label);
3166 fprintf (asmfile, "\n");
3170 /* Output the subblocks. */
3171 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
3173 /* Refer to the marker for the end of the block. */
3174 if (depth > 0 && did_output)
3177 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
3178 #ifdef DBX_OUTPUT_RBRAC
3179 DBX_OUTPUT_RBRAC (asmfile, buf);
3181 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC);
3182 assemble_name (asmfile, buf);
3183 #if DBX_BLOCKS_FUNCTION_RELATIVE
3184 putc ('-', asmfile);
3185 assemble_name (asmfile, begin_label);
3187 fprintf (asmfile, "\n");
3191 block = BLOCK_CHAIN (block);
3195 /* Output the information about a function and its arguments and result.
3196 Usually this follows the function's code,
3197 but on some systems, it comes before. */
3199 #if defined (DBX_DEBUGGING_INFO)
3201 dbxout_begin_function (tree decl)
3203 int saved_tree_used1 = TREE_USED (decl);
3204 TREE_USED (decl) = 1;
3205 if (DECL_NAME (DECL_RESULT (decl)) != 0)
3207 int saved_tree_used2 = TREE_USED (DECL_RESULT (decl));
3208 TREE_USED (DECL_RESULT (decl)) = 1;
3209 dbxout_symbol (decl, 0);
3210 TREE_USED (DECL_RESULT (decl)) = saved_tree_used2;
3213 dbxout_symbol (decl, 0);
3214 TREE_USED (decl) = saved_tree_used1;
3216 dbxout_parms (DECL_ARGUMENTS (decl));
3217 if (DECL_NAME (DECL_RESULT (decl)) != 0)
3218 dbxout_symbol (DECL_RESULT (decl), 1);
3220 #endif /* DBX_DEBUGGING_INFO */
3222 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3224 #include "gt-dbxout.h"