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'. */
79 #include "insn-config.h"
82 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
88 #ifdef XCOFF_DEBUGGING_INFO
93 #define ASM_STABS_OP ".stabs"
97 #define ASM_STABN_OP ".stabn"
100 #ifndef DBX_TYPE_DECL_STABS_CODE
101 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
104 #ifndef DBX_STATIC_CONST_VAR_CODE
105 #define DBX_STATIC_CONST_VAR_CODE N_FUN
108 #ifndef DBX_REGPARM_STABS_CODE
109 #define DBX_REGPARM_STABS_CODE N_RSYM
112 #ifndef DBX_REGPARM_STABS_LETTER
113 #define DBX_REGPARM_STABS_LETTER 'P'
116 /* This is used for parameters passed by invisible reference in a register. */
117 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
118 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
121 #ifndef DBX_MEMPARM_STABS_LETTER
122 #define DBX_MEMPARM_STABS_LETTER 'p'
125 #ifndef FILE_NAME_JOINER
126 #define FILE_NAME_JOINER "/"
129 /* Nonzero means if the type has methods, only output debugging
130 information if methods are actually written to the asm file. This
131 optimization only works if the debugger can detect the special C++
134 #define MINIMAL_DEBUG 1
136 #ifdef NO_DOLLAR_IN_LABEL
137 #ifdef NO_DOT_IN_LABEL
139 #define MINIMAL_DEBUG 0
143 static int flag_minimal_debug = MINIMAL_DEBUG;
145 /* Nonzero if we have actually used any of the GDB extensions
146 to the debugging format. The idea is that we use them for the
147 first time only if there's a strong reason, but once we have done that,
148 we use them whenever convenient. */
150 static int have_used_extensions = 0;
152 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
153 for the N_SO filename stabs label. */
155 static int source_label_number = 1;
157 static int scope_labelno = 0;
161 /* Typical USG systems don't have stab.h, and they also have
162 no use for DBX-format debugging info. */
164 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
166 #ifdef DEBUG_SYMS_TEXT
167 #define FORCE_TEXT text_section ();
172 #if defined (USG) || defined (NO_STAB_H) || defined (CROSS_COMPILE)
173 #include "gstab.h" /* If doing DBX on sysV, use our own stab.h. */
175 #include <stab.h> /* On BSD, use the system's stab.h. */
177 /* This is a GNU extension we need to reference in this file. */
184 #define STAB_CODE_TYPE enum __stab_debug_code
186 #define STAB_CODE_TYPE int
189 /* 1 if PARM is passed to this function in memory. */
191 #define PARM_PASSED_IN_MEMORY(PARM) \
192 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
194 /* A C expression for the integer offset value of an automatic variable
195 (N_LSYM) having address X (an RTX). */
196 #ifndef DEBUGGER_AUTO_OFFSET
197 #define DEBUGGER_AUTO_OFFSET(X) \
198 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
201 /* A C expression for the integer offset value of an argument (N_PSYM)
202 having address X (an RTX). The nominal offset is OFFSET. */
203 #ifndef DEBUGGER_ARG_OFFSET
204 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
207 /* Stream for writing to assembler file. */
209 static FILE *asmfile;
211 /* Last source file name mentioned in a NOTE insn. */
213 static char *lastfile;
215 /* Current working directory. */
219 enum typestatus {TYPE_UNSEEN, TYPE_XREF, TYPE_DEFINED};
221 /* Structure recording information about a C data type.
222 The status element says whether we have yet output
223 the definition of the type. TYPE_XREF says we have
224 output it as a cross-reference only.
225 The file_number and type_number elements are used if DBX_USE_BINCL
230 enum typestatus status;
237 /* Vector recording information about C data types.
238 When we first notice a data type (a tree node),
239 we assign it a number using next_type_number.
240 That is its index in this vector. */
242 struct typeinfo *typevec;
244 /* Number of elements of space allocated in `typevec'. */
246 static int typevec_len;
248 /* In dbx output, each type gets a unique number.
249 This is the number for the next type output.
250 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
252 static int next_type_number;
256 /* When using N_BINCL in dbx output, each type number is actually a
257 pair of the file number and the type number within the file.
258 This is a stack of input files. */
262 struct dbx_file *next;
264 int next_type_number;
267 /* This is the top of the stack. */
269 static struct dbx_file *current_file;
271 /* This is the next file number to use. */
273 static int next_file_number;
275 #endif /* DBX_USE_BINCL */
277 /* In dbx output, we must assign symbol-blocks id numbers
278 in the order in which their beginnings are encountered.
279 We output debugging info that refers to the beginning and
280 end of the ranges of code in each block
281 with assembler labels LBBn and LBEn, where n is the block number.
282 The labels are generated in final, which assigns numbers to the
283 blocks in the same way. */
285 static int next_block_number;
287 /* These variables are for dbxout_symbol to communicate to
288 dbxout_finish_symbol.
289 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
290 current_sym_value and current_sym_addr are two ways to address the
291 value to store in the symtab entry.
292 current_sym_addr if nonzero represents the value as an rtx.
293 If that is zero, current_sym_value is used. This is used
294 when the value is an offset (such as for auto variables,
295 register variables and parms). */
297 static STAB_CODE_TYPE current_sym_code;
298 static int current_sym_value;
299 static rtx current_sym_addr;
301 /* Number of chars of symbol-description generated so far for the
302 current symbol. Used by CHARS and CONTIN. */
304 static int current_sym_nchars;
306 /* Report having output N chars of the current symbol-description. */
308 #define CHARS(N) (current_sym_nchars += (N))
310 /* Break the current symbol-description, generating a continuation,
311 if it has become long. */
313 #ifndef DBX_CONTIN_LENGTH
314 #define DBX_CONTIN_LENGTH 80
317 #if DBX_CONTIN_LENGTH > 0
319 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
324 void dbxout_types ();
326 void dbxout_symbol ();
328 static void dbxout_function_end PROTO((void));
329 static void dbxout_typedefs PROTO((tree));
330 static void dbxout_type_index PROTO((tree));
331 static void dbxout_continue PROTO((void));
332 static void dbxout_type_fields PROTO((tree));
333 static void dbxout_type_method_1 PROTO((tree, char *));
334 static void dbxout_type_methods PROTO((tree));
335 static void dbxout_range_type PROTO((tree));
336 static void dbxout_type PROTO((tree, int, int));
337 static void print_int_cst_octal PROTO((tree));
338 static void print_octal PROTO((unsigned HOST_WIDE_INT, int));
339 static void dbxout_type_name PROTO((tree));
340 static void dbxout_symbol_location PROTO((tree, tree, char *, rtx));
341 static void dbxout_symbol_name PROTO((tree, char *, int));
342 static void dbxout_prepare_symbol PROTO((tree));
343 static void dbxout_finish_symbol PROTO((tree));
344 static void dbxout_block PROTO((tree, int, tree));
345 static void dbxout_really_begin_function PROTO((tree));
348 dbxout_function_end ()
350 char lscope_label_name[100];
351 /* Convert Ltext into the appropriate format for local labels in case
352 the system doesn't insert underscores in front of user generated
354 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
355 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Lscope", scope_labelno);
358 /* By convention, GCC will mark the end of a function with an N_FUN
359 symbol and an empty string. */
360 fprintf (asmfile, "%s \"\",%d,0,0,", ASM_STABS_OP, N_FUN);
361 assemble_name (asmfile, lscope_label_name);
362 fputc ('-', asmfile);
363 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
364 fprintf (asmfile, "\n");
367 /* At the beginning of compilation, start writing the symbol table.
368 Initialize `typevec' and output the standard data types of C. */
371 dbxout_init (asm_file, input_file_name, syms)
373 char *input_file_name;
376 char ltext_label_name[100];
381 typevec = (struct typeinfo *) xmalloc (typevec_len * sizeof typevec[0]);
382 bzero ((char *) typevec, typevec_len * sizeof typevec[0]);
384 /* Convert Ltext into the appropriate format for local labels in case
385 the system doesn't insert underscores in front of user generated
387 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);
389 /* Put the current working directory in an N_SO symbol. */
390 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
391 but GDB always does. */
392 if (use_gnu_debug_info_extensions)
395 if (!cwd && (cwd = getpwd ()) && (!*cwd || cwd[strlen (cwd) - 1] != '/'))
397 char *wdslash = xmalloc (strlen (cwd) + sizeof (FILE_NAME_JOINER));
398 sprintf (wdslash, "%s%s", cwd, FILE_NAME_JOINER);
403 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
404 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
405 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
406 fprintf (asmfile, "%s ", ASM_STABS_OP);
407 output_quoted_string (asmfile, cwd);
408 fprintf (asmfile, ",%d,0,0,%s\n", N_SO, <ext_label_name[1]);
409 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
413 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
414 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
415 would give us an N_SOL, and we want an N_SO. */
416 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile, input_file_name);
417 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
418 /* We include outputting `Ltext:' here,
419 because that gives you a way to override it. */
420 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
421 fprintf (asmfile, "%s ", ASM_STABS_OP);
422 output_quoted_string (asmfile, input_file_name);
423 fprintf (asmfile, ",%d,0,0,%s\n",
424 N_SO, <ext_label_name[1]);
426 ASM_OUTPUT_INTERNAL_LABEL (asmfile, "Ltext", 0);
427 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
429 /* Possibly output something to inform GDB that this compilation was by
430 GCC. It's easier for GDB to parse it when after the N_SO's. This
431 is used in Solaris 2. */
432 #ifdef ASM_IDENTIFY_GCC_AFTER_SOURCE
433 ASM_IDENTIFY_GCC_AFTER_SOURCE (asmfile);
436 lastfile = input_file_name;
438 next_type_number = 1;
439 next_block_number = 2;
442 current_file = (struct dbx_file *) xmalloc (sizeof *current_file);
443 current_file->next = NULL;
444 current_file->file_number = 0;
445 current_file->next_type_number = 1;
446 next_file_number = 1;
449 /* Make sure that types `int' and `char' have numbers 1 and 2.
450 Definitions of other integer types will refer to those numbers.
451 (Actually it should no longer matter what their numbers are.
452 Also, if any types with tags have been defined, dbxout_symbol
453 will output them first, so the numbers won't be 1 and 2. That
454 happens in C++. So it's a good thing it should no longer matter). */
456 #ifdef DBX_OUTPUT_STANDARD_TYPES
457 DBX_OUTPUT_STANDARD_TYPES (syms);
459 dbxout_symbol (TYPE_NAME (integer_type_node), 0);
460 dbxout_symbol (TYPE_NAME (char_type_node), 0);
463 /* Get all permanent types that have typedef names,
464 and output them all, except for those already output. */
466 dbxout_typedefs (syms);
469 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
470 in the reverse order from that which is found in SYMS. */
473 dbxout_typedefs (syms)
478 dbxout_typedefs (TREE_CHAIN (syms));
479 if (TREE_CODE (syms) == TYPE_DECL)
481 tree type = TREE_TYPE (syms);
483 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
484 && TYPE_SIZE (type) != NULL_TREE
485 && ! TREE_ASM_WRITTEN (TYPE_NAME (type)))
486 dbxout_symbol (TYPE_NAME (type), 0);
491 /* Change to reading from a new source file. Generate a N_BINCL stab. */
494 dbxout_start_new_source_file (filename)
498 struct dbx_file *n = (struct dbx_file *) xmalloc (sizeof *n);
500 n->next = current_file;
501 n->file_number = next_file_number++;
502 n->next_type_number = 1;
504 fprintf (asmfile, "%s ", ASM_STABS_OP);
505 output_quoted_string (asmfile, filename);
506 fprintf (asmfile, ",%d,0,0,0\n", N_BINCL);
510 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
513 dbxout_resume_previous_source_file ()
516 struct dbx_file *next;
518 fprintf (asmfile, "%s %d,0,0,0\n", ASM_STABN_OP, N_EINCL);
519 next = current_file->next;
525 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
528 dbxout_source_file (file, filename)
532 char ltext_label_name[100];
534 if (filename && (lastfile == 0 || strcmp (filename, lastfile)))
536 #ifdef DBX_OUTPUT_SOURCE_FILENAME
537 DBX_OUTPUT_SOURCE_FILENAME (file, filename);
539 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
540 source_label_number);
541 fprintf (file, "%s ", ASM_STABS_OP);
542 output_quoted_string (file, filename);
543 fprintf (file, ",%d,0,0,%s\n", N_SOL, <ext_label_name[1]);
544 if (current_function_decl != NULL_TREE
545 && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
546 ; /* Don't change section amid function. */
549 ASM_OUTPUT_INTERNAL_LABEL (file, "Ltext", source_label_number);
550 source_label_number++;
556 /* Output a line number symbol entry into output stream FILE,
557 for source file FILENAME and line number LINENO. */
560 dbxout_source_line (file, filename, lineno)
565 dbxout_source_file (file, filename);
567 #ifdef ASM_OUTPUT_SOURCE_LINE
568 ASM_OUTPUT_SOURCE_LINE (file, lineno);
570 fprintf (file, "\t%s %d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
574 /* At the end of compilation, finish writing the symbol table.
575 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
579 dbxout_finish (file, filename)
583 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
584 DBX_OUTPUT_MAIN_SOURCE_FILE_END (file, filename);
585 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
588 /* Output the index of a type. */
591 dbxout_type_index (type)
594 #ifndef DBX_USE_BINCL
595 fprintf (asmfile, "%d", TYPE_SYMTAB_ADDRESS (type));
598 struct typeinfo *t = &typevec[TYPE_SYMTAB_ADDRESS (type)];
599 fprintf (asmfile, "(%d,%d)", t->file_number, t->type_number);
604 /* Continue a symbol-description that gets too big.
605 End one symbol table entry with a double-backslash
606 and start a new one, eventually producing something like
607 .stabs "start......\\",code,0,value
608 .stabs "...rest",code,0,value */
613 #ifdef DBX_CONTIN_CHAR
614 fprintf (asmfile, "%c", DBX_CONTIN_CHAR);
616 fprintf (asmfile, "\\\\");
618 dbxout_finish_symbol (NULL_TREE);
619 fprintf (asmfile, "%s \"", ASM_STABS_OP);
620 current_sym_nchars = 0;
623 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
624 This must be a separate function because anonymous unions require
628 dbxout_type_fields (type)
632 /* Output the name, type, position (in bits), size (in bits) of each
634 for (tem = TYPE_FIELDS (type); tem; tem = TREE_CHAIN (tem))
636 /* Omit here local type decls until we know how to support them. */
637 if (TREE_CODE (tem) == TYPE_DECL)
639 /* Omit fields whose position or size are variable. */
640 else if (TREE_CODE (tem) == FIELD_DECL
641 && (TREE_CODE (DECL_FIELD_BITPOS (tem)) != INTEGER_CST
642 || TREE_CODE (DECL_SIZE (tem)) != INTEGER_CST))
644 /* Omit here the nameless fields that are used to skip bits. */
645 else if (DECL_IGNORED_P (tem))
647 else if (TREE_CODE (tem) != CONST_DECL)
649 /* Continue the line if necessary,
650 but not before the first field. */
651 if (tem != TYPE_FIELDS (type))
654 if (use_gnu_debug_info_extensions
655 && flag_minimal_debug
656 && TREE_CODE (tem) == FIELD_DECL
657 && DECL_VIRTUAL_P (tem)
658 && DECL_ASSEMBLER_NAME (tem))
660 have_used_extensions = 1;
661 CHARS (3 + IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (tem)));
662 fputs (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem)), asmfile);
663 dbxout_type (DECL_FCONTEXT (tem), 0, 0);
664 fprintf (asmfile, ":");
665 dbxout_type (TREE_TYPE (tem), 0, 0);
666 fprintf (asmfile, ",%d;",
667 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)));
673 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (DECL_NAME (tem)));
674 CHARS (2 + IDENTIFIER_LENGTH (DECL_NAME (tem)));
678 fprintf (asmfile, ":");
682 if (use_gnu_debug_info_extensions
683 && (TREE_PRIVATE (tem) || TREE_PROTECTED (tem)
684 || TREE_CODE (tem) != FIELD_DECL))
686 have_used_extensions = 1;
688 putc ((TREE_PRIVATE (tem) ? '0'
689 : TREE_PROTECTED (tem) ? '1' : '2'),
694 dbxout_type ((TREE_CODE (tem) == FIELD_DECL
695 && DECL_BIT_FIELD_TYPE (tem))
696 ? DECL_BIT_FIELD_TYPE (tem)
697 : TREE_TYPE (tem), 0, 0);
699 if (TREE_CODE (tem) == VAR_DECL)
701 if (TREE_STATIC (tem) && use_gnu_debug_info_extensions)
703 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem));
704 have_used_extensions = 1;
705 fprintf (asmfile, ":%s;", name);
706 CHARS (strlen (name));
710 /* If TEM is non-static, GDB won't understand it. */
711 fprintf (asmfile, ",0,0;");
714 else if (TREE_CODE (DECL_FIELD_BITPOS (tem)) == INTEGER_CST)
716 fprintf (asmfile, ",%d,%d;",
717 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem)),
718 TREE_INT_CST_LOW (DECL_SIZE (tem)));
725 /* Subroutine of `dbxout_type_methods'. Output debug info about the
726 method described DECL. DEBUG_NAME is an encoding of the method's
727 type signature. ??? We may be able to do without DEBUG_NAME altogether
731 dbxout_type_method_1 (decl, debug_name)
737 if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
739 else /* it's a METHOD_TYPE. */
741 tree firstarg = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)));
742 /* A for normal functions.
743 B for `const' member functions.
744 C for `volatile' member functions.
745 D for `const volatile' member functions. */
746 if (TYPE_READONLY (TREE_TYPE (firstarg)))
748 if (TYPE_VOLATILE (TREE_TYPE (firstarg)))
751 if (DECL_VINDEX (decl))
757 fprintf (asmfile, ":%s;%c%c%c", debug_name,
758 TREE_PRIVATE (decl) ? '0' : TREE_PROTECTED (decl) ? '1' : '2', c1, c2);
759 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl)) + 6
760 - (debug_name - IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
761 if (DECL_VINDEX (decl))
763 fprintf (asmfile, "%d;",
764 TREE_INT_CST_LOW (DECL_VINDEX (decl)));
765 dbxout_type (DECL_CONTEXT (decl), 0, 0);
766 fprintf (asmfile, ";");
771 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
775 dbxout_type_methods (type)
778 /* C++: put out the method names and their parameter lists */
779 tree methods = TYPE_METHODS (type);
781 register tree fndecl;
783 char formatted_type_identifier_length[16];
784 register int type_identifier_length;
786 if (methods == NULL_TREE)
789 type_encoding = DECL_NAME (TYPE_NAME (type));
792 /* C++: Template classes break some assumptions made by this code about
793 the class names, constructor names, and encodings for assembler
794 label names. For now, disable output of dbx info for them. */
796 char *ptr = IDENTIFIER_POINTER (type_encoding);
797 /* This should use index. (mrs) */
798 while (*ptr && *ptr != '<') ptr++;
805 #ifdef HAVE_TEMPLATES
806 if (warn_template_debugging)
807 warning ("dbx info for template class methods not yet supported");
815 type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
817 sprintf(formatted_type_identifier_length, "%d", type_identifier_length);
819 if (TREE_CODE (methods) == FUNCTION_DECL)
821 else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
822 fndecl = TREE_VEC_ELT (methods, 0);
824 fndecl = TREE_VEC_ELT (methods, 1);
828 tree name = DECL_NAME (fndecl);
831 /* Group together all the methods for the same operation.
832 These differ in the types of the arguments. */
833 for (last = NULL_TREE;
834 fndecl && (last == NULL_TREE || DECL_NAME (fndecl) == DECL_NAME (last));
835 fndecl = TREE_CHAIN (fndecl))
836 /* Output the name of the field (after overloading), as
837 well as the name of the field before overloading, along
838 with its parameter list */
840 /* This is the "mangled" name of the method.
841 It encodes the argument types. */
842 char *debug_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
843 int show_arg_types = 0;
849 if (DECL_IGNORED_P (fndecl))
852 if (flag_minimal_debug)
856 /* We can't optimize a method which uses an anonymous
857 class, because the debugger will not be able to
858 associate the arbitrary class name with the actual
860 #ifndef NO_DOLLAR_IN_LABEL
865 if (strchr (debug_name, marker))
867 /* Detect ordinary methods because their mangled names
868 start with the operation name. */
869 else if (!strncmp (IDENTIFIER_POINTER (name), debug_name,
870 IDENTIFIER_LENGTH (name)))
872 debug_name += IDENTIFIER_LENGTH (name);
873 if (debug_name[0] == '_' && debug_name[1] == '_')
875 char *method_name = debug_name + 2;
876 char *length_ptr = formatted_type_identifier_length;
877 /* Get past const and volatile qualifiers. */
878 while (*method_name == 'C' || *method_name == 'V')
880 /* Skip digits for length of type_encoding. */
881 while (*method_name == *length_ptr && *length_ptr)
882 length_ptr++, method_name++;
883 if (! strncmp (method_name,
884 IDENTIFIER_POINTER (type_encoding),
885 type_identifier_length))
886 method_name += type_identifier_length;
887 debug_name = method_name;
890 /* Detect constructors by their style of name mangling. */
891 else if (debug_name[0] == '_' && debug_name[1] == '_')
893 char *ctor_name = debug_name + 2;
894 char *length_ptr = formatted_type_identifier_length;
895 while (*ctor_name == 'C' || *ctor_name == 'V')
897 /* Skip digits for length of type_encoding. */
898 while (*ctor_name == *length_ptr && *length_ptr)
899 length_ptr++, ctor_name++;
900 if (!strncmp (IDENTIFIER_POINTER (type_encoding), ctor_name,
901 type_identifier_length))
902 debug_name = ctor_name + type_identifier_length;
904 /* The other alternative is a destructor. */
908 /* Output the operation name just once, for the first method
912 fprintf (asmfile, "%s::", IDENTIFIER_POINTER (name));
913 CHARS (IDENTIFIER_LENGTH (name) + 2);
918 dbxout_type (TREE_TYPE (fndecl), 0, show_arg_types);
920 dbxout_type_method_1 (fndecl, debug_name);
930 /* Emit a "range" type specification, which has the form:
931 "r<index type>;<lower bound>;<upper bound>;".
932 TYPE is an INTEGER_TYPE. */
935 dbxout_range_type (type)
938 fprintf (asmfile, "r");
939 if (TREE_TYPE (type))
940 dbxout_type (TREE_TYPE (type), 0, 0);
941 else if (TREE_CODE (type) != INTEGER_TYPE)
942 dbxout_type (type, 0, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
945 /* Traditionally, we made sure 'int' was type 1, and builtin types
946 were defined to be sub-ranges of int. Unfortunately, this
947 does not allow us to distinguish true sub-ranges from integer
948 types. So, instead we define integer (non-sub-range) types as
949 sub-ranges of themselves. */
950 dbxout_type_index (type);
952 if (TREE_CODE (TYPE_MIN_VALUE (type)) == INTEGER_CST)
953 fprintf (asmfile, ";%d",
954 TREE_INT_CST_LOW (TYPE_MIN_VALUE (type)));
956 fprintf (asmfile, ";0");
957 if (TYPE_MAX_VALUE (type)
958 && TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST)
959 fprintf (asmfile, ";%d;",
960 TREE_INT_CST_LOW (TYPE_MAX_VALUE (type)));
962 fprintf (asmfile, ";-1;");
965 /* Output a reference to a type. If the type has not yet been
966 described in the dbx output, output its definition now.
967 For a type already defined, just refer to its definition
968 using the type number.
970 If FULL is nonzero, and the type has been described only with
971 a forward-reference, output the definition now.
972 If FULL is zero in this case, just refer to the forward-reference
973 using the number previously allocated.
975 If SHOW_ARG_TYPES is nonzero, we output a description of the argument
976 types for a METHOD_TYPE. */
979 dbxout_type (type, full, show_arg_types)
985 static int anonymous_type_number = 0;
987 /* If there was an input error and we don't really have a type,
988 avoid crashing and write something that is at least valid
989 by assuming `int'. */
990 if (type == error_mark_node)
991 type = integer_type_node;
994 /* Try to find the "main variant" with the same name but not const
995 or volatile. (Since stabs does not distinguish const and volatile,
996 there is no need to make them separate types. But types with
997 different names are usefully distinguished.) */
999 for (tem = TYPE_MAIN_VARIANT (type); tem; tem = TYPE_NEXT_VARIANT (tem))
1000 if (!TYPE_READONLY (tem) && !TYPE_VOLATILE (tem)
1001 && TYPE_NAME (tem) == TYPE_NAME (type))
1006 if (TYPE_NAME (type)
1007 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1008 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type)))
1012 if (TYPE_SYMTAB_ADDRESS (type) == 0)
1014 /* Type has no dbx number assigned. Assign next available number. */
1015 TYPE_SYMTAB_ADDRESS (type) = next_type_number++;
1017 /* Make sure type vector is long enough to record about this type. */
1019 if (next_type_number == typevec_len)
1022 = (struct typeinfo *) xrealloc (typevec,
1023 typevec_len * 2 * sizeof typevec[0]);
1024 bzero ((char *) (typevec + typevec_len),
1025 typevec_len * sizeof typevec[0]);
1029 #ifdef DBX_USE_BINCL
1030 typevec[TYPE_SYMTAB_ADDRESS (type)].file_number
1031 = current_file->file_number;
1032 typevec[TYPE_SYMTAB_ADDRESS (type)].type_number
1033 = current_file->next_type_number++;
1037 /* Output the number of this type, to refer to it. */
1038 dbxout_type_index (type);
1040 #ifdef DBX_TYPE_DEFINED
1041 if (DBX_TYPE_DEFINED (type))
1045 /* If this type's definition has been output or is now being output,
1048 switch (typevec[TYPE_SYMTAB_ADDRESS (type)].status)
1053 /* If we have already had a cross reference,
1054 and either that's all we want or that's the best we could do,
1055 don't repeat the cross reference.
1056 Sun dbx crashes if we do. */
1057 if (! full || TYPE_SIZE (type) == 0
1058 /* No way in DBX fmt to describe a variable size. */
1059 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1067 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1068 leave the type-number completely undefined rather than output
1069 a cross-reference. If we have already used GNU debug info extensions,
1070 then it is OK to output a cross reference. This is necessary to get
1071 proper C++ debug output. */
1072 if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
1073 || TREE_CODE (type) == QUAL_UNION_TYPE
1074 || TREE_CODE (type) == ENUMERAL_TYPE)
1075 && ! use_gnu_debug_info_extensions)
1076 /* We must use the same test here as we use twice below when deciding
1077 whether to emit a cross-reference. */
1078 if ((TYPE_NAME (type) != 0
1079 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1080 && DECL_IGNORED_P (TYPE_NAME (type)))
1082 || TYPE_SIZE (type) == 0
1083 /* No way in DBX fmt to describe a variable size. */
1084 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1086 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1091 /* Output a definition now. */
1093 fprintf (asmfile, "=");
1096 /* Mark it as defined, so that if it is self-referent
1097 we will not get into an infinite recursion of definitions. */
1099 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_DEFINED;
1101 if (TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1102 && DECL_ORIGINAL_TYPE (TYPE_NAME (type)))
1104 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type)), 0, 0);
1108 switch (TREE_CODE (type))
1112 /* For a void type, just define it as itself; ie, "5=5".
1113 This makes us consider it defined
1114 without saying what it is. The debugger will make it
1115 a void type when the reference is seen, and nothing will
1116 ever override that default. */
1117 dbxout_type_index (type);
1121 if (type == char_type_node && ! TREE_UNSIGNED (type))
1123 /* Output the type `char' as a subrange of itself!
1124 I don't understand this definition, just copied it
1125 from the output of pcc.
1126 This used to use `r2' explicitly and we used to
1127 take care to make sure that `char' was type number 2. */
1128 fprintf (asmfile, "r");
1129 dbxout_type_index (type);
1130 fprintf (asmfile, ";0;127;");
1132 else if (use_gnu_debug_info_extensions
1133 && (TYPE_PRECISION (type) > TYPE_PRECISION (integer_type_node)
1134 || TYPE_PRECISION (type) > HOST_BITS_PER_WIDE_INT))
1136 /* This used to say `r1' and we used to take care
1137 to make sure that `int' was type number 1. */
1138 fprintf (asmfile, "r");
1139 dbxout_type_index (integer_type_node);
1140 fprintf (asmfile, ";");
1141 print_int_cst_octal (TYPE_MIN_VALUE (type));
1142 fprintf (asmfile, ";");
1143 print_int_cst_octal (TYPE_MAX_VALUE (type));
1144 fprintf (asmfile, ";");
1146 else /* Output other integer types as subranges of `int'. */
1147 dbxout_range_type (type);
1152 /* This used to say `r1' and we used to take care
1153 to make sure that `int' was type number 1. */
1154 fprintf (asmfile, "r");
1155 dbxout_type_index (integer_type_node);
1156 fprintf (asmfile, ";%d;0;", int_size_in_bytes (type));
1161 if (use_gnu_debug_info_extensions)
1162 fprintf (asmfile, "@s%d;-20;",
1163 BITS_PER_UNIT * int_size_in_bytes (type));
1166 /* Output the type `char' as a subrange of itself.
1167 That is what pcc seems to do. */
1168 fprintf (asmfile, "r");
1169 dbxout_type_index (char_type_node);
1170 fprintf (asmfile, ";0;%d;", TREE_UNSIGNED (type) ? 255 : 127);
1176 if (use_gnu_debug_info_extensions)
1177 fprintf (asmfile, "@s%d;-16;",
1178 BITS_PER_UNIT * int_size_in_bytes (type));
1179 else /* Define as enumeral type (False, True) */
1180 fprintf (asmfile, "eFalse:0,True:1,;");
1185 putc ('d', asmfile);
1187 dbxout_type (TREE_TYPE (type), 0, 0);
1191 /* Differs from the REAL_TYPE by its new data type number */
1193 if (TREE_CODE (TREE_TYPE (type)) == REAL_TYPE)
1195 fprintf (asmfile, "r");
1196 dbxout_type_index (type);
1197 fprintf (asmfile, ";%d;0;",
1198 int_size_in_bytes (TREE_TYPE (type)));
1199 CHARS (12); /* The number is probably incorrect here. */
1203 /* Output a complex integer type as a structure,
1204 pending some other way to do it. */
1205 fprintf (asmfile, "s%d", int_size_in_bytes (type));
1207 fprintf (asmfile, "real:");
1209 dbxout_type (TREE_TYPE (type), 0, 0);
1210 fprintf (asmfile, ",%d,%d;",
1211 0, TYPE_PRECISION (TREE_TYPE (type)));
1213 fprintf (asmfile, "imag:");
1215 dbxout_type (TREE_TYPE (type), 0, 0);
1216 fprintf (asmfile, ",%d,%d;;",
1217 TYPE_PRECISION (TREE_TYPE (type)),
1218 TYPE_PRECISION (TREE_TYPE (type)));
1224 if (use_gnu_debug_info_extensions)
1226 have_used_extensions = 1;
1227 fprintf (asmfile, "@s%d;",
1228 BITS_PER_UNIT * int_size_in_bytes (type));
1229 /* Check if a bitstring type, which in Chill is
1230 different from a [power]set. */
1231 if (TYPE_STRING_FLAG (type))
1232 fprintf (asmfile, "@S;");
1234 putc ('S', asmfile);
1236 dbxout_type (TYPE_DOMAIN (type), 0, 0);
1240 /* Output "a" followed by a range type definition
1241 for the index type of the array
1242 followed by a reference to the target-type.
1243 ar1;0;N;M for a C array of type M and size N+1. */
1244 /* Check if a character string type, which in Chill is
1245 different from an array of characters. */
1246 if (TYPE_STRING_FLAG (type) && use_gnu_debug_info_extensions)
1248 have_used_extensions = 1;
1249 fprintf (asmfile, "@S;");
1251 tem = TYPE_DOMAIN (type);
1254 fprintf (asmfile, "ar");
1255 dbxout_type_index (integer_type_node);
1256 fprintf (asmfile, ";0;-1;");
1260 fprintf (asmfile, "a");
1261 dbxout_range_type (tem);
1264 dbxout_type (TREE_TYPE (type), 0, 0);
1269 case QUAL_UNION_TYPE:
1271 int i, n_baseclasses = 0;
1273 if (TYPE_BINFO (type) != 0 && TYPE_BINFO_BASETYPES (type) != 0)
1274 n_baseclasses = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type));
1276 /* Output a structure type. We must use the same test here as we
1277 use in the DBX_NO_XREFS case above. */
1278 if ((TYPE_NAME (type) != 0
1279 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1280 && DECL_IGNORED_P (TYPE_NAME (type)))
1282 || TYPE_SIZE (type) == 0
1283 /* No way in DBX fmt to describe a variable size. */
1284 || TREE_CODE (TYPE_SIZE (type)) != INTEGER_CST)
1286 /* If the type is just a cross reference, output one
1287 and mark the type as partially described.
1288 If it later becomes defined, we will output
1289 its real definition.
1290 If the type has a name, don't nest its definition within
1291 another type's definition; instead, output an xref
1292 and let the definition come when the name is defined. */
1293 fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "xs" : "xu");
1295 #if 0 /* This assertion is legitimately false in C++. */
1296 /* We shouldn't be outputting a reference to a type before its
1297 definition unless the type has a tag name.
1298 A typedef name without a tag name should be impossible. */
1299 if (TREE_CODE (TYPE_NAME (type)) != IDENTIFIER_NODE)
1302 if (TYPE_NAME (type) != 0)
1303 dbxout_type_name (type);
1305 fprintf (asmfile, "$$%d", anonymous_type_number++);
1306 fprintf (asmfile, ":");
1307 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1311 /* Identify record or union, and print its size. */
1312 fprintf (asmfile, (TREE_CODE (type) == RECORD_TYPE) ? "s%d" : "u%d",
1313 int_size_in_bytes (type));
1315 if (use_gnu_debug_info_extensions)
1319 have_used_extensions = 1;
1320 fprintf (asmfile, "!%d,", n_baseclasses);
1324 for (i = 0; i < n_baseclasses; i++)
1326 tree child = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type)), i);
1327 if (use_gnu_debug_info_extensions)
1329 have_used_extensions = 1;
1330 putc (TREE_VIA_VIRTUAL (child) ? '1'
1333 putc (TREE_VIA_PUBLIC (child) ? '2'
1336 fprintf (asmfile, "%d,",
1337 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT);
1339 dbxout_type (BINFO_TYPE (child), 0, 0);
1340 putc (';', asmfile);
1344 /* Print out the base class information with fields
1345 which have the same names at the types they hold. */
1346 dbxout_type_name (BINFO_TYPE (child));
1347 putc (':', asmfile);
1348 dbxout_type (BINFO_TYPE (child), full, 0);
1349 fprintf (asmfile, ",%d,%d;",
1350 TREE_INT_CST_LOW (BINFO_OFFSET (child)) * BITS_PER_UNIT,
1351 TREE_INT_CST_LOW (DECL_SIZE (TYPE_NAME (BINFO_TYPE (child)))) * BITS_PER_UNIT);
1359 /* Write out the field declarations. */
1360 dbxout_type_fields (type);
1361 if (use_gnu_debug_info_extensions && TYPE_METHODS (type) != NULL_TREE)
1363 have_used_extensions = 1;
1364 dbxout_type_methods (type);
1366 putc (';', asmfile);
1368 if (use_gnu_debug_info_extensions && TREE_CODE (type) == RECORD_TYPE
1369 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1370 && TYPE_VFIELD (type))
1372 have_used_extensions = 1;
1374 /* Tell GDB+ that it may keep reading. */
1375 putc ('~', asmfile);
1377 /* We need to write out info about what field this class
1378 uses as its "main" vtable pointer field, because if this
1379 field is inherited from a base class, GDB cannot necessarily
1380 figure out which field it's using in time. */
1381 if (TYPE_VFIELD (type))
1383 putc ('%', asmfile);
1384 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type)), 0, 0);
1386 putc (';', asmfile);
1392 /* We must use the same test here as we use in the DBX_NO_XREFS case
1393 above. We simplify it a bit since an enum will never have a variable
1395 if ((TYPE_NAME (type) != 0
1396 && ! (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1397 && DECL_IGNORED_P (TYPE_NAME (type)))
1399 || TYPE_SIZE (type) == 0)
1401 fprintf (asmfile, "xe");
1403 dbxout_type_name (type);
1404 typevec[TYPE_SYMTAB_ADDRESS (type)].status = TYPE_XREF;
1405 fprintf (asmfile, ":");
1408 #ifdef DBX_OUTPUT_ENUM
1409 DBX_OUTPUT_ENUM (asmfile, type);
1411 if (use_gnu_debug_info_extensions
1412 && TYPE_PRECISION (type) != TYPE_PRECISION (integer_type_node))
1413 fprintf (asmfile, "@s%d;", TYPE_PRECISION (type));
1414 putc ('e', asmfile);
1416 for (tem = TYPE_VALUES (type); tem; tem = TREE_CHAIN (tem))
1418 fprintf (asmfile, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem)));
1419 if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == 0)
1420 fprintf (asmfile, "%lu",
1421 (unsigned long) TREE_INT_CST_LOW (TREE_VALUE (tem)));
1422 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem)) == -1
1423 && TREE_INT_CST_LOW (TREE_VALUE (tem)) < 0)
1424 fprintf (asmfile, "%ld",
1425 (long) TREE_INT_CST_LOW (TREE_VALUE (tem)));
1427 print_int_cst_octal (TREE_VALUE (tem));
1428 fprintf (asmfile, ",");
1429 CHARS (20 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem)));
1430 if (TREE_CHAIN (tem) != 0)
1433 putc (';', asmfile);
1439 putc ('*', asmfile);
1441 dbxout_type (TREE_TYPE (type), 0, 0);
1445 if (use_gnu_debug_info_extensions)
1447 have_used_extensions = 1;
1448 putc ('#', asmfile);
1450 if (flag_minimal_debug && !show_arg_types)
1452 /* Normally, just output the return type.
1453 The argument types are encoded in the method name. */
1454 putc ('#', asmfile);
1456 dbxout_type (TREE_TYPE (type), 0, 0);
1457 putc (';', asmfile);
1462 /* When outputting destructors, we need to write
1463 the argument types out longhand. */
1464 dbxout_type (TYPE_METHOD_BASETYPE (type), 0, 0);
1465 putc (',', asmfile);
1467 dbxout_type (TREE_TYPE (type), 0, 0);
1468 dbxout_args (TYPE_ARG_TYPES (type));
1469 putc (';', asmfile);
1475 /* Treat it as a function type. */
1476 dbxout_type (TREE_TYPE (type), 0, 0);
1481 if (use_gnu_debug_info_extensions)
1483 have_used_extensions = 1;
1484 putc ('@', asmfile);
1486 dbxout_type (TYPE_OFFSET_BASETYPE (type), 0, 0);
1487 putc (',', asmfile);
1489 dbxout_type (TREE_TYPE (type), 0, 0);
1493 /* Should print as an int, because it is really
1495 dbxout_type (integer_type_node, 0, 0);
1499 case REFERENCE_TYPE:
1500 if (use_gnu_debug_info_extensions)
1501 have_used_extensions = 1;
1502 putc (use_gnu_debug_info_extensions ? '&' : '*', asmfile);
1504 dbxout_type (TREE_TYPE (type), 0, 0);
1508 putc ('f', asmfile);
1510 dbxout_type (TREE_TYPE (type), 0, 0);
1518 /* Print the value of integer constant C, in octal,
1519 handling double precision. */
1522 print_int_cst_octal (c)
1525 unsigned HOST_WIDE_INT high = TREE_INT_CST_HIGH (c);
1526 unsigned HOST_WIDE_INT low = TREE_INT_CST_LOW (c);
1527 int excess = (3 - (HOST_BITS_PER_WIDE_INT % 3));
1528 int width = TYPE_PRECISION (TREE_TYPE (c));
1530 /* GDB wants constants with no extra leading "1" bits, so
1531 we need to remove any sign-extension that might be
1533 if (width == HOST_BITS_PER_WIDE_INT * 2)
1535 else if (width > HOST_BITS_PER_WIDE_INT)
1536 high &= (((HOST_WIDE_INT) 1 << (width - HOST_BITS_PER_WIDE_INT)) - 1);
1537 else if (width == HOST_BITS_PER_WIDE_INT)
1540 high = 0, low &= (((HOST_WIDE_INT) 1 << width) - 1);
1542 fprintf (asmfile, "0");
1546 print_octal (high, HOST_BITS_PER_WIDE_INT / 3);
1547 print_octal (low, HOST_BITS_PER_WIDE_INT / 3);
1551 unsigned HOST_WIDE_INT beg = high >> excess;
1552 unsigned HOST_WIDE_INT middle
1553 = ((high & (((HOST_WIDE_INT) 1 << excess) - 1)) << (3 - excess)
1554 | (low >> (HOST_BITS_PER_WIDE_INT / 3 * 3)));
1555 unsigned HOST_WIDE_INT end
1556 = low & (((unsigned HOST_WIDE_INT) 1
1557 << (HOST_BITS_PER_WIDE_INT / 3 * 3))
1560 fprintf (asmfile, "%o%01o", beg, middle);
1561 print_octal (end, HOST_BITS_PER_WIDE_INT / 3);
1566 print_octal (value, digits)
1567 unsigned HOST_WIDE_INT value;
1572 for (i = digits - 1; i >= 0; i--)
1573 fprintf (asmfile, "%01o", ((value >> (3 * i)) & 7));
1576 /* Output the name of type TYPE, with no punctuation.
1577 Such names can be set up either by typedef declarations
1578 or by struct, enum and union tags. */
1581 dbxout_type_name (type)
1585 if (TYPE_NAME (type) == 0)
1587 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
1589 t = TYPE_NAME (type);
1591 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
1593 t = DECL_NAME (TYPE_NAME (type));
1598 fprintf (asmfile, "%s", IDENTIFIER_POINTER (t));
1599 CHARS (IDENTIFIER_LENGTH (t));
1602 /* Output a .stabs for the symbol defined by DECL,
1603 which must be a ..._DECL node in the normal namespace.
1604 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1605 LOCAL is nonzero if the scope is less than the entire file. */
1608 dbxout_symbol (decl, local)
1612 tree type = TREE_TYPE (decl);
1613 tree context = NULL_TREE;
1615 /* Cast avoids warning in old compilers. */
1616 current_sym_code = (STAB_CODE_TYPE) 0;
1617 current_sym_value = 0;
1618 current_sym_addr = 0;
1620 /* Ignore nameless syms, but don't ignore type tags. */
1622 if ((DECL_NAME (decl) == 0 && TREE_CODE (decl) != TYPE_DECL)
1623 || DECL_IGNORED_P (decl))
1626 dbxout_prepare_symbol (decl);
1628 /* The output will always start with the symbol name,
1629 so always count that in the length-output-so-far. */
1631 if (DECL_NAME (decl) != 0)
1632 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (decl));
1634 switch (TREE_CODE (decl))
1637 /* Enum values are defined by defining the enum type. */
1641 if (DECL_RTL (decl) == 0)
1643 if (DECL_EXTERNAL (decl))
1645 /* Don't mention a nested function under its parent. */
1646 context = decl_function_context (decl);
1647 if (context == current_function_decl)
1649 if (GET_CODE (DECL_RTL (decl)) != MEM
1650 || GET_CODE (XEXP (DECL_RTL (decl), 0)) != SYMBOL_REF)
1654 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
1655 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1656 TREE_PUBLIC (decl) ? 'F' : 'f');
1658 current_sym_code = N_FUN;
1659 current_sym_addr = XEXP (DECL_RTL (decl), 0);
1661 if (TREE_TYPE (type))
1662 dbxout_type (TREE_TYPE (type), 0, 0);
1664 dbxout_type (void_type_node, 0, 0);
1666 /* For a nested function, when that function is compiled,
1667 mention the containing function name
1668 as well as (since dbx wants it) our own assembler-name. */
1670 fprintf (asmfile, ",%s,%s",
1671 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
1672 IDENTIFIER_POINTER (DECL_NAME (context)));
1674 dbxout_finish_symbol (decl);
1679 /* This seems all wrong. Outputting most kinds of types gives no name
1680 at all. A true definition gives no name; a cross-ref for a
1681 structure can give the tag name, but not a type name.
1682 It seems that no typedef name is defined by outputting a type. */
1684 /* If this typedef name was defined by outputting the type,
1685 don't duplicate it. */
1686 if (typevec[TYPE_SYMTAB_ADDRESS (type)].status == TYPE_DEFINED
1687 && TYPE_NAME (TREE_TYPE (decl)) == decl)
1690 /* Don't output the same typedef twice.
1691 And don't output what language-specific stuff doesn't want output. */
1692 if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
1701 if (DECL_NAME (decl))
1703 /* Nonzero means we must output a tag as well as a typedef. */
1706 /* Handle the case of a C++ structure or union
1707 where the TYPE_NAME is a TYPE_DECL
1708 which gives both a typedef name and a tag. */
1709 /* dbx requires the tag first and the typedef second. */
1710 if ((TREE_CODE (type) == RECORD_TYPE
1711 || TREE_CODE (type) == UNION_TYPE
1712 || TREE_CODE (type) == QUAL_UNION_TYPE)
1713 && TYPE_NAME (type) == decl
1714 && !(use_gnu_debug_info_extensions && have_used_extensions)
1715 && !TREE_ASM_WRITTEN (TYPE_NAME (type))
1716 /* Distinguish the implicit typedefs of C++
1717 from explicit ones that might be found in C. */
1718 && DECL_ARTIFICIAL (decl))
1720 tree name = TYPE_NAME (type);
1721 if (TREE_CODE (name) == TYPE_DECL)
1722 name = DECL_NAME (name);
1724 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1725 current_sym_value = 0;
1726 current_sym_addr = 0;
1727 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1729 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1730 IDENTIFIER_POINTER (name));
1731 dbxout_type (type, 1, 0);
1732 dbxout_finish_symbol (NULL_TREE);
1735 /* Output typedef name. */
1736 fprintf (asmfile, "%s \"%s:", ASM_STABS_OP,
1737 IDENTIFIER_POINTER (DECL_NAME (decl)));
1739 /* Short cut way to output a tag also. */
1740 if ((TREE_CODE (type) == RECORD_TYPE
1741 || TREE_CODE (type) == UNION_TYPE
1742 || TREE_CODE (type) == QUAL_UNION_TYPE)
1743 && TYPE_NAME (type) == decl
1744 /* Distinguish the implicit typedefs of C++
1745 from explicit ones that might be found in C. */
1746 && DECL_ARTIFICIAL (decl))
1748 if (use_gnu_debug_info_extensions && have_used_extensions)
1750 putc ('T', asmfile);
1751 TREE_ASM_WRITTEN (TYPE_NAME (type)) = 1;
1753 #if 0 /* Now we generate the tag for this case up above. */
1759 putc ('t', asmfile);
1760 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1762 dbxout_type (type, 1, 0);
1763 dbxout_finish_symbol (decl);
1767 /* Don't output a tag if this is an incomplete type (TYPE_SIZE is
1768 zero). This prevents the sun4 Sun OS 4.x dbx from crashing. */
1770 if (tag_needed && TYPE_NAME (type) != 0
1771 && (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE
1772 || (DECL_NAME (TYPE_NAME (type)) != 0))
1773 && TYPE_SIZE (type) != 0
1774 && !TREE_ASM_WRITTEN (TYPE_NAME (type)))
1776 /* For a TYPE_DECL with no name, but the type has a name,
1778 This is what represents `struct foo' with no typedef. */
1779 /* In C++, the name of a type is the corresponding typedef.
1780 In C, it is an IDENTIFIER_NODE. */
1781 tree name = TYPE_NAME (type);
1782 if (TREE_CODE (name) == TYPE_DECL)
1783 name = DECL_NAME (name);
1785 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1786 current_sym_value = 0;
1787 current_sym_addr = 0;
1788 current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
1790 fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
1791 IDENTIFIER_POINTER (name));
1792 dbxout_type (type, 1, 0);
1793 dbxout_finish_symbol (NULL_TREE);
1797 /* If an enum type has no name, it cannot be referred to,
1798 but we must output it anyway, since the enumeration constants
1799 can be referred to. */
1800 if (!did_output && TREE_CODE (type) == ENUMERAL_TYPE)
1802 current_sym_code = DBX_TYPE_DECL_STABS_CODE;
1803 current_sym_value = 0;
1804 current_sym_addr = 0;
1805 current_sym_nchars = 2;
1807 /* Some debuggers fail when given NULL names, so give this a
1808 harmless name of ` '. */
1809 fprintf (asmfile, "%s \" :T", ASM_STABS_OP);
1810 dbxout_type (type, 1, 0);
1811 dbxout_finish_symbol (NULL_TREE);
1814 /* Prevent duplicate output of a typedef. */
1815 TREE_ASM_WRITTEN (decl) = 1;
1820 /* Parm decls go in their own separate chains
1821 and are output by dbxout_reg_parms and dbxout_parms. */
1825 /* Named return value, treat like a VAR_DECL. */
1827 if (DECL_RTL (decl) == 0)
1829 /* Don't mention a variable that is external.
1830 Let the file that defines it describe it. */
1831 if (DECL_EXTERNAL (decl))
1834 /* If the variable is really a constant
1835 and not written in memory, inform the debugger. */
1836 if (TREE_STATIC (decl) && TREE_READONLY (decl)
1837 && DECL_INITIAL (decl) != 0
1838 && ! TREE_ASM_WRITTEN (decl)
1839 && (DECL_FIELD_CONTEXT (decl) == NULL_TREE
1840 || TREE_CODE (DECL_FIELD_CONTEXT (decl)) == BLOCK))
1842 if (TREE_PUBLIC (decl) == 0)
1844 /* The sun4 assembler does not grok this. */
1845 char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
1846 if (TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE
1847 || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE)
1849 HOST_WIDE_INT ival = TREE_INT_CST_LOW (DECL_INITIAL (decl));
1850 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
1851 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile, name, ival);
1853 fprintf (asmfile, "%s \"%s:c=i%d\",0x%x,0,0,0\n",
1854 ASM_STABS_OP, name, ival, N_LSYM);
1858 else if (TREE_CODE (TREE_TYPE (decl)) == REAL_TYPE)
1860 /* don't know how to do this yet. */
1864 /* else it is something we handle like a normal variable. */
1867 DECL_RTL (decl) = eliminate_regs (DECL_RTL (decl), 0, NULL_RTX);
1868 #ifdef LEAF_REG_REMAP
1870 leaf_renumber_regs_insn (DECL_RTL (decl));
1873 dbxout_symbol_location (decl, type, 0, DECL_RTL (decl));
1881 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
1882 Add SUFFIX to its name, if SUFFIX is not 0.
1883 Describe the variable as residing in HOME
1884 (usually HOME is DECL_RTL (DECL), but not always). */
1887 dbxout_symbol_location (decl, type, suffix, home)
1895 /* Don't mention a variable at all
1896 if it was completely optimized into nothingness.
1898 If the decl was from an inline function, then it's rtl
1899 is not identically the rtl that was used in this
1900 particular compilation. */
1901 if (GET_CODE (home) == REG)
1903 regno = REGNO (home);
1904 if (regno >= FIRST_PSEUDO_REGISTER)
1907 else if (GET_CODE (home) == SUBREG)
1911 while (GET_CODE (value) == SUBREG)
1913 offset += SUBREG_WORD (value);
1914 value = SUBREG_REG (value);
1916 if (GET_CODE (value) == REG)
1918 regno = REGNO (value);
1919 if (regno >= FIRST_PSEUDO_REGISTER)
1923 alter_subreg (home);
1926 /* The kind-of-variable letter depends on where
1927 the variable is and on the scope of its name:
1928 G and N_GSYM for static storage and global scope,
1929 S for static storage and file scope,
1930 V for static storage and local scope,
1931 for those two, use N_LCSYM if data is in bss segment,
1932 N_STSYM if in data segment, N_FUN otherwise.
1933 (We used N_FUN originally, then changed to N_STSYM
1934 to please GDB. However, it seems that confused ld.
1935 Now GDB has been fixed to like N_FUN, says Kingdon.)
1936 no letter at all, and N_LSYM, for auto variable,
1937 r and N_RSYM for register variable. */
1939 if (GET_CODE (home) == MEM
1940 && GET_CODE (XEXP (home, 0)) == SYMBOL_REF)
1942 if (TREE_PUBLIC (decl))
1945 current_sym_code = N_GSYM;
1949 current_sym_addr = XEXP (home, 0);
1951 letter = decl_function_context (decl) ? 'V' : 'S';
1953 /* This should be the same condition as in assemble_variable, but
1954 we don't have access to dont_output_data here. So, instead,
1955 we rely on the fact that error_mark_node initializers always
1956 end up in bss for C++ and never end up in bss for C. */
1957 if (DECL_INITIAL (decl) == 0
1958 || (!strcmp (lang_identify (), "cplusplus")
1959 && DECL_INITIAL (decl) == error_mark_node))
1960 current_sym_code = N_LCSYM;
1961 else if (DECL_IN_TEXT_SECTION (decl))
1962 /* This is not quite right, but it's the closest
1963 of all the codes that Unix defines. */
1964 current_sym_code = DBX_STATIC_CONST_VAR_CODE;
1967 /* Ultrix `as' seems to need this. */
1968 #ifdef DBX_STATIC_STAB_DATA_SECTION
1971 current_sym_code = N_STSYM;
1975 else if (regno >= 0)
1978 current_sym_code = N_RSYM;
1979 current_sym_value = DBX_REGISTER_NUMBER (regno);
1981 else if (GET_CODE (home) == MEM
1982 && (GET_CODE (XEXP (home, 0)) == MEM
1983 || (GET_CODE (XEXP (home, 0)) == REG
1984 && REGNO (XEXP (home, 0)) != HARD_FRAME_POINTER_REGNUM
1985 && REGNO (XEXP (home, 0)) != STACK_POINTER_REGNUM
1986 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
1987 && REGNO (XEXP (home, 0)) != ARG_POINTER_REGNUM
1990 /* If the value is indirect by memory or by a register
1991 that isn't the frame pointer
1992 then it means the object is variable-sized and address through
1993 that register or stack slot. DBX has no way to represent this
1994 so all we can do is output the variable as a pointer.
1995 If it's not a parameter, ignore it.
1996 (VAR_DECLs like this can be made by integrate.c.) */
1998 if (GET_CODE (XEXP (home, 0)) == REG)
2001 current_sym_code = N_RSYM;
2002 current_sym_value = DBX_REGISTER_NUMBER (REGNO (XEXP (home, 0)));
2006 current_sym_code = N_LSYM;
2007 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2008 We want the value of that CONST_INT. */
2010 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home, 0), 0));
2013 /* Effectively do build_pointer_type, but don't cache this type,
2014 since it might be temporary whereas the type it points to
2015 might have been saved for inlining. */
2016 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2017 type = make_node (POINTER_TYPE);
2018 TREE_TYPE (type) = TREE_TYPE (decl);
2020 else if (GET_CODE (home) == MEM
2021 && GET_CODE (XEXP (home, 0)) == REG)
2023 current_sym_code = N_LSYM;
2024 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2026 else if (GET_CODE (home) == MEM
2027 && GET_CODE (XEXP (home, 0)) == PLUS
2028 && GET_CODE (XEXP (XEXP (home, 0), 1)) == CONST_INT)
2030 current_sym_code = N_LSYM;
2031 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2032 We want the value of that CONST_INT. */
2033 current_sym_value = DEBUGGER_AUTO_OFFSET (XEXP (home, 0));
2035 else if (GET_CODE (home) == MEM
2036 && GET_CODE (XEXP (home, 0)) == CONST)
2038 /* Handle an obscure case which can arise when optimizing and
2039 when there are few available registers. (This is *always*
2040 the case for i386/i486 targets). The RTL looks like
2041 (MEM (CONST ...)) even though this variable is a local `auto'
2042 or a local `register' variable. In effect, what has happened
2043 is that the reload pass has seen that all assignments and
2044 references for one such a local variable can be replaced by
2045 equivalent assignments and references to some static storage
2046 variable, thereby avoiding the need for a register. In such
2047 cases we're forced to lie to debuggers and tell them that
2048 this variable was itself `static'. */
2049 current_sym_code = N_LCSYM;
2051 current_sym_addr = XEXP (XEXP (home, 0), 0);
2053 else if (GET_CODE (home) == CONCAT)
2055 tree subtype = TREE_TYPE (type);
2057 /* If the variable's storage is in two parts,
2058 output each as a separate stab with a modified name. */
2059 if (WORDS_BIG_ENDIAN)
2060 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 0));
2062 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 0));
2064 /* Cast avoids warning in old compilers. */
2065 current_sym_code = (STAB_CODE_TYPE) 0;
2066 current_sym_value = 0;
2067 current_sym_addr = 0;
2068 dbxout_prepare_symbol (decl);
2070 if (WORDS_BIG_ENDIAN)
2071 dbxout_symbol_location (decl, subtype, "$real", XEXP (home, 1));
2073 dbxout_symbol_location (decl, subtype, "$imag", XEXP (home, 1));
2077 /* Address might be a MEM, when DECL is a variable-sized object.
2078 Or it might be const0_rtx, meaning previous passes
2079 want us to ignore this variable. */
2082 /* Ok, start a symtab entry and output the variable name. */
2085 #ifdef DBX_STATIC_BLOCK_START
2086 DBX_STATIC_BLOCK_START (asmfile, current_sym_code);
2089 dbxout_symbol_name (decl, suffix, letter);
2090 dbxout_type (type, 0, 0);
2091 dbxout_finish_symbol (decl);
2093 #ifdef DBX_STATIC_BLOCK_END
2094 DBX_STATIC_BLOCK_END (asmfile, current_sym_code);
2098 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2099 Then output LETTER to indicate the kind of location the symbol has. */
2102 dbxout_symbol_name (decl, suffix, letter)
2107 /* One slight hitch: if this is a VAR_DECL which is a static
2108 class member, we must put out the mangled name instead of the
2109 DECL_NAME. Note also that static member (variable) names DO NOT begin
2110 with underscores in .stabs directives. */
2111 char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
2114 fprintf (asmfile, "%s \"%s%s:", ASM_STABS_OP, name,
2115 (suffix ? suffix : ""));
2117 if (letter) putc (letter, asmfile);
2121 dbxout_prepare_symbol (decl)
2125 char *filename = DECL_SOURCE_FILE (decl);
2127 dbxout_source_file (asmfile, filename);
2132 dbxout_finish_symbol (sym)
2135 #ifdef DBX_FINISH_SYMBOL
2136 DBX_FINISH_SYMBOL (sym);
2139 if (use_gnu_debug_info_extensions && sym != 0)
2140 line = DECL_SOURCE_LINE (sym);
2142 fprintf (asmfile, "\",%d,0,%d,", current_sym_code, line);
2143 if (current_sym_addr)
2144 output_addr_const (asmfile, current_sym_addr);
2146 fprintf (asmfile, "%d", current_sym_value);
2147 putc ('\n', asmfile);
2151 /* Output definitions of all the decls in a chain. */
2159 dbxout_symbol (syms, 1);
2160 syms = TREE_CHAIN (syms);
2164 /* The following two functions output definitions of function parameters.
2165 Each parameter gets a definition locating it in the parameter list.
2166 Each parameter that is a register variable gets a second definition
2167 locating it in the register.
2169 Printing or argument lists in gdb uses the definitions that
2170 locate in the parameter list. But reference to the variable in
2171 expressions uses preferentially the definition as a register. */
2173 /* Output definitions, referring to storage in the parmlist,
2174 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2177 dbxout_parms (parms)
2180 for (; parms; parms = TREE_CHAIN (parms))
2181 if (DECL_NAME (parms) && TREE_TYPE (parms) != error_mark_node)
2183 dbxout_prepare_symbol (parms);
2185 /* Perform any necessary register eliminations on the parameter's rtl,
2186 so that the debugging output will be accurate. */
2187 DECL_INCOMING_RTL (parms)
2188 = eliminate_regs (DECL_INCOMING_RTL (parms), 0, NULL_RTX);
2189 DECL_RTL (parms) = eliminate_regs (DECL_RTL (parms), 0, NULL_RTX);
2190 #ifdef LEAF_REG_REMAP
2193 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms));
2194 leaf_renumber_regs_insn (DECL_RTL (parms));
2198 if (PARM_PASSED_IN_MEMORY (parms))
2200 rtx addr = XEXP (DECL_INCOMING_RTL (parms), 0);
2202 /* ??? Here we assume that the parm address is indexed
2203 off the frame pointer or arg pointer.
2204 If that is not true, we produce meaningless results,
2205 but do not crash. */
2206 if (GET_CODE (addr) == PLUS
2207 && GET_CODE (XEXP (addr, 1)) == CONST_INT)
2208 current_sym_value = INTVAL (XEXP (addr, 1));
2210 current_sym_value = 0;
2212 current_sym_code = N_PSYM;
2213 current_sym_addr = 0;
2216 if (DECL_NAME (parms))
2218 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2220 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2221 IDENTIFIER_POINTER (DECL_NAME (parms)),
2222 DBX_MEMPARM_STABS_LETTER);
2226 current_sym_nchars = 8;
2227 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2228 DBX_MEMPARM_STABS_LETTER);
2231 dbxout_type (DECL_ARG_TYPE (parms), 0, 0);
2232 current_sym_value = DEBUGGER_ARG_OFFSET (current_sym_value, addr);
2233 dbxout_finish_symbol (parms);
2235 else if (GET_CODE (DECL_RTL (parms)) == REG)
2238 char regparm_letter;
2240 /* Parm passed in registers and lives in registers or nowhere. */
2242 current_sym_code = DBX_REGPARM_STABS_CODE;
2243 regparm_letter = DBX_REGPARM_STABS_LETTER;
2244 current_sym_addr = 0;
2246 /* If parm lives in a register, use that register;
2247 pretend the parm was passed there. It would be more consistent
2248 to describe the register where the parm was passed,
2249 but in practice that register usually holds something else.
2251 If we use DECL_RTL, then we must use the declared type of
2252 the variable, not the type that it arrived in. */
2253 if (REGNO (DECL_RTL (parms)) >= 0
2254 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2256 best_rtl = DECL_RTL (parms);
2257 parm_type = TREE_TYPE (parms);
2259 /* If the parm lives nowhere, use the register where it was
2260 passed. It is also better to use the declared type here. */
2263 best_rtl = DECL_INCOMING_RTL (parms);
2264 parm_type = TREE_TYPE (parms);
2266 current_sym_value = DBX_REGISTER_NUMBER (REGNO (best_rtl));
2269 if (DECL_NAME (parms))
2271 current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
2272 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2273 IDENTIFIER_POINTER (DECL_NAME (parms)),
2278 current_sym_nchars = 8;
2279 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2283 dbxout_type (parm_type, 0, 0);
2284 dbxout_finish_symbol (parms);
2286 else if (GET_CODE (DECL_RTL (parms)) == MEM
2287 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2288 && REGNO (XEXP (DECL_RTL (parms), 0)) != HARD_FRAME_POINTER_REGNUM
2289 && REGNO (XEXP (DECL_RTL (parms), 0)) != STACK_POINTER_REGNUM
2290 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2291 && REGNO (XEXP (DECL_RTL (parms), 0)) != ARG_POINTER_REGNUM
2295 /* Parm was passed via invisible reference.
2296 That is, its address was passed in a register.
2297 Output it as if it lived in that register.
2298 The debugger will know from the type
2299 that it was actually passed by invisible reference. */
2301 char regparm_letter;
2302 /* Parm passed in registers and lives in registers or nowhere. */
2304 current_sym_code = DBX_REGPARM_STABS_CODE;
2305 if (use_gnu_debug_info_extensions)
2306 regparm_letter = GDB_INV_REF_REGPARM_STABS_LETTER;
2308 regparm_letter = DBX_REGPARM_STABS_LETTER;
2310 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2311 If it is an unallocated pseudo-reg, then use the register where
2312 it was passed instead. */
2313 if (REGNO (XEXP (DECL_RTL (parms), 0)) >= 0
2314 && REGNO (XEXP (DECL_RTL (parms), 0)) < FIRST_PSEUDO_REGISTER)
2315 current_sym_value = REGNO (XEXP (DECL_RTL (parms), 0));
2317 current_sym_value = REGNO (DECL_INCOMING_RTL (parms));
2319 current_sym_addr = 0;
2322 if (DECL_NAME (parms))
2324 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2326 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2327 IDENTIFIER_POINTER (DECL_NAME (parms)),
2332 current_sym_nchars = 8;
2333 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2337 dbxout_type (TREE_TYPE (parms), 0, 0);
2338 dbxout_finish_symbol (parms);
2340 else if (GET_CODE (DECL_RTL (parms)) == MEM
2341 && XEXP (DECL_RTL (parms), 0) != const0_rtx
2342 /* ??? A constant address for a parm can happen
2343 when the reg it lives in is equiv to a constant in memory.
2344 Should make this not happen, after 2.4. */
2345 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
2347 /* Parm was passed in registers but lives on the stack. */
2349 current_sym_code = N_PSYM;
2350 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2351 in which case we want the value of that CONST_INT,
2352 or (MEM (REG ...)) or (MEM (MEM ...)),
2353 in which case we use a value of zero. */
2354 if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG
2355 || GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
2356 current_sym_value = 0;
2358 current_sym_value = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
2359 current_sym_addr = 0;
2362 if (DECL_NAME (parms))
2364 current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
2366 fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
2367 IDENTIFIER_POINTER (DECL_NAME (parms)),
2368 DBX_MEMPARM_STABS_LETTER);
2372 current_sym_nchars = 8;
2373 fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
2374 DBX_MEMPARM_STABS_LETTER);
2378 = DEBUGGER_ARG_OFFSET (current_sym_value,
2379 XEXP (DECL_RTL (parms), 0));
2380 dbxout_type (TREE_TYPE (parms), 0, 0);
2381 dbxout_finish_symbol (parms);
2386 /* Output definitions for the places where parms live during the function,
2387 when different from where they were passed, when the parms were passed
2390 It is not useful to do this for parms passed in registers
2391 that live during the function in different registers, because it is
2392 impossible to look in the passed register for the passed value,
2393 so we use the within-the-function register to begin with.
2395 PARMS is a chain of PARM_DECL nodes. */
2398 dbxout_reg_parms (parms)
2401 for (; parms; parms = TREE_CHAIN (parms))
2402 if (DECL_NAME (parms) && PARM_PASSED_IN_MEMORY (parms))
2404 dbxout_prepare_symbol (parms);
2406 /* Report parms that live in registers during the function
2407 but were passed in memory. */
2408 if (GET_CODE (DECL_RTL (parms)) == REG
2409 && REGNO (DECL_RTL (parms)) >= 0
2410 && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER)
2411 dbxout_symbol_location (parms, TREE_TYPE (parms),
2412 0, DECL_RTL (parms));
2413 else if (GET_CODE (DECL_RTL (parms)) == CONCAT)
2414 dbxout_symbol_location (parms, TREE_TYPE (parms),
2415 0, DECL_RTL (parms));
2416 /* Report parms that live in memory but not where they were passed. */
2417 else if (GET_CODE (DECL_RTL (parms)) == MEM
2418 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
2419 dbxout_symbol_location (parms, TREE_TYPE (parms),
2420 0, DECL_RTL (parms));
2424 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2425 output definitions of those names, in raw form */
2433 putc (',', asmfile);
2434 dbxout_type (TREE_VALUE (args), 0, 0);
2436 args = TREE_CHAIN (args);
2440 /* Given a chain of ..._TYPE nodes,
2441 find those which have typedef names and output those names.
2442 This is to ensure those types get output. */
2445 dbxout_types (types)
2446 register tree types;
2450 if (TYPE_NAME (types)
2451 && TREE_CODE (TYPE_NAME (types)) == TYPE_DECL
2452 && ! TREE_ASM_WRITTEN (TYPE_NAME (types)))
2453 dbxout_symbol (TYPE_NAME (types), 1);
2454 types = TREE_CHAIN (types);
2458 /* Output everything about a symbol block (a BLOCK node
2459 that represents a scope level),
2460 including recursive output of contained blocks.
2462 BLOCK is the BLOCK node.
2463 DEPTH is its depth within containing symbol blocks.
2464 ARGS is usually zero; but for the outermost block of the
2465 body of a function, it is a chain of PARM_DECLs for the function parameters.
2466 We output definitions of all the register parms
2467 as if they were local variables of that block.
2469 If -g1 was used, we count blocks just the same, but output nothing
2470 except for the outermost block.
2472 Actually, BLOCK may be several blocks chained together.
2473 We handle them all in sequence. */
2476 dbxout_block (block, depth, args)
2477 register tree block;
2485 /* Ignore blocks never expanded or otherwise marked as real. */
2486 if (TREE_USED (block))
2488 #ifndef DBX_LBRAC_FIRST
2489 /* In dbx format, the syms of a block come before the N_LBRAC. */
2490 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2491 dbxout_syms (BLOCK_VARS (block));
2493 dbxout_reg_parms (args);
2496 /* Now output an N_LBRAC symbol to represent the beginning of
2497 the block. Use the block's tree-walk order to generate
2498 the assembler symbols LBBn and LBEn
2499 that final will define around the code in this block. */
2500 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2503 blocknum = next_block_number++;
2504 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
2506 if (BLOCK_HANDLER_BLOCK (block))
2508 /* A catch block. Must precede N_LBRAC. */
2509 tree decl = BLOCK_VARS (block);
2512 #ifdef DBX_OUTPUT_CATCH
2513 DBX_OUTPUT_CATCH (asmfile, decl, buf);
2515 fprintf (asmfile, "%s \"%s:C1\",%d,0,0,", ASM_STABS_OP,
2516 IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
2517 assemble_name (asmfile, buf);
2518 fprintf (asmfile, "\n");
2520 decl = TREE_CHAIN (decl);
2524 #ifdef DBX_OUTPUT_LBRAC
2525 DBX_OUTPUT_LBRAC (asmfile, buf);
2527 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);
2528 assemble_name (asmfile, buf);
2529 #if DBX_BLOCKS_FUNCTION_RELATIVE
2530 fputc ('-', asmfile);
2531 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2533 fprintf (asmfile, "\n");
2537 /* Count blocks the same way regardless of debug_info_level. */
2538 next_block_number++;
2540 #ifdef DBX_LBRAC_FIRST
2541 /* On some weird machines, the syms of a block
2542 come after the N_LBRAC. */
2543 if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
2544 dbxout_syms (BLOCK_VARS (block));
2546 dbxout_reg_parms (args);
2549 /* Output the subblocks. */
2550 dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
2552 /* Refer to the marker for the end of the block. */
2553 if (depth > 0 && debug_info_level != DINFO_LEVEL_TERSE)
2556 ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
2557 #ifdef DBX_OUTPUT_RBRAC
2558 DBX_OUTPUT_RBRAC (asmfile, buf);
2560 fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);
2561 assemble_name (asmfile, buf);
2562 #if DBX_BLOCKS_FUNCTION_RELATIVE
2563 fputc ('-', asmfile);
2564 assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
2566 fprintf (asmfile, "\n");
2570 block = BLOCK_CHAIN (block);
2574 /* Output the information about a function and its arguments and result.
2575 Usually this follows the function's code,
2576 but on some systems, it comes before. */
2579 dbxout_really_begin_function (decl)
2582 dbxout_symbol (decl, 0);
2583 dbxout_parms (DECL_ARGUMENTS (decl));
2584 if (DECL_NAME (DECL_RESULT (decl)) != 0)
2585 dbxout_symbol (DECL_RESULT (decl), 1);
2588 /* Called at beginning of output of function definition. */
2591 dbxout_begin_function (decl)
2594 #ifdef DBX_FUNCTION_FIRST
2595 dbxout_really_begin_function (decl);
2599 /* Output dbx data for a function definition.
2600 This includes a definition of the function name itself (a symbol),
2601 definitions of the parameters (locating them in the parameter list)
2602 and then output the block that makes up the function's body
2603 (including all the auto variables of the function). */
2606 dbxout_function (decl)
2609 #ifndef DBX_FUNCTION_FIRST
2610 dbxout_really_begin_function (decl);
2612 dbxout_block (DECL_INITIAL (decl), 0, DECL_ARGUMENTS (decl));
2613 #ifdef DBX_OUTPUT_FUNCTION_END
2614 DBX_OUTPUT_FUNCTION_END (asmfile, decl);
2616 #if defined(ASM_OUTPUT_SECTION_NAME)
2617 if (use_gnu_debug_info_extensions
2618 #if defined(NO_DBX_FUNCTION_END)
2619 && ! NO_DBX_FUNCTION_END
2622 dbxout_function_end ();
2625 #endif /* DBX_DEBUGGING_INFO */