OSDN Git Service

* cse.c: Convert prototypes to ISO C90.
[pf3gnuchains/gcc-fork.git] / gcc / dbxout.c
1 /* Output dbx-format symbol table information from GNU compiler.
2    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3    1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
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
10 version.
11
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
15 for more details.
16
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
20 02111-1307, USA.  */
21
22
23 /* Output dbx-format symbol table data.
24    This consists of many symbol table entries, each of them
25    a .stabs assembler pseudo-op with four operands:
26    a "name" which is really a description of one symbol and its type,
27    a "code", which is a symbol defined in stab.h whose name starts with N_,
28    an unused operand always 0,
29    and a "value" which is an address or an offset.
30    The name is enclosed in doublequote characters.
31
32    Each function, variable, typedef, and structure tag
33    has a symbol table entry to define it.
34    The beginning and end of each level of name scoping within
35    a function are also marked by special symbol table entries.
36
37    The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
38    and a data type number.  The data type number may be followed by
39    "=" and a type definition; normally this will happen the first time
40    the type number is mentioned.  The type definition may refer to
41    other types by number, and those type numbers may be followed
42    by "=" and nested definitions.
43
44    This can make the "name" quite long.
45    When a name is more than 80 characters, we split the .stabs pseudo-op
46    into two .stabs pseudo-ops, both sharing the same "code" and "value".
47    The first one is marked as continued with a double-backslash at the
48    end of its "name".
49
50    The kind-of-symbol letter distinguished function names from global
51    variables from file-scope variables from parameters from auto
52    variables in memory from typedef names from register variables.
53    See `dbxout_symbol'.
54
55    The "code" is mostly redundant with the kind-of-symbol letter
56    that goes in the "name", but not entirely: for symbols located
57    in static storage, the "code" says which segment the address is in,
58    which controls how it is relocated.
59
60    The "value" for a symbol in static storage
61    is the core address of the symbol (actually, the assembler
62    label for the symbol).  For a symbol located in a stack slot
63    it is the stack offset; for one in a register, the register number.
64    For a typedef symbol, it is zero.
65
66    If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
67    output while in the text section.
68
69    For more on data type definitions, see `dbxout_type'.  */
70
71 #include "config.h"
72 #include "system.h"
73 #include "coretypes.h"
74 #include "tm.h"
75
76 #include "tree.h"
77 #include "rtl.h"
78 #include "flags.h"
79 #include "regs.h"
80 #include "insn-config.h"
81 #include "reload.h"
82 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions.  */
83 #include "dbxout.h"
84 #include "toplev.h"
85 #include "tm_p.h"
86 #include "ggc.h"
87 #include "debug.h"
88 #include "function.h"
89 #include "target.h"
90 #include "langhooks.h"
91
92 #ifdef XCOFF_DEBUGGING_INFO
93 #include "xcoffout.h"
94 #endif
95
96 #undef DBXOUT_DECR_NESTING
97 #define DBXOUT_DECR_NESTING \
98   if (--debug_nesting == 0 && symbol_queue_index > 0) \
99     debug_flush_symbol_queue ()
100
101 #undef DBXOUT_DECR_NESTING_AND_RETURN
102 #define DBXOUT_DECR_NESTING_AND_RETURN(x) \
103   do {--debug_nesting; return (x);} while (0)
104
105 #ifndef ASM_STABS_OP
106 #define ASM_STABS_OP "\t.stabs\t"
107 #endif
108
109 #ifndef ASM_STABN_OP
110 #define ASM_STABN_OP "\t.stabn\t"
111 #endif
112
113 #ifndef DBX_TYPE_DECL_STABS_CODE
114 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
115 #endif
116
117 #ifndef DBX_STATIC_CONST_VAR_CODE
118 #define DBX_STATIC_CONST_VAR_CODE N_FUN
119 #endif
120
121 #ifndef DBX_REGPARM_STABS_CODE
122 #define DBX_REGPARM_STABS_CODE N_RSYM
123 #endif
124
125 #ifndef DBX_REGPARM_STABS_LETTER
126 #define DBX_REGPARM_STABS_LETTER 'P'
127 #endif
128
129 /* This is used for parameters passed by invisible reference in a register.  */
130 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
131 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
132 #endif
133
134 #ifndef DBX_MEMPARM_STABS_LETTER
135 #define DBX_MEMPARM_STABS_LETTER 'p'
136 #endif
137
138 #ifndef FILE_NAME_JOINER
139 #define FILE_NAME_JOINER "/"
140 #endif
141
142 /* GDB needs to know that the stabs were generated by GCC.  We emit an
143    N_OPT stab at the beginning of the source file to indicate this.
144    The string is historical, and different on a very few targets.  */
145 #ifndef STABS_GCC_MARKER
146 #define STABS_GCC_MARKER "gcc2_compiled."
147 #endif
148
149 enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
150
151 /* Structure recording information about a C data type.
152    The status element says whether we have yet output
153    the definition of the type.  TYPE_XREF says we have
154    output it as a cross-reference only.
155    The file_number and type_number elements are used if DBX_USE_BINCL
156    is defined.  */
157
158 struct typeinfo GTY(())
159 {
160   enum typestatus status;
161   int file_number;
162   int type_number;
163 };
164
165 /* Vector recording information about C data types.
166    When we first notice a data type (a tree node),
167    we assign it a number using next_type_number.
168    That is its index in this vector.  */
169
170 static GTY ((length ("typevec_len"))) struct typeinfo *typevec;
171
172 /* Number of elements of space allocated in `typevec'.  */
173
174 static GTY(()) int typevec_len;
175
176 /* In dbx output, each type gets a unique number.
177    This is the number for the next type output.
178    The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field.  */
179
180 static GTY(()) int next_type_number;
181
182 /* When using N_BINCL in dbx output, each type number is actually a
183    pair of the file number and the type number within the file.
184    This is a stack of input files.  */
185
186 struct dbx_file GTY(())
187 {
188   struct dbx_file *next;
189   int file_number;
190   int next_type_number;
191 };
192
193 /* This is the top of the stack.  */
194
195 static GTY(()) struct dbx_file *current_file;
196
197 /* This is the next file number to use.  */
198
199 static GTY(()) int next_file_number;
200
201 /* A counter for dbxout_function_end.  */
202
203 static GTY(()) int scope_labelno;
204
205 /* A counter for dbxout_source_line.  */
206
207 static GTY(()) int dbxout_source_line_counter;
208
209 /* Nonzero if we have actually used any of the GDB extensions
210    to the debugging format.  The idea is that we use them for the
211    first time only if there's a strong reason, but once we have done that,
212    we use them whenever convenient.  */
213
214 static GTY(()) int have_used_extensions = 0;
215
216 /* Number for the next N_SOL filename stabs label.  The number 0 is reserved
217    for the N_SO filename stabs label.  */
218
219 static GTY(()) int source_label_number = 1;
220
221 /* Last source file name mentioned in a NOTE insn.  */
222
223 static GTY(()) const char *lastfile;
224
225 /* Used by PCH machinery to detect if 'lastfile' should be reset to
226    base_input_file.  */
227 static GTY(()) int lastfile_is_base;
228
229 /* Typical USG systems don't have stab.h, and they also have
230    no use for DBX-format debugging info.  */
231
232 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
233
234 /* The original input file name.  */
235 static const char *base_input_file;
236
237 /* Current working directory.  */
238
239 static const char *cwd;
240
241 #ifdef DEBUG_SYMS_TEXT
242 #define FORCE_TEXT function_section (current_function_decl);
243 #else
244 #define FORCE_TEXT
245 #endif
246
247 #include "gstab.h"
248
249 #define STAB_CODE_TYPE enum __stab_debug_code
250
251 /* 1 if PARM is passed to this function in memory.  */
252
253 #define PARM_PASSED_IN_MEMORY(PARM) \
254  (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
255
256 /* A C expression for the integer offset value of an automatic variable
257    (N_LSYM) having address X (an RTX).  */
258 #ifndef DEBUGGER_AUTO_OFFSET
259 #define DEBUGGER_AUTO_OFFSET(X) \
260   (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
261 #endif
262
263 /* A C expression for the integer offset value of an argument (N_PSYM)
264    having address X (an RTX).  The nominal offset is OFFSET.  */
265 #ifndef DEBUGGER_ARG_OFFSET
266 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
267 #endif
268
269 /* Stream for writing to assembler file.  */
270
271 static FILE *asmfile;
272
273 /* These variables are for dbxout_symbol to communicate to
274    dbxout_finish_symbol.
275    current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
276    current_sym_value and current_sym_addr are two ways to address the
277    value to store in the symtab entry.
278    current_sym_addr if nonzero represents the value as an rtx.
279    If that is zero, current_sym_value is used.  This is used
280    when the value is an offset (such as for auto variables,
281    register variables and parms).  */
282
283 static STAB_CODE_TYPE current_sym_code;
284 static int current_sym_value;
285 static rtx current_sym_addr;
286
287 /* Number of chars of symbol-description generated so far for the
288    current symbol.  Used by CHARS and CONTIN.  */
289
290 static int current_sym_nchars;
291
292 /* Report having output N chars of the current symbol-description.  */
293
294 #define CHARS(N) (current_sym_nchars += (N))
295
296 /* Break the current symbol-description, generating a continuation,
297    if it has become long.  */
298
299 #ifndef DBX_CONTIN_LENGTH
300 #define DBX_CONTIN_LENGTH 80
301 #endif
302
303 #if DBX_CONTIN_LENGTH > 0
304 #define CONTIN  \
305   do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
306 #else
307 #define CONTIN do { } while (0)
308 #endif
309
310 static void dbxout_init (const char *);
311 static void dbxout_finish (const char *);
312 static void dbxout_start_source_file (unsigned, const char *);
313 static void dbxout_end_source_file (unsigned);
314 static void dbxout_typedefs (tree);
315 static void dbxout_fptype_value (tree);
316 static void dbxout_type_index (tree);
317 #if DBX_CONTIN_LENGTH > 0
318 static void dbxout_continue (void);
319 #endif
320 static void dbxout_args (tree);
321 static void dbxout_type_fields (tree);
322 static void dbxout_type_method_1 (tree, const char *);
323 static void dbxout_type_methods (tree);
324 static void dbxout_range_type (tree);
325 static void dbxout_type (tree, int);
326 static bool print_int_cst_bounds_in_octal_p (tree);
327 static void print_int_cst_octal (tree);
328 static void print_octal (unsigned HOST_WIDE_INT, int);
329 static void print_wide_int (HOST_WIDE_INT);
330 static void dbxout_type_name (tree);
331 static void dbxout_class_name_qualifiers (tree);
332 static int dbxout_symbol_location (tree, tree, const char *, rtx);
333 static void dbxout_symbol_name (tree, const char *, int);
334 static void dbxout_prepare_symbol (tree);
335 static void dbxout_finish_symbol (tree);
336 static void dbxout_block (tree, int, tree);
337 static void dbxout_global_decl (tree);
338 static void dbxout_handle_pch (unsigned);
339 \f
340 /* The debug hooks structure.  */
341 #if defined (DBX_DEBUGGING_INFO)
342
343 static void dbxout_source_line (unsigned int, const char *);
344 static void dbxout_source_file (FILE *, const char *);
345 static void dbxout_function_end (void);
346 static void dbxout_begin_function (tree);
347 static void dbxout_begin_block (unsigned, unsigned);
348 static void dbxout_end_block (unsigned, unsigned);
349 static void dbxout_function_decl (tree);
350
351 const struct gcc_debug_hooks dbx_debug_hooks =
352 {
353   dbxout_init,
354   dbxout_finish,
355   debug_nothing_int_charstar,
356   debug_nothing_int_charstar,
357   dbxout_start_source_file,
358   dbxout_end_source_file,
359   dbxout_begin_block,
360   dbxout_end_block,
361   debug_true_tree,              /* ignore_block */
362   dbxout_source_line,           /* source_line */
363   dbxout_source_line,           /* begin_prologue: just output line info */
364   debug_nothing_int_charstar,   /* end_prologue */
365   debug_nothing_int_charstar,   /* end_epilogue */
366 #ifdef DBX_FUNCTION_FIRST
367   dbxout_begin_function,
368 #else
369   debug_nothing_tree,           /* begin_function */
370 #endif
371   debug_nothing_int,            /* end_function */
372   dbxout_function_decl,
373   dbxout_global_decl,           /* global_decl */
374   debug_nothing_tree,           /* deferred_inline_function */
375   debug_nothing_tree,           /* outlining_inline_function */
376   debug_nothing_rtx,            /* label */
377   dbxout_handle_pch             /* handle_pch */
378 };
379 #endif /* DBX_DEBUGGING_INFO  */
380
381 #if defined (XCOFF_DEBUGGING_INFO)
382 const struct gcc_debug_hooks xcoff_debug_hooks =
383 {
384   dbxout_init,
385   dbxout_finish,
386   debug_nothing_int_charstar,
387   debug_nothing_int_charstar,
388   dbxout_start_source_file,
389   dbxout_end_source_file,
390   xcoffout_begin_block,
391   xcoffout_end_block,
392   debug_true_tree,              /* ignore_block */
393   xcoffout_source_line,
394   xcoffout_begin_prologue,      /* begin_prologue */
395   debug_nothing_int_charstar,   /* end_prologue */
396   xcoffout_end_epilogue,
397   debug_nothing_tree,           /* begin_function */
398   xcoffout_end_function,
399   debug_nothing_tree,           /* function_decl */
400   dbxout_global_decl,           /* global_decl */
401   debug_nothing_tree,           /* deferred_inline_function */
402   debug_nothing_tree,           /* outlining_inline_function */
403   debug_nothing_rtx,            /* label */
404   dbxout_handle_pch             /* handle_pch */
405 };
406 #endif /* XCOFF_DEBUGGING_INFO  */
407 \f
408 #if defined (DBX_DEBUGGING_INFO)
409 static void
410 dbxout_function_end (void)
411 {
412   char lscope_label_name[100];
413   /* Convert Ltext into the appropriate format for local labels in case
414      the system doesn't insert underscores in front of user generated
415      labels.  */
416   ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
417   (*targetm.asm_out.internal_label) (asmfile, "Lscope", scope_labelno);
418   scope_labelno++;
419
420   /* By convention, GCC will mark the end of a function with an N_FUN
421      symbol and an empty string.  */
422 #ifdef DBX_OUTPUT_NFUN
423   DBX_OUTPUT_NFUN (asmfile, lscope_label_name, current_function_decl);
424 #else
425   fprintf (asmfile, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN);
426   assemble_name (asmfile, lscope_label_name);
427   putc ('-', asmfile);
428   assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
429   fprintf (asmfile, "\n");
430 #endif
431 }
432 #endif /* DBX_DEBUGGING_INFO */
433
434 /* At the beginning of compilation, start writing the symbol table.
435    Initialize `typevec' and output the standard data types of C.  */
436
437 static void
438 dbxout_init (const char *input_file_name)
439 {
440   char ltext_label_name[100];
441   tree syms = (*lang_hooks.decls.getdecls) ();
442
443   asmfile = asm_out_file;
444
445   typevec_len = 100;
446   typevec = (struct typeinfo *) ggc_calloc (typevec_len, sizeof typevec[0]);
447
448   /* Convert Ltext into the appropriate format for local labels in case
449      the system doesn't insert underscores in front of user generated
450      labels.  */
451   ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
452
453   /* Put the current working directory in an N_SO symbol.  */
454   if (use_gnu_debug_info_extensions)
455     {
456       if (!cwd && (cwd = getpwd ()) && (!*cwd || cwd[strlen (cwd) - 1] != '/'))
457         cwd = concat (cwd, FILE_NAME_JOINER, NULL);
458       if (cwd)
459         {
460 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
461           DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
462 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
463           fprintf (asmfile, "%s", ASM_STABS_OP);
464           output_quoted_string (asmfile, cwd);
465           fprintf (asmfile, ",%d,0,0,", N_SO);
466           assemble_name (asmfile, ltext_label_name);
467           fputc ('\n', asmfile);
468 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
469         }
470     }
471
472 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
473   DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
474 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
475   /* We include outputting `Ltext:' here,
476      because that gives you a way to override it.  */
477   /* Used to put `Ltext:' before the reference, but that loses on sun 4.  */
478   fprintf (asmfile, "%s", ASM_STABS_OP);
479   output_quoted_string (asmfile, input_file_name);
480   fprintf (asmfile, ",%d,0,0,", N_SO);
481   assemble_name (asmfile, ltext_label_name);
482   fputc ('\n', asmfile);
483   text_section ();
484   (*targetm.asm_out.internal_label) (asmfile, "Ltext", 0);
485 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
486
487 #ifdef DBX_OUTPUT_GCC_MARKER
488   DBX_OUTPUT_GCC_MARKER (asmfile);
489 #else
490   /* Emit an N_OPT stab to indicate that this file was compiled by GCC.  */
491   fprintf (asmfile, "%s\"%s\",%d,0,0,0\n",
492            ASM_STABS_OP, STABS_GCC_MARKER, N_OPT);
493 #endif
494
495   base_input_file = lastfile = input_file_name;
496
497   next_type_number = 1;
498
499 #ifdef DBX_USE_BINCL
500   current_file = (struct dbx_file *) ggc_alloc (sizeof *current_file);
501   current_file->next = NULL;
502   current_file->file_number = 0;
503   current_file->next_type_number = 1;
504   next_file_number = 1;
505 #endif
506
507   /* Make sure that types `int' and `char' have numbers 1 and 2.
508      Definitions of other integer types will refer to those numbers.
509      (Actually it should no longer matter what their numbers are.
510      Also, if any types with tags have been defined, dbxout_symbol
511      will output them first, so the numbers won't be 1 and 2.  That
512      happens in C++.  So it's a good thing it should no longer matter).  */
513
514 #ifdef DBX_OUTPUT_STANDARD_TYPES
515   DBX_OUTPUT_STANDARD_TYPES (syms);
516 #endif
517
518   /* Get all permanent types that have typedef names,
519      and output them all, except for those already output.  */
520
521   dbxout_typedefs (syms);
522 }
523
524 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
525    in the reverse order from that which is found in SYMS.  */
526
527 static void
528 dbxout_typedefs (tree syms)
529 {
530   if (syms)
531     {
532       dbxout_typedefs (TREE_CHAIN (syms));
533       if (TREE_CODE (syms) == TYPE_DECL)
534         {
535           tree type = TREE_TYPE (syms);
536           if (TYPE_NAME (type)
537               && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
538               && COMPLETE_TYPE_P (type)
539               && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
540             dbxout_symbol (TYPE_NAME (type), 0);
541         }
542     }
543 }
544
545 /* Change to reading from a new source file.  Generate a N_BINCL stab.  */
546
547 static void
548 dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
549                           const char *filename ATTRIBUTE_UNUSED)
550 {
551 #ifdef DBX_USE_BINCL
552   struct dbx_file *n = (struct dbx_file *) ggc_alloc (sizeof *n);
553
554   n->next = current_file;
555   n->file_number = next_file_number++;
556   n->next_type_number = 1;
557   current_file = n;
558   fprintf (asmfile, "%s", ASM_STABS_OP);
559   output_quoted_string (asmfile, filename);
560   fprintf (asmfile, ",%d,0,0,0\n", N_BINCL);
561 #endif
562 }
563
564 /* Revert to reading a previous source file.  Generate a N_EINCL stab.  */
565
566 static void
567 dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED)
568 {
569 #ifdef DBX_USE_BINCL
570   fprintf (asmfile, "%s%d,0,0,0\n", ASM_STABN_OP, N_EINCL);
571   current_file = current_file->next;
572 #endif
573 }
574
575 /* Handle a few odd cases that occur when trying to make PCH files work.  */
576
577 static void
578 dbxout_handle_pch (unsigned at_end)
579 {
580   if (! at_end)
581     {
582       /* When using the PCH, this file will be included, so we need to output
583          a BINCL.  */
584       dbxout_start_source_file (0, lastfile);
585
586       /* The base file when using the PCH won't be the same as
587          the base file when it's being generated.  */
588       lastfile = NULL;
589     }
590   else
591     {
592       /* ... and an EINCL.  */
593       dbxout_end_source_file (0);
594
595       /* Deal with cases where 'lastfile' was never actually changed.  */
596       lastfile_is_base = lastfile == NULL;
597     }
598 }
599
600 #if defined (DBX_DEBUGGING_INFO)
601 /* Output debugging info to FILE to switch to sourcefile FILENAME.  */
602
603 static void
604 dbxout_source_file (FILE *file, const char *filename)
605 {
606   if (lastfile == 0 && lastfile_is_base)
607     {
608       lastfile = base_input_file;
609       lastfile_is_base = 0;
610     }
611
612   if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
613     {
614       char ltext_label_name[100];
615
616       ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
617                                    source_label_number);
618       fprintf (file, "%s", ASM_STABS_OP);
619       output_quoted_string (file, filename);
620       fprintf (asmfile, ",%d,0,0,", N_SOL);
621       assemble_name (asmfile, ltext_label_name);
622       fputc ('\n', asmfile);
623       if (current_function_decl != NULL_TREE
624           && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
625         ; /* Don't change section amid function.  */
626       else
627         text_section ();
628       (*targetm.asm_out.internal_label) (file, "Ltext", source_label_number);
629       source_label_number++;
630       lastfile = filename;
631     }
632 }
633
634 /* Output a line number symbol entry for source file FILENAME and line
635    number LINENO.  */
636
637 static void
638 dbxout_source_line (unsigned int lineno, const char *filename)
639 {
640   dbxout_source_file (asmfile, filename);
641
642 #ifdef ASM_OUTPUT_SOURCE_LINE
643   dbxout_source_line_counter += 1;
644   ASM_OUTPUT_SOURCE_LINE (asmfile, lineno, dbxout_source_line_counter);
645 #else
646   fprintf (asmfile, "%s%d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
647 #endif
648 }
649
650 /* Describe the beginning of an internal block within a function.  */
651
652 static void
653 dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
654 {
655   (*targetm.asm_out.internal_label) (asmfile, "LBB", n);
656 }
657
658 /* Describe the end line-number of an internal block within a function.  */
659
660 static void
661 dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
662 {
663   (*targetm.asm_out.internal_label) (asmfile, "LBE", n);
664 }
665
666 /* Output dbx data for a function definition.
667    This includes a definition of the function name itself (a symbol),
668    definitions of the parameters (locating them in the parameter list)
669    and then output the block that makes up the function's body
670    (including all the auto variables of the function).  */
671
672 static void
673 dbxout_function_decl (tree decl)
674 {
675 #ifndef DBX_FUNCTION_FIRST
676   dbxout_begin_function (decl);
677 #endif
678   dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
679 #ifdef DBX_OUTPUT_FUNCTION_END
680   DBX_OUTPUT_FUNCTION_END (asmfile, decl);
681 #endif
682   if (use_gnu_debug_info_extensions
683 #if defined(NO_DBX_FUNCTION_END)
684       && ! NO_DBX_FUNCTION_END
685 #endif
686       && targetm.have_named_sections)
687     dbxout_function_end ();
688 }
689
690 #endif /* DBX_DEBUGGING_INFO  */
691
692 /* Debug information for a global DECL.  Called from toplev.c after
693    compilation proper has finished.  */
694 static void
695 dbxout_global_decl (tree decl)
696 {
697   if (TREE_CODE (decl) == VAR_DECL
698       && ! DECL_EXTERNAL (decl)
699       && DECL_RTL_SET_P (decl)) /* Not necessary?  */
700     {
701       int saved_tree_used = TREE_USED (decl);
702       TREE_USED (decl) = 1;
703       dbxout_symbol (decl, 0);
704       TREE_USED (decl) = saved_tree_used;
705     }
706 }
707
708 /* At the end of compilation, finish writing the symbol table.
709    Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
710    to do nothing.  */
711
712 static void
713 dbxout_finish (const char *filename ATTRIBUTE_UNUSED)
714 {
715 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
716   DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile, filename);
717 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
718
719   debug_free_queue ();
720 }
721
722 /* Output floating point type values used by the 'R' stab letter.
723    These numbers come from include/aout/stab_gnu.h in binutils/gdb.
724
725    There are only 3 real/complex types defined, and we need 7/6.
726    We use NF_SINGLE as a generic float type, and NF_COMPLEX as a generic
727    complex type.  Since we have the type size anyways, we don't really need
728    to distinguish between different FP types, we only need to distinguish
729    between float and complex.  This works fine with gdb.
730
731    We only use this for complex types, to avoid breaking backwards
732    compatibility for real types.  complex types aren't in ISO C90, so it is
733    OK if old debuggers don't understand the debug info we emit for them.  */
734
735 /* ??? These are supposed to be IEEE types, but we don't check for that.
736    We could perhaps add additional numbers for non-IEEE types if we need
737    them.  */
738
739 static void
740 dbxout_fptype_value (tree type)
741 {
742   char value = '0';
743   enum machine_mode mode = TYPE_MODE (type);
744
745   if (TREE_CODE (type) == REAL_TYPE)
746     {
747       if (mode == SFmode)
748         value = '1';
749       else if (mode == DFmode)
750         value = '2';
751       else if (mode == TFmode || mode == XFmode)
752         value = '6';
753       else
754         /* Use NF_SINGLE as a generic real type for other sizes.  */
755         value = '1';
756     }
757   else if (TREE_CODE (type) == COMPLEX_TYPE)
758     {
759       if (mode == SCmode)
760         value = '3';
761       else if (mode == DCmode)
762         value = '4';
763       else if (mode == TCmode || mode == XCmode)
764         value = '5';
765       else
766         /* Use NF_COMPLEX as a generic complex type for other sizes.  */
767         value = '3';
768     }
769   else
770     abort ();
771
772   putc (value, asmfile);
773   CHARS (1);
774 }
775
776 /* Output the index of a type.  */
777
778 static void
779 dbxout_type_index (tree type)
780 {
781 #ifndef DBX_USE_BINCL
782   fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
783   CHARS (3);
784 #else
785   struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
786   fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number);
787   CHARS (9);
788 #endif
789 }
790
791 #if DBX_CONTIN_LENGTH > 0
792 /* Continue a symbol-description that gets too big.
793    End one symbol table entry with a double-backslash
794    and start a new one, eventually producing something like
795    .stabs "start......\\",code,0,value
796    .stabs "...rest",code,0,value   */
797
798 static void
799 dbxout_continue (void)
800 {
801 #ifdef DBX_CONTIN_CHAR
802   fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
803 #else
804   fprintf (asmfile, "\\\\");
805 #endif
806   dbxout_finish_symbol (NULL_TREE);
807   fprintf (asmfile, "%s\"", ASM_STABS_OP);
808   current_sym_nchars = 0;
809 }
810 #endif /* DBX_CONTIN_LENGTH > 0 */
811 \f
812 /* Subroutine of `dbxout_type'.  Output the type fields of TYPE.
813    This must be a separate function because anonymous unions require
814    recursive calls.  */
815
816 static void
817 dbxout_type_fields (tree type)
818 {
819   tree tem;
820
821   /* Output the name, type, position (in bits), size (in bits) of each
822      field that we can support.  */
823   for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
824     {
825       /* Omit here local type decls until we know how to support them.  */
826       if (TREE_CODE (tem) == TYPE_DECL
827           /* Omit fields whose position or size are variable or too large to
828              represent.  */
829           || (TREE_CODE (tem) == FIELD_DECL
830               && (! host_integerp (bit_position (tem), 0)
831                   || ! DECL_SIZE (tem)
832                   || ! host_integerp (DECL_SIZE (tem), 1)))
833           /* Omit here the nameless fields that are used to skip bits.  */
834            || DECL_IGNORED_P (tem))
835         continue;
836
837       else if (TREE_CODE (tem) != CONST_DECL)
838         {
839           /* Continue the line if necessary,
840              but not before the first field.  */
841           if (tem != TYPE_FIELDS (type))
842             CONTIN;
843
844           if (DECL_NAME (tem))
845             {
846               fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
847               CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
848             }
849           else
850             {
851               fprintf (asmfile, ":");
852               CHARS (1);
853             }
854
855           if (use_gnu_debug_info_extensions
856               && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
857                   || TREE_CODE (tem) != FIELD_DECL))
858             {
859               have_used_extensions = 1;
860               putc ('/', asmfile);
861               putc ((TREE_PRIVATE (tem) ? '0'
862                      : TREE_PROTECTED (tem) ? '1' : '2'),
863                     asmfile);
864               CHARS (2);
865             }
866
867           dbxout_type ((TREE_CODE (tem) == FIELD_DECL
868                         && DECL_BIT_FIELD_TYPE (tem))
869                        ? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0);
870
871           if (TREE_CODE (tem) == VAR_DECL)
872             {
873               if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
874                 {
875                   tree name = DECL_ASSEMBLER_NAME (tem);
876
877                   have_used_extensions = 1;
878                   fprintf (asmfile, ":%s;", IDENTIFIER_POINTER (name));
879                   CHARS (IDENTIFIER_LENGTH (name) + 2);
880                 }
881               else
882                 {
883                   /* If TEM is non-static, GDB won't understand it.  */
884                   fprintf (asmfile, ",0,0;");
885                   CHARS (5);
886                 }
887             }
888           else
889             {
890               putc (',', asmfile);
891               print_wide_int (int_bit_position (tem));
892               putc (',', asmfile);
893               print_wide_int (tree_low_cst (DECL_SIZE (tem), 1));
894               putc (';', asmfile);
895               CHARS (3);
896             }
897         }
898     }
899 }
900 \f
901 /* Subroutine of `dbxout_type_methods'.  Output debug info about the
902    method described DECL.  DEBUG_NAME is an encoding of the method's
903    type signature.  ??? We may be able to do without DEBUG_NAME altogether
904    now.  */
905
906 static void
907 dbxout_type_method_1 (tree decl, const char *debug_name)
908 {
909   char c1 = 'A', c2;
910
911   if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
912     c2 = '?';
913   else /* it's a METHOD_TYPE.  */
914     {
915       tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
916       /* A for normal functions.
917          B for `const' member functions.
918          C for `volatile' member functions.
919          D for `const volatile' member functions.  */
920       if (TYPE_READONLY (TREE_TYPE (firstarg)))
921         c1 += 1;
922       if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
923         c1 += 2;
924
925       if (DECL_VINDEX (decl))
926         c2 = '*';
927       else
928         c2 = '.';
929     }
930
931   fprintf (asmfile, ":%s;%c%c%c", debug_name,
932            TREE_PRIVATE (decl) ? '0'
933            : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
934   CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
935          - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
936
937   if (DECL_VINDEX (decl) && host_integerp (DECL_VINDEX (decl), 0))
938     {
939       print_wide_int (tree_low_cst (DECL_VINDEX (decl), 0));
940       putc (';', asmfile);
941       CHARS (1);
942       dbxout_type (DECL_CONTEXT (decl), 0);
943       fprintf (asmfile, ";");
944       CHARS (1);
945     }
946 }
947 \f
948 /* Subroutine of `dbxout_type'.  Output debug info about the methods defined
949    in TYPE.  */
950
951 static void
952 dbxout_type_methods (tree type)
953 {
954   /* C++: put out the method names and their parameter lists */
955   tree methods = TYPE_METHODS (type);
956   tree type_encoding;
957   tree fndecl;
958   tree last;
959   char formatted_type_identifier_length[16];
960   int type_identifier_length;
961
962   if (methods == NULL_TREE)
963     return;
964
965   type_encoding = DECL_NAME (TYPE_NAME (type));
966
967 #if 0
968   /* C++: Template classes break some assumptions made by this code about
969      the class names, constructor names, and encodings for assembler
970      label names.  For now, disable output of dbx info for them.  */
971   {
972     const char *ptr = IDENTIFIER_POINTER (type_encoding);
973     /* This should use index.  (mrs) */
974     while (*ptr && *ptr != '<') ptr++;
975     if (*ptr != 0)
976       {
977         static int warned;
978         if (!warned)
979             warned = 1;
980         return;
981       }
982   }
983 #endif
984
985   type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
986
987   sprintf (formatted_type_identifier_length, "%d", type_identifier_length);
988
989   if (TREE_CODE (methods) != TREE_VEC)
990     fndecl = methods;
991   else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
992     fndecl = TREE_VEC_ELT (methods, 0);
993   else
994     fndecl = TREE_VEC_ELT (methods, 1);
995
996   while (fndecl)
997     {
998       int need_prefix = 1;
999
1000       /* Group together all the methods for the same operation.
1001          These differ in the types of the arguments.  */
1002       for (last = NULL_TREE;
1003            fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
1004            fndecl = TREE_CHAIN (fndecl))
1005         /* Output the name of the field (after overloading), as
1006            well as the name of the field before overloading, along
1007            with its parameter list */
1008         {
1009           /* This is the "mangled" name of the method.
1010              It encodes the argument types.  */
1011           const char *debug_name;
1012
1013           /* Skip methods that aren't FUNCTION_DECLs.  (In C++, these
1014              include TEMPLATE_DECLs.)  The debugger doesn't know what
1015              to do with such entities anyhow.  */
1016           if (TREE_CODE (fndecl) != FUNCTION_DECL)
1017             continue;
1018
1019           debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
1020
1021           CONTIN;
1022
1023           last = fndecl;
1024
1025           /* Also ignore abstract methods; those are only interesting to
1026              the DWARF backends.  */
1027           if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT (fndecl))
1028             continue;
1029
1030           /* Redundantly output the plain name, since that's what gdb
1031              expects.  */
1032           if (need_prefix)
1033             {
1034               tree name = DECL_NAME (fndecl);
1035               fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
1036               CHARS (IDENTIFIER_LENGTH (name) + 2);
1037               need_prefix = 0;
1038             }
1039
1040           dbxout_type (TREE_TYPE (fndecl), 0);
1041
1042           dbxout_type_method_1 (fndecl, debug_name);
1043         }
1044       if (!need_prefix)
1045         {
1046           putc (';', asmfile);
1047           CHARS (1);
1048         }
1049     }
1050 }
1051
1052 /* Emit a "range" type specification, which has the form:
1053    "r<index type>;<lower bound>;<upper bound>;".
1054    TYPE is an INTEGER_TYPE.  */
1055
1056 static void
1057 dbxout_range_type (tree type)
1058 {
1059   fprintf (asmfile, "r");
1060   if (TREE_TYPE (type))
1061     dbxout_type (TREE_TYPE (type), 0);
1062   else if (TREE_CODE (type) != INTEGER_TYPE)
1063     dbxout_type (type, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1064   else
1065     {
1066       /* Traditionally, we made sure 'int' was type 1, and builtin types
1067          were defined to be sub-ranges of int.  Unfortunately, this
1068          does not allow us to distinguish true sub-ranges from integer
1069          types.  So, instead we define integer (non-sub-range) types as
1070          sub-ranges of themselves.  This matters for Chill.  If this isn't
1071          a subrange type, then we want to define it in terms of itself.
1072          However, in C, this may be an anonymous integer type, and we don't
1073          want to emit debug info referring to it.  Just calling
1074          dbxout_type_index won't work anyways, because the type hasn't been
1075          defined yet.  We make this work for both cases by checked to see
1076          whether this is a defined type, referring to it if it is, and using
1077          'int' otherwise.  */
1078       if (TYPE_SYMTAB_ADDRESS (type) != 0)
1079         dbxout_type_index (type);
1080       else
1081         dbxout_type_index (integer_type_node);
1082     }
1083
1084   if (TYPE_MIN_VALUE (type) != 0
1085       && host_integerp (TYPE_MIN_VALUE (type), 0))
1086     {
1087       putc (';', asmfile);
1088       CHARS (1);
1089       if (print_int_cst_bounds_in_octal_p (type))
1090         print_int_cst_octal (TYPE_MIN_VALUE (type));
1091       else
1092         print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type), 0));
1093     }
1094   else
1095     {
1096       fprintf (asmfile, ";0");
1097       CHARS (2);
1098     }
1099
1100   if (TYPE_MAX_VALUE (type) != 0
1101       && host_integerp (TYPE_MAX_VALUE (type), 0))
1102     {
1103       putc (';', asmfile);
1104       CHARS (1);
1105       if (print_int_cst_bounds_in_octal_p (type))
1106         print_int_cst_octal (TYPE_MAX_VALUE (type));
1107       else
1108         print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type), 0));
1109       putc (';', asmfile);
1110       CHARS (1);
1111     }
1112   else
1113     {
1114       fprintf (asmfile, ";-1;");
1115       CHARS (4);
1116     }
1117 }
1118 \f
1119
1120 /* Output a reference to a type.  If the type has not yet been
1121    described in the dbx output, output its definition now.
1122    For a type already defined, just refer to its definition
1123    using the type number.
1124
1125    If FULL is nonzero, and the type has been described only with
1126    a forward-reference, output the definition now.
1127    If FULL is zero in this case, just refer to the forward-reference
1128    using the number previously allocated.  */
1129
1130 static void
1131 dbxout_type (tree type, int full)
1132 {
1133   tree tem;
1134   tree main_variant;
1135   static int anonymous_type_number = 0;
1136
1137   if (TREE_CODE (type) == VECTOR_TYPE)
1138     /* The frontend feeds us a representation for the vector as a struct
1139        containing an array.  Pull out the array type.  */
1140     type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type)));
1141
1142   /* If there was an input error and we don't really have a type,
1143      avoid crashing and write something that is at least valid
1144      by assuming `int'.  */
1145   if (type == error_mark_node)
1146     type = integer_type_node;
1147   else
1148     {
1149       if (TYPE_NAME (type)
1150           && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1151           && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1152         full = 0;
1153     }
1154
1155   /* Try to find the "main variant" with the same name.  */
1156   if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1157       && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1158     main_variant = TREE_TYPE (TYPE_NAME (type));
1159   else
1160     main_variant = TYPE_MAIN_VARIANT (type);
1161
1162   /* If we are not using extensions, stabs does not distinguish const and
1163      volatile, so there is no need to make them separate types.  */
1164   if (!use_gnu_debug_info_extensions)
1165     type = main_variant;
1166
1167   if (TYPE_SYMTAB_ADDRESS (type) == 0)
1168     {
1169       /* Type has no dbx number assigned.  Assign next available number.  */
1170       TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1171
1172       /* Make sure type vector is long enough to record about this type.  */
1173
1174       if (next_type_number == typevec_len)
1175         {
1176           typevec
1177             = (struct typeinfo *) ggc_realloc (typevec,
1178                                                (typevec_len * 2
1179                                                 * sizeof typevec[0]));
1180           memset ((char *) (typevec + typevec_len), 0,
1181                  typevec_len * sizeof typevec[0]);
1182           typevec_len *= 2;
1183         }
1184
1185 #ifdef DBX_USE_BINCL
1186       typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1187         = current_file->file_number;
1188       typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1189         = current_file->next_type_number++;
1190 #endif
1191     }
1192
1193   if (flag_debug_only_used_symbols)
1194     {
1195       if ((TREE_CODE (type) == RECORD_TYPE
1196            || TREE_CODE (type) == UNION_TYPE
1197            || TREE_CODE (type) == QUAL_UNION_TYPE
1198            || TREE_CODE (type) == ENUMERAL_TYPE)
1199           && TYPE_STUB_DECL (type)
1200           && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (type))) == 'd'
1201           && ! DECL_IGNORED_P (TYPE_STUB_DECL (type)))
1202         debug_queue_symbol (TYPE_STUB_DECL (type));
1203       else if (TYPE_NAME (type)
1204                && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1205         debug_queue_symbol (TYPE_NAME (type));
1206     }
1207
1208   /* Output the number of this type, to refer to it.  */
1209   dbxout_type_index (type);
1210
1211 #ifdef DBX_TYPE_DEFINED
1212   if (DBX_TYPE_DEFINED (type))
1213     return;
1214 #endif
1215
1216   /* If this type's definition has been output or is now being output,
1217      that is all.  */
1218
1219   switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1220     {
1221     case TYPE_UNSEEN:
1222       break;
1223     case TYPE_XREF:
1224       /* If we have already had a cross reference,
1225          and either that's all we want or that's the best we could do,
1226          don't repeat the cross reference.
1227          Sun dbx crashes if we do.  */
1228       if (! full || !COMPLETE_TYPE_P (type)
1229           /* No way in DBX fmt to describe a variable size.  */
1230           || ! host_integerp (TYPE_SIZE (type), 1))
1231         return;
1232       break;
1233     case TYPE_DEFINED:
1234       return;
1235     }
1236
1237 #ifdef DBX_NO_XREFS
1238   /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1239      leave the type-number completely undefined rather than output
1240      a cross-reference.  If we have already used GNU debug info extensions,
1241      then it is OK to output a cross reference.  This is necessary to get
1242      proper C++ debug output.  */
1243   if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1244        || TREE_CODE (type) == QUAL_UNION_TYPE
1245        || TREE_CODE (type) == ENUMERAL_TYPE)
1246       && ! use_gnu_debug_info_extensions)
1247     /* We must use the same test here as we use twice below when deciding
1248        whether to emit a cross-reference.  */
1249     if ((TYPE_NAME (type) != 0
1250          && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1251                && DECL_IGNORED_P (TYPE_NAME (type)))
1252          && !full)
1253         || !COMPLETE_TYPE_P (type)
1254         /* No way in DBX fmt to describe a variable size.  */
1255         || ! host_integerp (TYPE_SIZE (type), 1))
1256       {
1257         typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1258         return;
1259       }
1260 #endif
1261
1262   /* Output a definition now.  */
1263
1264   fprintf (asmfile, "=");
1265   CHARS (1);
1266
1267   /* Mark it as defined, so that if it is self-referent
1268      we will not get into an infinite recursion of definitions.  */
1269
1270   typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1271
1272   /* If this type is a variant of some other, hand off.  Types with
1273      different names are usefully distinguished.  We only distinguish
1274      cv-qualified types if we're using extensions.  */
1275   if (TYPE_READONLY (type) > TYPE_READONLY (main_variant))
1276     {
1277       putc ('k', asmfile);
1278       CHARS (1);
1279       dbxout_type (build_type_variant (type, 0, TYPE_VOLATILE (type)), 0);
1280       return;
1281     }
1282   else if (TYPE_VOLATILE (type) > TYPE_VOLATILE (main_variant))
1283     {
1284       putc ('B', asmfile);
1285       CHARS (1);
1286       dbxout_type (build_type_variant (type, TYPE_READONLY (type), 0), 0);
1287       return;
1288     }
1289   else if (main_variant != TYPE_MAIN_VARIANT (type))
1290     {
1291       if (flag_debug_only_used_symbols)
1292         {
1293           tree orig_type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
1294
1295           if ((TREE_CODE (orig_type) == RECORD_TYPE
1296                || TREE_CODE (orig_type) == UNION_TYPE
1297                || TREE_CODE (orig_type) == QUAL_UNION_TYPE
1298                || TREE_CODE (orig_type) == ENUMERAL_TYPE)
1299               && TYPE_STUB_DECL (orig_type)
1300               && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type)))
1301             debug_queue_symbol (TYPE_STUB_DECL (orig_type));
1302         }
1303       /* 'type' is a typedef; output the type it refers to.  */
1304       dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0);
1305       return;
1306     }
1307   /* else continue.  */
1308
1309   switch (TREE_CODE (type))
1310     {
1311     case VOID_TYPE:
1312     case LANG_TYPE:
1313       /* For a void type, just define it as itself; ie, "5=5".
1314          This makes us consider it defined
1315          without saying what it is.  The debugger will make it
1316          a void type when the reference is seen, and nothing will
1317          ever override that default.  */
1318       dbxout_type_index (type);
1319       break;
1320
1321     case INTEGER_TYPE:
1322       if (type == char_type_node && ! TREE_UNSIGNED (type))
1323         {
1324           /* Output the type `char' as a subrange of itself!
1325              I don't understand this definition, just copied it
1326              from the output of pcc.
1327              This used to use `r2' explicitly and we used to
1328              take care to make sure that `char' was type number 2.  */
1329           fprintf (asmfile, "r");
1330           CHARS (1);
1331           dbxout_type_index (type);
1332           fprintf (asmfile, ";0;127;");
1333           CHARS (7);
1334         }
1335
1336       /* If this is a subtype of another integer type, always prefer to
1337          write it as a subtype.  */
1338       else if (TREE_TYPE (type) != 0
1339                && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
1340         {
1341           /* If the size is non-standard, say what it is if we can use
1342              GDB extensions.  */
1343
1344           if (use_gnu_debug_info_extensions
1345               && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1346             {
1347               have_used_extensions = 1;
1348               fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1349               CHARS (5);
1350             }
1351
1352           dbxout_range_type (type);
1353         }
1354
1355       else
1356         {
1357           /* If the size is non-standard, say what it is if we can use
1358              GDB extensions.  */
1359
1360           if (use_gnu_debug_info_extensions
1361               && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1362             {
1363               have_used_extensions = 1;
1364               fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1365               CHARS (5);
1366             }
1367
1368           if (print_int_cst_bounds_in_octal_p (type))
1369             {
1370               fprintf (asmfile, "r");
1371               CHARS (1);
1372
1373               /* If this type derives from another type, output type index of
1374                  parent type. This is particularly important when parent type
1375                  is an enumerated type, because not generating the parent type
1376                  index would transform the definition of this enumerated type
1377                  into a plain unsigned type.  */
1378               if (TREE_TYPE (type) != 0)
1379                 dbxout_type_index (TREE_TYPE (type));
1380               else
1381                 dbxout_type_index (type);
1382
1383               fprintf (asmfile, ";");
1384               CHARS (1);
1385               print_int_cst_octal (TYPE_MIN_VALUE (type));
1386               fprintf (asmfile, ";");
1387               CHARS (1);
1388               print_int_cst_octal (TYPE_MAX_VALUE (type));
1389               fprintf (asmfile, ";");
1390               CHARS (1);
1391             }
1392
1393           else
1394             /* Output other integer types as subranges of `int'.  */
1395             dbxout_range_type (type);
1396         }
1397
1398       break;
1399
1400     case REAL_TYPE:
1401       /* This used to say `r1' and we used to take care
1402          to make sure that `int' was type number 1.  */
1403       fprintf (asmfile, "r");
1404       CHARS (1);
1405       dbxout_type_index (integer_type_node);
1406       putc (';', asmfile);
1407       CHARS (1);
1408       print_wide_int (int_size_in_bytes (type));
1409       fputs (";0;", asmfile);
1410       CHARS (3);
1411       break;
1412
1413     case CHAR_TYPE:
1414       if (use_gnu_debug_info_extensions)
1415         {
1416           have_used_extensions = 1;
1417           fputs ("@s", asmfile);
1418           CHARS (2);
1419           print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1420           fputs (";-20;", asmfile);
1421           CHARS (4);
1422         }
1423       else
1424         {
1425           /* Output the type `char' as a subrange of itself.
1426              That is what pcc seems to do.  */
1427           fprintf (asmfile, "r");
1428           CHARS (1);
1429           dbxout_type_index (char_type_node);
1430           fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1431           CHARS (7);
1432         }
1433       break;
1434
1435     case BOOLEAN_TYPE:
1436       if (use_gnu_debug_info_extensions)
1437         {
1438           have_used_extensions = 1;
1439           fputs ("@s", asmfile);
1440           CHARS (2);
1441           print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1442           fputs (";-16;", asmfile);
1443           CHARS (4);
1444         }
1445       else /* Define as enumeral type (False, True) */
1446         {
1447           fprintf (asmfile, "eFalse:0,True:1,;");
1448           CHARS (17);
1449         }
1450       break;
1451
1452     case FILE_TYPE:
1453       putc ('d', asmfile);
1454       CHARS (1);
1455       dbxout_type (TREE_TYPE (type), 0);
1456       break;
1457
1458     case COMPLEX_TYPE:
1459       /* Differs from the REAL_TYPE by its new data type number */
1460
1461       if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1462         {
1463           putc ('R', asmfile);
1464           CHARS (1);
1465           dbxout_fptype_value (type);
1466           putc (';', asmfile);
1467           CHARS (1);
1468           print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type)));
1469           fputs (";0;", asmfile);
1470           CHARS (3);
1471         }
1472       else
1473         {
1474           /* Output a complex integer type as a structure,
1475              pending some other way to do it.  */
1476           putc ('s', asmfile);
1477           CHARS (1);
1478           print_wide_int (int_size_in_bytes (type));
1479           fprintf (asmfile, "real:");
1480           CHARS (5);
1481
1482           dbxout_type (TREE_TYPE (type), 0);
1483           fprintf (asmfile, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type)));
1484           CHARS (7);
1485           fprintf (asmfile, "imag:");
1486           CHARS (5);
1487           dbxout_type (TREE_TYPE (type), 0);
1488           fprintf (asmfile, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type)),
1489                    TYPE_PRECISION (TREE_TYPE (type)));
1490           CHARS (10);
1491         }
1492       break;
1493
1494     case SET_TYPE:
1495       if (use_gnu_debug_info_extensions)
1496         {
1497           have_used_extensions = 1;
1498           fputs ("@s", asmfile);
1499           CHARS (2);
1500           print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1501           putc (';', asmfile);
1502           CHARS (1);
1503
1504           /* Check if a bitstring type, which in Chill is
1505              different from a [power]set.  */
1506           if (TYPE_STRING_FLAG (type))
1507             {
1508               fprintf (asmfile, "@S;");
1509               CHARS (3);
1510             }
1511         }
1512       putc ('S', asmfile);
1513       CHARS (1);
1514       dbxout_type (TYPE_DOMAIN (type), 0);
1515       break;
1516
1517     case ARRAY_TYPE:
1518       /* Make arrays of packed bits look like bitstrings for chill.  */
1519       if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
1520         {
1521           have_used_extensions = 1;
1522           fputs ("@s", asmfile);
1523           CHARS (2);
1524           print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1525           fprintf (asmfile, ";@S;S");
1526           CHARS (5);
1527           dbxout_type (TYPE_DOMAIN (type), 0);
1528           break;
1529         }
1530
1531       /* Output "a" followed by a range type definition
1532          for the index type of the array
1533          followed by a reference to the target-type.
1534          ar1;0;N;M for a C array of type M and size N+1.  */
1535       /* Check if a character string type, which in Chill is
1536          different from an array of characters.  */
1537       if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1538         {
1539           have_used_extensions = 1;
1540           fprintf (asmfile, "@S;");
1541           CHARS (3);
1542         }
1543       tem = TYPE_DOMAIN (type);
1544       if (tem == NULL)
1545         {
1546           fprintf (asmfile, "ar");
1547           CHARS (2);
1548           dbxout_type_index (integer_type_node);
1549           fprintf (asmfile, ";0;-1;");
1550           CHARS (6);
1551         }
1552       else
1553         {
1554           fprintf (asmfile, "a");
1555           CHARS (1);
1556           dbxout_range_type (tem);
1557         }
1558
1559       dbxout_type (TREE_TYPE (type), 0);
1560       break;
1561
1562     case RECORD_TYPE:
1563     case UNION_TYPE:
1564     case QUAL_UNION_TYPE:
1565       {
1566         int i, n_baseclasses = 0;
1567
1568         if (TYPE_BINFO (type) != 0
1569             && TREE_CODE (TYPE_BINFO (type)) == TREE_VEC
1570             && TYPE_BINFO_BASETYPES (type) != 0)
1571           n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1572
1573         /* Output a structure type.  We must use the same test here as we
1574            use in the DBX_NO_XREFS case above.  */
1575         if ((TYPE_NAME (type) != 0
1576              && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1577                    && DECL_IGNORED_P (TYPE_NAME (type)))
1578              && !full)
1579             || !COMPLETE_TYPE_P (type)
1580             /* No way in DBX fmt to describe a variable size.  */
1581             || ! host_integerp (TYPE_SIZE (type), 1))
1582           {
1583             /* If the type is just a cross reference, output one
1584                and mark the type as partially described.
1585                If it later becomes defined, we will output
1586                its real definition.
1587                If the type has a name, don't nest its definition within
1588                another type's definition; instead, output an xref
1589                and let the definition come when the name is defined.  */
1590             fputs ((TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu", asmfile);
1591             CHARS (2);
1592 #if 0 /* This assertion is legitimately false in C++.  */
1593             /* We shouldn't be outputting a reference to a type before its
1594                definition unless the type has a tag name.
1595                A typedef name without a tag name should be impossible.  */
1596             if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1597               abort ();
1598 #endif
1599             if (TYPE_NAME (type) != 0)
1600               dbxout_type_name (type);
1601             else
1602               {
1603                 fprintf (asmfile, "$$%d", anonymous_type_number++);
1604                 CHARS (5);
1605               }
1606
1607             fprintf (asmfile, ":");
1608             CHARS (1);
1609             typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1610             break;
1611           }
1612
1613         /* Identify record or union, and print its size.  */
1614         putc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asmfile);
1615         CHARS (1);
1616         print_wide_int (int_size_in_bytes (type));
1617
1618         if (use_gnu_debug_info_extensions)
1619           {
1620             if (n_baseclasses)
1621               {
1622                 have_used_extensions = 1;
1623                 fprintf (asmfile, "!%d,", n_baseclasses);
1624                 CHARS (8);
1625               }
1626           }
1627         for (i = 0; i < n_baseclasses; i++)
1628           {
1629             tree binfo = TYPE_BINFO (type);
1630             tree child = BINFO_BASETYPE (binfo, i);
1631             tree access = (BINFO_BASEACCESSES (binfo)
1632                            ? BINFO_BASEACCESS (binfo, i) : access_public_node);
1633
1634             if (use_gnu_debug_info_extensions)
1635               {
1636                 have_used_extensions = 1;
1637                 putc (TREE_VIA_VIRTUAL (child) ? '1' : '0', asmfile);
1638                 putc (access == access_public_node ? '2' : '0', asmfile);
1639                 CHARS (2);
1640                 if (TREE_VIA_VIRTUAL (child)
1641                     && strcmp (lang_hooks.name, "GNU C++") == 0)
1642                   /* For a virtual base, print the (negative) offset within
1643                      the vtable where we must look to find the necessary
1644                      adjustment.  */
1645                   print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child), 0)
1646                                   * BITS_PER_UNIT);
1647                 else
1648                   print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1649                                   * BITS_PER_UNIT);
1650                 putc (',', asmfile);
1651                 CHARS (1);
1652                 dbxout_type (BINFO_TYPE (child), 0);
1653                 putc (';', asmfile);
1654                 CHARS (1);
1655               }
1656             else
1657               {
1658                 /* Print out the base class information with fields
1659                    which have the same names at the types they hold.  */
1660                 dbxout_type_name (BINFO_TYPE (child));
1661                 putc (':', asmfile);
1662                 CHARS (1);
1663                 dbxout_type (BINFO_TYPE (child), full);
1664                 putc (',', asmfile);
1665                 CHARS (1);
1666                 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1667                                 * BITS_PER_UNIT);
1668                 putc (',', asmfile);
1669                 CHARS (1);
1670                 print_wide_int (tree_low_cst (DECL_SIZE
1671                                               (TYPE_NAME
1672                                                (BINFO_TYPE (child))),
1673                                               0)
1674                                 * BITS_PER_UNIT);
1675                 putc (';', asmfile);
1676                 CHARS (1);
1677               }
1678           }
1679       }
1680
1681       /* Write out the field declarations.  */
1682       dbxout_type_fields (type);
1683       if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1684         {
1685           have_used_extensions = 1;
1686           dbxout_type_methods (type);
1687         }
1688
1689       putc (';', asmfile);
1690       CHARS (1);
1691
1692       if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1693           /* Avoid the ~ if we don't really need it--it confuses dbx.  */
1694           && TYPE_VFIELD (type))
1695         {
1696           have_used_extensions = 1;
1697
1698           /* Tell GDB+ that it may keep reading.  */
1699           putc ('~', asmfile);
1700           CHARS (1);
1701
1702           /* We need to write out info about what field this class
1703              uses as its "main" vtable pointer field, because if this
1704              field is inherited from a base class, GDB cannot necessarily
1705              figure out which field it's using in time.  */
1706           if (TYPE_VFIELD (type))
1707             {
1708               putc ('%', asmfile);
1709               CHARS (1);
1710               dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0);
1711             }
1712
1713           putc (';', asmfile);
1714           CHARS (1);
1715         }
1716       break;
1717
1718     case ENUMERAL_TYPE:
1719       /* We must use the same test here as we use in the DBX_NO_XREFS case
1720          above.  We simplify it a bit since an enum will never have a variable
1721          size.  */
1722       if ((TYPE_NAME (type) != 0
1723            && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1724                  && DECL_IGNORED_P (TYPE_NAME (type)))
1725            && !full)
1726           || !COMPLETE_TYPE_P (type))
1727         {
1728           fprintf (asmfile, "xe");
1729           CHARS (2);
1730           dbxout_type_name (type);
1731           typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1732           putc (':', asmfile);
1733           CHARS (1);
1734           return;
1735         }
1736       if (use_gnu_debug_info_extensions
1737           && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1738         {
1739           fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1740           CHARS (5);
1741         }
1742
1743       putc ('e', asmfile);
1744       CHARS (1);
1745       for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1746         {
1747           fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1748           CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem)) + 1);
1749           if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1750             print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1751           else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1752                    && (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1753             print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1754           else
1755             print_int_cst_octal (TREE_VALUE (tem));
1756
1757           putc (',', asmfile);
1758           CHARS (1);
1759           if (TREE_CHAIN (tem) != 0)
1760             CONTIN;
1761         }
1762
1763       putc (';', asmfile);
1764       CHARS (1);
1765       break;
1766
1767     case POINTER_TYPE:
1768       putc ('*', asmfile);
1769       CHARS (1);
1770       dbxout_type (TREE_TYPE (type), 0);
1771       break;
1772
1773     case METHOD_TYPE:
1774       if (use_gnu_debug_info_extensions)
1775         {
1776           have_used_extensions = 1;
1777           putc ('#', asmfile);
1778           CHARS (1);
1779
1780           /* Write the argument types out longhand.  */
1781           dbxout_type (TYPE_METHOD_BASETYPE (type), 0);
1782           putc (',', asmfile);
1783           CHARS (1);
1784           dbxout_type (TREE_TYPE (type), 0);
1785           dbxout_args (TYPE_ARG_TYPES (type));
1786           putc (';', asmfile);
1787           CHARS (1);
1788         }
1789       else
1790         /* Treat it as a function type.  */
1791         dbxout_type (TREE_TYPE (type), 0);
1792       break;
1793
1794     case OFFSET_TYPE:
1795       if (use_gnu_debug_info_extensions)
1796         {
1797           have_used_extensions = 1;
1798           putc ('@', asmfile);
1799           CHARS (1);
1800           dbxout_type (TYPE_OFFSET_BASETYPE (type), 0);
1801           putc (',', asmfile);
1802           CHARS (1);
1803           dbxout_type (TREE_TYPE (type), 0);
1804         }
1805       else
1806         /* Should print as an int, because it is really just an offset.  */
1807         dbxout_type (integer_type_node, 0);
1808       break;
1809
1810     case REFERENCE_TYPE:
1811       if (use_gnu_debug_info_extensions)
1812         have_used_extensions = 1;
1813       putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1814       CHARS (1);
1815       dbxout_type (TREE_TYPE (type), 0);
1816       break;
1817
1818     case FUNCTION_TYPE:
1819       putc ('f', asmfile);
1820       CHARS (1);
1821       dbxout_type (TREE_TYPE (type), 0);
1822       break;
1823
1824     default:
1825       abort ();
1826     }
1827 }
1828
1829 /* Return nonzero if the given type represents an integer whose bounds
1830    should be printed in octal format.  */
1831
1832 static bool
1833 print_int_cst_bounds_in_octal_p (tree type)
1834 {
1835   /* If we can use GDB extensions and the size is wider than a long
1836      (the size used by GDB to read them) or we may have trouble writing
1837      the bounds the usual way, write them in octal.  Note the test is for
1838      the *target's* size of "long", not that of the host.  The host test
1839      is just to make sure we can write it out in case the host wide int
1840      is narrower than the target "long".
1841
1842      For unsigned types, we use octal if they are the same size or larger.
1843      This is because we print the bounds as signed decimal, and hence they
1844      can't span same size unsigned types.  */
1845
1846   if (use_gnu_debug_info_extensions
1847       && TYPE_MIN_VALUE (type) != 0
1848       && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
1849       && TYPE_MAX_VALUE (type) != 0
1850       && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
1851       && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1852           || ((TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
1853               && TREE_UNSIGNED (type))
1854           || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT
1855           || (TYPE_PRECISION (type) == HOST_BITS_PER_WIDE_INT
1856               && TREE_UNSIGNED (type))))
1857     return TRUE;
1858   else
1859     return FALSE;
1860 }
1861
1862 /* Print the value of integer constant C, in octal,
1863    handling double precision.  */
1864
1865 static void
1866 print_int_cst_octal (tree c)
1867 {
1868   unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1869   unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1870   int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1871   unsigned int width = TYPE_PRECISION (TREE_TYPE (c));
1872
1873   /* GDB wants constants with no extra leading "1" bits, so
1874      we need to remove any sign-extension that might be
1875      present.  */
1876   if (width == HOST_BITS_PER_WIDE_INT * 2)
1877     ;
1878   else if (width > HOST_BITS_PER_WIDE_INT)
1879     high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1880   else if (width == HOST_BITS_PER_WIDE_INT)
1881     high = 0;
1882   else
1883     high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1884
1885   fprintf (asmfile, "0");
1886   CHARS (1);
1887
1888   if (excess == 3)
1889     {
1890       print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1891       print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1892     }
1893   else
1894     {
1895       unsigned HOST_WIDE_INT beg = high >> excess;
1896       unsigned HOST_WIDE_INT middle
1897         = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1898            | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1899       unsigned HOST_WIDE_INT end
1900         = low & (((unsigned HOST_WIDE_INT) 1
1901                   << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1902                  - 1);
1903
1904       fprintf (asmfile, "%o%01o", (int) beg, (int) middle);
1905       CHARS (2);
1906       print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1907     }
1908 }
1909
1910 static void
1911 print_octal (unsigned HOST_WIDE_INT value, int digits)
1912 {
1913   int i;
1914
1915   for (i = digits - 1; i >= 0; i--)
1916     fprintf (asmfile, "%01o", (int) ((value >> (3 * i)) & 7));
1917
1918   CHARS (digits);
1919 }
1920
1921 /* Output C in decimal while adjusting the number of digits written.  */
1922
1923 static void
1924 print_wide_int (HOST_WIDE_INT c)
1925 {
1926   int digs = 0;
1927
1928   fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, c);
1929
1930   if (c < 0)
1931     digs++, c = -c;
1932
1933   while (c > 0)
1934     c /= 10; digs++;
1935
1936   CHARS (digs);
1937 }
1938
1939 /* Output the name of type TYPE, with no punctuation.
1940    Such names can be set up either by typedef declarations
1941    or by struct, enum and union tags.  */
1942
1943 static void
1944 dbxout_type_name (tree type)
1945 {
1946   tree t;
1947   if (TYPE_NAME (type) == 0)
1948     abort ();
1949   if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
1950     {
1951       t = TYPE_NAME (type);
1952     }
1953   else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1954     {
1955       t = DECL_NAME (TYPE_NAME (type));
1956     }
1957   else
1958     abort ();
1959
1960   fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
1961   CHARS (IDENTIFIER_LENGTH (t));
1962 }
1963
1964 /* Output leading leading struct or class names needed for qualifying
1965    type whose scope is limited to a struct or class.  */
1966
1967 static void
1968 dbxout_class_name_qualifiers (tree decl)
1969 {
1970   tree context = decl_type_context (decl);
1971
1972   if (context != NULL_TREE
1973       && TREE_CODE(context) == RECORD_TYPE
1974       && TYPE_NAME (context) != 0
1975       && (TREE_CODE (TYPE_NAME (context)) == IDENTIFIER_NODE
1976           || (DECL_NAME (TYPE_NAME (context)) != 0)))
1977     {
1978       tree name = TYPE_NAME (context);
1979
1980       if (TREE_CODE (name) == TYPE_DECL)
1981         {
1982           dbxout_class_name_qualifiers (name);
1983           name = DECL_NAME (name);
1984         }
1985       fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
1986       CHARS (IDENTIFIER_LENGTH (name) + 2);
1987     }
1988 }
1989 \f
1990 /* Output a .stabs for the symbol defined by DECL,
1991    which must be a ..._DECL node in the normal namespace.
1992    It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1993    LOCAL is nonzero if the scope is less than the entire file.
1994    Return 1 if a stabs might have been emitted.  */
1995
1996 int
1997 dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
1998 {
1999   tree type = TREE_TYPE (decl);
2000   tree context = NULL_TREE;
2001   int result = 0;
2002
2003   /* "Intercept" dbxout_symbol() calls like we do all debug_hooks.  */
2004   ++debug_nesting;
2005
2006   /* Cast avoids warning in old compilers.  */
2007   current_sym_code = (STAB_CODE_TYPE) 0;
2008   current_sym_value = 0;
2009   current_sym_addr = 0;
2010
2011   /* Ignore nameless syms, but don't ignore type tags.  */
2012
2013   if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
2014       || DECL_IGNORED_P (decl))
2015     DBXOUT_DECR_NESTING_AND_RETURN (0);
2016
2017   /* If we are to generate only the symbols actualy used then such
2018      symbol nodees are flagged with TREE_USED.  Ignore any that
2019      aren't flaged as TREE_USED.  */
2020
2021   if (flag_debug_only_used_symbols)
2022     {
2023       tree t;
2024
2025       if (!TREE_USED (decl)
2026           && (TREE_CODE (decl) != VAR_DECL || !DECL_INITIAL (decl)))
2027         DBXOUT_DECR_NESTING_AND_RETURN (0);
2028
2029       /* We now have a used symbol.  We need to generate the info for
2030          the symbol's type in addition to the symbol itself.  These
2031          type symbols are queued to be generated after were done with
2032          the symbol itself (done because the symbol's info is generated
2033          with fprintf's, etc. as it determines what's needed).
2034
2035          Note, because the TREE_TYPE(type) might be something like a
2036          pointer to a named type we need to look for the first name
2037          we see following the TREE_TYPE chain.  */
2038
2039       t = type;
2040       while (POINTER_TYPE_P (t))
2041         t = TREE_TYPE (t);
2042
2043       /* RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE, and ENUMERAL_TYPE
2044          need special treatment.  The TYPE_STUB_DECL field in these
2045          types generally represents the tag name type we want to
2046          output.  In addition there  could be a typedef type with
2047          a different name.  In that case we also want to output
2048          that.  */
2049
2050       if ((TREE_CODE (t) == RECORD_TYPE
2051            || TREE_CODE (t) == UNION_TYPE
2052            || TREE_CODE (t) == QUAL_UNION_TYPE
2053            || TREE_CODE (t) == ENUMERAL_TYPE)
2054           && TYPE_STUB_DECL (t)
2055           && TYPE_STUB_DECL (t) != decl
2056           && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (t))) == 'd'
2057           && ! DECL_IGNORED_P (TYPE_STUB_DECL (t)))
2058         {
2059           debug_queue_symbol (TYPE_STUB_DECL (t));
2060           if (TYPE_NAME (t)
2061               && TYPE_NAME (t) != TYPE_STUB_DECL (t)
2062               && TYPE_NAME (t) != decl
2063               && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t))) == 'd')
2064             debug_queue_symbol (TYPE_NAME (t));
2065         }
2066       else if (TYPE_NAME (t)
2067                && TYPE_NAME (t) != decl
2068                && TREE_CODE_CLASS (TREE_CODE (TYPE_NAME (t))) == 'd')
2069         debug_queue_symbol (TYPE_NAME (t));
2070     }
2071
2072   dbxout_prepare_symbol (decl);
2073
2074   /* The output will always start with the symbol name,
2075      so always count that in the length-output-so-far.  */
2076
2077   if (DECL_NAME (decl) != 0)
2078     current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
2079
2080   switch (TREE_CODE (decl))
2081     {
2082     case CONST_DECL:
2083       /* Enum values are defined by defining the enum type.  */
2084       break;
2085
2086     case FUNCTION_DECL:
2087       if (DECL_RTL (decl) == 0)
2088         DBXOUT_DECR_NESTING_AND_RETURN (0);
2089       if (DECL_EXTERNAL (decl))
2090         break;
2091       /* Don't mention a nested function under its parent.  */
2092       context = decl_function_context (decl);
2093       if (context == current_function_decl)
2094         break;
2095       if (GET_CODE (DECL_RTL (decl)) != MEM
2096           || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
2097         break;
2098       FORCE_TEXT;
2099
2100       fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2101                IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
2102                TREE_PUBLIC (decl) ? 'F' : 'f');
2103       result = 1;
2104
2105       current_sym_code = N_FUN;
2106       current_sym_addr = XEXP (DECL_RTL (decl), 0);
2107
2108       if (TREE_TYPE (type))
2109         dbxout_type (TREE_TYPE (type), 0);
2110       else
2111         dbxout_type (void_type_node, 0);
2112
2113       /* For a nested function, when that function is compiled,
2114          mention the containing function name
2115          as well as (since dbx wants it) our own assembler-name.  */
2116       if (context != 0)
2117         fprintf (asmfile, ",%s,%s",
2118                  IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
2119                  IDENTIFIER_POINTER (DECL_NAME (context)));
2120
2121       dbxout_finish_symbol (decl);
2122       break;
2123
2124     case TYPE_DECL:
2125       /* Don't output the same typedef twice.
2126          And don't output what language-specific stuff doesn't want output.  */
2127       if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
2128         DBXOUT_DECR_NESTING_AND_RETURN (0);
2129
2130       FORCE_TEXT;
2131       result = 1;
2132       {
2133         int tag_needed = 1;
2134         int did_output = 0;
2135
2136         if (DECL_NAME (decl))
2137           {
2138             /* Nonzero means we must output a tag as well as a typedef.  */
2139             tag_needed = 0;
2140
2141             /* Handle the case of a C++ structure or union
2142                where the TYPE_NAME is a TYPE_DECL
2143                which gives both a typedef name and a tag.  */
2144             /* dbx requires the tag first and the typedef second.  */
2145             if ((TREE_CODE (type) == RECORD_TYPE
2146                  || TREE_CODE (type) == UNION_TYPE
2147                  || TREE_CODE (type) == QUAL_UNION_TYPE)
2148                 && TYPE_NAME (type) == decl
2149                 && !(use_gnu_debug_info_extensions && have_used_extensions)
2150                 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
2151                 /* Distinguish the implicit typedefs of C++
2152                    from explicit ones that might be found in C.  */
2153                 && DECL_ARTIFICIAL (decl)
2154                 /* Do not generate a tag for incomplete records.  */
2155                 && COMPLETE_TYPE_P (type)
2156                 /* Do not generate a tag for records of variable size,
2157                    since this type can not be properly described in the
2158                    DBX format, and it confuses some tools such as objdump.  */
2159                 && host_integerp (TYPE_SIZE (type), 1))
2160               {
2161                 tree name = TYPE_NAME (type);
2162                 if (TREE_CODE (name) == TYPE_DECL)
2163                   name = DECL_NAME (name);
2164
2165                 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2166                 current_sym_value = 0;
2167                 current_sym_addr = 0;
2168                 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2169
2170                 fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
2171                          IDENTIFIER_POINTER (name));
2172                 dbxout_type (type, 1);
2173                 dbxout_finish_symbol (NULL_TREE);
2174               }
2175
2176             /* Output .stabs (or whatever) and leading double quote.  */
2177             fprintf (asmfile, "%s\"", ASM_STABS_OP);
2178
2179             if (use_gnu_debug_info_extensions)
2180               {
2181                 /* Output leading class/struct qualifiers.  */
2182                 dbxout_class_name_qualifiers (decl);
2183               }
2184
2185             /* Output typedef name.  */
2186             fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (decl)));
2187
2188             /* Short cut way to output a tag also.  */
2189             if ((TREE_CODE (type) == RECORD_TYPE
2190                  || TREE_CODE (type) == UNION_TYPE
2191                  || TREE_CODE (type) == QUAL_UNION_TYPE)
2192                 && TYPE_NAME (type) == decl
2193                 /* Distinguish the implicit typedefs of C++
2194                    from explicit ones that might be found in C.  */
2195                 && DECL_ARTIFICIAL (decl))
2196               {
2197                 if (use_gnu_debug_info_extensions && have_used_extensions)
2198                   {
2199                     putc ('T', asmfile);
2200                     TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
2201                   }
2202 #if 0 /* Now we generate the tag for this case up above.  */
2203                 else
2204                   tag_needed = 1;
2205 #endif
2206               }
2207
2208             putc ('t', asmfile);
2209             current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2210
2211             dbxout_type (type, 1);
2212             dbxout_finish_symbol (decl);
2213             did_output = 1;
2214           }
2215
2216         /* Don't output a tag if this is an incomplete type.  This prevents
2217            the sun4 Sun OS 4.x dbx from crashing.  */
2218
2219         if (tag_needed && TYPE_NAME (type) != 0
2220             && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
2221                 || (DECL_NAME (TYPE_NAME (type)) != 0))
2222             && COMPLETE_TYPE_P (type)
2223             && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
2224           {
2225             /* For a TYPE_DECL with no name, but the type has a name,
2226                output a tag.
2227                This is what represents `struct foo' with no typedef.  */
2228             /* In C++, the name of a type is the corresponding typedef.
2229                In C, it is an IDENTIFIER_NODE.  */
2230             tree name = TYPE_NAME (type);
2231             if (TREE_CODE (name) == TYPE_DECL)
2232               name = DECL_NAME (name);
2233
2234             current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2235             current_sym_value = 0;
2236             current_sym_addr = 0;
2237             current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
2238
2239             fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
2240                      IDENTIFIER_POINTER (name));
2241             dbxout_type (type, 1);
2242             dbxout_finish_symbol (NULL_TREE);
2243             did_output = 1;
2244           }
2245
2246         /* If an enum type has no name, it cannot be referred to,
2247            but we must output it anyway, since the enumeration constants
2248            can be referred to.  */
2249         if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
2250           {
2251             current_sym_code = DBX_TYPE_DECL_STABS_CODE;
2252             current_sym_value = 0;
2253             current_sym_addr = 0;
2254             current_sym_nchars = 2;
2255
2256             /* Some debuggers fail when given NULL names, so give this a
2257                harmless name of ` '.  */
2258             fprintf (asmfile, "%s\" :T", ASM_STABS_OP);
2259             dbxout_type (type, 1);
2260             dbxout_finish_symbol (NULL_TREE);
2261           }
2262
2263         /* Prevent duplicate output of a typedef.  */
2264         TREE_ASM_WRITTEN (decl) = 1;
2265         break;
2266       }
2267
2268     case PARM_DECL:
2269       /* Parm decls go in their own separate chains
2270          and are output by dbxout_reg_parms and dbxout_parms.  */
2271       abort ();
2272
2273     case RESULT_DECL:
2274       /* Named return value, treat like a VAR_DECL.  */
2275     case VAR_DECL:
2276       if (! DECL_RTL_SET_P (decl))
2277         DBXOUT_DECR_NESTING_AND_RETURN (0);
2278       /* Don't mention a variable that is external.
2279          Let the file that defines it describe it.  */
2280       if (DECL_EXTERNAL (decl))
2281         break;
2282
2283       /* If the variable is really a constant
2284          and not written in memory, inform the debugger.  */
2285       if (TREE_STATIC (decl) && TREE_READONLY (decl)
2286           && DECL_INITIAL (decl) != 0
2287           && host_integerp (DECL_INITIAL (decl), 0)
2288           && ! TREE_ASM_WRITTEN (decl)
2289           && (DECL_CONTEXT (decl) == NULL_TREE
2290               || TREE_CODE (DECL_CONTEXT (decl)) == BLOCK))
2291         {
2292           if (TREE_PUBLIC (decl) == 0)
2293             {
2294               /* The sun4 assembler does not grok this.  */
2295               const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
2296
2297               if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
2298                   || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
2299                 {
2300                   HOST_WIDE_INT ival = tree_low_cst (DECL_INITIAL (decl), 0);
2301                   fprintf (asmfile, "%s\"%s:c=i" HOST_WIDE_INT_PRINT_DEC
2302                            "\",0x%x,0,0,0\n",
2303                            ASM_STABS_OP, name, ival, N_LSYM);
2304                   DBXOUT_DECR_NESTING;
2305                   return 1;
2306                 }
2307               else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
2308                 {
2309                   /* don't know how to do this yet.  */
2310                 }
2311               break;
2312             }
2313           /* else it is something we handle like a normal variable.  */
2314         }
2315
2316       SET_DECL_RTL (decl, eliminate_regs (DECL_RTL (decl), 0, NULL_RTX));
2317 #ifdef LEAF_REG_REMAP
2318       if (current_function_uses_only_leaf_regs)
2319         leaf_renumber_regs_insn (DECL_RTL (decl));
2320 #endif
2321
2322       result = dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
2323       break;
2324
2325     default:
2326       break;
2327     }
2328   DBXOUT_DECR_NESTING;
2329   return result;
2330 }
2331 \f
2332 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
2333    Add SUFFIX to its name, if SUFFIX is not 0.
2334    Describe the variable as residing in HOME
2335    (usually HOME is DECL_RTL (DECL), but not always).
2336    Returns 1 if the stab was really emitted.  */
2337
2338 static int
2339 dbxout_symbol_location (tree decl, tree type, const char *suffix, rtx home)
2340 {
2341   int letter = 0;
2342   int regno = -1;
2343
2344   /* Don't mention a variable at all
2345      if it was completely optimized into nothingness.
2346
2347      If the decl was from an inline function, then its rtl
2348      is not identically the rtl that was used in this
2349      particular compilation.  */
2350   if (GET_CODE (home) == SUBREG)
2351     {
2352       rtx value = home;
2353
2354       while (GET_CODE (value) == SUBREG)
2355         value = SUBREG_REG (value);
2356       if (GET_CODE (value) == REG)
2357         {
2358           if (REGNO (value) >= FIRST_PSEUDO_REGISTER)
2359             return 0;
2360         }
2361       home = alter_subreg (&home);
2362     }
2363   if (GET_CODE (home) == REG)
2364     {
2365       regno = REGNO (home);
2366       if (regno >= FIRST_PSEUDO_REGISTER)
2367         return 0;
2368     }
2369
2370   /* The kind-of-variable letter depends on where
2371      the variable is and on the scope of its name:
2372      G and N_GSYM for static storage and global scope,
2373      S for static storage and file scope,
2374      V for static storage and local scope,
2375      for those two, use N_LCSYM if data is in bss segment,
2376      N_STSYM if in data segment, N_FUN otherwise.
2377      (We used N_FUN originally, then changed to N_STSYM
2378      to please GDB.  However, it seems that confused ld.
2379      Now GDB has been fixed to like N_FUN, says Kingdon.)
2380      no letter at all, and N_LSYM, for auto variable,
2381      r and N_RSYM for register variable.  */
2382
2383   if (GET_CODE (home) == MEM
2384       && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
2385     {
2386       if (TREE_PUBLIC (decl))
2387         {
2388           letter = 'G';
2389           current_sym_code = N_GSYM;
2390         }
2391       else
2392         {
2393           current_sym_addr = XEXP (home, 0);
2394
2395           letter = decl_function_context (decl) ? 'V' : 'S';
2396
2397           /* This should be the same condition as in assemble_variable, but
2398              we don't have access to dont_output_data here.  So, instead,
2399              we rely on the fact that error_mark_node initializers always
2400              end up in bss for C++ and never end up in bss for C.  */
2401           if (DECL_INITIAL (decl) == 0
2402               || (!strcmp (lang_hooks.name, "GNU C++")
2403                   && DECL_INITIAL (decl) == error_mark_node))
2404             current_sym_code = N_LCSYM;
2405           else if (DECL_IN_TEXT_SECTION (decl))
2406             /* This is not quite right, but it's the closest
2407                of all the codes that Unix defines.  */
2408             current_sym_code = DBX_STATIC_CONST_VAR_CODE;
2409           else
2410             {
2411               /* Some ports can transform a symbol ref into a label ref,
2412                  because the symbol ref is too far away and has to be
2413                  dumped into a constant pool.  Alternatively, the symbol
2414                  in the constant pool might be referenced by a different
2415                  symbol.  */
2416               if (GET_CODE (current_sym_addr) == SYMBOL_REF
2417                   && CONSTANT_POOL_ADDRESS_P (current_sym_addr))
2418                 {
2419                   rtx tmp = get_pool_constant (current_sym_addr);
2420
2421                   if (GET_CODE (tmp) == SYMBOL_REF
2422                       || GET_CODE (tmp) == LABEL_REF)
2423                     current_sym_addr = tmp;
2424                 }
2425
2426               /* Ultrix `as' seems to need this.  */
2427 #ifdef DBX_STATIC_STAB_DATA_SECTION
2428               data_section ();
2429 #endif
2430               current_sym_code = N_STSYM;
2431             }
2432         }
2433     }
2434   else if (regno >= 0)
2435     {
2436       letter = 'r';
2437       current_sym_code = N_RSYM;
2438       current_sym_value = DBX_REGISTER_NUMBER (regno);
2439     }
2440   else if (GET_CODE (home) == MEM
2441            && (GET_CODE (XEXP (home, 0)) == MEM
2442                || (GET_CODE (XEXP (home, 0)) == REG
2443                    && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
2444                    && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
2445 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2446                    && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
2447 #endif
2448                    )))
2449     /* If the value is indirect by memory or by a register
2450        that isn't the frame pointer
2451        then it means the object is variable-sized and address through
2452        that register or stack slot.  DBX has no way to represent this
2453        so all we can do is output the variable as a pointer.
2454        If it's not a parameter, ignore it.
2455        (VAR_DECLs like this can be made by integrate.c.)  */
2456     {
2457       if (GET_CODE (XEXP (home, 0)) == REG)
2458         {
2459           letter = 'r';
2460           current_sym_code = N_RSYM;
2461           if (REGNO (XEXP (home, 0)) >= FIRST_PSEUDO_REGISTER)
2462             return 0;
2463           current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2464         }
2465       else
2466         {
2467           current_sym_code = N_LSYM;
2468           /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2469              We want the value of that CONST_INT.  */
2470           current_sym_value
2471             = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2472         }
2473
2474       /* Effectively do build_pointer_type, but don't cache this type,
2475          since it might be temporary whereas the type it points to
2476          might have been saved for inlining.  */
2477       /* Don't use REFERENCE_TYPE because dbx can't handle that.  */
2478       type = make_node (POINTER_TYPE);
2479       TREE_TYPE (type) = TREE_TYPE (decl);
2480     }
2481   else if (GET_CODE (home) == MEM
2482            && GET_CODE (XEXP (home, 0)) == REG)
2483     {
2484       current_sym_code = N_LSYM;
2485       current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2486     }
2487   else if (GET_CODE (home) == MEM
2488            && GET_CODE (XEXP (home, 0)) == PLUS
2489            && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2490     {
2491       current_sym_code = N_LSYM;
2492       /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2493          We want the value of that CONST_INT.  */
2494       current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2495     }
2496   else if (GET_CODE (home) == MEM
2497            && GET_CODE (XEXP (home, 0)) == CONST)
2498     {
2499       /* Handle an obscure case which can arise when optimizing and
2500          when there are few available registers.  (This is *always*
2501          the case for i386/i486 targets).  The RTL looks like
2502          (MEM (CONST ...)) even though this variable is a local `auto'
2503          or a local `register' variable.  In effect, what has happened
2504          is that the reload pass has seen that all assignments and
2505          references for one such a local variable can be replaced by
2506          equivalent assignments and references to some static storage
2507          variable, thereby avoiding the need for a register.  In such
2508          cases we're forced to lie to debuggers and tell them that
2509          this variable was itself `static'.  */
2510       current_sym_code = N_LCSYM;
2511       letter = 'V';
2512       current_sym_addr = XEXP (XEXP (home, 0), 0);
2513     }
2514   else if (GET_CODE (home) == CONCAT)
2515     {
2516       tree subtype;
2517
2518       /* If TYPE is not a COMPLEX_TYPE (it might be a RECORD_TYPE,
2519          for example), then there is no easy way to figure out
2520          what SUBTYPE should be.  So, we give up.  */
2521       if (TREE_CODE (type) != COMPLEX_TYPE)
2522         return 0;
2523
2524       subtype = TREE_TYPE (type);
2525
2526       /* If the variable's storage is in two parts,
2527          output each as a separate stab with a modified name.  */
2528       if (WORDS_BIG_ENDIAN)
2529         dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2530       else
2531         dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2532
2533       /* Cast avoids warning in old compilers.  */
2534       current_sym_code = (STAB_CODE_TYPE) 0;
2535       current_sym_value = 0;
2536       current_sym_addr = 0;
2537       dbxout_prepare_symbol (decl);
2538
2539       if (WORDS_BIG_ENDIAN)
2540         dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2541       else
2542         dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2543       return 1;
2544     }
2545   else
2546     /* Address might be a MEM, when DECL is a variable-sized object.
2547        Or it might be const0_rtx, meaning previous passes
2548        want us to ignore this variable.  */
2549     return 0;
2550
2551   /* Ok, start a symtab entry and output the variable name.  */
2552   FORCE_TEXT;
2553
2554 #ifdef DBX_STATIC_BLOCK_START
2555   DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2556 #endif
2557
2558   dbxout_symbol_name (decl, suffix, letter);
2559   dbxout_type (type, 0);
2560   dbxout_finish_symbol (decl);
2561
2562 #ifdef DBX_STATIC_BLOCK_END
2563   DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2564 #endif
2565   return 1;
2566 }
2567 \f
2568 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2569    Then output LETTER to indicate the kind of location the symbol has.  */
2570
2571 static void
2572 dbxout_symbol_name (tree decl, const char *suffix, int letter)
2573 {
2574   const char *name;
2575
2576   if (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl)))
2577     /* One slight hitch: if this is a VAR_DECL which is a static
2578        class member, we must put out the mangled name instead of the
2579        DECL_NAME.  Note also that static member (variable) names DO NOT begin
2580        with underscores in .stabs directives.  */
2581     name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2582   else
2583     /* ...but if we're function-local, we don't want to include the junk
2584        added by ASM_FORMAT_PRIVATE_NAME.  */
2585     name = IDENTIFIER_POINTER (DECL_NAME (decl));
2586
2587   if (name == 0)
2588     name = "(anon)";
2589   fprintf (asmfile, "%s\"%s%s:", ASM_STABS_OP, name,
2590            (suffix ? suffix : ""));
2591
2592   if (letter)
2593     putc (letter, asmfile);
2594 }
2595
2596 static void
2597 dbxout_prepare_symbol (tree decl ATTRIBUTE_UNUSED)
2598 {
2599 #ifdef WINNING_GDB
2600   const char *filename = DECL_SOURCE_FILE (decl);
2601
2602   dbxout_source_file (asmfile, filename);
2603 #endif
2604 }
2605
2606 static void
2607 dbxout_finish_symbol (tree sym)
2608 {
2609 #ifdef DBX_FINISH_SYMBOL
2610   DBX_FINISH_SYMBOL (sym);
2611 #else
2612   int line = 0;
2613   if (use_gnu_debug_info_extensions && sym != 0)
2614     line = DECL_SOURCE_LINE (sym);
2615
2616   fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2617   if (current_sym_addr)
2618     output_addr_const (asmfile, current_sym_addr);
2619   else
2620     fprintf (asmfile, "%d", current_sym_value);
2621   putc ('\n', asmfile);
2622 #endif
2623 }
2624
2625 /* Output definitions of all the decls in a chain. Return nonzero if
2626    anything was output */
2627
2628 int
2629 dbxout_syms (tree syms)
2630 {
2631   int result = 0;
2632   while (syms)
2633     {
2634       result += dbxout_symbol (syms, 1);
2635       syms = TREE_CHAIN (syms);
2636     }
2637   return result;
2638 }
2639 \f
2640 /* The following two functions output definitions of function parameters.
2641    Each parameter gets a definition locating it in the parameter list.
2642    Each parameter that is a register variable gets a second definition
2643    locating it in the register.
2644
2645    Printing or argument lists in gdb uses the definitions that
2646    locate in the parameter list.  But reference to the variable in
2647    expressions uses preferentially the definition as a register.  */
2648
2649 /* Output definitions, referring to storage in the parmlist,
2650    of all the parms in PARMS, which is a chain of PARM_DECL nodes.  */
2651
2652 void
2653 dbxout_parms (tree parms)
2654 {
2655   ++debug_nesting;
2656
2657   for (; parms; parms = TREE_CHAIN (parms))
2658     if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2659       {
2660         dbxout_prepare_symbol (parms);
2661
2662         /* Perform any necessary register eliminations on the parameter's rtl,
2663            so that the debugging output will be accurate.  */
2664         DECL_INCOMING_RTL (parms)
2665           = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2666         SET_DECL_RTL (parms, eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
2667 #ifdef LEAF_REG_REMAP
2668         if (current_function_uses_only_leaf_regs)
2669           {
2670             leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2671             leaf_renumber_regs_insn (DECL_RTL (parms));
2672           }
2673 #endif
2674
2675         if (PARM_PASSED_IN_MEMORY (parms))
2676           {
2677             rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2678
2679             /* ??? Here we assume that the parm address is indexed
2680                off the frame pointer or arg pointer.
2681                If that is not true, we produce meaningless results,
2682                but do not crash.  */
2683             if (GET_CODE (addr) == PLUS
2684                 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2685               current_sym_value = INTVAL (XEXP (addr, 1));
2686             else
2687               current_sym_value = 0;
2688
2689             current_sym_code = N_PSYM;
2690             current_sym_addr = 0;
2691
2692             FORCE_TEXT;
2693             if (DECL_NAME (parms))
2694               {
2695                 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2696
2697                 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2698                          IDENTIFIER_POINTER (DECL_NAME (parms)),
2699                          DBX_MEMPARM_STABS_LETTER);
2700               }
2701             else
2702               {
2703                 current_sym_nchars = 8;
2704                 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2705                          DBX_MEMPARM_STABS_LETTER);
2706               }
2707
2708             /* It is quite tempting to use:
2709
2710                    dbxout_type (TREE_TYPE (parms), 0);
2711
2712                as the next statement, rather than using DECL_ARG_TYPE(), so
2713                that gcc reports the actual type of the parameter, rather
2714                than the promoted type.  This certainly makes GDB's life
2715                easier, at least for some ports.  The change is a bad idea
2716                however, since GDB expects to be able access the type without
2717                performing any conversions.  So for example, if we were
2718                passing a float to an unprototyped function, gcc will store a
2719                double on the stack, but if we emit a stab saying the type is a
2720                float, then gdb will only read in a single value, and this will
2721                produce an erroneous value.  */
2722             dbxout_type (DECL_ARG_TYPE (parms), 0);
2723             current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2724             dbxout_finish_symbol (parms);
2725           }
2726         else if (GET_CODE (DECL_RTL (parms)) == REG)
2727           {
2728             rtx best_rtl;
2729             char regparm_letter;
2730             tree parm_type;
2731             /* Parm passed in registers and lives in registers or nowhere.  */
2732
2733             current_sym_code = DBX_REGPARM_STABS_CODE;
2734             regparm_letter = DBX_REGPARM_STABS_LETTER;
2735             current_sym_addr = 0;
2736
2737             /* If parm lives in a register, use that register;
2738                pretend the parm was passed there.  It would be more consistent
2739                to describe the register where the parm was passed,
2740                but in practice that register usually holds something else.
2741
2742                If we use DECL_RTL, then we must use the declared type of
2743                the variable, not the type that it arrived in.  */
2744             if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2745               {
2746                 best_rtl = DECL_RTL (parms);
2747                 parm_type = TREE_TYPE (parms);
2748               }
2749             /* If the parm lives nowhere, use the register where it was
2750                passed.  It is also better to use the declared type here.  */
2751             else
2752               {
2753                 best_rtl = DECL_INCOMING_RTL (parms);
2754                 parm_type = TREE_TYPE (parms);
2755               }
2756             current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2757
2758             FORCE_TEXT;
2759             if (DECL_NAME (parms))
2760               {
2761                 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2762                 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2763                          IDENTIFIER_POINTER (DECL_NAME (parms)),
2764                          regparm_letter);
2765               }
2766             else
2767               {
2768                 current_sym_nchars = 8;
2769                 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2770                          regparm_letter);
2771               }
2772
2773             dbxout_type (parm_type, 0);
2774             dbxout_finish_symbol (parms);
2775           }
2776         else if (GET_CODE (DECL_RTL (parms)) == MEM
2777                  && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2778                  && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2779                  && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2780 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2781                  && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2782 #endif
2783                  )
2784           {
2785             /* Parm was passed via invisible reference.
2786                That is, its address was passed in a register.
2787                Output it as if it lived in that register.
2788                The debugger will know from the type
2789                that it was actually passed by invisible reference.  */
2790
2791             char regparm_letter;
2792             /* Parm passed in registers and lives in registers or nowhere.  */
2793
2794             current_sym_code = DBX_REGPARM_STABS_CODE;
2795             if (use_gnu_debug_info_extensions)
2796               regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2797             else
2798               regparm_letter = DBX_REGPARM_STABS_LETTER;
2799
2800             /* DECL_RTL looks like (MEM (REG...).  Get the register number.
2801                If it is an unallocated pseudo-reg, then use the register where
2802                it was passed instead.  */
2803             if (REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2804               current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2805             else
2806               current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2807
2808             current_sym_addr = 0;
2809
2810             FORCE_TEXT;
2811             if (DECL_NAME (parms))
2812               {
2813                 current_sym_nchars
2814                   = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2815
2816                 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2817                          IDENTIFIER_POINTER (DECL_NAME (parms)),
2818                          regparm_letter);
2819               }
2820             else
2821               {
2822                 current_sym_nchars = 8;
2823                 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2824                          regparm_letter);
2825               }
2826
2827             dbxout_type (TREE_TYPE (parms), 0);
2828             dbxout_finish_symbol (parms);
2829           }
2830         else if (GET_CODE (DECL_RTL (parms)) == MEM
2831                  && GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2832           {
2833             /* Parm was passed via invisible reference, with the reference
2834                living on the stack.  DECL_RTL looks like
2835                (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2836                could look like (MEM (MEM (REG))).  */
2837             const char *const decl_name = (DECL_NAME (parms)
2838                                      ? IDENTIFIER_POINTER (DECL_NAME (parms))
2839                                      : "(anon)");
2840             if (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 0)) == REG)
2841               current_sym_value = 0;
2842             else
2843               current_sym_value
2844                 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1));
2845             current_sym_addr = 0;
2846             current_sym_code = N_PSYM;
2847
2848             FORCE_TEXT;
2849             fprintf (asmfile, "%s\"%s:v", ASM_STABS_OP, decl_name);
2850
2851             current_sym_value
2852               = DEBUGGER_ARG_OFFSET (current_sym_value,
2853                                      XEXP (XEXP (DECL_RTL (parms), 0), 0));
2854             dbxout_type (TREE_TYPE (parms), 0);
2855             dbxout_finish_symbol (parms);
2856           }
2857         else if (GET_CODE (DECL_RTL (parms)) == MEM
2858                  && XEXP (DECL_RTL (parms), 0) != const0_rtx
2859                  /* ??? A constant address for a parm can happen
2860                     when the reg it lives in is equiv to a constant in memory.
2861                     Should make this not happen, after 2.4.  */
2862                  && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2863           {
2864             /* Parm was passed in registers but lives on the stack.  */
2865
2866             current_sym_code = N_PSYM;
2867             /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2868                in which case we want the value of that CONST_INT,
2869                or (MEM (REG ...)),
2870                in which case we use a value of zero.  */
2871             if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG)
2872               current_sym_value = 0;
2873             else
2874                 current_sym_value
2875                   = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2876
2877             current_sym_addr = 0;
2878
2879             /* Make a big endian correction if the mode of the type of the
2880                parameter is not the same as the mode of the rtl.  */
2881             if (BYTES_BIG_ENDIAN
2882                 && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms))
2883                 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD)
2884               {
2885                 current_sym_value +=
2886                     GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))
2887                     - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms)));
2888               }
2889
2890             FORCE_TEXT;
2891             if (DECL_NAME (parms))
2892               {
2893                 current_sym_nchars
2894                   = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2895
2896                 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2897                          IDENTIFIER_POINTER (DECL_NAME (parms)),
2898                          DBX_MEMPARM_STABS_LETTER);
2899               }
2900             else
2901               {
2902                 current_sym_nchars = 8;
2903                 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2904                 DBX_MEMPARM_STABS_LETTER);
2905               }
2906
2907             current_sym_value
2908               = DEBUGGER_ARG_OFFSET (current_sym_value,
2909                                      XEXP (DECL_RTL (parms), 0));
2910             dbxout_type (TREE_TYPE (parms), 0);
2911             dbxout_finish_symbol (parms);
2912           }
2913       }
2914   DBXOUT_DECR_NESTING;
2915 }
2916
2917 /* Output definitions for the places where parms live during the function,
2918    when different from where they were passed, when the parms were passed
2919    in memory.
2920
2921    It is not useful to do this for parms passed in registers
2922    that live during the function in different registers, because it is
2923    impossible to look in the passed register for the passed value,
2924    so we use the within-the-function register to begin with.
2925
2926    PARMS is a chain of PARM_DECL nodes.  */
2927
2928 void
2929 dbxout_reg_parms (tree parms)
2930 {
2931   ++debug_nesting;
2932
2933   for (; parms; parms = TREE_CHAIN (parms))
2934     if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
2935       {
2936         dbxout_prepare_symbol (parms);
2937
2938         /* Report parms that live in registers during the function
2939            but were passed in memory.  */
2940         if (GET_CODE (DECL_RTL (parms)) == REG
2941             && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2942           dbxout_symbol_location (parms, TREE_TYPE (parms),
2943                                   0, DECL_RTL (parms));
2944         else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
2945           dbxout_symbol_location (parms, TREE_TYPE (parms),
2946                                   0, DECL_RTL (parms));
2947         /* Report parms that live in memory but not where they were passed.  */
2948         else if (GET_CODE (DECL_RTL (parms)) == MEM
2949                  && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
2950           dbxout_symbol_location (parms, TREE_TYPE (parms),
2951                                   0, DECL_RTL (parms));
2952       }
2953   DBXOUT_DECR_NESTING;
2954 }
2955 \f
2956 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2957    output definitions of those names, in raw form */
2958
2959 static void
2960 dbxout_args (tree args)
2961 {
2962   while (args)
2963     {
2964       putc (',', asmfile);
2965       dbxout_type (TREE_VALUE (args), 0);
2966       CHARS (1);
2967       args = TREE_CHAIN (args);
2968     }
2969 }
2970 \f
2971 /* Output everything about a symbol block (a BLOCK node
2972    that represents a scope level),
2973    including recursive output of contained blocks.
2974
2975    BLOCK is the BLOCK node.
2976    DEPTH is its depth within containing symbol blocks.
2977    ARGS is usually zero; but for the outermost block of the
2978    body of a function, it is a chain of PARM_DECLs for the function parameters.
2979    We output definitions of all the register parms
2980    as if they were local variables of that block.
2981
2982    If -g1 was used, we count blocks just the same, but output nothing
2983    except for the outermost block.
2984
2985    Actually, BLOCK may be several blocks chained together.
2986    We handle them all in sequence.  */
2987
2988 static void
2989 dbxout_block (tree block, int depth, tree args)
2990 {
2991   int blocknum = -1;
2992
2993 #if DBX_BLOCKS_FUNCTION_RELATIVE
2994   const char *begin_label;
2995   if (current_function_func_begin_label != NULL_TREE)
2996     begin_label = IDENTIFIER_POINTER (current_function_func_begin_label);
2997   else
2998     begin_label = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
2999 #endif
3000
3001   while (block)
3002     {
3003       /* Ignore blocks never expanded or otherwise marked as real.  */
3004       if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
3005         {
3006           int did_output;
3007
3008           /* In dbx format, the syms of a block come before the N_LBRAC.
3009              If nothing is output, we don't need the N_LBRAC, either.  */
3010           did_output = 0;
3011           if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
3012             did_output = dbxout_syms (BLOCK_VARS (block));
3013           if (args)
3014             dbxout_reg_parms (args);
3015
3016           /* Now output an N_LBRAC symbol to represent the beginning of
3017              the block.  Use the block's tree-walk order to generate
3018              the assembler symbols LBBn and LBEn
3019              that final will define around the code in this block.  */
3020           if (depth > 0 && did_output)
3021             {
3022               char buf[20];
3023               blocknum = BLOCK_NUMBER (block);
3024               ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
3025
3026               if (BLOCK_HANDLER_BLOCK (block))
3027                 {
3028                   /* A catch block.  Must precede N_LBRAC.  */
3029                   tree decl = BLOCK_VARS (block);
3030                   while (decl)
3031                     {
3032                       fprintf (asmfile, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP,
3033                                IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
3034                       assemble_name (asmfile, buf);
3035                       fprintf (asmfile, "\n");
3036                       decl = TREE_CHAIN (decl);
3037                     }
3038                 }
3039
3040 #ifdef DBX_OUTPUT_LBRAC
3041               DBX_OUTPUT_LBRAC (asmfile, buf);
3042 #else
3043               fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
3044               assemble_name (asmfile, buf);
3045 #if DBX_BLOCKS_FUNCTION_RELATIVE
3046               putc ('-', asmfile);
3047               assemble_name (asmfile, begin_label);
3048 #endif
3049               fprintf (asmfile, "\n");
3050 #endif
3051             }
3052
3053           /* Output the subblocks.  */
3054           dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
3055
3056           /* Refer to the marker for the end of the block.  */
3057           if (depth > 0 && did_output)
3058             {
3059               char buf[20];
3060               ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
3061 #ifdef DBX_OUTPUT_RBRAC
3062               DBX_OUTPUT_RBRAC (asmfile, buf);
3063 #else
3064               fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC);
3065               assemble_name (asmfile, buf);
3066 #if DBX_BLOCKS_FUNCTION_RELATIVE
3067               putc ('-', asmfile);
3068               assemble_name (asmfile, begin_label);
3069 #endif
3070               fprintf (asmfile, "\n");
3071 #endif
3072             }
3073         }
3074       block = BLOCK_CHAIN (block);
3075     }
3076 }
3077
3078 /* Output the information about a function and its arguments and result.
3079    Usually this follows the function's code,
3080    but on some systems, it comes before.  */
3081
3082 #if defined (DBX_DEBUGGING_INFO)
3083 static void
3084 dbxout_begin_function (tree decl)
3085 {
3086   int saved_tree_used1 = TREE_USED (decl);
3087   TREE_USED (decl) = 1;
3088   if (DECL_NAME (DECL_RESULT (decl)) != 0)
3089     {
3090       int saved_tree_used2 = TREE_USED (DECL_RESULT (decl));
3091       TREE_USED (DECL_RESULT (decl)) = 1;
3092       dbxout_symbol (decl, 0);
3093       TREE_USED (DECL_RESULT (decl)) = saved_tree_used2;
3094     }
3095   else
3096     dbxout_symbol (decl, 0);
3097   TREE_USED (decl) = saved_tree_used1;
3098
3099   dbxout_parms (DECL_ARGUMENTS (decl));
3100   if (DECL_NAME (DECL_RESULT (decl)) != 0)
3101     dbxout_symbol (DECL_RESULT (decl), 1);
3102 }
3103 #endif /* DBX_DEBUGGING_INFO */
3104
3105 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3106
3107 #include "gt-dbxout.h"