OSDN Git Service

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