OSDN Git Service

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