OSDN Git Service

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