1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987, 88, 92, 93, 94, 95, 1996 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, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
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.
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.
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.
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
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.
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.
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.
65 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
66 output while in the text section.
68 For more on data type definitions, see `dbxout_type'. */
70 /* Include these first, because they may define MIN and MAX. */
79 #include "insn-config.h"
82 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
88 #ifdef XCOFF_DEBUGGING_INFO
93 #define ASM_STABS_OP ".stabs"
97 #define ASM_STABN_OP ".stabn"
100 #ifndef DBX_TYPE_DECL_STABS_CODE
101 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
104 #ifndef DBX_STATIC_CONST_VAR_CODE
105 #define DBX_STATIC_CONST_VAR_CODE N_FUN
108 #ifndef DBX_REGPARM_STABS_CODE
109 #define DBX_REGPARM_STABS_CODE N_RSYM
112 #ifndef DBX_REGPARM_STABS_LETTER
113 #define DBX_REGPARM_STABS_LETTER 'P'
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'
121 #ifndef DBX_MEMPARM_STABS_LETTER
122 #define DBX_MEMPARM_STABS_LETTER 'p'
125 #ifndef FILE_NAME_JOINER
126 #define FILE_NAME_JOINER "/"
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++
134 #define MINIMAL_DEBUG 1
136 #ifdef NO_DOLLAR_IN_LABEL
137 #ifdef NO_DOT_IN_LABEL
139 #define MINIMAL_DEBUG 0
143 static int flag_minimal_debug = MINIMAL_DEBUG;
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. */
150 static int have_used_extensions = 0;
152 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
153 for the N_SO filename stabs label. */
155 static int source_label_number = 1;
159 /* Typical USG systems don't have stab.h, and they also have
160 no use for DBX-format debugging info. */
162 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
164 #ifdef DEBUG_SYMS_TEXT
165 #define FORCE_TEXT text_section ();
170 #if defined (USG) || defined (NO_STAB_H) || defined (CROSS_COMPILE)
171 #include "gstab.h" /* If doing DBX on sysV, use our own stab.h. */
173 #include <stab.h> /* On BSD, use the system's stab.h. */
175 /* This is a GNU extension we need to reference in this file. */
182 #define STAB_CODE_TYPE enum __stab_debug_code
184 #define STAB_CODE_TYPE int
187 /* 1 if PARM is passed to this function in memory. */
189 #define PARM_PASSED_IN_MEMORY(PARM) \
190 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
192 /* A C expression for the integer offset value of an automatic variable
193 (N_LSYM) having address X (an RTX). */
194 #ifndef DEBUGGER_AUTO_OFFSET
195 #define DEBUGGER_AUTO_OFFSET(X) \
196 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
199 /* A C expression for the integer offset value of an argument (N_PSYM)
200 having address X (an RTX). The nominal offset is OFFSET. */
201 #ifndef DEBUGGER_ARG_OFFSET
202 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
205 /* Stream for writing to assembler file. */
207 static FILE *asmfile;
209 /* Last source file name mentioned in a NOTE insn. */
211 static char *lastfile;
213 /* Current working directory. */
217 enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
219 /* Structure recording information about a C data type.
220 The status element says whether we have yet output
221 the definition of the type. TYPE_XREF says we have
222 output it as a cross-reference only.
223 The file_number and type_number elements are used if DBX_USE_BINCL
228 enum typestatus status;
235 /* Vector recording information about C data types.
236 When we first notice a data type (a tree node),
237 we assign it a number using next_type_number.
238 That is its index in this vector. */
240 struct typeinfo *typevec;
242 /* Number of elements of space allocated in `typevec'. */
244 static int typevec_len;
246 /* In dbx output, each type gets a unique number.
247 This is the number for the next type output.
248 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
250 static int next_type_number;
254 /* When using N_BINCL in dbx output, each type number is actually a
255 pair of the file number and the type number within the file.
256 This is a stack of input files. */
260 struct dbx_file *next;
262 int next_type_number;
265 /* This is the top of the stack. */
267 static struct dbx_file *current_file;
269 /* This is the next file number to use. */
271 static int next_file_number;
273 #endif /* DBX_USE_BINCL */
275 /* In dbx output, we must assign symbol-blocks id numbers
276 in the order in which their beginnings are encountered.
277 We output debugging info that refers to the beginning and
278 end of the ranges of code in each block
279 with assembler labels LBBn and LBEn, where n is the block number.
280 The labels are generated in final, which assigns numbers to the
281 blocks in the same way. */
283 static int next_block_number;
285 /* These variables are for dbxout_symbol to communicate to
286 dbxout_finish_symbol.
287 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
288 current_sym_value and current_sym_addr are two ways to address the
289 value to store in the symtab entry.
290 current_sym_addr if nonzero represents the value as an rtx.
291 If that is zero, current_sym_value is used. This is used
292 when the value is an offset (such as for auto variables,
293 register variables and parms). */
295 static STAB_CODE_TYPE current_sym_code;
296 static int current_sym_value;
297 static rtx current_sym_addr;
299 /* Number of chars of symbol-description generated so far for the
300 current symbol. Used by CHARS and CONTIN. */
302 static int current_sym_nchars;
304 /* Report having output N chars of the current symbol-description. */
306 #define CHARS(N) (current_sym_nchars += (N))
308 /* Break the current symbol-description, generating a continuation,
309 if it has become long. */
311 #ifndef DBX_CONTIN_LENGTH
312 #define DBX_CONTIN_LENGTH 80
315 #if DBX_CONTIN_LENGTH > 0
317 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
322 void dbxout_types ();
324 void dbxout_symbol ();
325 static void dbxout_type_name ();
326 static void dbxout_type ();
327 static void dbxout_typedefs ();
328 static void dbxout_symbol_name ();
329 static void dbxout_symbol_location ();
330 static void dbxout_prepare_symbol ();
331 static void dbxout_finish_symbol ();
332 static void dbxout_type_index ();
333 static void dbxout_continue ();
334 static void print_int_cst_octal ();
335 static void print_octal ();
337 #if 0 /* Not clear we will actually need this. */
339 /* Return the absolutized filename for the given relative
340 filename. Note that if that filename is already absolute, it may
341 still be returned in a modified form because this routine also
342 eliminates redundant slashes and single dots and eliminates double
343 dots to get a shortest possible filename from the given input
344 filename. The absolutization of relative filenames is made by
345 assuming that the given filename is to be taken as relative to
346 the first argument (cwd) or to the current directory if cwd is
350 abspath (rel_filename)
353 /* Setup the current working directory as needed. */
355 = (char *) alloca (strlen (cwd) + strlen (rel_filename) + 1);
356 char *endp = abs_buffer;
360 /* Copy the filename (possibly preceded by the current working
361 directory name) into the absolutization buffer. */
366 if (rel_filename[0] != '/')
369 while (*endp++ = *src_p++)
371 *(endp-1) = '/'; /* overwrite null */
373 src_p = rel_filename;
374 while (*endp++ = *src_p++)
379 /* Now make a copy of abs_buffer into abs_buffer, shortening the
380 filename (by taking out slashes and dots) as we go. */
382 outp = inp = abs_buffer;
383 *outp++ = *inp++; /* copy first slash */
388 else if (inp[0] == '/' && outp[-1] == '/')
393 else if (inp[0] == '.' && outp[-1] == '/')
397 else if (inp[1] == '/')
402 else if ((inp[1] == '.') && (inp[2] == 0 || inp[2] == '/'))
404 inp += (inp[2] == '/') ? 3 : 2;
406 while (outp >= abs_buffer && *outp != '/')
408 if (outp < abs_buffer)
410 /* Catch cases like /.. where we try to backup to a
411 point above the absolute root of the logical file
414 fprintf (stderr, "%s: invalid file name: %s\n",
415 pname, rel_filename);
425 /* On exit, make sure that there is a trailing null, and make sure that
426 the last character of the returned string is *not* a slash. */
432 /* Make a copy (in the heap) of the stuff left in the absolutization
433 buffer and return a pointer to the copy. */
435 value = (char *) oballoc (strlen (abs_buffer) + 1);
436 strcpy (value, abs_buffer);
441 /* At the beginning of compilation, start writing the symbol table.
442 Initialize `typevec' and output the standard data types of C. */
445 dbxout_init (asm_file, input_file_name, syms)
447 char *input_file_name;
450 char ltext_label_name[100];
455 typevec = (struct typeinfo *) xmalloc (typevec_len * sizeof typevec[0]);
456 bzero ((char *) typevec, typevec_len * sizeof typevec[0]);
458 /* Convert Ltext into the appropriate format for local labels in case
459 the system doesn't insert underscores in front of user generated
461 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
463 /* Put the current working directory in an N_SO symbol. */
464 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
465 but GDB always does. */
466 if (use_gnu_debug_info_extensions)
469 if (!cwd && (cwd = getpwd ()) && (!*cwd || cwd[strlen (cwd) - 1] != '/'))
471 char *wdslash = xmalloc (strlen (cwd) + sizeof (FILE_NAME_JOINER));
472 sprintf (wdslash, "%s%s", cwd, FILE_NAME_JOINER);
477 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
478 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
479 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
480 fprintf (asmfile, "%s ", ASM_STABS_OP);
481 output_quoted_string (asmfile, cwd);
482 fprintf (asmfile, ",%d,0,0,%s\n", N_SO, <ext_label_name[1]);
483 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
487 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
488 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
489 would give us an N_SOL, and we want an N_SO. */
490 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
491 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
492 /* We include outputting `Ltext:' here,
493 because that gives you a way to override it. */
494 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
495 fprintf (asmfile, "%s ", ASM_STABS_OP);
496 output_quoted_string (asmfile, input_file_name);
497 fprintf (asmfile, ",%d,0,0,%s\n",
498 N_SO, <ext_label_name[1]);
500 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Ltext", 0);
501 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
503 /* Possibly output something to inform GDB that this compilation was by
504 GCC. It's easier for GDB to parse it when after the N_SO's. This
505 is used in Solaris 2. */
506 #ifdef ASM_IDENTIFY_GCC_AFTER_SOURCE
507 ASM_IDENTIFY_GCC_AFTER_SOURCE (asmfile);
510 lastfile = input_file_name;
512 next_type_number = 1;
513 next_block_number = 2;
516 current_file = (struct dbx_file *) xmalloc (sizeof *current_file);
517 current_file->next = NULL;
518 current_file->file_number = 0;
519 current_file->next_type_number = 1;
520 next_file_number = 1;
523 /* Make sure that types `int' and `char' have numbers 1 and 2.
524 Definitions of other integer types will refer to those numbers.
525 (Actually it should no longer matter what their numbers are.
526 Also, if any types with tags have been defined, dbxout_symbol
527 will output them first, so the numbers won't be 1 and 2. That
528 happens in C++. So it's a good thing it should no longer matter). */
530 #ifdef DBX_OUTPUT_STANDARD_TYPES
531 DBX_OUTPUT_STANDARD_TYPES (syms);
533 dbxout_symbol (TYPE_NAME (integer_type_node), 0);
534 dbxout_symbol (TYPE_NAME (char_type_node), 0);
537 /* Get all permanent types that have typedef names,
538 and output them all, except for those already output. */
540 dbxout_typedefs (syms);
543 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
544 in the reverse order from that which is found in SYMS. */
547 dbxout_typedefs (syms)
552 dbxout_typedefs (TREE_CHAIN (syms));
553 if (TREE_CODE (syms) == TYPE_DECL)
555 tree type = TREE_TYPE (syms);
557 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
558 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
559 dbxout_symbol (TYPE_NAME (type), 0);
564 /* Change to reading from a new source file. Generate a N_BINCL stab. */
567 dbxout_start_new_source_file (filename)
571 struct dbx_file *n = (struct dbx_file *) xmalloc (sizeof *n);
573 n->next = current_file;
574 n->file_number = next_file_number++;
575 n->next_type_number = 1;
577 fprintf (asmfile, "%s \"%s\",%d,0,0,0\n", ASM_STABS_OP, filename, N_BINCL);
581 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
584 dbxout_resume_previous_source_file ()
587 struct dbx_file *next;
589 fprintf (asmfile, "%s %d,0,0,0\n", ASM_STABN_OP, N_EINCL);
590 next = current_file->next;
596 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
599 dbxout_source_file (file, filename)
603 char ltext_label_name[100];
605 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
607 #ifdef DBX_OUTPUT_SOURCE_FILENAME
608 DBX_OUTPUT_SOURCE_FILENAME (file, filename);
610 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
611 source_label_number);
612 fprintf (file, "%s ", ASM_STABS_OP);
613 output_quoted_string (file, filename);
614 fprintf (file, ",%d,0,0,%s\n", N_SOL, <ext_label_name[1]);
615 if (current_function_decl != NULL_TREE
616 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
617 ; /* Don't change section amid function. */
620 ASM_OUTPUT_INTERNAL_LABEL (file, "Ltext", source_label_number);
621 source_label_number++;
627 /* Output a line number symbol entry into output stream FILE,
628 for source file FILENAME and line number LINENO. */
631 dbxout_source_line (file, filename, lineno)
636 dbxout_source_file (file, filename);
638 #ifdef ASM_OUTPUT_SOURCE_LINE
639 ASM_OUTPUT_SOURCE_LINE (file, lineno);
641 fprintf (file, "\t%s %d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
645 /* At the end of compilation, finish writing the symbol table.
646 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
650 dbxout_finish (file, filename)
654 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
655 DBX_OUTPUT_MAIN_SOURCE_FILE_END (file, filename);
656 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
659 /* Output the index of a type. */
662 dbxout_type_index (type)
665 #ifndef DBX_USE_BINCL
666 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
669 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
670 fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number);
675 /* Continue a symbol-description that gets too big.
676 End one symbol table entry with a double-backslash
677 and start a new one, eventually producing something like
678 .stabs "start......\\",code,0,value
679 .stabs "...rest",code,0,value */
684 #ifdef DBX_CONTIN_CHAR
685 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
687 fprintf (asmfile, "\\\\");
689 dbxout_finish_symbol (NULL_TREE);
690 fprintf (asmfile, "%s \"", ASM_STABS_OP);
691 current_sym_nchars = 0;
694 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
695 This must be a separate function because anonymous unions require
699 dbxout_type_fields (type)
703 /* Output the name, type, position (in bits), size (in bits) of each
705 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
707 /* Omit here local type decls until we know how to support them. */
708 if (TREE_CODE (tem) == TYPE_DECL)
710 /* Omit fields whose position or size are variable. */
711 else if (TREE_CODE (tem) == FIELD_DECL
712 && (TREE_CODE (DECL_FIELD_BITPOS (tem)) != INTEGER_CST
713 || TREE_CODE (DECL_SIZE (tem)) != INTEGER_CST))
715 /* Omit here the nameless fields that are used to skip bits. */
716 else if (TREE_CODE (tem) != CONST_DECL)
718 /* Continue the line if necessary,
719 but not before the first field. */
720 if (tem != TYPE_FIELDS (type))
723 if (use_gnu_debug_info_extensions
724 && flag_minimal_debug
725 && TREE_CODE (tem) == FIELD_DECL
726 && DECL_VIRTUAL_P (tem)
727 && DECL_ASSEMBLER_NAME (tem))
729 have_used_extensions = 1;
730 CHARS (3 + IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (tem)));
731 fputs (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem)), asmfile);
732 dbxout_type (DECL_FCONTEXT (tem), 0, 0);
733 fprintf (asmfile, ":");
734 dbxout_type (TREE_TYPE (tem), 0, 0);
735 fprintf (asmfile, ",%d;",
736 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)));
742 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
743 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
747 fprintf (asmfile, ":");
751 if (use_gnu_debug_info_extensions
752 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
753 || TREE_CODE (tem) != FIELD_DECL))
755 have_used_extensions = 1;
757 putc ((TREE_PRIVATE (tem) ? '0'
758 : TREE_PROTECTED (tem) ? '1' : '2'),
763 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
764 && DECL_BIT_FIELD_TYPE (tem))
765 ? DECL_BIT_FIELD_TYPE (tem)
766 : TREE_TYPE (tem), 0, 0);
768 if (TREE_CODE (tem) == VAR_DECL)
770 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
772 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem));
773 have_used_extensions = 1;
774 fprintf (asmfile, ":%s;", name);
775 CHARS (strlen (name));
779 /* If TEM is non-static, GDB won't understand it. */
780 fprintf (asmfile, ",0,0;");
783 else if (TREE_CODE (DECL_FIELD_BITPOS (tem)) == INTEGER_CST)
785 fprintf (asmfile, ",%d,%d;",
786 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)),
787 TREE_INT_CST_LOW (DECL_SIZE (tem)));
794 /* Subroutine of `dbxout_type_methods'. Output debug info about the
795 method described DECL. DEBUG_NAME is an encoding of the method's
796 type signature. ??? We may be able to do without DEBUG_NAME altogether
800 dbxout_type_method_1 (decl, debug_name)
806 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
808 else /* it's a METHOD_TYPE. */
810 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
811 /* A for normal functions.
812 B for `const' member functions.
813 C for `volatile' member functions.
814 D for `const volatile' member functions. */
815 if (TYPE_READONLY (TREE_TYPE (firstarg)))
817 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
820 if (DECL_VINDEX (decl))
826 fprintf (asmfile, ":%s;%c%c%c", debug_name,
827 TREE_PRIVATE (decl) ? '0' : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
828 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
829 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
830 if (DECL_VINDEX (decl))
832 fprintf (asmfile, "%d;",
833 TREE_INT_CST_LOW (DECL_VINDEX (decl)));
834 dbxout_type (DECL_CONTEXT (decl), 0, 0);
835 fprintf (asmfile, ";");
840 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
844 dbxout_type_methods (type)
847 /* C++: put out the method names and their parameter lists */
848 tree methods = TYPE_METHODS (type);
850 register tree fndecl;
852 char formatted_type_identifier_length[16];
853 register int type_identifier_length;
855 if (methods == NULL_TREE)
858 type_encoding = DECL_NAME (TYPE_NAME (type));
861 /* C++: Template classes break some assumptions made by this code about
862 the class names, constructor names, and encodings for assembler
863 label names. For now, disable output of dbx info for them. */
865 char *ptr = IDENTIFIER_POINTER (type_encoding);
866 /* This should use index. (mrs) */
867 while (*ptr && *ptr != '<') ptr++;
874 #ifdef HAVE_TEMPLATES
875 if (warn_template_debugging)
876 warning ("dbx info for template class methods not yet supported");
884 type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
886 sprintf(formatted_type_identifier_length, "%d", type_identifier_length);
888 if (TREE_CODE (methods) == FUNCTION_DECL)
890 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
891 fndecl = TREE_VEC_ELT (methods, 0);
893 fndecl = TREE_VEC_ELT (methods, 1);
897 tree name = DECL_NAME (fndecl);
900 /* Group together all the methods for the same operation.
901 These differ in the types of the arguments. */
902 for (last = NULL_TREE;
903 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
904 fndecl = TREE_CHAIN (fndecl))
905 /* Output the name of the field (after overloading), as
906 well as the name of the field before overloading, along
907 with its parameter list */
909 /* This is the "mangled" name of the method.
910 It encodes the argument types. */
911 char *debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
912 int show_arg_types = 0;
918 if (DECL_IGNORED_P (fndecl))
921 if (flag_minimal_debug)
925 /* We can't optimize a method which uses an anonymous
926 class, because the debugger will not be able to
927 associate the arbitrary class name with the actual
929 #ifndef NO_DOLLAR_IN_LABEL
934 if (strchr (debug_name, marker))
936 /* Detect ordinary methods because their mangled names
937 start with the operation name. */
938 else if (!strncmp (IDENTIFIER_POINTER (name), debug_name,
939 IDENTIFIER_LENGTH (name)))
941 debug_name += IDENTIFIER_LENGTH (name);
942 if (debug_name[0] == '_' && debug_name[1] == '_')
944 char *method_name = debug_name + 2;
945 char *length_ptr = formatted_type_identifier_length;
946 /* Get past const and volatile qualifiers. */
947 while (*method_name == 'C' || *method_name == 'V')
949 /* Skip digits for length of type_encoding. */
950 while (*method_name == *length_ptr && *length_ptr)
951 length_ptr++, method_name++;
952 if (! strncmp (method_name,
953 IDENTIFIER_POINTER (type_encoding),
954 type_identifier_length))
955 method_name += type_identifier_length;
956 debug_name = method_name;
959 /* Detect constructors by their style of name mangling. */
960 else if (debug_name[0] == '_' && debug_name[1] == '_')
962 char *ctor_name = debug_name + 2;
963 char *length_ptr = formatted_type_identifier_length;
964 while (*ctor_name == 'C' || *ctor_name == 'V')
966 /* Skip digits for length of type_encoding. */
967 while (*ctor_name == *length_ptr && *length_ptr)
968 length_ptr++, ctor_name++;
969 if (!strncmp (IDENTIFIER_POINTER (type_encoding), ctor_name,
970 type_identifier_length))
971 debug_name = ctor_name + type_identifier_length;
973 /* The other alternative is a destructor. */
977 /* Output the operation name just once, for the first method
981 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
982 CHARS (IDENTIFIER_LENGTH (name) + 2);
987 dbxout_type (TREE_TYPE (fndecl), 0, show_arg_types);
989 dbxout_type_method_1 (fndecl, debug_name);
999 /* Emit a "range" type specification, which has the form:
1000 "r<index type>;<lower bound>;<upper bound>;".
1001 TYPE is an INTEGER_TYPE. */
1004 dbxout_range_type (type)
1007 fprintf (asmfile, "r");
1008 if (TREE_TYPE (type))
1009 dbxout_type (TREE_TYPE (type), 0, 0);
1010 else if (TREE_CODE (type) != INTEGER_TYPE)
1011 dbxout_type (type, 0, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
1014 /* This used to say `r1' and we used to take care
1015 to make sure that `int' was type number 1. */
1016 dbxout_type_index (integer_type_node);
1018 if (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST)
1019 fprintf (asmfile, ";%d",
1020 TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)));
1022 fprintf (asmfile, ";0");
1023 if (TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST)
1024 fprintf (asmfile, ";%d;",
1025 TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)));
1027 fprintf (asmfile, ";-1;");
1030 /* Output a reference to a type. If the type has not yet been
1031 described in the dbx output, output its definition now.
1032 For a type already defined, just refer to its definition
1033 using the type number.
1035 If FULL is nonzero, and the type has been described only with
1036 a forward-reference, output the definition now.
1037 If FULL is zero in this case, just refer to the forward-reference
1038 using the number previously allocated.
1040 If SHOW_ARG_TYPES is nonzero, we output a description of the argument
1041 types for a METHOD_TYPE. */
1044 dbxout_type (type, full, show_arg_types)
1050 static int anonymous_type_number = 0;
1052 /* If there was an input error and we don't really have a type,
1053 avoid crashing and write something that is at least valid
1054 by assuming `int'. */
1055 if (type == error_mark_node)
1056 type = integer_type_node;
1059 type = TYPE_MAIN_VARIANT (type);
1060 if (TYPE_NAME (type)
1061 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1062 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1066 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1068 /* Type has no dbx number assigned. Assign next available number. */
1069 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1071 /* Make sure type vector is long enough to record about this type. */
1073 if (next_type_number == typevec_len)
1076 (struct typeinfo *) xrealloc (typevec,
1077 typevec_len * 2 * sizeof typevec[0]);
1078 bzero ((char *) (typevec + typevec_len),
1079 typevec_len * sizeof typevec[0]);
1083 #ifdef DBX_USE_BINCL
1084 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number =
1085 current_file->file_number;
1086 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number =
1087 current_file->next_type_number++;
1091 /* Output the number of this type, to refer to it. */
1092 dbxout_type_index (type);
1094 #ifdef DBX_TYPE_DEFINED
1095 if (DBX_TYPE_DEFINED (type))
1099 /* If this type's definition has been output or is now being output,
1102 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1107 /* If we have already had a cross reference,
1108 and either that's all we want or that's the best we could do,
1109 don't repeat the cross reference.
1110 Sun dbx crashes if we do. */
1111 if (! full || TYPE_SIZE (type) == 0
1112 /* No way in DBX fmt to describe a variable size. */
1113 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1121 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1122 leave the type-number completely undefined rather than output
1123 a cross-reference. If we have already used GNU debug info extensions,
1124 then it is OK to output a cross reference. This is necessary to get
1125 proper C++ debug output. */
1126 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1127 || TREE_CODE (type) == QUAL_UNION_TYPE
1128 || TREE_CODE (type) == ENUMERAL_TYPE)
1129 && ! use_gnu_debug_info_extensions)
1130 /* We must use the same test here as we use twice below when deciding
1131 whether to emit a cross-reference. */
1132 if ((TYPE_NAME (type) != 0
1133 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1134 && DECL_IGNORED_P (TYPE_NAME (type)))
1136 || TYPE_SIZE (type) == 0
1137 /* No way in DBX fmt to describe a variable size. */
1138 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1140 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1145 /* Output a definition now. */
1147 fprintf (asmfile, "=");
1150 /* Mark it as defined, so that if it is self-referent
1151 we will not get into an infinite recursion of definitions. */
1153 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1155 switch (TREE_CODE (type))
1159 /* For a void type, just define it as itself; ie, "5=5".
1160 This makes us consider it defined
1161 without saying what it is. The debugger will make it
1162 a void type when the reference is seen, and nothing will
1163 ever override that default. */
1164 dbxout_type_index (type);
1168 if (type == char_type_node && ! TREE_UNSIGNED (type))
1170 /* Output the type `char' as a subrange of itself!
1171 I don't understand this definition, just copied it
1172 from the output of pcc.
1173 This used to use `r2' explicitly and we used to
1174 take care to make sure that `char' was type number 2. */
1175 fprintf (asmfile, "r");
1176 dbxout_type_index (type);
1177 fprintf (asmfile, ";0;127;");
1179 else if (use_gnu_debug_info_extensions
1180 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1181 || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT))
1183 /* This used to say `r1' and we used to take care
1184 to make sure that `int' was type number 1. */
1185 fprintf (asmfile, "r");
1186 dbxout_type_index (integer_type_node);
1187 fprintf (asmfile, ";");
1188 print_int_cst_octal (TYPE_MIN_VALUE (type));
1189 fprintf (asmfile, ";");
1190 print_int_cst_octal (TYPE_MAX_VALUE (type));
1191 fprintf (asmfile, ";");
1193 else /* Output other integer types as subranges of `int'. */
1194 dbxout_range_type (type);
1199 /* This used to say `r1' and we used to take care
1200 to make sure that `int' was type number 1. */
1201 fprintf (asmfile, "r");
1202 dbxout_type_index (integer_type_node);
1203 fprintf (asmfile, ";%d;0;", int_size_in_bytes (type));
1208 if (use_gnu_debug_info_extensions)
1209 fprintf (asmfile, "@s%d;-20;",
1210 BITS_PER_UNIT * int_size_in_bytes (type));
1213 /* Output the type `char' as a subrange of itself.
1214 That is what pcc seems to do. */
1215 fprintf (asmfile, "r");
1216 dbxout_type_index (char_type_node);
1217 fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1223 if (use_gnu_debug_info_extensions)
1224 fprintf (asmfile, "@s%d;-16;",
1225 BITS_PER_UNIT * int_size_in_bytes (type));
1226 else /* Define as enumeral type (False, True) */
1227 fprintf (asmfile, "eFalse:0,True:1,;");
1232 putc ('d', asmfile);
1234 dbxout_type (TREE_TYPE (type), 0, 0);
1238 /* Differs from the REAL_TYPE by its new data type number */
1240 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1242 fprintf (asmfile, "r");
1243 dbxout_type_index (type);
1244 fprintf (asmfile, ";%d;0;",
1245 int_size_in_bytes (TREE_TYPE (type)));
1246 CHARS (12); /* The number is probably incorrect here. */
1250 /* Output a complex integer type as a structure,
1251 pending some other way to do it. */
1252 fprintf (asmfile, "s%d", int_size_in_bytes (type));
1254 fprintf (asmfile, "real:");
1256 dbxout_type (TREE_TYPE (type), 0, 0);
1257 fprintf (asmfile, ",%d,%d;",
1258 0, TYPE_PRECISION (TREE_TYPE (type)));
1260 fprintf (asmfile, "imag:");
1262 dbxout_type (TREE_TYPE (type), 0, 0);
1263 fprintf (asmfile, ",%d,%d;;",
1264 TYPE_PRECISION (TREE_TYPE (type)),
1265 TYPE_PRECISION (TREE_TYPE (type)));
1271 if (use_gnu_debug_info_extensions)
1273 have_used_extensions = 1;
1274 fprintf (asmfile, "@s%d;",
1275 BITS_PER_UNIT * int_size_in_bytes (type));
1276 /* Check if a bitstring type, which in Chill is
1277 different from a [power]set. */
1278 if (TYPE_STRING_FLAG (type))
1279 fprintf (asmfile, "@S;");
1281 putc ('S', asmfile);
1283 dbxout_type (TYPE_DOMAIN (type), 0, 0);
1287 /* Output "a" followed by a range type definition
1288 for the index type of the array
1289 followed by a reference to the target-type.
1290 ar1;0;N;M for a C array of type M and size N+1. */
1291 /* Check if a character string type, which in Chill is
1292 different from an array of characters. */
1293 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1295 have_used_extensions = 1;
1296 fprintf (asmfile, "@S;");
1298 tem = TYPE_DOMAIN (type);
1301 fprintf (asmfile, "ar");
1302 dbxout_type_index (integer_type_node);
1303 fprintf (asmfile, ";0;-1;");
1307 fprintf (asmfile, "a");
1308 dbxout_range_type (tem);
1311 dbxout_type (TREE_TYPE (type), 0, 0);
1316 case QUAL_UNION_TYPE:
1318 int i, n_baseclasses = 0;
1320 if (TYPE_BINFO (type) != 0 && TYPE_BINFO_BASETYPES (type) != 0)
1321 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1323 /* Output a structure type. We must use the same test here as we
1324 use in the DBX_NO_XREFS case above. */
1325 if ((TYPE_NAME (type) != 0
1326 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1327 && DECL_IGNORED_P (TYPE_NAME (type)))
1329 || TYPE_SIZE (type) == 0
1330 /* No way in DBX fmt to describe a variable size. */
1331 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1333 /* If the type is just a cross reference, output one
1334 and mark the type as partially described.
1335 If it later becomes defined, we will output
1336 its real definition.
1337 If the type has a name, don't nest its definition within
1338 another type's definition; instead, output an xref
1339 and let the definition come when the name is defined. */
1340 fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu");
1342 #if 0 /* This assertion is legitimately false in C++. */
1343 /* We shouldn't be outputting a reference to a type before its
1344 definition unless the type has a tag name.
1345 A typedef name without a tag name should be impossible. */
1346 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1349 if (TYPE_NAME (type) != 0)
1350 dbxout_type_name (type);
1352 fprintf (asmfile, "$$%d", anonymous_type_number++);
1353 fprintf (asmfile, ":");
1354 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1358 /* Identify record or union, and print its size. */
1359 fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "s%d" : "u%d",
1360 int_size_in_bytes (type));
1362 if (use_gnu_debug_info_extensions)
1366 have_used_extensions = 1;
1367 fprintf (asmfile, "!%d,", n_baseclasses);
1371 for (i = 0; i < n_baseclasses; i++)
1373 tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i);
1374 if (use_gnu_debug_info_extensions)
1376 have_used_extensions = 1;
1377 putc (TREE_VIA_VIRTUAL (child) ? '1'
1380 putc (TREE_VIA_PUBLIC (child) ? '2'
1383 fprintf (asmfile, "%d,",
1384 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT);
1386 dbxout_type (BINFO_TYPE (child), 0, 0);
1387 putc (';', asmfile);
1391 /* Print out the base class information with fields
1392 which have the same names at the types they hold. */
1393 dbxout_type_name (BINFO_TYPE (child));
1394 putc (':', asmfile);
1395 dbxout_type (BINFO_TYPE (child), full, 0);
1396 fprintf (asmfile, ",%d,%d;",
1397 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT,
1398 TREE_INT_CST_LOW (DECL_SIZE (TYPE_NAME (BINFO_TYPE (child)))) * BITS_PER_UNIT);
1406 /* Write out the field declarations. */
1407 dbxout_type_fields (type);
1408 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1410 have_used_extensions = 1;
1411 dbxout_type_methods (type);
1413 putc (';', asmfile);
1415 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1416 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1417 && TYPE_VFIELD (type))
1419 have_used_extensions = 1;
1421 /* Tell GDB+ that it may keep reading. */
1422 putc ('~', asmfile);
1424 /* We need to write out info about what field this class
1425 uses as its "main" vtable pointer field, because if this
1426 field is inherited from a base class, GDB cannot necessarily
1427 figure out which field it's using in time. */
1428 if (TYPE_VFIELD (type))
1430 putc ('%', asmfile);
1431 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0, 0);
1433 putc (';', asmfile);
1439 /* We must use the same test here as we use in the DBX_NO_XREFS case
1440 above. We simplify it a bit since an enum will never have a variable
1442 if ((TYPE_NAME (type) != 0
1443 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1444 && DECL_IGNORED_P (TYPE_NAME (type)))
1446 || TYPE_SIZE (type) == 0)
1448 fprintf (asmfile, "xe");
1450 dbxout_type_name (type);
1451 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1452 fprintf (asmfile, ":");
1455 #ifdef DBX_OUTPUT_ENUM
1456 DBX_OUTPUT_ENUM (asmfile, type);
1458 if (use_gnu_debug_info_extensions
1459 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1460 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1461 putc ('e', asmfile);
1463 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1465 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1466 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1467 fprintf (asmfile, "%lu",
1468 (unsigned long) TREE_INT_CST_LOW (TREE_VALUE (tem)));
1469 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1470 && TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1471 fprintf (asmfile, "%ld",
1472 (long) TREE_INT_CST_LOW (TREE_VALUE (tem)));
1474 print_int_cst_octal (TREE_VALUE (tem));
1475 fprintf (asmfile, ",");
1476 CHARS (20 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem)));
1477 if (TREE_CHAIN (tem) != 0)
1480 putc (';', asmfile);
1486 putc ('*', asmfile);
1488 dbxout_type (TREE_TYPE (type), 0, 0);
1492 if (use_gnu_debug_info_extensions)
1494 have_used_extensions = 1;
1495 putc ('#', asmfile);
1497 if (flag_minimal_debug && !show_arg_types)
1499 /* Normally, just output the return type.
1500 The argument types are encoded in the method name. */
1501 putc ('#', asmfile);
1502 dbxout_type (TREE_TYPE (type), 0, 0);
1503 putc (';', asmfile);
1508 /* When outputting destructors, we need to write
1509 the argument types out longhand. */
1510 dbxout_type (TYPE_METHOD_BASETYPE (type), 0, 0);
1511 putc (',', asmfile);
1513 dbxout_type (TREE_TYPE (type), 0, 0);
1514 dbxout_args (TYPE_ARG_TYPES (type));
1515 putc (';', asmfile);
1521 /* Treat it as a function type. */
1522 dbxout_type (TREE_TYPE (type), 0, 0);
1527 if (use_gnu_debug_info_extensions)
1529 have_used_extensions = 1;
1530 putc ('@', asmfile);
1532 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0, 0);
1533 putc (',', asmfile);
1535 dbxout_type (TREE_TYPE (type), 0, 0);
1539 /* Should print as an int, because it is really
1541 dbxout_type (integer_type_node, 0, 0);
1545 case REFERENCE_TYPE:
1546 if (use_gnu_debug_info_extensions)
1547 have_used_extensions = 1;
1548 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1550 dbxout_type (TREE_TYPE (type), 0, 0);
1554 putc ('f', asmfile);
1556 dbxout_type (TREE_TYPE (type), 0, 0);
1564 /* Print the value of integer constant C, in octal,
1565 handling double precision. */
1568 print_int_cst_octal (c)
1571 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1572 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1573 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1574 int width = TYPE_PRECISION (TREE_TYPE (c));
1576 /* GDB wants constants with no extra leading "1" bits, so
1577 we need to remove any sign-extension that might be
1579 if (width == HOST_BITS_PER_WIDE_INT * 2)
1581 else if (width > HOST_BITS_PER_WIDE_INT)
1582 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1583 else if (width == HOST_BITS_PER_WIDE_INT)
1586 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1588 fprintf (asmfile, "0");
1592 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1593 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1597 unsigned HOST_WIDE_INT beg = high >> excess;
1598 unsigned HOST_WIDE_INT middle
1599 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1600 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1601 unsigned HOST_WIDE_INT end
1602 = low & (((unsigned HOST_WIDE_INT) 1
1603 << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1606 fprintf (asmfile, "%o%01o", beg, middle);
1607 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1612 print_octal (value, digits)
1613 unsigned HOST_WIDE_INT value;
1618 for (i = digits - 1; i >= 0; i--)
1619 fprintf (asmfile, "%01o", ((value >> (3 * i)) & 7));
1622 /* Output the name of type TYPE, with no punctuation.
1623 Such names can be set up either by typedef declarations
1624 or by struct, enum and union tags. */
1627 dbxout_type_name (type)
1631 if (TYPE_NAME (type) == 0)
1633 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
1635 t = TYPE_NAME (type);
1637 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1639 t = DECL_NAME (TYPE_NAME (type));
1644 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
1645 CHARS (IDENTIFIER_LENGTH (t));
1648 /* Output a .stabs for the symbol defined by DECL,
1649 which must be a ..._DECL node in the normal namespace.
1650 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1651 LOCAL is nonzero if the scope is less than the entire file. */
1654 dbxout_symbol (decl, local)
1658 tree type = TREE_TYPE (decl);
1659 tree context = NULL_TREE;
1661 /* Cast avoids warning in old compilers. */
1662 current_sym_code = (STAB_CODE_TYPE) 0;
1663 current_sym_value = 0;
1664 current_sym_addr = 0;
1666 /* Ignore nameless syms, but don't ignore type tags. */
1668 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
1669 || DECL_IGNORED_P (decl))
1672 dbxout_prepare_symbol (decl);
1674 /* The output will always start with the symbol name,
1675 so always count that in the length-output-so-far. */
1677 if (DECL_NAME (decl) != 0)
1678 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
1680 switch (TREE_CODE (decl))
1683 /* Enum values are defined by defining the enum type. */
1687 if (DECL_RTL (decl) == 0)
1689 if (DECL_EXTERNAL (decl))
1691 /* Don't mention a nested function under its parent. */
1692 context = decl_function_context (decl);
1693 if (context == current_function_decl)
1695 if (GET_CODE (DECL_RTL (decl)) != MEM
1696 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
1700 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
1701 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1702 TREE_PUBLIC (decl) ? 'F' : 'f');
1704 current_sym_code = N_FUN;
1705 current_sym_addr = XEXP (DECL_RTL (decl), 0);
1707 if (TREE_TYPE (type))
1708 dbxout_type (TREE_TYPE (type), 0, 0);
1710 dbxout_type (void_type_node, 0, 0);
1712 /* For a nested function, when that function is compiled,
1713 mention the containing function name
1714 as well as (since dbx wants it) our own assembler-name. */
1716 fprintf (asmfile, ",%s,%s",
1717 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1718 IDENTIFIER_POINTER (DECL_NAME (context)));
1720 dbxout_finish_symbol (decl);
1725 /* This seems all wrong. Outputting most kinds of types gives no name
1726 at all. A true definition gives no name; a cross-ref for a
1727 structure can give the tag name, but not a type name.
1728 It seems that no typedef name is defined by outputting a type. */
1730 /* If this typedef name was defined by outputting the type,
1731 don't duplicate it. */
1732 if (typevec[TYPE_SYMTAB_ADDRESS (type)].status == TYPE_DEFINED
1733 && TYPE_NAME (TREE_TYPE (decl)) == decl)
1736 /* Don't output the same typedef twice.
1737 And don't output what language-specific stuff doesn't want output. */
1738 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
1747 if (DECL_NAME (decl))
1749 /* Nonzero means we must output a tag as well as a typedef. */
1752 /* Handle the case of a C++ structure or union
1753 where the TYPE_NAME is a TYPE_DECL
1754 which gives both a typedef name and a tag. */
1755 /* dbx requires the tag first and the typedef second. */
1756 if ((TREE_CODE (type) == RECORD_TYPE
1757 || TREE_CODE (type) == UNION_TYPE
1758 || TREE_CODE (type) == QUAL_UNION_TYPE)
1759 && TYPE_NAME (type) == decl
1760 && !(use_gnu_debug_info_extensions && have_used_extensions)
1761 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
1762 /* Distinguish the implicit typedefs of C++
1763 from explicit ones that might be found in C. */
1764 && (!strcmp (lang_identify (), "cplusplus")
1765 /* The following line maybe unnecessary;
1766 in 2.6, try removing it. */
1767 || DECL_SOURCE_LINE (decl) == 0))
1769 tree name = TYPE_NAME (type);
1770 if (TREE_CODE (name) == TYPE_DECL)
1771 name = DECL_NAME (name);
1773 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1774 current_sym_value = 0;
1775 current_sym_addr = 0;
1776 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1778 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1779 IDENTIFIER_POINTER (name));
1780 dbxout_type (type, 1, 0);
1781 dbxout_finish_symbol (NULL_TREE);
1784 /* Output typedef name. */
1785 fprintf (asmfile, "%s \"%s:", ASM_STABS_OP,
1786 IDENTIFIER_POINTER (DECL_NAME (decl)));
1788 /* Short cut way to output a tag also. */
1789 if ((TREE_CODE (type) == RECORD_TYPE
1790 || TREE_CODE (type) == UNION_TYPE
1791 || TREE_CODE (type) == QUAL_UNION_TYPE)
1792 && TYPE_NAME (type) == decl)
1794 if (use_gnu_debug_info_extensions && have_used_extensions)
1796 putc ('T', asmfile);
1797 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
1799 #if 0 /* Now we generate the tag for this case up above. */
1805 putc ('t', asmfile);
1806 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1808 dbxout_type (type, 1, 0);
1809 dbxout_finish_symbol (decl);
1813 /* Don't output a tag if this is an incomplete type (TYPE_SIZE is
1814 zero). This prevents the sun4 Sun OS 4.x dbx from crashing. */
1816 if (tag_needed && TYPE_NAME (type) != 0
1817 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
1818 || (DECL_NAME (TYPE_NAME (type)) != 0))
1819 && TYPE_SIZE (type) != 0
1820 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
1822 /* For a TYPE_DECL with no name, but the type has a name,
1824 This is what represents `struct foo' with no typedef. */
1825 /* In C++, the name of a type is the corresponding typedef.
1826 In C, it is an IDENTIFIER_NODE. */
1827 tree name = TYPE_NAME (type);
1828 if (TREE_CODE (name) == TYPE_DECL)
1829 name = DECL_NAME (name);
1831 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1832 current_sym_value = 0;
1833 current_sym_addr = 0;
1834 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1836 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1837 IDENTIFIER_POINTER (name));
1838 dbxout_type (type, 1, 0);
1839 dbxout_finish_symbol (NULL_TREE);
1843 /* If an enum type has no name, it cannot be referred to,
1844 but we must output it anyway, since the enumeration constants
1845 can be referred to. */
1846 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
1848 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1849 current_sym_value = 0;
1850 current_sym_addr = 0;
1851 current_sym_nchars = 2;
1853 /* Some debuggers fail when given NULL names, so give this a
1854 harmless name of ` '. */
1855 fprintf (asmfile, "%s \" :T", ASM_STABS_OP);
1856 dbxout_type (type, 1, 0);
1857 dbxout_finish_symbol (NULL_TREE);
1860 /* Prevent duplicate output of a typedef. */
1861 TREE_ASM_WRITTEN (decl) = 1;
1866 /* Parm decls go in their own separate chains
1867 and are output by dbxout_reg_parms and dbxout_parms. */
1871 /* Named return value, treat like a VAR_DECL. */
1873 if (DECL_RTL (decl) == 0)
1875 /* Don't mention a variable that is external.
1876 Let the file that defines it describe it. */
1877 if (DECL_EXTERNAL (decl))
1880 /* If the variable is really a constant
1881 and not written in memory, inform the debugger. */
1882 if (TREE_STATIC (decl) && TREE_READONLY (decl)
1883 && DECL_INITIAL (decl) != 0
1884 && ! TREE_ASM_WRITTEN (decl)
1885 && (DECL_FIELD_CONTEXT (decl) == NULL_TREE
1886 || TREE_CODE (DECL_FIELD_CONTEXT (decl)) == BLOCK))
1888 if (TREE_PUBLIC (decl) == 0)
1890 /* The sun4 assembler does not grok this. */
1891 char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
1892 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
1893 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
1895 HOST_WIDE_INT ival = TREE_INT_CST_LOW (DECL_INITIAL (decl));
1896 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
1897 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile, name, ival);
1899 fprintf (asmfile, "%s \"%s:c=i%d\",0x%x,0,0,0\n",
1900 ASM_STABS_OP, name, ival, N_LSYM);
1904 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
1906 /* don't know how to do this yet. */
1910 /* else it is something we handle like a normal variable. */
1913 DECL_RTL (decl) = eliminate_regs (DECL_RTL (decl), 0, NULL_RTX);
1914 #ifdef LEAF_REG_REMAP
1916 leaf_renumber_regs_insn (DECL_RTL (decl));
1919 dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
1923 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
1924 Add SUFFIX to its name, if SUFFIX is not 0.
1925 Describe the variable as residing in HOME
1926 (usually HOME is DECL_RTL (DECL), but not always). */
1929 dbxout_symbol_location (decl, type, suffix, home)
1937 /* Don't mention a variable at all
1938 if it was completely optimized into nothingness.
1940 If the decl was from an inline function, then it's rtl
1941 is not identically the rtl that was used in this
1942 particular compilation. */
1943 if (GET_CODE (home) == REG)
1945 regno = REGNO (home);
1946 if (regno >= FIRST_PSEUDO_REGISTER)
1949 else if (GET_CODE (home) == SUBREG)
1953 while (GET_CODE (value) == SUBREG)
1955 offset += SUBREG_WORD (value);
1956 value = SUBREG_REG (value);
1958 if (GET_CODE (value) == REG)
1960 regno = REGNO (value);
1961 if (regno >= FIRST_PSEUDO_REGISTER)
1965 alter_subreg (home);
1968 /* The kind-of-variable letter depends on where
1969 the variable is and on the scope of its name:
1970 G and N_GSYM for static storage and global scope,
1971 S for static storage and file scope,
1972 V for static storage and local scope,
1973 for those two, use N_LCSYM if data is in bss segment,
1974 N_STSYM if in data segment, N_FUN otherwise.
1975 (We used N_FUN originally, then changed to N_STSYM
1976 to please GDB. However, it seems that confused ld.
1977 Now GDB has been fixed to like N_FUN, says Kingdon.)
1978 no letter at all, and N_LSYM, for auto variable,
1979 r and N_RSYM for register variable. */
1981 if (GET_CODE (home) == MEM
1982 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
1984 if (TREE_PUBLIC (decl))
1987 current_sym_code = N_GSYM;
1991 current_sym_addr = XEXP (home, 0);
1993 letter = decl_function_context (decl) ? 'V' : 'S';
1995 /* This should be the same condition as in assemble_variable, but
1996 we don't have access to dont_output_data here. So, instead,
1997 we rely on the fact that error_mark_node initializers always
1998 end up in bss for C++ and never end up in bss for C. */
1999 if (DECL_INITIAL (decl) == 0
2000 || (!strcmp (lang_identify (), "cplusplus")
2001 && DECL_INITIAL (decl) == error_mark_node))
2002 current_sym_code = N_LCSYM;
2003 else if (DECL_IN_TEXT_SECTION (decl))
2004 /* This is not quite right, but it's the closest
2005 of all the codes that Unix defines. */
2006 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
2009 /* Ultrix `as' seems to need this. */
2010 #ifdef DBX_STATIC_STAB_DATA_SECTION
2013 current_sym_code = N_STSYM;
2017 else if (regno >= 0)
2020 current_sym_code = N_RSYM;
2021 current_sym_value = DBX_REGISTER_NUMBER (regno);
2023 else if (GET_CODE (home) == MEM
2024 && (GET_CODE (XEXP (home, 0)) == MEM
2025 || (GET_CODE (XEXP (home, 0)) == REG
2026 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM)))
2027 /* If the value is indirect by memory or by a register
2028 that isn't the frame pointer
2029 then it means the object is variable-sized and address through
2030 that register or stack slot. DBX has no way to represent this
2031 so all we can do is output the variable as a pointer.
2032 If it's not a parameter, ignore it.
2033 (VAR_DECLs like this can be made by integrate.c.) */
2035 if (GET_CODE (XEXP (home, 0)) == REG)
2038 current_sym_code = N_RSYM;
2039 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2043 current_sym_code = N_LSYM;
2044 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2045 We want the value of that CONST_INT. */
2047 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2050 /* Effectively do build_pointer_type, but don't cache this type,
2051 since it might be temporary whereas the type it points to
2052 might have been saved for inlining. */
2053 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2054 type = make_node (POINTER_TYPE);
2055 TREE_TYPE (type) = TREE_TYPE (decl);
2057 else if (GET_CODE (home) == MEM
2058 && GET_CODE (XEXP (home, 0)) == REG)
2060 current_sym_code = N_LSYM;
2061 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2063 else if (GET_CODE (home) == MEM
2064 && GET_CODE (XEXP (home, 0)) == PLUS
2065 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2067 current_sym_code = N_LSYM;
2068 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2069 We want the value of that CONST_INT. */
2070 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2072 else if (GET_CODE (home) == MEM
2073 && GET_CODE (XEXP (home, 0)) == CONST)
2075 /* Handle an obscure case which can arise when optimizing and
2076 when there are few available registers. (This is *always*
2077 the case for i386/i486 targets). The RTL looks like
2078 (MEM (CONST ...)) even though this variable is a local `auto'
2079 or a local `register' variable. In effect, what has happened
2080 is that the reload pass has seen that all assignments and
2081 references for one such a local variable can be replaced by
2082 equivalent assignments and references to some static storage
2083 variable, thereby avoiding the need for a register. In such
2084 cases we're forced to lie to debuggers and tell them that
2085 this variable was itself `static'. */
2086 current_sym_code = N_LCSYM;
2088 current_sym_addr = XEXP (XEXP (home, 0), 0);
2090 else if (GET_CODE (home) == CONCAT)
2092 tree subtype = TREE_TYPE (type);
2094 /* If the variable's storage is in two parts,
2095 output each as a separate stab with a modified name. */
2096 if (WORDS_BIG_ENDIAN)
2097 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2099 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2101 /* Cast avoids warning in old compilers. */
2102 current_sym_code = (STAB_CODE_TYPE) 0;
2103 current_sym_value = 0;
2104 current_sym_addr = 0;
2105 dbxout_prepare_symbol (decl);
2107 if (WORDS_BIG_ENDIAN)
2108 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2110 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2114 /* Address might be a MEM, when DECL is a variable-sized object.
2115 Or it might be const0_rtx, meaning previous passes
2116 want us to ignore this variable. */
2119 /* Ok, start a symtab entry and output the variable name. */
2122 #ifdef DBX_STATIC_BLOCK_START
2123 DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2126 dbxout_symbol_name (decl, suffix, letter);
2127 dbxout_type (type, 0, 0);
2128 dbxout_finish_symbol (decl);
2130 #ifdef DBX_STATIC_BLOCK_END
2131 DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2135 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2136 Then output LETTER to indicate the kind of location the symbol has. */
2139 dbxout_symbol_name (decl, suffix, letter)
2144 /* One slight hitch: if this is a VAR_DECL which is a static
2145 class member, we must put out the mangled name instead of the
2146 DECL_NAME. Note also that static member (variable) names DO NOT begin
2147 with underscores in .stabs directives. */
2148 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2151 fprintf (asmfile, "%s \"%s%s:", ASM_STABS_OP, name,
2152 (suffix ? suffix : ""));
2154 if (letter) putc (letter, asmfile);
2158 dbxout_prepare_symbol (decl)
2162 char *filename = DECL_SOURCE_FILE (decl);
2164 dbxout_source_file (asmfile, filename);
2169 dbxout_finish_symbol (sym)
2172 #ifdef DBX_FINISH_SYMBOL
2173 DBX_FINISH_SYMBOL (sym);
2176 if (use_gnu_debug_info_extensions && sym != 0)
2177 line = DECL_SOURCE_LINE (sym);
2179 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2180 if (current_sym_addr)
2181 output_addr_const (asmfile, current_sym_addr);
2183 fprintf (asmfile, "%d", current_sym_value);
2184 putc ('\n', asmfile);
2188 /* Output definitions of all the decls in a chain. */
2196 dbxout_symbol (syms, 1);
2197 syms = TREE_CHAIN (syms);
2201 /* The following two functions output definitions of function parameters.
2202 Each parameter gets a definition locating it in the parameter list.
2203 Each parameter that is a register variable gets a second definition
2204 locating it in the register.
2206 Printing or argument lists in gdb uses the definitions that
2207 locate in the parameter list. But reference to the variable in
2208 expressions uses preferentially the definition as a register. */
2210 /* Output definitions, referring to storage in the parmlist,
2211 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2214 dbxout_parms (parms)
2217 for (; parms; parms = TREE_CHAIN (parms))
2218 if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2220 dbxout_prepare_symbol (parms);
2222 /* Perform any necessary register eliminations on the parameter's rtl,
2223 so that the debugging output will be accurate. */
2224 DECL_INCOMING_RTL (parms)
2225 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2226 DECL_RTL (parms) = eliminate_regs (DECL_RTL (parms), 0, NULL_RTX);
2227 #ifdef LEAF_REG_REMAP
2230 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2231 leaf_renumber_regs_insn (DECL_RTL (parms));
2235 if (PARM_PASSED_IN_MEMORY (parms))
2237 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2239 /* ??? Here we assume that the parm address is indexed
2240 off the frame pointer or arg pointer.
2241 If that is not true, we produce meaningless results,
2242 but do not crash. */
2243 if (GET_CODE (addr) == PLUS
2244 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2245 current_sym_value = INTVAL (XEXP (addr, 1));
2247 current_sym_value = 0;
2249 current_sym_code = N_PSYM;
2250 current_sym_addr = 0;
2253 if (DECL_NAME (parms))
2255 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2257 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2258 IDENTIFIER_POINTER (DECL_NAME (parms)),
2259 DBX_MEMPARM_STABS_LETTER);
2263 current_sym_nchars = 8;
2264 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2265 DBX_MEMPARM_STABS_LETTER);
2268 dbxout_type (DECL_ARG_TYPE (parms), 0, 0);
2269 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2270 dbxout_finish_symbol (parms);
2272 else if (GET_CODE (DECL_RTL (parms)) == REG)
2275 char regparm_letter;
2277 /* Parm passed in registers and lives in registers or nowhere. */
2279 current_sym_code = DBX_REGPARM_STABS_CODE;
2280 regparm_letter = DBX_REGPARM_STABS_LETTER;
2281 current_sym_addr = 0;
2283 /* If parm lives in a register, use that register;
2284 pretend the parm was passed there. It would be more consistent
2285 to describe the register where the parm was passed,
2286 but in practice that register usually holds something else.
2288 If we use DECL_RTL, then we must use the declared type of
2289 the variable, not the type that it arrived in. */
2290 if (REGNO (DECL_RTL (parms)) >= 0
2291 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2293 best_rtl = DECL_RTL (parms);
2294 parm_type = TREE_TYPE (parms);
2296 /* If the parm lives nowhere, use the register where it was
2297 passed. It is also better to use the declared type here. */
2300 best_rtl = DECL_INCOMING_RTL (parms);
2301 parm_type = TREE_TYPE (parms);
2303 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2306 if (DECL_NAME (parms))
2308 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2309 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2310 IDENTIFIER_POINTER (DECL_NAME (parms)),
2315 current_sym_nchars = 8;
2316 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2320 dbxout_type (parm_type, 0, 0);
2321 dbxout_finish_symbol (parms);
2323 else if (GET_CODE (DECL_RTL (parms)) == MEM
2324 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2325 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2326 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2327 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2328 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2332 /* Parm was passed via invisible reference.
2333 That is, its address was passed in a register.
2334 Output it as if it lived in that register.
2335 The debugger will know from the type
2336 that it was actually passed by invisible reference. */
2338 char regparm_letter;
2339 /* Parm passed in registers and lives in registers or nowhere. */
2341 current_sym_code = DBX_REGPARM_STABS_CODE;
2342 if (use_gnu_debug_info_extensions)
2343 regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2345 regparm_letter = DBX_REGPARM_STABS_LETTER;
2347 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2348 If it is an unallocated pseudo-reg, then use the register where
2349 it was passed instead. */
2350 if (REGNO (XEXP (DECL_RTL (parms), 0)) >= 0
2351 && REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2352 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2354 current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2356 current_sym_addr = 0;
2359 if (DECL_NAME (parms))
2361 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2363 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2364 IDENTIFIER_POINTER (DECL_NAME (parms)),
2369 current_sym_nchars = 8;
2370 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2374 dbxout_type (TREE_TYPE (parms), 0, 0);
2375 dbxout_finish_symbol (parms);
2377 else if (GET_CODE (DECL_RTL (parms)) == MEM
2378 && XEXP (DECL_RTL (parms), 0) != const0_rtx
2379 /* ??? A constant address for a parm can happen
2380 when the reg it lives in is equiv to a constant in memory.
2381 Should make this not happen, after 2.4. */
2382 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2384 /* Parm was passed in registers but lives on the stack. */
2386 current_sym_code = N_PSYM;
2387 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2388 in which case we want the value of that CONST_INT,
2389 or (MEM (REG ...)) or (MEM (MEM ...)),
2390 in which case we use a value of zero. */
2391 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2392 || GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2393 current_sym_value = 0;
2395 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2396 current_sym_addr = 0;
2399 if (DECL_NAME (parms))
2401 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2403 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2404 IDENTIFIER_POINTER (DECL_NAME (parms)),
2405 DBX_MEMPARM_STABS_LETTER);
2409 current_sym_nchars = 8;
2410 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2411 DBX_MEMPARM_STABS_LETTER);
2415 = DEBUGGER_ARG_OFFSET (current_sym_value,
2416 XEXP (DECL_RTL (parms), 0));
2417 dbxout_type (TREE_TYPE (parms), 0, 0);
2418 dbxout_finish_symbol (parms);
2423 /* Output definitions for the places where parms live during the function,
2424 when different from where they were passed, when the parms were passed
2427 It is not useful to do this for parms passed in registers
2428 that live during the function in different registers, because it is
2429 impossible to look in the passed register for the passed value,
2430 so we use the within-the-function register to begin with.
2432 PARMS is a chain of PARM_DECL nodes. */
2435 dbxout_reg_parms (parms)
2438 for (; parms; parms = TREE_CHAIN (parms))
2439 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
2441 dbxout_prepare_symbol (parms);
2443 /* Report parms that live in registers during the function
2444 but were passed in memory. */
2445 if (GET_CODE (DECL_RTL (parms)) == REG
2446 && REGNO (DECL_RTL (parms)) >= 0
2447 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2448 dbxout_symbol_location (parms, TREE_TYPE (parms),
2449 0, DECL_RTL (parms));
2450 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
2451 dbxout_symbol_location (parms, TREE_TYPE (parms),
2452 0, DECL_RTL (parms));
2453 /* Report parms that live in memory but not where they were passed. */
2454 else if (GET_CODE (DECL_RTL (parms)) == MEM
2455 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
2456 dbxout_symbol_location (parms, TREE_TYPE (parms),
2457 0, DECL_RTL (parms));
2461 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2462 output definitions of those names, in raw form */
2470 putc (',', asmfile);
2471 dbxout_type (TREE_VALUE (args), 0, 0);
2473 args = TREE_CHAIN (args);
2477 /* Given a chain of ..._TYPE nodes,
2478 find those which have typedef names and output those names.
2479 This is to ensure those types get output. */
2482 dbxout_types (types)
2483 register tree types;
2487 if (TYPE_NAME (types)
2488 && TREE_CODE (TYPE_NAME (types)) == TYPE_DECL
2489 && ! TREE_ASM_WRITTEN (TYPE_NAME (types)))
2490 dbxout_symbol (TYPE_NAME (types), 1);
2491 types = TREE_CHAIN (types);
2495 /* Output everything about a symbol block (a BLOCK node
2496 that represents a scope level),
2497 including recursive output of contained blocks.
2499 BLOCK is the BLOCK node.
2500 DEPTH is its depth within containing symbol blocks.
2501 ARGS is usually zero; but for the outermost block of the
2502 body of a function, it is a chain of PARM_DECLs for the function parameters.
2503 We output definitions of all the register parms
2504 as if they were local variables of that block.
2506 If -g1 was used, we count blocks just the same, but output nothing
2507 except for the outermost block.
2509 Actually, BLOCK may be several blocks chained together.
2510 We handle them all in sequence. */
2513 dbxout_block (block, depth, args)
2514 register tree block;
2522 /* Ignore blocks never expanded or otherwise marked as real. */
2523 if (TREE_USED (block))
2525 #ifndef DBX_LBRAC_FIRST
2526 /* In dbx format, the syms of a block come before the N_LBRAC. */
2527 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2528 dbxout_syms (BLOCK_VARS (block));
2530 dbxout_reg_parms (args);
2533 /* Now output an N_LBRAC symbol to represent the beginning of
2534 the block. Use the block's tree-walk order to generate
2535 the assembler symbols LBBn and LBEn
2536 that final will define around the code in this block. */
2537 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2540 blocknum = next_block_number++;
2541 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
2543 if (BLOCK_HANDLER_BLOCK (block))
2545 /* A catch block. Must precede N_LBRAC. */
2546 tree decl = BLOCK_VARS (block);
2549 #ifdef DBX_OUTPUT_CATCH
2550 DBX_OUTPUT_CATCH (asmfile, decl, buf);
2552 fprintf (asmfile, "%s \"%s:C1\",%d,0,0,", ASM_STABS_OP,
2553 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
2554 assemble_name (asmfile, buf);
2555 fprintf (asmfile, "\n");
2557 decl = TREE_CHAIN (decl);
2561 #ifdef DBX_OUTPUT_LBRAC
2562 DBX_OUTPUT_LBRAC (asmfile, buf);
2564 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);
2565 assemble_name (asmfile, buf);
2566 #if DBX_BLOCKS_FUNCTION_RELATIVE
2567 fputc ('-', asmfile);
2568 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2570 fprintf (asmfile, "\n");
2574 /* Count blocks the same way regardless of debug_info_level. */
2575 next_block_number++;
2577 #ifdef DBX_LBRAC_FIRST
2578 /* On some weird machines, the syms of a block
2579 come after the N_LBRAC. */
2580 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2581 dbxout_syms (BLOCK_VARS (block));
2583 dbxout_reg_parms (args);
2586 /* Output the subblocks. */
2587 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
2589 /* Refer to the marker for the end of the block. */
2590 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2593 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
2594 #ifdef DBX_OUTPUT_RBRAC
2595 DBX_OUTPUT_RBRAC (asmfile, buf);
2597 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);
2598 assemble_name (asmfile, buf);
2599 #if DBX_BLOCKS_FUNCTION_RELATIVE
2600 fputc ('-', asmfile);
2601 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2603 fprintf (asmfile, "\n");
2607 block = BLOCK_CHAIN (block);
2611 /* Output the information about a function and its arguments and result.
2612 Usually this follows the function's code,
2613 but on some systems, it comes before. */
2616 dbxout_really_begin_function (decl)
2619 dbxout_symbol (decl, 0);
2620 dbxout_parms (DECL_ARGUMENTS (decl));
2621 if (DECL_NAME (DECL_RESULT (decl)) != 0)
2622 dbxout_symbol (DECL_RESULT (decl), 1);
2625 /* Called at beginning of output of function definition. */
2628 dbxout_begin_function (decl)
2631 #ifdef DBX_FUNCTION_FIRST
2632 dbxout_really_begin_function (decl);
2636 /* Output dbx data for a function definition.
2637 This includes a definition of the function name itself (a symbol),
2638 definitions of the parameters (locating them in the parameter list)
2639 and then output the block that makes up the function's body
2640 (including all the auto variables of the function). */
2643 dbxout_function (decl)
2646 #ifndef DBX_FUNCTION_FIRST
2647 dbxout_really_begin_function (decl);
2649 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
2650 #ifdef DBX_OUTPUT_FUNCTION_END
2651 DBX_OUTPUT_FUNCTION_END (asmfile, decl);
2654 #endif /* DBX_DEBUGGING_INFO */