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 */
404 debug_nothing_rtx /* var_location */
406 #endif /* DBX_DEBUGGING_INFO */
408 #if defined (XCOFF_DEBUGGING_INFO)
409 const struct gcc_debug_hooks xcoff_debug_hooks =
413 debug_nothing_int_charstar,
414 debug_nothing_int_charstar,
415 dbxout_start_source_file,
416 dbxout_end_source_file,
417 xcoffout_begin_block,
419 debug_true_tree, /* ignore_block */
420 xcoffout_source_line,
421 xcoffout_begin_prologue, /* begin_prologue */
422 debug_nothing_int_charstar, /* end_prologue */
423 xcoffout_end_epilogue,
424 debug_nothing_tree, /* begin_function */
425 xcoffout_end_function,
426 debug_nothing_tree, /* function_decl */
427 dbxout_global_decl, /* global_decl */
428 debug_nothing_tree_tree, /* imported_module_or_decl */
429 debug_nothing_tree, /* deferred_inline_function */
430 debug_nothing_tree, /* outlining_inline_function */
431 debug_nothing_rtx, /* label */
432 dbxout_handle_pch, /* handle_pch */
433 debug_nothing_rtx /* var_location */
435 #endif /* XCOFF_DEBUGGING_INFO */
437 #if defined (DBX_DEBUGGING_INFO)
439 dbxout_function_end (void)
441 char lscope_label_name[100];
442 /* Convert Ltext into the appropriate format for local labels in case
443 the system doesn't insert underscores in front of user generated
445 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
446 (*targetm.asm_out.internal_label) (asmfile, "Lscope", scope_labelno);
449 /* By convention, GCC will mark the end of a function with an N_FUN
450 symbol and an empty string. */
451 #ifdef DBX_OUTPUT_NFUN
452 DBX_OUTPUT_NFUN (asmfile, lscope_label_name, current_function_decl);
454 fprintf (asmfile, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN);
455 assemble_name (asmfile, lscope_label_name);
457 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
458 fprintf (asmfile, "\n");
461 #endif /* DBX_DEBUGGING_INFO */
463 /* At the beginning of compilation, start writing the symbol table.
464 Initialize `typevec' and output the standard data types of C. */
467 dbxout_init (const char *input_file_name)
469 char ltext_label_name[100];
470 tree syms = (*lang_hooks.decls.getdecls) ();
472 asmfile = asm_out_file;
475 typevec = ggc_calloc (typevec_len, sizeof typevec[0]);
477 /* Convert Ltext into the appropriate format for local labels in case
478 the system doesn't insert underscores in front of user generated
480 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
482 /* Put the current working directory in an N_SO symbol. */
483 if (use_gnu_debug_info_extensions)
485 if (!cwd && (cwd = get_src_pwd ())
486 && (!*cwd || cwd[strlen (cwd) - 1] != '/'))
487 cwd = concat (cwd, FILE_NAME_JOINER, NULL);
490 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
491 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
492 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
493 fprintf (asmfile, "%s", ASM_STABS_OP);
494 output_quoted_string (asmfile, cwd);
495 fprintf (asmfile, ",%d,0,0,", N_SO);
496 assemble_name (asmfile, ltext_label_name);
497 fputc ('\n', asmfile);
498 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
502 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
503 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
504 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
505 /* We include outputting `Ltext:' here,
506 because that gives you a way to override it. */
507 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
508 fprintf (asmfile, "%s", ASM_STABS_OP);
509 output_quoted_string (asmfile, input_file_name);
510 fprintf (asmfile, ",%d,0,0,", N_SO);
511 assemble_name (asmfile, ltext_label_name);
512 fputc ('\n', asmfile);
514 (*targetm.asm_out.internal_label) (asmfile, "Ltext", 0);
515 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
517 #ifdef DBX_OUTPUT_GCC_MARKER
518 DBX_OUTPUT_GCC_MARKER (asmfile);
520 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
521 fprintf (asmfile, "%s\"%s\",%d,0,0,0\n",
522 ASM_STABS_OP, STABS_GCC_MARKER, N_OPT);
525 base_input_file = lastfile = input_file_name;
527 next_type_number = 1;
530 current_file = xmalloc (sizeof *current_file);
531 current_file->next = NULL;
532 current_file->file_number = 0;
533 current_file->next_type_number = 1;
534 next_file_number = 1;
535 current_file->prev = NULL;
536 current_file->bincl_status = BINCL_NOT_REQUIRED;
537 current_file->pending_bincl_name = NULL;
540 /* Make sure that types `int' and `char' have numbers 1 and 2.
541 Definitions of other integer types will refer to those numbers.
542 (Actually it should no longer matter what their numbers are.
543 Also, if any types with tags have been defined, dbxout_symbol
544 will output them first, so the numbers won't be 1 and 2. That
545 happens in C++. So it's a good thing it should no longer matter). */
547 #ifdef DBX_OUTPUT_STANDARD_TYPES
548 DBX_OUTPUT_STANDARD_TYPES (syms);
551 /* Get all permanent types that have typedef names, and output them
552 all, except for those already output. Some language front ends
553 put these declarations in the top-level scope; some do not. */
554 dbxout_typedefs ((*lang_hooks.decls.builtin_type_decls) ());
555 dbxout_typedefs (syms);
558 /* Output any typedef names for types described by TYPE_DECLs in SYMS. */
561 dbxout_typedefs (tree syms)
563 for (; syms != NULL_TREE; syms = TREE_CHAIN (syms))
565 if (TREE_CODE (syms) == TYPE_DECL)
567 tree type = TREE_TYPE (syms);
569 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
570 && COMPLETE_OR_VOID_TYPE_P (type)
571 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
572 dbxout_symbol (TYPE_NAME (type), 0);
578 /* Emit BINCL stab using given name. */
580 emit_bincl_stab (const char *name)
582 fprintf (asmfile, "%s", ASM_STABS_OP);
583 output_quoted_string (asmfile, name);
584 fprintf (asmfile, ",%d,0,0,0\n", N_BINCL);
587 /* If there are pending bincls then it is time to emit all of them. */
590 emit_pending_bincls_if_required (void)
593 emit_pending_bincls ();
596 /* Emit all pending bincls. */
599 emit_pending_bincls (void)
601 struct dbx_file *f = current_file;
603 /* Find first pending bincl. */
604 while (f->bincl_status == BINCL_PENDING)
607 /* Now emit all bincls. */
612 if (f->bincl_status == BINCL_PENDING)
614 emit_bincl_stab (f->pending_bincl_name);
616 /* Update file number and status. */
617 f->file_number = next_file_number++;
618 f->bincl_status = BINCL_PROCESSED;
620 if (f == current_file)
625 /* All pending bincls have been emitted. */
632 emit_pending_bincls_if_required (void) {}
635 /* Change to reading from a new source file. Generate a N_BINCL stab. */
638 dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
639 const char *filename ATTRIBUTE_UNUSED)
642 struct dbx_file *n = xmalloc (sizeof *n);
644 n->next = current_file;
645 n->next_type_number = 1;
646 /* Do not assign file number now.
647 Delay it until we actually emit BINCL. */
650 current_file->prev = n;
651 n->bincl_status = BINCL_PENDING;
652 n->pending_bincl_name = filename;
658 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
661 dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED)
664 /* Emit EINCL stab only if BINCL is not pending. */
665 if (current_file->bincl_status == BINCL_PROCESSED)
666 fprintf (asmfile, "%s%d,0,0,0\n", ASM_STABN_OP, N_EINCL);
667 current_file->bincl_status = BINCL_NOT_REQUIRED;
668 current_file = current_file->next;
672 /* Handle a few odd cases that occur when trying to make PCH files work. */
675 dbxout_handle_pch (unsigned at_end)
679 /* When using the PCH, this file will be included, so we need to output
681 dbxout_start_source_file (0, lastfile);
683 /* The base file when using the PCH won't be the same as
684 the base file when it's being generated. */
689 /* ... and an EINCL. */
690 dbxout_end_source_file (0);
692 /* Deal with cases where 'lastfile' was never actually changed. */
693 lastfile_is_base = lastfile == NULL;
697 #if defined (DBX_DEBUGGING_INFO)
698 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
701 dbxout_source_file (FILE *file, const char *filename)
703 if (lastfile == 0 && lastfile_is_base)
705 lastfile = base_input_file;
706 lastfile_is_base = 0;
709 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
711 char ltext_label_name[100];
713 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
714 source_label_number);
715 fprintf (file, "%s", ASM_STABS_OP);
716 output_quoted_string (file, filename);
717 fprintf (asmfile, ",%d,0,0,", N_SOL);
718 assemble_name (asmfile, ltext_label_name);
719 fputc ('\n', asmfile);
720 if (current_function_decl != NULL_TREE
721 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
722 ; /* Don't change section amid function. */
725 (*targetm.asm_out.internal_label) (file, "Ltext", source_label_number);
726 source_label_number++;
731 /* Output a line number symbol entry for source file FILENAME and line
735 dbxout_source_line (unsigned int lineno, const char *filename)
737 dbxout_source_file (asmfile, filename);
739 #ifdef ASM_OUTPUT_SOURCE_LINE
740 dbxout_source_line_counter += 1;
741 ASM_OUTPUT_SOURCE_LINE (asmfile, lineno, dbxout_source_line_counter);
743 fprintf (asmfile, "%s%d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
747 /* Describe the beginning of an internal block within a function. */
750 dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
752 emit_pending_bincls_if_required ();
753 (*targetm.asm_out.internal_label) (asmfile, "LBB", n);
756 /* Describe the end line-number of an internal block within a function. */
759 dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
761 emit_pending_bincls_if_required ();
762 (*targetm.asm_out.internal_label) (asmfile, "LBE", n);
765 /* Output dbx data for a function definition.
766 This includes a definition of the function name itself (a symbol),
767 definitions of the parameters (locating them in the parameter list)
768 and then output the block that makes up the function's body
769 (including all the auto variables of the function). */
772 dbxout_function_decl (tree decl)
774 emit_pending_bincls_if_required ();
775 #ifndef DBX_FUNCTION_FIRST
776 dbxout_begin_function (decl);
778 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
779 #ifdef DBX_OUTPUT_FUNCTION_END
780 DBX_OUTPUT_FUNCTION_END (asmfile, decl);
782 if (use_gnu_debug_info_extensions
783 #if defined(NO_DBX_FUNCTION_END)
784 && ! NO_DBX_FUNCTION_END
786 && targetm.have_named_sections)
787 dbxout_function_end ();
790 #endif /* DBX_DEBUGGING_INFO */
792 /* Debug information for a global DECL. Called from toplev.c after
793 compilation proper has finished. */
795 dbxout_global_decl (tree decl)
797 if (TREE_CODE (decl) == VAR_DECL
798 && ! DECL_EXTERNAL (decl)
799 && DECL_RTL_SET_P (decl)) /* Not necessary? */
801 int saved_tree_used = TREE_USED (decl);
802 TREE_USED (decl) = 1;
803 dbxout_symbol (decl, 0);
804 TREE_USED (decl) = saved_tree_used;
808 /* At the end of compilation, finish writing the symbol table.
809 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
813 dbxout_finish (const char *filename ATTRIBUTE_UNUSED)
815 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
816 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile, filename);
817 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
822 /* Output the index of a type. */
825 dbxout_type_index (tree type)
827 #ifndef DBX_USE_BINCL
828 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
831 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
832 fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number);
837 #if DBX_CONTIN_LENGTH > 0
838 /* Continue a symbol-description that gets too big.
839 End one symbol table entry with a double-backslash
840 and start a new one, eventually producing something like
841 .stabs "start......\\",code,0,value
842 .stabs "...rest",code,0,value */
845 dbxout_continue (void)
847 emit_pending_bincls_if_required ();
848 #ifdef DBX_CONTIN_CHAR
849 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
851 fprintf (asmfile, "\\\\");
853 dbxout_finish_symbol (NULL_TREE);
854 fprintf (asmfile, "%s\"", ASM_STABS_OP);
855 current_sym_nchars = 0;
857 #endif /* DBX_CONTIN_LENGTH > 0 */
859 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
860 This must be a separate function because anonymous unions require
864 dbxout_type_fields (tree type)
868 /* Output the name, type, position (in bits), size (in bits) of each
869 field that we can support. */
870 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
873 /* If on of the nodes is an error_mark or its type is then return early. */
874 if (tem == error_mark_node || TREE_TYPE (tem) == error_mark_node)
877 /* Omit here local type decls until we know how to support them. */
878 if (TREE_CODE (tem) == TYPE_DECL
879 /* Omit fields whose position or size are variable or too large to
881 || (TREE_CODE (tem) == FIELD_DECL
882 && (! host_integerp (bit_position (tem), 0)
884 || ! host_integerp (DECL_SIZE (tem), 1)))
885 /* Omit here the nameless fields that are used to skip bits. */
886 || DECL_IGNORED_P (tem))
889 else if (TREE_CODE (tem) != CONST_DECL)
891 /* Continue the line if necessary,
892 but not before the first field. */
893 if (tem != TYPE_FIELDS (type))
898 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
899 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
903 fprintf (asmfile, ":");
907 if (use_gnu_debug_info_extensions
908 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
909 || TREE_CODE (tem) != FIELD_DECL))
911 have_used_extensions = 1;
913 putc ((TREE_PRIVATE (tem) ? '0'
914 : TREE_PROTECTED (tem) ? '1' : '2'),
919 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
920 && DECL_BIT_FIELD_TYPE (tem))
921 ? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0);
923 if (TREE_CODE (tem) == VAR_DECL)
925 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
927 tree name = DECL_ASSEMBLER_NAME (tem);
929 have_used_extensions = 1;
930 fprintf (asmfile, ":%s;", IDENTIFIER_POINTER (name));
931 CHARS (IDENTIFIER_LENGTH (name) + 2);
935 /* If TEM is non-static, GDB won't understand it. */
936 fprintf (asmfile, ",0,0;");
943 print_wide_int (int_bit_position (tem));
945 print_wide_int (tree_low_cst (DECL_SIZE (tem), 1));
953 /* Subroutine of `dbxout_type_methods'. Output debug info about the
954 method described DECL. DEBUG_NAME is an encoding of the method's
955 type signature. ??? We may be able to do without DEBUG_NAME altogether
959 dbxout_type_method_1 (tree decl, const char *debug_name)
963 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
965 else /* it's a METHOD_TYPE. */
967 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
968 /* A for normal functions.
969 B for `const' member functions.
970 C for `volatile' member functions.
971 D for `const volatile' member functions. */
972 if (TYPE_READONLY (TREE_TYPE (firstarg)))
974 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
977 if (DECL_VINDEX (decl))
983 fprintf (asmfile, ":%s;%c%c%c", debug_name,
984 TREE_PRIVATE (decl) ? '0'
985 : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
986 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
987 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
989 if (DECL_VINDEX (decl) && host_integerp (DECL_VINDEX (decl), 0))
991 print_wide_int (tree_low_cst (DECL_VINDEX (decl), 0));
994 dbxout_type (DECL_CONTEXT (decl), 0);
995 fprintf (asmfile, ";");
1000 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
1004 dbxout_type_methods (tree type)
1006 /* C++: put out the method names and their parameter lists */
1007 tree methods = TYPE_METHODS (type);
1011 char formatted_type_identifier_length[16];
1012 int type_identifier_length;
1014 if (methods == NULL_TREE)
1017 type_encoding = DECL_NAME (TYPE_NAME (type));
1020 /* C++: Template classes break some assumptions made by this code about
1021 the class names, constructor names, and encodings for assembler
1022 label names. For now, disable output of dbx info for them. */
1024 const char *ptr = IDENTIFIER_POINTER (type_encoding);
1025 /* This should use index. (mrs) */
1026 while (*ptr && *ptr != '<') ptr++;
1037 type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
1039 sprintf (formatted_type_identifier_length, "%d", type_identifier_length);
1041 if (TREE_CODE (methods) != TREE_VEC)
1043 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
1044 fndecl = TREE_VEC_ELT (methods, 0);
1046 fndecl = TREE_VEC_ELT (methods, 1);
1050 int need_prefix = 1;
1052 /* Group together all the methods for the same operation.
1053 These differ in the types of the arguments. */
1054 for (last = NULL_TREE;
1055 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
1056 fndecl = TREE_CHAIN (fndecl))
1057 /* Output the name of the field (after overloading), as
1058 well as the name of the field before overloading, along
1059 with its parameter list */
1061 /* This is the "mangled" name of the method.
1062 It encodes the argument types. */
1063 const char *debug_name;
1065 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
1066 include TEMPLATE_DECLs.) The debugger doesn't know what
1067 to do with such entities anyhow. */
1068 if (TREE_CODE (fndecl) != FUNCTION_DECL)
1071 debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
1077 /* Also ignore abstract methods; those are only interesting to
1078 the DWARF backends. */
1079 if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT (fndecl))
1082 /* Redundantly output the plain name, since that's what gdb
1086 tree name = DECL_NAME (fndecl);
1087 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
1088 CHARS (IDENTIFIER_LENGTH (name) + 2);
1092 dbxout_type (TREE_TYPE (fndecl), 0);
1094 dbxout_type_method_1 (fndecl, debug_name);
1098 putc (';', asmfile);
1104 /* Emit a "range" type specification, which has the form:
1105 "r<index type>;<lower bound>;<upper bound>;".
1106 TYPE is an INTEGER_TYPE. */
1109 dbxout_range_type (tree type)
1111 fprintf (asmfile, "r");
1112 if (TREE_TYPE (type))
1113 dbxout_type (TREE_TYPE (type), 0);
1114 else if (TREE_CODE (type) != INTEGER_TYPE)
1115 dbxout_type (type, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1118 /* Traditionally, we made sure 'int' was type 1, and builtin types
1119 were defined to be sub-ranges of int. Unfortunately, this
1120 does not allow us to distinguish true sub-ranges from integer
1121 types. So, instead we define integer (non-sub-range) types as
1122 sub-ranges of themselves. This matters for Chill. If this isn't
1123 a subrange type, then we want to define it in terms of itself.
1124 However, in C, this may be an anonymous integer type, and we don't
1125 want to emit debug info referring to it. Just calling
1126 dbxout_type_index won't work anyways, because the type hasn't been
1127 defined yet. We make this work for both cases by checked to see
1128 whether this is a defined type, referring to it if it is, and using
1130 if (TYPE_SYMTAB_ADDRESS (type) != 0)
1131 dbxout_type_index (type);
1133 dbxout_type_index (integer_type_node);
1136 if (TYPE_MIN_VALUE (type) != 0
1137 && host_integerp (TYPE_MIN_VALUE (type), 0))
1139 putc (';', asmfile);
1141 if (print_int_cst_bounds_in_octal_p (type))
1142 print_int_cst_octal (TYPE_MIN_VALUE (type));
1144 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type), 0));
1148 fprintf (asmfile, ";0");
1152 if (TYPE_MAX_VALUE (type) != 0
1153 && host_integerp (TYPE_MAX_VALUE (type), 0))
1155 putc (';', asmfile);
1157 if (print_int_cst_bounds_in_octal_p (type))
1158 print_int_cst_octal (TYPE_MAX_VALUE (type));
1160 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type), 0));
1161 putc (';', asmfile);
1166 fprintf (asmfile, ";-1;");
1172 /* Output a reference to a type. If the type has not yet been
1173 described in the dbx output, output its definition now.
1174 For a type already defined, just refer to its definition
1175 using the type number.
1177 If FULL is nonzero, and the type has been described only with
1178 a forward-reference, output the definition now.
1179 If FULL is zero in this case, just refer to the forward-reference
1180 using the number previously allocated. */
1183 dbxout_type (tree type, int full)
1187 static int anonymous_type_number = 0;
1189 if (TREE_CODE (type) == VECTOR_TYPE)
1190 /* The frontend feeds us a representation for the vector as a struct
1191 containing an array. Pull out the array type. */
1192 type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type)));
1194 /* If there was an input error and we don't really have a type,
1195 avoid crashing and write something that is at least valid
1196 by assuming `int'. */
1197 if (type == error_mark_node)
1198 type = integer_type_node;
1201 if (TYPE_NAME (type)
1202 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1203 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1207 /* Try to find the "main variant" with the same name. */
1208 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1209 && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1210 main_variant = TREE_TYPE (TYPE_NAME (type));
1212 main_variant = TYPE_MAIN_VARIANT (type);
1214 /* If we are not using extensions, stabs does not distinguish const and
1215 volatile, so there is no need to make them separate types. */
1216 if (!use_gnu_debug_info_extensions)
1217 type = main_variant;
1219 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1221 /* Type has no dbx number assigned. Assign next available number. */
1222 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1224 /* Make sure type vector is long enough to record about this type. */
1226 if (next_type_number == typevec_len)
1229 = ggc_realloc (typevec, (typevec_len * 2 * sizeof typevec[0]));
1230 memset (typevec + typevec_len, 0, typevec_len * sizeof typevec[0]);
1234 #ifdef DBX_USE_BINCL
1235 emit_pending_bincls_if_required ();
1236 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1237 = current_file->file_number;
1238 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1239 = current_file->next_type_number++;
1243 if (flag_debug_only_used_symbols)
1245 if ((TREE_CODE (type) == RECORD_TYPE
1246 || TREE_CODE (type) == UNION_TYPE
1247 || TREE_CODE (type) == QUAL_UNION_TYPE
1248 || TREE_CODE (type) == ENUMERAL_TYPE)
1249 && TYPE_STUB_DECL (type)
1250 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (type))) == 'd'
1251 && ! DECL_IGNORED_P (TYPE_STUB_DECL (type)))
1252 debug_queue_symbol (TYPE_STUB_DECL (type));
1253 else if (TYPE_NAME (type)
1254 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1255 debug_queue_symbol (TYPE_NAME (type));
1258 /* Output the number of this type, to refer to it. */
1259 dbxout_type_index (type);
1261 #ifdef DBX_TYPE_DEFINED
1262 if (DBX_TYPE_DEFINED (type))
1266 /* If this type's definition has been output or is now being output,
1269 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1274 /* If we have already had a cross reference,
1275 and either that's all we want or that's the best we could do,
1276 don't repeat the cross reference.
1277 Sun dbx crashes if we do. */
1278 if (! full || !COMPLETE_TYPE_P (type)
1279 /* No way in DBX fmt to describe a variable size. */
1280 || ! host_integerp (TYPE_SIZE (type), 1))
1288 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1289 leave the type-number completely undefined rather than output
1290 a cross-reference. If we have already used GNU debug info extensions,
1291 then it is OK to output a cross reference. This is necessary to get
1292 proper C++ debug output. */
1293 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1294 || TREE_CODE (type) == QUAL_UNION_TYPE
1295 || TREE_CODE (type) == ENUMERAL_TYPE)
1296 && ! use_gnu_debug_info_extensions)
1297 /* We must use the same test here as we use twice below when deciding
1298 whether to emit a cross-reference. */
1299 if ((TYPE_NAME (type) != 0
1300 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1301 && DECL_IGNORED_P (TYPE_NAME (type)))
1303 || !COMPLETE_TYPE_P (type)
1304 /* No way in DBX fmt to describe a variable size. */
1305 || ! host_integerp (TYPE_SIZE (type), 1))
1307 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1312 /* Output a definition now. */
1314 fprintf (asmfile, "=");
1317 /* Mark it as defined, so that if it is self-referent
1318 we will not get into an infinite recursion of definitions. */
1320 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1322 /* If this type is a variant of some other, hand off. Types with
1323 different names are usefully distinguished. We only distinguish
1324 cv-qualified types if we're using extensions. */
1325 if (TYPE_READONLY (type) > TYPE_READONLY (main_variant))
1327 putc ('k', asmfile);
1329 dbxout_type (build_type_variant (type, 0, TYPE_VOLATILE (type)), 0);
1332 else if (TYPE_VOLATILE (type) > TYPE_VOLATILE (main_variant))
1334 putc ('B', asmfile);
1336 dbxout_type (build_type_variant (type, TYPE_READONLY (type), 0), 0);
1339 else if (main_variant != TYPE_MAIN_VARIANT (type))
1341 if (flag_debug_only_used_symbols)
1343 tree orig_type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
1345 if ((TREE_CODE (orig_type) == RECORD_TYPE
1346 || TREE_CODE (orig_type) == UNION_TYPE
1347 || TREE_CODE (orig_type) == QUAL_UNION_TYPE
1348 || TREE_CODE (orig_type) == ENUMERAL_TYPE)
1349 && TYPE_STUB_DECL (orig_type)
1350 && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type)))
1351 debug_queue_symbol (TYPE_STUB_DECL (orig_type));
1353 /* 'type' is a typedef; output the type it refers to. */
1354 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0);
1357 /* else continue. */
1359 switch (TREE_CODE (type))
1363 /* For a void type, just define it as itself; ie, "5=5".
1364 This makes us consider it defined
1365 without saying what it is. The debugger will make it
1366 a void type when the reference is seen, and nothing will
1367 ever override that default. */
1368 dbxout_type_index (type);
1372 if (type == char_type_node && ! TREE_UNSIGNED (type))
1374 /* Output the type `char' as a subrange of itself!
1375 I don't understand this definition, just copied it
1376 from the output of pcc.
1377 This used to use `r2' explicitly and we used to
1378 take care to make sure that `char' was type number 2. */
1379 fprintf (asmfile, "r");
1381 dbxout_type_index (type);
1382 fprintf (asmfile, ";0;127;");
1386 /* If this is a subtype of another integer type, always prefer to
1387 write it as a subtype. */
1388 else if (TREE_TYPE (type) != 0
1389 && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
1391 /* If the size is non-standard, say what it is if we can use
1394 if (use_gnu_debug_info_extensions
1395 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1397 have_used_extensions = 1;
1398 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1402 dbxout_range_type (type);
1407 /* If the size is non-standard, say what it is if we can use
1410 if (use_gnu_debug_info_extensions
1411 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1413 have_used_extensions = 1;
1414 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1418 if (print_int_cst_bounds_in_octal_p (type))
1420 fprintf (asmfile, "r");
1423 /* If this type derives from another type, output type index of
1424 parent type. This is particularly important when parent type
1425 is an enumerated type, because not generating the parent type
1426 index would transform the definition of this enumerated type
1427 into a plain unsigned type. */
1428 if (TREE_TYPE (type) != 0)
1429 dbxout_type_index (TREE_TYPE (type));
1431 dbxout_type_index (type);
1433 fprintf (asmfile, ";");
1435 print_int_cst_octal (TYPE_MIN_VALUE (type));
1436 fprintf (asmfile, ";");
1438 print_int_cst_octal (TYPE_MAX_VALUE (type));
1439 fprintf (asmfile, ";");
1444 /* Output other integer types as subranges of `int'. */
1445 dbxout_range_type (type);
1451 /* This used to say `r1' and we used to take care
1452 to make sure that `int' was type number 1. */
1453 fprintf (asmfile, "r");
1455 dbxout_type_index (integer_type_node);
1456 putc (';', asmfile);
1458 print_wide_int (int_size_in_bytes (type));
1459 fputs (";0;", asmfile);
1464 if (use_gnu_debug_info_extensions)
1466 have_used_extensions = 1;
1467 fputs ("@s", asmfile);
1469 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1470 fputs (";-20;", asmfile);
1475 /* Output the type `char' as a subrange of itself.
1476 That is what pcc seems to do. */
1477 fprintf (asmfile, "r");
1479 dbxout_type_index (char_type_node);
1480 fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1486 if (use_gnu_debug_info_extensions)
1488 have_used_extensions = 1;
1489 fputs ("@s", asmfile);
1491 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1492 fputs (";-16;", asmfile);
1495 else /* Define as enumeral type (False, True) */
1497 fprintf (asmfile, "eFalse:0,True:1,;");
1503 putc ('d', asmfile);
1505 dbxout_type (TREE_TYPE (type), 0);
1509 /* Differs from the REAL_TYPE by its new data type number.
1510 R3 is NF_COMPLEX. We don't try to use any of the other NF_*
1511 codes since gdb doesn't care anyway. */
1513 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1515 fputs ("R3;", asmfile);
1517 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type)));
1518 fputs (";0;", asmfile);
1523 /* Output a complex integer type as a structure,
1524 pending some other way to do it. */
1525 putc ('s', asmfile);
1527 print_wide_int (int_size_in_bytes (type));
1528 fprintf (asmfile, "real:");
1531 dbxout_type (TREE_TYPE (type), 0);
1532 fprintf (asmfile, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type)));
1534 fprintf (asmfile, "imag:");
1536 dbxout_type (TREE_TYPE (type), 0);
1537 fprintf (asmfile, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type)),
1538 TYPE_PRECISION (TREE_TYPE (type)));
1544 if (use_gnu_debug_info_extensions)
1546 have_used_extensions = 1;
1547 fputs ("@s", asmfile);
1549 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1550 putc (';', asmfile);
1553 /* Check if a bitstring type, which in Chill is
1554 different from a [power]set. */
1555 if (TYPE_STRING_FLAG (type))
1557 fprintf (asmfile, "@S;");
1561 putc ('S', asmfile);
1563 dbxout_type (TYPE_DOMAIN (type), 0);
1567 /* Make arrays of packed bits look like bitstrings for chill. */
1568 if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
1570 have_used_extensions = 1;
1571 fputs ("@s", asmfile);
1573 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1574 fprintf (asmfile, ";@S;S");
1576 dbxout_type (TYPE_DOMAIN (type), 0);
1580 /* Output "a" followed by a range type definition
1581 for the index type of the array
1582 followed by a reference to the target-type.
1583 ar1;0;N;M for a C array of type M and size N+1. */
1584 /* Check if a character string type, which in Chill is
1585 different from an array of characters. */
1586 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1588 have_used_extensions = 1;
1589 fprintf (asmfile, "@S;");
1592 tem = TYPE_DOMAIN (type);
1595 fprintf (asmfile, "ar");
1597 dbxout_type_index (integer_type_node);
1598 fprintf (asmfile, ";0;-1;");
1603 fprintf (asmfile, "a");
1605 dbxout_range_type (tem);
1608 dbxout_type (TREE_TYPE (type), 0);
1613 case QUAL_UNION_TYPE:
1615 int i, n_baseclasses = 0;
1617 if (TYPE_BINFO (type) != 0
1618 && TREE_CODE (TYPE_BINFO (type)) == TREE_VEC
1619 && TYPE_BINFO_BASETYPES (type) != 0)
1620 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1622 /* Output a structure type. We must use the same test here as we
1623 use in the DBX_NO_XREFS case above. */
1624 if ((TYPE_NAME (type) != 0
1625 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1626 && DECL_IGNORED_P (TYPE_NAME (type)))
1628 || !COMPLETE_TYPE_P (type)
1629 /* No way in DBX fmt to describe a variable size. */
1630 || ! host_integerp (TYPE_SIZE (type), 1))
1632 /* If the type is just a cross reference, output one
1633 and mark the type as partially described.
1634 If it later becomes defined, we will output
1635 its real definition.
1636 If the type has a name, don't nest its definition within
1637 another type's definition; instead, output an xref
1638 and let the definition come when the name is defined. */
1639 fputs ((TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu", asmfile);
1641 #if 0 /* This assertion is legitimately false in C++. */
1642 /* We shouldn't be outputting a reference to a type before its
1643 definition unless the type has a tag name.
1644 A typedef name without a tag name should be impossible. */
1645 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1648 if (TYPE_NAME (type) != 0)
1649 dbxout_type_name (type);
1652 fprintf (asmfile, "$$%d", anonymous_type_number++);
1656 fprintf (asmfile, ":");
1658 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1662 /* Identify record or union, and print its size. */
1663 putc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asmfile);
1665 print_wide_int (int_size_in_bytes (type));
1667 if (use_gnu_debug_info_extensions)
1671 have_used_extensions = 1;
1672 fprintf (asmfile, "!%d,", n_baseclasses);
1676 for (i = 0; i < n_baseclasses; i++)
1678 tree binfo = TYPE_BINFO (type);
1679 tree child = BINFO_BASETYPE (binfo, i);
1680 tree access = (BINFO_BASEACCESSES (binfo)
1681 ? BINFO_BASEACCESS (binfo, i) : access_public_node);
1683 if (use_gnu_debug_info_extensions)
1685 have_used_extensions = 1;
1686 putc (TREE_VIA_VIRTUAL (child) ? '1' : '0', asmfile);
1687 putc (access == access_public_node ? '2' :
1688 (access == access_protected_node ? '1' :'0'),
1691 if (TREE_VIA_VIRTUAL (child)
1692 && strcmp (lang_hooks.name, "GNU C++") == 0)
1693 /* For a virtual base, print the (negative) offset within
1694 the vtable where we must look to find the necessary
1696 print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child), 0)
1699 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1701 putc (',', asmfile);
1703 dbxout_type (BINFO_TYPE (child), 0);
1704 putc (';', asmfile);
1709 /* Print out the base class information with fields
1710 which have the same names at the types they hold. */
1711 dbxout_type_name (BINFO_TYPE (child));
1712 putc (':', asmfile);
1714 dbxout_type (BINFO_TYPE (child), full);
1715 putc (',', asmfile);
1717 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1719 putc (',', asmfile);
1721 print_wide_int (tree_low_cst (TYPE_SIZE (BINFO_TYPE (child)),
1724 putc (';', asmfile);
1730 /* Write out the field declarations. */
1731 dbxout_type_fields (type);
1732 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1734 have_used_extensions = 1;
1735 dbxout_type_methods (type);
1738 putc (';', asmfile);
1741 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1742 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1743 && TYPE_VFIELD (type))
1745 have_used_extensions = 1;
1747 /* Tell GDB+ that it may keep reading. */
1748 putc ('~', asmfile);
1751 /* We need to write out info about what field this class
1752 uses as its "main" vtable pointer field, because if this
1753 field is inherited from a base class, GDB cannot necessarily
1754 figure out which field it's using in time. */
1755 if (TYPE_VFIELD (type))
1757 putc ('%', asmfile);
1759 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0);
1762 putc (';', asmfile);
1768 /* We must use the same test here as we use in the DBX_NO_XREFS case
1769 above. We simplify it a bit since an enum will never have a variable
1771 if ((TYPE_NAME (type) != 0
1772 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1773 && DECL_IGNORED_P (TYPE_NAME (type)))
1775 || !COMPLETE_TYPE_P (type))
1777 fprintf (asmfile, "xe");
1779 dbxout_type_name (type);
1780 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1781 putc (':', asmfile);
1785 if (use_gnu_debug_info_extensions
1786 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1788 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1792 putc ('e', asmfile);
1794 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1796 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1797 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem)) + 1);
1798 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1799 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1800 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1801 && (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1802 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1804 print_int_cst_octal (TREE_VALUE (tem));
1806 putc (',', asmfile);
1808 if (TREE_CHAIN (tem) != 0)
1812 putc (';', asmfile);
1817 putc ('*', asmfile);
1819 dbxout_type (TREE_TYPE (type), 0);
1823 if (use_gnu_debug_info_extensions)
1825 have_used_extensions = 1;
1826 putc ('#', asmfile);
1829 /* Write the argument types out longhand. */
1830 dbxout_type (TYPE_METHOD_BASETYPE (type), 0);
1831 putc (',', asmfile);
1833 dbxout_type (TREE_TYPE (type), 0);
1834 dbxout_args (TYPE_ARG_TYPES (type));
1835 putc (';', asmfile);
1839 /* Treat it as a function type. */
1840 dbxout_type (TREE_TYPE (type), 0);
1844 if (use_gnu_debug_info_extensions)
1846 have_used_extensions = 1;
1847 putc ('@', asmfile);
1849 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0);
1850 putc (',', asmfile);
1852 dbxout_type (TREE_TYPE (type), 0);
1855 /* Should print as an int, because it is really just an offset. */
1856 dbxout_type (integer_type_node, 0);
1859 case REFERENCE_TYPE:
1860 if (use_gnu_debug_info_extensions)
1861 have_used_extensions = 1;
1862 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1864 dbxout_type (TREE_TYPE (type), 0);
1868 putc ('f', asmfile);
1870 dbxout_type (TREE_TYPE (type), 0);
1878 /* Return nonzero if the given type represents an integer whose bounds
1879 should be printed in octal format. */
1882 print_int_cst_bounds_in_octal_p (tree type)
1884 /* If we can use GDB extensions and the size is wider than a long
1885 (the size used by GDB to read them) or we may have trouble writing
1886 the bounds the usual way, write them in octal. Note the test is for
1887 the *target's* size of "long", not that of the host. The host test
1888 is just to make sure we can write it out in case the host wide int
1889 is narrower than the target "long".
1891 For unsigned types, we use octal if they are the same size or larger.
1892 This is because we print the bounds as signed decimal, and hence they
1893 can't span same size unsigned types. */
1895 if (use_gnu_debug_info_extensions
1896 && TYPE_MIN_VALUE (type) != 0
1897 && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
1898 && TYPE_MAX_VALUE (type) != 0
1899 && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
1900 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1901 || ((TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
1902 && TREE_UNSIGNED (type))
1903 || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT
1904 || (TYPE_PRECISION (type) == HOST_BITS_PER_WIDE_INT
1905 && TREE_UNSIGNED (type))))
1911 /* Print the value of integer constant C, in octal,
1912 handling double precision. */
1915 print_int_cst_octal (tree c)
1917 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1918 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1919 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1920 unsigned int width = TYPE_PRECISION (TREE_TYPE (c));
1922 /* GDB wants constants with no extra leading "1" bits, so
1923 we need to remove any sign-extension that might be
1925 if (width == HOST_BITS_PER_WIDE_INT * 2)
1927 else if (width > HOST_BITS_PER_WIDE_INT)
1928 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1929 else if (width == HOST_BITS_PER_WIDE_INT)
1932 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1934 fprintf (asmfile, "0");
1939 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1940 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1944 unsigned HOST_WIDE_INT beg = high >> excess;
1945 unsigned HOST_WIDE_INT middle
1946 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1947 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1948 unsigned HOST_WIDE_INT end
1949 = low & (((unsigned HOST_WIDE_INT) 1
1950 << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1953 fprintf (asmfile, "%o%01o", (int) beg, (int) middle);
1955 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1960 print_octal (unsigned HOST_WIDE_INT value, int digits)
1964 for (i = digits - 1; i >= 0; i--)
1965 fprintf (asmfile, "%01o", (int) ((value >> (3 * i)) & 7));
1970 /* Output C in decimal while adjusting the number of digits written. */
1973 print_wide_int (HOST_WIDE_INT c)
1977 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, c);
1988 /* Output the name of type TYPE, with no punctuation.
1989 Such names can be set up either by typedef declarations
1990 or by struct, enum and union tags. */
1993 dbxout_type_name (tree type)
1996 if (TYPE_NAME (type) == 0)
1998 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
2000 t = TYPE_NAME (type);
2002 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
2004 t = DECL_NAME (TYPE_NAME (type));
2009 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
2010 CHARS (IDENTIFIER_LENGTH (t));
2013 /* Output leading leading struct or class names needed for qualifying
2014 type whose scope is limited to a struct or class. */
2017 dbxout_class_name_qualifiers (tree decl)
2019 tree context = decl_type_context (decl);
2021 if (context != NULL_TREE
2022 && TREE_CODE(context) == RECORD_TYPE
2023 && TYPE_NAME (context) != 0
2024 && (TREE_CODE (TYPE_NAME (context)) == IDENTIFIER_NODE
2025 || (DECL_NAME (TYPE_NAME (context)) != 0)))
2027 tree name = TYPE_NAME (context);
2029 emit_pending_bincls_if_required ();
2031 if (TREE_CODE (name) == TYPE_DECL)
2033 dbxout_class_name_qualifiers (name);
2034 name = DECL_NAME (name);
2036 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
2037 CHARS (IDENTIFIER_LENGTH (name) + 2);
2041 /* Output a .stabs for the symbol defined by DECL,
2042 which must be a ..._DECL node in the normal namespace.
2043 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
2044 LOCAL is nonzero if the scope is less than the entire file.
2045 Return 1 if a stabs might have been emitted. */
2048 dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
2050 tree type = TREE_TYPE (decl);
2051 tree context = NULL_TREE;
2054 /* "Intercept" dbxout_symbol() calls like we do all debug_hooks. */
2057 /* Ignore nameless syms, but don't ignore type tags. */
2059 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
2060 || DECL_IGNORED_P (decl))
2061 DBXOUT_DECR_NESTING_AND_RETURN (0);
2063 /* If we are to generate only the symbols actually used then such
2064 symbol nodees are flagged with TREE_USED. Ignore any that
2065 aren't flaged as TREE_USED. */
2067 if (flag_debug_only_used_symbols)
2071 if (!TREE_USED (decl)
2072 && (TREE_CODE (decl) != VAR_DECL || !DECL_INITIAL (decl)))
2073 DBXOUT_DECR_NESTING_AND_RETURN (0);
2075 /* We now have a used symbol. We need to generate the info for
2076 the symbol's type in addition to the symbol itself. These
2077 type symbols are queued to be generated after were done with
2078 the symbol itself (done because the symbol's info is generated
2079 with fprintf's, etc. as it determines what's needed).
2081 Note, because the TREE_TYPE(type) might be something like a
2082 pointer to a named type we need to look for the first name
2083 we see following the TREE_TYPE chain. */
2086 while (POINTER_TYPE_P (t))
2089 /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE
2090 need special treatment. The TYPE_STUB_DECL field in these
2091 types generally represents the tag name type we want to
2092 output. In addition there could be a typedef type with
2093 a different name. In that case we also want to output
2096 if ((TREE_CODE (t) == RECORD_TYPE
2097 || TREE_CODE (t) == UNION_TYPE
2098 || TREE_CODE (t) == QUAL_UNION_TYPE
2099 || TREE_CODE (t) == ENUMERAL_TYPE)
2100 && TYPE_STUB_DECL (t)
2101 && TYPE_STUB_DECL (t) != decl
2102 && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (t))) == 'd'
2103 && ! DECL_IGNORED_P (TYPE_STUB_DECL (t)))
2105 debug_queue_symbol (TYPE_STUB_DECL (t));
2107 && TYPE_NAME (t) != TYPE_STUB_DECL (t)
2108 && TYPE_NAME (t) != decl
2109 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t))) == 'd')
2110 debug_queue_symbol (TYPE_NAME (t));
2112 else if (TYPE_NAME (t)
2113 && TYPE_NAME (t) != decl
2114 && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t))) == 'd')
2115 debug_queue_symbol (TYPE_NAME (t));
2118 emit_pending_bincls_if_required ();
2120 dbxout_prepare_symbol (decl);
2122 /* The output will always start with the symbol name,
2123 so always count that in the length-output-so-far. */
2125 if (DECL_NAME (decl) != 0)
2126 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
2128 switch (TREE_CODE (decl))
2131 /* Enum values are defined by defining the enum type. */
2135 if (DECL_RTL (decl) == 0)
2136 DBXOUT_DECR_NESTING_AND_RETURN (0);
2137 if (DECL_EXTERNAL (decl))
2139 /* Don't mention a nested function under its parent. */
2140 context = decl_function_context (decl);
2141 if (context == current_function_decl)
2143 if (GET_CODE (DECL_RTL (decl)) != MEM
2144 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
2148 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2149 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
2150 TREE_PUBLIC (decl) ? 'F' : 'f');
2153 current_sym_code = N_FUN;
2154 current_sym_addr = XEXP (DECL_RTL (decl), 0);
2156 if (TREE_TYPE (type))
2157 dbxout_type (TREE_TYPE (type), 0);
2159 dbxout_type (void_type_node, 0);
2161 /* For a nested function, when that function is compiled,
2162 mention the containing function name
2163 as well as (since dbx wants it) our own assembler-name. */
2165 fprintf (asmfile, ",%s,%s",
2166 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
2167 IDENTIFIER_POINTER (DECL_NAME (context)));
2169 dbxout_finish_symbol (decl);
2173 /* Don't output the same typedef twice.
2174 And don't output what language-specific stuff doesn't want output. */
2175 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
2176 DBXOUT_DECR_NESTING_AND_RETURN (0);
2184 if (DECL_NAME (decl))
2186 /* Nonzero means we must output a tag as well as a typedef. */
2189 /* Handle the case of a C++ structure or union
2190 where the TYPE_NAME is a TYPE_DECL
2191 which gives both a typedef name and a tag. */
2192 /* dbx requires the tag first and the typedef second. */
2193 if ((TREE_CODE (type) == RECORD_TYPE
2194 || TREE_CODE (type) == UNION_TYPE
2195 || TREE_CODE (type) == QUAL_UNION_TYPE)
2196 && TYPE_NAME (type) == decl
2197 && !(use_gnu_debug_info_extensions && have_used_extensions)
2198 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
2199 /* Distinguish the implicit typedefs of C++
2200 from explicit ones that might be found in C. */
2201 && DECL_ARTIFICIAL (decl)
2202 /* Do not generate a tag for incomplete records. */
2203 && COMPLETE_TYPE_P (type)
2204 /* Do not generate a tag for records of variable size,
2205 since this type can not be properly described in the
2206 DBX format, and it confuses some tools such as objdump. */
2207 && host_integerp (TYPE_SIZE (type), 1))
2209 tree name = TYPE_NAME (type);
2210 if (TREE_CODE (name) == TYPE_DECL)
2211 name = DECL_NAME (name);
2213 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2214 current_sym_value = 0;
2215 current_sym_addr = 0;
2216 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2218 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
2219 IDENTIFIER_POINTER (name));
2220 dbxout_type (type, 1);
2221 dbxout_finish_symbol (NULL_TREE);
2224 /* Output .stabs (or whatever) and leading double quote. */
2225 fprintf (asmfile, "%s\"", ASM_STABS_OP);
2227 if (use_gnu_debug_info_extensions)
2229 /* Output leading class/struct qualifiers. */
2230 dbxout_class_name_qualifiers (decl);
2233 /* Output typedef name. */
2234 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl)));
2236 /* Short cut way to output a tag also. */
2237 if ((TREE_CODE (type) == RECORD_TYPE
2238 || TREE_CODE (type) == UNION_TYPE
2239 || TREE_CODE (type) == QUAL_UNION_TYPE)
2240 && TYPE_NAME (type) == decl
2241 /* Distinguish the implicit typedefs of C++
2242 from explicit ones that might be found in C. */
2243 && DECL_ARTIFICIAL (decl))
2245 if (use_gnu_debug_info_extensions && have_used_extensions)
2247 putc ('T', asmfile);
2248 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
2250 #if 0 /* Now we generate the tag for this case up above. */
2256 putc ('t', asmfile);
2257 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2259 dbxout_type (type, 1);
2260 dbxout_finish_symbol (decl);
2264 /* Don't output a tag if this is an incomplete type. This prevents
2265 the sun4 Sun OS 4.x dbx from crashing. */
2267 if (tag_needed && TYPE_NAME (type) != 0
2268 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
2269 || (DECL_NAME (TYPE_NAME (type)) != 0))
2270 && COMPLETE_TYPE_P (type)
2271 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
2273 /* For a TYPE_DECL with no name, but the type has a name,
2275 This is what represents `struct foo' with no typedef. */
2276 /* In C++, the name of a type is the corresponding typedef.
2277 In C, it is an IDENTIFIER_NODE. */
2278 tree name = TYPE_NAME (type);
2279 if (TREE_CODE (name) == TYPE_DECL)
2280 name = DECL_NAME (name);
2282 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2283 current_sym_value = 0;
2284 current_sym_addr = 0;
2285 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2287 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
2288 IDENTIFIER_POINTER (name));
2289 dbxout_type (type, 1);
2290 dbxout_finish_symbol (NULL_TREE);
2294 /* If an enum type has no name, it cannot be referred to,
2295 but we must output it anyway, since the enumeration constants
2296 can be referred to. */
2297 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
2299 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2300 current_sym_value = 0;
2301 current_sym_addr = 0;
2302 current_sym_nchars = 2;
2304 /* Some debuggers fail when given NULL names, so give this a
2305 harmless name of ` '. */
2306 fprintf (asmfile, "%s\" :T", ASM_STABS_OP);
2307 dbxout_type (type, 1);
2308 dbxout_finish_symbol (NULL_TREE);
2311 /* Prevent duplicate output of a typedef. */
2312 TREE_ASM_WRITTEN (decl) = 1;
2317 /* Parm decls go in their own separate chains
2318 and are output by dbxout_reg_parms and dbxout_parms. */
2322 /* Named return value, treat like a VAR_DECL. */
2324 if (! DECL_RTL_SET_P (decl))
2325 DBXOUT_DECR_NESTING_AND_RETURN (0);
2326 /* Don't mention a variable that is external.
2327 Let the file that defines it describe it. */
2328 if (DECL_EXTERNAL (decl))
2331 /* If the variable is really a constant
2332 and not written in memory, inform the debugger. */
2333 if (TREE_STATIC (decl) && TREE_READONLY (decl)
2334 && DECL_INITIAL (decl) != 0
2335 && host_integerp (DECL_INITIAL (decl), 0)
2336 && ! TREE_ASM_WRITTEN (decl)
2337 && (DECL_CONTEXT (decl) == NULL_TREE
2338 || TREE_CODE (DECL_CONTEXT (decl)) == BLOCK))
2340 if (TREE_PUBLIC (decl) == 0)
2342 /* The sun4 assembler does not grok this. */
2343 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
2345 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
2346 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
2348 HOST_WIDE_INT ival = tree_low_cst (DECL_INITIAL (decl), 0);
2349 fprintf (asmfile, "%s\"%s:c=i" HOST_WIDE_INT_PRINT_DEC
2351 ASM_STABS_OP, name, ival, N_LSYM);
2352 DBXOUT_DECR_NESTING;
2355 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
2357 /* Don't know how to do this yet. */
2361 /* else it is something we handle like a normal variable. */
2364 SET_DECL_RTL (decl, eliminate_regs (DECL_RTL (decl), 0, NULL_RTX));
2365 #ifdef LEAF_REG_REMAP
2366 if (current_function_uses_only_leaf_regs)
2367 leaf_renumber_regs_insn (DECL_RTL (decl));
2370 result = dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
2376 DBXOUT_DECR_NESTING;
2380 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2381 Add SUFFIX to its name, if SUFFIX is not 0.
2382 Describe the variable as residing in HOME
2383 (usually HOME is DECL_RTL (DECL), but not always).
2384 Returns 1 if the stab was really emitted. */
2387 dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
2392 emit_pending_bincls_if_required ();
2394 /* Don't mention a variable at all
2395 if it was completely optimized into nothingness.
2397 If the decl was from an inline function, then its rtl
2398 is not identically the rtl that was used in this
2399 particular compilation. */
2400 if (GET_CODE (home) == SUBREG)
2404 while (GET_CODE (value) == SUBREG)
2405 value = SUBREG_REG (value);
2406 if (GET_CODE (value) == REG)
2408 if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
2411 home = alter_subreg (&home);
2413 if (GET_CODE (home) == REG)
2415 regno = REGNO (home);
2416 if (regno >= FIRST_PSEUDO_REGISTER)
2420 /* The kind-of-variable letter depends on where
2421 the variable is and on the scope of its name:
2422 G and N_GSYM for static storage and global scope,
2423 S for static storage and file scope,
2424 V for static storage and local scope,
2425 for those two, use N_LCSYM if data is in bss segment,
2426 N_STSYM if in data segment, N_FUN otherwise.
2427 (We used N_FUN originally, then changed to N_STSYM
2428 to please GDB. However, it seems that confused ld.
2429 Now GDB has been fixed to like N_FUN, says Kingdon.)
2430 no letter at all, and N_LSYM, for auto variable,
2431 r and N_RSYM for register variable. */
2433 if (GET_CODE (home) == MEM
2434 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
2436 if (TREE_PUBLIC (decl))
2439 current_sym_code = N_GSYM;
2443 current_sym_addr = XEXP (home, 0);
2445 letter = decl_function_context (decl) ? 'V' : 'S';
2447 /* This should be the same condition as in assemble_variable, but
2448 we don't have access to dont_output_data here. So, instead,
2449 we rely on the fact that error_mark_node initializers always
2450 end up in bss for C++ and never end up in bss for C. */
2451 if (DECL_INITIAL (decl) == 0
2452 || (!strcmp (lang_hooks.name, "GNU C++")
2453 && DECL_INITIAL (decl) == error_mark_node))
2454 current_sym_code = N_LCSYM;
2455 else if (DECL_IN_TEXT_SECTION (decl))
2456 /* This is not quite right, but it's the closest
2457 of all the codes that Unix defines. */
2458 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
2461 /* Some ports can transform a symbol ref into a label ref,
2462 because the symbol ref is too far away and has to be
2463 dumped into a constant pool. Alternatively, the symbol
2464 in the constant pool might be referenced by a different
2466 if (GET_CODE (current_sym_addr) == SYMBOL_REF
2467 && CONSTANT_POOL_ADDRESS_P (current_sym_addr))
2469 rtx tmp = get_pool_constant (current_sym_addr);
2471 if (GET_CODE (tmp) == SYMBOL_REF
2472 || GET_CODE (tmp) == LABEL_REF)
2473 current_sym_addr = tmp;
2476 /* Ultrix `as' seems to need this. */
2477 #ifdef DBX_STATIC_STAB_DATA_SECTION
2480 current_sym_code = N_STSYM;
2484 else if (regno >= 0)
2487 current_sym_code = N_RSYM;
2488 current_sym_value = DBX_REGISTER_NUMBER (regno);
2490 else if (GET_CODE (home) == MEM
2491 && (GET_CODE (XEXP (home, 0)) == MEM
2492 || (GET_CODE (XEXP (home, 0)) == REG
2493 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
2494 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
2495 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2496 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
2499 /* If the value is indirect by memory or by a register
2500 that isn't the frame pointer
2501 then it means the object is variable-sized and address through
2502 that register or stack slot. DBX has no way to represent this
2503 so all we can do is output the variable as a pointer.
2504 If it's not a parameter, ignore it.
2505 (VAR_DECLs like this can be made by integrate.c.) */
2507 if (GET_CODE (XEXP (home, 0)) == REG)
2510 current_sym_code = N_RSYM;
2511 if (REGNO (XEXP (home, 0)) >= FIRST_PSEUDO_REGISTER)
2513 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2517 current_sym_code = N_LSYM;
2518 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2519 We want the value of that CONST_INT. */
2521 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2524 /* Effectively do build_pointer_type, but don't cache this type,
2525 since it might be temporary whereas the type it points to
2526 might have been saved for inlining. */
2527 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2528 type = make_node (POINTER_TYPE);
2529 TREE_TYPE (type) = TREE_TYPE (decl);
2531 else if (GET_CODE (home) == MEM
2532 && GET_CODE (XEXP (home, 0)) == REG)
2534 current_sym_code = N_LSYM;
2535 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2537 else if (GET_CODE (home) == MEM
2538 && GET_CODE (XEXP (home, 0)) == PLUS
2539 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2541 current_sym_code = N_LSYM;
2542 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2543 We want the value of that CONST_INT. */
2544 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2546 else if (GET_CODE (home) == MEM
2547 && GET_CODE (XEXP (home, 0)) == CONST)
2549 /* Handle an obscure case which can arise when optimizing and
2550 when there are few available registers. (This is *always*
2551 the case for i386/i486 targets). The RTL looks like
2552 (MEM (CONST ...)) even though this variable is a local `auto'
2553 or a local `register' variable. In effect, what has happened
2554 is that the reload pass has seen that all assignments and
2555 references for one such a local variable can be replaced by
2556 equivalent assignments and references to some static storage
2557 variable, thereby avoiding the need for a register. In such
2558 cases we're forced to lie to debuggers and tell them that
2559 this variable was itself `static'. */
2560 current_sym_code = N_LCSYM;
2562 current_sym_addr = XEXP (XEXP (home, 0), 0);
2564 else if (GET_CODE (home) == CONCAT)
2568 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2569 for example), then there is no easy way to figure out
2570 what SUBTYPE should be. So, we give up. */
2571 if (TREE_CODE (type) != COMPLEX_TYPE)
2574 subtype = TREE_TYPE (type);
2576 /* If the variable's storage is in two parts,
2577 output each as a separate stab with a modified name. */
2578 if (WORDS_BIG_ENDIAN)
2579 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2581 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2583 dbxout_prepare_symbol (decl);
2585 if (WORDS_BIG_ENDIAN)
2586 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2588 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2592 /* Address might be a MEM, when DECL is a variable-sized object.
2593 Or it might be const0_rtx, meaning previous passes
2594 want us to ignore this variable. */
2597 /* Ok, start a symtab entry and output the variable name. */
2600 #ifdef DBX_STATIC_BLOCK_START
2601 DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2604 dbxout_symbol_name (decl, suffix, letter);
2605 dbxout_type (type, 0);
2606 dbxout_finish_symbol (decl);
2608 #ifdef DBX_STATIC_BLOCK_END
2609 DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2614 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2615 Then output LETTER to indicate the kind of location the symbol has. */
2618 dbxout_symbol_name (tree decl, const char *suffix, int letter)
2622 if (DECL_CONTEXT (decl)
2623 && (TYPE_P (DECL_CONTEXT (decl))
2624 || TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL))
2625 /* One slight hitch: if this is a VAR_DECL which is a class member
2626 or a namespace member, we must put out the mangled name instead of the
2627 DECL_NAME. Note also that static member (variable) names DO NOT begin
2628 with underscores in .stabs directives. */
2629 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2631 /* ...but if we're function-local, we don't want to include the junk
2632 added by ASM_FORMAT_PRIVATE_NAME. */
2633 name = IDENTIFIER_POINTER (DECL_NAME (decl));
2637 fprintf (asmfile, "%s\"%s%s:", ASM_STABS_OP, name,
2638 (suffix ? suffix : ""));
2641 putc (letter, asmfile);
2645 dbxout_prepare_symbol (tree decl ATTRIBUTE_UNUSED)
2648 const char *filename = DECL_SOURCE_FILE (decl);
2650 dbxout_source_file (asmfile, filename);
2653 /* Initialize variables used to communicate each symbol's debug
2654 information to dbxout_finish_symbol with zeroes. */
2656 /* Cast avoids warning in old compilers. */
2657 current_sym_code = (STAB_CODE_TYPE) 0;
2658 current_sym_value = 0;
2659 current_sym_addr = 0;
2663 dbxout_finish_symbol (tree sym)
2665 #ifdef DBX_FINISH_SYMBOL
2666 DBX_FINISH_SYMBOL (sym);
2669 if (use_gnu_debug_info_extensions && sym != 0)
2670 line = DECL_SOURCE_LINE (sym);
2672 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2673 if (current_sym_addr)
2674 output_addr_const (asmfile, current_sym_addr);
2676 fprintf (asmfile, "%d", current_sym_value);
2677 putc ('\n', asmfile);
2681 /* Output definitions of all the decls in a chain. Return nonzero if
2682 anything was output */
2685 dbxout_syms (tree syms)
2690 result += dbxout_symbol (syms, 1);
2691 syms = TREE_CHAIN (syms);
2696 /* The following two functions output definitions of function parameters.
2697 Each parameter gets a definition locating it in the parameter list.
2698 Each parameter that is a register variable gets a second definition
2699 locating it in the register.
2701 Printing or argument lists in gdb uses the definitions that
2702 locate in the parameter list. But reference to the variable in
2703 expressions uses preferentially the definition as a register. */
2705 /* Output definitions, referring to storage in the parmlist,
2706 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2709 dbxout_parms (tree parms)
2713 emit_pending_bincls_if_required ();
2715 for (; parms; parms = TREE_CHAIN (parms))
2716 if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2718 dbxout_prepare_symbol (parms);
2720 /* Perform any necessary register eliminations on the parameter's rtl,
2721 so that the debugging output will be accurate. */
2722 DECL_INCOMING_RTL (parms)
2723 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2724 SET_DECL_RTL (parms, eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
2725 #ifdef LEAF_REG_REMAP
2726 if (current_function_uses_only_leaf_regs)
2728 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2729 leaf_renumber_regs_insn (DECL_RTL (parms));
2733 if (PARM_PASSED_IN_MEMORY (parms))
2735 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2737 /* ??? Here we assume that the parm address is indexed
2738 off the frame pointer or arg pointer.
2739 If that is not true, we produce meaningless results,
2740 but do not crash. */
2741 if (GET_CODE (addr) == PLUS
2742 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2743 current_sym_value = INTVAL (XEXP (addr, 1));
2745 current_sym_value = 0;
2747 current_sym_code = N_PSYM;
2748 current_sym_addr = 0;
2751 if (DECL_NAME (parms))
2753 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2755 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2756 IDENTIFIER_POINTER (DECL_NAME (parms)),
2757 DBX_MEMPARM_STABS_LETTER);
2761 current_sym_nchars = 8;
2762 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2763 DBX_MEMPARM_STABS_LETTER);
2766 /* It is quite tempting to use:
2768 dbxout_type (TREE_TYPE (parms), 0);
2770 as the next statement, rather than using DECL_ARG_TYPE(), so
2771 that gcc reports the actual type of the parameter, rather
2772 than the promoted type. This certainly makes GDB's life
2773 easier, at least for some ports. The change is a bad idea
2774 however, since GDB expects to be able access the type without
2775 performing any conversions. So for example, if we were
2776 passing a float to an unprototyped function, gcc will store a
2777 double on the stack, but if we emit a stab saying the type is a
2778 float, then gdb will only read in a single value, and this will
2779 produce an erroneous value. */
2780 dbxout_type (DECL_ARG_TYPE (parms), 0);
2781 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2782 dbxout_finish_symbol (parms);
2784 else if (GET_CODE (DECL_RTL (parms)) == REG)
2787 char regparm_letter;
2789 /* Parm passed in registers and lives in registers or nowhere. */
2791 current_sym_code = DBX_REGPARM_STABS_CODE;
2792 regparm_letter = DBX_REGPARM_STABS_LETTER;
2793 current_sym_addr = 0;
2795 /* If parm lives in a register, use that register;
2796 pretend the parm was passed there. It would be more consistent
2797 to describe the register where the parm was passed,
2798 but in practice that register usually holds something else.
2800 If we use DECL_RTL, then we must use the declared type of
2801 the variable, not the type that it arrived in. */
2802 if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2804 best_rtl = DECL_RTL (parms);
2805 parm_type = TREE_TYPE (parms);
2807 /* If the parm lives nowhere, use the register where it was
2808 passed. It is also better to use the declared type here. */
2811 best_rtl = DECL_INCOMING_RTL (parms);
2812 parm_type = TREE_TYPE (parms);
2814 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2817 if (DECL_NAME (parms))
2819 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2820 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2821 IDENTIFIER_POINTER (DECL_NAME (parms)),
2826 current_sym_nchars = 8;
2827 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2831 dbxout_type (parm_type, 0);
2832 dbxout_finish_symbol (parms);
2834 else if (GET_CODE (DECL_RTL (parms)) == MEM
2835 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2836 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2837 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2838 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2839 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2843 /* Parm was passed via invisible reference.
2844 That is, its address was passed in a register.
2845 Output it as if it lived in that register.
2846 The debugger will know from the type
2847 that it was actually passed by invisible reference. */
2849 char regparm_letter;
2850 /* Parm passed in registers and lives in registers or nowhere. */
2852 current_sym_code = DBX_REGPARM_STABS_CODE;
2853 if (use_gnu_debug_info_extensions)
2854 regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2856 regparm_letter = DBX_REGPARM_STABS_LETTER;
2858 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2859 If it is an unallocated pseudo-reg, then use the register where
2860 it was passed instead. */
2861 if (REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2862 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2864 current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2866 current_sym_addr = 0;
2869 if (DECL_NAME (parms))
2872 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2874 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2875 IDENTIFIER_POINTER (DECL_NAME (parms)),
2880 current_sym_nchars = 8;
2881 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2885 dbxout_type (TREE_TYPE (parms), 0);
2886 dbxout_finish_symbol (parms);
2888 else if (GET_CODE (DECL_RTL (parms)) == MEM
2889 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2891 /* Parm was passed via invisible reference, with the reference
2892 living on the stack. DECL_RTL looks like
2893 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2894 could look like (MEM (MEM (REG))). */
2895 const char *const decl_name = (DECL_NAME (parms)
2896 ? IDENTIFIER_POINTER (DECL_NAME (parms))
2898 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 0)) == REG)
2899 current_sym_value = 0;
2902 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1));
2903 current_sym_addr = 0;
2904 current_sym_code = N_PSYM;
2907 fprintf (asmfile, "%s\"%s:v", ASM_STABS_OP, decl_name);
2910 = DEBUGGER_ARG_OFFSET (current_sym_value,
2911 XEXP (XEXP (DECL_RTL (parms), 0), 0));
2912 dbxout_type (TREE_TYPE (parms), 0);
2913 dbxout_finish_symbol (parms);
2915 else if (GET_CODE (DECL_RTL (parms)) == MEM
2916 && XEXP (DECL_RTL (parms), 0) != const0_rtx
2917 /* ??? A constant address for a parm can happen
2918 when the reg it lives in is equiv to a constant in memory.
2919 Should make this not happen, after 2.4. */
2920 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2922 /* Parm was passed in registers but lives on the stack. */
2924 current_sym_code = N_PSYM;
2925 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2926 in which case we want the value of that CONST_INT,
2928 in which case we use a value of zero. */
2929 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG)
2930 current_sym_value = 0;
2933 = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2935 current_sym_addr = 0;
2937 /* Make a big endian correction if the mode of the type of the
2938 parameter is not the same as the mode of the rtl. */
2939 if (BYTES_BIG_ENDIAN
2940 && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms))
2941 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD)
2943 current_sym_value +=
2944 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))
2945 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms)));
2949 if (DECL_NAME (parms))
2952 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2954 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2955 IDENTIFIER_POINTER (DECL_NAME (parms)),
2956 DBX_MEMPARM_STABS_LETTER);
2960 current_sym_nchars = 8;
2961 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2962 DBX_MEMPARM_STABS_LETTER);
2966 = DEBUGGER_ARG_OFFSET (current_sym_value,
2967 XEXP (DECL_RTL (parms), 0));
2968 dbxout_type (TREE_TYPE (parms), 0);
2969 dbxout_finish_symbol (parms);
2972 DBXOUT_DECR_NESTING;
2975 /* Output definitions for the places where parms live during the function,
2976 when different from where they were passed, when the parms were passed
2979 It is not useful to do this for parms passed in registers
2980 that live during the function in different registers, because it is
2981 impossible to look in the passed register for the passed value,
2982 so we use the within-the-function register to begin with.
2984 PARMS is a chain of PARM_DECL nodes. */
2987 dbxout_reg_parms (tree parms)
2991 for (; parms; parms = TREE_CHAIN (parms))
2992 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
2994 dbxout_prepare_symbol (parms);
2996 /* Report parms that live in registers during the function
2997 but were passed in memory. */
2998 if (GET_CODE (DECL_RTL (parms)) == REG
2999 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
3000 dbxout_symbol_location (parms, TREE_TYPE (parms),
3001 0, DECL_RTL (parms));
3002 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
3003 dbxout_symbol_location (parms, TREE_TYPE (parms),
3004 0, DECL_RTL (parms));
3005 /* Report parms that live in memory but not where they were passed. */
3006 else if (GET_CODE (DECL_RTL (parms)) == MEM
3007 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
3008 dbxout_symbol_location (parms, TREE_TYPE (parms),
3009 0, DECL_RTL (parms));
3011 DBXOUT_DECR_NESTING;
3014 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
3015 output definitions of those names, in raw form */
3018 dbxout_args (tree args)
3022 putc (',', asmfile);
3023 dbxout_type (TREE_VALUE (args), 0);
3025 args = TREE_CHAIN (args);
3029 /* Output everything about a symbol block (a BLOCK node
3030 that represents a scope level),
3031 including recursive output of contained blocks.
3033 BLOCK is the BLOCK node.
3034 DEPTH is its depth within containing symbol blocks.
3035 ARGS is usually zero; but for the outermost block of the
3036 body of a function, it is a chain of PARM_DECLs for the function parameters.
3037 We output definitions of all the register parms
3038 as if they were local variables of that block.
3040 If -g1 was used, we count blocks just the same, but output nothing
3041 except for the outermost block.
3043 Actually, BLOCK may be several blocks chained together.
3044 We handle them all in sequence. */
3047 dbxout_block (tree block, int depth, tree args)
3051 #if DBX_BLOCKS_FUNCTION_RELATIVE
3052 const char *begin_label;
3053 if (current_function_func_begin_label != NULL_TREE)
3054 begin_label = IDENTIFIER_POINTER (current_function_func_begin_label);
3056 begin_label = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
3061 /* Ignore blocks never expanded or otherwise marked as real. */
3062 if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
3066 /* In dbx format, the syms of a block come before the N_LBRAC.
3067 If nothing is output, we don't need the N_LBRAC, either. */
3069 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
3070 did_output = dbxout_syms (BLOCK_VARS (block));
3072 dbxout_reg_parms (args);
3074 /* Now output an N_LBRAC symbol to represent the beginning of
3075 the block. Use the block's tree-walk order to generate
3076 the assembler symbols LBBn and LBEn
3077 that final will define around the code in this block. */
3078 if (depth > 0 && did_output)
3081 blocknum = BLOCK_NUMBER (block);
3082 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
3084 if (BLOCK_HANDLER_BLOCK (block))
3086 /* A catch block. Must precede N_LBRAC. */
3087 tree decl = BLOCK_VARS (block);
3090 fprintf (asmfile, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP,
3091 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
3092 assemble_name (asmfile, buf);
3093 fprintf (asmfile, "\n");
3094 decl = TREE_CHAIN (decl);
3098 #ifdef DBX_OUTPUT_LBRAC
3099 DBX_OUTPUT_LBRAC (asmfile, buf);
3101 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
3102 assemble_name (asmfile, buf);
3103 #if DBX_BLOCKS_FUNCTION_RELATIVE
3104 putc ('-', asmfile);
3105 assemble_name (asmfile, begin_label);
3107 fprintf (asmfile, "\n");
3111 /* Output the subblocks. */
3112 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
3114 /* Refer to the marker for the end of the block. */
3115 if (depth > 0 && did_output)
3118 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
3119 #ifdef DBX_OUTPUT_RBRAC
3120 DBX_OUTPUT_RBRAC (asmfile, buf);
3122 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC);
3123 assemble_name (asmfile, buf);
3124 #if DBX_BLOCKS_FUNCTION_RELATIVE
3125 putc ('-', asmfile);
3126 assemble_name (asmfile, begin_label);
3128 fprintf (asmfile, "\n");
3132 block = BLOCK_CHAIN (block);
3136 /* Output the information about a function and its arguments and result.
3137 Usually this follows the function's code,
3138 but on some systems, it comes before. */
3140 #if defined (DBX_DEBUGGING_INFO)
3142 dbxout_begin_function (tree decl)
3144 int saved_tree_used1 = TREE_USED (decl);
3145 TREE_USED (decl) = 1;
3146 if (DECL_NAME (DECL_RESULT (decl)) != 0)
3148 int saved_tree_used2 = TREE_USED (DECL_RESULT (decl));
3149 TREE_USED (DECL_RESULT (decl)) = 1;
3150 dbxout_symbol (decl, 0);
3151 TREE_USED (DECL_RESULT (decl)) = saved_tree_used2;
3154 dbxout_symbol (decl, 0);
3155 TREE_USED (decl) = saved_tree_used1;
3157 dbxout_parms (DECL_ARGUMENTS (decl));
3158 if (DECL_NAME (DECL_RESULT (decl)) != 0)
3159 dbxout_symbol (DECL_RESULT (decl), 1);
3161 #endif /* DBX_DEBUGGING_INFO */
3163 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3165 #include "gt-dbxout.h"