1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987, 88, 92-97, 1998 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. */
21 /* $FreeBSD: src/contrib/gcc/dbxout.c,v 1.4.2.1 2003/05/07 16:47:53 obrien Exp $ */
22 /* $DragonFly: src/contrib/gcc/Attic/dbxout.c,v 1.2 2003/06/17 04:23:59 dillon Exp $ */
25 /* Output dbx-format symbol table data.
26 This consists of many symbol table entries, each of them
27 a .stabs assembler pseudo-op with four operands:
28 a "name" which is really a description of one symbol and its type,
29 a "code", which is a symbol defined in stab.h whose name starts with N_,
30 an unused operand always 0,
31 and a "value" which is an address or an offset.
32 The name is enclosed in doublequote characters.
34 Each function, variable, typedef, and structure tag
35 has a symbol table entry to define it.
36 The beginning and end of each level of name scoping within
37 a function are also marked by special symbol table entries.
39 The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
40 and a data type number. The data type number may be followed by
41 "=" and a type definition; normally this will happen the first time
42 the type number is mentioned. The type definition may refer to
43 other types by number, and those type numbers may be followed
44 by "=" and nested definitions.
46 This can make the "name" quite long.
47 When a name is more than 80 characters, we split the .stabs pseudo-op
48 into two .stabs pseudo-ops, both sharing the same "code" and "value".
49 The first one is marked as continued with a double-backslash at the
52 The kind-of-symbol letter distinguished function names from global
53 variables from file-scope variables from parameters from auto
54 variables in memory from typedef names from register variables.
57 The "code" is mostly redundant with the kind-of-symbol letter
58 that goes in the "name", but not entirely: for symbols located
59 in static storage, the "code" says which segment the address is in,
60 which controls how it is relocated.
62 The "value" for a symbol in static storage
63 is the core address of the symbol (actually, the assembler
64 label for the symbol). For a symbol located in a stack slot
65 it is the stack offset; for one in a register, the register number.
66 For a typedef symbol, it is zero.
68 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
69 output while in the text section.
71 For more on data type definitions, see `dbxout_type'. */
80 #include "insn-config.h"
83 #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 /* This is used for parameters passed by invisible reference in a register. */
116 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
117 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
120 #ifndef DBX_MEMPARM_STABS_LETTER
121 #define DBX_MEMPARM_STABS_LETTER 'p'
124 #ifndef FILE_NAME_JOINER
125 #define FILE_NAME_JOINER "/"
128 /* Nonzero means if the type has methods, only output debugging
129 information if methods are actually written to the asm file. This
130 optimization only works if the debugger can detect the special C++
133 #define MINIMAL_DEBUG 1
135 #ifdef NO_DOLLAR_IN_LABEL
136 #ifdef NO_DOT_IN_LABEL
138 #define MINIMAL_DEBUG 0
144 /* Typical USG systems don't have stab.h, and they also have
145 no use for DBX-format debugging info. */
147 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
149 static int flag_minimal_debug = MINIMAL_DEBUG;
151 /* Nonzero if we have actually used any of the GDB extensions
152 to the debugging format. The idea is that we use them for the
153 first time only if there's a strong reason, but once we have done that,
154 we use them whenever convenient. */
156 static int have_used_extensions = 0;
158 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
159 for the N_SO filename stabs label. */
161 static int source_label_number = 1;
163 #ifdef DEBUG_SYMS_TEXT
164 #define FORCE_TEXT text_section ();
169 /* If there is a system stab.h, use it. Otherwise, use our own. */
170 /* ??? This is supposed to describe the target's stab format, so using
171 the host HAVE_STAB_H appears to be wrong. For now, we use our own file
172 when cross compiling. */
173 #if defined (USG) || !defined (HAVE_STAB_H) || defined (CROSS_COMPILE)
174 #include "gstab.h" /* If doing DBX on sysV, use our own stab.h. */
178 /* This is a GNU extension we need to reference in this file. */
185 #define STAB_CODE_TYPE enum __stab_debug_code
187 #define STAB_CODE_TYPE int
190 /* 1 if PARM is passed to this function in memory. */
192 #define PARM_PASSED_IN_MEMORY(PARM) \
193 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
195 /* A C expression for the integer offset value of an automatic variable
196 (N_LSYM) having address X (an RTX). */
197 #ifndef DEBUGGER_AUTO_OFFSET
198 #define DEBUGGER_AUTO_OFFSET(X) \
199 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
202 /* A C expression for the integer offset value of an argument (N_PSYM)
203 having address X (an RTX). The nominal offset is OFFSET. */
204 #ifndef DEBUGGER_ARG_OFFSET
205 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
208 /* Stream for writing to assembler file. */
210 static FILE *asmfile;
212 /* Last source file name mentioned in a NOTE insn. */
214 static char *lastfile;
216 /* Current working directory. */
220 enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
222 /* Structure recording information about a C data type.
223 The status element says whether we have yet output
224 the definition of the type. TYPE_XREF says we have
225 output it as a cross-reference only.
226 The file_number and type_number elements are used if DBX_USE_BINCL
231 enum typestatus status;
238 /* Vector recording information about C data types.
239 When we first notice a data type (a tree node),
240 we assign it a number using next_type_number.
241 That is its index in this vector. */
243 struct typeinfo *typevec;
245 /* Number of elements of space allocated in `typevec'. */
247 static int typevec_len;
249 /* In dbx output, each type gets a unique number.
250 This is the number for the next type output.
251 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
253 static int next_type_number;
257 /* When using N_BINCL in dbx output, each type number is actually a
258 pair of the file number and the type number within the file.
259 This is a stack of input files. */
263 struct dbx_file *next;
265 int next_type_number;
268 /* This is the top of the stack. */
270 static struct dbx_file *current_file;
272 /* This is the next file number to use. */
274 static int next_file_number;
276 #endif /* DBX_USE_BINCL */
278 /* In dbx output, we must assign symbol-blocks id numbers
279 in the order in which their beginnings are encountered.
280 We output debugging info that refers to the beginning and
281 end of the ranges of code in each block
282 with assembler labels LBBn and LBEn, where n is the block number.
283 The labels are generated in final, which assigns numbers to the
284 blocks in the same way. */
286 static int next_block_number;
288 /* These variables are for dbxout_symbol to communicate to
289 dbxout_finish_symbol.
290 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
291 current_sym_value and current_sym_addr are two ways to address the
292 value to store in the symtab entry.
293 current_sym_addr if nonzero represents the value as an rtx.
294 If that is zero, current_sym_value is used. This is used
295 when the value is an offset (such as for auto variables,
296 register variables and parms). */
298 static STAB_CODE_TYPE current_sym_code;
299 static int current_sym_value;
300 static rtx current_sym_addr;
302 /* Number of chars of symbol-description generated so far for the
303 current symbol. Used by CHARS and CONTIN. */
305 static int current_sym_nchars;
307 /* Report having output N chars of the current symbol-description. */
309 #define CHARS(N) (current_sym_nchars += (N))
311 /* Break the current symbol-description, generating a continuation,
312 if it has become long. */
314 #ifndef DBX_CONTIN_LENGTH
315 #define DBX_CONTIN_LENGTH 80
318 #if DBX_CONTIN_LENGTH > 0
320 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
325 void dbxout_types ();
327 void dbxout_symbol ();
329 #if defined(ASM_OUTPUT_SECTION_NAME)
330 static void dbxout_function_end PROTO((void));
332 static void dbxout_typedefs PROTO((tree));
333 static void dbxout_type_index PROTO((tree));
334 #if DBX_CONTIN_LENGTH > 0
335 static void dbxout_continue PROTO((void));
337 static void dbxout_type_fields PROTO((tree));
338 static void dbxout_type_method_1 PROTO((tree, char *));
339 static void dbxout_type_methods PROTO((tree));
340 static void dbxout_range_type PROTO((tree));
341 static void dbxout_type PROTO((tree, int, int));
342 static void print_int_cst_octal PROTO((tree));
343 static void print_octal PROTO((unsigned HOST_WIDE_INT, int));
344 static void dbxout_type_name PROTO((tree));
345 static void dbxout_symbol_location PROTO((tree, tree, char *, rtx));
346 static void dbxout_symbol_name PROTO((tree, char *, int));
347 static void dbxout_prepare_symbol PROTO((tree));
348 static void dbxout_finish_symbol PROTO((tree));
349 static void dbxout_block PROTO((tree, int, tree));
350 static void dbxout_really_begin_function PROTO((tree));
352 #if defined(ASM_OUTPUT_SECTION_NAME)
354 dbxout_function_end ()
356 static int scope_labelno = 0;
357 char lscope_label_name[100];
358 /* Convert Ltext into the appropriate format for local labels in case
359 the system doesn't insert underscores in front of user generated
361 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
362 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Lscope", scope_labelno);
365 /* By convention, GCC will mark the end of a function with an N_FUN
366 symbol and an empty string. */
367 fprintf (asmfile, "%s \"\",%d,0,0,", ASM_STABS_OP, N_FUN);
368 assemble_name (asmfile, lscope_label_name);
369 fputc ('-', asmfile);
370 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
371 fprintf (asmfile, "\n");
373 #endif /* ! NO_DBX_FUNCTION_END */
375 /* At the beginning of compilation, start writing the symbol table.
376 Initialize `typevec' and output the standard data types of C. */
379 dbxout_init (asm_file, input_file_name, syms)
381 char *input_file_name;
384 char ltext_label_name[100];
389 typevec = (struct typeinfo *) xmalloc (typevec_len * sizeof typevec[0]);
390 bzero ((char *) typevec, typevec_len * sizeof typevec[0]);
392 /* Convert Ltext into the appropriate format for local labels in case
393 the system doesn't insert underscores in front of user generated
395 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
397 /* Put the current working directory in an N_SO symbol. */
398 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
399 but GDB always does. */
400 if (use_gnu_debug_info_extensions)
403 if (!cwd && (cwd = getpwd ()) && (!*cwd || cwd[strlen (cwd) - 1] != '/'))
405 char *wdslash = xmalloc (strlen (cwd) + sizeof (FILE_NAME_JOINER));
406 sprintf (wdslash, "%s%s", cwd, FILE_NAME_JOINER);
411 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
412 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
413 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
414 fprintf (asmfile, "%s ", ASM_STABS_OP);
415 output_quoted_string (asmfile, cwd);
416 fprintf (asmfile, ",%d,0,0,%s\n", N_SO, <ext_label_name[1]);
417 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
421 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
422 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
423 would give us an N_SOL, and we want an N_SO. */
424 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
425 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
426 /* We include outputting `Ltext:' here,
427 because that gives you a way to override it. */
428 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
429 fprintf (asmfile, "%s ", ASM_STABS_OP);
430 output_quoted_string (asmfile, input_file_name);
431 fprintf (asmfile, ",%d,0,0,%s\n",
432 N_SO, <ext_label_name[1]);
434 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Ltext", 0);
435 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
437 /* Possibly output something to inform GDB that this compilation was by
438 GCC. It's easier for GDB to parse it when after the N_SO's. This
439 is used in Solaris 2. */
440 #ifdef ASM_IDENTIFY_GCC_AFTER_SOURCE
441 ASM_IDENTIFY_GCC_AFTER_SOURCE (asmfile);
444 lastfile = input_file_name;
446 next_type_number = 1;
447 next_block_number = 2;
450 current_file = (struct dbx_file *) xmalloc (sizeof *current_file);
451 current_file->next = NULL;
452 current_file->file_number = 0;
453 current_file->next_type_number = 1;
454 next_file_number = 1;
457 /* Make sure that types `int' and `char' have numbers 1 and 2.
458 Definitions of other integer types will refer to those numbers.
459 (Actually it should no longer matter what their numbers are.
460 Also, if any types with tags have been defined, dbxout_symbol
461 will output them first, so the numbers won't be 1 and 2. That
462 happens in C++. So it's a good thing it should no longer matter). */
464 #ifdef DBX_OUTPUT_STANDARD_TYPES
465 DBX_OUTPUT_STANDARD_TYPES (syms);
467 dbxout_symbol (TYPE_NAME (integer_type_node), 0);
468 dbxout_symbol (TYPE_NAME (char_type_node), 0);
471 /* Get all permanent types that have typedef names,
472 and output them all, except for those already output. */
474 dbxout_typedefs (syms);
477 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
478 in the reverse order from that which is found in SYMS. */
481 dbxout_typedefs (syms)
486 dbxout_typedefs (TREE_CHAIN (syms));
487 if (TREE_CODE (syms) == TYPE_DECL)
489 tree type = TREE_TYPE (syms);
491 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
492 && TYPE_SIZE (type) != NULL_TREE
493 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
494 dbxout_symbol (TYPE_NAME (type), 0);
499 /* Change to reading from a new source file. Generate a N_BINCL stab. */
502 dbxout_start_new_source_file (filename)
503 char *filename ATTRIBUTE_UNUSED;
506 struct dbx_file *n = (struct dbx_file *) xmalloc (sizeof *n);
508 n->next = current_file;
509 n->file_number = next_file_number++;
510 n->next_type_number = 1;
512 fprintf (asmfile, "%s ", ASM_STABS_OP);
513 output_quoted_string (asmfile, filename);
514 fprintf (asmfile, ",%d,0,0,0\n", N_BINCL);
518 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
521 dbxout_resume_previous_source_file ()
524 struct dbx_file *next;
526 fprintf (asmfile, "%s %d,0,0,0\n", ASM_STABN_OP, N_EINCL);
527 next = current_file->next;
533 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
536 dbxout_source_file (file, filename)
540 char ltext_label_name[100];
542 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
544 #ifdef DBX_OUTPUT_SOURCE_FILENAME
545 DBX_OUTPUT_SOURCE_FILENAME (file, filename);
547 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
548 source_label_number);
549 fprintf (file, "%s ", ASM_STABS_OP);
550 output_quoted_string (file, filename);
551 fprintf (file, ",%d,0,0,%s\n", N_SOL, <ext_label_name[1]);
552 if (current_function_decl != NULL_TREE
553 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
554 ; /* Don't change section amid function. */
557 ASM_OUTPUT_INTERNAL_LABEL (file, "Ltext", source_label_number);
558 source_label_number++;
564 /* Output a line number symbol entry into output stream FILE,
565 for source file FILENAME and line number LINENO. */
568 dbxout_source_line (file, filename, lineno)
573 dbxout_source_file (file, filename);
575 #ifdef ASM_OUTPUT_SOURCE_LINE
576 ASM_OUTPUT_SOURCE_LINE (file, lineno);
578 fprintf (file, "\t%s %d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
582 /* At the end of compilation, finish writing the symbol table.
583 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
587 dbxout_finish (file, filename)
588 FILE *file ATTRIBUTE_UNUSED;
589 char *filename ATTRIBUTE_UNUSED;
591 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
592 DBX_OUTPUT_MAIN_SOURCE_FILE_END (file, filename);
593 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
596 /* Output the index of a type. */
599 dbxout_type_index (type)
602 #ifndef DBX_USE_BINCL
603 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
606 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
607 fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number);
612 #if DBX_CONTIN_LENGTH > 0
613 /* Continue a symbol-description that gets too big.
614 End one symbol table entry with a double-backslash
615 and start a new one, eventually producing something like
616 .stabs "start......\\",code,0,value
617 .stabs "...rest",code,0,value */
622 #ifdef DBX_CONTIN_CHAR
623 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
625 fprintf (asmfile, "\\\\");
627 dbxout_finish_symbol (NULL_TREE);
628 fprintf (asmfile, "%s \"", ASM_STABS_OP);
629 current_sym_nchars = 0;
631 #endif /* DBX_CONTIN_LENGTH > 0 */
633 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
634 This must be a separate function because anonymous unions require
638 dbxout_type_fields (type)
642 /* Output the name, type, position (in bits), size (in bits) of each
644 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
646 /* Omit here local type decls until we know how to support them. */
647 if (TREE_CODE (tem) == TYPE_DECL)
649 /* Omit fields whose position or size are variable. */
650 else if (TREE_CODE (tem) == FIELD_DECL
651 && (TREE_CODE (DECL_FIELD_BITPOS (tem)) != INTEGER_CST
652 || TREE_CODE (DECL_SIZE (tem)) != INTEGER_CST))
654 /* Omit here the nameless fields that are used to skip bits. */
655 else if (DECL_IGNORED_P (tem))
657 else if (TREE_CODE (tem) != CONST_DECL)
659 /* Continue the line if necessary,
660 but not before the first field. */
661 if (tem != TYPE_FIELDS (type))
666 if (use_gnu_debug_info_extensions
667 && flag_minimal_debug
668 && TREE_CODE (tem) == FIELD_DECL
669 && DECL_VIRTUAL_P (tem)
670 && DECL_ASSEMBLER_NAME (tem))
672 have_used_extensions = 1;
673 CHARS (3 + IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (tem)));
674 fputs (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem)), asmfile);
675 dbxout_type (DECL_FCONTEXT (tem), 0, 0);
676 fprintf (asmfile, ":");
677 dbxout_type (TREE_TYPE (tem), 0, 0);
678 fputc (',', asmfile);
679 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
680 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)));
681 fputc (';', asmfile);
687 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
688 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
692 fprintf (asmfile, ":");
696 if (use_gnu_debug_info_extensions
697 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
698 || TREE_CODE (tem) != FIELD_DECL))
700 have_used_extensions = 1;
702 putc ((TREE_PRIVATE (tem) ? '0'
703 : TREE_PROTECTED (tem) ? '1' : '2'),
708 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
709 && DECL_BIT_FIELD_TYPE (tem))
710 ? DECL_BIT_FIELD_TYPE (tem)
711 : TREE_TYPE (tem), 0, 0);
713 if (TREE_CODE (tem) == VAR_DECL)
715 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
717 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem));
718 have_used_extensions = 1;
719 fprintf (asmfile, ":%s;", name);
720 CHARS (strlen (name));
724 /* If TEM is non-static, GDB won't understand it. */
725 fprintf (asmfile, ",0,0;");
728 else if (TREE_CODE (DECL_FIELD_BITPOS (tem)) == INTEGER_CST)
730 fputc (',', asmfile);
731 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
732 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)));
733 fputc (',', asmfile);
734 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
735 TREE_INT_CST_LOW (DECL_SIZE (tem)));
736 fputc (';', asmfile);
743 /* Subroutine of `dbxout_type_methods'. Output debug info about the
744 method described DECL. DEBUG_NAME is an encoding of the method's
745 type signature. ??? We may be able to do without DEBUG_NAME altogether
749 dbxout_type_method_1 (decl, debug_name)
755 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
757 else /* it's a METHOD_TYPE. */
759 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
760 /* A for normal functions.
761 B for `const' member functions.
762 C for `volatile' member functions.
763 D for `const volatile' member functions. */
764 if (TYPE_READONLY (TREE_TYPE (firstarg)))
766 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
769 if (DECL_VINDEX (decl))
775 fprintf (asmfile, ":%s;%c%c%c", debug_name,
776 TREE_PRIVATE (decl) ? '0' : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
777 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
778 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
779 if (DECL_VINDEX (decl))
781 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
782 TREE_INT_CST_LOW (DECL_VINDEX (decl)));
783 fputc (';', asmfile);
784 dbxout_type (DECL_CONTEXT (decl), 0, 0);
785 fprintf (asmfile, ";");
790 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
794 dbxout_type_methods (type)
797 /* C++: put out the method names and their parameter lists */
798 tree methods = TYPE_METHODS (type);
800 register tree fndecl;
802 char formatted_type_identifier_length[16];
803 register int type_identifier_length;
805 if (methods == NULL_TREE)
808 type_encoding = DECL_NAME (TYPE_NAME (type));
811 /* C++: Template classes break some assumptions made by this code about
812 the class names, constructor names, and encodings for assembler
813 label names. For now, disable output of dbx info for them. */
815 char *ptr = IDENTIFIER_POINTER (type_encoding);
816 /* This should use index. (mrs) */
817 while (*ptr && *ptr != '<') ptr++;
828 type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
830 sprintf(formatted_type_identifier_length, "%d", type_identifier_length);
832 if (TREE_CODE (methods) != TREE_VEC)
834 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
835 fndecl = TREE_VEC_ELT (methods, 0);
837 fndecl = TREE_VEC_ELT (methods, 1);
841 tree name = DECL_NAME (fndecl);
844 /* Group together all the methods for the same operation.
845 These differ in the types of the arguments. */
846 for (last = NULL_TREE;
847 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
848 fndecl = TREE_CHAIN (fndecl))
849 /* Output the name of the field (after overloading), as
850 well as the name of the field before overloading, along
851 with its parameter list */
853 /* This is the "mangled" name of the method.
854 It encodes the argument types. */
855 char *debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
856 int show_arg_types = 0;
862 if (DECL_IGNORED_P (fndecl))
865 if (flag_minimal_debug)
869 /* We can't optimize a method which uses an anonymous
870 class, because the debugger will not be able to
871 associate the arbitrary class name with the actual
873 #ifndef NO_DOLLAR_IN_LABEL
878 if (strchr (debug_name, marker))
880 /* Detect ordinary methods because their mangled names
881 start with the operation name. */
882 else if (!strncmp (IDENTIFIER_POINTER (name), debug_name,
883 IDENTIFIER_LENGTH (name)))
885 debug_name += IDENTIFIER_LENGTH (name);
886 if (debug_name[0] == '_' && debug_name[1] == '_')
888 char *method_name = debug_name + 2;
889 char *length_ptr = formatted_type_identifier_length;
890 /* Get past const and volatile qualifiers. */
891 while (*method_name == 'C' || *method_name == 'V')
893 /* Skip digits for length of type_encoding. */
894 while (*method_name == *length_ptr && *length_ptr)
895 length_ptr++, method_name++;
896 if (! strncmp (method_name,
897 IDENTIFIER_POINTER (type_encoding),
898 type_identifier_length))
899 method_name += type_identifier_length;
900 debug_name = method_name;
903 /* Detect constructors by their style of name mangling. */
904 else if (debug_name[0] == '_' && debug_name[1] == '_')
906 char *ctor_name = debug_name + 2;
907 char *length_ptr = formatted_type_identifier_length;
908 while (*ctor_name == 'C' || *ctor_name == 'V')
910 /* Skip digits for length of type_encoding. */
911 while (*ctor_name == *length_ptr && *length_ptr)
912 length_ptr++, ctor_name++;
913 if (!strncmp (IDENTIFIER_POINTER (type_encoding), ctor_name,
914 type_identifier_length))
915 debug_name = ctor_name + type_identifier_length;
917 /* The other alternative is a destructor. */
921 /* Output the operation name just once, for the first method
925 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
926 CHARS (IDENTIFIER_LENGTH (name) + 2);
931 dbxout_type (TREE_TYPE (fndecl), 0, show_arg_types);
933 dbxout_type_method_1 (fndecl, debug_name);
943 /* Emit a "range" type specification, which has the form:
944 "r<index type>;<lower bound>;<upper bound>;".
945 TYPE is an INTEGER_TYPE. */
948 dbxout_range_type (type)
951 fprintf (asmfile, "r");
952 if (TREE_TYPE (type))
953 dbxout_type (TREE_TYPE (type), 0, 0);
954 else if (TREE_CODE (type) != INTEGER_TYPE)
955 dbxout_type (type, 0, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
958 /* Traditionally, we made sure 'int' was type 1, and builtin types
959 were defined to be sub-ranges of int. Unfortunately, this
960 does not allow us to distinguish true sub-ranges from integer
961 types. So, instead we define integer (non-sub-range) types as
962 sub-ranges of themselves. This matters for Chill. If this isn't
963 a subrange type, then we want to define it in terms of itself.
964 However, in C, this may be an anonymous integer type, and we don't
965 want to emit debug info referring to it. Just calling
966 dbxout_type_index won't work anyways, because the type hasn't been
967 defined yet. We make this work for both cases by checked to see
968 whether this is a defined type, referring to it if it is, and using
970 if (TYPE_SYMTAB_ADDRESS (type) != 0)
971 dbxout_type_index (type);
973 dbxout_type_index (integer_type_node);
975 if (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST)
977 fputc (';', asmfile);
978 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
979 TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)));
982 fprintf (asmfile, ";0");
983 if (TYPE_MAX_VALUE (type)
984 && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST)
986 fputc (';', asmfile);
987 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
988 TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)));
989 fputc (';', asmfile);
992 fprintf (asmfile, ";-1;");
995 /* Output a reference to a type. If the type has not yet been
996 described in the dbx output, output its definition now.
997 For a type already defined, just refer to its definition
998 using the type number.
1000 If FULL is nonzero, and the type has been described only with
1001 a forward-reference, output the definition now.
1002 If FULL is zero in this case, just refer to the forward-reference
1003 using the number previously allocated.
1005 If SHOW_ARG_TYPES is nonzero, we output a description of the argument
1006 types for a METHOD_TYPE. */
1009 dbxout_type (type, full, show_arg_types)
1015 static int anonymous_type_number = 0;
1017 /* If there was an input error and we don't really have a type,
1018 avoid crashing and write something that is at least valid
1019 by assuming `int'. */
1020 if (type == error_mark_node)
1021 type = integer_type_node;
1024 /* Try to find the "main variant" with the same name but not const
1025 or volatile. (Since stabs does not distinguish const and volatile,
1026 there is no need to make them separate types. But types with
1027 different names are usefully distinguished.) */
1029 for (tem = TYPE_MAIN_VARIANT (type); tem; tem = TYPE_NEXT_VARIANT (tem))
1030 if (!TYPE_READONLY (tem) && !TYPE_VOLATILE (tem)
1031 && TYPE_NAME (tem) == TYPE_NAME (type))
1036 if (TYPE_NAME (type)
1037 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1038 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1042 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1044 /* Type has no dbx number assigned. Assign next available number. */
1045 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1047 /* Make sure type vector is long enough to record about this type. */
1049 if (next_type_number == typevec_len)
1052 = (struct typeinfo *) xrealloc (typevec,
1053 typevec_len * 2 * sizeof typevec[0]);
1054 bzero ((char *) (typevec + typevec_len),
1055 typevec_len * sizeof typevec[0]);
1059 #ifdef DBX_USE_BINCL
1060 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1061 = current_file->file_number;
1062 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1063 = current_file->next_type_number++;
1067 /* Output the number of this type, to refer to it. */
1068 dbxout_type_index (type);
1070 #ifdef DBX_TYPE_DEFINED
1071 if (DBX_TYPE_DEFINED (type))
1075 /* If this type's definition has been output or is now being output,
1078 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1083 /* If we have already had a cross reference,
1084 and either that's all we want or that's the best we could do,
1085 don't repeat the cross reference.
1086 Sun dbx crashes if we do. */
1087 if (! full || TYPE_SIZE (type) == 0
1088 /* No way in DBX fmt to describe a variable size. */
1089 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1097 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1098 leave the type-number completely undefined rather than output
1099 a cross-reference. If we have already used GNU debug info extensions,
1100 then it is OK to output a cross reference. This is necessary to get
1101 proper C++ debug output. */
1102 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1103 || TREE_CODE (type) == QUAL_UNION_TYPE
1104 || TREE_CODE (type) == ENUMERAL_TYPE)
1105 && ! use_gnu_debug_info_extensions)
1106 /* We must use the same test here as we use twice below when deciding
1107 whether to emit a cross-reference. */
1108 if ((TYPE_NAME (type) != 0
1109 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1110 && DECL_IGNORED_P (TYPE_NAME (type)))
1112 || TYPE_SIZE (type) == 0
1113 /* No way in DBX fmt to describe a variable size. */
1114 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1116 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1121 /* Output a definition now. */
1123 fprintf (asmfile, "=");
1126 /* Mark it as defined, so that if it is self-referent
1127 we will not get into an infinite recursion of definitions. */
1129 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1131 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1132 && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1134 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0, 0);
1138 switch (TREE_CODE (type))
1142 /* For a void type, just define it as itself; ie, "5=5".
1143 This makes us consider it defined
1144 without saying what it is. The debugger will make it
1145 a void type when the reference is seen, and nothing will
1146 ever override that default. */
1147 dbxout_type_index (type);
1151 if (type == char_type_node && ! TREE_UNSIGNED (type))
1153 /* Output the type `char' as a subrange of itself!
1154 I don't understand this definition, just copied it
1155 from the output of pcc.
1156 This used to use `r2' explicitly and we used to
1157 take care to make sure that `char' was type number 2. */
1158 fprintf (asmfile, "r");
1159 dbxout_type_index (type);
1160 fprintf (asmfile, ";0;127;");
1162 /* This used to check if the type's precision was more than
1163 HOST_BITS_PER_WIDE_INT. That is wrong since gdb uses a
1164 long (it has no concept of HOST_BITS_PER_WIDE_INT). */
1165 else if (use_gnu_debug_info_extensions
1166 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1167 || TYPE_PRECISION (type) >= HOST_BITS_PER_LONG))
1169 /* This used to say `r1' and we used to take care
1170 to make sure that `int' was type number 1. */
1171 fprintf (asmfile, "r");
1172 dbxout_type_index (integer_type_node);
1173 fprintf (asmfile, ";");
1174 print_int_cst_octal (TYPE_MIN_VALUE (type));
1175 fprintf (asmfile, ";");
1176 print_int_cst_octal (TYPE_MAX_VALUE (type));
1177 fprintf (asmfile, ";");
1179 else /* Output other integer types as subranges of `int'. */
1180 dbxout_range_type (type);
1185 /* This used to say `r1' and we used to take care
1186 to make sure that `int' was type number 1. */
1187 fprintf (asmfile, "r");
1188 dbxout_type_index (integer_type_node);
1189 fputc (';', asmfile);
1190 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, int_size_in_bytes (type));
1191 fputs (";0;", asmfile);
1196 if (use_gnu_debug_info_extensions)
1198 fputs ("@s", asmfile);
1199 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1200 BITS_PER_UNIT * int_size_in_bytes (type));
1201 fputs (";-20;", asmfile);
1205 /* Output the type `char' as a subrange of itself.
1206 That is what pcc seems to do. */
1207 fprintf (asmfile, "r");
1208 dbxout_type_index (char_type_node);
1209 fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1215 if (use_gnu_debug_info_extensions)
1217 fputs ("@s", asmfile);
1218 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1219 BITS_PER_UNIT * int_size_in_bytes (type));
1220 fputs (";-16;", asmfile);
1222 else /* Define as enumeral type (False, True) */
1223 fprintf (asmfile, "eFalse:0,True:1,;");
1228 putc ('d', asmfile);
1230 dbxout_type (TREE_TYPE (type), 0, 0);
1234 /* Differs from the REAL_TYPE by its new data type number */
1236 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1238 fprintf (asmfile, "r");
1239 dbxout_type_index (type);
1240 fputc (';', asmfile);
1241 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1242 int_size_in_bytes (TREE_TYPE (type)));
1243 fputs (";0;", asmfile);
1244 CHARS (12); /* The number is probably incorrect here. */
1248 /* Output a complex integer type as a structure,
1249 pending some other way to do it. */
1250 fputc ('s', asmfile);
1251 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, int_size_in_bytes (type));
1253 fprintf (asmfile, "real:");
1255 dbxout_type (TREE_TYPE (type), 0, 0);
1256 fprintf (asmfile, ",%d,%d;",
1257 0, TYPE_PRECISION (TREE_TYPE (type)));
1259 fprintf (asmfile, "imag:");
1261 dbxout_type (TREE_TYPE (type), 0, 0);
1262 fprintf (asmfile, ",%d,%d;;",
1263 TYPE_PRECISION (TREE_TYPE (type)),
1264 TYPE_PRECISION (TREE_TYPE (type)));
1270 if (use_gnu_debug_info_extensions)
1272 have_used_extensions = 1;
1273 fputs ("@s", asmfile);
1274 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1275 BITS_PER_UNIT * int_size_in_bytes (type));
1276 fputc (';', asmfile);
1277 /* Check if a bitstring type, which in Chill is
1278 different from a [power]set. */
1279 if (TYPE_STRING_FLAG (type))
1280 fprintf (asmfile, "@S;");
1282 putc ('S', asmfile);
1284 dbxout_type (TYPE_DOMAIN (type), 0, 0);
1288 /* Make arrays of packed bits look like bitstrings for chill. */
1289 if (TYPE_PACKED (type) && use_gnu_debug_info_extensions)
1291 have_used_extensions = 1;
1292 fputs ("@s", asmfile);
1293 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1294 BITS_PER_UNIT * int_size_in_bytes (type));
1295 fputc (';', asmfile);
1296 fprintf (asmfile, "@S;");
1297 putc ('S', asmfile);
1299 dbxout_type (TYPE_DOMAIN (type), 0, 0);
1302 /* Output "a" followed by a range type definition
1303 for the index type of the array
1304 followed by a reference to the target-type.
1305 ar1;0;N;M for a C array of type M and size N+1. */
1306 /* Check if a character string type, which in Chill is
1307 different from an array of characters. */
1308 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1310 have_used_extensions = 1;
1311 fprintf (asmfile, "@S;");
1313 tem = TYPE_DOMAIN (type);
1316 fprintf (asmfile, "ar");
1317 dbxout_type_index (integer_type_node);
1318 fprintf (asmfile, ";0;-1;");
1322 fprintf (asmfile, "a");
1323 dbxout_range_type (tem);
1326 dbxout_type (TREE_TYPE (type), 0, 0);
1331 case QUAL_UNION_TYPE:
1333 int i, n_baseclasses = 0;
1335 if (TYPE_BINFO (type) != 0
1336 && TREE_CODE (TYPE_BINFO (type)) == TREE_VEC
1337 && TYPE_BINFO_BASETYPES (type) != 0)
1338 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1340 /* Output a structure type. We must use the same test here as we
1341 use in the DBX_NO_XREFS case above. */
1342 if ((TYPE_NAME (type) != 0
1343 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1344 && DECL_IGNORED_P (TYPE_NAME (type)))
1346 || TYPE_SIZE (type) == 0
1347 /* No way in DBX fmt to describe a variable size. */
1348 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1350 /* If the type is just a cross reference, output one
1351 and mark the type as partially described.
1352 If it later becomes defined, we will output
1353 its real definition.
1354 If the type has a name, don't nest its definition within
1355 another type's definition; instead, output an xref
1356 and let the definition come when the name is defined. */
1357 fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu");
1359 #if 0 /* This assertion is legitimately false in C++. */
1360 /* We shouldn't be outputting a reference to a type before its
1361 definition unless the type has a tag name.
1362 A typedef name without a tag name should be impossible. */
1363 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1366 if (TYPE_NAME (type) != 0)
1367 dbxout_type_name (type);
1369 fprintf (asmfile, "$$%d", anonymous_type_number++);
1370 fprintf (asmfile, ":");
1371 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1375 /* Identify record or union, and print its size. */
1376 fputc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asmfile);
1377 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1378 int_size_in_bytes (type));
1380 if (use_gnu_debug_info_extensions)
1384 have_used_extensions = 1;
1385 fprintf (asmfile, "!%d,", n_baseclasses);
1389 for (i = 0; i < n_baseclasses; i++)
1391 tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i);
1392 if (use_gnu_debug_info_extensions)
1394 have_used_extensions = 1;
1395 putc (TREE_VIA_VIRTUAL (child) ? '1'
1398 putc (TREE_VIA_PUBLIC (child) ? '2'
1401 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1402 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT);
1403 fputc (',', asmfile);
1405 dbxout_type (BINFO_TYPE (child), 0, 0);
1406 putc (';', asmfile);
1410 /* Print out the base class information with fields
1411 which have the same names at the types they hold. */
1412 dbxout_type_name (BINFO_TYPE (child));
1413 putc (':', asmfile);
1414 dbxout_type (BINFO_TYPE (child), full, 0);
1415 fputc (',', asmfile);
1416 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1417 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT);
1418 fputc (',', asmfile);
1419 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1420 TREE_INT_CST_LOW (DECL_SIZE (TYPE_NAME (BINFO_TYPE (child)))) * BITS_PER_UNIT);
1421 fputc (';', asmfile);
1429 /* Write out the field declarations. */
1430 dbxout_type_fields (type);
1431 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1433 have_used_extensions = 1;
1434 dbxout_type_methods (type);
1436 putc (';', asmfile);
1438 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1439 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1440 && TYPE_VFIELD (type))
1442 have_used_extensions = 1;
1444 /* Tell GDB+ that it may keep reading. */
1445 putc ('~', asmfile);
1447 /* We need to write out info about what field this class
1448 uses as its "main" vtable pointer field, because if this
1449 field is inherited from a base class, GDB cannot necessarily
1450 figure out which field it's using in time. */
1451 if (TYPE_VFIELD (type))
1453 putc ('%', asmfile);
1454 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0, 0);
1456 putc (';', asmfile);
1462 /* We must use the same test here as we use in the DBX_NO_XREFS case
1463 above. We simplify it a bit since an enum will never have a variable
1465 if ((TYPE_NAME (type) != 0
1466 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1467 && DECL_IGNORED_P (TYPE_NAME (type)))
1469 || TYPE_SIZE (type) == 0)
1471 fprintf (asmfile, "xe");
1473 dbxout_type_name (type);
1474 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1475 fprintf (asmfile, ":");
1478 #ifdef DBX_OUTPUT_ENUM
1479 DBX_OUTPUT_ENUM (asmfile, type);
1481 if (use_gnu_debug_info_extensions
1482 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1483 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1484 putc ('e', asmfile);
1486 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1488 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1489 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1490 fprintf (asmfile, HOST_WIDE_INT_PRINT_UNSIGNED,
1491 TREE_INT_CST_LOW (TREE_VALUE (tem)));
1492 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1493 && TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1494 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1495 TREE_INT_CST_LOW (TREE_VALUE (tem)));
1497 print_int_cst_octal (TREE_VALUE (tem));
1498 fprintf (asmfile, ",");
1499 CHARS (20 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem)));
1500 if (TREE_CHAIN (tem) != 0)
1505 putc (';', asmfile);
1511 putc ('*', asmfile);
1513 dbxout_type (TREE_TYPE (type), 0, 0);
1517 if (use_gnu_debug_info_extensions)
1519 have_used_extensions = 1;
1520 putc ('#', asmfile);
1522 if (flag_minimal_debug && !show_arg_types)
1524 /* Normally, just output the return type.
1525 The argument types are encoded in the method name. */
1526 putc ('#', asmfile);
1528 dbxout_type (TREE_TYPE (type), 0, 0);
1529 putc (';', asmfile);
1534 /* When outputting destructors, we need to write
1535 the argument types out longhand. */
1536 dbxout_type (TYPE_METHOD_BASETYPE (type), 0, 0);
1537 putc (',', asmfile);
1539 dbxout_type (TREE_TYPE (type), 0, 0);
1540 dbxout_args (TYPE_ARG_TYPES (type));
1541 putc (';', asmfile);
1547 /* Treat it as a function type. */
1548 dbxout_type (TREE_TYPE (type), 0, 0);
1553 if (use_gnu_debug_info_extensions)
1555 have_used_extensions = 1;
1556 putc ('@', asmfile);
1558 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0, 0);
1559 putc (',', asmfile);
1561 dbxout_type (TREE_TYPE (type), 0, 0);
1565 /* Should print as an int, because it is really
1567 dbxout_type (integer_type_node, 0, 0);
1571 case REFERENCE_TYPE:
1572 if (use_gnu_debug_info_extensions)
1573 have_used_extensions = 1;
1574 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1576 dbxout_type (TREE_TYPE (type), 0, 0);
1580 putc ('f', asmfile);
1582 dbxout_type (TREE_TYPE (type), 0, 0);
1590 /* Print the value of integer constant C, in octal,
1591 handling double precision. */
1594 print_int_cst_octal (c)
1597 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1598 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1599 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1600 int width = TYPE_PRECISION (TREE_TYPE (c));
1602 /* GDB wants constants with no extra leading "1" bits, so
1603 we need to remove any sign-extension that might be
1605 if (width == HOST_BITS_PER_WIDE_INT * 2)
1607 else if (width > HOST_BITS_PER_WIDE_INT)
1608 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1609 else if (width == HOST_BITS_PER_WIDE_INT)
1612 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1614 fprintf (asmfile, "0");
1618 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1619 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1623 unsigned HOST_WIDE_INT beg = high >> excess;
1624 unsigned HOST_WIDE_INT middle
1625 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1626 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1627 unsigned HOST_WIDE_INT end
1628 = low & (((unsigned HOST_WIDE_INT) 1
1629 << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1632 fprintf (asmfile, "%o%01o", (int)beg, (int)middle);
1633 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1638 print_octal (value, digits)
1639 unsigned HOST_WIDE_INT value;
1644 for (i = digits - 1; i >= 0; i--)
1645 fprintf (asmfile, "%01o", (int)((value >> (3 * i)) & 7));
1648 /* Output the name of type TYPE, with no punctuation.
1649 Such names can be set up either by typedef declarations
1650 or by struct, enum and union tags. */
1653 dbxout_type_name (type)
1657 if (TYPE_NAME (type) == 0)
1659 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
1661 t = TYPE_NAME (type);
1663 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1665 t = DECL_NAME (TYPE_NAME (type));
1670 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
1671 CHARS (IDENTIFIER_LENGTH (t));
1674 /* Output a .stabs for the symbol defined by DECL,
1675 which must be a ..._DECL node in the normal namespace.
1676 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1677 LOCAL is nonzero if the scope is less than the entire file. */
1680 dbxout_symbol (decl, local)
1684 tree type = TREE_TYPE (decl);
1685 tree context = NULL_TREE;
1687 /* Cast avoids warning in old compilers. */
1688 current_sym_code = (STAB_CODE_TYPE) 0;
1689 current_sym_value = 0;
1690 current_sym_addr = 0;
1692 /* Ignore nameless syms, but don't ignore type tags. */
1694 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
1695 || DECL_IGNORED_P (decl))
1698 dbxout_prepare_symbol (decl);
1700 /* The output will always start with the symbol name,
1701 so always count that in the length-output-so-far. */
1703 if (DECL_NAME (decl) != 0)
1704 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
1706 switch (TREE_CODE (decl))
1709 /* Enum values are defined by defining the enum type. */
1713 if (DECL_RTL (decl) == 0)
1715 if (DECL_EXTERNAL (decl))
1717 /* Don't mention a nested function under its parent. */
1718 context = decl_function_context (decl);
1719 if (context == current_function_decl)
1721 if (GET_CODE (DECL_RTL (decl)) != MEM
1722 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
1726 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
1727 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1728 TREE_PUBLIC (decl) ? 'F' : 'f');
1730 current_sym_code = N_FUN;
1731 current_sym_addr = XEXP (DECL_RTL (decl), 0);
1733 if (TREE_TYPE (type))
1734 dbxout_type (TREE_TYPE (type), 0, 0);
1736 dbxout_type (void_type_node, 0, 0);
1738 /* For a nested function, when that function is compiled,
1739 mention the containing function name
1740 as well as (since dbx wants it) our own assembler-name. */
1742 fprintf (asmfile, ",%s,%s",
1743 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1744 IDENTIFIER_POINTER (DECL_NAME (context)));
1746 dbxout_finish_symbol (decl);
1751 /* This seems all wrong. Outputting most kinds of types gives no name
1752 at all. A true definition gives no name; a cross-ref for a
1753 structure can give the tag name, but not a type name.
1754 It seems that no typedef name is defined by outputting a type. */
1756 /* If this typedef name was defined by outputting the type,
1757 don't duplicate it. */
1758 if (typevec[TYPE_SYMTAB_ADDRESS (type)].status == TYPE_DEFINED
1759 && TYPE_NAME (TREE_TYPE (decl)) == decl)
1762 /* Don't output the same typedef twice.
1763 And don't output what language-specific stuff doesn't want output. */
1764 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
1773 if (DECL_NAME (decl))
1775 /* Nonzero means we must output a tag as well as a typedef. */
1778 /* Handle the case of a C++ structure or union
1779 where the TYPE_NAME is a TYPE_DECL
1780 which gives both a typedef name and a tag. */
1781 /* dbx requires the tag first and the typedef second. */
1782 if ((TREE_CODE (type) == RECORD_TYPE
1783 || TREE_CODE (type) == UNION_TYPE
1784 || TREE_CODE (type) == QUAL_UNION_TYPE)
1785 && TYPE_NAME (type) == decl
1786 && !(use_gnu_debug_info_extensions && have_used_extensions)
1787 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
1788 /* Distinguish the implicit typedefs of C++
1789 from explicit ones that might be found in C. */
1790 && DECL_ARTIFICIAL (decl))
1792 tree name = TYPE_NAME (type);
1793 if (TREE_CODE (name) == TYPE_DECL)
1794 name = DECL_NAME (name);
1796 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1797 current_sym_value = 0;
1798 current_sym_addr = 0;
1799 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1801 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1802 IDENTIFIER_POINTER (name));
1803 dbxout_type (type, 1, 0);
1804 dbxout_finish_symbol (NULL_TREE);
1807 /* Output typedef name. */
1808 fprintf (asmfile, "%s \"%s:", ASM_STABS_OP,
1809 IDENTIFIER_POINTER (DECL_NAME (decl)));
1811 /* Short cut way to output a tag also. */
1812 if ((TREE_CODE (type) == RECORD_TYPE
1813 || TREE_CODE (type) == UNION_TYPE
1814 || TREE_CODE (type) == QUAL_UNION_TYPE)
1815 && TYPE_NAME (type) == decl
1816 /* Distinguish the implicit typedefs of C++
1817 from explicit ones that might be found in C. */
1818 && DECL_ARTIFICIAL (decl))
1820 if (use_gnu_debug_info_extensions && have_used_extensions)
1822 putc ('T', asmfile);
1823 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
1825 #if 0 /* Now we generate the tag for this case up above. */
1831 putc ('t', asmfile);
1832 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1834 dbxout_type (type, 1, 0);
1835 dbxout_finish_symbol (decl);
1839 /* Don't output a tag if this is an incomplete type (TYPE_SIZE is
1840 zero). This prevents the sun4 Sun OS 4.x dbx from crashing. */
1842 if (tag_needed && TYPE_NAME (type) != 0
1843 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
1844 || (DECL_NAME (TYPE_NAME (type)) != 0))
1845 && TYPE_SIZE (type) != 0
1846 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
1848 /* For a TYPE_DECL with no name, but the type has a name,
1850 This is what represents `struct foo' with no typedef. */
1851 /* In C++, the name of a type is the corresponding typedef.
1852 In C, it is an IDENTIFIER_NODE. */
1853 tree name = TYPE_NAME (type);
1854 if (TREE_CODE (name) == TYPE_DECL)
1855 name = DECL_NAME (name);
1857 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1858 current_sym_value = 0;
1859 current_sym_addr = 0;
1860 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1862 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1863 IDENTIFIER_POINTER (name));
1864 dbxout_type (type, 1, 0);
1865 dbxout_finish_symbol (NULL_TREE);
1869 /* If an enum type has no name, it cannot be referred to,
1870 but we must output it anyway, since the enumeration constants
1871 can be referred to. */
1872 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
1874 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1875 current_sym_value = 0;
1876 current_sym_addr = 0;
1877 current_sym_nchars = 2;
1879 /* Some debuggers fail when given NULL names, so give this a
1880 harmless name of ` '. */
1881 fprintf (asmfile, "%s \" :T", ASM_STABS_OP);
1882 dbxout_type (type, 1, 0);
1883 dbxout_finish_symbol (NULL_TREE);
1886 /* Prevent duplicate output of a typedef. */
1887 TREE_ASM_WRITTEN (decl) = 1;
1892 /* Parm decls go in their own separate chains
1893 and are output by dbxout_reg_parms and dbxout_parms. */
1897 /* Named return value, treat like a VAR_DECL. */
1899 if (DECL_RTL (decl) == 0)
1901 /* Don't mention a variable that is external.
1902 Let the file that defines it describe it. */
1903 if (DECL_EXTERNAL (decl))
1906 /* If the variable is really a constant
1907 and not written in memory, inform the debugger. */
1908 if (TREE_STATIC (decl) && TREE_READONLY (decl)
1909 && DECL_INITIAL (decl) != 0
1910 && ! TREE_ASM_WRITTEN (decl)
1911 && (DECL_FIELD_CONTEXT (decl) == NULL_TREE
1912 || TREE_CODE (DECL_FIELD_CONTEXT (decl)) == BLOCK))
1914 if (TREE_PUBLIC (decl) == 0)
1916 /* The sun4 assembler does not grok this. */
1917 char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
1918 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
1919 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
1921 HOST_WIDE_INT ival = TREE_INT_CST_LOW (DECL_INITIAL (decl));
1922 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
1923 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile, name, ival);
1925 fprintf (asmfile, "%s \"%s:c=i", ASM_STABS_OP, name);
1927 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, ival);
1928 fprintf (asmfile, "\",0x%x,0,0,0\n", N_LSYM);
1932 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
1934 /* don't know how to do this yet. */
1938 /* else it is something we handle like a normal variable. */
1941 DECL_RTL (decl) = eliminate_regs (DECL_RTL (decl), 0, NULL_RTX);
1942 #ifdef LEAF_REG_REMAP
1943 if (current_function_uses_only_leaf_regs)
1944 leaf_renumber_regs_insn (DECL_RTL (decl));
1947 dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
1955 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
1956 Add SUFFIX to its name, if SUFFIX is not 0.
1957 Describe the variable as residing in HOME
1958 (usually HOME is DECL_RTL (DECL), but not always). */
1961 dbxout_symbol_location (decl, type, suffix, home)
1969 /* Don't mention a variable at all
1970 if it was completely optimized into nothingness.
1972 If the decl was from an inline function, then its rtl
1973 is not identically the rtl that was used in this
1974 particular compilation. */
1975 if (GET_CODE (home) == REG)
1977 regno = REGNO (home);
1978 if (regno >= FIRST_PSEUDO_REGISTER)
1981 else if (GET_CODE (home) == SUBREG)
1985 while (GET_CODE (value) == SUBREG)
1987 offset += SUBREG_WORD (value);
1988 value = SUBREG_REG (value);
1990 if (GET_CODE (value) == REG)
1992 regno = REGNO (value);
1993 if (regno >= FIRST_PSEUDO_REGISTER)
1997 alter_subreg (home);
2000 /* The kind-of-variable letter depends on where
2001 the variable is and on the scope of its name:
2002 G and N_GSYM for static storage and global scope,
2003 S for static storage and file scope,
2004 V for static storage and local scope,
2005 for those two, use N_LCSYM if data is in bss segment,
2006 N_STSYM if in data segment, N_FUN otherwise.
2007 (We used N_FUN originally, then changed to N_STSYM
2008 to please GDB. However, it seems that confused ld.
2009 Now GDB has been fixed to like N_FUN, says Kingdon.)
2010 no letter at all, and N_LSYM, for auto variable,
2011 r and N_RSYM for register variable. */
2013 if (GET_CODE (home) == MEM
2014 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
2016 if (TREE_PUBLIC (decl))
2019 current_sym_code = N_GSYM;
2023 current_sym_addr = XEXP (home, 0);
2025 letter = decl_function_context (decl) ? 'V' : 'S';
2027 /* This should be the same condition as in assemble_variable, but
2028 we don't have access to dont_output_data here. So, instead,
2029 we rely on the fact that error_mark_node initializers always
2030 end up in bss for C++ and never end up in bss for C. */
2031 if (DECL_INITIAL (decl) == 0
2032 || (!strcmp (lang_identify (), "cplusplus")
2033 && DECL_INITIAL (decl) == error_mark_node))
2034 current_sym_code = N_LCSYM;
2035 else if (DECL_IN_TEXT_SECTION (decl))
2036 /* This is not quite right, but it's the closest
2037 of all the codes that Unix defines. */
2038 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
2041 /* Ultrix `as' seems to need this. */
2042 #ifdef DBX_STATIC_STAB_DATA_SECTION
2045 current_sym_code = N_STSYM;
2049 else if (regno >= 0)
2052 current_sym_code = N_RSYM;
2053 current_sym_value = DBX_REGISTER_NUMBER (regno);
2055 else if (GET_CODE (home) == MEM
2056 && (GET_CODE (XEXP (home, 0)) == MEM
2057 || (GET_CODE (XEXP (home, 0)) == REG
2058 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
2059 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
2060 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2061 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
2064 /* If the value is indirect by memory or by a register
2065 that isn't the frame pointer
2066 then it means the object is variable-sized and address through
2067 that register or stack slot. DBX has no way to represent this
2068 so all we can do is output the variable as a pointer.
2069 If it's not a parameter, ignore it.
2070 (VAR_DECLs like this can be made by integrate.c.) */
2072 if (GET_CODE (XEXP (home, 0)) == REG)
2075 current_sym_code = N_RSYM;
2076 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2080 current_sym_code = N_LSYM;
2081 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2082 We want the value of that CONST_INT. */
2084 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2087 /* Effectively do build_pointer_type, but don't cache this type,
2088 since it might be temporary whereas the type it points to
2089 might have been saved for inlining. */
2090 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2091 type = make_node (POINTER_TYPE);
2092 TREE_TYPE (type) = TREE_TYPE (decl);
2094 else if (GET_CODE (home) == MEM
2095 && GET_CODE (XEXP (home, 0)) == REG)
2097 current_sym_code = N_LSYM;
2098 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2100 else if (GET_CODE (home) == MEM
2101 && GET_CODE (XEXP (home, 0)) == PLUS
2102 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2104 current_sym_code = N_LSYM;
2105 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2106 We want the value of that CONST_INT. */
2107 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2109 else if (GET_CODE (home) == MEM
2110 && GET_CODE (XEXP (home, 0)) == CONST)
2112 /* Handle an obscure case which can arise when optimizing and
2113 when there are few available registers. (This is *always*
2114 the case for i386/i486 targets). The RTL looks like
2115 (MEM (CONST ...)) even though this variable is a local `auto'
2116 or a local `register' variable. In effect, what has happened
2117 is that the reload pass has seen that all assignments and
2118 references for one such a local variable can be replaced by
2119 equivalent assignments and references to some static storage
2120 variable, thereby avoiding the need for a register. In such
2121 cases we're forced to lie to debuggers and tell them that
2122 this variable was itself `static'. */
2123 current_sym_code = N_LCSYM;
2125 current_sym_addr = XEXP (XEXP (home, 0), 0);
2127 else if (GET_CODE (home) == CONCAT)
2129 tree subtype = TREE_TYPE (type);
2131 /* If the variable's storage is in two parts,
2132 output each as a separate stab with a modified name. */
2133 if (WORDS_BIG_ENDIAN)
2134 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2136 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2138 /* Cast avoids warning in old compilers. */
2139 current_sym_code = (STAB_CODE_TYPE) 0;
2140 current_sym_value = 0;
2141 current_sym_addr = 0;
2142 dbxout_prepare_symbol (decl);
2144 if (WORDS_BIG_ENDIAN)
2145 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2147 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2151 /* Address might be a MEM, when DECL is a variable-sized object.
2152 Or it might be const0_rtx, meaning previous passes
2153 want us to ignore this variable. */
2156 /* Ok, start a symtab entry and output the variable name. */
2159 #ifdef DBX_STATIC_BLOCK_START
2160 DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2163 dbxout_symbol_name (decl, suffix, letter);
2164 dbxout_type (type, 0, 0);
2165 dbxout_finish_symbol (decl);
2167 #ifdef DBX_STATIC_BLOCK_END
2168 DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2172 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2173 Then output LETTER to indicate the kind of location the symbol has. */
2176 dbxout_symbol_name (decl, suffix, letter)
2181 /* One slight hitch: if this is a VAR_DECL which is a static
2182 class member, we must put out the mangled name instead of the
2183 DECL_NAME. Note also that static member (variable) names DO NOT begin
2184 with underscores in .stabs directives. */
2185 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2188 fprintf (asmfile, "%s \"%s%s:", ASM_STABS_OP, name,
2189 (suffix ? suffix : ""));
2191 if (letter) putc (letter, asmfile);
2195 dbxout_prepare_symbol (decl)
2196 tree decl ATTRIBUTE_UNUSED;
2199 char *filename = DECL_SOURCE_FILE (decl);
2201 dbxout_source_file (asmfile, filename);
2206 dbxout_finish_symbol (sym)
2209 #ifdef DBX_FINISH_SYMBOL
2210 DBX_FINISH_SYMBOL (sym);
2213 if (use_gnu_debug_info_extensions && sym != 0)
2214 line = DECL_SOURCE_LINE (sym);
2216 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2217 if (current_sym_addr)
2218 output_addr_const (asmfile, current_sym_addr);
2220 fprintf (asmfile, "%d", current_sym_value);
2221 putc ('\n', asmfile);
2225 /* Output definitions of all the decls in a chain. */
2233 dbxout_symbol (syms, 1);
2234 syms = TREE_CHAIN (syms);
2238 /* The following two functions output definitions of function parameters.
2239 Each parameter gets a definition locating it in the parameter list.
2240 Each parameter that is a register variable gets a second definition
2241 locating it in the register.
2243 Printing or argument lists in gdb uses the definitions that
2244 locate in the parameter list. But reference to the variable in
2245 expressions uses preferentially the definition as a register. */
2247 /* Output definitions, referring to storage in the parmlist,
2248 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2251 dbxout_parms (parms)
2254 for (; parms; parms = TREE_CHAIN (parms))
2255 if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2257 dbxout_prepare_symbol (parms);
2259 /* Perform any necessary register eliminations on the parameter's rtl,
2260 so that the debugging output will be accurate. */
2261 DECL_INCOMING_RTL (parms)
2262 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2263 DECL_RTL (parms) = eliminate_regs (DECL_RTL (parms), 0, NULL_RTX);
2264 #ifdef LEAF_REG_REMAP
2265 if (current_function_uses_only_leaf_regs)
2267 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2268 leaf_renumber_regs_insn (DECL_RTL (parms));
2272 if (PARM_PASSED_IN_MEMORY (parms))
2274 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2276 /* ??? Here we assume that the parm address is indexed
2277 off the frame pointer or arg pointer.
2278 If that is not true, we produce meaningless results,
2279 but do not crash. */
2280 if (GET_CODE (addr) == PLUS
2281 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2282 current_sym_value = INTVAL (XEXP (addr, 1));
2284 current_sym_value = 0;
2286 current_sym_code = N_PSYM;
2287 current_sym_addr = 0;
2290 if (DECL_NAME (parms))
2292 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2294 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2295 IDENTIFIER_POINTER (DECL_NAME (parms)),
2296 DBX_MEMPARM_STABS_LETTER);
2300 current_sym_nchars = 8;
2301 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2302 DBX_MEMPARM_STABS_LETTER);
2305 /* It is quite tempting to use:
2307 dbxout_type (TREE_TYPE (parms), 0, 0);
2309 as the next statement, rather than using DECL_ARG_TYPE(), so
2310 that gcc reports the actual type of the parameter, rather
2311 than the promoted type. This certainly makes GDB's life
2312 easier, at least for some ports. The change is a bad idea
2313 however, since GDB expects to be able access the type without
2314 performing any conversions. So for example, if we were
2315 passing a float to an unprototyped function, gcc will store a
2316 double on the stack, but if we emit a stab saying the type is a
2317 float, then gdb will only read in a single value, and this will
2318 produce an erropneous value. */
2319 dbxout_type (DECL_ARG_TYPE (parms), 0, 0);
2320 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2321 dbxout_finish_symbol (parms);
2323 else if (GET_CODE (DECL_RTL (parms)) == REG)
2326 char regparm_letter;
2328 /* Parm passed in registers and lives in registers or nowhere. */
2330 current_sym_code = DBX_REGPARM_STABS_CODE;
2331 regparm_letter = DBX_REGPARM_STABS_LETTER;
2332 current_sym_addr = 0;
2334 /* If parm lives in a register, use that register;
2335 pretend the parm was passed there. It would be more consistent
2336 to describe the register where the parm was passed,
2337 but in practice that register usually holds something else.
2339 If we use DECL_RTL, then we must use the declared type of
2340 the variable, not the type that it arrived in. */
2341 if (REGNO (DECL_RTL (parms)) >= 0
2342 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2344 best_rtl = DECL_RTL (parms);
2345 parm_type = TREE_TYPE (parms);
2347 /* If the parm lives nowhere, use the register where it was
2348 passed. It is also better to use the declared type here. */
2351 best_rtl = DECL_INCOMING_RTL (parms);
2352 parm_type = TREE_TYPE (parms);
2354 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2357 if (DECL_NAME (parms))
2359 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2360 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2361 IDENTIFIER_POINTER (DECL_NAME (parms)),
2366 current_sym_nchars = 8;
2367 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2371 dbxout_type (parm_type, 0, 0);
2372 dbxout_finish_symbol (parms);
2374 else if (GET_CODE (DECL_RTL (parms)) == MEM
2375 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2376 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2377 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2378 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2379 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2383 /* Parm was passed via invisible reference.
2384 That is, its address was passed in a register.
2385 Output it as if it lived in that register.
2386 The debugger will know from the type
2387 that it was actually passed by invisible reference. */
2389 char regparm_letter;
2390 /* Parm passed in registers and lives in registers or nowhere. */
2392 current_sym_code = DBX_REGPARM_STABS_CODE;
2393 if (use_gnu_debug_info_extensions)
2394 regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2396 regparm_letter = DBX_REGPARM_STABS_LETTER;
2398 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2399 If it is an unallocated pseudo-reg, then use the register where
2400 it was passed instead. */
2401 if (REGNO (XEXP (DECL_RTL (parms), 0)) >= 0
2402 && REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2403 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2405 current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2407 current_sym_addr = 0;
2410 if (DECL_NAME (parms))
2412 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2414 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2415 IDENTIFIER_POINTER (DECL_NAME (parms)),
2420 current_sym_nchars = 8;
2421 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2425 dbxout_type (TREE_TYPE (parms), 0, 0);
2426 dbxout_finish_symbol (parms);
2428 else if (GET_CODE (DECL_RTL (parms)) == MEM
2429 && XEXP (DECL_RTL (parms), 0) != const0_rtx
2430 /* ??? A constant address for a parm can happen
2431 when the reg it lives in is equiv to a constant in memory.
2432 Should make this not happen, after 2.4. */
2433 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2435 /* Parm was passed in registers but lives on the stack. */
2437 current_sym_code = N_PSYM;
2438 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2439 in which case we want the value of that CONST_INT,
2440 or (MEM (REG ...)) or (MEM (MEM ...)),
2441 in which case we use a value of zero. */
2442 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2443 || GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2444 current_sym_value = 0;
2446 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2447 current_sym_addr = 0;
2449 /* Make a big endian correction if the mode of the type of the
2450 parameter is not the same as the mode of the rtl. */
2451 if (BYTES_BIG_ENDIAN
2452 && TYPE_MODE (TREE_TYPE (parms)) != GET_MODE (DECL_RTL (parms))
2453 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms))) < UNITS_PER_WORD)
2455 current_sym_value += UNITS_PER_WORD - GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms)));
2459 if (DECL_NAME (parms))
2461 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2463 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2464 IDENTIFIER_POINTER (DECL_NAME (parms)),
2465 DBX_MEMPARM_STABS_LETTER);
2469 current_sym_nchars = 8;
2470 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2471 DBX_MEMPARM_STABS_LETTER);
2475 = DEBUGGER_ARG_OFFSET (current_sym_value,
2476 XEXP (DECL_RTL (parms), 0));
2477 dbxout_type (TREE_TYPE (parms), 0, 0);
2478 dbxout_finish_symbol (parms);
2483 /* Output definitions for the places where parms live during the function,
2484 when different from where they were passed, when the parms were passed
2487 It is not useful to do this for parms passed in registers
2488 that live during the function in different registers, because it is
2489 impossible to look in the passed register for the passed value,
2490 so we use the within-the-function register to begin with.
2492 PARMS is a chain of PARM_DECL nodes. */
2495 dbxout_reg_parms (parms)
2498 for (; parms; parms = TREE_CHAIN (parms))
2499 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
2501 dbxout_prepare_symbol (parms);
2503 /* Report parms that live in registers during the function
2504 but were passed in memory. */
2505 if (GET_CODE (DECL_RTL (parms)) == REG
2506 && REGNO (DECL_RTL (parms)) >= 0
2507 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2508 dbxout_symbol_location (parms, TREE_TYPE (parms),
2509 0, DECL_RTL (parms));
2510 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
2511 dbxout_symbol_location (parms, TREE_TYPE (parms),
2512 0, DECL_RTL (parms));
2513 /* Report parms that live in memory but not where they were passed. */
2514 else if (GET_CODE (DECL_RTL (parms)) == MEM
2515 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
2516 dbxout_symbol_location (parms, TREE_TYPE (parms),
2517 0, DECL_RTL (parms));
2521 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2522 output definitions of those names, in raw form */
2530 putc (',', asmfile);
2531 dbxout_type (TREE_VALUE (args), 0, 0);
2533 args = TREE_CHAIN (args);
2537 /* Given a chain of ..._TYPE nodes,
2538 find those which have typedef names and output those names.
2539 This is to ensure those types get output. */
2542 dbxout_types (types)
2543 register tree types;
2547 if (TYPE_NAME (types)
2548 && TREE_CODE (TYPE_NAME (types)) == TYPE_DECL
2549 && ! TREE_ASM_WRITTEN (TYPE_NAME (types)))
2550 dbxout_symbol (TYPE_NAME (types), 1);
2551 types = TREE_CHAIN (types);
2555 /* Output everything about a symbol block (a BLOCK node
2556 that represents a scope level),
2557 including recursive output of contained blocks.
2559 BLOCK is the BLOCK node.
2560 DEPTH is its depth within containing symbol blocks.
2561 ARGS is usually zero; but for the outermost block of the
2562 body of a function, it is a chain of PARM_DECLs for the function parameters.
2563 We output definitions of all the register parms
2564 as if they were local variables of that block.
2566 If -g1 was used, we count blocks just the same, but output nothing
2567 except for the outermost block.
2569 Actually, BLOCK may be several blocks chained together.
2570 We handle them all in sequence. */
2573 dbxout_block (block, depth, args)
2574 register tree block;
2582 /* Ignore blocks never expanded or otherwise marked as real. */
2583 if (TREE_USED (block))
2585 #ifndef DBX_LBRAC_FIRST
2586 /* In dbx format, the syms of a block come before the N_LBRAC. */
2587 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2588 dbxout_syms (BLOCK_VARS (block));
2590 dbxout_reg_parms (args);
2593 /* Now output an N_LBRAC symbol to represent the beginning of
2594 the block. Use the block's tree-walk order to generate
2595 the assembler symbols LBBn and LBEn
2596 that final will define around the code in this block. */
2597 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2600 blocknum = next_block_number++;
2601 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
2603 if (BLOCK_HANDLER_BLOCK (block))
2605 /* A catch block. Must precede N_LBRAC. */
2606 tree decl = BLOCK_VARS (block);
2609 #ifdef DBX_OUTPUT_CATCH
2610 DBX_OUTPUT_CATCH (asmfile, decl, buf);
2612 fprintf (asmfile, "%s \"%s:C1\",%d,0,0,", ASM_STABS_OP,
2613 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
2614 assemble_name (asmfile, buf);
2615 fprintf (asmfile, "\n");
2617 decl = TREE_CHAIN (decl);
2621 #ifdef DBX_OUTPUT_LBRAC
2622 DBX_OUTPUT_LBRAC (asmfile, buf);
2624 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);
2625 assemble_name (asmfile, buf);
2626 #if DBX_BLOCKS_FUNCTION_RELATIVE
2627 fputc ('-', asmfile);
2628 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2630 fprintf (asmfile, "\n");
2634 /* Count blocks the same way regardless of debug_info_level. */
2635 next_block_number++;
2637 #ifdef DBX_LBRAC_FIRST
2638 /* On some weird machines, the syms of a block
2639 come after the N_LBRAC. */
2640 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2641 dbxout_syms (BLOCK_VARS (block));
2643 dbxout_reg_parms (args);
2646 /* Output the subblocks. */
2647 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
2649 /* Refer to the marker for the end of the block. */
2650 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2653 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
2654 #ifdef DBX_OUTPUT_RBRAC
2655 DBX_OUTPUT_RBRAC (asmfile, buf);
2657 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);
2658 assemble_name (asmfile, buf);
2659 #if DBX_BLOCKS_FUNCTION_RELATIVE
2660 fputc ('-', asmfile);
2661 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2663 fprintf (asmfile, "\n");
2667 block = BLOCK_CHAIN (block);
2671 /* Output the information about a function and its arguments and result.
2672 Usually this follows the function's code,
2673 but on some systems, it comes before. */
2676 dbxout_really_begin_function (decl)
2679 dbxout_symbol (decl, 0);
2680 dbxout_parms (DECL_ARGUMENTS (decl));
2681 if (DECL_NAME (DECL_RESULT (decl)) != 0)
2682 dbxout_symbol (DECL_RESULT (decl), 1);
2685 /* Called at beginning of output of function definition. */
2688 dbxout_begin_function (decl)
2689 tree decl ATTRIBUTE_UNUSED;
2691 #ifdef DBX_FUNCTION_FIRST
2692 dbxout_really_begin_function (decl);
2694 #ifdef DBX_CHECK_FUNCTION_FIRST
2695 if (DBX_CHECK_FUNCTION_FIRST)
2696 dbxout_really_begin_function (decl);
2701 /* Output dbx data for a function definition.
2702 This includes a definition of the function name itself (a symbol),
2703 definitions of the parameters (locating them in the parameter list)
2704 and then output the block that makes up the function's body
2705 (including all the auto variables of the function). */
2708 dbxout_function (decl)
2711 #ifndef DBX_FUNCTION_FIRST
2712 #ifdef DBX_CHECK_FUNCTION_FIRST
2713 if (!(DBX_CHECK_FUNCTION_FIRST))
2714 dbxout_really_begin_function (decl);
2716 dbxout_really_begin_function (decl);
2719 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
2720 #ifdef DBX_OUTPUT_FUNCTION_END
2721 DBX_OUTPUT_FUNCTION_END (asmfile, decl);
2723 #if defined(ASM_OUTPUT_SECTION_NAME)
2724 if (use_gnu_debug_info_extensions
2725 #if defined(NO_DBX_FUNCTION_END)
2726 && ! NO_DBX_FUNCTION_END
2729 dbxout_function_end ();
2732 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */