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 fprintf (asmfile, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN);
402 assemble_name (asmfile, lscope_label_name);
404 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
405 fprintf (asmfile, "\n");
407 #endif /* DBX_DEBUGGING_INFO */
409 /* At the beginning of compilation, start writing the symbol table.
410 Initialize `typevec' and output the standard data types of C. */
413 dbxout_init (input_file_name)
414 const char *input_file_name;
416 char ltext_label_name[100];
417 tree syms = getdecls ();
419 asmfile = asm_out_file;
422 typevec = (struct typeinfo *) xcalloc (typevec_len, sizeof typevec[0]);
424 /* Convert Ltext into the appropriate format for local labels in case
425 the system doesn't insert underscores in front of user generated
427 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
429 /* Put the current working directory in an N_SO symbol. */
430 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
431 but GDB always does. */
432 if (use_gnu_debug_info_extensions)
435 if (!cwd && (cwd = getpwd ()) && (!*cwd || cwd[strlen (cwd) - 1] != '/'))
436 cwd = concat (cwd, FILE_NAME_JOINER, NULL);
439 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
440 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
441 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
442 fprintf (asmfile, "%s", ASM_STABS_OP);
443 output_quoted_string (asmfile, cwd);
444 fprintf (asmfile, ",%d,0,0,", N_SO);
445 assemble_name (asmfile, ltext_label_name);
446 fputc ('\n', asmfile);
447 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
451 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
452 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
453 would give us an N_SOL, and we want an N_SO. */
454 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
455 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
456 /* We include outputting `Ltext:' here,
457 because that gives you a way to override it. */
458 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
459 fprintf (asmfile, "%s", ASM_STABS_OP);
460 output_quoted_string (asmfile, input_file_name);
461 fprintf (asmfile, ",%d,0,0,", N_SO);
462 assemble_name (asmfile, ltext_label_name);
463 fputc ('\n', asmfile);
465 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Ltext", 0);
466 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
468 #ifdef DBX_OUTPUT_GCC_MARKER
469 DBX_OUTPUT_GCC_MARKER (asmfile);
471 /* Emit an N_OPT stab to indicate that this file was compiled by GCC. */
472 fprintf (asmfile, "%s\"%s\",%d,0,0,0\n",
473 ASM_STABS_OP, STABS_GCC_MARKER, N_OPT);
476 lastfile = input_file_name;
478 next_type_number = 1;
481 current_file = (struct dbx_file *) xmalloc (sizeof *current_file);
482 current_file->next = NULL;
483 current_file->file_number = 0;
484 current_file->next_type_number = 1;
485 next_file_number = 1;
488 /* Make sure that types `int' and `char' have numbers 1 and 2.
489 Definitions of other integer types will refer to those numbers.
490 (Actually it should no longer matter what their numbers are.
491 Also, if any types with tags have been defined, dbxout_symbol
492 will output them first, so the numbers won't be 1 and 2. That
493 happens in C++. So it's a good thing it should no longer matter). */
495 #ifdef DBX_OUTPUT_STANDARD_TYPES
496 DBX_OUTPUT_STANDARD_TYPES (syms);
498 dbxout_symbol (TYPE_NAME (integer_type_node), 0);
499 dbxout_symbol (TYPE_NAME (char_type_node), 0);
502 /* Get all permanent types that have typedef names,
503 and output them all, except for those already output. */
505 dbxout_typedefs (syms);
508 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
509 in the reverse order from that which is found in SYMS. */
512 dbxout_typedefs (syms)
517 dbxout_typedefs (TREE_CHAIN (syms));
518 if (TREE_CODE (syms) == TYPE_DECL)
520 tree type = TREE_TYPE (syms);
522 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
523 && COMPLETE_TYPE_P (type)
524 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
525 dbxout_symbol (TYPE_NAME (type), 0);
530 /* Change to reading from a new source file. Generate a N_BINCL stab. */
533 dbxout_start_source_file (line, filename)
534 unsigned int line ATTRIBUTE_UNUSED;
535 const char *filename ATTRIBUTE_UNUSED;
538 struct dbx_file *n = (struct dbx_file *) xmalloc (sizeof *n);
540 n->next = current_file;
541 n->file_number = next_file_number++;
542 n->next_type_number = 1;
544 fprintf (asmfile, "%s", ASM_STABS_OP);
545 output_quoted_string (asmfile, filename);
546 fprintf (asmfile, ",%d,0,0,0\n", N_BINCL);
550 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
553 dbxout_end_source_file (line)
554 unsigned int line ATTRIBUTE_UNUSED;
557 struct dbx_file *next;
559 fprintf (asmfile, "%s%d,0,0,0\n", ASM_STABN_OP, N_EINCL);
560 next = current_file->next;
566 #if defined (DBX_DEBUGGING_INFO)
567 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
570 dbxout_source_file (file, filename)
572 const char *filename;
574 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
576 #ifdef DBX_OUTPUT_SOURCE_FILENAME
577 DBX_OUTPUT_SOURCE_FILENAME (file, filename);
579 char ltext_label_name[100];
581 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
582 source_label_number);
583 fprintf (file, "%s", ASM_STABS_OP);
584 output_quoted_string (file, filename);
585 fprintf (asmfile, ",%d,0,0,", N_SOL);
586 assemble_name (asmfile, ltext_label_name);
587 fputc ('\n', asmfile);
588 if (current_function_decl != NULL_TREE
589 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
590 ; /* Don't change section amid function. */
593 ASM_OUTPUT_INTERNAL_LABEL (file, "Ltext", source_label_number);
594 source_label_number++;
600 /* Output a line number symbol entry for source file FILENAME and line
604 dbxout_source_line (lineno, filename)
606 const char *filename;
608 dbxout_source_file (asmfile, filename);
610 #ifdef ASM_OUTPUT_SOURCE_LINE
611 ASM_OUTPUT_SOURCE_LINE (asmfile, lineno);
613 fprintf (asmfile, "%s%d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
617 /* Describe the beginning of an internal block within a function. */
620 dbxout_begin_block (line, n)
621 unsigned int line ATTRIBUTE_UNUSED;
624 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "LBB", n);
627 /* Describe the end line-number of an internal block within a function. */
630 dbxout_end_block (line, n)
631 unsigned int line ATTRIBUTE_UNUSED;
634 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "LBE", n);
637 /* Output dbx data for a function definition.
638 This includes a definition of the function name itself (a symbol),
639 definitions of the parameters (locating them in the parameter list)
640 and then output the block that makes up the function's body
641 (including all the auto variables of the function). */
644 dbxout_function_decl (decl)
647 #ifndef DBX_FUNCTION_FIRST
648 dbxout_begin_function (decl);
650 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
651 #ifdef DBX_OUTPUT_FUNCTION_END
652 DBX_OUTPUT_FUNCTION_END (asmfile, decl);
654 if (use_gnu_debug_info_extensions
655 #if defined(NO_DBX_FUNCTION_END)
656 && ! NO_DBX_FUNCTION_END
658 && targetm.have_named_sections)
659 dbxout_function_end ();
662 #endif /* DBX_DEBUGGING_INFO */
664 /* Debug information for a global DECL. Called from toplev.c after
665 compilation proper has finished. */
667 dbxout_global_decl (decl)
670 if (TREE_CODE (decl) == VAR_DECL
671 && ! DECL_EXTERNAL (decl)
672 && DECL_RTL_SET_P (decl)) /* Not necessary? */
673 dbxout_symbol (decl, 0);
676 /* At the end of compilation, finish writing the symbol table.
677 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
681 dbxout_finish (filename)
682 const char *filename ATTRIBUTE_UNUSED;
684 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
685 DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile, filename);
686 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
689 /* Output the index of a type. */
692 dbxout_type_index (type)
695 #ifndef DBX_USE_BINCL
696 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
699 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
700 fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number);
705 #if DBX_CONTIN_LENGTH > 0
706 /* Continue a symbol-description that gets too big.
707 End one symbol table entry with a double-backslash
708 and start a new one, eventually producing something like
709 .stabs "start......\\",code,0,value
710 .stabs "...rest",code,0,value */
715 #ifdef DBX_CONTIN_CHAR
716 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
718 fprintf (asmfile, "\\\\");
720 dbxout_finish_symbol (NULL_TREE);
721 fprintf (asmfile, "%s\"", ASM_STABS_OP);
722 current_sym_nchars = 0;
724 #endif /* DBX_CONTIN_LENGTH > 0 */
726 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
727 This must be a separate function because anonymous unions require
731 dbxout_type_fields (type)
736 /* Output the name, type, position (in bits), size (in bits) of each
737 field that we can support. */
738 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
740 /* Omit here local type decls until we know how to support them. */
741 if (TREE_CODE (tem) == TYPE_DECL
742 /* Omit fields whose position or size are variable or too large to
744 || (TREE_CODE (tem) == FIELD_DECL
745 && (! host_integerp (bit_position (tem), 0)
747 || ! host_integerp (DECL_SIZE (tem), 1)))
748 /* Omit here the nameless fields that are used to skip bits. */
749 || DECL_IGNORED_P (tem))
752 else if (TREE_CODE (tem) != CONST_DECL)
754 /* Continue the line if necessary,
755 but not before the first field. */
756 if (tem != TYPE_FIELDS (type))
761 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
762 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
766 fprintf (asmfile, ":");
770 if (use_gnu_debug_info_extensions
771 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
772 || TREE_CODE (tem) != FIELD_DECL))
774 have_used_extensions = 1;
776 putc ((TREE_PRIVATE (tem) ? '0'
777 : TREE_PROTECTED (tem) ? '1' : '2'),
782 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
783 && DECL_BIT_FIELD_TYPE (tem))
784 ? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0);
786 if (TREE_CODE (tem) == VAR_DECL)
788 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
790 tree name = DECL_ASSEMBLER_NAME (tem);
792 have_used_extensions = 1;
793 fprintf (asmfile, ":%s;", IDENTIFIER_POINTER (name));
794 CHARS (IDENTIFIER_LENGTH (name) + 2);
798 /* If TEM is non-static, GDB won't understand it. */
799 fprintf (asmfile, ",0,0;");
806 print_wide_int (int_bit_position (tem));
808 print_wide_int (tree_low_cst (DECL_SIZE (tem), 1));
816 /* Subroutine of `dbxout_type_methods'. Output debug info about the
817 method described DECL. DEBUG_NAME is an encoding of the method's
818 type signature. ??? We may be able to do without DEBUG_NAME altogether
822 dbxout_type_method_1 (decl, debug_name)
824 const char *debug_name;
828 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
830 else /* it's a METHOD_TYPE. */
832 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
833 /* A for normal functions.
834 B for `const' member functions.
835 C for `volatile' member functions.
836 D for `const volatile' member functions. */
837 if (TYPE_READONLY (TREE_TYPE (firstarg)))
839 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
842 if (DECL_VINDEX (decl))
848 fprintf (asmfile, ":%s;%c%c%c", debug_name,
849 TREE_PRIVATE (decl) ? '0'
850 : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
851 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
852 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
854 if (DECL_VINDEX (decl) && host_integerp (DECL_VINDEX (decl), 0))
856 print_wide_int (tree_low_cst (DECL_VINDEX (decl), 0));
859 dbxout_type (DECL_CONTEXT (decl), 0);
860 fprintf (asmfile, ";");
865 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
869 dbxout_type_methods (type)
872 /* C++: put out the method names and their parameter lists */
873 tree methods = TYPE_METHODS (type);
877 char formatted_type_identifier_length[16];
878 int type_identifier_length;
880 if (methods == NULL_TREE)
883 type_encoding = DECL_NAME (TYPE_NAME (type));
886 /* C++: Template classes break some assumptions made by this code about
887 the class names, constructor names, and encodings for assembler
888 label names. For now, disable output of dbx info for them. */
890 const char *ptr = IDENTIFIER_POINTER (type_encoding);
891 /* This should use index. (mrs) */
892 while (*ptr && *ptr != '<') ptr++;
903 type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
905 sprintf (formatted_type_identifier_length, "%d", type_identifier_length);
907 if (TREE_CODE (methods) != TREE_VEC)
909 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
910 fndecl = TREE_VEC_ELT (methods, 0);
912 fndecl = TREE_VEC_ELT (methods, 1);
918 /* Group together all the methods for the same operation.
919 These differ in the types of the arguments. */
920 for (last = NULL_TREE;
921 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
922 fndecl = TREE_CHAIN (fndecl))
923 /* Output the name of the field (after overloading), as
924 well as the name of the field before overloading, along
925 with its parameter list */
927 /* This is the "mangled" name of the method.
928 It encodes the argument types. */
929 const char *debug_name;
931 /* Skip methods that aren't FUNCTION_DECLs. (In C++, these
932 include TEMPLATE_DECLs.) The debugger doesn't know what
933 to do with such entities anyhow. */
934 if (TREE_CODE (fndecl) != FUNCTION_DECL)
937 debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
943 /* Also ignore abstract methods; those are only interesting to
944 the DWARF backends. */
945 if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT (fndecl))
948 /* Redundantly output the plain name, since that's what gdb
952 tree name = DECL_NAME (fndecl);
953 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
954 CHARS (IDENTIFIER_LENGTH (name) + 2);
958 dbxout_type (TREE_TYPE (fndecl), 0);
960 dbxout_type_method_1 (fndecl, debug_name);
970 /* Emit a "range" type specification, which has the form:
971 "r<index type>;<lower bound>;<upper bound>;".
972 TYPE is an INTEGER_TYPE. */
975 dbxout_range_type (type)
978 fprintf (asmfile, "r");
979 if (TREE_TYPE (type))
980 dbxout_type (TREE_TYPE (type), 0);
981 else if (TREE_CODE (type) != INTEGER_TYPE)
982 dbxout_type (type, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
985 /* Traditionally, we made sure 'int' was type 1, and builtin types
986 were defined to be sub-ranges of int. Unfortunately, this
987 does not allow us to distinguish true sub-ranges from integer
988 types. So, instead we define integer (non-sub-range) types as
989 sub-ranges of themselves. This matters for Chill. If this isn't
990 a subrange type, then we want to define it in terms of itself.
991 However, in C, this may be an anonymous integer type, and we don't
992 want to emit debug info referring to it. Just calling
993 dbxout_type_index won't work anyways, because the type hasn't been
994 defined yet. We make this work for both cases by checked to see
995 whether this is a defined type, referring to it if it is, and using
997 if (TYPE_SYMTAB_ADDRESS (type) != 0)
998 dbxout_type_index (type);
1000 dbxout_type_index (integer_type_node);
1003 if (TYPE_MIN_VALUE (type) != 0
1004 && host_integerp (TYPE_MIN_VALUE (type), 0))
1006 putc (';', asmfile);
1008 print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type), 0));
1012 fprintf (asmfile, ";0");
1016 if (TYPE_MAX_VALUE (type) != 0
1017 && host_integerp (TYPE_MAX_VALUE (type), 0))
1019 putc (';', asmfile);
1021 print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type), 0));
1022 putc (';', asmfile);
1027 fprintf (asmfile, ";-1;");
1032 /* Output a reference to a type. If the type has not yet been
1033 described in the dbx output, output its definition now.
1034 For a type already defined, just refer to its definition
1035 using the type number.
1037 If FULL is nonzero, and the type has been described only with
1038 a forward-reference, output the definition now.
1039 If FULL is zero in this case, just refer to the forward-reference
1040 using the number previously allocated. */
1043 dbxout_type (type, full)
1049 static int anonymous_type_number = 0;
1051 if (TREE_CODE (type) == VECTOR_TYPE)
1052 type = TYPE_DEBUG_REPRESENTATION_TYPE (type);
1054 /* If there was an input error and we don't really have a type,
1055 avoid crashing and write something that is at least valid
1056 by assuming `int'. */
1057 if (type == error_mark_node)
1058 type = integer_type_node;
1061 if (TYPE_NAME (type)
1062 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1063 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1067 /* Try to find the "main variant" with the same name. */
1068 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1069 && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1070 main_variant = TREE_TYPE (TYPE_NAME (type));
1072 main_variant = TYPE_MAIN_VARIANT (type);
1074 /* If we are not using extensions, stabs does not distinguish const and
1075 volatile, so there is no need to make them separate types. */
1076 if (!use_gnu_debug_info_extensions)
1077 type = main_variant;
1079 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1081 /* Type has no dbx number assigned. Assign next available number. */
1082 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1084 /* Make sure type vector is long enough to record about this type. */
1086 if (next_type_number == typevec_len)
1089 = (struct typeinfo *) xrealloc (typevec,
1090 typevec_len * 2 * sizeof typevec[0]);
1091 memset ((char *) (typevec + typevec_len), 0,
1092 typevec_len * sizeof typevec[0]);
1096 #ifdef DBX_USE_BINCL
1097 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1098 = current_file->file_number;
1099 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1100 = current_file->next_type_number++;
1104 /* Output the number of this type, to refer to it. */
1105 dbxout_type_index (type);
1107 #ifdef DBX_TYPE_DEFINED
1108 if (DBX_TYPE_DEFINED (type))
1112 /* If this type's definition has been output or is now being output,
1115 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1120 /* If we have already had a cross reference,
1121 and either that's all we want or that's the best we could do,
1122 don't repeat the cross reference.
1123 Sun dbx crashes if we do. */
1124 if (! full || !COMPLETE_TYPE_P (type)
1125 /* No way in DBX fmt to describe a variable size. */
1126 || ! host_integerp (TYPE_SIZE (type), 1))
1134 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1135 leave the type-number completely undefined rather than output
1136 a cross-reference. If we have already used GNU debug info extensions,
1137 then it is OK to output a cross reference. This is necessary to get
1138 proper C++ debug output. */
1139 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1140 || TREE_CODE (type) == QUAL_UNION_TYPE
1141 || TREE_CODE (type) == ENUMERAL_TYPE)
1142 && ! use_gnu_debug_info_extensions)
1143 /* We must use the same test here as we use twice below when deciding
1144 whether to emit a cross-reference. */
1145 if ((TYPE_NAME (type) != 0
1146 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1147 && DECL_IGNORED_P (TYPE_NAME (type)))
1149 || !COMPLETE_TYPE_P (type)
1150 /* No way in DBX fmt to describe a variable size. */
1151 || ! host_integerp (TYPE_SIZE (type), 1))
1153 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1158 /* Output a definition now. */
1160 fprintf (asmfile, "=");
1163 /* Mark it as defined, so that if it is self-referent
1164 we will not get into an infinite recursion of definitions. */
1166 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1168 /* If this type is a variant of some other, hand off. Types with
1169 different names are usefully distinguished. We only distinguish
1170 cv-qualified types if we're using extensions. */
1171 if (TYPE_READONLY (type) > TYPE_READONLY (main_variant))
1173 putc ('k', asmfile);
1175 dbxout_type (build_type_variant (type, 0, TYPE_VOLATILE (type)), 0);
1178 else if (TYPE_VOLATILE (type) > TYPE_VOLATILE (main_variant))
1180 putc ('B', asmfile);
1182 dbxout_type (build_type_variant (type, TYPE_READONLY (type), 0), 0);
1185 else if (main_variant != TYPE_MAIN_VARIANT (type))
1187 /* 'type' is a typedef; output the type it refers to. */
1188 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0);
1191 /* else continue. */
1193 switch (TREE_CODE (type))
1197 /* For a void type, just define it as itself; ie, "5=5".
1198 This makes us consider it defined
1199 without saying what it is. The debugger will make it
1200 a void type when the reference is seen, and nothing will
1201 ever override that default. */
1202 dbxout_type_index (type);
1206 if (type == char_type_node && ! TREE_UNSIGNED (type))
1208 /* Output the type `char' as a subrange of itself!
1209 I don't understand this definition, just copied it
1210 from the output of pcc.
1211 This used to use `r2' explicitly and we used to
1212 take care to make sure that `char' was type number 2. */
1213 fprintf (asmfile, "r");
1215 dbxout_type_index (type);
1216 fprintf (asmfile, ";0;127;");
1220 /* If this is a subtype of another integer type, always prefer to
1221 write it as a subtype. */
1222 else if (TREE_TYPE (type) != 0
1223 && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
1224 dbxout_range_type (type);
1228 /* If the size is non-standard, say what it is if we can use
1231 if (use_gnu_debug_info_extensions
1232 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1234 have_used_extensions = 1;
1235 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1239 /* If we can use GDB extensions and the size is wider than a
1240 long (the size used by GDB to read them) or we may have
1241 trouble writing the bounds the usual way, write them in
1242 octal. Note the test is for the *target's* size of "long",
1243 not that of the host. The host test is just to make sure we
1244 can write it out in case the host wide int is narrower than the
1247 /* For unsigned types, we use octal if they are the same size or
1248 larger. This is because we print the bounds as signed decimal,
1249 and hence they can't span same size unsigned types. */
1251 if (use_gnu_debug_info_extensions
1252 && TYPE_MIN_VALUE (type) != 0
1253 && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
1254 && TYPE_MAX_VALUE (type) != 0
1255 && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
1256 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1257 || ((TYPE_PRECISION (type)
1258 == TYPE_PRECISION (integer_type_node))
1259 && TREE_UNSIGNED (type))
1260 || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT
1261 || (TYPE_PRECISION (type) == HOST_BITS_PER_WIDE_INT
1262 && TREE_UNSIGNED (type))))
1264 fprintf (asmfile, "r");
1266 dbxout_type_index (type);
1267 fprintf (asmfile, ";");
1269 print_int_cst_octal (TYPE_MIN_VALUE (type));
1270 fprintf (asmfile, ";");
1272 print_int_cst_octal (TYPE_MAX_VALUE (type));
1273 fprintf (asmfile, ";");
1278 /* Output other integer types as subranges of `int'. */
1279 dbxout_range_type (type);
1285 /* This used to say `r1' and we used to take care
1286 to make sure that `int' was type number 1. */
1287 fprintf (asmfile, "r");
1289 dbxout_type_index (integer_type_node);
1290 putc (';', asmfile);
1292 print_wide_int (int_size_in_bytes (type));
1293 fputs (";0;", asmfile);
1298 if (use_gnu_debug_info_extensions)
1300 have_used_extensions = 1;
1301 fputs ("@s", asmfile);
1303 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1304 fputs (";-20;", asmfile);
1309 /* Output the type `char' as a subrange of itself.
1310 That is what pcc seems to do. */
1311 fprintf (asmfile, "r");
1313 dbxout_type_index (char_type_node);
1314 fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1320 if (use_gnu_debug_info_extensions)
1322 have_used_extensions = 1;
1323 fputs ("@s", asmfile);
1325 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1326 fputs (";-16;", asmfile);
1329 else /* Define as enumeral type (False, True) */
1331 fprintf (asmfile, "eFalse:0,True:1,;");
1337 putc ('d', asmfile);
1339 dbxout_type (TREE_TYPE (type), 0);
1343 /* Differs from the REAL_TYPE by its new data type number */
1345 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1347 fprintf (asmfile, "r");
1349 dbxout_type_index (type);
1350 putc (';', asmfile);
1352 print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type)));
1353 fputs (";0;", asmfile);
1358 /* Output a complex integer type as a structure,
1359 pending some other way to do it. */
1360 putc ('s', asmfile);
1362 print_wide_int (int_size_in_bytes (type));
1363 fprintf (asmfile, "real:");
1366 dbxout_type (TREE_TYPE (type), 0);
1367 fprintf (asmfile, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type)));
1369 fprintf (asmfile, "imag:");
1371 dbxout_type (TREE_TYPE (type), 0);
1372 fprintf (asmfile, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type)),
1373 TYPE_PRECISION (TREE_TYPE (type)));
1379 if (use_gnu_debug_info_extensions)
1381 have_used_extensions = 1;
1382 fputs ("@s", asmfile);
1384 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1385 putc (';', asmfile);
1388 /* Check if a bitstring type, which in Chill is
1389 different from a [power]set. */
1390 if (TYPE_STRING_FLAG (type))
1392 fprintf (asmfile, "@S;");
1396 putc ('S', asmfile);
1398 dbxout_type (TYPE_DOMAIN (type), 0);
1402 /* Make arrays of packed bits look like bitstrings for chill. */
1403 if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
1405 have_used_extensions = 1;
1406 fputs ("@s", asmfile);
1408 print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1409 fprintf (asmfile, ";@S;S");
1411 dbxout_type (TYPE_DOMAIN (type), 0);
1415 /* Output "a" followed by a range type definition
1416 for the index type of the array
1417 followed by a reference to the target-type.
1418 ar1;0;N;M for a C array of type M and size N+1. */
1419 /* Check if a character string type, which in Chill is
1420 different from an array of characters. */
1421 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1423 have_used_extensions = 1;
1424 fprintf (asmfile, "@S;");
1427 tem = TYPE_DOMAIN (type);
1430 fprintf (asmfile, "ar");
1432 dbxout_type_index (integer_type_node);
1433 fprintf (asmfile, ";0;-1;");
1438 fprintf (asmfile, "a");
1440 dbxout_range_type (tem);
1443 dbxout_type (TREE_TYPE (type), 0);
1448 case QUAL_UNION_TYPE:
1450 int i, n_baseclasses = 0;
1452 if (TYPE_BINFO (type) != 0
1453 && TREE_CODE (TYPE_BINFO (type)) == TREE_VEC
1454 && TYPE_BINFO_BASETYPES (type) != 0)
1455 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1457 /* Output a structure type. We must use the same test here as we
1458 use in the DBX_NO_XREFS case above. */
1459 if ((TYPE_NAME (type) != 0
1460 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1461 && DECL_IGNORED_P (TYPE_NAME (type)))
1463 || !COMPLETE_TYPE_P (type)
1464 /* No way in DBX fmt to describe a variable size. */
1465 || ! host_integerp (TYPE_SIZE (type), 1))
1467 /* If the type is just a cross reference, output one
1468 and mark the type as partially described.
1469 If it later becomes defined, we will output
1470 its real definition.
1471 If the type has a name, don't nest its definition within
1472 another type's definition; instead, output an xref
1473 and let the definition come when the name is defined. */
1474 fputs ((TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu", asmfile);
1476 #if 0 /* This assertion is legitimately false in C++. */
1477 /* We shouldn't be outputting a reference to a type before its
1478 definition unless the type has a tag name.
1479 A typedef name without a tag name should be impossible. */
1480 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1483 if (TYPE_NAME (type) != 0)
1484 dbxout_type_name (type);
1487 fprintf (asmfile, "$$%d", anonymous_type_number++);
1491 fprintf (asmfile, ":");
1493 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1497 /* Identify record or union, and print its size. */
1498 putc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asmfile);
1500 print_wide_int (int_size_in_bytes (type));
1502 if (use_gnu_debug_info_extensions)
1506 have_used_extensions = 1;
1507 fprintf (asmfile, "!%d,", n_baseclasses);
1511 for (i = 0; i < n_baseclasses; i++)
1513 tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i);
1515 if (use_gnu_debug_info_extensions)
1517 have_used_extensions = 1;
1518 putc (TREE_VIA_VIRTUAL (child) ? '1' : '0', asmfile);
1519 putc (TREE_VIA_PUBLIC (child) ? '2' : '0', asmfile);
1521 if (TREE_VIA_VIRTUAL (child) && strcmp (lang_hooks.name, "GNU C++") == 0)
1522 /* For a virtual base, print the (negative) offset within
1523 the vtable where we must look to find the necessary
1525 print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child), 0)
1528 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1530 putc (',', asmfile);
1532 dbxout_type (BINFO_TYPE (child), 0);
1533 putc (';', asmfile);
1538 /* Print out the base class information with fields
1539 which have the same names at the types they hold. */
1540 dbxout_type_name (BINFO_TYPE (child));
1541 putc (':', asmfile);
1543 dbxout_type (BINFO_TYPE (child), full);
1544 putc (',', asmfile);
1546 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1548 putc (',', asmfile);
1550 print_wide_int (tree_low_cst (DECL_SIZE
1552 (BINFO_TYPE (child))),
1555 putc (';', asmfile);
1561 /* Write out the field declarations. */
1562 dbxout_type_fields (type);
1563 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1565 have_used_extensions = 1;
1566 dbxout_type_methods (type);
1569 putc (';', asmfile);
1572 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1573 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1574 && TYPE_VFIELD (type))
1576 have_used_extensions = 1;
1578 /* Tell GDB+ that it may keep reading. */
1579 putc ('~', asmfile);
1582 /* We need to write out info about what field this class
1583 uses as its "main" vtable pointer field, because if this
1584 field is inherited from a base class, GDB cannot necessarily
1585 figure out which field it's using in time. */
1586 if (TYPE_VFIELD (type))
1588 putc ('%', asmfile);
1590 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0);
1593 putc (';', asmfile);
1599 /* We must use the same test here as we use in the DBX_NO_XREFS case
1600 above. We simplify it a bit since an enum will never have a variable
1602 if ((TYPE_NAME (type) != 0
1603 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1604 && DECL_IGNORED_P (TYPE_NAME (type)))
1606 || !COMPLETE_TYPE_P (type))
1608 fprintf (asmfile, "xe");
1610 dbxout_type_name (type);
1611 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1612 putc (':', asmfile);
1616 #ifdef DBX_OUTPUT_ENUM
1617 DBX_OUTPUT_ENUM (asmfile, type);
1619 if (use_gnu_debug_info_extensions
1620 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1622 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1626 putc ('e', asmfile);
1628 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1630 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1631 CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem)) + 1);
1632 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1633 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1634 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1635 && (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1636 print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1638 print_int_cst_octal (TREE_VALUE (tem));
1640 putc (',', asmfile);
1642 if (TREE_CHAIN (tem) != 0)
1646 putc (';', asmfile);
1652 putc ('*', asmfile);
1654 dbxout_type (TREE_TYPE (type), 0);
1658 if (use_gnu_debug_info_extensions)
1660 have_used_extensions = 1;
1661 putc ('#', asmfile);
1664 /* Write the argument types out longhand. */
1665 dbxout_type (TYPE_METHOD_BASETYPE (type), 0);
1666 putc (',', asmfile);
1668 dbxout_type (TREE_TYPE (type), 0);
1669 dbxout_args (TYPE_ARG_TYPES (type));
1670 putc (';', asmfile);
1674 /* Treat it as a function type. */
1675 dbxout_type (TREE_TYPE (type), 0);
1679 if (use_gnu_debug_info_extensions)
1681 have_used_extensions = 1;
1682 putc ('@', asmfile);
1684 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0);
1685 putc (',', asmfile);
1687 dbxout_type (TREE_TYPE (type), 0);
1690 /* Should print as an int, because it is really just an offset. */
1691 dbxout_type (integer_type_node, 0);
1694 case REFERENCE_TYPE:
1695 if (use_gnu_debug_info_extensions)
1696 have_used_extensions = 1;
1697 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1699 dbxout_type (TREE_TYPE (type), 0);
1703 putc ('f', asmfile);
1705 dbxout_type (TREE_TYPE (type), 0);
1713 /* Print the value of integer constant C, in octal,
1714 handling double precision. */
1717 print_int_cst_octal (c)
1720 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1721 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1722 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1723 unsigned int width = TYPE_PRECISION (TREE_TYPE (c));
1725 /* GDB wants constants with no extra leading "1" bits, so
1726 we need to remove any sign-extension that might be
1728 if (width == HOST_BITS_PER_WIDE_INT * 2)
1730 else if (width > HOST_BITS_PER_WIDE_INT)
1731 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1732 else if (width == HOST_BITS_PER_WIDE_INT)
1735 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1737 fprintf (asmfile, "0");
1742 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1743 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1747 unsigned HOST_WIDE_INT beg = high >> excess;
1748 unsigned HOST_WIDE_INT middle
1749 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1750 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1751 unsigned HOST_WIDE_INT end
1752 = low & (((unsigned HOST_WIDE_INT) 1
1753 << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1756 fprintf (asmfile, "%o%01o", (int) beg, (int) middle);
1758 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1763 print_octal (value, digits)
1764 unsigned HOST_WIDE_INT value;
1769 for (i = digits - 1; i >= 0; i--)
1770 fprintf (asmfile, "%01o", (int) ((value >> (3 * i)) & 7));
1775 /* Output C in decimal while adjusting the number of digits written. */
1783 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, c);
1794 /* Output the name of type TYPE, with no punctuation.
1795 Such names can be set up either by typedef declarations
1796 or by struct, enum and union tags. */
1799 dbxout_type_name (type)
1803 if (TYPE_NAME (type) == 0)
1805 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
1807 t = TYPE_NAME (type);
1809 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1811 t = DECL_NAME (TYPE_NAME (type));
1816 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
1817 CHARS (IDENTIFIER_LENGTH (t));
1820 /* Output a .stabs for the symbol defined by DECL,
1821 which must be a ..._DECL node in the normal namespace.
1822 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1823 LOCAL is nonzero if the scope is less than the entire file.
1824 Return 1 if a stabs might have been emitted. */
1827 dbxout_symbol (decl, local)
1829 int local ATTRIBUTE_UNUSED;
1831 tree type = TREE_TYPE (decl);
1832 tree context = NULL_TREE;
1835 /* Cast avoids warning in old compilers. */
1836 current_sym_code = (STAB_CODE_TYPE) 0;
1837 current_sym_value = 0;
1838 current_sym_addr = 0;
1840 /* Ignore nameless syms, but don't ignore type tags. */
1842 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
1843 || DECL_IGNORED_P (decl))
1846 dbxout_prepare_symbol (decl);
1848 /* The output will always start with the symbol name,
1849 so always count that in the length-output-so-far. */
1851 if (DECL_NAME (decl) != 0)
1852 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
1854 switch (TREE_CODE (decl))
1857 /* Enum values are defined by defining the enum type. */
1861 if (DECL_RTL (decl) == 0)
1863 if (DECL_EXTERNAL (decl))
1865 /* Don't mention a nested function under its parent. */
1866 context = decl_function_context (decl);
1867 if (context == current_function_decl)
1869 if (GET_CODE (DECL_RTL (decl)) != MEM
1870 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
1874 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
1875 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1876 TREE_PUBLIC (decl) ? 'F' : 'f');
1879 current_sym_code = N_FUN;
1880 current_sym_addr = XEXP (DECL_RTL (decl), 0);
1882 if (TREE_TYPE (type))
1883 dbxout_type (TREE_TYPE (type), 0);
1885 dbxout_type (void_type_node, 0);
1887 /* For a nested function, when that function is compiled,
1888 mention the containing function name
1889 as well as (since dbx wants it) our own assembler-name. */
1891 fprintf (asmfile, ",%s,%s",
1892 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1893 IDENTIFIER_POINTER (DECL_NAME (context)));
1895 dbxout_finish_symbol (decl);
1900 /* This seems all wrong. Outputting most kinds of types gives no name
1901 at all. A true definition gives no name; a cross-ref for a
1902 structure can give the tag name, but not a type name.
1903 It seems that no typedef name is defined by outputting a type. */
1905 /* If this typedef name was defined by outputting the type,
1906 don't duplicate it. */
1907 if (typevec[TYPE_SYMTAB_ADDRESS (type)].status == TYPE_DEFINED
1908 && TYPE_NAME (TREE_TYPE (decl)) == decl)
1911 /* Don't output the same typedef twice.
1912 And don't output what language-specific stuff doesn't want output. */
1913 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
1922 if (DECL_NAME (decl))
1924 /* Nonzero means we must output a tag as well as a typedef. */
1927 /* Handle the case of a C++ structure or union
1928 where the TYPE_NAME is a TYPE_DECL
1929 which gives both a typedef name and a tag. */
1930 /* dbx requires the tag first and the typedef second. */
1931 if ((TREE_CODE (type) == RECORD_TYPE
1932 || TREE_CODE (type) == UNION_TYPE
1933 || TREE_CODE (type) == QUAL_UNION_TYPE)
1934 && TYPE_NAME (type) == decl
1935 && !(use_gnu_debug_info_extensions && have_used_extensions)
1936 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
1937 /* Distinguish the implicit typedefs of C++
1938 from explicit ones that might be found in C. */
1939 && DECL_ARTIFICIAL (decl)
1940 /* Do not generate a tag for records of variable size,
1941 since this type can not be properly described in the
1942 DBX format, and it confuses some tools such as objdump. */
1943 && host_integerp (TYPE_SIZE (type), 1))
1945 tree name = TYPE_NAME (type);
1946 if (TREE_CODE (name) == TYPE_DECL)
1947 name = DECL_NAME (name);
1949 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1950 current_sym_value = 0;
1951 current_sym_addr = 0;
1952 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1954 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
1955 IDENTIFIER_POINTER (name));
1956 dbxout_type (type, 1);
1957 dbxout_finish_symbol (NULL_TREE);
1960 /* Output typedef name. */
1961 fprintf (asmfile, "%s\"%s:", ASM_STABS_OP,
1962 IDENTIFIER_POINTER (DECL_NAME (decl)));
1964 /* Short cut way to output a tag also. */
1965 if ((TREE_CODE (type) == RECORD_TYPE
1966 || TREE_CODE (type) == UNION_TYPE
1967 || TREE_CODE (type) == QUAL_UNION_TYPE)
1968 && TYPE_NAME (type) == decl
1969 /* Distinguish the implicit typedefs of C++
1970 from explicit ones that might be found in C. */
1971 && DECL_ARTIFICIAL (decl))
1973 if (use_gnu_debug_info_extensions && have_used_extensions)
1975 putc ('T', asmfile);
1976 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
1978 #if 0 /* Now we generate the tag for this case up above. */
1984 putc ('t', asmfile);
1985 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1987 dbxout_type (type, 1);
1988 dbxout_finish_symbol (decl);
1992 /* Don't output a tag if this is an incomplete type. This prevents
1993 the sun4 Sun OS 4.x dbx from crashing. */
1995 if (tag_needed && TYPE_NAME (type) != 0
1996 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
1997 || (DECL_NAME (TYPE_NAME (type)) != 0))
1998 && COMPLETE_TYPE_P (type)
1999 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
2001 /* For a TYPE_DECL with no name, but the type has a name,
2003 This is what represents `struct foo' with no typedef. */
2004 /* In C++, the name of a type is the corresponding typedef.
2005 In C, it is an IDENTIFIER_NODE. */
2006 tree name = TYPE_NAME (type);
2007 if (TREE_CODE (name) == TYPE_DECL)
2008 name = DECL_NAME (name);
2010 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2011 current_sym_value = 0;
2012 current_sym_addr = 0;
2013 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2015 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
2016 IDENTIFIER_POINTER (name));
2017 dbxout_type (type, 1);
2018 dbxout_finish_symbol (NULL_TREE);
2022 /* If an enum type has no name, it cannot be referred to,
2023 but we must output it anyway, since the enumeration constants
2024 can be referred to. */
2025 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
2027 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2028 current_sym_value = 0;
2029 current_sym_addr = 0;
2030 current_sym_nchars = 2;
2032 /* Some debuggers fail when given NULL names, so give this a
2033 harmless name of ` '. */
2034 fprintf (asmfile, "%s\" :T", ASM_STABS_OP);
2035 dbxout_type (type, 1);
2036 dbxout_finish_symbol (NULL_TREE);
2039 /* Prevent duplicate output of a typedef. */
2040 TREE_ASM_WRITTEN (decl) = 1;
2045 /* Parm decls go in their own separate chains
2046 and are output by dbxout_reg_parms and dbxout_parms. */
2050 /* Named return value, treat like a VAR_DECL. */
2052 if (! DECL_RTL_SET_P (decl))
2054 /* Don't mention a variable that is external.
2055 Let the file that defines it describe it. */
2056 if (DECL_EXTERNAL (decl))
2059 /* If the variable is really a constant
2060 and not written in memory, inform the debugger. */
2061 if (TREE_STATIC (decl) && TREE_READONLY (decl)
2062 && DECL_INITIAL (decl) != 0
2063 && host_integerp (DECL_INITIAL (decl), 0)
2064 && ! TREE_ASM_WRITTEN (decl)
2065 && (DECL_CONTEXT (decl) == NULL_TREE
2066 || TREE_CODE (DECL_CONTEXT (decl)) == BLOCK))
2068 if (TREE_PUBLIC (decl) == 0)
2070 /* The sun4 assembler does not grok this. */
2071 const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
2073 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
2074 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
2076 HOST_WIDE_INT ival = tree_low_cst (DECL_INITIAL (decl), 0);
2077 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
2078 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile, name, ival);
2080 fprintf (asmfile, "%s\"%s:c=i", ASM_STABS_OP, name);
2082 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, ival);
2083 fprintf (asmfile, "\",0x%x,0,0,0\n", N_LSYM);
2087 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
2089 /* don't know how to do this yet. */
2093 /* else it is something we handle like a normal variable. */
2096 SET_DECL_RTL (decl, eliminate_regs (DECL_RTL (decl), 0, NULL_RTX));
2097 #ifdef LEAF_REG_REMAP
2098 if (current_function_uses_only_leaf_regs)
2099 leaf_renumber_regs_insn (DECL_RTL (decl));
2102 result = dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
2111 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2112 Add SUFFIX to its name, if SUFFIX is not 0.
2113 Describe the variable as residing in HOME
2114 (usually HOME is DECL_RTL (DECL), but not always).
2115 Returns 1 if the stab was really emitted. */
2118 dbxout_symbol_location (decl, type, suffix, home)
2126 /* Don't mention a variable at all
2127 if it was completely optimized into nothingness.
2129 If the decl was from an inline function, then its rtl
2130 is not identically the rtl that was used in this
2131 particular compilation. */
2132 if (GET_CODE (home) == SUBREG)
2136 while (GET_CODE (value) == SUBREG)
2137 value = SUBREG_REG (value);
2138 if (GET_CODE (value) == REG)
2140 if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
2143 home = alter_subreg (&home);
2145 if (GET_CODE (home) == REG)
2147 regno = REGNO (home);
2148 if (regno >= FIRST_PSEUDO_REGISTER)
2152 /* The kind-of-variable letter depends on where
2153 the variable is and on the scope of its name:
2154 G and N_GSYM for static storage and global scope,
2155 S for static storage and file scope,
2156 V for static storage and local scope,
2157 for those two, use N_LCSYM if data is in bss segment,
2158 N_STSYM if in data segment, N_FUN otherwise.
2159 (We used N_FUN originally, then changed to N_STSYM
2160 to please GDB. However, it seems that confused ld.
2161 Now GDB has been fixed to like N_FUN, says Kingdon.)
2162 no letter at all, and N_LSYM, for auto variable,
2163 r and N_RSYM for register variable. */
2165 if (GET_CODE (home) == MEM
2166 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
2168 if (TREE_PUBLIC (decl))
2171 current_sym_code = N_GSYM;
2175 current_sym_addr = XEXP (home, 0);
2177 letter = decl_function_context (decl) ? 'V' : 'S';
2179 /* This should be the same condition as in assemble_variable, but
2180 we don't have access to dont_output_data here. So, instead,
2181 we rely on the fact that error_mark_node initializers always
2182 end up in bss for C++ and never end up in bss for C. */
2183 if (DECL_INITIAL (decl) == 0
2184 || (!strcmp (lang_hooks.name, "GNU C++")
2185 && DECL_INITIAL (decl) == error_mark_node))
2186 current_sym_code = N_LCSYM;
2187 else if (DECL_IN_TEXT_SECTION (decl))
2188 /* This is not quite right, but it's the closest
2189 of all the codes that Unix defines. */
2190 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
2193 /* Some ports can transform a symbol ref into a label ref,
2194 because the symbol ref is too far away and has to be
2195 dumped into a constant pool. Alternatively, the symbol
2196 in the constant pool might be referenced by a different
2198 if (GET_CODE (current_sym_addr) == SYMBOL_REF
2199 && CONSTANT_POOL_ADDRESS_P (current_sym_addr))
2201 rtx tmp = get_pool_constant (current_sym_addr);
2203 if (GET_CODE (tmp) == SYMBOL_REF)
2204 current_sym_addr = tmp;
2207 /* Ultrix `as' seems to need this. */
2208 #ifdef DBX_STATIC_STAB_DATA_SECTION
2211 current_sym_code = N_STSYM;
2215 else if (regno >= 0)
2218 current_sym_code = N_RSYM;
2219 current_sym_value = DBX_REGISTER_NUMBER (regno);
2221 else if (GET_CODE (home) == MEM
2222 && (GET_CODE (XEXP (home, 0)) == MEM
2223 || (GET_CODE (XEXP (home, 0)) == REG
2224 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
2225 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
2226 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2227 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
2230 /* If the value is indirect by memory or by a register
2231 that isn't the frame pointer
2232 then it means the object is variable-sized and address through
2233 that register or stack slot. DBX has no way to represent this
2234 so all we can do is output the variable as a pointer.
2235 If it's not a parameter, ignore it.
2236 (VAR_DECLs like this can be made by integrate.c.) */
2238 if (GET_CODE (XEXP (home, 0)) == REG)
2241 current_sym_code = N_RSYM;
2242 if (REGNO (XEXP (home, 0)) >= FIRST_PSEUDO_REGISTER)
2244 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2248 current_sym_code = N_LSYM;
2249 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2250 We want the value of that CONST_INT. */
2252 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2255 /* Effectively do build_pointer_type, but don't cache this type,
2256 since it might be temporary whereas the type it points to
2257 might have been saved for inlining. */
2258 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2259 type = make_node (POINTER_TYPE);
2260 TREE_TYPE (type) = TREE_TYPE (decl);
2262 else if (GET_CODE (home) == MEM
2263 && GET_CODE (XEXP (home, 0)) == REG)
2265 current_sym_code = N_LSYM;
2266 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2268 else if (GET_CODE (home) == MEM
2269 && GET_CODE (XEXP (home, 0)) == PLUS
2270 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2272 current_sym_code = N_LSYM;
2273 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2274 We want the value of that CONST_INT. */
2275 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2277 else if (GET_CODE (home) == MEM
2278 && GET_CODE (XEXP (home, 0)) == CONST)
2280 /* Handle an obscure case which can arise when optimizing and
2281 when there are few available registers. (This is *always*
2282 the case for i386/i486 targets). The RTL looks like
2283 (MEM (CONST ...)) even though this variable is a local `auto'
2284 or a local `register' variable. In effect, what has happened
2285 is that the reload pass has seen that all assignments and
2286 references for one such a local variable can be replaced by
2287 equivalent assignments and references to some static storage
2288 variable, thereby avoiding the need for a register. In such
2289 cases we're forced to lie to debuggers and tell them that
2290 this variable was itself `static'. */
2291 current_sym_code = N_LCSYM;
2293 current_sym_addr = XEXP (XEXP (home, 0), 0);
2295 else if (GET_CODE (home) == CONCAT)
2299 /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2300 for example), then there is no easy way to figure out
2301 what SUBTYPE should be. So, we give up. */
2302 if (TREE_CODE (type) != COMPLEX_TYPE)
2305 subtype = TREE_TYPE (type);
2307 /* If the variable's storage is in two parts,
2308 output each as a separate stab with a modified name. */
2309 if (WORDS_BIG_ENDIAN)
2310 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2312 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2314 /* Cast avoids warning in old compilers. */
2315 current_sym_code = (STAB_CODE_TYPE) 0;
2316 current_sym_value = 0;
2317 current_sym_addr = 0;
2318 dbxout_prepare_symbol (decl);
2320 if (WORDS_BIG_ENDIAN)
2321 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2323 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2327 /* Address might be a MEM, when DECL is a variable-sized object.
2328 Or it might be const0_rtx, meaning previous passes
2329 want us to ignore this variable. */
2332 /* Ok, start a symtab entry and output the variable name. */
2335 #ifdef DBX_STATIC_BLOCK_START
2336 DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2339 dbxout_symbol_name (decl, suffix, letter);
2340 dbxout_type (type, 0);
2341 dbxout_finish_symbol (decl);
2343 #ifdef DBX_STATIC_BLOCK_END
2344 DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2349 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2350 Then output LETTER to indicate the kind of location the symbol has. */
2353 dbxout_symbol_name (decl, suffix, letter)
2360 if (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl)))
2361 /* One slight hitch: if this is a VAR_DECL which is a static
2362 class member, we must put out the mangled name instead of the
2363 DECL_NAME. Note also that static member (variable) names DO NOT begin
2364 with underscores in .stabs directives. */
2365 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2367 /* ...but if we're function-local, we don't want to include the junk
2368 added by ASM_FORMAT_PRIVATE_NAME. */
2369 name = IDENTIFIER_POINTER (DECL_NAME (decl));
2373 fprintf (asmfile, "%s\"%s%s:", ASM_STABS_OP, name,
2374 (suffix ? suffix : ""));
2377 putc (letter, asmfile);
2381 dbxout_prepare_symbol (decl)
2382 tree decl ATTRIBUTE_UNUSED;
2385 const char *filename = DECL_SOURCE_FILE (decl);
2387 dbxout_source_file (asmfile, filename);
2392 dbxout_finish_symbol (sym)
2395 #ifdef DBX_FINISH_SYMBOL
2396 DBX_FINISH_SYMBOL (sym);
2399 if (use_gnu_debug_info_extensions && sym != 0)
2400 line = DECL_SOURCE_LINE (sym);
2402 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2403 if (current_sym_addr)
2404 output_addr_const (asmfile, current_sym_addr);
2406 fprintf (asmfile, "%d", current_sym_value);
2407 putc ('\n', asmfile);
2411 /* Output definitions of all the decls in a chain. Return non-zero if
2412 anything was output */
2421 result += dbxout_symbol (syms, 1);
2422 syms = TREE_CHAIN (syms);
2427 /* The following two functions output definitions of function parameters.
2428 Each parameter gets a definition locating it in the parameter list.
2429 Each parameter that is a register variable gets a second definition
2430 locating it in the register.
2432 Printing or argument lists in gdb uses the definitions that
2433 locate in the parameter list. But reference to the variable in
2434 expressions uses preferentially the definition as a register. */
2436 /* Output definitions, referring to storage in the parmlist,
2437 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2440 dbxout_parms (parms)
2443 for (; parms; parms = TREE_CHAIN (parms))
2444 if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2446 dbxout_prepare_symbol (parms);
2448 /* Perform any necessary register eliminations on the parameter's rtl,
2449 so that the debugging output will be accurate. */
2450 DECL_INCOMING_RTL (parms)
2451 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2452 SET_DECL_RTL (parms, eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
2453 #ifdef LEAF_REG_REMAP
2454 if (current_function_uses_only_leaf_regs)
2456 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2457 leaf_renumber_regs_insn (DECL_RTL (parms));
2461 if (PARM_PASSED_IN_MEMORY (parms))
2463 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2465 /* ??? Here we assume that the parm address is indexed
2466 off the frame pointer or arg pointer.
2467 If that is not true, we produce meaningless results,
2468 but do not crash. */
2469 if (GET_CODE (addr) == PLUS
2470 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2471 current_sym_value = INTVAL (XEXP (addr, 1));
2473 current_sym_value = 0;
2475 current_sym_code = N_PSYM;
2476 current_sym_addr = 0;
2479 if (DECL_NAME (parms))
2481 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2483 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2484 IDENTIFIER_POINTER (DECL_NAME (parms)),
2485 DBX_MEMPARM_STABS_LETTER);
2489 current_sym_nchars = 8;
2490 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2491 DBX_MEMPARM_STABS_LETTER);
2494 /* It is quite tempting to use:
2496 dbxout_type (TREE_TYPE (parms), 0);
2498 as the next statement, rather than using DECL_ARG_TYPE(), so
2499 that gcc reports the actual type of the parameter, rather
2500 than the promoted type. This certainly makes GDB's life
2501 easier, at least for some ports. The change is a bad idea
2502 however, since GDB expects to be able access the type without
2503 performing any conversions. So for example, if we were
2504 passing a float to an unprototyped function, gcc will store a
2505 double on the stack, but if we emit a stab saying the type is a
2506 float, then gdb will only read in a single value, and this will
2507 produce an erroneous value. */
2508 dbxout_type (DECL_ARG_TYPE (parms), 0);
2509 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2510 dbxout_finish_symbol (parms);
2512 else if (GET_CODE (DECL_RTL (parms)) == REG)
2515 char regparm_letter;
2517 /* Parm passed in registers and lives in registers or nowhere. */
2519 current_sym_code = DBX_REGPARM_STABS_CODE;
2520 regparm_letter = DBX_REGPARM_STABS_LETTER;
2521 current_sym_addr = 0;
2523 /* If parm lives in a register, use that register;
2524 pretend the parm was passed there. It would be more consistent
2525 to describe the register where the parm was passed,
2526 but in practice that register usually holds something else.
2528 If we use DECL_RTL, then we must use the declared type of
2529 the variable, not the type that it arrived in. */
2530 if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2532 best_rtl = DECL_RTL (parms);
2533 parm_type = TREE_TYPE (parms);
2535 /* If the parm lives nowhere, use the register where it was
2536 passed. It is also better to use the declared type here. */
2539 best_rtl = DECL_INCOMING_RTL (parms);
2540 parm_type = TREE_TYPE (parms);
2542 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2545 if (DECL_NAME (parms))
2547 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2548 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2549 IDENTIFIER_POINTER (DECL_NAME (parms)),
2554 current_sym_nchars = 8;
2555 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2559 dbxout_type (parm_type, 0);
2560 dbxout_finish_symbol (parms);
2562 else if (GET_CODE (DECL_RTL (parms)) == MEM
2563 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2564 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2565 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2566 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2567 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2571 /* Parm was passed via invisible reference.
2572 That is, its address was passed in a register.
2573 Output it as if it lived in that register.
2574 The debugger will know from the type
2575 that it was actually passed by invisible reference. */
2577 char regparm_letter;
2578 /* Parm passed in registers and lives in registers or nowhere. */
2580 current_sym_code = DBX_REGPARM_STABS_CODE;
2581 if (use_gnu_debug_info_extensions)
2582 regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2584 regparm_letter = DBX_REGPARM_STABS_LETTER;
2586 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2587 If it is an unallocated pseudo-reg, then use the register where
2588 it was passed instead. */
2589 if (REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2590 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2592 current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2594 current_sym_addr = 0;
2597 if (DECL_NAME (parms))
2600 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2602 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2603 IDENTIFIER_POINTER (DECL_NAME (parms)),
2608 current_sym_nchars = 8;
2609 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2613 dbxout_type (TREE_TYPE (parms), 0);
2614 dbxout_finish_symbol (parms);
2616 else if (GET_CODE (DECL_RTL (parms)) == MEM
2617 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2619 /* Parm was passed via invisible reference, with the reference
2620 living on the stack. DECL_RTL looks like
2621 (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2622 could look like (MEM (MEM (REG))). */
2623 const char *const decl_name = (DECL_NAME (parms)
2624 ? IDENTIFIER_POINTER (DECL_NAME (parms))
2626 if (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 0)) == REG)
2627 current_sym_value = 0;
2630 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1));
2631 current_sym_addr = 0;
2634 fprintf (asmfile, "%s\"%s:v", ASM_STABS_OP, decl_name);
2635 dbxout_type (TREE_TYPE (parms), 0);
2636 dbxout_finish_symbol (parms);
2638 else if (GET_CODE (DECL_RTL (parms)) == MEM
2639 && XEXP (DECL_RTL (parms), 0) != const0_rtx
2640 /* ??? A constant address for a parm can happen
2641 when the reg it lives in is equiv to a constant in memory.
2642 Should make this not happen, after 2.4. */
2643 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2645 /* Parm was passed in registers but lives on the stack. */
2647 current_sym_code = N_PSYM;
2648 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2649 in which case we want the value of that CONST_INT,
2651 in which case we use a value of zero. */
2652 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG)
2653 current_sym_value = 0;
2656 = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2658 current_sym_addr = 0;
2660 /* Make a big endian correction if the mode of the type of the
2661 parameter is not the same as the mode of the rtl. */
2662 if (BYTES_BIG_ENDIAN
2663 && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms))
2664 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD)
2666 current_sym_value +=
2667 GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))
2668 - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms)));
2672 if (DECL_NAME (parms))
2675 = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2677 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2678 IDENTIFIER_POINTER (DECL_NAME (parms)),
2679 DBX_MEMPARM_STABS_LETTER);
2683 current_sym_nchars = 8;
2684 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2685 DBX_MEMPARM_STABS_LETTER);
2689 = DEBUGGER_ARG_OFFSET (current_sym_value,
2690 XEXP (DECL_RTL (parms), 0));
2691 dbxout_type (TREE_TYPE (parms), 0);
2692 dbxout_finish_symbol (parms);
2697 /* Output definitions for the places where parms live during the function,
2698 when different from where they were passed, when the parms were passed
2701 It is not useful to do this for parms passed in registers
2702 that live during the function in different registers, because it is
2703 impossible to look in the passed register for the passed value,
2704 so we use the within-the-function register to begin with.
2706 PARMS is a chain of PARM_DECL nodes. */
2709 dbxout_reg_parms (parms)
2712 for (; parms; parms = TREE_CHAIN (parms))
2713 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
2715 dbxout_prepare_symbol (parms);
2717 /* Report parms that live in registers during the function
2718 but were passed in memory. */
2719 if (GET_CODE (DECL_RTL (parms)) == REG
2720 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2721 dbxout_symbol_location (parms, TREE_TYPE (parms),
2722 0, DECL_RTL (parms));
2723 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
2724 dbxout_symbol_location (parms, TREE_TYPE (parms),
2725 0, DECL_RTL (parms));
2726 /* Report parms that live in memory but not where they were passed. */
2727 else if (GET_CODE (DECL_RTL (parms)) == MEM
2728 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
2729 dbxout_symbol_location (parms, TREE_TYPE (parms),
2730 0, DECL_RTL (parms));
2734 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2735 output definitions of those names, in raw form */
2743 putc (',', asmfile);
2744 dbxout_type (TREE_VALUE (args), 0);
2746 args = TREE_CHAIN (args);
2750 /* Output everything about a symbol block (a BLOCK node
2751 that represents a scope level),
2752 including recursive output of contained blocks.
2754 BLOCK is the BLOCK node.
2755 DEPTH is its depth within containing symbol blocks.
2756 ARGS is usually zero; but for the outermost block of the
2757 body of a function, it is a chain of PARM_DECLs for the function parameters.
2758 We output definitions of all the register parms
2759 as if they were local variables of that block.
2761 If -g1 was used, we count blocks just the same, but output nothing
2762 except for the outermost block.
2764 Actually, BLOCK may be several blocks chained together.
2765 We handle them all in sequence. */
2768 dbxout_block (block, depth, args)
2775 #if DBX_BLOCKS_FUNCTION_RELATIVE
2776 const char *begin_label;
2777 if (current_function_func_begin_label != NULL_TREE)
2778 begin_label = IDENTIFIER_POINTER (current_function_func_begin_label);
2780 begin_label = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
2785 /* Ignore blocks never expanded or otherwise marked as real. */
2786 if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
2790 #ifdef DBX_LBRAC_FIRST
2793 /* In dbx format, the syms of a block come before the N_LBRAC.
2794 If nothing is output, we don't need the N_LBRAC, either. */
2796 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2797 did_output = dbxout_syms (BLOCK_VARS (block));
2799 dbxout_reg_parms (args);
2802 /* Now output an N_LBRAC symbol to represent the beginning of
2803 the block. Use the block's tree-walk order to generate
2804 the assembler symbols LBBn and LBEn
2805 that final will define around the code in this block. */
2806 if (depth > 0 && did_output)
2809 blocknum = BLOCK_NUMBER (block);
2810 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
2812 if (BLOCK_HANDLER_BLOCK (block))
2814 /* A catch block. Must precede N_LBRAC. */
2815 tree decl = BLOCK_VARS (block);
2818 #ifdef DBX_OUTPUT_CATCH
2819 DBX_OUTPUT_CATCH (asmfile, decl, buf);
2821 fprintf (asmfile, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP,
2822 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
2823 assemble_name (asmfile, buf);
2824 fprintf (asmfile, "\n");
2826 decl = TREE_CHAIN (decl);
2830 #ifdef DBX_OUTPUT_LBRAC
2831 DBX_OUTPUT_LBRAC (asmfile, buf);
2833 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
2834 assemble_name (asmfile, buf);
2835 #if DBX_BLOCKS_FUNCTION_RELATIVE
2836 putc ('-', asmfile);
2837 assemble_name (asmfile, begin_label);
2839 fprintf (asmfile, "\n");
2843 #ifdef DBX_LBRAC_FIRST
2844 /* On some weird machines, the syms of a block
2845 come after the N_LBRAC. */
2846 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2847 dbxout_syms (BLOCK_VARS (block));
2849 dbxout_reg_parms (args);
2852 /* Output the subblocks. */
2853 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
2855 /* Refer to the marker for the end of the block. */
2856 if (depth > 0 && did_output)
2859 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
2860 #ifdef DBX_OUTPUT_RBRAC
2861 DBX_OUTPUT_RBRAC (asmfile, buf);
2863 fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC);
2864 assemble_name (asmfile, buf);
2865 #if DBX_BLOCKS_FUNCTION_RELATIVE
2866 putc ('-', asmfile);
2867 assemble_name (asmfile, begin_label);
2869 fprintf (asmfile, "\n");
2873 block = BLOCK_CHAIN (block);
2877 /* Output the information about a function and its arguments and result.
2878 Usually this follows the function's code,
2879 but on some systems, it comes before. */
2881 #if defined (DBX_DEBUGGING_INFO)
2883 dbxout_begin_function (decl)
2886 dbxout_symbol (decl, 0);
2887 dbxout_parms (DECL_ARGUMENTS (decl));
2888 if (DECL_NAME (DECL_RESULT (decl)) != 0)
2889 dbxout_symbol (DECL_RESULT (decl), 1);
2891 #endif /* DBX_DEBUGGING_INFO */
2893 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */