OSDN Git Service

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