OSDN Git Service

91th Cygnus<->FSF merge
[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, "-1\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 (TREE_CODE (tem) != CONST_DECL)
644         {
645           /* Continue the line if necessary,
646              but not before the first field.  */
647           if (tem != TYPE_FIELDS (type))
648             CONTIN;
649
650           if (use_gnu_debug_info_extensions
651               && flag_minimal_debug
652               && TREE_CODE (tem) == FIELD_DECL
653               && DECL_VIRTUAL_P (tem)
654               && DECL_ASSEMBLER_NAME (tem))
655             {
656               have_used_extensions = 1;
657               CHARS (3 + IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (tem)));
658               fputs (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem)), asmfile);
659               dbxout_type (DECL_FCONTEXT (tem), 0, 0);
660               fprintf (asmfile, ":");
661               dbxout_type (TREE_TYPE (tem), 0, 0);
662               fprintf (asmfile, ",%d;",
663                        TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)));
664               continue;
665             }
666
667           if (DECL_NAME (tem))
668             {
669               fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
670               CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
671             }
672           else
673             {
674               fprintf (asmfile, ":");
675               CHARS (2);
676             }
677
678           if (use_gnu_debug_info_extensions
679               && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
680                   || TREE_CODE (tem) != FIELD_DECL))
681             {
682               have_used_extensions = 1;
683               putc ('/', asmfile);
684               putc ((TREE_PRIVATE (tem) ? '0'
685                      : TREE_PROTECTED (tem) ? '1' : '2'),
686                     asmfile);
687               CHARS (2);
688             }
689
690           dbxout_type ((TREE_CODE (tem) == FIELD_DECL
691                         && DECL_BIT_FIELD_TYPE (tem))
692                        ? DECL_BIT_FIELD_TYPE (tem)
693                        : TREE_TYPE (tem), 0, 0);
694
695           if (TREE_CODE (tem) == VAR_DECL)
696             {
697               if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
698                 {
699                   char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem));
700                   have_used_extensions = 1;
701                   fprintf (asmfile, ":%s;", name);
702                   CHARS (strlen (name));
703                 }
704               else
705                 {
706                   /* If TEM is non-static, GDB won't understand it.  */
707                   fprintf (asmfile, ",0,0;");
708                 }
709             }
710           else if (TREE_CODE (DECL_FIELD_BITPOS (tem)) == INTEGER_CST)
711             {
712               fprintf (asmfile, ",%d,%d;",
713                        TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)),
714                        TREE_INT_CST_LOW (DECL_SIZE (tem)));
715             }
716           CHARS (23);
717         }
718     }
719 }
720 \f
721 /* Subroutine of `dbxout_type_methods'.  Output debug info about the
722    method described DECL.  DEBUG_NAME is an encoding of the method's
723    type signature.  ??? We may be able to do without DEBUG_NAME altogether
724    now.  */
725
726 static void
727 dbxout_type_method_1 (decl, debug_name)
728      tree decl;
729      char *debug_name;
730 {
731   char c1 = 'A', c2;
732
733   if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
734     c2 = '?';
735   else /* it's a METHOD_TYPE.  */
736     {
737       tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
738       /* A for normal functions.
739          B for `const' member functions.
740          C for `volatile' member functions.
741          D for `const volatile' member functions.  */
742       if (TYPE_READONLY (TREE_TYPE (firstarg)))
743         c1 += 1;
744       if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
745         c1 += 2;
746
747       if (DECL_VINDEX (decl))
748         c2 = '*';
749       else
750         c2 = '.';
751     }
752
753   fprintf (asmfile, ":%s;%c%c%c", debug_name,
754            TREE_PRIVATE (decl) ? '0' : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
755   CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
756          - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
757   if (DECL_VINDEX (decl))
758     {
759       fprintf (asmfile, "%d;",
760                TREE_INT_CST_LOW (DECL_VINDEX (decl)));
761       dbxout_type (DECL_CONTEXT (decl), 0, 0);
762       fprintf (asmfile, ";");
763       CHARS (8);
764     }
765 }
766 \f
767 /* Subroutine of `dbxout_type'.  Output debug info about the methods defined
768    in TYPE.  */
769
770 static void
771 dbxout_type_methods (type)
772      register tree type;
773 {
774   /* C++: put out the method names and their parameter lists */
775   tree methods = TYPE_METHODS (type);
776   tree type_encoding;
777   register tree fndecl;
778   register tree last;
779   char formatted_type_identifier_length[16];
780   register int type_identifier_length;
781
782   if (methods == NULL_TREE)
783     return;
784
785   type_encoding = DECL_NAME (TYPE_NAME (type));
786
787 #if 0
788   /* C++: Template classes break some assumptions made by this code about
789      the class names, constructor names, and encodings for assembler
790      label names.  For now, disable output of dbx info for them.  */
791   {
792     char *ptr = IDENTIFIER_POINTER (type_encoding);
793     /* This should use index.  (mrs) */
794     while (*ptr && *ptr != '<') ptr++;
795     if (*ptr != 0)
796       {
797         static int warned;
798         if (!warned)
799           {
800             warned = 1;
801 #ifdef HAVE_TEMPLATES
802             if (warn_template_debugging)
803               warning ("dbx info for template class methods not yet supported");
804 #endif
805           }
806         return;
807       }
808   }
809 #endif
810
811   type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
812
813   sprintf(formatted_type_identifier_length, "%d", type_identifier_length);
814
815   if (TREE_CODE (methods) == FUNCTION_DECL)
816     fndecl = methods;
817   else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
818     fndecl = TREE_VEC_ELT (methods, 0);
819   else
820     fndecl = TREE_VEC_ELT (methods, 1);
821
822   while (fndecl)
823     {
824       tree name = DECL_NAME (fndecl);
825       int need_prefix = 1;
826
827       /* Group together all the methods for the same operation.
828          These differ in the types of the arguments.  */
829       for (last = NULL_TREE;
830            fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
831            fndecl = TREE_CHAIN (fndecl))
832         /* Output the name of the field (after overloading), as
833            well as the name of the field before overloading, along
834            with its parameter list */
835         {
836           /* This is the "mangled" name of the method.
837              It encodes the argument types.  */
838           char *debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
839           int show_arg_types = 0;
840
841           CONTIN;
842
843           last = fndecl;
844
845           if (DECL_IGNORED_P (fndecl))
846             continue;
847
848           if (flag_minimal_debug)
849             {
850               char marker;
851
852               /* We can't optimize a method which uses an anonymous
853                  class, because the debugger will not be able to
854                  associate the arbitrary class name with the actual
855                  class.  */
856 #ifndef NO_DOLLAR_IN_LABEL
857               marker = '$';
858 #else
859               marker = '.';
860 #endif
861               if (strchr (debug_name, marker))
862                 show_arg_types = 1;
863               /* Detect ordinary methods because their mangled names
864                  start with the operation name.  */
865               else if (!strncmp (IDENTIFIER_POINTER (name), debug_name,
866                                  IDENTIFIER_LENGTH (name)))
867                 {
868                   debug_name += IDENTIFIER_LENGTH (name);
869                   if (debug_name[0] == '_' && debug_name[1] == '_')
870                     {
871                       char *method_name = debug_name + 2;
872                       char *length_ptr = formatted_type_identifier_length;
873                       /* Get past const and volatile qualifiers.  */
874                       while (*method_name == 'C' || *method_name == 'V')
875                         method_name++;
876                       /* Skip digits for length of type_encoding.  */
877                       while (*method_name == *length_ptr && *length_ptr)
878                           length_ptr++, method_name++;
879                       if (! strncmp (method_name,
880                                      IDENTIFIER_POINTER (type_encoding),
881                                      type_identifier_length))
882                         method_name += type_identifier_length;
883                       debug_name = method_name;
884                     }
885                 }
886               /* Detect constructors by their style of name mangling.  */
887               else if (debug_name[0] == '_' && debug_name[1] == '_')
888                 {
889                   char *ctor_name = debug_name + 2;
890                   char *length_ptr = formatted_type_identifier_length;
891                   while (*ctor_name == 'C' || *ctor_name == 'V')
892                     ctor_name++;
893                   /* Skip digits for length of type_encoding.  */
894                   while (*ctor_name == *length_ptr && *length_ptr)
895                       length_ptr++, ctor_name++;
896                   if (!strncmp (IDENTIFIER_POINTER (type_encoding), ctor_name,
897                                 type_identifier_length))
898                     debug_name = ctor_name + type_identifier_length;
899                 }
900               /* The other alternative is a destructor.  */
901               else
902                 show_arg_types = 1;
903
904               /* Output the operation name just once, for the first method
905                  that we output.  */
906               if (need_prefix)
907                 {
908                   fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
909                   CHARS (IDENTIFIER_LENGTH (name) + 2);
910                   need_prefix = 0;
911                 }
912             }
913
914           dbxout_type (TREE_TYPE (fndecl), 0, show_arg_types);
915
916           dbxout_type_method_1 (fndecl, debug_name);
917         }
918       if (!need_prefix)
919         {
920           putc (';', asmfile);
921           CHARS (1);
922         }
923     }
924 }
925
926 /* Emit a "range" type specification, which has the form:
927    "r<index type>;<lower bound>;<upper bound>;".
928    TYPE is an INTEGER_TYPE.  */
929
930 static void
931 dbxout_range_type (type)
932      tree type;
933 {
934   fprintf (asmfile, "r");
935   if (TREE_TYPE (type))
936     dbxout_type (TREE_TYPE (type), 0, 0);
937   else if (TREE_CODE (type) != INTEGER_TYPE)
938     dbxout_type (type, 0, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
939   else
940     {
941       /* Traditionally, we made sure 'int' was type 1, and builtin types
942          were defined to be sub-ranges of int.  Unfortunately, this
943          does not allow us to distinguish true sub-ranges from integer
944          types.  So, instead we define integer (non-sub-range) types as
945          sub-ranges of themselves.  */
946       dbxout_type_index (type);
947     }
948   if (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST)
949     fprintf (asmfile, ";%d", 
950              TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)));
951   else
952     fprintf (asmfile, ";0");
953   if (TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST)
954     fprintf (asmfile, ";%d;", 
955              TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)));
956   else
957     fprintf (asmfile, ";-1;");
958 }
959 \f
960 /* Output a reference to a type.  If the type has not yet been
961    described in the dbx output, output its definition now.
962    For a type already defined, just refer to its definition
963    using the type number.
964
965    If FULL is nonzero, and the type has been described only with
966    a forward-reference, output the definition now.
967    If FULL is zero in this case, just refer to the forward-reference
968    using the number previously allocated.
969
970    If SHOW_ARG_TYPES is nonzero, we output a description of the argument
971    types for a METHOD_TYPE.  */
972
973 static void
974 dbxout_type (type, full, show_arg_types)
975      tree type;
976      int full;
977      int show_arg_types;
978 {
979   register tree tem;
980   static int anonymous_type_number = 0;
981
982   /* If there was an input error and we don't really have a type,
983      avoid crashing and write something that is at least valid
984      by assuming `int'.  */
985   if (type == error_mark_node)
986     type = integer_type_node;
987   else
988     {
989       /* Try to find the "main variant" with the same name but not const
990          or volatile.  (Since stabs does not distinguish const and volatile,
991          there is no need to make them separate types.  But types with
992          different names are usefully distinguished.) */
993          
994       for (tem = TYPE_MAIN_VARIANT (type); tem; tem = TYPE_NEXT_VARIANT (tem))
995         if (!TYPE_READONLY (tem) && !TYPE_VOLATILE (tem)
996             && TYPE_NAME (tem) == TYPE_NAME (type))
997           {
998             type = tem;
999             break;
1000           }
1001       if (TYPE_NAME (type)
1002           && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1003           && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1004         full = 0;
1005     }
1006
1007   if (TYPE_SYMTAB_ADDRESS (type) == 0)
1008     {
1009       /* Type has no dbx number assigned.  Assign next available number.  */
1010       TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1011
1012       /* Make sure type vector is long enough to record about this type.  */
1013
1014       if (next_type_number == typevec_len)
1015         {
1016           typevec =
1017             (struct typeinfo *) xrealloc (typevec,
1018                                           typevec_len * 2 * sizeof typevec[0]);
1019           bzero ((char *) (typevec + typevec_len),
1020                  typevec_len * sizeof typevec[0]);
1021           typevec_len *= 2;
1022         }
1023
1024 #ifdef DBX_USE_BINCL
1025       typevec[TYPE_SYMTAB_ADDRESS (type)].file_number =
1026         current_file->file_number;
1027       typevec[TYPE_SYMTAB_ADDRESS (type)].type_number =
1028         current_file->next_type_number++;
1029 #endif
1030     }
1031
1032   /* Output the number of this type, to refer to it.  */
1033   dbxout_type_index (type);
1034
1035 #ifdef DBX_TYPE_DEFINED
1036   if (DBX_TYPE_DEFINED (type))
1037     return;
1038 #endif
1039
1040   /* If this type's definition has been output or is now being output,
1041      that is all.  */
1042
1043   switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1044     {
1045     case TYPE_UNSEEN:
1046       break;
1047     case TYPE_XREF:
1048       /* If we have already had a cross reference,
1049          and either that's all we want or that's the best we could do,
1050          don't repeat the cross reference.
1051          Sun dbx crashes if we do.  */
1052       if (! full || TYPE_SIZE (type) == 0
1053           /* No way in DBX fmt to describe a variable size.  */
1054           || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1055         return;
1056       break;
1057     case TYPE_DEFINED:
1058       return;
1059     }
1060
1061 #ifdef DBX_NO_XREFS
1062   /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1063      leave the type-number completely undefined rather than output
1064      a cross-reference.  If we have already used GNU debug info extensions,
1065      then it is OK to output a cross reference.  This is necessary to get
1066      proper C++ debug output.  */
1067   if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1068        || TREE_CODE (type) == QUAL_UNION_TYPE
1069        || TREE_CODE (type) == ENUMERAL_TYPE)
1070       && ! use_gnu_debug_info_extensions)
1071     /* We must use the same test here as we use twice below when deciding
1072        whether to emit a cross-reference.  */
1073     if ((TYPE_NAME (type) != 0
1074          && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1075                && DECL_IGNORED_P (TYPE_NAME (type)))
1076          && !full)
1077         || TYPE_SIZE (type) == 0
1078         /* No way in DBX fmt to describe a variable size.  */
1079         || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1080       {
1081         typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1082         return;
1083       }
1084 #endif
1085
1086   /* Output a definition now.  */
1087
1088   fprintf (asmfile, "=");
1089   CHARS (1);
1090
1091   /* Mark it as defined, so that if it is self-referent
1092      we will not get into an infinite recursion of definitions.  */
1093
1094   typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1095
1096   if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1097       && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1098     { 
1099       dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0, 0);
1100       return;
1101     }
1102
1103   switch (TREE_CODE (type))
1104     {
1105     case VOID_TYPE:
1106     case LANG_TYPE:
1107       /* For a void type, just define it as itself; ie, "5=5".
1108          This makes us consider it defined
1109          without saying what it is.  The debugger will make it
1110          a void type when the reference is seen, and nothing will
1111          ever override that default.  */
1112       dbxout_type_index (type);
1113       break;
1114
1115     case INTEGER_TYPE:
1116       if (type == char_type_node && ! TREE_UNSIGNED (type))
1117         {
1118           /* Output the type `char' as a subrange of itself!
1119              I don't understand this definition, just copied it
1120              from the output of pcc.
1121              This used to use `r2' explicitly and we used to
1122              take care to make sure that `char' was type number 2.  */
1123           fprintf (asmfile, "r");
1124           dbxout_type_index (type);
1125           fprintf (asmfile, ";0;127;");
1126         }
1127       else if (use_gnu_debug_info_extensions
1128                && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1129                    || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT))
1130         {
1131           /* This used to say `r1' and we used to take care
1132              to make sure that `int' was type number 1.  */
1133           fprintf (asmfile, "r");
1134           dbxout_type_index (integer_type_node);
1135           fprintf (asmfile, ";");
1136           print_int_cst_octal (TYPE_MIN_VALUE (type));
1137           fprintf (asmfile, ";");
1138           print_int_cst_octal (TYPE_MAX_VALUE (type));
1139           fprintf (asmfile, ";");
1140         }
1141       else /* Output other integer types as subranges of `int'.  */
1142         dbxout_range_type (type);
1143       CHARS (22);
1144       break;
1145
1146     case REAL_TYPE:
1147       /* This used to say `r1' and we used to take care
1148          to make sure that `int' was type number 1.  */
1149       fprintf (asmfile, "r");
1150       dbxout_type_index (integer_type_node);
1151       fprintf (asmfile, ";%d;0;", int_size_in_bytes (type));
1152       CHARS (13);
1153       break;
1154
1155     case CHAR_TYPE:
1156       if (use_gnu_debug_info_extensions)
1157         fprintf (asmfile, "@s%d;-20;",
1158                  BITS_PER_UNIT * int_size_in_bytes (type));
1159       else
1160         {
1161           /* Output the type `char' as a subrange of itself.
1162              That is what pcc seems to do.  */
1163           fprintf (asmfile, "r");
1164           dbxout_type_index (char_type_node);
1165           fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1166         }
1167       CHARS (9);
1168       break;
1169
1170     case BOOLEAN_TYPE:
1171       if (use_gnu_debug_info_extensions)
1172         fprintf (asmfile, "@s%d;-16;",
1173                  BITS_PER_UNIT * int_size_in_bytes (type));
1174       else /* Define as enumeral type (False, True) */
1175         fprintf (asmfile, "eFalse:0,True:1,;");
1176       CHARS (17);
1177       break;
1178
1179     case FILE_TYPE:
1180       putc ('d', asmfile);
1181       CHARS (1);
1182       dbxout_type (TREE_TYPE (type), 0, 0);
1183       break;
1184
1185     case COMPLEX_TYPE:
1186       /* Differs from the REAL_TYPE by its new data type number */
1187
1188       if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1189         {
1190           fprintf (asmfile, "r");
1191           dbxout_type_index (type);
1192           fprintf (asmfile, ";%d;0;",
1193                    int_size_in_bytes (TREE_TYPE (type)));
1194           CHARS (12);           /* The number is probably incorrect here.  */
1195         }
1196       else
1197         {
1198           /* Output a complex integer type as a structure,
1199              pending some other way to do it.  */
1200           fprintf (asmfile, "s%d", int_size_in_bytes (type));
1201
1202           fprintf (asmfile, "real:");
1203           CHARS (10);
1204           dbxout_type (TREE_TYPE (type), 0, 0);
1205           fprintf (asmfile, ",%d,%d;",
1206                    0, TYPE_PRECISION (TREE_TYPE (type)));
1207           CHARS (8);
1208           fprintf (asmfile, "imag:");
1209           CHARS (5);
1210           dbxout_type (TREE_TYPE (type), 0, 0);
1211           fprintf (asmfile, ",%d,%d;;",
1212                    TYPE_PRECISION (TREE_TYPE (type)),
1213                    TYPE_PRECISION (TREE_TYPE (type)));
1214           CHARS (9);
1215         }
1216       break;
1217
1218     case SET_TYPE:
1219       if (use_gnu_debug_info_extensions)
1220         {
1221           have_used_extensions = 1;
1222           fprintf (asmfile, "@s%d;",
1223                    BITS_PER_UNIT * int_size_in_bytes (type));
1224           /* Check if a bitstring type, which in Chill is
1225              different from a [power]set.  */
1226           if (TYPE_STRING_FLAG (type))
1227             fprintf (asmfile, "@S;");
1228         }
1229       putc ('S', asmfile);
1230       CHARS (1);
1231       dbxout_type (TYPE_DOMAIN (type), 0, 0);
1232       break;
1233
1234     case ARRAY_TYPE:
1235       /* Output "a" followed by a range type definition
1236          for the index type of the array
1237          followed by a reference to the target-type.
1238          ar1;0;N;M for a C array of type M and size N+1.  */
1239       /* Check if a character string type, which in Chill is
1240          different from an array of characters.  */
1241       if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1242         {
1243           have_used_extensions = 1;
1244           fprintf (asmfile, "@S;");
1245         }
1246       tem = TYPE_DOMAIN (type);
1247       if (tem == NULL)
1248         {
1249           fprintf (asmfile, "ar");
1250           dbxout_type_index (integer_type_node);
1251           fprintf (asmfile, ";0;-1;");
1252         }
1253       else
1254         {
1255           fprintf (asmfile, "a");
1256           dbxout_range_type (tem);
1257         }
1258       CHARS (14);
1259       dbxout_type (TREE_TYPE (type), 0, 0);
1260       break;
1261
1262     case RECORD_TYPE:
1263     case UNION_TYPE:
1264     case QUAL_UNION_TYPE:
1265       {
1266         int i, n_baseclasses = 0;
1267
1268         if (TYPE_BINFO (type) != 0 && TYPE_BINFO_BASETYPES (type) != 0)
1269           n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1270
1271         /* Output a structure type.  We must use the same test here as we
1272            use in the DBX_NO_XREFS case above.  */
1273         if ((TYPE_NAME (type) != 0
1274              && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1275                    && DECL_IGNORED_P (TYPE_NAME (type)))
1276              && !full)
1277             || TYPE_SIZE (type) == 0
1278             /* No way in DBX fmt to describe a variable size.  */
1279             || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1280           {
1281             /* If the type is just a cross reference, output one
1282                and mark the type as partially described.
1283                If it later becomes defined, we will output
1284                its real definition.
1285                If the type has a name, don't nest its definition within
1286                another type's definition; instead, output an xref
1287                and let the definition come when the name is defined.  */
1288             fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu");
1289             CHARS (3);
1290 #if 0 /* This assertion is legitimately false in C++.  */
1291             /* We shouldn't be outputting a reference to a type before its
1292                definition unless the type has a tag name.
1293                A typedef name without a tag name should be impossible.  */
1294             if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1295               abort ();
1296 #endif
1297             if (TYPE_NAME (type) != 0)
1298               dbxout_type_name (type);
1299             else
1300               fprintf (asmfile, "$$%d", anonymous_type_number++);
1301             fprintf (asmfile, ":");
1302             typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1303             break;
1304           }
1305
1306         /* Identify record or union, and print its size.  */
1307         fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "s%d" : "u%d",
1308                  int_size_in_bytes (type));
1309
1310         if (use_gnu_debug_info_extensions)
1311           {
1312             if (n_baseclasses)
1313               {
1314                 have_used_extensions = 1;
1315                 fprintf (asmfile, "!%d,", n_baseclasses);
1316                 CHARS (8);
1317               }
1318           }
1319         for (i = 0; i < n_baseclasses; i++)
1320           {
1321             tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i);
1322             if (use_gnu_debug_info_extensions)
1323               {
1324                 have_used_extensions = 1;
1325                 putc (TREE_VIA_VIRTUAL (child) ? '1'
1326                       : '0',
1327                       asmfile);
1328                 putc (TREE_VIA_PUBLIC (child) ? '2'
1329                       : '0',
1330                       asmfile);
1331                 fprintf (asmfile, "%d,",
1332                          TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT);
1333                 CHARS (15);
1334                 dbxout_type (BINFO_TYPE (child), 0, 0);
1335                 putc (';', asmfile);
1336               }
1337             else
1338               {
1339                 /* Print out the base class information with fields
1340                    which have the same names at the types they hold.  */
1341                 dbxout_type_name (BINFO_TYPE (child));
1342                 putc (':', asmfile);
1343                 dbxout_type (BINFO_TYPE (child), full, 0);
1344                 fprintf (asmfile, ",%d,%d;",
1345                          TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT,
1346                          TREE_INT_CST_LOW (DECL_SIZE (TYPE_NAME (BINFO_TYPE (child)))) * BITS_PER_UNIT);
1347                 CHARS (20);
1348               }
1349           }
1350       }
1351
1352       CHARS (11);
1353
1354       /* Write out the field declarations.  */
1355       dbxout_type_fields (type);
1356       if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1357         {
1358           have_used_extensions = 1;
1359           dbxout_type_methods (type);
1360         }
1361       putc (';', asmfile);
1362
1363       if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1364           /* Avoid the ~ if we don't really need it--it confuses dbx.  */
1365           && TYPE_VFIELD (type))
1366         {
1367           have_used_extensions = 1;
1368
1369           /* Tell GDB+ that it may keep reading.  */
1370           putc ('~', asmfile);
1371
1372           /* We need to write out info about what field this class
1373              uses as its "main" vtable pointer field, because if this
1374              field is inherited from a base class, GDB cannot necessarily
1375              figure out which field it's using in time.  */
1376           if (TYPE_VFIELD (type))
1377             {
1378               putc ('%', asmfile);
1379               dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0, 0);
1380             }
1381           putc (';', asmfile);
1382           CHARS (3);
1383         }
1384       break;
1385
1386     case ENUMERAL_TYPE:
1387       /* We must use the same test here as we use in the DBX_NO_XREFS case
1388          above.  We simplify it a bit since an enum will never have a variable
1389          size.  */
1390       if ((TYPE_NAME (type) != 0
1391            && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1392                  && DECL_IGNORED_P (TYPE_NAME (type)))
1393            && !full)
1394           || TYPE_SIZE (type) == 0)
1395         {
1396           fprintf (asmfile, "xe");
1397           CHARS (3);
1398           dbxout_type_name (type);
1399           typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1400           fprintf (asmfile, ":");
1401           return;
1402         }
1403 #ifdef DBX_OUTPUT_ENUM
1404       DBX_OUTPUT_ENUM (asmfile, type);
1405 #else
1406       if (use_gnu_debug_info_extensions
1407           && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1408         fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1409       putc ('e', asmfile);
1410       CHARS (1);
1411       for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1412         {
1413           fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1414           if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1415             fprintf (asmfile, "%lu",
1416                      (unsigned long) TREE_INT_CST_LOW (TREE_VALUE (tem)));
1417           else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1418                    && TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1419             fprintf (asmfile, "%ld",
1420                      (long) TREE_INT_CST_LOW (TREE_VALUE (tem)));
1421           else
1422             print_int_cst_octal (TREE_VALUE (tem));
1423           fprintf (asmfile, ",");
1424           CHARS (20 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem)));
1425           if (TREE_CHAIN (tem) != 0)
1426             CONTIN;
1427         }
1428       putc (';', asmfile);
1429       CHARS (1);
1430 #endif
1431       break;
1432
1433     case POINTER_TYPE:
1434       putc ('*', asmfile);
1435       CHARS (1);
1436       dbxout_type (TREE_TYPE (type), 0, 0);
1437       break;
1438
1439     case METHOD_TYPE:
1440       if (use_gnu_debug_info_extensions)
1441         {
1442           have_used_extensions = 1;
1443           putc ('#', asmfile);
1444           CHARS (1);
1445           if (flag_minimal_debug && !show_arg_types)
1446             {
1447               /* Normally, just output the return type.
1448                  The argument types are encoded in the method name.  */
1449               putc ('#', asmfile);
1450               CHARS (1);
1451               dbxout_type (TREE_TYPE (type), 0, 0);
1452               putc (';', asmfile);
1453               CHARS (1);
1454             }
1455           else
1456             {
1457               /* When outputting destructors, we need to write
1458                  the argument types out longhand.  */
1459               dbxout_type (TYPE_METHOD_BASETYPE (type), 0, 0);
1460               putc (',', asmfile);
1461               CHARS (1);
1462               dbxout_type (TREE_TYPE (type), 0, 0);
1463               dbxout_args (TYPE_ARG_TYPES (type));
1464               putc (';', asmfile);
1465               CHARS (1);
1466             }
1467         }
1468       else
1469         {
1470           /* Treat it as a function type.  */
1471           dbxout_type (TREE_TYPE (type), 0, 0);
1472         }
1473       break;
1474
1475     case OFFSET_TYPE:
1476       if (use_gnu_debug_info_extensions)
1477         {
1478           have_used_extensions = 1;
1479           putc ('@', asmfile);
1480           CHARS (1);
1481           dbxout_type (TYPE_OFFSET_BASETYPE (type), 0, 0);
1482           putc (',', asmfile);
1483           CHARS (1);
1484           dbxout_type (TREE_TYPE (type), 0, 0);
1485         }
1486       else
1487         {
1488           /* Should print as an int, because it is really
1489              just an offset.  */
1490           dbxout_type (integer_type_node, 0, 0);
1491         }
1492       break;
1493
1494     case REFERENCE_TYPE:
1495       if (use_gnu_debug_info_extensions)
1496         have_used_extensions = 1;
1497       putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1498       CHARS (1);
1499       dbxout_type (TREE_TYPE (type), 0, 0);
1500       break;
1501
1502     case FUNCTION_TYPE:
1503       putc ('f', asmfile);
1504       CHARS (1);
1505       dbxout_type (TREE_TYPE (type), 0, 0);
1506       break;
1507
1508     default:
1509       abort ();
1510     }
1511 }
1512
1513 /* Print the value of integer constant C, in octal,
1514    handling double precision.  */
1515
1516 static void
1517 print_int_cst_octal (c)
1518      tree c;
1519 {
1520   unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1521   unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1522   int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1523   int width = TYPE_PRECISION (TREE_TYPE (c));
1524
1525   /* GDB wants constants with no extra leading "1" bits, so
1526      we need to remove any sign-extension that might be
1527      present.  */
1528   if (width == HOST_BITS_PER_WIDE_INT * 2)
1529     ;
1530   else if (width > HOST_BITS_PER_WIDE_INT)
1531     high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1532   else if (width == HOST_BITS_PER_WIDE_INT)
1533     high = 0;
1534   else
1535     high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1536
1537   fprintf (asmfile, "0");
1538
1539   if (excess == 3)
1540     {
1541       print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1542       print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1543     }
1544   else
1545     {
1546       unsigned HOST_WIDE_INT beg = high >> excess;
1547       unsigned HOST_WIDE_INT middle
1548         = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1549            | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1550       unsigned HOST_WIDE_INT end
1551         = low & (((unsigned HOST_WIDE_INT) 1
1552                   << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1553                  - 1);
1554
1555       fprintf (asmfile, "%o%01o", beg, middle);
1556       print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1557     }
1558 }
1559
1560 static void
1561 print_octal (value, digits)
1562      unsigned HOST_WIDE_INT value;
1563      int digits;
1564 {
1565   int i;
1566
1567   for (i = digits - 1; i >= 0; i--)
1568     fprintf (asmfile, "%01o", ((value >> (3 * i)) & 7));
1569 }
1570
1571 /* Output the name of type TYPE, with no punctuation.
1572    Such names can be set up either by typedef declarations
1573    or by struct, enum and union tags.  */
1574
1575 static void
1576 dbxout_type_name (type)
1577      register tree type;
1578 {
1579   tree t;
1580   if (TYPE_NAME (type) == 0)
1581     abort ();
1582   if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
1583     {
1584       t = TYPE_NAME (type);
1585     }
1586   else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1587     {
1588       t = DECL_NAME (TYPE_NAME (type));
1589     }
1590   else
1591     abort ();
1592
1593   fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
1594   CHARS (IDENTIFIER_LENGTH (t));
1595 }
1596 \f
1597 /* Output a .stabs for the symbol defined by DECL,
1598    which must be a ..._DECL node in the normal namespace.
1599    It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1600    LOCAL is nonzero if the scope is less than the entire file.  */
1601
1602 void
1603 dbxout_symbol (decl, local)
1604      tree decl;
1605      int local;
1606 {
1607   tree type = TREE_TYPE (decl);
1608   tree context = NULL_TREE;
1609
1610   /* Cast avoids warning in old compilers.  */
1611   current_sym_code = (STAB_CODE_TYPE) 0;
1612   current_sym_value = 0;
1613   current_sym_addr = 0;
1614
1615   /* Ignore nameless syms, but don't ignore type tags.  */
1616
1617   if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
1618       || DECL_IGNORED_P (decl))
1619     return;
1620
1621   dbxout_prepare_symbol (decl);
1622
1623   /* The output will always start with the symbol name,
1624      so always count that in the length-output-so-far.  */
1625
1626   if (DECL_NAME (decl) != 0)
1627     current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
1628
1629   switch (TREE_CODE (decl))
1630     {
1631     case CONST_DECL:
1632       /* Enum values are defined by defining the enum type.  */
1633       break;
1634
1635     case FUNCTION_DECL:
1636       if (DECL_RTL (decl) == 0)
1637         return;
1638       if (DECL_EXTERNAL (decl))
1639         break;
1640       /* Don't mention a nested function under its parent.  */
1641       context = decl_function_context (decl);
1642       if (context == current_function_decl)
1643         break;
1644       if (GET_CODE (DECL_RTL (decl)) != MEM
1645           || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
1646         break;
1647       FORCE_TEXT;
1648
1649       fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
1650                IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1651                TREE_PUBLIC (decl) ? 'F' : 'f');
1652
1653       current_sym_code = N_FUN;
1654       current_sym_addr = XEXP (DECL_RTL (decl), 0);
1655
1656       if (TREE_TYPE (type))
1657         dbxout_type (TREE_TYPE (type), 0, 0);
1658       else
1659         dbxout_type (void_type_node, 0, 0);
1660
1661       /* For a nested function, when that function is compiled,
1662          mention the containing function name
1663          as well as (since dbx wants it) our own assembler-name.  */
1664       if (context != 0)
1665         fprintf (asmfile, ",%s,%s",
1666                  IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1667                  IDENTIFIER_POINTER (DECL_NAME (context)));
1668
1669       dbxout_finish_symbol (decl);
1670       break;
1671
1672     case TYPE_DECL:
1673 #if 0
1674       /* This seems all wrong.  Outputting most kinds of types gives no name
1675          at all.  A true definition gives no name; a cross-ref for a
1676          structure can give the tag name, but not a type name.
1677          It seems that no typedef name is defined by outputting a type.  */
1678
1679       /* If this typedef name was defined by outputting the type,
1680          don't duplicate it.  */
1681       if (typevec[TYPE_SYMTAB_ADDRESS (type)].status == TYPE_DEFINED
1682           && TYPE_NAME (TREE_TYPE (decl)) == decl)
1683         return;
1684 #endif
1685       /* Don't output the same typedef twice.
1686          And don't output what language-specific stuff doesn't want output.  */
1687       if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
1688         return;
1689
1690       FORCE_TEXT;
1691
1692       {
1693         int tag_needed = 1;
1694         int did_output = 0;
1695
1696         if (DECL_NAME (decl))
1697           {
1698             /* Nonzero means we must output a tag as well as a typedef.  */
1699             tag_needed = 0;
1700
1701             /* Handle the case of a C++ structure or union
1702                where the TYPE_NAME is a TYPE_DECL
1703                which gives both a typedef name and a tag.  */
1704             /* dbx requires the tag first and the typedef second.  */
1705             if ((TREE_CODE (type) == RECORD_TYPE
1706                  || TREE_CODE (type) == UNION_TYPE
1707                  || TREE_CODE (type) == QUAL_UNION_TYPE)
1708                 && TYPE_NAME (type) == decl
1709                 && !(use_gnu_debug_info_extensions && have_used_extensions)
1710                 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
1711                 /* Distinguish the implicit typedefs of C++
1712                    from explicit ones that might be found in C.  */
1713                 && DECL_ARTIFICIAL (decl))
1714               {
1715                 tree name = TYPE_NAME (type);
1716                 if (TREE_CODE (name) == TYPE_DECL)
1717                   name = DECL_NAME (name);
1718
1719                 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1720                 current_sym_value = 0;
1721                 current_sym_addr = 0;
1722                 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1723
1724                 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1725                          IDENTIFIER_POINTER (name));
1726                 dbxout_type (type, 1, 0);
1727                 dbxout_finish_symbol (NULL_TREE);
1728               }
1729
1730             /* Output typedef name.  */
1731             fprintf (asmfile, "%s \"%s:", ASM_STABS_OP,
1732                      IDENTIFIER_POINTER (DECL_NAME (decl)));
1733
1734             /* Short cut way to output a tag also.  */
1735             if ((TREE_CODE (type) == RECORD_TYPE
1736                  || TREE_CODE (type) == UNION_TYPE
1737                  || TREE_CODE (type) == QUAL_UNION_TYPE)
1738                 && TYPE_NAME (type) == decl
1739                 /* Distinguish the implicit typedefs of C++
1740                    from explicit ones that might be found in C.  */
1741                 && DECL_ARTIFICIAL (decl))
1742               {
1743                 if (use_gnu_debug_info_extensions && have_used_extensions)
1744                   {
1745                     putc ('T', asmfile);
1746                     TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
1747                   }
1748 #if 0 /* Now we generate the tag for this case up above.  */
1749                 else
1750                   tag_needed = 1;
1751 #endif
1752               }
1753
1754             putc ('t', asmfile);
1755             current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1756
1757             dbxout_type (type, 1, 0);
1758             dbxout_finish_symbol (decl);
1759             did_output = 1;
1760           }
1761
1762         /* Don't output a tag if this is an incomplete type (TYPE_SIZE is
1763            zero).  This prevents the sun4 Sun OS 4.x dbx from crashing.  */ 
1764
1765         if (tag_needed && TYPE_NAME (type) != 0
1766             && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
1767                 || (DECL_NAME (TYPE_NAME (type)) != 0))
1768             && TYPE_SIZE (type) != 0
1769             && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
1770           {
1771             /* For a TYPE_DECL with no name, but the type has a name,
1772                output a tag.
1773                This is what represents `struct foo' with no typedef.  */
1774             /* In C++, the name of a type is the corresponding typedef.
1775                In C, it is an IDENTIFIER_NODE.  */
1776             tree name = TYPE_NAME (type);
1777             if (TREE_CODE (name) == TYPE_DECL)
1778               name = DECL_NAME (name);
1779
1780             current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1781             current_sym_value = 0;
1782             current_sym_addr = 0;
1783             current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1784
1785             fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1786                      IDENTIFIER_POINTER (name));
1787             dbxout_type (type, 1, 0);
1788             dbxout_finish_symbol (NULL_TREE);
1789             did_output = 1;
1790           }
1791
1792         /* If an enum type has no name, it cannot be referred to,
1793            but we must output it anyway, since the enumeration constants
1794            can be referred to.  */
1795         if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
1796           {
1797             current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1798             current_sym_value = 0;
1799             current_sym_addr = 0;
1800             current_sym_nchars = 2;
1801
1802             /* Some debuggers fail when given NULL names, so give this a
1803                harmless name of ` '.  */
1804             fprintf (asmfile, "%s \" :T", ASM_STABS_OP);
1805             dbxout_type (type, 1, 0);
1806             dbxout_finish_symbol (NULL_TREE);
1807           }
1808
1809         /* Prevent duplicate output of a typedef.  */
1810         TREE_ASM_WRITTEN (decl) = 1;
1811         break;
1812       }
1813
1814     case PARM_DECL:
1815       /* Parm decls go in their own separate chains
1816          and are output by dbxout_reg_parms and dbxout_parms.  */
1817       abort ();
1818
1819     case RESULT_DECL:
1820       /* Named return value, treat like a VAR_DECL.  */
1821     case VAR_DECL:
1822       if (DECL_RTL (decl) == 0)
1823         return;
1824       /* Don't mention a variable that is external.
1825          Let the file that defines it describe it.  */
1826       if (DECL_EXTERNAL (decl))
1827         break;
1828
1829       /* If the variable is really a constant
1830          and not written in memory, inform the debugger.  */
1831       if (TREE_STATIC (decl) && TREE_READONLY (decl)
1832           && DECL_INITIAL (decl) != 0
1833           && ! TREE_ASM_WRITTEN (decl)
1834           && (DECL_FIELD_CONTEXT (decl) == NULL_TREE
1835               || TREE_CODE (DECL_FIELD_CONTEXT (decl)) == BLOCK))
1836         {
1837           if (TREE_PUBLIC (decl) == 0)
1838             {
1839               /* The sun4 assembler does not grok this.  */
1840               char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
1841               if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
1842                   || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
1843                 {
1844                   HOST_WIDE_INT ival = TREE_INT_CST_LOW (DECL_INITIAL (decl));
1845 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
1846                   DBX_OUTPUT_CONSTANT_SYMBOL (asmfile, name, ival);
1847 #else
1848                   fprintf (asmfile, "%s \"%s:c=i%d\",0x%x,0,0,0\n",
1849                            ASM_STABS_OP, name, ival, N_LSYM);
1850 #endif
1851                   return;
1852                 }
1853               else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
1854                 {
1855                   /* don't know how to do this yet.  */
1856                 }
1857               break;
1858             }
1859           /* else it is something we handle like a normal variable.  */
1860         }
1861
1862       DECL_RTL (decl) = eliminate_regs (DECL_RTL (decl), 0, NULL_RTX, 0);
1863 #ifdef LEAF_REG_REMAP
1864       if (leaf_function)
1865         leaf_renumber_regs_insn (DECL_RTL (decl));
1866 #endif
1867
1868       dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
1869     }
1870 }
1871 \f
1872 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
1873    Add SUFFIX to its name, if SUFFIX is not 0.
1874    Describe the variable as residing in HOME
1875    (usually HOME is DECL_RTL (DECL), but not always).  */
1876
1877 static void
1878 dbxout_symbol_location (decl, type, suffix, home)
1879      tree decl, type;
1880      char *suffix;
1881      rtx home;
1882 {
1883   int letter = 0;
1884   int regno = -1;
1885
1886   /* Don't mention a variable at all
1887      if it was completely optimized into nothingness.
1888      
1889      If the decl was from an inline function, then it's rtl
1890      is not identically the rtl that was used in this
1891      particular compilation.  */
1892   if (GET_CODE (home) == REG)
1893     {
1894       regno = REGNO (home);
1895       if (regno >= FIRST_PSEUDO_REGISTER)
1896         return;
1897     }
1898   else if (GET_CODE (home) == SUBREG)
1899     {
1900       rtx value = home;
1901       int offset = 0;
1902       while (GET_CODE (value) == SUBREG)
1903         {
1904           offset += SUBREG_WORD (value);
1905           value = SUBREG_REG (value);
1906         }
1907       if (GET_CODE (value) == REG)
1908         {
1909           regno = REGNO (value);
1910           if (regno >= FIRST_PSEUDO_REGISTER)
1911             return;
1912           regno += offset;
1913         }
1914       alter_subreg (home);
1915     }
1916
1917   /* The kind-of-variable letter depends on where
1918      the variable is and on the scope of its name:
1919      G and N_GSYM for static storage and global scope,
1920      S for static storage and file scope,
1921      V for static storage and local scope,
1922      for those two, use N_LCSYM if data is in bss segment,
1923      N_STSYM if in data segment, N_FUN otherwise.
1924      (We used N_FUN originally, then changed to N_STSYM
1925      to please GDB.  However, it seems that confused ld.
1926      Now GDB has been fixed to like N_FUN, says Kingdon.)
1927      no letter at all, and N_LSYM, for auto variable,
1928      r and N_RSYM for register variable.  */
1929
1930   if (GET_CODE (home) == MEM
1931       && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
1932     {
1933       if (TREE_PUBLIC (decl))
1934         {
1935           letter = 'G';
1936           current_sym_code = N_GSYM;
1937         }
1938       else
1939         {
1940           current_sym_addr = XEXP (home, 0);
1941
1942           letter = decl_function_context (decl) ? 'V' : 'S';
1943
1944           /* This should be the same condition as in assemble_variable, but
1945              we don't have access to dont_output_data here.  So, instead,
1946              we rely on the fact that error_mark_node initializers always
1947              end up in bss for C++ and never end up in bss for C.  */
1948           if (DECL_INITIAL (decl) == 0
1949               || (!strcmp (lang_identify (), "cplusplus")
1950                   && DECL_INITIAL (decl) == error_mark_node))
1951             current_sym_code = N_LCSYM;
1952           else if (DECL_IN_TEXT_SECTION (decl))
1953             /* This is not quite right, but it's the closest
1954                of all the codes that Unix defines.  */
1955             current_sym_code = DBX_STATIC_CONST_VAR_CODE;
1956           else
1957             {
1958               /* Ultrix `as' seems to need this.  */
1959 #ifdef DBX_STATIC_STAB_DATA_SECTION
1960               data_section ();
1961 #endif
1962               current_sym_code = N_STSYM;
1963             }
1964         }
1965     }
1966   else if (regno >= 0)
1967     {
1968       letter = 'r';
1969       current_sym_code = N_RSYM;
1970       current_sym_value = DBX_REGISTER_NUMBER (regno);
1971     }
1972   else if (GET_CODE (home) == MEM
1973            && (GET_CODE (XEXP (home, 0)) == MEM
1974                || (GET_CODE (XEXP (home, 0)) == REG
1975                    && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM)))
1976     /* If the value is indirect by memory or by a register
1977        that isn't the frame pointer
1978        then it means the object is variable-sized and address through
1979        that register or stack slot.  DBX has no way to represent this
1980        so all we can do is output the variable as a pointer.
1981        If it's not a parameter, ignore it.
1982        (VAR_DECLs like this can be made by integrate.c.)  */
1983     {
1984       if (GET_CODE (XEXP (home, 0)) == REG)
1985         {
1986           letter = 'r';
1987           current_sym_code = N_RSYM;
1988           current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
1989         }
1990       else
1991         {
1992           current_sym_code = N_LSYM;
1993           /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
1994              We want the value of that CONST_INT.  */
1995           current_sym_value
1996             = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
1997         }
1998
1999       /* Effectively do build_pointer_type, but don't cache this type,
2000          since it might be temporary whereas the type it points to
2001          might have been saved for inlining.  */
2002       /* Don't use REFERENCE_TYPE because dbx can't handle that.  */
2003       type = make_node (POINTER_TYPE);
2004       TREE_TYPE (type) = TREE_TYPE (decl);
2005     }
2006   else if (GET_CODE (home) == MEM
2007            && GET_CODE (XEXP (home, 0)) == REG)
2008     {
2009       current_sym_code = N_LSYM;
2010       current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2011     }
2012   else if (GET_CODE (home) == MEM
2013            && GET_CODE (XEXP (home, 0)) == PLUS
2014            && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2015     {
2016       current_sym_code = N_LSYM;
2017       /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2018          We want the value of that CONST_INT.  */
2019       current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2020     }
2021   else if (GET_CODE (home) == MEM
2022            && GET_CODE (XEXP (home, 0)) == CONST)
2023     {
2024       /* Handle an obscure case which can arise when optimizing and
2025          when there are few available registers.  (This is *always*
2026          the case for i386/i486 targets).  The RTL looks like
2027          (MEM (CONST ...)) even though this variable is a local `auto'
2028          or a local `register' variable.  In effect, what has happened
2029          is that the reload pass has seen that all assignments and
2030          references for one such a local variable can be replaced by
2031          equivalent assignments and references to some static storage
2032          variable, thereby avoiding the need for a register.  In such
2033          cases we're forced to lie to debuggers and tell them that
2034          this variable was itself `static'.  */
2035       current_sym_code = N_LCSYM;
2036       letter = 'V';
2037       current_sym_addr = XEXP (XEXP (home, 0), 0);
2038     }
2039   else if (GET_CODE (home) == CONCAT)
2040     {
2041       tree subtype = TREE_TYPE (type);
2042
2043       /* If the variable's storage is in two parts,
2044          output each as a separate stab with a modified name.  */
2045       if (WORDS_BIG_ENDIAN)
2046         dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2047       else
2048         dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2049
2050       /* Cast avoids warning in old compilers.  */
2051       current_sym_code = (STAB_CODE_TYPE) 0;
2052       current_sym_value = 0;
2053       current_sym_addr = 0;
2054       dbxout_prepare_symbol (decl);
2055
2056       if (WORDS_BIG_ENDIAN)
2057         dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2058       else
2059         dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2060       return;
2061     }
2062   else
2063     /* Address might be a MEM, when DECL is a variable-sized object.
2064        Or it might be const0_rtx, meaning previous passes
2065        want us to ignore this variable.  */
2066     return;
2067
2068   /* Ok, start a symtab entry and output the variable name.  */
2069   FORCE_TEXT;
2070
2071 #ifdef DBX_STATIC_BLOCK_START
2072   DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2073 #endif
2074
2075   dbxout_symbol_name (decl, suffix, letter);
2076   dbxout_type (type, 0, 0);
2077   dbxout_finish_symbol (decl);
2078
2079 #ifdef DBX_STATIC_BLOCK_END
2080   DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2081 #endif
2082 }
2083 \f
2084 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2085    Then output LETTER to indicate the kind of location the symbol has.  */
2086
2087 static void
2088 dbxout_symbol_name (decl, suffix, letter)
2089      tree decl;
2090      char *suffix;
2091      int letter;
2092 {
2093   /* One slight hitch: if this is a VAR_DECL which is a static
2094      class member, we must put out the mangled name instead of the
2095      DECL_NAME.  Note also that static member (variable) names DO NOT begin
2096      with underscores in .stabs directives.  */
2097   char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2098   if (name == 0)
2099     name = "(anon)";
2100   fprintf (asmfile, "%s \"%s%s:", ASM_STABS_OP, name,
2101            (suffix ? suffix : ""));
2102
2103   if (letter) putc (letter, asmfile);
2104 }
2105
2106 static void
2107 dbxout_prepare_symbol (decl)
2108      tree decl;
2109 {
2110 #ifdef WINNING_GDB
2111   char *filename = DECL_SOURCE_FILE (decl);
2112
2113   dbxout_source_file (asmfile, filename);
2114 #endif
2115 }
2116
2117 static void
2118 dbxout_finish_symbol (sym)
2119      tree sym;
2120 {
2121 #ifdef DBX_FINISH_SYMBOL
2122   DBX_FINISH_SYMBOL (sym);
2123 #else
2124   int line = 0;
2125   if (use_gnu_debug_info_extensions && sym != 0)
2126     line = DECL_SOURCE_LINE (sym);
2127
2128   fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2129   if (current_sym_addr)
2130     output_addr_const (asmfile, current_sym_addr);
2131   else
2132     fprintf (asmfile, "%d", current_sym_value);
2133   putc ('\n', asmfile);
2134 #endif
2135 }
2136
2137 /* Output definitions of all the decls in a chain.  */
2138
2139 void
2140 dbxout_syms (syms)
2141      tree syms;
2142 {
2143   while (syms)
2144     {
2145       dbxout_symbol (syms, 1);
2146       syms = TREE_CHAIN (syms);
2147     }
2148 }
2149 \f
2150 /* The following two functions output definitions of function parameters.
2151    Each parameter gets a definition locating it in the parameter list.
2152    Each parameter that is a register variable gets a second definition
2153    locating it in the register.
2154
2155    Printing or argument lists in gdb uses the definitions that
2156    locate in the parameter list.  But reference to the variable in
2157    expressions uses preferentially the definition as a register.  */
2158
2159 /* Output definitions, referring to storage in the parmlist,
2160    of all the parms in PARMS, which is a chain of PARM_DECL nodes.  */
2161
2162 void
2163 dbxout_parms (parms)
2164      tree parms;
2165 {
2166   for (; parms; parms = TREE_CHAIN (parms))
2167     if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2168       {
2169         dbxout_prepare_symbol (parms);
2170
2171         /* Perform any necessary register eliminations on the parameter's rtl,
2172            so that the debugging output will be accurate.  */
2173         DECL_INCOMING_RTL (parms)
2174           = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX, 0);
2175         DECL_RTL (parms) = eliminate_regs (DECL_RTL (parms), 0, NULL_RTX, 0);
2176 #ifdef LEAF_REG_REMAP
2177         if (leaf_function)
2178           {
2179             leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2180             leaf_renumber_regs_insn (DECL_RTL (parms));
2181           }
2182 #endif
2183
2184         if (PARM_PASSED_IN_MEMORY (parms))
2185           {
2186             rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2187
2188             /* ??? Here we assume that the parm address is indexed
2189                off the frame pointer or arg pointer.
2190                If that is not true, we produce meaningless results,
2191                but do not crash.  */
2192             if (GET_CODE (addr) == PLUS
2193                 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2194               current_sym_value = INTVAL (XEXP (addr, 1));
2195             else
2196               current_sym_value = 0;
2197
2198             current_sym_code = N_PSYM;
2199             current_sym_addr = 0;
2200
2201             FORCE_TEXT;
2202             if (DECL_NAME (parms))
2203               {
2204                 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2205
2206                 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2207                          IDENTIFIER_POINTER (DECL_NAME (parms)),
2208                          DBX_MEMPARM_STABS_LETTER);
2209               }
2210             else
2211               {
2212                 current_sym_nchars = 8;
2213                 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2214                          DBX_MEMPARM_STABS_LETTER);
2215               }
2216
2217             dbxout_type (DECL_ARG_TYPE (parms), 0, 0);
2218             current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2219             dbxout_finish_symbol (parms);
2220           }
2221         else if (GET_CODE (DECL_RTL (parms)) == REG)
2222           {
2223             rtx best_rtl;
2224             char regparm_letter;
2225             tree parm_type;
2226             /* Parm passed in registers and lives in registers or nowhere.  */
2227
2228             current_sym_code = DBX_REGPARM_STABS_CODE;
2229             regparm_letter = DBX_REGPARM_STABS_LETTER;
2230             current_sym_addr = 0;
2231
2232             /* If parm lives in a register, use that register;
2233                pretend the parm was passed there.  It would be more consistent
2234                to describe the register where the parm was passed,
2235                but in practice that register usually holds something else.
2236
2237                If we use DECL_RTL, then we must use the declared type of
2238                the variable, not the type that it arrived in.  */
2239             if (REGNO (DECL_RTL (parms)) >= 0
2240                 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2241               {
2242                 best_rtl = DECL_RTL (parms);
2243                 parm_type = TREE_TYPE (parms);
2244               }
2245             /* If the parm lives nowhere, use the register where it was
2246                passed.  It is also better to use the declared type here.  */
2247             else
2248               {
2249                 best_rtl = DECL_INCOMING_RTL (parms);
2250                 parm_type = TREE_TYPE (parms);
2251               }
2252             current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2253
2254             FORCE_TEXT;
2255             if (DECL_NAME (parms))
2256               {
2257                 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2258                 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2259                          IDENTIFIER_POINTER (DECL_NAME (parms)),
2260                          regparm_letter);
2261               }
2262             else
2263               {
2264                 current_sym_nchars = 8;
2265                 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2266                          regparm_letter);
2267               }
2268
2269             dbxout_type (parm_type, 0, 0);
2270             dbxout_finish_symbol (parms);
2271           }
2272         else if (GET_CODE (DECL_RTL (parms)) == MEM
2273                  && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2274                  && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2275                  && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2276 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2277                  && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2278 #endif
2279                  )
2280           {
2281             /* Parm was passed via invisible reference.
2282                That is, its address was passed in a register.
2283                Output it as if it lived in that register.
2284                The debugger will know from the type
2285                that it was actually passed by invisible reference.  */
2286
2287             char regparm_letter;
2288             /* Parm passed in registers and lives in registers or nowhere.  */
2289
2290             current_sym_code = DBX_REGPARM_STABS_CODE;
2291             if (use_gnu_debug_info_extensions)
2292               regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2293             else
2294               regparm_letter = DBX_REGPARM_STABS_LETTER;
2295
2296             /* DECL_RTL looks like (MEM (REG...).  Get the register number.
2297                If it is an unallocated pseudo-reg, then use the register where
2298                it was passed instead.  */
2299             if (REGNO (XEXP (DECL_RTL (parms), 0)) >= 0
2300                 && REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2301               current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2302             else
2303               current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2304
2305             current_sym_addr = 0;
2306
2307             FORCE_TEXT;
2308             if (DECL_NAME (parms))
2309               {
2310                 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2311
2312                 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2313                          IDENTIFIER_POINTER (DECL_NAME (parms)),
2314                          regparm_letter);
2315               }
2316             else
2317               {
2318                 current_sym_nchars = 8;
2319                 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2320                          regparm_letter);
2321               }
2322
2323             dbxout_type (TREE_TYPE (parms), 0, 0);
2324             dbxout_finish_symbol (parms);
2325           }
2326         else if (GET_CODE (DECL_RTL (parms)) == MEM
2327                  && XEXP (DECL_RTL (parms), 0) != const0_rtx
2328                  /* ??? A constant address for a parm can happen
2329                     when the reg it lives in is equiv to a constant in memory.
2330                     Should make this not happen, after 2.4.  */
2331                  && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2332           {
2333             /* Parm was passed in registers but lives on the stack.  */
2334
2335             current_sym_code = N_PSYM;
2336             /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2337                in which case we want the value of that CONST_INT,
2338                or (MEM (REG ...)) or (MEM (MEM ...)),
2339                in which case we use a value of zero.  */
2340             if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2341                 || GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2342               current_sym_value = 0;
2343             else
2344               current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2345             current_sym_addr = 0;
2346
2347             FORCE_TEXT;
2348             if (DECL_NAME (parms))
2349               {
2350                 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2351
2352                 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2353                          IDENTIFIER_POINTER (DECL_NAME (parms)),
2354                          DBX_MEMPARM_STABS_LETTER);
2355               }
2356             else
2357               {
2358                 current_sym_nchars = 8;
2359                 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2360                 DBX_MEMPARM_STABS_LETTER);
2361               }
2362
2363             current_sym_value
2364               = DEBUGGER_ARG_OFFSET (current_sym_value,
2365                                      XEXP (DECL_RTL (parms), 0));
2366             dbxout_type (TREE_TYPE (parms), 0, 0);
2367             dbxout_finish_symbol (parms);
2368           }
2369       }
2370 }
2371
2372 /* Output definitions for the places where parms live during the function,
2373    when different from where they were passed, when the parms were passed
2374    in memory.
2375
2376    It is not useful to do this for parms passed in registers
2377    that live during the function in different registers, because it is
2378    impossible to look in the passed register for the passed value,
2379    so we use the within-the-function register to begin with.
2380
2381    PARMS is a chain of PARM_DECL nodes.  */
2382
2383 void
2384 dbxout_reg_parms (parms)
2385      tree parms;
2386 {
2387   for (; parms; parms = TREE_CHAIN (parms))
2388     if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
2389       {
2390         dbxout_prepare_symbol (parms);
2391
2392         /* Report parms that live in registers during the function
2393            but were passed in memory.  */
2394         if (GET_CODE (DECL_RTL (parms)) == REG
2395             && REGNO (DECL_RTL (parms)) >= 0
2396             && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2397           dbxout_symbol_location (parms, TREE_TYPE (parms),
2398                                   0, DECL_RTL (parms));
2399         else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
2400           dbxout_symbol_location (parms, TREE_TYPE (parms),
2401                                   0, DECL_RTL (parms));
2402         /* Report parms that live in memory but not where they were passed.  */
2403         else if (GET_CODE (DECL_RTL (parms)) == MEM
2404                  && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
2405           dbxout_symbol_location (parms, TREE_TYPE (parms),
2406                                   0, DECL_RTL (parms));
2407       }
2408 }
2409 \f
2410 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2411    output definitions of those names, in raw form */
2412
2413 void
2414 dbxout_args (args)
2415      tree args;
2416 {
2417   while (args)
2418     {
2419       putc (',', asmfile);
2420       dbxout_type (TREE_VALUE (args), 0, 0);
2421       CHARS (1);
2422       args = TREE_CHAIN (args);
2423     }
2424 }
2425 \f
2426 /* Given a chain of ..._TYPE nodes,
2427    find those which have typedef names and output those names.
2428    This is to ensure those types get output.  */
2429
2430 void
2431 dbxout_types (types)
2432      register tree types;
2433 {
2434   while (types)
2435     {
2436       if (TYPE_NAME (types)
2437           && TREE_CODE (TYPE_NAME (types)) == TYPE_DECL
2438           && ! TREE_ASM_WRITTEN (TYPE_NAME (types)))
2439         dbxout_symbol (TYPE_NAME (types), 1);
2440       types = TREE_CHAIN (types);
2441     }
2442 }
2443 \f
2444 /* Output everything about a symbol block (a BLOCK node
2445    that represents a scope level),
2446    including recursive output of contained blocks.
2447
2448    BLOCK is the BLOCK node.
2449    DEPTH is its depth within containing symbol blocks.
2450    ARGS is usually zero; but for the outermost block of the
2451    body of a function, it is a chain of PARM_DECLs for the function parameters.
2452    We output definitions of all the register parms
2453    as if they were local variables of that block.
2454
2455    If -g1 was used, we count blocks just the same, but output nothing
2456    except for the outermost block.
2457
2458    Actually, BLOCK may be several blocks chained together.
2459    We handle them all in sequence.  */
2460
2461 static void
2462 dbxout_block (block, depth, args)
2463      register tree block;
2464      int depth;
2465      tree args;
2466 {
2467   int blocknum;
2468
2469   while (block)
2470     {
2471       /* Ignore blocks never expanded or otherwise marked as real.  */
2472       if (TREE_USED (block))
2473         {
2474 #ifndef DBX_LBRAC_FIRST
2475           /* In dbx format, the syms of a block come before the N_LBRAC.  */
2476           if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2477             dbxout_syms (BLOCK_VARS (block));
2478           if (args)
2479             dbxout_reg_parms (args);
2480 #endif
2481
2482           /* Now output an N_LBRAC symbol to represent the beginning of
2483              the block.  Use the block's tree-walk order to generate
2484              the assembler symbols LBBn and LBEn
2485              that final will define around the code in this block.  */
2486           if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2487             {
2488               char buf[20];
2489               blocknum = next_block_number++;
2490               ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
2491
2492               if (BLOCK_HANDLER_BLOCK (block))
2493                 {
2494                   /* A catch block.  Must precede N_LBRAC.  */
2495                   tree decl = BLOCK_VARS (block);
2496                   while (decl)
2497                     {
2498 #ifdef DBX_OUTPUT_CATCH
2499                       DBX_OUTPUT_CATCH (asmfile, decl, buf);
2500 #else
2501                       fprintf (asmfile, "%s \"%s:C1\",%d,0,0,", ASM_STABS_OP,
2502                                IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
2503                       assemble_name (asmfile, buf);
2504                       fprintf (asmfile, "\n");
2505 #endif
2506                       decl = TREE_CHAIN (decl);
2507                     }
2508                 }
2509
2510 #ifdef DBX_OUTPUT_LBRAC
2511               DBX_OUTPUT_LBRAC (asmfile, buf);
2512 #else
2513               fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);
2514               assemble_name (asmfile, buf);
2515 #if DBX_BLOCKS_FUNCTION_RELATIVE
2516               fputc ('-', asmfile);
2517               assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2518 #endif
2519               fprintf (asmfile, "\n");
2520 #endif
2521             }
2522           else if (depth > 0)
2523             /* Count blocks the same way regardless of debug_info_level.  */
2524             next_block_number++;
2525
2526 #ifdef DBX_LBRAC_FIRST
2527           /* On some weird machines, the syms of a block
2528              come after the N_LBRAC.  */
2529           if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2530             dbxout_syms (BLOCK_VARS (block));
2531           if (args)
2532             dbxout_reg_parms (args);
2533 #endif
2534
2535           /* Output the subblocks.  */
2536           dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
2537
2538           /* Refer to the marker for the end of the block.  */
2539           if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2540             {
2541               char buf[20];
2542               ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
2543 #ifdef DBX_OUTPUT_RBRAC
2544               DBX_OUTPUT_RBRAC (asmfile, buf);
2545 #else
2546               fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);
2547               assemble_name (asmfile, buf);
2548 #if DBX_BLOCKS_FUNCTION_RELATIVE
2549               fputc ('-', asmfile);
2550               assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2551 #endif
2552               fprintf (asmfile, "\n");
2553 #endif
2554             }
2555         }
2556       block = BLOCK_CHAIN (block);
2557     }
2558 }
2559
2560 /* Output the information about a function and its arguments and result.
2561    Usually this follows the function's code,
2562    but on some systems, it comes before.  */
2563
2564 static void
2565 dbxout_really_begin_function (decl)
2566      tree decl;
2567 {
2568   dbxout_symbol (decl, 0);
2569   dbxout_parms (DECL_ARGUMENTS (decl));
2570   if (DECL_NAME (DECL_RESULT (decl)) != 0)
2571     dbxout_symbol (DECL_RESULT (decl), 1);
2572 }
2573
2574 /* Called at beginning of output of function definition.  */
2575
2576 void
2577 dbxout_begin_function (decl)
2578      tree decl;
2579 {
2580 #ifdef DBX_FUNCTION_FIRST
2581   dbxout_really_begin_function (decl);
2582 #endif
2583 }
2584
2585 /* Output dbx data for a function definition.
2586    This includes a definition of the function name itself (a symbol),
2587    definitions of the parameters (locating them in the parameter list)
2588    and then output the block that makes up the function's body
2589    (including all the auto variables of the function).  */
2590
2591 void
2592 dbxout_function (decl)
2593      tree decl;
2594 {
2595 #ifndef DBX_FUNCTION_FIRST
2596   dbxout_really_begin_function (decl);
2597 #endif
2598   dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
2599 #ifdef DBX_OUTPUT_FUNCTION_END
2600   DBX_OUTPUT_FUNCTION_END (asmfile, decl);
2601 #endif
2602 #if defined(ASM_OUTPUT_SECTION_NAME) && !defined(NO_DBX_FUNCTION_END)
2603   if (use_gnu_debug_info_extensions)
2604     dbxout_function_end ();
2605 #endif
2606 }
2607 #endif /* DBX_DEBUGGING_INFO */