OSDN Git Service

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