1 /* Output dbx-format symbol table information from GNU compiler.
2 Copyright (C) 1987, 88, 92-97, 1998 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 GNU CC is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU CC is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU CC; see the file COPYING. If not, write to
18 the Free Software Foundation, 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 /* Output dbx-format symbol table data.
23 This consists of many symbol table entries, each of them
24 a .stabs assembler pseudo-op with four operands:
25 a "name" which is really a description of one symbol and its type,
26 a "code", which is a symbol defined in stab.h whose name starts with N_,
27 an unused operand always 0,
28 and a "value" which is an address or an offset.
29 The name is enclosed in doublequote characters.
31 Each function, variable, typedef, and structure tag
32 has a symbol table entry to define it.
33 The beginning and end of each level of name scoping within
34 a function are also marked by special symbol table entries.
36 The "name" consists of the symbol name, a colon, a kind-of-symbol letter,
37 and a data type number. The data type number may be followed by
38 "=" and a type definition; normally this will happen the first time
39 the type number is mentioned. The type definition may refer to
40 other types by number, and those type numbers may be followed
41 by "=" and nested definitions.
43 This can make the "name" quite long.
44 When a name is more than 80 characters, we split the .stabs pseudo-op
45 into two .stabs pseudo-ops, both sharing the same "code" and "value".
46 The first one is marked as continued with a double-backslash at the
49 The kind-of-symbol letter distinguished function names from global
50 variables from file-scope variables from parameters from auto
51 variables in memory from typedef names from register variables.
54 The "code" is mostly redundant with the kind-of-symbol letter
55 that goes in the "name", but not entirely: for symbols located
56 in static storage, the "code" says which segment the address is in,
57 which controls how it is relocated.
59 The "value" for a symbol in static storage
60 is the core address of the symbol (actually, the assembler
61 label for the symbol). For a symbol located in a stack slot
62 it is the stack offset; for one in a register, the register number.
63 For a typedef symbol, it is zero.
65 If DEBUG_SYMS_TEXT is defined, all debugging symbols must be
66 output while in the text section.
68 For more on data type definitions, see `dbxout_type'. */
77 #include "insn-config.h"
80 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions. */
84 #ifdef XCOFF_DEBUGGING_INFO
89 #define ASM_STABS_OP ".stabs"
93 #define ASM_STABN_OP ".stabn"
96 #ifndef DBX_TYPE_DECL_STABS_CODE
97 #define DBX_TYPE_DECL_STABS_CODE N_LSYM
100 #ifndef DBX_STATIC_CONST_VAR_CODE
101 #define DBX_STATIC_CONST_VAR_CODE N_FUN
104 #ifndef DBX_REGPARM_STABS_CODE
105 #define DBX_REGPARM_STABS_CODE N_RSYM
108 #ifndef DBX_REGPARM_STABS_LETTER
109 #define DBX_REGPARM_STABS_LETTER 'P'
112 /* This is used for parameters passed by invisible reference in a register. */
113 #ifndef GDB_INV_REF_REGPARM_STABS_LETTER
114 #define GDB_INV_REF_REGPARM_STABS_LETTER 'a'
117 #ifndef DBX_MEMPARM_STABS_LETTER
118 #define DBX_MEMPARM_STABS_LETTER 'p'
121 #ifndef FILE_NAME_JOINER
122 #define FILE_NAME_JOINER "/"
125 /* Nonzero means if the type has methods, only output debugging
126 information if methods are actually written to the asm file. This
127 optimization only works if the debugger can detect the special C++
130 #define MINIMAL_DEBUG 1
132 #ifdef NO_DOLLAR_IN_LABEL
133 #ifdef NO_DOT_IN_LABEL
135 #define MINIMAL_DEBUG 0
139 /* Typical USG systems don't have stab.h, and they also have
140 no use for DBX-format debugging info. */
142 #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
144 static int flag_minimal_debug
= MINIMAL_DEBUG
;
146 /* Nonzero if we have actually used any of the GDB extensions
147 to the debugging format. The idea is that we use them for the
148 first time only if there's a strong reason, but once we have done that,
149 we use them whenever convenient. */
151 static int have_used_extensions
= 0;
153 /* Number for the next N_SOL filename stabs label. The number 0 is reserved
154 for the N_SO filename stabs label. */
156 static int source_label_number
= 1;
158 #ifdef DEBUG_SYMS_TEXT
159 #define FORCE_TEXT text_section ();
164 /* If there is a system stab.h, use it. Otherwise, use our own. */
165 /* ??? This is supposed to describe the target's stab format, so using
166 the host HAVE_STAB_H appears to be wrong. For now, we use our own file
167 when cross compiling. */
168 #if defined (USG) || !defined (HAVE_STAB_H) || defined (CROSS_COMPILE)
169 #include "gstab.h" /* If doing DBX on sysV, use our own stab.h. */
173 /* This is a GNU extension we need to reference in this file. */
180 #define STAB_CODE_TYPE enum __stab_debug_code
182 #define STAB_CODE_TYPE int
185 /* 1 if PARM is passed to this function in memory. */
187 #define PARM_PASSED_IN_MEMORY(PARM) \
188 (GET_CODE (DECL_INCOMING_RTL (PARM)) == MEM)
190 /* A C expression for the integer offset value of an automatic variable
191 (N_LSYM) having address X (an RTX). */
192 #ifndef DEBUGGER_AUTO_OFFSET
193 #define DEBUGGER_AUTO_OFFSET(X) \
194 (GET_CODE (X) == PLUS ? INTVAL (XEXP (X, 1)) : 0)
197 /* A C expression for the integer offset value of an argument (N_PSYM)
198 having address X (an RTX). The nominal offset is OFFSET. */
199 #ifndef DEBUGGER_ARG_OFFSET
200 #define DEBUGGER_ARG_OFFSET(OFFSET, X) (OFFSET)
203 /* Stream for writing to assembler file. */
205 static FILE *asmfile
;
207 /* Last source file name mentioned in a NOTE insn. */
209 static char *lastfile
;
211 /* Current working directory. */
215 enum typestatus
{TYPE_UNSEEN
, TYPE_XREF
, TYPE_DEFINED
};
217 /* Structure recording information about a C data type.
218 The status element says whether we have yet output
219 the definition of the type. TYPE_XREF says we have
220 output it as a cross-reference only.
221 The file_number and type_number elements are used if DBX_USE_BINCL
226 enum typestatus status
;
233 /* Vector recording information about C data types.
234 When we first notice a data type (a tree node),
235 we assign it a number using next_type_number.
236 That is its index in this vector. */
238 struct typeinfo
*typevec
;
240 /* Number of elements of space allocated in `typevec'. */
242 static int typevec_len
;
244 /* In dbx output, each type gets a unique number.
245 This is the number for the next type output.
246 The number, once assigned, is in the TYPE_SYMTAB_ADDRESS field. */
248 static int next_type_number
;
252 /* When using N_BINCL in dbx output, each type number is actually a
253 pair of the file number and the type number within the file.
254 This is a stack of input files. */
258 struct dbx_file
*next
;
260 int next_type_number
;
263 /* This is the top of the stack. */
265 static struct dbx_file
*current_file
;
267 /* This is the next file number to use. */
269 static int next_file_number
;
271 #endif /* DBX_USE_BINCL */
273 /* In dbx output, we must assign symbol-blocks id numbers
274 in the order in which their beginnings are encountered.
275 We output debugging info that refers to the beginning and
276 end of the ranges of code in each block
277 with assembler labels LBBn and LBEn, where n is the block number.
278 The labels are generated in final, which assigns numbers to the
279 blocks in the same way. */
281 static int next_block_number
;
283 /* These variables are for dbxout_symbol to communicate to
284 dbxout_finish_symbol.
285 current_sym_code is the symbol-type-code, a symbol N_... define in stab.h.
286 current_sym_value and current_sym_addr are two ways to address the
287 value to store in the symtab entry.
288 current_sym_addr if nonzero represents the value as an rtx.
289 If that is zero, current_sym_value is used. This is used
290 when the value is an offset (such as for auto variables,
291 register variables and parms). */
293 static STAB_CODE_TYPE current_sym_code
;
294 static int current_sym_value
;
295 static rtx current_sym_addr
;
297 /* Number of chars of symbol-description generated so far for the
298 current symbol. Used by CHARS and CONTIN. */
300 static int current_sym_nchars
;
302 /* Report having output N chars of the current symbol-description. */
304 #define CHARS(N) (current_sym_nchars += (N))
306 /* Break the current symbol-description, generating a continuation,
307 if it has become long. */
309 #ifndef DBX_CONTIN_LENGTH
310 #define DBX_CONTIN_LENGTH 80
313 #if DBX_CONTIN_LENGTH > 0
315 do {if (current_sym_nchars > DBX_CONTIN_LENGTH) dbxout_continue ();} while (0)
320 void dbxout_types ();
322 void dbxout_symbol ();
324 #if defined(ASM_OUTPUT_SECTION_NAME)
325 static void dbxout_function_end
PROTO((void));
327 static void dbxout_typedefs
PROTO((tree
));
328 static void dbxout_type_index
PROTO((tree
));
329 #if DBX_CONTIN_LENGTH > 0
330 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
));
347 #if defined(ASM_OUTPUT_SECTION_NAME)
349 dbxout_function_end ()
351 static int scope_labelno
= 0;
352 char lscope_label_name
[100];
353 /* Convert Ltext into the appropriate format for local labels in case
354 the system doesn't insert underscores in front of user generated
356 ASM_GENERATE_INTERNAL_LABEL (lscope_label_name
, "Lscope", scope_labelno
);
357 ASM_OUTPUT_INTERNAL_LABEL (asmfile
, "Lscope", scope_labelno
);
360 /* By convention, GCC will mark the end of a function with an N_FUN
361 symbol and an empty string. */
362 fprintf (asmfile
, "%s \"\",%d,0,0,", ASM_STABS_OP
, N_FUN
);
363 assemble_name (asmfile
, lscope_label_name
);
364 fputc ('-', asmfile
);
365 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
366 fprintf (asmfile
, "\n");
368 #endif /* ! NO_DBX_FUNCTION_END */
370 /* At the beginning of compilation, start writing the symbol table.
371 Initialize `typevec' and output the standard data types of C. */
374 dbxout_init (asm_file
, input_file_name
, syms
)
376 char *input_file_name
;
379 char ltext_label_name
[100];
384 typevec
= (struct typeinfo
*) xcalloc (typevec_len
, sizeof typevec
[0]);
386 /* Convert Ltext into the appropriate format for local labels in case
387 the system doesn't insert underscores in front of user generated
389 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext", 0);
391 /* Put the current working directory in an N_SO symbol. */
392 #ifndef DBX_WORKING_DIRECTORY /* Only some versions of DBX want this,
393 but GDB always does. */
394 if (use_gnu_debug_info_extensions
)
397 if (!cwd
&& (cwd
= getpwd ()) && (!*cwd
|| cwd
[strlen (cwd
) - 1] != '/'))
399 char *wdslash
= xmalloc (strlen (cwd
) + sizeof (FILE_NAME_JOINER
));
400 sprintf (wdslash
, "%s%s", cwd
, FILE_NAME_JOINER
);
405 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
406 DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile
, cwd
);
407 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
408 fprintf (asmfile
, "%s ", ASM_STABS_OP
);
409 output_quoted_string (asmfile
, cwd
);
410 fprintf (asmfile
, ",%d,0,0,%s\n", N_SO
, <ext_label_name
[1]);
411 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
415 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME
416 /* This should NOT be DBX_OUTPUT_SOURCE_FILENAME. That
417 would give us an N_SOL, and we want an N_SO. */
418 DBX_OUTPUT_MAIN_SOURCE_FILENAME (asmfile
, input_file_name
);
419 #else /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
420 /* We include outputting `Ltext:' here,
421 because that gives you a way to override it. */
422 /* Used to put `Ltext:' before the reference, but that loses on sun 4. */
423 fprintf (asmfile
, "%s ", ASM_STABS_OP
);
424 output_quoted_string (asmfile
, input_file_name
);
425 fprintf (asmfile
, ",%d,0,0,%s\n",
426 N_SO
, <ext_label_name
[1]);
428 ASM_OUTPUT_INTERNAL_LABEL (asmfile
, "Ltext", 0);
429 #endif /* no DBX_OUTPUT_MAIN_SOURCE_FILENAME */
431 /* Possibly output something to inform GDB that this compilation was by
432 GCC. It's easier for GDB to parse it when after the N_SO's. This
433 is used in Solaris 2. */
434 #ifdef ASM_IDENTIFY_GCC_AFTER_SOURCE
435 ASM_IDENTIFY_GCC_AFTER_SOURCE (asmfile
);
438 lastfile
= input_file_name
;
440 next_type_number
= 1;
441 next_block_number
= 2;
444 current_file
= (struct dbx_file
*) xmalloc (sizeof *current_file
);
445 current_file
->next
= NULL
;
446 current_file
->file_number
= 0;
447 current_file
->next_type_number
= 1;
448 next_file_number
= 1;
451 /* Make sure that types `int' and `char' have numbers 1 and 2.
452 Definitions of other integer types will refer to those numbers.
453 (Actually it should no longer matter what their numbers are.
454 Also, if any types with tags have been defined, dbxout_symbol
455 will output them first, so the numbers won't be 1 and 2. That
456 happens in C++. So it's a good thing it should no longer matter). */
458 #ifdef DBX_OUTPUT_STANDARD_TYPES
459 DBX_OUTPUT_STANDARD_TYPES (syms
);
461 dbxout_symbol (TYPE_NAME (integer_type_node
), 0);
462 dbxout_symbol (TYPE_NAME (char_type_node
), 0);
465 /* Get all permanent types that have typedef names,
466 and output them all, except for those already output. */
468 dbxout_typedefs (syms
);
471 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
472 in the reverse order from that which is found in SYMS. */
475 dbxout_typedefs (syms
)
480 dbxout_typedefs (TREE_CHAIN (syms
));
481 if (TREE_CODE (syms
) == TYPE_DECL
)
483 tree type
= TREE_TYPE (syms
);
485 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
486 && TYPE_SIZE (type
) != NULL_TREE
487 && ! TREE_ASM_WRITTEN (TYPE_NAME (type
)))
488 dbxout_symbol (TYPE_NAME (type
), 0);
493 /* Change to reading from a new source file. Generate a N_BINCL stab. */
496 dbxout_start_new_source_file (filename
)
497 char *filename ATTRIBUTE_UNUSED
;
500 struct dbx_file
*n
= (struct dbx_file
*) xmalloc (sizeof *n
);
502 n
->next
= current_file
;
503 n
->file_number
= next_file_number
++;
504 n
->next_type_number
= 1;
506 fprintf (asmfile
, "%s ", ASM_STABS_OP
);
507 output_quoted_string (asmfile
, filename
);
508 fprintf (asmfile
, ",%d,0,0,0\n", N_BINCL
);
512 /* Revert to reading a previous source file. Generate a N_EINCL stab. */
515 dbxout_resume_previous_source_file ()
518 struct dbx_file
*next
;
520 fprintf (asmfile
, "%s %d,0,0,0\n", ASM_STABN_OP
, N_EINCL
);
521 next
= current_file
->next
;
527 /* Output debugging info to FILE to switch to sourcefile FILENAME. */
530 dbxout_source_file (file
, filename
)
534 char ltext_label_name
[100];
536 if (filename
&& (lastfile
== 0 || strcmp (filename
, lastfile
)))
538 #ifdef DBX_OUTPUT_SOURCE_FILENAME
539 DBX_OUTPUT_SOURCE_FILENAME (file
, filename
);
541 ASM_GENERATE_INTERNAL_LABEL (ltext_label_name
, "Ltext",
542 source_label_number
);
543 fprintf (file
, "%s ", ASM_STABS_OP
);
544 output_quoted_string (file
, filename
);
545 fprintf (file
, ",%d,0,0,%s\n", N_SOL
, <ext_label_name
[1]);
546 if (current_function_decl
!= NULL_TREE
547 && DECL_SECTION_NAME (current_function_decl
) != NULL_TREE
)
548 ; /* Don't change section amid function. */
551 ASM_OUTPUT_INTERNAL_LABEL (file
, "Ltext", source_label_number
);
552 source_label_number
++;
558 /* Output a line number symbol entry into output stream FILE,
559 for source file FILENAME and line number LINENO. */
562 dbxout_source_line (file
, filename
, lineno
)
567 dbxout_source_file (file
, filename
);
569 #ifdef ASM_OUTPUT_SOURCE_LINE
570 ASM_OUTPUT_SOURCE_LINE (file
, lineno
);
572 fprintf (file
, "\t%s %d,0,%d\n", ASM_STABD_OP
, N_SLINE
, lineno
);
576 /* At the end of compilation, finish writing the symbol table.
577 Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
581 dbxout_finish (file
, filename
)
582 FILE *file ATTRIBUTE_UNUSED
;
583 char *filename ATTRIBUTE_UNUSED
;
585 #ifdef DBX_OUTPUT_MAIN_SOURCE_FILE_END
586 DBX_OUTPUT_MAIN_SOURCE_FILE_END (file
, filename
);
587 #endif /* DBX_OUTPUT_MAIN_SOURCE_FILE_END */
590 /* Output the index of a type. */
593 dbxout_type_index (type
)
596 #ifndef DBX_USE_BINCL
597 fprintf (asmfile
, "%d", TYPE_SYMTAB_ADDRESS (type
));
600 struct typeinfo
*t
= &typevec
[TYPE_SYMTAB_ADDRESS (type
)];
601 fprintf (asmfile
, "(%d,%d)", t
->file_number
, t
->type_number
);
606 #if DBX_CONTIN_LENGTH > 0
607 /* Continue a symbol-description that gets too big.
608 End one symbol table entry with a double-backslash
609 and start a new one, eventually producing something like
610 .stabs "start......\\",code,0,value
611 .stabs "...rest",code,0,value */
616 #ifdef DBX_CONTIN_CHAR
617 fprintf (asmfile
, "%c", DBX_CONTIN_CHAR
);
619 fprintf (asmfile
, "\\\\");
621 dbxout_finish_symbol (NULL_TREE
);
622 fprintf (asmfile
, "%s \"", ASM_STABS_OP
);
623 current_sym_nchars
= 0;
625 #endif /* DBX_CONTIN_LENGTH > 0 */
627 /* Subroutine of `dbxout_type'. Output the type fields of TYPE.
628 This must be a separate function because anonymous unions require
632 dbxout_type_fields (type
)
636 /* Output the name, type, position (in bits), size (in bits) of each
638 for (tem
= TYPE_FIELDS (type
); tem
; tem
= TREE_CHAIN (tem
))
640 /* Omit here local type decls until we know how to support them. */
641 if (TREE_CODE (tem
) == TYPE_DECL
)
643 /* Omit fields whose position or size are variable. */
644 else if (TREE_CODE (tem
) == FIELD_DECL
645 && (TREE_CODE (DECL_FIELD_BITPOS (tem
)) != INTEGER_CST
646 || TREE_CODE (DECL_SIZE (tem
)) != INTEGER_CST
))
648 /* Omit here the nameless fields that are used to skip bits. */
649 else if (DECL_IGNORED_P (tem
))
651 else if (TREE_CODE (tem
) != CONST_DECL
)
653 /* Continue the line if necessary,
654 but not before the first field. */
655 if (tem
!= TYPE_FIELDS (type
))
660 if (use_gnu_debug_info_extensions
661 && flag_minimal_debug
662 && TREE_CODE (tem
) == FIELD_DECL
663 && DECL_VIRTUAL_P (tem
)
664 && DECL_ASSEMBLER_NAME (tem
))
666 have_used_extensions
= 1;
667 CHARS (3 + IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (tem
)));
668 fputs (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (tem
)), asmfile
);
669 dbxout_type (DECL_FCONTEXT (tem
), 0, 0);
670 fprintf (asmfile
, ":");
671 dbxout_type (TREE_TYPE (tem
), 0, 0);
672 fputc (',', asmfile
);
673 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
674 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem
)));
675 fputc (';', asmfile
);
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 fputc (',', asmfile
);
725 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
726 TREE_INT_CST_LOW (DECL_FIELD_BITPOS (tem
)));
727 fputc (',', asmfile
);
728 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
729 TREE_INT_CST_LOW (DECL_SIZE (tem
)));
730 fputc (';', asmfile
);
737 /* Subroutine of `dbxout_type_methods'. Output debug info about the
738 method described DECL. DEBUG_NAME is an encoding of the method's
739 type signature. ??? We may be able to do without DEBUG_NAME altogether
743 dbxout_type_method_1 (decl
, debug_name
)
749 if (TREE_CODE (TREE_TYPE (decl
)) == FUNCTION_TYPE
)
751 else /* it's a METHOD_TYPE. */
753 tree firstarg
= TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl
)));
754 /* A for normal functions.
755 B for `const' member functions.
756 C for `volatile' member functions.
757 D for `const volatile' member functions. */
758 if (TYPE_READONLY (TREE_TYPE (firstarg
)))
760 if (TYPE_VOLATILE (TREE_TYPE (firstarg
)))
763 if (DECL_VINDEX (decl
))
769 fprintf (asmfile
, ":%s;%c%c%c", debug_name
,
770 TREE_PRIVATE (decl
) ? '0' : TREE_PROTECTED (decl
) ? '1' : '2', c1
, c2
);
771 CHARS (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (decl
)) + 6
772 - (debug_name
- IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
))));
773 if (DECL_VINDEX (decl
))
775 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
776 TREE_INT_CST_LOW (DECL_VINDEX (decl
)));
777 fputc (';', asmfile
);
778 dbxout_type (DECL_CONTEXT (decl
), 0, 0);
779 fprintf (asmfile
, ";");
784 /* Subroutine of `dbxout_type'. Output debug info about the methods defined
788 dbxout_type_methods (type
)
791 /* C++: put out the method names and their parameter lists */
792 tree methods
= TYPE_METHODS (type
);
794 register tree fndecl
;
796 char formatted_type_identifier_length
[16];
797 register int type_identifier_length
;
799 if (methods
== NULL_TREE
)
802 type_encoding
= DECL_NAME (TYPE_NAME (type
));
805 /* C++: Template classes break some assumptions made by this code about
806 the class names, constructor names, and encodings for assembler
807 label names. For now, disable output of dbx info for them. */
809 char *ptr
= IDENTIFIER_POINTER (type_encoding
);
810 /* This should use index. (mrs) */
811 while (*ptr
&& *ptr
!= '<') ptr
++;
822 type_identifier_length
= IDENTIFIER_LENGTH (type_encoding
);
824 sprintf(formatted_type_identifier_length
, "%d", type_identifier_length
);
826 if (TREE_CODE (methods
) != TREE_VEC
)
828 else if (TREE_VEC_ELT (methods
, 0) != NULL_TREE
)
829 fndecl
= TREE_VEC_ELT (methods
, 0);
831 fndecl
= TREE_VEC_ELT (methods
, 1);
835 tree name
= DECL_NAME (fndecl
);
838 /* Group together all the methods for the same operation.
839 These differ in the types of the arguments. */
840 for (last
= NULL_TREE
;
841 fndecl
&& (last
== NULL_TREE
|| DECL_NAME (fndecl
) == DECL_NAME (last
));
842 fndecl
= TREE_CHAIN (fndecl
))
843 /* Output the name of the field (after overloading), as
844 well as the name of the field before overloading, along
845 with its parameter list */
847 /* This is the "mangled" name of the method.
848 It encodes the argument types. */
849 char *debug_name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl
));
850 int show_arg_types
= 0;
856 if (DECL_IGNORED_P (fndecl
))
859 if (flag_minimal_debug
)
863 /* We can't optimize a method which uses an anonymous
864 class, because the debugger will not be able to
865 associate the arbitrary class name with the actual
867 #ifndef NO_DOLLAR_IN_LABEL
872 if (strchr (debug_name
, marker
))
874 /* Detect ordinary methods because their mangled names
875 start with the operation name. */
876 else if (!strncmp (IDENTIFIER_POINTER (name
), debug_name
,
877 IDENTIFIER_LENGTH (name
)))
879 debug_name
+= IDENTIFIER_LENGTH (name
);
880 if (debug_name
[0] == '_' && debug_name
[1] == '_')
882 char *method_name
= debug_name
+ 2;
883 char *length_ptr
= formatted_type_identifier_length
;
884 /* Get past const and volatile qualifiers. */
885 while (*method_name
== 'C' || *method_name
== 'V')
887 /* Skip digits for length of type_encoding. */
888 while (*method_name
== *length_ptr
&& *length_ptr
)
889 length_ptr
++, method_name
++;
890 if (! strncmp (method_name
,
891 IDENTIFIER_POINTER (type_encoding
),
892 type_identifier_length
))
893 method_name
+= type_identifier_length
;
894 debug_name
= method_name
;
897 /* Detect constructors by their style of name mangling. */
898 else if (debug_name
[0] == '_' && debug_name
[1] == '_')
900 char *ctor_name
= debug_name
+ 2;
901 char *length_ptr
= formatted_type_identifier_length
;
902 while (*ctor_name
== 'C' || *ctor_name
== 'V')
904 /* Skip digits for length of type_encoding. */
905 while (*ctor_name
== *length_ptr
&& *length_ptr
)
906 length_ptr
++, ctor_name
++;
907 if (!strncmp (IDENTIFIER_POINTER (type_encoding
), ctor_name
,
908 type_identifier_length
))
909 debug_name
= ctor_name
+ type_identifier_length
;
911 /* The other alternative is a destructor. */
915 /* Output the operation name just once, for the first method
919 fprintf (asmfile
, "%s::", IDENTIFIER_POINTER (name
));
920 CHARS (IDENTIFIER_LENGTH (name
) + 2);
925 dbxout_type (TREE_TYPE (fndecl
), 0, show_arg_types
);
927 dbxout_type_method_1 (fndecl
, debug_name
);
937 /* Emit a "range" type specification, which has the form:
938 "r<index type>;<lower bound>;<upper bound>;".
939 TYPE is an INTEGER_TYPE. */
942 dbxout_range_type (type
)
945 fprintf (asmfile
, "r");
946 if (TREE_TYPE (type
))
947 dbxout_type (TREE_TYPE (type
), 0, 0);
948 else if (TREE_CODE (type
) != INTEGER_TYPE
)
949 dbxout_type (type
, 0, 0); /* E.g. Pascal's ARRAY [BOOLEAN] of INTEGER */
952 /* Traditionally, we made sure 'int' was type 1, and builtin types
953 were defined to be sub-ranges of int. Unfortunately, this
954 does not allow us to distinguish true sub-ranges from integer
955 types. So, instead we define integer (non-sub-range) types as
956 sub-ranges of themselves. This matters for Chill. If this isn't
957 a subrange type, then we want to define it in terms of itself.
958 However, in C, this may be an anonymous integer type, and we don't
959 want to emit debug info referring to it. Just calling
960 dbxout_type_index won't work anyways, because the type hasn't been
961 defined yet. We make this work for both cases by checked to see
962 whether this is a defined type, referring to it if it is, and using
964 if (TYPE_SYMTAB_ADDRESS (type
) != 0)
965 dbxout_type_index (type
);
967 dbxout_type_index (integer_type_node
);
969 if (TREE_CODE (TYPE_MIN_VALUE (type
)) == INTEGER_CST
)
971 fputc (';', asmfile
);
972 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
973 TREE_INT_CST_LOW (TYPE_MIN_VALUE (type
)));
976 fprintf (asmfile
, ";0");
977 if (TYPE_MAX_VALUE (type
)
978 && TREE_CODE (TYPE_MAX_VALUE (type
)) == INTEGER_CST
)
980 fputc (';', asmfile
);
981 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
982 TREE_INT_CST_LOW (TYPE_MAX_VALUE (type
)));
983 fputc (';', asmfile
);
986 fprintf (asmfile
, ";-1;");
989 /* Output a reference to a type. If the type has not yet been
990 described in the dbx output, output its definition now.
991 For a type already defined, just refer to its definition
992 using the type number.
994 If FULL is nonzero, and the type has been described only with
995 a forward-reference, output the definition now.
996 If FULL is zero in this case, just refer to the forward-reference
997 using the number previously allocated.
999 If SHOW_ARG_TYPES is nonzero, we output a description of the argument
1000 types for a METHOD_TYPE. */
1003 dbxout_type (type
, full
, show_arg_types
)
1009 static int anonymous_type_number
= 0;
1011 /* If there was an input error and we don't really have a type,
1012 avoid crashing and write something that is at least valid
1013 by assuming `int'. */
1014 if (type
== error_mark_node
)
1015 type
= integer_type_node
;
1018 /* Try to find the "main variant" with the same name but not const
1019 or volatile. (Since stabs does not distinguish const and volatile,
1020 there is no need to make them separate types. But types with
1021 different names are usefully distinguished.) */
1023 for (tem
= TYPE_MAIN_VARIANT (type
); tem
; tem
= TYPE_NEXT_VARIANT (tem
))
1024 if (!TYPE_READONLY (tem
) && !TYPE_VOLATILE (tem
)
1025 && TYPE_NAME (tem
) == TYPE_NAME (type
))
1030 if (TYPE_NAME (type
)
1031 && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1032 && TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (type
)))
1036 if (TYPE_SYMTAB_ADDRESS (type
) == 0)
1038 /* Type has no dbx number assigned. Assign next available number. */
1039 TYPE_SYMTAB_ADDRESS (type
) = next_type_number
++;
1041 /* Make sure type vector is long enough to record about this type. */
1043 if (next_type_number
== typevec_len
)
1046 = (struct typeinfo
*) xrealloc (typevec
,
1047 typevec_len
* 2 * sizeof typevec
[0]);
1048 bzero ((char *) (typevec
+ typevec_len
),
1049 typevec_len
* sizeof typevec
[0]);
1053 #ifdef DBX_USE_BINCL
1054 typevec
[TYPE_SYMTAB_ADDRESS (type
)].file_number
1055 = current_file
->file_number
;
1056 typevec
[TYPE_SYMTAB_ADDRESS (type
)].type_number
1057 = current_file
->next_type_number
++;
1061 /* Output the number of this type, to refer to it. */
1062 dbxout_type_index (type
);
1064 #ifdef DBX_TYPE_DEFINED
1065 if (DBX_TYPE_DEFINED (type
))
1069 /* If this type's definition has been output or is now being output,
1072 switch (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
)
1077 /* If we have already had a cross reference,
1078 and either that's all we want or that's the best we could do,
1079 don't repeat the cross reference.
1080 Sun dbx crashes if we do. */
1081 if (! full
|| TYPE_SIZE (type
) == 0
1082 /* No way in DBX fmt to describe a variable size. */
1083 || TREE_CODE (TYPE_SIZE (type
)) != INTEGER_CST
)
1091 /* For systems where dbx output does not allow the `=xsNAME:' syntax,
1092 leave the type-number completely undefined rather than output
1093 a cross-reference. If we have already used GNU debug info extensions,
1094 then it is OK to output a cross reference. This is necessary to get
1095 proper C++ debug output. */
1096 if ((TREE_CODE (type
) == RECORD_TYPE
|| TREE_CODE (type
) == UNION_TYPE
1097 || TREE_CODE (type
) == QUAL_UNION_TYPE
1098 || TREE_CODE (type
) == ENUMERAL_TYPE
)
1099 && ! use_gnu_debug_info_extensions
)
1100 /* We must use the same test here as we use twice below when deciding
1101 whether to emit a cross-reference. */
1102 if ((TYPE_NAME (type
) != 0
1103 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1104 && DECL_IGNORED_P (TYPE_NAME (type
)))
1106 || TYPE_SIZE (type
) == 0
1107 /* No way in DBX fmt to describe a variable size. */
1108 || TREE_CODE (TYPE_SIZE (type
)) != INTEGER_CST
)
1110 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1115 /* Output a definition now. */
1117 fprintf (asmfile
, "=");
1120 /* Mark it as defined, so that if it is self-referent
1121 we will not get into an infinite recursion of definitions. */
1123 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_DEFINED
;
1125 if (TYPE_NAME (type
) && TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1126 && DECL_ORIGINAL_TYPE (TYPE_NAME (type
)))
1128 dbxout_type (DECL_ORIGINAL_TYPE (TYPE_NAME (type
)), 0, 0);
1132 switch (TREE_CODE (type
))
1136 /* For a void type, just define it as itself; ie, "5=5".
1137 This makes us consider it defined
1138 without saying what it is. The debugger will make it
1139 a void type when the reference is seen, and nothing will
1140 ever override that default. */
1141 dbxout_type_index (type
);
1145 if (type
== char_type_node
&& ! TREE_UNSIGNED (type
))
1147 /* Output the type `char' as a subrange of itself!
1148 I don't understand this definition, just copied it
1149 from the output of pcc.
1150 This used to use `r2' explicitly and we used to
1151 take care to make sure that `char' was type number 2. */
1152 fprintf (asmfile
, "r");
1153 dbxout_type_index (type
);
1154 fprintf (asmfile
, ";0;127;");
1156 /* This used to check if the type's precision was more than
1157 HOST_BITS_PER_WIDE_INT. That is wrong since gdb uses a
1158 long (it has no concept of HOST_BITS_PER_WIDE_INT). */
1159 else if (use_gnu_debug_info_extensions
1160 && (TYPE_PRECISION (type
) > TYPE_PRECISION (integer_type_node
)
1161 || TYPE_PRECISION (type
) >= HOST_BITS_PER_LONG
))
1163 /* This used to say `r1' and we used to take care
1164 to make sure that `int' was type number 1. */
1165 fprintf (asmfile
, "r");
1166 dbxout_type_index (integer_type_node
);
1167 fprintf (asmfile
, ";");
1168 print_int_cst_octal (TYPE_MIN_VALUE (type
));
1169 fprintf (asmfile
, ";");
1170 print_int_cst_octal (TYPE_MAX_VALUE (type
));
1171 fprintf (asmfile
, ";");
1173 else /* Output other integer types as subranges of `int'. */
1174 dbxout_range_type (type
);
1179 /* This used to say `r1' and we used to take care
1180 to make sure that `int' was type number 1. */
1181 fprintf (asmfile
, "r");
1182 dbxout_type_index (integer_type_node
);
1183 fputc (';', asmfile
);
1184 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, int_size_in_bytes (type
));
1185 fputs (";0;", asmfile
);
1190 if (use_gnu_debug_info_extensions
)
1192 fputs ("@s", asmfile
);
1193 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1194 BITS_PER_UNIT
* int_size_in_bytes (type
));
1195 fputs (";-20;", asmfile
);
1199 /* Output the type `char' as a subrange of itself.
1200 That is what pcc seems to do. */
1201 fprintf (asmfile
, "r");
1202 dbxout_type_index (char_type_node
);
1203 fprintf (asmfile
, ";0;%d;", TREE_UNSIGNED (type
) ? 255 : 127);
1209 if (use_gnu_debug_info_extensions
)
1211 fputs ("@s", asmfile
);
1212 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1213 BITS_PER_UNIT
* int_size_in_bytes (type
));
1214 fputs (";-16;", asmfile
);
1216 else /* Define as enumeral type (False, True) */
1217 fprintf (asmfile
, "eFalse:0,True:1,;");
1222 putc ('d', asmfile
);
1224 dbxout_type (TREE_TYPE (type
), 0, 0);
1228 /* Differs from the REAL_TYPE by its new data type number */
1230 if (TREE_CODE (TREE_TYPE (type
)) == REAL_TYPE
)
1232 fprintf (asmfile
, "r");
1233 dbxout_type_index (type
);
1234 fputc (';', asmfile
);
1235 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1236 int_size_in_bytes (TREE_TYPE (type
)));
1237 fputs (";0;", asmfile
);
1238 CHARS (12); /* The number is probably incorrect here. */
1242 /* Output a complex integer type as a structure,
1243 pending some other way to do it. */
1244 fputc ('s', asmfile
);
1245 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, int_size_in_bytes (type
));
1247 fprintf (asmfile
, "real:");
1249 dbxout_type (TREE_TYPE (type
), 0, 0);
1250 fprintf (asmfile
, ",%d,%d;",
1251 0, TYPE_PRECISION (TREE_TYPE (type
)));
1253 fprintf (asmfile
, "imag:");
1255 dbxout_type (TREE_TYPE (type
), 0, 0);
1256 fprintf (asmfile
, ",%d,%d;;",
1257 TYPE_PRECISION (TREE_TYPE (type
)),
1258 TYPE_PRECISION (TREE_TYPE (type
)));
1264 if (use_gnu_debug_info_extensions
)
1266 have_used_extensions
= 1;
1267 fputs ("@s", asmfile
);
1268 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1269 BITS_PER_UNIT
* int_size_in_bytes (type
));
1270 fputc (';', asmfile
);
1271 /* Check if a bitstring type, which in Chill is
1272 different from a [power]set. */
1273 if (TYPE_STRING_FLAG (type
))
1274 fprintf (asmfile
, "@S;");
1276 putc ('S', asmfile
);
1278 dbxout_type (TYPE_DOMAIN (type
), 0, 0);
1282 /* Make arrays of packed bits look like bitstrings for chill. */
1283 if (TYPE_PACKED (type
) && use_gnu_debug_info_extensions
)
1285 have_used_extensions
= 1;
1286 fputs ("@s", asmfile
);
1287 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1288 BITS_PER_UNIT
* int_size_in_bytes (type
));
1289 fputc (';', asmfile
);
1290 fprintf (asmfile
, "@S;");
1291 putc ('S', asmfile
);
1293 dbxout_type (TYPE_DOMAIN (type
), 0, 0);
1296 /* Output "a" followed by a range type definition
1297 for the index type of the array
1298 followed by a reference to the target-type.
1299 ar1;0;N;M for a C array of type M and size N+1. */
1300 /* Check if a character string type, which in Chill is
1301 different from an array of characters. */
1302 if (TYPE_STRING_FLAG (type
) && use_gnu_debug_info_extensions
)
1304 have_used_extensions
= 1;
1305 fprintf (asmfile
, "@S;");
1307 tem
= TYPE_DOMAIN (type
);
1310 fprintf (asmfile
, "ar");
1311 dbxout_type_index (integer_type_node
);
1312 fprintf (asmfile
, ";0;-1;");
1316 fprintf (asmfile
, "a");
1317 dbxout_range_type (tem
);
1320 dbxout_type (TREE_TYPE (type
), 0, 0);
1325 case QUAL_UNION_TYPE
:
1327 int i
, n_baseclasses
= 0;
1329 if (TYPE_BINFO (type
) != 0
1330 && TREE_CODE (TYPE_BINFO (type
)) == TREE_VEC
1331 && TYPE_BINFO_BASETYPES (type
) != 0)
1332 n_baseclasses
= TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type
));
1334 /* Output a structure type. We must use the same test here as we
1335 use in the DBX_NO_XREFS case above. */
1336 if ((TYPE_NAME (type
) != 0
1337 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1338 && DECL_IGNORED_P (TYPE_NAME (type
)))
1340 || TYPE_SIZE (type
) == 0
1341 /* No way in DBX fmt to describe a variable size. */
1342 || TREE_CODE (TYPE_SIZE (type
)) != INTEGER_CST
)
1344 /* If the type is just a cross reference, output one
1345 and mark the type as partially described.
1346 If it later becomes defined, we will output
1347 its real definition.
1348 If the type has a name, don't nest its definition within
1349 another type's definition; instead, output an xref
1350 and let the definition come when the name is defined. */
1351 fprintf (asmfile
, (TREE_CODE (type
) == RECORD_TYPE
) ? "xs" : "xu");
1353 #if 0 /* This assertion is legitimately false in C++. */
1354 /* We shouldn't be outputting a reference to a type before its
1355 definition unless the type has a tag name.
1356 A typedef name without a tag name should be impossible. */
1357 if (TREE_CODE (TYPE_NAME (type
)) != IDENTIFIER_NODE
)
1360 if (TYPE_NAME (type
) != 0)
1361 dbxout_type_name (type
);
1363 fprintf (asmfile
, "$$%d", anonymous_type_number
++);
1364 fprintf (asmfile
, ":");
1365 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1369 /* Identify record or union, and print its size. */
1370 fputc (((TREE_CODE (type
) == RECORD_TYPE
) ? 's' : 'u'), asmfile
);
1371 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1372 int_size_in_bytes (type
));
1374 if (use_gnu_debug_info_extensions
)
1378 have_used_extensions
= 1;
1379 fprintf (asmfile
, "!%d,", n_baseclasses
);
1383 for (i
= 0; i
< n_baseclasses
; i
++)
1385 tree child
= TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (type
)), i
);
1386 if (use_gnu_debug_info_extensions
)
1388 have_used_extensions
= 1;
1389 putc (TREE_VIA_VIRTUAL (child
) ? '1'
1392 putc (TREE_VIA_PUBLIC (child
) ? '2'
1395 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1396 TREE_INT_CST_LOW (BINFO_OFFSET (child
)) * BITS_PER_UNIT
);
1397 fputc (',', asmfile
);
1399 dbxout_type (BINFO_TYPE (child
), 0, 0);
1400 putc (';', asmfile
);
1404 /* Print out the base class information with fields
1405 which have the same names at the types they hold. */
1406 dbxout_type_name (BINFO_TYPE (child
));
1407 putc (':', asmfile
);
1408 dbxout_type (BINFO_TYPE (child
), full
, 0);
1409 fputc (',', asmfile
);
1410 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1411 TREE_INT_CST_LOW (BINFO_OFFSET (child
)) * BITS_PER_UNIT
);
1412 fputc (',', asmfile
);
1413 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1414 TREE_INT_CST_LOW (DECL_SIZE (TYPE_NAME (BINFO_TYPE (child
)))) * BITS_PER_UNIT
);
1415 fputc (';', asmfile
);
1423 /* Write out the field declarations. */
1424 dbxout_type_fields (type
);
1425 if (use_gnu_debug_info_extensions
&& TYPE_METHODS (type
) != NULL_TREE
)
1427 have_used_extensions
= 1;
1428 dbxout_type_methods (type
);
1430 putc (';', asmfile
);
1432 if (use_gnu_debug_info_extensions
&& TREE_CODE (type
) == RECORD_TYPE
1433 /* Avoid the ~ if we don't really need it--it confuses dbx. */
1434 && TYPE_VFIELD (type
))
1436 have_used_extensions
= 1;
1438 /* Tell GDB+ that it may keep reading. */
1439 putc ('~', asmfile
);
1441 /* We need to write out info about what field this class
1442 uses as its "main" vtable pointer field, because if this
1443 field is inherited from a base class, GDB cannot necessarily
1444 figure out which field it's using in time. */
1445 if (TYPE_VFIELD (type
))
1447 putc ('%', asmfile
);
1448 dbxout_type (DECL_FCONTEXT (TYPE_VFIELD (type
)), 0, 0);
1450 putc (';', asmfile
);
1456 /* We must use the same test here as we use in the DBX_NO_XREFS case
1457 above. We simplify it a bit since an enum will never have a variable
1459 if ((TYPE_NAME (type
) != 0
1460 && ! (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
1461 && DECL_IGNORED_P (TYPE_NAME (type
)))
1463 || TYPE_SIZE (type
) == 0)
1465 fprintf (asmfile
, "xe");
1467 dbxout_type_name (type
);
1468 typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
= TYPE_XREF
;
1469 fprintf (asmfile
, ":");
1472 #ifdef DBX_OUTPUT_ENUM
1473 DBX_OUTPUT_ENUM (asmfile
, type
);
1475 if (use_gnu_debug_info_extensions
1476 && TYPE_PRECISION (type
) != TYPE_PRECISION (integer_type_node
))
1477 fprintf (asmfile
, "@s%d;", TYPE_PRECISION (type
));
1478 putc ('e', asmfile
);
1480 for (tem
= TYPE_VALUES (type
); tem
; tem
= TREE_CHAIN (tem
))
1482 fprintf (asmfile
, "%s:", IDENTIFIER_POINTER (TREE_PURPOSE (tem
)));
1483 if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == 0)
1484 fprintf (asmfile
, HOST_WIDE_INT_PRINT_UNSIGNED
,
1485 TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1486 else if (TREE_INT_CST_HIGH (TREE_VALUE (tem
)) == -1
1487 && TREE_INT_CST_LOW (TREE_VALUE (tem
)) < 0)
1488 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
,
1489 TREE_INT_CST_LOW (TREE_VALUE (tem
)));
1491 print_int_cst_octal (TREE_VALUE (tem
));
1492 fprintf (asmfile
, ",");
1493 CHARS (20 + IDENTIFIER_LENGTH (TREE_PURPOSE (tem
)));
1494 if (TREE_CHAIN (tem
) != 0)
1499 putc (';', asmfile
);
1505 putc ('*', asmfile
);
1507 dbxout_type (TREE_TYPE (type
), 0, 0);
1511 if (use_gnu_debug_info_extensions
)
1513 have_used_extensions
= 1;
1514 putc ('#', asmfile
);
1516 if (flag_minimal_debug
&& !show_arg_types
)
1518 /* Normally, just output the return type.
1519 The argument types are encoded in the method name. */
1520 putc ('#', asmfile
);
1522 dbxout_type (TREE_TYPE (type
), 0, 0);
1523 putc (';', asmfile
);
1528 /* When outputting destructors, we need to write
1529 the argument types out longhand. */
1530 dbxout_type (TYPE_METHOD_BASETYPE (type
), 0, 0);
1531 putc (',', asmfile
);
1533 dbxout_type (TREE_TYPE (type
), 0, 0);
1534 dbxout_args (TYPE_ARG_TYPES (type
));
1535 putc (';', asmfile
);
1541 /* Treat it as a function type. */
1542 dbxout_type (TREE_TYPE (type
), 0, 0);
1547 if (use_gnu_debug_info_extensions
)
1549 have_used_extensions
= 1;
1550 putc ('@', asmfile
);
1552 dbxout_type (TYPE_OFFSET_BASETYPE (type
), 0, 0);
1553 putc (',', asmfile
);
1555 dbxout_type (TREE_TYPE (type
), 0, 0);
1559 /* Should print as an int, because it is really
1561 dbxout_type (integer_type_node
, 0, 0);
1565 case REFERENCE_TYPE
:
1566 if (use_gnu_debug_info_extensions
)
1567 have_used_extensions
= 1;
1568 putc (use_gnu_debug_info_extensions
? '&' : '*', asmfile
);
1570 dbxout_type (TREE_TYPE (type
), 0, 0);
1574 putc ('f', asmfile
);
1576 dbxout_type (TREE_TYPE (type
), 0, 0);
1584 /* Print the value of integer constant C, in octal,
1585 handling double precision. */
1588 print_int_cst_octal (c
)
1591 unsigned HOST_WIDE_INT high
= TREE_INT_CST_HIGH (c
);
1592 unsigned HOST_WIDE_INT low
= TREE_INT_CST_LOW (c
);
1593 int excess
= (3 - (HOST_BITS_PER_WIDE_INT
% 3));
1594 int width
= TYPE_PRECISION (TREE_TYPE (c
));
1596 /* GDB wants constants with no extra leading "1" bits, so
1597 we need to remove any sign-extension that might be
1599 if (width
== HOST_BITS_PER_WIDE_INT
* 2)
1601 else if (width
> HOST_BITS_PER_WIDE_INT
)
1602 high
&= (((HOST_WIDE_INT
) 1 << (width
- HOST_BITS_PER_WIDE_INT
)) - 1);
1603 else if (width
== HOST_BITS_PER_WIDE_INT
)
1606 high
= 0, low
&= (((HOST_WIDE_INT
) 1 << width
) - 1);
1608 fprintf (asmfile
, "0");
1612 print_octal (high
, HOST_BITS_PER_WIDE_INT
/ 3);
1613 print_octal (low
, HOST_BITS_PER_WIDE_INT
/ 3);
1617 unsigned HOST_WIDE_INT beg
= high
>> excess
;
1618 unsigned HOST_WIDE_INT middle
1619 = ((high
& (((HOST_WIDE_INT
) 1 << excess
) - 1)) << (3 - excess
)
1620 | (low
>> (HOST_BITS_PER_WIDE_INT
/ 3 * 3)));
1621 unsigned HOST_WIDE_INT end
1622 = low
& (((unsigned HOST_WIDE_INT
) 1
1623 << (HOST_BITS_PER_WIDE_INT
/ 3 * 3))
1626 fprintf (asmfile
, "%o%01o", (int)beg
, (int)middle
);
1627 print_octal (end
, HOST_BITS_PER_WIDE_INT
/ 3);
1632 print_octal (value
, digits
)
1633 unsigned HOST_WIDE_INT value
;
1638 for (i
= digits
- 1; i
>= 0; i
--)
1639 fprintf (asmfile
, "%01o", (int)((value
>> (3 * i
)) & 7));
1642 /* Output the name of type TYPE, with no punctuation.
1643 Such names can be set up either by typedef declarations
1644 or by struct, enum and union tags. */
1647 dbxout_type_name (type
)
1651 if (TYPE_NAME (type
) == 0)
1653 if (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
)
1655 t
= TYPE_NAME (type
);
1657 else if (TREE_CODE (TYPE_NAME (type
)) == TYPE_DECL
)
1659 t
= DECL_NAME (TYPE_NAME (type
));
1664 fprintf (asmfile
, "%s", IDENTIFIER_POINTER (t
));
1665 CHARS (IDENTIFIER_LENGTH (t
));
1668 /* Output a .stabs for the symbol defined by DECL,
1669 which must be a ..._DECL node in the normal namespace.
1670 It may be a CONST_DECL, a FUNCTION_DECL, a PARM_DECL or a VAR_DECL.
1671 LOCAL is nonzero if the scope is less than the entire file. */
1674 dbxout_symbol (decl
, local
)
1678 tree type
= TREE_TYPE (decl
);
1679 tree context
= NULL_TREE
;
1681 /* Cast avoids warning in old compilers. */
1682 current_sym_code
= (STAB_CODE_TYPE
) 0;
1683 current_sym_value
= 0;
1684 current_sym_addr
= 0;
1686 /* Ignore nameless syms, but don't ignore type tags. */
1688 if ((DECL_NAME (decl
) == 0 && TREE_CODE (decl
) != TYPE_DECL
)
1689 || DECL_IGNORED_P (decl
))
1692 dbxout_prepare_symbol (decl
);
1694 /* The output will always start with the symbol name,
1695 so always count that in the length-output-so-far. */
1697 if (DECL_NAME (decl
) != 0)
1698 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (decl
));
1700 switch (TREE_CODE (decl
))
1703 /* Enum values are defined by defining the enum type. */
1707 if (DECL_RTL (decl
) == 0)
1709 if (DECL_EXTERNAL (decl
))
1711 /* Don't mention a nested function under its parent. */
1712 context
= decl_function_context (decl
);
1713 if (context
== current_function_decl
)
1715 if (GET_CODE (DECL_RTL (decl
)) != MEM
1716 || GET_CODE (XEXP (DECL_RTL (decl
), 0)) != SYMBOL_REF
)
1720 fprintf (asmfile
, "%s \"%s:%c", ASM_STABS_OP
,
1721 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
1722 TREE_PUBLIC (decl
) ? 'F' : 'f');
1724 current_sym_code
= N_FUN
;
1725 current_sym_addr
= XEXP (DECL_RTL (decl
), 0);
1727 if (TREE_TYPE (type
))
1728 dbxout_type (TREE_TYPE (type
), 0, 0);
1730 dbxout_type (void_type_node
, 0, 0);
1732 /* For a nested function, when that function is compiled,
1733 mention the containing function name
1734 as well as (since dbx wants it) our own assembler-name. */
1736 fprintf (asmfile
, ",%s,%s",
1737 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
)),
1738 IDENTIFIER_POINTER (DECL_NAME (context
)));
1740 dbxout_finish_symbol (decl
);
1745 /* This seems all wrong. Outputting most kinds of types gives no name
1746 at all. A true definition gives no name; a cross-ref for a
1747 structure can give the tag name, but not a type name.
1748 It seems that no typedef name is defined by outputting a type. */
1750 /* If this typedef name was defined by outputting the type,
1751 don't duplicate it. */
1752 if (typevec
[TYPE_SYMTAB_ADDRESS (type
)].status
== TYPE_DEFINED
1753 && TYPE_NAME (TREE_TYPE (decl
)) == decl
)
1756 /* Don't output the same typedef twice.
1757 And don't output what language-specific stuff doesn't want output. */
1758 if (TREE_ASM_WRITTEN (decl
) || TYPE_DECL_SUPPRESS_DEBUG (decl
))
1767 if (DECL_NAME (decl
))
1769 /* Nonzero means we must output a tag as well as a typedef. */
1772 /* Handle the case of a C++ structure or union
1773 where the TYPE_NAME is a TYPE_DECL
1774 which gives both a typedef name and a tag. */
1775 /* dbx requires the tag first and the typedef second. */
1776 if ((TREE_CODE (type
) == RECORD_TYPE
1777 || TREE_CODE (type
) == UNION_TYPE
1778 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
1779 && TYPE_NAME (type
) == decl
1780 && !(use_gnu_debug_info_extensions
&& have_used_extensions
)
1781 && !TREE_ASM_WRITTEN (TYPE_NAME (type
))
1782 /* Distinguish the implicit typedefs of C++
1783 from explicit ones that might be found in C. */
1784 && DECL_ARTIFICIAL (decl
))
1786 tree name
= TYPE_NAME (type
);
1787 if (TREE_CODE (name
) == TYPE_DECL
)
1788 name
= DECL_NAME (name
);
1790 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1791 current_sym_value
= 0;
1792 current_sym_addr
= 0;
1793 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
1795 fprintf (asmfile
, "%s \"%s:T", ASM_STABS_OP
,
1796 IDENTIFIER_POINTER (name
));
1797 dbxout_type (type
, 1, 0);
1798 dbxout_finish_symbol (NULL_TREE
);
1801 /* Output typedef name. */
1802 fprintf (asmfile
, "%s \"%s:", ASM_STABS_OP
,
1803 IDENTIFIER_POINTER (DECL_NAME (decl
)));
1805 /* Short cut way to output a tag also. */
1806 if ((TREE_CODE (type
) == RECORD_TYPE
1807 || TREE_CODE (type
) == UNION_TYPE
1808 || TREE_CODE (type
) == QUAL_UNION_TYPE
)
1809 && TYPE_NAME (type
) == decl
1810 /* Distinguish the implicit typedefs of C++
1811 from explicit ones that might be found in C. */
1812 && DECL_ARTIFICIAL (decl
))
1814 if (use_gnu_debug_info_extensions
&& have_used_extensions
)
1816 putc ('T', asmfile
);
1817 TREE_ASM_WRITTEN (TYPE_NAME (type
)) = 1;
1819 #if 0 /* Now we generate the tag for this case up above. */
1825 putc ('t', asmfile
);
1826 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1828 dbxout_type (type
, 1, 0);
1829 dbxout_finish_symbol (decl
);
1833 /* Don't output a tag if this is an incomplete type (TYPE_SIZE is
1834 zero). This prevents the sun4 Sun OS 4.x dbx from crashing. */
1836 if (tag_needed
&& TYPE_NAME (type
) != 0
1837 && (TREE_CODE (TYPE_NAME (type
)) == IDENTIFIER_NODE
1838 || (DECL_NAME (TYPE_NAME (type
)) != 0))
1839 && TYPE_SIZE (type
) != 0
1840 && !TREE_ASM_WRITTEN (TYPE_NAME (type
)))
1842 /* For a TYPE_DECL with no name, but the type has a name,
1844 This is what represents `struct foo' with no typedef. */
1845 /* In C++, the name of a type is the corresponding typedef.
1846 In C, it is an IDENTIFIER_NODE. */
1847 tree name
= TYPE_NAME (type
);
1848 if (TREE_CODE (name
) == TYPE_DECL
)
1849 name
= DECL_NAME (name
);
1851 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1852 current_sym_value
= 0;
1853 current_sym_addr
= 0;
1854 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (name
);
1856 fprintf (asmfile
, "%s \"%s:T", ASM_STABS_OP
,
1857 IDENTIFIER_POINTER (name
));
1858 dbxout_type (type
, 1, 0);
1859 dbxout_finish_symbol (NULL_TREE
);
1863 /* If an enum type has no name, it cannot be referred to,
1864 but we must output it anyway, since the enumeration constants
1865 can be referred to. */
1866 if (!did_output
&& TREE_CODE (type
) == ENUMERAL_TYPE
)
1868 current_sym_code
= DBX_TYPE_DECL_STABS_CODE
;
1869 current_sym_value
= 0;
1870 current_sym_addr
= 0;
1871 current_sym_nchars
= 2;
1873 /* Some debuggers fail when given NULL names, so give this a
1874 harmless name of ` '. */
1875 fprintf (asmfile
, "%s \" :T", ASM_STABS_OP
);
1876 dbxout_type (type
, 1, 0);
1877 dbxout_finish_symbol (NULL_TREE
);
1880 /* Prevent duplicate output of a typedef. */
1881 TREE_ASM_WRITTEN (decl
) = 1;
1886 /* Parm decls go in their own separate chains
1887 and are output by dbxout_reg_parms and dbxout_parms. */
1891 /* Named return value, treat like a VAR_DECL. */
1893 if (DECL_RTL (decl
) == 0)
1895 /* Don't mention a variable that is external.
1896 Let the file that defines it describe it. */
1897 if (DECL_EXTERNAL (decl
))
1900 /* If the variable is really a constant
1901 and not written in memory, inform the debugger. */
1902 if (TREE_STATIC (decl
) && TREE_READONLY (decl
)
1903 && DECL_INITIAL (decl
) != 0
1904 && ! TREE_ASM_WRITTEN (decl
)
1905 && (DECL_FIELD_CONTEXT (decl
) == NULL_TREE
1906 || TREE_CODE (DECL_FIELD_CONTEXT (decl
)) == BLOCK
))
1908 if (TREE_PUBLIC (decl
) == 0)
1910 /* The sun4 assembler does not grok this. */
1911 char *name
= IDENTIFIER_POINTER (DECL_NAME (decl
));
1912 if (TREE_CODE (TREE_TYPE (decl
)) == INTEGER_TYPE
1913 || TREE_CODE (TREE_TYPE (decl
)) == ENUMERAL_TYPE
)
1915 HOST_WIDE_INT ival
= TREE_INT_CST_LOW (DECL_INITIAL (decl
));
1916 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
1917 DBX_OUTPUT_CONSTANT_SYMBOL (asmfile
, name
, ival
);
1919 fprintf (asmfile
, "%s \"%s:c=i", ASM_STABS_OP
, name
);
1921 fprintf (asmfile
, HOST_WIDE_INT_PRINT_DEC
, ival
);
1922 fprintf (asmfile
, "\",0x%x,0,0,0\n", N_LSYM
);
1926 else if (TREE_CODE (TREE_TYPE (decl
)) == REAL_TYPE
)
1928 /* don't know how to do this yet. */
1932 /* else it is something we handle like a normal variable. */
1935 DECL_RTL (decl
) = eliminate_regs (DECL_RTL (decl
), 0, NULL_RTX
);
1936 #ifdef LEAF_REG_REMAP
1937 if (current_function_uses_only_leaf_regs
)
1938 leaf_renumber_regs_insn (DECL_RTL (decl
));
1941 dbxout_symbol_location (decl
, type
, 0, DECL_RTL (decl
));
1949 /* Output the stab for DECL, a VAR_DECL, RESULT_DECL or PARM_DECL.
1950 Add SUFFIX to its name, if SUFFIX is not 0.
1951 Describe the variable as residing in HOME
1952 (usually HOME is DECL_RTL (DECL), but not always). */
1955 dbxout_symbol_location (decl
, type
, suffix
, home
)
1963 /* Don't mention a variable at all
1964 if it was completely optimized into nothingness.
1966 If the decl was from an inline function, then its rtl
1967 is not identically the rtl that was used in this
1968 particular compilation. */
1969 if (GET_CODE (home
) == REG
)
1971 regno
= REGNO (home
);
1972 if (regno
>= FIRST_PSEUDO_REGISTER
)
1975 else if (GET_CODE (home
) == SUBREG
)
1979 while (GET_CODE (value
) == SUBREG
)
1981 offset
+= SUBREG_WORD (value
);
1982 value
= SUBREG_REG (value
);
1984 if (GET_CODE (value
) == REG
)
1986 regno
= REGNO (value
);
1987 if (regno
>= FIRST_PSEUDO_REGISTER
)
1991 alter_subreg (home
);
1994 /* The kind-of-variable letter depends on where
1995 the variable is and on the scope of its name:
1996 G and N_GSYM for static storage and global scope,
1997 S for static storage and file scope,
1998 V for static storage and local scope,
1999 for those two, use N_LCSYM if data is in bss segment,
2000 N_STSYM if in data segment, N_FUN otherwise.
2001 (We used N_FUN originally, then changed to N_STSYM
2002 to please GDB. However, it seems that confused ld.
2003 Now GDB has been fixed to like N_FUN, says Kingdon.)
2004 no letter at all, and N_LSYM, for auto variable,
2005 r and N_RSYM for register variable. */
2007 if (GET_CODE (home
) == MEM
2008 && GET_CODE (XEXP (home
, 0)) == SYMBOL_REF
)
2010 if (TREE_PUBLIC (decl
))
2013 current_sym_code
= N_GSYM
;
2017 current_sym_addr
= XEXP (home
, 0);
2019 letter
= decl_function_context (decl
) ? 'V' : 'S';
2021 /* This should be the same condition as in assemble_variable, but
2022 we don't have access to dont_output_data here. So, instead,
2023 we rely on the fact that error_mark_node initializers always
2024 end up in bss for C++ and never end up in bss for C. */
2025 if (DECL_INITIAL (decl
) == 0
2026 || (!strcmp (lang_identify (), "cplusplus")
2027 && DECL_INITIAL (decl
) == error_mark_node
))
2028 current_sym_code
= N_LCSYM
;
2029 else if (DECL_IN_TEXT_SECTION (decl
))
2030 /* This is not quite right, but it's the closest
2031 of all the codes that Unix defines. */
2032 current_sym_code
= DBX_STATIC_CONST_VAR_CODE
;
2035 /* Ultrix `as' seems to need this. */
2036 #ifdef DBX_STATIC_STAB_DATA_SECTION
2039 current_sym_code
= N_STSYM
;
2043 else if (regno
>= 0)
2046 current_sym_code
= N_RSYM
;
2047 current_sym_value
= DBX_REGISTER_NUMBER (regno
);
2049 else if (GET_CODE (home
) == MEM
2050 && (GET_CODE (XEXP (home
, 0)) == MEM
2051 || (GET_CODE (XEXP (home
, 0)) == REG
2052 && REGNO (XEXP (home
, 0)) != HARD_FRAME_POINTER_REGNUM
2053 && REGNO (XEXP (home
, 0)) != STACK_POINTER_REGNUM
2054 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2055 && REGNO (XEXP (home
, 0)) != ARG_POINTER_REGNUM
2058 /* If the value is indirect by memory or by a register
2059 that isn't the frame pointer
2060 then it means the object is variable-sized and address through
2061 that register or stack slot. DBX has no way to represent this
2062 so all we can do is output the variable as a pointer.
2063 If it's not a parameter, ignore it.
2064 (VAR_DECLs like this can be made by integrate.c.) */
2066 if (GET_CODE (XEXP (home
, 0)) == REG
)
2069 current_sym_code
= N_RSYM
;
2070 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (XEXP (home
, 0)));
2074 current_sym_code
= N_LSYM
;
2075 /* RTL looks like (MEM (MEM (PLUS (REG...) (CONST_INT...)))).
2076 We want the value of that CONST_INT. */
2078 = DEBUGGER_AUTO_OFFSET (XEXP (XEXP (home
, 0), 0));
2081 /* Effectively do build_pointer_type, but don't cache this type,
2082 since it might be temporary whereas the type it points to
2083 might have been saved for inlining. */
2084 /* Don't use REFERENCE_TYPE because dbx can't handle that. */
2085 type
= make_node (POINTER_TYPE
);
2086 TREE_TYPE (type
) = TREE_TYPE (decl
);
2088 else if (GET_CODE (home
) == MEM
2089 && GET_CODE (XEXP (home
, 0)) == REG
)
2091 current_sym_code
= N_LSYM
;
2092 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2094 else if (GET_CODE (home
) == MEM
2095 && GET_CODE (XEXP (home
, 0)) == PLUS
2096 && GET_CODE (XEXP (XEXP (home
, 0), 1)) == CONST_INT
)
2098 current_sym_code
= N_LSYM
;
2099 /* RTL looks like (MEM (PLUS (REG...) (CONST_INT...)))
2100 We want the value of that CONST_INT. */
2101 current_sym_value
= DEBUGGER_AUTO_OFFSET (XEXP (home
, 0));
2103 else if (GET_CODE (home
) == MEM
2104 && GET_CODE (XEXP (home
, 0)) == CONST
)
2106 /* Handle an obscure case which can arise when optimizing and
2107 when there are few available registers. (This is *always*
2108 the case for i386/i486 targets). The RTL looks like
2109 (MEM (CONST ...)) even though this variable is a local `auto'
2110 or a local `register' variable. In effect, what has happened
2111 is that the reload pass has seen that all assignments and
2112 references for one such a local variable can be replaced by
2113 equivalent assignments and references to some static storage
2114 variable, thereby avoiding the need for a register. In such
2115 cases we're forced to lie to debuggers and tell them that
2116 this variable was itself `static'. */
2117 current_sym_code
= N_LCSYM
;
2119 current_sym_addr
= XEXP (XEXP (home
, 0), 0);
2121 else if (GET_CODE (home
) == CONCAT
)
2123 tree subtype
= TREE_TYPE (type
);
2125 /* If the variable's storage is in two parts,
2126 output each as a separate stab with a modified name. */
2127 if (WORDS_BIG_ENDIAN
)
2128 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 0));
2130 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 0));
2132 /* Cast avoids warning in old compilers. */
2133 current_sym_code
= (STAB_CODE_TYPE
) 0;
2134 current_sym_value
= 0;
2135 current_sym_addr
= 0;
2136 dbxout_prepare_symbol (decl
);
2138 if (WORDS_BIG_ENDIAN
)
2139 dbxout_symbol_location (decl
, subtype
, "$real", XEXP (home
, 1));
2141 dbxout_symbol_location (decl
, subtype
, "$imag", XEXP (home
, 1));
2145 /* Address might be a MEM, when DECL is a variable-sized object.
2146 Or it might be const0_rtx, meaning previous passes
2147 want us to ignore this variable. */
2150 /* Ok, start a symtab entry and output the variable name. */
2153 #ifdef DBX_STATIC_BLOCK_START
2154 DBX_STATIC_BLOCK_START (asmfile
, current_sym_code
);
2157 dbxout_symbol_name (decl
, suffix
, letter
);
2158 dbxout_type (type
, 0, 0);
2159 dbxout_finish_symbol (decl
);
2161 #ifdef DBX_STATIC_BLOCK_END
2162 DBX_STATIC_BLOCK_END (asmfile
, current_sym_code
);
2166 /* Output the symbol name of DECL for a stabs, with suffix SUFFIX.
2167 Then output LETTER to indicate the kind of location the symbol has. */
2170 dbxout_symbol_name (decl
, suffix
, letter
)
2175 /* One slight hitch: if this is a VAR_DECL which is a static
2176 class member, we must put out the mangled name instead of the
2177 DECL_NAME. Note also that static member (variable) names DO NOT begin
2178 with underscores in .stabs directives. */
2179 char *name
= IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl
));
2182 fprintf (asmfile
, "%s \"%s%s:", ASM_STABS_OP
, name
,
2183 (suffix
? suffix
: ""));
2185 if (letter
) putc (letter
, asmfile
);
2189 dbxout_prepare_symbol (decl
)
2190 tree decl ATTRIBUTE_UNUSED
;
2193 char *filename
= DECL_SOURCE_FILE (decl
);
2195 dbxout_source_file (asmfile
, filename
);
2200 dbxout_finish_symbol (sym
)
2203 #ifdef DBX_FINISH_SYMBOL
2204 DBX_FINISH_SYMBOL (sym
);
2207 if (use_gnu_debug_info_extensions
&& sym
!= 0)
2208 line
= DECL_SOURCE_LINE (sym
);
2210 fprintf (asmfile
, "\",%d,0,%d,", current_sym_code
, line
);
2211 if (current_sym_addr
)
2212 output_addr_const (asmfile
, current_sym_addr
);
2214 fprintf (asmfile
, "%d", current_sym_value
);
2215 putc ('\n', asmfile
);
2219 /* Output definitions of all the decls in a chain. */
2227 dbxout_symbol (syms
, 1);
2228 syms
= TREE_CHAIN (syms
);
2232 /* The following two functions output definitions of function parameters.
2233 Each parameter gets a definition locating it in the parameter list.
2234 Each parameter that is a register variable gets a second definition
2235 locating it in the register.
2237 Printing or argument lists in gdb uses the definitions that
2238 locate in the parameter list. But reference to the variable in
2239 expressions uses preferentially the definition as a register. */
2241 /* Output definitions, referring to storage in the parmlist,
2242 of all the parms in PARMS, which is a chain of PARM_DECL nodes. */
2245 dbxout_parms (parms
)
2248 for (; parms
; parms
= TREE_CHAIN (parms
))
2249 if (DECL_NAME (parms
) && TREE_TYPE (parms
) != error_mark_node
)
2251 dbxout_prepare_symbol (parms
);
2253 /* Perform any necessary register eliminations on the parameter's rtl,
2254 so that the debugging output will be accurate. */
2255 DECL_INCOMING_RTL (parms
)
2256 = eliminate_regs (DECL_INCOMING_RTL (parms
), 0, NULL_RTX
);
2257 DECL_RTL (parms
) = eliminate_regs (DECL_RTL (parms
), 0, NULL_RTX
);
2258 #ifdef LEAF_REG_REMAP
2259 if (current_function_uses_only_leaf_regs
)
2261 leaf_renumber_regs_insn (DECL_INCOMING_RTL (parms
));
2262 leaf_renumber_regs_insn (DECL_RTL (parms
));
2266 if (PARM_PASSED_IN_MEMORY (parms
))
2268 rtx addr
= XEXP (DECL_INCOMING_RTL (parms
), 0);
2270 /* ??? Here we assume that the parm address is indexed
2271 off the frame pointer or arg pointer.
2272 If that is not true, we produce meaningless results,
2273 but do not crash. */
2274 if (GET_CODE (addr
) == PLUS
2275 && GET_CODE (XEXP (addr
, 1)) == CONST_INT
)
2276 current_sym_value
= INTVAL (XEXP (addr
, 1));
2278 current_sym_value
= 0;
2280 current_sym_code
= N_PSYM
;
2281 current_sym_addr
= 0;
2284 if (DECL_NAME (parms
))
2286 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2288 fprintf (asmfile
, "%s \"%s:%c", ASM_STABS_OP
,
2289 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2290 DBX_MEMPARM_STABS_LETTER
);
2294 current_sym_nchars
= 8;
2295 fprintf (asmfile
, "%s \"(anon):%c", ASM_STABS_OP
,
2296 DBX_MEMPARM_STABS_LETTER
);
2299 /* It is quite tempting to use:
2301 dbxout_type (TREE_TYPE (parms), 0, 0);
2303 as the next statement, rather than using DECL_ARG_TYPE(), so
2304 that gcc reports the actual type of the parameter, rather
2305 than the promoted type. This certainly makes GDB's life
2306 easier, at least for some ports. The change is a bad idea
2307 however, since GDB expects to be able access the type without
2308 performing any conversions. So for example, if we were
2309 passing a float to an unprototyped function, gcc will store a
2310 double on the stack, but if we emit a stab saying the type is a
2311 float, then gdb will only read in a single value, and this will
2312 produce an erropneous value. */
2313 dbxout_type (DECL_ARG_TYPE (parms
), 0, 0);
2314 current_sym_value
= DEBUGGER_ARG_OFFSET (current_sym_value
, addr
);
2315 dbxout_finish_symbol (parms
);
2317 else if (GET_CODE (DECL_RTL (parms
)) == REG
)
2320 char regparm_letter
;
2322 /* Parm passed in registers and lives in registers or nowhere. */
2324 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2325 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2326 current_sym_addr
= 0;
2328 /* If parm lives in a register, use that register;
2329 pretend the parm was passed there. It would be more consistent
2330 to describe the register where the parm was passed,
2331 but in practice that register usually holds something else.
2333 If we use DECL_RTL, then we must use the declared type of
2334 the variable, not the type that it arrived in. */
2335 if (REGNO (DECL_RTL (parms
)) >= 0
2336 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2338 best_rtl
= DECL_RTL (parms
);
2339 parm_type
= TREE_TYPE (parms
);
2341 /* If the parm lives nowhere, use the register where it was
2342 passed. It is also better to use the declared type here. */
2345 best_rtl
= DECL_INCOMING_RTL (parms
);
2346 parm_type
= TREE_TYPE (parms
);
2348 current_sym_value
= DBX_REGISTER_NUMBER (REGNO (best_rtl
));
2351 if (DECL_NAME (parms
))
2353 current_sym_nchars
= 2 + IDENTIFIER_LENGTH (DECL_NAME (parms
));
2354 fprintf (asmfile
, "%s \"%s:%c", ASM_STABS_OP
,
2355 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2360 current_sym_nchars
= 8;
2361 fprintf (asmfile
, "%s \"(anon):%c", ASM_STABS_OP
,
2365 dbxout_type (parm_type
, 0, 0);
2366 dbxout_finish_symbol (parms
);
2368 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2369 && GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
2370 && REGNO (XEXP (DECL_RTL (parms
), 0)) != HARD_FRAME_POINTER_REGNUM
2371 && REGNO (XEXP (DECL_RTL (parms
), 0)) != STACK_POINTER_REGNUM
2372 #if ARG_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
2373 && REGNO (XEXP (DECL_RTL (parms
), 0)) != ARG_POINTER_REGNUM
2377 /* Parm was passed via invisible reference.
2378 That is, its address was passed in a register.
2379 Output it as if it lived in that register.
2380 The debugger will know from the type
2381 that it was actually passed by invisible reference. */
2383 char regparm_letter
;
2384 /* Parm passed in registers and lives in registers or nowhere. */
2386 current_sym_code
= DBX_REGPARM_STABS_CODE
;
2387 if (use_gnu_debug_info_extensions
)
2388 regparm_letter
= GDB_INV_REF_REGPARM_STABS_LETTER
;
2390 regparm_letter
= DBX_REGPARM_STABS_LETTER
;
2392 /* DECL_RTL looks like (MEM (REG...). Get the register number.
2393 If it is an unallocated pseudo-reg, then use the register where
2394 it was passed instead. */
2395 if (REGNO (XEXP (DECL_RTL (parms
), 0)) >= 0
2396 && REGNO (XEXP (DECL_RTL (parms
), 0)) < FIRST_PSEUDO_REGISTER
)
2397 current_sym_value
= REGNO (XEXP (DECL_RTL (parms
), 0));
2399 current_sym_value
= REGNO (DECL_INCOMING_RTL (parms
));
2401 current_sym_addr
= 0;
2404 if (DECL_NAME (parms
))
2406 current_sym_nchars
= 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2408 fprintf (asmfile
, "%s \"%s:%c", ASM_STABS_OP
,
2409 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2414 current_sym_nchars
= 8;
2415 fprintf (asmfile
, "%s \"(anon):%c", ASM_STABS_OP
,
2419 dbxout_type (TREE_TYPE (parms
), 0, 0);
2420 dbxout_finish_symbol (parms
);
2422 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2423 && XEXP (DECL_RTL (parms
), 0) != const0_rtx
2424 /* ??? A constant address for a parm can happen
2425 when the reg it lives in is equiv to a constant in memory.
2426 Should make this not happen, after 2.4. */
2427 && ! CONSTANT_P (XEXP (DECL_RTL (parms
), 0)))
2429 /* Parm was passed in registers but lives on the stack. */
2431 current_sym_code
= N_PSYM
;
2432 /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
2433 in which case we want the value of that CONST_INT,
2434 or (MEM (REG ...)) or (MEM (MEM ...)),
2435 in which case we use a value of zero. */
2436 if (GET_CODE (XEXP (DECL_RTL (parms
), 0)) == REG
2437 || GET_CODE (XEXP (DECL_RTL (parms
), 0)) == MEM
)
2438 current_sym_value
= 0;
2440 current_sym_value
= INTVAL (XEXP (XEXP (DECL_RTL (parms
), 0), 1));
2441 current_sym_addr
= 0;
2443 /* Make a big endian correction if the mode of the type of the
2444 parameter is not the same as the mode of the rtl. */
2445 if (BYTES_BIG_ENDIAN
2446 && TYPE_MODE (TREE_TYPE (parms
)) != GET_MODE (DECL_RTL (parms
))
2447 && GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
))) < UNITS_PER_WORD
)
2449 current_sym_value
+= UNITS_PER_WORD
- GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (parms
)));
2453 if (DECL_NAME (parms
))
2455 current_sym_nchars
= 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms
)));
2457 fprintf (asmfile
, "%s \"%s:%c", ASM_STABS_OP
,
2458 IDENTIFIER_POINTER (DECL_NAME (parms
)),
2459 DBX_MEMPARM_STABS_LETTER
);
2463 current_sym_nchars
= 8;
2464 fprintf (asmfile
, "%s \"(anon):%c", ASM_STABS_OP
,
2465 DBX_MEMPARM_STABS_LETTER
);
2469 = DEBUGGER_ARG_OFFSET (current_sym_value
,
2470 XEXP (DECL_RTL (parms
), 0));
2471 dbxout_type (TREE_TYPE (parms
), 0, 0);
2472 dbxout_finish_symbol (parms
);
2477 /* Output definitions for the places where parms live during the function,
2478 when different from where they were passed, when the parms were passed
2481 It is not useful to do this for parms passed in registers
2482 that live during the function in different registers, because it is
2483 impossible to look in the passed register for the passed value,
2484 so we use the within-the-function register to begin with.
2486 PARMS is a chain of PARM_DECL nodes. */
2489 dbxout_reg_parms (parms
)
2492 for (; parms
; parms
= TREE_CHAIN (parms
))
2493 if (DECL_NAME (parms
) && PARM_PASSED_IN_MEMORY (parms
))
2495 dbxout_prepare_symbol (parms
);
2497 /* Report parms that live in registers during the function
2498 but were passed in memory. */
2499 if (GET_CODE (DECL_RTL (parms
)) == REG
2500 && REGNO (DECL_RTL (parms
)) >= 0
2501 && REGNO (DECL_RTL (parms
)) < FIRST_PSEUDO_REGISTER
)
2502 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2503 0, DECL_RTL (parms
));
2504 else if (GET_CODE (DECL_RTL (parms
)) == CONCAT
)
2505 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2506 0, DECL_RTL (parms
));
2507 /* Report parms that live in memory but not where they were passed. */
2508 else if (GET_CODE (DECL_RTL (parms
)) == MEM
2509 && ! rtx_equal_p (DECL_RTL (parms
), DECL_INCOMING_RTL (parms
)))
2510 dbxout_symbol_location (parms
, TREE_TYPE (parms
),
2511 0, DECL_RTL (parms
));
2515 /* Given a chain of ..._TYPE nodes (as come in a parameter list),
2516 output definitions of those names, in raw form */
2524 putc (',', asmfile
);
2525 dbxout_type (TREE_VALUE (args
), 0, 0);
2527 args
= TREE_CHAIN (args
);
2531 /* Given a chain of ..._TYPE nodes,
2532 find those which have typedef names and output those names.
2533 This is to ensure those types get output. */
2536 dbxout_types (types
)
2537 register tree types
;
2541 if (TYPE_NAME (types
)
2542 && TREE_CODE (TYPE_NAME (types
)) == TYPE_DECL
2543 && ! TREE_ASM_WRITTEN (TYPE_NAME (types
)))
2544 dbxout_symbol (TYPE_NAME (types
), 1);
2545 types
= TREE_CHAIN (types
);
2549 /* Output everything about a symbol block (a BLOCK node
2550 that represents a scope level),
2551 including recursive output of contained blocks.
2553 BLOCK is the BLOCK node.
2554 DEPTH is its depth within containing symbol blocks.
2555 ARGS is usually zero; but for the outermost block of the
2556 body of a function, it is a chain of PARM_DECLs for the function parameters.
2557 We output definitions of all the register parms
2558 as if they were local variables of that block.
2560 If -g1 was used, we count blocks just the same, but output nothing
2561 except for the outermost block.
2563 Actually, BLOCK may be several blocks chained together.
2564 We handle them all in sequence. */
2567 dbxout_block (block
, depth
, args
)
2568 register tree block
;
2576 /* Ignore blocks never expanded or otherwise marked as real. */
2577 if (TREE_USED (block
))
2579 #ifndef DBX_LBRAC_FIRST
2580 /* In dbx format, the syms of a block come before the N_LBRAC. */
2581 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2582 dbxout_syms (BLOCK_VARS (block
));
2584 dbxout_reg_parms (args
);
2587 /* Now output an N_LBRAC symbol to represent the beginning of
2588 the block. Use the block's tree-walk order to generate
2589 the assembler symbols LBBn and LBEn
2590 that final will define around the code in this block. */
2591 if (depth
> 0 && debug_info_level
!= DINFO_LEVEL_TERSE
)
2594 blocknum
= next_block_number
++;
2595 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBB", blocknum
);
2597 if (BLOCK_HANDLER_BLOCK (block
))
2599 /* A catch block. Must precede N_LBRAC. */
2600 tree decl
= BLOCK_VARS (block
);
2603 #ifdef DBX_OUTPUT_CATCH
2604 DBX_OUTPUT_CATCH (asmfile
, decl
, buf
);
2606 fprintf (asmfile
, "%s \"%s:C1\",%d,0,0,", ASM_STABS_OP
,
2607 IDENTIFIER_POINTER (DECL_NAME (decl
)), N_CATCH
);
2608 assemble_name (asmfile
, buf
);
2609 fprintf (asmfile
, "\n");
2611 decl
= TREE_CHAIN (decl
);
2615 #ifdef DBX_OUTPUT_LBRAC
2616 DBX_OUTPUT_LBRAC (asmfile
, buf
);
2618 fprintf (asmfile
, "%s %d,0,0,", ASM_STABN_OP
, N_LBRAC
);
2619 assemble_name (asmfile
, buf
);
2620 #if DBX_BLOCKS_FUNCTION_RELATIVE
2621 fputc ('-', asmfile
);
2622 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
2624 fprintf (asmfile
, "\n");
2628 /* Count blocks the same way regardless of debug_info_level. */
2629 next_block_number
++;
2631 #ifdef DBX_LBRAC_FIRST
2632 /* On some weird machines, the syms of a block
2633 come after the N_LBRAC. */
2634 if (debug_info_level
!= DINFO_LEVEL_TERSE
|| depth
== 0)
2635 dbxout_syms (BLOCK_VARS (block
));
2637 dbxout_reg_parms (args
);
2640 /* Output the subblocks. */
2641 dbxout_block (BLOCK_SUBBLOCKS (block
), depth
+ 1, NULL_TREE
);
2643 /* Refer to the marker for the end of the block. */
2644 if (depth
> 0 && debug_info_level
!= DINFO_LEVEL_TERSE
)
2647 ASM_GENERATE_INTERNAL_LABEL (buf
, "LBE", blocknum
);
2648 #ifdef DBX_OUTPUT_RBRAC
2649 DBX_OUTPUT_RBRAC (asmfile
, buf
);
2651 fprintf (asmfile
, "%s %d,0,0,", ASM_STABN_OP
, N_RBRAC
);
2652 assemble_name (asmfile
, buf
);
2653 #if DBX_BLOCKS_FUNCTION_RELATIVE
2654 fputc ('-', asmfile
);
2655 assemble_name (asmfile
, XSTR (XEXP (DECL_RTL (current_function_decl
), 0), 0));
2657 fprintf (asmfile
, "\n");
2661 block
= BLOCK_CHAIN (block
);
2665 /* Output the information about a function and its arguments and result.
2666 Usually this follows the function's code,
2667 but on some systems, it comes before. */
2670 dbxout_really_begin_function (decl
)
2673 dbxout_symbol (decl
, 0);
2674 dbxout_parms (DECL_ARGUMENTS (decl
));
2675 if (DECL_NAME (DECL_RESULT (decl
)) != 0)
2676 dbxout_symbol (DECL_RESULT (decl
), 1);
2679 /* Called at beginning of output of function definition. */
2682 dbxout_begin_function (decl
)
2683 tree decl ATTRIBUTE_UNUSED
;
2685 #ifdef DBX_FUNCTION_FIRST
2686 dbxout_really_begin_function (decl
);
2690 /* Output dbx data for a function definition.
2691 This includes a definition of the function name itself (a symbol),
2692 definitions of the parameters (locating them in the parameter list)
2693 and then output the block that makes up the function's body
2694 (including all the auto variables of the function). */
2697 dbxout_function (decl
)
2700 #ifndef DBX_FUNCTION_FIRST
2701 dbxout_really_begin_function (decl
);
2703 dbxout_block (DECL_INITIAL (decl
), 0, DECL_ARGUMENTS (decl
));
2704 #ifdef DBX_OUTPUT_FUNCTION_END
2705 DBX_OUTPUT_FUNCTION_END (asmfile
, decl
);
2707 #if defined(ASM_OUTPUT_SECTION_NAME)
2708 if (use_gnu_debug_info_extensions
2709 #if defined(NO_DBX_FUNCTION_END)
2710 && ! NO_DBX_FUNCTION_END
2713 dbxout_function_end ();
2716 #endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */