1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987, 88, 92-96, 1997 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'. */
87 #include "insn-config.h"
90 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
96 #ifdef XCOFF_DEBUGGING_INFO
101 #define ASM_STABS_OP ".stabs"
105 #define ASM_STABN_OP ".stabn"
108 #ifndef DBX_TYPE_DECL_STABS_CODE
109 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
112 #ifndef DBX_STATIC_CONST_VAR_CODE
113 #define DBX_STATIC_CONST_VAR_CODE N_FUN
116 #ifndef DBX_REGPARM_STABS_CODE
117 #define DBX_REGPARM_STABS_CODE N_RSYM
120 #ifndef DBX_REGPARM_STABS_LETTER
121 #define DBX_REGPARM_STABS_LETTER 'P'
124 /* This is used for parameters passed by invisible reference in a register. */
125 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
126 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
129 #ifndef DBX_MEMPARM_STABS_LETTER
130 #define DBX_MEMPARM_STABS_LETTER 'p'
133 #ifndef FILE_NAME_JOINER
134 #define FILE_NAME_JOINER "/"
137 /* Nonzero means if the type has methods, only output debugging
138 information if methods are actually written to the asm file. This
139 optimization only works if the debugger can detect the special C++
142 #define MINIMAL_DEBUG 1
144 #ifdef NO_DOLLAR_IN_LABEL
145 #ifdef NO_DOT_IN_LABEL
147 #define MINIMAL_DEBUG 0
151 static int flag_minimal_debug = MINIMAL_DEBUG;
153 /* Nonzero if we have actually used any of the GDB extensions
154 to the debugging format. The idea is that we use them for the
155 first time only if there's a strong reason, but once we have done that,
156 we use them whenever convenient. */
158 static int have_used_extensions = 0;
160 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
161 for the N_SO filename stabs label. */
163 static int source_label_number = 1;
165 static int scope_labelno = 0;
169 /* Typical USG systems don't have stab.h, and they also have
170 no use for DBX-format debugging info. */
172 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
174 #ifdef DEBUG_SYMS_TEXT
175 #define FORCE_TEXT text_section ();
180 #if defined (USG) || defined (NO_STAB_H) || defined (CROSS_COMPILE)
181 #include "gstab.h" /* If doing DBX on sysV, use our own stab.h. */
183 #include <stab.h> /* On BSD, use the system's stab.h. */
185 /* This is a GNU extension we need to reference in this file. */
192 #define STAB_CODE_TYPE enum __stab_debug_code
194 #define STAB_CODE_TYPE int
197 /* 1 if PARM is passed to this function in memory. */
199 #define PARM_PASSED_IN_MEMORY(PARM) \
200 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
202 /* A C expression for the integer offset value of an automatic variable
203 (N_LSYM) having address X (an RTX). */
204 #ifndef DEBUGGER_AUTO_OFFSET
205 #define DEBUGGER_AUTO_OFFSET(X) \
206 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
209 /* A C expression for the integer offset value of an argument (N_PSYM)
210 having address X (an RTX). The nominal offset is OFFSET. */
211 #ifndef DEBUGGER_ARG_OFFSET
212 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
215 /* Stream for writing to assembler file. */
217 static FILE *asmfile;
219 /* Last source file name mentioned in a NOTE insn. */
221 static char *lastfile;
223 /* Current working directory. */
227 enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
229 /* Structure recording information about a C data type.
230 The status element says whether we have yet output
231 the definition of the type. TYPE_XREF says we have
232 output it as a cross-reference only.
233 The file_number and type_number elements are used if DBX_USE_BINCL
238 enum typestatus status;
245 /* Vector recording information about C data types.
246 When we first notice a data type (a tree node),
247 we assign it a number using next_type_number.
248 That is its index in this vector. */
250 struct typeinfo *typevec;
252 /* Number of elements of space allocated in `typevec'. */
254 static int typevec_len;
256 /* In dbx output, each type gets a unique number.
257 This is the number for the next type output.
258 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
260 static int next_type_number;
264 /* When using N_BINCL in dbx output, each type number is actually a
265 pair of the file number and the type number within the file.
266 This is a stack of input files. */
270 struct dbx_file *next;
272 int next_type_number;
275 /* This is the top of the stack. */
277 static struct dbx_file *current_file;
279 /* This is the next file number to use. */
281 static int next_file_number;
283 #endif /* DBX_USE_BINCL */
285 /* In dbx output, we must assign symbol-blocks id numbers
286 in the order in which their beginnings are encountered.
287 We output debugging info that refers to the beginning and
288 end of the ranges of code in each block
289 with assembler labels LBBn and LBEn, where n is the block number.
290 The labels are generated in final, which assigns numbers to the
291 blocks in the same way. */
293 static int next_block_number;
295 /* These variables are for dbxout_symbol to communicate to
296 dbxout_finish_symbol.
297 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
298 current_sym_value and current_sym_addr are two ways to address the
299 value to store in the symtab entry.
300 current_sym_addr if nonzero represents the value as an rtx.
301 If that is zero, current_sym_value is used. This is used
302 when the value is an offset (such as for auto variables,
303 register variables and parms). */
305 static STAB_CODE_TYPE current_sym_code;
306 static int current_sym_value;
307 static rtx current_sym_addr;
309 /* Number of chars of symbol-description generated so far for the
310 current symbol. Used by CHARS and CONTIN. */
312 static int current_sym_nchars;
314 /* Report having output N chars of the current symbol-description. */
316 #define CHARS(N) (current_sym_nchars += (N))
318 /* Break the current symbol-description, generating a continuation,
319 if it has become long. */
321 #ifndef DBX_CONTIN_LENGTH
322 #define DBX_CONTIN_LENGTH 80
325 #if DBX_CONTIN_LENGTH > 0
327 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
332 void dbxout_types ();
334 void dbxout_symbol ();
336 static void dbxout_function_end PROTO((void));
337 static void dbxout_typedefs PROTO((tree));
338 static void dbxout_type_index PROTO((tree));
339 static void dbxout_continue PROTO((void));
340 static void dbxout_type_fields PROTO((tree));
341 static void dbxout_type_method_1 PROTO((tree, char *));
342 static void dbxout_type_methods PROTO((tree));
343 static void dbxout_range_type PROTO((tree));
344 static void dbxout_type PROTO((tree, int, int));
345 static void print_int_cst_octal PROTO((tree));
346 static void print_octal PROTO((unsigned HOST_WIDE_INT, int));
347 static void dbxout_type_name PROTO((tree));
348 static void dbxout_symbol_location PROTO((tree, tree, char *, rtx));
349 static void dbxout_symbol_name PROTO((tree, char *, int));
350 static void dbxout_prepare_symbol PROTO((tree));
351 static void dbxout_finish_symbol PROTO((tree));
352 static void dbxout_block PROTO((tree, int, tree));
353 static void dbxout_really_begin_function PROTO((tree));
356 dbxout_function_end ()
358 char lscope_label_name[100];
359 /* Convert Ltext into the appropriate format for local labels in case
360 the system doesn't insert underscores in front of user generated
362 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
363 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Lscope", scope_labelno);
366 /* By convention, GCC will mark the end of a function with an N_FUN
367 symbol and an empty string. */
368 fprintf (asmfile, "%s \"\",%d,0,0,", ASM_STABS_OP, N_FUN);
369 assemble_name (asmfile, lscope_label_name);
370 fputc ('-', asmfile);
371 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
372 fprintf (asmfile, "\n");
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)
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)
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 /* Continue a symbol-description that gets too big.
613 End one symbol table entry with a double-backslash
614 and start a new one, eventually producing something like
615 .stabs "start......\\",code,0,value
616 .stabs "...rest",code,0,value */
621 #ifdef DBX_CONTIN_CHAR
622 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
624 fprintf (asmfile, "\\\\");
626 dbxout_finish_symbol (NULL_TREE);
627 fprintf (asmfile, "%s \"", ASM_STABS_OP);
628 current_sym_nchars = 0;
631 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
632 This must be a separate function because anonymous unions require
636 dbxout_type_fields (type)
640 /* Output the name, type, position (in bits), size (in bits) of each
642 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
644 /* Omit here local type decls until we know how to support them. */
645 if (TREE_CODE (tem) == TYPE_DECL)
647 /* Omit fields whose position or size are variable. */
648 else if (TREE_CODE (tem) == FIELD_DECL
649 && (TREE_CODE (DECL_FIELD_BITPOS (tem)) != INTEGER_CST
650 || TREE_CODE (DECL_SIZE (tem)) != INTEGER_CST))
652 /* Omit here the nameless fields that are used to skip bits. */
653 else if (DECL_IGNORED_P (tem))
655 else if (TREE_CODE (tem) != CONST_DECL)
657 /* Continue the line if necessary,
658 but not before the first field. */
659 if (tem != TYPE_FIELDS (type))
662 if (use_gnu_debug_info_extensions
663 && flag_minimal_debug
664 && TREE_CODE (tem) == FIELD_DECL
665 && DECL_VIRTUAL_P (tem)
666 && DECL_ASSEMBLER_NAME (tem))
668 have_used_extensions = 1;
669 CHARS (3 + IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (tem)));
670 fputs (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem)), asmfile);
671 dbxout_type (DECL_FCONTEXT (tem), 0, 0);
672 fprintf (asmfile, ":");
673 dbxout_type (TREE_TYPE (tem), 0, 0);
674 fprintf (asmfile, ",%d;",
675 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)));
681 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
682 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
686 fprintf (asmfile, ":");
690 if (use_gnu_debug_info_extensions
691 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
692 || TREE_CODE (tem) != FIELD_DECL))
694 have_used_extensions = 1;
696 putc ((TREE_PRIVATE (tem) ? '0'
697 : TREE_PROTECTED (tem) ? '1' : '2'),
702 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
703 && DECL_BIT_FIELD_TYPE (tem))
704 ? DECL_BIT_FIELD_TYPE (tem)
705 : TREE_TYPE (tem), 0, 0);
707 if (TREE_CODE (tem) == VAR_DECL)
709 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
711 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem));
712 have_used_extensions = 1;
713 fprintf (asmfile, ":%s;", name);
714 CHARS (strlen (name));
718 /* If TEM is non-static, GDB won't understand it. */
719 fprintf (asmfile, ",0,0;");
722 else if (TREE_CODE (DECL_FIELD_BITPOS (tem)) == INTEGER_CST)
724 fprintf (asmfile, ",%d,%d;",
725 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)),
726 TREE_INT_CST_LOW (DECL_SIZE (tem)));
733 /* Subroutine of `dbxout_type_methods'. Output debug info about the
734 method described DECL. DEBUG_NAME is an encoding of the method's
735 type signature. ??? We may be able to do without DEBUG_NAME altogether
739 dbxout_type_method_1 (decl, debug_name)
745 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
747 else /* it's a METHOD_TYPE. */
749 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
750 /* A for normal functions.
751 B for `const' member functions.
752 C for `volatile' member functions.
753 D for `const volatile' member functions. */
754 if (TYPE_READONLY (TREE_TYPE (firstarg)))
756 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
759 if (DECL_VINDEX (decl))
765 fprintf (asmfile, ":%s;%c%c%c", debug_name,
766 TREE_PRIVATE (decl) ? '0' : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
767 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
768 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
769 if (DECL_VINDEX (decl))
771 fprintf (asmfile, "%d;",
772 TREE_INT_CST_LOW (DECL_VINDEX (decl)));
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)
961 fprintf (asmfile, ";%d",
962 TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)));
964 fprintf (asmfile, ";0");
965 if (TYPE_MAX_VALUE (type)
966 && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST)
967 fprintf (asmfile, ";%d;",
968 TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)));
970 fprintf (asmfile, ";-1;");
973 /* Output a reference to a type. If the type has not yet been
974 described in the dbx output, output its definition now.
975 For a type already defined, just refer to its definition
976 using the type number.
978 If FULL is nonzero, and the type has been described only with
979 a forward-reference, output the definition now.
980 If FULL is zero in this case, just refer to the forward-reference
981 using the number previously allocated.
983 If SHOW_ARG_TYPES is nonzero, we output a description of the argument
984 types for a METHOD_TYPE. */
987 dbxout_type (type, full, show_arg_types)
993 static int anonymous_type_number = 0;
995 /* If there was an input error and we don't really have a type,
996 avoid crashing and write something that is at least valid
997 by assuming `int'. */
998 if (type == error_mark_node)
999 type = integer_type_node;
1002 /* Try to find the "main variant" with the same name but not const
1003 or volatile. (Since stabs does not distinguish const and volatile,
1004 there is no need to make them separate types. But types with
1005 different names are usefully distinguished.) */
1007 for (tem = TYPE_MAIN_VARIANT (type); tem; tem = TYPE_NEXT_VARIANT (tem))
1008 if (!TYPE_READONLY (tem) && !TYPE_VOLATILE (tem)
1009 && TYPE_NAME (tem) == TYPE_NAME (type))
1014 if (TYPE_NAME (type)
1015 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1016 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1020 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1022 /* Type has no dbx number assigned. Assign next available number. */
1023 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1025 /* Make sure type vector is long enough to record about this type. */
1027 if (next_type_number == typevec_len)
1030 = (struct typeinfo *) xrealloc (typevec,
1031 typevec_len * 2 * sizeof typevec[0]);
1032 bzero ((char *) (typevec + typevec_len),
1033 typevec_len * sizeof typevec[0]);
1037 #ifdef DBX_USE_BINCL
1038 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1039 = current_file->file_number;
1040 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1041 = current_file->next_type_number++;
1045 /* Output the number of this type, to refer to it. */
1046 dbxout_type_index (type);
1048 #ifdef DBX_TYPE_DEFINED
1049 if (DBX_TYPE_DEFINED (type))
1053 /* If this type's definition has been output or is now being output,
1056 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1061 /* If we have already had a cross reference,
1062 and either that's all we want or that's the best we could do,
1063 don't repeat the cross reference.
1064 Sun dbx crashes if we do. */
1065 if (! full || TYPE_SIZE (type) == 0
1066 /* No way in DBX fmt to describe a variable size. */
1067 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1075 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1076 leave the type-number completely undefined rather than output
1077 a cross-reference. If we have already used GNU debug info extensions,
1078 then it is OK to output a cross reference. This is necessary to get
1079 proper C++ debug output. */
1080 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1081 || TREE_CODE (type) == QUAL_UNION_TYPE
1082 || TREE_CODE (type) == ENUMERAL_TYPE)
1083 && ! use_gnu_debug_info_extensions)
1084 /* We must use the same test here as we use twice below when deciding
1085 whether to emit a cross-reference. */
1086 if ((TYPE_NAME (type) != 0
1087 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1088 && DECL_IGNORED_P (TYPE_NAME (type)))
1090 || TYPE_SIZE (type) == 0
1091 /* No way in DBX fmt to describe a variable size. */
1092 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1094 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1099 /* Output a definition now. */
1101 fprintf (asmfile, "=");
1104 /* Mark it as defined, so that if it is self-referent
1105 we will not get into an infinite recursion of definitions. */
1107 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1109 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1110 && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1112 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0, 0);
1116 switch (TREE_CODE (type))
1120 /* For a void type, just define it as itself; ie, "5=5".
1121 This makes us consider it defined
1122 without saying what it is. The debugger will make it
1123 a void type when the reference is seen, and nothing will
1124 ever override that default. */
1125 dbxout_type_index (type);
1129 if (type == char_type_node && ! TREE_UNSIGNED (type))
1131 /* Output the type `char' as a subrange of itself!
1132 I don't understand this definition, just copied it
1133 from the output of pcc.
1134 This used to use `r2' explicitly and we used to
1135 take care to make sure that `char' was type number 2. */
1136 fprintf (asmfile, "r");
1137 dbxout_type_index (type);
1138 fprintf (asmfile, ";0;127;");
1140 else if (use_gnu_debug_info_extensions
1141 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1142 || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT))
1144 /* This used to say `r1' and we used to take care
1145 to make sure that `int' was type number 1. */
1146 fprintf (asmfile, "r");
1147 dbxout_type_index (integer_type_node);
1148 fprintf (asmfile, ";");
1149 print_int_cst_octal (TYPE_MIN_VALUE (type));
1150 fprintf (asmfile, ";");
1151 print_int_cst_octal (TYPE_MAX_VALUE (type));
1152 fprintf (asmfile, ";");
1154 else /* Output other integer types as subranges of `int'. */
1155 dbxout_range_type (type);
1160 /* This used to say `r1' and we used to take care
1161 to make sure that `int' was type number 1. */
1162 fprintf (asmfile, "r");
1163 dbxout_type_index (integer_type_node);
1164 fprintf (asmfile, ";%d;0;", int_size_in_bytes (type));
1169 if (use_gnu_debug_info_extensions)
1170 fprintf (asmfile, "@s%d;-20;",
1171 BITS_PER_UNIT * int_size_in_bytes (type));
1174 /* Output the type `char' as a subrange of itself.
1175 That is what pcc seems to do. */
1176 fprintf (asmfile, "r");
1177 dbxout_type_index (char_type_node);
1178 fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1184 if (use_gnu_debug_info_extensions)
1185 fprintf (asmfile, "@s%d;-16;",
1186 BITS_PER_UNIT * int_size_in_bytes (type));
1187 else /* Define as enumeral type (False, True) */
1188 fprintf (asmfile, "eFalse:0,True:1,;");
1193 putc ('d', asmfile);
1195 dbxout_type (TREE_TYPE (type), 0, 0);
1199 /* Differs from the REAL_TYPE by its new data type number */
1201 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1203 fprintf (asmfile, "r");
1204 dbxout_type_index (type);
1205 fprintf (asmfile, ";%d;0;",
1206 int_size_in_bytes (TREE_TYPE (type)));
1207 CHARS (12); /* The number is probably incorrect here. */
1211 /* Output a complex integer type as a structure,
1212 pending some other way to do it. */
1213 fprintf (asmfile, "s%d", int_size_in_bytes (type));
1215 fprintf (asmfile, "real:");
1217 dbxout_type (TREE_TYPE (type), 0, 0);
1218 fprintf (asmfile, ",%d,%d;",
1219 0, TYPE_PRECISION (TREE_TYPE (type)));
1221 fprintf (asmfile, "imag:");
1223 dbxout_type (TREE_TYPE (type), 0, 0);
1224 fprintf (asmfile, ",%d,%d;;",
1225 TYPE_PRECISION (TREE_TYPE (type)),
1226 TYPE_PRECISION (TREE_TYPE (type)));
1232 if (use_gnu_debug_info_extensions)
1234 have_used_extensions = 1;
1235 fprintf (asmfile, "@s%d;",
1236 BITS_PER_UNIT * int_size_in_bytes (type));
1237 /* Check if a bitstring type, which in Chill is
1238 different from a [power]set. */
1239 if (TYPE_STRING_FLAG (type))
1240 fprintf (asmfile, "@S;");
1242 putc ('S', asmfile);
1244 dbxout_type (TYPE_DOMAIN (type), 0, 0);
1248 /* Output "a" followed by a range type definition
1249 for the index type of the array
1250 followed by a reference to the target-type.
1251 ar1;0;N;M for a C array of type M and size N+1. */
1252 /* Check if a character string type, which in Chill is
1253 different from an array of characters. */
1254 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1256 have_used_extensions = 1;
1257 fprintf (asmfile, "@S;");
1259 tem = TYPE_DOMAIN (type);
1262 fprintf (asmfile, "ar");
1263 dbxout_type_index (integer_type_node);
1264 fprintf (asmfile, ";0;-1;");
1268 fprintf (asmfile, "a");
1269 dbxout_range_type (tem);
1272 dbxout_type (TREE_TYPE (type), 0, 0);
1277 case QUAL_UNION_TYPE:
1279 int i, n_baseclasses = 0;
1281 if (TYPE_BINFO (type) != 0
1282 && TREE_CODE (TYPE_BINFO (type)) == TREE_VEC
1283 && TYPE_BINFO_BASETYPES (type) != 0)
1284 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1286 /* Output a structure type. We must use the same test here as we
1287 use in the DBX_NO_XREFS case above. */
1288 if ((TYPE_NAME (type) != 0
1289 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1290 && DECL_IGNORED_P (TYPE_NAME (type)))
1292 || TYPE_SIZE (type) == 0
1293 /* No way in DBX fmt to describe a variable size. */
1294 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1296 /* If the type is just a cross reference, output one
1297 and mark the type as partially described.
1298 If it later becomes defined, we will output
1299 its real definition.
1300 If the type has a name, don't nest its definition within
1301 another type's definition; instead, output an xref
1302 and let the definition come when the name is defined. */
1303 fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu");
1305 #if 0 /* This assertion is legitimately false in C++. */
1306 /* We shouldn't be outputting a reference to a type before its
1307 definition unless the type has a tag name.
1308 A typedef name without a tag name should be impossible. */
1309 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1312 if (TYPE_NAME (type) != 0)
1313 dbxout_type_name (type);
1315 fprintf (asmfile, "$$%d", anonymous_type_number++);
1316 fprintf (asmfile, ":");
1317 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1321 /* Identify record or union, and print its size. */
1322 fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "s%d" : "u%d",
1323 int_size_in_bytes (type));
1325 if (use_gnu_debug_info_extensions)
1329 have_used_extensions = 1;
1330 fprintf (asmfile, "!%d,", n_baseclasses);
1334 for (i = 0; i < n_baseclasses; i++)
1336 tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i);
1337 if (use_gnu_debug_info_extensions)
1339 have_used_extensions = 1;
1340 putc (TREE_VIA_VIRTUAL (child) ? '1'
1343 putc (TREE_VIA_PUBLIC (child) ? '2'
1346 fprintf (asmfile, "%d,",
1347 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT);
1349 dbxout_type (BINFO_TYPE (child), 0, 0);
1350 putc (';', asmfile);
1354 /* Print out the base class information with fields
1355 which have the same names at the types they hold. */
1356 dbxout_type_name (BINFO_TYPE (child));
1357 putc (':', asmfile);
1358 dbxout_type (BINFO_TYPE (child), full, 0);
1359 fprintf (asmfile, ",%d,%d;",
1360 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT,
1361 TREE_INT_CST_LOW (DECL_SIZE (TYPE_NAME (BINFO_TYPE (child)))) * BITS_PER_UNIT);
1369 /* Write out the field declarations. */
1370 dbxout_type_fields (type);
1371 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1373 have_used_extensions = 1;
1374 dbxout_type_methods (type);
1376 putc (';', asmfile);
1378 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1379 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1380 && TYPE_VFIELD (type))
1382 have_used_extensions = 1;
1384 /* Tell GDB+ that it may keep reading. */
1385 putc ('~', asmfile);
1387 /* We need to write out info about what field this class
1388 uses as its "main" vtable pointer field, because if this
1389 field is inherited from a base class, GDB cannot necessarily
1390 figure out which field it's using in time. */
1391 if (TYPE_VFIELD (type))
1393 putc ('%', asmfile);
1394 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0, 0);
1396 putc (';', asmfile);
1402 /* We must use the same test here as we use in the DBX_NO_XREFS case
1403 above. We simplify it a bit since an enum will never have a variable
1405 if ((TYPE_NAME (type) != 0
1406 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1407 && DECL_IGNORED_P (TYPE_NAME (type)))
1409 || TYPE_SIZE (type) == 0)
1411 fprintf (asmfile, "xe");
1413 dbxout_type_name (type);
1414 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1415 fprintf (asmfile, ":");
1418 #ifdef DBX_OUTPUT_ENUM
1419 DBX_OUTPUT_ENUM (asmfile, type);
1421 if (use_gnu_debug_info_extensions
1422 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1423 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1424 putc ('e', asmfile);
1426 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1428 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1429 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1430 fprintf (asmfile, "%lu",
1431 (unsigned long) TREE_INT_CST_LOW (TREE_VALUE (tem)));
1432 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1433 && TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1434 fprintf (asmfile, "%ld",
1435 (long) TREE_INT_CST_LOW (TREE_VALUE (tem)));
1437 print_int_cst_octal (TREE_VALUE (tem));
1438 fprintf (asmfile, ",");
1439 CHARS (20 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem)));
1440 if (TREE_CHAIN (tem) != 0)
1443 putc (';', asmfile);
1449 putc ('*', asmfile);
1451 dbxout_type (TREE_TYPE (type), 0, 0);
1455 if (use_gnu_debug_info_extensions)
1457 have_used_extensions = 1;
1458 putc ('#', asmfile);
1460 if (flag_minimal_debug && !show_arg_types)
1462 /* Normally, just output the return type.
1463 The argument types are encoded in the method name. */
1464 putc ('#', asmfile);
1466 dbxout_type (TREE_TYPE (type), 0, 0);
1467 putc (';', asmfile);
1472 /* When outputting destructors, we need to write
1473 the argument types out longhand. */
1474 dbxout_type (TYPE_METHOD_BASETYPE (type), 0, 0);
1475 putc (',', asmfile);
1477 dbxout_type (TREE_TYPE (type), 0, 0);
1478 dbxout_args (TYPE_ARG_TYPES (type));
1479 putc (';', asmfile);
1485 /* Treat it as a function type. */
1486 dbxout_type (TREE_TYPE (type), 0, 0);
1491 if (use_gnu_debug_info_extensions)
1493 have_used_extensions = 1;
1494 putc ('@', asmfile);
1496 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0, 0);
1497 putc (',', asmfile);
1499 dbxout_type (TREE_TYPE (type), 0, 0);
1503 /* Should print as an int, because it is really
1505 dbxout_type (integer_type_node, 0, 0);
1509 case REFERENCE_TYPE:
1510 if (use_gnu_debug_info_extensions)
1511 have_used_extensions = 1;
1512 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1514 dbxout_type (TREE_TYPE (type), 0, 0);
1518 putc ('f', asmfile);
1520 dbxout_type (TREE_TYPE (type), 0, 0);
1528 /* Print the value of integer constant C, in octal,
1529 handling double precision. */
1532 print_int_cst_octal (c)
1535 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1536 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1537 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1538 int width = TYPE_PRECISION (TREE_TYPE (c));
1540 /* GDB wants constants with no extra leading "1" bits, so
1541 we need to remove any sign-extension that might be
1543 if (width == HOST_BITS_PER_WIDE_INT * 2)
1545 else if (width > HOST_BITS_PER_WIDE_INT)
1546 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1547 else if (width == HOST_BITS_PER_WIDE_INT)
1550 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1552 fprintf (asmfile, "0");
1556 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1557 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1561 unsigned HOST_WIDE_INT beg = high >> excess;
1562 unsigned HOST_WIDE_INT middle
1563 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1564 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1565 unsigned HOST_WIDE_INT end
1566 = low & (((unsigned HOST_WIDE_INT) 1
1567 << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1570 fprintf (asmfile, "%o%01o", beg, middle);
1571 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1576 print_octal (value, digits)
1577 unsigned HOST_WIDE_INT value;
1582 for (i = digits - 1; i >= 0; i--)
1583 fprintf (asmfile, "%01o", ((value >> (3 * i)) & 7));
1586 /* Output the name of type TYPE, with no punctuation.
1587 Such names can be set up either by typedef declarations
1588 or by struct, enum and union tags. */
1591 dbxout_type_name (type)
1595 if (TYPE_NAME (type) == 0)
1597 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
1599 t = TYPE_NAME (type);
1601 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1603 t = DECL_NAME (TYPE_NAME (type));
1608 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
1609 CHARS (IDENTIFIER_LENGTH (t));
1612 /* Output a .stabs for the symbol defined by DECL,
1613 which must be a ..._DECL node in the normal namespace.
1614 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1615 LOCAL is nonzero if the scope is less than the entire file. */
1618 dbxout_symbol (decl, local)
1622 tree type = TREE_TYPE (decl);
1623 tree context = NULL_TREE;
1625 /* Cast avoids warning in old compilers. */
1626 current_sym_code = (STAB_CODE_TYPE) 0;
1627 current_sym_value = 0;
1628 current_sym_addr = 0;
1630 /* Ignore nameless syms, but don't ignore type tags. */
1632 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
1633 || DECL_IGNORED_P (decl))
1636 dbxout_prepare_symbol (decl);
1638 /* The output will always start with the symbol name,
1639 so always count that in the length-output-so-far. */
1641 if (DECL_NAME (decl) != 0)
1642 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
1644 switch (TREE_CODE (decl))
1647 /* Enum values are defined by defining the enum type. */
1651 if (DECL_RTL (decl) == 0)
1653 if (DECL_EXTERNAL (decl))
1655 /* Don't mention a nested function under its parent. */
1656 context = decl_function_context (decl);
1657 if (context == current_function_decl)
1659 if (GET_CODE (DECL_RTL (decl)) != MEM
1660 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
1664 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
1665 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1666 TREE_PUBLIC (decl) ? 'F' : 'f');
1668 current_sym_code = N_FUN;
1669 current_sym_addr = XEXP (DECL_RTL (decl), 0);
1671 if (TREE_TYPE (type))
1672 dbxout_type (TREE_TYPE (type), 0, 0);
1674 dbxout_type (void_type_node, 0, 0);
1676 /* For a nested function, when that function is compiled,
1677 mention the containing function name
1678 as well as (since dbx wants it) our own assembler-name. */
1680 fprintf (asmfile, ",%s,%s",
1681 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1682 IDENTIFIER_POINTER (DECL_NAME (context)));
1684 dbxout_finish_symbol (decl);
1689 /* This seems all wrong. Outputting most kinds of types gives no name
1690 at all. A true definition gives no name; a cross-ref for a
1691 structure can give the tag name, but not a type name.
1692 It seems that no typedef name is defined by outputting a type. */
1694 /* If this typedef name was defined by outputting the type,
1695 don't duplicate it. */
1696 if (typevec[TYPE_SYMTAB_ADDRESS (type)].status == TYPE_DEFINED
1697 && TYPE_NAME (TREE_TYPE (decl)) == decl)
1700 /* Don't output the same typedef twice.
1701 And don't output what language-specific stuff doesn't want output. */
1702 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
1711 if (DECL_NAME (decl))
1713 /* Nonzero means we must output a tag as well as a typedef. */
1716 /* Handle the case of a C++ structure or union
1717 where the TYPE_NAME is a TYPE_DECL
1718 which gives both a typedef name and a tag. */
1719 /* dbx requires the tag first and the typedef second. */
1720 if ((TREE_CODE (type) == RECORD_TYPE
1721 || TREE_CODE (type) == UNION_TYPE
1722 || TREE_CODE (type) == QUAL_UNION_TYPE)
1723 && TYPE_NAME (type) == decl
1724 && !(use_gnu_debug_info_extensions && have_used_extensions)
1725 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
1726 /* Distinguish the implicit typedefs of C++
1727 from explicit ones that might be found in C. */
1728 && DECL_ARTIFICIAL (decl))
1730 tree name = TYPE_NAME (type);
1731 if (TREE_CODE (name) == TYPE_DECL)
1732 name = DECL_NAME (name);
1734 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1735 current_sym_value = 0;
1736 current_sym_addr = 0;
1737 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1739 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1740 IDENTIFIER_POINTER (name));
1741 dbxout_type (type, 1, 0);
1742 dbxout_finish_symbol (NULL_TREE);
1745 /* Output typedef name. */
1746 fprintf (asmfile, "%s \"%s:", ASM_STABS_OP,
1747 IDENTIFIER_POINTER (DECL_NAME (decl)));
1749 /* Short cut way to output a tag also. */
1750 if ((TREE_CODE (type) == RECORD_TYPE
1751 || TREE_CODE (type) == UNION_TYPE
1752 || TREE_CODE (type) == QUAL_UNION_TYPE)
1753 && TYPE_NAME (type) == decl
1754 /* Distinguish the implicit typedefs of C++
1755 from explicit ones that might be found in C. */
1756 && DECL_ARTIFICIAL (decl))
1758 if (use_gnu_debug_info_extensions && have_used_extensions)
1760 putc ('T', asmfile);
1761 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
1763 #if 0 /* Now we generate the tag for this case up above. */
1769 putc ('t', asmfile);
1770 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1772 dbxout_type (type, 1, 0);
1773 dbxout_finish_symbol (decl);
1777 /* Don't output a tag if this is an incomplete type (TYPE_SIZE is
1778 zero). This prevents the sun4 Sun OS 4.x dbx from crashing. */
1780 if (tag_needed && TYPE_NAME (type) != 0
1781 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
1782 || (DECL_NAME (TYPE_NAME (type)) != 0))
1783 && TYPE_SIZE (type) != 0
1784 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
1786 /* For a TYPE_DECL with no name, but the type has a name,
1788 This is what represents `struct foo' with no typedef. */
1789 /* In C++, the name of a type is the corresponding typedef.
1790 In C, it is an IDENTIFIER_NODE. */
1791 tree name = TYPE_NAME (type);
1792 if (TREE_CODE (name) == TYPE_DECL)
1793 name = DECL_NAME (name);
1795 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1796 current_sym_value = 0;
1797 current_sym_addr = 0;
1798 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1800 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1801 IDENTIFIER_POINTER (name));
1802 dbxout_type (type, 1, 0);
1803 dbxout_finish_symbol (NULL_TREE);
1807 /* If an enum type has no name, it cannot be referred to,
1808 but we must output it anyway, since the enumeration constants
1809 can be referred to. */
1810 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
1812 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1813 current_sym_value = 0;
1814 current_sym_addr = 0;
1815 current_sym_nchars = 2;
1817 /* Some debuggers fail when given NULL names, so give this a
1818 harmless name of ` '. */
1819 fprintf (asmfile, "%s \" :T", ASM_STABS_OP);
1820 dbxout_type (type, 1, 0);
1821 dbxout_finish_symbol (NULL_TREE);
1824 /* Prevent duplicate output of a typedef. */
1825 TREE_ASM_WRITTEN (decl) = 1;
1830 /* Parm decls go in their own separate chains
1831 and are output by dbxout_reg_parms and dbxout_parms. */
1835 /* Named return value, treat like a VAR_DECL. */
1837 if (DECL_RTL (decl) == 0)
1839 /* Don't mention a variable that is external.
1840 Let the file that defines it describe it. */
1841 if (DECL_EXTERNAL (decl))
1844 /* If the variable is really a constant
1845 and not written in memory, inform the debugger. */
1846 if (TREE_STATIC (decl) && TREE_READONLY (decl)
1847 && DECL_INITIAL (decl) != 0
1848 && ! TREE_ASM_WRITTEN (decl)
1849 && (DECL_FIELD_CONTEXT (decl) == NULL_TREE
1850 || TREE_CODE (DECL_FIELD_CONTEXT (decl)) == BLOCK))
1852 if (TREE_PUBLIC (decl) == 0)
1854 /* The sun4 assembler does not grok this. */
1855 char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
1856 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
1857 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
1859 HOST_WIDE_INT ival = TREE_INT_CST_LOW (DECL_INITIAL (decl));
1860 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
1861 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile, name, ival);
1863 fprintf (asmfile, "%s \"%s:c=i%d\",0x%x,0,0,0\n",
1864 ASM_STABS_OP, name, ival, N_LSYM);
1868 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
1870 /* don't know how to do this yet. */
1874 /* else it is something we handle like a normal variable. */
1877 DECL_RTL (decl) = eliminate_regs (DECL_RTL (decl), 0, NULL_RTX);
1878 #ifdef LEAF_REG_REMAP
1880 leaf_renumber_regs_insn (DECL_RTL (decl));
1883 dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
1891 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
1892 Add SUFFIX to its name, if SUFFIX is not 0.
1893 Describe the variable as residing in HOME
1894 (usually HOME is DECL_RTL (DECL), but not always). */
1897 dbxout_symbol_location (decl, type, suffix, home)
1905 /* Don't mention a variable at all
1906 if it was completely optimized into nothingness.
1908 If the decl was from an inline function, then it's rtl
1909 is not identically the rtl that was used in this
1910 particular compilation. */
1911 if (GET_CODE (home) == REG)
1913 regno = REGNO (home);
1914 if (regno >= FIRST_PSEUDO_REGISTER)
1917 else if (GET_CODE (home) == SUBREG)
1921 while (GET_CODE (value) == SUBREG)
1923 offset += SUBREG_WORD (value);
1924 value = SUBREG_REG (value);
1926 if (GET_CODE (value) == REG)
1928 regno = REGNO (value);
1929 if (regno >= FIRST_PSEUDO_REGISTER)
1933 alter_subreg (home);
1936 /* The kind-of-variable letter depends on where
1937 the variable is and on the scope of its name:
1938 G and N_GSYM for static storage and global scope,
1939 S for static storage and file scope,
1940 V for static storage and local scope,
1941 for those two, use N_LCSYM if data is in bss segment,
1942 N_STSYM if in data segment, N_FUN otherwise.
1943 (We used N_FUN originally, then changed to N_STSYM
1944 to please GDB. However, it seems that confused ld.
1945 Now GDB has been fixed to like N_FUN, says Kingdon.)
1946 no letter at all, and N_LSYM, for auto variable,
1947 r and N_RSYM for register variable. */
1949 if (GET_CODE (home) == MEM
1950 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
1952 if (TREE_PUBLIC (decl))
1955 current_sym_code = N_GSYM;
1959 current_sym_addr = XEXP (home, 0);
1961 letter = decl_function_context (decl) ? 'V' : 'S';
1963 /* This should be the same condition as in assemble_variable, but
1964 we don't have access to dont_output_data here. So, instead,
1965 we rely on the fact that error_mark_node initializers always
1966 end up in bss for C++ and never end up in bss for C. */
1967 if (DECL_INITIAL (decl) == 0
1968 || (!strcmp (lang_identify (), "cplusplus")
1969 && DECL_INITIAL (decl) == error_mark_node))
1970 current_sym_code = N_LCSYM;
1971 else if (DECL_IN_TEXT_SECTION (decl))
1972 /* This is not quite right, but it's the closest
1973 of all the codes that Unix defines. */
1974 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
1977 /* Ultrix `as' seems to need this. */
1978 #ifdef DBX_STATIC_STAB_DATA_SECTION
1981 current_sym_code = N_STSYM;
1985 else if (regno >= 0)
1988 current_sym_code = N_RSYM;
1989 current_sym_value = DBX_REGISTER_NUMBER (regno);
1991 else if (GET_CODE (home) == MEM
1992 && (GET_CODE (XEXP (home, 0)) == MEM
1993 || (GET_CODE (XEXP (home, 0)) == REG
1994 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
1995 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
1996 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
1997 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
2000 /* If the value is indirect by memory or by a register
2001 that isn't the frame pointer
2002 then it means the object is variable-sized and address through
2003 that register or stack slot. DBX has no way to represent this
2004 so all we can do is output the variable as a pointer.
2005 If it's not a parameter, ignore it.
2006 (VAR_DECLs like this can be made by integrate.c.) */
2008 if (GET_CODE (XEXP (home, 0)) == REG)
2011 current_sym_code = N_RSYM;
2012 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2016 current_sym_code = N_LSYM;
2017 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2018 We want the value of that CONST_INT. */
2020 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2023 /* Effectively do build_pointer_type, but don't cache this type,
2024 since it might be temporary whereas the type it points to
2025 might have been saved for inlining. */
2026 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2027 type = make_node (POINTER_TYPE);
2028 TREE_TYPE (type) = TREE_TYPE (decl);
2030 else if (GET_CODE (home) == MEM
2031 && GET_CODE (XEXP (home, 0)) == REG)
2033 current_sym_code = N_LSYM;
2034 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2036 else if (GET_CODE (home) == MEM
2037 && GET_CODE (XEXP (home, 0)) == PLUS
2038 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2040 current_sym_code = N_LSYM;
2041 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2042 We want the value of that CONST_INT. */
2043 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2045 else if (GET_CODE (home) == MEM
2046 && GET_CODE (XEXP (home, 0)) == CONST)
2048 /* Handle an obscure case which can arise when optimizing and
2049 when there are few available registers. (This is *always*
2050 the case for i386/i486 targets). The RTL looks like
2051 (MEM (CONST ...)) even though this variable is a local `auto'
2052 or a local `register' variable. In effect, what has happened
2053 is that the reload pass has seen that all assignments and
2054 references for one such a local variable can be replaced by
2055 equivalent assignments and references to some static storage
2056 variable, thereby avoiding the need for a register. In such
2057 cases we're forced to lie to debuggers and tell them that
2058 this variable was itself `static'. */
2059 current_sym_code = N_LCSYM;
2061 current_sym_addr = XEXP (XEXP (home, 0), 0);
2063 else if (GET_CODE (home) == CONCAT)
2065 tree subtype = TREE_TYPE (type);
2067 /* If the variable's storage is in two parts,
2068 output each as a separate stab with a modified name. */
2069 if (WORDS_BIG_ENDIAN)
2070 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2072 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2074 /* Cast avoids warning in old compilers. */
2075 current_sym_code = (STAB_CODE_TYPE) 0;
2076 current_sym_value = 0;
2077 current_sym_addr = 0;
2078 dbxout_prepare_symbol (decl);
2080 if (WORDS_BIG_ENDIAN)
2081 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2083 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2087 /* Address might be a MEM, when DECL is a variable-sized object.
2088 Or it might be const0_rtx, meaning previous passes
2089 want us to ignore this variable. */
2092 /* Ok, start a symtab entry and output the variable name. */
2095 #ifdef DBX_STATIC_BLOCK_START
2096 DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2099 dbxout_symbol_name (decl, suffix, letter);
2100 dbxout_type (type, 0, 0);
2101 dbxout_finish_symbol (decl);
2103 #ifdef DBX_STATIC_BLOCK_END
2104 DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2108 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2109 Then output LETTER to indicate the kind of location the symbol has. */
2112 dbxout_symbol_name (decl, suffix, letter)
2117 /* One slight hitch: if this is a VAR_DECL which is a static
2118 class member, we must put out the mangled name instead of the
2119 DECL_NAME. Note also that static member (variable) names DO NOT begin
2120 with underscores in .stabs directives. */
2121 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2124 fprintf (asmfile, "%s \"%s%s:", ASM_STABS_OP, name,
2125 (suffix ? suffix : ""));
2127 if (letter) putc (letter, asmfile);
2131 dbxout_prepare_symbol (decl)
2135 char *filename = DECL_SOURCE_FILE (decl);
2137 dbxout_source_file (asmfile, filename);
2142 dbxout_finish_symbol (sym)
2145 #ifdef DBX_FINISH_SYMBOL
2146 DBX_FINISH_SYMBOL (sym);
2149 if (use_gnu_debug_info_extensions && sym != 0)
2150 line = DECL_SOURCE_LINE (sym);
2152 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2153 if (current_sym_addr)
2154 output_addr_const (asmfile, current_sym_addr);
2156 fprintf (asmfile, "%d", current_sym_value);
2157 putc ('\n', asmfile);
2161 /* Output definitions of all the decls in a chain. */
2169 dbxout_symbol (syms, 1);
2170 syms = TREE_CHAIN (syms);
2174 /* The following two functions output definitions of function parameters.
2175 Each parameter gets a definition locating it in the parameter list.
2176 Each parameter that is a register variable gets a second definition
2177 locating it in the register.
2179 Printing or argument lists in gdb uses the definitions that
2180 locate in the parameter list. But reference to the variable in
2181 expressions uses preferentially the definition as a register. */
2183 /* Output definitions, referring to storage in the parmlist,
2184 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2187 dbxout_parms (parms)
2190 for (; parms; parms = TREE_CHAIN (parms))
2191 if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2193 dbxout_prepare_symbol (parms);
2195 /* Perform any necessary register eliminations on the parameter's rtl,
2196 so that the debugging output will be accurate. */
2197 DECL_INCOMING_RTL (parms)
2198 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2199 DECL_RTL (parms) = eliminate_regs (DECL_RTL (parms), 0, NULL_RTX);
2200 #ifdef LEAF_REG_REMAP
2203 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2204 leaf_renumber_regs_insn (DECL_RTL (parms));
2208 if (PARM_PASSED_IN_MEMORY (parms))
2210 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2212 /* ??? Here we assume that the parm address is indexed
2213 off the frame pointer or arg pointer.
2214 If that is not true, we produce meaningless results,
2215 but do not crash. */
2216 if (GET_CODE (addr) == PLUS
2217 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2218 current_sym_value = INTVAL (XEXP (addr, 1));
2220 current_sym_value = 0;
2222 current_sym_code = N_PSYM;
2223 current_sym_addr = 0;
2226 if (DECL_NAME (parms))
2228 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2230 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2231 IDENTIFIER_POINTER (DECL_NAME (parms)),
2232 DBX_MEMPARM_STABS_LETTER);
2236 current_sym_nchars = 8;
2237 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2238 DBX_MEMPARM_STABS_LETTER);
2241 dbxout_type (DECL_ARG_TYPE (parms), 0, 0);
2242 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2243 dbxout_finish_symbol (parms);
2245 else if (GET_CODE (DECL_RTL (parms)) == REG)
2248 char regparm_letter;
2250 /* Parm passed in registers and lives in registers or nowhere. */
2252 current_sym_code = DBX_REGPARM_STABS_CODE;
2253 regparm_letter = DBX_REGPARM_STABS_LETTER;
2254 current_sym_addr = 0;
2256 /* If parm lives in a register, use that register;
2257 pretend the parm was passed there. It would be more consistent
2258 to describe the register where the parm was passed,
2259 but in practice that register usually holds something else.
2261 If we use DECL_RTL, then we must use the declared type of
2262 the variable, not the type that it arrived in. */
2263 if (REGNO (DECL_RTL (parms)) >= 0
2264 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2266 best_rtl = DECL_RTL (parms);
2267 parm_type = TREE_TYPE (parms);
2269 /* If the parm lives nowhere, use the register where it was
2270 passed. It is also better to use the declared type here. */
2273 best_rtl = DECL_INCOMING_RTL (parms);
2274 parm_type = TREE_TYPE (parms);
2276 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2279 if (DECL_NAME (parms))
2281 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2282 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2283 IDENTIFIER_POINTER (DECL_NAME (parms)),
2288 current_sym_nchars = 8;
2289 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2293 dbxout_type (parm_type, 0, 0);
2294 dbxout_finish_symbol (parms);
2296 else if (GET_CODE (DECL_RTL (parms)) == MEM
2297 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2298 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2299 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2300 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2301 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2305 /* Parm was passed via invisible reference.
2306 That is, its address was passed in a register.
2307 Output it as if it lived in that register.
2308 The debugger will know from the type
2309 that it was actually passed by invisible reference. */
2311 char regparm_letter;
2312 /* Parm passed in registers and lives in registers or nowhere. */
2314 current_sym_code = DBX_REGPARM_STABS_CODE;
2315 if (use_gnu_debug_info_extensions)
2316 regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2318 regparm_letter = DBX_REGPARM_STABS_LETTER;
2320 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2321 If it is an unallocated pseudo-reg, then use the register where
2322 it was passed instead. */
2323 if (REGNO (XEXP (DECL_RTL (parms), 0)) >= 0
2324 && REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2325 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2327 current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2329 current_sym_addr = 0;
2332 if (DECL_NAME (parms))
2334 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2336 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2337 IDENTIFIER_POINTER (DECL_NAME (parms)),
2342 current_sym_nchars = 8;
2343 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2347 dbxout_type (TREE_TYPE (parms), 0, 0);
2348 dbxout_finish_symbol (parms);
2350 else if (GET_CODE (DECL_RTL (parms)) == MEM
2351 && XEXP (DECL_RTL (parms), 0) != const0_rtx
2352 /* ??? A constant address for a parm can happen
2353 when the reg it lives in is equiv to a constant in memory.
2354 Should make this not happen, after 2.4. */
2355 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2357 /* Parm was passed in registers but lives on the stack. */
2359 current_sym_code = N_PSYM;
2360 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2361 in which case we want the value of that CONST_INT,
2362 or (MEM (REG ...)) or (MEM (MEM ...)),
2363 in which case we use a value of zero. */
2364 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2365 || GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2366 current_sym_value = 0;
2368 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2369 current_sym_addr = 0;
2372 if (DECL_NAME (parms))
2374 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2376 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2377 IDENTIFIER_POINTER (DECL_NAME (parms)),
2378 DBX_MEMPARM_STABS_LETTER);
2382 current_sym_nchars = 8;
2383 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2384 DBX_MEMPARM_STABS_LETTER);
2388 = DEBUGGER_ARG_OFFSET (current_sym_value,
2389 XEXP (DECL_RTL (parms), 0));
2390 dbxout_type (TREE_TYPE (parms), 0, 0);
2391 dbxout_finish_symbol (parms);
2396 /* Output definitions for the places where parms live during the function,
2397 when different from where they were passed, when the parms were passed
2400 It is not useful to do this for parms passed in registers
2401 that live during the function in different registers, because it is
2402 impossible to look in the passed register for the passed value,
2403 so we use the within-the-function register to begin with.
2405 PARMS is a chain of PARM_DECL nodes. */
2408 dbxout_reg_parms (parms)
2411 for (; parms; parms = TREE_CHAIN (parms))
2412 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
2414 dbxout_prepare_symbol (parms);
2416 /* Report parms that live in registers during the function
2417 but were passed in memory. */
2418 if (GET_CODE (DECL_RTL (parms)) == REG
2419 && REGNO (DECL_RTL (parms)) >= 0
2420 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2421 dbxout_symbol_location (parms, TREE_TYPE (parms),
2422 0, DECL_RTL (parms));
2423 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
2424 dbxout_symbol_location (parms, TREE_TYPE (parms),
2425 0, DECL_RTL (parms));
2426 /* Report parms that live in memory but not where they were passed. */
2427 else if (GET_CODE (DECL_RTL (parms)) == MEM
2428 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
2429 dbxout_symbol_location (parms, TREE_TYPE (parms),
2430 0, DECL_RTL (parms));
2434 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2435 output definitions of those names, in raw form */
2443 putc (',', asmfile);
2444 dbxout_type (TREE_VALUE (args), 0, 0);
2446 args = TREE_CHAIN (args);
2450 /* Given a chain of ..._TYPE nodes,
2451 find those which have typedef names and output those names.
2452 This is to ensure those types get output. */
2455 dbxout_types (types)
2456 register tree types;
2460 if (TYPE_NAME (types)
2461 && TREE_CODE (TYPE_NAME (types)) == TYPE_DECL
2462 && ! TREE_ASM_WRITTEN (TYPE_NAME (types)))
2463 dbxout_symbol (TYPE_NAME (types), 1);
2464 types = TREE_CHAIN (types);
2468 /* Output everything about a symbol block (a BLOCK node
2469 that represents a scope level),
2470 including recursive output of contained blocks.
2472 BLOCK is the BLOCK node.
2473 DEPTH is its depth within containing symbol blocks.
2474 ARGS is usually zero; but for the outermost block of the
2475 body of a function, it is a chain of PARM_DECLs for the function parameters.
2476 We output definitions of all the register parms
2477 as if they were local variables of that block.
2479 If -g1 was used, we count blocks just the same, but output nothing
2480 except for the outermost block.
2482 Actually, BLOCK may be several blocks chained together.
2483 We handle them all in sequence. */
2486 dbxout_block (block, depth, args)
2487 register tree block;
2495 /* Ignore blocks never expanded or otherwise marked as real. */
2496 if (TREE_USED (block))
2498 #ifndef DBX_LBRAC_FIRST
2499 /* In dbx format, the syms of a block come before the N_LBRAC. */
2500 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2501 dbxout_syms (BLOCK_VARS (block));
2503 dbxout_reg_parms (args);
2506 /* Now output an N_LBRAC symbol to represent the beginning of
2507 the block. Use the block's tree-walk order to generate
2508 the assembler symbols LBBn and LBEn
2509 that final will define around the code in this block. */
2510 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2513 blocknum = next_block_number++;
2514 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
2516 if (BLOCK_HANDLER_BLOCK (block))
2518 /* A catch block. Must precede N_LBRAC. */
2519 tree decl = BLOCK_VARS (block);
2522 #ifdef DBX_OUTPUT_CATCH
2523 DBX_OUTPUT_CATCH (asmfile, decl, buf);
2525 fprintf (asmfile, "%s \"%s:C1\",%d,0,0,", ASM_STABS_OP,
2526 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
2527 assemble_name (asmfile, buf);
2528 fprintf (asmfile, "\n");
2530 decl = TREE_CHAIN (decl);
2534 #ifdef DBX_OUTPUT_LBRAC
2535 DBX_OUTPUT_LBRAC (asmfile, buf);
2537 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);
2538 assemble_name (asmfile, buf);
2539 #if DBX_BLOCKS_FUNCTION_RELATIVE
2540 fputc ('-', asmfile);
2541 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2543 fprintf (asmfile, "\n");
2547 /* Count blocks the same way regardless of debug_info_level. */
2548 next_block_number++;
2550 #ifdef DBX_LBRAC_FIRST
2551 /* On some weird machines, the syms of a block
2552 come after the N_LBRAC. */
2553 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2554 dbxout_syms (BLOCK_VARS (block));
2556 dbxout_reg_parms (args);
2559 /* Output the subblocks. */
2560 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
2562 /* Refer to the marker for the end of the block. */
2563 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2566 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
2567 #ifdef DBX_OUTPUT_RBRAC
2568 DBX_OUTPUT_RBRAC (asmfile, buf);
2570 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);
2571 assemble_name (asmfile, buf);
2572 #if DBX_BLOCKS_FUNCTION_RELATIVE
2573 fputc ('-', asmfile);
2574 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2576 fprintf (asmfile, "\n");
2580 block = BLOCK_CHAIN (block);
2584 /* Output the information about a function and its arguments and result.
2585 Usually this follows the function's code,
2586 but on some systems, it comes before. */
2589 dbxout_really_begin_function (decl)
2592 dbxout_symbol (decl, 0);
2593 dbxout_parms (DECL_ARGUMENTS (decl));
2594 if (DECL_NAME (DECL_RESULT (decl)) != 0)
2595 dbxout_symbol (DECL_RESULT (decl), 1);
2598 /* Called at beginning of output of function definition. */
2601 dbxout_begin_function (decl)
2604 #ifdef DBX_FUNCTION_FIRST
2605 dbxout_really_begin_function (decl);
2609 /* Output dbx data for a function definition.
2610 This includes a definition of the function name itself (a symbol),
2611 definitions of the parameters (locating them in the parameter list)
2612 and then output the block that makes up the function's body
2613 (including all the auto variables of the function). */
2616 dbxout_function (decl)
2619 #ifndef DBX_FUNCTION_FIRST
2620 dbxout_really_begin_function (decl);
2622 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
2623 #ifdef DBX_OUTPUT_FUNCTION_END
2624 DBX_OUTPUT_FUNCTION_END (asmfile, decl);
2626 #if defined(ASM_OUTPUT_SECTION_NAME)
2627 if (use_gnu_debug_info_extensions
2628 #if defined(NO_DBX_FUNCTION_END)
2629 && ! NO_DBX_FUNCTION_END
2632 dbxout_function_end ();
2635 #endif /* DBX_DEBUGGING_INFO */