OSDN Git Service

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