1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987, 1988, 1992 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 /* Output dbx-format symbol table data.
22 This consists of many symbol table entries, each of them
23 a .stabs assembler pseudo-op with four operands:
24 a "name" which is really a description of one symbol and its type,
25 a "code", which is a symbol defined in stab.h whose name starts with N_,
26 an unused operand always 0,
27 and a "value" which is an address or an offset.
28 The name is enclosed in doublequote characters.
30 Each function, variable, typedef, and structure tag
31 has a symbol table entry to define it.
32 The beginning and end of each level of name scoping within
33 a function are also marked by special symbol table entries.
35 The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
36 and a data type number. The data type number may be followed by
37 "=" and a type definition; normally this will happen the first time
38 the type number is mentioned. The type definition may refer to
39 other types by number, and those type numbers may be followed
40 by "=" and nested definitions.
42 This can make the "name" quite long.
43 When a name is more than 80 characters, we split the .stabs pseudo-op
44 into two .stabs pseudo-ops, both sharing the same "code" and "value".
45 The first one is marked as continued with a double-backslash at the
48 The kind-of-symbol letter distinguished function names from global
49 variables from file-scope variables from parameters from auto
50 variables in memory from typedef names from register variables.
53 The "code" is mostly redundant with the kind-of-symbol letter
54 that goes in the "name", but not entirely: for symbols located
55 in static storage, the "code" says which segment the address is in,
56 which controls how it is relocated.
58 The "value" for a symbol in static storage
59 is the core address of the symbol (actually, the assembler
60 label for the symbol). For a symbol located in a stack slot
61 it is the stack offset; for one in a register, the register number.
62 For a typedef symbol, it is zero.
64 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
65 output while in the text section.
67 For more on data type definitions, see `dbxout_type'. */
69 /* Include these first, because they may define MIN and MAX. */
78 #include "insn-config.h"
81 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
87 #ifdef XCOFF_DEBUGGING_INFO
92 #define ASM_STABS_OP ".stabs"
96 #define ASM_STABN_OP ".stabn"
99 #ifndef DBX_TYPE_DECL_STABS_CODE
100 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
103 #ifndef DBX_STATIC_CONST_VAR_CODE
104 #define DBX_STATIC_CONST_VAR_CODE N_FUN
107 #ifndef DBX_REGPARM_STABS_CODE
108 #define DBX_REGPARM_STABS_CODE N_RSYM
111 #ifndef DBX_REGPARM_STABS_LETTER
112 #define DBX_REGPARM_STABS_LETTER 'P'
115 #ifndef DBX_MEMPARM_STABS_LETTER
116 #define DBX_MEMPARM_STABS_LETTER 'p'
119 /* Nonzero means if the type has methods, only output debugging
120 information if methods are actually written to the asm file. */
122 static int flag_minimal_debug = 1;
124 /* Nonzero if we have actually used any of the GDB extensions
125 to the debugging format. The idea is that we use them for the
126 first time only if there's a strong reason, but once we have done that,
127 we use them whenever convenient. */
129 static int have_used_extensions = 0;
133 /* Typical USG systems don't have stab.h, and they also have
134 no use for DBX-format debugging info. */
136 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
138 #ifdef DEBUG_SYMS_TEXT
139 #define FORCE_TEXT text_section ();
144 #if defined (USG) || defined (NO_STAB_H)
145 #include "gstab.h" /* If doing DBX on sysV, use our own stab.h. */
147 #include <stab.h> /* On BSD, use the system's stab.h. */
149 /* This is a GNU extension we need to reference in this file. */
156 #define STAB_CODE_TYPE enum __stab_debug_code
158 #define STAB_CODE_TYPE int
161 /* 1 if PARM is passed to this function in memory. */
163 #define PARM_PASSED_IN_MEMORY(PARM) \
164 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
166 /* A C expression for the integer offset value of an automatic variable
167 (N_LSYM) having address X (an RTX). */
168 #ifndef DEBUGGER_AUTO_OFFSET
169 #define DEBUGGER_AUTO_OFFSET(X) \
170 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
173 /* A C expression for the integer offset value of an argument (N_PSYM)
174 having address X (an RTX). The nominal offset is OFFSET. */
175 #ifndef DEBUGGER_ARG_OFFSET
176 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
179 /* Stream for writing to assembler file. */
181 static FILE *asmfile;
183 /* Last source file name mentioned in a NOTE insn. */
185 static char *lastfile;
187 /* Current working directory. */
191 enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
193 /* Vector recording the status of describing C data types.
194 When we first notice a data type (a tree node),
195 we assign it a number using next_type_number.
196 That is its index in this vector.
197 The vector element says whether we have yet output
198 the definition of the type. TYPE_XREF says we have
199 output it as a cross-reference only. */
201 enum typestatus *typevec;
203 /* Number of elements of space allocated in `typevec'. */
205 static int typevec_len;
207 /* In dbx output, each type gets a unique number.
208 This is the number for the next type output.
209 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
211 static int next_type_number;
213 /* In dbx output, we must assign symbol-blocks id numbers
214 in the order in which their beginnings are encountered.
215 We output debugging info that refers to the beginning and
216 end of the ranges of code in each block
217 with assembler labels LBBn and LBEn, where n is the block number.
218 The labels are generated in final, which assigns numbers to the
219 blocks in the same way. */
221 static int next_block_number;
223 /* These variables are for dbxout_symbol to communicate to
224 dbxout_finish_symbol.
225 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
226 current_sym_value and current_sym_addr are two ways to address the
227 value to store in the symtab entry.
228 current_sym_addr if nonzero represents the value as an rtx.
229 If that is zero, current_sym_value is used. This is used
230 when the value is an offset (such as for auto variables,
231 register variables and parms). */
233 static STAB_CODE_TYPE current_sym_code;
234 static int current_sym_value;
235 static rtx current_sym_addr;
237 /* Number of chars of symbol-description generated so far for the
238 current symbol. Used by CHARS and CONTIN. */
240 static int current_sym_nchars;
242 /* Report having output N chars of the current symbol-description. */
244 #define CHARS(N) (current_sym_nchars += (N))
246 /* Break the current symbol-description, generating a continuation,
247 if it has become long. */
249 #ifndef DBX_CONTIN_LENGTH
250 #define DBX_CONTIN_LENGTH 80
253 #if DBX_CONTIN_LENGTH > 0
255 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
260 void dbxout_types ();
262 void dbxout_symbol ();
263 static void dbxout_type_name ();
264 static void dbxout_type ();
265 static void dbxout_typedefs ();
266 static void dbxout_symbol_name ();
267 static void dbxout_symbol_location ();
268 static void dbxout_prepare_symbol ();
269 static void dbxout_finish_symbol ();
270 static void dbxout_continue ();
271 static void print_int_cst_octal ();
272 static void print_octal ();
274 #if 0 /* Not clear we will actually need this. */
276 /* Return the absolutized filename for the given relative
277 filename. Note that if that filename is already absolute, it may
278 still be returned in a modified form because this routine also
279 eliminates redundant slashes and single dots and eliminates double
280 dots to get a shortest possible filename from the given input
281 filename. The absolutization of relative filenames is made by
282 assuming that the given filename is to be taken as relative to
283 the first argument (cwd) or to the current directory if cwd is
287 abspath (rel_filename)
290 /* Setup the current working directory as needed. */
292 = (char *) alloca (strlen (cwd) + strlen (rel_filename) + 1);
293 char *endp = abs_buffer;
297 /* Copy the filename (possibly preceded by the current working
298 directory name) into the absolutization buffer. */
303 if (rel_filename[0] != '/')
306 while (*endp++ = *src_p++)
308 *(endp-1) = '/'; /* overwrite null */
310 src_p = rel_filename;
311 while (*endp++ = *src_p++)
316 /* Now make a copy of abs_buffer into abs_buffer, shortening the
317 filename (by taking out slashes and dots) as we go. */
319 outp = inp = abs_buffer;
320 *outp++ = *inp++; /* copy first slash */
325 else if (inp[0] == '/' && outp[-1] == '/')
330 else if (inp[0] == '.' && outp[-1] == '/')
334 else if (inp[1] == '/')
339 else if ((inp[1] == '.') && (inp[2] == 0 || inp[2] == '/'))
341 inp += (inp[2] == '/') ? 3 : 2;
343 while (outp >= abs_buffer && *outp != '/')
345 if (outp < abs_buffer)
347 /* Catch cases like /.. where we try to backup to a
348 point above the absolute root of the logical file
351 fprintf (stderr, "%s: invalid file name: %s\n",
352 pname, rel_filename);
362 /* On exit, make sure that there is a trailing null, and make sure that
363 the last character of the returned string is *not* a slash. */
369 /* Make a copy (in the heap) of the stuff left in the absolutization
370 buffer and return a pointer to the copy. */
372 value = (char *) oballoc (strlen (abs_buffer) + 1);
373 strcpy (value, abs_buffer);
378 /* At the beginning of compilation, start writing the symbol table.
379 Initialize `typevec' and output the standard data types of C. */
382 dbxout_init (asm_file, input_file_name, syms)
384 char *input_file_name;
387 char ltext_label_name[100];
392 typevec = (enum typestatus *) xmalloc (typevec_len * sizeof typevec[0]);
393 bzero (typevec, typevec_len * sizeof typevec[0]);
395 /* Convert Ltext into the appropriate format for local labels in case
396 the system doesn't insert underscores in front of user generated
398 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
400 /* Put the current working directory in an N_SO symbol. */
401 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
402 but GDB always does. */
403 if (use_gnu_debug_info_extensions)
406 if (cwd || (cwd = getpwd ()))
408 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
409 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
410 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
411 fprintf (asmfile, "%s \"%s/\",%d,0,0,%s\n", ASM_STABS_OP,
412 cwd, N_SO, <ext_label_name[1]);
413 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
417 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
418 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
419 would give us an N_SOL, and we want an N_SO. */
420 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
421 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
422 /* We include outputting `Ltext:' here,
423 because that gives you a way to override it. */
424 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
425 fprintf (asmfile, "%s \"%s\",%d,0,0,%s\n", ASM_STABS_OP, input_file_name,
426 N_SO, <ext_label_name[1]);
428 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Ltext", 0);
429 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
431 /* Possibly output something to inform GDB that this compilation was by
432 GCC. It's easier for GDB to parse it when after the N_SO's. This
433 is used in Solaris 2. */
434 #ifdef ASM_IDENTIFY_GCC_AFTER_SOURCE
435 ASM_IDENTIFY_GCC_AFTER_SOURCE (asmfile);
438 lastfile = input_file_name;
440 next_type_number = 1;
441 next_block_number = 2;
443 /* Make sure that types `int' and `char' have numbers 1 and 2.
444 Definitions of other integer types will refer to those numbers.
445 (Actually it should no longer matter what their numbers are.
446 Also, if any types with tags have been defined, dbxout_symbol
447 will output them first, so the numbers won't be 1 and 2. That
448 happens in C++. So it's a good thing it should no longer matter). */
450 #ifdef DBX_OUTPUT_STANDARD_TYPES
451 DBX_OUTPUT_STANDARD_TYPES (syms);
453 dbxout_symbol (TYPE_NAME (integer_type_node), 0);
454 dbxout_symbol (TYPE_NAME (char_type_node), 0);
457 /* Get all permanent types that have typedef names,
458 and output them all, except for those already output. */
460 dbxout_typedefs (syms);
463 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
464 in the reverse order from that which is found in SYMS. */
467 dbxout_typedefs (syms)
472 dbxout_typedefs (TREE_CHAIN (syms));
473 if (TREE_CODE (syms) == TYPE_DECL)
475 tree type = TREE_TYPE (syms);
477 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
478 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
479 dbxout_symbol (TYPE_NAME (type), 0);
484 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
487 dbxout_source_file (file, filename)
491 char ltext_label_name[100];
493 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
495 #ifdef DBX_OUTPUT_SOURCE_FILENAME
496 DBX_OUTPUT_SOURCE_FILENAME (file, filename);
498 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
499 fprintf (file, "%s \"%s\",%d,0,0,%s\n", ASM_STABS_OP,
500 filename, N_SOL, <ext_label_name[1]);
506 /* Output a line number symbol entry into output stream FILE,
507 for source file FILENAME and line number LINENO. */
510 dbxout_source_line (file, filename, lineno)
515 dbxout_source_file (file, filename);
517 #ifdef ASM_OUTPUT_SOURCE_LINE
518 ASM_OUTPUT_SOURCE_LINE (file, lineno);
520 fprintf (file, "\t%s %d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
524 /* At the end of compilation, finish writing the symbol table.
525 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
529 dbxout_finish (file, filename)
533 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
534 DBX_OUTPUT_MAIN_SOURCE_FILE_END (file, filename);
535 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
538 /* Continue a symbol-description that gets too big.
539 End one symbol table entry with a double-backslash
540 and start a new one, eventually producing something like
541 .stabs "start......\\",code,0,value
542 .stabs "...rest",code,0,value */
547 #ifdef DBX_CONTIN_CHAR
548 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
550 fprintf (asmfile, "\\\\");
552 dbxout_finish_symbol (NULL_TREE);
553 fprintf (asmfile, "%s \"", ASM_STABS_OP);
554 current_sym_nchars = 0;
557 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
558 This must be a separate function because anonymous unions require
562 dbxout_type_fields (type)
566 /* Output the name, type, position (in bits), size (in bits) of each
568 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
570 /* For nameless subunions and subrecords, treat their fields as ours. */
571 if (DECL_NAME (tem) == NULL_TREE
572 && (TREE_CODE (TREE_TYPE (tem)) == UNION_TYPE
573 || TREE_CODE (TREE_TYPE (tem)) == QUAL_UNION_TYPE
574 || TREE_CODE (TREE_TYPE (tem)) == RECORD_TYPE))
575 dbxout_type_fields (TREE_TYPE (tem));
576 /* Omit here local type decls until we know how to support them. */
577 else if (TREE_CODE (tem) == TYPE_DECL)
579 /* Omit here the nameless fields that are used to skip bits. */
580 else if (DECL_NAME (tem) != 0 && TREE_CODE (tem) != CONST_DECL)
582 /* Continue the line if necessary,
583 but not before the first field. */
584 if (tem != TYPE_FIELDS (type))
587 if (use_gnu_debug_info_extensions
588 && flag_minimal_debug
589 && TREE_CODE (tem) == FIELD_DECL
590 && DECL_VIRTUAL_P (tem)
591 && DECL_ASSEMBLER_NAME (tem))
593 have_used_extensions = 1;
594 CHARS (3 + IDENTIFIER_LENGTH (DECL_NAME (TYPE_NAME (DECL_FCONTEXT (tem)))));
595 fputs (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem)), asmfile);
596 dbxout_type (DECL_FCONTEXT (tem), 0, 0);
597 fprintf (asmfile, ":");
598 dbxout_type (TREE_TYPE (tem), 0, 0);
599 fprintf (asmfile, ",%d;",
600 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)));
604 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
605 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
607 if (use_gnu_debug_info_extensions
608 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
609 || TREE_CODE (tem) != FIELD_DECL))
611 have_used_extensions = 1;
613 putc ((TREE_PRIVATE (tem) ? '0'
614 : TREE_PROTECTED (tem) ? '1' : '2'),
619 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
620 && DECL_BIT_FIELD_TYPE (tem))
621 ? DECL_BIT_FIELD_TYPE (tem)
622 : TREE_TYPE (tem), 0, 0);
624 if (TREE_CODE (tem) == VAR_DECL)
626 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
628 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem));
629 have_used_extensions = 1;
630 fprintf (asmfile, ":%s;", name);
631 CHARS (strlen (name));
635 /* If TEM is non-static, GDB won't understand it. */
636 fprintf (asmfile, ",0,0;");
639 else if (TREE_CODE (DECL_FIELD_BITPOS (tem)) == INTEGER_CST)
641 fprintf (asmfile, ",%d,%d;",
642 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)),
643 TREE_INT_CST_LOW (DECL_SIZE (tem)));
646 /* This has yet to be implemented. */
653 /* Subroutine of `dbxout_type_methods'. Output debug info about the
654 method described DECL. DEBUG_NAME is an encoding of the method's
655 type signature. ??? We may be able to do without DEBUG_NAME altogether
659 dbxout_type_method_1 (decl, debug_name)
663 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
666 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
668 else /* it's a METHOD_TYPE. */
670 /* A for normal functions.
671 B for `const' member functions.
672 C for `volatile' member functions.
673 D for `const volatile' member functions. */
674 if (TYPE_READONLY (TREE_TYPE (firstarg)))
676 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
679 if (DECL_VINDEX (decl))
685 fprintf (asmfile, ":%s;%c%c%c", debug_name,
686 TREE_PRIVATE (decl) ? '0' : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
687 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
688 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
689 if (DECL_VINDEX (decl))
691 fprintf (asmfile, "%d;",
692 TREE_INT_CST_LOW (DECL_VINDEX (decl)));
693 dbxout_type (DECL_CONTEXT (decl), 0, 0);
694 fprintf (asmfile, ";");
699 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
703 dbxout_type_methods (type)
706 /* C++: put out the method names and their parameter lists */
707 tree methods = TYPE_METHODS (type);
709 register tree fndecl;
711 char formatted_type_identifier_length[16];
712 register int type_identifier_length;
714 if (methods == NULL_TREE)
717 type_encoding = DECL_NAME (TYPE_NAME (type));
719 /* C++: Template classes break some assumptions made by this code about
720 the class names, constructor names, and encodings for assembler
721 label names. For now, disable output of dbx info for them. */
723 char *ptr = IDENTIFIER_POINTER (type_encoding);
724 /* This should use index. (mrs) */
725 while (*ptr && *ptr != '<') ptr++;
732 #ifdef HAVE_TEMPLATES
733 if (warn_template_debugging)
734 warning ("dbx info for template class methods not yet supported");
741 type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
743 sprintf(formatted_type_identifier_length, "%d", type_identifier_length);
745 if (TREE_CODE (methods) == FUNCTION_DECL)
747 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
748 fndecl = TREE_VEC_ELT (methods, 0);
750 fndecl = TREE_VEC_ELT (methods, 1);
754 tree name = DECL_NAME (fndecl);
757 /* Group together all the methods for the same operation.
758 These differ in the types of the arguments. */
759 for (last = NULL_TREE;
760 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
761 fndecl = TREE_CHAIN (fndecl))
762 /* Output the name of the field (after overloading), as
763 well as the name of the field before overloading, along
764 with its parameter list */
766 /* This is the "mangled" name of the method.
767 It encodes the argument types. */
768 char *debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
775 if (DECL_IGNORED_P (fndecl))
778 if (flag_minimal_debug)
780 /* Detect ordinary methods because their mangled names
781 start with the operation name. */
782 if (!strncmp (IDENTIFIER_POINTER (name), debug_name,
783 IDENTIFIER_LENGTH (name)))
785 debug_name += IDENTIFIER_LENGTH (name);
786 if (debug_name[0] == '_' && debug_name[1] == '_')
788 char *method_name = debug_name + 2;
789 char *length_ptr = formatted_type_identifier_length;
790 /* Get past const and volatile qualifiers. */
791 while (*method_name == 'C' || *method_name == 'V')
793 /* Skip digits for length of type_encoding. */
794 while (*method_name == *length_ptr && *length_ptr)
795 length_ptr++, method_name++;
796 if (! strncmp (method_name,
797 IDENTIFIER_POINTER (type_encoding),
798 type_identifier_length))
799 method_name += type_identifier_length;
800 debug_name = method_name;
803 /* Detect constructors by their style of name mangling. */
804 else if (debug_name[0] == '_' && debug_name[1] == '_')
806 char *ctor_name = debug_name + 2;
807 char *length_ptr = formatted_type_identifier_length;
808 while (*ctor_name == 'C' || *ctor_name == 'V')
810 /* Skip digits for length of type_encoding. */
811 while (*ctor_name == *length_ptr && *length_ptr)
812 length_ptr++, ctor_name++;
813 if (!strncmp (IDENTIFIER_POINTER (type_encoding), ctor_name,
814 type_identifier_length))
815 debug_name = ctor_name + type_identifier_length;
817 /* The other alternative is a destructor. */
821 /* Output the operation name just once, for the first method
825 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
826 CHARS (IDENTIFIER_LENGTH (name) + 2);
831 dbxout_type (TREE_TYPE (fndecl), 0, destructor);
833 dbxout_type_method_1 (fndecl, debug_name);
843 /* Emit a "range" type specification, which has the form:
844 "r<index type>;<lower bound>;<upper bound>;".
845 TYPE is an INTEGER_TYPE. */
848 dbxout_range_type (type)
851 fprintf (asmfile, "r");
852 if (TREE_TYPE (type) && TREE_CODE (TREE_TYPE(type)) != INTEGER_TYPE)
853 dbxout_type (TREE_TYPE (type), 0, 0);
856 /* This used to say `r1' and we used to take care
857 to make sure that `int' was type number 1. */
858 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (integer_type_node));
860 if (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST)
861 fprintf (asmfile, ";%d",
862 TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)));
864 fprintf (asmfile, ";0");
865 if (TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST)
866 fprintf (asmfile, ";%d;",
867 TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)));
869 fprintf (asmfile, ";-1;");
872 /* Output a reference to a type. If the type has not yet been
873 described in the dbx output, output its definition now.
874 For a type already defined, just refer to its definition
875 using the type number.
877 If FULL is nonzero, and the type has been described only with
878 a forward-reference, output the definition now.
879 If FULL is zero in this case, just refer to the forward-reference
880 using the number previously allocated.
882 If SHOW_ARG_TYPES is nonzero, we output a description of the argument
883 types for a METHOD_TYPE. */
886 dbxout_type (type, full, show_arg_types)
892 static int anonymous_type_number = 0;
894 /* If there was an input error and we don't really have a type,
895 avoid crashing and write something that is at least valid
896 by assuming `int'. */
897 if (type == error_mark_node)
898 type = integer_type_node;
901 type = TYPE_MAIN_VARIANT (type);
903 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
904 && DECL_IGNORED_P (TYPE_NAME (type)))
908 if (TYPE_SYMTAB_ADDRESS (type) == 0)
910 /* Type has no dbx number assigned. Assign next available number. */
911 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
913 /* Make sure type vector is long enough to record about this type. */
915 if (next_type_number == typevec_len)
917 typevec = (enum typestatus *) xrealloc (typevec, typevec_len * 2 * sizeof typevec[0]);
918 bzero (typevec + typevec_len, typevec_len * sizeof typevec[0]);
923 /* Output the number of this type, to refer to it. */
924 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
927 #ifdef DBX_TYPE_DEFINED
928 if (DBX_TYPE_DEFINED (type))
932 /* If this type's definition has been output or is now being output,
935 switch (typevec[TYPE_SYMTAB_ADDRESS (type)])
940 /* If we have already had a cross reference,
941 and either that's all we want or that's the best we could do,
942 don't repeat the cross reference.
943 Sun dbx crashes if we do. */
944 if (! full || TYPE_SIZE (type) == 0
945 /* No way in DBX fmt to describe a variable size. */
946 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
954 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
955 leave the type-number completely undefined rather than output
956 a cross-reference. */
957 if (TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
958 || TREE_CODE (type) == QUAL_UNION_TYPE
959 || TREE_CODE (type) == ENUMERAL_TYPE)
961 if ((TYPE_NAME (type) != 0 && !full)
962 || TYPE_SIZE (type) == 0)
964 typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_XREF;
969 /* Output a definition now. */
971 fprintf (asmfile, "=");
974 /* Mark it as defined, so that if it is self-referent
975 we will not get into an infinite recursion of definitions. */
977 typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_DEFINED;
979 switch (TREE_CODE (type))
983 /* For a void type, just define it as itself; ie, "5=5".
984 This makes us consider it defined
985 without saying what it is. The debugger will make it
986 a void type when the reference is seen, and nothing will
987 ever override that default. */
988 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
993 if (type == char_type_node && ! TREE_UNSIGNED (type))
994 /* Output the type `char' as a subrange of itself!
995 I don't understand this definition, just copied it
996 from the output of pcc.
997 This used to use `r2' explicitly and we used to
998 take care to make sure that `char' was type number 2. */
999 fprintf (asmfile, "r%d;0;127;", TYPE_SYMTAB_ADDRESS (type));
1000 else if (use_gnu_debug_info_extensions && TYPE_PRECISION (type) > BITS_PER_WORD)
1002 /* This used to say `r1' and we used to take care
1003 to make sure that `int' was type number 1. */
1004 fprintf (asmfile, "r%d;", TYPE_SYMTAB_ADDRESS (integer_type_node));
1005 print_int_cst_octal (TYPE_MIN_VALUE (type));
1006 fprintf (asmfile, ";");
1007 print_int_cst_octal (TYPE_MAX_VALUE (type));
1008 fprintf (asmfile, ";");
1010 else /* Output other integer types as subranges of `int'. */
1011 dbxout_range_type (type);
1016 /* This used to say `r1' and we used to take care
1017 to make sure that `int' was type number 1. */
1018 fprintf (asmfile, "r%d;%d;0;", TYPE_SYMTAB_ADDRESS (integer_type_node),
1019 int_size_in_bytes (type));
1024 if (use_gnu_debug_info_extensions)
1025 fprintf (asmfile, "@s%d;-20;",
1026 BITS_PER_UNIT * int_size_in_bytes (type));
1028 /* Output the type `char' as a subrange of itself.
1029 That is what pcc seems to do. */
1030 fprintf (asmfile, "r%d;0;%d;", TYPE_SYMTAB_ADDRESS (char_type_node),
1031 TREE_UNSIGNED (type) ? 255 : 127);
1036 if (use_gnu_debug_info_extensions)
1037 fprintf (asmfile, "@s%d;-16;",
1038 BITS_PER_UNIT * int_size_in_bytes (type));
1039 else /* Define as enumeral type (False, True) */
1040 fprintf (asmfile, "eFalse:0,True:1,;");
1045 putc ('d', asmfile);
1047 dbxout_type (TREE_TYPE (type), 0, 0);
1051 /* Differs from the REAL_TYPE by its new data type number */
1053 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1055 fprintf (asmfile, "r%d;%d;0;",
1056 TYPE_SYMTAB_ADDRESS (type),
1057 int_size_in_bytes (TREE_TYPE (type)));
1058 CHARS (15); /* The number is probably incorrect here. */
1062 /* Output a complex integer type as a structure,
1063 pending some other way to do it. */
1064 fprintf (asmfile, "s%d", int_size_in_bytes (type));
1066 fprintf (asmfile, "real:");
1068 dbxout_type (TREE_TYPE (type), 0, 0);
1069 fprintf (asmfile, ",%d,%d;",
1070 0, TYPE_PRECISION (TREE_TYPE (type)));
1072 fprintf (asmfile, "imag:");
1074 dbxout_type (TREE_TYPE (type), 0, 0);
1075 fprintf (asmfile, ",%d,%d;;",
1076 TYPE_PRECISION (TREE_TYPE (type)),
1077 TYPE_PRECISION (TREE_TYPE (type)));
1083 putc ('S', asmfile);
1085 dbxout_type (TREE_TYPE (type), 0, 0);
1089 /* Output "a" followed by a range type definition
1090 for the index type of the array
1091 followed by a reference to the target-type.
1092 ar1;0;N;M for a C array of type M and size N+1. */
1093 tem = TYPE_DOMAIN (type);
1095 fprintf (asmfile, "ar%d;0;-1;",
1096 TYPE_SYMTAB_ADDRESS (integer_type_node));
1099 fprintf (asmfile, "a");
1100 dbxout_range_type (tem);
1103 dbxout_type (TREE_TYPE (type), 0, 0);
1108 case QUAL_UNION_TYPE:
1110 int i, n_baseclasses = 0;
1112 if (TYPE_BINFO (type) != 0 && TYPE_BINFO_BASETYPES (type) != 0)
1113 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1115 /* Output a structure type. */
1116 if ((TYPE_NAME (type) != 0
1117 /* Long ago, Tiemann said this creates output that "confuses GDB".
1118 In April 93, mrs@cygnus.com said there is no such problem.
1119 The type decls made automatically by struct specifiers
1120 are marked with DECL_IGNORED_P in C++. */
1121 #if 0 /* This creates output for anonymous classes which confuses GDB. */
1122 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1123 && DECL_IGNORED_P (TYPE_NAME (type)))
1126 || TYPE_SIZE (type) == 0
1127 /* No way in DBX fmt to describe a variable size. */
1128 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1130 /* If the type is just a cross reference, output one
1131 and mark the type as partially described.
1132 If it later becomes defined, we will output
1133 its real definition.
1134 If the type has a name, don't nest its definition within
1135 another type's definition; instead, output an xref
1136 and let the definition come when the name is defined. */
1137 fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu");
1139 #if 0 /* This assertion is legitimately false in C++. */
1140 /* We shouldn't be outputting a reference to a type before its
1141 definition unless the type has a tag name.
1142 A typedef name without a tag name should be impossible. */
1143 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1146 if (TYPE_NAME (type) != 0)
1147 dbxout_type_name (type);
1149 fprintf (asmfile, "$$%d", anonymous_type_number++);
1150 fprintf (asmfile, ":");
1151 typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_XREF;
1155 /* Identify record or union, and print its size. */
1156 fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "s%d" : "u%d",
1157 int_size_in_bytes (type));
1159 if (use_gnu_debug_info_extensions)
1163 have_used_extensions = 1;
1164 fprintf (asmfile, "!%d,", n_baseclasses);
1168 for (i = 0; i < n_baseclasses; i++)
1170 tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i);
1171 if (use_gnu_debug_info_extensions)
1173 have_used_extensions = 1;
1174 putc (TREE_VIA_VIRTUAL (child) ? '1'
1177 putc (TREE_VIA_PUBLIC (child) ? '2'
1180 fprintf (asmfile, "%d,",
1181 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT);
1183 dbxout_type (BINFO_TYPE (child), 0, 0);
1184 putc (';', asmfile);
1188 /* Print out the base class information with fields
1189 which have the same names at the types they hold. */
1190 dbxout_type_name (BINFO_TYPE (child));
1191 putc (':', asmfile);
1192 dbxout_type (BINFO_TYPE (child), full, 0);
1193 fprintf (asmfile, ",%d,%d;",
1194 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT,
1195 TREE_INT_CST_LOW (DECL_SIZE (TYPE_NAME (BINFO_TYPE (child)))) * BITS_PER_UNIT);
1203 /* Write out the field declarations. */
1204 dbxout_type_fields (type);
1205 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1207 have_used_extensions = 1;
1208 dbxout_type_methods (type);
1210 putc (';', asmfile);
1212 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1213 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1214 && TYPE_VFIELD (type))
1216 have_used_extensions = 1;
1218 /* Tell GDB+ that it may keep reading. */
1219 putc ('~', asmfile);
1221 /* We need to write out info about what field this class
1222 uses as its "main" vtable pointer field, because if this
1223 field is inherited from a base class, GDB cannot necessarily
1224 figure out which field it's using in time. */
1225 if (TYPE_VFIELD (type))
1227 putc ('%', asmfile);
1228 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0, 0);
1230 putc (';', asmfile);
1236 if ((TYPE_NAME (type) != 0 && !full
1237 && (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1238 && ! DECL_IGNORED_P (TYPE_NAME (type))))
1239 || TYPE_SIZE (type) == 0)
1241 fprintf (asmfile, "xe");
1243 dbxout_type_name (type);
1244 typevec[TYPE_SYMTAB_ADDRESS (type)] = TYPE_XREF;
1245 fprintf (asmfile, ":");
1248 #ifdef DBX_OUTPUT_ENUM
1249 DBX_OUTPUT_ENUM (asmfile, type);
1251 putc ('e', asmfile);
1253 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1255 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1256 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1258 if (TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1259 fprintf (asmfile, "%u", TREE_INT_CST_LOW (TREE_VALUE (tem)));
1261 fprintf (asmfile, "%d", TREE_INT_CST_LOW (TREE_VALUE (tem)));
1264 print_int_cst_octal (TREE_VALUE (tem));
1265 fprintf (asmfile, ",");
1266 CHARS (20 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem)));
1267 if (TREE_CHAIN (tem) != 0)
1270 putc (';', asmfile);
1276 putc ('*', asmfile);
1278 dbxout_type (TREE_TYPE (type), 0, 0);
1282 if (use_gnu_debug_info_extensions)
1284 have_used_extensions = 1;
1285 putc ('#', asmfile);
1287 if (flag_minimal_debug && !show_arg_types)
1289 /* Normally, just output the return type.
1290 The argument types are encoded in the method name. */
1291 putc ('#', asmfile);
1292 dbxout_type (TREE_TYPE (type), 0, 0);
1293 putc (';', asmfile);
1298 /* When outputting destructors, we need to write
1299 the argument types out longhand. */
1300 dbxout_type (TYPE_METHOD_BASETYPE (type), 0, 0);
1301 putc (',', asmfile);
1303 dbxout_type (TREE_TYPE (type), 0, 0);
1304 dbxout_args (TYPE_ARG_TYPES (type));
1305 putc (';', asmfile);
1311 /* Treat it as a function type. */
1312 dbxout_type (TREE_TYPE (type), 0, 0);
1317 if (use_gnu_debug_info_extensions)
1319 have_used_extensions = 1;
1320 putc ('@', asmfile);
1322 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0, 0);
1323 putc (',', asmfile);
1325 dbxout_type (TREE_TYPE (type), 0, 0);
1329 /* Should print as an int, because it is really
1331 dbxout_type (integer_type_node, 0, 0);
1335 case REFERENCE_TYPE:
1336 if (use_gnu_debug_info_extensions)
1337 have_used_extensions = 1;
1338 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1340 dbxout_type (TREE_TYPE (type), 0, 0);
1344 putc ('f', asmfile);
1346 dbxout_type (TREE_TYPE (type), 0, 0);
1354 /* Print the value of integer constant C, in octal,
1355 handling double precision. */
1358 print_int_cst_octal (c)
1361 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1362 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1363 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1365 fprintf (asmfile, "0");
1369 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1370 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1374 unsigned HOST_WIDE_INT beg = high >> excess;
1375 unsigned HOST_WIDE_INT middle
1376 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1377 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1378 unsigned HOST_WIDE_INT end
1379 = low & (((HOST_WIDE_INT) 1 << (HOST_BITS_PER_WIDE_INT / 3 * 3)) - 1);
1380 fprintf (asmfile, "%o%01o", beg, middle);
1381 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1386 print_octal (value, digits)
1387 unsigned HOST_WIDE_INT value;
1392 for (i = digits - 1; i >= 0; i--)
1393 fprintf (asmfile, "%01o", ((value >> (3 * i)) & 7));
1396 /* Output the name of type TYPE, with no punctuation.
1397 Such names can be set up either by typedef declarations
1398 or by struct, enum and union tags. */
1401 dbxout_type_name (type)
1405 if (TYPE_NAME (type) == 0)
1407 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
1409 t = TYPE_NAME (type);
1411 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1413 t = DECL_NAME (TYPE_NAME (type));
1418 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
1419 CHARS (IDENTIFIER_LENGTH (t));
1422 /* Output a .stabs for the symbol defined by DECL,
1423 which must be a ..._DECL node in the normal namespace.
1424 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1425 LOCAL is nonzero if the scope is less than the entire file. */
1428 dbxout_symbol (decl, local)
1433 tree type = TREE_TYPE (decl);
1434 tree context = NULL_TREE;
1437 /* Cast avoids warning in old compilers. */
1438 current_sym_code = (STAB_CODE_TYPE) 0;
1439 current_sym_value = 0;
1440 current_sym_addr = 0;
1442 /* Ignore nameless syms, but don't ignore type tags. */
1444 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
1445 || DECL_IGNORED_P (decl))
1448 dbxout_prepare_symbol (decl);
1450 /* The output will always start with the symbol name,
1451 so always count that in the length-output-so-far. */
1453 if (DECL_NAME (decl) != 0)
1454 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
1456 switch (TREE_CODE (decl))
1459 /* Enum values are defined by defining the enum type. */
1463 if (DECL_RTL (decl) == 0)
1465 if (DECL_EXTERNAL (decl))
1467 /* Don't mention a nested function under its parent. */
1468 context = decl_function_context (decl);
1469 if (context == current_function_decl)
1471 if (GET_CODE (DECL_RTL (decl)) != MEM
1472 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
1476 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
1477 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1478 TREE_PUBLIC (decl) ? 'F' : 'f');
1480 current_sym_code = N_FUN;
1481 current_sym_addr = XEXP (DECL_RTL (decl), 0);
1483 if (TREE_TYPE (type))
1484 dbxout_type (TREE_TYPE (type), 0, 0);
1486 dbxout_type (void_type_node, 0, 0);
1488 /* For a nested function, when that function is compiled,
1489 mention the containing function name
1490 as well as (since dbx wants it) our own assembler-name. */
1492 fprintf (asmfile, ",%s,%s",
1493 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1494 IDENTIFIER_POINTER (DECL_NAME (context)));
1496 dbxout_finish_symbol (decl);
1501 /* This seems all wrong. Outputting most kinds of types gives no name
1502 at all. A true definition gives no name; a cross-ref for a
1503 structure can give the tag name, but not a type name.
1504 It seems that no typedef name is defined by outputting a type. */
1506 /* If this typedef name was defined by outputting the type,
1507 don't duplicate it. */
1508 if (typevec[TYPE_SYMTAB_ADDRESS (type)] == TYPE_DEFINED
1509 && TYPE_NAME (TREE_TYPE (decl)) == decl)
1512 /* Don't output the same typedef twice.
1513 And don't output what language-specific stuff doesn't want output. */
1514 if (TREE_ASM_WRITTEN (decl) || DECL_IGNORED_P (decl))
1523 if (DECL_NAME (decl))
1525 /* Nonzero means we must output a tag as well as a typedef. */
1528 /* Handle the case of a C++ structure or union
1529 where the TYPE_NAME is a TYPE_DECL
1530 which gives both a typedef name and a tag. */
1531 /* dbx requires the tag first and the typedef second. */
1532 if ((TREE_CODE (type) == RECORD_TYPE
1533 || TREE_CODE (type) == UNION_TYPE
1534 || TREE_CODE (type) == QUAL_UNION_TYPE)
1535 && TYPE_NAME (type) == decl
1536 && !(use_gnu_debug_info_extensions && have_used_extensions)
1537 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
1538 /* Distinguish the implicit typedefs of C++
1539 from explicit ones that might be found in C. */
1540 && DECL_SOURCE_LINE (decl) == 0)
1542 tree name = TYPE_NAME (type);
1543 if (TREE_CODE (name) == TYPE_DECL)
1544 name = DECL_NAME (name);
1546 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1547 current_sym_value = 0;
1548 current_sym_addr = 0;
1549 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1551 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1552 IDENTIFIER_POINTER (name));
1553 dbxout_type (type, 1, 0);
1554 dbxout_finish_symbol (NULL_TREE);
1557 /* Output typedef name. */
1558 fprintf (asmfile, "%s \"%s:", ASM_STABS_OP,
1559 IDENTIFIER_POINTER (DECL_NAME (decl)));
1561 /* Short cut way to output a tag also. */
1562 if ((TREE_CODE (type) == RECORD_TYPE
1563 || TREE_CODE (type) == UNION_TYPE
1564 || TREE_CODE (type) == QUAL_UNION_TYPE)
1565 && TYPE_NAME (type) == decl)
1567 if (use_gnu_debug_info_extensions && have_used_extensions)
1569 putc ('T', asmfile);
1570 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
1572 #if 0 /* Now we generate the tag for this case up above. */
1578 putc ('t', asmfile);
1579 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1581 dbxout_type (type, 1, 0);
1582 dbxout_finish_symbol (decl);
1586 /* Don't output a tag if this is an incomplete type (TYPE_SIZE is
1587 zero). This prevents the sun4 Sun OS 4.x dbx from crashing. */
1589 if (tag_needed && TYPE_NAME (type) != 0 && TYPE_SIZE (type) != 0
1590 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
1592 /* For a TYPE_DECL with no name, but the type has a name,
1594 This is what represents `struct foo' with no typedef. */
1595 /* In C++, the name of a type is the corresponding typedef.
1596 In C, it is an IDENTIFIER_NODE. */
1597 tree name = TYPE_NAME (type);
1598 if (TREE_CODE (name) == TYPE_DECL)
1599 name = DECL_NAME (name);
1601 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1602 current_sym_value = 0;
1603 current_sym_addr = 0;
1604 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1606 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1607 IDENTIFIER_POINTER (name));
1608 dbxout_type (type, 1, 0);
1609 dbxout_finish_symbol (NULL_TREE);
1613 /* If an enum type has no name, it cannot be referred to,
1614 but we must output it anyway, since the enumeration constants
1615 can be referred to. */
1616 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
1618 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1619 current_sym_value = 0;
1620 current_sym_addr = 0;
1621 current_sym_nchars = 2;
1623 /* Some debuggers fail when given NULL names, so give this a
1624 harmless name of ` '. */
1625 fprintf (asmfile, "%s \" :T", ASM_STABS_OP);
1626 dbxout_type (type, 1, 0);
1627 dbxout_finish_symbol (NULL_TREE);
1630 /* Prevent duplicate output of a typedef. */
1631 TREE_ASM_WRITTEN (decl) = 1;
1636 /* Parm decls go in their own separate chains
1637 and are output by dbxout_reg_parms and dbxout_parms. */
1641 /* Named return value, treat like a VAR_DECL. */
1643 if (DECL_RTL (decl) == 0)
1645 /* Don't mention a variable that is external.
1646 Let the file that defines it describe it. */
1647 if (DECL_EXTERNAL (decl))
1650 /* If the variable is really a constant
1651 and not written in memory, inform the debugger. */
1652 if (TREE_STATIC (decl) && TREE_READONLY (decl)
1653 && DECL_INITIAL (decl) != 0
1654 && ! TREE_ASM_WRITTEN (decl)
1655 && (DECL_FIELD_CONTEXT (decl) == NULL_TREE
1656 || TREE_CODE (DECL_FIELD_CONTEXT (decl)) == BLOCK))
1658 if (TREE_PUBLIC (decl) == 0)
1660 /* The sun4 assembler does not grok this. */
1661 char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
1662 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
1663 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
1665 HOST_WIDE_INT ival = TREE_INT_CST_LOW (DECL_INITIAL (decl));
1666 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
1667 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile, name, ival);
1669 fprintf (asmfile, "%s \"%s:c=i%d\",0x%x,0,0,0\n",
1670 ASM_STABS_OP, name, ival, N_LSYM);
1674 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
1676 /* don't know how to do this yet. */
1680 /* else it is something we handle like a normal variable. */
1683 DECL_RTL (decl) = eliminate_regs (DECL_RTL (decl), 0, NULL_RTX);
1684 #ifdef LEAF_REG_REMAP
1686 leaf_renumber_regs_insn (DECL_RTL (decl));
1689 dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
1693 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
1694 Add SUFFIX to its name, if SUFFIX is not 0.
1695 Describe the variable as residing in HOME
1696 (usually HOME is DECL_RTL (DECL), but not always). */
1699 dbxout_symbol_location (decl, type, suffix, home)
1707 /* Don't mention a variable at all
1708 if it was completely optimized into nothingness.
1710 If the decl was from an inline function, then it's rtl
1711 is not identically the rtl that was used in this
1712 particular compilation. */
1713 if (GET_CODE (home) == REG)
1715 regno = REGNO (home);
1716 if (regno >= FIRST_PSEUDO_REGISTER)
1719 else if (GET_CODE (home) == SUBREG)
1723 while (GET_CODE (value) == SUBREG)
1725 offset += SUBREG_WORD (value);
1726 value = SUBREG_REG (value);
1728 if (GET_CODE (value) == REG)
1730 regno = REGNO (value);
1731 if (regno >= FIRST_PSEUDO_REGISTER)
1735 alter_subreg (home);
1738 /* The kind-of-variable letter depends on where
1739 the variable is and on the scope of its name:
1740 G and N_GSYM for static storage and global scope,
1741 S for static storage and file scope,
1742 V for static storage and local scope,
1743 for those two, use N_LCSYM if data is in bss segment,
1744 N_STSYM if in data segment, N_FUN otherwise.
1745 (We used N_FUN originally, then changed to N_STSYM
1746 to please GDB. However, it seems that confused ld.
1747 Now GDB has been fixed to like N_FUN, says Kingdon.)
1748 no letter at all, and N_LSYM, for auto variable,
1749 r and N_RSYM for register variable. */
1751 if (GET_CODE (home) == MEM
1752 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
1754 if (TREE_PUBLIC (decl))
1757 current_sym_code = N_GSYM;
1761 current_sym_addr = XEXP (home, 0);
1763 letter = decl_function_context (decl) ? 'V' : 'S';
1765 if (!DECL_INITIAL (decl))
1766 current_sym_code = N_LCSYM;
1767 else if (in_text_section ())
1768 /* This is not quite right, but it's the closest
1769 of all the codes that Unix defines. */
1770 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
1773 /* Ultrix `as' seems to need this. */
1774 #ifdef DBX_STATIC_STAB_DATA_SECTION
1777 current_sym_code = N_STSYM;
1781 else if (regno >= 0)
1784 current_sym_code = N_RSYM;
1785 current_sym_value = DBX_REGISTER_NUMBER (regno);
1787 else if (GET_CODE (home) == MEM
1788 && (GET_CODE (XEXP (home, 0)) == MEM
1789 || (GET_CODE (XEXP (home, 0)) == REG
1790 && REGNO (XEXP (home, 0)) != FRAME_POINTER_REGNUM)))
1791 /* If the value is indirect by memory or by a register
1792 that isn't the frame pointer
1793 then it means the object is variable-sized and address through
1794 that register or stack slot. DBX has no way to represent this
1795 so all we can do is output the variable as a pointer.
1796 If it's not a parameter, ignore it.
1797 (VAR_DECLs like this can be made by integrate.c.) */
1799 if (GET_CODE (XEXP (home, 0)) == REG)
1802 current_sym_code = N_RSYM;
1803 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
1807 current_sym_code = N_LSYM;
1808 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
1809 We want the value of that CONST_INT. */
1811 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
1814 /* Effectively do build_pointer_type, but don't cache this type,
1815 since it might be temporary whereas the type it points to
1816 might have been saved for inlining. */
1817 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
1818 type = make_node (POINTER_TYPE);
1819 TREE_TYPE (type) = TREE_TYPE (decl);
1821 else if (GET_CODE (home) == MEM
1822 && GET_CODE (XEXP (home, 0)) == REG)
1824 current_sym_code = N_LSYM;
1825 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
1827 else if (GET_CODE (home) == MEM
1828 && GET_CODE (XEXP (home, 0)) == PLUS
1829 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
1831 current_sym_code = N_LSYM;
1832 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
1833 We want the value of that CONST_INT. */
1834 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
1836 else if (GET_CODE (home) == MEM
1837 && GET_CODE (XEXP (home, 0)) == CONST)
1839 /* Handle an obscure case which can arise when optimizing and
1840 when there are few available registers. (This is *always*
1841 the case for i386/i486 targets). The RTL looks like
1842 (MEM (CONST ...)) even though this variable is a local `auto'
1843 or a local `register' variable. In effect, what has happened
1844 is that the reload pass has seen that all assignments and
1845 references for one such a local variable can be replaced by
1846 equivalent assignments and references to some static storage
1847 variable, thereby avoiding the need for a register. In such
1848 cases we're forced to lie to debuggers and tell them that
1849 this variable was itself `static'. */
1850 current_sym_code = N_LCSYM;
1852 current_sym_addr = XEXP (XEXP (home, 0), 0);
1854 else if (GET_CODE (home) == CONCAT)
1856 tree subtype = TREE_TYPE (type);
1858 /* If the variable's storage is in two parts,
1859 output each as a separate stab with a modified name. */
1860 if (WORDS_BIG_ENDIAN)
1861 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
1863 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
1865 /* Cast avoids warning in old compilers. */
1866 current_sym_code = (STAB_CODE_TYPE) 0;
1867 current_sym_value = 0;
1868 current_sym_addr = 0;
1869 dbxout_prepare_symbol (decl);
1871 if (WORDS_BIG_ENDIAN)
1872 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
1874 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
1878 /* Address might be a MEM, when DECL is a variable-sized object.
1879 Or it might be const0_rtx, meaning previous passes
1880 want us to ignore this variable. */
1883 /* Ok, start a symtab entry and output the variable name. */
1886 #ifdef DBX_STATIC_BLOCK_START
1887 DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
1890 dbxout_symbol_name (decl, suffix, letter);
1891 dbxout_type (type, 0, 0);
1892 dbxout_finish_symbol (decl);
1894 #ifdef DBX_STATIC_BLOCK_END
1895 DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
1899 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
1900 Then output LETTER to indicate the kind of location the symbol has. */
1903 dbxout_symbol_name (decl, suffix, letter)
1908 /* One slight hitch: if this is a VAR_DECL which is a static
1909 class member, we must put out the mangled name instead of the
1913 /* Note also that static member (variable) names DO NOT begin
1914 with underscores in .stabs directives. */
1915 if (DECL_LANG_SPECIFIC (decl))
1916 name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
1918 name = IDENTIFIER_POINTER (DECL_NAME (decl));
1921 fprintf (asmfile, "%s \"%s%s:", ASM_STABS_OP, name,
1922 (suffix ? suffix : ""));
1924 if (letter) putc (letter, asmfile);
1928 dbxout_prepare_symbol (decl)
1932 char *filename = DECL_SOURCE_FILE (decl);
1934 dbxout_source_file (asmfile, filename);
1939 dbxout_finish_symbol (sym)
1942 #ifdef DBX_FINISH_SYMBOL
1943 DBX_FINISH_SYMBOL (sym);
1946 if (use_gnu_debug_info_extensions && sym != 0)
1947 line = DECL_SOURCE_LINE (sym);
1949 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
1950 if (current_sym_addr)
1951 output_addr_const (asmfile, current_sym_addr);
1953 fprintf (asmfile, "%d", current_sym_value);
1954 putc ('\n', asmfile);
1958 /* Output definitions of all the decls in a chain. */
1966 dbxout_symbol (syms, 1);
1967 syms = TREE_CHAIN (syms);
1971 /* The following two functions output definitions of function parameters.
1972 Each parameter gets a definition locating it in the parameter list.
1973 Each parameter that is a register variable gets a second definition
1974 locating it in the register.
1976 Printing or argument lists in gdb uses the definitions that
1977 locate in the parameter list. But reference to the variable in
1978 expressions uses preferentially the definition as a register. */
1980 /* Output definitions, referring to storage in the parmlist,
1981 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
1984 dbxout_parms (parms)
1987 for (; parms; parms = TREE_CHAIN (parms))
1988 if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
1990 dbxout_prepare_symbol (parms);
1992 /* Perform any necessary register eliminations on the parameter's rtl,
1993 so that the debugging output will be accurate. */
1994 DECL_INCOMING_RTL (parms)
1995 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
1996 DECL_RTL (parms) = eliminate_regs (DECL_RTL (parms), 0, NULL_RTX);
1997 #ifdef LEAF_REG_REMAP
2000 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2001 leaf_renumber_regs_insn (DECL_RTL (parms));
2005 if (PARM_PASSED_IN_MEMORY (parms))
2007 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2009 /* ??? Here we assume that the parm address is indexed
2010 off the frame pointer or arg pointer.
2011 If that is not true, we produce meaningless results,
2012 but do not crash. */
2013 if (GET_CODE (addr) == PLUS
2014 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2015 current_sym_value = INTVAL (XEXP (addr, 1));
2017 current_sym_value = 0;
2019 current_sym_code = N_PSYM;
2020 current_sym_addr = 0;
2023 if (DECL_NAME (parms))
2025 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2027 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2028 IDENTIFIER_POINTER (DECL_NAME (parms)),
2029 DBX_MEMPARM_STABS_LETTER);
2033 current_sym_nchars = 8;
2034 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2035 DBX_MEMPARM_STABS_LETTER);
2038 if (GET_CODE (DECL_RTL (parms)) == REG
2039 && REGNO (DECL_RTL (parms)) >= 0
2040 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2041 dbxout_type (DECL_ARG_TYPE (parms), 0, 0);
2044 int original_value = current_sym_value;
2046 /* This is the case where the parm is passed as an int or double
2047 and it is converted to a char, short or float and stored back
2048 in the parmlist. In this case, describe the parm
2049 with the variable's declared type, and adjust the address
2050 if the least significant bytes (which we are using) are not
2052 #if BYTES_BIG_ENDIAN
2053 if (TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
2054 current_sym_value += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
2055 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
2058 if (GET_CODE (DECL_RTL (parms)) == MEM
2059 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
2060 && GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == CONST_INT
2061 && INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == current_sym_value)
2062 dbxout_type (TREE_TYPE (parms), 0, 0);
2065 current_sym_value = original_value;
2066 dbxout_type (DECL_ARG_TYPE (parms), 0, 0);
2069 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2070 dbxout_finish_symbol (parms);
2072 else if (GET_CODE (DECL_RTL (parms)) == REG)
2075 char regparm_letter;
2077 /* Parm passed in registers and lives in registers or nowhere. */
2079 current_sym_code = DBX_REGPARM_STABS_CODE;
2080 regparm_letter = DBX_REGPARM_STABS_LETTER;
2081 current_sym_addr = 0;
2083 /* If parm lives in a register, use that register;
2084 pretend the parm was passed there. It would be more consistent
2085 to describe the register where the parm was passed,
2086 but in practice that register usually holds something else.
2088 If we use DECL_RTL, then we must use the declared type of
2089 the variable, not the type that it arrived in. */
2090 if (REGNO (DECL_RTL (parms)) >= 0
2091 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2093 best_rtl = DECL_RTL (parms);
2094 parm_type = TREE_TYPE (parms);
2096 /* If the parm lives nowhere,
2097 use the register where it was passed. */
2100 best_rtl = DECL_INCOMING_RTL (parms);
2101 parm_type = DECL_ARG_TYPE (parms);
2103 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2106 if (DECL_NAME (parms))
2108 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2109 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2110 IDENTIFIER_POINTER (DECL_NAME (parms)),
2115 current_sym_nchars = 8;
2116 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2120 dbxout_type (parm_type, 0, 0);
2121 dbxout_finish_symbol (parms);
2123 else if (GET_CODE (DECL_RTL (parms)) == MEM
2124 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG)
2125 /* && rtx_equal_p (XEXP (DECL_RTL (parms), 0),
2126 DECL_INCOMING_RTL (parms))) */
2128 /* Parm was passed via invisible reference.
2129 That is, its address was passed in a register.
2130 Output it as if it lived in that register.
2131 The debugger will know from the type
2132 that it was actually passed by invisible reference. */
2134 char regparm_letter;
2135 /* Parm passed in registers and lives in registers or nowhere. */
2137 current_sym_code = DBX_REGPARM_STABS_CODE;
2138 regparm_letter = DBX_REGPARM_STABS_LETTER;
2140 /* DECL_RTL looks like (MEM (REG...). Get the register number. */
2141 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2142 current_sym_addr = 0;
2145 if (DECL_NAME (parms))
2147 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2149 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2150 IDENTIFIER_POINTER (DECL_NAME (parms)),
2151 DBX_REGPARM_STABS_LETTER);
2155 current_sym_nchars = 8;
2156 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2157 DBX_REGPARM_STABS_LETTER);
2160 dbxout_type (TREE_TYPE (parms), 0, 0);
2161 dbxout_finish_symbol (parms);
2163 else if (GET_CODE (DECL_RTL (parms)) == MEM
2164 && XEXP (DECL_RTL (parms), 0) != const0_rtx
2165 /* ??? A constant address for a parm can happen
2166 when the reg it lives in is equiv to a constant in memory.
2167 Should make this not happen, after 2.4. */
2168 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2170 /* Parm was passed in registers but lives on the stack. */
2172 current_sym_code = N_PSYM;
2173 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2174 in which case we want the value of that CONST_INT,
2175 or (MEM (REG ...)) or (MEM (MEM ...)),
2176 in which case we use a value of zero. */
2177 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2178 || GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2179 current_sym_value = 0;
2181 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2182 current_sym_addr = 0;
2185 if (DECL_NAME (parms))
2187 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2189 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2190 IDENTIFIER_POINTER (DECL_NAME (parms)),
2191 DBX_MEMPARM_STABS_LETTER);
2195 current_sym_nchars = 8;
2196 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2197 DBX_MEMPARM_STABS_LETTER);
2201 = DEBUGGER_ARG_OFFSET (current_sym_value,
2202 XEXP (DECL_RTL (parms), 0));
2203 dbxout_type (TREE_TYPE (parms), 0, 0);
2204 dbxout_finish_symbol (parms);
2209 /* Output definitions for the places where parms live during the function,
2210 when different from where they were passed, when the parms were passed
2213 It is not useful to do this for parms passed in registers
2214 that live during the function in different registers, because it is
2215 impossible to look in the passed register for the passed value,
2216 so we use the within-the-function register to begin with.
2218 PARMS is a chain of PARM_DECL nodes. */
2221 dbxout_reg_parms (parms)
2224 for (; parms; parms = TREE_CHAIN (parms))
2225 if (DECL_NAME (parms))
2227 dbxout_prepare_symbol (parms);
2229 /* Report parms that live in registers during the function
2230 but were passed in memory. */
2231 if (GET_CODE (DECL_RTL (parms)) == REG
2232 && REGNO (DECL_RTL (parms)) >= 0
2233 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER
2234 && PARM_PASSED_IN_MEMORY (parms))
2235 dbxout_symbol_location (parms, TREE_TYPE (parms),
2236 0, DECL_RTL (parms));
2237 else if (GET_CODE (DECL_RTL (parms)) == CONCAT
2238 && PARM_PASSED_IN_MEMORY (parms))
2239 dbxout_symbol_location (parms, TREE_TYPE (parms),
2240 0, DECL_RTL (parms));
2241 /* Report parms that live in memory but not where they were passed. */
2242 else if (GET_CODE (DECL_RTL (parms)) == MEM
2243 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
2244 && GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 1)) == CONST_INT
2245 && PARM_PASSED_IN_MEMORY (parms)
2246 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
2248 #if 0 /* ??? It is not clear yet what should replace this. */
2249 int offset = DECL_OFFSET (parms) / BITS_PER_UNIT;
2250 /* A parm declared char is really passed as an int,
2251 so it occupies the least significant bytes.
2252 On a big-endian machine those are not the low-numbered ones. */
2253 #if BYTES_BIG_ENDIAN
2254 if (offset != -1 && TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
2255 offset += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
2256 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
2258 if (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) != offset) {...}
2260 dbxout_symbol_location (parms, TREE_TYPE (parms),
2261 0, DECL_RTL (parms));
2264 else if (GET_CODE (DECL_RTL (parms)) == MEM
2265 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG)
2267 /* Parm was passed via invisible reference.
2268 That is, its address was passed in a register.
2269 Output it as if it lived in that register.
2270 The debugger will know from the type
2271 that it was actually passed by invisible reference. */
2273 current_sym_code = N_RSYM;
2275 /* DECL_RTL looks like (MEM (REG...). Get the register number. */
2276 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2277 current_sym_addr = 0;
2280 if (DECL_NAME (parms))
2282 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2284 fprintf (asmfile, "%s \"%s:r", ASM_STABS_OP,
2285 IDENTIFIER_POINTER (DECL_NAME (parms)));
2289 current_sym_nchars = 8;
2290 fprintf (asmfile, "%s \"(anon):r", ASM_STABS_OP);
2293 dbxout_type (TREE_TYPE (parms), 0, 0);
2294 dbxout_finish_symbol (parms);
2300 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2301 output definitions of those names, in raw form */
2309 putc (',', asmfile);
2310 dbxout_type (TREE_VALUE (args), 0, 0);
2312 args = TREE_CHAIN (args);
2316 /* Given a chain of ..._TYPE nodes,
2317 find those which have typedef names and output those names.
2318 This is to ensure those types get output. */
2321 dbxout_types (types)
2322 register tree types;
2326 if (TYPE_NAME (types)
2327 && TREE_CODE (TYPE_NAME (types)) == TYPE_DECL
2328 && ! TREE_ASM_WRITTEN (TYPE_NAME (types)))
2329 dbxout_symbol (TYPE_NAME (types), 1);
2330 types = TREE_CHAIN (types);
2334 /* Output everything about a symbol block (a BLOCK node
2335 that represents a scope level),
2336 including recursive output of contained blocks.
2338 BLOCK is the BLOCK node.
2339 DEPTH is its depth within containing symbol blocks.
2340 ARGS is usually zero; but for the outermost block of the
2341 body of a function, it is a chain of PARM_DECLs for the function parameters.
2342 We output definitions of all the register parms
2343 as if they were local variables of that block.
2345 If -g1 was used, we count blocks just the same, but output nothing
2346 except for the outermost block.
2348 Actually, BLOCK may be several blocks chained together.
2349 We handle them all in sequence. */
2352 dbxout_block (block, depth, args)
2353 register tree block;
2361 /* Ignore blocks never expanded or otherwise marked as real. */
2362 if (TREE_USED (block))
2364 #ifndef DBX_LBRAC_FIRST
2365 /* In dbx format, the syms of a block come before the N_LBRAC. */
2366 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2367 dbxout_syms (BLOCK_VARS (block));
2369 dbxout_reg_parms (args);
2372 /* Now output an N_LBRAC symbol to represent the beginning of
2373 the block. Use the block's tree-walk order to generate
2374 the assembler symbols LBBn and LBEn
2375 that final will define around the code in this block. */
2376 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2379 blocknum = next_block_number++;
2380 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
2382 if (BLOCK_HANDLER_BLOCK (block))
2384 /* A catch block. Must precede N_LBRAC. */
2385 tree decl = BLOCK_VARS (block);
2388 #ifdef DBX_OUTPUT_CATCH
2389 DBX_OUTPUT_CATCH (asmfile, decl, buf);
2391 fprintf (asmfile, "%s \"%s:C1\",%d,0,0,", ASM_STABS_OP,
2392 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
2393 assemble_name (asmfile, buf);
2394 fprintf (asmfile, "\n");
2396 decl = TREE_CHAIN (decl);
2400 #ifdef DBX_OUTPUT_LBRAC
2401 DBX_OUTPUT_LBRAC (asmfile, buf);
2403 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);
2404 assemble_name (asmfile, buf);
2405 #if DBX_BLOCKS_FUNCTION_RELATIVE
2406 fputc ('-', asmfile);
2407 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2409 fprintf (asmfile, "\n");
2413 /* Count blocks the same way regardless of debug_info_level. */
2414 next_block_number++;
2416 #ifdef DBX_LBRAC_FIRST
2417 /* On some weird machines, the syms of a block
2418 come after the N_LBRAC. */
2419 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2420 dbxout_syms (BLOCK_VARS (block));
2422 dbxout_reg_parms (args);
2425 /* Output the subblocks. */
2426 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
2428 /* Refer to the marker for the end of the block. */
2429 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2432 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
2433 #ifdef DBX_OUTPUT_RBRAC
2434 DBX_OUTPUT_RBRAC (asmfile, buf);
2436 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);
2437 assemble_name (asmfile, buf);
2438 #if DBX_BLOCKS_FUNCTION_RELATIVE
2439 fputc ('-', asmfile);
2440 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2442 fprintf (asmfile, "\n");
2446 block = BLOCK_CHAIN (block);
2450 /* Output the information about a function and its arguments and result.
2451 Usually this follows the function's code,
2452 but on some systems, it comes before. */
2455 dbxout_really_begin_function (decl)
2458 dbxout_symbol (decl, 0);
2459 dbxout_parms (DECL_ARGUMENTS (decl));
2460 if (DECL_NAME (DECL_RESULT (decl)) != 0)
2461 dbxout_symbol (DECL_RESULT (decl), 1);
2464 /* Called at beginning of output of function definition. */
2467 dbxout_begin_function (decl)
2470 #ifdef DBX_FUNCTION_FIRST
2471 dbxout_really_begin_function (decl);
2475 /* Output dbx data for a function definition.
2476 This includes a definition of the function name itself (a symbol),
2477 definitions of the parameters (locating them in the parameter list)
2478 and then output the block that makes up the function's body
2479 (including all the auto variables of the function). */
2482 dbxout_function (decl)
2485 #ifndef DBX_FUNCTION_FIRST
2486 dbxout_really_begin_function (decl);
2488 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
2489 #ifdef DBX_OUTPUT_FUNCTION_END
2490 DBX_OUTPUT_FUNCTION_END (asmfile, decl);
2493 #endif /* DBX_DEBUGGING_INFO */