OSDN Git Service

2004-01-27 Devang Patel <dpatel@apple.com>
[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, 2004 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 
388                                             line info */
389   debug_nothing_int_charstar,            /* end_prologue */
390   debug_nothing_int_charstar,            /* end_epilogue */
391 #ifdef DBX_FUNCTION_FIRST
392   dbxout_begin_function,
393 #else
394   debug_nothing_tree,                    /* begin_function */
395 #endif
396   debug_nothing_int,                     /* end_function */
397   dbxout_function_decl,
398   dbxout_global_decl,                    /* global_decl */
399   debug_nothing_tree_tree,               /* imported_module_or_decl */
400   debug_nothing_tree,                    /* deferred_inline_function */
401   debug_nothing_tree,                    /* outlining_inline_function */
402   debug_nothing_rtx,                     /* label */
403   dbxout_handle_pch                      /* handle_pch */
404 };
405 #endif /* DBX_DEBUGGING_INFO  */
406
407 #if defined (XCOFF_DEBUGGING_INFO)
408 const struct gcc_debug_hooks xcoff_debug_hooks =
409 {
410   dbxout_init,
411   dbxout_finish,
412   debug_nothing_int_charstar,
413   debug_nothing_int_charstar,
414   dbxout_start_source_file,
415   dbxout_end_source_file,
416   xcoffout_begin_block,
417   xcoffout_end_block,
418   debug_true_tree,                       /* ignore_block */
419   xcoffout_source_line,
420   xcoffout_begin_prologue,               /* begin_prologue */
421   debug_nothing_int_charstar,            /* end_prologue */
422   xcoffout_end_epilogue,
423   debug_nothing_tree,                    /* begin_function */
424   xcoffout_end_function,
425   debug_nothing_tree,                    /* function_decl */
426   dbxout_global_decl,                    /* global_decl */
427   debug_nothing_tree_tree,               /* imported_module_or_decl */
428   debug_nothing_tree,                    /* deferred_inline_function */
429   debug_nothing_tree,                    /* outlining_inline_function */
430   debug_nothing_rtx,                     /* label */
431   dbxout_handle_pch                      /* handle_pch */
432 };
433 #endif /* XCOFF_DEBUGGING_INFO  */
434 \f
435 #if defined (DBX_DEBUGGING_INFO)
436 static void
437 dbxout_function_end (void)
438 {
439   char lscope_label_name[100];
440   /* Convert Ltext into the appropriate format for local labels in case
441      the system doesn't insert underscores in front of user generated
442      labels.  */
443   ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
444   (*targetm.asm_out.internal_label) (asmfile, "Lscope", scope_labelno);
445   scope_labelno++;
446
447   /* By convention, GCC will mark the end of a function with an N_FUN
448      symbol and an empty string.  */
449 #ifdef DBX_OUTPUT_NFUN
450   DBX_OUTPUT_NFUN (asmfile, lscope_label_name, current_function_decl);
451 #else
452   fprintf (asmfile, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN);
453   assemble_name (asmfile, lscope_label_name);
454   putc ('-', asmfile);
455   assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
456   fprintf (asmfile, "\n");
457 #endif
458 }
459 #endif /* DBX_DEBUGGING_INFO */
460
461 /* At the beginning of compilation, start writing the symbol table.
462    Initialize `typevec' and output the standard data types of C.  */
463
464 static void
465 dbxout_init (const char *input_file_name)
466 {
467   char ltext_label_name[100];
468   tree syms = (*lang_hooks.decls.getdecls) ();
469
470   asmfile = asm_out_file;
471
472   typevec_len = 100;
473   typevec = ggc_calloc (typevec_len, sizeof typevec[0]);
474
475   /* Convert Ltext into the appropriate format for local labels in case
476      the system doesn't insert underscores in front of user generated
477      labels.  */
478   ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
479
480   /* Put the current working directory in an N_SO symbol.  */
481   if (use_gnu_debug_info_extensions)
482     {
483       if (!cwd && (cwd = get_src_pwd ())
484           && (!*cwd || cwd[strlen (cwd) - 1] != '/'))
485         cwd = concat (cwd, FILE_NAME_JOINER, NULL);
486       if (cwd)
487         {
488 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
489           DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
490 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
491           fprintf (asmfile, "%s", ASM_STABS_OP);
492           output_quoted_string (asmfile, cwd);
493           fprintf (asmfile, ",%d,0,0,", N_SO);
494           assemble_name (asmfile, ltext_label_name);
495           fputc ('\n', asmfile);
496 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
497         }
498     }
499
500 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
501   DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
502 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
503   /* We include outputting `Ltext:' here,
504      because that gives you a way to override it.  */
505   /* Used to put `Ltext:' before the reference, but that loses on sun 4.  */
506   fprintf (asmfile, "%s", ASM_STABS_OP);
507   output_quoted_string (asmfile, input_file_name);
508   fprintf (asmfile, ",%d,0,0,", N_SO);
509   assemble_name (asmfile, ltext_label_name);
510   fputc ('\n', asmfile);
511   text_section ();
512   (*targetm.asm_out.internal_label) (asmfile, "Ltext", 0);
513 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
514
515 #ifdef DBX_OUTPUT_GCC_MARKER
516   DBX_OUTPUT_GCC_MARKER (asmfile);
517 #else
518   /* Emit an N_OPT stab to indicate that this file was compiled by GCC.  */
519   fprintf (asmfile, "%s\"%s\",%d,0,0,0\n",
520            ASM_STABS_OP, STABS_GCC_MARKER, N_OPT);
521 #endif
522
523   base_input_file = lastfile = input_file_name;
524
525   next_type_number = 1;
526
527 #ifdef DBX_USE_BINCL
528   current_file = xmalloc (sizeof *current_file);
529   current_file->next = NULL;
530   current_file->file_number = 0;
531   current_file->next_type_number = 1;
532   next_file_number = 1;
533   current_file->prev = NULL;
534   current_file->bincl_status = BINCL_NOT_REQUIRED;
535   current_file->pending_bincl_name = NULL;
536 #endif
537
538   /* Make sure that types `int' and `char' have numbers 1 and 2.
539      Definitions of other integer types will refer to those numbers.
540      (Actually it should no longer matter what their numbers are.
541      Also, if any types with tags have been defined, dbxout_symbol
542      will output them first, so the numbers won't be 1 and 2.  That
543      happens in C++.  So it's a good thing it should no longer matter).  */
544
545 #ifdef DBX_OUTPUT_STANDARD_TYPES
546   DBX_OUTPUT_STANDARD_TYPES (syms);
547 #endif
548
549   /* Get all permanent types that have typedef names, and output them
550      all, except for those already output.  Some language front ends
551      put these declarations in the top-level scope; some do not.  */
552   dbxout_typedefs ((*lang_hooks.decls.builtin_type_decls) ());
553   dbxout_typedefs (syms);
554 }
555
556 /* Output any typedef names for types described by TYPE_DECLs in SYMS.  */
557
558 static void
559 dbxout_typedefs (tree syms)
560 {
561   for (; syms != NULL_TREE; syms = TREE_CHAIN (syms))
562     {
563       if (TREE_CODE (syms) == TYPE_DECL)
564         {
565           tree type = TREE_TYPE (syms);
566           if (TYPE_NAME (type)
567               && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
568               && COMPLETE_OR_VOID_TYPE_P (type)
569               && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
570             dbxout_symbol (TYPE_NAME (type), 0);
571         }
572     }
573 }
574
575 #ifdef DBX_USE_BINCL
576 /* Emit BINCL stab using given name.  */
577 static void
578 emit_bincl_stab (const char *name)
579 {
580   fprintf (asmfile, "%s", ASM_STABS_OP);
581   output_quoted_string (asmfile, name);
582   fprintf (asmfile, ",%d,0,0,0\n", N_BINCL);
583 }
584
585 /* If there are pending bincls then it is time to emit all of them.  */
586
587 static inline void
588 emit_pending_bincls_if_required (void)
589 {
590   if (pending_bincls)
591     emit_pending_bincls ();
592 }
593
594 /* Emit all pending bincls.  */
595
596 static void
597 emit_pending_bincls (void)
598 {
599   struct dbx_file *f = current_file;
600
601   /* Find first pending bincl.  */
602   while (f->bincl_status == BINCL_PENDING)
603     f = f->next;
604
605   /* Now emit all bincls.  */
606   f = f->prev;
607
608   while (f)
609     {
610       if (f->bincl_status == BINCL_PENDING)
611         {
612           emit_bincl_stab (f->pending_bincl_name);
613
614           /* Update file number and status.  */
615           f->file_number = next_file_number++;
616           f->bincl_status = BINCL_PROCESSED;
617         }
618       if (f == current_file)
619         break;
620       f = f->prev;
621     }
622
623   /* All pending bincls have been emitted.  */
624   pending_bincls = 0;
625 }
626
627 #else
628
629 static inline void
630 emit_pending_bincls_if_required (void) {}
631 #endif
632
633 /* Change to reading from a new source file.  Generate a N_BINCL stab.  */
634
635 static void
636 dbxout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
637                           const char *filename ATTRIBUTE_UNUSED)
638 {
639 #ifdef DBX_USE_BINCL
640   struct dbx_file *n = xmalloc (sizeof *n);
641
642   n->next = current_file;
643   n->next_type_number = 1;
644   /* Do not assign file number now. 
645      Delay it until we actually emit BINCL.  */
646   n->file_number = 0;
647   n->prev = NULL;
648   current_file->prev = n;
649   n->bincl_status = BINCL_PENDING;
650   n->pending_bincl_name = filename;
651   pending_bincls = 1;
652   current_file = n;
653 #endif
654 }
655
656 /* Revert to reading a previous source file.  Generate a N_EINCL stab.  */
657
658 static void
659 dbxout_end_source_file (unsigned int line ATTRIBUTE_UNUSED)
660 {
661 #ifdef DBX_USE_BINCL
662   /* Emit EINCL stab only if BINCL is not pending.  */
663   if (current_file->bincl_status == BINCL_PROCESSED)
664     fprintf (asmfile, "%s%d,0,0,0\n", ASM_STABN_OP, N_EINCL);
665   current_file->bincl_status = BINCL_NOT_REQUIRED;
666   current_file = current_file->next;
667 #endif
668 }
669
670 /* Handle a few odd cases that occur when trying to make PCH files work.  */
671
672 static void
673 dbxout_handle_pch (unsigned at_end)
674 {
675   if (! at_end)
676     {
677       /* When using the PCH, this file will be included, so we need to output
678          a BINCL.  */
679       dbxout_start_source_file (0, lastfile);
680
681       /* The base file when using the PCH won't be the same as
682          the base file when it's being generated.  */
683       lastfile = NULL;
684     }
685   else
686     {
687       /* ... and an EINCL.  */
688       dbxout_end_source_file (0);
689
690       /* Deal with cases where 'lastfile' was never actually changed.  */
691       lastfile_is_base = lastfile == NULL;
692     }
693 }
694
695 #if defined (DBX_DEBUGGING_INFO)
696 /* Output debugging info to FILE to switch to sourcefile FILENAME.  */
697
698 static void
699 dbxout_source_file (FILE *file, const char *filename)
700 {
701   if (lastfile == 0 && lastfile_is_base)
702     {
703       lastfile = base_input_file;
704       lastfile_is_base = 0;
705     }
706
707   if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
708     {
709       char ltext_label_name[100];
710
711       ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
712                                    source_label_number);
713       fprintf (file, "%s", ASM_STABS_OP);
714       output_quoted_string (file, filename);
715       fprintf (asmfile, ",%d,0,0,", N_SOL);
716       assemble_name (asmfile, ltext_label_name);
717       fputc ('\n', asmfile);
718       if (current_function_decl != NULL_TREE
719           && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
720         ; /* Don't change section amid function.  */
721       else
722         text_section ();
723       (*targetm.asm_out.internal_label) (file, "Ltext", source_label_number);
724       source_label_number++;
725       lastfile = filename;
726     }
727 }
728
729 /* Output a line number symbol entry for source file FILENAME and line
730    number LINENO.  */
731
732 static void
733 dbxout_source_line (unsigned int lineno, const char *filename)
734 {
735   dbxout_source_file (asmfile, filename);
736
737 #ifdef ASM_OUTPUT_SOURCE_LINE
738   dbxout_source_line_counter += 1;
739   ASM_OUTPUT_SOURCE_LINE (asmfile, lineno, dbxout_source_line_counter);
740 #else
741   fprintf (asmfile, "%s%d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
742 #endif
743 }
744
745 /* Describe the beginning of an internal block within a function.  */
746
747 static void
748 dbxout_begin_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
749 {
750   emit_pending_bincls_if_required ();
751   (*targetm.asm_out.internal_label) (asmfile, "LBB", n);
752 }
753
754 /* Describe the end line-number of an internal block within a function.  */
755
756 static void
757 dbxout_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int n)
758 {
759   emit_pending_bincls_if_required ();
760   (*targetm.asm_out.internal_label) (asmfile, "LBE", n);
761 }
762
763 /* Output dbx data for a function definition.
764    This includes a definition of the function name itself (a symbol),
765    definitions of the parameters (locating them in the parameter list)
766    and then output the block that makes up the function's body
767    (including all the auto variables of the function).  */
768
769 static void
770 dbxout_function_decl (tree decl)
771 {
772   emit_pending_bincls_if_required ();
773 #ifndef DBX_FUNCTION_FIRST
774   dbxout_begin_function (decl);
775 #endif
776   dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
777 #ifdef DBX_OUTPUT_FUNCTION_END
778   DBX_OUTPUT_FUNCTION_END (asmfile, decl);
779 #endif
780   if (use_gnu_debug_info_extensions
781 #if defined(NO_DBX_FUNCTION_END)
782       && ! NO_DBX_FUNCTION_END
783 #endif
784       && targetm.have_named_sections)
785     dbxout_function_end ();
786 }
787
788 #endif /* DBX_DEBUGGING_INFO  */
789
790 /* Debug information for a global DECL.  Called from toplev.c after
791    compilation proper has finished.  */
792 static void
793 dbxout_global_decl (tree decl)
794 {
795   if (TREE_CODE (decl) == VAR_DECL
796       && ! DECL_EXTERNAL (decl)
797       && DECL_RTL_SET_P (decl)) /* Not necessary?  */
798     {
799       int saved_tree_used = TREE_USED (decl);
800       TREE_USED (decl) = 1;
801       dbxout_symbol (decl, 0);
802       TREE_USED (decl) = saved_tree_used;
803     }
804 }
805
806 /* At the end of compilation, finish writing the symbol table.
807    Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
808    to do nothing.  */
809
810 static void
811 dbxout_finish (const char *filename ATTRIBUTE_UNUSED)
812 {
813 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
814   DBX_OUTPUT_MAIN_SOURCE_FILE_END (asmfile, filename);
815 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
816
817   debug_free_queue ();
818 }
819
820 /* Output the index of a type.  */
821
822 static void
823 dbxout_type_index (tree type)
824 {
825 #ifndef DBX_USE_BINCL
826   fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
827   CHARS (3);
828 #else
829   struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
830   fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number);
831   CHARS (9);
832 #endif
833 }
834
835 #if DBX_CONTIN_LENGTH > 0
836 /* Continue a symbol-description that gets too big.
837    End one symbol table entry with a double-backslash
838    and start a new one, eventually producing something like
839    .stabs "start......\\",code,0,value
840    .stabs "...rest",code,0,value   */
841
842 static void
843 dbxout_continue (void)
844 {
845   emit_pending_bincls_if_required ();
846 #ifdef DBX_CONTIN_CHAR
847   fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
848 #else
849   fprintf (asmfile, "\\\\");
850 #endif
851   dbxout_finish_symbol (NULL_TREE);
852   fprintf (asmfile, "%s\"", ASM_STABS_OP);
853   current_sym_nchars = 0;
854 }
855 #endif /* DBX_CONTIN_LENGTH > 0 */
856 \f
857 /* Subroutine of `dbxout_type'.  Output the type fields of TYPE.
858    This must be a separate function because anonymous unions require
859    recursive calls.  */
860
861 static void
862 dbxout_type_fields (tree type)
863 {
864   tree tem;
865
866   /* Output the name, type, position (in bits), size (in bits) of each
867      field that we can support.  */
868   for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
869     {
870
871       /* If on of the nodes is an error_mark or its type is then return early. */
872       if (tem == error_mark_node || TREE_TYPE (tem) == error_mark_node)
873         return;
874
875       /* Omit here local type decls until we know how to support them.  */
876       if (TREE_CODE (tem) == TYPE_DECL
877           /* Omit fields whose position or size are variable or too large to
878              represent.  */
879           || (TREE_CODE (tem) == FIELD_DECL
880               && (! host_integerp (bit_position (tem), 0)
881                   || ! DECL_SIZE (tem)
882                   || ! host_integerp (DECL_SIZE (tem), 1)))
883           /* Omit here the nameless fields that are used to skip bits.  */
884            || DECL_IGNORED_P (tem))
885         continue;
886
887       else if (TREE_CODE (tem) != CONST_DECL)
888         {
889           /* Continue the line if necessary,
890              but not before the first field.  */
891           if (tem != TYPE_FIELDS (type))
892             CONTIN;
893
894           if (DECL_NAME (tem))
895             {
896               fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
897               CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
898             }
899           else
900             {
901               fprintf (asmfile, ":");
902               CHARS (1);
903             }
904
905           if (use_gnu_debug_info_extensions
906               && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
907                   || TREE_CODE (tem) != FIELD_DECL))
908             {
909               have_used_extensions = 1;
910               putc ('/', asmfile);
911               putc ((TREE_PRIVATE (tem) ? '0'
912                      : TREE_PROTECTED (tem) ? '1' : '2'),
913                     asmfile);
914               CHARS (2);
915             }
916
917           dbxout_type ((TREE_CODE (tem) == FIELD_DECL
918                         && DECL_BIT_FIELD_TYPE (tem))
919                        ? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 0);
920
921           if (TREE_CODE (tem) == VAR_DECL)
922             {
923               if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
924                 {
925                   tree name = DECL_ASSEMBLER_NAME (tem);
926
927                   have_used_extensions = 1;
928                   fprintf (asmfile, ":%s;", IDENTIFIER_POINTER (name));
929                   CHARS (IDENTIFIER_LENGTH (name) + 2);
930                 }
931               else
932                 {
933                   /* If TEM is non-static, GDB won't understand it.  */
934                   fprintf (asmfile, ",0,0;");
935                   CHARS (5);
936                 }
937             }
938           else
939             {
940               putc (',', asmfile);
941               print_wide_int (int_bit_position (tem));
942               putc (',', asmfile);
943               print_wide_int (tree_low_cst (DECL_SIZE (tem), 1));
944               putc (';', asmfile);
945               CHARS (3);
946             }
947         }
948     }
949 }
950 \f
951 /* Subroutine of `dbxout_type_methods'.  Output debug info about the
952    method described DECL.  DEBUG_NAME is an encoding of the method's
953    type signature.  ??? We may be able to do without DEBUG_NAME altogether
954    now.  */
955
956 static void
957 dbxout_type_method_1 (tree decl, const char *debug_name)
958 {
959   char c1 = 'A', c2;
960
961   if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
962     c2 = '?';
963   else /* it's a METHOD_TYPE.  */
964     {
965       tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
966       /* A for normal functions.
967          B for `const' member functions.
968          C for `volatile' member functions.
969          D for `const volatile' member functions.  */
970       if (TYPE_READONLY (TREE_TYPE (firstarg)))
971         c1 += 1;
972       if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
973         c1 += 2;
974
975       if (DECL_VINDEX (decl))
976         c2 = '*';
977       else
978         c2 = '.';
979     }
980
981   fprintf (asmfile, ":%s;%c%c%c", debug_name,
982            TREE_PRIVATE (decl) ? '0'
983            : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
984   CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
985          - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
986
987   if (DECL_VINDEX (decl) && host_integerp (DECL_VINDEX (decl), 0))
988     {
989       print_wide_int (tree_low_cst (DECL_VINDEX (decl), 0));
990       putc (';', asmfile);
991       CHARS (1);
992       dbxout_type (DECL_CONTEXT (decl), 0);
993       fprintf (asmfile, ";");
994       CHARS (1);
995     }
996 }
997 \f
998 /* Subroutine of `dbxout_type'.  Output debug info about the methods defined
999    in TYPE.  */
1000
1001 static void
1002 dbxout_type_methods (tree type)
1003 {
1004   /* C++: put out the method names and their parameter lists */
1005   tree methods = TYPE_METHODS (type);
1006   tree type_encoding;
1007   tree fndecl;
1008   tree last;
1009   char formatted_type_identifier_length[16];
1010   int type_identifier_length;
1011
1012   if (methods == NULL_TREE)
1013     return;
1014
1015   type_encoding = DECL_NAME (TYPE_NAME (type));
1016
1017 #if 0
1018   /* C++: Template classes break some assumptions made by this code about
1019      the class names, constructor names, and encodings for assembler
1020      label names.  For now, disable output of dbx info for them.  */
1021   {
1022     const char *ptr = IDENTIFIER_POINTER (type_encoding);
1023     /* This should use index.  (mrs) */
1024     while (*ptr && *ptr != '<') ptr++;
1025     if (*ptr != 0)
1026       {
1027         static int warned;
1028         if (!warned)
1029             warned = 1;
1030         return;
1031       }
1032   }
1033 #endif
1034
1035   type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
1036
1037   sprintf (formatted_type_identifier_length, "%d", type_identifier_length);
1038
1039   if (TREE_CODE (methods) != TREE_VEC)
1040     fndecl = methods;
1041   else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
1042     fndecl = TREE_VEC_ELT (methods, 0);
1043   else
1044     fndecl = TREE_VEC_ELT (methods, 1);
1045
1046   while (fndecl)
1047     {
1048       int need_prefix = 1;
1049
1050       /* Group together all the methods for the same operation.
1051          These differ in the types of the arguments.  */
1052       for (last = NULL_TREE;
1053            fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
1054            fndecl = TREE_CHAIN (fndecl))
1055         /* Output the name of the field (after overloading), as
1056            well as the name of the field before overloading, along
1057            with its parameter list */
1058         {
1059           /* This is the "mangled" name of the method.
1060              It encodes the argument types.  */
1061           const char *debug_name;
1062
1063           /* Skip methods that aren't FUNCTION_DECLs.  (In C++, these
1064              include TEMPLATE_DECLs.)  The debugger doesn't know what
1065              to do with such entities anyhow.  */
1066           if (TREE_CODE (fndecl) != FUNCTION_DECL)
1067             continue;
1068
1069           debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
1070
1071           CONTIN;
1072
1073           last = fndecl;
1074
1075           /* Also ignore abstract methods; those are only interesting to
1076              the DWARF backends.  */
1077           if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT (fndecl))
1078             continue;
1079
1080           /* Redundantly output the plain name, since that's what gdb
1081              expects.  */
1082           if (need_prefix)
1083             {
1084               tree name = DECL_NAME (fndecl);
1085               fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
1086               CHARS (IDENTIFIER_LENGTH (name) + 2);
1087               need_prefix = 0;
1088             }
1089
1090           dbxout_type (TREE_TYPE (fndecl), 0);
1091
1092           dbxout_type_method_1 (fndecl, debug_name);
1093         }
1094       if (!need_prefix)
1095         {
1096           putc (';', asmfile);
1097           CHARS (1);
1098         }
1099     }
1100 }
1101
1102 /* Emit a "range" type specification, which has the form:
1103    "r<index type>;<lower bound>;<upper bound>;".
1104    TYPE is an INTEGER_TYPE.  */
1105
1106 static void
1107 dbxout_range_type (tree type)
1108 {
1109   fprintf (asmfile, "r");
1110   if (TREE_TYPE (type))
1111     dbxout_type (TREE_TYPE (type), 0);
1112   else if (TREE_CODE (type) != INTEGER_TYPE)
1113     dbxout_type (type, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1114   else
1115     {
1116       /* Traditionally, we made sure 'int' was type 1, and builtin types
1117          were defined to be sub-ranges of int.  Unfortunately, this
1118          does not allow us to distinguish true sub-ranges from integer
1119          types.  So, instead we define integer (non-sub-range) types as
1120          sub-ranges of themselves.  This matters for Chill.  If this isn't
1121          a subrange type, then we want to define it in terms of itself.
1122          However, in C, this may be an anonymous integer type, and we don't
1123          want to emit debug info referring to it.  Just calling
1124          dbxout_type_index won't work anyways, because the type hasn't been
1125          defined yet.  We make this work for both cases by checked to see
1126          whether this is a defined type, referring to it if it is, and using
1127          'int' otherwise.  */
1128       if (TYPE_SYMTAB_ADDRESS (type) != 0)
1129         dbxout_type_index (type);
1130       else
1131         dbxout_type_index (integer_type_node);
1132     }
1133
1134   if (TYPE_MIN_VALUE (type) != 0
1135       && host_integerp (TYPE_MIN_VALUE (type), 0))
1136     {
1137       putc (';', asmfile);
1138       CHARS (1);
1139       if (print_int_cst_bounds_in_octal_p (type))
1140         print_int_cst_octal (TYPE_MIN_VALUE (type));
1141       else
1142         print_wide_int (tree_low_cst (TYPE_MIN_VALUE (type), 0));
1143     }
1144   else
1145     {
1146       fprintf (asmfile, ";0");
1147       CHARS (2);
1148     }
1149
1150   if (TYPE_MAX_VALUE (type) != 0
1151       && host_integerp (TYPE_MAX_VALUE (type), 0))
1152     {
1153       putc (';', asmfile);
1154       CHARS (1);
1155       if (print_int_cst_bounds_in_octal_p (type))
1156         print_int_cst_octal (TYPE_MAX_VALUE (type));
1157       else
1158         print_wide_int (tree_low_cst (TYPE_MAX_VALUE (type), 0));
1159       putc (';', asmfile);
1160       CHARS (1);
1161     }
1162   else
1163     {
1164       fprintf (asmfile, ";-1;");
1165       CHARS (4);
1166     }
1167 }
1168 \f
1169
1170 /* Output a reference to a type.  If the type has not yet been
1171    described in the dbx output, output its definition now.
1172    For a type already defined, just refer to its definition
1173    using the type number.
1174
1175    If FULL is nonzero, and the type has been described only with
1176    a forward-reference, output the definition now.
1177    If FULL is zero in this case, just refer to the forward-reference
1178    using the number previously allocated.  */
1179
1180 static void
1181 dbxout_type (tree type, int full)
1182 {
1183   tree tem;
1184   tree main_variant;
1185   static int anonymous_type_number = 0;
1186
1187   if (TREE_CODE (type) == VECTOR_TYPE)
1188     /* The frontend feeds us a representation for the vector as a struct
1189        containing an array.  Pull out the array type.  */
1190     type = TREE_TYPE (TYPE_FIELDS (TYPE_DEBUG_REPRESENTATION_TYPE (type)));
1191
1192   /* If there was an input error and we don't really have a type,
1193      avoid crashing and write something that is at least valid
1194      by assuming `int'.  */
1195   if (type == error_mark_node)
1196     type = integer_type_node;
1197   else
1198     {
1199       if (TYPE_NAME (type)
1200           && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1201           && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1202         full = 0;
1203     }
1204
1205   /* Try to find the "main variant" with the same name.  */
1206   if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1207       && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1208     main_variant = TREE_TYPE (TYPE_NAME (type));
1209   else
1210     main_variant = TYPE_MAIN_VARIANT (type);
1211
1212   /* If we are not using extensions, stabs does not distinguish const and
1213      volatile, so there is no need to make them separate types.  */
1214   if (!use_gnu_debug_info_extensions)
1215     type = main_variant;
1216
1217   if (TYPE_SYMTAB_ADDRESS (type) == 0)
1218     {
1219       /* Type has no dbx number assigned.  Assign next available number.  */
1220       TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1221
1222       /* Make sure type vector is long enough to record about this type.  */
1223
1224       if (next_type_number == typevec_len)
1225         {
1226           typevec
1227             = ggc_realloc (typevec, (typevec_len * 2 * sizeof typevec[0]));
1228           memset (typevec + typevec_len, 0, typevec_len * sizeof typevec[0]);
1229           typevec_len *= 2;
1230         }
1231
1232 #ifdef DBX_USE_BINCL
1233       emit_pending_bincls_if_required ();
1234       typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1235         = current_file->file_number;
1236       typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1237         = current_file->next_type_number++;
1238 #endif
1239     }
1240
1241   if (flag_debug_only_used_symbols)
1242     {
1243       if ((TREE_CODE (type) == RECORD_TYPE
1244            || TREE_CODE (type) == UNION_TYPE
1245            || TREE_CODE (type) == QUAL_UNION_TYPE
1246            || TREE_CODE (type) == ENUMERAL_TYPE)
1247           && TYPE_STUB_DECL (type)
1248           && TREE_CODE_CLASS (TREE_CODE (TYPE_STUB_DECL (type))) == 'd'
1249           && ! DECL_IGNORED_P (TYPE_STUB_DECL (type)))
1250         debug_queue_symbol (TYPE_STUB_DECL (type));
1251       else if (TYPE_NAME (type)
1252                && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1253         debug_queue_symbol (TYPE_NAME (type));
1254     }
1255
1256   /* Output the number of this type, to refer to it.  */
1257   dbxout_type_index (type);
1258
1259 #ifdef DBX_TYPE_DEFINED
1260   if (DBX_TYPE_DEFINED (type))
1261     return;
1262 #endif
1263
1264   /* If this type's definition has been output or is now being output,
1265      that is all.  */
1266
1267   switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1268     {
1269     case TYPE_UNSEEN:
1270       break;
1271     case TYPE_XREF:
1272       /* If we have already had a cross reference,
1273          and either that's all we want or that's the best we could do,
1274          don't repeat the cross reference.
1275          Sun dbx crashes if we do.  */
1276       if (! full || !COMPLETE_TYPE_P (type)
1277           /* No way in DBX fmt to describe a variable size.  */
1278           || ! host_integerp (TYPE_SIZE (type), 1))
1279         return;
1280       break;
1281     case TYPE_DEFINED:
1282       return;
1283     }
1284
1285 #ifdef DBX_NO_XREFS
1286   /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1287      leave the type-number completely undefined rather than output
1288      a cross-reference.  If we have already used GNU debug info extensions,
1289      then it is OK to output a cross reference.  This is necessary to get
1290      proper C++ debug output.  */
1291   if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1292        || TREE_CODE (type) == QUAL_UNION_TYPE
1293        || TREE_CODE (type) == ENUMERAL_TYPE)
1294       && ! use_gnu_debug_info_extensions)
1295     /* We must use the same test here as we use twice below when deciding
1296        whether to emit a cross-reference.  */
1297     if ((TYPE_NAME (type) != 0
1298          && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1299                && DECL_IGNORED_P (TYPE_NAME (type)))
1300          && !full)
1301         || !COMPLETE_TYPE_P (type)
1302         /* No way in DBX fmt to describe a variable size.  */
1303         || ! host_integerp (TYPE_SIZE (type), 1))
1304       {
1305         typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1306         return;
1307       }
1308 #endif
1309
1310   /* Output a definition now.  */
1311
1312   fprintf (asmfile, "=");
1313   CHARS (1);
1314
1315   /* Mark it as defined, so that if it is self-referent
1316      we will not get into an infinite recursion of definitions.  */
1317
1318   typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1319
1320   /* If this type is a variant of some other, hand off.  Types with
1321      different names are usefully distinguished.  We only distinguish
1322      cv-qualified types if we're using extensions.  */
1323   if (TYPE_READONLY (type) > TYPE_READONLY (main_variant))
1324     {
1325       putc ('k', asmfile);
1326       CHARS (1);
1327       dbxout_type (build_type_variant (type, 0, TYPE_VOLATILE (type)), 0);
1328       return;
1329     }
1330   else if (TYPE_VOLATILE (type) > TYPE_VOLATILE (main_variant))
1331     {
1332       putc ('B', asmfile);
1333       CHARS (1);
1334       dbxout_type (build_type_variant (type, TYPE_READONLY (type), 0), 0);
1335       return;
1336     }
1337   else if (main_variant != TYPE_MAIN_VARIANT (type))
1338     {
1339       if (flag_debug_only_used_symbols)
1340         {
1341           tree orig_type = DECL_ORIGINAL_TYPE (TYPE_NAME (type));
1342
1343           if ((TREE_CODE (orig_type) == RECORD_TYPE
1344                || TREE_CODE (orig_type) == UNION_TYPE
1345                || TREE_CODE (orig_type) == QUAL_UNION_TYPE
1346                || TREE_CODE (orig_type) == ENUMERAL_TYPE)
1347               && TYPE_STUB_DECL (orig_type)
1348               && ! DECL_IGNORED_P (TYPE_STUB_DECL (orig_type)))
1349             debug_queue_symbol (TYPE_STUB_DECL (orig_type));
1350         }
1351       /* 'type' is a typedef; output the type it refers to.  */
1352       dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0);
1353       return;
1354     }
1355   /* else continue.  */
1356
1357   switch (TREE_CODE (type))
1358     {
1359     case VOID_TYPE:
1360     case LANG_TYPE:
1361       /* For a void type, just define it as itself; ie, "5=5".
1362          This makes us consider it defined
1363          without saying what it is.  The debugger will make it
1364          a void type when the reference is seen, and nothing will
1365          ever override that default.  */
1366       dbxout_type_index (type);
1367       break;
1368
1369     case INTEGER_TYPE:
1370       if (type == char_type_node && ! TREE_UNSIGNED (type))
1371         {
1372           /* Output the type `char' as a subrange of itself!
1373              I don't understand this definition, just copied it
1374              from the output of pcc.
1375              This used to use `r2' explicitly and we used to
1376              take care to make sure that `char' was type number 2.  */
1377           fprintf (asmfile, "r");
1378           CHARS (1);
1379           dbxout_type_index (type);
1380           fprintf (asmfile, ";0;127;");
1381           CHARS (7);
1382         }
1383
1384       /* If this is a subtype of another integer type, always prefer to
1385          write it as a subtype.  */
1386       else if (TREE_TYPE (type) != 0
1387                && TREE_CODE (TREE_TYPE (type)) == INTEGER_TYPE)
1388         {
1389           /* If the size is non-standard, say what it is if we can use
1390              GDB extensions.  */
1391
1392           if (use_gnu_debug_info_extensions
1393               && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1394             {
1395               have_used_extensions = 1;
1396               fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1397               CHARS (5);
1398             }
1399
1400           dbxout_range_type (type);
1401         }
1402
1403       else
1404         {
1405           /* If the size is non-standard, say what it is if we can use
1406              GDB extensions.  */
1407
1408           if (use_gnu_debug_info_extensions
1409               && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1410             {
1411               have_used_extensions = 1;
1412               fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1413               CHARS (5);
1414             }
1415
1416           if (print_int_cst_bounds_in_octal_p (type))
1417             {
1418               fprintf (asmfile, "r");
1419               CHARS (1);
1420
1421               /* If this type derives from another type, output type index of
1422                  parent type. This is particularly important when parent type
1423                  is an enumerated type, because not generating the parent type
1424                  index would transform the definition of this enumerated type
1425                  into a plain unsigned type.  */
1426               if (TREE_TYPE (type) != 0)
1427                 dbxout_type_index (TREE_TYPE (type));
1428               else
1429                 dbxout_type_index (type);
1430
1431               fprintf (asmfile, ";");
1432               CHARS (1);
1433               print_int_cst_octal (TYPE_MIN_VALUE (type));
1434               fprintf (asmfile, ";");
1435               CHARS (1);
1436               print_int_cst_octal (TYPE_MAX_VALUE (type));
1437               fprintf (asmfile, ";");
1438               CHARS (1);
1439             }
1440
1441           else
1442             /* Output other integer types as subranges of `int'.  */
1443             dbxout_range_type (type);
1444         }
1445
1446       break;
1447
1448     case REAL_TYPE:
1449       /* This used to say `r1' and we used to take care
1450          to make sure that `int' was type number 1.  */
1451       fprintf (asmfile, "r");
1452       CHARS (1);
1453       dbxout_type_index (integer_type_node);
1454       putc (';', asmfile);
1455       CHARS (1);
1456       print_wide_int (int_size_in_bytes (type));
1457       fputs (";0;", asmfile);
1458       CHARS (3);
1459       break;
1460
1461     case CHAR_TYPE:
1462       if (use_gnu_debug_info_extensions)
1463         {
1464           have_used_extensions = 1;
1465           fputs ("@s", asmfile);
1466           CHARS (2);
1467           print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1468           fputs (";-20;", asmfile);
1469           CHARS (4);
1470         }
1471       else
1472         {
1473           /* Output the type `char' as a subrange of itself.
1474              That is what pcc seems to do.  */
1475           fprintf (asmfile, "r");
1476           CHARS (1);
1477           dbxout_type_index (char_type_node);
1478           fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1479           CHARS (7);
1480         }
1481       break;
1482
1483     case BOOLEAN_TYPE:
1484       if (use_gnu_debug_info_extensions)
1485         {
1486           have_used_extensions = 1;
1487           fputs ("@s", asmfile);
1488           CHARS (2);
1489           print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1490           fputs (";-16;", asmfile);
1491           CHARS (4);
1492         }
1493       else /* Define as enumeral type (False, True) */
1494         {
1495           fprintf (asmfile, "eFalse:0,True:1,;");
1496           CHARS (17);
1497         }
1498       break;
1499
1500     case FILE_TYPE:
1501       putc ('d', asmfile);
1502       CHARS (1);
1503       dbxout_type (TREE_TYPE (type), 0);
1504       break;
1505
1506     case COMPLEX_TYPE:
1507       /* Differs from the REAL_TYPE by its new data type number.
1508          R3 is NF_COMPLEX.  We don't try to use any of the other NF_*
1509          codes since gdb doesn't care anyway.  */
1510
1511       if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1512         {
1513           fputs ("R3;", asmfile);
1514           CHARS (3);
1515           print_wide_int (2 * int_size_in_bytes (TREE_TYPE (type)));
1516           fputs (";0;", asmfile);
1517           CHARS (3);
1518         }
1519       else
1520         {
1521           /* Output a complex integer type as a structure,
1522              pending some other way to do it.  */
1523           putc ('s', asmfile);
1524           CHARS (1);
1525           print_wide_int (int_size_in_bytes (type));
1526           fprintf (asmfile, "real:");
1527           CHARS (5);
1528
1529           dbxout_type (TREE_TYPE (type), 0);
1530           fprintf (asmfile, ",0,%d;", TYPE_PRECISION (TREE_TYPE (type)));
1531           CHARS (7);
1532           fprintf (asmfile, "imag:");
1533           CHARS (5);
1534           dbxout_type (TREE_TYPE (type), 0);
1535           fprintf (asmfile, ",%d,%d;;", TYPE_PRECISION (TREE_TYPE (type)),
1536                    TYPE_PRECISION (TREE_TYPE (type)));
1537           CHARS (10);
1538         }
1539       break;
1540
1541     case SET_TYPE:
1542       if (use_gnu_debug_info_extensions)
1543         {
1544           have_used_extensions = 1;
1545           fputs ("@s", asmfile);
1546           CHARS (2);
1547           print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1548           putc (';', asmfile);
1549           CHARS (1);
1550
1551           /* Check if a bitstring type, which in Chill is
1552              different from a [power]set.  */
1553           if (TYPE_STRING_FLAG (type))
1554             {
1555               fprintf (asmfile, "@S;");
1556               CHARS (3);
1557             }
1558         }
1559       putc ('S', asmfile);
1560       CHARS (1);
1561       dbxout_type (TYPE_DOMAIN (type), 0);
1562       break;
1563
1564     case ARRAY_TYPE:
1565       /* Make arrays of packed bits look like bitstrings for chill.  */
1566       if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
1567         {
1568           have_used_extensions = 1;
1569           fputs ("@s", asmfile);
1570           CHARS (2);
1571           print_wide_int (BITS_PER_UNIT * int_size_in_bytes (type));
1572           fprintf (asmfile, ";@S;S");
1573           CHARS (5);
1574           dbxout_type (TYPE_DOMAIN (type), 0);
1575           break;
1576         }
1577
1578       /* Output "a" followed by a range type definition
1579          for the index type of the array
1580          followed by a reference to the target-type.
1581          ar1;0;N;M for a C array of type M and size N+1.  */
1582       /* Check if a character string type, which in Chill is
1583          different from an array of characters.  */
1584       if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1585         {
1586           have_used_extensions = 1;
1587           fprintf (asmfile, "@S;");
1588           CHARS (3);
1589         }
1590       tem = TYPE_DOMAIN (type);
1591       if (tem == NULL)
1592         {
1593           fprintf (asmfile, "ar");
1594           CHARS (2);
1595           dbxout_type_index (integer_type_node);
1596           fprintf (asmfile, ";0;-1;");
1597           CHARS (6);
1598         }
1599       else
1600         {
1601           fprintf (asmfile, "a");
1602           CHARS (1);
1603           dbxout_range_type (tem);
1604         }
1605
1606       dbxout_type (TREE_TYPE (type), 0);
1607       break;
1608
1609     case RECORD_TYPE:
1610     case UNION_TYPE:
1611     case QUAL_UNION_TYPE:
1612       {
1613         int i, n_baseclasses = 0;
1614
1615         if (TYPE_BINFO (type) != 0
1616             && TREE_CODE (TYPE_BINFO (type)) == TREE_VEC
1617             && TYPE_BINFO_BASETYPES (type) != 0)
1618           n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1619
1620         /* Output a structure type.  We must use the same test here as we
1621            use in the DBX_NO_XREFS case above.  */
1622         if ((TYPE_NAME (type) != 0
1623              && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1624                    && DECL_IGNORED_P (TYPE_NAME (type)))
1625              && !full)
1626             || !COMPLETE_TYPE_P (type)
1627             /* No way in DBX fmt to describe a variable size.  */
1628             || ! host_integerp (TYPE_SIZE (type), 1))
1629           {
1630             /* If the type is just a cross reference, output one
1631                and mark the type as partially described.
1632                If it later becomes defined, we will output
1633                its real definition.
1634                If the type has a name, don't nest its definition within
1635                another type's definition; instead, output an xref
1636                and let the definition come when the name is defined.  */
1637             fputs ((TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu", asmfile);
1638             CHARS (2);
1639 #if 0 /* This assertion is legitimately false in C++.  */
1640             /* We shouldn't be outputting a reference to a type before its
1641                definition unless the type has a tag name.
1642                A typedef name without a tag name should be impossible.  */
1643             if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1644               abort ();
1645 #endif
1646             if (TYPE_NAME (type) != 0)
1647               dbxout_type_name (type);
1648             else
1649               {
1650                 fprintf (asmfile, "$$%d", anonymous_type_number++);
1651                 CHARS (5);
1652               }
1653
1654             fprintf (asmfile, ":");
1655             CHARS (1);
1656             typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1657             break;
1658           }
1659
1660         /* Identify record or union, and print its size.  */
1661         putc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asmfile);
1662         CHARS (1);
1663         print_wide_int (int_size_in_bytes (type));
1664
1665         if (use_gnu_debug_info_extensions)
1666           {
1667             if (n_baseclasses)
1668               {
1669                 have_used_extensions = 1;
1670                 fprintf (asmfile, "!%d,", n_baseclasses);
1671                 CHARS (8);
1672               }
1673           }
1674         for (i = 0; i < n_baseclasses; i++)
1675           {
1676             tree binfo = TYPE_BINFO (type);
1677             tree child = BINFO_BASETYPE (binfo, i);
1678             tree access = (BINFO_BASEACCESSES (binfo)
1679                            ? BINFO_BASEACCESS (binfo, i) : access_public_node);
1680
1681             if (use_gnu_debug_info_extensions)
1682               {
1683                 have_used_extensions = 1;
1684                 putc (TREE_VIA_VIRTUAL (child) ? '1' : '0', asmfile);
1685                 putc (access == access_public_node ? '2' :
1686                       (access == access_protected_node ? '1' :'0'),
1687                       asmfile);
1688                 CHARS (2);
1689                 if (TREE_VIA_VIRTUAL (child)
1690                     && strcmp (lang_hooks.name, "GNU C++") == 0)
1691                   /* For a virtual base, print the (negative) offset within
1692                      the vtable where we must look to find the necessary
1693                      adjustment.  */
1694                   print_wide_int (tree_low_cst (BINFO_VPTR_FIELD (child), 0)
1695                                   * BITS_PER_UNIT);
1696                 else
1697                   print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1698                                   * BITS_PER_UNIT);
1699                 putc (',', asmfile);
1700                 CHARS (1);
1701                 dbxout_type (BINFO_TYPE (child), 0);
1702                 putc (';', asmfile);
1703                 CHARS (1);
1704               }
1705             else
1706               {
1707                 /* Print out the base class information with fields
1708                    which have the same names at the types they hold.  */
1709                 dbxout_type_name (BINFO_TYPE (child));
1710                 putc (':', asmfile);
1711                 CHARS (1);
1712                 dbxout_type (BINFO_TYPE (child), full);
1713                 putc (',', asmfile);
1714                 CHARS (1);
1715                 print_wide_int (tree_low_cst (BINFO_OFFSET (child), 0)
1716                                 * BITS_PER_UNIT);
1717                 putc (',', asmfile);
1718                 CHARS (1);
1719                 print_wide_int (tree_low_cst (TYPE_SIZE (BINFO_TYPE (child)),
1720                                               0)
1721                                 * BITS_PER_UNIT);
1722                 putc (';', asmfile);
1723                 CHARS (1);
1724               }
1725           }
1726       }
1727
1728       /* Write out the field declarations.  */
1729       dbxout_type_fields (type);
1730       if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1731         {
1732           have_used_extensions = 1;
1733           dbxout_type_methods (type);
1734         }
1735
1736       putc (';', asmfile);
1737       CHARS (1);
1738
1739       if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1740           /* Avoid the ~ if we don't really need it--it confuses dbx.  */
1741           && TYPE_VFIELD (type))
1742         {
1743           have_used_extensions = 1;
1744
1745           /* Tell GDB+ that it may keep reading.  */
1746           putc ('~', asmfile);
1747           CHARS (1);
1748
1749           /* We need to write out info about what field this class
1750              uses as its "main" vtable pointer field, because if this
1751              field is inherited from a base class, GDB cannot necessarily
1752              figure out which field it's using in time.  */
1753           if (TYPE_VFIELD (type))
1754             {
1755               putc ('%', asmfile);
1756               CHARS (1);
1757               dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0);
1758             }
1759
1760           putc (';', asmfile);
1761           CHARS (1);
1762         }
1763       break;
1764
1765     case ENUMERAL_TYPE:
1766       /* We must use the same test here as we use in the DBX_NO_XREFS case
1767          above.  We simplify it a bit since an enum will never have a variable
1768          size.  */
1769       if ((TYPE_NAME (type) != 0
1770            && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1771                  && DECL_IGNORED_P (TYPE_NAME (type)))
1772            && !full)
1773           || !COMPLETE_TYPE_P (type))
1774         {
1775           fprintf (asmfile, "xe");
1776           CHARS (2);
1777           dbxout_type_name (type);
1778           typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1779           putc (':', asmfile);
1780           CHARS (1);
1781           return;
1782         }
1783       if (use_gnu_debug_info_extensions
1784           && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1785         {
1786           fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1787           CHARS (5);
1788         }
1789
1790       putc ('e', asmfile);
1791       CHARS (1);
1792       for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1793         {
1794           fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1795           CHARS (IDENTIFIER_LENGTH (TREE_PURPOSE (tem)) + 1);
1796           if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1797             print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1798           else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1799                    && (HOST_WIDE_INT) TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1800             print_wide_int (TREE_INT_CST_LOW (TREE_VALUE (tem)));
1801           else
1802             print_int_cst_octal (TREE_VALUE (tem));
1803
1804           putc (',', asmfile);
1805           CHARS (1);
1806           if (TREE_CHAIN (tem) != 0)
1807             CONTIN;
1808         }
1809
1810       putc (';', asmfile);
1811       CHARS (1);
1812       break;
1813
1814     case POINTER_TYPE:
1815       putc ('*', asmfile);
1816       CHARS (1);
1817       dbxout_type (TREE_TYPE (type), 0);
1818       break;
1819
1820     case METHOD_TYPE:
1821       if (use_gnu_debug_info_extensions)
1822         {
1823           have_used_extensions = 1;
1824           putc ('#', asmfile);
1825           CHARS (1);
1826
1827           /* Write the argument types out longhand.  */
1828           dbxout_type (TYPE_METHOD_BASETYPE (type), 0);
1829           putc (',', asmfile);
1830           CHARS (1);
1831           dbxout_type (TREE_TYPE (type), 0);
1832           dbxout_args (TYPE_ARG_TYPES (type));
1833           putc (';', asmfile);
1834           CHARS (1);
1835         }
1836       else
1837         /* Treat it as a function type.  */
1838         dbxout_type (TREE_TYPE (type), 0);
1839       break;
1840
1841     case OFFSET_TYPE:
1842       if (use_gnu_debug_info_extensions)
1843         {
1844           have_used_extensions = 1;
1845           putc ('@', asmfile);
1846           CHARS (1);
1847           dbxout_type (TYPE_OFFSET_BASETYPE (type), 0);
1848           putc (',', asmfile);
1849           CHARS (1);
1850           dbxout_type (TREE_TYPE (type), 0);
1851         }
1852       else
1853         /* Should print as an int, because it is really just an offset.  */
1854         dbxout_type (integer_type_node, 0);
1855       break;
1856
1857     case REFERENCE_TYPE:
1858       if (use_gnu_debug_info_extensions)
1859         have_used_extensions = 1;
1860       putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1861       CHARS (1);
1862       dbxout_type (TREE_TYPE (type), 0);
1863       break;
1864
1865     case FUNCTION_TYPE:
1866       putc ('f', asmfile);
1867       CHARS (1);
1868       dbxout_type (TREE_TYPE (type), 0);
1869       break;
1870
1871     default:
1872       abort ();
1873     }
1874 }
1875
1876 /* Return nonzero if the given type represents an integer whose bounds
1877    should be printed in octal format.  */
1878
1879 static bool
1880 print_int_cst_bounds_in_octal_p (tree type)
1881 {
1882   /* If we can use GDB extensions and the size is wider than a long
1883      (the size used by GDB to read them) or we may have trouble writing
1884      the bounds the usual way, write them in octal.  Note the test is for
1885      the *target's* size of "long", not that of the host.  The host test
1886      is just to make sure we can write it out in case the host wide int
1887      is narrower than the target "long".
1888
1889      For unsigned types, we use octal if they are the same size or larger.
1890      This is because we print the bounds as signed decimal, and hence they
1891      can't span same size unsigned types.  */
1892
1893   if (use_gnu_debug_info_extensions
1894       && TYPE_MIN_VALUE (type) != 0
1895       && TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST
1896       && TYPE_MAX_VALUE (type) != 0
1897       && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST
1898       && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1899           || ((TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
1900               && TREE_UNSIGNED (type))
1901           || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT
1902           || (TYPE_PRECISION (type) == HOST_BITS_PER_WIDE_INT
1903               && TREE_UNSIGNED (type))))
1904     return TRUE;
1905   else
1906     return FALSE;
1907 }
1908
1909 /* Print the value of integer constant C, in octal,
1910    handling double precision.  */
1911
1912 static void
1913 print_int_cst_octal (tree c)
1914 {
1915   unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1916   unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1917   int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1918   unsigned int width = TYPE_PRECISION (TREE_TYPE (c));
1919
1920   /* GDB wants constants with no extra leading "1" bits, so
1921      we need to remove any sign-extension that might be
1922      present.  */
1923   if (width == HOST_BITS_PER_WIDE_INT * 2)
1924     ;
1925   else if (width > HOST_BITS_PER_WIDE_INT)
1926     high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1927   else if (width == HOST_BITS_PER_WIDE_INT)
1928     high = 0;
1929   else
1930     high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1931
1932   fprintf (asmfile, "0");
1933   CHARS (1);
1934
1935   if (excess == 3)
1936     {
1937       print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1938       print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1939     }
1940   else
1941     {
1942       unsigned HOST_WIDE_INT beg = high >> excess;
1943       unsigned HOST_WIDE_INT middle
1944         = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1945            | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1946       unsigned HOST_WIDE_INT end
1947         = low & (((unsigned HOST_WIDE_INT) 1
1948                   << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1949                  - 1);
1950
1951       fprintf (asmfile, "%o%01o", (int) beg, (int) middle);
1952       CHARS (2);
1953       print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1954     }
1955 }
1956
1957 static void
1958 print_octal (unsigned HOST_WIDE_INT value, int digits)
1959 {
1960   int i;
1961
1962   for (i = digits - 1; i >= 0; i--)
1963     fprintf (asmfile, "%01o", (int) ((value >> (3 * i)) & 7));
1964
1965   CHARS (digits);
1966 }
1967
1968 /* Output C in decimal while adjusting the number of digits written.  */
1969
1970 static void
1971 print_wide_int (HOST_WIDE_INT c)
1972 {
1973   int digs = 0;
1974
1975   fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, c);
1976
1977   if (c < 0)
1978     digs++, c = -c;
1979
1980   while (c > 0)
1981     c /= 10; digs++;
1982
1983   CHARS (digs);
1984 }
1985
1986 /* Output the name of type TYPE, with no punctuation.
1987    Such names can be set up either by typedef declarations
1988    or by struct, enum and union tags.  */
1989
1990 static void
1991 dbxout_type_name (tree type)
1992 {
1993   tree t;
1994   if (TYPE_NAME (type) == 0)
1995     abort ();
1996   if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
1997     {
1998       t = TYPE_NAME (type);
1999     }
2000   else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
2001     {
2002       t = DECL_NAME (TYPE_NAME (type));
2003     }
2004   else
2005     abort ();
2006
2007   fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
2008   CHARS (IDENTIFIER_LENGTH (t));
2009 }
2010
2011 /* Output leading leading struct or class names needed for qualifying
2012    type whose scope is limited to a struct or class.  */
2013
2014 static void
2015 dbxout_class_name_qualifiers (tree decl)
2016 {
2017   tree context = decl_type_context (decl);
2018
2019   if (context != NULL_TREE
2020       && TREE_CODE(context) == RECORD_TYPE
2021       && TYPE_NAME (context) != 0
2022       && (TREE_CODE (TYPE_NAME (context)) == IDENTIFIER_NODE
2023           || (DECL_NAME (TYPE_NAME (context)) != 0)))
2024     {
2025       tree name = TYPE_NAME (context);
2026
2027       emit_pending_bincls_if_required ();
2028
2029       if (TREE_CODE (name) == TYPE_DECL)
2030         {
2031           dbxout_class_name_qualifiers (name);
2032           name = DECL_NAME (name);
2033         }
2034       fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
2035       CHARS (IDENTIFIER_LENGTH (name) + 2);
2036     }
2037 }
2038 \f
2039 /* Output a .stabs for the symbol defined by DECL,
2040    which must be a ..._DECL node in the normal namespace.
2041    It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
2042    LOCAL is nonzero if the scope is less than the entire file.
2043    Return 1 if a stabs might have been emitted.  */
2044
2045 int
2046 dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
2047 {
2048   tree type = TREE_TYPE (decl);
2049   tree context = NULL_TREE;
2050   int result = 0;
2051
2052   /* "Intercept" dbxout_symbol() calls like we do all debug_hooks.  */
2053   ++debug_nesting;
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       dbxout_prepare_symbol (decl);
2582
2583       if (WORDS_BIG_ENDIAN)
2584         dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2585       else
2586         dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2587       return 1;
2588     }
2589   else
2590     /* Address might be a MEM, when DECL is a variable-sized object.
2591        Or it might be const0_rtx, meaning previous passes
2592        want us to ignore this variable.  */
2593     return 0;
2594
2595   /* Ok, start a symtab entry and output the variable name.  */
2596   FORCE_TEXT;
2597
2598 #ifdef DBX_STATIC_BLOCK_START
2599   DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2600 #endif
2601
2602   dbxout_symbol_name (decl, suffix, letter);
2603   dbxout_type (type, 0);
2604   dbxout_finish_symbol (decl);
2605
2606 #ifdef DBX_STATIC_BLOCK_END
2607   DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2608 #endif
2609   return 1;
2610 }
2611 \f
2612 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2613    Then output LETTER to indicate the kind of location the symbol has.  */
2614
2615 static void
2616 dbxout_symbol_name (tree decl, const char *suffix, int letter)
2617 {
2618   const char *name;
2619
2620   if (DECL_CONTEXT (decl) 
2621       && (TYPE_P (DECL_CONTEXT (decl))
2622           || TREE_CODE (DECL_CONTEXT (decl)) == NAMESPACE_DECL))
2623     /* One slight hitch: if this is a VAR_DECL which is a class member
2624        or a namespace member, we must put out the mangled name instead of the
2625        DECL_NAME.  Note also that static member (variable) names DO NOT begin
2626        with underscores in .stabs directives.  */
2627     name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2628   else
2629     /* ...but if we're function-local, we don't want to include the junk
2630        added by ASM_FORMAT_PRIVATE_NAME.  */
2631     name = IDENTIFIER_POINTER (DECL_NAME (decl));
2632
2633   if (name == 0)
2634     name = "(anon)";
2635   fprintf (asmfile, "%s\"%s%s:", ASM_STABS_OP, name,
2636            (suffix ? suffix : ""));
2637
2638   if (letter)
2639     putc (letter, asmfile);
2640 }
2641
2642 static void
2643 dbxout_prepare_symbol (tree decl ATTRIBUTE_UNUSED)
2644 {
2645 #ifdef WINNING_GDB
2646   const char *filename = DECL_SOURCE_FILE (decl);
2647
2648   dbxout_source_file (asmfile, filename);
2649 #endif
2650
2651   /* Initialize variables used to communicate each symbol's debug
2652      information to dbxout_finish_symbol with zeroes.  */
2653
2654   /* Cast avoids warning in old compilers.  */
2655   current_sym_code = (STAB_CODE_TYPE) 0;
2656   current_sym_value = 0;
2657   current_sym_addr = 0;
2658 }
2659
2660 static void
2661 dbxout_finish_symbol (tree sym)
2662 {
2663 #ifdef DBX_FINISH_SYMBOL
2664   DBX_FINISH_SYMBOL (sym);
2665 #else
2666   int line = 0;
2667   if (use_gnu_debug_info_extensions && sym != 0)
2668     line = DECL_SOURCE_LINE (sym);
2669
2670   fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2671   if (current_sym_addr)
2672     output_addr_const (asmfile, current_sym_addr);
2673   else
2674     fprintf (asmfile, "%d", current_sym_value);
2675   putc ('\n', asmfile);
2676 #endif
2677 }
2678
2679 /* Output definitions of all the decls in a chain. Return nonzero if
2680    anything was output */
2681
2682 int
2683 dbxout_syms (tree syms)
2684 {
2685   int result = 0;
2686   while (syms)
2687     {
2688       result += dbxout_symbol (syms, 1);
2689       syms = TREE_CHAIN (syms);
2690     }
2691   return result;
2692 }
2693 \f
2694 /* The following two functions output definitions of function parameters.
2695    Each parameter gets a definition locating it in the parameter list.
2696    Each parameter that is a register variable gets a second definition
2697    locating it in the register.
2698
2699    Printing or argument lists in gdb uses the definitions that
2700    locate in the parameter list.  But reference to the variable in
2701    expressions uses preferentially the definition as a register.  */
2702
2703 /* Output definitions, referring to storage in the parmlist,
2704    of all the parms in PARMS, which is a chain of PARM_DECL nodes.  */
2705
2706 void
2707 dbxout_parms (tree parms)
2708 {
2709   ++debug_nesting;
2710
2711   emit_pending_bincls_if_required ();
2712
2713   for (; parms; parms = TREE_CHAIN (parms))
2714     if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2715       {
2716         dbxout_prepare_symbol (parms);
2717
2718         /* Perform any necessary register eliminations on the parameter's rtl,
2719            so that the debugging output will be accurate.  */
2720         DECL_INCOMING_RTL (parms)
2721           = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2722         SET_DECL_RTL (parms, eliminate_regs (DECL_RTL (parms), 0, NULL_RTX));
2723 #ifdef LEAF_REG_REMAP
2724         if (current_function_uses_only_leaf_regs)
2725           {
2726             leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2727             leaf_renumber_regs_insn (DECL_RTL (parms));
2728           }
2729 #endif
2730
2731         if (PARM_PASSED_IN_MEMORY (parms))
2732           {
2733             rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2734
2735             /* ??? Here we assume that the parm address is indexed
2736                off the frame pointer or arg pointer.
2737                If that is not true, we produce meaningless results,
2738                but do not crash.  */
2739             if (GET_CODE (addr) == PLUS
2740                 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2741               current_sym_value = INTVAL (XEXP (addr, 1));
2742             else
2743               current_sym_value = 0;
2744
2745             current_sym_code = N_PSYM;
2746             current_sym_addr = 0;
2747
2748             FORCE_TEXT;
2749             if (DECL_NAME (parms))
2750               {
2751                 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2752
2753                 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2754                          IDENTIFIER_POINTER (DECL_NAME (parms)),
2755                          DBX_MEMPARM_STABS_LETTER);
2756               }
2757             else
2758               {
2759                 current_sym_nchars = 8;
2760                 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2761                          DBX_MEMPARM_STABS_LETTER);
2762               }
2763
2764             /* It is quite tempting to use:
2765
2766                    dbxout_type (TREE_TYPE (parms), 0);
2767
2768                as the next statement, rather than using DECL_ARG_TYPE(), so
2769                that gcc reports the actual type of the parameter, rather
2770                than the promoted type.  This certainly makes GDB's life
2771                easier, at least for some ports.  The change is a bad idea
2772                however, since GDB expects to be able access the type without
2773                performing any conversions.  So for example, if we were
2774                passing a float to an unprototyped function, gcc will store a
2775                double on the stack, but if we emit a stab saying the type is a
2776                float, then gdb will only read in a single value, and this will
2777                produce an erroneous value.  */
2778             dbxout_type (DECL_ARG_TYPE (parms), 0);
2779             current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2780             dbxout_finish_symbol (parms);
2781           }
2782         else if (GET_CODE (DECL_RTL (parms)) == REG)
2783           {
2784             rtx best_rtl;
2785             char regparm_letter;
2786             tree parm_type;
2787             /* Parm passed in registers and lives in registers or nowhere.  */
2788
2789             current_sym_code = DBX_REGPARM_STABS_CODE;
2790             regparm_letter = DBX_REGPARM_STABS_LETTER;
2791             current_sym_addr = 0;
2792
2793             /* If parm lives in a register, use that register;
2794                pretend the parm was passed there.  It would be more consistent
2795                to describe the register where the parm was passed,
2796                but in practice that register usually holds something else.
2797
2798                If we use DECL_RTL, then we must use the declared type of
2799                the variable, not the type that it arrived in.  */
2800             if (REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2801               {
2802                 best_rtl = DECL_RTL (parms);
2803                 parm_type = TREE_TYPE (parms);
2804               }
2805             /* If the parm lives nowhere, use the register where it was
2806                passed.  It is also better to use the declared type here.  */
2807             else
2808               {
2809                 best_rtl = DECL_INCOMING_RTL (parms);
2810                 parm_type = TREE_TYPE (parms);
2811               }
2812             current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2813
2814             FORCE_TEXT;
2815             if (DECL_NAME (parms))
2816               {
2817                 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2818                 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2819                          IDENTIFIER_POINTER (DECL_NAME (parms)),
2820                          regparm_letter);
2821               }
2822             else
2823               {
2824                 current_sym_nchars = 8;
2825                 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2826                          regparm_letter);
2827               }
2828
2829             dbxout_type (parm_type, 0);
2830             dbxout_finish_symbol (parms);
2831           }
2832         else if (GET_CODE (DECL_RTL (parms)) == MEM
2833                  && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2834                  && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2835                  && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2836 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2837                  && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2838 #endif
2839                  )
2840           {
2841             /* Parm was passed via invisible reference.
2842                That is, its address was passed in a register.
2843                Output it as if it lived in that register.
2844                The debugger will know from the type
2845                that it was actually passed by invisible reference.  */
2846
2847             char regparm_letter;
2848             /* Parm passed in registers and lives in registers or nowhere.  */
2849
2850             current_sym_code = DBX_REGPARM_STABS_CODE;
2851             if (use_gnu_debug_info_extensions)
2852               regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2853             else
2854               regparm_letter = DBX_REGPARM_STABS_LETTER;
2855
2856             /* DECL_RTL looks like (MEM (REG...).  Get the register number.
2857                If it is an unallocated pseudo-reg, then use the register where
2858                it was passed instead.  */
2859             if (REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2860               current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2861             else
2862               current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2863
2864             current_sym_addr = 0;
2865
2866             FORCE_TEXT;
2867             if (DECL_NAME (parms))
2868               {
2869                 current_sym_nchars
2870                   = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2871
2872                 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2873                          IDENTIFIER_POINTER (DECL_NAME (parms)),
2874                          regparm_letter);
2875               }
2876             else
2877               {
2878                 current_sym_nchars = 8;
2879                 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2880                          regparm_letter);
2881               }
2882
2883             dbxout_type (TREE_TYPE (parms), 0);
2884             dbxout_finish_symbol (parms);
2885           }
2886         else if (GET_CODE (DECL_RTL (parms)) == MEM
2887                  && GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2888           {
2889             /* Parm was passed via invisible reference, with the reference
2890                living on the stack.  DECL_RTL looks like
2891                (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
2892                could look like (MEM (MEM (REG))).  */
2893             const char *const decl_name = (DECL_NAME (parms)
2894                                      ? IDENTIFIER_POINTER (DECL_NAME (parms))
2895                                      : "(anon)");
2896             if (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 0)) == REG)
2897               current_sym_value = 0;
2898             else
2899               current_sym_value
2900                 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1));
2901             current_sym_addr = 0;
2902             current_sym_code = N_PSYM;
2903
2904             FORCE_TEXT;
2905             fprintf (asmfile, "%s\"%s:v", ASM_STABS_OP, decl_name);
2906
2907             current_sym_value
2908               = DEBUGGER_ARG_OFFSET (current_sym_value,
2909                                      XEXP (XEXP (DECL_RTL (parms), 0), 0));
2910             dbxout_type (TREE_TYPE (parms), 0);
2911             dbxout_finish_symbol (parms);
2912           }
2913         else if (GET_CODE (DECL_RTL (parms)) == MEM
2914                  && XEXP (DECL_RTL (parms), 0) != const0_rtx
2915                  /* ??? A constant address for a parm can happen
2916                     when the reg it lives in is equiv to a constant in memory.
2917                     Should make this not happen, after 2.4.  */
2918                  && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2919           {
2920             /* Parm was passed in registers but lives on the stack.  */
2921
2922             current_sym_code = N_PSYM;
2923             /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2924                in which case we want the value of that CONST_INT,
2925                or (MEM (REG ...)),
2926                in which case we use a value of zero.  */
2927             if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG)
2928               current_sym_value = 0;
2929             else
2930                 current_sym_value
2931                   = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2932
2933             current_sym_addr = 0;
2934
2935             /* Make a big endian correction if the mode of the type of the
2936                parameter is not the same as the mode of the rtl.  */
2937             if (BYTES_BIG_ENDIAN
2938                 && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms))
2939                 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD)
2940               {
2941                 current_sym_value +=
2942                     GET_MODE_SIZE (GET_MODE (DECL_RTL (parms)))
2943                     - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms)));
2944               }
2945
2946             FORCE_TEXT;
2947             if (DECL_NAME (parms))
2948               {
2949                 current_sym_nchars
2950                   = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2951
2952                 fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
2953                          IDENTIFIER_POINTER (DECL_NAME (parms)),
2954                          DBX_MEMPARM_STABS_LETTER);
2955               }
2956             else
2957               {
2958                 current_sym_nchars = 8;
2959                 fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
2960                 DBX_MEMPARM_STABS_LETTER);
2961               }
2962
2963             current_sym_value
2964               = DEBUGGER_ARG_OFFSET (current_sym_value,
2965                                      XEXP (DECL_RTL (parms), 0));
2966             dbxout_type (TREE_TYPE (parms), 0);
2967             dbxout_finish_symbol (parms);
2968           }
2969       }
2970   DBXOUT_DECR_NESTING;
2971 }
2972
2973 /* Output definitions for the places where parms live during the function,
2974    when different from where they were passed, when the parms were passed
2975    in memory.
2976
2977    It is not useful to do this for parms passed in registers
2978    that live during the function in different registers, because it is
2979    impossible to look in the passed register for the passed value,
2980    so we use the within-the-function register to begin with.
2981
2982    PARMS is a chain of PARM_DECL nodes.  */
2983
2984 void
2985 dbxout_reg_parms (tree parms)
2986 {
2987   ++debug_nesting;
2988
2989   for (; parms; parms = TREE_CHAIN (parms))
2990     if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
2991       {
2992         dbxout_prepare_symbol (parms);
2993
2994         /* Report parms that live in registers during the function
2995            but were passed in memory.  */
2996         if (GET_CODE (DECL_RTL (parms)) == REG
2997             && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2998           dbxout_symbol_location (parms, TREE_TYPE (parms),
2999                                   0, DECL_RTL (parms));
3000         else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
3001           dbxout_symbol_location (parms, TREE_TYPE (parms),
3002                                   0, DECL_RTL (parms));
3003         /* Report parms that live in memory but not where they were passed.  */
3004         else if (GET_CODE (DECL_RTL (parms)) == MEM
3005                  && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
3006           dbxout_symbol_location (parms, TREE_TYPE (parms),
3007                                   0, DECL_RTL (parms));
3008       }
3009   DBXOUT_DECR_NESTING;
3010 }
3011 \f
3012 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
3013    output definitions of those names, in raw form */
3014
3015 static void
3016 dbxout_args (tree args)
3017 {
3018   while (args)
3019     {
3020       putc (',', asmfile);
3021       dbxout_type (TREE_VALUE (args), 0);
3022       CHARS (1);
3023       args = TREE_CHAIN (args);
3024     }
3025 }
3026 \f
3027 /* Output everything about a symbol block (a BLOCK node
3028    that represents a scope level),
3029    including recursive output of contained blocks.
3030
3031    BLOCK is the BLOCK node.
3032    DEPTH is its depth within containing symbol blocks.
3033    ARGS is usually zero; but for the outermost block of the
3034    body of a function, it is a chain of PARM_DECLs for the function parameters.
3035    We output definitions of all the register parms
3036    as if they were local variables of that block.
3037
3038    If -g1 was used, we count blocks just the same, but output nothing
3039    except for the outermost block.
3040
3041    Actually, BLOCK may be several blocks chained together.
3042    We handle them all in sequence.  */
3043
3044 static void
3045 dbxout_block (tree block, int depth, tree args)
3046 {
3047   int blocknum = -1;
3048
3049 #if DBX_BLOCKS_FUNCTION_RELATIVE
3050   const char *begin_label;
3051   if (current_function_func_begin_label != NULL_TREE)
3052     begin_label = IDENTIFIER_POINTER (current_function_func_begin_label);
3053   else
3054     begin_label = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
3055 #endif
3056
3057   while (block)
3058     {
3059       /* Ignore blocks never expanded or otherwise marked as real.  */
3060       if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
3061         {
3062           int did_output;
3063
3064           /* In dbx format, the syms of a block come before the N_LBRAC.
3065              If nothing is output, we don't need the N_LBRAC, either.  */
3066           did_output = 0;
3067           if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
3068             did_output = dbxout_syms (BLOCK_VARS (block));
3069           if (args)
3070             dbxout_reg_parms (args);
3071
3072           /* Now output an N_LBRAC symbol to represent the beginning of
3073              the block.  Use the block's tree-walk order to generate
3074              the assembler symbols LBBn and LBEn
3075              that final will define around the code in this block.  */
3076           if (depth > 0 && did_output)
3077             {
3078               char buf[20];
3079               blocknum = BLOCK_NUMBER (block);
3080               ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
3081
3082               if (BLOCK_HANDLER_BLOCK (block))
3083                 {
3084                   /* A catch block.  Must precede N_LBRAC.  */
3085                   tree decl = BLOCK_VARS (block);
3086                   while (decl)
3087                     {
3088                       fprintf (asmfile, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP,
3089                                IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
3090                       assemble_name (asmfile, buf);
3091                       fprintf (asmfile, "\n");
3092                       decl = TREE_CHAIN (decl);
3093                     }
3094                 }
3095
3096 #ifdef DBX_OUTPUT_LBRAC
3097               DBX_OUTPUT_LBRAC (asmfile, buf);
3098 #else
3099               fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
3100               assemble_name (asmfile, buf);
3101 #if DBX_BLOCKS_FUNCTION_RELATIVE
3102               putc ('-', asmfile);
3103               assemble_name (asmfile, begin_label);
3104 #endif
3105               fprintf (asmfile, "\n");
3106 #endif
3107             }
3108
3109           /* Output the subblocks.  */
3110           dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
3111
3112           /* Refer to the marker for the end of the block.  */
3113           if (depth > 0 && did_output)
3114             {
3115               char buf[20];
3116               ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
3117 #ifdef DBX_OUTPUT_RBRAC
3118               DBX_OUTPUT_RBRAC (asmfile, buf);
3119 #else
3120               fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC);
3121               assemble_name (asmfile, buf);
3122 #if DBX_BLOCKS_FUNCTION_RELATIVE
3123               putc ('-', asmfile);
3124               assemble_name (asmfile, begin_label);
3125 #endif
3126               fprintf (asmfile, "\n");
3127 #endif
3128             }
3129         }
3130       block = BLOCK_CHAIN (block);
3131     }
3132 }
3133
3134 /* Output the information about a function and its arguments and result.
3135    Usually this follows the function's code,
3136    but on some systems, it comes before.  */
3137
3138 #if defined (DBX_DEBUGGING_INFO)
3139 static void
3140 dbxout_begin_function (tree decl)
3141 {
3142   int saved_tree_used1 = TREE_USED (decl);
3143   TREE_USED (decl) = 1;
3144   if (DECL_NAME (DECL_RESULT (decl)) != 0)
3145     {
3146       int saved_tree_used2 = TREE_USED (DECL_RESULT (decl));
3147       TREE_USED (DECL_RESULT (decl)) = 1;
3148       dbxout_symbol (decl, 0);
3149       TREE_USED (DECL_RESULT (decl)) = saved_tree_used2;
3150     }
3151   else
3152     dbxout_symbol (decl, 0);
3153   TREE_USED (decl) = saved_tree_used1;
3154
3155   dbxout_parms (DECL_ARGUMENTS (decl));
3156   if (DECL_NAME (DECL_RESULT (decl)) != 0)
3157     dbxout_symbol (DECL_RESULT (decl), 1);
3158 }
3159 #endif /* DBX_DEBUGGING_INFO */
3160
3161 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
3162
3163 #include "gt-dbxout.h"