OSDN Git Service

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