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 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
25 /* Output dbx-format symbol table data.
26 This consists of many symbol table entries, each of them
27 a .stabs assembler pseudo-op with four operands:
28 a "name" which is really a description of one symbol and its type,
29 a "code", which is a symbol defined in stab.h whose name starts with N_,
30 an unused operand always 0,
31 and a "value" which is an address or an offset.
32 The name is enclosed in doublequote characters.
34 Each function, variable, typedef, and structure tag
35 has a symbol table entry to define it.
36 The beginning and end of each level of name scoping within
37 a function are also marked by special symbol table entries.
39 The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
40 and a data type number. The data type number may be followed by
41 "=" and a type definition; normally this will happen the first time
42 the type number is mentioned. The type definition may refer to
43 other types by number, and those type numbers may be followed
44 by "=" and nested definitions.
46 This can make the "name" quite long.
47 When a name is more than 80 characters, we split the .stabs pseudo-op
48 into two .stabs pseudo-ops, both sharing the same "code" and "value".
49 The first one is marked as continued with a double-backslash at the
52 The kind-of-symbol letter distinguished function names from global
53 variables from file-scope variables from parameters from auto
54 variables in memory from typedef names from register variables.
57 The "code" is mostly redundant with the kind-of-symbol letter
58 that goes in the "name", but not entirely: for symbols located
59 in static storage, the "code" says which segment the address is in,
60 which controls how it is relocated.
62 The "value" for a symbol in static storage
63 is the core address of the symbol (actually, the assembler
64 label for the symbol). For a symbol located in a stack slot
65 it is the stack offset; for one in a register, the register number.
66 For a typedef symbol, it is zero.
68 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
69 output while in the text section.
71 For more on data type definitions, see `dbxout_type'. */
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
97 #define ASM_STABS_OP "\t.stabs\t"
101 #define ASM_STABN_OP "\t.stabn\t"
104 #ifndef DBX_TYPE_DECL_STABS_CODE
105 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
108 #ifndef DBX_STATIC_CONST_VAR_CODE
109 #define DBX_STATIC_CONST_VAR_CODE N_FUN
112 #ifndef DBX_REGPARM_STABS_CODE
113 #define DBX_REGPARM_STABS_CODE N_RSYM
116 #ifndef DBX_REGPARM_STABS_LETTER
117 #define DBX_REGPARM_STABS_LETTER 'P'
120 /* This is used for parameters passed by invisible reference in a register. */
121 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
122 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
125 #ifndef DBX_MEMPARM_STABS_LETTER
126 #define DBX_MEMPARM_STABS_LETTER 'p'
129 #ifndef FILE_NAME_JOINER
130 #define FILE_NAME_JOINER "/"
133 /* GDB needs to know that the stabs were generated by GCC. We emit an
134 N_OPT stab at the beginning of the source file to indicate this.
135 The string is historical, and different on a very few targets. */
136 #ifndef STABS_GCC_MARKER
137 #define STABS_GCC_MARKER "gcc2_compiled."
140 /* Typical USG systems don't have stab.h, and they also have
141 no use for DBX-format debugging info. */
143 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
145 /* Nonzero if we have actually used any of the GDB extensions
146 to the debugging format. The idea is that we use them for the
147 first time only if there's a strong reason, but once we have done that,
148 we use them whenever convenient. */
150 static int have_used_extensions = 0;
152 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
153 for the N_SO filename stabs label. */
155 #if defined (DBX_DEBUGGING_INFO) && !defined (DBX_OUTPUT_SOURCE_FILENAME)
156 static int source_label_number = 1;
159 #ifdef DEBUG_SYMS_TEXT
160 #define FORCE_TEXT text_section ();
167 #define STAB_CODE_TYPE enum __stab_debug_code
169 /* 1 if PARM is passed to this function in memory. */
171 #define PARM_PASSED_IN_MEMORY(PARM) \
172 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
174 /* A C expression for the integer offset value of an automatic variable
175 (N_LSYM) having address X (an RTX). */
176 #ifndef DEBUGGER_AUTO_OFFSET
177 #define DEBUGGER_AUTO_OFFSET(X) \
178 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
181 /* A C expression for the integer offset value of an argument (N_PSYM)
182 having address X (an RTX). The nominal offset is OFFSET. */
183 #ifndef DEBUGGER_ARG_OFFSET
184 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
187 /* Stream for writing to assembler file. */
189 static FILE *asmfile;
191 /* Last source file name mentioned in a NOTE insn. */
193 static const char *lastfile;
195 /* Current working directory. */
197 static const char *cwd;
199 enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
201 /* Structure recording information about a C data type.
202 The status element says whether we have yet output
203 the definition of the type. TYPE_XREF says we have
204 output it as a cross-reference only.
205 The file_number and type_number elements are used if DBX_USE_BINCL
210 enum typestatus status;
217 /* Vector recording information about C data types.
218 When we first notice a data type (a tree node),
219 we assign it a number using next_type_number.
220 That is its index in this vector. */
222 struct typeinfo *typevec;
224 /* Number of elements of space allocated in `typevec'. */
226 static int typevec_len;
228 /* In dbx output, each type gets a unique number.
229 This is the number for the next type output.
230 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
232 static int next_type_number;
236 /* When using N_BINCL in dbx output, each type number is actually a
237 pair of the file number and the type number within the file.
238 This is a stack of input files. */
242 struct dbx_file *next;
244 int next_type_number;
247 /* This is the top of the stack. */
249 static struct dbx_file *current_file;
251 /* This is the next file number to use. */
253 static int next_file_number;
255 #endif /* DBX_USE_BINCL */
257 /* These variables are for dbxout_symbol to communicate to
258 dbxout_finish_symbol.
259 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
260 current_sym_value and current_sym_addr are two ways to address the
261 value to store in the symtab entry.
262 current_sym_addr if nonzero represents the value as an rtx.
263 If that is zero, current_sym_value is used. This is used
264 when the value is an offset (such as for auto variables,
265 register variables and parms). */
267 static STAB_CODE_TYPE current_sym_code;
268 static int current_sym_value;
269 static rtx current_sym_addr;
271 /* Number of chars of symbol-description generated so far for the
272 current symbol. Used by CHARS and CONTIN. */
274 static int current_sym_nchars;
276 /* Report having output N chars of the current symbol-description. */
278 #define CHARS(N) (current_sym_nchars += (N))
280 /* Break the current symbol-description, generating a continuation,
281 if it has become long. */
283 #ifndef DBX_CONTIN_LENGTH
284 #define DBX_CONTIN_LENGTH 80
287 #if DBX_CONTIN_LENGTH > 0
289 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
291 #define CONTIN do { } while (0)
294 static void dbxout_init PARAMS ((const char *));
295 static void dbxout_finish PARAMS ((const char *));
296 static void dbxout_start_source_file PARAMS ((unsigned, const char *));
297 static void dbxout_end_source_file PARAMS ((unsigned));
298 static void dbxout_typedefs PARAMS ((tree));
299 static void dbxout_type_index PARAMS ((tree));
300 #if DBX_CONTIN_LENGTH > 0
301 static void dbxout_continue PARAMS ((void));
303 static void dbxout_args PARAMS ((tree));
304 static void dbxout_type_fields PARAMS ((tree));
305 static void dbxout_type_method_1 PARAMS ((tree, const char *));
306 static void dbxout_type_methods PARAMS ((tree));
307 static void dbxout_range_type PARAMS ((tree));
308 static void dbxout_type PARAMS ((tree, int));
309 static void print_int_cst_octal PARAMS ((tree));
310 static void print_octal PARAMS ((unsigned HOST_WIDE_INT, int));
311 static void print_wide_int PARAMS ((HOST_WIDE_INT));
312 static void dbxout_type_name PARAMS ((tree));
313 static int dbxout_symbol_location PARAMS ((tree, tree, const char *, rtx));
314 static void dbxout_symbol_name PARAMS ((tree, const char *, int));
315 static void dbxout_prepare_symbol PARAMS ((tree));
316 static void dbxout_finish_symbol PARAMS ((tree));
317 static void dbxout_block PARAMS ((tree, int, tree));
318 static void dbxout_global_decl PARAMS ((tree));
320 /* The debug hooks structure. */
321 #if defined (DBX_DEBUGGING_INFO)
323 static void dbxout_source_line PARAMS ((unsigned int, const char *));
324 static void dbxout_source_file PARAMS ((FILE *, const char *));
325 static void dbxout_function_end PARAMS ((void));
326 static void dbxout_begin_function PARAMS ((tree));
327 static void dbxout_begin_block PARAMS ((unsigned, unsigned));
328 static void dbxout_end_block PARAMS ((unsigned, unsigned));
329 static void dbxout_function_decl PARAMS ((tree));
331 struct gcc_debug_hooks dbx_debug_hooks =
335 debug_nothing_int_charstar,
336 debug_nothing_int_charstar,
337 dbxout_start_source_file,
338 dbxout_end_source_file,
341 debug_true_tree, /* ignore_block */
342 dbxout_source_line, /* source_line */
343 dbxout_source_line, /* begin_prologue: just output line info */
344 debug_nothing_int, /* end_prologue */
345 debug_nothing_void, /* end_epilogue */
346 #ifdef DBX_FUNCTION_FIRST
347 dbxout_begin_function,
349 debug_nothing_tree, /* begin_function */
351 debug_nothing_int, /* end_function */
352 dbxout_function_decl,
353 dbxout_global_decl, /* global_decl */
354 debug_nothing_tree, /* deferred_inline_function */
355 debug_nothing_tree, /* outlining_inline_function */
356 debug_nothing_rtx /* label */
358 #endif /* DBX_DEBUGGING_INFO */
360 #if defined (XCOFF_DEBUGGING_INFO)
361 struct gcc_debug_hooks xcoff_debug_hooks =
365 debug_nothing_int_charstar,
366 debug_nothing_int_charstar,
367 dbxout_start_source_file,
368 dbxout_end_source_file,
369 xcoffout_begin_block,
371 debug_true_tree, /* ignore_block */
372 xcoffout_source_line,
373 xcoffout_begin_prologue, /* begin_prologue */
374 debug_nothing_int, /* end_prologue */
375 xcoffout_end_epilogue,
376 debug_nothing_tree, /* begin_function */
377 xcoffout_end_function,
378 debug_nothing_tree, /* function_decl */
379 dbxout_global_decl, /* global_decl */
380 debug_nothing_tree, /* deferred_inline_function */
381 debug_nothing_tree, /* outlining_inline_function */
382 debug_nothing_rtx /* label */
384 #endif /* XCOFF_DEBUGGING_INFO */
386 #if defined (DBX_DEBUGGING_INFO)
388 dbxout_function_end ()
390 static int scope_labelno = 0;
391 char lscope_label_name[100];
392 /* Convert Ltext into the appropriate format for local labels in case
393 the system doesn't insert underscores in front of user generated
395 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
396 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Lscope", scope_labelno);
399 /* By convention, GCC will mark the end of a function with an N_FUN
400 symbol and an empty string. */
401 #ifdef DBX_OUTPUT_NFUN
402 DBX_OUTPUT_NFUN (asmfile, lscope_label_name, current_function_decl);
404 fprintf (asmfile, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN);
405 assemble_name (asmfile, lscope_label_name);
407 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
408 fprintf (asmfile, "\n");
411 #endif /* DBX_DEBUGGING_INFO */
413 /* At the beginning of compilation, start writing the symbol table.
414 Initialize `typevec' and output the standard data types of C. */
417 dbxout_init (input_file_name)
418 const char *input_file_name;
420 char ltext_label_name[100];
421 tree syms = getdecls ();
423 asmfile = asm_out_file;
426 typevec = (struct typeinfo *) xcalloc (typevec_len, sizeof typevec[0]);
428 /* Convert Ltext into the appropriate format for local labels in case
429 the system doesn't insert underscores in front of user generated
431 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
433 /* Put the current working directory in an N_SO symbol. */
434 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
435 but GDB always does. */
436 if (use_gnu_debug_info_extensions)
439 if (!cwd && (cwd = getpwd ()) && (!*cwd || cwd[strlen (cwd) - 1] != '/'))
440 cwd = concat (cwd, FILE_NAME_JOINER, NULL);
443 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
444 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
445 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
446 fprintf (asmfile, "%s", ASM_STABS_OP);
447 output_quoted_string (asmfile, cwd);
448 fprintf (asmfile, ",%d,0,0,", N_SO);
449 assemble_name (asmfile, ltext_label_name);
450 fputc ('\n', asmfile);
451 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
455 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
456 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
457 would give us an N_SOL, and we want an N_SO. */
458 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
459 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
460 /* We include outputting `Ltext:' here,
461 because that gives you a way to override it. */
462 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
463 fprintf (asmfile, "%s", ASM_STABS_OP);
464 output_quoted_string (asmfile, input_file_name);
465 fprintf (asmfile, ",%d,0,0,", N_SO);
466 assemble_name (asmfile, ltext_label_name);
467 fputc ('\n', asmfile);
469 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Ltext", 0);
470 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
472 #ifdef DBX_OUTPUT_GCC_MARKER
473 DBX_OUTPUT_GCC_MARKER (asmfile);
475 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
476 fprintf (asmfile, "%s\"%s\",%d,0,0,0\n",
477 ASM_STABS_OP, STABS_GCC_MARKER, N_OPT);
480 lastfile = input_file_name;
482 next_type_number = 1;
485 current_file = (struct dbx_file *) xmalloc (sizeof *current_file);
486 current_file->next = NULL;
487 current_file->file_number = 0;
488 current_file->next_type_number = 1;
489 next_file_number = 1;
492 /* Make sure that types `int' and `char' have numbers 1 and 2.
493 Definitions of other integer types will refer to those numbers.
494 (Actually it should no longer matter what their numbers are.
495 Also, if any types with tags have been defined, dbxout_symbol
496 will output them first, so the numbers won't be 1 and 2. That
497 happens in C++. So it's a good thing it should no longer matter). */
499 #ifdef DBX_OUTPUT_STANDARD_TYPES
500 DBX_OUTPUT_STANDARD_TYPES (syms);
502 dbxout_symbol (TYPE_NAME (integer_type_node), 0);
503 dbxout_symbol (TYPE_NAME (char_type_node), 0);
506 /* Get all permanent types that have typedef names,
507 and output them all, except for those already output. */
509 dbxout_typedefs (syms);
512 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
513 in the reverse order from that which is found in SYMS. */
516 dbxout_typedefs (syms)
521 dbxout_typedefs (TREE_CHAIN (syms));
522 if (TREE_CODE (syms) == TYPE_DECL)
524 tree type = TREE_TYPE (syms);
526 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
527 && COMPLETE_TYPE_P (type)
528 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
529 dbxout_symbol (TYPE_NAME (type), 0);
534 /* Change to reading from a new source file. Generate a N_BINCL stab. */
537 dbxout_start_source_file (line, filename)
538 unsigned int line ATTRIBUTE_UNUSED;
539 const char *filename ATTRIBUTE_UNUSED;
542 struct dbx_file *n = (struct dbx_file *) xmalloc (sizeof *n);
544 n->next = current_file;
545 n->file_number = next_file_number++;
546 n->next_type_number = 1;
548 fprintf (asmfile, "%s", ASM_STABS_OP);
549 output_quoted_string (asmfile, filename);
550 fprintf (asmfile, ",%d,0,0,0\n", N_BINCL);
554 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
557 dbxout_end_source_file (line)
558 unsigned int line ATTRIBUTE_UNUSED;
561 struct dbx_file *next;
563 fprintf (asmfile, "%s%d,0,0,0\n", ASM_STABN_OP, N_EINCL);
564 next = current_file->next;
570 #if defined (DBX_DEBUGGING_INFO)
571 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
574 dbxout_source_file (file, filename)
576 const char *filename;
578 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
580 #ifdef DBX_OUTPUT_SOURCE_FILENAME
581 DBX_OUTPUT_SOURCE_FILENAME (file, filename);
583 char ltext_label_name[100];
585 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
586 source_label_number);
587 fprintf (file, "%s", ASM_STABS_OP);
588 output_quoted_string (file, filename);
589 fprintf (asmfile, ",%d,0,0,", N_SOL);
590 assemble_name (asmfile, ltext_label_name);
591 fputc ('\n', asmfile);
592 if (current_function_decl != NULL_TREE
593 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
594 ; /* Don't change section amid function. */
597 ASM_OUTPUT_INTERNAL_LABEL (file, "Ltext", source_label_number);
598 source_label_number++;
604 /* Output a line number symbol entry for source file FILENAME and line
608 dbxout_source_line (lineno, filename)
610 const char *filename;
612 dbxout_source_file (asmfile, filename);
614 #ifdef ASM_OUTPUT_SOURCE_LINE
615 ASM_OUTPUT_SOURCE_LINE (asmfile, lineno);
617 fprintf (asmfile, "%s%d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
621 /* Describe the beginning of an internal block within a function. */
624 dbxout_begin_block (line, n)
625 unsigned int line ATTRIBUTE_UNUSED;
628 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "LBB", n);
631 /* Describe the end line-number of an internal block within a function. */
634 dbxout_end_block (line, n)
635 unsigned int line ATTRIBUTE_UNUSED;
638 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "LBE", n);
641 /* Output dbx data for a function definition.
642 This includes a definition of the function name itself (a symbol),
643 definitions of the parameters (locating them in the parameter list)
644 and then output the block that makes up the function's body
645 (including all the auto variables of the function). */
648 dbxout_function_decl (decl)
651 #ifndef DBX_FUNCTION_FIRST
652 dbxout_begin_function (decl);
654 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
655 #ifdef DBX_OUTPUT_FUNCTION_END
656 DBX_OUTPUT_FUNCTION_END (asmfile, decl);
658 if (use_gnu_debug_info_extensions
659 #if defined(NO_DBX_FUNCTION_END)
660 && ! NO_DBX_FUNCTION_END
662 && targetm.have_named_sections)
663 dbxout_function_end ();
666 #endif /* DBX_DEBUGGING_INFO */
668 /* Debug information for a global DECL. Called from toplev.c after
669 compilation proper has finished. */
671 dbxout_global_decl (decl)
674 if (TREE_CODE (decl) == VAR_DECL
675 && ! DECL_EXTERNAL (decl)
676 && DECL_RTL_SET_P (decl)) /* Not necessary? */
677 dbxout_symbol (decl, 0);
680 /* At the end of compilation, finish writing the symbol table.
681 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
685 dbxout_finish (filename)
686 const char *filename ATTRIBUTE_UNUSED;
688 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
689 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile, filename);
690 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
693 /* Output the index of a type. */
696 dbxout_type_index (type)
699 #ifndef DBX_USE_BINCL
700 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
703 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
704 fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number);
709 #if DBX_CONTIN_LENGTH > 0
710 /* Continue a symbol-description that gets too big.
711 End one symbol table entry with a double-backslash
712 and start a new one, eventually producing something like
713 .stabs "start......\\",code,0,value
714 .stabs "...rest",code,0,value */
719 #ifdef DBX_CONTIN_CHAR
720 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
722 fprintf (asmfile, "\\\\");
724 dbxout_finish_symbol (NULL_TREE);
725 fprintf (asmfile, "%s\"", ASM_STABS_OP);
726 current_sym_nchars = 0;
728 #endif /* DBX_CONTIN_LENGTH > 0 */
730 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
731 This must be a separate function because anonymous unions require
735 dbxout_type_fields (type)
740 /* Output the name, type, position (in bits), size (in bits) of each
741 field that we can support. */
742 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
744 /* Omit here local type decls until we know how to support them. */
745 if (TREE_CODE (tem) == TYPE_DECL
746 /* Omit fields whose position or size are variable or too large to
748 || (TREE_CODE (tem) == FIELD_DECL
749 && (! host_integerp (bit_position (tem), 0)
751 || ! host_integerp (DECL_SIZE (tem), 1)))
752 /* Omit here the nameless fields that are used to skip bits. */
753 || DECL_IGNORED_P (tem))
756 else if (TREE_CODE (tem) != CONST_DECL)
758 /* Continue the line if necessary,
759 but not before the first field. */
760 if (tem != TYPE_FIELDS (type))
765 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
766 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
770 fprintf (asmfile, ":");
774 if (use_gnu_debug_info_extensions
775 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
776 || TREE_CODE (tem) != FIELD_DECL))
778 have_used_extensions = 1;
780 putc ((TREE_PRIVATE (tem) ? '0'
781 : TREE_PROTECTED (tem) ? '1' : '2'),
786 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
787 && DECL_BIT_FIELD_TYPE (tem))
788 ? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0);
790 if (TREE_CODE (tem) == VAR_DECL)
792 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
794 tree name = DECL_ASSEMBLER_NAME (tem);
796 have_used_extensions = 1;
797 fprintf (asmfile, ":%s;", IDENTIFIER_POINTER (name));
798 CHARS (IDENTIFIER_LENGTH (name) + 2);
802 /* If TEM is non-static, GDB won't understand it. */
803 fprintf (asmfile, ",0,0;");
810 print_wide_int (int_bit_position (tem));
812 print_wide_int (tree_low_cst (DECL_SIZE (tem), 1));
820 /* Subroutine of `dbxout_type_methods'. Output debug info about the
821 method described DECL. DEBUG_NAME is an encoding of the method's
822 type signature. ??? We may be able to do without DEBUG_NAME altogether
826 dbxout_type_method_1 (decl, debug_name)
828 const char *debug_name;
832 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
834 else /* it's a METHOD_TYPE. */
836 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
837 /* A for normal functions.
838 B for `const' member functions.
839 C for `volatile' member functions.
840 D for `const volatile' member functions. */
841 if (TYPE_READONLY (TREE_TYPE (firstarg)))
843 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
846 if (DECL_VINDEX (decl))
852 fprintf (asmfile, ":%s;%c%c%c", debug_name,
853 TREE_PRIVATE (decl) ? '0'
854 : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
855 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
856 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
858 if (DECL_VINDEX (decl) && host_integerp (DECL_VINDEX (decl), 0))
860 print_wide_int (tree_low_cst (DECL_VINDEX (decl), 0));
863 dbxout_type (DECL_CONTEXT (decl), 0);
864 fprintf (asmfile, ";");
869 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
873 dbxout_type_methods (type)
876 /* C++: put out the method names and their parameter lists */
877 tree methods = TYPE_METHODS (type);
881 char formatted_type_identifier_length[16];
882 int type_identifier_length;
884 if (methods == NULL_TREE)
887 type_encoding = DECL_NAME (TYPE_NAME (type));
890 /* C++: Template classes break some assumptions made by this code about
891 the class names, constructor names, and encodings for assembler
892 label names. For now, disable output of dbx info for them. */
894 const char *ptr = IDENTIFIER_POINTER (type_encoding);
895 /* This should use index. (mrs) */
896 while (*ptr && *ptr != '<') ptr++;
907 type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
909 sprintf (formatted_type_identifier_length, "%d", type_identifier_length);
911 if (TREE_CODE (methods) != TREE_VEC)
913 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
914 fndecl = TREE_VEC_ELT (methods, 0);
916 fndecl = TREE_VEC_ELT (methods, 1);
922 /* Group together all the methods for the same operation.
923 These differ in the types of the arguments. */
924 for (last = NULL_TREE;
925 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
926 fndecl = TREE_CHAIN (fndecl))
927 /* Output the name of the field (after overloading), as
928 well as the name of the field before overloading, along
929 with its parameter list */
931 /* This is the "mangled" name of the method.
932 It encodes the argument types. */
933 const char *debug_name;
935 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
936 include TEMPLATE_DECLs.) The debugger doesn't know what
937 to do with such entities anyhow. */
938 if (TREE_CODE (fndecl) != FUNCTION_DECL)
941 debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
947 /* Also ignore abstract methods; those are only interesting to
948 the DWARF backends. */
949 if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT (fndecl))
952 /* Redundantly output the plain name, since that's what gdb
956 tree name = DECL_NAME (fndecl);
957 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
958 CHARS (IDENTIFIER_LENGTH (name) + 2);
962 dbxout_type (TREE_TYPE (fndecl), 0);
964 dbxout_type_method_1 (fndecl, debug_name);
974 /* Emit a "range" type specification, which has the form:
975 "r<index type>;<lower bound>;<upper bound>;".
976 TYPE is an INTEGER_TYPE. */
979 dbxout_range_type (type)
982 fprintf (asmfile, "r");
983 if (TREE_TYPE (type))
984 dbxout_type (TREE_TYPE (type), 0);
985 else if (TREE_CODE (type) != INTEGER_TYPE)
986 dbxout_type (type, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
989 /* Traditionally, we made sure 'int' was type 1, and builtin types
990 were defined to be sub-ranges of int. Unfortunately, this
991 does not allow us to distinguish true sub-ranges from integer
992 types. So, instead we define integer (non-sub-range) types as
993 sub-ranges of themselves. This matters for Chill. If this isn't
994 a subrange type, then we want to define it in terms of itself.
995 However, in C, this may be an anonymous integer type, and we don't
996 want to emit debug info referring to it. Just calling
997 dbxout_type_index won't work anyways, because the type hasn't been
998 defined yet. We make this work for both cases by checked to see
999 whether this is a defined type, referring to it if it is, and using
1001 if (TYPE_SYMTAB_ADDRESS (type) != 0)
1002 dbxout_type_index (type);
1004 dbxout_type_index (integer_type_node);
1007 if (TYPE_MIN_VALUE (type) != 0
1008 && host_integerp (TYPE_MIN_VALUE (type), 0))
1010 putc (';', asmfile);
1012 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type), 0));
1016 fprintf (asmfile, ";0");
1020 if (TYPE_MAX_VALUE (type) != 0
1021 && host_integerp (TYPE_MAX_VALUE (type), 0))
1023 putc (';', asmfile);
1025 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type), 0));
1026 putc (';', asmfile);
1031 fprintf (asmfile, ";-1;");
1036 /* Output a reference to a type. If the type has not yet been
1037 described in the dbx output, output its definition now.
1038 For a type already defined, just refer to its definition
1039 using the type number.
1041 If FULL is nonzero, and the type has been described only with
1042 a forward-reference, output the definition now.
1043 If FULL is zero in this case, just refer to the forward-reference
1044 using the number previously allocated. */
1047 dbxout_type (type, full)
1053 static int anonymous_type_number = 0;
1055 if (TREE_CODE (type) == VECTOR_TYPE)
1056 type = TYPE_DEBUG_REPRESENTATION_TYPE (type);
1058 /* If there was an input error and we don't really have a type,
1059 avoid crashing and write something that is at least valid
1060 by assuming `int'. */
1061 if (type == error_mark_node)
1062 type = integer_type_node;
1065 if (TYPE_NAME (type)
1066 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1067 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1071 /* Try to find the "main variant" with the same name. */
1072 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1073 && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1074 main_variant = TREE_TYPE (TYPE_NAME (type));
1076 main_variant = TYPE_MAIN_VARIANT (type);
1078 /* If we are not using extensions, stabs does not distinguish const and
1079 volatile, so there is no need to make them separate types. */
1080 if (!use_gnu_debug_info_extensions)
1081 type = main_variant;
1083 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1085 /* Type has no dbx number assigned. Assign next available number. */
1086 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1088 /* Make sure type vector is long enough to record about this type. */
1090 if (next_type_number == typevec_len)
1093 = (struct typeinfo *) xrealloc (typevec,
1094 typevec_len * 2 * sizeof typevec[0]);
1095 memset ((char *) (typevec + typevec_len), 0,
1096 typevec_len * sizeof typevec[0]);
1100 #ifdef DBX_USE_BINCL
1101 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1102 = current_file->file_number;
1103 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1104 = current_file->next_type_number++;
1108 /* Output the number of this type, to refer to it. */
1109 dbxout_type_index (type);
1111 #ifdef DBX_TYPE_DEFINED
1112 if (DBX_TYPE_DEFINED (type))
1116 /* If this type's definition has been output or is now being output,
1119 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1124 /* If we have already had a cross reference,
1125 and either that's all we want or that's the best we could do,
1126 don't repeat the cross reference.
1127 Sun dbx crashes if we do. */
1128 if (! full || !COMPLETE_TYPE_P (type)
1129 /* No way in DBX fmt to describe a variable size. */
1130 || ! host_integerp (TYPE_SIZE (type), 1))
1138 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1139 leave the type-number completely undefined rather than output
1140 a cross-reference. If we have already used GNU debug info extensions,
1141 then it is OK to output a cross reference. This is necessary to get
1142 proper C++ debug output. */
1143 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1144 || TREE_CODE (type) == QUAL_UNION_TYPE
1145 || TREE_CODE (type) == ENUMERAL_TYPE)
1146 && ! use_gnu_debug_info_extensions)
1147 /* We must use the same test here as we use twice below when deciding
1148 whether to emit a cross-reference. */
1149 if ((TYPE_NAME (type) != 0
1150 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1151 && DECL_IGNORED_P (TYPE_NAME (type)))
1153 || !COMPLETE_TYPE_P (type)
1154 /* No way in DBX fmt to describe a variable size. */
1155 || ! host_integerp (TYPE_SIZE (type), 1))
1157 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1162 /* Output a definition now. */
1164 fprintf (asmfile, "=");
1167 /* Mark it as defined, so that if it is self-referent
1168 we will not get into an infinite recursion of definitions. */
1170 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1172 /* If this type is a variant of some other, hand off. Types with
1173 different names are usefully distinguished. We only distinguish
1174 cv-qualified types if we're using extensions. */
1175 if (TYPE_READONLY (type) > TYPE_READONLY (main_variant))
1177 putc ('k', asmfile);
1179 dbxout_type (build_type_variant (type, 0, TYPE_VOLATILE (type)), 0);
1182 else if (TYPE_VOLATILE (type) > TYPE_VOLATILE (main_variant))
1184 putc ('B', asmfile);
1186 dbxout_type (build_type_variant (type, TYPE_READONLY (type), 0), 0);
1189 else if (main_variant != TYPE_MAIN_VARIANT (type))
1191 /* 'type' is a typedef; output the type it refers to. */
1192 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0);
1195 /* else continue. */
1197 switch (TREE_CODE (type))
1201 /* For a void type, just define it as itself; ie, "5=5".
1202 This makes us consider it defined
1203 without saying what it is. The debugger will make it
1204 a void type when the reference is seen, and nothing will
1205 ever override that default. */
1206 dbxout_type_index (type);
1210 if (type == char_type_node && ! TREE_UNSIGNED (type))
1212 /* Output the type `char' as a subrange of itself!
1213 I don't understand this definition, just copied it
1214 from the output of pcc.
1215 This used to use `r2' explicitly and we used to
1216 take care to make sure that `char' was type number 2. */
1217 fprintf (asmfile, "r");
1219 dbxout_type_index (type);
1220 fprintf (asmfile, ";0;127;");
1224 /* If this is a subtype of another integer type, always prefer to
1225 write it as a subtype. */
1226 else if (TREE_TYPE (type) != 0
1227 && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
1229 /* If the size is non-standard, say what it is if we can use
1232 if (use_gnu_debug_info_extensions
1233 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1235 have_used_extensions = 1;
1236 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1240 dbxout_range_type (type);
1245 /* If the size is non-standard, say what it is if we can use
1248 if (use_gnu_debug_info_extensions
1249 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1251 have_used_extensions = 1;
1252 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1256 /* If we can use GDB extensions and the size is wider than a
1257 long (the size used by GDB to read them) or we may have
1258 trouble writing the bounds the usual way, write them in
1259 octal. Note the test is for the *target's* size of "long",
1260 not that of the host. The host test is just to make sure we
1261 can write it out in case the host wide int is narrower than the
1264 /* For unsigned types, we use octal if they are the same size or
1265 larger. This is because we print the bounds as signed decimal,
1266 and hence they can't span same size unsigned types. */
1268 if (use_gnu_debug_info_extensions
1269 && TYPE_MIN_VALUE (type) != 0
1270 && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
1271 && TYPE_MAX_VALUE (type) != 0
1272 && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
1273 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1274 || ((TYPE_PRECISION (type)
1275 == TYPE_PRECISION (integer_type_node))
1276 && TREE_UNSIGNED (type))
1277 || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT
1278 || (TYPE_PRECISION (type) == HOST_BITS_PER_WIDE_INT
1279 && TREE_UNSIGNED (type))))
1281 fprintf (asmfile, "r");
1283 dbxout_type_index (type);
1284 fprintf (asmfile, ";");
1286 print_int_cst_octal (TYPE_MIN_VALUE (type));
1287 fprintf (asmfile, ";");
1289 print_int_cst_octal (TYPE_MAX_VALUE (type));
1290 fprintf (asmfile, ";");
1295 /* Output other integer types as subranges of `int'. */
1296 dbxout_range_type (type);
1302 /* This used to say `r1' and we used to take care
1303 to make sure that `int' was type number 1. */
1304 fprintf (asmfile, "r");
1306 dbxout_type_index (integer_type_node);
1307 putc (';', asmfile);
1309 print_wide_int (int_size_in_bytes (type));
1310 fputs (";0;", asmfile);
1315 if (use_gnu_debug_info_extensions)
1317 have_used_extensions = 1;
1318 fputs ("@s", asmfile);
1320 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1321 fputs (";-20;", asmfile);
1326 /* Output the type `char' as a subrange of itself.
1327 That is what pcc seems to do. */
1328 fprintf (asmfile, "r");
1330 dbxout_type_index (char_type_node);
1331 fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1337 if (use_gnu_debug_info_extensions)
1339 have_used_extensions = 1;
1340 fputs ("@s", asmfile);
1342 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1343 fputs (";-16;", asmfile);
1346 else /* Define as enumeral type (False, True) */
1348 fprintf (asmfile, "eFalse:0,True:1,;");
1354 putc ('d', asmfile);
1356 dbxout_type (TREE_TYPE (type), 0);
1360 /* Differs from the REAL_TYPE by its new data type number */
1362 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1364 fprintf (asmfile, "r");
1366 dbxout_type_index (type);
1367 putc (';', asmfile);
1369 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type)));
1370 fputs (";0;", asmfile);
1375 /* Output a complex integer type as a structure,
1376 pending some other way to do it. */
1377 putc ('s', asmfile);
1379 print_wide_int (int_size_in_bytes (type));
1380 fprintf (asmfile, "real:");
1383 dbxout_type (TREE_TYPE (type), 0);
1384 fprintf (asmfile, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type)));
1386 fprintf (asmfile, "imag:");
1388 dbxout_type (TREE_TYPE (type), 0);
1389 fprintf (asmfile, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type)),
1390 TYPE_PRECISION (TREE_TYPE (type)));
1396 if (use_gnu_debug_info_extensions)
1398 have_used_extensions = 1;
1399 fputs ("@s", asmfile);
1401 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1402 putc (';', asmfile);
1405 /* Check if a bitstring type, which in Chill is
1406 different from a [power]set. */
1407 if (TYPE_STRING_FLAG (type))
1409 fprintf (asmfile, "@S;");
1413 putc ('S', asmfile);
1415 dbxout_type (TYPE_DOMAIN (type), 0);
1419 /* Make arrays of packed bits look like bitstrings for chill. */
1420 if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
1422 have_used_extensions = 1;
1423 fputs ("@s", asmfile);
1425 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1426 fprintf (asmfile, ";@S;S");
1428 dbxout_type (TYPE_DOMAIN (type), 0);
1432 /* Output "a" followed by a range type definition
1433 for the index type of the array
1434 followed by a reference to the target-type.
1435 ar1;0;N;M for a C array of type M and size N+1. */
1436 /* Check if a character string type, which in Chill is
1437 different from an array of characters. */
1438 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1440 have_used_extensions = 1;
1441 fprintf (asmfile, "@S;");
1444 tem = TYPE_DOMAIN (type);
1447 fprintf (asmfile, "ar");
1449 dbxout_type_index (integer_type_node);
1450 fprintf (asmfile, ";0;-1;");
1455 fprintf (asmfile, "a");
1457 dbxout_range_type (tem);
1460 dbxout_type (TREE_TYPE (type), 0);
1465 case QUAL_UNION_TYPE:
1467 int i, n_baseclasses = 0;
1469 if (TYPE_BINFO (type) != 0
1470 && TREE_CODE (TYPE_BINFO (type)) == TREE_VEC
1471 && TYPE_BINFO_BASETYPES (type) != 0)
1472 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1474 /* Output a structure type. We must use the same test here as we
1475 use in the DBX_NO_XREFS case above. */
1476 if ((TYPE_NAME (type) != 0
1477 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1478 && DECL_IGNORED_P (TYPE_NAME (type)))
1480 || !COMPLETE_TYPE_P (type)
1481 /* No way in DBX fmt to describe a variable size. */
1482 || ! host_integerp (TYPE_SIZE (type), 1))
1484 /* If the type is just a cross reference, output one
1485 and mark the type as partially described.
1486 If it later becomes defined, we will output
1487 its real definition.
1488 If the type has a name, don't nest its definition within
1489 another type's definition; instead, output an xref
1490 and let the definition come when the name is defined. */
1491 fputs ((TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu", asmfile);
1493 #if 0 /* This assertion is legitimately false in C++. */
1494 /* We shouldn't be outputting a reference to a type before its
1495 definition unless the type has a tag name.
1496 A typedef name without a tag name should be impossible. */
1497 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1500 if (TYPE_NAME (type) != 0)
1501 dbxout_type_name (type);
1504 fprintf (asmfile, "$$%d", anonymous_type_number++);
1508 fprintf (asmfile, ":");
1510 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1514 /* Identify record or union, and print its size. */
1515 putc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asmfile);
1517 print_wide_int (int_size_in_bytes (type));
1519 if (use_gnu_debug_info_extensions)
1523 have_used_extensions = 1;
1524 fprintf (asmfile, "!%d,", n_baseclasses);
1528 for (i = 0; i < n_baseclasses; i++)
1530 tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i);
1532 if (use_gnu_debug_info_extensions)
1534 have_used_extensions = 1;
1535 putc (TREE_VIA_VIRTUAL (child) ? '1' : '0', asmfile);
1536 putc (TREE_VIA_PUBLIC (child) ? '2' : '0', asmfile);
1538 if (TREE_VIA_VIRTUAL (child) && strcmp (lang_hooks.name, "GNU C++") == 0)
1539 /* For a virtual base, print the (negative) offset within
1540 the vtable where we must look to find the necessary
1542 print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child), 0)
1545 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1547 putc (',', asmfile);
1549 dbxout_type (BINFO_TYPE (child), 0);
1550 putc (';', asmfile);
1555 /* Print out the base class information with fields
1556 which have the same names at the types they hold. */
1557 dbxout_type_name (BINFO_TYPE (child));
1558 putc (':', asmfile);
1560 dbxout_type (BINFO_TYPE (child), full);
1561 putc (',', asmfile);
1563 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1565 putc (',', asmfile);
1567 print_wide_int (tree_low_cst (DECL_SIZE
1569 (BINFO_TYPE (child))),
1572 putc (';', asmfile);
1578 /* Write out the field declarations. */
1579 dbxout_type_fields (type);
1580 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1582 have_used_extensions = 1;
1583 dbxout_type_methods (type);
1586 putc (';', asmfile);
1589 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1590 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1591 && TYPE_VFIELD (type))
1593 have_used_extensions = 1;
1595 /* Tell GDB+ that it may keep reading. */
1596 putc ('~', asmfile);
1599 /* We need to write out info about what field this class
1600 uses as its "main" vtable pointer field, because if this
1601 field is inherited from a base class, GDB cannot necessarily
1602 figure out which field it's using in time. */
1603 if (TYPE_VFIELD (type))
1605 putc ('%', asmfile);
1607 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0);
1610 putc (';', asmfile);
1616 /* We must use the same test here as we use in the DBX_NO_XREFS case
1617 above. We simplify it a bit since an enum will never have a variable
1619 if ((TYPE_NAME (type) != 0
1620 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1621 && DECL_IGNORED_P (TYPE_NAME (type)))
1623 || !COMPLETE_TYPE_P (type))
1625 fprintf (asmfile, "xe");
1627 dbxout_type_name (type);
1628 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1629 putc (':', asmfile);
1633 #ifdef DBX_OUTPUT_ENUM
1634 DBX_OUTPUT_ENUM (asmfile, type);
1636 if (use_gnu_debug_info_extensions
1637 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1639 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1643 putc ('e', asmfile);
1645 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1647 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1648 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem)) + 1);
1649 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1650 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1651 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1652 && (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1653 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1655 print_int_cst_octal (TREE_VALUE (tem));
1657 putc (',', asmfile);
1659 if (TREE_CHAIN (tem) != 0)
1663 putc (';', asmfile);
1669 putc ('*', asmfile);
1671 dbxout_type (TREE_TYPE (type), 0);
1675 if (use_gnu_debug_info_extensions)
1677 have_used_extensions = 1;
1678 putc ('#', asmfile);
1681 /* Write the argument types out longhand. */
1682 dbxout_type (TYPE_METHOD_BASETYPE (type), 0);
1683 putc (',', asmfile);
1685 dbxout_type (TREE_TYPE (type), 0);
1686 dbxout_args (TYPE_ARG_TYPES (type));
1687 putc (';', asmfile);
1691 /* Treat it as a function type. */
1692 dbxout_type (TREE_TYPE (type), 0);
1696 if (use_gnu_debug_info_extensions)
1698 have_used_extensions = 1;
1699 putc ('@', asmfile);
1701 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0);
1702 putc (',', asmfile);
1704 dbxout_type (TREE_TYPE (type), 0);
1707 /* Should print as an int, because it is really just an offset. */
1708 dbxout_type (integer_type_node, 0);
1711 case REFERENCE_TYPE:
1712 if (use_gnu_debug_info_extensions)
1713 have_used_extensions = 1;
1714 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1716 dbxout_type (TREE_TYPE (type), 0);
1720 putc ('f', asmfile);
1722 dbxout_type (TREE_TYPE (type), 0);
1730 /* Print the value of integer constant C, in octal,
1731 handling double precision. */
1734 print_int_cst_octal (c)
1737 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1738 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1739 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1740 unsigned int width = TYPE_PRECISION (TREE_TYPE (c));
1742 /* GDB wants constants with no extra leading "1" bits, so
1743 we need to remove any sign-extension that might be
1745 if (width == HOST_BITS_PER_WIDE_INT * 2)
1747 else if (width > HOST_BITS_PER_WIDE_INT)
1748 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1749 else if (width == HOST_BITS_PER_WIDE_INT)
1752 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1754 fprintf (asmfile, "0");
1759 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1760 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1764 unsigned HOST_WIDE_INT beg = high >> excess;
1765 unsigned HOST_WIDE_INT middle
1766 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1767 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1768 unsigned HOST_WIDE_INT end
1769 = low & (((unsigned HOST_WIDE_INT) 1
1770 << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1773 fprintf (asmfile, "%o%01o", (int) beg, (int) middle);
1775 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1780 print_octal (value, digits)
1781 unsigned HOST_WIDE_INT value;
1786 for (i = digits - 1; i >= 0; i--)
1787 fprintf (asmfile, "%01o", (int) ((value >> (3 * i)) & 7));
1792 /* Output C in decimal while adjusting the number of digits written. */
1800 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, c);
1811 /* Output the name of type TYPE, with no punctuation.
1812 Such names can be set up either by typedef declarations
1813 or by struct, enum and union tags. */
1816 dbxout_type_name (type)
1820 if (TYPE_NAME (type) == 0)
1822 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
1824 t = TYPE_NAME (type);
1826 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1828 t = DECL_NAME (TYPE_NAME (type));
1833 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
1834 CHARS (IDENTIFIER_LENGTH (t));
1837 /* Output a .stabs for the symbol defined by DECL,
1838 which must be a ..._DECL node in the normal namespace.
1839 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1840 LOCAL is nonzero if the scope is less than the entire file.
1841 Return 1 if a stabs might have been emitted. */
1844 dbxout_symbol (decl, local)
1846 int local ATTRIBUTE_UNUSED;
1848 tree type = TREE_TYPE (decl);
1849 tree context = NULL_TREE;
1852 /* Cast avoids warning in old compilers. */
1853 current_sym_code = (STAB_CODE_TYPE) 0;
1854 current_sym_value = 0;
1855 current_sym_addr = 0;
1857 /* Ignore nameless syms, but don't ignore type tags. */
1859 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
1860 || DECL_IGNORED_P (decl))
1863 dbxout_prepare_symbol (decl);
1865 /* The output will always start with the symbol name,
1866 so always count that in the length-output-so-far. */
1868 if (DECL_NAME (decl) != 0)
1869 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
1871 switch (TREE_CODE (decl))
1874 /* Enum values are defined by defining the enum type. */
1878 if (DECL_RTL (decl) == 0)
1880 if (DECL_EXTERNAL (decl))
1882 /* Don't mention a nested function under its parent. */
1883 context = decl_function_context (decl);
1884 if (context == current_function_decl)
1886 if (GET_CODE (DECL_RTL (decl)) != MEM
1887 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
1891 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
1892 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1893 TREE_PUBLIC (decl) ? 'F' : 'f');
1896 current_sym_code = N_FUN;
1897 current_sym_addr = XEXP (DECL_RTL (decl), 0);
1899 if (TREE_TYPE (type))
1900 dbxout_type (TREE_TYPE (type), 0);
1902 dbxout_type (void_type_node, 0);
1904 /* For a nested function, when that function is compiled,
1905 mention the containing function name
1906 as well as (since dbx wants it) our own assembler-name. */
1908 fprintf (asmfile, ",%s,%s",
1909 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1910 IDENTIFIER_POINTER (DECL_NAME (context)));
1912 dbxout_finish_symbol (decl);
1917 /* This seems all wrong. Outputting most kinds of types gives no name
1918 at all. A true definition gives no name; a cross-ref for a
1919 structure can give the tag name, but not a type name.
1920 It seems that no typedef name is defined by outputting a type. */
1922 /* If this typedef name was defined by outputting the type,
1923 don't duplicate it. */
1924 if (typevec[TYPE_SYMTAB_ADDRESS (type)].status == TYPE_DEFINED
1925 && TYPE_NAME (TREE_TYPE (decl)) == decl)
1928 /* Don't output the same typedef twice.
1929 And don't output what language-specific stuff doesn't want output. */
1930 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
1939 if (DECL_NAME (decl))
1941 /* Nonzero means we must output a tag as well as a typedef. */
1944 /* Handle the case of a C++ structure or union
1945 where the TYPE_NAME is a TYPE_DECL
1946 which gives both a typedef name and a tag. */
1947 /* dbx requires the tag first and the typedef second. */
1948 if ((TREE_CODE (type) == RECORD_TYPE
1949 || TREE_CODE (type) == UNION_TYPE
1950 || TREE_CODE (type) == QUAL_UNION_TYPE)
1951 && TYPE_NAME (type) == decl
1952 && !(use_gnu_debug_info_extensions && have_used_extensions)
1953 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
1954 /* Distinguish the implicit typedefs of C++
1955 from explicit ones that might be found in C. */
1956 && DECL_ARTIFICIAL (decl)
1957 /* Do not generate a tag for records of variable size,
1958 since this type can not be properly described in the
1959 DBX format, and it confuses some tools such as objdump. */
1960 && host_integerp (TYPE_SIZE (type), 1))
1962 tree name = TYPE_NAME (type);
1963 if (TREE_CODE (name) == TYPE_DECL)
1964 name = DECL_NAME (name);
1966 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1967 current_sym_value = 0;
1968 current_sym_addr = 0;
1969 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1971 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
1972 IDENTIFIER_POINTER (name));
1973 dbxout_type (type, 1);
1974 dbxout_finish_symbol (NULL_TREE);
1977 /* Output typedef name. */
1978 fprintf (asmfile, "%s\"%s:", ASM_STABS_OP,
1979 IDENTIFIER_POINTER (DECL_NAME (decl)));
1981 /* Short cut way to output a tag also. */
1982 if ((TREE_CODE (type) == RECORD_TYPE
1983 || TREE_CODE (type) == UNION_TYPE
1984 || TREE_CODE (type) == QUAL_UNION_TYPE)
1985 && TYPE_NAME (type) == decl
1986 /* Distinguish the implicit typedefs of C++
1987 from explicit ones that might be found in C. */
1988 && DECL_ARTIFICIAL (decl))
1990 if (use_gnu_debug_info_extensions && have_used_extensions)
1992 putc ('T', asmfile);
1993 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
1995 #if 0 /* Now we generate the tag for this case up above. */
2001 putc ('t', asmfile);
2002 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2004 dbxout_type (type, 1);
2005 dbxout_finish_symbol (decl);
2009 /* Don't output a tag if this is an incomplete type. This prevents
2010 the sun4 Sun OS 4.x dbx from crashing. */
2012 if (tag_needed && TYPE_NAME (type) != 0
2013 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
2014 || (DECL_NAME (TYPE_NAME (type)) != 0))
2015 && COMPLETE_TYPE_P (type)
2016 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
2018 /* For a TYPE_DECL with no name, but the type has a name,
2020 This is what represents `struct foo' with no typedef. */
2021 /* In C++, the name of a type is the corresponding typedef.
2022 In C, it is an IDENTIFIER_NODE. */
2023 tree name = TYPE_NAME (type);
2024 if (TREE_CODE (name) == TYPE_DECL)
2025 name = DECL_NAME (name);
2027 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2028 current_sym_value = 0;
2029 current_sym_addr = 0;
2030 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2032 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
2033 IDENTIFIER_POINTER (name));
2034 dbxout_type (type, 1);
2035 dbxout_finish_symbol (NULL_TREE);
2039 /* If an enum type has no name, it cannot be referred to,
2040 but we must output it anyway, since the enumeration constants
2041 can be referred to. */
2042 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
2044 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2045 current_sym_value = 0;
2046 current_sym_addr = 0;
2047 current_sym_nchars = 2;
2049 /* Some debuggers fail when given NULL names, so give this a
2050 harmless name of ` '. */
2051 fprintf (asmfile, "%s\" :T", ASM_STABS_OP);
2052 dbxout_type (type, 1);
2053 dbxout_finish_symbol (NULL_TREE);
2056 /* Prevent duplicate output of a typedef. */
2057 TREE_ASM_WRITTEN (decl) = 1;
2062 /* Parm decls go in their own separate chains
2063 and are output by dbxout_reg_parms and dbxout_parms. */
2067 /* Named return value, treat like a VAR_DECL. */
2069 if (! DECL_RTL_SET_P (decl))
2071 /* Don't mention a variable that is external.
2072 Let the file that defines it describe it. */
2073 if (DECL_EXTERNAL (decl))
2076 /* If the variable is really a constant
2077 and not written in memory, inform the debugger. */
2078 if (TREE_STATIC (decl) && TREE_READONLY (decl)
2079 && DECL_INITIAL (decl) != 0
2080 && host_integerp (DECL_INITIAL (decl), 0)
2081 && ! TREE_ASM_WRITTEN (decl)
2082 && (DECL_CONTEXT (decl) == NULL_TREE
2083 || TREE_CODE (DECL_CONTEXT (decl)) == BLOCK))
2085 if (TREE_PUBLIC (decl) == 0)
2087 /* The sun4 assembler does not grok this. */
2088 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
2090 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
2091 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
2093 HOST_WIDE_INT ival = tree_low_cst (DECL_INITIAL (decl), 0);
2094 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
2095 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile, name, ival);
2097 fprintf (asmfile, "%s\"%s:c=i", ASM_STABS_OP, name);
2099 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, ival);
2100 fprintf (asmfile, "\",0x%x,0,0,0\n", N_LSYM);
2104 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
2106 /* don't know how to do this yet. */
2110 /* else it is something we handle like a normal variable. */
2113 SET_DECL_RTL (decl, eliminate_regs (DECL_RTL (decl), 0, NULL_RTX));
2114 #ifdef LEAF_REG_REMAP
2115 if (current_function_uses_only_leaf_regs)
2116 leaf_renumber_regs_insn (DECL_RTL (decl));
2119 result = dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
2128 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2129 Add SUFFIX to its name, if SUFFIX is not 0.
2130 Describe the variable as residing in HOME
2131 (usually HOME is DECL_RTL (DECL), but not always).
2132 Returns 1 if the stab was really emitted. */
2135 dbxout_symbol_location (decl, type, suffix, home)
2143 /* Don't mention a variable at all
2144 if it was completely optimized into nothingness.
2146 If the decl was from an inline function, then its rtl
2147 is not identically the rtl that was used in this
2148 particular compilation. */
2149 if (GET_CODE (home) == SUBREG)
2153 while (GET_CODE (value) == SUBREG)
2154 value = SUBREG_REG (value);
2155 if (GET_CODE (value) == REG)
2157 if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
2160 home = alter_subreg (&home);
2162 if (GET_CODE (home) == REG)
2164 regno = REGNO (home);
2165 if (regno >= FIRST_PSEUDO_REGISTER)
2169 /* The kind-of-variable letter depends on where
2170 the variable is and on the scope of its name:
2171 G and N_GSYM for static storage and global scope,
2172 S for static storage and file scope,
2173 V for static storage and local scope,
2174 for those two, use N_LCSYM if data is in bss segment,
2175 N_STSYM if in data segment, N_FUN otherwise.
2176 (We used N_FUN originally, then changed to N_STSYM
2177 to please GDB. However, it seems that confused ld.
2178 Now GDB has been fixed to like N_FUN, says Kingdon.)
2179 no letter at all, and N_LSYM, for auto variable,
2180 r and N_RSYM for register variable. */
2182 if (GET_CODE (home) == MEM
2183 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
2185 if (TREE_PUBLIC (decl))
2188 current_sym_code = N_GSYM;
2192 current_sym_addr = XEXP (home, 0);
2194 letter = decl_function_context (decl) ? 'V' : 'S';
2196 /* This should be the same condition as in assemble_variable, but
2197 we don't have access to dont_output_data here. So, instead,
2198 we rely on the fact that error_mark_node initializers always
2199 end up in bss for C++ and never end up in bss for C. */
2200 if (DECL_INITIAL (decl) == 0
2201 || (!strcmp (lang_hooks.name, "GNU C++")
2202 && DECL_INITIAL (decl) == error_mark_node))
2203 current_sym_code = N_LCSYM;
2204 else if (DECL_IN_TEXT_SECTION (decl))
2205 /* This is not quite right, but it's the closest
2206 of all the codes that Unix defines. */
2207 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
2210 /* Some ports can transform a symbol ref into a label ref,
2211 because the symbol ref is too far away and has to be
2212 dumped into a constant pool. Alternatively, the symbol
2213 in the constant pool might be referenced by a different
2215 if (GET_CODE (current_sym_addr) == SYMBOL_REF
2216 && CONSTANT_POOL_ADDRESS_P (current_sym_addr))
2218 rtx tmp = get_pool_constant (current_sym_addr);
2220 if (GET_CODE (tmp) == SYMBOL_REF
2221 || GET_CODE (tmp) == LABEL_REF)
2222 current_sym_addr = tmp;
2225 /* Ultrix `as' seems to need this. */
2226 #ifdef DBX_STATIC_STAB_DATA_SECTION
2229 current_sym_code = N_STSYM;
2233 else if (regno >= 0)
2236 current_sym_code = N_RSYM;
2237 current_sym_value = DBX_REGISTER_NUMBER (regno);
2239 else if (GET_CODE (home) == MEM
2240 && (GET_CODE (XEXP (home, 0)) == MEM
2241 || (GET_CODE (XEXP (home, 0)) == REG
2242 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
2243 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
2244 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2245 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
2248 /* If the value is indirect by memory or by a register
2249 that isn't the frame pointer
2250 then it means the object is variable-sized and address through
2251 that register or stack slot. DBX has no way to represent this
2252 so all we can do is output the variable as a pointer.
2253 If it's not a parameter, ignore it.
2254 (VAR_DECLs like this can be made by integrate.c.) */
2256 if (GET_CODE (XEXP (home, 0)) == REG)
2259 current_sym_code = N_RSYM;
2260 if (REGNO (XEXP (home, 0)) >= FIRST_PSEUDO_REGISTER)
2262 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2266 current_sym_code = N_LSYM;
2267 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2268 We want the value of that CONST_INT. */
2270 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2273 /* Effectively do build_pointer_type, but don't cache this type,
2274 since it might be temporary whereas the type it points to
2275 might have been saved for inlining. */
2276 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2277 type = make_node (POINTER_TYPE);
2278 TREE_TYPE (type) = TREE_TYPE (decl);
2280 else if (GET_CODE (home) == MEM
2281 && GET_CODE (XEXP (home, 0)) == REG)
2283 current_sym_code = N_LSYM;
2284 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2286 else if (GET_CODE (home) == MEM
2287 && GET_CODE (XEXP (home, 0)) == PLUS
2288 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2290 current_sym_code = N_LSYM;
2291 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2292 We want the value of that CONST_INT. */
2293 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2295 else if (GET_CODE (home) == MEM
2296 && GET_CODE (XEXP (home, 0)) == CONST)
2298 /* Handle an obscure case which can arise when optimizing and
2299 when there are few available registers. (This is *always*
2300 the case for i386/i486 targets). The RTL looks like
2301 (MEM (CONST ...)) even though this variable is a local `auto'
2302 or a local `register' variable. In effect, what has happened
2303 is that the reload pass has seen that all assignments and
2304 references for one such a local variable can be replaced by
2305 equivalent assignments and references to some static storage
2306 variable, thereby avoiding the need for a register. In such
2307 cases we're forced to lie to debuggers and tell them that
2308 this variable was itself `static'. */
2309 current_sym_code = N_LCSYM;
2311 current_sym_addr = XEXP (XEXP (home, 0), 0);
2313 else if (GET_CODE (home) == CONCAT)
2317 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2318 for example), then there is no easy way to figure out
2319 what SUBTYPE should be. So, we give up. */
2320 if (TREE_CODE (type) != COMPLEX_TYPE)
2323 subtype = TREE_TYPE (type);
2325 /* If the variable's storage is in two parts,
2326 output each as a separate stab with a modified name. */
2327 if (WORDS_BIG_ENDIAN)
2328 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2330 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2332 /* Cast avoids warning in old compilers. */
2333 current_sym_code = (STAB_CODE_TYPE) 0;
2334 current_sym_value = 0;
2335 current_sym_addr = 0;
2336 dbxout_prepare_symbol (decl);
2338 if (WORDS_BIG_ENDIAN)
2339 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2341 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2345 /* Address might be a MEM, when DECL is a variable-sized object.
2346 Or it might be const0_rtx, meaning previous passes
2347 want us to ignore this variable. */
2350 /* Ok, start a symtab entry and output the variable name. */
2353 #ifdef DBX_STATIC_BLOCK_START
2354 DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2357 dbxout_symbol_name (decl, suffix, letter);
2358 dbxout_type (type, 0);
2359 dbxout_finish_symbol (decl);
2361 #ifdef DBX_STATIC_BLOCK_END
2362 DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2367 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2368 Then output LETTER to indicate the kind of location the symbol has. */
2371 dbxout_symbol_name (decl, suffix, letter)
2378 if (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl)))
2379 /* One slight hitch: if this is a VAR_DECL which is a static
2380 class member, we must put out the mangled name instead of the
2381 DECL_NAME. Note also that static member (variable) names DO NOT begin
2382 with underscores in .stabs directives. */
2383 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2385 /* ...but if we're function-local, we don't want to include the junk
2386 added by ASM_FORMAT_PRIVATE_NAME. */
2387 name = IDENTIFIER_POINTER (DECL_NAME (decl));
2391 fprintf (asmfile, "%s\"%s%s:", ASM_STABS_OP, name,
2392 (suffix ? suffix : ""));
2395 putc (letter, asmfile);
2399 dbxout_prepare_symbol (decl)
2400 tree decl ATTRIBUTE_UNUSED;
2403 const char *filename = DECL_SOURCE_FILE (decl);
2405 dbxout_source_file (asmfile, filename);
2410 dbxout_finish_symbol (sym)
2413 #ifdef DBX_FINISH_SYMBOL
2414 DBX_FINISH_SYMBOL (sym);
2417 if (use_gnu_debug_info_extensions && sym != 0)
2418 line = DECL_SOURCE_LINE (sym);
2420 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2421 if (current_sym_addr)
2422 output_addr_const (asmfile, current_sym_addr);
2424 fprintf (asmfile, "%d", current_sym_value);
2425 putc ('\n', asmfile);
2429 /* Output definitions of all the decls in a chain. Return non-zero if
2430 anything was output */
2439 result += dbxout_symbol (syms, 1);
2440 syms = TREE_CHAIN (syms);
2445 /* The following two functions output definitions of function parameters.
2446 Each parameter gets a definition locating it in the parameter list.
2447 Each parameter that is a register variable gets a second definition
2448 locating it in the register.
2450 Printing or argument lists in gdb uses the definitions that
2451 locate in the parameter list. But reference to the variable in
2452 expressions uses preferentially the definition as a register. */
2454 /* Output definitions, referring to storage in the parmlist,
2455 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2458 dbxout_parms (parms)
2461 for (; parms; parms = TREE_CHAIN (parms))
2462 if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2464 dbxout_prepare_symbol (parms);
2466 /* Perform any necessary register eliminations on the parameter's rtl,
2467 so that the debugging output will be accurate. */
2468 DECL_INCOMING_RTL (parms)
2469 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2470 SET_DECL_RTL (parms, eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
2471 #ifdef LEAF_REG_REMAP
2472 if (current_function_uses_only_leaf_regs)
2474 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2475 leaf_renumber_regs_insn (DECL_RTL (parms));
2479 if (PARM_PASSED_IN_MEMORY (parms))
2481 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2483 /* ??? Here we assume that the parm address is indexed
2484 off the frame pointer or arg pointer.
2485 If that is not true, we produce meaningless results,
2486 but do not crash. */
2487 if (GET_CODE (addr) == PLUS
2488 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2489 current_sym_value = INTVAL (XEXP (addr, 1));
2491 current_sym_value = 0;
2493 current_sym_code = N_PSYM;
2494 current_sym_addr = 0;
2497 if (DECL_NAME (parms))
2499 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2501 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2502 IDENTIFIER_POINTER (DECL_NAME (parms)),
2503 DBX_MEMPARM_STABS_LETTER);
2507 current_sym_nchars = 8;
2508 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2509 DBX_MEMPARM_STABS_LETTER);
2512 /* It is quite tempting to use:
2514 dbxout_type (TREE_TYPE (parms), 0);
2516 as the next statement, rather than using DECL_ARG_TYPE(), so
2517 that gcc reports the actual type of the parameter, rather
2518 than the promoted type. This certainly makes GDB's life
2519 easier, at least for some ports. The change is a bad idea
2520 however, since GDB expects to be able access the type without
2521 performing any conversions. So for example, if we were
2522 passing a float to an unprototyped function, gcc will store a
2523 double on the stack, but if we emit a stab saying the type is a
2524 float, then gdb will only read in a single value, and this will
2525 produce an erroneous value. */
2526 dbxout_type (DECL_ARG_TYPE (parms), 0);
2527 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2528 dbxout_finish_symbol (parms);
2530 else if (GET_CODE (DECL_RTL (parms)) == REG)
2533 char regparm_letter;
2535 /* Parm passed in registers and lives in registers or nowhere. */
2537 current_sym_code = DBX_REGPARM_STABS_CODE;
2538 regparm_letter = DBX_REGPARM_STABS_LETTER;
2539 current_sym_addr = 0;
2541 /* If parm lives in a register, use that register;
2542 pretend the parm was passed there. It would be more consistent
2543 to describe the register where the parm was passed,
2544 but in practice that register usually holds something else.
2546 If we use DECL_RTL, then we must use the declared type of
2547 the variable, not the type that it arrived in. */
2548 if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2550 best_rtl = DECL_RTL (parms);
2551 parm_type = TREE_TYPE (parms);
2553 /* If the parm lives nowhere, use the register where it was
2554 passed. It is also better to use the declared type here. */
2557 best_rtl = DECL_INCOMING_RTL (parms);
2558 parm_type = TREE_TYPE (parms);
2560 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2563 if (DECL_NAME (parms))
2565 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2566 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2567 IDENTIFIER_POINTER (DECL_NAME (parms)),
2572 current_sym_nchars = 8;
2573 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2577 dbxout_type (parm_type, 0);
2578 dbxout_finish_symbol (parms);
2580 else if (GET_CODE (DECL_RTL (parms)) == MEM
2581 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2582 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2583 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2584 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2585 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2589 /* Parm was passed via invisible reference.
2590 That is, its address was passed in a register.
2591 Output it as if it lived in that register.
2592 The debugger will know from the type
2593 that it was actually passed by invisible reference. */
2595 char regparm_letter;
2596 /* Parm passed in registers and lives in registers or nowhere. */
2598 current_sym_code = DBX_REGPARM_STABS_CODE;
2599 if (use_gnu_debug_info_extensions)
2600 regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2602 regparm_letter = DBX_REGPARM_STABS_LETTER;
2604 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2605 If it is an unallocated pseudo-reg, then use the register where
2606 it was passed instead. */
2607 if (REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2608 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2610 current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2612 current_sym_addr = 0;
2615 if (DECL_NAME (parms))
2618 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2620 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2621 IDENTIFIER_POINTER (DECL_NAME (parms)),
2626 current_sym_nchars = 8;
2627 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2631 dbxout_type (TREE_TYPE (parms), 0);
2632 dbxout_finish_symbol (parms);
2634 else if (GET_CODE (DECL_RTL (parms)) == MEM
2635 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2637 /* Parm was passed via invisible reference, with the reference
2638 living on the stack. DECL_RTL looks like
2639 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2640 could look like (MEM (MEM (REG))). */
2641 const char *const decl_name = (DECL_NAME (parms)
2642 ? IDENTIFIER_POINTER (DECL_NAME (parms))
2644 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 0)) == REG)
2645 current_sym_value = 0;
2648 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1));
2649 current_sym_addr = 0;
2652 fprintf (asmfile, "%s\"%s:v", ASM_STABS_OP, decl_name);
2655 = DEBUGGER_ARG_OFFSET (current_sym_value,
2656 XEXP (XEXP (DECL_RTL (parms), 0), 0));
2657 dbxout_type (TREE_TYPE (parms), 0);
2658 dbxout_finish_symbol (parms);
2660 else if (GET_CODE (DECL_RTL (parms)) == MEM
2661 && XEXP (DECL_RTL (parms), 0) != const0_rtx
2662 /* ??? A constant address for a parm can happen
2663 when the reg it lives in is equiv to a constant in memory.
2664 Should make this not happen, after 2.4. */
2665 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2667 /* Parm was passed in registers but lives on the stack. */
2669 current_sym_code = N_PSYM;
2670 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2671 in which case we want the value of that CONST_INT,
2673 in which case we use a value of zero. */
2674 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG)
2675 current_sym_value = 0;
2678 = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2680 current_sym_addr = 0;
2682 /* Make a big endian correction if the mode of the type of the
2683 parameter is not the same as the mode of the rtl. */
2684 if (BYTES_BIG_ENDIAN
2685 && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms))
2686 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD)
2688 current_sym_value +=
2689 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))
2690 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms)));
2694 if (DECL_NAME (parms))
2697 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2699 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2700 IDENTIFIER_POINTER (DECL_NAME (parms)),
2701 DBX_MEMPARM_STABS_LETTER);
2705 current_sym_nchars = 8;
2706 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2707 DBX_MEMPARM_STABS_LETTER);
2711 = DEBUGGER_ARG_OFFSET (current_sym_value,
2712 XEXP (DECL_RTL (parms), 0));
2713 dbxout_type (TREE_TYPE (parms), 0);
2714 dbxout_finish_symbol (parms);
2719 /* Output definitions for the places where parms live during the function,
2720 when different from where they were passed, when the parms were passed
2723 It is not useful to do this for parms passed in registers
2724 that live during the function in different registers, because it is
2725 impossible to look in the passed register for the passed value,
2726 so we use the within-the-function register to begin with.
2728 PARMS is a chain of PARM_DECL nodes. */
2731 dbxout_reg_parms (parms)
2734 for (; parms; parms = TREE_CHAIN (parms))
2735 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
2737 dbxout_prepare_symbol (parms);
2739 /* Report parms that live in registers during the function
2740 but were passed in memory. */
2741 if (GET_CODE (DECL_RTL (parms)) == REG
2742 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2743 dbxout_symbol_location (parms, TREE_TYPE (parms),
2744 0, DECL_RTL (parms));
2745 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
2746 dbxout_symbol_location (parms, TREE_TYPE (parms),
2747 0, DECL_RTL (parms));
2748 /* Report parms that live in memory but not where they were passed. */
2749 else if (GET_CODE (DECL_RTL (parms)) == MEM
2750 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
2751 dbxout_symbol_location (parms, TREE_TYPE (parms),
2752 0, DECL_RTL (parms));
2756 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2757 output definitions of those names, in raw form */
2765 putc (',', asmfile);
2766 dbxout_type (TREE_VALUE (args), 0);
2768 args = TREE_CHAIN (args);
2772 /* Output everything about a symbol block (a BLOCK node
2773 that represents a scope level),
2774 including recursive output of contained blocks.
2776 BLOCK is the BLOCK node.
2777 DEPTH is its depth within containing symbol blocks.
2778 ARGS is usually zero; but for the outermost block of the
2779 body of a function, it is a chain of PARM_DECLs for the function parameters.
2780 We output definitions of all the register parms
2781 as if they were local variables of that block.
2783 If -g1 was used, we count blocks just the same, but output nothing
2784 except for the outermost block.
2786 Actually, BLOCK may be several blocks chained together.
2787 We handle them all in sequence. */
2790 dbxout_block (block, depth, args)
2797 #if DBX_BLOCKS_FUNCTION_RELATIVE
2798 const char *begin_label;
2799 if (current_function_func_begin_label != NULL_TREE)
2800 begin_label = IDENTIFIER_POINTER (current_function_func_begin_label);
2802 begin_label = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
2807 /* Ignore blocks never expanded or otherwise marked as real. */
2808 if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
2812 #ifdef DBX_LBRAC_FIRST
2815 /* In dbx format, the syms of a block come before the N_LBRAC.
2816 If nothing is output, we don't need the N_LBRAC, either. */
2818 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2819 did_output = dbxout_syms (BLOCK_VARS (block));
2821 dbxout_reg_parms (args);
2824 /* Now output an N_LBRAC symbol to represent the beginning of
2825 the block. Use the block's tree-walk order to generate
2826 the assembler symbols LBBn and LBEn
2827 that final will define around the code in this block. */
2828 if (depth > 0 && did_output)
2831 blocknum = BLOCK_NUMBER (block);
2832 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
2834 if (BLOCK_HANDLER_BLOCK (block))
2836 /* A catch block. Must precede N_LBRAC. */
2837 tree decl = BLOCK_VARS (block);
2840 #ifdef DBX_OUTPUT_CATCH
2841 DBX_OUTPUT_CATCH (asmfile, decl, buf);
2843 fprintf (asmfile, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP,
2844 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
2845 assemble_name (asmfile, buf);
2846 fprintf (asmfile, "\n");
2848 decl = TREE_CHAIN (decl);
2852 #ifdef DBX_OUTPUT_LBRAC
2853 DBX_OUTPUT_LBRAC (asmfile, buf);
2855 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
2856 assemble_name (asmfile, buf);
2857 #if DBX_BLOCKS_FUNCTION_RELATIVE
2858 putc ('-', asmfile);
2859 assemble_name (asmfile, begin_label);
2861 fprintf (asmfile, "\n");
2865 #ifdef DBX_LBRAC_FIRST
2866 /* On some weird machines, the syms of a block
2867 come after the N_LBRAC. */
2868 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2869 dbxout_syms (BLOCK_VARS (block));
2871 dbxout_reg_parms (args);
2874 /* Output the subblocks. */
2875 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
2877 /* Refer to the marker for the end of the block. */
2878 if (depth > 0 && did_output)
2881 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
2882 #ifdef DBX_OUTPUT_RBRAC
2883 DBX_OUTPUT_RBRAC (asmfile, buf);
2885 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC);
2886 assemble_name (asmfile, buf);
2887 #if DBX_BLOCKS_FUNCTION_RELATIVE
2888 putc ('-', asmfile);
2889 assemble_name (asmfile, begin_label);
2891 fprintf (asmfile, "\n");
2895 block = BLOCK_CHAIN (block);
2899 /* Output the information about a function and its arguments and result.
2900 Usually this follows the function's code,
2901 but on some systems, it comes before. */
2903 #if defined (DBX_DEBUGGING_INFO)
2905 dbxout_begin_function (decl)
2908 dbxout_symbol (decl, 0);
2909 dbxout_parms (DECL_ARGUMENTS (decl));
2910 if (DECL_NAME (DECL_RESULT (decl)) != 0)
2911 dbxout_symbol (DECL_RESULT (decl), 1);
2913 #endif /* DBX_DEBUGGING_INFO */
2915 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */