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. */
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'. */
77 #include "insn-config.h"
80 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
82 #ifdef XCOFF_DEBUGGING_INFO
87 #define ASM_STABS_OP ".stabs"
91 #define ASM_STABN_OP ".stabn"
94 #ifndef DBX_TYPE_DECL_STABS_CODE
95 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
98 #ifndef DBX_STATIC_CONST_VAR_CODE
99 #define DBX_STATIC_CONST_VAR_CODE N_FUN
102 #ifndef DBX_REGPARM_STABS_CODE
103 #define DBX_REGPARM_STABS_CODE N_RSYM
106 #ifndef DBX_REGPARM_STABS_LETTER
107 #define DBX_REGPARM_STABS_LETTER 'P'
110 /* This is used for parameters passed by invisible reference in a register. */
111 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
112 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
115 #ifndef DBX_MEMPARM_STABS_LETTER
116 #define DBX_MEMPARM_STABS_LETTER 'p'
119 #ifndef FILE_NAME_JOINER
120 #define FILE_NAME_JOINER "/"
123 /* Nonzero means if the type has methods, only output debugging
124 information if methods are actually written to the asm file. This
125 optimization only works if the debugger can detect the special C++
128 #define MINIMAL_DEBUG 1
130 #ifdef NO_DOLLAR_IN_LABEL
131 #ifdef NO_DOT_IN_LABEL
133 #define MINIMAL_DEBUG 0
139 /* Typical USG systems don't have stab.h, and they also have
140 no use for DBX-format debugging info. */
142 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
144 static int flag_minimal_debug = MINIMAL_DEBUG;
146 /* Nonzero if we have actually used any of the GDB extensions
147 to the debugging format. The idea is that we use them for the
148 first time only if there's a strong reason, but once we have done that,
149 we use them whenever convenient. */
151 static int have_used_extensions = 0;
153 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
154 for the N_SO filename stabs label. */
156 static int source_label_number = 1;
158 #ifdef DEBUG_SYMS_TEXT
159 #define FORCE_TEXT text_section ();
164 /* If there is a system stabs.h, use it. Otherwise, use our own. */
171 /* This is a GNU extension we need to reference in this file. */
178 #define STAB_CODE_TYPE enum __stab_debug_code
180 #define STAB_CODE_TYPE int
183 /* 1 if PARM is passed to this function in memory. */
185 #define PARM_PASSED_IN_MEMORY(PARM) \
186 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
188 /* A C expression for the integer offset value of an automatic variable
189 (N_LSYM) having address X (an RTX). */
190 #ifndef DEBUGGER_AUTO_OFFSET
191 #define DEBUGGER_AUTO_OFFSET(X) \
192 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
195 /* A C expression for the integer offset value of an argument (N_PSYM)
196 having address X (an RTX). The nominal offset is OFFSET. */
197 #ifndef DEBUGGER_ARG_OFFSET
198 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
201 /* Stream for writing to assembler file. */
203 static FILE *asmfile;
205 /* Last source file name mentioned in a NOTE insn. */
207 static char *lastfile;
209 /* Current working directory. */
213 enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
215 /* Structure recording information about a C data type.
216 The status element says whether we have yet output
217 the definition of the type. TYPE_XREF says we have
218 output it as a cross-reference only.
219 The file_number and type_number elements are used if DBX_USE_BINCL
224 enum typestatus status;
231 /* Vector recording information about C data types.
232 When we first notice a data type (a tree node),
233 we assign it a number using next_type_number.
234 That is its index in this vector. */
236 struct typeinfo *typevec;
238 /* Number of elements of space allocated in `typevec'. */
240 static int typevec_len;
242 /* In dbx output, each type gets a unique number.
243 This is the number for the next type output.
244 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
246 static int next_type_number;
250 /* When using N_BINCL in dbx output, each type number is actually a
251 pair of the file number and the type number within the file.
252 This is a stack of input files. */
256 struct dbx_file *next;
258 int next_type_number;
261 /* This is the top of the stack. */
263 static struct dbx_file *current_file;
265 /* This is the next file number to use. */
267 static int next_file_number;
269 #endif /* DBX_USE_BINCL */
271 /* In dbx output, we must assign symbol-blocks id numbers
272 in the order in which their beginnings are encountered.
273 We output debugging info that refers to the beginning and
274 end of the ranges of code in each block
275 with assembler labels LBBn and LBEn, where n is the block number.
276 The labels are generated in final, which assigns numbers to the
277 blocks in the same way. */
279 static int next_block_number;
281 /* These variables are for dbxout_symbol to communicate to
282 dbxout_finish_symbol.
283 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
284 current_sym_value and current_sym_addr are two ways to address the
285 value to store in the symtab entry.
286 current_sym_addr if nonzero represents the value as an rtx.
287 If that is zero, current_sym_value is used. This is used
288 when the value is an offset (such as for auto variables,
289 register variables and parms). */
291 static STAB_CODE_TYPE current_sym_code;
292 static int current_sym_value;
293 static rtx current_sym_addr;
295 /* Number of chars of symbol-description generated so far for the
296 current symbol. Used by CHARS and CONTIN. */
298 static int current_sym_nchars;
300 /* Report having output N chars of the current symbol-description. */
302 #define CHARS(N) (current_sym_nchars += (N))
304 /* Break the current symbol-description, generating a continuation,
305 if it has become long. */
307 #ifndef DBX_CONTIN_LENGTH
308 #define DBX_CONTIN_LENGTH 80
311 #if DBX_CONTIN_LENGTH > 0
313 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
318 void dbxout_types ();
320 void dbxout_symbol ();
322 #if defined(ASM_OUTPUT_SECTION_NAME)
323 static void dbxout_function_end PROTO((void));
325 static void dbxout_typedefs PROTO((tree));
326 static void dbxout_type_index PROTO((tree));
327 static void dbxout_continue PROTO((void));
328 static void dbxout_type_fields PROTO((tree));
329 static void dbxout_type_method_1 PROTO((tree, char *));
330 static void dbxout_type_methods PROTO((tree));
331 static void dbxout_range_type PROTO((tree));
332 static void dbxout_type PROTO((tree, int, int));
333 static void print_int_cst_octal PROTO((tree));
334 static void print_octal PROTO((unsigned HOST_WIDE_INT, int));
335 static void dbxout_type_name PROTO((tree));
336 static void dbxout_symbol_location PROTO((tree, tree, char *, rtx));
337 static void dbxout_symbol_name PROTO((tree, char *, int));
338 static void dbxout_prepare_symbol PROTO((tree));
339 static void dbxout_finish_symbol PROTO((tree));
340 static void dbxout_block PROTO((tree, int, tree));
341 static void dbxout_really_begin_function PROTO((tree));
343 #if defined(ASM_OUTPUT_SECTION_NAME)
345 dbxout_function_end ()
347 static int scope_labelno = 0;
348 char lscope_label_name[100];
349 /* Convert Ltext into the appropriate format for local labels in case
350 the system doesn't insert underscores in front of user generated
352 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
353 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Lscope", scope_labelno);
356 /* By convention, GCC will mark the end of a function with an N_FUN
357 symbol and an empty string. */
358 fprintf (asmfile, "%s \"\",%d,0,0,", ASM_STABS_OP, N_FUN);
359 assemble_name (asmfile, lscope_label_name);
360 fputc ('-', asmfile);
361 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
362 fprintf (asmfile, "\n");
364 #endif /* ! NO_DBX_FUNCTION_END */
366 /* At the beginning of compilation, start writing the symbol table.
367 Initialize `typevec' and output the standard data types of C. */
370 dbxout_init (asm_file, input_file_name, syms)
372 char *input_file_name;
375 char ltext_label_name[100];
380 typevec = (struct typeinfo *) xmalloc (typevec_len * sizeof typevec[0]);
381 bzero ((char *) typevec, typevec_len * sizeof typevec[0]);
383 /* Convert Ltext into the appropriate format for local labels in case
384 the system doesn't insert underscores in front of user generated
386 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
388 /* Put the current working directory in an N_SO symbol. */
389 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
390 but GDB always does. */
391 if (use_gnu_debug_info_extensions)
394 if (!cwd && (cwd = getpwd ()) && (!*cwd || cwd[strlen (cwd) - 1] != '/'))
396 char *wdslash = xmalloc (strlen (cwd) + sizeof (FILE_NAME_JOINER));
397 sprintf (wdslash, "%s%s", cwd, FILE_NAME_JOINER);
402 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
403 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
404 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
405 fprintf (asmfile, "%s ", ASM_STABS_OP);
406 output_quoted_string (asmfile, cwd);
407 fprintf (asmfile, ",%d,0,0,%s\n", N_SO, <ext_label_name[1]);
408 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
412 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
413 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
414 would give us an N_SOL, and we want an N_SO. */
415 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
416 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
417 /* We include outputting `Ltext:' here,
418 because that gives you a way to override it. */
419 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
420 fprintf (asmfile, "%s ", ASM_STABS_OP);
421 output_quoted_string (asmfile, input_file_name);
422 fprintf (asmfile, ",%d,0,0,%s\n",
423 N_SO, <ext_label_name[1]);
425 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Ltext", 0);
426 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
428 /* Possibly output something to inform GDB that this compilation was by
429 GCC. It's easier for GDB to parse it when after the N_SO's. This
430 is used in Solaris 2. */
431 #ifdef ASM_IDENTIFY_GCC_AFTER_SOURCE
432 ASM_IDENTIFY_GCC_AFTER_SOURCE (asmfile);
435 lastfile = input_file_name;
437 next_type_number = 1;
438 next_block_number = 2;
441 current_file = (struct dbx_file *) xmalloc (sizeof *current_file);
442 current_file->next = NULL;
443 current_file->file_number = 0;
444 current_file->next_type_number = 1;
445 next_file_number = 1;
448 /* Make sure that types `int' and `char' have numbers 1 and 2.
449 Definitions of other integer types will refer to those numbers.
450 (Actually it should no longer matter what their numbers are.
451 Also, if any types with tags have been defined, dbxout_symbol
452 will output them first, so the numbers won't be 1 and 2. That
453 happens in C++. So it's a good thing it should no longer matter). */
455 #ifdef DBX_OUTPUT_STANDARD_TYPES
456 DBX_OUTPUT_STANDARD_TYPES (syms);
458 dbxout_symbol (TYPE_NAME (integer_type_node), 0);
459 dbxout_symbol (TYPE_NAME (char_type_node), 0);
462 /* Get all permanent types that have typedef names,
463 and output them all, except for those already output. */
465 dbxout_typedefs (syms);
468 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
469 in the reverse order from that which is found in SYMS. */
472 dbxout_typedefs (syms)
477 dbxout_typedefs (TREE_CHAIN (syms));
478 if (TREE_CODE (syms) == TYPE_DECL)
480 tree type = TREE_TYPE (syms);
482 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
483 && TYPE_SIZE (type) != NULL_TREE
484 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
485 dbxout_symbol (TYPE_NAME (type), 0);
490 /* Change to reading from a new source file. Generate a N_BINCL stab. */
493 dbxout_start_new_source_file (filename)
497 struct dbx_file *n = (struct dbx_file *) xmalloc (sizeof *n);
499 n->next = current_file;
500 n->file_number = next_file_number++;
501 n->next_type_number = 1;
503 fprintf (asmfile, "%s ", ASM_STABS_OP);
504 output_quoted_string (asmfile, filename);
505 fprintf (asmfile, ",%d,0,0,0\n", N_BINCL);
509 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
512 dbxout_resume_previous_source_file ()
515 struct dbx_file *next;
517 fprintf (asmfile, "%s %d,0,0,0\n", ASM_STABN_OP, N_EINCL);
518 next = current_file->next;
524 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
527 dbxout_source_file (file, filename)
531 char ltext_label_name[100];
533 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
535 #ifdef DBX_OUTPUT_SOURCE_FILENAME
536 DBX_OUTPUT_SOURCE_FILENAME (file, filename);
538 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
539 source_label_number);
540 fprintf (file, "%s ", ASM_STABS_OP);
541 output_quoted_string (file, filename);
542 fprintf (file, ",%d,0,0,%s\n", N_SOL, <ext_label_name[1]);
543 if (current_function_decl != NULL_TREE
544 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
545 ; /* Don't change section amid function. */
548 ASM_OUTPUT_INTERNAL_LABEL (file, "Ltext", source_label_number);
549 source_label_number++;
555 /* Output a line number symbol entry into output stream FILE,
556 for source file FILENAME and line number LINENO. */
559 dbxout_source_line (file, filename, lineno)
564 dbxout_source_file (file, filename);
566 #ifdef ASM_OUTPUT_SOURCE_LINE
567 ASM_OUTPUT_SOURCE_LINE (file, lineno);
569 fprintf (file, "\t%s %d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
573 /* At the end of compilation, finish writing the symbol table.
574 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
578 dbxout_finish (file, filename)
582 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
583 DBX_OUTPUT_MAIN_SOURCE_FILE_END (file, filename);
584 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
587 /* Output the index of a type. */
590 dbxout_type_index (type)
593 #ifndef DBX_USE_BINCL
594 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
597 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
598 fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number);
603 /* Continue a symbol-description that gets too big.
604 End one symbol table entry with a double-backslash
605 and start a new one, eventually producing something like
606 .stabs "start......\\",code,0,value
607 .stabs "...rest",code,0,value */
612 #ifdef DBX_CONTIN_CHAR
613 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
615 fprintf (asmfile, "\\\\");
617 dbxout_finish_symbol (NULL_TREE);
618 fprintf (asmfile, "%s \"", ASM_STABS_OP);
619 current_sym_nchars = 0;
622 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
623 This must be a separate function because anonymous unions require
627 dbxout_type_fields (type)
631 /* Output the name, type, position (in bits), size (in bits) of each
633 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
635 /* Omit here local type decls until we know how to support them. */
636 if (TREE_CODE (tem) == TYPE_DECL)
638 /* Omit fields whose position or size are variable. */
639 else if (TREE_CODE (tem) == FIELD_DECL
640 && (TREE_CODE (DECL_FIELD_BITPOS (tem)) != INTEGER_CST
641 || TREE_CODE (DECL_SIZE (tem)) != INTEGER_CST))
643 /* Omit here the nameless fields that are used to skip bits. */
644 else if (DECL_IGNORED_P (tem))
646 else if (TREE_CODE (tem) != CONST_DECL)
648 /* Continue the line if necessary,
649 but not before the first field. */
650 if (tem != TYPE_FIELDS (type))
655 if (use_gnu_debug_info_extensions
656 && flag_minimal_debug
657 && TREE_CODE (tem) == FIELD_DECL
658 && DECL_VIRTUAL_P (tem)
659 && DECL_ASSEMBLER_NAME (tem))
661 have_used_extensions = 1;
662 CHARS (3 + IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (tem)));
663 fputs (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem)), asmfile);
664 dbxout_type (DECL_FCONTEXT (tem), 0, 0);
665 fprintf (asmfile, ":");
666 dbxout_type (TREE_TYPE (tem), 0, 0);
667 fputc (',', asmfile);
668 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
669 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)));
670 fputc (';', asmfile);
676 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
677 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
681 fprintf (asmfile, ":");
685 if (use_gnu_debug_info_extensions
686 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
687 || TREE_CODE (tem) != FIELD_DECL))
689 have_used_extensions = 1;
691 putc ((TREE_PRIVATE (tem) ? '0'
692 : TREE_PROTECTED (tem) ? '1' : '2'),
697 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
698 && DECL_BIT_FIELD_TYPE (tem))
699 ? DECL_BIT_FIELD_TYPE (tem)
700 : TREE_TYPE (tem), 0, 0);
702 if (TREE_CODE (tem) == VAR_DECL)
704 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
706 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem));
707 have_used_extensions = 1;
708 fprintf (asmfile, ":%s;", name);
709 CHARS (strlen (name));
713 /* If TEM is non-static, GDB won't understand it. */
714 fprintf (asmfile, ",0,0;");
717 else if (TREE_CODE (DECL_FIELD_BITPOS (tem)) == INTEGER_CST)
719 fputc (',', asmfile);
720 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
721 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)));
722 fputc (',', asmfile);
723 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
724 TREE_INT_CST_LOW (DECL_SIZE (tem)));
725 fputc (';', asmfile);
732 /* Subroutine of `dbxout_type_methods'. Output debug info about the
733 method described DECL. DEBUG_NAME is an encoding of the method's
734 type signature. ??? We may be able to do without DEBUG_NAME altogether
738 dbxout_type_method_1 (decl, debug_name)
744 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
746 else /* it's a METHOD_TYPE. */
748 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
749 /* A for normal functions.
750 B for `const' member functions.
751 C for `volatile' member functions.
752 D for `const volatile' member functions. */
753 if (TYPE_READONLY (TREE_TYPE (firstarg)))
755 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
758 if (DECL_VINDEX (decl))
764 fprintf (asmfile, ":%s;%c%c%c", debug_name,
765 TREE_PRIVATE (decl) ? '0' : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
766 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
767 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
768 if (DECL_VINDEX (decl))
770 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
771 TREE_INT_CST_LOW (DECL_VINDEX (decl)));
772 fputc (';', asmfile);
773 dbxout_type (DECL_CONTEXT (decl), 0, 0);
774 fprintf (asmfile, ";");
779 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
783 dbxout_type_methods (type)
786 /* C++: put out the method names and their parameter lists */
787 tree methods = TYPE_METHODS (type);
789 register tree fndecl;
791 char formatted_type_identifier_length[16];
792 register int type_identifier_length;
794 if (methods == NULL_TREE)
797 type_encoding = DECL_NAME (TYPE_NAME (type));
800 /* C++: Template classes break some assumptions made by this code about
801 the class names, constructor names, and encodings for assembler
802 label names. For now, disable output of dbx info for them. */
804 char *ptr = IDENTIFIER_POINTER (type_encoding);
805 /* This should use index. (mrs) */
806 while (*ptr && *ptr != '<') ptr++;
813 #ifdef HAVE_TEMPLATES
814 if (warn_template_debugging)
815 warning ("dbx info for template class methods not yet supported");
823 type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
825 sprintf(formatted_type_identifier_length, "%d", type_identifier_length);
827 if (TREE_CODE (methods) != TREE_VEC)
829 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
830 fndecl = TREE_VEC_ELT (methods, 0);
832 fndecl = TREE_VEC_ELT (methods, 1);
836 tree name = DECL_NAME (fndecl);
839 /* Group together all the methods for the same operation.
840 These differ in the types of the arguments. */
841 for (last = NULL_TREE;
842 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
843 fndecl = TREE_CHAIN (fndecl))
844 /* Output the name of the field (after overloading), as
845 well as the name of the field before overloading, along
846 with its parameter list */
848 /* This is the "mangled" name of the method.
849 It encodes the argument types. */
850 char *debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
851 int show_arg_types = 0;
857 if (DECL_IGNORED_P (fndecl))
860 if (flag_minimal_debug)
864 /* We can't optimize a method which uses an anonymous
865 class, because the debugger will not be able to
866 associate the arbitrary class name with the actual
868 #ifndef NO_DOLLAR_IN_LABEL
873 if (strchr (debug_name, marker))
875 /* Detect ordinary methods because their mangled names
876 start with the operation name. */
877 else if (!strncmp (IDENTIFIER_POINTER (name), debug_name,
878 IDENTIFIER_LENGTH (name)))
880 debug_name += IDENTIFIER_LENGTH (name);
881 if (debug_name[0] == '_' && debug_name[1] == '_')
883 char *method_name = debug_name + 2;
884 char *length_ptr = formatted_type_identifier_length;
885 /* Get past const and volatile qualifiers. */
886 while (*method_name == 'C' || *method_name == 'V')
888 /* Skip digits for length of type_encoding. */
889 while (*method_name == *length_ptr && *length_ptr)
890 length_ptr++, method_name++;
891 if (! strncmp (method_name,
892 IDENTIFIER_POINTER (type_encoding),
893 type_identifier_length))
894 method_name += type_identifier_length;
895 debug_name = method_name;
898 /* Detect constructors by their style of name mangling. */
899 else if (debug_name[0] == '_' && debug_name[1] == '_')
901 char *ctor_name = debug_name + 2;
902 char *length_ptr = formatted_type_identifier_length;
903 while (*ctor_name == 'C' || *ctor_name == 'V')
905 /* Skip digits for length of type_encoding. */
906 while (*ctor_name == *length_ptr && *length_ptr)
907 length_ptr++, ctor_name++;
908 if (!strncmp (IDENTIFIER_POINTER (type_encoding), ctor_name,
909 type_identifier_length))
910 debug_name = ctor_name + type_identifier_length;
912 /* The other alternative is a destructor. */
916 /* Output the operation name just once, for the first method
920 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
921 CHARS (IDENTIFIER_LENGTH (name) + 2);
926 dbxout_type (TREE_TYPE (fndecl), 0, show_arg_types);
928 dbxout_type_method_1 (fndecl, debug_name);
938 /* Emit a "range" type specification, which has the form:
939 "r<index type>;<lower bound>;<upper bound>;".
940 TYPE is an INTEGER_TYPE. */
943 dbxout_range_type (type)
946 fprintf (asmfile, "r");
947 if (TREE_TYPE (type))
948 dbxout_type (TREE_TYPE (type), 0, 0);
949 else if (TREE_CODE (type) != INTEGER_TYPE)
950 dbxout_type (type, 0, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
953 /* Traditionally, we made sure 'int' was type 1, and builtin types
954 were defined to be sub-ranges of int. Unfortunately, this
955 does not allow us to distinguish true sub-ranges from integer
956 types. So, instead we define integer (non-sub-range) types as
957 sub-ranges of themselves. */
958 dbxout_type_index (type);
960 if (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST)
962 fputc (';', asmfile);
963 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
964 TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)));
967 fprintf (asmfile, ";0");
968 if (TYPE_MAX_VALUE (type)
969 && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST)
971 fputc (';', asmfile);
972 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
973 TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)));
974 fputc (';', asmfile);
977 fprintf (asmfile, ";-1;");
980 /* Output a reference to a type. If the type has not yet been
981 described in the dbx output, output its definition now.
982 For a type already defined, just refer to its definition
983 using the type number.
985 If FULL is nonzero, and the type has been described only with
986 a forward-reference, output the definition now.
987 If FULL is zero in this case, just refer to the forward-reference
988 using the number previously allocated.
990 If SHOW_ARG_TYPES is nonzero, we output a description of the argument
991 types for a METHOD_TYPE. */
994 dbxout_type (type, full, show_arg_types)
1000 static int anonymous_type_number = 0;
1002 /* If there was an input error and we don't really have a type,
1003 avoid crashing and write something that is at least valid
1004 by assuming `int'. */
1005 if (type == error_mark_node)
1006 type = integer_type_node;
1009 /* Try to find the "main variant" with the same name but not const
1010 or volatile. (Since stabs does not distinguish const and volatile,
1011 there is no need to make them separate types. But types with
1012 different names are usefully distinguished.) */
1014 for (tem = TYPE_MAIN_VARIANT (type); tem; tem = TYPE_NEXT_VARIANT (tem))
1015 if (!TYPE_READONLY (tem) && !TYPE_VOLATILE (tem)
1016 && TYPE_NAME (tem) == TYPE_NAME (type))
1021 if (TYPE_NAME (type)
1022 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1023 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1027 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1029 /* Type has no dbx number assigned. Assign next available number. */
1030 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1032 /* Make sure type vector is long enough to record about this type. */
1034 if (next_type_number == typevec_len)
1037 = (struct typeinfo *) xrealloc (typevec,
1038 typevec_len * 2 * sizeof typevec[0]);
1039 bzero ((char *) (typevec + typevec_len),
1040 typevec_len * sizeof typevec[0]);
1044 #ifdef DBX_USE_BINCL
1045 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1046 = current_file->file_number;
1047 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1048 = current_file->next_type_number++;
1052 /* Output the number of this type, to refer to it. */
1053 dbxout_type_index (type);
1055 #ifdef DBX_TYPE_DEFINED
1056 if (DBX_TYPE_DEFINED (type))
1060 /* If this type's definition has been output or is now being output,
1063 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1068 /* If we have already had a cross reference,
1069 and either that's all we want or that's the best we could do,
1070 don't repeat the cross reference.
1071 Sun dbx crashes if we do. */
1072 if (! full || TYPE_SIZE (type) == 0
1073 /* No way in DBX fmt to describe a variable size. */
1074 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1082 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1083 leave the type-number completely undefined rather than output
1084 a cross-reference. If we have already used GNU debug info extensions,
1085 then it is OK to output a cross reference. This is necessary to get
1086 proper C++ debug output. */
1087 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1088 || TREE_CODE (type) == QUAL_UNION_TYPE
1089 || TREE_CODE (type) == ENUMERAL_TYPE)
1090 && ! use_gnu_debug_info_extensions)
1091 /* We must use the same test here as we use twice below when deciding
1092 whether to emit a cross-reference. */
1093 if ((TYPE_NAME (type) != 0
1094 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1095 && DECL_IGNORED_P (TYPE_NAME (type)))
1097 || TYPE_SIZE (type) == 0
1098 /* No way in DBX fmt to describe a variable size. */
1099 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1101 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1106 /* Output a definition now. */
1108 fprintf (asmfile, "=");
1111 /* Mark it as defined, so that if it is self-referent
1112 we will not get into an infinite recursion of definitions. */
1114 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1116 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1117 && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1119 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0, 0);
1123 switch (TREE_CODE (type))
1127 /* For a void type, just define it as itself; ie, "5=5".
1128 This makes us consider it defined
1129 without saying what it is. The debugger will make it
1130 a void type when the reference is seen, and nothing will
1131 ever override that default. */
1132 dbxout_type_index (type);
1136 if (type == char_type_node && ! TREE_UNSIGNED (type))
1138 /* Output the type `char' as a subrange of itself!
1139 I don't understand this definition, just copied it
1140 from the output of pcc.
1141 This used to use `r2' explicitly and we used to
1142 take care to make sure that `char' was type number 2. */
1143 fprintf (asmfile, "r");
1144 dbxout_type_index (type);
1145 fprintf (asmfile, ";0;127;");
1147 /* This used to check if the type's precision was more than
1148 HOST_BITS_PER_WIDE_INT. That is wrong since gdb uses a
1149 long (it has no concept of HOST_BITS_PER_WIDE_INT). */
1150 else if (use_gnu_debug_info_extensions
1151 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1152 || TYPE_PRECISION (type) >= HOST_BITS_PER_LONG))
1154 /* This used to say `r1' and we used to take care
1155 to make sure that `int' was type number 1. */
1156 fprintf (asmfile, "r");
1157 dbxout_type_index (integer_type_node);
1158 fprintf (asmfile, ";");
1159 print_int_cst_octal (TYPE_MIN_VALUE (type));
1160 fprintf (asmfile, ";");
1161 print_int_cst_octal (TYPE_MAX_VALUE (type));
1162 fprintf (asmfile, ";");
1164 else /* Output other integer types as subranges of `int'. */
1165 dbxout_range_type (type);
1170 /* This used to say `r1' and we used to take care
1171 to make sure that `int' was type number 1. */
1172 fprintf (asmfile, "r");
1173 dbxout_type_index (integer_type_node);
1174 fputc (';', asmfile);
1175 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, int_size_in_bytes (type));
1176 fputs (";0;", asmfile);
1181 if (use_gnu_debug_info_extensions)
1183 fputs ("@s", asmfile);
1184 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1185 BITS_PER_UNIT * int_size_in_bytes (type));
1186 fputs (";-20;", asmfile);
1190 /* Output the type `char' as a subrange of itself.
1191 That is what pcc seems to do. */
1192 fprintf (asmfile, "r");
1193 dbxout_type_index (char_type_node);
1194 fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1200 if (use_gnu_debug_info_extensions)
1202 fputs ("@s", asmfile);
1203 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1204 BITS_PER_UNIT * int_size_in_bytes (type));
1205 fputs (";-16;", asmfile);
1207 else /* Define as enumeral type (False, True) */
1208 fprintf (asmfile, "eFalse:0,True:1,;");
1213 putc ('d', asmfile);
1215 dbxout_type (TREE_TYPE (type), 0, 0);
1219 /* Differs from the REAL_TYPE by its new data type number */
1221 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1223 fprintf (asmfile, "r");
1224 dbxout_type_index (type);
1225 fputc (';', asmfile);
1226 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1227 int_size_in_bytes (TREE_TYPE (type)));
1228 fputs (";0;", asmfile);
1229 CHARS (12); /* The number is probably incorrect here. */
1233 /* Output a complex integer type as a structure,
1234 pending some other way to do it. */
1235 fputc ('s', asmfile);
1236 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, int_size_in_bytes (type));
1238 fprintf (asmfile, "real:");
1240 dbxout_type (TREE_TYPE (type), 0, 0);
1241 fprintf (asmfile, ",%d,%d;",
1242 0, TYPE_PRECISION (TREE_TYPE (type)));
1244 fprintf (asmfile, "imag:");
1246 dbxout_type (TREE_TYPE (type), 0, 0);
1247 fprintf (asmfile, ",%d,%d;;",
1248 TYPE_PRECISION (TREE_TYPE (type)),
1249 TYPE_PRECISION (TREE_TYPE (type)));
1255 if (use_gnu_debug_info_extensions)
1257 have_used_extensions = 1;
1258 fputs ("@s", asmfile);
1259 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1260 BITS_PER_UNIT * int_size_in_bytes (type));
1261 fputc (';', asmfile);
1262 /* Check if a bitstring type, which in Chill is
1263 different from a [power]set. */
1264 if (TYPE_STRING_FLAG (type))
1265 fprintf (asmfile, "@S;");
1267 putc ('S', asmfile);
1269 dbxout_type (TYPE_DOMAIN (type), 0, 0);
1273 /* Output "a" followed by a range type definition
1274 for the index type of the array
1275 followed by a reference to the target-type.
1276 ar1;0;N;M for a C array of type M and size N+1. */
1277 /* Check if a character string type, which in Chill is
1278 different from an array of characters. */
1279 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1281 have_used_extensions = 1;
1282 fprintf (asmfile, "@S;");
1284 tem = TYPE_DOMAIN (type);
1287 fprintf (asmfile, "ar");
1288 dbxout_type_index (integer_type_node);
1289 fprintf (asmfile, ";0;-1;");
1293 fprintf (asmfile, "a");
1294 dbxout_range_type (tem);
1297 dbxout_type (TREE_TYPE (type), 0, 0);
1302 case QUAL_UNION_TYPE:
1304 int i, n_baseclasses = 0;
1306 if (TYPE_BINFO (type) != 0
1307 && TREE_CODE (TYPE_BINFO (type)) == TREE_VEC
1308 && TYPE_BINFO_BASETYPES (type) != 0)
1309 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1311 /* Output a structure type. We must use the same test here as we
1312 use in the DBX_NO_XREFS case above. */
1313 if ((TYPE_NAME (type) != 0
1314 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1315 && DECL_IGNORED_P (TYPE_NAME (type)))
1317 || TYPE_SIZE (type) == 0
1318 /* No way in DBX fmt to describe a variable size. */
1319 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1321 /* If the type is just a cross reference, output one
1322 and mark the type as partially described.
1323 If it later becomes defined, we will output
1324 its real definition.
1325 If the type has a name, don't nest its definition within
1326 another type's definition; instead, output an xref
1327 and let the definition come when the name is defined. */
1328 fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu");
1330 #if 0 /* This assertion is legitimately false in C++. */
1331 /* We shouldn't be outputting a reference to a type before its
1332 definition unless the type has a tag name.
1333 A typedef name without a tag name should be impossible. */
1334 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1337 if (TYPE_NAME (type) != 0)
1338 dbxout_type_name (type);
1340 fprintf (asmfile, "$$%d", anonymous_type_number++);
1341 fprintf (asmfile, ":");
1342 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1346 /* Identify record or union, and print its size. */
1347 fputc (((TREE_CODE (type) == RECORD_TYPE) ? 's' : 'u'), asmfile);
1348 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1349 int_size_in_bytes (type));
1351 if (use_gnu_debug_info_extensions)
1355 have_used_extensions = 1;
1356 fprintf (asmfile, "!%d,", n_baseclasses);
1360 for (i = 0; i < n_baseclasses; i++)
1362 tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i);
1363 if (use_gnu_debug_info_extensions)
1365 have_used_extensions = 1;
1366 putc (TREE_VIA_VIRTUAL (child) ? '1'
1369 putc (TREE_VIA_PUBLIC (child) ? '2'
1372 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1373 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT);
1374 fputc (',', asmfile);
1376 dbxout_type (BINFO_TYPE (child), 0, 0);
1377 putc (';', asmfile);
1381 /* Print out the base class information with fields
1382 which have the same names at the types they hold. */
1383 dbxout_type_name (BINFO_TYPE (child));
1384 putc (':', asmfile);
1385 dbxout_type (BINFO_TYPE (child), full, 0);
1386 fputc (',', asmfile);
1387 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1388 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT);
1389 fputc (',', asmfile);
1390 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1391 TREE_INT_CST_LOW (DECL_SIZE (TYPE_NAME (BINFO_TYPE (child)))) * BITS_PER_UNIT);
1392 fputc (';', asmfile);
1400 /* Write out the field declarations. */
1401 dbxout_type_fields (type);
1402 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1404 have_used_extensions = 1;
1405 dbxout_type_methods (type);
1407 putc (';', asmfile);
1409 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1410 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1411 && TYPE_VFIELD (type))
1413 have_used_extensions = 1;
1415 /* Tell GDB+ that it may keep reading. */
1416 putc ('~', asmfile);
1418 /* We need to write out info about what field this class
1419 uses as its "main" vtable pointer field, because if this
1420 field is inherited from a base class, GDB cannot necessarily
1421 figure out which field it's using in time. */
1422 if (TYPE_VFIELD (type))
1424 putc ('%', asmfile);
1425 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0, 0);
1427 putc (';', asmfile);
1433 /* We must use the same test here as we use in the DBX_NO_XREFS case
1434 above. We simplify it a bit since an enum will never have a variable
1436 if ((TYPE_NAME (type) != 0
1437 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1438 && DECL_IGNORED_P (TYPE_NAME (type)))
1440 || TYPE_SIZE (type) == 0)
1442 fprintf (asmfile, "xe");
1444 dbxout_type_name (type);
1445 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1446 fprintf (asmfile, ":");
1449 #ifdef DBX_OUTPUT_ENUM
1450 DBX_OUTPUT_ENUM (asmfile, type);
1452 if (use_gnu_debug_info_extensions
1453 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1454 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1455 putc ('e', asmfile);
1457 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1459 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1460 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1461 fprintf (asmfile, HOST_WIDE_INT_PRINT_UNSIGNED,
1462 TREE_INT_CST_LOW (TREE_VALUE (tem)));
1463 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1464 && TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1465 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC,
1466 TREE_INT_CST_LOW (TREE_VALUE (tem)));
1468 print_int_cst_octal (TREE_VALUE (tem));
1469 fprintf (asmfile, ",");
1470 CHARS (20 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem)));
1471 if (TREE_CHAIN (tem) != 0)
1476 putc (';', asmfile);
1482 putc ('*', asmfile);
1484 dbxout_type (TREE_TYPE (type), 0, 0);
1488 if (use_gnu_debug_info_extensions)
1490 have_used_extensions = 1;
1491 putc ('#', asmfile);
1493 if (flag_minimal_debug && !show_arg_types)
1495 /* Normally, just output the return type.
1496 The argument types are encoded in the method name. */
1497 putc ('#', asmfile);
1499 dbxout_type (TREE_TYPE (type), 0, 0);
1500 putc (';', asmfile);
1505 /* When outputting destructors, we need to write
1506 the argument types out longhand. */
1507 dbxout_type (TYPE_METHOD_BASETYPE (type), 0, 0);
1508 putc (',', asmfile);
1510 dbxout_type (TREE_TYPE (type), 0, 0);
1511 dbxout_args (TYPE_ARG_TYPES (type));
1512 putc (';', asmfile);
1518 /* Treat it as a function type. */
1519 dbxout_type (TREE_TYPE (type), 0, 0);
1524 if (use_gnu_debug_info_extensions)
1526 have_used_extensions = 1;
1527 putc ('@', asmfile);
1529 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0, 0);
1530 putc (',', asmfile);
1532 dbxout_type (TREE_TYPE (type), 0, 0);
1536 /* Should print as an int, because it is really
1538 dbxout_type (integer_type_node, 0, 0);
1542 case REFERENCE_TYPE:
1543 if (use_gnu_debug_info_extensions)
1544 have_used_extensions = 1;
1545 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1547 dbxout_type (TREE_TYPE (type), 0, 0);
1551 putc ('f', asmfile);
1553 dbxout_type (TREE_TYPE (type), 0, 0);
1561 /* Print the value of integer constant C, in octal,
1562 handling double precision. */
1565 print_int_cst_octal (c)
1568 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1569 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1570 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1571 int width = TYPE_PRECISION (TREE_TYPE (c));
1573 /* GDB wants constants with no extra leading "1" bits, so
1574 we need to remove any sign-extension that might be
1576 if (width == HOST_BITS_PER_WIDE_INT * 2)
1578 else if (width > HOST_BITS_PER_WIDE_INT)
1579 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1580 else if (width == HOST_BITS_PER_WIDE_INT)
1583 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1585 fprintf (asmfile, "0");
1589 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1590 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1594 unsigned HOST_WIDE_INT beg = high >> excess;
1595 unsigned HOST_WIDE_INT middle
1596 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1597 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1598 unsigned HOST_WIDE_INT end
1599 = low & (((unsigned HOST_WIDE_INT) 1
1600 << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1603 fprintf (asmfile, "%o%01o", (int)beg, (int)middle);
1604 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1609 print_octal (value, digits)
1610 unsigned HOST_WIDE_INT value;
1615 for (i = digits - 1; i >= 0; i--)
1616 fprintf (asmfile, "%01o", (int)((value >> (3 * i)) & 7));
1619 /* Output the name of type TYPE, with no punctuation.
1620 Such names can be set up either by typedef declarations
1621 or by struct, enum and union tags. */
1624 dbxout_type_name (type)
1628 if (TYPE_NAME (type) == 0)
1630 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
1632 t = TYPE_NAME (type);
1634 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1636 t = DECL_NAME (TYPE_NAME (type));
1641 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
1642 CHARS (IDENTIFIER_LENGTH (t));
1645 /* Output a .stabs for the symbol defined by DECL,
1646 which must be a ..._DECL node in the normal namespace.
1647 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1648 LOCAL is nonzero if the scope is less than the entire file. */
1651 dbxout_symbol (decl, local)
1655 tree type = TREE_TYPE (decl);
1656 tree context = NULL_TREE;
1658 /* Cast avoids warning in old compilers. */
1659 current_sym_code = (STAB_CODE_TYPE) 0;
1660 current_sym_value = 0;
1661 current_sym_addr = 0;
1663 /* Ignore nameless syms, but don't ignore type tags. */
1665 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
1666 || DECL_IGNORED_P (decl))
1669 dbxout_prepare_symbol (decl);
1671 /* The output will always start with the symbol name,
1672 so always count that in the length-output-so-far. */
1674 if (DECL_NAME (decl) != 0)
1675 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
1677 switch (TREE_CODE (decl))
1680 /* Enum values are defined by defining the enum type. */
1684 if (DECL_RTL (decl) == 0)
1686 if (DECL_EXTERNAL (decl))
1688 /* Don't mention a nested function under its parent. */
1689 context = decl_function_context (decl);
1690 if (context == current_function_decl)
1692 if (GET_CODE (DECL_RTL (decl)) != MEM
1693 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
1697 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
1698 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1699 TREE_PUBLIC (decl) ? 'F' : 'f');
1701 current_sym_code = N_FUN;
1702 current_sym_addr = XEXP (DECL_RTL (decl), 0);
1704 if (TREE_TYPE (type))
1705 dbxout_type (TREE_TYPE (type), 0, 0);
1707 dbxout_type (void_type_node, 0, 0);
1709 /* For a nested function, when that function is compiled,
1710 mention the containing function name
1711 as well as (since dbx wants it) our own assembler-name. */
1713 fprintf (asmfile, ",%s,%s",
1714 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1715 IDENTIFIER_POINTER (DECL_NAME (context)));
1717 dbxout_finish_symbol (decl);
1722 /* This seems all wrong. Outputting most kinds of types gives no name
1723 at all. A true definition gives no name; a cross-ref for a
1724 structure can give the tag name, but not a type name.
1725 It seems that no typedef name is defined by outputting a type. */
1727 /* If this typedef name was defined by outputting the type,
1728 don't duplicate it. */
1729 if (typevec[TYPE_SYMTAB_ADDRESS (type)].status == TYPE_DEFINED
1730 && TYPE_NAME (TREE_TYPE (decl)) == decl)
1733 /* Don't output the same typedef twice.
1734 And don't output what language-specific stuff doesn't want output. */
1735 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
1744 if (DECL_NAME (decl))
1746 /* Nonzero means we must output a tag as well as a typedef. */
1749 /* Handle the case of a C++ structure or union
1750 where the TYPE_NAME is a TYPE_DECL
1751 which gives both a typedef name and a tag. */
1752 /* dbx requires the tag first and the typedef second. */
1753 if ((TREE_CODE (type) == RECORD_TYPE
1754 || TREE_CODE (type) == UNION_TYPE
1755 || TREE_CODE (type) == QUAL_UNION_TYPE)
1756 && TYPE_NAME (type) == decl
1757 && !(use_gnu_debug_info_extensions && have_used_extensions)
1758 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
1759 /* Distinguish the implicit typedefs of C++
1760 from explicit ones that might be found in C. */
1761 && DECL_ARTIFICIAL (decl))
1763 tree name = TYPE_NAME (type);
1764 if (TREE_CODE (name) == TYPE_DECL)
1765 name = DECL_NAME (name);
1767 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1768 current_sym_value = 0;
1769 current_sym_addr = 0;
1770 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1772 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1773 IDENTIFIER_POINTER (name));
1774 dbxout_type (type, 1, 0);
1775 dbxout_finish_symbol (NULL_TREE);
1778 /* Output typedef name. */
1779 fprintf (asmfile, "%s \"%s:", ASM_STABS_OP,
1780 IDENTIFIER_POINTER (DECL_NAME (decl)));
1782 /* Short cut way to output a tag also. */
1783 if ((TREE_CODE (type) == RECORD_TYPE
1784 || TREE_CODE (type) == UNION_TYPE
1785 || TREE_CODE (type) == QUAL_UNION_TYPE)
1786 && TYPE_NAME (type) == decl
1787 /* Distinguish the implicit typedefs of C++
1788 from explicit ones that might be found in C. */
1789 && DECL_ARTIFICIAL (decl))
1791 if (use_gnu_debug_info_extensions && have_used_extensions)
1793 putc ('T', asmfile);
1794 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
1796 #if 0 /* Now we generate the tag for this case up above. */
1802 putc ('t', asmfile);
1803 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1805 dbxout_type (type, 1, 0);
1806 dbxout_finish_symbol (decl);
1810 /* Don't output a tag if this is an incomplete type (TYPE_SIZE is
1811 zero). This prevents the sun4 Sun OS 4.x dbx from crashing. */
1813 if (tag_needed && TYPE_NAME (type) != 0
1814 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
1815 || (DECL_NAME (TYPE_NAME (type)) != 0))
1816 && TYPE_SIZE (type) != 0
1817 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
1819 /* For a TYPE_DECL with no name, but the type has a name,
1821 This is what represents `struct foo' with no typedef. */
1822 /* In C++, the name of a type is the corresponding typedef.
1823 In C, it is an IDENTIFIER_NODE. */
1824 tree name = TYPE_NAME (type);
1825 if (TREE_CODE (name) == TYPE_DECL)
1826 name = DECL_NAME (name);
1828 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1829 current_sym_value = 0;
1830 current_sym_addr = 0;
1831 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1833 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1834 IDENTIFIER_POINTER (name));
1835 dbxout_type (type, 1, 0);
1836 dbxout_finish_symbol (NULL_TREE);
1840 /* If an enum type has no name, it cannot be referred to,
1841 but we must output it anyway, since the enumeration constants
1842 can be referred to. */
1843 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
1845 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1846 current_sym_value = 0;
1847 current_sym_addr = 0;
1848 current_sym_nchars = 2;
1850 /* Some debuggers fail when given NULL names, so give this a
1851 harmless name of ` '. */
1852 fprintf (asmfile, "%s \" :T", ASM_STABS_OP);
1853 dbxout_type (type, 1, 0);
1854 dbxout_finish_symbol (NULL_TREE);
1857 /* Prevent duplicate output of a typedef. */
1858 TREE_ASM_WRITTEN (decl) = 1;
1863 /* Parm decls go in their own separate chains
1864 and are output by dbxout_reg_parms and dbxout_parms. */
1868 /* Named return value, treat like a VAR_DECL. */
1870 if (DECL_RTL (decl) == 0)
1872 /* Don't mention a variable that is external.
1873 Let the file that defines it describe it. */
1874 if (DECL_EXTERNAL (decl))
1877 /* If the variable is really a constant
1878 and not written in memory, inform the debugger. */
1879 if (TREE_STATIC (decl) && TREE_READONLY (decl)
1880 && DECL_INITIAL (decl) != 0
1881 && ! TREE_ASM_WRITTEN (decl)
1882 && (DECL_FIELD_CONTEXT (decl) == NULL_TREE
1883 || TREE_CODE (DECL_FIELD_CONTEXT (decl)) == BLOCK))
1885 if (TREE_PUBLIC (decl) == 0)
1887 /* The sun4 assembler does not grok this. */
1888 char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
1889 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
1890 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
1892 HOST_WIDE_INT ival = TREE_INT_CST_LOW (DECL_INITIAL (decl));
1893 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
1894 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile, name, ival);
1896 fprintf (asmfile, "%s \"%s:c=i", ASM_STABS_OP, name);
1898 fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, ival);
1899 fprintf (asmfile, "\",0x%x,0,0,0\n", N_LSYM);
1903 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
1905 /* don't know how to do this yet. */
1909 /* else it is something we handle like a normal variable. */
1912 DECL_RTL (decl) = eliminate_regs (DECL_RTL (decl), 0, NULL_RTX);
1913 #ifdef LEAF_REG_REMAP
1915 leaf_renumber_regs_insn (DECL_RTL (decl));
1918 dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
1926 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
1927 Add SUFFIX to its name, if SUFFIX is not 0.
1928 Describe the variable as residing in HOME
1929 (usually HOME is DECL_RTL (DECL), but not always). */
1932 dbxout_symbol_location (decl, type, suffix, home)
1940 /* Don't mention a variable at all
1941 if it was completely optimized into nothingness.
1943 If the decl was from an inline function, then it's rtl
1944 is not identically the rtl that was used in this
1945 particular compilation. */
1946 if (GET_CODE (home) == REG)
1948 regno = REGNO (home);
1949 if (regno >= FIRST_PSEUDO_REGISTER)
1952 else if (GET_CODE (home) == SUBREG)
1956 while (GET_CODE (value) == SUBREG)
1958 offset += SUBREG_WORD (value);
1959 value = SUBREG_REG (value);
1961 if (GET_CODE (value) == REG)
1963 regno = REGNO (value);
1964 if (regno >= FIRST_PSEUDO_REGISTER)
1968 alter_subreg (home);
1971 /* The kind-of-variable letter depends on where
1972 the variable is and on the scope of its name:
1973 G and N_GSYM for static storage and global scope,
1974 S for static storage and file scope,
1975 V for static storage and local scope,
1976 for those two, use N_LCSYM if data is in bss segment,
1977 N_STSYM if in data segment, N_FUN otherwise.
1978 (We used N_FUN originally, then changed to N_STSYM
1979 to please GDB. However, it seems that confused ld.
1980 Now GDB has been fixed to like N_FUN, says Kingdon.)
1981 no letter at all, and N_LSYM, for auto variable,
1982 r and N_RSYM for register variable. */
1984 if (GET_CODE (home) == MEM
1985 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
1987 if (TREE_PUBLIC (decl))
1990 current_sym_code = N_GSYM;
1994 current_sym_addr = XEXP (home, 0);
1996 letter = decl_function_context (decl) ? 'V' : 'S';
1998 /* This should be the same condition as in assemble_variable, but
1999 we don't have access to dont_output_data here. So, instead,
2000 we rely on the fact that error_mark_node initializers always
2001 end up in bss for C++ and never end up in bss for C. */
2002 if (DECL_INITIAL (decl) == 0
2003 || (!strcmp (lang_identify (), "cplusplus")
2004 && DECL_INITIAL (decl) == error_mark_node))
2005 current_sym_code = N_LCSYM;
2006 else if (DECL_IN_TEXT_SECTION (decl))
2007 /* This is not quite right, but it's the closest
2008 of all the codes that Unix defines. */
2009 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
2012 /* Ultrix `as' seems to need this. */
2013 #ifdef DBX_STATIC_STAB_DATA_SECTION
2016 current_sym_code = N_STSYM;
2020 else if (regno >= 0)
2023 current_sym_code = N_RSYM;
2024 current_sym_value = DBX_REGISTER_NUMBER (regno);
2026 else if (GET_CODE (home) == MEM
2027 && (GET_CODE (XEXP (home, 0)) == MEM
2028 || (GET_CODE (XEXP (home, 0)) == REG
2029 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
2030 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
2031 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2032 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
2035 /* If the value is indirect by memory or by a register
2036 that isn't the frame pointer
2037 then it means the object is variable-sized and address through
2038 that register or stack slot. DBX has no way to represent this
2039 so all we can do is output the variable as a pointer.
2040 If it's not a parameter, ignore it.
2041 (VAR_DECLs like this can be made by integrate.c.) */
2043 if (GET_CODE (XEXP (home, 0)) == REG)
2046 current_sym_code = N_RSYM;
2047 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2051 current_sym_code = N_LSYM;
2052 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2053 We want the value of that CONST_INT. */
2055 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2058 /* Effectively do build_pointer_type, but don't cache this type,
2059 since it might be temporary whereas the type it points to
2060 might have been saved for inlining. */
2061 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2062 type = make_node (POINTER_TYPE);
2063 TREE_TYPE (type) = TREE_TYPE (decl);
2065 else if (GET_CODE (home) == MEM
2066 && GET_CODE (XEXP (home, 0)) == REG)
2068 current_sym_code = N_LSYM;
2069 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2071 else if (GET_CODE (home) == MEM
2072 && GET_CODE (XEXP (home, 0)) == PLUS
2073 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2075 current_sym_code = N_LSYM;
2076 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2077 We want the value of that CONST_INT. */
2078 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2080 else if (GET_CODE (home) == MEM
2081 && GET_CODE (XEXP (home, 0)) == CONST)
2083 /* Handle an obscure case which can arise when optimizing and
2084 when there are few available registers. (This is *always*
2085 the case for i386/i486 targets). The RTL looks like
2086 (MEM (CONST ...)) even though this variable is a local `auto'
2087 or a local `register' variable. In effect, what has happened
2088 is that the reload pass has seen that all assignments and
2089 references for one such a local variable can be replaced by
2090 equivalent assignments and references to some static storage
2091 variable, thereby avoiding the need for a register. In such
2092 cases we're forced to lie to debuggers and tell them that
2093 this variable was itself `static'. */
2094 current_sym_code = N_LCSYM;
2096 current_sym_addr = XEXP (XEXP (home, 0), 0);
2098 else if (GET_CODE (home) == CONCAT)
2100 tree subtype = TREE_TYPE (type);
2102 /* If the variable's storage is in two parts,
2103 output each as a separate stab with a modified name. */
2104 if (WORDS_BIG_ENDIAN)
2105 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2107 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2109 /* Cast avoids warning in old compilers. */
2110 current_sym_code = (STAB_CODE_TYPE) 0;
2111 current_sym_value = 0;
2112 current_sym_addr = 0;
2113 dbxout_prepare_symbol (decl);
2115 if (WORDS_BIG_ENDIAN)
2116 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2118 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2122 /* Address might be a MEM, when DECL is a variable-sized object.
2123 Or it might be const0_rtx, meaning previous passes
2124 want us to ignore this variable. */
2127 /* Ok, start a symtab entry and output the variable name. */
2130 #ifdef DBX_STATIC_BLOCK_START
2131 DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2134 dbxout_symbol_name (decl, suffix, letter);
2135 dbxout_type (type, 0, 0);
2136 dbxout_finish_symbol (decl);
2138 #ifdef DBX_STATIC_BLOCK_END
2139 DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2143 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2144 Then output LETTER to indicate the kind of location the symbol has. */
2147 dbxout_symbol_name (decl, suffix, letter)
2152 /* One slight hitch: if this is a VAR_DECL which is a static
2153 class member, we must put out the mangled name instead of the
2154 DECL_NAME. Note also that static member (variable) names DO NOT begin
2155 with underscores in .stabs directives. */
2156 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2159 fprintf (asmfile, "%s \"%s%s:", ASM_STABS_OP, name,
2160 (suffix ? suffix : ""));
2162 if (letter) putc (letter, asmfile);
2166 dbxout_prepare_symbol (decl)
2170 char *filename = DECL_SOURCE_FILE (decl);
2172 dbxout_source_file (asmfile, filename);
2177 dbxout_finish_symbol (sym)
2180 #ifdef DBX_FINISH_SYMBOL
2181 DBX_FINISH_SYMBOL (sym);
2184 if (use_gnu_debug_info_extensions && sym != 0)
2185 line = DECL_SOURCE_LINE (sym);
2187 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2188 if (current_sym_addr)
2189 output_addr_const (asmfile, current_sym_addr);
2191 fprintf (asmfile, "%d", current_sym_value);
2192 putc ('\n', asmfile);
2196 /* Output definitions of all the decls in a chain. */
2204 dbxout_symbol (syms, 1);
2205 syms = TREE_CHAIN (syms);
2209 /* The following two functions output definitions of function parameters.
2210 Each parameter gets a definition locating it in the parameter list.
2211 Each parameter that is a register variable gets a second definition
2212 locating it in the register.
2214 Printing or argument lists in gdb uses the definitions that
2215 locate in the parameter list. But reference to the variable in
2216 expressions uses preferentially the definition as a register. */
2218 /* Output definitions, referring to storage in the parmlist,
2219 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2222 dbxout_parms (parms)
2225 for (; parms; parms = TREE_CHAIN (parms))
2226 if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2228 dbxout_prepare_symbol (parms);
2230 /* Perform any necessary register eliminations on the parameter's rtl,
2231 so that the debugging output will be accurate. */
2232 DECL_INCOMING_RTL (parms)
2233 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2234 DECL_RTL (parms) = eliminate_regs (DECL_RTL (parms), 0, NULL_RTX);
2235 #ifdef LEAF_REG_REMAP
2238 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2239 leaf_renumber_regs_insn (DECL_RTL (parms));
2243 if (PARM_PASSED_IN_MEMORY (parms))
2245 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2247 /* ??? Here we assume that the parm address is indexed
2248 off the frame pointer or arg pointer.
2249 If that is not true, we produce meaningless results,
2250 but do not crash. */
2251 if (GET_CODE (addr) == PLUS
2252 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2253 current_sym_value = INTVAL (XEXP (addr, 1));
2255 current_sym_value = 0;
2257 current_sym_code = N_PSYM;
2258 current_sym_addr = 0;
2261 if (DECL_NAME (parms))
2263 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2265 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2266 IDENTIFIER_POINTER (DECL_NAME (parms)),
2267 DBX_MEMPARM_STABS_LETTER);
2271 current_sym_nchars = 8;
2272 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2273 DBX_MEMPARM_STABS_LETTER);
2276 dbxout_type (DECL_ARG_TYPE (parms), 0, 0);
2277 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2278 dbxout_finish_symbol (parms);
2280 else if (GET_CODE (DECL_RTL (parms)) == REG)
2283 char regparm_letter;
2285 /* Parm passed in registers and lives in registers or nowhere. */
2287 current_sym_code = DBX_REGPARM_STABS_CODE;
2288 regparm_letter = DBX_REGPARM_STABS_LETTER;
2289 current_sym_addr = 0;
2291 /* If parm lives in a register, use that register;
2292 pretend the parm was passed there. It would be more consistent
2293 to describe the register where the parm was passed,
2294 but in practice that register usually holds something else.
2296 If we use DECL_RTL, then we must use the declared type of
2297 the variable, not the type that it arrived in. */
2298 if (REGNO (DECL_RTL (parms)) >= 0
2299 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2301 best_rtl = DECL_RTL (parms);
2302 parm_type = TREE_TYPE (parms);
2304 /* If the parm lives nowhere, use the register where it was
2305 passed. It is also better to use the declared type here. */
2308 best_rtl = DECL_INCOMING_RTL (parms);
2309 parm_type = TREE_TYPE (parms);
2311 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2314 if (DECL_NAME (parms))
2316 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2317 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2318 IDENTIFIER_POINTER (DECL_NAME (parms)),
2323 current_sym_nchars = 8;
2324 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2328 dbxout_type (parm_type, 0, 0);
2329 dbxout_finish_symbol (parms);
2331 else if (GET_CODE (DECL_RTL (parms)) == MEM
2332 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2333 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2334 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2335 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2336 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2340 /* Parm was passed via invisible reference.
2341 That is, its address was passed in a register.
2342 Output it as if it lived in that register.
2343 The debugger will know from the type
2344 that it was actually passed by invisible reference. */
2346 char regparm_letter;
2347 /* Parm passed in registers and lives in registers or nowhere. */
2349 current_sym_code = DBX_REGPARM_STABS_CODE;
2350 if (use_gnu_debug_info_extensions)
2351 regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2353 regparm_letter = DBX_REGPARM_STABS_LETTER;
2355 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2356 If it is an unallocated pseudo-reg, then use the register where
2357 it was passed instead. */
2358 if (REGNO (XEXP (DECL_RTL (parms), 0)) >= 0
2359 && REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2360 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2362 current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2364 current_sym_addr = 0;
2367 if (DECL_NAME (parms))
2369 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2371 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2372 IDENTIFIER_POINTER (DECL_NAME (parms)),
2377 current_sym_nchars = 8;
2378 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2382 dbxout_type (TREE_TYPE (parms), 0, 0);
2383 dbxout_finish_symbol (parms);
2385 else if (GET_CODE (DECL_RTL (parms)) == MEM
2386 && XEXP (DECL_RTL (parms), 0) != const0_rtx
2387 /* ??? A constant address for a parm can happen
2388 when the reg it lives in is equiv to a constant in memory.
2389 Should make this not happen, after 2.4. */
2390 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2392 /* Parm was passed in registers but lives on the stack. */
2394 current_sym_code = N_PSYM;
2395 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2396 in which case we want the value of that CONST_INT,
2397 or (MEM (REG ...)) or (MEM (MEM ...)),
2398 in which case we use a value of zero. */
2399 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2400 || GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2401 current_sym_value = 0;
2403 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2404 current_sym_addr = 0;
2407 if (DECL_NAME (parms))
2409 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2411 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2412 IDENTIFIER_POINTER (DECL_NAME (parms)),
2413 DBX_MEMPARM_STABS_LETTER);
2417 current_sym_nchars = 8;
2418 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2419 DBX_MEMPARM_STABS_LETTER);
2423 = DEBUGGER_ARG_OFFSET (current_sym_value,
2424 XEXP (DECL_RTL (parms), 0));
2425 dbxout_type (TREE_TYPE (parms), 0, 0);
2426 dbxout_finish_symbol (parms);
2431 /* Output definitions for the places where parms live during the function,
2432 when different from where they were passed, when the parms were passed
2435 It is not useful to do this for parms passed in registers
2436 that live during the function in different registers, because it is
2437 impossible to look in the passed register for the passed value,
2438 so we use the within-the-function register to begin with.
2440 PARMS is a chain of PARM_DECL nodes. */
2443 dbxout_reg_parms (parms)
2446 for (; parms; parms = TREE_CHAIN (parms))
2447 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
2449 dbxout_prepare_symbol (parms);
2451 /* Report parms that live in registers during the function
2452 but were passed in memory. */
2453 if (GET_CODE (DECL_RTL (parms)) == REG
2454 && REGNO (DECL_RTL (parms)) >= 0
2455 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2456 dbxout_symbol_location (parms, TREE_TYPE (parms),
2457 0, DECL_RTL (parms));
2458 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
2459 dbxout_symbol_location (parms, TREE_TYPE (parms),
2460 0, DECL_RTL (parms));
2461 /* Report parms that live in memory but not where they were passed. */
2462 else if (GET_CODE (DECL_RTL (parms)) == MEM
2463 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
2464 dbxout_symbol_location (parms, TREE_TYPE (parms),
2465 0, DECL_RTL (parms));
2469 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2470 output definitions of those names, in raw form */
2478 putc (',', asmfile);
2479 dbxout_type (TREE_VALUE (args), 0, 0);
2481 args = TREE_CHAIN (args);
2485 /* Given a chain of ..._TYPE nodes,
2486 find those which have typedef names and output those names.
2487 This is to ensure those types get output. */
2490 dbxout_types (types)
2491 register tree types;
2495 if (TYPE_NAME (types)
2496 && TREE_CODE (TYPE_NAME (types)) == TYPE_DECL
2497 && ! TREE_ASM_WRITTEN (TYPE_NAME (types)))
2498 dbxout_symbol (TYPE_NAME (types), 1);
2499 types = TREE_CHAIN (types);
2503 /* Output everything about a symbol block (a BLOCK node
2504 that represents a scope level),
2505 including recursive output of contained blocks.
2507 BLOCK is the BLOCK node.
2508 DEPTH is its depth within containing symbol blocks.
2509 ARGS is usually zero; but for the outermost block of the
2510 body of a function, it is a chain of PARM_DECLs for the function parameters.
2511 We output definitions of all the register parms
2512 as if they were local variables of that block.
2514 If -g1 was used, we count blocks just the same, but output nothing
2515 except for the outermost block.
2517 Actually, BLOCK may be several blocks chained together.
2518 We handle them all in sequence. */
2521 dbxout_block (block, depth, args)
2522 register tree block;
2530 /* Ignore blocks never expanded or otherwise marked as real. */
2531 if (TREE_USED (block))
2533 #ifndef DBX_LBRAC_FIRST
2534 /* In dbx format, the syms of a block come before the N_LBRAC. */
2535 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2536 dbxout_syms (BLOCK_VARS (block));
2538 dbxout_reg_parms (args);
2541 /* Now output an N_LBRAC symbol to represent the beginning of
2542 the block. Use the block's tree-walk order to generate
2543 the assembler symbols LBBn and LBEn
2544 that final will define around the code in this block. */
2545 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2548 blocknum = next_block_number++;
2549 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
2551 if (BLOCK_HANDLER_BLOCK (block))
2553 /* A catch block. Must precede N_LBRAC. */
2554 tree decl = BLOCK_VARS (block);
2557 #ifdef DBX_OUTPUT_CATCH
2558 DBX_OUTPUT_CATCH (asmfile, decl, buf);
2560 fprintf (asmfile, "%s \"%s:C1\",%d,0,0,", ASM_STABS_OP,
2561 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
2562 assemble_name (asmfile, buf);
2563 fprintf (asmfile, "\n");
2565 decl = TREE_CHAIN (decl);
2569 #ifdef DBX_OUTPUT_LBRAC
2570 DBX_OUTPUT_LBRAC (asmfile, buf);
2572 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);
2573 assemble_name (asmfile, buf);
2574 #if DBX_BLOCKS_FUNCTION_RELATIVE
2575 fputc ('-', asmfile);
2576 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2578 fprintf (asmfile, "\n");
2582 /* Count blocks the same way regardless of debug_info_level. */
2583 next_block_number++;
2585 #ifdef DBX_LBRAC_FIRST
2586 /* On some weird machines, the syms of a block
2587 come after the N_LBRAC. */
2588 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2589 dbxout_syms (BLOCK_VARS (block));
2591 dbxout_reg_parms (args);
2594 /* Output the subblocks. */
2595 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
2597 /* Refer to the marker for the end of the block. */
2598 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2601 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
2602 #ifdef DBX_OUTPUT_RBRAC
2603 DBX_OUTPUT_RBRAC (asmfile, buf);
2605 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);
2606 assemble_name (asmfile, buf);
2607 #if DBX_BLOCKS_FUNCTION_RELATIVE
2608 fputc ('-', asmfile);
2609 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2611 fprintf (asmfile, "\n");
2615 block = BLOCK_CHAIN (block);
2619 /* Output the information about a function and its arguments and result.
2620 Usually this follows the function's code,
2621 but on some systems, it comes before. */
2624 dbxout_really_begin_function (decl)
2627 dbxout_symbol (decl, 0);
2628 dbxout_parms (DECL_ARGUMENTS (decl));
2629 if (DECL_NAME (DECL_RESULT (decl)) != 0)
2630 dbxout_symbol (DECL_RESULT (decl), 1);
2633 /* Called at beginning of output of function definition. */
2636 dbxout_begin_function (decl)
2639 #ifdef DBX_FUNCTION_FIRST
2640 dbxout_really_begin_function (decl);
2644 /* Output dbx data for a function definition.
2645 This includes a definition of the function name itself (a symbol),
2646 definitions of the parameters (locating them in the parameter list)
2647 and then output the block that makes up the function's body
2648 (including all the auto variables of the function). */
2651 dbxout_function (decl)
2654 #ifndef DBX_FUNCTION_FIRST
2655 dbxout_really_begin_function (decl);
2657 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
2658 #ifdef DBX_OUTPUT_FUNCTION_END
2659 DBX_OUTPUT_FUNCTION_END (asmfile, decl);
2661 #if defined(ASM_OUTPUT_SECTION_NAME)
2662 if (use_gnu_debug_info_extensions
2663 #if defined(NO_DBX_FUNCTION_END)
2664 && ! NO_DBX_FUNCTION_END
2667 dbxout_function_end ();
2670 #endif /* DBX_DEBUGGING_INFO */