source: trunk/third/gcc/dbxout.c @ 11288

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